tempo-sdk 0.0.92 → 0.0.94

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 (47) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/dist/astro/asset-preview-client.js +3 -3
  3. package/dist/astro.js +2 -2
  4. package/dist/canvas/astro.js +3 -3
  5. package/dist/canvas/index.js +157 -7
  6. package/dist/canvas/index.js.map +1 -1
  7. package/dist/canvas/interact-projection.js +4 -4
  8. package/dist/canvas/svelte.js +3 -3
  9. package/dist/canvas/vue.js +3 -3
  10. package/dist/{chunk-FENUT2N2.js → chunk-3W6B75UK.js} +2 -2
  11. package/dist/{chunk-FENUT2N2.js.map → chunk-3W6B75UK.js.map} +1 -1
  12. package/dist/{chunk-3XEEVCM3.js → chunk-6QGMLNO3.js} +137 -69
  13. package/dist/chunk-6QGMLNO3.js.map +1 -0
  14. package/dist/{chunk-DNERBE7A.js → chunk-KY52JZZL.js} +17 -11
  15. package/dist/chunk-KY52JZZL.js.map +1 -0
  16. package/dist/{chunk-NXPP3CSM.js → chunk-LEW24RRZ.js} +2 -2
  17. package/dist/{chunk-TWW2DL7E.js → chunk-OYNR6D7K.js} +2 -2
  18. package/dist/{chunk-TWW2DL7E.js.map → chunk-OYNR6D7K.js.map} +1 -1
  19. package/dist/{chunk-RZ3TG6MV.js → chunk-REYOX4JT.js} +2 -2
  20. package/dist/{chunk-RZ3TG6MV.js.map → chunk-REYOX4JT.js.map} +1 -1
  21. package/dist/chunk-T364NBR3.js +1440 -0
  22. package/dist/chunk-T364NBR3.js.map +1 -0
  23. package/dist/{chunk-KQSOE4KZ.js → chunk-VRNJI4Y6.js} +2 -2
  24. package/dist/{chunk-I5MJ342V.js → chunk-WRILG6GR.js} +3 -3
  25. package/dist/{chunk-XN2K7GED.js → chunk-YHGUAOBM.js} +45 -19
  26. package/dist/chunk-YHGUAOBM.js.map +1 -0
  27. package/dist/index.js +2 -2
  28. package/dist/nextjs/plugin.cjs +1 -1
  29. package/dist/nextjs/plugin.cjs.map +1 -1
  30. package/dist/nextjs/plugin.js +1 -1
  31. package/dist/nextjs-loader.cjs +1 -1
  32. package/dist/nextjs-loader.cjs.map +1 -1
  33. package/dist/nextjs.cjs +1 -1
  34. package/dist/nextjs.cjs.map +1 -1
  35. package/dist/nextjs.js +1 -1
  36. package/dist/nuxt/runtime/identity.js +1 -1
  37. package/dist/nuxt.js +1 -1
  38. package/dist/vue.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-3XEEVCM3.js.map +0 -1
  41. package/dist/chunk-5M45Z7K6.js +0 -611
  42. package/dist/chunk-5M45Z7K6.js.map +0 -1
  43. package/dist/chunk-DNERBE7A.js.map +0 -1
  44. package/dist/chunk-XN2K7GED.js.map +0 -1
  45. /package/dist/{chunk-NXPP3CSM.js.map → chunk-LEW24RRZ.js.map} +0 -0
  46. /package/dist/{chunk-KQSOE4KZ.js.map → chunk-VRNJI4Y6.js.map} +0 -0
  47. /package/dist/{chunk-I5MJ342V.js.map → chunk-WRILG6GR.js.map} +0 -0
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  captureAssetPreview
3
- } from "../chunk-I5MJ342V.js";
3
+ } from "../chunk-WRILG6GR.js";
4
4
  import {
5
5
  UNRESOLVED_VALUE
6
6
  } from "../chunk-DI2ZFAWL.js";
7
- import "../chunk-XN2K7GED.js";
8
- import "../chunk-5M45Z7K6.js";
7
+ import "../chunk-YHGUAOBM.js";
8
+ import "../chunk-T364NBR3.js";
9
9
 
10
10
  // assets/controls.ts
