@overmvp/kumi 0.0.0-stage → 0.3.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 (319) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/animation/color-transition.ts +196 -0
  4. package/animation/cycle.ts +151 -0
  5. package/animation/ease.ts +29 -0
  6. package/animation/index.ts +13 -0
  7. package/animation/package.json +12 -0
  8. package/animation/presets.ts +376 -0
  9. package/animation/spec.ts +197 -0
  10. package/builder/Cargo.lock +192 -0
  11. package/builder/Cargo.toml +7 -0
  12. package/builder/css-v1.mjs +387 -0
  13. package/builder/css-v1.test.mjs +361 -0
  14. package/builder/generated-output.mjs +61 -0
  15. package/builder/generated-output.test.mjs +132 -0
  16. package/builder/jsx-form.mjs +93 -0
  17. package/builder/jsx-form.test.mjs +48 -0
  18. package/builder/jsx-lists.mjs +209 -0
  19. package/builder/link-addon-package.mjs +127 -0
  20. package/builder/lua-assets.mjs +74 -0
  21. package/builder/lua-builtin-values.mjs +57 -0
  22. package/builder/lua-builtin-values.test.mjs +155 -0
  23. package/builder/lua-loop-closures.mjs +183 -0
  24. package/builder/lua-loop-closures.test.mjs +89 -0
  25. package/builder/lua-truthiness.mjs +61 -0
  26. package/builder/lua-truthiness.test.mjs +113 -0
  27. package/builder/module-declarations.mjs +594 -0
  28. package/builder/module-declarations.test.mjs +435 -0
  29. package/builder/native-kernels.mjs +60 -0
  30. package/builder/native-lua.d.ts +57 -0
  31. package/builder/native-routes.mjs +51 -0
  32. package/builder/no-static-ref-read.mjs +93 -0
  33. package/builder/no-static-ref-read.test.mjs +181 -0
  34. package/builder/secure-snippet.mjs +317 -0
  35. package/builder/secure-snippet.test.mjs +101 -0
  36. package/builder/shared-lua-runtime.mjs +150 -0
  37. package/builder/src/addon-link.lua +29 -0
  38. package/builder/src/arrays.lua +260 -0
  39. package/builder/src/assets.rs +177 -0
  40. package/builder/src/classes.lua +75 -0
  41. package/builder/src/collections.lua +190 -0
  42. package/builder/src/compiler.rs +2336 -0
  43. package/builder/src/config.rs +42 -0
  44. package/builder/src/entries.rs +166 -0
  45. package/builder/src/errors.lua +15 -0
  46. package/builder/src/lua_data.rs +231 -0
  47. package/builder/src/main.rs +381 -0
  48. package/builder/src/native_ir.rs +65 -0
  49. package/builder/src/native_signal.rs +83 -0
  50. package/builder/src/numbers.lua +76 -0
  51. package/builder/src/project-front.mjs +3682 -0
  52. package/builder/src/records.lua +75 -0
  53. package/builder/src/routes.rs +124 -0
  54. package/builder/src/setup-store.lua +18 -0
  55. package/builder/src/signal-kernel.fingerprint +1 -0
  56. package/builder/src/strings.lua +103 -0
  57. package/builder/src/ts-lower.mjs +68 -0
  58. package/builder/src/wow-reads.lua +22 -0
  59. package/builder/src/wow_client.rs +253 -0
  60. package/builder/src/wow_types.rs +564 -0
  61. package/builder/style-modules.mjs +93 -0
  62. package/builder/style-states.mjs +100 -0
  63. package/builder/style-states.test.mjs +103 -0
  64. package/builder/vite-assets.mjs +53 -0
  65. package/builder/vite-project.mjs +10 -0
  66. package/config.ts +59 -0
  67. package/eslint.mjs +74 -0
  68. package/form/index.ts +526 -0
  69. package/form/package.json +13 -0
  70. package/motion/index.ts +2 -0
  71. package/motion/package.json +10 -0
  72. package/package.json +26 -4
  73. package/router/index.ts +50 -0
  74. package/router/navigation.ts +22 -0
  75. package/router/package.json +12 -0
  76. package/router/router-view.ts +134 -0
  77. package/router/routes.ts +64 -0
  78. package/scripts/addon-build.mjs +364 -0
  79. package/scripts/addon-project.mjs +78 -0
  80. package/scripts/kumi-cli.mjs +105 -0
  81. package/scripts/link-addons.mjs +61 -0
  82. package/src/bindings.ts +35 -0
  83. package/src/context.ts +15 -0
  84. package/src/css-tokens.ts +239 -0
  85. package/src/css-v1.ts +68 -0
  86. package/src/cvars.ts +91 -0
  87. package/src/element-node.ts +32 -0
  88. package/src/elements.ts +505 -0
  89. package/src/feature-scope.ts +82 -0
  90. package/src/flex-layout.ts +807 -0
  91. package/src/frame-scheduler.ts +336 -0
  92. package/src/grid-tracks.ts +165 -0
  93. package/src/image-imports.d.ts +24 -0
  94. package/src/images.ts +79 -0
  95. package/src/index.ts +29 -0
  96. package/src/jsx-dev-runtime.ts +2 -0
  97. package/src/jsx-runtime.ts +29 -0
  98. package/src/jsx.d.ts +12 -0
  99. package/src/keyed-list.ts +366 -0
  100. package/src/media-query.ts +144 -0
  101. package/src/module-ui.ts +147 -0
  102. package/src/module.ts +311 -0
  103. package/src/node-selectors.ts +114 -0
  104. package/src/owned-collections.ts +52 -0
  105. package/src/providers.ts +241 -0
  106. package/src/reactive-scope.ts +34 -0
  107. package/src/reactivity.ts +275 -0
  108. package/src/result.ts +64 -0
  109. package/src/runtime.ts +52 -0
  110. package/src/scheduler.ts +185 -0
  111. package/src/signal-kernel.ts +63 -0
  112. package/src/style-classes.ts +51 -0
  113. package/src/style-states.ts +134 -0
  114. package/src/style-variables.ts +53 -0
  115. package/src/text-children.ts +42 -0
  116. package/src/theme.ts +50 -0
  117. package/src/transition.ts +18 -0
  118. package/state/index.ts +9 -0
  119. package/state/package.json +12 -0
  120. package/state/setup-store-persistence.ts +206 -0
  121. package/state/setup-store-view.ts +10 -0
  122. package/state/setup-store.ts +342 -0
  123. package/state/store-bindings.ts +25 -0
  124. package/state/store.ts +84 -0
  125. package/styles/_layers.scss +14 -0
  126. package/templates/addon/.agents/skills/kumi-build-debug/SKILL.md +36 -0
  127. package/templates/addon/.agents/skills/kumi-feature/SKILL.md +50 -0
  128. package/templates/addon/.agents/skills/kumi-plugin/SKILL.md +36 -0
  129. package/templates/addon/.agents/skills/kumi-store/SKILL.md +47 -0
  130. package/templates/addon/.agents/skills/kumi-ui/SKILL.md +73 -0
  131. package/templates/addon/.agents/skills/kumi-wow-api/SKILL.md +30 -0
  132. package/templates/addon/.claude/skills/kumi-build-debug/SKILL.md +36 -0
  133. package/templates/addon/.claude/skills/kumi-feature/SKILL.md +50 -0
  134. package/templates/addon/.claude/skills/kumi-plugin/SKILL.md +36 -0
  135. package/templates/addon/.claude/skills/kumi-store/SKILL.md +47 -0
  136. package/templates/addon/.claude/skills/kumi-ui/SKILL.md +73 -0
  137. package/templates/addon/.claude/skills/kumi-wow-api/SKILL.md +30 -0
  138. package/templates/addon/AGENTS.md +34 -0
  139. package/templates/addon/Assets/Art/Corner10.tga +0 -0
  140. package/templates/addon/Assets/Art/Corner11.tga +0 -0
  141. package/templates/addon/Assets/Art/Corner12.tga +0 -0
  142. package/templates/addon/Assets/Art/Corner13.tga +0 -0
  143. package/templates/addon/Assets/Art/Corner14.tga +0 -0
  144. package/templates/addon/Assets/Art/Corner15.tga +0 -0
  145. package/templates/addon/Assets/Art/Corner16.tga +0 -0
  146. package/templates/addon/Assets/Art/Corner2.tga +0 -0
  147. package/templates/addon/Assets/Art/Corner3.tga +0 -0
  148. package/templates/addon/Assets/Art/Corner4.tga +0 -0
  149. package/templates/addon/Assets/Art/Corner5.tga +0 -0
  150. package/templates/addon/Assets/Art/Corner6.tga +0 -0
  151. package/templates/addon/Assets/Art/Corner7.tga +0 -0
  152. package/templates/addon/Assets/Art/Corner8.tga +0 -0
  153. package/templates/addon/Assets/Art/Corner9.tga +0 -0
  154. package/templates/addon/Assets/Art/Dot.tga +0 -0
  155. package/templates/addon/Assets/Art/Gear.tga +0 -0
  156. package/templates/addon/Assets/Art/Grip.tga +0 -0
  157. package/templates/addon/Assets/Art/Outline10.tga +0 -0
  158. package/templates/addon/Assets/Art/Outline12.tga +0 -0
  159. package/templates/addon/Assets/Art/Outline13.tga +0 -0
  160. package/templates/addon/Assets/Art/Outline14.tga +0 -0
  161. package/templates/addon/Assets/Art/Outline15.tga +0 -0
  162. package/templates/addon/Assets/Art/Outline2.tga +0 -0
  163. package/templates/addon/Assets/Art/Outline3.tga +0 -0
  164. package/templates/addon/Assets/Art/Outline5.tga +0 -0
  165. package/templates/addon/Assets/Art/Outline7.tga +0 -0
  166. package/templates/addon/Assets/Art/Outline9.tga +0 -0
  167. package/templates/addon/Assets/Art/Round11.tga +0 -0
  168. package/templates/addon/Assets/Art/Round11Border.tga +0 -0
  169. package/templates/addon/Assets/Art/Round4.tga +0 -0
  170. package/templates/addon/Assets/Art/Round4Border.tga +0 -0
  171. package/templates/addon/Assets/Art/Round6.tga +0 -0
  172. package/templates/addon/Assets/Art/Round6Border.tga +0 -0
  173. package/templates/addon/Assets/Art/Round8.tga +0 -0
  174. package/templates/addon/Assets/Art/Round8Border.tga +0 -0
  175. package/templates/addon/Assets/Art/Search.tga +0 -0
  176. package/templates/addon/CLAUDE.md +1 -0
  177. package/templates/addon/README.md +49 -0
  178. package/templates/addon/eslint.config.mjs +6 -0
  179. package/templates/addon/gitignore +9 -0
  180. package/templates/addon/kumi.config.ts +17 -0
  181. package/templates/addon/package.json +20 -0
  182. package/templates/addon/src/app/app.module.ts +18 -0
  183. package/templates/addon/src/app/commands.store.ts +11 -0
  184. package/templates/addon/src/app/layout/AppWindow.module.scss +92 -0
  185. package/templates/addon/src/app/layout/AppWindow.tsx +32 -0
  186. package/templates/addon/src/app/main.ts +5 -0
  187. package/templates/addon/src/app/routes/(window)/home/page.tsx +8 -0
  188. package/templates/addon/src/app/routes/(window)/plugins/page.tsx +38 -0
  189. package/templates/addon/src/app/routes/(window)/settings/page.tsx +8 -0
  190. package/templates/addon/src/app/theme.ts +6 -0
  191. package/templates/addon/src/modules/greeting/api/player.api.ts +29 -0
  192. package/templates/addon/src/modules/greeting/greeting.module.ts +18 -0
  193. package/templates/addon/src/modules/greeting/model/greeting.store.ts +81 -0
  194. package/templates/addon/src/modules/greeting/services/greeting.service.ts +38 -0
  195. package/templates/addon/src/modules/greeting/ui/Greeting.module.scss +105 -0
  196. package/templates/addon/src/modules/greeting/ui/GreetingCard.tsx +29 -0
  197. package/templates/addon/src/modules/greeting/widgets/GreetingHud.tsx +54 -0
  198. package/templates/addon/src/modules/greeting/widgets/GreetingOverview.tsx +18 -0
  199. package/templates/addon/src/modules/greeting/widgets/GreetingSettings.tsx +56 -0
  200. package/templates/addon/src/modules/playtime/api/clock.api.ts +6 -0
  201. package/templates/addon/src/modules/playtime/model/playtime.store.ts +19 -0
  202. package/templates/addon/src/modules/playtime/playtime.module.ts +18 -0
  203. package/templates/addon/src/modules/playtime/services/playtime.service.ts +18 -0
  204. package/templates/addon/src/modules/playtime/ui/Playtime.module.scss +25 -0
  205. package/templates/addon/src/modules/playtime/ui/PlaytimeBadge.tsx +10 -0
  206. package/templates/addon/src/modules/playtime/widgets/PlaytimePage.tsx +16 -0
  207. package/templates/addon/src/shared/api/native-art.ts +28 -0
  208. package/templates/addon/src/shared/assets/close.png +0 -0
  209. package/templates/addon/src/shared/lib/format.ts +20 -0
  210. package/templates/addon/src/shared/styles/_tokens.scss +12 -0
  211. package/templates/addon/src/shared/ui/Button.tsx +29 -0
  212. package/templates/addon/src/shared/ui/Choice.tsx +34 -0
  213. package/templates/addon/src/shared/ui/Controls.module.scss +93 -0
  214. package/templates/addon/src/shared/ui/Glyph.tsx +18 -0
  215. package/templates/addon/src/shared/ui/Slider.tsx +25 -0
  216. package/templates/addon/src/shared/ui/Toggle.tsx +29 -0
  217. package/templates/addon/src/shared/ui/focus-ref.ts +7 -0
  218. package/templates/addon/src/shared/ui/range-skin.tsx +15 -0
  219. package/templates/addon/tsconfig.json +63 -0
  220. package/translate/index.ts +14 -0
  221. package/translate/package.json +9 -0
  222. package/utils/colors.ts +76 -0
  223. package/utils/format.ts +37 -0
  224. package/utils/index.ts +4 -0
  225. package/utils/number.ts +17 -0
  226. package/utils/package.json +7 -0
  227. package/utils/text.ts +6 -0
  228. package/validate/index.ts +119 -0
  229. package/validate/package.json +9 -0
  230. package/wow/absolute-position.ts +142 -0
  231. package/wow/action-bar-layout.ts +108 -0
  232. package/wow/action-button.ts +219 -0
  233. package/wow/action-catalog.ts +98 -0
  234. package/wow/addon-manifest.ts +36 -0
  235. package/wow/animation.ts +428 -0
  236. package/wow/app-ui.ts +221 -0
  237. package/wow/aura-button.ts +76 -0
  238. package/wow/aura-container.ts +591 -0
  239. package/wow/aura-countdown.ts +201 -0
  240. package/wow/aura-slot.ts +153 -0
  241. package/wow/bar-shade.ts +93 -0
  242. package/wow/borrowed-slot.ts +216 -0
  243. package/wow/button-drag.ts +48 -0
  244. package/wow/cast-clock.ts +153 -0
  245. package/wow/cast-text.ts +83 -0
  246. package/wow/class-colors.ts +126 -0
  247. package/wow/clock.ts +7 -0
  248. package/wow/color-picker.ts +128 -0
  249. package/wow/commands.ts +17 -0
  250. package/wow/contained-frame.ts +128 -0
  251. package/wow/contract.ts +42 -0
  252. package/wow/cooldown-timing.ts +24 -0
  253. package/wow/css-box.ts +144 -0
  254. package/wow/css-color.ts +12 -0
  255. package/wow/css-style.ts +109 -0
  256. package/wow/css-surfaces.ts +603 -0
  257. package/wow/css-text.ts +399 -0
  258. package/wow/cursor.ts +45 -0
  259. package/wow/cvar-schema.ts +32 -0
  260. package/wow/cvars.ts +98 -0
  261. package/wow/dropdown-art.ts +39 -0
  262. package/wow/element-click.ts +20 -0
  263. package/wow/element-event-coordinator.ts +219 -0
  264. package/wow/element-events.ts +317 -0
  265. package/wow/event-dispatcher.ts +151 -0
  266. package/wow/events.ts +50 -0
  267. package/wow/font-cache.ts +92 -0
  268. package/wow/frame-access.ts +53 -0
  269. package/wow/frame-layer.ts +5 -0
  270. package/wow/frame-timing.ts +13 -0
  271. package/wow/frames.ts +236 -0
  272. package/wow/heal-prediction.ts +305 -0
  273. package/wow/hooks.ts +133 -0
  274. package/wow/image-layers.ts +55 -0
  275. package/wow/index.ts +111 -0
  276. package/wow/layout-view.ts +663 -0
  277. package/wow/locale-font.ts +15 -0
  278. package/wow/lua-string.ts +18 -0
  279. package/wow/lua-table.ts +18 -0
  280. package/wow/macro-book.ts +84 -0
  281. package/wow/map-position.ts +27 -0
  282. package/wow/media-query.ts +65 -0
  283. package/wow/module-events.ts +11 -0
  284. package/wow/native-hooks.ts +168 -0
  285. package/wow/native-placement.ts +88 -0
  286. package/wow/native.ts +153 -0
  287. package/wow/number-format.ts +8 -0
  288. package/wow/number-input.ts +10 -0
  289. package/wow/panel-host.ts +97 -0
  290. package/wow/pixel.ts +35 -0
  291. package/wow/plugins.ts +246 -0
  292. package/wow/protect.ts +48 -0
  293. package/wow/protected-layout.ts +133 -0
  294. package/wow/protected-view.ts +103 -0
  295. package/wow/range-art.ts +81 -0
  296. package/wow/readable-api.ts +120 -0
  297. package/wow/reparent-frame.ts +99 -0
  298. package/wow/rounded-texture.ts +183 -0
  299. package/wow/saved-variables.ts +109 -0
  300. package/wow/scroll-view.ts +64 -0
  301. package/wow/secret-ref.ts +14 -0
  302. package/wow/secure-bindings.ts +89 -0
  303. package/wow/secure-clicks.ts +432 -0
  304. package/wow/secure-snippet.ts +235 -0
  305. package/wow/secure-state.ts +130 -0
  306. package/wow/secure-target-visibility.ts +89 -0
  307. package/wow/secure-transaction.ts +331 -0
  308. package/wow/special-window.ts +269 -0
  309. package/wow/spell-cooldown.ts +36 -0
  310. package/wow/start-addon.ts +122 -0
  311. package/wow/state-paint.ts +256 -0
  312. package/wow/transition.ts +86 -0
  313. package/wow/unit-button.ts +39 -0
  314. package/wow/unit-cast.ts +92 -0
  315. package/wow/unit-health-text.ts +47 -0
  316. package/wow/view-nodes.ts +304 -0
  317. package/wow/view.ts +1864 -0
  318. package/wow/visible-frame-job.ts +34 -0
  319. package/wow/width-reserve.ts +108 -0
