@loopdive/js2 0.57.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 (233) hide show
  1. package/CHANGELOG.md +1425 -0
  2. package/LICENSE +189 -0
  3. package/README.md +451 -0
  4. package/dist/checker/index.d.ts +117 -0
  5. package/dist/checker/language-service.d.ts +39 -0
  6. package/dist/checker/node-capability-map.d.ts +63 -0
  7. package/dist/checker/type-mapper.d.ts +84 -0
  8. package/dist/cjs-rewrite.d.ts +19 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +363 -0
  11. package/dist/codegen/accessor-driver.d.ts +97 -0
  12. package/dist/codegen/any-helpers.d.ts +72 -0
  13. package/dist/codegen/array-element-typing.d.ts +46 -0
  14. package/dist/codegen/array-holes.d.ts +69 -0
  15. package/dist/codegen/array-methods.d.ts +68 -0
  16. package/dist/codegen/array-object-proto.d.ts +64 -0
  17. package/dist/codegen/array-reduce-fusion.d.ts +31 -0
  18. package/dist/codegen/array-to-primitive.d.ts +28 -0
  19. package/dist/codegen/async-cps.d.ts +239 -0
  20. package/dist/codegen/async-scheduler.d.ts +349 -0
  21. package/dist/codegen/binary-ops.d.ts +78 -0
  22. package/dist/codegen/binding-info.d.ts +31 -0
  23. package/dist/codegen/builtin-scaffold.d.ts +98 -0
  24. package/dist/codegen/builtin-static-globals.d.ts +8 -0
  25. package/dist/codegen/builtin-tags.d.ts +189 -0
  26. package/dist/codegen/case-convert-native.d.ts +12 -0
  27. package/dist/codegen/case-tables.d.ts +4 -0
  28. package/dist/codegen/class-bodies.d.ts +41 -0
  29. package/dist/codegen/class-member-keys.d.ts +33 -0
  30. package/dist/codegen/class-to-primitive.d.ts +39 -0
  31. package/dist/codegen/closed-method-dispatch.d.ts +42 -0
  32. package/dist/codegen/closures.d.ts +285 -0
  33. package/dist/codegen/coercion-engine.d.ts +154 -0
  34. package/dist/codegen/coercion-plan.d.ts +29 -0
  35. package/dist/codegen/context/bodies.d.ts +4 -0
  36. package/dist/codegen/context/create-context.d.ts +4 -0
  37. package/dist/codegen/context/errors.d.ts +39 -0
  38. package/dist/codegen/context/locals.d.ts +69 -0
  39. package/dist/codegen/context/source-pos.d.ts +5 -0
  40. package/dist/codegen/context/speculative.d.ts +95 -0
  41. package/dist/codegen/context/types.d.ts +1936 -0
  42. package/dist/codegen/custom-iterable.d.ts +34 -0
  43. package/dist/codegen/dataview-native.d.ts +51 -0
  44. package/dist/codegen/date-parse-native.d.ts +13 -0
  45. package/dist/codegen/dead-elimination.d.ts +26 -0
  46. package/dist/codegen/declarations.d.ts +147 -0
  47. package/dist/codegen/deno-api.d.ts +11 -0
  48. package/dist/codegen/destructuring-params.d.ts +102 -0
  49. package/dist/codegen/dyn-read.d.ts +26 -0
  50. package/dist/codegen/eval-tiering.d.ts +19 -0
  51. package/dist/codegen/expressions/assignment.d.ts +61 -0
  52. package/dist/codegen/expressions/builtins.d.ts +26 -0
  53. package/dist/codegen/expressions/calls-closures.d.ts +54 -0
  54. package/dist/codegen/expressions/calls-guards.d.ts +49 -0
  55. package/dist/codegen/expressions/calls-optional.d.ts +4 -0
  56. package/dist/codegen/expressions/calls.d.ts +83 -0
  57. package/dist/codegen/expressions/eval-inline.d.ts +24 -0
  58. package/dist/codegen/expressions/extern.d.ts +67 -0
  59. package/dist/codegen/expressions/fnctor-prototype.d.ts +52 -0
  60. package/dist/codegen/expressions/helpers.d.ts +212 -0
  61. package/dist/codegen/expressions/identifiers.d.ts +57 -0
  62. package/dist/codegen/expressions/late-imports.d.ts +81 -0
  63. package/dist/codegen/expressions/logical-ops.d.ts +18 -0
  64. package/dist/codegen/expressions/misc.d.ts +27 -0
  65. package/dist/codegen/expressions/new-super.d.ts +25 -0
  66. package/dist/codegen/expressions/promise-subclass.d.ts +38 -0
  67. package/dist/codegen/expressions/proto-override.d.ts +63 -0
  68. package/dist/codegen/expressions/unary-updates.d.ts +21 -0
  69. package/dist/codegen/expressions/unary.d.ts +6 -0
  70. package/dist/codegen/expressions.d.ts +31 -0
  71. package/dist/codegen/fallback-telemetry.d.ts +53 -0
  72. package/dist/codegen/fixups.d.ts +80 -0
  73. package/dist/codegen/fmod.d.ts +10 -0
  74. package/dist/codegen/fnctor-escape-gate.d.ts +92 -0
  75. package/dist/codegen/function-body.d.ts +52 -0
  76. package/dist/codegen/generators-native.d.ts +92 -0
  77. package/dist/codegen/helpers/body-references-own-this.d.ts +22 -0
  78. package/dist/codegen/helpers/body-uses-arguments.d.ts +12 -0
  79. package/dist/codegen/helpers/is-strict-function.d.ts +52 -0
  80. package/dist/codegen/host-import-allowlist.d.ts +140 -0
  81. package/dist/codegen/index.d.ts +500 -0
  82. package/dist/codegen/ir-tail-call.d.ts +8 -0
  83. package/dist/codegen/iterator-native.d.ts +44 -0
  84. package/dist/codegen/json-codec-native.d.ts +78 -0
  85. package/dist/codegen/json-runtime.d.ts +35 -0
  86. package/dist/codegen/json-standalone.d.ts +25 -0
  87. package/dist/codegen/linear-uint8-analysis.d.ts +46 -0
  88. package/dist/codegen/linear-uint8-arena.d.ts +7 -0
  89. package/dist/codegen/linear-uint8-codegen.d.ts +103 -0
  90. package/dist/codegen/linear-uint8-signatures.d.ts +26 -0
  91. package/dist/codegen/literals.d.ts +115 -0
  92. package/dist/codegen/map-runtime.d.ts +142 -0
  93. package/dist/codegen/math-helpers.d.ts +7 -0
  94. package/dist/codegen/member-get-dispatch.d.ts +42 -0
  95. package/dist/codegen/member-set-dispatch.d.ts +28 -0
  96. package/dist/codegen/native-proto.d.ts +98 -0
  97. package/dist/codegen/native-regex.d.ts +158 -0
  98. package/dist/codegen/native-strings.d.ts +146 -0
  99. package/dist/codegen/new-target.d.ts +30 -0
  100. package/dist/codegen/node-fs-api.d.ts +47 -0
  101. package/dist/codegen/number-format-native.d.ts +9 -0
  102. package/dist/codegen/number-ryu.d.ts +27 -0
  103. package/dist/codegen/object-ops.d.ts +94 -0
  104. package/dist/codegen/object-runtime.d.ts +171 -0
  105. package/dist/codegen/parse-number-native.d.ts +10 -0
  106. package/dist/codegen/peephole.d.ts +6 -0
  107. package/dist/codegen/property-access.d.ts +294 -0
  108. package/dist/codegen/raw-wasi-api.d.ts +13 -0
  109. package/dist/codegen/regex/bytecode.d.ts +140 -0
  110. package/dist/codegen/regex/casefold.d.ts +41 -0
  111. package/dist/codegen/regex/compile.d.ts +51 -0
  112. package/dist/codegen/regex/parse.d.ts +76 -0
  113. package/dist/codegen/regex/unicode.d.ts +42 -0
  114. package/dist/codegen/regex/vm.d.ts +24 -0
  115. package/dist/codegen/regexp-standalone.d.ts +350 -0
  116. package/dist/codegen/registry/error-types.d.ts +38 -0
  117. package/dist/codegen/registry/imports.d.ts +46 -0
  118. package/dist/codegen/registry/types.d.ts +59 -0
  119. package/dist/codegen/set-algebra.d.ts +17 -0
  120. package/dist/codegen/set-runtime.d.ts +74 -0
  121. package/dist/codegen/shared.d.ts +111 -0
  122. package/dist/codegen/stack-balance.d.ts +43 -0
  123. package/dist/codegen/statements/control-flow.d.ts +25 -0
  124. package/dist/codegen/statements/destructuring.d.ts +177 -0
  125. package/dist/codegen/statements/exceptions.d.ts +11 -0
  126. package/dist/codegen/statements/functions.d.ts +1 -0
  127. package/dist/codegen/statements/index.d.ts +1 -0
  128. package/dist/codegen/statements/loops.d.ts +7 -0
  129. package/dist/codegen/statements/nested-declarations.d.ts +78 -0
  130. package/dist/codegen/statements/shared.d.ts +38 -0
  131. package/dist/codegen/statements/tdz.d.ts +43 -0
  132. package/dist/codegen/statements/variables.d.ts +3 -0
  133. package/dist/codegen/statements.d.ts +9 -0
  134. package/dist/codegen/string-builder.d.ts +131 -0
  135. package/dist/codegen/string-ops.d.ts +87 -0
  136. package/dist/codegen/struct-accessor-closure.d.ts +36 -0
  137. package/dist/codegen/symbol-native.d.ts +55 -0
  138. package/dist/codegen/temporal-native.d.ts +8 -0
  139. package/dist/codegen/timsort.d.ts +2 -0
  140. package/dist/codegen/type-coercion.d.ts +123 -0
  141. package/dist/codegen/typeof-delete.d.ts +38 -0
  142. package/dist/codegen/uri-encoding-native.d.ts +33 -0
  143. package/dist/codegen/value-tags.d.ts +74 -0
  144. package/dist/codegen/walk-instructions.d.ts +20 -0
  145. package/dist/codegen/weak-collections-runtime.d.ts +16 -0
  146. package/dist/codegen/with-scope.d.ts +106 -0
  147. package/dist/codegen-linear/c-abi.d.ts +74 -0
  148. package/dist/codegen-linear/context.d.ts +86 -0
  149. package/dist/codegen-linear/index.d.ts +28 -0
  150. package/dist/codegen-linear/layout.d.ts +39 -0
  151. package/dist/codegen-linear/runtime.d.ts +161 -0
  152. package/dist/codegen-linear/simd.d.ts +7 -0
  153. package/dist/compiler/define-substitution.d.ts +27 -0
  154. package/dist/compiler/early-errors/assignment.d.ts +26 -0
  155. package/dist/compiler/early-errors/context.d.ts +17 -0
  156. package/dist/compiler/early-errors/duplicates.d.ts +20 -0
  157. package/dist/compiler/early-errors/index.d.ts +11 -0
  158. package/dist/compiler/early-errors/labels.d.ts +13 -0
  159. package/dist/compiler/early-errors/module-rules.d.ts +36 -0
  160. package/dist/compiler/early-errors/node-checks.d.ts +7 -0
  161. package/dist/compiler/early-errors/predicates.d.ts +140 -0
  162. package/dist/compiler/early-errors/tdz.d.ts +17 -0
  163. package/dist/compiler/import-manifest.d.ts +18 -0
  164. package/dist/compiler/output.d.ts +46 -0
  165. package/dist/compiler/validation.d.ts +45 -0
  166. package/dist/compiler.d.ts +48 -0
  167. package/dist/define-substitution-BcUeKC2A.js +109 -0
  168. package/dist/emit/binary.d.ts +50 -0
  169. package/dist/emit/c-header.d.ts +23 -0
  170. package/dist/emit/canonical-recgroup.d.ts +86 -0
  171. package/dist/emit/encoder.d.ts +28 -0
  172. package/dist/emit/object.d.ts +14 -0
  173. package/dist/emit/opcodes.d.ts +464 -0
  174. package/dist/emit/sourcemap.d.ts +33 -0
  175. package/dist/emit/wat.d.ts +6 -0
  176. package/dist/env.d.ts +46 -0
  177. package/dist/import-resolver.d.ts +68 -0
  178. package/dist/index.d.ts +486 -0
  179. package/dist/index.js +755 -0
  180. package/dist/ir/alloc-registry.d.ts +75 -0
  181. package/dist/ir/analysis/encoding.d.ts +38 -0
  182. package/dist/ir/analysis/escape.d.ts +32 -0
  183. package/dist/ir/analysis/lattice.d.ts +72 -0
  184. package/dist/ir/analysis/ownership.d.ts +31 -0
  185. package/dist/ir/analysis/stack-alloc.d.ts +20 -0
  186. package/dist/ir/backend/bytecode-emitter.d.ts +237 -0
  187. package/dist/ir/backend/bytecode-vm.d.ts +74 -0
  188. package/dist/ir/backend/emitter.d.ts +121 -0
  189. package/dist/ir/backend/handles.d.ts +133 -0
  190. package/dist/ir/backend/legality.d.ts +9 -0
  191. package/dist/ir/backend/linear-emitter.d.ts +41 -0
  192. package/dist/ir/backend/wasmgc-emitter.d.ts +43 -0
  193. package/dist/ir/builder.d.ts +401 -0
  194. package/dist/ir/from-ast.d.ts +192 -0
  195. package/dist/ir/index.d.ts +16 -0
  196. package/dist/ir/integration.d.ts +27 -0
  197. package/dist/ir/lower.d.ts +203 -0
  198. package/dist/ir/nodes.d.ts +1452 -0
  199. package/dist/ir/passes/alloc-discipline.d.ts +19 -0
  200. package/dist/ir/passes/constant-fold.d.ts +7 -0
  201. package/dist/ir/passes/dead-code.d.ts +18 -0
  202. package/dist/ir/passes/inline-small.d.ts +7 -0
  203. package/dist/ir/passes/monomorphize.d.ts +21 -0
  204. package/dist/ir/passes/simplify-cfg.d.ts +19 -0
  205. package/dist/ir/passes/tagged-union-types.d.ts +45 -0
  206. package/dist/ir/passes/tagged-unions.d.ts +22 -0
  207. package/dist/ir/propagate.d.ts +135 -0
  208. package/dist/ir/select.d.ts +81 -0
  209. package/dist/ir/types.d.ts +832 -0
  210. package/dist/ir/verify-alloc.d.ts +18 -0
  211. package/dist/ir/verify.d.ts +7 -0
  212. package/dist/link/index.d.ts +11 -0
  213. package/dist/link/isolation.d.ts +24 -0
  214. package/dist/link/linker.d.ts +37 -0
  215. package/dist/link/reader.d.ts +158 -0
  216. package/dist/link/resolver.d.ts +19 -0
  217. package/dist/optimize.d.ts +54 -0
  218. package/dist/optimize.js +262 -0
  219. package/dist/position-map.d.ts +64 -0
  220. package/dist/process-stdin-prelude.d.ts +16 -0
  221. package/dist/resolve.d.ts +82 -0
  222. package/dist/runtime/builtins.d.ts +1 -0
  223. package/dist/runtime-C-4q_KwU.js +164438 -0
  224. package/dist/runtime-containment.d.ts +6 -0
  225. package/dist/runtime-eval.d.ts +132 -0
  226. package/dist/runtime-instantiate.d.ts +16 -0
  227. package/dist/runtime.d.ts +128 -0
  228. package/dist/runtime.js +12 -0
  229. package/dist/shape-inference.d.ts +20 -0
  230. package/dist/treeshake.d.ts +17 -0
  231. package/dist/ts-api.d.ts +30 -0
  232. package/dist/wit-generator.d.ts +18 -0
  233. package/package.json +187 -0
