tempo-sdk 0.0.51 → 0.0.57

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 (84) hide show
  1. package/dist/assets/editor.d.ts +1 -1
  2. package/dist/assets/editor.js +1 -1
  3. package/dist/assets/index.d.ts +3 -3
  4. package/dist/assets/index.js +4 -2
  5. package/dist/assets/index.js.map +1 -1
  6. package/dist/assets/parser.d.ts +10 -4
  7. package/dist/assets/parser.js +1 -1
  8. package/dist/canvas/editor.d.ts +11 -16
  9. package/dist/canvas/editor.js +79 -49
  10. package/dist/canvas/editor.js.map +1 -1
  11. package/dist/canvas/index.d.ts +15 -11
  12. package/dist/canvas/index.js +130 -47
  13. package/dist/canvas/index.js.map +1 -1
  14. package/dist/canvas/interact-projection.js +4 -3
  15. package/dist/canvas/parser.d.ts +10 -5
  16. package/dist/canvas/parser.js +3 -1
  17. package/dist/canvas/svelte.d.ts +9 -7
  18. package/dist/canvas/svelte.js +20 -5
  19. package/dist/canvas/svelte.js.map +1 -1
  20. package/dist/chunk-2IQD2KPS.js +219 -0
  21. package/dist/chunk-2IQD2KPS.js.map +1 -0
  22. package/dist/chunk-5BHIHP25.js +410 -0
  23. package/dist/chunk-5BHIHP25.js.map +1 -0
  24. package/dist/chunk-EMYYTS6D.js +1585 -0
  25. package/dist/chunk-EMYYTS6D.js.map +1 -0
  26. package/dist/{chunk-DX6XAXCK.js → chunk-N2TYN3RB.js} +189 -420
  27. package/dist/chunk-N2TYN3RB.js.map +1 -0
  28. package/dist/{chunk-LFYKJJC5.js → chunk-QXL6GL2P.js} +18 -3
  29. package/dist/chunk-QXL6GL2P.js.map +1 -0
  30. package/dist/{chunk-QP2NTODB.js → chunk-RHHVVWAC.js} +115 -25
  31. package/dist/chunk-RHHVVWAC.js.map +1 -0
  32. package/dist/chunk-TL4MGN7E.js +2570 -0
  33. package/dist/chunk-TL4MGN7E.js.map +1 -0
  34. package/dist/{chunk-PULSTDX2.js → chunk-U3SLJNRS.js} +284 -46
  35. package/dist/chunk-U3SLJNRS.js.map +1 -0
  36. package/dist/{chunk-ZZYNOX24.js → chunk-U64AHDHZ.js} +1708 -2461
  37. package/dist/chunk-U64AHDHZ.js.map +1 -0
  38. package/dist/{chunk-O65OD3NA.js → chunk-XLEKCOB7.js} +6 -5
  39. package/dist/chunk-XLEKCOB7.js.map +1 -0
  40. package/dist/expo/plugin.cjs +1256 -16
  41. package/dist/expo/plugin.cjs.map +1 -1
  42. package/dist/expo/plugin.d.cts +0 -1
  43. package/dist/expo/plugin.d.ts +0 -1
  44. package/dist/expo/plugin.js +1 -1
  45. package/dist/expo-babel-plugin.cjs +1258 -16
  46. package/dist/expo-babel-plugin.cjs.map +1 -1
  47. package/dist/expo-babel-plugin.d.cts +8 -5
  48. package/dist/expo-babel-plugin.d.ts +8 -5
  49. package/dist/expo-babel-plugin.js +1 -1
  50. package/dist/index.d.ts +5 -1
  51. package/dist/index.js +464 -154
  52. package/dist/index.js.map +1 -1
  53. package/dist/nextjs/plugin.cjs +151 -0
  54. package/dist/nextjs/plugin.cjs.map +1 -1
  55. package/dist/nextjs/plugin.d.cts +1 -1
  56. package/dist/nextjs/plugin.d.ts +1 -1
  57. package/dist/nextjs/plugin.js +1 -1
  58. package/dist/nextjs-loader.cjs +1432 -35
  59. package/dist/nextjs-loader.cjs.map +1 -1
  60. package/dist/nextjs.cjs +17 -2
  61. package/dist/nextjs.cjs.map +1 -1
  62. package/dist/nextjs.d.cts +14 -3
  63. package/dist/nextjs.d.ts +14 -3
  64. package/dist/nextjs.js +1 -1
  65. package/dist/{page-xi1aI5a7.d.ts → page-DwLnOM5d.d.ts} +12 -6
  66. package/dist/{storyboard-CBHki7Aw.d.ts → storyboard-BtQuVGpl.d.ts} +35 -17
  67. package/dist/svelte.d.ts +3 -2
  68. package/dist/svelte.js +103 -29
  69. package/dist/svelte.js.map +1 -1
  70. package/dist/{types-C7cvcY6T.d.ts → types-C8OIU-kc.d.ts} +1 -1
  71. package/dist/v1-client-compat-qxaXEDm_.d.ts +23 -0
  72. package/package.json +5 -2
  73. package/dist/chunk-57KAYXHF.js +0 -19
  74. package/dist/chunk-57KAYXHF.js.map +0 -1
  75. package/dist/chunk-CB5NJJJT.js +0 -345
  76. package/dist/chunk-CB5NJJJT.js.map +0 -1
  77. package/dist/chunk-DX6XAXCK.js.map +0 -1
  78. package/dist/chunk-F3KJDCMU.js +0 -19
  79. package/dist/chunk-F3KJDCMU.js.map +0 -1
  80. package/dist/chunk-LFYKJJC5.js.map +0 -1
  81. package/dist/chunk-O65OD3NA.js.map +0 -1
  82. package/dist/chunk-PULSTDX2.js.map +0 -1
  83. package/dist/chunk-QP2NTODB.js.map +0 -1
  84. package/dist/chunk-ZZYNOX24.js.map +0 -1
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  installTempoInteractProjectionSource
3
- } from "../chunk-ZZYNOX24.js";
3
+ } from "../chunk-U64AHDHZ.js";
4
4
  import "../chunk-65B52AR7.js";