@@ -0,0 +1,93 @@
1
+ /** Delay JSX children of the imported Form component until its context is installed. */
2
+ export function transformJsxForm(ts, path, source) {
3
+ if (!path.endsWith(".tsx") || !source.includes("@kumi/form")) return;
4
+ const file = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
5
+ const forms = new Set();
6
+ const namespaces = new Set();
7
+
8
+ for (const statement of file.statements) {
9
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)
10
+ || statement.moduleSpecifier.text !== "@kumi/form" || statement.importClause?.isTypeOnly) continue;
11
+ const bindings = statement.importClause?.namedBindings;
12
+ if (!bindings) continue;
13
+ if (ts.isNamespaceImport(bindings)) namespaces.add(bindings.name.text);
14
+ if (ts.isNamedImports(bindings)) {
15
+ for (const binding of bindings.elements) {
16
+ if (!binding.isTypeOnly && (binding.propertyName ?? binding.name).text === "Form") forms.add(binding.name.text);
17
+ }
18
+ }
19
+ }
20
+ if (forms.size === 0 && namespaces.size === 0) return;
21
+
22
+ function isForm(tag) {
23
+ return ts.isIdentifier(tag) ? forms.has(tag.text)
24
+ : ts.isPropertyAccessExpression(tag) && ts.isIdentifier(tag.expression)
25
+ && namespaces.has(tag.expression.text) && tag.name.text === "Form";
26
+ }
27
+
28
+ function unwrap(expression) {
29
+ while (expression && ts.isParenthesizedExpression(expression)) expression = expression.expression;
30
+ return expression;
31
+ }
32
+
33
+ function isCallback(expression) {
34
+ return expression && (ts.isArrowFunction(expression) || ts.isFunctionExpression(expression));
35
+ }
36
+
37
+ function checkChildren(children) {
38
+ for (const child of children) {
39
+ const element = ts.isJsxExpression(child) ? unwrap(child.expression) : child;
40
+ if (isCallback(element)) {
41
+ const { line, character } = file.getLineAndCharacterOfPosition(element.getStart(file));
42
+ throw new Error(`${path}:${line + 1}:${character + 1}: Pass a Form render callback as its only child`);
43
+ }
44
+ if (element && ts.isJsxFragment(element)) checkChildren(element.children);
45
+ }
46
+ }
47
+
48
+ function checkReturnedFragment(expression) {
49
+ const fragment = unwrap(expression);
50
+ if (fragment && ts.isJsxFragment(fragment)) checkChildren(fragment.children);
51
+ }
52
+
53
+ function checkCallback(callback) {
54
+ if (ts.isBlock(callback.body)) {
55
+ for (const statement of callback.body.statements) {
56
+ if (ts.isReturnStatement(statement)) checkReturnedFragment(statement.expression);
57
+ }
58
+ } else {
59
+ checkReturnedFragment(callback.body);
60
+ }
61
+ }
62
+
63
+ const inserts = [];
64
+ function visit(node) {
65
+ if (ts.isJsxElement(node) && isForm(node.openingElement.tagName)) {
66
+ const children = node.children.filter(child => ts.isJsxText(child)
67
+ ? child.text.trim().length > 0 : !ts.isJsxExpression(child) || child.expression !== undefined);
68
+ const child = children.length === 1 && ts.isJsxExpression(children[0]) ? children[0].expression : undefined;
69
+ const legacy = node.openingElement.attributes.properties.some(prop => ts.isJsxAttribute(prop)
70
+ && ts.isIdentifier(prop.name) && prop.name.text === "form");
71
+ const callback = unwrap(child);
72
+ const renderProp = isCallback(callback) || legacy && child && ts.isIdentifier(child);
73
+ if (isCallback(callback)) checkCallback(callback);
74
+ else if (!renderProp) checkChildren(children);
75
+ if (children.length > 0 && !renderProp) {
76
+ const only = children.length === 1 ? children[0] : undefined;
77
+ const direct = only && (ts.isJsxElement(only) || ts.isJsxSelfClosingElement(only) || ts.isJsxFragment(only));
78
+ const start = direct ? "{() => " : "{() => <>";
79
+ const end = direct ? "}" : "</>}";
80
+ inserts.push([node.openingElement.end, start], [node.closingElement.getStart(file), end]);
81
+ }
82
+ }
83
+ ts.forEachChild(node, visit);
84
+ }
85
+ visit(file);
86
+ if (inserts.length === 0) return;
87
+
88
+ let output = source;
89
+ for (const [offset, text] of inserts.sort(([left], [right]) => right - left)) {
90
+ output = output.slice(0, offset) + text + output.slice(offset);
91
+ }
92
+ return output;
93
+ }
@@ -0,0 +1,48 @@
1
+ import assert from "node:assert/strict";
2
+ import { createRequire } from "node:module";
3
+ import { test } from "node:test";
4
+ import { transformJsxForm } from "./jsx-form.mjs";
5
+
6
+ const ts = createRequire(import.meta.url)("typescript");
7
+
8
+ function transform(jsx) {
9
+ return transformJsxForm(ts, "fixture.tsx", 'import { Form } from "@kumi/form";\n' + jsx);
10
+ }
11
+
12
+ test("keeps explicit render callbacks with a spread form controller", () => {
13
+ assert.equal(transform('<Form {...control}>{() => <Field />}</Form>'), undefined);
14
+ assert.equal(transform('<Form {...control}>{((function () { return <Field />; }))}</Form>'), undefined);
15
+ assert.equal(transform('<Form {...control}>{(() => <Field />)}</Form>'), undefined);
16
+ });
17
+
18
+ test("keeps legacy callbacks with an explicit form prop", () => {
19
+ assert.equal(transform('<Form form={control}>{render}</Form>'), undefined);
20
+ assert.equal(transform('<Form form={control}>{form => <Field form={form} />}</Form>'), undefined);
21
+ });
22
+
23
+ test("still delays direct JSX children inside nested forms", () => {
24
+ const result = transform('<Form {...outer}>{() => <Form {...inner}><Field /></Form>}</Form>');
25
+ assert.equal(result, 'import { Form } from "@kumi/form";\n'
26
+ + '<Form {...outer}>{() => <Form {...inner}>{() => <Field />}</Form>}</Form>');
27
+ assert.equal(transform('<Form {...control}>{node}</Form>'),
28
+ 'import { Form } from "@kumi/form";\n<Form {...control}>{() => <>{node}</>}</Form>');
29
+ });
30
+
31
+ test("reports the original function position in a Form callback's returned fragment", () => {
32
+ const child = "() => <Field />";
33
+ for (const jsx of [
34
+ '<Form {...control}>{() => <>{' + child + '}</>}</Form>',
35
+ '<Form {...control}>{function () { return (<>{(' + child + ')}</>); }}</Form>',
36
+ '<Form {...control}><Note />{' + child + '}</Form>',
37
+ ]) {
38
+ assert.throws(() => transform(jsx), {
39
+ message: "fixture.tsx:2:" + (jsx.indexOf(child) + 1) + ": Pass a Form render callback as its only child",
40
+ });
41
+ }
42
+ });
43
+
44
+ test("leaves reactive children and callbacks of nested components alone", () => {
45
+ assert.equal(transform(
46
+ '<Form {...control}>{() => <><Widget onChange={() => apply()}>{() => <Field />}</Widget>{ref}</>}</Form>',
47
+ ), undefined);
48
+ });
@@ -0,0 +1,209 @@
1
+ import { transformJsxForm } from "./jsx-form.mjs";
2
+
3
+ export function transformJsx(ts, path, source) {
4
+ const form = transformJsxForm(ts, path, source);
5
+ return transformJsxLists(ts, path, form ?? source) ?? form;
6
+ }
7
+
8
+ function unwrap(ts, expression) {
9
+ while (expression && ts.isParenthesizedExpression(expression)) expression = expression.expression;
10
+ return expression;
11
+ }
12
+
13
+ export function getReactiveMap(ts, node) {
14
+ if (!ts.isJsxExpression(node) || !(ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent))) return;
15
+ const call = unwrap(ts, node.expression);
16
+ if (!call || !ts.isCallExpression(call) || ts.isOptionalChain(call)) return;
17
+ const member = call.expression;
18
+ if (!ts.isPropertyAccessExpression(member) || member.name.text !== "map") return;
19
+ const array = member.expression;
20
+ const receiver = unwrap(ts, array);
21
+ if (ts.isOptionalChain(receiver)) return;
22
+ const ref = ts.isPropertyAccessExpression(receiver) && receiver.name.text === "value";
23
+ if (ref || ts.isCallExpression(receiver)) return { call, array };
24
+ }
25
+
26
+ function isJsx(ts, node) {
27
+ return ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node);
28
+ }
29
+
30
+ function containsJsx(ts, node) {
31
+ return isJsx(ts, node) || ts.forEachChild(node, child => containsJsx(ts, child));
32
+ }
33
+
34
+ function addBindings(ts, binding, names) {
35
+ if (ts.isIdentifier(binding)) {
36
+ names.add(binding.text);
37
+ return;
38
+ }
39
+ for (const element of binding.elements) if (ts.isBindingElement(element)) addBindings(ts, element.name, names);
40
+ }
41
+
42
+ function returnedRow(ts, body, locals) {
43
+ if (!ts.isBlock(body)) return unwrap(ts, body);
44
+
45
+ const returns = [];
46
+ function visit(node) {
47
+ if (ts.isReturnStatement(node)) {
48
+ returns.push(node);
49
+ return;
50
+ }
51
+ if (ts.isVariableDeclarationList(node) && !(node.flags & ts.NodeFlags.BlockScoped)) {
52
+ for (const declaration of node.declarations) addBindings(ts, declaration.name, locals);
53
+ }
54
+ if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) ts.forEachChild(node, visit);
55
+ }
56
+ ts.forEachChild(body, visit);
57
+
58
+ if (returns.length !== 1 || returns[0].parent !== body) return;
59
+ for (const statement of body.statements) {
60
+ if (ts.isVariableStatement(statement)) {
61
+ for (const declaration of statement.declarationList.declarations) addBindings(ts, declaration.name, locals);
62
+ } else if (statement.name && ts.isIdentifier(statement.name)) {
63
+ locals.add(statement.name.text);
64
+ }
65
+ }
66
+ return unwrap(ts, returns[0].expression);
67
+ }
68
+
69
+ function refersToLocal(ts, node, locals) {
70
+ if (ts.isIdentifier(node) && locals.has(node.text)) {
71
+ const parent = node.parent;
72
+ if (!((ts.isPropertyAccessExpression(parent) || ts.isPropertyAssignment(parent)) && parent.name === node)) return true;
73
+ }
74
+ return ts.forEachChild(node, child => refersToLocal(ts, child, locals));
75
+ }
76
+
77
+ function canCopyParameter(ts, parameter) {
78
+ if (parameter.initializer || parameter.dotDotDotToken) return false;
79
+ return ts.isIdentifier(parameter.name) || parameter.name.elements.every(element => ts.isOmittedExpression(element)
80
+ || (!element.propertyName || !ts.isComputedPropertyName(element.propertyName)) && canCopyParameter(ts, element));
81
+ }
82
+
83
+ function extractRow(ts, file, call, report) {
84
+ const original = call.arguments[0];
85
+ const callback = unwrap(ts, original);
86
+ if (!callback || !(ts.isArrowFunction(callback) || ts.isFunctionExpression(callback))) return;
87
+
88
+ const locals = new Set();
89
+ const row = returnedRow(ts, callback.body, locals);
90
+ if (!row || !(ts.isJsxElement(row) || ts.isJsxSelfClosingElement(row))) {
91
+ if (containsJsx(ts, callback.body)) report(callback.body, "Return one JSX element with an explicit key directly from the reactive map callback");
92
+ return;
93
+ }
94
+ if (!ts.isArrowFunction(callback) || call.arguments.length !== 1 || callback.modifiers?.length
95
+ || callback.typeParameters?.length || callback.parameters.length > 2 || !callback.parameters.every(param => canCopyParameter(ts, param))) {
96
+ report(callback, "Use an arrow callback with item and optional index parameters that returns the keyed JSX row directly");
97
+ }
98
+
99
+ const opening = ts.isJsxElement(row) ? row.openingElement : row;
100
+ const attributes = opening.attributes.properties;
101
+ const keys = attributes.filter(attr => ts.isJsxAttribute(attr) && ts.isIdentifier(attr.name) && attr.name.text === "key");
102
+ if (keys.length !== 1 || attributes.slice(attributes.indexOf(keys[0]) + 1).some(ts.isJsxSpreadAttribute)) {
103
+ report(opening, "Give the reactive map row one explicit key after any spread attributes");
104
+ }
105
+ const initializer = keys[0].initializer;
106
+ if (!initializer) report(keys[0], "Give the reactive map row a string or numeric key");
107
+
108
+ let key;
109
+ if (ts.isStringLiteral(initializer) && !initializer.text.includes("&")) {
110
+ key = JSON.stringify(initializer.text);
111
+ } else if (ts.isJsxExpression(initializer) && initializer.expression && !containsJsx(ts, initializer.expression)) {
112
+ if (locals.size && refersToLocal(ts, initializer.expression, locals)) {
113
+ report(initializer, "Derive the reactive map key from its parameters or the enclosing scope");
114
+ }
115
+ key = initializer.expression.getText(file);
116
+ } else {
117
+ report(initializer, "Use a string or numeric expression for the reactive map key");
118
+ }
119
+ return { original, callback, initializer, key };
120
+ }
121
+
122
+ /** Defer direct reactive JSX map children to the mounted list. */
123
+ export function transformJsxLists(ts, path, source) {
124
+ if (!path.endsWith(".tsx") || !source.includes("map")) return;
125
+ const file = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
126
+ const maps = [];
127
+ const names = new Set();
128
+
129
+ function visit(node) {
130
+ if (ts.isIdentifier(node)) names.add(node.text);
131
+ const mapping = getReactiveMap(ts, node);
132
+ if (mapping) maps.push(mapping);
133
+ ts.forEachChild(node, visit);
134
+ }
135
+ visit(file);
136
+ if (maps.length === 0) return;
137
+
138
+ function uniqueName(name) {
139
+ while (names.has(name)) name += "_";
140
+ names.add(name);
141
+ return name;
142
+ }
143
+
144
+ function report(node, message) {
145
+ const { line, character } = file.getLineAndCharacterOfPosition(node.getStart(file));
146
+ throw new Error(`${path}:${line + 1}:${character + 1}: ${message}`);
147
+ }
148
+
149
+ const map = uniqueName("__kumiJsxMap");
150
+ const list = uniqueName("__kumiJsxList");
151
+ const item = uniqueName("__kumiItem");
152
+ const index = uniqueName("__kumiIndex");
153
+ const key = uniqueName("__kumiKey");
154
+ const edits = [];
155
+ let hasMap = false;
156
+ let hasList = false;
157
+
158
+ function insert(offset, text) {
159
+ edits.push([offset, offset, text]);
160
+ }
161
+
162
+ for (const { call, array } of maps) {
163
+ const row = extractRow(ts, file, call, report);
164
+ if (!row) {
165
+ hasList = true;
166
+ insert(call.getStart(file), list + "(() => ");
167
+ insert(call.end, ")");
168
+ continue;
169
+ }
170
+
171
+ hasMap = true;
172
+ const { original, callback, initializer } = row;
173
+ const params = callback.parameters;
174
+ const usesIndex = params.length === 2;
175
+ // Edit around the original receiver and render body so nested list edits keep their source offsets.
176
+ insert(call.getStart(file), map + "(() => (");
177
+ edits.push([array.end, original.getStart(file), `), (${params.map(param => param.getText(file)).join(", ")}) => (${row.key}), `]);
178
+ edits.push([initializer.getStart(file), initializer.end, `{${key}}`]);
179
+ insert(original.end, `, ${usesIndex}`);
180
+
181
+ const extra = [item, index, key].slice(params.length).join(", ");
182
+ if (callback.getFirstToken(file).kind === ts.SyntaxKind.OpenParenToken) {
183
+ const separator = params.length && !params.hasTrailingComma ? ", " : "";
184
+ insert(params.end, separator + extra);
185
+ } else {
186
+ insert(params[0].getStart(file), "(");
187
+ insert(params.end, `, ${extra})`);
188
+ }
189
+ }
190
+
191
+ let output = source;
192
+ for (const [start, end, replacement] of edits.sort(([left], [right]) => right - left)) {
193
+ output = output.slice(0, start) + replacement + output.slice(end);
194
+ }
195
+ const imports = [];
196
+ if (hasMap) imports.push(`jsxMap as ${map}`);
197
+ if (hasList) imports.push(`jsxList as ${list}`);
198
+ return output + `\nimport { ${imports.join(", ")} } from "@kumi/core";\n`;
199
+ }
200
+
201
+ export function viteJsxLists(ts) {
202
+ return {
203
+ name: "kumi-jsx-lists",
204
+ enforce: "pre",
205
+ transform(source, id) {
206
+ return transformJsx(ts, id.split("?", 1)[0], source);
207
+ },
208
+ };
209
+ }
@@ -0,0 +1,127 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFile } from "node:fs/promises";
3
+ import { writeGeneratedText } from "./generated-output.mjs";
4
+
5
+ const magic = Buffer.from("kumi-addon-fragments-1\n");
6
+
7
+ function readFragment(path, packet) {
8
+ let offset = magic.length;
9
+ function field() {
10
+ if (offset + 4 > packet.length) throw new Error(`Truncated native fragment: ${path}`);
11
+ const size = packet.readUInt32LE(offset);
12
+ offset += 4;
13
+ const end = offset + size;
14
+ if (end > packet.length) throw new Error(`Truncated native fragment: ${path}`);
15
+ const value = packet.subarray(offset, end);
16
+ offset = end;
17
+ return value;
18
+ }
19
+ if (!packet.subarray(0, offset).equals(magic)) throw new Error(`Unknown native fragment version: ${path}`);
20
+ const header = field();
21
+ const prelude = field();
22
+ const footer = field();
23
+ const modules = [];
24
+ while (offset < packet.length) {
25
+ const key = field().toString();
26
+ const fingerprint = field().toString();
27
+ modules.push({ key, fingerprint, prefix: field(), factory: field(), suffix: field() });
28
+ }
29
+ if (!modules.length) throw new Error(`Empty native fragment: ${path}`);
30
+ return { header, prelude, footer, modules };
31
+ }
32
+
33
+ // Fragment keys use the Rust backend's Lua string encoding.
34
+ function moduleKeyLiteral(key) {
35
+ let literal = '"';
36
+ for (const character of key) {
37
+ const code = character.codePointAt(0);
38
+ if (code < 32 || code === 127) literal += "\\" + String(code).padStart(3, "0");
39
+ else if (character === '"' || character === "\\") literal += "\\" + character;
40
+ else literal += character;
41
+ }
42
+ return literal + '"';
43
+ }
44
+
45
+ async function publish(path, parts, check) {
46
+ const source = Buffer.concat(parts.map(part => typeof part === "string" ? Buffer.from(part) : part));
47
+ if (check) {
48
+ if (!source.equals(await readFile(path))) throw new Error(`${path} is stale; link the native package again`);
49
+ } else await writeGeneratedText(path, source.toString());
50
+ return source.length;
51
+ }
52
+
53
+ /** Link opaque Rust codegen fragments. The entry order is fixed by the package manifest. */
54
+ export async function linkAddonPackage(entries, output, check = false, autoStamp) {
55
+ if (!entries.length) throw new Error("A native package requires at least one entry");
56
+ const chunks = [];
57
+ const candidates = new Map();
58
+ let prelude;
59
+ const digest = autoStamp === undefined ? undefined : createHash("sha256");
60
+ for (const { fragment, lua, lazyModule, ownedFolder, name, pluginId } of entries) {
61
+ const packet = await readFile(fragment);
62
+ digest?.update(packet);
63
+ const chunk = readFragment(fragment, packet);
64
+ prelude ??= chunk.prelude;
65
+ if (!prelude.equals(chunk.prelude)) throw new Error(`Mixed native package build stamps: ${fragment}`);
66
+ for (const module of chunk.modules) {
67
+ const hash = createHash("sha256").update(module.factory).digest("hex");
68
+ const id = `${module.key}\0${module.fingerprint}\0${hash}`;
69
+ let other = candidates.get(id);
70
+ if (other) {
71
+ if (!other.factory.equals(module.factory)) throw new Error(`Native factory hash collision for ${module.key}`);
72
+ other.count++;
73
+ } else {
74
+ other = { factory: module.factory, count: 1 };
75
+ candidates.set(id, other);
76
+ }
77
+ module.shared = other;
78
+ }
79
+ chunks.push({ lua, lazyModule, ownedFolder, name, pluginId, ...chunk });
80
+ }
81
+ for (const owner of chunks) {
82
+ if (owner.lazyModule === undefined) continue;
83
+ const key = moduleKeyLiteral(owner.lazyModule);
84
+ if (!owner.modules.some(module => module.key === key)) {
85
+ throw new Error("Missing plugin module " + owner.lazyModule + " in " + (owner.name ?? owner.lua));
86
+ }
87
+ // Every file in a plugin's folder belongs to that plugin. Another chunk must not bundle any of them.
88
+ const folder = owner.ownedFolder === undefined ? undefined : moduleKeyLiteral(owner.ownedFolder).slice(0, -1);
89
+ for (const other of chunks) {
90
+ if (other === owner) continue;
91
+ const leaked = other.modules.find(module => module.key === key || folder !== undefined && module.key.startsWith(folder));
92
+ if (leaked === undefined) continue;
93
+ const file = leaked.key.slice(1, -1).replace(/^addon\//u, "");
94
+ const plugin = owner.pluginId === undefined ? owner.lazyModule : "plugin " + owner.pluginId;
95
+ throw new Error(file + " belongs to " + plugin + ", but " + (other.name ?? other.lua) + " imports it. "
96
+ + "Use `import type` for the plugin's types, or move shared code into a core module.");
97
+ }
98
+ }
99
+ const stamp = digest?.digest("hex");
100
+ function stampHeader(header) {
101
+ if (stamp === undefined) return header;
102
+ const source = header.toString();
103
+ const before = "local nativeBuild = " + JSON.stringify(autoStamp) + "\n";
104
+ if (!source.includes(before)) throw new Error("The native linked header is missing its build stamp");
105
+ return source.replace(before, "local nativeBuild = " + JSON.stringify(stamp) + "\n");
106
+ }
107
+ let shared = 0;
108
+ let duplicateBytes = 0;
109
+ const pool = [stampHeader(prelude)];
110
+ for (const candidate of candidates.values()) {
111
+ if (candidate.count < 2) continue;
112
+ candidate.slot = ++shared;
113
+ duplicateBytes += (candidate.count - 1) * candidate.factory.length;
114
+ pool.push(`definitions[${candidate.slot}] = `, candidate.factory, "\n");
115
+ }
116
+ pool.push("nativeRegistry.definitions = definitions\n");
117
+ let bytes = await publish(output, pool, check);
118
+ for (const chunk of chunks) {
119
+ const parts = [stampHeader(chunk.header)];
120
+ for (const { prefix, shared, factory, suffix } of chunk.modules) {
121
+ parts.push(prefix, shared.slot ? `nativeDefinitions[${shared.slot}]` : factory, suffix);
122
+ }
123
+ parts.push(chunk.footer);
124
+ bytes += await publish(chunk.lua, parts, check);
125
+ }
126
+ return { shared, duplicateBytes, bytes };
127
+ }
@@ -0,0 +1,74 @@
1
+ import { execFile } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import { realpathSync } from "node:fs";
4
+ import { readFile } from "node:fs/promises";
5
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
+ import { promisify } from "node:util";
7
+
8
+ const run = promisify(execFile);
9
+ const imageExtension = /\.(?:png|jpe?g|webp|tga)$/;
10
+ const textureDirectory = "KumiGenerated/Assets";
11
+
12
+ export async function prepareLuaImages({ ts, program, workspace, output, module, texturePath, pack, check, writeOutput }) {
13
+ if (typeof texturePath !== "string" || !/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(texturePath)) {
14
+ throw new Error("Expected a Lua texture path resolver name");
15
+ }
16
+ const root = realpathSync(workspace);
17
+ const paths = new Map();
18
+ const imports = new Map();
19
+ const files = new Set();
20
+ const key = (specifier, owner) => resolve(owner) + "\0" + specifier;
21
+
22
+ async function prepare(path) {
23
+ const data = await readFile(path);
24
+ const hash = createHash("sha256").update(data).digest("hex");
25
+ const texture = `${textureDirectory}/${hash}.tga`;
26
+ const filename = join(output, "asset-modules", module, hash + ".lua");
27
+ const target = join(output, "lua", texture);
28
+ const conversion = run(pack, ["image", "-", "--image-output", target,
29
+ ...(path.endsWith(".tga") ? ["--image-input-tga"] : []), ...(check ? ["--check"] : [])],
30
+ { windowsHide: true });
31
+ conversion.child.stdin.on("error", () => {});
32
+ conversion.child.stdin.end(data);
33
+ const { stdout } = await conversion;
34
+ const [width, height, textureWidth, textureHeight] = stdout.trim().split(/\s+/).map(Number);
35
+ if (![width, height, textureWidth, textureHeight].every(value => Number.isInteger(value) && value > 0)) {
36
+ throw new Error("kumi-pack returned invalid texture dimensions");
37
+ }
38
+ const relativePath = JSON.stringify(texture.replaceAll("/", "\\"));
39
+ const descriptor = `{path=${texturePath}(${relativePath}),width=${width},height=${height},uMax=${width / textureWidth},vMax=${height / textureHeight}}`;
40
+ await writeOutput(filename, `return {default=${descriptor}}\n`);
41
+ files.add(texture);
42
+ return filename;
43
+ }
44
+
45
+ for (const source of program.getSourceFiles()) {
46
+ if (source.isDeclarationFile) continue;
47
+ for (const statement of source.statements) {
48
+ if (!ts.isImportDeclaration(statement) && !ts.isExportDeclaration(statement)) continue;
49
+ const name = statement.moduleSpecifier;
50
+ if (!name || !ts.isStringLiteral(name) || !imageExtension.test(name.text)) continue;
51
+ if ((ts.isImportDeclaration(statement) && statement.importClause?.isTypeOnly)
52
+ || (ts.isExportDeclaration(statement) && statement.isTypeOnly)) continue;
53
+ try {
54
+ if (!name.text.startsWith("./") && !name.text.startsWith("../")) {
55
+ throw new Error("Image imports must use a path relative to their source file");
56
+ }
57
+ const path = realpathSync(resolve(dirname(source.fileName), name.text));
58
+ const local = relative(root, path);
59
+ if (isAbsolute(local) || local === ".." || local.startsWith(".." + sep)) {
60
+ throw new Error("Image imports must stay inside the project workspace");
61
+ }
62
+ if (!paths.has(path)) paths.set(path, await prepare(path));
63
+ imports.set(key(name.text, source.fileName), paths.get(path));
64
+ } catch (error) {
65
+ const { line, character } = source.getLineAndCharacterOfPosition(name.getStart(source));
66
+ throw new Error(`${source.fileName}:${line + 1}:${character + 1}: ${name.text}: ${error.message}`, { cause: error });
67
+ }
68
+ }
69
+ }
70
+ return {
71
+ plugin: { moduleResolution: (name, owner) => imports.get(key(name, owner)) },
72
+ writeManifest: () => writeOutput(join(output, "assets", module + ".json"), JSON.stringify([...files].sort()) + "\n"),
73
+ };
74
+ }
@@ -0,0 +1,57 @@
1
+ const builtins = new Set(["Boolean", "Number", "String"]);
2
+
3
+ function valueExpression(ts, reference) {
4
+ const parent = reference.parent;
5
+ if ((ts.isPropertyAccessExpression(parent) && parent.name === reference)
6
+ || (ts.isElementAccessExpression(parent) && parent.argumentExpression === reference && ts.isStringLiteralLike(reference))) {
7
+ return parent;
8
+ }
9
+ return ts.isIdentifier(reference) ? reference : undefined;
10
+ }
11
+
12
+ function isAllowedUse(ts, original, allowCall) {
13
+ let expression = original;
14
+ while (expression.parent && ts.skipOuterExpressions(expression.parent) === original) expression = expression.parent;
15
+
16
+ const parent = expression.parent;
17
+ return parent?.expression === expression && (
18
+ ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)
19
+ || allowCall && (ts.isCallExpression(parent) || ts.isNewExpression(parent))
20
+ );
21
+ }
22
+
23
+ function valueSymbol(ts, checker, reference) {
24
+ const parent = reference.parent;
25
+ if (ts.isBindingElement(parent) && !parent.dotDotDotToken && ts.isObjectBindingPattern(parent.parent)
26
+ && (parent.propertyName ?? parent.name) === reference) {
27
+ const input = checker.getTypeAtLocation(parent.parent);
28
+ return checker.getPropertyOfType(input, reference.text);
29
+ }
30
+
31
+ const expression = valueExpression(ts, reference);
32
+ if (!expression || isAllowedUse(ts, expression, reference.text !== "Boolean") || ts.isWriteOnlyAccess(expression)) return undefined;
33
+ return ts.isShorthandPropertyAssignment(parent) && parent.name === reference
34
+ ? checker.getShorthandAssignmentValueSymbol(parent)
35
+ : checker.getSymbolAtLocation(reference);
36
+ }
37
+
38
+ export function lintLuaBuiltinValues(ts, source, checker, report, program) {
39
+ if (source.isDeclarationFile) return;
40
+
41
+ function visit(node) {
42
+ if (ts.isTypeNode(node)) return;
43
+ if ((ts.isIdentifier(node) || ts.isStringLiteralLike(node)) && builtins.has(node.text)) {
44
+ const declaration = valueSymbol(ts, checker, node)?.valueDeclaration;
45
+ if (declaration && program.isSourceFileDefaultLibrary(declaration.getSourceFile())) {
46
+ const name = node.text;
47
+ const message = name === "Boolean"
48
+ ? "Lua does not support the global Boolean conversion. Use an explicit comparison suited to the value type."
49
+ : "Lua requires a direct " + name + "(...) call. For a callback, use value => " + name + "(value).";
50
+ report(node, message);
51
+ }
52
+ }
53
+ ts.forEachChild(node, visit);
54
+ }
55
+
56
+ visit(source);
57
+ }