11
11
  function normalizeAssetControl(control) {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  captureAssetPreview
3
- } from "../chunk-I5MJ342V.js";
4
- import "../chunk-XN2K7GED.js";
5
- import "../chunk-5M45Z7K6.js";
3
+ } from "../chunk-WRILG6GR.js";
4
+ import "../chunk-YHGUAOBM.js";
5
+ import "../chunk-T364NBR3.js";
6
6
 
7
7
  // astro/asset-preview-client.ts
8
8
  var messageType = "tempo:asset-live-preview";
package/dist/astro.js CHANGED
@@ -8,14 +8,14 @@ import {
8
8
  } from "./chunk-JVVHU3A7.js";
9
9
  import {
10
10
  tempoVitePlugin
11
- } from "./chunk-KQSOE4KZ.js";
11
+ } from "./chunk-VRNJI4Y6.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-TWW2DL7E.js";
18
+ } from "./chunk-OYNR6D7K.js";
19
19
  import "./chunk-BQPKOVI5.js";
20
20
  import "./chunk-FGWGY3G3.js";
21
21
  import {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  StoryboardSlot
3
- } from "../chunk-NXPP3CSM.js";
4
- import "../chunk-DNERBE7A.js";
5
- import "../chunk-5M45Z7K6.js";
3
+ } from "../chunk-LEW24RRZ.js";
4
+ import "../chunk-KY52JZZL.js";
5
+ import "../chunk-T364NBR3.js";
6
6
  import {
7
7
  astroStoryboardPath,
8
8
  isAstroComponent
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  installTempoInteractProjectionSource
3
- } from "../chunk-3XEEVCM3.js";
3
+ } from "../chunk-6QGMLNO3.js";
4
4
  import "../chunk-SGN7BDRE.js";
5
- import "../chunk-XN2K7GED.js";
5
+ import "../chunk-YHGUAOBM.js";
6
6
  import {
7
7
  VITE_ERROR_FEED_KEY
8
8
  } from "../chunk-WTXOWQ7N.js";
@@ -38,13 +38,13 @@ import {
38
38
  useStoryboardSize,
39
39
  v1DirectUrlSize,
40
40
  v1RenderRequestSize
41
- } from "../chunk-NXPP3CSM.js";
41
+ } from "../chunk-LEW24RRZ.js";
42
42
  import {
43
43
  PROJECTION_PENDING_ATTRIBUTE,
44
44
  PROJECTION_SCOPE_ROLE,
45
45
  isProjectionUnavailableOnly
46
- } from "../chunk-DNERBE7A.js";
47
- import "../chunk-5M45Z7K6.js";
46
+ } from "../chunk-KY52JZZL.js";
47
+ import "../chunk-T364NBR3.js";
48
48
 
49
49
  // canvas/canvas-host.tsx
50
50
  import {
@@ -598,11 +598,16 @@ function readWatchId(commandType, payload) {
598
598
  }
599
599
  return watchId;
600
600
  }
601
+ function readPinId(commandType, payload) {
602
+ const pinId = readTrimmedString(payload.pinId);
603
+ if (!pinId) throw new Error(`${commandType} requires payload.pinId`);
604
+ return pinId;
605
+ }
601
606
 
602
607
  // canvas/canvas-host-render-state.ts
603
608
  var propsMatch = (a, b) => JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
604
609
  function renderRequestMatchesEntry(entry, request) {
605
- 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);
610
+ return entry?.sourceOnly !== true && 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);
606
611
  }
607
612
  function renderRequestTargetsEntry(entry, request) {
608
613
  return entry?.importPath === request.importPath && entry.importName === request.importName && propsMatch(entry.props, request.props);
@@ -620,6 +625,33 @@ function acquireRender(entries, request) {
620
625
  });
621
626
  return next;
622
627
  }
628
+ function pinRenderSource(entries, request) {
629
+ const next = new Map(entries);
630
+ const current = next.get(request.renderId);
631
+ if (current) {
632
+ next.set(request.renderId, {
633
+ ...current,
634
+ status: "active",
635
+ activeCount: current.activeCount + 1
636
+ });
637
+ } else {
638
+ const {
639
+ width: _width,
640
+ height: _height,
641
+ intrinsicSize: _intrinsicSize,
642
+ userInitiated: _userInitiated,
643
+ ...source
644
+ } = request;
645
+ next.set(request.renderId, {
646
+ ...source,
647
+ sourceOnly: true,
648
+ status: "active",
649
+ activeCount: 1,
650
+ revision: 1
651
+ });
652
+ }
653
+ return next;
654
+ }
623
655
  function releaseRender(entries, renderId, maxCached, now = Date.now(), cacheWhenIdle) {
624
656
  const previous = entries.get(renderId);
625
657
  if (!previous) return entries;
@@ -662,6 +694,7 @@ function buildRenderStatePayload(entries, maxCached, canvasPaths = []) {
662
694
  lastUsedAt: _lastUsedAt,
663
695
  userInitiated: _userInitiated,
664
696
  revision: _revision,
697
+ sourceOnly: _sourceOnly,
665
698
  ...entry
666
699
  }) => entry
