luau2ts 0.1.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 (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/dist/cli/args.d.ts +19 -0
  4. package/dist/cli/args.d.ts.map +1 -0
  5. package/dist/cli/args.js +130 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/bin.d.ts +3 -0
  8. package/dist/cli/bin.d.ts.map +1 -0
  9. package/dist/cli/bin.js +65 -0
  10. package/dist/cli/bin.js.map +1 -0
  11. package/dist/cli/modes.d.ts +17 -0
  12. package/dist/cli/modes.d.ts.map +1 -0
  13. package/dist/cli/modes.js +134 -0
  14. package/dist/cli/modes.js.map +1 -0
  15. package/dist/compile/class-shape.d.ts +31 -0
  16. package/dist/compile/class-shape.d.ts.map +1 -0
  17. package/dist/compile/class-shape.js +291 -0
  18. package/dist/compile/class-shape.js.map +1 -0
  19. package/dist/compile/context.d.ts +86 -0
  20. package/dist/compile/context.d.ts.map +1 -0
  21. package/dist/compile/context.js +144 -0
  22. package/dist/compile/context.js.map +1 -0
  23. package/dist/compile/index.d.ts +43 -0
  24. package/dist/compile/index.d.ts.map +1 -0
  25. package/dist/compile/index.js +2028 -0
  26. package/dist/compile/index.js.map +1 -0
  27. package/dist/compile/macros/datatypes.d.ts +2 -0
  28. package/dist/compile/macros/datatypes.d.ts.map +1 -0
  29. package/dist/compile/macros/datatypes.js +76 -0
  30. package/dist/compile/macros/datatypes.js.map +1 -0
  31. package/dist/compile/macros/index.d.ts +33 -0
  32. package/dist/compile/macros/index.d.ts.map +1 -0
  33. package/dist/compile/macros/index.js +71 -0
  34. package/dist/compile/macros/index.js.map +1 -0
  35. package/dist/compile/macros/instance.d.ts +2 -0
  36. package/dist/compile/macros/instance.d.ts.map +1 -0
  37. package/dist/compile/macros/instance.js +58 -0
  38. package/dist/compile/macros/instance.js.map +1 -0
  39. package/dist/compile/macros/stdlib.d.ts +2 -0
  40. package/dist/compile/macros/stdlib.d.ts.map +1 -0
  41. package/dist/compile/macros/stdlib.js +140 -0
  42. package/dist/compile/macros/stdlib.js.map +1 -0
  43. package/dist/compile/rbxts-runtime.d.ts +2 -0
  44. package/dist/compile/rbxts-runtime.d.ts.map +1 -0
  45. package/dist/compile/rbxts-runtime.js +163 -0
  46. package/dist/compile/rbxts-runtime.js.map +1 -0
  47. package/dist/compile/sourcemap.d.ts +25 -0
  48. package/dist/compile/sourcemap.d.ts.map +1 -0
  49. package/dist/compile/sourcemap.js +71 -0
  50. package/dist/compile/sourcemap.js.map +1 -0
  51. package/dist/compile/type.d.ts +6 -0
  52. package/dist/compile/type.d.ts.map +1 -0
  53. package/dist/compile/type.js +122 -0
  54. package/dist/compile/type.js.map +1 -0
  55. package/dist/compile/util.d.ts +38 -0
  56. package/dist/compile/util.d.ts.map +1 -0
  57. package/dist/compile/util.js +153 -0
  58. package/dist/compile/util.js.map +1 -0
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +7 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/parser/index.d.ts +4 -0
  64. package/dist/parser/index.d.ts.map +1 -0
  65. package/dist/parser/index.js +227 -0
  66. package/dist/parser/index.js.map +1 -0
  67. package/dist/parser/types.d.ts +430 -0
  68. package/dist/parser/types.d.ts.map +1 -0
  69. package/dist/parser/types.js +14 -0
  70. package/dist/parser/types.js.map +1 -0
  71. package/dist/parser/wasm/luau-parser.d.mts +21 -0
  72. package/dist/parser/wasm/luau-parser.mjs +2 -0
  73. package/dist/parser/wasm/luau-parser.wasm +0 -0
  74. package/dist/rojo/index.d.ts +4 -0
  75. package/dist/rojo/index.d.ts.map +1 -0
  76. package/dist/rojo/index.js +3 -0
  77. package/dist/rojo/index.js.map +1 -0
  78. package/dist/rojo/load-project.d.ts +12 -0
  79. package/dist/rojo/load-project.d.ts.map +1 -0
  80. package/dist/rojo/load-project.js +35 -0
  81. package/dist/rojo/load-project.js.map +1 -0
  82. package/dist/rojo/types.d.ts +39 -0
  83. package/dist/rojo/types.d.ts.map +1 -0
  84. package/dist/rojo/types.js +2 -0
  85. package/dist/rojo/types.js.map +1 -0
  86. package/dist/rojo/walk-tree.d.ts +40 -0
  87. package/dist/rojo/walk-tree.d.ts.map +1 -0
  88. package/dist/rojo/walk-tree.js +164 -0
  89. package/dist/rojo/walk-tree.js.map +1 -0
  90. package/dist/runtime/arith.d.ts +13 -0
  91. package/dist/runtime/arith.d.ts.map +1 -0
  92. package/dist/runtime/arith.js +151 -0
  93. package/dist/runtime/arith.js.map +1 -0
  94. package/dist/runtime/index-helper.d.ts +3 -0
  95. package/dist/runtime/index-helper.d.ts.map +1 -0
  96. package/dist/runtime/index-helper.js +40 -0
  97. package/dist/runtime/index-helper.js.map +1 -0
  98. package/dist/runtime/index.d.ts +13 -0
  99. package/dist/runtime/index.d.ts.map +1 -0
  100. package/dist/runtime/index.js +13 -0
  101. package/dist/runtime/index.js.map +1 -0
  102. package/dist/runtime/iterator.d.ts +58 -0
  103. package/dist/runtime/iterator.d.ts.map +1 -0
  104. package/dist/runtime/iterator.js +181 -0
  105. package/dist/runtime/iterator.js.map +1 -0
  106. package/dist/runtime/length.d.ts +2 -0
  107. package/dist/runtime/length.d.ts.map +1 -0
  108. package/dist/runtime/length.js +15 -0
  109. package/dist/runtime/length.js.map +1 -0
  110. package/dist/runtime/lua-stdlib.d.ts +186 -0
  111. package/dist/runtime/lua-stdlib.d.ts.map +1 -0
  112. package/dist/runtime/lua-stdlib.js +502 -0
  113. package/dist/runtime/lua-stdlib.js.map +1 -0
  114. package/dist/runtime/metatable.d.ts +16 -0
  115. package/dist/runtime/metatable.d.ts.map +1 -0
  116. package/dist/runtime/metatable.js +129 -0
  117. package/dist/runtime/metatable.js.map +1 -0
  118. package/dist/runtime/pattern.d.ts +21 -0
  119. package/dist/runtime/pattern.d.ts.map +1 -0
  120. package/dist/runtime/pattern.js +375 -0
  121. package/dist/runtime/pattern.js.map +1 -0
  122. package/dist/runtime/pcall.d.ts +12 -0
  123. package/dist/runtime/pcall.d.ts.map +1 -0
  124. package/dist/runtime/pcall.js +54 -0
  125. package/dist/runtime/pcall.js.map +1 -0
  126. package/dist/runtime/string-lib.d.ts +31 -0
  127. package/dist/runtime/string-lib.d.ts.map +1 -0
  128. package/dist/runtime/string-lib.js +296 -0
  129. package/dist/runtime/string-lib.js.map +1 -0
  130. package/dist/runtime/table-lib.d.ts +18 -0
  131. package/dist/runtime/table-lib.d.ts.map +1 -0
  132. package/dist/runtime/table-lib.js +133 -0
  133. package/dist/runtime/table-lib.js.map +1 -0
  134. package/dist/runtime/tostring.d.ts +3 -0
  135. package/dist/runtime/tostring.d.ts.map +1 -0
  136. package/dist/runtime/tostring.js +82 -0
  137. package/dist/runtime/tostring.js.map +1 -0
  138. package/dist/runtime/truthy.d.ts +13 -0
  139. package/dist/runtime/truthy.d.ts.map +1 -0
  140. package/dist/runtime/truthy.js +26 -0
  141. package/dist/runtime/truthy.js.map +1 -0
  142. package/package.json +70 -0
@@ -0,0 +1,26 @@
1
+ export function isTruthy(value) {
2
+ return (value !== false
3
+ && value !== null
4
+ && value !== undefined
5
+ && !(typeof value === 'object'
6
+ && value !== null
7
+ && value.__isNull === true));
8
+ }
9
+ export function luaNot(value) {
10
+ return !isTruthy(value);
11
+ }
12
+ /**
13
+ * `a and b` in Lua: returns the first falsy value, otherwise the last value.
14
+ * Note both operands are passed already-evaluated; this helper does NOT
15
+ * short-circuit (the compiler emits its own short-circuit when it can).
16
+ */
17
+ export function luaAnd(a, b) {
18
+ return isTruthy(a) ? b : a;
19
+ }
20
+ /**
21
+ * `a or b` in Lua: returns the first truthy value, otherwise the last.
22
+ */
23
+ export function luaOr(a, b) {
24
+ return isTruthy(a) ? a : b;
25
+ }
26
+ //# sourceMappingURL=truthy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"truthy.js","sourceRoot":"","sources":["../../src/runtime/truthy.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,CACL,KAAK,KAAK,KAAK;WACZ,KAAK,KAAK,IAAI;WACd,KAAK,KAAK,SAAS;WACnB,CAAC,CACF,OAAO,KAAK,KAAK,QAAQ;eACtB,KAAK,KAAK,IAAI;eACb,KAAgC,CAAC,QAAQ,KAAK,IAAI,CACvD,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAO,CAAI,EAAE,CAAI;IACrC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAO,CAAI,EAAE,CAAI;IACpC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "luau2ts",
3
+ "version": "0.1.0",
4
+ "description": "A Luau-to-TypeScript compiler for Roblox.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Tony Bolivar",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "bin": {
11
+ "luau2ts": "./dist/cli/bin.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./runtime": {
20
+ "types": "./dist/runtime/index.d.ts",
21
+ "import": "./dist/runtime/index.js",
22
+ "default": "./dist/runtime/index.js"
23
+ },
24
+ "./rojo": {
25
+ "types": "./dist/rojo/index.d.ts",
26
+ "import": "./dist/rojo/index.js",
27
+ "default": "./dist/rojo/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsc -b && node scripts/copy-wasm.mjs",
37
+ "clean": "tsc -b --clean",
38
+ "test": "vitest run",
39
+ "test:watch": "vitest",
40
+ "typecheck": "tsc --noEmit"
41
+ },
42
+ "dependencies": {
43
+ "prettier": "^3.4.0",
44
+ "typescript": "^5.5.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^22.10.0",
48
+ "@vitest/coverage-v8": "^2.0.0",
49
+ "vitest": "^2.0.0"
50
+ },
51
+ "keywords": [
52
+ "luau",
53
+ "typescript",
54
+ "compiler",
55
+ "roblox",
56
+ "roblox-ts",
57
+ "transpiler"
58
+ ],
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "git+https://github.com/luau2ts/luau2ts.git"
62
+ },
63
+ "homepage": "https://luau2ts.com",
64
+ "bugs": {
65
+ "url": "https://github.com/luau2ts/luau2ts/issues"
66
+ },
67
+ "engines": {
68
+ "node": ">=18"
69
+ }
70
+ }