tempo-sdk 0.0.28 → 0.0.31
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/canvas/editor.d.ts +29 -1
- package/dist/canvas/editor.js +50 -5
- package/dist/canvas/editor.js.map +1 -1
- package/dist/canvas/index.d.ts +3 -66
- package/dist/canvas/index.js +56 -940
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +2679 -1956
- package/dist/canvas/interact-projection.js.map +1 -1
- package/dist/canvas/parser.d.ts +6 -0
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.d.ts +18 -0
- package/dist/canvas/svelte.js +68 -0
- package/dist/canvas/svelte.js.map +1 -0
- package/dist/chunk-DXKG4IGS.js +919 -0
- package/dist/chunk-DXKG4IGS.js.map +1 -0
- package/dist/chunk-F3KJDCMU.js +19 -0
- package/dist/chunk-F3KJDCMU.js.map +1 -0
- package/dist/{chunk-2MAQPUCU.js → chunk-QP2NTODB.js} +19 -12
- package/dist/chunk-QP2NTODB.js.map +1 -0
- package/dist/{chunk-XEXMGSTU.js → chunk-YZ3TMGUC.js} +21 -2
- package/dist/{chunk-XEXMGSTU.js.map → chunk-YZ3TMGUC.js.map} +1 -1
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs.cjs +20 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/storyboard-xVaRTJAu.d.ts +69 -0
- package/dist/svelte.d.ts +21 -0
- package/dist/svelte.js +1898 -0
- package/dist/svelte.js.map +1 -0
- package/package.json +20 -1
- package/dist/chunk-2MAQPUCU.js.map +0 -1
package/dist/canvas/parser.d.ts
CHANGED
|
@@ -92,6 +92,8 @@ type ParsedCanvasStoryboard = {
|
|
|
92
92
|
storyboardKey: string;
|
|
93
93
|
displayName?: string;
|
|
94
94
|
kind: "component" | "route" | "html";
|
|
95
|
+
/** Authored component runtime selected by the storyboard declaration. */
|
|
96
|
+
uiFramework?: "svelte";
|
|
95
97
|
layout: ParsedCanvasLayout;
|
|
96
98
|
editable: boolean;
|
|
97
99
|
jsxElementSpan: CanvasSourceSpan;
|
|
@@ -105,6 +107,10 @@ type ParsedCanvasStoryboard = {
|
|
|
105
107
|
component?: ParsedCanvasComponentReference;
|
|
106
108
|
props?: ParsedCanvasExpressionReference;
|
|
107
109
|
vrt?: ParsedStoryboardVrt;
|
|
110
|
+
/** Span of the whole `vrt` attribute. Present whenever the attribute
|
|
111
|
+
* exists in source — including `vrt={false}` and degraded (dynamic /
|
|
112
|
+
* malformed) forms whose `vrt` value stays absent — so an editor can
|
|
113
|
+
* replace or remove the declaration without ever inserting a duplicate. */
|
|
108
114
|
vrtAttributeSpan?: CanvasSourceSpan;
|
|
109
115
|
route?: string;
|
|
110
116
|
routeSpan?: CanvasSourceSpan;
|
package/dist/canvas/parser.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as StoryboardLayout } from '../storyboard-xVaRTJAu.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '../page-xi1aI5a7.js';
|
|
5
|
+
|
|
6
|
+
/** Public Svelte 5 component call shape. This Svelte-specific entrypoint keeps
|
|
7
|
+
* React-only consumers of tempo-sdk/canvas from resolving the optional Svelte
|
|
8
|
+
* 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, }: {
|
|
11
|
+
id: string;
|
|
12
|
+
component: SvelteComponent<Props>;
|
|
13
|
+
layout: StoryboardLayout;
|
|
14
|
+
name?: string;
|
|
15
|
+
props?: Props;
|
|
16
|
+
}): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { type SvelteComponent, SvelteStoryboard };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StoryboardSlot
|
|
3
|
+
} from "../chunk-DXKG4IGS.js";
|
|
4
|
+
import "../chunk-ZT2REPH4.js";
|
|
5
|
+
|
|
6
|
+
// canvas/svelte.tsx
|
|
7
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var svelteRuntimeState = null;
|
|
10
|
+
function readSvelteRuntime() {
|
|
11
|
+
if (svelteRuntimeState?.kind === "ready") return svelteRuntimeState.runtime;
|
|
12
|
+
if (svelteRuntimeState?.kind === "error") throw svelteRuntimeState.error;
|
|
13
|
+
if (!svelteRuntimeState) {
|
|
14
|
+
const promise = import("svelte").then(
|
|
15
|
+
(runtime) => {
|
|
16
|
+
svelteRuntimeState = { kind: "ready", runtime };
|
|
17
|
+
},
|
|
18
|
+
(error) => {
|
|
19
|
+
svelteRuntimeState = { kind: "error", error };
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
svelteRuntimeState = { kind: "pending", promise };
|
|
23
|
+
}
|
|
24
|
+
throw svelteRuntimeState.promise;
|
|
25
|
+
}
|
|
26
|
+
function SvelteStoryboard({
|
|
27
|
+
id,
|
|
28
|
+
name,
|
|
29
|
+
component,
|
|
30
|
+
layout,
|
|
31
|
+
props
|
|
32
|
+
}) {
|
|
33
|
+
return /* @__PURE__ */ jsx(StoryboardSlot, { id, name, layout, kind: "component", children: /* @__PURE__ */ jsx(SvelteComponentMount, { component, props }) });
|
|
34
|
+
}
|
|
35
|
+
function SvelteComponentMount({
|
|
36
|
+
component,
|
|
37
|
+
props
|
|
38
|
+
}) {
|
|
39
|
+
const targetRef = useRef(null);
|
|
40
|
+
const [mountError, setMountError] = useState(null);
|
|
41
|
+
const runtime = readSvelteRuntime();
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
const target = targetRef.current;
|
|
44
|
+
if (!target) return;
|
|
45
|
+
let mounted = null;
|
|
46
|
+
try {
|
|
47
|
+
mounted = runtime.mount(component, {
|
|
48
|
+
target,
|
|
49
|
+
props: props ?? {}
|
|
50
|
+
});
|
|
51
|
+
runtime.flushSync();
|
|
52
|
+
} catch (error) {
|
|
53
|
+
setMountError(error);
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
const current = mounted;
|
|
57
|
+
mounted = null;
|
|
58
|
+
if (current) void runtime.unmount(current);
|
|
59
|
+
target.replaceChildren();
|
|
60
|
+
};
|
|
61
|
+
}, [component, runtime]);
|
|
62
|
+
if (mountError) throw mountError;
|
|
63
|
+
return /* @__PURE__ */ jsx("div", { ref: targetRef });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
SvelteStoryboard
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=svelte.js.map
|
|
@@ -0,0 +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;AAxCN,IAAI,qBAAgD;AAMpD,SAAS,oBAAmC;AAC1C,MAAI,oBAAoB,SAAS,QAAS,QAAO,mBAAmB;AACpE,MAAI,oBAAoB,SAAS,QAAS,OAAM,mBAAmB;AACnE,MAAI,C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