667
700
  ),
@@ -683,7 +716,7 @@ function buildRenderStatusMap(entries, previous) {
683
716
  function buildRenderSizeMap(entries, previous) {
684
717
  const v1Client = isV1CanvasClient();
685
718
  const next = new Map(
686
- [...entries].map(([id, entry]) => [
719
+ [...entries].filter(([, entry]) => !entry.sourceOnly).map(([id, entry]) => [
687
720
  id,
688
721
  {
689
722
  width: entry.width,
@@ -697,6 +730,19 @@ function buildRenderSizeMap(entries, previous) {
697
730
  return previous && sameMap(previous, next, sameSize) ? previous : next;
698
731
  }
699
732
 
733
+ // canvas/fresh-mounts.ts
734
+ var FRESH_MOUNTS_GLOBAL = "__tempoCanvasFreshMounts";
735
+ function freshMounts() {
736
+ const scope = globalThis;
737
+ return scope[FRESH_MOUNTS_GLOBAL] ?? (scope[FRESH_MOUNTS_GLOBAL] = /* @__PURE__ */ new Set());
738
+ }
739
+ function noteFreshMount(renderId) {
740
+ freshMounts().add(renderId);
741
+ }
742
+ function forgetFreshMount(renderId) {
743
+ freshMounts().delete(renderId);
744
+ }
745
+
700
746
  // canvas/source-identity.ts
701
747
  function normalizeSourceIdentity(value) {
702
748
  let normalized = value.trim().replace(/\\/g, "/");
@@ -1681,6 +1727,9 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
1681
1727
  const pendingRenderWaitersRef = useRef2(
1682
1728
  /* @__PURE__ */ new Map()
1683
1729
  );
1730
+ const sourcePinsRef = useRef2(
1731
+ /* @__PURE__ */ new Map()
1732
+ );
1684
1733
  const watchesRef = useRef2(/* @__PURE__ */ new Map());
1685
1734
  const startingWatchesRef = useRef2(
1686
1735
  /* @__PURE__ */ new Map()
@@ -1817,6 +1866,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
1817
1866
  );
1818
1867
  const buildState = useCallback2(
1819
1868
  () => ({
1869
+ sourceCapturePins: true,
1820
1870
  ...registerCanvasRef.current ? { incrementalCanvasRegistration: true } : {},
1821
1871
  ...buildRenderStatePayload(
1822
1872
  renderEntriesRef.current,
@@ -1926,6 +1976,10 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
1926
1976
  filename: normalizedPath
1927
1977
  }
1928
1978
  );
1979
+ for (const pin of sourcePinsRef.current.values()) {
1980
+ if (pin.canvasPath === normalizedPath)
1981
+ pin.cancel(new Error(error.message));
1982
+ }
1929
1983
  },
1930
1984
  []
1931
1985
  );
@@ -2091,6 +2145,77 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
2091
2145
  releaseRenderLease(request.renderId);
2092
2146
  }
2093
2147
  };
2148
+ const releaseSourcePin = (pinId) => {
2149
+ const pin = sourcePinsRef.current.get(pinId);
2150
+ if (!pin) return;
2151
+ sourcePinsRef.current.delete(pinId);
2152
+ pin.cancel(new Error(`Canvas host source pin ${pinId} was cancelled`));
2153
+ forgetFreshMount(pin.renderId);
2154
+ releaseRenderLease(pin.renderId, false);
2155
+ };
2156
+ const acquireSourcePin = (pinId, request) => {
2157
+ const existing = sourcePinsRef.current.get(pinId);
2158
+ if (existing) {
2159
+ if (existing.renderId !== request.renderId)
2160
+ throw new Error(
2161
+ `Canvas host source pin ${pinId} targets another render`
2162
+ );
2163
+ return existing;
2164
+ }
2165
+ const canvasProblem = problemTrackerRef.current.snapshot().canvasProblems.find(
2166
+ (entry) => entry.canvasPath === request.canvasPath
2167
+ );
2168
+ if (canvasProblem) throw new Error(canvasProblem.problem.message);
2169
+ const committed = committedRenderEntriesRef.current.get(request.renderId);
2170
+ const alreadyRendered = renderedRenderIdsRef.current.has(request.renderId) && (urlPinnedRenderIdRef.current === request.renderId || committed?.status === "active");
2171
+ let resolve;
2172
+ let reject;
2173
+ let settled = false;
2174
+ const ready = new Promise((resolveReady, rejectReady) => {
2175
+ resolve = resolveReady;
2176
+ reject = rejectReady;
2177
+ });
2178
+ const removeWaiter = () => {
2179
+ const waiters = pendingRenderWaitersRef.current.get(request.renderId);
2180
+ if (!waiters) return;
2181
+ const remaining = waiters.filter((candidate) => candidate !== waiter);
2182
+ if (remaining.length)
2183
+ pendingRenderWaitersRef.current.set(request.renderId, remaining);
2184
+ else pendingRenderWaitersRef.current.delete(request.renderId);
2185
+ };
2186
+ const waiter = {
2187
+ resolve() {
2188
+ if (settled) return;
2189
+ settled = true;
2190
+ removeWaiter();
2191
+ resolve();
2192
+ },
2193
+ reject(error) {
2194
+ if (settled) return;
2195
+ settled = true;
2196
+ removeWaiter();
2197
+ reject(error);
2198
+ }
2199
+ };
2200
+ const pin = {
2201
+ renderId: request.renderId,
2202
+ canvasPath: request.canvasPath,
2203
+ ready,
2204
+ cancel: waiter.reject
2205
+ };
2206
+ sourcePinsRef.current.set(pinId, pin);
2207
+ setEntries((entries) => pinRenderSource(entries, request));
2208
+ if (alreadyRendered) waiter.resolve();
2209
+ else {
2210
+ noteFreshMount(request.renderId);
2211
+ const waiters = pendingRenderWaitersRef.current.get(request.renderId) ?? [];
2212
+ pendingRenderWaitersRef.current.set(request.renderId, [
2213
+ ...waiters,
2214
+ waiter
2215
+ ]);
2216
+ }
2217
+ return pin;
2218
+ };
2094
2219
  const handleCommand = (message, source, targetOrigin) => {
2095
2220
  const command = readCanvasHostCommand(message);
2096
2221
  if (!command) return;
@@ -2120,6 +2245,30 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
2120
2245
  });
2121
2246
  };
2122
2247
  try {
2248
+ if (command.type === "render-pool:pin-render") {
2249
+ const pinId = readPinId(command.type, payload);
2250
+ const pin = acquireSourcePin(
2251
+ pinId,
2252
+ readRenderRequest(command.type, payload)
2253
+ );
2254
+ void pin.ready.then(() => {
2255
+ if (sourcePinsRef.current.get(pinId) !== pin)
2256
+ throw new Error(
2257
+ `Canvas host source pin ${pinId} was cancelled`
2258
+ );
2259
+ ack();
2260
+ }).catch((caught) => {
2261
+ if (sourcePinsRef.current.get(pinId) === pin)
2262
+ releaseSourcePin(pinId);
2263
+ postAsyncError(caught);
2264
+ });
2265
+ return;
2266
+ }
2267
+ if (command.type === "render-pool:unpin-render") {
2268
+ releaseSourcePin(readPinId(command.type, payload));
2269
+ ack();
2270
+ return;
2271
+ }
2123
2272
  if (command.type === "render-pool:capture-image") {
2124
2273
  const captureOptions = {
2125
2274
  captureOverflow: payload.captureOverflow === true,
@@ -2338,6 +2487,7 @@ function useCanvasHostPostMessage(registeredCanvasPaths = [], urlPinnedRenderId
2338
2487
  window.removeEventListener("message", onMessage);
2339
2488
  window.removeEventListener("__render-pool:command", onBridgeCommand);
2340
2489
  stopProblemPublisher();
2490
+ for (const pinId of sourcePinsRef.current.keys()) releaseSourcePin(pinId);
2341
2491
  for (const { watch } of watchesRef.current.values()) {
2342
2492
  void watch.stop();
2343
2493
  }