@opcat-labs/scrypt-ts-transpiler-opcat 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/compile/compilerWrapper.d.ts +203 -0
  2. package/dist/compile/compilerWrapper.d.ts.map +1 -0
  3. package/dist/compile/compilerWrapper.js +1019 -0
  4. package/dist/compile/compilerWrapper.js.map +1 -0
  5. package/dist/compile/findCompiler.d.ts +3 -0
  6. package/dist/compile/findCompiler.d.ts.map +1 -0
  7. package/dist/compile/findCompiler.js +102 -0
  8. package/dist/compile/findCompiler.js.map +1 -0
  9. package/dist/compile/getBinary.d.ts +3 -0
  10. package/dist/compile/getBinary.d.ts.map +1 -0
  11. package/dist/compile/getBinary.js +94 -0
  12. package/dist/compile/getBinary.js.map +1 -0
  13. package/dist/debug.d.ts +25 -0
  14. package/dist/debug.d.ts.map +1 -0
  15. package/dist/debug.js +110 -0
  16. package/dist/debug.js.map +1 -0
  17. package/dist/index.d.ts +12 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +110 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/indexer.d.ts +52 -0
  22. package/dist/indexer.d.ts.map +1 -0
  23. package/dist/indexer.js +189 -0
  24. package/dist/indexer.js.map +1 -0
  25. package/dist/relinker.d.ts +44 -0
  26. package/dist/relinker.d.ts.map +1 -0
  27. package/dist/relinker.js +321 -0
  28. package/dist/relinker.js.map +1 -0
  29. package/dist/resolver.d.ts +3 -0
  30. package/dist/resolver.d.ts.map +1 -0
  31. package/dist/resolver.js +280 -0
  32. package/dist/resolver.js.map +1 -0
  33. package/dist/scryptParser.d.ts +31 -0
  34. package/dist/scryptParser.d.ts.map +1 -0
  35. package/dist/scryptParser.js +372 -0
  36. package/dist/scryptParser.js.map +1 -0
  37. package/dist/snippets.d.ts +39 -0
  38. package/dist/snippets.d.ts.map +1 -0
  39. package/dist/snippets.js +54 -0
  40. package/dist/snippets.js.map +1 -0
  41. package/dist/transpiler.d.ts +314 -0
  42. package/dist/transpiler.d.ts.map +1 -0
  43. package/dist/transpiler.js +4239 -0
  44. package/dist/transpiler.js.map +1 -0
  45. package/dist/types.d.ts +33 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +31 -0
  48. package/dist/types.js.map +1 -0
  49. package/dist/utils.d.ts +23 -0
  50. package/dist/utils.d.ts.map +1 -0
  51. package/dist/utils.js +352 -0
  52. package/dist/utils.js.map +1 -0
  53. package/package.json +43 -0
