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
@@ -2,6 +2,7 @@ import {
2
2
  VITE_ERROR_FEED_KEY
3
3
  } from "../chunk-K3EYTZLL.js";
4
4
  import {
5
+ AdmissionBudgetError,
5
6
  Canvas,
6
7
  CanvasContext,
7
8
  CanvasHostContext,
@@ -12,21 +13,26 @@ import {
12
13
  Storyboard,
13
14
  StoryboardSlot,
14
15
  getCanvasStoryboardRenderId,
16
+ getStoryboardKey,
15
17
  getStoryboardPortalSelectors,
18
+ isV1CanvasClient,
16
19
  normalizeId,
17
20
  useActiveState,
18
21
  useRenderErrorRecovery,
19
- useRequiredCanvasHost
20
- } from "../chunk-PULSTDX2.js";
22
+ useRequiredCanvasHost,
23
+ v1DirectUrlSize,
24
+ v1RenderRequestSize
25
+ } from "../chunk-U3SLJNRS.js";
21
26
  import {
22
27
  installTempoInteractProjectionSource
23
- } from "../chunk-ZZYNOX24.js";
28
+ } from "../chunk-U64AHDHZ.js";
24
29
  import {
25
30
  TEMPO_INTERACT_FRAME_NAME,
26
31
  isTempoInteractFrameName
27
32
  } from "../chunk-65B52AR7.js";
28
- import "../chunk-57KAYXHF.js";
29
- import "../chunk-DX6XAXCK.js";
33
+ import "../chunk-TL4MGN7E.js";
34
+ import "../chunk-5BHIHP25.js";
35
+ import "../chunk-N2TYN3RB.js";
30
36
 
31
37
  // canvas/canvas-host.tsx
