@overmvp/kumi 0.0.0-stage → 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 (205) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -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 +334 -0
  13. package/builder/css-v1.test.mjs +321 -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 +86 -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 +444 -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 +2164 -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 +367 -0
  48. package/builder/src/native_ir.rs +65 -0
  49. package/builder/src/native_signal.rs +47 -0
  50. package/builder/src/numbers.lua +62 -0
  51. package/builder/src/project-front.mjs +3331 -0
  52. package/builder/src/records.lua +75 -0
  53. package/builder/src/routes.rs +127 -0
  54. package/builder/src/signal-kernel.fingerprint +1 -0
  55. package/builder/src/strings.lua +103 -0
  56. package/builder/src/ts-lower.mjs +68 -0
  57. package/builder/src/wow_client.rs +253 -0
  58. package/builder/src/wow_types.rs +564 -0
  59. package/builder/style-states.mjs +100 -0
  60. package/builder/style-states.test.mjs +103 -0
  61. package/builder/vite-assets.mjs +53 -0
  62. package/builder/vite-project.mjs +10 -0
  63. package/config.ts +17 -0
  64. package/form/index.ts +522 -0
  65. package/form/package.json +13 -0
  66. package/motion/index.ts +2 -0
  67. package/motion/package.json +10 -0
  68. package/package.json +22 -4
  69. package/router/index.ts +43 -0
  70. package/router/package.json +12 -0
  71. package/router/routes.ts +64 -0
  72. package/scripts/kumi-cli.mjs +70 -0
  73. package/scripts/link-addons.mjs +51 -0
  74. package/src/bindings.ts +35 -0
  75. package/src/context.ts +15 -0
  76. package/src/css-tokens.ts +234 -0
  77. package/src/css-v1.ts +58 -0
  78. package/src/cvars.ts +91 -0
  79. package/src/element-node.ts +32 -0
  80. package/src/elements.ts +479 -0
  81. package/src/feature-scope.ts +82 -0
  82. package/src/flex-layout.ts +807 -0
  83. package/src/frame-scheduler.ts +334 -0
  84. package/src/grid-tracks.ts +165 -0
  85. package/src/image-imports.d.ts +24 -0
  86. package/src/images.ts +79 -0
  87. package/src/index.ts +28 -0
  88. package/src/jsx-dev-runtime.ts +2 -0
  89. package/src/jsx-runtime.ts +22 -0
  90. package/src/jsx.d.ts +12 -0
  91. package/src/keyed-list.ts +363 -0
  92. package/src/media-query.ts +144 -0
  93. package/src/module.ts +277 -0
  94. package/src/node-selectors.ts +114 -0
  95. package/src/owned-collections.ts +44 -0
  96. package/src/providers.ts +235 -0
  97. package/src/reactive-scope.ts +34 -0
  98. package/src/reactivity.ts +254 -0
  99. package/src/result.ts +58 -0
  100. package/src/runtime.ts +52 -0
  101. package/src/scheduler.ts +185 -0
  102. package/src/signal-kernel.ts +30 -0
  103. package/src/style-classes.ts +51 -0
  104. package/src/style-states.ts +134 -0
  105. package/src/style-variables.ts +53 -0
  106. package/src/text-children.ts +42 -0
  107. package/src/theme.ts +50 -0
  108. package/src/transition.ts +18 -0
  109. package/state/index.ts +3 -0
  110. package/state/package.json +12 -0
  111. package/state/store-bindings.ts +25 -0
  112. package/state/store.ts +82 -0
  113. package/styles/_layers.scss +14 -0
  114. package/templates/addon/README.md +14 -0
  115. package/templates/addon/__ADDON_NAME__.toc +4 -0
  116. package/templates/addon/eslint.config.mjs +12 -0
  117. package/templates/addon/gitignore +8 -0
  118. package/templates/addon/package.json +21 -0
  119. package/templates/addon/scripts/build.mjs +25 -0
  120. package/templates/addon/src/app/main.tsx +13 -0
  121. package/templates/addon/tsconfig.json +24 -0
  122. package/translate/index.ts +14 -0
  123. package/translate/package.json +9 -0
  124. package/utils/colors.ts +76 -0
  125. package/utils/format.ts +37 -0
  126. package/utils/index.ts +4 -0
  127. package/utils/number.ts +17 -0
  128. package/utils/package.json +7 -0
  129. package/utils/text.ts +6 -0
  130. package/validate/index.ts +119 -0
  131. package/validate/package.json +9 -0
  132. package/wow/absolute-position.ts +142 -0
  133. package/wow/animation.ts +428 -0
  134. package/wow/aura-button.ts +76 -0
  135. package/wow/aura-container.ts +591 -0
  136. package/wow/aura-countdown.ts +201 -0
  137. package/wow/aura-slot.ts +153 -0
  138. package/wow/bar-shade.ts +93 -0
  139. package/wow/borrowed-slot.ts +216 -0
  140. package/wow/button-drag.ts +48 -0
  141. package/wow/cast-clock.ts +153 -0
  142. package/wow/cast-text.ts +83 -0
  143. package/wow/class-colors.ts +126 -0
  144. package/wow/clock.ts +7 -0
  145. package/wow/color-picker.ts +128 -0
  146. package/wow/commands.ts +17 -0
  147. package/wow/contained-frame.ts +128 -0
  148. package/wow/contract.ts +42 -0
  149. package/wow/css-box.ts +110 -0
  150. package/wow/css-color.ts +12 -0
  151. package/wow/css-style.ts +109 -0
  152. package/wow/css-surfaces.ts +398 -0
  153. package/wow/css-text.ts +399 -0
  154. package/wow/cvar-schema.ts +32 -0
  155. package/wow/cvars.ts +98 -0
  156. package/wow/dropdown-art.ts +39 -0
  157. package/wow/element-click.ts +20 -0
  158. package/wow/element-event-coordinator.ts +219 -0
  159. package/wow/element-events.ts +317 -0
  160. package/wow/event-dispatcher.ts +151 -0
  161. package/wow/events.ts +50 -0
  162. package/wow/font-cache.ts +92 -0
  163. package/wow/frame-access.ts +31 -0
  164. package/wow/frame-layer.ts +5 -0
  165. package/wow/frames.ts +236 -0
  166. package/wow/heal-prediction.ts +305 -0
  167. package/wow/image-layers.ts +55 -0
  168. package/wow/index.ts +97 -0
  169. package/wow/layout-view.ts +651 -0
  170. package/wow/lua-string.ts +18 -0
  171. package/wow/lua-table.ts +18 -0
  172. package/wow/macro-book.ts +84 -0
  173. package/wow/map-position.ts +27 -0
  174. package/wow/media-query.ts +65 -0
  175. package/wow/module-events.ts +11 -0
  176. package/wow/native-hooks.ts +168 -0
  177. package/wow/native-placement.ts +88 -0
  178. package/wow/native.ts +135 -0
  179. package/wow/number-format.ts +8 -0
  180. package/wow/number-input.ts +10 -0
  181. package/wow/protect.ts +24 -0
  182. package/wow/protected-layout.ts +133 -0
  183. package/wow/range-art.ts +74 -0
  184. package/wow/reparent-frame.ts +99 -0
  185. package/wow/rounded-texture.ts +156 -0
  186. package/wow/saved-variables.ts +60 -0
  187. package/wow/scroll-view.ts +64 -0
  188. package/wow/secret-ref.ts +14 -0
  189. package/wow/secure-bindings.ts +89 -0
  190. package/wow/secure-clicks.ts +432 -0
  191. package/wow/secure-snippet.ts +235 -0
  192. package/wow/secure-state.ts +130 -0
  193. package/wow/secure-target-visibility.ts +89 -0
  194. package/wow/secure-transaction.ts +331 -0
  195. package/wow/special-window.ts +269 -0
  196. package/wow/start-addon.ts +99 -0
  197. package/wow/state-paint.ts +256 -0
  198. package/wow/transition.ts +86 -0
  199. package/wow/unit-button.ts +39 -0
  200. package/wow/unit-cast.ts +92 -0
  201. package/wow/unit-health-text.ts +47 -0
  202. package/wow/view-nodes.ts +304 -0
  203. package/wow/view.ts +1746 -0
  204. package/wow/visible-frame-job.ts +34 -0
  205. package/wow/width-reserve.ts +108 -0
