@vcp-dev/site-edit-engine 0.11.41 → 0.11.42

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.
@@ -1,4 +1,4 @@
1
- import type { SiteEditCompositionContext } from "@vcp-dev/contracts";
1
+ import type { SiteEditCompositionContext } from "@vcp-dev/platform-shared/contracts";
2
2
  /**
3
3
  * 节点能力快照 —— 描述该节点支持的操作及约束。
4
4
  *
@@ -1,8 +1,8 @@
1
- import type { SiteEditOperationErrorCode } from "@vcp-dev/contracts";
1
+ import type { SiteEditOperationErrorCode } from "@vcp-dev/platform-shared/contracts";
2
2
  /**
3
3
  * 操作错误码 —— 覆盖从节点查找到写回的所有失败路径。
4
4
  *
5
- * 值域以 @vcp-dev/contracts 的 SiteEditOperationErrorCode 为唯一权威源;这里
5
+ * 值域以 @vcp-dev/platform-shared/contracts 的 SiteEditOperationErrorCode 为唯一权威源;这里
6
6
  * 保留对象形式,供 engine 内部继续使用 OperationErrorCode.NODE_NOT_FOUND
7
7
  * 这类可读访问方式。
8
8
  */
@@ -1,6 +1,6 @@
1
1
  import type { OperationResult } from "./operation.js";
2
2
  import type { OperationError } from "./error.js";
3
- import type { SiteEditCompositionContext } from "@vcp-dev/contracts";
3
+ import type { SiteEditCompositionContext } from "@vcp-dev/platform-shared/contracts";
4
4
  /**
5
5
  * 设计器事件联合类型 —— engine 向 client 推送的所有事件。
6
6
  *
@@ -1,4 +1,4 @@
1
- import type { SiteEditCompositionContext, SiteEditInsertNodeSpec, SiteEditMoveTarget, SiteEditOperationParams, SiteEditOperationRequest, SiteEditOperationTarget, SiteEditOperationType, SiteEditOperationValue, SiteEditStyleBreakpoint, SiteEditStyleProperty, SiteEditStyleStateMode, SiteEditOperationOutput, SiteEditOperationPayload } from "@vcp-dev/contracts";
1
+ import type { SiteEditCompositionContext, SiteEditInsertNodeSpec, SiteEditMoveTarget, SiteEditOperationParams, SiteEditOperationRequest, SiteEditOperationTarget, SiteEditOperationType, SiteEditOperationValue, SiteEditStyleBreakpoint, SiteEditStyleProperty, SiteEditStyleStateMode, SiteEditOperationOutput, SiteEditOperationPayload } from "@vcp-dev/platform-shared/contracts";
2
2
  import type { OperationError } from "./error.js";
3
3
  /** caller-facing 操作类型 */
4
4
  export type OperationType = SiteEditOperationType;
@@ -1,4 +1,4 @@
1
- import type { BlockDirectory, SiteEditClassNameSourceStyleContext, SiteEditCompositionContext, SiteEditPageCompositionActionScope, SiteEditPageComposition, SiteEditProperties } from "@vcp-dev/contracts";
1
+ import type { BlockDirectory, SiteEditClassNameSourceStyleContext, SiteEditCompositionContext, SiteEditPageCompositionActionScope, SiteEditPageComposition, SiteEditProperties } from "@vcp-dev/platform-shared/contracts";
2
2
  import type { NodeCapabilitySnapshot } from "./capability.js";
3
3
  import type { BoundaryKind } from "./boundary.js";
4
4
  import type { OperationType } from "./operation.js";
@@ -1,4 +1,4 @@
1
- import type { SiteEditOperationRequest, SiteEditOperationResult, SiteEditOperationType } from "@vcp-dev/contracts";
1
+ import type { SiteEditOperationRequest, SiteEditOperationResult, SiteEditOperationType } from "@vcp-dev/platform-shared/contracts";
2
2
  import type { RenderDocument as SiteEditRenderDocument, RenderEntry as SiteEditRenderEntry } from "./internal/protocol.js";
3
3
  export type { SiteEditRenderDocument, SiteEditRenderEntry };
4
4
  export declare const DEFAULT_SITE_EDIT_RUNTIME_READY_TIMEOUT_MS = 1500;