@@ -0,0 +1,203 @@
1
+ /// <reference types="node" />
2
+ import { ChildProcess } from 'child_process';
3
+ import { ABI, ABIEntity, AliasEntity, Artifact, ContractEntity, LibraryEntity, ParamEntity, StaticEntity, StructEntity, TypeResolver } from '@opcat-labs/scrypt-ts-opcat';
4
+ export declare const SOURCE_REG: RegExp;
5
+ export declare enum CompileErrorType {
6
+ SyntaxError = "SyntaxError",
7
+ SemanticError = "SemanticError",
8
+ InternalError = "InternalError",
9
+ Warning = "Warning"
10
+ }
11
+ export declare enum BuildType {
12
+ Debug = "debug",
13
+ Release = "release"
14
+ }
15
+ export interface RelatedInformation {
16
+ filePath: string;
17
+ position: [
18
+ {
19
+ line: number;
20
+ column: number;
21
+ },
22
+ {
23
+ line: number;
24
+ column: number;
25
+ }?
26
+ ];
27
+ message: string;
28
+ }
29
+ export interface CompileErrorBase {
30
+ type: string;
31
+ filePath: string;
32
+ position: [
33
+ {
34
+ line: number;
35
+ column: number;
36
+ },
37
+ {
38
+ line: number;
39
+ column: number;
40
+ }?
41
+ ];
42
+ message: string;
43
+ relatedInformation: RelatedInformation[];
44
+ }
45
+ export interface SyntaxError extends CompileErrorBase {
46
+ type: CompileErrorType.SyntaxError;
47
+ unexpected: string;
48
+ expecting: string;
49
+ }
50
+ export interface SemanticError extends CompileErrorBase {
51
+ type: CompileErrorType.SemanticError;
52
+ }
53
+ export interface InternalError extends CompileErrorBase {
54
+ type: CompileErrorType.InternalError;
55
+ }
56
+ export interface Warning extends CompileErrorBase {
57
+ type: CompileErrorType.Warning;
58
+ }
59
+ export type CompileError = SyntaxError | SemanticError | InternalError | Warning;
60
+ export declare class CompileResult {
61
+ errors: CompileError[];
62
+ warnings: Warning[];
63
+ constructor(errors: CompileError[], warnings: Warning[]);
64
+ asm?: OpCode[];
65
+ hex?: string;
66
+ ast?: Record<string, unknown>;
67
+ dependencyAsts?: Record<string, unknown>;
68
+ abi?: Array<ABIEntity>;
69
+ stateProps?: Array<ParamEntity>;
70
+ stateType?: string;
71
+ compilerVersion?: string;
72
+ contract?: string;
73
+ md5?: string;
74
+ structs?: Array<StructEntity>;
75
+ library?: Array<LibraryEntity>;
76
+ contracts?: Array<ContractEntity>;
77
+ alias?: Array<AliasEntity>;
78
+ file?: string;
79
+ buildType?: string;
80
+ autoTypedVars?: AutoTypedVar[];
81
+ statics?: Array<StaticEntity>;
82
+ sources?: Array<string>;
83
+ sourceMap?: Array<string>;
84
+ sourceMapFile?: string;
85
+ dbgFile?: string;
86
+ toArtifact(): Artifact;
87
+ }
88
+ export declare enum DebugModeTag {
89
+ FuncStart = "F0",
90
+ FuncEnd = "F1",
91
+ LoopStart = "L0"
92
+ }
93
+ export interface DebugInfo {
94
+ tag: DebugModeTag;
95
+ contract: string;
96
+ func: string;
97
+ context: string;
98
+ }
99
+ export interface Pos {
100
+ file: string;
101
+ line: number;
102
+ endLine: number;
103
+ column: number;
104
+ endColumn: number;
105
+ }
106
+ export interface OpCode {
107
+ opcode: string;
108
+ stack?: string[];
109
+ topVars?: string[];
110
+ pos?: Pos;
111
+ debugInfo?: DebugInfo;
112
+ }
113
+ export interface AutoTypedVar {
114
+ name: string;
115
+ pos: Pos;
116
+ type: string;
117
+ }
118
+ export interface CompilingSettings {
119
+ ast?: boolean;
120
+ asm?: boolean;
121
+ hex?: boolean;
122
+ debug?: boolean;
123
+ artifact?: boolean;
124
+ outputDir?: string;
125
+ outputToFiles?: boolean;
126
+ cwd?: string;
127
+ cmdPrefix?: string;
128
+ cmdArgs?: string;
129
+ buildType?: string;
130
+ stdout?: boolean;
131
+ sourceMap?: boolean;
132
+ timeout?: number;
133
+ optimize?: boolean;
134
+ }
135
+ export declare function doCompileAsync(source: {
136
+ path: string;
137
+ content?: string;
138
+ }, settings: CompilingSettings, callback?: (error: Error | null, result: {
139
+ path: string;
140
+ output: string;
141
+ } | null) => void): ChildProcess;
142
+ export declare function compileAsync(source: {
143
+ path: string;
144
+ content?: string;
145
+ }, settings: CompilingSettings): Promise<CompileResult>;
146
+ export declare function settings2cmd(sourcePath: string, settings: CompilingSettings): string;
147
+ export declare function compile(source: {
148
+ path: string;
149
+ content?: string;
150
+ }, settings: CompilingSettings): CompileResult;
151
+ export declare function handleCompilerOutput(sourcePath: string, settings: CompilingSettings, output: string): CompileResult;
152
+ export declare function compilerVersion(cwd: string): string | undefined;
153
+ export declare function getFullFilePath(relativePath: string, baseDir: string, curFileName: string): string;
154
+ export declare function getContractName(astRoot: object): string;
155
+ /**
156
+ *
157
+ * @param astRoot AST root node after main contract compilation
158
+ * @param typeResolver a Type Resolver
159
+ * @returns All function ABIs defined by the main contract, including constructors
160
+ */
161
+ export declare function getABIDeclaration(astRoot: object, typeResolver: TypeResolver): ABI;
162
+ /**
163
+ *
164
+ * @param astRoot AST root node after main contract compilation
165
+ * @param dependencyAsts AST root node after all dependency contract compilation
166
+ * @returns all defined structures of the main contract and dependent contracts
167
+ */
168
+ export declare function getStructDeclaration(astRoot: object, dependencyAsts: object): Array<StructEntity>;
169
+ /**
170
+ *
171
+ * @param astRoot AST root node after main contract compilation
172
+ * @param dependencyAsts AST root node after all dependency contract compilation
173
+ * @returns all defined Library of the main contract and dependent contracts
174
+ */
175
+ export declare function getLibraryDeclaration(astRoot: object, dependencyAsts: object): Array<LibraryEntity>;
176
+ export declare function getContractDeclaration(astRoot: object, dependencyAsts: object): Array<ContractEntity>;
177
+ /**
178
+ *
179
+ * @param astRoot AST root node after main contract compilation
180
+ * @param dependencyAsts AST root node after all dependency contract compilation
181
+ * @returns all defined type aliaes of the main contract and dependent contracts
182
+ */
183
+ export declare function getAliasDeclaration(astRoot: object, dependencyAsts: object): Array<AliasEntity>;
184
+ /**
185
+ *
186
+ * @param astRoot AST root node after main contract compilation
187
+ * @param dependencyAsts AST root node after all dependency contract compilation
188
+ * @returns all defined static const int literal of the main contract and dependent contracts
189
+ */
190
+ export declare function getStaticDeclaration(astRoot: object, dependencyAsts: object): Array<StaticEntity>;
191
+ export declare function compileContract(file: string, options?: {
192
+ out?: string;
193
+ sourceMap?: boolean;
194
+ artifact?: boolean;
195
+ optimize?: boolean;
196
+ }): CompileResult;
197
+ export declare function compileContractAsync(file: string, options?: {
198
+ out?: string;
199
+ artifact?: boolean;
200
+ sourceMap?: boolean;
201
+ optimize?: boolean;
202
+ }): Promise<CompileResult>;
203
+ //# sourceMappingURL=compilerWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compilerWrapper.d.ts","sourceRoot":"","sources":["../../src/compile/compilerWrapper.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,eAAe,CAAC;AAW7D,OAAO,EACL,GAAG,EACH,SAAS,EAET,WAAW,EACX,QAAQ,EACR,cAAc,EAEd,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,6BAA6B,CAAC;AAcrC,eAAO,MAAM,UAAU,QAC0E,CAAC;AAMlG,oBAAY,gBAAgB;IAC1B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,OAAO,YAAY;CACpB;AAED,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;SAChB;QACD;YACE,IAAI,EAAE,MAAM,CAAC;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