5
- import "../chunk-57KAYXHF.js";
6
- import "../chunk-DX6XAXCK.js";
5
+ import "../chunk-TL4MGN7E.js";
6
+ import "../chunk-5BHIHP25.js";
7
+ import "../chunk-N2TYN3RB.js";
7
8
  export {
8
9
  installTempoInteractProjectionSource
9
10
  };
@@ -1,3 +1,5 @@
1
+ import { JSXElement } from 'oxc-parser';
2
+
1
3
  type CanvasSourceSpan = {
2
4
  start: number;
3
5
  end: number;
@@ -44,10 +46,9 @@ type MisimportedSdkCanvasImport = {
44
46
  type ParsedCanvasLayout = {
45
47
  x: number;
46
48
  y: number;
47
- width: number;
48
- height: number;
49
+ width?: number;
50
+ height?: number;
49
51
  zIndex?: number;
50
- intrinsicSizing?: "root-element";
51
52
  };
52
53
  type ParsedCanvasLayoutSpans = {
53
54
  x?: CanvasSourceSpan;
@@ -55,7 +56,6 @@ type ParsedCanvasLayoutSpans = {
55
56
  width?: CanvasSourceSpan;
56
57
  height?: CanvasSourceSpan;
57
58
  zIndex?: CanvasSourceSpan;
58
- intrinsicSizing?: CanvasSourceSpan;
59
59
  layoutClose?: number;
60
60
  };
61
61
  type ParsedCanvasComponentReference = {
@@ -157,5 +157,10 @@ declare function parseCanvasFile(filePath: string, source: string): ParsedCanvas
157
157
  declare function misimportedSdkCanvasImportMessage(entry: MisimportedSdkCanvasImport): string;
158
158
  declare function unwrapTsExpression(node: any): any;
159
159
  declare function fallbackPageName(filePath: string): string;
160
+ /** Resolve only direct component returns, so nested callbacks cannot supply a false root. */
161
+ declare function parseComponentRoot(filePath: string, source: string, exportName: string): {
162
+ name: string;
163
+ root: JSXElement;
164
+ } | null;
160
165
 
161
- export { type CanvasParseError, type CanvasSourceSpan, type MisimportedSdkCanvasImport, NO_CANVAS_DECLARATION_ERROR, type ParsedCanvasComponentReference, type ParsedCanvasExpressionReference, type ParsedCanvasFile, type ParsedCanvasImport, type ParsedCanvasLayout, type ParsedCanvasLayoutSpans, type ParsedCanvasStoryboard, type ParsedStoryboardVrt, type ParsedStoryboardVrtIgnoreRegion, fallbackPageName, misimportedSdkCanvasImportMessage, parseCanvasFile, unwrapTsExpression };
166
+ export { type CanvasParseError, type CanvasSourceSpan, type MisimportedSdkCanvasImport, NO_CANVAS_DECLARATION_ERROR, type ParsedCanvasComponentReference, type ParsedCanvasExpressionReference, type ParsedCanvasFile, type ParsedCanvasImport, type ParsedCanvasLayout, type ParsedCanvasLayoutSpans, type ParsedCanvasStoryboard, type ParsedStoryboardVrt, type ParsedStoryboardVrtIgnoreRegion, fallbackPageName, misimportedSdkCanvasImportMessage, parseCanvasFile, parseComponentRoot, unwrapTsExpression };
@@ -3,13 +3,15 @@ import {
3
3
  fallbackPageName,
4
4
  misimportedSdkCanvasImportMessage,
5
5
  parseCanvasFile,
6
+ parseComponentRoot,
6
7
  unwrapTsExpression
7
- } from "../chunk-QP2NTODB.js";
8
+ } from "../chunk-RHHVVWAC.js";
8
9
  export {
9
10
  NO_CANVAS_DECLARATION_ERROR,
10
11
  fallbackPageName,
11
12
  misimportedSdkCanvasImportMessage,
12
13
  parseCanvasFile,
14
+ parseComponentRoot,
13
15
  unwrapTsExpression
14
16
  };
15
17
  //# sourceMappingURL=parser.js.map
@@ -1,18 +1,20 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as StoryboardLayout } from '../storyboard-CBHki7Aw.js';
3
- import 'react';
4
- import '../page-xi1aI5a7.js';
1
+ import * as react from 'react';
2
+ import * as svelte from 'svelte';
3
+ import { a as StoryboardLayout, c as StoryboardVrtConfig } from '../storyboard-BtQuVGpl.js';
4
+ import '../page-DwLnOM5d.js';
5
+ import '../v1-client-compat-qxaXEDm_.js';
5
6
 
6
7
  /** Public Svelte 5 component call shape. This Svelte-specific entrypoint keeps
7
8
  * React-only consumers of tempo-sdk/canvas from resolving the optional Svelte
8
9
  * peer dependency. */
9
- type SvelteComponent<Props extends Record<string, unknown> = Record<string, unknown>> = (anchor: unknown, props: Props) => Record<string, unknown>;
10
- declare function SvelteStoryboard<Props extends Record<string, unknown> = Record<string, unknown>>({ id, name, component, layout, props, }: {
10
+ type SvelteComponent<Props extends Record<string, unknown> = Record<string, unknown>> = svelte.Component<Props>;
11
+ declare function SvelteStoryboard<Props extends Record<string, unknown> = Record<string, unknown>>({ id, name, component, layout, props, vrt, ...annotations }: {
11
12
  id: string;
12
13
  component: SvelteComponent<Props>;
13
14
  layout: StoryboardLayout;
14
15
  name?: string;
15
16
  props?: Props;
16
- }): react_jsx_runtime.JSX.Element;
17
+ vrt?: boolean | StoryboardVrtConfig;
18
+ } & Record<`data-tempo-${string}`, unknown>): react.JSX.Element;
17
19
 
18
20
  export { type SvelteComponent, SvelteStoryboard };
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  StoryboardSlot
3
- } from "../chunk-PULSTDX2.js";
4
- import "../chunk-57KAYXHF.js";
3
+ } from "../chunk-U3SLJNRS.js";
4
+ import "../chunk-TL4MGN7E.js";
5
+ import "../chunk-N2TYN3RB.js";
5
6
 
6
7
  // canvas/svelte.tsx
7
8
  import { useLayoutEffect, useRef, useState } from "react";
