tempo-sdk 0.0.27 → 0.0.30
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 -45
- 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 +30 -1
- package/dist/canvas/parser.js +3 -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-IPCTMTJE.js → chunk-KVQPEU4H.js} +16 -2
- package/dist/{chunk-IPCTMTJE.js.map → chunk-KVQPEU4H.js.map} +1 -1
- package/dist/{chunk-GBKYTBEE.js → chunk-QP2NTODB.js} +126 -10
- package/dist/chunk-QP2NTODB.js.map +1 -0
- package/dist/index.js +18 -16
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs.cjs +15 -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 +41 -25
- package/dist/chunk-GBKYTBEE.js.map +0 -1
package/dist/canvas/parser.d.ts
CHANGED
|
@@ -65,6 +65,24 @@ type ParsedCanvasComponentReference = {
|
|
|
65
65
|
localName?: string;
|
|
66
66
|
import?: ParsedCanvasImport;
|
|
67
67
|
};
|
|
68
|
+
type ParsedStoryboardVrtIgnoreRegion = {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
w: number;
|
|
72
|
+
h: number;
|
|
73
|
+
};
|
|
74
|
+
/** Opt-in visual-regression tracking parsed from the `vrt` prop on
|
|
75
|
+
* `<Storyboard>` (TEM-1775). Presence of the parsed field means the
|
|
76
|
+
* storyboard is tracked; `skip: true` keeps the config but pauses gating.
|
|
77
|
+
* `vrt` / `vrt={true}` parse to `{}`; `vrt={false}` parses to absent. */
|
|
78
|
+
type ParsedStoryboardVrt = {
|
|
79
|
+
/** Per-storyboard pixelmatch threshold override (0..0.5). */
|
|
80
|
+
threshold?: number;
|
|
81
|
+
/** Temporarily untracked without losing config. */
|
|
82
|
+
skip?: boolean;
|
|
83
|
+
/** Regions (storyboard-local px) excluded from comparison. */
|
|
84
|
+
ignore?: ParsedStoryboardVrtIgnoreRegion[];
|
|
85
|
+
};
|
|
68
86
|
type ParsedCanvasExpressionReference = {
|
|
69
87
|
expression: string;
|
|
70
88
|
span: CanvasSourceSpan;
|
|
@@ -74,6 +92,8 @@ type ParsedCanvasStoryboard = {
|
|
|
74
92
|
storyboardKey: string;
|
|
75
93
|
displayName?: string;
|
|
76
94
|
kind: "component" | "route" | "html";
|
|
95
|
+
/** Authored component runtime selected by the storyboard declaration. */
|
|
96
|
+
uiFramework?: "svelte";
|
|
77
97
|
layout: ParsedCanvasLayout;
|
|
78
98
|
editable: boolean;
|
|
79
99
|
jsxElementSpan: CanvasSourceSpan;
|
|
@@ -86,6 +106,12 @@ type ParsedCanvasStoryboard = {
|
|
|
86
106
|
layoutSpans?: ParsedCanvasLayoutSpans;
|
|
87
107
|
component?: ParsedCanvasComponentReference;
|
|
88
108
|
props?: ParsedCanvasExpressionReference;
|
|
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. */
|
|
114
|
+
vrtAttributeSpan?: CanvasSourceSpan;
|
|
89
115
|
route?: string;
|
|
90
116
|
routeSpan?: CanvasSourceSpan;
|
|
91
117
|
routeAttributeSpan?: CanvasSourceSpan;
|
|
@@ -124,9 +150,12 @@ type ParsedCanvasFile = {
|
|
|
124
150
|
storyboards: ParsedCanvasStoryboard[];
|
|
125
151
|
errors: CanvasParseError[];
|
|
126
152
|
};
|
|
153
|
+
/** Emitted when a file parses cleanly but declares no `<Canvas>` — for
|
|
154
|
+
* readers that need to distinguish "legacy page format" from "broken". */
|
|
155
|
+
declare const NO_CANVAS_DECLARATION_ERROR = "No <Canvas> declaration found in canvas file";
|
|
127
156
|
declare function parseCanvasFile(filePath: string, source: string): ParsedCanvasFile;
|
|
128
157
|
declare function misimportedSdkCanvasImportMessage(entry: MisimportedSdkCanvasImport): string;
|
|
129
158
|
declare function unwrapTsExpression(node: any): any;
|
|
130
159
|
declare function fallbackPageName(filePath: string): string;
|
|
131
160
|
|
|
132
|
-
export { type CanvasParseError, type CanvasSourceSpan, type MisimportedSdkCanvasImport, type ParsedCanvasComponentReference, type ParsedCanvasExpressionReference, type ParsedCanvasFile, type ParsedCanvasImport, type ParsedCanvasLayout, type ParsedCanvasLayoutSpans, type ParsedCanvasStoryboard, fallbackPageName, misimportedSdkCanvasImportMessage, parseCanvasFile, unwrapTsExpression };
|
|
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 };
|
package/dist/canvas/parser.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
NO_CANVAS_DECLARATION_ERROR,
|
|
2
3
|
fallbackPageName,
|
|
3
4
|
misimportedSdkCanvasImportMessage,
|
|
4
5
|
parseCanvasFile,
|
|
5
6
|
unwrapTsExpression
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-QP2NTODB.js";
|
|
7
8
|
export {
|
|
9
|
+
NO_CANVAS_DECLARATION_ERROR,
|
|
8
10
|
fallbackPageName,
|
|
9
11
|
misimportedSdkCanvasImportMessage,
|
|
10
12
|
parseCanvasFile,
|
|
@@ -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,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;AACF,GAMG;AACD,SACE,oBAAC,kBAAe,IAAQ,MAAY,QAAgB,MAAK,aACvD,8BAAC,wBAAqB,WAAsB,OAAc,GAC5D;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;AAC9B;","names":[]}
|