tempo-sdk 0.0.45 → 0.0.51
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/assets/editor.d.ts +1 -1
- package/dist/assets/editor.js +4 -2
- package/dist/assets/editor.js.map +1 -1
- package/dist/assets/index.d.ts +112 -24
- package/dist/assets/index.js +309 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/parser.d.ts +14 -3
- package/dist/assets/parser.js +7 -3
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.js +3 -2
- package/dist/canvas/index.js.map +1 -1
- package/dist/canvas/interact-projection.js +2 -1
- package/dist/canvas/svelte.d.ts +1 -1
- package/dist/canvas/svelte.js +1 -1
- package/dist/chunk-DI2ZFAWL.js +14 -0
- package/dist/chunk-DI2ZFAWL.js.map +1 -0
- package/dist/chunk-DX6XAXCK.js +827 -0
- package/dist/chunk-DX6XAXCK.js.map +1 -0
- package/dist/{chunk-7AJVPFFG.js → chunk-LFYKJJC5.js} +3 -3
- package/dist/{chunk-7AJVPFFG.js.map → chunk-LFYKJJC5.js.map} +1 -1
- package/dist/{chunk-IWULHYPW.js → chunk-O65OD3NA.js} +216 -19
- package/dist/chunk-O65OD3NA.js.map +1 -0
- package/dist/{chunk-7O6DPEMF.js → chunk-PULSTDX2.js} +9 -3
- package/dist/chunk-PULSTDX2.js.map +1 -0
- package/dist/{chunk-FIIU52RN.js → chunk-ZZYNOX24.js} +22 -810
- package/dist/chunk-ZZYNOX24.js.map +1 -0
- package/dist/index.js +86 -13
- package/dist/index.js.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs.cjs +2 -2
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.js +1 -1
- package/dist/{storyboard-xVaRTJAu.d.ts → storyboard-CBHki7Aw.d.ts} +2 -1
- package/dist/{types-B-dRoF2T.d.ts → types-C7cvcY6T.d.ts} +5 -1
- package/package.json +2 -2
- package/dist/chunk-7O6DPEMF.js.map +0 -1
- package/dist/chunk-FIIU52RN.js.map +0 -1
- package/dist/chunk-IWULHYPW.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,10 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
TEMPO_INTERACT_FRAME_NAME
|
|
12
12
|
} from "./chunk-65B52AR7.js";
|
|
13
|
+
import {
|
|
14
|
+
parseControlsFile
|
|
15
|
+
} from "./chunk-O65OD3NA.js";
|
|
16
|
+
import "./chunk-DI2ZFAWL.js";
|
|
13
17
|
|
|
14
18
|
// index.ts
|
|
15
19
|
import {
|
|
@@ -20,6 +24,26 @@ import {
|
|
|
20
24
|
watch as watchFileSystem
|
|
21
25
|
} from "fs";
|
|
22
26
|
import { createRequire } from "module";
|
|
27
|
+
|
|
28
|
+
// assets/controls-transform.ts
|
|
29
|
+
function transformControlsForHmr(source, filePath, previouslyDefinedControls = false) {
|
|
30
|
+
const calls = source.includes("defineControls") ? parseControlsFile(filePath, source) : [];
|
|
31
|
+
if (!calls.length && !previouslyDefinedControls) return source;
|
|
32
|
+
for (const { start, end } of calls.reverse()) {
|
|
33
|
+
source = source.slice(0, start) + `((dispose) => { if (import.meta.hot && typeof dispose === "function") import.meta.hot.data.__tempoControlsDisposers.push(dispose); })(${source.slice(start, end)})` + source.slice(end);
|
|
34
|
+
}
|
|
35
|
+
return `if (import.meta.hot) {
|
|
36
|
+
for (const dispose of import.meta.hot.data.__tempoControlsDisposers ?? []) dispose();
|
|
37
|
+
import.meta.hot.data.__tempoControlsDisposers = [];
|
|
38
|
+
import.meta.hot.dispose(() => {
|
|
39
|
+
for (const dispose of import.meta.hot.data.__tempoControlsDisposers ?? []) dispose();
|
|
40
|
+
import.meta.hot.data.__tempoControlsDisposers = [];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
${source}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// index.ts
|
|
23
47
|
import { dirname, isAbsolute, join, relative as relative2, resolve as resolve2 } from "path";
|
|
24
48
|
import { fileURLToPath } from "url";
|
|
25
49
|
import { createFilter } from "@rollup/pluginutils";
|
|
@@ -300,7 +324,7 @@ import { resolve } from "path";
|
|
|
300
324
|
// package.json
|
|
301
325
|
var package_default = {
|
|
302
326
|
name: "tempo-sdk",
|
|
303
|
-
version: "0.0.
|
|
327
|
+
version: "0.0.51",
|
|
304
328
|
type: "module",
|
|
305
329
|
description: "Tempo SDK \u2014 Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types",
|
|
306
330
|
repository: {
|
|
@@ -381,7 +405,7 @@ var package_default = {
|
|
|
381
405
|
demo: "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
|
|
382
406
|
"demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
|
|
383
407
|
test: "vitest run",
|
|
384
|
-
"test:browser": "vitest run canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
|
|
408
|
+
"test:browser": "vitest run asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
|
|
385
409
|
"test:watch": "vitest",
|
|
386
410
|
"test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
|
|
387
411
|
"test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
|
|
@@ -997,22 +1021,39 @@ async function synchronizeCanvasHostRegistrationTransform(server, canvasPath) {
|
|
|
997
1021
|
);
|
|
998
1022
|
}
|
|
999
1023
|
const canonicalWrapperPath = realpathSync2(wrapperPath);
|
|
1024
|
+
const modulePattern = /\bcanvasPath:\s*("(?:\\.|[^"\\])*")\s*,\s*load:\s*\(\)\s*=>\s*import\(\s*("(?:\\.|[^"\\])*")\s*\)/g;
|
|
1025
|
+
const transformer = server.environments?.client ?? server;
|
|
1026
|
+
for (const match of wrapperSource.matchAll(modulePattern)) {
|
|
1027
|
+
if (normalizeCanvasRegistrationPath(JSON.parse(match[1])) !== canvasPath)
|
|
1028
|
+
continue;
|
|
1029
|
+
const resolvedModule = await transformer.pluginContainer.resolveId(
|
|
1030
|
+
JSON.parse(match[2]),
|
|
1031
|
+
wrapperPath
|
|
1032
|
+
);
|
|
1033
|
+
if (!resolvedModule) throw new Error(`Cannot resolve canvas ${canvasPath}`);
|
|
1034
|
+
const modulePath = fsPathFromModuleId(resolvedModule.id);
|
|
1035
|
+
await retransformCanvasHostWrapper(
|
|
1036
|
+
transformer,
|
|
1037
|
+
realpathSync2(modulePath),
|
|
1038
|
+
modulePath,
|
|
1039
|
+
`/@fs/${modulePath.replace(/^\/+/, "")}`
|
|
1040
|
+
);
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1000
1043
|
await retransformCanvasHostWrapper(
|
|
1001
|
-
|
|
1044
|
+
transformer,
|
|
1002
1045
|
canonicalWrapperPath,
|
|
1003
1046
|
wrapperPath
|
|
1004
1047
|
);
|
|
1005
1048
|
}
|
|
1006
|
-
async function retransformCanvasHostWrapper(transformer, canonicalWrapperPath, wrapperPath) {
|
|
1049
|
+
async function retransformCanvasHostWrapper(transformer, canonicalWrapperPath, wrapperPath, requestUrl = CANVAS_HOST_WRAPPER_URL) {
|
|
1007
1050
|
const modules = transformer.moduleGraph.getModulesByFile(canonicalWrapperPath) ?? transformer.moduleGraph.getModulesByFile(wrapperPath);
|
|
1008
1051
|
for (const module of modules ?? []) {
|
|
1009
1052
|
transformer.moduleGraph.invalidateModule(module);
|
|
1010
1053
|
}
|
|
1011
|
-
const result = await transformer.transformRequest(
|
|
1054
|
+
const result = await transformer.transformRequest(requestUrl);
|
|
1012
1055
|
if (!result) {
|
|
1013
|
-
throw new Error(
|
|
1014
|
-
`Vite did not transform ${CANVAS_HOST_WRAPPER_URL} after registration`
|
|
1015
|
-
);
|
|
1056
|
+
throw new Error(`Vite did not transform ${requestUrl} after registration`);
|
|
1016
1057
|
}
|
|
1017
1058
|
}
|
|
1018
1059
|
function writeCanvasRegistrationResponseHeaders(res) {
|
|
@@ -1196,6 +1237,16 @@ function tempoVitePlugin(options = {}) {
|
|
|
1196
1237
|
const include = options.include === void 0 ? DEFAULT_INCLUDE : options.include;
|
|
1197
1238
|
const exclude = options.exclude === void 0 ? DEFAULT_EXCLUDE : options.exclude;
|
|
1198
1239
|
const filter = createFilter(include, exclude);
|
|
1240
|
+
const controlsFilter = createFilter(
|
|
1241
|
+
["**/*.tsx", "**/*.jsx", "**/*.ts", "**/*.js"],
|
|
1242
|
+
exclude
|
|
1243
|
+
);
|
|
1244
|
+
const controlsModules = /* @__PURE__ */ new Set();
|
|
1245
|
+
function transformControls(source, id) {
|
|
1246
|
+
const code = transformControlsForHmr(source, id, controlsModules.has(id));
|
|
1247
|
+
if (code !== source) controlsModules.add(id);
|
|
1248
|
+
return code;
|
|
1249
|
+
}
|
|
1199
1250
|
let canonicalRoot = process.cwd();
|
|
1200
1251
|
let sourceIdentityRoot = canonicalRoot;
|
|
1201
1252
|
let command = "serve";
|
|
@@ -1670,9 +1721,14 @@ if (import.meta.hot) import.meta.hot.dispose(() => {
|
|
|
1670
1721
|
if (!enabled) return;
|
|
1671
1722
|
const ownInteractModule = resolveOwnInteractProjectionModule();
|
|
1672
1723
|
const allow = server.config?.server?.fs?.allow;
|
|
1673
|
-
if (
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1724
|
+
if (Array.isArray(allow)) {
|
|
1725
|
+
const requiredRoots = [
|
|
1726
|
+
sourceIdentityRoot,
|
|
1727
|
+
...ownInteractModule ? [dirname(ownInteractModule)] : []
|
|
1728
|
+
];
|
|
1729
|
+
for (const requiredRoot of requiredRoots) {
|
|
1730
|
+
if (!allow.includes(requiredRoot)) allow.push(requiredRoot);
|
|
1731
|
+
}
|
|
1676
1732
|
}
|
|
1677
1733
|
devServer = server;
|
|
1678
1734
|
server.ws.on?.(VITE_ERROR_SUBSCRIBE_EVENT, (_data, client) => {
|
|
@@ -1682,6 +1738,15 @@ if (import.meta.hot) import.meta.hot.dispose(() => {
|
|
|
1682
1738
|
server.watcher?.once?.("close", closeUnresolvedImportWatchers);
|
|
1683
1739
|
server.httpServer?.once("close", closeUnresolvedImportWatchers);
|
|
1684
1740
|
server.middlewares.use((req, res, next) => {
|
|
1741
|
+
const name = req.url?.match(
|
|
1742
|
+
/^\/tempo-assets\/([a-zA-Z0-9._-]+)(?:\?.*)?$/
|
|
1743
|
+
)?.[1];
|
|
1744
|
+
if (name) {
|
|
1745
|
+
const file = ["public", "static"].map(
|
|
1746
|
+
(directory) => join(sourceIdentityRoot, directory, "tempo-assets", name)
|
|
1747
|
+
).find((file2) => existsSync(file2));
|
|
1748
|
+
if (file) req.url = `/@fs/${file.replace(/\\/g, "/")}`;
|
|
1749
|
+
}
|
|
1685
1750
|
handleTempoMiddleware(errorServer, server, req, res, next);
|
|
1686
1751
|
});
|
|
1687
1752
|
installMissedChangeSweep(
|
|
@@ -1746,6 +1811,11 @@ if (import.meta.hot) import.meta.hot.dispose(() => {
|
|
|
1746
1811
|
order: "post",
|
|
1747
1812
|
async handler(context) {
|
|
1748
1813
|
if (!enabled || this.environment.config.consumer !== "client") return;
|
|
1814
|
+
if (context.type === "create" && /\/\.tempo\/asset-edit-previews\/\d+\/index\.canvas\.tsx$/.test(
|
|
1815
|
+
context.file.replace(/\\/g, "/")
|
|
1816
|
+
)) {
|
|
1817
|
+
return [];
|
|
1818
|
+
}
|
|
1749
1819
|
recordHotUpdateCoverage(context.file);
|
|
1750
1820
|
if (context.type === "update" && context.modules.length > 0) {
|
|
1751
1821
|
rapidHotUpdateReplay.observe(burstKey(context.file), () => {
|
|
@@ -1871,7 +1941,10 @@ if (import.meta.hot) import.meta.hot.dispose(() => {
|
|
|
1871
1941
|
const code = preservePendingViteModuleUpdates(source);
|
|
1872
1942
|
return code === source ? null : { code, map: null };
|
|
1873
1943
|
}
|
|
1944
|
+
const controlsSource = controlsFilter(cleanId) ? transformControls(source, cleanId) : source;
|
|
1874
1945
|
if (!filter(cleanId)) {
|
|
1946
|
+
if (controlsSource !== source)
|
|
1947
|
+
return { code: controlsSource, map: null };
|
|
1875
1948
|
return null;
|
|
1876
1949
|
}
|
|
1877
1950
|
try {
|
|
@@ -1898,10 +1971,10 @@ if (import.meta.hot) import.meta.hot.dispose(() => {
|
|
|
1898
1971
|
})
|
|
1899
1972
|
);
|
|
1900
1973
|
if (result.elementsAnnotated === 0) {
|
|
1901
|
-
return null;
|
|
1974
|
+
return controlsSource === source ? null : { code: controlsSource, map: null };
|
|
1902
1975
|
}
|
|
1903
1976
|
return {
|
|
1904
|
-
code: result.annotatedSource,
|
|
1977
|
+
code: controlsFilter(cleanId) ? transformControls(result.annotatedSource, cleanId) : result.annotatedSource,
|
|
1905
1978
|
map: null
|
|
1906
1979
|
};
|
|
1907
1980
|
} catch {
|