tempo-sdk 0.0.79 → 0.0.85

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 (49) hide show
  1. package/dist/astro.js +3 -3
  2. package/dist/canvas/astro.js +2 -2
  3. package/dist/canvas/index.js +12 -7
  4. package/dist/canvas/index.js.map +1 -1
  5. package/dist/canvas/interact-projection.js +2 -2
  6. package/dist/canvas/svelte.js +2 -2
  7. package/dist/canvas/vue.js +2 -2
  8. package/dist/{chunk-4PGZTWKS.js → chunk-2OFKPSKO.js} +4 -3
  9. package/dist/{chunk-4PGZTWKS.js.map → chunk-2OFKPSKO.js.map} +1 -1
  10. package/dist/{chunk-XFPFWTWX.js → chunk-2ZQMVAFM.js} +4 -1
  11. package/dist/{chunk-XFPFWTWX.js.map → chunk-2ZQMVAFM.js.map} +1 -1
  12. package/dist/{chunk-UBTL6JUF.js → chunk-DMT5MRMS.js} +4 -1
  13. package/dist/chunk-DMT5MRMS.js.map +1 -0
  14. package/dist/{chunk-QJA366VX.js → chunk-DNERBE7A.js} +70 -25
  15. package/dist/chunk-DNERBE7A.js.map +1 -0
  16. package/dist/{chunk-JMG5IDS5.js → chunk-G3W3FVUJ.js} +2 -2
  17. package/dist/{chunk-JMG5IDS5.js.map → chunk-G3W3FVUJ.js.map} +1 -1
  18. package/dist/{chunk-TFPT6T3K.js → chunk-KPWCY6PY.js} +93 -55
  19. package/dist/chunk-KPWCY6PY.js.map +1 -0
  20. package/dist/{chunk-54P7S7VU.js → chunk-O74WU2S7.js} +2 -2
  21. package/dist/{chunk-54P7S7VU.js.map → chunk-O74WU2S7.js.map} +1 -1
  22. package/dist/{chunk-D3WLLHZU.js → chunk-PPIIUCX5.js} +2 -2
  23. package/dist/{chunk-BHDCNLCO.js → chunk-WP74QZYX.js} +2 -2
  24. package/dist/{chunk-BHDCNLCO.js.map → chunk-WP74QZYX.js.map} +1 -1
  25. package/dist/expo/plugin.cjs +3 -0
  26. package/dist/expo/plugin.cjs.map +1 -1
  27. package/dist/expo/plugin.js +1 -1
  28. package/dist/expo-babel-plugin.cjs +3 -0
  29. package/dist/expo-babel-plugin.cjs.map +1 -1
  30. package/dist/expo-babel-plugin.js +1 -1
  31. package/dist/index.js +3 -3
  32. package/dist/nextjs/plugin.cjs +1 -1
  33. package/dist/nextjs/plugin.cjs.map +1 -1
  34. package/dist/nextjs/plugin.js +1 -1
  35. package/dist/nextjs-loader.cjs +4 -1
  36. package/dist/nextjs-loader.cjs.map +1 -1
  37. package/dist/nextjs.cjs +1 -1
  38. package/dist/nextjs.cjs.map +1 -1
  39. package/dist/nextjs.js +1 -1
  40. package/dist/nuxt/runtime/identity.js +1 -1
  41. package/dist/nuxt.js +5 -1
  42. package/dist/nuxt.js.map +1 -1
  43. package/dist/svelte.js +1 -1
  44. package/dist/vue.js +2 -2
  45. package/package.json +1 -1
  46. package/dist/chunk-QJA366VX.js.map +0 -1
  47. package/dist/chunk-TFPT6T3K.js.map +0 -1
  48. package/dist/chunk-UBTL6JUF.js.map +0 -1
  49. /package/dist/{chunk-D3WLLHZU.js.map → chunk-PPIIUCX5.js.map} +0 -0