@@ -1 +1 @@
1
- "use strict";var k=require("@babel/generator"),ee=require("@babel/parser"),L=require("@babel/traverse"),r=require("@babel/types"),U=require("node:fs"),d=require("node:path"),te=typeof k=="function"?k:k.default,F=typeof L=="function"?L:L.default,K={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},ne=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]);var re="suppressHydrationWarning",ie=new Set(["SiteEditBootstrap"]),se="data-vcp-ui-component",J="components/ui";function oe(e,t){this.cacheable?.();let n=this.async();try{if(!ce(this.resourcePath)){n(null,e,t);return}let s=this.getOptions?.()??{},i=Q({source:e,file:this.resourcePath,projectRoot:s.projectRoot,cmsPreviewModulePath:ae(s.projectRoot)});n(null,i.code,i.code===e?t:null)}catch(s){n(s)}}function ae(e){try{let t=require.resolve("@vcp-dev/site-edit-bridge/auto-bootstrap",{paths:[e||process.cwd()]});for(let n of[d.dirname(t),d.resolve(d.dirname(t),"../dist")]){let s=d.join(n,"cms-preview-record.js");if(U.existsSync(s)&&U.existsSync(d.join(n,"cms-preview-probe.js")))return s}return}catch{return}}function ce(e){return typeof e=="string"&&/\.(jsx|tsx)$/.test(e)&&!e.includes("/node_modules/")&&!e.endsWith(".d.ts")}function Q(e){let t=be(e.file,e.projectRoot);if(!me(e.source)||X(t))return{code:e.source,elements:[]};let n=e.attributes??K,s=ee.parse(e.source,{sourceType:"module",plugins:["jsx","typescript"]}),i=[],o=Se(s,t);F(s,{JSXElement(u){let c=u.node.openingElement,b=c.name;if(!ve(b)||B(c,n.key))return;let S=Ce(u)??"default",w=we(u),E=ge(t,S,w),x=P(b)??"unknown",f=Ee(b)?"jsx":"component-call";if(f==="component-call"&&!Pe(u.node.children)&&ie.has(x))return;let a=f==="component-call"&&he(x,o);Ie(c,n.key,E),a&&z(c,se),fe(u)&&z(c,re),i.push({key:E,tag:x,component_name:S,source_file:t,source_kind:f})}});let p=e.cmsPreviewModulePath?le(s,e.cmsPreviewModulePath,t,e.file,e.projectRoot):!1;return i.length===0&&!p?{code:e.source,elements:i}:{code:te(s,{jsescOption:{minimal:!0}}).code,elements:i}}function W(e,t,n){if(!d.isAbsolute(e))return e;let s=d.isAbsolute(t)?t:d.resolve(n||process.cwd(),t),i=d.relative(d.dirname(s),e).split(d.sep).join("/");return i.startsWith(".")?i:`./${i}`}function le(e,t,n,s,i){let o;if(F(e,{Program(a){o=a,a.stop()}}),!o)return!1;let p=o.scope.generateUidIdentifier("vcpAttachCmsPreviewRecord"),u=o.scope.generateUidIdentifier("vcpStripCmsPreviewMetadata"),c=o.scope.generateUidIdentifier("vcpReadCmsPreviewCandidate"),b=o.scope.generateUidIdentifier("VcpCmsPreviewProbe"),S=!1,w=!1,E=!1,x=/(?:^|\/)(?:[^/]+-)?(?:list|detail)-view\.[jt]sx$/.test(n)||e.program.body.some(a=>r.isImportDeclaration(a)&&(a.source.value==="@/lib/cms"||/^@\/lib\/cms\/generated\//.test(a.source.value)));F(e,{CallExpression(a){let l=a.node;if(r.isMemberExpression(l.callee)&&!l.callee.computed&&r.isIdentifier(l.callee.property,{name:"map"})&&l.arguments.length===1&&r.isIdentifier(l.arguments[0])){let I=D(a,l.arguments[0].name),C=O(a,l.callee.object);if(I&&C?.operation==="list"&&C.slug===I.slug){let R=a.scope.generateUidIdentifier("vcpCmsRecord");l.arguments[0]=r.arrowFunctionExpression([R],r.callExpression(p,[r.callExpression(r.cloneNode(l.arguments[0]),[r.cloneNode(R)]),r.cloneNode(R),r.stringLiteral(I.slug),r.stringLiteral("list")])),S=!0,a.skip()}return}if(!r.isIdentifier(l.callee)||l.arguments.length!==1)return;let m=D(a,l.callee.name),y=r.isIdentifier(l.arguments[0]),v=y?l.arguments[0].name:N(l.arguments[0],["data"]),h=v&&Z(a,v);if(!m||h?.operation!=="detail"||(y?h.slug!==m.slug:h.slug!==void 0))return;let T=r.cloneNode(l,!0),A=r.cloneNode(l.arguments[0],!0);a.replaceWith(r.callExpression(p,[T,A,r.stringLiteral(m.slug),r.stringLiteral("detail")])),S=!0,a.skip()},JSXSpreadAttribute(a){a.node.argument=r.callExpression(u,[a.node.argument]),w=!0},JSXElement:{exit(a){if(!x)return;let l=a.node.openingElement;if(!B(l,K.key))return;let m=ue(a);if(!m)return;let y=l.attributes.findIndex(C=>r.isJSXAttribute(C)&&r.isJSXIdentifier(C.name,{name:"key"})),v=y<0?null:l.attributes.splice(y,1)[0],h=[r.identifier(m.base),r.stringLiteral(m.field)];m.index&&h.push(r.cloneNode(m.index,!0));let T=[...v?[v]:[],r.jsxAttribute(r.jsxIdentifier("candidate"),r.jsxExpressionContainer(r.callExpression(c,h)))],A=r.jsxIdentifier(b.name),I=r.jsxElement(r.jsxOpeningElement(r.cloneNode(A),T,!1),r.jsxClosingElement(r.cloneNode(A)),[a.node]);a.replaceWith(I),E=!0,a.skip()}}});let f=[];return S&&f.push(r.importSpecifier(p,r.identifier("attachCmsPreviewRecord"))),w&&f.push(r.importSpecifier(u,r.identifier("stripCmsPreviewMetadata"))),E&&f.push(r.importSpecifier(c,r.identifier("readCmsPreviewCandidate"))),f.length&&e.program.body.unshift(r.importDeclaration(f,r.stringLiteral(W(t,s,i)))),E&&e.program.body.unshift(r.importDeclaration([r.importSpecifier(b,r.identifier("CmsPreviewProbe"))],r.stringLiteral(W(d.join(d.dirname(t),"cms-preview-probe.js"),s,i)))),f.length>0||E}function ue(e){let t=e.node,n=t.openingElement.name,s=P(n);if(!s)return null;let i=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"src"})),o=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"dangerouslySetInnerHTML"})),p=s==="img"||/^[A-Z]/.test(s)&&i,u=p?r.isJSXAttribute(i)&&r.isJSXExpressionContainer(i.value)&&r.isExpression(i.value.expression)?[i.value.expression]:[]:r.isJSXAttribute(o)&&r.isJSXExpressionContainer(o.value)&&r.isExpression(o.value.expression)?[o.value.expression]:t.children.flatMap(c=>r.isJSXExpressionContainer(c)&&r.isExpression(c.expression)?[c.expression]:[]);return u.length!==1?null:p&&r.isIdentifier(u[0])&&e.scope.hasBinding(u[0].name)?{base:u[0].name,field:"url"}:pe(u[0],e)}function pe(e,t){let n=e,s=[];for(;r.isMemberExpression(n)||r.isOptionalMemberExpression(n);){if(!n.computed&&r.isIdentifier(n.property))s.unshift({property:n.property.name});else if(n.computed&&r.isNumericLiteral(n.property)&&Number.isSafeInteger(n.property.value)&&n.property.value>=0)s.unshift({index:n.property});else if(n.computed&&r.isIdentifier(n.property)&&t.scope.hasBinding(n.property.name))s.unshift({index:n.property});else return null;n=n.object}if(!r.isIdentifier(n)||!t.scope.hasBinding(n.name)||(s[0]?.property==="fields"&&s.shift(),!s[0]?.property||s.slice(2).some(o=>o.index)))return null;let i=s[1];return{base:n.name,field:s[0].property,...i?.index?{index:i.index}:{}}}function D(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isImportSpecifier())return null;let s=n.path.node;if(!r.isIdentifier(s.imported)||!/^to[A-Za-z0-9_$]+View$/.test(s.imported.name))return null;let i=n.path.parentPath.node.source.value,o=typeof i=="string"&&i.match(/^@\/lib\/cms\/generated\/([a-z0-9][a-z0-9-]*)$/);return o?{slug:o[1]}:null}function N(e,t){let n=e;for(let s of[...t].reverse()){if(!r.isMemberExpression(n)||n.computed||!r.isIdentifier(n.property,{name:s}))return null;n=n.object}return r.isIdentifier(n)?n.name:null}function de(e){if(r.isConditionalExpression(e)){let t=N(e.consequent,["data","items"]);return!t||!r.isArrayExpression(e.alternate)||e.alternate.elements.length!==0||!r.isBinaryExpression(e.test,{operator:"==="})||N(e.test.left,["kind"])!==t||!r.isStringLiteral(e.test.right,{value:"ok"})?null:t}return N(e,["data","items"])}function O(e,t,n=new Set){let s=de(t);if(s)return Z(e,s);if(n.size>=20)return null;if(r.isIdentifier(t)){let i=e.scope.getBinding(t.name);return!i?.constant||!i.path.isVariableDeclarator()||!i.path.node.init||n.has(i)?null:(n.add(i),O(e,i.path.node.init,n))}return r.isCallExpression(t)&&r.isMemberExpression(t.callee)&&!t.callee.computed&&r.isIdentifier(t.callee.property)&&["filter","slice","sort","toSorted","reverse","toReversed"].includes(t.callee.property.name)?(n.add(t),O(e,t.callee.object,n)):null}function Z(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isVariableDeclarator())return null;let s=n.path.node.init,i=r.isAwaitExpression(s)?s.argument:null;if(!r.isCallExpression(i)||!r.isMemberExpression(i.callee)||i.callee.computed||!r.isIdentifier(i.callee.property)||!r.isMemberExpression(i.callee.object)||i.callee.object.computed||!r.isIdentifier(i.callee.object.property,{name:"collections"})||!r.isIdentifier(i.callee.object.object))return null;let o=e.scope.getBinding(i.callee.object.object.name);return!o?.constant||!o.path.isImportSpecifier()||!r.isIdentifier(o.path.node.imported,{name:"cms"})||o.path.parentPath.node.source.value!=="@/lib/cms"?null:i.callee.property.name==="listStrict"&&r.isStringLiteral(i.arguments[0])?{operation:"list",slug:i.arguments[0].value}:i.callee.property.name==="getByUrlStrict"?{operation:"detail"}:i.callee.property.name==="get"&&r.isStringLiteral(i.arguments[0])?{operation:"detail",slug:i.arguments[0].value}:null}function fe(e){return!e.findParent(t=>t.isJSXElement())}function me(e){if(typeof e!="string")throw new TypeError("site edit instrumentation source must be a string");return/(?:^|[=(:,?;\[{>&|\n\r]|return\s+)\s*<(?:[A-Za-z][\w.:-]*|>)(?:\s|>|\/)/m.test(e)}function ge(e,t,n){return`${e}::${t}::${n}`}function be(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),s=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(s&&n.startsWith(`${s}/`))return n.slice(s.length+1);for(let[o,p]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let u=n.indexOf(o);if(u>=0)return n.slice(u+p)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function Ee(e){return r.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function P(e){return r.isJSXIdentifier(e)?e.name:r.isJSXMemberExpression(e)?G(e):null}function Se(e,t){let n=new Set;for(let s of e.program.body)if(!(!r.isImportDeclaration(s)||!xe(s.source.value,t)))for(let i of s.specifiers)n.add(i.local.name);return n}function he(e,t){let n=e.split(".")[0]??e;return t.has(n)}function X(e){if(!e)return!1;let t=$(e);return t===J||t.startsWith(`${J}/`)||t.includes(`/${J}/`)||t.endsWith(`/${J}`)}function xe(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?X(e.slice(2)):e.startsWith("./")||e.startsWith("../")?X($(`${ye(t)}/${e}`)):X(e):!1}function $(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),s=[];for(let i of n.split("/"))if(!(!i||i===".")){if(i===".."){s.pop();continue}s.push(i)}return s.join("/")}function ye(e){let t=$(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function ve(e){let t=P(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!ne.has(t)}function B(e,t){return e.attributes.some(n=>r.isJSXAttribute(n)&&r.isJSXIdentifier(n.name,{name:t}))}function Ie(e,t,n){H(e,r.jsxAttribute(r.jsxIdentifier(t),r.stringLiteral(n)))}function z(e,t){B(e,t)||H(e,r.jsxAttribute(r.jsxIdentifier(t),null))}function H(e,t){let n=e.attributes.findIndex(s=>r.isJSXSpreadAttribute(s));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function G(e){return`${r.isJSXIdentifier(e.object)?e.object.name:G(e.object)}.${e.property.name}`}function Ce(e){let t=e;for(;t;){if(t.isFunctionDeclaration()||t.isClassDeclaration())return t.node.id?.name??null;if(t.isVariableDeclarator()&&r.isIdentifier(t.node.id)){let n=t.get("init");if(!Array.isArray(n)&&(n.isArrowFunctionExpression()||n.isFunctionExpression()))return t.node.id.name}t=t.parentPath}return null}function Pe(e){return e.some(t=>r.isJSXElement(t)||r.isJSXFragment(t))}var q=new WeakMap,j=new WeakMap,_=new WeakMap;function we(e){let t=q.get(e.node);if(t!==void 0)return t;let n=[],s=e;for(;s;){if(s.isJSXElement()){let o=Ae(s);o&&n.unshift(o)}s=s.parentPath}let i=n.join("/");return q.set(e.node,i),i}function Ae(e){let t=P(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${V(e,t)}`:`${t}#${V(e,t)}`}function V(e,t){let n=Y(e)??e.getFunctionParent();if(!n)return 0;let s=_.get(n.node)?.get(t)?.get(e.node);if(s!==void 0)return s;let i=_.get(n.node);i||(i=new Map,_.set(n.node,i));let o=i.get(t);o||(o=new WeakMap,i.set(t,o));let p=0,u=n.isJSXElement()||n.isJSXFragment()?M(n):Je(n);for(let c of u)if(P(c.node.openingElement.name)===t){if(o.set(c.node,p),c.node===e.node)return p;p+=1}return o.get(e.node)??0}function Je(e){let t=j.get(e.node);if(t)return t;let n=[];return e.traverse({JSXElement(s){s.getFunctionParent()?.node===e.node&&!Y(s)&&n.push(s)}}),j.set(e.node,n),n}function Y(e){let t=e.parentPath,n=null;for(;t;){if(t.isJSXFragment()){n=t,t=t.parentPath;continue}if(t.isJSXElement())return t;t=t.parentPath}return n}function M(e){let t=j.get(e.node);if(t)return t;let n=[],s=e.get("children");for(let i of s)if(!Array.isArray(i)){if(i.isJSXElement()){n.push(i);continue}if(i.isJSXFragment()){n.push(...M(i));continue}i.isJSXExpressionContainer()&&n.push(...g(i.get("expression")))}return j.set(e.node,n),n}function g(e){return e.isJSXElement()?[e]:e.isJSXFragment()?M(e):e.isParenthesizedExpression()?g(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?g(e.get("right")):e.isConditionalExpression()?[...g(e.get("consequent")),...g(e.get("alternate"))]:e.isCallExpression()&&Xe(e.node)?Ne(e.get("arguments")[0]):[]}function Ne(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return M(t);if(t.isParenthesizedExpression())return g(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let s of t.get("body")){if(s.isVariableDeclaration())for(let o of s.get("declarations")){let p=o.get("init");(p.isJSXElement()||p.isJSXFragment())&&n.push(...g(p))}if(!s.isReturnStatement())continue;let i=s.get("argument");return i.node&&n.push(...g(i)),n}return n}function Xe(e){return r.isMemberExpression(e.callee)&&r.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}module.exports=oe;module.exports.instrumentSiteEditRuntimeAttributes=Q;
1
+ "use strict";var R=require("@babel/generator"),ne=require("@babel/parser"),k=require("@babel/traverse"),r=require("@babel/types"),B=require("node:fs"),d=require("node:path"),re=typeof R=="function"?R:R.default,_=typeof k=="function"?k:k.default,Z={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},ie=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]);var se="suppressHydrationWarning",oe=new Set(["SiteEditBootstrap"]),W="data-vcp-source-location",ae="data-vcp-ui-component",J="components/ui";function ce(e,t){this.cacheable?.();let n=this.async();try{if(!ue(this.resourcePath)){n(null,e,t);return}let s=this.getOptions?.()??{},i=H({source:e,file:this.resourcePath,projectRoot:s.projectRoot,sourceLocations:s.sourceLocations===!0,cmsPreviewModulePath:le(s.projectRoot)});n(null,i.code,i.code===e?t:null)}catch(s){n(s)}}function le(e){try{let t=require.resolve("@vcp-dev/site-edit-bridge/auto-bootstrap",{paths:[e||process.cwd()]});for(let n of[d.dirname(t),d.resolve(d.dirname(t),"../dist")]){let s=d.join(n,"cms-preview-record.js");if(B.existsSync(s)&&B.existsSync(d.join(n,"cms-preview-probe.js")))return s}return}catch{return}}function ue(e){return typeof e=="string"&&/\.(jsx|tsx)$/.test(e)&&!e.includes("/node_modules/")&&!e.endsWith(".d.ts")}function H(e){let t=be(e.file,e.projectRoot);if(!Ee(e.source)||X(t))return{code:e.source,elements:[]};let n=e.attributes??Z,s=ne.parse(e.source,{sourceType:"module",plugins:["jsx","typescript"]}),i=[],o=xe(s,t);_(s,{JSXElement(u){let c=u.node.openingElement,S=c.name;if(!Ce(S)||$(c,n.key)&&!e.sourceLocations)return;let b=Pe(u)??"default",x=Ae(u),g=Se(t,b,x),y=w(S)??"unknown",m=he(S)?"jsx":"component-call";if(m==="component-call"&&!we(u.node.children)&&oe.has(y))return;let l=m==="component-call"&&ye(y,o);if(e.sourceLocations&&(c.attributes=c.attributes.filter(a=>!(r.isJSXAttribute(a)&&r.isJSXIdentifier(a.name)&&(a.name.name===n.key||a.name.name===W))),c.loc)){let{start:a,end:f}=c.loc;q(c,W,encodeURIComponent(JSON.stringify({key:g,sourceFile:t,componentName:b,structuralPath:x,openingElementRange:{startLine:a.line,startColumn:a.column,endLine:f.line,endColumn:f.column}})))}q(c,n.key,g),l&&V(c,ae),ge(u)&&V(c,se),i.push({key:g,tag:y,component_name:b,source_file:t,source_kind:m})}});let p=e.cmsPreviewModulePath?pe(s,e.cmsPreviewModulePath,t,e.file,e.projectRoot):!1;return i.length===0&&!p?{code:e.source,elements:i}:{code:re(s,{jsescOption:{minimal:!0}}).code,elements:i}}function D(e,t,n){if(!d.isAbsolute(e))return e;let s=d.isAbsolute(t)?t:d.resolve(n||process.cwd(),t),i=d.relative(d.dirname(s),e).split(d.sep).join("/");return i.startsWith(".")?i:`./${i}`}function pe(e,t,n,s,i){let o;if(_(e,{Program(l){o=l,l.stop()}}),!o)return!1;let p=o.scope.generateUidIdentifier("vcpAttachCmsPreviewRecord"),u=o.scope.generateUidIdentifier("vcpStripCmsPreviewMetadata"),c=o.scope.generateUidIdentifier("vcpReadCmsPreviewCandidate"),S=o.scope.generateUidIdentifier("VcpCmsPreviewProbe"),b=!1,x=!1,g=!1,y=/(?:^|\/)(?:[^/]+-)?(?:list|detail)-view\.[jt]sx$/.test(n)||e.program.body.some(l=>r.isImportDeclaration(l)&&(l.source.value==="@/lib/cms"||/^@\/lib\/cms\/generated\//.test(l.source.value)));_(e,{CallExpression(l){let a=l.node;if(r.isMemberExpression(a.callee)&&!a.callee.computed&&r.isIdentifier(a.callee.property,{name:"map"})&&a.arguments.length===1&&r.isIdentifier(a.arguments[0])){let C=z(l,a.arguments[0].name),P=F(l,a.callee.object);if(C&&P?.operation==="list"&&P.slug===C.slug){let M=l.scope.generateUidIdentifier("vcpCmsRecord");a.arguments[0]=r.arrowFunctionExpression([M],r.callExpression(p,[r.callExpression(r.cloneNode(a.arguments[0]),[r.cloneNode(M)]),r.cloneNode(M),r.stringLiteral(C.slug),r.stringLiteral("list")])),b=!0,l.skip()}return}if(!r.isIdentifier(a.callee)||a.arguments.length!==1)return;let f=z(l,a.callee.name),I=r.isIdentifier(a.arguments[0]),v=I?a.arguments[0].name:N(a.arguments[0],["data"]),h=v&&G(l,v);if(!f||h?.operation!=="detail"||(I?h.slug!==f.slug:h.slug!==void 0))return;let L=r.cloneNode(a,!0),A=r.cloneNode(a.arguments[0],!0);l.replaceWith(r.callExpression(p,[L,A,r.stringLiteral(f.slug),r.stringLiteral("detail")])),b=!0,l.skip()},JSXSpreadAttribute(l){l.node.argument=r.callExpression(u,[l.node.argument]),x=!0},JSXElement:{exit(l){if(!y)return;let a=l.node.openingElement;if(!$(a,Z.key))return;let f=de(l);if(!f)return;let I=a.attributes.findIndex(P=>r.isJSXAttribute(P)&&r.isJSXIdentifier(P.name,{name:"key"})),v=I<0?null:a.attributes.splice(I,1)[0],h=[r.identifier(f.base),r.stringLiteral(f.field)];f.index&&h.push(r.cloneNode(f.index,!0));let L=[...v?[v]:[],r.jsxAttribute(r.jsxIdentifier("candidate"),r.jsxExpressionContainer(r.callExpression(c,h)))],A=r.jsxIdentifier(S.name),C=r.jsxElement(r.jsxOpeningElement(r.cloneNode(A),L,!1),r.jsxClosingElement(r.cloneNode(A)),[l.node]);l.replaceWith(C),g=!0,l.skip()}}});let m=[];return b&&m.push(r.importSpecifier(p,r.identifier("attachCmsPreviewRecord"))),x&&m.push(r.importSpecifier(u,r.identifier("stripCmsPreviewMetadata"))),g&&m.push(r.importSpecifier(c,r.identifier("readCmsPreviewCandidate"))),m.length&&e.program.body.unshift(r.importDeclaration(m,r.stringLiteral(D(t,s,i)))),g&&e.program.body.unshift(r.importDeclaration([r.importSpecifier(S,r.identifier("CmsPreviewProbe"))],r.stringLiteral(D(d.join(d.dirname(t),"cms-preview-probe.js"),s,i)))),m.length>0||g}function de(e){let t=e.node,n=t.openingElement.name,s=w(n);if(!s)return null;let i=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"src"})),o=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"dangerouslySetInnerHTML"})),p=s==="img"||/^[A-Z]/.test(s)&&i,u=p?r.isJSXAttribute(i)&&r.isJSXExpressionContainer(i.value)&&r.isExpression(i.value.expression)?[i.value.expression]:[]:r.isJSXAttribute(o)&&r.isJSXExpressionContainer(o.value)&&r.isExpression(o.value.expression)?[o.value.expression]:t.children.flatMap(c=>r.isJSXExpressionContainer(c)&&r.isExpression(c.expression)?[c.expression]:[]);return u.length!==1?null:p&&r.isIdentifier(u[0])&&e.scope.hasBinding(u[0].name)?{base:u[0].name,field:"url"}:fe(u[0],e)}function fe(e,t){let n=e,s=[];for(;r.isMemberExpression(n)||r.isOptionalMemberExpression(n);){if(!n.computed&&r.isIdentifier(n.property))s.unshift({property:n.property.name});else if(n.computed&&r.isNumericLiteral(n.property)&&Number.isSafeInteger(n.property.value)&&n.property.value>=0)s.unshift({index:n.property});else if(n.computed&&r.isIdentifier(n.property)&&t.scope.hasBinding(n.property.name))s.unshift({index:n.property});else return null;n=n.object}if(!r.isIdentifier(n)||!t.scope.hasBinding(n.name)||(s[0]?.property==="fields"&&s.shift(),!s[0]?.property||s.slice(2).some(o=>o.index)))return null;let i=s[1];return{base:n.name,field:s[0].property,...i?.index?{index:i.index}:{}}}function z(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isImportSpecifier())return null;let s=n.path.node;if(!r.isIdentifier(s.imported)||!/^to[A-Za-z0-9_$]+View$/.test(s.imported.name))return null;let i=n.path.parentPath.node.source.value,o=typeof i=="string"&&i.match(/^@\/lib\/cms\/generated\/([a-z0-9][a-z0-9-]*)$/);return o?{slug:o[1]}:null}function N(e,t){let n=e;for(let s of[...t].reverse()){if(!r.isMemberExpression(n)||n.computed||!r.isIdentifier(n.property,{name:s}))return null;n=n.object}return r.isIdentifier(n)?n.name:null}function me(e){if(r.isConditionalExpression(e)){let t=N(e.consequent,["data","items"]);return!t||!r.isArrayExpression(e.alternate)||e.alternate.elements.length!==0||!r.isBinaryExpression(e.test,{operator:"==="})||N(e.test.left,["kind"])!==t||!r.isStringLiteral(e.test.right,{value:"ok"})?null:t}return N(e,["data","items"])}function F(e,t,n=new Set){let s=me(t);if(s)return G(e,s);if(n.size>=20)return null;if(r.isIdentifier(t)){let i=e.scope.getBinding(t.name);return!i?.constant||!i.path.isVariableDeclarator()||!i.path.node.init||n.has(i)?null:(n.add(i),F(e,i.path.node.init,n))}return r.isCallExpression(t)&&r.isMemberExpression(t.callee)&&!t.callee.computed&&r.isIdentifier(t.callee.property)&&["filter","slice","sort","toSorted","reverse","toReversed"].includes(t.callee.property.name)?(n.add(t),F(e,t.callee.object,n)):null}function G(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isVariableDeclarator())return null;let s=n.path.node.init,i=r.isAwaitExpression(s)?s.argument:null;if(!r.isCallExpression(i)||!r.isMemberExpression(i.callee)||i.callee.computed||!r.isIdentifier(i.callee.property)||!r.isMemberExpression(i.callee.object)||i.callee.object.computed||!r.isIdentifier(i.callee.object.property,{name:"collections"})||!r.isIdentifier(i.callee.object.object))return null;let o=e.scope.getBinding(i.callee.object.object.name);return!o?.constant||!o.path.isImportSpecifier()||!r.isIdentifier(o.path.node.imported,{name:"cms"})||o.path.parentPath.node.source.value!=="@/lib/cms"?null:i.callee.property.name==="listStrict"&&r.isStringLiteral(i.arguments[0])?{operation:"list",slug:i.arguments[0].value}:i.callee.property.name==="getByUrlStrict"?{operation:"detail"}:i.callee.property.name==="get"&&r.isStringLiteral(i.arguments[0])?{operation:"detail",slug:i.arguments[0].value}:null}function ge(e){return!e.findParent(t=>t.isJSXElement())}function Ee(e){if(typeof e!="string")throw new TypeError("site edit instrumentation source must be a string");return/(?:^|[=(:,?;\[{>&|\n\r]|return\s+)\s*<(?:[A-Za-z][\w.:-]*|>)(?:\s|>|\/)/m.test(e)}function Se(e,t,n){return`${e}::${t}::${n}`}function be(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),s=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(s&&n.startsWith(`${s}/`))return n.slice(s.length+1);for(let[o,p]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let u=n.indexOf(o);if(u>=0)return n.slice(u+p)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function he(e){return r.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function w(e){return r.isJSXIdentifier(e)?e.name:r.isJSXMemberExpression(e)?ee(e):null}function xe(e,t){let n=new Set;for(let s of e.program.body)if(!(!r.isImportDeclaration(s)||!Ie(s.source.value,t)))for(let i of s.specifiers)n.add(i.local.name);return n}function ye(e,t){let n=e.split(".")[0]??e;return t.has(n)}function X(e){if(!e)return!1;let t=U(e);return t===J||t.startsWith(`${J}/`)||t.includes(`/${J}/`)||t.endsWith(`/${J}`)}function Ie(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?X(e.slice(2)):e.startsWith("./")||e.startsWith("../")?X(U(`${ve(t)}/${e}`)):X(e):!1}function U(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),s=[];for(let i of n.split("/"))if(!(!i||i===".")){if(i===".."){s.pop();continue}s.push(i)}return s.join("/")}function ve(e){let t=U(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function Ce(e){let t=w(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!ie.has(t)}function $(e,t){return e.attributes.some(n=>r.isJSXAttribute(n)&&r.isJSXIdentifier(n.name,{name:t}))}function q(e,t,n){Y(e,r.jsxAttribute(r.jsxIdentifier(t),r.stringLiteral(n)))}function V(e,t){$(e,t)||Y(e,r.jsxAttribute(r.jsxIdentifier(t),null))}function Y(e,t){let n=e.attributes.findIndex(s=>r.isJSXSpreadAttribute(s));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function ee(e){return`${r.isJSXIdentifier(e.object)?e.object.name:ee(e.object)}.${e.property.name}`}function Pe(e){let t=e;for(;t;){if(t.isFunctionDeclaration()||t.isClassDeclaration())return t.node.id?.name??null;if(t.isVariableDeclarator()&&r.isIdentifier(t.node.id)){let n=t.get("init");if(!Array.isArray(n)&&(n.isArrowFunctionExpression()||n.isFunctionExpression()))return t.node.id.name}t=t.parentPath}return null}function we(e){return e.some(t=>r.isJSXElement(t)||r.isJSXFragment(t))}var K=new WeakMap,j=new WeakMap,O=new WeakMap;function Ae(e){let t=K.get(e.node);if(t!==void 0)return t;let n=[],s=e;for(;s;){if(s.isJSXElement()){let o=Je(s);o&&n.unshift(o)}s=s.parentPath}let i=n.join("/");return K.set(e.node,i),i}function Je(e){let t=w(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${Q(e,t)}`:`${t}#${Q(e,t)}`}function Q(e,t){let n=te(e)??e.getFunctionParent();if(!n)return 0;let s=O.get(n.node)?.get(t)?.get(e.node);if(s!==void 0)return s;let i=O.get(n.node);i||(i=new Map,O.set(n.node,i));let o=i.get(t);o||(o=new WeakMap,i.set(t,o));let p=0,u=n.isJSXElement()||n.isJSXFragment()?T(n):Ne(n);for(let c of u)if(w(c.node.openingElement.name)===t){if(o.set(c.node,p),c.node===e.node)return p;p+=1}return o.get(e.node)??0}function Ne(e){let t=j.get(e.node);if(t)return t;let n=[];return e.traverse({JSXElement(s){s.getFunctionParent()?.node===e.node&&!te(s)&&n.push(s)}}),j.set(e.node,n),n}function te(e){let t=e.parentPath,n=null;for(;t;){if(t.isJSXFragment()){n=t,t=t.parentPath;continue}if(t.isJSXElement())return t;t=t.parentPath}return n}function T(e){let t=j.get(e.node);if(t)return t;let n=[],s=e.get("children");for(let i of s)if(!Array.isArray(i)){if(i.isJSXElement()){n.push(i);continue}if(i.isJSXFragment()){n.push(...T(i));continue}i.isJSXExpressionContainer()&&n.push(...E(i.get("expression")))}return j.set(e.node,n),n}function E(e){return e.isJSXElement()?[e]:e.isJSXFragment()?T(e):e.isParenthesizedExpression()?E(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?E(e.get("right")):e.isConditionalExpression()?[...E(e.get("consequent")),...E(e.get("alternate"))]:e.isCallExpression()&&je(e.node)?Xe(e.get("arguments")[0]):[]}function Xe(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return T(t);if(t.isParenthesizedExpression())return E(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let s of t.get("body")){if(s.isVariableDeclaration())for(let o of s.get("declarations")){let p=o.get("init");(p.isJSXElement()||p.isJSXFragment())&&n.push(...E(p))}if(!s.isReturnStatement())continue;let i=s.get("argument");return i.node&&n.push(...E(i)),n}return n}function je(e){return r.isMemberExpression(e.callee)&&r.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}module.exports=ce;module.exports.instrumentSiteEditRuntimeAttributes=H;
@@ -12,7 +12,7 @@ declare function siteEditInstrumentationLoader(
12
12
  inputSourceMap?: unknown,
13
13
  ) => void;
14
14
  resourcePath?: string;
15
- getOptions?: () => { projectRoot?: string };
15
+ getOptions?: () => { projectRoot?: string; sourceLocations?: boolean };
16
16
  },
17
17
  source: string,
18
18
  inputSourceMap?: unknown,
@@ -3,6 +3,8 @@ export type SiteEditInstrumentationOptions = {
3
3
  source: string;
4
4
  file: string;
5
5
  projectRoot?: string;
6
+ /** Platform-controlled preview compilation; emits actual Babel opening ranges. */
7
+ sourceLocations?: boolean;
6
8
  attributes?: SiteEditRuntimeAttributes;
7
9
  };
8
10
  export type SiteEditInstrumentedElement = {
@@ -1 +1 @@
1
- "use strict";var ne=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var te=ne((ke,U)=>{"use strict";var k=require("@babel/generator"),re=require("@babel/parser"),L=require("@babel/traverse"),r=require("@babel/types"),W=require("node:fs"),d=require("node:path"),ie=typeof k=="function"?k:k.default,F=typeof L=="function"?L:L.default,Q={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},se=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]),oe="suppressHydrationWarning",ae=new Set(["SiteEditBootstrap"]),ce="data-vcp-ui-component",J="components/ui";function le(e,t){this.cacheable?.();let n=this.async();try{if(!pe(this.resourcePath)){n(null,e,t);return}let s=this.getOptions?.()??{},i=Z({source:e,file:this.resourcePath,projectRoot:s.projectRoot,cmsPreviewModulePath:ue(s.projectRoot)});n(null,i.code,i.code===e?t:null)}catch(s){n(s)}}function ue(e){try{let t=require.resolve("@vcp-dev/site-edit-bridge/auto-bootstrap",{paths:[e||process.cwd()]});for(let n of[d.dirname(t),d.resolve(d.dirname(t),"../dist")]){let s=d.join(n,"cms-preview-record.js");if(W.existsSync(s)&&W.existsSync(d.join(n,"cms-preview-probe.js")))return s}return}catch{return}}function pe(e){return typeof e=="string"&&/\.(jsx|tsx)$/.test(e)&&!e.includes("/node_modules/")&&!e.endsWith(".d.ts")}function Z(e){let t=he(e.file,e.projectRoot);if(!Ee(e.source)||X(t))return{code:e.source,elements:[]};let n=e.attributes??Q,s=re.parse(e.source,{sourceType:"module",plugins:["jsx","typescript"]}),i=[],o=ye(s,t);F(s,{JSXElement(u){let c=u.node.openingElement,b=c.name;if(!Pe(b)||B(c,n.key))return;let S=Ae(u)??"default",w=Ne(u),E=Se(t,S,w),x=P(b)??"unknown",f=xe(b)?"jsx":"component-call";if(f==="component-call"&&!Je(u.node.children)&&ae.has(x))return;let a=f==="component-call"&&ve(x,o);we(c,n.key,E),a&&q(c,ce),be(u)&&q(c,oe),i.push({key:E,tag:x,component_name:S,source_file:t,source_kind:f})}});let p=e.cmsPreviewModulePath?de(s,e.cmsPreviewModulePath,t,e.file,e.projectRoot):!1;return i.length===0&&!p?{code:e.source,elements:i}:{code:ie(s,{jsescOption:{minimal:!0}}).code,elements:i}}function D(e,t,n){if(!d.isAbsolute(e))return e;let s=d.isAbsolute(t)?t:d.resolve(n||process.cwd(),t),i=d.relative(d.dirname(s),e).split(d.sep).join("/");return i.startsWith(".")?i:`./${i}`}function de(e,t,n,s,i){let o;if(F(e,{Program(a){o=a,a.stop()}}),!o)return!1;let p=o.scope.generateUidIdentifier("vcpAttachCmsPreviewRecord"),u=o.scope.generateUidIdentifier("vcpStripCmsPreviewMetadata"),c=o.scope.generateUidIdentifier("vcpReadCmsPreviewCandidate"),b=o.scope.generateUidIdentifier("VcpCmsPreviewProbe"),S=!1,w=!1,E=!1,x=/(?:^|\/)(?:[^/]+-)?(?:list|detail)-view\.[jt]sx$/.test(n)||e.program.body.some(a=>r.isImportDeclaration(a)&&(a.source.value==="@/lib/cms"||/^@\/lib\/cms\/generated\//.test(a.source.value)));F(e,{CallExpression(a){let l=a.node;if(r.isMemberExpression(l.callee)&&!l.callee.computed&&r.isIdentifier(l.callee.property,{name:"map"})&&l.arguments.length===1&&r.isIdentifier(l.arguments[0])){let I=z(a,l.arguments[0].name),C=O(a,l.callee.object);if(I&&C?.operation==="list"&&C.slug===I.slug){let R=a.scope.generateUidIdentifier("vcpCmsRecord");l.arguments[0]=r.arrowFunctionExpression([R],r.callExpression(p,[r.callExpression(r.cloneNode(l.arguments[0]),[r.cloneNode(R)]),r.cloneNode(R),r.stringLiteral(I.slug),r.stringLiteral("list")])),S=!0,a.skip()}return}if(!r.isIdentifier(l.callee)||l.arguments.length!==1)return;let m=z(a,l.callee.name),y=r.isIdentifier(l.arguments[0]),v=y?l.arguments[0].name:N(l.arguments[0],["data"]),h=v&&H(a,v);if(!m||h?.operation!=="detail"||(y?h.slug!==m.slug:h.slug!==void 0))return;let T=r.cloneNode(l,!0),A=r.cloneNode(l.arguments[0],!0);a.replaceWith(r.callExpression(p,[T,A,r.stringLiteral(m.slug),r.stringLiteral("detail")])),S=!0,a.skip()},JSXSpreadAttribute(a){a.node.argument=r.callExpression(u,[a.node.argument]),w=!0},JSXElement:{exit(a){if(!x)return;let l=a.node.openingElement;if(!B(l,Q.key))return;let m=fe(a);if(!m)return;let y=l.attributes.findIndex(C=>r.isJSXAttribute(C)&&r.isJSXIdentifier(C.name,{name:"key"})),v=y<0?null:l.attributes.splice(y,1)[0],h=[r.identifier(m.base),r.stringLiteral(m.field)];m.index&&h.push(r.cloneNode(m.index,!0));let T=[...v?[v]:[],r.jsxAttribute(r.jsxIdentifier("candidate"),r.jsxExpressionContainer(r.callExpression(c,h)))],A=r.jsxIdentifier(b.name),I=r.jsxElement(r.jsxOpeningElement(r.cloneNode(A),T,!1),r.jsxClosingElement(r.cloneNode(A)),[a.node]);a.replaceWith(I),E=!0,a.skip()}}});let f=[];return S&&f.push(r.importSpecifier(p,r.identifier("attachCmsPreviewRecord"))),w&&f.push(r.importSpecifier(u,r.identifier("stripCmsPreviewMetadata"))),E&&f.push(r.importSpecifier(c,r.identifier("readCmsPreviewCandidate"))),f.length&&e.program.body.unshift(r.importDeclaration(f,r.stringLiteral(D(t,s,i)))),E&&e.program.body.unshift(r.importDeclaration([r.importSpecifier(b,r.identifier("CmsPreviewProbe"))],r.stringLiteral(D(d.join(d.dirname(t),"cms-preview-probe.js"),s,i)))),f.length>0||E}function fe(e){let t=e.node,n=t.openingElement.name,s=P(n);if(!s)return null;let i=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"src"})),o=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"dangerouslySetInnerHTML"})),p=s==="img"||/^[A-Z]/.test(s)&&i,u=p?r.isJSXAttribute(i)&&r.isJSXExpressionContainer(i.value)&&r.isExpression(i.value.expression)?[i.value.expression]:[]:r.isJSXAttribute(o)&&r.isJSXExpressionContainer(o.value)&&r.isExpression(o.value.expression)?[o.value.expression]:t.children.flatMap(c=>r.isJSXExpressionContainer(c)&&r.isExpression(c.expression)?[c.expression]:[]);return u.length!==1?null:p&&r.isIdentifier(u[0])&&e.scope.hasBinding(u[0].name)?{base:u[0].name,field:"url"}:me(u[0],e)}function me(e,t){let n=e,s=[];for(;r.isMemberExpression(n)||r.isOptionalMemberExpression(n);){if(!n.computed&&r.isIdentifier(n.property))s.unshift({property:n.property.name});else if(n.computed&&r.isNumericLiteral(n.property)&&Number.isSafeInteger(n.property.value)&&n.property.value>=0)s.unshift({index:n.property});else if(n.computed&&r.isIdentifier(n.property)&&t.scope.hasBinding(n.property.name))s.unshift({index:n.property});else return null;n=n.object}if(!r.isIdentifier(n)||!t.scope.hasBinding(n.name)||(s[0]?.property==="fields"&&s.shift(),!s[0]?.property||s.slice(2).some(o=>o.index)))return null;let i=s[1];return{base:n.name,field:s[0].property,...i?.index?{index:i.index}:{}}}function z(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isImportSpecifier())return null;let s=n.path.node;if(!r.isIdentifier(s.imported)||!/^to[A-Za-z0-9_$]+View$/.test(s.imported.name))return null;let i=n.path.parentPath.node.source.value,o=typeof i=="string"&&i.match(/^@\/lib\/cms\/generated\/([a-z0-9][a-z0-9-]*)$/);return o?{slug:o[1]}:null}function N(e,t){let n=e;for(let s of[...t].reverse()){if(!r.isMemberExpression(n)||n.computed||!r.isIdentifier(n.property,{name:s}))return null;n=n.object}return r.isIdentifier(n)?n.name:null}function ge(e){if(r.isConditionalExpression(e)){let t=N(e.consequent,["data","items"]);return!t||!r.isArrayExpression(e.alternate)||e.alternate.elements.length!==0||!r.isBinaryExpression(e.test,{operator:"==="})||N(e.test.left,["kind"])!==t||!r.isStringLiteral(e.test.right,{value:"ok"})?null:t}return N(e,["data","items"])}function O(e,t,n=new Set){let s=ge(t);if(s)return H(e,s);if(n.size>=20)return null;if(r.isIdentifier(t)){let i=e.scope.getBinding(t.name);return!i?.constant||!i.path.isVariableDeclarator()||!i.path.node.init||n.has(i)?null:(n.add(i),O(e,i.path.node.init,n))}return r.isCallExpression(t)&&r.isMemberExpression(t.callee)&&!t.callee.computed&&r.isIdentifier(t.callee.property)&&["filter","slice","sort","toSorted","reverse","toReversed"].includes(t.callee.property.name)?(n.add(t),O(e,t.callee.object,n)):null}function H(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isVariableDeclarator())return null;let s=n.path.node.init,i=r.isAwaitExpression(s)?s.argument:null;if(!r.isCallExpression(i)||!r.isMemberExpression(i.callee)||i.callee.computed||!r.isIdentifier(i.callee.property)||!r.isMemberExpression(i.callee.object)||i.callee.object.computed||!r.isIdentifier(i.callee.object.property,{name:"collections"})||!r.isIdentifier(i.callee.object.object))return null;let o=e.scope.getBinding(i.callee.object.object.name);return!o?.constant||!o.path.isImportSpecifier()||!r.isIdentifier(o.path.node.imported,{name:"cms"})||o.path.parentPath.node.source.value!=="@/lib/cms"?null:i.callee.property.name==="listStrict"&&r.isStringLiteral(i.arguments[0])?{operation:"list",slug:i.arguments[0].value}:i.callee.property.name==="getByUrlStrict"?{operation:"detail"}:i.callee.property.name==="get"&&r.isStringLiteral(i.arguments[0])?{operation:"detail",slug:i.arguments[0].value}:null}function be(e){return!e.findParent(t=>t.isJSXElement())}function Ee(e){if(typeof e!="string")throw new TypeError("site edit instrumentation source must be a string");return/(?:^|[=(:,?;\[{>&|\n\r]|return\s+)\s*<(?:[A-Za-z][\w.:-]*|>)(?:\s|>|\/)/m.test(e)}function Se(e,t,n){return`${e}::${t}::${n}`}function he(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),s=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(s&&n.startsWith(`${s}/`))return n.slice(s.length+1);for(let[o,p]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let u=n.indexOf(o);if(u>=0)return n.slice(u+p)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function xe(e){return r.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function P(e){return r.isJSXIdentifier(e)?e.name:r.isJSXMemberExpression(e)?Y(e):null}function ye(e,t){let n=new Set;for(let s of e.program.body)if(!(!r.isImportDeclaration(s)||!Ie(s.source.value,t)))for(let i of s.specifiers)n.add(i.local.name);return n}function ve(e,t){let n=e.split(".")[0]??e;return t.has(n)}function X(e){if(!e)return!1;let t=$(e);return t===J||t.startsWith(`${J}/`)||t.includes(`/${J}/`)||t.endsWith(`/${J}`)}function Ie(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?X(e.slice(2)):e.startsWith("./")||e.startsWith("../")?X($(`${Ce(t)}/${e}`)):X(e):!1}function $(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),s=[];for(let i of n.split("/"))if(!(!i||i===".")){if(i===".."){s.pop();continue}s.push(i)}return s.join("/")}function Ce(e){let t=$(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function Pe(e){let t=P(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!se.has(t)}function B(e,t){return e.attributes.some(n=>r.isJSXAttribute(n)&&r.isJSXIdentifier(n.name,{name:t}))}function we(e,t,n){G(e,r.jsxAttribute(r.jsxIdentifier(t),r.stringLiteral(n)))}function q(e,t){B(e,t)||G(e,r.jsxAttribute(r.jsxIdentifier(t),null))}function G(e,t){let n=e.attributes.findIndex(s=>r.isJSXSpreadAttribute(s));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function Y(e){return`${r.isJSXIdentifier(e.object)?e.object.name:Y(e.object)}.${e.property.name}`}function Ae(e){let t=e;for(;t;){if(t.isFunctionDeclaration()||t.isClassDeclaration())return t.node.id?.name??null;if(t.isVariableDeclarator()&&r.isIdentifier(t.node.id)){let n=t.get("init");if(!Array.isArray(n)&&(n.isArrowFunctionExpression()||n.isFunctionExpression()))return t.node.id.name}t=t.parentPath}return null}function Je(e){return e.some(t=>r.isJSXElement(t)||r.isJSXFragment(t))}var V=new WeakMap,j=new WeakMap,_=new WeakMap;function Ne(e){let t=V.get(e.node);if(t!==void 0)return t;let n=[],s=e;for(;s;){if(s.isJSXElement()){let o=Xe(s);o&&n.unshift(o)}s=s.parentPath}let i=n.join("/");return V.set(e.node,i),i}function Xe(e){let t=P(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${K(e,t)}`:`${t}#${K(e,t)}`}function K(e,t){let n=ee(e)??e.getFunctionParent();if(!n)return 0;let s=_.get(n.node)?.get(t)?.get(e.node);if(s!==void 0)return s;let i=_.get(n.node);i||(i=new Map,_.set(n.node,i));let o=i.get(t);o||(o=new WeakMap,i.set(t,o));let p=0,u=n.isJSXElement()||n.isJSXFragment()?M(n):je(n);for(let c of u)if(P(c.node.openingElement.name)===t){if(o.set(c.node,p),c.node===e.node)return p;p+=1}return o.get(e.node)??0}function je(e){let t=j.get(e.node);if(t)return t;let n=[];return e.traverse({JSXElement(s){s.getFunctionParent()?.node===e.node&&!ee(s)&&n.push(s)}}),j.set(e.node,n),n}function ee(e){let t=e.parentPath,n=null;for(;t;){if(t.isJSXFragment()){n=t,t=t.parentPath;continue}if(t.isJSXElement())return t;t=t.parentPath}return n}function M(e){let t=j.get(e.node);if(t)return t;let n=[],s=e.get("children");for(let i of s)if(!Array.isArray(i)){if(i.isJSXElement()){n.push(i);continue}if(i.isJSXFragment()){n.push(...M(i));continue}i.isJSXExpressionContainer()&&n.push(...g(i.get("expression")))}return j.set(e.node,n),n}function g(e){return e.isJSXElement()?[e]:e.isJSXFragment()?M(e):e.isParenthesizedExpression()?g(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?g(e.get("right")):e.isConditionalExpression()?[...g(e.get("consequent")),...g(e.get("alternate"))]:e.isCallExpression()&&Te(e.node)?Me(e.get("arguments")[0]):[]}function Me(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return M(t);if(t.isParenthesizedExpression())return g(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let s of t.get("body")){if(s.isVariableDeclaration())for(let o of s.get("declarations")){let p=o.get("init");(p.isJSXElement()||p.isJSXFragment())&&n.push(...g(p))}if(!s.isReturnStatement())continue;let i=s.get("argument");return i.node&&n.push(...g(i)),n}return n}function Te(e){return r.isMemberExpression(e.callee)&&r.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}U.exports=le;U.exports.instrumentSiteEditRuntimeAttributes=Z});module.exports=te();
1
+ "use strict";var ie=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var re=ie((ke,B)=>{"use strict";var R=require("@babel/generator"),se=require("@babel/parser"),k=require("@babel/traverse"),r=require("@babel/types"),W=require("node:fs"),d=require("node:path"),oe=typeof R=="function"?R:R.default,_=typeof k=="function"?k:k.default,H={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},ae=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]),ce="suppressHydrationWarning",le=new Set(["SiteEditBootstrap"]),D="data-vcp-source-location",ue="data-vcp-ui-component",J="components/ui";function pe(e,t){this.cacheable?.();let n=this.async();try{if(!fe(this.resourcePath)){n(null,e,t);return}let s=this.getOptions?.()??{},i=G({source:e,file:this.resourcePath,projectRoot:s.projectRoot,sourceLocations:s.sourceLocations===!0,cmsPreviewModulePath:de(s.projectRoot)});n(null,i.code,i.code===e?t:null)}catch(s){n(s)}}function de(e){try{let t=require.resolve("@vcp-dev/site-edit-bridge/auto-bootstrap",{paths:[e||process.cwd()]});for(let n of[d.dirname(t),d.resolve(d.dirname(t),"../dist")]){let s=d.join(n,"cms-preview-record.js");if(W.existsSync(s)&&W.existsSync(d.join(n,"cms-preview-probe.js")))return s}return}catch{return}}function fe(e){return typeof e=="string"&&/\.(jsx|tsx)$/.test(e)&&!e.includes("/node_modules/")&&!e.endsWith(".d.ts")}function G(e){let t=ye(e.file,e.projectRoot);if(!he(e.source)||X(t))return{code:e.source,elements:[]};let n=e.attributes??H,s=se.parse(e.source,{sourceType:"module",plugins:["jsx","typescript"]}),i=[],o=ve(s,t);_(s,{JSXElement(u){let c=u.node.openingElement,S=c.name;if(!Ae(S)||$(c,n.key)&&!e.sourceLocations)return;let b=Je(u)??"default",x=Xe(u),g=xe(t,b,x),y=w(S)??"unknown",m=Ie(S)?"jsx":"component-call";if(m==="component-call"&&!Ne(u.node.children)&&le.has(y))return;let l=m==="component-call"&&Ce(y,o);if(e.sourceLocations&&(c.attributes=c.attributes.filter(a=>!(r.isJSXAttribute(a)&&r.isJSXIdentifier(a.name)&&(a.name.name===n.key||a.name.name===D))),c.loc)){let{start:a,end:f}=c.loc;V(c,D,encodeURIComponent(JSON.stringify({key:g,sourceFile:t,componentName:b,structuralPath:x,openingElementRange:{startLine:a.line,startColumn:a.column,endLine:f.line,endColumn:f.column}})))}V(c,n.key,g),l&&K(c,ue),be(u)&&K(c,ce),i.push({key:g,tag:y,component_name:b,source_file:t,source_kind:m})}});let p=e.cmsPreviewModulePath?me(s,e.cmsPreviewModulePath,t,e.file,e.projectRoot):!1;return i.length===0&&!p?{code:e.source,elements:i}:{code:oe(s,{jsescOption:{minimal:!0}}).code,elements:i}}function z(e,t,n){if(!d.isAbsolute(e))return e;let s=d.isAbsolute(t)?t:d.resolve(n||process.cwd(),t),i=d.relative(d.dirname(s),e).split(d.sep).join("/");return i.startsWith(".")?i:`./${i}`}function me(e,t,n,s,i){let o;if(_(e,{Program(l){o=l,l.stop()}}),!o)return!1;let p=o.scope.generateUidIdentifier("vcpAttachCmsPreviewRecord"),u=o.scope.generateUidIdentifier("vcpStripCmsPreviewMetadata"),c=o.scope.generateUidIdentifier("vcpReadCmsPreviewCandidate"),S=o.scope.generateUidIdentifier("VcpCmsPreviewProbe"),b=!1,x=!1,g=!1,y=/(?:^|\/)(?:[^/]+-)?(?:list|detail)-view\.[jt]sx$/.test(n)||e.program.body.some(l=>r.isImportDeclaration(l)&&(l.source.value==="@/lib/cms"||/^@\/lib\/cms\/generated\//.test(l.source.value)));_(e,{CallExpression(l){let a=l.node;if(r.isMemberExpression(a.callee)&&!a.callee.computed&&r.isIdentifier(a.callee.property,{name:"map"})&&a.arguments.length===1&&r.isIdentifier(a.arguments[0])){let C=q(l,a.arguments[0].name),P=F(l,a.callee.object);if(C&&P?.operation==="list"&&P.slug===C.slug){let M=l.scope.generateUidIdentifier("vcpCmsRecord");a.arguments[0]=r.arrowFunctionExpression([M],r.callExpression(p,[r.callExpression(r.cloneNode(a.arguments[0]),[r.cloneNode(M)]),r.cloneNode(M),r.stringLiteral(C.slug),r.stringLiteral("list")])),b=!0,l.skip()}return}if(!r.isIdentifier(a.callee)||a.arguments.length!==1)return;let f=q(l,a.callee.name),I=r.isIdentifier(a.arguments[0]),v=I?a.arguments[0].name:N(a.arguments[0],["data"]),h=v&&Y(l,v);if(!f||h?.operation!=="detail"||(I?h.slug!==f.slug:h.slug!==void 0))return;let L=r.cloneNode(a,!0),A=r.cloneNode(a.arguments[0],!0);l.replaceWith(r.callExpression(p,[L,A,r.stringLiteral(f.slug),r.stringLiteral("detail")])),b=!0,l.skip()},JSXSpreadAttribute(l){l.node.argument=r.callExpression(u,[l.node.argument]),x=!0},JSXElement:{exit(l){if(!y)return;let a=l.node.openingElement;if(!$(a,H.key))return;let f=ge(l);if(!f)return;let I=a.attributes.findIndex(P=>r.isJSXAttribute(P)&&r.isJSXIdentifier(P.name,{name:"key"})),v=I<0?null:a.attributes.splice(I,1)[0],h=[r.identifier(f.base),r.stringLiteral(f.field)];f.index&&h.push(r.cloneNode(f.index,!0));let L=[...v?[v]:[],r.jsxAttribute(r.jsxIdentifier("candidate"),r.jsxExpressionContainer(r.callExpression(c,h)))],A=r.jsxIdentifier(S.name),C=r.jsxElement(r.jsxOpeningElement(r.cloneNode(A),L,!1),r.jsxClosingElement(r.cloneNode(A)),[l.node]);l.replaceWith(C),g=!0,l.skip()}}});let m=[];return b&&m.push(r.importSpecifier(p,r.identifier("attachCmsPreviewRecord"))),x&&m.push(r.importSpecifier(u,r.identifier("stripCmsPreviewMetadata"))),g&&m.push(r.importSpecifier(c,r.identifier("readCmsPreviewCandidate"))),m.length&&e.program.body.unshift(r.importDeclaration(m,r.stringLiteral(z(t,s,i)))),g&&e.program.body.unshift(r.importDeclaration([r.importSpecifier(S,r.identifier("CmsPreviewProbe"))],r.stringLiteral(z(d.join(d.dirname(t),"cms-preview-probe.js"),s,i)))),m.length>0||g}function ge(e){let t=e.node,n=t.openingElement.name,s=w(n);if(!s)return null;let i=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"src"})),o=t.openingElement.attributes.find(c=>r.isJSXAttribute(c)&&r.isJSXIdentifier(c.name,{name:"dangerouslySetInnerHTML"})),p=s==="img"||/^[A-Z]/.test(s)&&i,u=p?r.isJSXAttribute(i)&&r.isJSXExpressionContainer(i.value)&&r.isExpression(i.value.expression)?[i.value.expression]:[]:r.isJSXAttribute(o)&&r.isJSXExpressionContainer(o.value)&&r.isExpression(o.value.expression)?[o.value.expression]:t.children.flatMap(c=>r.isJSXExpressionContainer(c)&&r.isExpression(c.expression)?[c.expression]:[]);return u.length!==1?null:p&&r.isIdentifier(u[0])&&e.scope.hasBinding(u[0].name)?{base:u[0].name,field:"url"}:Ee(u[0],e)}function Ee(e,t){let n=e,s=[];for(;r.isMemberExpression(n)||r.isOptionalMemberExpression(n);){if(!n.computed&&r.isIdentifier(n.property))s.unshift({property:n.property.name});else if(n.computed&&r.isNumericLiteral(n.property)&&Number.isSafeInteger(n.property.value)&&n.property.value>=0)s.unshift({index:n.property});else if(n.computed&&r.isIdentifier(n.property)&&t.scope.hasBinding(n.property.name))s.unshift({index:n.property});else return null;n=n.object}if(!r.isIdentifier(n)||!t.scope.hasBinding(n.name)||(s[0]?.property==="fields"&&s.shift(),!s[0]?.property||s.slice(2).some(o=>o.index)))return null;let i=s[1];return{base:n.name,field:s[0].property,...i?.index?{index:i.index}:{}}}function q(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isImportSpecifier())return null;let s=n.path.node;if(!r.isIdentifier(s.imported)||!/^to[A-Za-z0-9_$]+View$/.test(s.imported.name))return null;let i=n.path.parentPath.node.source.value,o=typeof i=="string"&&i.match(/^@\/lib\/cms\/generated\/([a-z0-9][a-z0-9-]*)$/);return o?{slug:o[1]}:null}function N(e,t){let n=e;for(let s of[...t].reverse()){if(!r.isMemberExpression(n)||n.computed||!r.isIdentifier(n.property,{name:s}))return null;n=n.object}return r.isIdentifier(n)?n.name:null}function Se(e){if(r.isConditionalExpression(e)){let t=N(e.consequent,["data","items"]);return!t||!r.isArrayExpression(e.alternate)||e.alternate.elements.length!==0||!r.isBinaryExpression(e.test,{operator:"==="})||N(e.test.left,["kind"])!==t||!r.isStringLiteral(e.test.right,{value:"ok"})?null:t}return N(e,["data","items"])}function F(e,t,n=new Set){let s=Se(t);if(s)return Y(e,s);if(n.size>=20)return null;if(r.isIdentifier(t)){let i=e.scope.getBinding(t.name);return!i?.constant||!i.path.isVariableDeclarator()||!i.path.node.init||n.has(i)?null:(n.add(i),F(e,i.path.node.init,n))}return r.isCallExpression(t)&&r.isMemberExpression(t.callee)&&!t.callee.computed&&r.isIdentifier(t.callee.property)&&["filter","slice","sort","toSorted","reverse","toReversed"].includes(t.callee.property.name)?(n.add(t),F(e,t.callee.object,n)):null}function Y(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isVariableDeclarator())return null;let s=n.path.node.init,i=r.isAwaitExpression(s)?s.argument:null;if(!r.isCallExpression(i)||!r.isMemberExpression(i.callee)||i.callee.computed||!r.isIdentifier(i.callee.property)||!r.isMemberExpression(i.callee.object)||i.callee.object.computed||!r.isIdentifier(i.callee.object.property,{name:"collections"})||!r.isIdentifier(i.callee.object.object))return null;let o=e.scope.getBinding(i.callee.object.object.name);return!o?.constant||!o.path.isImportSpecifier()||!r.isIdentifier(o.path.node.imported,{name:"cms"})||o.path.parentPath.node.source.value!=="@/lib/cms"?null:i.callee.property.name==="listStrict"&&r.isStringLiteral(i.arguments[0])?{operation:"list",slug:i.arguments[0].value}:i.callee.property.name==="getByUrlStrict"?{operation:"detail"}:i.callee.property.name==="get"&&r.isStringLiteral(i.arguments[0])?{operation:"detail",slug:i.arguments[0].value}:null}function be(e){return!e.findParent(t=>t.isJSXElement())}function he(e){if(typeof e!="string")throw new TypeError("site edit instrumentation source must be a string");return/(?:^|[=(:,?;\[{>&|\n\r]|return\s+)\s*<(?:[A-Za-z][\w.:-]*|>)(?:\s|>|\/)/m.test(e)}function xe(e,t,n){return`${e}::${t}::${n}`}function ye(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),s=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(s&&n.startsWith(`${s}/`))return n.slice(s.length+1);for(let[o,p]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let u=n.indexOf(o);if(u>=0)return n.slice(u+p)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function Ie(e){return r.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function w(e){return r.isJSXIdentifier(e)?e.name:r.isJSXMemberExpression(e)?te(e):null}function ve(e,t){let n=new Set;for(let s of e.program.body)if(!(!r.isImportDeclaration(s)||!Pe(s.source.value,t)))for(let i of s.specifiers)n.add(i.local.name);return n}function Ce(e,t){let n=e.split(".")[0]??e;return t.has(n)}function X(e){if(!e)return!1;let t=U(e);return t===J||t.startsWith(`${J}/`)||t.includes(`/${J}/`)||t.endsWith(`/${J}`)}function Pe(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?X(e.slice(2)):e.startsWith("./")||e.startsWith("../")?X(U(`${we(t)}/${e}`)):X(e):!1}function U(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),s=[];for(let i of n.split("/"))if(!(!i||i===".")){if(i===".."){s.pop();continue}s.push(i)}return s.join("/")}function we(e){let t=U(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function Ae(e){let t=w(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!ae.has(t)}function $(e,t){return e.attributes.some(n=>r.isJSXAttribute(n)&&r.isJSXIdentifier(n.name,{name:t}))}function V(e,t,n){ee(e,r.jsxAttribute(r.jsxIdentifier(t),r.stringLiteral(n)))}function K(e,t){$(e,t)||ee(e,r.jsxAttribute(r.jsxIdentifier(t),null))}function ee(e,t){let n=e.attributes.findIndex(s=>r.isJSXSpreadAttribute(s));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function te(e){return`${r.isJSXIdentifier(e.object)?e.object.name:te(e.object)}.${e.property.name}`}function Je(e){let t=e;for(;t;){if(t.isFunctionDeclaration()||t.isClassDeclaration())return t.node.id?.name??null;if(t.isVariableDeclarator()&&r.isIdentifier(t.node.id)){let n=t.get("init");if(!Array.isArray(n)&&(n.isArrowFunctionExpression()||n.isFunctionExpression()))return t.node.id.name}t=t.parentPath}return null}function Ne(e){return e.some(t=>r.isJSXElement(t)||r.isJSXFragment(t))}var Q=new WeakMap,j=new WeakMap,O=new WeakMap;function Xe(e){let t=Q.get(e.node);if(t!==void 0)return t;let n=[],s=e;for(;s;){if(s.isJSXElement()){let o=je(s);o&&n.unshift(o)}s=s.parentPath}let i=n.join("/");return Q.set(e.node,i),i}function je(e){let t=w(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${Z(e,t)}`:`${t}#${Z(e,t)}`}function Z(e,t){let n=ne(e)??e.getFunctionParent();if(!n)return 0;let s=O.get(n.node)?.get(t)?.get(e.node);if(s!==void 0)return s;let i=O.get(n.node);i||(i=new Map,O.set(n.node,i));let o=i.get(t);o||(o=new WeakMap,i.set(t,o));let p=0,u=n.isJSXElement()||n.isJSXFragment()?T(n):Te(n);for(let c of u)if(w(c.node.openingElement.name)===t){if(o.set(c.node,p),c.node===e.node)return p;p+=1}return o.get(e.node)??0}function Te(e){let t=j.get(e.node);if(t)return t;let n=[];return e.traverse({JSXElement(s){s.getFunctionParent()?.node===e.node&&!ne(s)&&n.push(s)}}),j.set(e.node,n),n}function ne(e){let t=e.parentPath,n=null;for(;t;){if(t.isJSXFragment()){n=t,t=t.parentPath;continue}if(t.isJSXElement())return t;t=t.parentPath}return n}function T(e){let t=j.get(e.node);if(t)return t;let n=[],s=e.get("children");for(let i of s)if(!Array.isArray(i)){if(i.isJSXElement()){n.push(i);continue}if(i.isJSXFragment()){n.push(...T(i));continue}i.isJSXExpressionContainer()&&n.push(...E(i.get("expression")))}return j.set(e.node,n),n}function E(e){return e.isJSXElement()?[e]:e.isJSXFragment()?T(e):e.isParenthesizedExpression()?E(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?E(e.get("right")):e.isConditionalExpression()?[...E(e.get("consequent")),...E(e.get("alternate"))]:e.isCallExpression()&&Me(e.node)?Le(e.get("arguments")[0]):[]}function Le(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return T(t);if(t.isParenthesizedExpression())return E(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let s of t.get("body")){if(s.isVariableDeclaration())for(let o of s.get("declarations")){let p=o.get("init");(p.isJSXElement()||p.isJSXFragment())&&n.push(...E(p))}if(!s.isReturnStatement())continue;let i=s.get("argument");return i.node&&n.push(...E(i)),n}return n}function Me(e){return r.isMemberExpression(e.callee)&&r.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}B.exports=pe;B.exports.instrumentSiteEditRuntimeAttributes=G});module.exports=re();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcp-dev/site-edit-engine",
3
- "version": "0.11.41",
3
+ "version": "0.11.42",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -18,27 +18,22 @@
18
18
  "types": "./dist/index.d.ts",
19
19
  "exports": {
20
20
  ".": {
21
- "development": "./src/index.ts",
22
21
  "types": "./dist/index.d.ts",
23
22
  "default": "./dist/index.js"
24
23
  },
25
24
  "./next-app-router": {
26
- "development": "./src/next-app-router.ts",
27
25
  "types": "./dist/next-app-router.d.ts",
28
26
  "default": "./dist/next-app-router.js"
29
27
  },
30
28
  "./source-watcher": {
31
- "development": "./src/source-watcher.ts",
32
29
  "types": "./dist/source-watcher.d.ts",
33
30
  "default": "./dist/source-watcher.js"
34
31
  },
35
32
  "./site-edit-instrumentation-loader": {
36
- "development": "./src/site-edit-instrumentation-loader.cjs",
37
33
  "types": "./dist/site-edit-instrumentation-loader.d.cts",
38
34
  "default": "./dist/site-edit-instrumentation-loader.cjs"
39
35
  },
40
36
  "./webpack-loader": {
41
- "development": "./src/webpack-loader.cjs",
42
37
  "types": "./dist/webpack-loader.d.cts",
43
38
  "default": "./dist/webpack-loader.cjs"
44
39
  }
@@ -62,9 +57,9 @@
62
57
  "@babel/types": "^7.29.0",
63
58
  "@csstools/css-tokenizer": "3.0.4",
64
59
  "@jridgewell/sourcemap-codec": "1.5.5",
65
- "@vcp-dev/contracts": "0.11.41",
60
+ "@vcp-dev/platform-shared": "0.11.42",
66
61
  "postcss": "8.5.23",
67
- "rollup": "4.60.4",
62
+ "rollup": "npm:@rollup/wasm-node@4.60.4",
68
63
  "typescript": "5.9.3",
69
64
  "yaml": "^2.9.0"
70
65
  },