@@ -28,9 +29,23 @@ function SvelteStoryboard({
28
29
  name,
29
30
  component,
30
31
  layout,
31
- props
32
+ props,
33
+ vrt,
34
+ ...annotations
32
35
  }) {
33
- return /* @__PURE__ */ jsx(StoryboardSlot, { id, name, layout, kind: "component", children: /* @__PURE__ */ jsx(SvelteComponentMount, { component, props }) });
36
+ return /* @__PURE__ */ jsx(
37
+ StoryboardSlot,
38
+ {
39
+ "data-tempo-hide-fiber": "true",
40
+ id,
41
+ name,
42
+ layout,
43
+ kind: "component",
44
+ uiFramework: "svelte",
45
+ vrt: !!vrt,
46
+ children: /* @__PURE__ */ jsx(SvelteComponentMount, { component, props })
47
+ }
48
+ );
34
49
  }
35
50
  function SvelteComponentMount({
36
51
  component,
@@ -60,7 +75,7 @@ function SvelteComponentMount({
60
75
  };
61
76
  }, [component, runtime]);
62
77
  if (mountError) throw mountError;
63
- return /* @__PURE__ */ jsx("div", { ref: targetRef });
78
+ return /* @__PURE__ */ jsx("div", { ref: targetRef, "data-tempo-hide-fiber": "true" });
64
79
  }