@@ -0,0 +1,464 @@
1
+ export declare const OP: {
2
+ readonly unreachable: 0;
3
+ readonly nop: 1;
4
+ readonly block: 2;
5
+ readonly loop: 3;
6
+ readonly if: 4;
7
+ readonly else: 5;
8
+ readonly try: 6;
9
+ readonly catch: 7;
10
+ readonly throw: 8;
11
+ readonly rethrow: 9;
12
+ readonly end: 11;
13
+ readonly br: 12;
14
+ readonly br_if: 13;
15
+ readonly return: 15;
16
+ readonly call: 16;
17
+ readonly call_indirect: 17;
18
+ readonly return_call: 18;
19
+ readonly return_call_indirect: 19;
20
+ readonly delegate: 24;
21
+ readonly catch_all: 25;
22
+ readonly drop: 26;
23
+ readonly select: 27;
24
+ readonly local_get: 32;
25
+ readonly local_set: 33;
26
+ readonly local_tee: 34;
27
+ readonly global_get: 35;
28
+ readonly global_set: 36;
29
+ readonly table_get: 37;
30
+ readonly table_set: 38;
31
+ readonly i32_load: 40;
32
+ readonly i32_load8_s: 44;
33
+ readonly i32_load8_u: 45;
34
+ readonly i32_load16_u: 47;
35
+ readonly i32_store: 54;
36
+ readonly i64_store: 55;
37
+ readonly i32_store8: 58;
38
+ readonly i32_store16: 59;
39
+ readonly f32_load: 42;
40
+ readonly f64_load: 43;
41
+ readonly f32_store: 56;
42
+ readonly f64_store: 57;
43
+ readonly i32_const: 65;
44
+ readonly i64_const: 66;
45
+ readonly f32_const: 67;
46
+ readonly f64_const: 68;
47
+ readonly i32_eqz: 69;
48
+ readonly i32_eq: 70;
49
+ readonly i32_ne: 71;
50
+ readonly i32_lt_s: 72;
51
+ readonly i32_lt_u: 73;
52
+ readonly i32_gt_s: 74;
53
+ readonly i32_gt_u: 75;
54
+ readonly i32_le_s: 76;
55
+ readonly i32_le_u: 77;
56
+ readonly i32_ge_s: 78;
57
+ readonly i32_ge_u: 79;
58
+ readonly i32_add: 106;
59
+ readonly i32_sub: 107;
60
+ readonly i32_mul: 108;
61
+ readonly i32_div_s: 109;
62
+ readonly i32_div_u: 110;
63
+ readonly i32_rem_s: 111;
64
+ readonly i32_rem_u: 112;
65
+ readonly i32_and: 113;
66
+ readonly i32_or: 114;
67
+ readonly i32_xor: 115;
68
+ readonly i32_shl: 116;
69
+ readonly i32_shr_s: 117;
70
+ readonly i32_shr_u: 118;
71
+ readonly i32_clz: 103;
72
+ readonly f64_eq: 97;
73
+ readonly f64_ne: 98;
74
+ readonly f64_lt: 99;
75
+ readonly f64_gt: 100;
76
+ readonly f64_le: 101;
77
+ readonly f64_ge: 102;
78
+ readonly f64_abs: 153;
79
+ readonly f64_neg: 154;
80
+ readonly f64_ceil: 155;
81
+ readonly f64_floor: 156;
82
+ readonly f64_trunc: 157;
83
+ readonly f64_nearest: 158;
84
+ readonly f64_sqrt: 159;
85
+ readonly f64_add: 160;
86
+ readonly f64_sub: 161;
87
+ readonly f64_mul: 162;
88
+ readonly f64_div: 163;
89
+ readonly f64_min: 164;
90
+ readonly f64_max: 165;
91
+ readonly f64_copysign: 166;
92
+ readonly i32_wrap_i64: 167;
93
+ readonly i32_trunc_f64_s: 170;
94
+ readonly i32_trunc_f64_u: 171;
95
+ readonly f32_demote_f64: 182;
96
+ readonly f64_promote_f32: 187;
97
+ readonly i64_eqz: 80;
98
+ readonly i64_eq: 81;
99
+ readonly i64_ne: 82;
100
+ readonly i64_lt_s: 83;
101
+ readonly i64_lt_u: 84;
102
+ readonly i64_gt_s: 85;
103
+ readonly i64_gt_u: 86;
104
+ readonly i64_le_s: 87;
105
+ readonly i64_le_u: 88;
106
+ readonly i64_ge_s: 89;
107
+ readonly i64_ge_u: 90;
108
+ readonly i64_add: 124;
109
+ readonly i64_sub: 125;
110
+ readonly i64_mul: 126;
111
+ readonly i64_div_s: 127;
112
+ readonly i64_div_u: 128;
113
+ readonly i64_rem_s: 129;
114
+ readonly i64_rem_u: 130;
115
+ readonly i64_and: 131;
116
+ readonly i64_or: 132;
117
+ readonly i64_xor: 133;
118
+ readonly i64_shl: 134;
119
+ readonly i64_shr_s: 135;
120
+ readonly i64_shr_u: 136;
121
+ readonly i64_extend_i32_s: 172;
122
+ readonly i64_extend_i32_u: 173;
123
+ readonly i64_trunc_f64_s: 176;
124
+ readonly f64_convert_i64_s: 185;
125
+ readonly f64_convert_i32_s: 183;
126
+ readonly f64_convert_i32_u: 184;
127
+ readonly i32_reinterpret_f32: 188;
128
+ readonly i64_reinterpret_f64: 189;
129
+ readonly f32_reinterpret_i32: 190;
130
+ readonly f64_reinterpret_i64: 191;
131
+ readonly ref_null: 208;
132
+ readonly ref_is_null: 209;
133
+ readonly ref_eq: 211;
134
+ readonly ref_as_non_null: 212;
135
+ readonly ref_func: 210;
136
+ readonly call_ref: 20;
137
+ readonly return_call_ref: 21;
138
+ readonly memory_size: 63;
139
+ readonly memory_grow: 64;
140
+ readonly misc_prefix: 252;
141
+ readonly i32_trunc_sat_f64_s: 2;
142
+ readonly i32_trunc_sat_f64_u: 3;
143
+ readonly i64_trunc_sat_f64_s: 6;
144
+ readonly i64_trunc_sat_f64_u: 7;
145
+ /** SIMD prefix byte — all SIMD instructions start with 0xFD */
146
+ readonly simd_prefix: 253;
147
+ };
148
+ /**
149
+ * WASM SIMD opcodes (v128 / 128-bit SIMD).
150
+ * All are prefixed by OP.simd_prefix (0xFD), followed by a LEB128 opcode.
151
+ */
152
+ export declare const SIMD: {
153
+ readonly v128_load: 0;
154
+ readonly v128_load8x8_s: 1;
155
+ readonly v128_load8x8_u: 2;
156
+ readonly v128_load16x4_s: 3;
157
+ readonly v128_load16x4_u: 4;
158
+ readonly v128_load32x2_s: 5;
159
+ readonly v128_load32x2_u: 6;
160
+ readonly v128_load8_splat: 7;
161
+ readonly v128_load16_splat: 8;
162
+ readonly v128_load32_splat: 9;
163
+ readonly v128_load64_splat: 10;
164
+ readonly v128_store: 11;
165
+ readonly v128_const: 12;
166
+ readonly i8x16_shuffle: 13;
167
+ readonly i8x16_swizzle: 14;
168
+ readonly i8x16_splat: 15;
169
+ readonly i16x8_splat: 16;
170
+ readonly i32x4_splat: 17;
171
+ readonly i64x2_splat: 18;
172
+ readonly f32x4_splat: 19;
173
+ readonly f64x2_splat: 20;
174
+ readonly i8x16_extract_lane_s: 21;
175
+ readonly i8x16_extract_lane_u: 22;
176
+ readonly i8x16_replace_lane: 23;
177
+ readonly i16x8_extract_lane_s: 24;
178
+ readonly i16x8_extract_lane_u: 25;
179
+ readonly i16x8_replace_lane: 26;
180
+ readonly i32x4_extract_lane: 27;
181
+ readonly i32x4_replace_lane: 28;
182
+ readonly i64x2_extract_lane: 29;
183
+ readonly i64x2_replace_lane: 30;
184
+ readonly f32x4_extract_lane: 31;
185
+ readonly f32x4_replace_lane: 32;
186
+ readonly f64x2_extract_lane: 33;
187
+ readonly f64x2_replace_lane: 34;
188
+ readonly i8x16_eq: 35;
189
+ readonly i8x16_ne: 36;
190
+ readonly i8x16_lt_s: 37;
191
+ readonly i8x16_lt_u: 38;
192
+ readonly i8x16_gt_s: 39;
193
+ readonly i8x16_gt_u: 40;
194
+ readonly i8x16_le_s: 41;
195
+ readonly i8x16_le_u: 42;
196
+ readonly i8x16_ge_s: 43;
197
+ readonly i8x16_ge_u: 44;
198
+ readonly i16x8_eq: 45;
199
+ readonly i16x8_ne: 46;
200
+ readonly i16x8_lt_s: 47;
201
+ readonly i16x8_lt_u: 48;
202
+ readonly i16x8_gt_s: 49;
203
+ readonly i16x8_gt_u: 50;
204
+ readonly i16x8_le_s: 51;
205
+ readonly i16x8_le_u: 52;
206
+ readonly i16x8_ge_s: 53;
207
+ readonly i16x8_ge_u: 54;
208
+ readonly i32x4_eq: 55;
209
+ readonly i32x4_ne: 56;
210
+ readonly i32x4_lt_s: 57;
211
+ readonly i32x4_lt_u: 58;
212
+ readonly i32x4_gt_s: 59;
213
+ readonly i32x4_gt_u: 60;
214
+ readonly i32x4_le_s: 61;
215
+ readonly i32x4_le_u: 62;
216
+ readonly i32x4_ge_s: 63;
217
+ readonly i32x4_ge_u: 64;
218
+ readonly f32x4_eq: 65;
219
+ readonly f32x4_ne: 66;
220
+ readonly f32x4_lt: 67;
221
+ readonly f32x4_gt: 68;
222
+ readonly f32x4_le: 69;
223
+ readonly f32x4_ge: 70;
224
+ readonly f64x2_eq: 71;
225
+ readonly f64x2_ne: 72;
226
+ readonly f64x2_lt: 73;
227
+ readonly f64x2_gt: 74;
228
+ readonly f64x2_le: 75;
229
+ readonly f64x2_ge: 76;
230
+ readonly v128_not: 77;
231
+ readonly v128_and: 78;
232
+ readonly v128_andnot: 79;
233
+ readonly v128_or: 80;
234
+ readonly v128_xor: 81;
235
+ readonly v128_bitselect: 82;
236
+ readonly v128_any_true: 83;
237
+ readonly i8x16_abs: 96;
238
+ readonly i8x16_neg: 97;
239
+ readonly i8x16_popcnt: 98;
240
+ readonly i8x16_all_true: 99;
241
+ readonly i8x16_bitmask: 100;
242
+ readonly i8x16_narrow_i16x8_s: 101;
243
+ readonly i8x16_narrow_i16x8_u: 102;
244
+ readonly i8x16_shl: 107;
245
+ readonly i8x16_shr_s: 108;
246
+ readonly i8x16_shr_u: 109;
247
+ readonly i8x16_add: 110;
248
+ readonly i8x16_add_sat_s: 111;
249
+ readonly i8x16_add_sat_u: 112;
250
+ readonly i8x16_sub: 113;
251
+ readonly i8x16_sub_sat_s: 114;
252
+ readonly i8x16_sub_sat_u: 115;
253
+ readonly i8x16_min_s: 118;
254
+ readonly i8x16_min_u: 119;
255
+ readonly i8x16_max_s: 120;
256
+ readonly i8x16_max_u: 121;
257
+ readonly i16x8_abs: 128;
258
+ readonly i16x8_neg: 129;
259
+ readonly i16x8_all_true: 131;
260
+ readonly i16x8_bitmask: 132;
261
+ readonly i16x8_narrow_i32x4_s: 133;
262
+ readonly i16x8_narrow_i32x4_u: 134;
263
+ readonly i16x8_extend_low_i8x16_s: 135;
264
+ readonly i16x8_extend_high_i8x16_s: 136;
265
+ readonly i16x8_extend_low_i8x16_u: 137;
266
+ readonly i16x8_extend_high_i8x16_u: 138;
267
+ readonly i16x8_shl: 139;
268
+ readonly i16x8_shr_s: 140;
269
+ readonly i16x8_shr_u: 141;
270
+ readonly i16x8_add: 142;
271
+ readonly i16x8_add_sat_s: 143;
272
+ readonly i16x8_add_sat_u: 144;
273
+ readonly i16x8_sub: 145;
274
+ readonly i16x8_sub_sat_s: 146;
275
+ readonly i16x8_sub_sat_u: 147;
276
+ readonly i16x8_mul: 149;
277
+ readonly i16x8_min_s: 150;
278
+ readonly i16x8_min_u: 151;
279
+ readonly i16x8_max_s: 152;
280
+ readonly i16x8_max_u: 153;
281
+ readonly i32x4_abs: 160;
282
+ readonly i32x4_neg: 161;
283
+ readonly i32x4_all_true: 163;
284
+ readonly i32x4_bitmask: 164;
285
+ readonly i32x4_extend_low_i16x8_s: 167;
286
+ readonly i32x4_extend_high_i16x8_s: 168;
287
+ readonly i32x4_extend_low_i16x8_u: 169;
288
+ readonly i32x4_extend_high_i16x8_u: 170;
289
+ readonly i32x4_shl: 171;
290
+ readonly i32x4_shr_s: 172;
291
+ readonly i32x4_shr_u: 173;
292
+ readonly i32x4_add: 174;
293
+ readonly i32x4_sub: 177;
294
+ readonly i32x4_mul: 181;
295
+ readonly i32x4_min_s: 182;
296
+ readonly i32x4_min_u: 183;
297
+ readonly i32x4_max_s: 184;
298
+ readonly i32x4_max_u: 185;
299
+ readonly i64x2_abs: 192;
300
+ readonly i64x2_neg: 193;
301
+ readonly i64x2_all_true: 195;
302
+ readonly i64x2_bitmask: 196;
303
+ readonly i64x2_shl: 203;
304
+ readonly i64x2_shr_s: 204;
305
+ readonly i64x2_shr_u: 205;
306
+ readonly i64x2_add: 206;
307
+ readonly i64x2_sub: 209;
308
+ readonly i64x2_mul: 213;
309
+ readonly i64x2_eq: 214;
310
+ readonly i64x2_ne: 215;
311
+ readonly i64x2_lt_s: 216;
312
+ readonly i64x2_gt_s: 217;
313
+ readonly i64x2_le_s: 218;
314
+ readonly i64x2_ge_s: 219;
315
+ readonly f32x4_abs: 224;
316
+ readonly f32x4_neg: 225;
317
+ readonly f32x4_sqrt: 227;
318
+ readonly f32x4_add: 228;
319
+ readonly f32x4_sub: 229;
320
+ readonly f32x4_mul: 230;
321
+ readonly f32x4_div: 231;
322
+ readonly f32x4_min: 232;
323
+ readonly f32x4_max: 233;
324
+ readonly f32x4_pmin: 234;
325
+ readonly f32x4_pmax: 235;
326
+ readonly f64x2_abs: 236;
327
+ readonly f64x2_neg: 237;
328
+ readonly f64x2_sqrt: 239;
329
+ readonly f64x2_add: 240;
330
+ readonly f64x2_sub: 241;
331
+ readonly f64x2_mul: 242;
332
+ readonly f64x2_div: 243;
333
+ readonly f64x2_min: 244;
334
+ readonly f64x2_max: 245;
335
+ readonly f64x2_pmin: 246;
336
+ readonly f64x2_pmax: 247;
337
+ readonly i32x4_trunc_sat_f32x4_s: 248;
338
+ readonly i32x4_trunc_sat_f32x4_u: 249;
339
+ readonly f32x4_convert_i32x4_s: 250;
340
+ readonly f32x4_convert_i32x4_u: 251;
341
+ readonly i32x4_trunc_sat_f64x2_s_zero: 252;
342
+ readonly i32x4_trunc_sat_f64x2_u_zero: 253;
343
+ readonly f64x2_convert_low_i32x4_s: 254;
344
+ readonly f64x2_convert_low_i32x4_u: 255;
345
+ readonly v128_load8_lane: 84;
346
+ readonly v128_load16_lane: 85;
347
+ readonly v128_load32_lane: 86;
348
+ readonly v128_load64_lane: 87;
349
+ readonly v128_store8_lane: 88;
350
+ readonly v128_store16_lane: 89;
351
+ readonly v128_store32_lane: 90;
352
+ readonly v128_store64_lane: 91;
353
+ readonly v128_load32_zero: 92;
354
+ readonly v128_load64_zero: 93;
355
+ };
356
+ export declare const GC: {
357
+ readonly prefix: 251;
358
+ readonly struct_new: 0;
359
+ readonly struct_new_default: 1;
360
+ readonly struct_get: 2;
361
+ readonly struct_get_s: 3;
362
+ readonly struct_get_u: 4;
363
+ readonly struct_set: 5;
364
+ readonly array_new: 6;
365
+ readonly array_new_default: 7;
366
+ readonly array_new_fixed: 8;
367
+ readonly array_get: 11;
368
+ readonly array_get_s: 12;
369
+ readonly array_get_u: 13;
370
+ readonly array_set: 14;
371
+ readonly array_len: 15;
372
+ readonly array_fill: 16;
373
+ readonly array_copy: 17;
374
+ readonly ref_test: 20;
375
+ readonly ref_test_null: 21;
376
+ readonly ref_cast: 22;
377
+ readonly ref_cast_null: 23;
378
+ readonly any_convert_extern: 26;
379
+ readonly extern_convert_any: 27;
380
+ };
381
+ export declare const TYPE: {
382
+ readonly i32: 127;
383
+ readonly i64: 126;
384
+ readonly f32: 125;
385
+ readonly f64: 124;
386
+ readonly funcref: 112;
387
+ readonly externref: 111;
388
+ readonly struct: 95;
389
+ readonly array: 94;
390
+ readonly func: 96;
391
+ readonly rec: 78;
392
+ readonly sub: 80;
393
+ readonly sub_final: 79;
394
+ readonly ref: 100;
395
+ readonly ref_null: 99;
396
+ readonly any: 110;
397
+ readonly eq: 109;
398
+ readonly i31: 108;
399
+ readonly struct_ht: 107;
400
+ readonly array_ht: 106;
401
+ readonly none: 113;
402
+ readonly noextern: 114;
403
+ readonly nofunc: 115;
404
+ readonly v128: 123;
405
+ readonly i8: 120;
406
+ readonly i16: 119;
407
+ readonly const_field: 0;
408
+ readonly mut_field: 1;
409
+ };
410
+ export declare const SECTION: {
411
+ readonly custom: 0;
412
+ readonly type: 1;
413
+ readonly import: 2;
414
+ readonly function: 3;
415
+ readonly table: 4;
416
+ readonly memory: 5;
417
+ readonly global: 6;
418
+ readonly export: 7;
419
+ readonly start: 8;
420
+ readonly element: 9;
421
+ readonly code: 10;
422
+ readonly data: 11;
423
+ readonly tag: 13;
424
+ };
425
+ /** LLVM-style Wasm relocation types */
426
+ export declare const RELOC: {
427
+ readonly R_WASM_FUNCTION_INDEX_LEB: 0;
428
+ readonly R_WASM_TABLE_INDEX_SLEB: 1;
429
+ readonly R_WASM_TABLE_INDEX_I32: 2;
430
+ readonly R_WASM_MEMORY_ADDR_LEB: 3;
431
+ readonly R_WASM_MEMORY_ADDR_SLEB: 4;
432
+ readonly R_WASM_MEMORY_ADDR_I32: 5;
433
+ readonly R_WASM_TYPE_INDEX_LEB: 6;
434
+ readonly R_WASM_GLOBAL_INDEX_LEB: 7;
435
+ readonly R_WASM_FUNCTION_OFFSET_I32: 8;
436
+ readonly R_WASM_SECTION_OFFSET_I32: 9;
437
+ readonly R_WASM_TAG_INDEX_LEB: 10;
438
+ };
439
+ /** Symbol flags for the linking section symbol table */
440
+ export declare const SYM_FLAGS: {
441
+ readonly WASM_SYM_BINDING_WEAK: 1;
442
+ readonly WASM_SYM_BINDING_LOCAL: 2;
443
+ readonly WASM_SYM_VISIBILITY_HIDDEN: 4;
444
+ readonly WASM_SYM_UNDEFINED: 16;
445
+ readonly WASM_SYM_EXPORTED: 32;
446
+ readonly WASM_SYM_EXPLICIT_NAME: 64;
447
+ readonly WASM_SYM_NO_STRIP: 128;
448
+ };
449
+ /** Symbol kinds for the linking section symbol table */
450
+ export declare const SYMTAB: {
451
+ readonly SYMTAB_FUNCTION: 0;
452
+ readonly SYMTAB_DATA: 1;
453
+ readonly SYMTAB_GLOBAL: 2;
454
+ readonly SYMTAB_SECTION: 3;
455
+ readonly SYMTAB_EVENT: 4;
456
+ readonly SYMTAB_TABLE: 5;
457
+ };
458
+ /** Linking section subsection types */
459
+ export declare const LINKING_SUBSECTION: {
460
+ readonly WASM_SEGMENT_INFO: 5;
461
+ readonly WASM_INIT_FUNCS: 6;
462
+ readonly WASM_COMDAT_INFO: 7;
463
+ readonly WASM_SYMBOL_TABLE: 8;
464
+ };
@@ -0,0 +1,33 @@
1
+ import { SourceMapEntry } from './binary.js';
2
+ /** Source map v3 JSON structure */
3
+ export interface SourceMapV3 {
4
+ version: 3;
5
+ sources: string[];
6
+ sourcesContent: (string | null)[];
7
+ names: string[];
8
+ mappings: string;
9
+ }
10
+ /** Encode a signed integer as a Base64 VLQ string */
11
+ export declare function encodeVLQ(value: number): string;
12
+ /** Decode a Base64 VLQ string back to a signed integer (for testing) */
13
+ export declare function decodeVLQ(encoded: string): {
14
+ value: number;
15
+ rest: string;
16
+ };
17
+ /**
18
+ * Decode all VLQ segments from a mappings string.
19
+ * Returns an array of segments, where each segment is an array of decoded values.
20
+ * Groups are separated by semicolons (;) and segments within a group by commas (,).
21
+ */
22
+ export declare function decodeMappings(mappings: string): number[][][];
23
+ /**
24
+ * Generate a source map from wasm binary emission entries.
25
+ *
26
+ * Each entry maps a wasm byte offset to a source file position.
27
+ * The generated source map uses the wasm-specific convention where
28
+ * each mapping segment is on a separate "line" (separated by ;).
29
+ *
30
+ * @param entries Source map entries from binary emission
31
+ * @param sourcesContent Optional map from file name to source content
32
+ */
33
+ export declare function generateSourceMap(entries: SourceMapEntry[], sourcesContent?: Map<string, string>): SourceMapV3;
@@ -0,0 +1,6 @@
1
+ import { WasmModule } from '../ir/types.js';
2
+ /** Escape a string for WAT text format (inside double quotes).
3
+ * Handles backslash, double-quote, and control characters. */
4
+ export declare function escapeWatString(s: string): string;
5
+ /** Emit a WAT text representation of the IR module */
6
+ export declare function emitWat(mod: WasmModule): string;
package/dist/env.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ import type * as fsType from "node:fs";
2
+ import type * as pathType from "node:path";
3
+ import type * as urlType from "node:url";
4
+ import type * as moduleType from "node:module";
5
+ /**
6
+ * Adapter for the host environment's filesystem and module-resolution APIs.
7
+ *
8
+ * Each field is `null` when the corresponding capability isn't available
9
+ * (e.g. browser builds get `null` for `fs`, `path`, `url`, `module`).
10
+ *
11
+ * Core compiler modules **must not** probe the runtime directly — they should
12
+ * receive an `Environment` and use whichever capabilities it provides.
13
+ */
14
+ export interface Environment {
15
+ /** node:fs equivalent (or null in browsers) */
16
+ fs: typeof fsType | null;
17
+ /** node:path equivalent (or null in browsers) */
18
+ path: typeof pathType | null;
19
+ /** node:url equivalent (or null in browsers) */
20
+ url: typeof urlType | null;
21
+ /** node:module equivalent (or null in browsers) */
22
+ module: typeof moduleType | null;
23
+ }
24
+ /**
25
+ * Return a default `Environment` for the current runtime, computing it
26
+ * synchronously on first call and caching the result.
27
+ *
28
+ * - Browser-like runtimes get an environment with all capabilities `null`.
29
+ * - Node runtimes load `fs`, `path`, `url`, and `module` synchronously via
30
+ * `process.getBuiltinModule` (Node 22+) or a CJS `require` fallback.
31
+ * - If neither sync loader is available (e.g. older Node ESM contexts), the
32
+ * environment will have `null` capabilities; embedders can override via
33
+ * `setDefaultEnvironment()`.
34
+ *
35
+ * **No top-level `await`** — this function is fully synchronous, which is
36
+ * why core compiler modules can keep calling it lazily without forcing the
37
+ * whole module graph through async initialization.
38
+ */
39
+ export declare function getDefaultEnvironment(): Environment;
40
+ /**
41
+ * Override the default environment. Useful for:
42
+ * - Embedding contexts where the runtime can't be probed (e.g. Wasm host).
43
+ * - Test harnesses that want to inject mocked filesystem behavior.
44
+ * - Resetting cached state between tests (pass `null`).
45
+ */
46
+ export declare function setDefaultEnvironment(env: Environment | null): void;
@@ -0,0 +1,68 @@
1
+ import { PositionMap } from './position-map.js';
2
+ /** Recognized Node.js builtin module specifiers (#1044). */
3
+ export declare const NODE_BUILTIN_MODULES: Set<string>;
4
+ /** Returns true if `spec` is a recognized Node.js builtin (with or without `node:` prefix). */
5
+ export declare function isNodeBuiltin(spec: string): boolean;
6
+ /**
7
+ * Recognized JSX runtime module specifiers (#1540).
8
+ *
9
+ * TypeScript emits auto-imports from these specifiers when
10
+ * `compilerOptions.jsx === "react-jsx"` (or `jsxImportSource` is set).
11
+ * The default is `"react"` so the specifier is `"react/jsx-runtime"`;
12
+ * Preact uses `"preact/jsx-runtime"`, SolidJS uses
13
+ * `"solid-js/h/jsx-runtime"`, etc.
14
+ */
15
+ export declare const JSX_RUNTIME_SPECIFIERS: Set<string>;
16
+ export declare function isJsxRuntime(spec: string): boolean;
17
+ /**
18
+ * Local-binding names for a detected JSX runtime import (#1540).
19
+ *
20
+ * TypeScript usually emits these as `import { jsx as _jsx, jsxs as _jsxs,
21
+ * Fragment as _Fragment } from "react/jsx-runtime"`, but the aliases are
22
+ * configurable via the user's source / TS options. We record the *local*
23
+ * names so codegen can route identifier references to the right host
24
+ * imports without hardcoding `_jsx`/`_jsxs`/`_Fragment`.
25
+ */
26
+ export interface JsxRuntimeImport {
27
+ /** The module specifier (e.g. `"react/jsx-runtime"`). */
28
+ specifier: string;
29
+ /** Local binding for the `jsx` named export, if imported. */
30
+ localJsx?: string;
31
+ /** Local binding for the `jsxs` named export, if imported. */
32
+ localJsxs?: string;
33
+ /** Local binding for the `Fragment` named export, if imported. */
34
+ localFragment?: string;
35
+ /** Local binding for the `jsxDEV` named export (dev runtime), if imported. */
36
+ localJsxDev?: string;
37
+ }
38
+ /** Normalizes a module specifier by stripping the `node:` prefix if present. */
39
+ export declare function normalizeNodeBuiltin(spec: string): string;
40
+ /** Info about a Node builtin import discovered during preprocessing. */
41
+ export interface NodeBuiltinImport {
42
+ /** The local binding name (e.g., `http` from `import http from 'node:http'`). */
43
+ localName: string;
44
+ /** The normalized module name (e.g., `http`). */
45
+ moduleName: string;
46
+ /** Named bindings imported (e.g., `['createServer', 'get']` from `import { createServer, get } from 'http'`). */
47
+ namedBindings?: string[];
48
+ }
49
+ /** Result of `preprocessImports`. */
50
+ export interface PreprocessResult {
51
+ /** The transformed source code with import stubs. */
52
+ source: string;
53
+ /** Node builtin modules detected during preprocessing. */
54
+ nodeBuiltins: NodeBuiltinImport[];
55
+ /** JSX runtime import (if any) detected during preprocessing (#1540). */
56
+ jsxRuntime?: JsxRuntimeImport;
57
+ /**
58
+ * #1928 — maps an offset in `source` (the processed output) back to an
59
+ * offset in the input this function consumed, covering the import-stub
60
+ * replacements and the prepended timer shim. Identity when neither fired.
61
+ * Lets the diagnostic layer report the user's line numbers, not the
62
+ * rewritten ones.
63
+ */
64
+ positionMap: PositionMap;
65
+ }
66
+ export declare function preprocessImports(source: string, opts?: {
67
+ wasi?: boolean;
68
+ }): PreprocessResult;