@fluixi/compiler 1.0.0-alpha.83 → 1.0.0-alpha.84

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 (163) hide show
  1. package/dist/analyze/expr-shape.cjs +62 -1
  2. package/dist/analyze/expr-shape.d.cts +14 -0
  3. package/dist/analyze/expr-shape.mjs +41 -1
  4. package/dist/analyze/intrinsics.cjs +80 -1
  5. package/dist/analyze/intrinsics.d.cts +66 -0
  6. package/dist/analyze/intrinsics.mjs +59 -1
  7. package/dist/analyze/paren.cjs +134 -0
  8. package/dist/analyze/paren.d.cts +23 -0
  9. package/dist/analyze/paren.d.ts +24 -0
  10. package/dist/analyze/paren.d.ts.map +1 -0
  11. package/dist/analyze/paren.js +168 -0
  12. package/dist/analyze/paren.mjs +113 -0
  13. package/dist/analyze/props-destructure.cjs +226 -1
  14. package/dist/analyze/props-destructure.d.cts +83 -0
  15. package/dist/analyze/props-destructure.mjs +205 -1
  16. package/dist/analyze/reactive-bindings.cjs +190 -1
  17. package/dist/analyze/reactive-bindings.d.cts +42 -0
  18. package/dist/analyze/reactive-bindings.mjs +167 -1
  19. package/dist/analyze/reactive-expr.cjs +38 -1
  20. package/dist/analyze/reactive-expr.d.cts +38 -0
  21. package/dist/analyze/reactive-expr.mjs +17 -1
  22. package/dist/analyze/static-graph.cjs +811 -1
  23. package/dist/analyze/static-graph.d.cts +102 -0
  24. package/dist/analyze/static-graph.mjs +793 -1
  25. package/dist/babel-NRW4EFTG.mjs +636 -0
  26. package/dist/chunk-3YKZ4GNH.mjs +11 -0
  27. package/dist/chunk-EZR7NZOY.mjs +1718 -0
  28. package/dist/chunk-FSSWUXUR.mjs +16 -0
  29. package/dist/chunk-MJV3UXIL.mjs +158 -0
  30. package/dist/chunk-R2VHAZAX.mjs +1078 -0
  31. package/dist/codegen/backend.cjs +18 -1
  32. package/dist/codegen/backend.d.cts +35 -0
  33. package/dist/codegen/backends/imperative.cjs +542 -1
  34. package/dist/codegen/backends/imperative.d.cts +11 -0
  35. package/dist/codegen/backends/imperative.d.ts.map +1 -1
  36. package/dist/codegen/backends/imperative.js +12 -8
  37. package/dist/codegen/backends/imperative.mjs +519 -1
  38. package/dist/codegen/contract.cjs +52 -1
  39. package/dist/codegen/contract.d.cts +24 -0
  40. package/dist/codegen/contract.mjs +31 -1
  41. package/dist/codegen/partial-template.cjs +176 -1
  42. package/dist/codegen/partial-template.d.cts +61 -0
  43. package/dist/codegen/partial-template.mjs +153 -1
  44. package/dist/codegen/serialize-static.cjs +125 -1
  45. package/dist/codegen/serialize-static.d.cts +38 -0
  46. package/dist/codegen/serialize-static.mjs +104 -1
  47. package/dist/frontend/babel/build-ir-lit.cjs +1509 -1
  48. package/dist/frontend/babel/build-ir-lit.d.cts +26 -0
  49. package/dist/frontend/babel/build-ir-lit.mjs +1478 -1
  50. package/dist/frontend/babel/build-ir.cjs +1524 -1
  51. package/dist/frontend/babel/build-ir.d.cts +35 -0
  52. package/dist/frontend/babel/build-ir.mjs +1495 -1
  53. package/dist/frontend/babel/index.cjs +2186 -1
  54. package/dist/frontend/babel/index.d.cts +33 -0
  55. package/dist/frontend/babel/index.mjs +2156 -1
  56. package/dist/frontend/babel/lower-template.cjs +1507 -1
  57. package/dist/frontend/babel/lower-template.d.cts +23 -0
  58. package/dist/frontend/babel/lower-template.mjs +1478 -1
  59. package/dist/frontend/babel/plugin.cjs +2132 -1
  60. package/dist/frontend/babel/plugin.d.cts +95 -0
  61. package/dist/frontend/babel/plugin.mjs +2103 -1
  62. package/dist/frontend/babel/server-functions.cjs +110 -1
  63. package/dist/frontend/babel/server-functions.d.cts +10 -0
  64. package/dist/frontend/babel/server-functions.mjs +89 -1
  65. package/dist/frontend/babel/types.cjs +18 -1
  66. package/dist/frontend/babel/types.d.cts +33 -0
  67. package/dist/frontend/types.cjs +18 -1
  68. package/dist/frontend/types.d.cts +25 -0
  69. package/dist/frontend/vocabulary.cjs +98 -0
  70. package/dist/frontend/vocabulary.d.cts +79 -0
  71. package/dist/frontend/vocabulary.d.ts +80 -0
  72. package/dist/frontend/vocabulary.d.ts.map +1 -0
  73. package/dist/frontend/vocabulary.js +124 -0
  74. package/dist/frontend/vocabulary.mjs +77 -0
  75. package/dist/index.cjs +1594 -13
  76. package/dist/index.d.cts +27 -0
  77. package/dist/index.mjs +1574 -13
  78. package/dist/integrations.cjs +4307 -25
  79. package/dist/integrations.d.cts +215 -0
  80. package/dist/integrations.mjs +531 -17
  81. package/dist/ir/nodes.cjs +18 -1
  82. package/dist/ir/nodes.d.cts +168 -0
  83. package/dist/lower/compile-template.cjs +1356 -1
  84. package/dist/lower/compile-template.d.cts +69 -0
  85. package/dist/lower/compile-template.mjs +1336 -1
  86. package/dist/lower/jsx.cjs +529 -1
  87. package/dist/lower/jsx.d.cts +25 -0
  88. package/dist/lower/jsx.d.ts.map +1 -1
  89. package/dist/lower/jsx.js +2 -1
  90. package/dist/lower/jsx.mjs +506 -1
  91. package/dist/lower/template.cjs +1061 -1
  92. package/dist/lower/template.d.cts +53 -0
  93. package/dist/lower/template.d.ts.map +1 -1
  94. package/dist/lower/template.js +5 -4
  95. package/dist/lower/template.mjs +1042 -1
  96. package/dist/lower/text.cjs +42 -1
  97. package/dist/lower/text.d.cts +10 -0
  98. package/dist/lower/text.mjs +21 -1
  99. package/dist/optimize/analyze-static.cjs +112 -1
  100. package/dist/optimize/analyze-static.d.cts +39 -0
  101. package/dist/optimize/analyze-static.mjs +91 -1
  102. package/dist/optimize/collapse-strategies.cjs +90 -1
  103. package/dist/optimize/collapse-strategies.d.cts +30 -0
  104. package/dist/optimize/collapse-strategies.mjs +67 -1
  105. package/dist/options.cjs +33 -1
  106. package/dist/options.d.cts +39 -0
  107. package/dist/options.mjs +12 -1
  108. package/dist/resolve/builtins.cjs +73 -1
  109. package/dist/resolve/builtins.d.cts +68 -0
  110. package/dist/resolve/builtins.mjs +53 -1
  111. package/dist/resolve/component-globals.cjs +233 -13
  112. package/dist/resolve/component-globals.d.cts +80 -0
  113. package/dist/resolve/component-globals.mjs +210 -13
  114. package/dist/resolve/component-resolver.cjs +80 -1
  115. package/dist/resolve/component-resolver.d.cts +68 -0
  116. package/dist/resolve/component-resolver.mjs +59 -1
  117. package/dist/resolve/load-directive.cjs +93 -1
  118. package/dist/resolve/load-directive.d.cts +53 -0
  119. package/dist/resolve/load-directive.mjs +72 -1
  120. package/dist/resolve/resolve-ir.cjs +108 -1
  121. package/dist/resolve/resolve-ir.d.cts +53 -0
  122. package/dist/resolve/resolve-ir.mjs +85 -1
  123. package/dist/resolve/write-globals.cjs +318 -13
  124. package/dist/resolve/write-globals.d.cts +30 -0
  125. package/dist/resolve/write-globals.mjs +297 -13
  126. package/dist/server-fns-4ZXN6DYU.mjs +78 -0
  127. package/dist/server-functions-V6D6DRIA.mjs +82 -0
  128. package/dist/transform/bindings.cjs +71 -1
  129. package/dist/transform/bindings.d.cts +16 -0
  130. package/dist/transform/bindings.mjs +50 -1
  131. package/dist/transform/index.cjs +2732 -8
  132. package/dist/transform/index.d.cts +15 -0
  133. package/dist/transform/index.mjs +3773 -17
  134. package/dist/transform/intrinsics.cjs +216 -3
  135. package/dist/transform/intrinsics.d.cts +21 -0
  136. package/dist/transform/intrinsics.mjs +193 -3
  137. package/dist/transform/props.cjs +441 -3
  138. package/dist/transform/props.d.cts +45 -0
  139. package/dist/transform/props.mjs +1482 -12
  140. package/dist/transform/server-fn-id.cjs +35 -1
  141. package/dist/transform/server-fn-id.d.cts +9 -0
  142. package/dist/transform/server-fn-id.mjs +14 -1
  143. package/dist/transform/server-fns.cjs +114 -2
  144. package/dist/transform/server-fns.d.cts +12 -0
  145. package/dist/transform/server-fns.mjs +1155 -11
  146. package/dist/transform/source-locations.cjs +330 -1
  147. package/dist/transform/source-locations.d.cts +43 -0
  148. package/dist/transform/source-locations.mjs +307 -1
  149. package/dist/transform/templates.cjs +2701 -7
  150. package/dist/transform/templates.d.cts +69 -0
  151. package/dist/transform/templates.mjs +3743 -16
  152. package/dist/transform-BT4MMASR.mjs +893 -0
  153. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  154. package/package.json +6 -5
  155. package/dist/babel-VXKH6MRQ.mjs +0 -1
  156. package/dist/chunk-3SAEGOMQ.mjs +0 -1
  157. package/dist/chunk-5KMMN5QP.mjs +0 -1
  158. package/dist/chunk-IBRM4W7I.mjs +0 -10
  159. package/dist/chunk-OHHZCYIQ.mjs +0 -1
  160. package/dist/chunk-YKZ54NVE.mjs +0 -1
  161. package/dist/server-fns-6QM243HC.mjs +0 -2
  162. package/dist/server-functions-E3LKCZ4R.mjs +0 -1
  163. package/dist/transform-C4ZXRVGP.mjs +0 -8