65
80
  export {
66
81
  SvelteStoryboard
@@ -1 +1 @@
1
- {"version":3,"sources":["../../canvas/svelte.tsx"],"sourcesContent":["import { useLayoutEffect, useRef, useState } from \"react\";\n\nimport { StoryboardSlot, type StoryboardLayout } from \"./storyboard\";\n\n/** Public Svelte 5 component call shape. This Svelte-specific entrypoint keeps\n * React-only consumers of tempo-sdk/canvas from resolving the optional Svelte\n * peer dependency. */\nexport type SvelteComponent<\n Props extends Record<string, unknown> = Record<string, unknown>,\n> = (anchor: unknown, props: Props) => Record<string, unknown>;\n\ntype SvelteRuntime = typeof import(\"svelte\");\ntype SvelteRuntimeState =\n | { kind: \"pending\"; promise: Promise<void> }\n | { kind: \"ready\"; runtime: SvelteRuntime }\n | { kind: \"error\"; error: unknown };\n\nlet svelteRuntimeState: SvelteRuntimeState | null = null;\n\n/** Suspense resource for the optional Svelte runtime. The storyboard must not\n * report its React shell as rendered before the authored Svelte DOM exists,\n * otherwise the component projection opens with a permanent DOM-only\n * baseline. */\nfunction readSvelteRuntime(): SvelteRuntime {\n if (svelteRuntimeState?.kind === \"ready\") return svelteRuntimeState.runtime;\n if (svelteRuntimeState?.kind === \"error\") throw svelteRuntimeState.error;\n if (!svelteRuntimeState) {\n const promise = import(\"svelte\").then(\n (runtime) => {\n svelteRuntimeState = { kind: \"ready\", runtime };\n },\n (error: unknown) => {\n svelteRuntimeState = { kind: \"error\", error };\n },\n );\n svelteRuntimeState = { kind: \"pending\", promise };\n }\n throw svelteRuntimeState.promise;\n}\n\nexport function SvelteStoryboard<\n Props extends Record<string, unknown> = Record<string, unknown>,\n>({\n id,\n name,\n component,\n layout,\n props,\n}: {\n id: string;\n component: SvelteComponent<Props>;\n layout: StoryboardLayout;\n name?: string;\n props?: Props;\n}) {\n return (\n <StoryboardSlot id={id} name={name} layout={layout} kind=\"component\">\n <SvelteComponentMount component={component} props={props} />\n </StoryboardSlot>\n );\n}\n\nfunction SvelteComponentMount<Props extends Record<string, unknown>>({\n component,\n props,\n}: {\n component: SvelteComponent<Props>;\n props?: Props;\n}) {\n const targetRef = useRef<HTMLDivElement | null>(null);\n const [mountError, setMountError] = useState<unknown>(null);\n const runtime = readSvelteRuntime();\n\n useLayoutEffect(() => {\n const target = targetRef.current;\n if (!target) return;\n let mounted: Record<string, unknown> | null = null;\n try {\n mounted = runtime.mount(component as never, {\n target,\n props: props ?? ({} as Props),\n }) as Record<string, unknown>;\n runtime.flushSync();\n } catch (error) {\n setMountError(error);\n }\n\n return () => {\n const current = mounted;\n mounted = null;\n if (current) void runtime.unmount(current);\n target.replaceChildren();\n };\n // Svelte component props are explicit static storyboard inputs today.\n // Canvas source/HMR replaces the component module when they change; avoid\n // remounting just because a parent React render recreated the props object.\n }, [component, runtime]);\n\n if (mountError) throw mountError;\n return <div ref={targetRef} />;\n}\n"],"mappings":";;;;;;AAAA,SAAS,iBAAiB,QAAQ,gBAAgB;AAyD5C;AA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AY,OAAM;AACtB,SAAO,oBAAC,SAAI,KAAK,WAAW;AAC9B;","names":[]}
1
+ {"version":3,"sources":["../../canvas/svelte.tsx"],"sourcesContent":["import { useLayoutEffect, useRef, useState } from \"react\";\n\nimport {\n StoryboardSlot,\n type StoryboardLayout,\n type StoryboardVrtConfig,\n} from \"./storyboard\";\n\n/** Public Svelte 5 component call shape. This Svelte-specific entrypoint keeps\n * React-only consumers of tempo-sdk/canvas from resolving the optional Svelte\n * peer dependency. */\nexport type SvelteComponent<\n Props extends Record<string, unknown> = Record<string, unknown>,\n> = import(\"svelte\").Component<Props>;\n\ntype SvelteRuntime = typeof import(\"svelte\");\ntype SvelteRuntimeState =\n | { kind: \"pending\"; promise: Promise<void> }\n | { kind: \"ready\"; runtime: SvelteRuntime }\n | { kind: \"error\"; error: unknown };\n\nlet svelteRuntimeState: SvelteRuntimeState | null = null;\n\n/** Suspense resource for the optional Svelte runtime. The storyboard must not\n * report its React shell as rendered before the authored Svelte DOM exists,\n * otherwise the component projection opens with a permanent DOM-only\n * baseline. */\nfunction readSvelteRuntime(): SvelteRuntime {\n if (svelteRuntimeState?.kind === \"ready\") return svelteRuntimeState.runtime;\n if (svelteRuntimeState?.kind === \"error\") throw svelteRuntimeState.error;\n if (!svelteRuntimeState) {\n const promise = import(\"svelte\").then(\n (runtime) => {\n svelteRuntimeState = { kind: \"ready\", runtime };\n },\n (error: unknown) => {\n svelteRuntimeState = { kind: \"error\", error };\n },\n );\n svelteRuntimeState = { kind: \"pending\", promise };\n }\n throw svelteRuntimeState.promise;\n}\n\nexport function SvelteStoryboard<\n Props extends Record<string, unknown> = Record<string, unknown>,\n>({\n id,\n name,\n component,\n layout,\n props,\n vrt,\n ...annotations\n}: {\n id: string;\n component: SvelteComponent<Props>;\n layout: StoryboardLayout;\n name?: string;\n props?: Props;\n vrt?: boolean | StoryboardVrtConfig;\n} & Record<`data-tempo-${string}`, unknown>) {\n return (\n <StoryboardSlot\n data-tempo-hide-fiber=\"true\"\n id={id}\n name={name}\n layout={layout}\n kind=\"component\"\n uiFramework=\"svelte\"\n vrt={!!vrt}\n >\n <SvelteComponentMount component={component} props={props} />\n </StoryboardSlot>\n );\n}\n\nfunction SvelteComponentMount<Props extends Record<string, unknown>>({\n component,\n props,\n}: {\n component: SvelteComponent<Props>;\n props?: Props;\n}) {\n const targetRef = useRef<HTMLDivElement | null>(null);\n const [mountError, setMountError] = useState<unknown>(null);\n const runtime = readSvelteRuntime();\n\n useLayoutEffect(() => {\n const target = targetRef.current;\n if (!target) return;\n let mounted: Record<string, unknown> | null = null;\n try {\n mounted = runtime.mount(component as never, {\n target,\n props: props ?? ({} as Props),\n }) as Record<string, unknown>;\n runtime.flushSync();\n } catch (error) {\n setMountError(error);\n }\n\n return () => {\n const current = mounted;\n mounted = null;\n if (current) void runtime.unmount(current);\n target.replaceChildren();\n };\n // Svelte component props are explicit static storyboard inputs today.\n // Canvas source/HMR replaces the component module when they change; avoid\n // remounting just because a parent React render recreated the props object.\n }, [component, runtime]);\n\n if (mountError) throw mountError;\n return <div ref={targetRef} data-tempo-hide-fiber=\"true\" />;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,iBAAiB,QAAQ,gBAAgB;AAwE5C;AAnDN,IAAI,qBAAgD;AAMpD,SAAS,oBAAmC;AAC1C,MAAI,oBAAoB,SAAS,QAAS,QAAO,mBAAmB;AACpE,MAAI,oBAAoB,SAAS,QAAS,OAAM,mBAAmB;AACnE,MAAI,CAAC,oBAAoB;AACvB,UAAM,UAAU,OAAO,QAAQ,EAAE;AAAA,MAC/B,CAAC,YAAY;AACX,6BAAqB,EAAE,MAAM,SAAS,QAAQ;AAAA,MAChD;AAAA,MACA,CAAC,UAAmB;AAClB,6BAAqB,EAAE,MAAM,SAAS,MAAM;AAAA,MAC9C;AAAA,IACF;AACA,yBAAqB,EAAE,MAAM,WAAW,QAAQ;AAAA,EAClD;AACA,QAAM,mBAAmB;AAC3B;AAEO,SAAS,iBAEd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAO6C;AAC3C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,yBAAsB;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAK;AAAA,MACL,aAAY;AAAA,MACZ,KAAK,CAAC,CAAC;AAAA,MAEP,8BAAC,wBAAqB,WAAsB,OAAc;AAAA;AAAA,EAC5D;AAEJ;AAEA,SAAS,qBAA4D;AAAA,EACnE;AAAA,EACA;AACF,GAGG;AACD,QAAM,YAAY,OAA8B,IAAI;AACpD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAkB,IAAI;AAC1D,QAAM,UAAU,kBAAkB;AAElC,kBAAgB,MAAM;AACpB,UAAM,SAAS,UAAU;AACzB,QAAI,CAAC,OAAQ;AACb,QAAI,UAA0C;AAC9C,QAAI;AACF,gBAAU,QAAQ,MAAM,WAAoB;AAAA,QAC1C;AAAA,QACA,OAAO,SAAU,CAAC;AAAA,MACpB,CAAC;AACD,cAAQ,UAAU;AAAA,IACpB,SAAS,OAAO;AACd,oBAAc,KAAK;AAAA,IACrB;AAEA,WAAO,MAAM;AACX,YAAM,UAAU;AAChB,gBAAU;AACV,UAAI,QAAS,MAAK,QAAQ,QAAQ,OAAO;AACzC,aAAO,gBAAgB;AAAA,IACzB;AAAA,EAIF,GAAG,CAAC,WAAW,OAAO,CAAC;AAEvB,MAAI,WAAY,OAAM;AACtB,SAAO,oBAAC,SAAI,KAAK,WAAW,yBAAsB,QAAO;AAC3D;","names":[]}
@@ -0,0 +1,219 @@
1
+ // ../../modules/annotation/source-version.ts
2
+ function sourceVersionHash(content) {
3
+ let djb2 = 5381;
4
+ let sdbm = 0;
5
+ for (let i = 0; i < content.length; i++) {
6
+ const c = content.charCodeAt(i);
7
+ djb2 = (djb2 << 5) + djb2 ^ c;
8
+ sdbm = c + (sdbm << 6) + (sdbm << 16) - sdbm | 0;
9
+ }
10
+ return toHex8(djb2) + toHex8(sdbm);
11
+ }
12
+ function toHex8(n) {
13
+ return (n >>> 0).toString(16).padStart(8, "0");
14
+ }
15
+
16
+ // annotation-strategy.ts
17
+ import { realpathSync, statSync } from "fs";
18
+ import { relative } from "path";
19
+
20
+ // ../../modules/annotation/expression-facts.ts
21
+ var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
22
+ var DYNAMIC_SLOT_FACT = "#slot";
23
+ function expressionFacts(element, parentType) {
24
+ const opening = element.openingElement;
25
+ const attributes = opening.attributes;
26
+ const facts = [];
27
+ if (parentType !== "JSXElement" && parentType !== "JSXFragment")
28
+ facts.push(DYNAMIC_SLOT_FACT);
29
+ const last = /* @__PURE__ */ new Map();
30
+ attributes.forEach((attribute, index) => {
31
+ const name = attributeName(attribute);
32
+ if (name !== null) last.set(name, index);
33
+ });
34
+ let lastSpread = -1;
35
+ attributes.forEach((attribute, index) => {
36
+ if (attribute.type === "JSXSpreadAttribute") lastSpread = index;
37
+ });
38
+ for (const [name, index] of last) {
39
+ if (unstamped(name)) continue;
40
+ const overridden = index < lastSpread;
41
+ const value = attributes[index].value;
42
+ if (value === null) continue;
43
+ if (name === "style" && !overridden) {
44
+ facts.push(...styleFacts(value));
45
+ continue;
46
+ }
47
+ if (overridden || !isLiteralValue(value)) facts.push(name);
48
+ }
49
+ if (facts.length > 0) return facts.join(" ");
50
+ return lastSpread >= 0 ? "" : void 0;
51
+ }
52
+ function attributeName(attribute) {
53
+ if (attribute.type !== "JSXAttribute") return null;
54
+ const name = attribute.name;
55
+ if (name.type === "JSXIdentifier") return name.name;
56
+ if (name.type === "JSXNamespacedName") {
57
+ const namespace = name.namespace.name;
58
+ return `${namespace}:${name.name.name}`;
59
+ }
60
+ return null;
61
+ }
62
+ function unstamped(name) {
63
+ return name === "key" || name.startsWith("data-tempo-");
64
+ }
65
+ function styleFacts(value) {
66
+ const expression = value.type === "JSXExpressionContainer" ? unwrap(value.expression) : value;
67
+ if (expression.type !== "ObjectExpression") return ["style"];
68
+ const properties = expression.properties;
69
+ const last = /* @__PURE__ */ new Map();
70
+ properties.forEach((property, index) => {
71
+ const key = styleKey(property);
72
+ if (key !== null) last.set(key, index);
73
+ });
74
+ const facts = [];
75
+ for (const [key, index] of last) {
76
+ const property = properties[index];
77
+ const overridden = properties.slice(index + 1).some((later) => later.type === "SpreadElement" || later.computed);
78
+ const literal = property.type !== "ObjectMethod" && !property.shorthand && isLiteral(property.value);
79
+ if (overridden || !literal) facts.push(`style.${key}`);
80
+ }
81
+ return facts;
82
+ }
83
+ function styleKey(property) {
84
+ const isProperty = property.type === "Property" || property.type === "ObjectProperty" || property.type === "ObjectMethod";
85
+ if (!isProperty || property.computed) return null;
86
+ const key = property.key;
87
+ if (key.type === "Identifier") return key.name;
88
+ const isString = (key.type === "Literal" || key.type === "StringLiteral") && typeof key.value === "string";
89
+ return isString ? key.value : null;
90
+ }
91
+ function isLiteralValue(value) {
92
+ if (value.type === "Literal" || value.type === "StringLiteral") return true;
93
+ if (value.type !== "JSXExpressionContainer") return false;
94
+ return isLiteral(value.expression);
95
+ }
96
+ function isLiteral(node) {
97
+ const current = unwrap(node);
98
+ if (current.type === "UnaryExpression") {
99
+ const signed = current.operator === "-" || current.operator === "+";
100
+ return signed && isNumber(current.argument);
101
+ }
102
+ if (isNumber(current)) return true;
103
+ if (current.type === "StringLiteral" || current.type === "BooleanLiteral")
104
+ return true;
105
+ const value = current.value;
106
+ return current.type === "Literal" && (typeof value === "string" || typeof value === "boolean");
107
+ }
108
+ function isNumber(node) {
109
+ const numeric = node.type === "Literal" || node.type === "NumericLiteral";
110
+ return numeric && typeof node.value === "number" && Number.isFinite(node.value);
111
+ }
112
+ function unwrap(node) {
113
+ let current = node;
114
+ while (current.type === "ParenthesizedExpression")
115
+ current = current.expression;
116
+ return current;
117
+ }
118
+
119
+ // annotation-strategy.ts
120
+ var HTML_VOID_ELEMENTS = /* @__PURE__ */ new Set([
121
+ "area",
122
+ "base",
123
+ "br",
124
+ "col",
125
+ "embed",
126
+ "hr",
127
+ "img",
128
+ "input",
129
+ "link",
130
+ "meta",
131
+ "param",
132
+ "source",
133
+ "track",
134
+ "wbr"
135
+ ]);
136
+ function isIntrinsicElement(tagName) {
137
+ return tagName.length > 0 && tagName[0] === tagName[0].toLowerCase();
138
+ }
139
+ function hasJsxAttribute(info, attrName) {
140
+ for (const attr of info.element.openingElement.attributes) {
141
+ const name = attr.name;
142
+ if (name?.name === attrName) return true;
143
+ }
144
+ return false;
145
+ }
146
+ function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion) {
147
+ return {
148
+ "data-tempo-filepath": filepath,
149
+ "data-tempo-position": info.element.openingElement.start,
150
+ "data-tempo-modifiedts": modifiedtsMs,
151
+ // Content-hash identity of the file this element was annotated from. The
152
+ // canvas reconcile loop equality-compares it against the write pipeline's
153
+ // computed version to decide whether a capture reflects a given edit.
154
+ "data-tempo-source-version": sourceVersion
155
+ };
156
+ }
157
+ function appendModuleVersionRecord(source, filepath, modifiedtsMs, sourceVersion) {
158
+ const record = JSON.stringify({
159
+ file: filepath,
160
+ modifiedTs: modifiedtsMs,
161
+ sourceVersion
162
+ });
163
+ return `${source}
164
+ ;typeof window !== "undefined" && (globalThis.__TEMPO_MODULE_VERSIONS__ || (globalThis.__TEMPO_MODULE_VERSIONS__ = [])).push(${record});
165
+ `;
166
+ }
167
+ function computeTempoAnnotatedProps(params) {
168
+ const {
169
+ info,
170
+ filepath,
171
+ modifiedtsMs,
172
+ sourceVersion,
173
+ computeAnnotatedProps,
174
+ elementSupportOverrides
175
+ } = params;
176
+ const userProps = {
177
+ ...computeAnnotatedProps ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion) : defaultComputeAnnotatedProps(
178
+ info,
179
+ filepath,
180
+ modifiedtsMs,
181
+ sourceVersion
182
+ ),
183
+ // Only a caller that knows the parent can say whether the slot is a JSX
184
+ // child; without it every element would read as a dynamic slot.
185
+ ...info.parentType !== void 0 && !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE) ? {
186
+ [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(
187
+ info.element,
188
+ info.parentType
189
+ )
190
+ } : {}
191
+ };
192
+ if (isIntrinsicElement(info.tagName)) {
193
+ return {
194
+ ...userProps,
195
+ "data-tempo-supports-children": hasJsxAttribute(
196
+ info,
197
+ "data-tempo-supports-children"
198
+ ) ? void 0 : !HTML_VOID_ELEMENTS.has(info.tagName)
199
+ };
200
+ }
201
+ const override = elementSupportOverrides?.get(info.tagName);
202
+ if (override) {
203
+ return {
204
+ ...userProps,
205
+ "data-tempo-supports-children": hasJsxAttribute(
206
+ info,
207
+ "data-tempo-supports-children"
208
+ ) ? void 0 : override.supportsChildren
209
+ };
210
+ }
211
+ return userProps;
212
+ }
213
+
214
+ export {
215
+ sourceVersionHash,
216
+ appendModuleVersionRecord,
217
+ computeTempoAnnotatedProps
218
+ };
219
+ //# sourceMappingURL=chunk-2IQD2KPS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../modules/annotation/source-version.ts","../annotation-strategy.ts","../../../modules/annotation/expression-facts.ts"],"sourcesContent":["/**\n * Canvas source-version identity.\n *\n * `sourceVersionHash` maps the exact text of a source file to a 16-hex-character\n * token identifying that content. It is the version stamp the canvas edit/\n * reconcile loop uses to answer \"has the host caught up to write W?\": the SDK\n * JSX transforms stamp `data-tempo-source-version` with the hash of the source\n * they annotate, and the write pipeline (`applyWrites` → `sourceVersionsByFile`)\n * reports the hash of the exact bytes it wrote. A captured element's stamp is\n * compared for EQUALITY against a write's version — never ordered, never\n * subtracted, never used as a high-water mark. Two identical contents MUST\n * produce the same token; two different contents MUST (for identity purposes)\n * produce different tokens.\n *\n * Because coverage is an equality test across independently-computed hashes,\n * every producer of a version — this function's callers in the vite/next/expo\n * transforms and in `applyWrites` — MUST route through THIS function so the\n * tokens are bit-identical. Changing the algorithm requires changing it for all\n * producers in lockstep, or old stamps and new write-versions stop matching.\n *\n * The token concatenates two independent 32-bit rolling hashes over the string's\n * UTF-16 code units — djb2 and sdbm — each rendered as unsigned 8-char hex. Two\n * independent hash families make an accidental collision between distinct source\n * contents vanishingly unlikely for version-identity use, while the function\n * stays dependency-free and single-pass (fast enough to run once per file per\n * transform on the devserver hot path).\n */\nexport function sourceVersionHash(content: string): string {\n let djb2 = 5381;\n let sdbm = 0;\n for (let i = 0; i < content.length; i++) {\n const c = content.charCodeAt(i);\n // djb2: hash * 33 ^ c. The trailing `^ c` keeps the value inside 32-bit\n // signed range every iteration, so no explicit coercion is needed.\n djb2 = ((djb2 << 5) + djb2) ^ c;\n // sdbm: c + hash*65599. The final term is an arithmetic subtraction, so\n // coerce back to a 32-bit int each step to prevent float drift.\n sdbm = (c + (sdbm << 6) + (sdbm << 16) - sdbm) | 0;\n }\n return toHex8(djb2) + toHex8(sdbm);\n}\n\n/** Render a 32-bit value as unsigned, zero-padded 8-char lowercase hex. */\nfunction toHex8(n: number): string {\n return (n >>> 0).toString(16).padStart(8, \"0\");\n}\n","import { realpathSync, statSync } from \"node:fs\";\nimport { relative } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n EXPRESSION_FACTS_ATTRIBUTE,\n expressionFacts,\n} from \"../../modules/annotation/expression-facts.ts\";\nimport { sourceVersionHash } from \"../../modules/annotation/source-version.ts\";\n\nexport const DEFAULT_EXCLUDE = [\"**/node_modules/**\"] as const;\n\n/**\n * Static per-component declaration of whether a custom component accepts\n * `children`. Supplied by callers that know this from a fixed table (e.g. the\n * Expo plugin's React Native host-component overrides). The Vite/Next.js\n * plugins supply no overrides — custom components are left without a\n * `supports-children` flag and consumers treat their support as unknown.\n */\nexport interface ElementTypeSupport {\n supportsChildren: boolean;\n}\n\n/** HTML void elements that cannot have children (self-closing only). */\nexport const HTML_VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n) => Record<string, PropValue>;\n\nexport function cleanModuleId(id: string): string {\n return id.replace(/[?#].*$/, \"\");\n}\n\nexport function resolveCanonicalRoot(root: string): string {\n try {\n return realpathSync.native(root);\n } catch {\n return root;\n }\n}\n\nexport function isIntrinsicElement(tagName: string): boolean {\n return tagName.length > 0 && tagName[0] === tagName[0]!.toLowerCase();\n}\n\nexport function hasJsxAttribute(info: ElementInfo, attrName: string): boolean {\n for (const attr of info.element.openingElement.attributes) {\n const name = (attr as { name?: { name?: unknown } }).name;\n if (name?.name === attrName) return true;\n }\n return false;\n}\n\nexport function defaultComputeAnnotatedProps(\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): Record<string, PropValue> {\n return {\n \"data-tempo-filepath\": filepath,\n \"data-tempo-position\": info.element.openingElement.start,\n \"data-tempo-modifiedts\": modifiedtsMs,\n // Content-hash identity of the file this element was annotated from. The\n // canvas reconcile loop equality-compares it against the write pipeline's\n // computed version to decide whether a capture reflects a given edit.\n \"data-tempo-source-version\": sourceVersion,\n };\n}\n\n/**\n * Appends the module version record: one guarded statement that runs when the\n * browser evaluates the module and pushes `{file, modifiedTs, sourceVersion}`\n * onto `globalThis.__TEMPO_MODULE_VERSIONS__`, keyed by the same `filepath`\n * the element stamps carry. The projection producer joins these records to\n * React's refresh so the canvas learns that a write reached the host even\n * when the write left no element of the file on a board (V2-498).\n *\n * It is appended to every filtered module, JSX or not: a write that removes a\n * file's last element is exactly the case that needs it. It goes at the end\n * so it never displaces a leading directive such as \"use client\", and adds no\n * line above existing code so positions and source maps are unchanged. The\n * `window` guard keeps server-side evaluation (Next server components, SSR)\n * from recording anything.\n */\nexport function appendModuleVersionRecord(\n source: string,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): string {\n const record = JSON.stringify({\n file: filepath,\n modifiedTs: modifiedtsMs,\n sourceVersion,\n });\n return `${source}\\n;typeof window !== \"undefined\" && (globalThis.__TEMPO_MODULE_VERSIONS__ || (globalThis.__TEMPO_MODULE_VERSIONS__ = [])).push(${record});\\n`;\n}\n\nexport function computeTempoAnnotatedProps(params: {\n info: ElementInfo;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n elementSupportOverrides?: ReadonlyMap<string, ElementTypeSupport>;\n}): Record<string, PropValue> {\n const {\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n computeAnnotatedProps,\n elementSupportOverrides,\n } = params;\n\n const userProps = {\n ...(computeAnnotatedProps\n ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion)\n : defaultComputeAnnotatedProps(\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n )),\n // Only a caller that knows the parent can say whether the slot is a JSX\n // child; without it every element would read as a dynamic slot.\n ...(info.parentType !== undefined &&\n !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE)\n ? {\n [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(\n info.element,\n info.parentType,\n ),\n }\n : {}),\n };\n\n if (isIntrinsicElement(info.tagName)) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : !HTML_VOID_ELEMENTS.has(info.tagName),\n };\n }\n\n const override = elementSupportOverrides?.get(info.tagName);\n if (override) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : override.supportsChildren,\n };\n }\n\n // Custom component with no static override: emit no `data-tempo-supports-*`\n // flags. Determining them required a per-file TypeScript program, which was\n // removed for being the dominant cost of devserver startup. Consumers treat\n // the absent flags as \"unknown\" and fall back to their own defaults.\n return userProps;\n}\n\nexport function getFileAnnotationContext(params: {\n source: string;\n filename: string;\n root: string;\n canonicalizeFilename?: boolean;\n}): {\n cleanFilename: string;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n} {\n const rawCleanFilename = cleanModuleId(params.filename);\n let cleanFilename = rawCleanFilename;\n if (params.canonicalizeFilename) {\n try {\n cleanFilename = realpathSync.native(rawCleanFilename);\n } catch {\n cleanFilename = rawCleanFilename;\n }\n }\n return {\n cleanFilename,\n filepath: relative(params.root, cleanFilename),\n modifiedtsMs: Math.trunc(statSync(cleanFilename).mtimeMs),\n // Hashed once per file per transform (the context is built once, reused\n // for every element) so the per-element funnel just forwards the token.\n sourceVersion: sourceVersionHash(params.source),\n };\n}\n","/**\n * Expression facts: which parts of one JSX element's source are runtime\n * expressions, stamped as `data-tempo-expr` so the canvas can know before an\n * edit that the edit's operand is not literal source.\n *\n * The value is a space-separated token list. Each token is a fact, never a\n * decision:\n * - `#slot`: the element's own slot is not a JSX child. Its syntactic parent\n * is a `.map` callback, a conditional, a `return`, a prop value or a `{}`\n * container. The `#` keeps it apart from attribute names.\n * - `<name>`: the attribute is written at the callsite and its value is an\n * expression, or a later spread may override it.\n * - `style` alone: the style value is not an object literal, or a later\n * spread may override it. Every style key is then an expression.\n * - `style.<key>`: that key of a style object literal is an expression, a\n * shorthand, or a later spread or computed key may override it.\n *\n * A fact is written only when the file proves it, and exactly where the\n * checked writer refuses (`main/literal-writes.ts` planAttribute and\n * planInlineStyles, `astParentKind` for the slot; pinned cell by cell in\n * `literal-writes.expression-facts.test.ts`). Both read JSX in order:\n * - a spread (or a computed key in a style object) overrides only what comes\n * before it, so an attribute or key before one is a fact and one after it\n * is not;\n * - of repeated occurrences the last renders, so only the last is judged\n * and the writer edits that one.\n * What the file leaves open, such as an attribute absent at a callsite with\n * a spread, gets no token.\n *\n * Works on oxc (ESTree) and Babel JSX trees alike.\n */\n\nexport const EXPRESSION_FACTS_ATTRIBUTE = \"data-tempo-expr\";\nexport const DYNAMIC_SLOT_FACT = \"#slot\";\n\ntype Node = { type: string; [key: string]: unknown };\n\n/**\n * The stamp for one element, or undefined when there is nothing to write.\n * An element with a spread attribute always gets a stamp, empty when it has\n * no fact: annotations land after every spread, so its own value replaces\n * one a caller's props would otherwise carry onto it.\n */\nexport function expressionFacts(\n element: unknown,\n parentType: string | null,\n): string | undefined {\n const opening = (element as { openingElement: { attributes: Node[] } })\n .openingElement;\n const attributes = opening.attributes;\n const facts: string[] = [];\n if (parentType !== \"JSXElement\" && parentType !== \"JSXFragment\")\n facts.push(DYNAMIC_SLOT_FACT);\n\n // The writer reads an attribute's last occurrence, so only that one counts.\n const last = new Map<string, number>();\n attributes.forEach((attribute, index) => {\n const name = attributeName(attribute);\n if (name !== null) last.set(name, index);\n });\n let lastSpread = -1;\n attributes.forEach((attribute, index) => {\n if (attribute.type === \"JSXSpreadAttribute\") lastSpread = index;\n });\n for (const [name, index] of last) {\n if (unstamped(name)) continue;\n const overridden = index < lastSpread;\n const value = attributes[index]!.value as Node | null;\n // A bare attribute is `true`, not an expression.\n if (value === null) continue;\n if (name === \"style\" && !overridden) {\n facts.push(...styleFacts(value));\n continue;\n }\n if (overridden || !isLiteralValue(value)) facts.push(name);\n }\n\n if (facts.length > 0) return facts.join(\" \");\n return lastSpread >= 0 ? \"\" : undefined;\n}\n\n/** The facts one stamp holds, the inverse of `expressionFacts`. No stamp\n * holds none. */\nexport function stampedFacts(stamp: string | undefined): ReadonlySet<string> {\n return new Set((stamp ?? \"\").split(\" \").filter(Boolean));\n}\n\nfunction attributeName(attribute: Node): string | null {\n if (attribute.type !== \"JSXAttribute\") return null;\n const name = attribute.name as Node;\n if (name.type === \"JSXIdentifier\") return name.name as string;\n if (name.type === \"JSXNamespacedName\") {\n const namespace = (name.namespace as Node).name as string;\n return `${namespace}:${(name.name as Node).name as string}`;\n }\n return null;\n}\n\n/** Props the stamp leaves out: Tempo's own annotations, and `key`, which\n * the canvas reads from the layer. A handler, `ref` or `children` is\n * stamped although no canvas edit writes it: it renders no DOM attribute,\n * so this is where the canvas learns that an element is not plain rich\n * text (review2 r2 R3-A: un-bold of `<b onClick={f}>` deleted the handler). */\nfunction unstamped(name: string): boolean {\n return name === \"key\" || name.startsWith(\"data-tempo-\");\n}\n\nfunction styleFacts(value: Node): string[] {\n const expression =\n value.type === \"JSXExpressionContainer\"\n ? unwrap(value.expression as Node)\n : value;\n if (expression.type !== \"ObjectExpression\") return [\"style\"];\n const properties = expression.properties as Node[];\n const last = new Map<string, number>();\n properties.forEach((property, index) => {\n const key = styleKey(property);\n if (key !== null) last.set(key, index);\n });\n const facts: string[] = [];\n for (const [key, index] of last) {\n const property = properties[index]!;\n const overridden = properties\n .slice(index + 1)\n .some((later) => later.type === \"SpreadElement\" || later.computed);\n const literal =\n property.type !== \"ObjectMethod\" &&\n !property.shorthand &&\n isLiteral(property.value as Node);\n if (overridden || !literal) facts.push(`style.${key}`);\n }\n return facts;\n}\n\n/** A property's key as the writer names it; computed keys have no name. */\nfunction styleKey(property: Node): string | null {\n const isProperty =\n property.type === \"Property\" ||\n property.type === \"ObjectProperty\" ||\n property.type === \"ObjectMethod\";\n if (!isProperty || property.computed) return null;\n const key = property.key as Node;\n if (key.type === \"Identifier\") return key.name as string;\n const isString =\n (key.type === \"Literal\" || key.type === \"StringLiteral\") &&\n typeof key.value === \"string\";\n return isString ? (key.value as string) : null;\n}\n\n/** An attribute value the writer can rewrite in place: a JSX string, or a\n * container holding one literal. */\nfunction isLiteralValue(value: Node): boolean {\n if (value.type === \"Literal\" || value.type === \"StringLiteral\") return true;\n if (value.type !== \"JSXExpressionContainer\") return false;\n return isLiteral(value.expression as Node);\n}\n\n/** The writer's literal: a string, a finite number, a boolean, or a signed\n * number, inside any parentheses. */\nfunction isLiteral(node: Node): boolean {\n const current = unwrap(node);\n if (current.type === \"UnaryExpression\") {\n const signed = current.operator === \"-\" || current.operator === \"+\";\n return signed && isNumber(current.argument as Node);\n }\n if (isNumber(current)) return true;\n if (current.type === \"StringLiteral\" || current.type === \"BooleanLiteral\")\n return true;\n const value = current.value;\n return (\n current.type === \"Literal\" &&\n (typeof value === \"string\" || typeof value === \"boolean\")\n );\n}\n\nfunction isNumber(node: Node): boolean {\n const numeric = node.type === \"Literal\" || node.type === \"NumericLiteral\";\n return (\n numeric && typeof node.value === \"number\" && Number.isFinite(node.value)\n );\n}\n\nfunction unwrap(node: Node): Node {\n let current = node;\n while (current.type === \"ParenthesizedExpression\")\n current = current.expression as Node;\n return current;\n}\n"],"mappings":";AA2BO,SAAS,kBAAkB,SAAyB;AACzD,MAAI,OAAO;AACX,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,UAAM,IAAI,QAAQ,WAAW,CAAC;AAG9B,YAAS,QAAQ,KAAK,OAAQ;AAG9B,WAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,OAAQ;AAAA,EACnD;AACA,SAAO,OAAO,IAAI,IAAI,OAAO,IAAI;AACnC;AAGA,SAAS,OAAO,GAAmB;AACjC,UAAQ,MAAM,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC/C;;;AC7CA,SAAS,cAAc,gBAAgB;AACvC,SAAS,gBAAgB;;;AC+BlB,IAAM,6BAA6B;AACnC,IAAM,oBAAoB;AAU1B,SAAS,gBACd,SACA,YACoB;AACpB,QAAM,UAAW,QACd;AACH,QAAM,aAAa,QAAQ;AAC3B,QAAM,QAAkB,CAAC;AACzB,MAAI,eAAe,gBAAgB,eAAe;AAChD,UAAM,KAAK,iBAAiB;AAG9B,QAAM,OAAO,oBAAI,IAAoB;AACrC,aAAW,QAAQ,CAAC,WAAW,UAAU;AACvC,UAAM,OAAO,cAAc,SAAS;AACpC,QAAI,SAAS,KAAM,MAAK,IAAI,MAAM,KAAK;AAAA,EACzC,CAAC;AACD,MAAI,aAAa;AACjB,aAAW,QAAQ,CAAC,WAAW,UAAU;AACvC,QAAI,UAAU,SAAS,qBAAsB,cAAa;AAAA,EAC5D,CAAC;AACD,aAAW,CAAC,MAAM,KAAK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