luau2ts 0.2.1 → 0.2.3

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 (140) hide show
  1. package/dist/cli/args.d.ts +23 -0
  2. package/dist/cli/args.d.ts.map +1 -0
  3. package/dist/cli/args.js +177 -0
  4. package/dist/cli/args.js.map +1 -0
  5. package/dist/cli/bin.d.ts +3 -0
  6. package/dist/cli/bin.d.ts.map +1 -0
  7. package/dist/cli/bin.js +71 -0
  8. package/dist/cli/bin.js.map +1 -0
  9. package/dist/cli/modes.d.ts +20 -0
  10. package/dist/cli/modes.d.ts.map +1 -0
  11. package/dist/cli/modes.js +145 -0
  12. package/dist/cli/modes.js.map +1 -0
  13. package/dist/compile/class-shape.d.ts +31 -0
  14. package/dist/compile/class-shape.d.ts.map +1 -0
  15. package/dist/compile/class-shape.js +291 -0
  16. package/dist/compile/class-shape.js.map +1 -0
  17. package/dist/compile/context.d.ts +86 -0
  18. package/dist/compile/context.d.ts.map +1 -0
  19. package/dist/compile/context.js +144 -0
  20. package/dist/compile/context.js.map +1 -0
  21. package/dist/compile/index.d.ts +58 -0
  22. package/dist/compile/index.d.ts.map +1 -0
  23. package/dist/compile/index.js +2155 -0
  24. package/dist/compile/index.js.map +1 -0
  25. package/dist/compile/macros/datatypes.d.ts +2 -0
  26. package/dist/compile/macros/datatypes.d.ts.map +1 -0
  27. package/dist/compile/macros/datatypes.js +76 -0
  28. package/dist/compile/macros/datatypes.js.map +1 -0
  29. package/dist/compile/macros/index.d.ts +33 -0
  30. package/dist/compile/macros/index.d.ts.map +1 -0
  31. package/dist/compile/macros/index.js +71 -0
  32. package/dist/compile/macros/index.js.map +1 -0
  33. package/dist/compile/macros/instance.d.ts +2 -0
  34. package/dist/compile/macros/instance.d.ts.map +1 -0
  35. package/dist/compile/macros/instance.js +58 -0
  36. package/dist/compile/macros/instance.js.map +1 -0
  37. package/dist/compile/macros/stdlib.d.ts +2 -0
  38. package/dist/compile/macros/stdlib.d.ts.map +1 -0
  39. package/dist/compile/macros/stdlib.js +140 -0
  40. package/dist/compile/macros/stdlib.js.map +1 -0
  41. package/dist/compile/rbxts-runtime.d.ts +2 -0
  42. package/dist/compile/rbxts-runtime.d.ts.map +1 -0
  43. package/dist/compile/rbxts-runtime.js +163 -0
  44. package/dist/compile/rbxts-runtime.js.map +1 -0
  45. package/dist/compile/sourcemap.d.ts +25 -0
  46. package/dist/compile/sourcemap.d.ts.map +1 -0
  47. package/dist/compile/sourcemap.js +71 -0
  48. package/dist/compile/sourcemap.js.map +1 -0
  49. package/dist/compile/type.d.ts +6 -0
  50. package/dist/compile/type.d.ts.map +1 -0
  51. package/dist/compile/type.js +122 -0
  52. package/dist/compile/type.js.map +1 -0
  53. package/dist/compile/util.d.ts +38 -0
  54. package/dist/compile/util.d.ts.map +1 -0
  55. package/dist/compile/util.js +153 -0
  56. package/dist/compile/util.js.map +1 -0
  57. package/dist/index.d.ts +3 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +7 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/parser/index.d.ts +4 -0
  62. package/dist/parser/index.d.ts.map +1 -0
  63. package/dist/parser/index.js +227 -0
  64. package/dist/parser/index.js.map +1 -0
  65. package/dist/parser/types.d.ts +430 -0
  66. package/dist/parser/types.d.ts.map +1 -0
  67. package/dist/parser/types.js +14 -0
  68. package/dist/parser/types.js.map +1 -0
  69. package/dist/parser/wasm/luau-parser.d.mts +21 -0
  70. package/dist/parser/wasm/luau-parser.mjs +2 -0
  71. package/dist/parser/wasm/luau-parser.wasm +0 -0
  72. package/dist/rojo/index.d.ts +4 -0
  73. package/dist/rojo/index.d.ts.map +1 -0
  74. package/dist/rojo/index.js +3 -0
  75. package/dist/rojo/index.js.map +1 -0
  76. package/dist/rojo/load-project.d.ts +12 -0
  77. package/dist/rojo/load-project.d.ts.map +1 -0
  78. package/dist/rojo/load-project.js +35 -0
  79. package/dist/rojo/load-project.js.map +1 -0
  80. package/dist/rojo/types.d.ts +39 -0
  81. package/dist/rojo/types.d.ts.map +1 -0
  82. package/dist/rojo/types.js +2 -0
  83. package/dist/rojo/types.js.map +1 -0
  84. package/dist/rojo/walk-tree.d.ts +40 -0
  85. package/dist/rojo/walk-tree.d.ts.map +1 -0
  86. package/dist/rojo/walk-tree.js +164 -0
  87. package/dist/rojo/walk-tree.js.map +1 -0
  88. package/dist/runtime/arith.d.ts +13 -0
  89. package/dist/runtime/arith.d.ts.map +1 -0
  90. package/dist/runtime/arith.js +151 -0
  91. package/dist/runtime/arith.js.map +1 -0
  92. package/dist/runtime/index-helper.d.ts +3 -0
  93. package/dist/runtime/index-helper.d.ts.map +1 -0
  94. package/dist/runtime/index-helper.js +40 -0
  95. package/dist/runtime/index-helper.js.map +1 -0
  96. package/dist/runtime/index.d.ts +13 -0
  97. package/dist/runtime/index.d.ts.map +1 -0
  98. package/dist/runtime/index.js +13 -0
  99. package/dist/runtime/index.js.map +1 -0
  100. package/dist/runtime/iterator.d.ts +58 -0
  101. package/dist/runtime/iterator.d.ts.map +1 -0
  102. package/dist/runtime/iterator.js +181 -0
  103. package/dist/runtime/iterator.js.map +1 -0
  104. package/dist/runtime/length.d.ts +2 -0
  105. package/dist/runtime/length.d.ts.map +1 -0
  106. package/dist/runtime/length.js +15 -0
  107. package/dist/runtime/length.js.map +1 -0
  108. package/dist/runtime/lua-stdlib.d.ts +186 -0
  109. package/dist/runtime/lua-stdlib.d.ts.map +1 -0
  110. package/dist/runtime/lua-stdlib.js +502 -0
  111. package/dist/runtime/lua-stdlib.js.map +1 -0
  112. package/dist/runtime/metatable.d.ts +16 -0
  113. package/dist/runtime/metatable.d.ts.map +1 -0
  114. package/dist/runtime/metatable.js +129 -0
  115. package/dist/runtime/metatable.js.map +1 -0
  116. package/dist/runtime/pattern.d.ts +21 -0
  117. package/dist/runtime/pattern.d.ts.map +1 -0
  118. package/dist/runtime/pattern.js +375 -0
  119. package/dist/runtime/pattern.js.map +1 -0
  120. package/dist/runtime/pcall.d.ts +12 -0
  121. package/dist/runtime/pcall.d.ts.map +1 -0
  122. package/dist/runtime/pcall.js +54 -0
  123. package/dist/runtime/pcall.js.map +1 -0
  124. package/dist/runtime/string-lib.d.ts +31 -0
  125. package/dist/runtime/string-lib.d.ts.map +1 -0
  126. package/dist/runtime/string-lib.js +296 -0
  127. package/dist/runtime/string-lib.js.map +1 -0
  128. package/dist/runtime/table-lib.d.ts +18 -0
  129. package/dist/runtime/table-lib.d.ts.map +1 -0
  130. package/dist/runtime/table-lib.js +133 -0
  131. package/dist/runtime/table-lib.js.map +1 -0
  132. package/dist/runtime/tostring.d.ts +3 -0
  133. package/dist/runtime/tostring.d.ts.map +1 -0
  134. package/dist/runtime/tostring.js +82 -0
  135. package/dist/runtime/tostring.js.map +1 -0
  136. package/dist/runtime/truthy.d.ts +13 -0
  137. package/dist/runtime/truthy.d.ts.map +1 -0
  138. package/dist/runtime/truthy.js +26 -0
  139. package/dist/runtime/truthy.js.map +1 -0
  140. package/package.json +10 -10