@@ -0,0 +1,321 @@
1
+ import assert from "node:assert/strict";
2
+ import { test } from "node:test";
3
+ import { compileCssDeclarations, cssFontWeights, cssRadii } from "./css-v1.mjs";
4
+
5
+ const compile = (pairs, options) => compileCssDeclarations(pairs.map(([prop, value]) => ({ prop, value })), options);
6
+ const single = (property, value, options) => compile([[property, value]], options);
7
+ const tokens = values => new Map(Object.entries(values));
8
+ const edges = ["top", "right", "bottom", "left"];
9
+
10
+ test("compiles ordered margin shorthands and individual sides into dense native insets", () => {
11
+ for (const [source, margin] of [
12
+ ["0", [0, 0, 0, 0]],
13
+ ["-1px", [-1, -1, -1, -1]],
14
+ ["2px -3px", [2, -3, 2, -3]],
15
+ ["-2px 3px 4px", [-2, 3, 4, 3]],
16
+ ["-2px 3px 4px 5px", [-2, 3, 4, 5]],
17
+ ]) assert.deepEqual(single("margin", source), { margin });
18
+ assert.deepEqual(compile([
19
+ ["margin-top", "8px"], ["margin", "-1px 2px"], ["margin-left", "-3px"],
20
+ ["margin-right", "6px"], ["margin-right", "4px"],
21
+ ]), { margin: [-1, 4, -1, -3] });
22
+ for (const [index, side] of edges.entries()) {
23
+ const margin = [0, 0, 0, 0];
24
+ margin[index] = -1.5;
25
+ assert.deepEqual(single("margin-" + side, "-1.5px"), { margin });
26
+ assert.throws(() => single("margin-" + side, "1px 2px"), /Invalid value for margin-/);
27
+ assert.throws(() => single("margin-" + side, "2%"), /Invalid value for margin-/);
28
+ }
29
+ for (const value of ["", "auto auto auto auto auto", "1 2px", "2rem", "1px, 2px", "1px 2px 3px 4px 5px"]) {
30
+ assert.throws(() => single("margin", value), /Invalid value for margin/, value);
31
+ }
32
+ });
33
+
34
+ test("validates minimum and maximum width and height, including reversed ranges", () => {
35
+ for (const [property, field] of [
36
+ ["min-width", "minWidth"], ["max-width", "maxWidth"], ["min-height", "minHeight"], ["max-height", "maxHeight"],
37
+ ]) {
38
+ assert.deepEqual(single(property, "0"), { [field]: 0 });
39
+ assert.deepEqual(single(property, "18.5px"), { [field]: 18.5 });
40
+ for (const value of ["-1px", "1", "auto", "1em", "1px 2px"]) {
41
+ assert.throws(() => single(property, value), /Invalid value for (min|max)-/, value);
42
+ }
43
+ }
44
+ assert.deepEqual(compile([["max-width", "4px"], ["min-width", "4px"], ["max-height", "0"], ["min-height", "0"]]), {
45
+ maxWidth: 4, minWidth: 4, maxHeight: 0, minHeight: 0,
46
+ });
47
+ assert.throws(() => compile([["max-width", "2px"], ["min-width", "4px"]]), /min-width \(4px\) exceeds max-width \(2px\)/);
48
+ assert.throws(() => compileCssDeclarations([
49
+ { prop: "min-height", value: "4px" },
50
+ { prop: "max-height", value: "2px", error: message => new SyntaxError("panel.css:7 " + message) },
51
+ ]), /^SyntaxError: panel\.css:7 min-height .* exceeds max-height/);
52
+ });
53
+
54
+ test("compiles absolute position, inset shorthand and the individual bounds in declaration order", () => {
55
+ assert.deepEqual(compile([
56
+ ["position", "absolute"], ["left", "9px"], ["inset", "1px -2px 3px"], ["top", "0"], ["left", "4px"],
57
+ ]), { position: "absolute", top: 0, right: -2, bottom: 3, left: 4 });
58
+ assert.deepEqual(single("inset", "0 1px 2px 3px"), { top: 0, right: 1, bottom: 2, left: 3 });
59
+ for (const side of edges) {
60
+ assert.deepEqual(single(side, "-0.25px"), { [side]: -0.25 });
61
+ assert.throws(() => single(side, "auto"), /Invalid value for/);
62
+ assert.throws(() => single(side, "1"), /Invalid value for/);
63
+ }
64
+ for (const position of ["static", "relative", "absolute"]) assert.deepEqual(single("position", position), { position });
65
+ assert.throws(() => single("position", "fixed"), /Invalid value for position/);
66
+ assert.throws(() => single("inset", "0 auto"), /Invalid value for inset/);
67
+ assert.throws(() => single("inset", "0 0 0 0 0"), /Invalid value for inset/);
68
+ });
69
+
70
+ test("compiles width and color for each border without losing declaration order", () => {
71
+ const flat = { width: 1, color: "#ffffff" };
72
+ assert.deepEqual(compile([
73
+ ["border-top", "6px #000000"], ["border", "solid #ffffff 1px"], ["border-bottom", "0 #aBC012"],
74
+ ["border-left", "#123456 3px solid"],
75
+ ]), { border: { top: flat, right: flat, bottom: { width: 0, color: "#aBC012" }, left: { width: 3, color: "#123456" } } });
76
+ for (const side of edges) {
77
+ assert.deepEqual(single("border-" + side, "1.5px #223344"), { border: { [side]: { width: 1.5, color: "#223344" } } });
78
+ assert.throws(() => single("border-" + side, "1px dotted #223344"), /Invalid value for border-/);
79
+ assert.throws(() => single("border-" + side, "#223344"), /Invalid value for border-/);
80
+ }
81
+ for (const value of [
82
+ "1px", "red 1px", "-1px #ffffff", "1px #123", "1px #123456 dashed", "1px solid #123456 solid",
83
+ "1px #aaaaaa #bbbbbb", "1px, #123456", "1px 2px #123456",
84
+ ]) assert.throws(() => single("border", value), /Invalid value for border/, value);
85
+ });
86
+
87
+ test("validates exact registered radii and permits an explicit host registry", () => {
88
+ assert.deepEqual(cssRadii, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12]);
89
+ for (const radius of cssRadii) assert.deepEqual(single("border-radius", radius + "px"), { borderRadius: radius });
90
+ assert.deepEqual(single("border-radius", "0"), { borderRadius: 0 });
91
+ for (const value of ["10px", "50%", "2.5px", "-2px", "2px 4px", "4px / 2px", "inherit"]) {
92
+ assert.throws(() => single("border-radius", value), /allowed radii: 0px, 1px,.*9px, 11px, 12px/, value);
93
+ }
94
+ assert.deepEqual(single("border-radius", "18px", { radii: new Set([0, 18]) }), { borderRadius: 18 });
95
+ assert.throws(() => single("border-radius", "2px", { radii: [0, 18] }), /allowed radii: 0px, 18px/);
96
+ });
97
+
98
+ test("accepts a single quoted local URL or atlas using the same grammar in base classes and states", () => {
99
+ for (const state of [false, true]) {
100
+ for (const [source, backgroundImage] of [
101
+ ['url("Interface/AddOns/Kumi/Textures/Tab Active.tga")', { path: "Interface/AddOns/Kumi/Textures/Tab Active.tga" }],
102
+ ["url( './textures/tab.blp' )", { path: "./textures/tab.blp" }],
103
+ ["atlas(UI-Panel_Active)", { atlas: "UI-Panel_Active" }],
104
+ ['atlas("UI-Panel_Active")', { atlas: "UI-Panel_Active" }],
105
+ ]) assert.deepEqual(single("background-image", source, { state }), { backgroundImage });
106
+ for (const value of [
107
+ 'url("https://example.com/tab.tga")', 'url("//example.com/tab.tga")', 'url("data:image/png;base64,ABC")',
108
+ 'url("file:///tab.tga")', 'url("C:/tab.tga")', 'url("/tab.tga")', 'url("../tab.tga")',
109
+ 'url("textures/../tab.tga")', 'url("textures/%2e%2e/tab.tga")', 'url("textures\\..\\tab.tga")',
110
+ 'url("textures//tab.tga")', 'url("tab.tga?query")', 'url("tab.tga#fragment")', 'url("tab.tga"), atlas(other)',
111
+ 'url("tab.tga") center', 'url("")', "url(tab.tga)", "atlas()", 'atlas("x/y")', 'atlas("x y")',
112
+ "linear-gradient(#123456, #ffffff)", "none",
113
+ ]) assert.throws(() => single("background-image", value, { state }), /Invalid value for background-image/, value);
114
+ }
115
+ });
116
+
117
+ test("validates typography properties and registered font weights", () => {
118
+ assert.deepEqual(compile([
119
+ ["font-size", "13.5px"], ["font-weight", "600"], ["text-align", "center"],
120
+ ["text-shadow", "1px -2px #123456"], ["text-transform", "uppercase"],
121
+ ["text-overflow", "ellipsis"], ["white-space", "nowrap"],
122
+ ]), {
123
+ fontSize: 13.5, fontWeight: 600, textAlign: "center", textShadow: { x: 1, y: -2, color: "#123456" },
124
+ textTransform: "uppercase", textOverflow: "ellipsis", whiteSpace: "nowrap",
125
+ });
126
+ for (const weight of cssFontWeights) assert.deepEqual(single("font-weight", String(weight)), { fontWeight: weight });
127
+ assert.deepEqual(single("font-weight", "normal"), { fontWeight: 400 });
128
+ assert.deepEqual(single("font-weight", "bold"), { fontWeight: 700 });
129
+ assert.deepEqual(single("font-weight", "500", { fontWeights: [400, 500] }), { fontWeight: 500 });
130
+ assert.deepEqual(single("text-shadow", "#abcDEF 0 0"), { textShadow: { x: 0, y: 0, color: "#abcDEF" } });
131
+ for (const textAlign of ["left", "center", "right"]) assert.deepEqual(single("text-align", textAlign), { textAlign });
132
+ for (const textTransform of ["none", "uppercase", "lowercase", "capitalize"]) {
133
+ assert.deepEqual(single("text-transform", textTransform), { textTransform });
134
+ }
135
+ for (const [prop, values] of Object.entries({
136
+ "font-size": ["0", "0px", "-1px", "14", "1rem", "auto"],
137
+ "font-weight": ["500", "boldest", "600px", "inherit", "0"],
138
+ "text-align": ["justify", "start", "center right"],
139
+ "text-shadow": ["1px #ffffff", "1px 2px 3px #ffffff", "1px 2px red", "1 0 #ffffff", "0 0 #ffffff, 0 0 #111111", "none"],
140
+ "text-transform": ["full-width", "uppercase lowercase"],
141
+ "text-overflow": ["clip", "default", "..."],
142
+ "white-space": ["normal", "pre", "nowrap pre"],
143
+ })) for (const value of values) assert.throws(() => single(prop, value), /Invalid value for/, prop + " " + value);
144
+ });
145
+
146
+ test("compiles block, inline and flex/grid display, none, wrapping and percent sizes; keeps overflow fixed at mount", () => {
147
+ for (const display of ["block", "inline", "inline-block", "flex", "grid", "none"]) assert.deepEqual(single("display", display), { display });
148
+ for (const overflow of ["hidden", "scroll"]) assert.deepEqual(single("overflow", overflow), { overflow });
149
+ for (const wrap of ["nowrap", "wrap"]) assert.deepEqual(single("flex-wrap", wrap), { flexWrap: wrap });
150
+ assert.deepEqual(single("width", "50%"), { width: "50%" });
151
+ assert.deepEqual(single("height", "12.5%"), { height: "12.5%" });
152
+ assert.throws(() => single("width", "-5%"), /Invalid value for width/);
153
+ assert.throws(() => single("display", "table"), /Invalid value for display/);
154
+ assert.throws(() => single("overflow", "auto"), /Invalid value for overflow/);
155
+ assert.throws(() => single("overflow", "hidden scroll"), /Invalid value for overflow/);
156
+ assert.throws(() => single("overflow", "hidden", { state: true }), /Unsupported property overflow in a style state/);
157
+ assert.throws(() => single("overflow", "hidden", { reactive: true }), /Overflow is fixed at mount/);
158
+ assert.deepEqual(single("overflow", "var(--over)", { tokens: tokens({ "--over": "scroll" }) }), { overflow: "scroll" });
159
+ for (const [prop, value] of [
160
+ ["position", "absolute"], ["margin", "0"], ["border", "1px #ffffff"], ["width", "5px"], ["font-size", "12px"],
161
+ ]) assert.throws(() => single(prop, value, { state: true }), /Unsupported property .* in a style state/);
162
+ });
163
+
164
+ test("compiles border-color as paint without changing border geometry", () => {
165
+ const options = { state: true, tokens: tokens({ "--ink": "#224466", "--width": "2px" }) };
166
+ assert.deepEqual(single("border-color", "#Aa2299", options), { borderColor: "#Aa2299" });
167
+ assert.deepEqual(single("border-color", "var(--ink)", options), {
168
+ borderColor: "#224466",
169
+ styleTokens: [{ path: ["borderColor"], token: "--ink", source: "#224466", kind: "color", fallback: "#224466" }],
170
+ });
171
+ assert.throws(() => single("border-color", "var(--width)", options), /Invalid value for border-color/);
172
+ assert.throws(() => single("border-color", "#112233 #445566", options), /Invalid value for border-color/);
173
+ assert.throws(() => single("border-left", "1px #112233", options), /Unsupported property border-left in a style state/);
174
+ });
175
+
176
+ test("emits typed native token recipes for inputs inside shorthands", () => {
177
+ const options = { tokens: tokens({ "--space": "5px", "--ink": "#224466", "--weight": "600", "--align": "left" }) };
178
+ assert.deepEqual(compile([
179
+ ["margin", "var(--space) 0 calc(var(--space) - 2px) 6px"],
180
+ ["margin-top", "1px"],
181
+ ["border-top", "calc(var(--space) - 4px) solid var(--ink)"],
182
+ ["text-shadow", "0 var(--space) var(--ink)"],
183
+ ["font-weight", "var(--weight)"],
184
+ ["text-align", "var(--align)"],
185
+ ["color", "var(--ink)"],
186
+ ], options), {
187
+ margin: [1, 0, 3, 6],
188
+ border: { top: { width: 1, color: "#224466" } },
189
+ textShadow: { x: 0, y: 5, color: "#224466" },
190
+ fontWeight: 600,
191
+ textAlign: "left",
192
+ color: "var(--ink, #224466)",
193
+ styleTokens: [
194
+ { path: ["margin", 2], token: "--space", source: "5px", kind: "signedLength", fallback: 3, add: -2 },
195
+ { path: ["border", "top", "width"], token: "--space", source: "5px", kind: "length", fallback: 1, add: -4 },
196
+ { path: ["border", "top", "color"], token: "--ink", source: "#224466", kind: "color", fallback: "#224466" },
197
+ { path: ["textShadow", "y"], token: "--space", source: "5px", kind: "signedLength", fallback: 5 },
198
+ { path: ["textShadow", "color"], token: "--ink", source: "#224466", kind: "color", fallback: "#224466" },
199
+ { path: ["fontWeight"], token: "--weight", source: "600", kind: "fontWeight", fallback: 600, values: [400, 600, 700] },
200
+ { path: ["textAlign"], token: "--align", source: "left", kind: "enum", fallback: "left", values: ["left", "center", "right"] },
201
+ ],
202
+ });
203
+ });
204
+
205
+ test("projects whole shorthand tokens and drops overwritten fields", () => {
206
+ const options = { tokens: tokens({
207
+ "--outside": "-1px 2px 3px", "--padding": "1px 2px", "--stroke": "0 solid #aabbcc", "--shadow": "#ffffff 0 -2px",
208
+ }) };
209
+ const { styleTokens, ...style } = compile([
210
+ ["margin", "var(--outside)"], ["margin-right", "7px"], ["inset", "var(--outside)"], ["right", "9px"],
211
+ ["padding", "var(--padding)"], ["border-left", "var(--stroke)"], ["text-shadow", "var(--shadow)"],
212
+ ], options);
213
+ assert.deepEqual(style, {
214
+ margin: [-1, 7, 3, 2], top: -1, right: 9, bottom: 3, left: 2, padding: [1, 2, 1, 2],
215
+ border: { left: { width: 0, color: "#aabbcc" } }, textShadow: { x: 0, y: -2, color: "#ffffff" },
216
+ });
217
+ assert.deepEqual(styleTokens, [
218
+ { path: ["margin", 0], token: "--outside", source: "-1px 2px 3px", kind: "margin", fallback: -1, part: 0 },
219
+ { path: ["margin", 2], token: "--outside", source: "-1px 2px 3px", kind: "margin", fallback: 3, part: 2 },
220
+ { path: ["margin", 3], token: "--outside", source: "-1px 2px 3px", kind: "margin", fallback: 2, part: 3 },
221
+ { path: ["top"], token: "--outside", source: "-1px 2px 3px", kind: "margin", fallback: -1, part: 0 },
222
+ { path: ["bottom"], token: "--outside", source: "-1px 2px 3px", kind: "margin", fallback: 3, part: 2 },
223
+ { path: ["left"], token: "--outside", source: "-1px 2px 3px", kind: "margin", fallback: 2, part: 3 },
224
+ ...[1, 2, 1, 2].map((fallback, part) => ({ path: ["padding", part], token: "--padding", source: "1px 2px", kind: "padding", fallback, part })),
225
+ { path: ["border", "left", "width"], token: "--stroke", source: "0 solid #aabbcc", kind: "border", fallback: 0, part: "width" },
226
+ { path: ["border", "left", "color"], token: "--stroke", source: "0 solid #aabbcc", kind: "border", fallback: "#aabbcc", part: "color" },
227
+ { path: ["textShadow", "x"], token: "--shadow", source: "#ffffff 0 -2px", kind: "textShadow", fallback: 0, part: "x" },
228
+ { path: ["textShadow", "y"], token: "--shadow", source: "#ffffff 0 -2px", kind: "textShadow", fallback: -2, part: "y" },
229
+ { path: ["textShadow", "color"], token: "--shadow", source: "#ffffff 0 -2px", kind: "textShadow", fallback: "#ffffff", part: "color" },
230
+ ]);
231
+ assert.deepEqual(compile([["border-left", "var(--stroke)"], ["border", "1px #ffffff"]], options).styleTokens, undefined);
232
+ assert.deepEqual(single("padding", "var(--uniform)", { tokens: tokens({ "--uniform": "6px" }) }), {
233
+ padding: 6,
234
+ styleTokens: [{ path: ["padding"], token: "--uniform", source: "6px", kind: "padding", fallback: 6 }],
235
+ });
236
+ });
237
+
238
+ test("checks typed token defaults and restricted calc operands and results", () => {
239
+ const options = { tokens: tokens({
240
+ "--space": "5px", "--near": "-4px", "--ink": "#123456", "--number": "0.5", "--round": "10px",
241
+ "--art": "atlas(kumi-check)", "--invalid": "2em",
242
+ }) };
243
+ assert.deepEqual(compile([
244
+ ["min-width", "calc(var(--near) + 5px)"], ["height", "calc( var(--space) + 2.5px )"],
245
+ ["border-radius", "calc(var(--round) + 1px)"], ["opacity", "calc(var(--number) - .25)"],
246
+ ["background-image", "var(--art)"],
247
+ ], options), {
248
+ minWidth: 1, height: 7.5, borderRadius: 11, opacity: 0.25, backgroundImage: { atlas: "kumi-check" },
249
+ styleTokens: [
250
+ { path: ["minWidth"], token: "--near", source: "-4px", kind: "length", fallback: 1, add: 5 },
251
+ { path: ["height"], token: "--space", source: "5px", kind: "size", fallback: 7.5, add: 2.5 },
252
+ { path: ["borderRadius"], token: "--round", source: "10px", kind: "radius", fallback: 11, add: 1, values: cssRadii },
253
+ { path: ["opacity"], token: "--number", source: "0.5", kind: "opacity", fallback: 0.25, add: -0.25 },
254
+ { path: ["backgroundImage"], token: "--art", source: "atlas(kumi-check)", kind: "backgroundImage", fallback: { atlas: "kumi-check" } },
255
+ ],
256
+ });
257
+ assert.deepEqual(compile([
258
+ ["background-color", "var(--ink)"], ["opacity", "var(--number)"], ["background-image", "var(--art)"],
259
+ ], { ...options, state: true }), {
260
+ backgroundColor: "var(--ink, #123456)", opacity: 0.5, backgroundImage: { atlas: "kumi-check" },
261
+ styleTokens: [
262
+ { path: ["opacity"], token: "--number", source: "0.5", kind: "opacity", fallback: 0.5 },
263
+ { path: ["backgroundImage"], token: "--art", source: "atlas(kumi-check)", kind: "backgroundImage", fallback: { atlas: "kumi-check" } },
264
+ ],
265
+ });
266
+ for (const [prop, value] of [
267
+ ["min-width", "calc(var(--near) + 2px)"], ["min-width", "var(--near)"], ["width", "var(--ink)"],
268
+ ["margin", "var(--ink) 4px"], ["border", "var(--ink) #112233"], ["text-shadow", "0 var(--ink) #112233"],
269
+ ["opacity", "var(--space)"], ["width", "var(--invalid)"], ["background-image", "var(--ink)"],
270
+ ["width", "calc(var(--space) + 2)"], ["width", "calc(var(--number) + 2px)"],
271
+ ["width", "calc(var(--space) + 2%)"], ["width", "calc(var(--space) + -2px)"],
272
+ ["width", "calc(var(--space) * 2px)"], ["width", "calc(var(--space) + var(--space))"],
273
+ ["width", "calc(var(--space) + 2px - 2px)"], ["width", "calc(var(--space)+2px)"],
274
+ ["width", "calc(2px + var(--space))"], ["width", "calc(calc(var(--space) + 2px) + 2px)"],
275
+ ["width", "var(--space, 5px)"], ["width", "var(--space)px"], ["color", "calc(var(--ink) + 2)"],
276
+ ["border-radius", "calc(var(--round) + 0px)"], ["opacity", "calc(var(--number) + .75)"],
277
+ ]) assert.throws(() => single(prop, value, options), /Invalid value for/, prop + " " + value);
278
+ for (const [prop, value] of [
279
+ ["width", "var(--missing)"], ["margin", "0 var(--missing)"], ["inset", "calc(var(--missing) + 2px)"],
280
+ ["border", "0 solid var(--missing)"], ["text-shadow", "var(--missing) 0 0"],
281
+ ]) assert.throws(() => single(prop, value, options), /Unknown token --missing/, prop + " " + value);
282
+ assert.throws(() => compile([["min-width", "var(--space)"], ["max-width", "2px"]], options), /min-width .* exceeds max-width/);
283
+ });
284
+
285
+ test("supports legacy property adapters, duplicate checks, and the array/scalar padding format", () => {
286
+ const options = {
287
+ legacyProperties: {
288
+ "grid-template-columns": ["gridTemplateColumns", value => value === "1fr 2fr" ? value : undefined],
289
+ "grid-column": ["gridColumn", value => /^span \d+$/.test(value) ? value : undefined],
290
+ "other-host-property": ["host", value => value === "valid" ? "HOST" : undefined],
291
+ },
292
+ tokens: tokens({ "--columns": "1fr 2fr", "--span": "span 2" }),
293
+ };
294
+ assert.deepEqual(compile([
295
+ ["grid-template-columns", "var(--columns)"], ["grid-column", "var(--span)"], ["other-host-property", "valid"],
296
+ ], options), {
297
+ gridTemplateColumns: "1fr 2fr", gridColumn: "span 2", host: "HOST",
298
+ styleTokens: [
299
+ { path: ["gridTemplateColumns"], token: "--columns", source: "1fr 2fr", kind: "gridTracks", fallback: "1fr 2fr" },
300
+ { path: ["gridColumn"], token: "--span", source: "span 2", kind: "gridColumn", fallback: "span 2" },
301
+ ],
302
+ });
303
+ assert.deepEqual(single("padding", "4px"), { padding: 4 });
304
+ assert.deepEqual(single("padding", "4px 5px"), { padding: [4, 5] });
305
+ assert.throws(() => single("padding", "-4px"), /Invalid value for padding/);
306
+ assert.throws(() => single("grid-column", "span anything", options), /Invalid value for grid-column/);
307
+ assert.throws(() => single("unknown", "valid", options), /Unsupported property unknown/);
308
+ assert.throws(() => single("__proto__", "valid", options), /Unsupported property __proto__/);
309
+ assert.throws(() => compile([["color", "#123456"], ["color", "#ffffff"]]), /Duplicate property color/);
310
+ assert.throws(() => compileCssDeclarations([{
311
+ prop: "position", value: "sticky", error: message => new SyntaxError("panel.css:2 " + message),
312
+ }]), /^SyntaxError: panel\.css:2 Invalid value for position: sticky/);
313
+ });
314
+
315
+ test("compiles auto margins to centering flags beside the numeric margins", () => {
316
+ assert.deepEqual(single("margin", "auto"), { autoMargin: [true, true, true, true] });
317
+ assert.deepEqual(single("margin", "4px auto"), { margin: [4, 0, 4, 0], autoMargin: [false, true, false, true] });
318
+ assert.deepEqual(compile([["inset", "0"], ["margin", "auto 0"]]),
319
+ { top: 0, right: 0, bottom: 0, left: 0, margin: [0, 0, 0, 0], autoMargin: [true, false, true, false] });
320
+ assert.deepEqual(compile([["margin-left", "auto"], ["margin-right", "auto"]]), { autoMargin: [false, true, false, true] });
321
+ });
@@ -0,0 +1,61 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { mkdir, open, readFile, rename, unlink } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { setTimeout as wait } from "node:timers/promises";
5
+
6
+ const sharingErrors = new Set(["EPERM", "EACCES", "EBUSY"]);
7
+ const retryDelays = [5, 10, 20, 40];
8
+
9
+ async function matchesText(path, contents) {
10
+ try {
11
+ const current = await readFile(path, "utf8");
12
+ return current === contents || current.replaceAll("\r\n", "\n") === contents;
13
+ } catch (error) {
14
+ if (error.code !== "ENOENT") throw error;
15
+ return false;
16
+ }
17
+ }
18
+
19
+ async function publishText(temporary, path, contents) {
20
+ let original;
21
+ for (let attempt = 0; ; attempt++) {
22
+ try {
23
+ await rename(temporary, path);
24
+ return;
25
+ } catch (error) {
26
+ original ??= error;
27
+ if (await matchesText(path, contents).catch(() => false)) {
28
+ await unlink(temporary);
29
+ return;
30
+ }
31
+ // Windows can reject replacement while a reader holds the destination.
32
+ const delay = retryDelays[attempt];
33
+ if (process.platform !== "win32" || !sharingErrors.has(error.code) || delay === undefined) throw original;
34
+ await wait(delay);
35
+ }
36
+ }
37
+ }
38
+
39
+ /** Publish complete generated text. In check mode, return false for missing or stale output. */
40
+ export async function writeGeneratedText(path, contents, { check = false } = {}) {
41
+ if (await matchesText(path, contents)) return true;
42
+ if (check) return false;
43
+
44
+ const parent = dirname(path);
45
+ await mkdir(parent, { recursive: true });
46
+ const temporary = join(parent, `.generated-${randomUUID()}.tmp`);
47
+ const file = await open(temporary, "wx");
48
+ try {
49
+ try {
50
+ await file.writeFile(contents, "utf8");
51
+ } finally {
52
+ await file.close();
53
+ }
54
+
55
+ await publishText(temporary, path, contents);
56
+ return true;
57
+ } catch (error) {
58
+ await unlink(temporary).catch(() => {});
59
+ throw error;
60
+ }
61
+ }
@@ -0,0 +1,132 @@
1
+ import assert from "node:assert/strict";
2
+ import fs, { mkdtemp, readFile, readdir, rmdir, stat, unlink, utimes, writeFile } from "node:fs/promises";
3
+ import { syncBuiltinESMExports } from "node:module";
4
+ import { tmpdir } from "node:os";
5
+ import { dirname, join } from "node:path";
6
+ import { test } from "node:test";
7
+ import { writeGeneratedText } from "./generated-output.mjs";
8
+
9
+ async function workspace(t) {
10
+ const root = await mkdtemp(join(tmpdir(), "kumi-generated-output-"));
11
+ t.after(async () => {
12
+ for (const name of await readdir(root)) await unlink(join(root, name));
13
+ await rmdir(root);
14
+ });
15
+ return root;
16
+ }
17
+
18
+ test("checks missing and stale files without creating or rewriting output", async t => {
19
+ const root = await workspace(t);
20
+ const output = join(root, "style.ts");
21
+ const contents = "export default {};\n";
22
+ const crlf = "export default {};\r\n";
23
+
24
+ assert.equal(await writeGeneratedText(join(root, "uncreated", "style.ts"), contents, { check: true }), false);
25
+ assert.deepEqual(await readdir(root), []);
26
+
27
+ assert.equal(await writeGeneratedText(output, "old\n"), true);
28
+ assert.equal(await writeGeneratedText(output, contents, { check: true }), false);
29
+ assert.equal(await readFile(output, "utf8"), "old\n");
30
+
31
+ await writeFile(output, crlf);
32
+ const time = new Date("2024-01-01T00:00:00.000Z");
33
+ await utimes(output, time, time);
34
+ const { mtimeMs } = await stat(output);
35
+ assert.equal(await writeGeneratedText(output, contents, { check: true }), true);
36
+ assert.equal(await writeGeneratedText(output, contents), true);
37
+ assert.equal(await readFile(output, "utf8"), crlf);
38
+ assert.equal((await stat(output)).mtimeMs, mtimeMs);
39
+ assert.deepEqual(await readdir(root), ["style.ts"]);
40
+ });
41
+
42
+ test("concurrent publishers expose complete old or new files to readers", async t => {
43
+ const root = await workspace(t);
44
+ const output = join(root, "style.ts");
45
+ const old = "old output\n".repeat(4096);
46
+ const contents = "new generated output\n".repeat(8192);
47
+ await writeFile(output, old);
48
+
49
+ let publishing = true;
50
+ const snapshots = new Set();
51
+ const reader = (async () => {
52
+ do {
53
+ snapshots.add(await readFile(output, "utf8").catch(error => error));
54
+ } while (publishing);
55
+ })();
56
+ const publishMany = () => Array.from({ length: 32 }, () => writeGeneratedText(output, contents));
57
+ const writers = await Promise.allSettled(publishMany());
58
+ publishing = false;
59
+ await reader;
60
+
61
+ for (const result of writers) {
62
+ if (result.status === "fulfilled") {
63
+ assert.equal(result.value, true);
64
+ } else {
65
+ // A continuous reader can keep the file locked beyond the retry window on Windows.
66
+ assert.equal(process.platform, "win32");
67
+ assert.equal(result.reason.syscall, "rename");
68
+ assert.match(result.reason.code, /^(EPERM|EACCES|EBUSY)$/);
69
+ }
70
+ }
71
+ assert.ok(snapshots.size > 0 && [...snapshots].every(text => text === old || text === contents));
72
+ assert.equal(await readFile(output, "utf8"), writers.some(result => result.status === "fulfilled") ? contents : old);
73
+ assert.deepEqual(await readdir(root), ["style.ts"]);
74
+
75
+ assert.ok((await Promise.all(publishMany())).every(Boolean));
76
+ assert.equal(await readFile(output, "utf8"), contents);
77
+ assert.deepEqual(await readdir(root), ["style.ts"]);
78
+ });
79
+
80
+ test("recovers matching or transient rename failures and surfaces the first error on exhaustion", async t => {
81
+ const root = await workspace(t);
82
+ const output = join(root, "style.ts");
83
+ const peer = join(root, "peer.ts");
84
+ const unrelated = join(root, ".generated-keep.tmp");
85
+ const contents = "new output\n";
86
+ await writeFile(output, "old output\n");
87
+ await writeFile(unrelated, "keep");
88
+
89
+ let mode = "permanent";
90
+ let attempts = 0;
91
+ const rename = fs.rename;
92
+ const failure = Object.assign(new Error("first rename failed"), { code: "EPERM" });
93
+ const retryFailure = Object.assign(new Error("later rename failed"), { code: "EBUSY" });
94
+ const simulated = t.mock.method(fs, "rename", async (temporary, destination) => {
95
+ attempts++;
96
+ assert.equal(dirname(temporary), root);
97
+ assert.equal(destination, output);
98
+ assert.equal(await readFile(temporary, "utf8"), contents);
99
+ if (mode === "peer") await rename(peer, destination);
100
+ if (mode === "transient" && attempts === 2) return rename(temporary, destination);
101
+ throw attempts === 1 ? failure : retryFailure;
102
+ });
103
+ syncBuiltinESMExports();
104
+ try {
105
+ await assert.rejects(writeGeneratedText(output, contents), error => error === failure);
106
+ assert.equal(attempts, process.platform === "win32" ? 5 : 1);
107
+ assert.equal(await readFile(output, "utf8"), "old output\n");
108
+ assert.deepEqual((await readdir(root)).sort(), [".generated-keep.tmp", "style.ts"]);
109
+
110
+ mode = "peer";
111
+ attempts = 0;
112
+ await writeFile(peer, "new output\r\n");
113
+ assert.equal(await writeGeneratedText(output, contents), true);
114
+ assert.equal(attempts, 1);
115
+ assert.equal(await readFile(output, "utf8"), "new output\r\n");
116
+
117
+ if (process.platform === "win32") {
118
+ mode = "transient";
119
+ attempts = 0;
120
+ await writeFile(output, "old output\n");
121
+ assert.equal(await writeGeneratedText(output, contents), true);
122
+ assert.equal(attempts, 2);
123
+ assert.equal(await readFile(output, "utf8"), contents);
124
+ }
125
+
126
+ assert.equal(await readFile(unrelated, "utf8"), "keep");
127
+ assert.deepEqual((await readdir(root)).sort(), [".generated-keep.tmp", "style.ts"]);
128
+ } finally {
129
+ simulated.mock.restore();
130
+ syncBuiltinESMExports();
131
+ }
132
+ });
@@ -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
+ }