@@ -1 +1,62 @@
1
- "use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var r in t)s(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of u(t))!l.call(e,p)&&p!==r&&s(e,p,{get:()=>t[p],enumerable:!(i=o(t,p))||i.enumerable});return e};var y=e=>c(s({},"__esModule",{value:!0}),e);var x={};m(x,{shapeOf:()=>a});module.exports=y(x);var f=new Set(["CallExpression","OptionalCallExpression"]),d=new Set(["MemberExpression","OptionalMemberExpression"]);function a(e){if(!e)return{kind:"opaque"};if(f.has(e.type))return{kind:"call"};if(d.has(e.type)){let t=e.property;return{kind:"member",property:!(e.computed===!0)&&t?.type==="Identifier"?t.name:null}}return e.type==="ConditionalExpression"?{kind:"compound",parts:[e.test,e.consequent,e.alternate].map(n)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(n)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(n)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(r=>(r.type==="ObjectProperty"||r.type==="Property")&&r.computed!==!0).map(r=>n(r.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(r=>r!=null&&r.type!=="SpreadElement").map(n)}:{kind:"opaque"}}var n=e=>a(e);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/analyze/expr-shape.ts
21
+ var expr_shape_exports = {};
22
+ __export(expr_shape_exports, {
23
+ shapeOf: () => shapeOf
24
+ });
25
+ module.exports = __toCommonJS(expr_shape_exports);
26
+ var CALL = /* @__PURE__ */ new Set(["CallExpression", "OptionalCallExpression"]);
27
+ var MEMBER = /* @__PURE__ */ new Set(["MemberExpression", "OptionalMemberExpression"]);
28
+ function shapeOf(node) {
29
+ if (!node) return { kind: "opaque" };
30
+ if (CALL.has(node.type)) return { kind: "call" };
31
+ if (MEMBER.has(node.type)) {
32
+ const property = node.property;
33
+ const computed = node.computed === true;
34
+ return {
35
+ kind: "member",
36
+ property: !computed && property?.type === "Identifier" ? property.name : null
37
+ };
38
+ }
39
+ if (node.type === "ConditionalExpression") {
40
+ return { kind: "compound", parts: [node.test, node.consequent, node.alternate].map(part) };
41
+ }
42
+ if (node.type === "LogicalExpression" || node.type === "BinaryExpression") {
43
+ return { kind: "compound", parts: [node.left, node.right].map(part) };
44
+ }
45
+ if (node.type === "TemplateLiteral") {
46
+ return { kind: "compound", parts: node.expressions.map(part) };
47
+ }
48
+ if (node.type === "ObjectExpression") {
49
+ const props = node.properties.filter(
50
+ (p) => (p.type === "ObjectProperty" || p.type === "Property") && p.computed !== true
51
+ );
52
+ return { kind: "compound", parts: props.map((p) => part(p.value)) };
53
+ }
54
+ if (node.type === "ArrayExpression") {
55
+ const items = node.elements.filter(
56
+ (e) => e != null && e.type !== "SpreadElement"
57
+ );
58
+ return { kind: "compound", parts: items.map(part) };
59
+ }
60
+ return { kind: "opaque" };
61
+ }
62
+ var part = (n) => shapeOf(n);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Map a parsed expression node to an `ExprShape`.
3
+ *
4
+ * Works off `node.type` strings, so it takes any ESTree-shaped AST — @babel/parser,
5
+ * acorn, or whatever replaces them — and accepts the few names Babel spells
6
+ * differently (`ObjectProperty`, `Optional*Expression`).
7
+ */
8
+ import type { ExprShape } from './reactive-expr.cjs';
9
+ interface Node {
10
+ type: string;
11
+ [key: string]: unknown;
12
+ }
13
+ export declare function shapeOf(node: Node | null | undefined): ExprShape;
14
+ export {};
@@ -1 +1,41 @@
1
- var n=new Set(["CallExpression","OptionalCallExpression"]),s=new Set(["MemberExpression","OptionalMemberExpression"]);function i(e){if(!e)return{kind:"opaque"};if(n.has(e.type))return{kind:"call"};if(s.has(e.type)){let p=e.property;return{kind:"member",property:!(e.computed===!0)&&p?.type==="Identifier"?p.name:null}}return e.type==="ConditionalExpression"?{kind:"compound",parts:[e.test,e.consequent,e.alternate].map(r)}:e.type==="LogicalExpression"||e.type==="BinaryExpression"?{kind:"compound",parts:[e.left,e.right].map(r)}:e.type==="TemplateLiteral"?{kind:"compound",parts:e.expressions.map(r)}:e.type==="ObjectExpression"?{kind:"compound",parts:e.properties.filter(t=>(t.type==="ObjectProperty"||t.type==="Property")&&t.computed!==!0).map(t=>r(t.value))}:e.type==="ArrayExpression"?{kind:"compound",parts:e.elements.filter(t=>t!=null&&t.type!=="SpreadElement").map(r)}:{kind:"opaque"}}var r=e=>i(e);export{i as shapeOf};
1
+ // src/analyze/expr-shape.ts
2
+ var CALL = /* @__PURE__ */ new Set(["CallExpression", "OptionalCallExpression"]);
3
+ var MEMBER = /* @__PURE__ */ new Set(["MemberExpression", "OptionalMemberExpression"]);
4
+ function shapeOf(node) {
5
+ if (!node) return { kind: "opaque" };
6
+ if (CALL.has(node.type)) return { kind: "call" };
7
+ if (MEMBER.has(node.type)) {
8
+ const property = node.property;
9
+ const computed = node.computed === true;
10
+ return {
11
+ kind: "member",
12
+ property: !computed && property?.type === "Identifier" ? property.name : null
13
+ };
14
+ }
15
+ if (node.type === "ConditionalExpression") {
16
+ return { kind: "compound", parts: [node.test, node.consequent, node.alternate].map(part) };
17
+ }
18
+ if (node.type === "LogicalExpression" || node.type === "BinaryExpression") {
19
+ return { kind: "compound", parts: [node.left, node.right].map(part) };
20
+ }
21
+ if (node.type === "TemplateLiteral") {
22
+ return { kind: "compound", parts: node.expressions.map(part) };
23
+ }
24
+ if (node.type === "ObjectExpression") {
25
+ const props = node.properties.filter(
26
+ (p) => (p.type === "ObjectProperty" || p.type === "Property") && p.computed !== true
27
+ );
28
+ return { kind: "compound", parts: props.map((p) => part(p.value)) };
29
+ }
30
+ if (node.type === "ArrayExpression") {
31
+ const items = node.elements.filter(
32
+ (e) => e != null && e.type !== "SpreadElement"
33
+ );
34
+ return { kind: "compound", parts: items.map(part) };
35
+ }
36
+ return { kind: "opaque" };
37
+ }
38
+ var part = (n) => shapeOf(n);
39
+ export {
40
+ shapeOf
41
+ };
@@ -1 +1,80 @@
1
- "use strict";var c=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var d=(e,r)=>{for(var n in r)c(e,n,{get:r[n],enumerable:!0})},f=(e,r,n,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of u(r))!m.call(e,o)&&o!==n&&c(e,o,{get:()=>r[o],enumerable:!(a=l(r,o))||a.enumerable});return e};var p=e=>f(c({},"__esModule",{value:!0}),e);var h={};d(h,{INTRINSICS:()=>s,PRIMITIVE_MODULES:()=>i,REACTIVE_MODULE:()=>t,RUNTIME_PRIMITIVES:()=>x,isIntrinsicName:()=>R,isPrimitiveModule:()=>v,mayHaveIntrinsic:()=>I});module.exports=p(h);var t="@fluixi/reactive/signal",s={$signal:{export:"signal",module:t,returns:"signal-handle"},$memo:{export:"memo",module:t,returns:"memo-handle"},$effect:{export:"effect",module:t,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:t,returns:"resource-handle"},$selector:{export:"createSelector",module:t,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:t,returns:"memo-accessor"},$untrack:{export:"untrack",module:t,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},x={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},i=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core"],g=new RegExp(`\\$(?:${Object.keys(s).map(e=>e.slice(1)).join("|")})\\s*\\(`);function I(e){return g.test(e)}function R(e){return Object.prototype.hasOwnProperty.call(s,e)}function v(e){return i.includes(e)}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/analyze/intrinsics.ts
21
+ var intrinsics_exports = {};
22
+ __export(intrinsics_exports, {
23
+ INTRINSICS: () => INTRINSICS,
24
+ PRIMITIVE_MODULES: () => PRIMITIVE_MODULES,
25
+ REACTIVE_MODULE: () => REACTIVE_MODULE,
26
+ RUNTIME_PRIMITIVES: () => RUNTIME_PRIMITIVES,
27
+ isIntrinsicName: () => isIntrinsicName,
28
+ isPrimitiveModule: () => isPrimitiveModule,
29
+ mayHaveIntrinsic: () => mayHaveIntrinsic
30
+ });
31
+ module.exports = __toCommonJS(intrinsics_exports);
32
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
33
+ var INTRINSICS = {
34
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
35
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
36
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
37
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
38
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
39
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
40
+ // name. Still worth having — no import to write — and when a shorter form is
41
+ // designed, the change is this line rather than a compiler pass.
42
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
43
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
44
+ // Not value constructors, but the compiler has to know them: they change what a read
45
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
46
+ // dependency analysis must not guess at.
47
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
48
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" }
49
+ };
50
+ var RUNTIME_PRIMITIVES = {
51
+ signal: "signal-handle",
52
+ memo: "memo-handle",
53
+ effect: "effect",
54
+ store: "store-handle",
55
+ createSignal: ["signal-accessor", "signal-setter"],
56
+ createMemo: "memo-accessor",
57
+ createEffect: "effect",
58
+ createRenderEffect: "effect",
59
+ createStore: "reactive-object",
60
+ resource: "resource-handle",
61
+ createResource: "reactive-object",
62
+ createSelector: "memo-accessor",
63
+ createDeferred: "memo-accessor"
64
+ };
65
+ var PRIMITIVE_MODULES = [
66
+ "@fluixi/reactive",
67
+ "@fluixi/reactive/signal",
68
+ "@fluixi/reactive/store",
69
+ "@fluixi/core"
70
+ ];
71
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
72
+ function mayHaveIntrinsic(code) {
73
+ return INTRINSIC_CALL.test(code);
74
+ }
75
+ function isIntrinsicName(name) {
76
+ return Object.prototype.hasOwnProperty.call(INTRINSICS, name);
77
+ }
78
+ function isPrimitiveModule(source) {
79
+ return PRIMITIVE_MODULES.includes(source);
80
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The reactive primitives the compiler knows by name, in one place.
3
+ *
4
+ * Two ways to write the same thing. The runtime call, which needs an import and works
5
+ * without us:
6
+ *
7
+ * import { createSignal } from '@fluixi/reactive/signal';
8
+ * const count = createSignal(0);
9
+ *
10
+ * And the intrinsic, which the compiler resolves and imports for you:
11
+ *
12
+ * const count = $signal(0);
13
+ *
14
+ * They are not two reactive systems. `$signal` compiles to the same `createSignal` call,
15
+ * so there's one graph, one lifecycle, one SSR story. The `$` form is authoring sugar
16
+ * the compiler understands; the runtime form stays public, because a library that never
17
+ * runs this compiler still has to be able to write reactive code.
18
+ *
19
+ * Everything the compiler needs to know about a primitive lives in this table rather
20
+ * than spread across passes, so adding one is an entry, not a new code path.
21
+ */
22
+ /** What a binding holds, once we know where it came from. */
23
+ export type ReactiveKind = 'plain'
24
+ /** `signal(0)` — one object, read with `.get()` and written with `.set()`. */
25
+ | 'signal-handle'
26
+ /** `memo(fn)` — read-only, so `.get()` only. */
27
+ | 'memo-handle'
28
+ /** `store(obj)` — read properties directly, `.set()` writes. */
29
+ | 'store-handle'
30
+ /** `resource(fn)` — `.get()` reads, with `.loading`/`.latest`/`.refetch()` on it. */
31
+ | 'resource-handle'
32
+ /** The accessor half of the tuple form, `const [count] = createSignal(0)`. */
33
+ | 'signal-accessor' | 'signal-setter' | 'memo-accessor' | 'effect' | 'reactive-object';
34
+ export interface Intrinsic {
35
+ /** Runtime export this compiles to. */
36
+ export: string;
37
+ /** Module it comes from. */
38
+ module: string;
39
+ /**
40
+ * What the call yields. A tuple means the call is destructured into that many
41
+ * bindings — `createSignal` gives an accessor and a setter, in that order.
42
+ */
43
+ returns: ReactiveKind | readonly ReactiveKind[];
44
+ }
45
+ /** Module the reactive primitives are imported from when the compiler adds the import. */
46
+ export declare const REACTIVE_MODULE = "@fluixi/reactive/signal";
47
+ /**
48
+ * `$name` → the runtime it stands for.
49
+ *
50
+ * The `$` prefix is reserved. A local binding of the same name wins — it has to, or the
51
+ * compiler would rewrite code that means something else — and that's reported rather
52
+ * than done quietly.
53
+ */
54
+ export declare const INTRINSICS: Readonly<Record<string, Intrinsic>>;
55
+ /**
56
+ * The runtime names, for the other direction: source that imports `createSignal` gets
57
+ * classified the same way as source that writes `$signal`, so later passes see one
58
+ * vocabulary whichever form the author used.
59
+ */
60
+ export declare const RUNTIME_PRIMITIVES: Readonly<Record<string, Intrinsic['returns']>>;
61
+ /** Modules whose exports count as reactive primitives. */
62
+ export declare const PRIMITIVE_MODULES: readonly string[];
63
+ export declare function mayHaveIntrinsic(code: string): boolean;
64
+ export declare function isIntrinsicName(name: string): boolean;
65
+ /** Whether a module path exports the reactive primitives. */
66
+ export declare function isPrimitiveModule(source: string): boolean;
@@ -1 +1,59 @@
1
- var r="@fluixi/reactive/signal",t={$signal:{export:"signal",module:r,returns:"signal-handle"},$memo:{export:"memo",module:r,returns:"memo-handle"},$effect:{export:"effect",module:r,returns:"effect"},$store:{export:"store",module:"@fluixi/reactive/store",returns:"store-handle"},$resource:{export:"resource",module:r,returns:"resource-handle"},$selector:{export:"createSelector",module:r,returns:"memo-accessor"},$deferred:{export:"createDeferred",module:r,returns:"memo-accessor"},$untrack:{export:"untrack",module:r,returns:"plain"},$untrackStore:{export:"untrackStore",module:"@fluixi/reactive/store",returns:"plain"}},c={signal:"signal-handle",memo:"memo-handle",effect:"effect",store:"store-handle",createSignal:["signal-accessor","signal-setter"],createMemo:"memo-accessor",createEffect:"effect",createRenderEffect:"effect",createStore:"reactive-object",resource:"resource-handle",createResource:"reactive-object",createSelector:"memo-accessor",createDeferred:"memo-accessor"},o=["@fluixi/reactive","@fluixi/reactive/signal","@fluixi/reactive/store","@fluixi/core"],n=new RegExp(`\\$(?:${Object.keys(t).map(e=>e.slice(1)).join("|")})\\s*\\(`);function s(e){return n.test(e)}function a(e){return Object.prototype.hasOwnProperty.call(t,e)}function i(e){return o.includes(e)}export{t as INTRINSICS,o as PRIMITIVE_MODULES,r as REACTIVE_MODULE,c as RUNTIME_PRIMITIVES,a as isIntrinsicName,i as isPrimitiveModule,s as mayHaveIntrinsic};
1
+ // src/analyze/intrinsics.ts
2
+ var REACTIVE_MODULE = "@fluixi/reactive/signal";
3
+ var INTRINSICS = {
4
+ $signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
5
+ $memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
6
+ $effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
7
+ $store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
8
+ $resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
9
+ // No short runtime form for these yet, so the intrinsic stands for the `create*`
10
+ // name. Still worth having — no import to write — and when a shorter form is
11
+ // designed, the change is this line rather than a compiler pass.
12
+ $selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
13
+ $deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
14
+ // Not value constructors, but the compiler has to know them: they change what a read
15
+ // does. `untrack` suppresses dependency collection, which is exactly the kind of thing
16
+ // dependency analysis must not guess at.
17
+ $untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
18
+ $untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" }
19
+ };
20
+ var RUNTIME_PRIMITIVES = {
21
+ signal: "signal-handle",
22
+ memo: "memo-handle",
23
+ effect: "effect",
24
+ store: "store-handle",
25
+ createSignal: ["signal-accessor", "signal-setter"],
26
+ createMemo: "memo-accessor",
27
+ createEffect: "effect",
28
+ createRenderEffect: "effect",
29
+ createStore: "reactive-object",
30
+ resource: "resource-handle",
31
+ createResource: "reactive-object",
32
+ createSelector: "memo-accessor",
33
+ createDeferred: "memo-accessor"
34
+ };
35
+ var PRIMITIVE_MODULES = [
36
+ "@fluixi/reactive",
37
+ "@fluixi/reactive/signal",
38
+ "@fluixi/reactive/store",
39
+ "@fluixi/core"
40
+ ];
41
+ var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
42
+ function mayHaveIntrinsic(code) {
43
+ return INTRINSIC_CALL.test(code);
44
+ }
45
+ function isIntrinsicName(name) {
46
+ return Object.prototype.hasOwnProperty.call(INTRINSICS, name);
47
+ }
48
+ function isPrimitiveModule(source) {
49
+ return PRIMITIVE_MODULES.includes(source);
50
+ }
51
+ export {
52
+ INTRINSICS,
53
+ PRIMITIVE_MODULES,
54
+ REACTIVE_MODULE,
55
+ RUNTIME_PRIMITIVES,
56
+ isIntrinsicName,
57
+ isPrimitiveModule,
58
+ mayHaveIntrinsic
59
+ };
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/analyze/paren.ts
21
+ var paren_exports = {};
22
+ __export(paren_exports, {
23
+ paren: () => paren,
24
+ topLevelComma: () => topLevelComma
25
+ });
26
+ module.exports = __toCommonJS(paren_exports);
27
+ function skipQuoted(src, start) {
28
+ const quote = src[start];
29
+ for (let i = start + 1; i < src.length; i++) {
30
+ const c = src[i];
31
+ if (c === "\\") i++;
32
+ else if (c === quote) return i + 1;
33
+ else if (c === "\n") return -1;
34
+ }
35
+ return -1;
36
+ }
37
+ function skipTemplate(src, start) {
38
+ let i = start + 1;
39
+ while (i < src.length) {
40
+ const c = src[i];
41
+ if (c === "\\") {
42
+ i += 2;
43
+ } else if (c === "`") {
44
+ return i + 1;
45
+ } else if (c === "$" && src[i + 1] === "{") {
46
+ let depth = 1;
47
+ i += 2;
48
+ while (i < src.length && depth > 0) {
49
+ const k = src[i];
50
+ if (k === "\\") i += 2;
51
+ else if (k === "`") {
52
+ const end = skipTemplate(src, i);
53
+ if (end < 0) return -1;
54
+ i = end;
55
+ } else if (k === '"' || k === "'") {
56
+ const end = skipQuoted(src, i);
57
+ if (end < 0) return -1;
58
+ i = end;
59
+ } else {
60
+ if (k === "{") depth++;
61
+ else if (k === "}") depth--;
62
+ i++;
63
+ }
64
+ }
65
+ } else {
66
+ i++;
67
+ }
68
+ }
69
+ return -1;
70
+ }
71
+ function skipRegex(src, start) {
72
+ let inClass = false;
73
+ for (let i = start + 1; i < src.length; i++) {
74
+ const c = src[i];
75
+ if (c === "\\") i++;
76
+ else if (c === "[") inClass = true;
77
+ else if (c === "]") inClass = false;
78
+ else if (c === "\n") return -1;
79
+ else if (c === "/" && !inClass) {
80
+ let end = i + 1;
81
+ while (end < src.length && /[a-z]/i.test(src[end])) end++;
82
+ return end;
83
+ }
84
+ }
85
+ return -1;
86
+ }
87
+ function divides(prev) {
88
+ return prev !== "" && /[A-Za-z0-9_$)\]]/.test(prev);
89
+ }
90
+ function topLevelComma(src) {
91
+ let depth = 0;
92
+ let prev = "";
93
+ let i = 0;
94
+ while (i < src.length) {
95
+ const c = src[i];
96
+ if (c === '"' || c === "'") {
97
+ const end = skipQuoted(src, i);
98
+ if (end < 0) return null;
99
+ i = end;
100
+ prev = c;
101
+ } else if (c === "`") {
102
+ const end = skipTemplate(src, i);
103
+ if (end < 0) return null;
104
+ i = end;
105
+ prev = c;
106
+ } else if (c === "/" && src[i + 1] === "/") {
107
+ return null;
108
+ } else if (c === "/" && src[i + 1] === "*") {
109
+ const end = src.indexOf("*/", i + 2);
110
+ if (end < 0) return null;
111
+ i = end + 2;
112
+ } else if (c === "/" && !divides(prev)) {
113
+ const end = skipRegex(src, i);
114
+ if (end < 0) return null;
115
+ i = end;
116
+ prev = "/";
117
+ } else {
118
+ if (c === "(" || c === "[" || c === "{") depth++;
119
+ else if (c === ")" || c === "]" || c === "}") {
120
+ depth--;
121
+ if (depth < 0) return null;
122
+ } else if (c === "," && depth === 0) return true;
123
+ if (!/\s/.test(c)) prev = c;
124
+ i++;
125
+ }
126
+ }
127
+ return depth === 0 ? false : null;
128
+ }
129
+ function paren(code, position) {
130
+ const src = code.trim();
131
+ if (src === "") return `(${code})`;
132
+ if (position === "arrowBody" && src[0] === "{") return `(${code})`;
133
+ return topLevelComma(src) === false ? code : `(${code})`;
134
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Whether a raw expression slice has to be wrapped in parens before it is dropped
3
+ * into an object value, an argument list, a `return`, or an arrow's concise body.
4
+ *
5
+ * The compiler holds expressions as source text: `IRExpression.code` is deliberately
6
+ * a string (see ir/nodes.ts), so there is no printer to ask about precedence and the
7
+ * decision comes from the characters.
8
+ *
9
+ * Two things bind wrong. A top-level comma reads as a sequence or as an argument
10
+ * separator, and a leading `{` in an arrow body reads as a block. Everything else
11
+ * parses the same wrapped or bare.
12
+ *
13
+ * Wrapping unconditionally was the old answer, and it reached production: esbuild's
14
+ * minifier keeps redundant parens. Measured on the fluixi-ui playground, 3,320 of
15
+ * the 3,322 bytes the native build ran over the babel one were these.
16
+ */
17
+ /**
18
+ * True when the text has a comma outside every bracket, string and substitution.
19
+ * Null when the scan cannot say, which the caller reads as "assume it does".
20
+ */
21
+ export declare function topLevelComma(src: string): boolean | null;
22
+ /** Wrap a raw expression slice only where the characters say it has to be. */
23
+ export declare function paren(code: string, position: 'value' | 'arrowBody'): string;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Whether a raw expression slice has to be wrapped in parens before it is dropped
3
+ * into an object value, an argument list, a `return`, or an arrow's concise body.
4
+ *
5
+ * The compiler holds expressions as source text: `IRExpression.code` is deliberately
6
+ * a string (see ir/nodes.ts), so there is no printer to ask about precedence and the
7
+ * decision comes from the characters.
8
+ *
9
+ * Two things bind wrong. A top-level comma reads as a sequence or as an argument
10
+ * separator, and a leading `{` in an arrow body reads as a block. Everything else
11
+ * parses the same wrapped or bare.
12
+ *
13
+ * Wrapping unconditionally was the old answer, and it reached production: esbuild's
14
+ * minifier keeps redundant parens. Measured on the fluixi-ui playground, 3,320 of
15
+ * the 3,322 bytes the native build ran over the babel one were these.
16
+ */
17
+ /**
18
+ * True when the text has a comma outside every bracket, string and substitution.
19
+ * Null when the scan cannot say, which the caller reads as "assume it does".
20
+ */
21
+ export declare function topLevelComma(src: string): boolean | null;
22
+ /** Wrap a raw expression slice only where the characters say it has to be. */
23
+ export declare function paren(code: string, position: 'value' | 'arrowBody'): string;
24
+ //# sourceMappingURL=paren.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paren.d.ts","sourceRoot":"","sources":["../../src/analyze/paren.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAyEH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAuCzD;AAED,8EAA8E;AAC9E,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,CAK3E"}