tempo-sdk 0.0.89 → 0.0.92
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.
- package/dist/astro.js +7 -7
- package/dist/canvas/editor.js +1 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.js +9 -1
- package/dist/canvas/svelte.js.map +1 -1
- package/dist/{chunk-2ZQMVAFM.js → chunk-6SOP4XU6.js} +98 -33
- package/dist/chunk-6SOP4XU6.js.map +1 -0
- package/dist/{chunk-Y72PIE3I.js → chunk-AFXE462X.js} +5 -4
- package/dist/{chunk-Y72PIE3I.js.map → chunk-AFXE462X.js.map} +1 -1
- package/dist/{chunk-DMT5MRMS.js → chunk-BQPKOVI5.js} +4 -3
- package/dist/{chunk-DMT5MRMS.js.map → chunk-BQPKOVI5.js.map} +1 -1
- package/dist/{chunk-SLAZCXFE.js → chunk-FENUT2N2.js} +2 -2
- package/dist/{chunk-SLAZCXFE.js.map → chunk-FENUT2N2.js.map} +1 -1
- package/dist/{chunk-H6OZIX2U.js → chunk-FGWGY3G3.js} +27 -3
- package/dist/chunk-FGWGY3G3.js.map +1 -0
- package/dist/{chunk-X5ORR3FI.js → chunk-KQSOE4KZ.js} +7 -7
- package/dist/chunk-MU7S7NU7.js +183 -0
- package/dist/chunk-MU7S7NU7.js.map +1 -0
- package/dist/{chunk-GZ6KY7ZF.js → chunk-RZ3TG6MV.js} +2 -2
- package/dist/{chunk-GZ6KY7ZF.js.map → chunk-RZ3TG6MV.js.map} +1 -1
- package/dist/{chunk-3JR2JRSV.js → chunk-TWW2DL7E.js} +2 -2
- package/dist/{chunk-3JR2JRSV.js.map → chunk-TWW2DL7E.js.map} +1 -1
- package/dist/{chunk-5VIBKVFO.js → chunk-U66QI3EN.js} +28 -18
- package/dist/chunk-U66QI3EN.js.map +1 -0
- package/dist/{controls-reader-Z7OQWYWQ.js → controls-reader-5MFHYBZZ.js} +4 -4
- package/dist/expo/plugin.cjs +97 -32
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +97 -32
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +2 -0
- package/dist/expo-babel-plugin.d.ts +2 -0
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -6
- package/dist/nextjs/plugin.cjs +1 -1
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +126 -37
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +1 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +2 -0
- package/dist/nextjs.d.ts +2 -0
- package/dist/nextjs.js +1 -1
- package/dist/nuxt/runtime/identity.js +1 -1
- package/dist/nuxt.js +230 -53
- package/dist/nuxt.js.map +1 -1
- package/dist/svelte.js +99 -24
- package/dist/svelte.js.map +1 -1
- package/dist/vue.js +120 -22
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2ZQMVAFM.js.map +0 -1
- package/dist/chunk-5VIBKVFO.js.map +0 -1
- package/dist/chunk-H6BQZOAW.js +0 -121
- package/dist/chunk-H6BQZOAW.js.map +0 -1
- package/dist/chunk-H6OZIX2U.js.map +0 -1
- /package/dist/{chunk-X5ORR3FI.js.map → chunk-KQSOE4KZ.js.map} +0 -0
- /package/dist/{controls-reader-Z7OQWYWQ.js.map → controls-reader-5MFHYBZZ.js.map} +0 -0
package/dist/astro.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
annotateAstroSource,
|
|
3
3
|
parseAstroSource
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U66QI3EN.js";
|
|
5
5
|
import "./chunk-EGRHWZRV.js";
|
|
6
6
|
import {
|
|
7
7
|
MagicString
|
|
8
8
|
} from "./chunk-JVVHU3A7.js";
|
|
9
9
|
import {
|
|
10
10
|
tempoVitePlugin
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-KQSOE4KZ.js";
|
|
12
12
|
import "./chunk-PYAJHLXO.js";
|
|
13
13
|
import "./chunk-DI2ZFAWL.js";
|
|
14
14
|
import {
|
|
15
15
|
TEMPO_HOST_IDENTITY_CAPABILITY_HEADER,
|
|
16
16
|
TEMPO_HOST_IDENTITY_ENDPOINT,
|
|
17
17
|
createTempoHostIdentity
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-TWW2DL7E.js";
|
|
19
|
+
import "./chunk-BQPKOVI5.js";
|
|
20
|
+
import "./chunk-FGWGY3G3.js";
|
|
21
21
|
import {
|
|
22
22
|
sourceVersionHash
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MU7S7NU7.js";
|
|
24
24
|
import {
|
|
25
25
|
componentFrameworkForStoryboard,
|
|
26
26
|
parseCanvasFile
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-AFXE462X.js";
|
|
28
28
|
import "./chunk-5HIIF354.js";
|
|
29
29
|
import "./chunk-WTXOWQ7N.js";
|
|
30
30
|
import "./chunk-65B52AR7.js";
|
package/dist/canvas/editor.js
CHANGED
package/dist/canvas/parser.js
CHANGED
package/dist/canvas/svelte.js
CHANGED
|
@@ -47,6 +47,13 @@ function SvelteStoryboard({
|
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
+
function svelteComponentIdentity(component) {
|
|
51
|
+
const symbol = Object.getOwnPropertySymbols(component).find(
|
|
52
|
+
(symbol2) => symbol2.description === "hmr"
|
|
53
|
+
);
|
|
54
|
+
const hmr = symbol ? Reflect.get(component, symbol) : null;
|
|
55
|
+
return hmr && typeof hmr === "object" && typeof hmr.fn === "function" && typeof hmr.update === "function" && hmr.current !== null && typeof hmr.current === "object" ? hmr.current : component;
|
|
56
|
+
}
|
|
50
57
|
function SvelteComponentMount({
|
|
51
58
|
component,
|
|
52
59
|
props
|
|
@@ -54,6 +61,7 @@ function SvelteComponentMount({
|
|
|
54
61
|
const targetRef = useRef(null);
|
|
55
62
|
const [mountError, setMountError] = useState(null);
|
|
56
63
|
const runtime = readSvelteRuntime();
|
|
64
|
+
const componentIdentity = svelteComponentIdentity(component);
|
|
57
65
|
useLayoutEffect(() => {
|
|
58
66
|
const target = targetRef.current;
|
|
59
67
|
if (!target) return;
|
|
@@ -73,7 +81,7 @@ function SvelteComponentMount({
|
|
|
73
81
|
if (current) void runtime.unmount(current);
|
|
74
82
|
target.replaceChildren();
|
|
75
83
|
};
|
|
76
|
-
}, [
|
|
84
|
+
}, [componentIdentity, runtime]);
|
|
77
85
|
if (mountError) throw mountError;
|
|
78
86
|
return /* @__PURE__ */ jsx("div", { ref: targetRef, "data-tempo-hide-fiber": "true" });
|
|
79
87
|
}
|
|
@@ -1 +1 @@
|
|
|
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 //
|
|
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\n/** Svelte's dev HMR exports a new function on every evaluation, but its\n * current signal names the existing live component family. Preserve that\n * mounted wrapper: remounting a later export disconnects the DOM from the\n * signal updated by subsequent hot updates. Production components and actual\n * component replacements retain their ordinary function identity.\n *\n * The optional Svelte 5 compiler HMR protocol uses a private symbol. Inspect\n * its full shape conservatively; unknown runtimes keep normal remounting.\n */\nfunction svelteComponentIdentity(component: object): object {\n const symbol = Object.getOwnPropertySymbols(component).find(\n (symbol) => symbol.description === \"hmr\",\n );\n const hmr = symbol ? Reflect.get(component, symbol) : null;\n return hmr &&\n typeof hmr === \"object\" &&\n typeof hmr.fn === \"function\" &&\n typeof hmr.update === \"function\" &&\n hmr.current !== null &&\n typeof hmr.current === \"object\"\n ? hmr.current\n : component;\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 const componentIdentity = svelteComponentIdentity(component);\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 // Actual component-family replacement remounts; Svelte HMR updates its\n // existing family in place. Static storyboard props remain unchanged.\n }, [componentIdentity, 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;AAWA,SAAS,wBAAwB,WAA2B;AAC1D,QAAM,SAAS,OAAO,sBAAsB,SAAS,EAAE;AAAA,IACrD,CAACA,YAAWA,QAAO,gBAAgB;AAAA,EACrC;AACA,QAAM,MAAM,SAAS,QAAQ,IAAI,WAAW,MAAM,IAAI;AACtD,SAAO,OACL,OAAO,QAAQ,YACf,OAAO,IAAI,OAAO,cAClB,OAAO,IAAI,WAAW,cACtB,IAAI,YAAY,QAChB,OAAO,IAAI,YAAY,WACrB,IAAI,UACJ;AACN;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;AAClC,QAAM,oBAAoB,wBAAwB,SAAS;AAE3D,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,mBAAmB,OAAO,CAAC;AAE/B,MAAI,WAAY,OAAM;AACtB,SAAO,oBAAC,SAAI,KAAK,WAAW,yBAAsB,QAAO;AAC3D;","names":["symbol"]}
|
|
@@ -1053,10 +1053,11 @@ function readStringAttribute(openingElement, name) {
|
|
|
1053
1053
|
attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
|
|
1054
1054
|
};
|
|
1055
1055
|
}
|
|
1056
|
-
const expression = unwrapAttributeExpression(value);
|
|
1057
|
-
|
|
1056
|
+
const expression = unwrapTsExpression(unwrapAttributeExpression(value));
|
|
1057
|
+
const fixed = expression?.type === "Literal" && typeof expression.value === "string" ? expression.value : expression?.type === "TemplateLiteral" && (expression.expressions?.length ?? 0) === 0 && expression.quasis?.length === 1 && typeof expression.quasis[0]?.value?.cooked === "string" ? expression.quasis[0].value.cooked : null;
|
|
1058
|
+
if (fixed !== null) {
|
|
1058
1059
|
return {
|
|
1059
|
-
value:
|
|
1060
|
+
value: fixed,
|
|
1060
1061
|
valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },
|
|
1061
1062
|
attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
|
|
1062
1063
|
};
|
|
@@ -1292,14 +1293,75 @@ import { createFilter } from "@rollup/pluginutils";
|
|
|
1292
1293
|
import { realpathSync as realpathSync3, statSync } from "fs";
|
|
1293
1294
|
import { relative } from "path";
|
|
1294
1295
|
|
|
1296
|
+
// ../../modules/annotation/literal-expression.ts
|
|
1297
|
+
function unwrapLiteralExpression(node) {
|
|
1298
|
+
let current = node;
|
|
1299
|
+
while ([
|
|
1300
|
+
"ParenthesizedExpression",
|
|
1301
|
+
"TSAsExpression",
|
|
1302
|
+
"TSSatisfiesExpression",
|
|
1303
|
+
"TSTypeAssertion",
|
|
1304
|
+
"TSNonNullExpression",
|
|
1305
|
+
"TSInstantiationExpression"
|
|
1306
|
+
].includes(current.type)) {
|
|
1307
|
+
const expression = current.expression;
|
|
1308
|
+
if (!expression) break;
|
|
1309
|
+
current = expression;
|
|
1310
|
+
}
|
|
1311
|
+
return current;
|
|
1312
|
+
}
|
|
1313
|
+
function readLiteralExpression(node) {
|
|
1314
|
+
const value = unwrapLiteralExpression(node);
|
|
1315
|
+
if (["Literal", "StringLiteral", "NumericLiteral", "BooleanLiteral"].includes(
|
|
1316
|
+
value.type
|
|
1317
|
+
)) {
|
|
1318
|
+
if (typeof value.value === "string" || typeof value.value === "boolean")
|
|
1319
|
+
return value.value;
|
|
1320
|
+
if (typeof value.value === "number" && Number.isFinite(value.value))
|
|
1321
|
+
return value.value;
|
|
1322
|
+
}
|
|
1323
|
+
if (value.type === "TemplateLiteral") {
|
|
1324
|
+
const expressions = value.expressions;
|
|
1325
|
+
const quasis = value.quasis;
|
|
1326
|
+
if (expressions.length === 0 && quasis.length === 1 && typeof quasis[0]?.value.cooked === "string")
|
|
1327
|
+
return quasis[0].value.cooked;
|
|
1328
|
+
}
|
|
1329
|
+
if (value.type === "UnaryExpression" && (value.operator === "-" || value.operator === "+")) {
|
|
1330
|
+
const argument = readLiteralExpression(value.argument);
|
|
1331
|
+
if (typeof argument === "number")
|
|
1332
|
+
return value.operator === "-" ? -argument : argument;
|
|
1333
|
+
}
|
|
1334
|
+
if (value.type === "BinaryExpression" && ["+", "-", "*", "/"].includes(value.operator)) {
|
|
1335
|
+
const left = readLiteralExpression(value.left);
|
|
1336
|
+
const right = readLiteralExpression(value.right);
|
|
1337
|
+
if (typeof left !== "number" || typeof right !== "number") return null;
|
|
1338
|
+
const result = value.operator === "+" ? left + right : value.operator === "-" ? left - right : value.operator === "*" ? left * right : left / right;
|
|
1339
|
+
return Number.isFinite(result) ? result : null;
|
|
1340
|
+
}
|
|
1341
|
+
return null;
|
|
1342
|
+
}
|
|
1343
|
+
function literalJsxChild(node) {
|
|
1344
|
+
if (node.type !== "JSXExpressionContainer") return null;
|
|
1345
|
+
const root = unwrapLiteralExpression(
|
|
1346
|
+
node.expression
|
|
1347
|
+
);
|
|
1348
|
+
return root.type === "JSXElement" ? root : null;
|
|
1349
|
+
}
|
|
1350
|
+
function literalPropertyName(key, computed = false) {
|
|
1351
|
+
if (!computed && key.type === "Identifier")
|
|
1352
|
+
return typeof key.name === "string" ? key.name : null;
|
|
1353
|
+
const value = readLiteralExpression(key);
|
|
1354
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : null;
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1295
1357
|
// ../../modules/annotation/expression-facts.ts
|
|
1296
1358
|
var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
|
|
1297
1359
|
var DYNAMIC_SLOT_FACT = "#slot";
|
|
1298
|
-
function expressionFacts(element, parentType) {
|
|
1360
|
+
function expressionFacts(element, parentType, isStaticJsxChild = false) {
|
|
1299
1361
|
const opening = element.openingElement;
|
|
1300
1362
|
const attributes = opening.attributes;
|
|
1301
1363
|
const facts = [];
|
|
1302
|
-
if (parentType !== "JSXElement" && parentType !== "JSXFragment")
|
|
1364
|
+
if (!isStaticJsxChild && parentType !== "JSXElement" && parentType !== "JSXFragment")
|
|
1303
1365
|
facts.push(DYNAMIC_SLOT_FACT);
|
|
1304
1366
|
const last = /* @__PURE__ */ new Map();
|
|
1305
1367
|
attributes.forEach((attribute, index) => {
|
|
@@ -1319,7 +1381,9 @@ function expressionFacts(element, parentType) {
|
|
|
1319
1381
|
facts.push(...styleFacts(value));
|
|
1320
1382
|
continue;
|
|
1321
1383
|
}
|
|
1322
|
-
if (overridden
|
|
1384
|
+
if (overridden) facts.push(name);
|
|
1385
|
+
else if (name === "className" && isClassHelperCall(value)) continue;
|
|
1386
|
+
else if (!isLiteralValue(value)) facts.push(name);
|
|
1323
1387
|
}
|
|
1324
1388
|
if (facts.length > 0) return facts.join(" ");
|
|
1325
1389
|
return lastSpread >= 0 ? "" : void 0;
|
|
@@ -1349,7 +1413,9 @@ function styleFacts(value) {
|
|
|
1349
1413
|
const facts = [];
|
|
1350
1414
|
for (const [key, index] of last) {
|
|
1351
1415
|
const property = properties[index];
|
|
1352
|
-
const overridden = properties.slice(index + 1).some(
|
|
1416
|
+
const overridden = properties.slice(index + 1).some(
|
|
1417
|
+
(later) => later.type === "SpreadElement" || later.computed && styleKey(later) === null
|
|
1418
|
+
);
|
|
1353
1419
|
const literal = property.type !== "ObjectMethod" && !property.shorthand && isLiteral(property.value);
|
|
1354
1420
|
if (overridden || !literal) facts.push(`style.${key}`);
|
|
1355
1421
|
}
|
|
@@ -1357,38 +1423,31 @@ function styleFacts(value) {
|
|
|
1357
1423
|
}
|
|
1358
1424
|
function styleKey(property) {
|
|
1359
1425
|
const isProperty = property.type === "Property" || property.type === "ObjectProperty" || property.type === "ObjectMethod";
|
|
1360
|
-
if (!isProperty
|
|
1361
|
-
|
|
1362
|
-
if (key.type === "Identifier") return key.name;
|
|
1363
|
-
const isString = (key.type === "Literal" || key.type === "StringLiteral") && typeof key.value === "string";
|
|
1364
|
-
return isString ? key.value : null;
|
|
1426
|
+
if (!isProperty) return null;
|
|
1427
|
+
return literalPropertyName(property.key, Boolean(property.computed));
|
|
1365
1428
|
}
|
|
1366
1429
|
function isLiteralValue(value) {
|
|
1367
1430
|
if (value.type === "Literal" || value.type === "StringLiteral") return true;
|
|
1368
1431
|
if (value.type !== "JSXExpressionContainer") return false;
|
|
1369
1432
|
return isLiteral(value.expression);
|
|
1370
1433
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
if (
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
if (
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1434
|
+
var CLASS_HELPERS = /* @__PURE__ */ new Set(["cn", "clsx", "twMerge", "cx", "classNames"]);
|
|
1435
|
+
function isClassHelperCall(value) {
|
|
1436
|
+
if (value.type !== "JSXExpressionContainer") return false;
|
|
1437
|
+
const call = value.expression;
|
|
1438
|
+
if (call.type !== "CallExpression") return false;
|
|
1439
|
+
const callee = call.callee;
|
|
1440
|
+
if (callee.type !== "Identifier" || !CLASS_HELPERS.has(callee.name))
|
|
1441
|
+
return false;
|
|
1442
|
+
return call.arguments.every(
|
|
1443
|
+
(argument) => (argument.type === "Literal" || argument.type === "StringLiteral") && typeof argument.value === "string" || argument.type === "TemplateLiteral" && argument.expressions.length === 0
|
|
1444
|
+
);
|
|
1382
1445
|
}
|
|
1383
|
-
function
|
|
1384
|
-
|
|
1385
|
-
return numeric && typeof node.value === "number" && Number.isFinite(node.value);
|
|
1446
|
+
function isLiteral(node) {
|
|
1447
|
+
return readLiteralExpression(node) !== null;
|
|
1386
1448
|
}
|
|
1387
1449
|
function unwrap(node) {
|
|
1388
|
-
|
|
1389
|
-
while (current.type === "ParenthesizedExpression")
|
|
1390
|
-
current = current.expression;
|
|
1391
|
-
return current;
|
|
1450
|
+
return unwrapLiteralExpression(node);
|
|
1392
1451
|
}
|
|
1393
1452
|
|
|
1394
1453
|
// ../../modules/annotation/source-version.ts
|
|
@@ -1479,7 +1538,8 @@ function computeTempoAnnotatedProps(params) {
|
|
|
1479
1538
|
...info.parentType !== void 0 && !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE) ? {
|
|
1480
1539
|
[EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(
|
|
1481
1540
|
info.element,
|
|
1482
|
-
info.parentType
|
|
1541
|
+
info.parentType,
|
|
1542
|
+
info.isStaticJsxChild
|
|
1483
1543
|
)
|
|
1484
1544
|
} : {}
|
|
1485
1545
|
};
|
|
@@ -1785,10 +1845,15 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
|
1785
1845
|
const element = elementPath.node;
|
|
1786
1846
|
const tagName = getBabelTagName(element.openingElement.name);
|
|
1787
1847
|
if (FRAGMENT_TAG_NAMES.has(tagName)) return;
|
|
1848
|
+
let container = elementPath.parentPath;
|
|
1849
|
+
while (container && unwrapLiteralExpression(container.node) === element)
|
|
1850
|
+
container = container.parentPath;
|
|
1851
|
+
const isStaticJsxChild = !!container && literalJsxChild(container.node) === element && (container.parent.type === "JSXElement" || container.parent.type === "JSXFragment");
|
|
1788
1852
|
const info = {
|
|
1789
1853
|
element,
|
|
1790
1854
|
tagName,
|
|
1791
|
-
parentType: elementPath.parent.type
|
|
1855
|
+
parentType: elementPath.parent.type,
|
|
1856
|
+
isStaticJsxChild
|
|
1792
1857
|
};
|
|
1793
1858
|
const props = computeTempoAnnotatedProps({
|
|
1794
1859
|
info,
|
|
@@ -1823,4 +1888,4 @@ function tempoExpoBabelPlugin(api, rawOptions = {}) {
|
|
|
1823
1888
|
export {
|
|
1824
1889
|
tempoExpoBabelPlugin
|
|
1825
1890
|
};
|
|
1826
|
-
//# sourceMappingURL=chunk-
|
|
1891
|
+
//# sourceMappingURL=chunk-6SOP4XU6.js.map
|