@@ -0,0 +1,38 @@
1
+ import ts from 'typescript';
2
+ import type { CompileContext } from './context.js';
3
+ /** Map a Luau identifier to a JS-safe one (suffixing reserved words). */
4
+ export declare function safeIdentifier(name: string): string;
5
+ /**
6
+ * Property-access name. JS allows reserved words as property names in
7
+ * dot notation (`obj.new`, `obj.delete`, `obj.class`) — only the
8
+ * identifier position needs escaping. Use this for IndexName / record
9
+ * keys / static class members.
10
+ *
11
+ * Parse-error recovery can hand us names with `%`, spaces, hyphens etc. —
12
+ * those would emit invalid JS when wrapped in `createIdentifier`. Replace
13
+ * such names with a safe placeholder so the file still compiles; the
14
+ * surrounding script will already have thrown a parse-error stub.
15
+ */
16
+ export declare function propertyName(name: string): string;
17
+ export declare function isRepeatableExpression(expr: ts.Expression): boolean;
18
+ /** Wrap a TS expression in a Lua-faithful truthiness check.
19
+ *
20
+ * Optional `staticType` hint short-circuits the wrapper when the runtime
21
+ * shape of the value is narrow enough:
22
+ * - `'boolean'` → return `expr` directly (already truthy-shaped).
23
+ * - `'number'` / `'string'` → always truthy in Lua (only nil/false are
24
+ * falsy). Return `true` literal when the expression is side-effect-
25
+ * free; otherwise fall through.
26
+ * - `'nil'` → always falsy. Return `false`.
27
+ *
28
+ * For everything else, route through the runtime `isTruthy()` helper.
29
+ * We previously inlined the check (`x !== false && x !== null && …`) for
30
+ * repeatable expressions, but the inline form bloats output by ~6× per
31
+ * use site for no measurable runtime win — `isTruthy()` is one indirect
32
+ * call into a 4-line function the engine inlines on the hot path. */
33
+ export declare function truthify(expr: ts.Expression, ctx: CompileContext, staticType?: import('./context.js').StaticValueType | undefined): ts.Expression;
34
+ /** `throw new Error(message)` — used for unsupported AST nodes. */
35
+ export declare function throwUnsupported(message: string): ts.Statement;
36
+ /** As an expression: `(() => { throw new Error(message) })()`. */
37
+ export declare function unsupportedExpr(message: string): ts.Expression;
38
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/compile/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAqEnD,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAInD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGjD;AAOD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,GAAG,OAAO,CASnE;AAED;;;;;;;;;;;;;;sEAcsE;AACtE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,EAAE,CAAC,UAAU,EACnB,GAAG,EAAE,cAAc,EACnB,UAAU,GAAE,OAAO,cAAc,EAAE,eAAe,GAAG,SAAqB,GACzE,EAAE,CAAC,UAAU,CAuBf;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC,SAAS,CAM9D;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAe9D"}
@@ -0,0 +1,153 @@
1
+ import ts from 'typescript';
2
+ const { factory } = ts;
3
+ const TS_RESERVED = new Set([
4
+ 'await',
5
+ 'break',
6
+ 'case',
7
+ 'catch',
8
+ 'class',
9
+ 'const',
10
+ 'continue',
11
+ 'debugger',
12
+ 'default',
13
+ 'delete',
14
+ 'do',
15
+ 'else',
16
+ 'enum',
17
+ 'export',
18
+ 'extends',
19
+ 'false',
20
+ 'finally',
21
+ 'for',
22
+ 'function',
23
+ 'if',
24
+ 'import',
25
+ 'in',
26
+ 'instanceof',
27
+ 'new',
28
+ 'null',
29
+ 'return',
30
+ 'super',
31
+ 'switch',
32
+ 'this',
33
+ 'throw',
34
+ 'true',
35
+ 'try',
36
+ 'typeof',
37
+ 'var',
38
+ 'void',
39
+ 'while',
40
+ 'with',
41
+ 'yield',
42
+ 'let',
43
+ 'implements',
44
+ 'interface',
45
+ 'package',
46
+ 'private',
47
+ 'protected',
48
+ 'public',
49
+ 'static',
50
+ 'as',
51
+ // TS type-name keywords. We deliberately do NOT escape `string`,
52
+ // `number`, `boolean`, `object` — they shadow the Lua stdlib globals
53
+ // (`string.format`, `math.floor`, `table.insert`) the script wrapper
54
+ // injects, and the JS engine accepts them as variable names anyway.
55
+ 'symbol',
56
+ 'unknown',
57
+ 'never',
58
+ // Strict-mode reserved words. Bare `const arguments = ...` and
59
+ // `const eval = ...` are rejected in ES modules even though
60
+ // they're not classic TS keywords. Lua treats both as ordinary
61
+ // identifiers, so Vigilant-style `for _, arguments in ipairs(...)`
62
+ // breaks without escaping.
63
+ 'arguments',
64
+ 'eval',
65
+ ]);
66
+ /** Map a Luau identifier to a JS-safe one (suffixing reserved words). */
67
+ export function safeIdentifier(name) {
68
+ if (TS_RESERVED.has(name))
69
+ return `${name}_`;
70
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
71
+ return '_invalid_';
72
+ return name;
73
+ }
74
+ /**
75
+ * Property-access name. JS allows reserved words as property names in
76
+ * dot notation (`obj.new`, `obj.delete`, `obj.class`) — only the
77
+ * identifier position needs escaping. Use this for IndexName / record
78
+ * keys / static class members.
79
+ *
80
+ * Parse-error recovery can hand us names with `%`, spaces, hyphens etc. —
81
+ * those would emit invalid JS when wrapped in `createIdentifier`. Replace
82
+ * such names with a safe placeholder so the file still compiles; the
83
+ * surrounding script will already have thrown a parse-error stub.
84
+ */
85
+ export function propertyName(name) {
86
+ if (!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
87
+ return '_invalid_';
88
+ return name;
89
+ }
90
+ /** Wrap an expression in `isTruthy(…)` for Lua-faithful conditional evaluation. */
91
+ function isUndefinedIdentifier(expr) {
92
+ return ts.isIdentifier(expr) && expr.text === 'undefined';
93
+ }
94
+ export function isRepeatableExpression(expr) {
95
+ return (ts.isIdentifier(expr)
96
+ || expr.kind === ts.SyntaxKind.ThisKeyword
97
+ || ts.isNumericLiteral(expr)
98
+ || ts.isStringLiteral(expr)
99
+ || expr.kind === ts.SyntaxKind.TrueKeyword
100
+ || expr.kind === ts.SyntaxKind.FalseKeyword);
101
+ }
102
+ /** Wrap a TS expression in a Lua-faithful truthiness check.
103
+ *
104
+ * Optional `staticType` hint short-circuits the wrapper when the runtime
105
+ * shape of the value is narrow enough:
106
+ * - `'boolean'` → return `expr` directly (already truthy-shaped).
107
+ * - `'number'` / `'string'` → always truthy in Lua (only nil/false are
108
+ * falsy). Return `true` literal when the expression is side-effect-
109
+ * free; otherwise fall through.
110
+ * - `'nil'` → always falsy. Return `false`.
111
+ *
112
+ * For everything else, route through the runtime `isTruthy()` helper.
113
+ * We previously inlined the check (`x !== false && x !== null && …`) for
114
+ * repeatable expressions, but the inline form bloats output by ~6× per
115
+ * use site for no measurable runtime win — `isTruthy()` is one indirect
116
+ * call into a 4-line function the engine inlines on the hot path. */
117
+ export function truthify(expr, ctx, staticType = undefined) {
118
+ if (staticType === 'boolean')
119
+ return expr;
120
+ if (staticType === 'nil')
121
+ return factory.createFalse();
122
+ // number, string, and Roblox datatypes (Vector3, CFrame, …) are never
123
+ // nil and never the literal `false` in Lua, so Lua truthiness is always
124
+ // `true`. Side-effect-free expressions fold to a boolean literal.
125
+ const isAlwaysTruthy = staticType === 'number'
126
+ || staticType === 'string'
127
+ || (typeof staticType === 'string' && staticType.startsWith('datatype:'));
128
+ if (isAlwaysTruthy && isRepeatableExpression(expr)) {
129
+ return factory.createTrue();
130
+ }
131
+ // Quick literal folds — match `inlineTruthy`'s special cases without
132
+ // emitting the 6-clause inline check.
133
+ if (expr.kind === ts.SyntaxKind.TrueKeyword)
134
+ return factory.createTrue();
135
+ if (expr.kind === ts.SyntaxKind.FalseKeyword || isUndefinedIdentifier(expr)) {
136
+ return factory.createFalse();
137
+ }
138
+ if (ts.isNumericLiteral(expr) || ts.isStringLiteral(expr))
139
+ return factory.createTrue();
140
+ const fn = ctx.use('isTruthy');
141
+ return factory.createCallExpression(factory.createIdentifier(fn), undefined, [expr]);
142
+ }
143
+ /** `throw new Error(message)` — used for unsupported AST nodes. */
144
+ export function throwUnsupported(message) {
145
+ return factory.createThrowStatement(factory.createNewExpression(factory.createIdentifier('Error'), undefined, [
146
+ factory.createStringLiteral(message),
147
+ ]));
148
+ }
149
+ /** As an expression: `(() => { throw new Error(message) })()`. */
150
+ export function unsupportedExpr(message) {
151
+ return factory.createCallExpression(factory.createParenthesizedExpression(factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), factory.createBlock([throwUnsupported(message)], true))), undefined, []);
152
+ }
153
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/compile/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,MAAM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E,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,YAAY,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5E,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;IAC/B,CAAC;IACD,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC,UAAU,EAAE,CAAC;IAEvF,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,OAAO,CAAC,oBAAoB,CACjC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE;QACxE,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC;KACrC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,OAAO,OAAO,CAAC,oBAAoB,CACjC,OAAO,CAAC,6BAA6B,CACnC,OAAO,CAAC,mBAAmB,CACzB,SAAS,EACT,SAAS,EACT,EAAE,EACF,SAAS,EACT,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,sBAAsB,CAAC,EACzD,OAAO,CAAC,WAAW,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CACvD,CACF,EACD,SAAS,EACT,EAAE,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { compile, type CompileOptions, type CompileResult, } from './compile/index.js';
2
+ export type { CompatMode } from './compile/context.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // Browser-safe public surface. Pulls only the compiler and the
2
+ // inlined WASM parser. The Rojo project reader (which needs Node's
3
+ // `fs/promises`) lives at the `luau2ts/rojo` subpath so this entry
4
+ // point can be bundled for the browser without dragging Node modules
5
+ // into the bundle graph.
6
+ export { compile, } from './compile/index.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,mEAAmE;AACnE,mEAAmE;AACnE,qEAAqE;AACrE,yBAAyB;AACzB,OAAO,EACL,OAAO,GAGR,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ParseResult } from './types.js';
2
+ export * from './types.js';
3
+ export declare function parse(source: string): Promise<ParseResult>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,cAAc,YAAY,CAAC;AA8K3B,wBAAsB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA+BhE"}
@@ -0,0 +1,227 @@
1
+ import createLuauParserModule, {} from './wasm/luau-parser.mjs';
2
+ export * from './types.js';
3
+ let modulePromise = null;
4
+ function loadModule() {
5
+ modulePromise ??= createLuauParserModule();
6
+ return modulePromise;
7
+ }
8
+ /** Strip the experimental Luau native-integer suffix `i` from numeric
9
+ * literals (e.g. `123i` → `123`). Released Luau parsers gate this on an
10
+ * FFlag; our prebuilt WASM rejects it as "Malformed number". JavaScript
11
+ * numbers don't distinguish int from float, so the runtime semantics are
12
+ * unchanged once stripped. We rewrite outside string and comment regions
13
+ * to avoid clobbering identifiers that happen to end in a digit-then-i. */
14
+ function stripNativeIntegerSuffix(source) {
15
+ let out = '';
16
+ let i = 0;
17
+ const n = source.length;
18
+ while (i < n) {
19
+ const ch = source[i];
20
+ // Single-line comment `-- ...`
21
+ if (ch === '-' && source[i + 1] === '-') {
22
+ // Detect long bracket level for block comment `--[==[ ... ]==]`
23
+ if (source[i + 2] === '[') {
24
+ let j = i + 3;
25
+ let level = 0;
26
+ while (source[j] === '=') {
27
+ level++;
28
+ j++;
29
+ }
30
+ if (source[j] === '[') {
31
+ // Long-bracket comment.
32
+ const close = ']' + '='.repeat(level) + ']';
33
+ const end = source.indexOf(close, j + 1);
34
+ const stop = end < 0 ? n : end + close.length;
35
+ out += source.slice(i, stop);
36
+ i = stop;
37
+ continue;
38
+ }
39
+ }
40
+ const eol = source.indexOf('\n', i);
41
+ const stop = eol < 0 ? n : eol;
42
+ out += source.slice(i, stop);
43
+ i = stop;
44
+ continue;
45
+ }
46
+ // Long-bracket string `[=*[ ... ]=*]`
47
+ if (ch === '[') {
48
+ let j = i + 1;
49
+ let level = 0;
50
+ while (source[j] === '=') {
51
+ level++;
52
+ j++;
53
+ }
54
+ if (source[j] === '[') {
55
+ const close = ']' + '='.repeat(level) + ']';
56
+ const end = source.indexOf(close, j + 1);
57
+ const stop = end < 0 ? n : end + close.length;
58
+ out += source.slice(i, stop);
59
+ i = stop;
60
+ continue;
61
+ }
62
+ }
63
+ // Short string literals `"..."` / `'...'`
64
+ if (ch === '"' || ch === "'") {
65
+ const quote = ch;
66
+ let j = i + 1;
67
+ while (j < n) {
68
+ const c = source[j];
69
+ if (c === '\\') {
70
+ j += 2;
71
+ continue;
72
+ }
73
+ if (c === quote || c === '\n') {
74
+ j++;
75
+ break;
76
+ }
77
+ j++;
78
+ }
79
+ out += source.slice(i, j);
80
+ i = j;
81
+ continue;
82
+ }
83
+ // Backtick interpolated string — `...{expr}...`. Recurse on `expr`s
84
+ // by simply scanning until matching backtick respecting brace depth.
85
+ if (ch === '`') {
86
+ let j = i + 1;
87
+ let depth = 0;
88
+ while (j < n) {
89
+ const c = source[j];
90
+ if (c === '\\') {
91
+ j += 2;
92
+ continue;
93
+ }
94
+ if (depth === 0 && c === '`') {
95
+ j++;
96
+ break;
97
+ }
98
+ if (c === '{')
99
+ depth++;
100
+ else if (c === '}')
101
+ depth--;
102
+ j++;
103
+ }
104
+ out += source.slice(i, j);
105
+ i = j;
106
+ continue;
107
+ }
108
+ // Numeric literal followed by `i` suffix. Match Luau-style numbers
109
+ // (decimal, hex, binary), then drop a trailing `i` if it's not part
110
+ // of a longer identifier.
111
+ const numMatch = /^(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)/.exec(source.slice(i));
112
+ if (numMatch && /[a-zA-Z_]/.test(source[Math.max(0, i - 1)] ?? '') === false) {
113
+ const lit = numMatch[0];
114
+ const after = source[i + lit.length];
115
+ if (after === 'i' && !/[a-zA-Z0-9_]/.test(source[i + lit.length + 1] ?? '')) {
116
+ out += lit;
117
+ i += lit.length + 1;
118
+ continue;
119
+ }
120
+ }
121
+ out += ch;
122
+ i++;
123
+ }
124
+ return out;
125
+ }
126
+ // Old Roblox scripts often contain backslash escapes that modern Luau rejects
127
+ // as invalid (e.g. `"rbxasset://textures\GunCursor.png"` — `\G` is not a
128
+ // recognized escape). The legacy parser silently dropped the backslash.
129
+ // Replace `\<unrecognized>` inside short string literals with just the
130
+ // character so these scripts continue to parse. Long-bracket strings don't
131
+ // process escapes at all, so they're left alone.
132
+ function normalizeStringEscapes(source) {
133
+ const VALID = /[abfnrtvxzu\\"'\r\n0-9]/;
134
+ let out = '';
135
+ let i = 0;
136
+ const n = source.length;
137
+ while (i < n) {
138
+ const ch = source[i];
139
+ if (ch === '-' && source[i + 1] === '-') {
140
+ const eol = source.indexOf('\n', i);
141
+ const stop = eol < 0 ? n : eol;
142
+ out += source.slice(i, stop);
143
+ i = stop;
144
+ continue;
145
+ }
146
+ if (ch === '[') {
147
+ let j = i + 1;
148
+ while (source[j] === '=')
149
+ j++;
150
+ if (source[j] === '[') {
151
+ const level = j - i - 1;
152
+ const close = ']' + '='.repeat(level) + ']';
153
+ const end = source.indexOf(close, j + 1);
154
+ const stop = end < 0 ? n : end + close.length;
155
+ out += source.slice(i, stop);
156
+ i = stop;
157
+ continue;
158
+ }
159
+ }
160
+ if (ch === '"' || ch === "'") {
161
+ const quote = ch;
162
+ out += ch;
163
+ i++;
164
+ while (i < n) {
165
+ const c = source[i];
166
+ if (c === '\\') {
167
+ const nx = source[i + 1] ?? '';
168
+ if (VALID.test(nx)) {
169
+ out += c + nx;
170
+ i += 2;
171
+ }
172
+ else {
173
+ out += nx;
174
+ i += 2;
175
+ }
176
+ continue;
177
+ }
178
+ if (c === quote || c === '\n') {
179
+ out += c;
180
+ i++;
181
+ break;
182
+ }
183
+ out += c;
184
+ i++;
185
+ }
186
+ continue;
187
+ }
188
+ out += ch;
189
+ i++;
190
+ }
191
+ return out;
192
+ }
193
+ export async function parse(source) {
194
+ const m = await loadModule();
195
+ source = stripNativeIntegerSuffix(source);
196
+ source = normalizeStringEscapes(source);
197
+ const bytes = new TextEncoder().encode(source);
198
+ const ptr = m._malloc(bytes.length);
199
+ if (!ptr) {
200
+ throw new Error('luau-parser: malloc failed');
201
+ }
202
+ let resultPtr = 0;
203
+ try {
204
+ m.HEAPU8.set(bytes, ptr);
205
+ resultPtr = m._luau_parse(ptr, bytes.length);
206
+ if (!resultPtr) {
207
+ throw new Error('luau-parser: parse returned null');
208
+ }
209
+ const json = m.UTF8ToString(resultPtr);
210
+ // The WASM glue serializes numbers via std::ostream, which emits `inf`,
211
+ // `-inf`, `nan`, `-nan` for non-finite floats — none of which are valid
212
+ // JSON. Substitute IEEE 754-equivalent literals so JSON.parse succeeds
213
+ // (1e9999 overflows to Infinity in JS; null is the closest stand-in for
214
+ // NaN since JSON has no distinct NaN literal).
215
+ const sanitized = json
216
+ .replace(/:\s*-inf\b/g, ':-1e9999')
217
+ .replace(/:\s*inf\b/g, ':1e9999')
218
+ .replace(/:\s*-?nan\b/g, ':null');
219
+ return JSON.parse(sanitized);
220
+ }
221
+ finally {
222
+ if (resultPtr)
223
+ m._luau_free(resultPtr);
224
+ m._free(ptr);
225
+ }
226
+ }
227
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,EAAE,EAAiB,MAAM,wBAAwB,CAAC;AAG/E,cAAc,YAAY,CAAC;AAE3B,IAAI,aAAa,GAA6B,IAAI,CAAC;AAEnD,SAAS,UAAU;IACjB,aAAa,KAAK,sBAAsB,EAAE,CAAC;IAC3C,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;;4EAK4E;AAC5E,SAAS,wBAAwB,CAAC,MAAc;IAC9C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC;QACtB,+BAA+B;QAC/B,IAAI,EAAE,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACxC,gEAAgE;YAChE,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACd,IAAI,K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