@@ -39,6 +39,9 @@ function defaultComputeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersio
39
39
  return {
40
40
  "data-tempo-filepath": filepath,
41
41
  "data-tempo-position": info.element.openingElement.start,
42
+ // Runtime display names can differ from the JSX used at this callsite
43
+ // (imports, member expressions, memo and forwardRef wrappers).
44
+ "data-tempo-source-tag": info.tagName,
42
45
  "data-tempo-modifiedts": modifiedtsMs,
43
46
  // Content-hash identity of the file this element was annotated from. The
44
47
  // canvas reconcile loop equality-compares it against the write pipeline's
@@ -108,4 +111,4 @@ export {
108
111
  appendModuleVersionRecord,
109
112
  computeTempoAnnotatedProps
110
113
  };
111
- //# sourceMappingURL=chunk-UBTL6JUF.js.map
114
+ //# sourceMappingURL=chunk-DMT5MRMS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../annotation-strategy.ts"],"sourcesContent":["import { realpathSync, statSync } from \"node:fs\";\nimport { relative } from \"node:path\";\n\nimport type {\n ElementInfo,\n PropValue,\n} from \"../../modules/annotation/annotate-file.ts\";\nimport {\n EXPRESSION_FACTS_ATTRIBUTE,\n expressionFacts,\n} from \"../../modules/annotation/expression-facts.ts\";\nimport { sourceVersionHash } from \"../../modules/annotation/source-version.ts\";\n\nexport const DEFAULT_EXCLUDE = [\"**/node_modules/**\"] as const;\n\n/**\n * Static per-component declaration of whether a custom component accepts\n * `children`. Supplied by callers that know this from a fixed table (e.g. the\n * Expo plugin's React Native host-component overrides). The Vite/Next.js\n * plugins supply no overrides — custom components are left without a\n * `supports-children` flag and consumers treat their support as unknown.\n */\nexport interface ElementTypeSupport {\n supportsChildren: boolean;\n}\n\n/** HTML void elements that cannot have children (self-closing only). */\nexport const HTML_VOID_ELEMENTS = new Set([\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n\nexport type ComputeAnnotatedProps = (\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n) => Record<string, PropValue>;\n\nexport function cleanModuleId(id: string): string {\n return id.replace(/[?#].*$/, \"\");\n}\n\nexport function resolveCanonicalRoot(root: string): string {\n try {\n return realpathSync.native(root);\n } catch {\n return root;\n }\n}\n\nexport function isIntrinsicElement(tagName: string): boolean {\n return tagName.length > 0 && tagName[0] === tagName[0]!.toLowerCase();\n}\n\nexport function hasJsxAttribute(info: ElementInfo, attrName: string): boolean {\n for (const attr of info.element.openingElement.attributes) {\n const name = (attr as { name?: { name?: unknown } }).name;\n if (name?.name === attrName) return true;\n }\n return false;\n}\n\nexport function defaultComputeAnnotatedProps(\n info: ElementInfo,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): Record<string, PropValue> {\n return {\n \"data-tempo-filepath\": filepath,\n \"data-tempo-position\": info.element.openingElement.start,\n // Runtime display names can differ from the JSX used at this callsite\n // (imports, member expressions, memo and forwardRef wrappers).\n \"data-tempo-source-tag\": info.tagName,\n \"data-tempo-modifiedts\": modifiedtsMs,\n // Content-hash identity of the file this element was annotated from. The\n // canvas reconcile loop equality-compares it against the write pipeline's\n // computed version to decide whether a capture reflects a given edit.\n \"data-tempo-source-version\": sourceVersion,\n };\n}\n\n/**\n * Appends the module version record: one guarded statement that runs when the\n * browser evaluates the module and pushes `{file, modifiedTs, sourceVersion}`\n * onto `globalThis.__TEMPO_MODULE_VERSIONS__`, keyed by the same `filepath`\n * the element stamps carry. The projection producer joins these records to\n * React's refresh so the canvas learns that a write reached the host even\n * when the write left no element of the file on a board (V2-498).\n *\n * It is appended to every filtered module, JSX or not: a write that removes a\n * file's last element is exactly the case that needs it. It goes at the end\n * so it never displaces a leading directive such as \"use client\", and adds no\n * line above existing code so positions and source maps are unchanged. The\n * `window` guard keeps server-side evaluation (Next server components, SSR)\n * from recording anything.\n */\nexport function appendModuleVersionRecord(\n source: string,\n filepath: string,\n modifiedtsMs: number,\n sourceVersion: string,\n): string {\n const record = JSON.stringify({\n file: filepath,\n modifiedTs: modifiedtsMs,\n sourceVersion,\n });\n return `${source}\\n;typeof window !== \"undefined\" && (globalThis.__TEMPO_MODULE_VERSIONS__ || (globalThis.__TEMPO_MODULE_VERSIONS__ = [])).push(${record});\\n`;\n}\n\nexport function computeTempoAnnotatedProps(params: {\n info: ElementInfo;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n computeAnnotatedProps?: ComputeAnnotatedProps;\n elementSupportOverrides?: ReadonlyMap<string, ElementTypeSupport>;\n}): Record<string, PropValue> {\n const {\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n computeAnnotatedProps,\n elementSupportOverrides,\n } = params;\n\n const userProps = {\n ...(computeAnnotatedProps\n ? computeAnnotatedProps(info, filepath, modifiedtsMs, sourceVersion)\n : defaultComputeAnnotatedProps(\n info,\n filepath,\n modifiedtsMs,\n sourceVersion,\n )),\n // Only a caller that knows the parent can say whether the slot is a JSX\n // child; without it every element would read as a dynamic slot.\n ...(info.parentType !== undefined &&\n !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE)\n ? {\n [EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(\n info.element,\n info.parentType,\n ),\n }\n : {}),\n };\n\n if (isIntrinsicElement(info.tagName)) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : !HTML_VOID_ELEMENTS.has(info.tagName),\n };\n }\n\n const override = elementSupportOverrides?.get(info.tagName);\n if (override) {\n return {\n ...userProps,\n \"data-tempo-supports-children\": hasJsxAttribute(\n info,\n \"data-tempo-supports-children\",\n )\n ? undefined\n : override.supportsChildren,\n };\n }\n\n // Custom component with no static override: emit no `data-tempo-supports-*`\n // flags. Determining them required a per-file TypeScript program, which was\n // removed for being the dominant cost of devserver startup. Consumers treat\n // the absent flags as \"unknown\" and fall back to their own defaults.\n return userProps;\n}\n\nexport function getFileAnnotationContext(params: {\n source: string;\n filename: string;\n root: string;\n canonicalizeFilename?: boolean;\n}): {\n cleanFilename: string;\n filepath: string;\n modifiedtsMs: number;\n sourceVersion: string;\n} {\n const rawCleanFilename = cleanModuleId(params.filename);\n let cleanFilename = rawCleanFilename;\n if (params.canonicalizeFilename) {\n try {\n cleanFilename = realpathSync.native(rawCleanFilename);\n } catch {\n cleanFilename = rawCleanFilename;\n }\n }\n return {\n cleanFilename,\n filepath: relative(params.root, cleanFilename),\n modifiedtsMs: Math.trunc(statSync(cleanFilename).mtimeMs),\n // Hashed once per file per transform (the context is built once, reused\n // for every element) so the per-element funnel just forwards the token.\n sourceVersion: sourceVersionHash(params.source),\n };\n}\n"],"mappings":";;;;;;AAAA,SAAS,cAAc,gBAAgB;AACvC,SAAS,gBAAgB;AA0BlB,IAAM,qBAAqB,oBAAI,IAAI;AAAA,EACxC;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AC,gBAAgB,MAAM,0BAA0B,IAC7C;AAAA,MACE,CAAC,0BAA0B,GAAG;AAAA,QAC5B,KAAK;AAAA,QACL,KAAK;AAAA,MACP;AAAA,IACF,IACA,CAAC;AAAA,EACP;AAEA,MAAI,mBAAmB,KAAK,OAAO,GAAG;AACpC,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gCAAgC;AAAA,QAC9B;AAAA,QACA;AAAA,MACF,IACI,SACA,CAAC,mBAAmB,IAAI,KAAK,OAAO;AAAA,IAC1C;AAAA,EACF;AAEA,QAAM,WAAW,yBAAyB,IAAI,KAAK,OAAO;AAC1D,MAAI,UAAU;AACZ,WAAO;AAAA,MACL,GAAG;AAAA,MACH,gCAAgC;AAAA,QAC9B;AAAA,QACA;AAAA,MACF,IACI,SACA,SAAS;AAAA,IACf;AAAA,EACF;AAMA,SAAO;AACT;","names":[]}
@@ -76,26 +76,9 @@ function getDisplayName(fiber) {
76
76
  if (tag === FiberTag.HostText) {
77
77
  return "#text";
78
78
  }
79
- if (typeof type === "function") {
80
- const fn = type;
81
- return fn.displayName || fn.name || "Anonymous";
82
- }
83
- if (type && typeof type === "object") {
84
- if ("type" in type && type.type) {
85
- const inner = type.type;
86
- if (typeof inner === "function") {
87
- return inner.displayName || inner.name || "Memo";
88
- }
89
- }
90
- if ("render" in type && type.render) {
91
- const render = type.render;
92
- return type.displayName || render.displayName || render.name || "ForwardRef";
93
- }
94
- if ("_context" in type) {
95
- const ctx = type._context;
96
- return ctx.displayName ? `${ctx.displayName}.Provider` : "Context.Provider";
97
- }
98
- }
79
+ const componentName = getComponentDisplayName(type, /* @__PURE__ */ new Set());
80
+ if (componentName) return componentName;
81
+ if (typeof type === "function") return "Anonymous";
99
82
  const tagNames = {
100
83
  [FiberTag.HostRoot]: "HostRoot",
101
84
  [FiberTag.Fragment]: "Fragment",
@@ -109,6 +92,27 @@ function getDisplayName(fiber) {
109
92
  };
110
93
  return tagNames[tag] || `Unknown(${tag})`;
111
94
  }
95
+ function getComponentDisplayName(type, seen) {
96
+ if (typeof type === "function") {
97
+ return type.displayName || type.name || null;
98
+ }
99
+ if (!type || typeof type !== "object" || seen.has(type)) return null;
100
+ seen.add(type);
101
+ if ("displayName" in type && typeof type.displayName === "string" && type.displayName) {
102
+ return type.displayName;
103
+ }
104
+ if ("type" in type && type.type) {
105
+ return getComponentDisplayName(type.type, seen) || "Memo";
106
+ }
107
+ if ("render" in type && type.render) {
108
+ return getComponentDisplayName(type.render, seen) || "ForwardRef";
109
+ }
110
+ if ("_context" in type) {
111
+ const ctx = type._context;
112
+ return ctx.displayName ? `${ctx.displayName}.Provider` : "Context.Provider";
113
+ }
114
+ return null;
115
+ }
112
116
  function getTag(fiber) {
113
117
  return fiber.tag;
114
118
  }
@@ -820,7 +824,8 @@ function assignDomId(element) {
820
824
  id2 = nextProjectionId();
821
825
  liveElementIds.set(element, id2);
822
826
  }
823
- if (hasPendingReactHydration(element)) return id2;
827
+ if (hasPendingReactHydration(element) || hasContentEditableAncestor(element))
828
+ return id2;
824
829
  if (element.getAttribute(DOM_ID_ATTR) !== id2) {
825
830
  element.setAttribute(DOM_ID_ATTR, id2);
826
831
  }
@@ -858,7 +863,6 @@ function ensureProjectionDomId(element, root) {
858
863
  return id2;
859
864
  }
860
865
  if (!(element instanceof Element)) return null;
861
- if (hasContentEditableAncestor(element)) return null;
862
866
  return assignDomId(element);
863
867
  }
864
868
  function readProjectionDomId(element) {
@@ -1085,6 +1089,46 @@ function hasPendingMutations(watcher) {
1085
1089
  return watcher.mutatedElements.size > 0;
1086
1090
  }
1087
1091
 
1092
+ // ../../modules/iframe-projection/inline-style.ts
1093
+ function splitCssDeclarations(text) {
1094
+ const declarations = [];
1095
+ let start = 0;
1096
+ let quote = "";
1097
+ let comment = false;
1098
+ let depth = 0;
1099
+ for (let i = 0; i < text.length; i++) {
1100
+ const char = text[i];
1101
+ if (comment) {
1102
+ if (char === "*" && text[i + 1] === "/") {
1103
+ comment = false;
1104
+ i++;
1105
+ }
1106
+ continue;
1107
+ }
1108
+ if (char === "\\") {
1109
+ i++;
1110
+ continue;
1111
+ }
1112
+ if (quote) {
1113
+ if (char === quote) quote = "";
1114
+ continue;
1115
+ }
1116
+ if (char === "/" && text[i + 1] === "*") {
1117
+ comment = true;
1118
+ i++;
1119
+ } else if (char === '"' || char === "'") quote = char;
1120
+ else if (char === "(" || char === "[" || char === "{") depth++;
1121
+ else if (char === ")" || char === "]" || char === "}")
1122
+ depth = Math.max(0, depth - 1);
1123
+ else if (char === ";" && depth === 0) {
1124
+ declarations.push(text.slice(start, i));
1125
+ start = i + 1;
1126
+ }
1127
+ }
1128
+ declarations.push(text.slice(start));
1129
+ return declarations;
1130
+ }
1131
+
1088
1132
  // ../../modules/iframe-projection/combined/projection-observed-files.ts
1089
1133
  var ProjectionObservedFileAccumulator = class {
1090
1134
  constructor() {
@@ -2149,7 +2193,7 @@ function invocationSourceLayerProps(source2, invocation) {
2149
2193
  function parseInlineStyle(value) {
2150
2194
  if (!value) return void 0;
2151
2195
  const style = {};
2152
- for (const declaration of value.split(";")) {
2196
+ for (const declaration of splitCssDeclarations(value)) {
2153
2197
  const separator = declaration.indexOf(":");
2154
2198
  if (separator < 0) continue;
2155
2199
  const property = declaration.slice(0, separator).trim();
@@ -2953,6 +2997,7 @@ function captureProjectionLayerProps(fiber, element, sourceAnnotations = "fiber"
2953
2997
  else if (locked === false || locked === "false")
2954
2998
  props["data-tempo-locked"] = false;
2955
2999
  putFiniteNumber("data-tempo-position", "tempoPosition");
3000
+ putString("data-tempo-source-tag", "tempoSourceTag");
2956
3001
  putFiniteNumber("data-tempo-modifiedts", "tempoModifiedts");
2957
3002
  putString("data-tempo-source-version", "tempoSourceVersion");
2958
3003
  putBoolean("data-tempo-supports-style", "tempoSupportsStyle");
@@ -2990,7 +3035,7 @@ function countNodes(nodes) {
2990
3035
  function parseInlineStyle2(value) {
2991
3036
  if (!value) return void 0;
2992
3037
  const style = {};
2993
- for (const declaration of value.split(";")) {
3038
+ for (const declaration of splitCssDeclarations(value)) {
2994
3039
  const colon = declaration.indexOf(":");
2995
3040
  if (colon < 0) continue;
2996
3041
  const property = declaration.slice(0, colon).trim();
@@ -3076,4 +3121,4 @@ export {
3076
3121
  invocationSourceLayerProps,
3077
3122
  parseInlineStyle
3078
3123
  };
3079
- //# sourceMappingURL=chunk-QJA366VX.js.map
3124
+ //# sourceMappingURL=chunk-DNERBE7A.js.map