32
38
  import {
@@ -111,11 +117,16 @@ function CanvasImportBoundary({
111
117
  const failedRef = useRef(false);
112
118
  const importRejectedRef = useRef(false);
113
119
  const loadRef = useRef(load);
120
+ const currentExportRef = useRef(null);
121
+ const [replacement, setReplacement] = useState(null);
122
+ const loadGenerationRef = useRef(0);
114
123
  const previousLoadRef = useRef(load);
115
124
  loadRef.current = load;
116
125
  const [retryRevision, setRetryRevision] = useState(0);
117
126
  const retryRenderNow = useCallback(() => {
118
127
  if (!failedRef.current || importRejectedRef.current) return false;
128
+ currentExportRef.current = null;
129
+ setReplacement(null);
119
130
  setRetryRevision((revision) => revision + 1);
120
131
  return true;
121
132
  }, []);
@@ -127,6 +138,19 @@ function CanvasImportBoundary({
127
138
  () => Promise.resolve().then(() => {
128
139
  importRejectedRef.current = false;
129
140
  return loadRef.current();
141
+ }).then((module) => {
142
+ const current = module;
143
+ if (currentExportRef.current === null) {
144
+ currentExportRef.current = module.default;
145
+ }
146
+ return {
147
+ default: function LoadedCanvas({
148
+ replacement: replacement2
149
+ }) {
150
+ const Component2 = replacement2 ?? current.default;
151
+ return /* @__PURE__ */ jsx(Component2, {});
152
+ }
153
+ };
130
154
  }).catch((error) => {
131
155
  importRejectedRef.current = true;
132
156
  getCanvasHostRecoveryFeed().publish({
@@ -155,10 +179,38 @@ function CanvasImportBoundary({
155
179
  useEffect(() => {
156
180
  const loadChanged = previousLoadRef.current !== load;
157
181
  previousLoadRef.current = load;
158
- if (loadChanged && failedRef.current) {
182
+ const generation = ++loadGenerationRef.current;
183
+ if (!loadChanged) return;
184
+ if (failedRef.current) {
185
+ currentExportRef.current = null;
186
+ setReplacement(null);
159
187
  setRetryRevision((revision) => revision + 1);
188
+ return;
160
189
  }
161
- }, [load]);
190
+ Promise.resolve().then(load).then(
191
+ (module) => {
192
+ if (generation !== loadGenerationRef.current) return;
193
+ const getFamily = globalThis[/* @__PURE__ */ Symbol.for("tempo.react-refresh.family")];
194
+ if (typeof getFamily === "function") {
195
+ const family = getFamily(currentExportRef.current);
196
+ if (family && family === getFamily(module.default)) return;
197
+ }
198
+ currentExportRef.current = module.default;
199
+ setReplacement(() => module.default);
200
+ },
201
+ (error) => {
202
+ if (generation !== loadGenerationRef.current) return;
203
+ getCanvasHostRecoveryFeed().publish({
204
+ type: "module-load-failure",
205
+ path: canvasPath,
206
+ message: error instanceof Error ? error.message : String(error)
207
+ });
208
+ }
209
+ );
210
+ return () => {
211
+ ++loadGenerationRef.current;
212
+ };
213
+ }, [load, canvasPath]);
162
214
  useEffect(
163
215
  () => () => {
164
216
  clearCanvasImportError(canvasPath);
@@ -170,7 +222,7 @@ function CanvasImportBoundary({
170
222
  [canvasPath, registerCanvasProblemScope]
171
223
  );
172
224
  return /* @__PURE__ */ jsx(CanvasImportErrorBoundary, { reportError, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(CanvasPendingMarker, {}), children: /* @__PURE__ */ jsxs(CanvasContext, { path: canvasPath, children: [
173
- /* @__PURE__ */ jsx(LazyCanvas, {}),
225
+ /* @__PURE__ */ jsx(LazyCanvas, { replacement }),
174
226
  /* @__PURE__ */ jsx(CanvasCommitSignal, { onCommit: markCommitted })
175
227
  ] }) }) }, retryRevision);
176
228
  }
@@ -483,7 +535,7 @@ function readRenderRequest(commandType, payload) {
483
535
  importName: importName ?? target.storyboardId ?? target.renderId,
484
536
  ...props ? { props } : {},
485
537
  ...readOptionalSize(payload),
486
- intrinsicSize: payload.intrinsicSize === true ? true : void 0
538
+ ...isV1CanvasClient() ? v1RenderRequestSize(payload) : {}
487
539
  };
488
540
  }
489
541
  function readWatchId(commandType, payload) {
@@ -497,7 +549,7 @@ function readWatchId(commandType, payload) {
497
549
  // canvas/canvas-host-render-state.ts
498
550
  var propsMatch = (a, b) => JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
499
551
  function renderRequestMatchesEntry(entry, request) {
500
- return entry?.importPath === request.importPath && entry.importName === request.importName && entry.width === request.width && entry.height === request.height && entry.intrinsicSize === request.intrinsicSize && propsMatch(entry.props, request.props);
552
+ return entry?.importPath === request.importPath && entry.importName === request.importName && entry.width === request.width && entry.height === request.height && (!isV1CanvasClient() || entry.intrinsicSize === request.intrinsicSize) && propsMatch(entry.props, request.props);
501
553
  }
502
554
  function renderRequestTargetsEntry(entry, request) {
503
555
  return entry?.importPath === request.importPath && entry.importName === request.importName && propsMatch(entry.props, request.props);
@@ -516,7 +568,7 @@ function acquireRender(entries, request) {
516
568
  }
517
569
  function releaseRender(entries, renderId, maxCached, now = Date.now()) {
518
570
  const current = entries.get(renderId);
519
- if (!current) return new Map(entries);
571
+ if (!current) return entries;
520
572
  const next = new Map(entries);
521
573
  const activeCount = Math.max(0, current.activeCount - 1);
522
574
  if (activeCount > 0) {
@@ -532,11 +584,11 @@ function releaseRender(entries, renderId, maxCached, now = Date.now()) {
532
584
  return evictCachedRenders(next, maxCached);
533
585
  }
534
586
  function evictCachedRenders(entries, maxCached) {
587
+ const cached = [...entries.values()].filter((entry) => entry.status === "cached").sort((a, b) => (a.lastInactiveAt ?? 0) - (b.lastInactiveAt ?? 0));
588
+ const evicted = cached.slice(0, Math.max(0, cached.length - maxCached));
589
+ if (evicted.length === 0) return entries;
535
590
  const next = new Map(entries);
536
- const cached = [...next.values()].filter((entry) => entry.status === "cached").sort((a, b) => (a.lastInactiveAt ?? 0) - (b.lastInactiveAt ?? 0));
537
- for (const entry of cached.slice(0, Math.max(0, cached.length - maxCached))) {
538
- next.delete(entry.renderId);
539
- }
591
+ for (const entry of evicted) next.delete(entry.renderId);
540
592
  return next;
541
593
  }
542
594
  function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
@@ -553,21 +605,33 @@ function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
553
605
  maxCached
554
606
  };
555
607
  }
556
- function buildRenderStatusMap(entries) {
557
- return new Map([...entries].map(([id, entry]) => [id, entry.status]));
608
+ function sameMap(previous, next, same) {
609
+ if (!previous || previous.size !== next.size) return false;
610
+ for (const [id, value] of next) {
611
+ const before = previous.get(id);
612
+ if (before === void 0 || !same(before, value)) return false;
613
+ }
614
+ return true;
615
+ }
616
+ function buildRenderStatusMap(entries, previous) {
617
+ const next = new Map([...entries].map(([id, entry]) => [id, entry.status]));
618
+ return previous && sameMap(previous, next, (a, b) => a === b) ? previous : next;
558
619
  }
559
- function buildRenderSizeMap(entries) {
560
- return new Map(
620
+ function buildRenderSizeMap(entries, previous) {
621
+ const v1Client = isV1CanvasClient();
622
+ const next = new Map(
561
623
  [...entries].map(([id, entry]) => [
562
624
  id,
563
625
  {
564
626
  width: entry.width,
565
627
  height: entry.height,
566
- intrinsicSize: entry.intrinsicSize,
567
- revision: entry.revision
628
+ revision: entry.revision,
629
+ ...v1Client ? { intrinsicSize: entry.intrinsicSize } : {}
568
630
  }
569
631
  ])
570
632
  );
633
+ const sameSize = (a, b) => a.width === b.width && a.height === b.height && a.revision === b.revision && (!v1Client || a.intrinsicSize === b.intrinsicSize);
634
+ return previous && sameMap(previous, next, sameSize) ? previous : next;
571
635
  }
572
636
 
573
637
  // canvas/source-identity.ts
@@ -1093,8 +1157,11 @@ var FAILED_RELOAD_PROBE_DELAYS_MS = [50, 400, 1600];
1093
1157
  async function moduleTransformSucceeds(path) {
1094
1158
  const [pathname, query = ""] = path.split("?");
1095
1159
  const url = `${pathname}?${query ? `${query}&` : ""}t=${Date.now()}`;
1096
- const response = await fetch(url, { cache: "no-store" });
1097
- return response.ok;
1160
+ const response = await fetch(url, {
1161
+ cache: "no-store",
1162
+ headers: { Accept: "application/javascript" }
1163
+ });
1164
+ return response.ok && /javascript/i.test(response.headers.get("content-type") ?? "");
1098
1165
  }
1099
1166
  async function compileErrorFileStillBroken(file) {
1100
1167
  const cleaned = file.replace(/:\d+(?::\d+)?$/, "");
@@ -1120,13 +1187,24 @@ function isProjectedViteProblemSourceKind(sourceKind) {
1120
1187
  function createProblem(sourceKind, error, details = {}) {
1121
1188
  return {
1122
1189
  sourceKind,
1123
- message: error instanceof Error ? error.message : String(error),
1124
- stack: error instanceof Error ? error.stack : void 0,
1190
+ ...describeError(error),
1125
1191
  frameUrl: typeof window === "undefined" ? void 0 : window.location.href,
1126
1192
  timestamp: Date.now(),
1127
1193
  ...details
1128
1194
  };
1129
1195
  }
1196
+ function describeError(error) {
1197
+ if (!(error instanceof Error)) return { message: String(error) };
1198
+ const cause = error.cause;
1199
+ if (cause === void 0 || cause === null) {
1200
+ return { message: error.message, stack: error.stack };
1201
+ }
1202
+ const inner = describeError(cause);
1203
+ return {
1204
+ message: `${error.message} Cause: ${inner.message}`,
1205
+ stack: inner.stack ?? error.stack
1206
+ };
1207
+ }
1130
1208
  function findRenderIdsForProblem(problem, registered = [], includeDom = true) {
1131
1209
  const observed = [
1132
1210
  ...registered
@@ -1207,9 +1285,13 @@ function uniqueRenderIds(matches) {
1207
1285
  function normalizeCanvasPath(value) {
1208
1286
  return value.trim();
1209
1287
  }
1288
+ function isRecoveredAdmissionBudgetError(error) {
1289
+ return error instanceof Error && error.cause instanceof AdmissionBudgetError;
1290
+ }
1210
1291
  function installHostProblemCapture(tracker) {
1211
1292
  const onError = (event) => {
1212
1293
  if (event.target instanceof Element) return;
1294
+ if (isRecoveredAdmissionBudgetError(event.error)) return;
1213
1295
  tracker.reportProblemNearRender(
1214
1296
  "page-error",
1215
1297
  event.error ?? event.message,
@@ -1509,9 +1591,7 @@ function setRuntimeWatchPaused(watch, paused, resumeOptions) {
1509
1591
  }
1510
1592
  }
1511
1593
  function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId = null) {
1512
- const [renderEntriesById, setRenderEntriesById] = useState2(
1513
- () => /* @__PURE__ */ new Map()
1514
- );
1594
+ const [renderEntriesById, setRenderEntriesById] = useState2(() => /* @__PURE__ */ new Map());
1515
1595
  const [watchRequestsById, setWatchRequestsById] = useState2(
1516
1596
  () => /* @__PURE__ */ new Map()
1517
1597
  );
@@ -1519,6 +1599,8 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
1519
1599
  () => /* @__PURE__ */ new Map()
1520
1600
  );
1521
1601
  const renderEntriesRef = useRef2(renderEntriesById);
1602
+ const renderStatusRef = useRef2();
1603
+ const renderSizeRef = useRef2();
1522
1604
  const watchRequestsRef = useRef2(watchRequestsById);
1523
1605
  const registeredCanvasPathsRef = useRef2([]);
1524
1606
  registeredCanvasPathsRef.current = registeredCanvasPaths;
@@ -1569,6 +1651,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
1569
1651
  (update) => {
1570
1652
  setRenderEntriesById((entries) => {
1571
1653
  const next = update(entries);
1654
+ if (next === entries) return entries;
1572
1655
  renderEntriesRef.current = next;
1573
1656
  problemTrackerRef.current.syncRenderSourcePaths([...next.values()]);
1574
1657
  for (const renderId of [...renderedRenderIdsRef.current]) {
@@ -2176,11 +2259,17 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
2176
2259
  ]);
2177
2260
  return {
2178
2261
  renderStatusById: useMemo2(
2179
- () => buildRenderStatusMap(renderEntriesById),
2262
+ () => renderStatusRef.current = buildRenderStatusMap(
2263
+ renderEntriesById,
2264
+ renderStatusRef.current
2265
+ ),
2180
2266
  [renderEntriesById]
2181
2267
  ),
2182
2268
  renderSizeById: useMemo2(
2183
- () => buildRenderSizeMap(renderEntriesById),
2269
+ () => renderSizeRef.current = buildRenderSizeMap(
2270
+ renderEntriesById,
2271
+ renderSizeRef.current
2272
+ ),
2184
2273
  [renderEntriesById]
2185
2274
  ),
2186
2275
  markStoryboardRendered,
@@ -2247,25 +2336,14 @@ function readDirectUrlDimension(value) {
2247
2336
  }
2248
2337
  return unit && unit !== "px" ? `${numberValue}${unit}` : numberValue;
2249
2338
  }
2250
- function readDirectUrlFlag(value) {
2251
- if (value === null) return false;
2252
- const normalized = value.trim().toLowerCase();
2253
- return normalized !== "0" && normalized !== "false";
2254
- }
2255
2339
  function readDirectUrlSize(params) {
2340
+ if (isV1CanvasClient()) return v1DirectUrlSize(params, readDirectUrlDimension);
2256
2341
  const width = params.get("width")?.trim();
2257
2342
  const height = params.get("height")?.trim();
2258
- const intrinsicSize = readDirectUrlFlag(params.get("intrinsicSize"));
2259
- if (!width && !height) {
2260
- return intrinsicSize ? { intrinsicSize: true, revision: 1 } : void 0;
2261
- }
2262
- if (!width || !height) {
2263
- throw new Error("Direct URL width and height must be provided together");
2264
- }
2343
+ if (!width || !height) return { revision: 1 };
2265
2344
  return {
2266
2345
  width: readDirectUrlDimension(width),
2267
2346
  height: readDirectUrlDimension(height),
2268
- ...intrinsicSize ? { intrinsicSize: true } : {},
2269
2347
  revision: 1
2270
2348
  };
2271
2349
  }
@@ -2395,16 +2473,20 @@ function CanvasHost({
2395
2473
  renderStatusById
2396
2474
  ]
2397
2475
  );
2398
- return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
2399
- children,
2400
- mountedCanvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
2476
+ const canvasBoundaries = useMemo3(
2477
+ () => mountedCanvasModules?.map(({ canvasPath, load }) => /* @__PURE__ */ jsx2(
2401
2478
  CanvasImportBoundary,
2402
2479
  {
2403
2480
  canvasPath,
2404
2481
  load
2405
2482
  },
2406
2483
  canvasPath
2407
- ))
2484
+ )),
2485
+ [mountedCanvasModules]
2486
+ );
2487
+ return /* @__PURE__ */ jsxs2(CanvasHostContext.Provider, { value: runtime, children: [
2488
+ children,
2489
+ canvasBoundaries
2408
2490
  ] });
2409
2491
  }
2410
2492
 
@@ -2437,6 +2519,7 @@ export {
2437
2519
  getCanvasHostRuntime,
2438
2520
  getCanvasStoryboardRenderId,
2439
2521
  getOptionalCanvasHostRuntime,
2522
+ getStoryboardKey,
2440
2523
  isTempoInteractFrameName,
2441
2524
  stripRenderContentWrapperAttributes,
2442
2525
  stripRenderContentWrapperFromCombinedCapture,