@vcp-dev/site-edit-engine 0.11.43 → 0.11.45

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 +1 @@
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;
1
+ "use strict";var F=require("@babel/generator"),le=require("@babel/parser"),B=require("@babel/traverse"),r=require("@babel/types"),K=require("node:fs"),m=require("node:path"),pe=typeof F=="function"?F:F.default,D=typeof B=="function"?B:B.default,ne={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},de=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]);var fe="suppressHydrationWarning",me=new Set(["SiteEditBootstrap"]),Q="data-vcp-source-location",ge="data-vcp-ui-component",j="components/ui";function Ee(e,t){this.cacheable?.();let n=this.async();try{if(!be(this.resourcePath)){n(null,e,t);return}let i=this.getOptions?.()??{},s=re({source:e,file:this.resourcePath,projectRoot:i.projectRoot,sourceLocations:i.sourceLocations===!0,cmsPreviewModulePath:Se(i.projectRoot)});n(null,s.code,s.code===e?t:null)}catch(i){n(i)}}function Se(e){try{let t=require.resolve("@vcp-dev/site-edit-bridge/auto-bootstrap",{paths:[e||process.cwd()]});for(let n of[m.dirname(t),m.resolve(m.dirname(t),"../dist")]){let i=m.join(n,"cms-preview-record.js");if(K.existsSync(i)&&K.existsSync(m.join(n,"cms-preview-probe.js")))return i}return}catch{return}}function be(e){return typeof e=="string"&&/\.[jt]sx?$/.test(e)&&!e.replace(/\\/g,"/").includes("/node_modules/")&&!e.endsWith(".d.ts")}function re(e){let t=we(e.file,e.projectRoot),n=Ce(e.source)&&!/\.ts$/.test(t),i=e.cmsPreviewModulePath&&e.source.includes("@/lib/cms");if(!n&&!i||T(t))return{code:e.source,elements:[]};let s=e.attributes??ne,o=le.parse(e.source,{sourceType:"module",plugins:["typescript",.../\.ts$/.test(t)?[]:["jsx"]]}),u=[],d=Ae(o,t);D(o,{JSXElement(E){let f=E.node.openingElement,y=f.name;if(!Le(y)||V(f,s.key)&&!e.sourceLocations)return;let h=je(E)??"default",P=Te(E),x=Pe(t,h,P),v=N(y)??"unknown",S=oe(y)?"jsx":"component-call";if(S==="component-call"&&!Re(E.node.children)&&me.has(v))return;let O=S==="component-call"&&Je(v,d);if(e.sourceLocations&&(f.attributes=f.attributes.filter(p=>!(r.isJSXAttribute(p)&&r.isJSXIdentifier(p.name)&&(p.name.name===s.key||p.name.name===Q))),f.loc)){let{start:p,end:a}=f.loc;G(f,Q,encodeURIComponent(JSON.stringify({key:x,sourceFile:t,componentName:h,structuralPath:P,openingElementRange:{startLine:p.line,startColumn:p.column,endLine:a.line,endColumn:a.column}})))}G(f,s.key,x),O&&Y(f,ge),Ie(E)&&Y(f,fe),u.push({key:x,tag:v,component_name:h,source_file:t,source_kind:S})}});let l=e.cmsPreviewModulePath?he(o,e.cmsPreviewModulePath,t,e.file,e.projectRoot):!1;return u.length===0&&!l?{code:e.source,elements:u}:{code:pe(o,{jsescOption:{minimal:!0}}).code,elements:u}}function Z(e,t,n){if(!m.isAbsolute(e))return e;let i=m.isAbsolute(t)?t:m.resolve(n||process.cwd(),t),s=m.relative(m.dirname(i),e).split(m.sep).join("/");return s.startsWith(".")?s:`./${s}`}function he(e,t,n,i,s){let o;if(D(e,{Program(a){o=a,a.stop()}}),!o)return!1;let u=o.scope.generateUidIdentifier("vcpAttachCmsPreviewRecord"),d=o.scope.generateUidIdentifier("vcpAttachCmsPreviewListResult"),l=o.scope.generateUidIdentifier("vcpAttachCmsPreviewListView"),E=o.scope.generateUidIdentifier("vcpStripCmsPreviewMetadata"),f=o.scope.generateUidIdentifier("vcpReadCmsPreviewCandidate"),y=o.scope.generateUidIdentifier("VcpCmsPreviewProbe"),h=!1,P=!1,x=[],v=!1,S=!1,O=/(?:^|\/)(?:[^/]+-)?(?: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)));D(e,{CallExpression(a){let c=a.node,g=se(a,c);if(g?.operation==="list"&&x.push({path:a,list:g}),r.isMemberExpression(c.callee)&&!c.callee.computed&&r.isIdentifier(c.callee.property,{name:"map"})&&c.arguments.length===1&&r.isIdentifier(c.arguments[0])){let C=H(a,c.arguments[0].name),L=z(a,c.callee.object);if(C&&(!L||L.operation==="list"&&L.slug===C.slug)){let _=L?.operation==="list",$=a.scope.generateUidIdentifier("vcpCmsRecord");c.arguments[0]=r.arrowFunctionExpression([$],r.callExpression(_?u:l,[r.callExpression(r.cloneNode(c.arguments[0]),[r.cloneNode($)]),r.cloneNode($),r.stringLiteral(C.slug),..._?[r.stringLiteral("list")]:[]])),_?h=!0:P=!0,a.skip()}return}if(!r.isIdentifier(c.callee)||c.arguments.length!==1)return;let I=H(a,c.callee.name),w=r.isIdentifier(c.arguments[0]),A=w?c.arguments[0].name:R(c.arguments[0],["data"]),J=A&&ie(a,A);if(!I||J?.operation!=="detail"||(w?J.slug!==I.slug:J.slug!==void 0))return;let X=r.cloneNode(c,!0),U=r.cloneNode(c.arguments[0],!0);a.replaceWith(r.callExpression(u,[X,U,r.stringLiteral(I.slug),r.stringLiteral("detail")])),h=!0,a.skip()},JSXSpreadAttribute(a){a.node.argument=r.callExpression(E,[a.node.argument]),v=!0},JSXElement:{exit(a){let c=a.node.openingElement;if(!V(c,ne.key))return;let g=xe(a);if(!g||!O&&(!oe(c.name)||a.scope.getBinding(g.base)?.kind!=="param"))return;let I=c.attributes.findIndex(C=>r.isJSXAttribute(C)&&r.isJSXIdentifier(C.name,{name:"key"})),w=I<0?null:c.attributes.splice(I,1)[0],A=[r.identifier(g.base),r.stringLiteral(g.field)];g.index&&A.push(r.cloneNode(g.index,!0));let J=[...w?[w]:[],r.jsxAttribute(r.jsxIdentifier("candidate"),r.jsxExpressionContainer(r.callExpression(f,A)))],X=r.jsxIdentifier(y.name),U=r.jsxElement(r.jsxOpeningElement(r.cloneNode(X),J,!1),r.jsxClosingElement(r.cloneNode(X)),[a.node]);a.replaceWith(U),S=!0,a.skip()}}});let p=[];if(x.length){p.push(r.importSpecifier(d,r.identifier("attachCmsPreviewListResult")));for(let{path:a,list:c}of x){let g=a.scope.generateUidIdentifier("vcpCmsList");a.replaceWith(r.callExpression(r.memberExpression(r.cloneNode(a.node,!0),r.identifier("then")),[r.arrowFunctionExpression([g],r.callExpression(d,[r.cloneNode(g),r.stringLiteral(c.slug),r.booleanLiteral(c.strict)]))]))}}return h&&p.push(r.importSpecifier(u,r.identifier("attachCmsPreviewRecord"))),P&&p.push(r.importSpecifier(l,r.identifier("attachCmsPreviewListView"))),v&&p.push(r.importSpecifier(E,r.identifier("stripCmsPreviewMetadata"))),S&&p.push(r.importSpecifier(f,r.identifier("readCmsPreviewCandidate"))),p.length&&e.program.body.unshift(r.importDeclaration(p,r.stringLiteral(Z(t,i,s)))),S&&e.program.body.unshift(r.importDeclaration([r.importSpecifier(y,r.identifier("CmsPreviewProbe"))],r.stringLiteral(Z(m.join(m.dirname(t),"cms-preview-probe.js"),i,s)))),p.length>0||S}function xe(e){let t=e.node,n=t.openingElement.name,i=N(n);if(!i)return null;let s=t.openingElement.attributes.find(l=>r.isJSXAttribute(l)&&r.isJSXIdentifier(l.name,{name:"src"})),o=t.openingElement.attributes.find(l=>r.isJSXAttribute(l)&&r.isJSXIdentifier(l.name,{name:"dangerouslySetInnerHTML"})),u=i==="img"||/^[A-Z]/.test(i)&&s,d=u?r.isJSXAttribute(s)&&r.isJSXExpressionContainer(s.value)&&r.isExpression(s.value.expression)?[s.value.expression]:[]:r.isJSXAttribute(o)&&r.isJSXExpressionContainer(o.value)&&r.isExpression(o.value.expression)?[o.value.expression]:t.children.flatMap(l=>r.isJSXExpressionContainer(l)&&r.isExpression(l.expression)?[l.expression]:[]);return d.length!==1?null:u&&r.isIdentifier(d[0])&&e.scope.hasBinding(d[0].name)?{base:d[0].name,field:"url"}:ye(d[0],e)}function ye(e,t){let n=e,i=[];for(;r.isMemberExpression(n)||r.isOptionalMemberExpression(n);){if(!n.computed&&r.isIdentifier(n.property))i.unshift({property:n.property.name});else if(n.computed&&r.isNumericLiteral(n.property)&&Number.isSafeInteger(n.property.value)&&n.property.value>=0)i.unshift({index:n.property});else if(n.computed&&r.isIdentifier(n.property)&&t.scope.hasBinding(n.property.name))i.unshift({index:n.property});else return null;n=n.object}if(!r.isIdentifier(n)||!t.scope.hasBinding(n.name)||(i[0]?.property==="fields"&&i.shift(),!i[0]?.property||i.slice(2).some(o=>o.index)))return null;let s=i[1];return{base:n.name,field:i[0].property,...s?.index?{index:s.index}:{}}}function H(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isImportSpecifier())return null;let i=n.path.node;if(!r.isIdentifier(i.imported)||!/^to[A-Za-z0-9_$]+View$/.test(i.imported.name))return null;let s=n.path.parentPath.node.source.value,o=typeof s=="string"&&s.match(/^@\/lib\/cms\/generated\/([a-z0-9][a-z0-9-]*)$/);return o?{slug:o[1]}:null}function R(e,t){let n=e;for(let i of[...t].reverse()){if(!r.isMemberExpression(n)||n.computed||!r.isIdentifier(n.property,{name:i}))return null;n=n.object}return r.isIdentifier(n)?n.name:null}function ve(e){if(r.isConditionalExpression(e)){let t=R(e.consequent,["data","items"]);return!t||!r.isArrayExpression(e.alternate)||e.alternate.elements.length!==0||!r.isBinaryExpression(e.test,{operator:"==="})||R(e.test.left,["kind"])!==t||!r.isStringLiteral(e.test.right,{value:"ok"})?null:t}return R(e,["data","items"])}function z(e,t,n=new Set){let i=ve(t);if(i)return ie(e,i);if(n.size>=20)return null;if(r.isIdentifier(t)){let s=e.scope.getBinding(t.name);return!s?.constant||!s.path.isVariableDeclarator()||!s.path.node.init||n.has(s)?null:(n.add(s),z(e,s.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),z(e,t.callee.object,n)):null}function ie(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isVariableDeclarator())return null;let i=n.path.node.init,s=r.isAwaitExpression(i)?i.argument:null;return se(e,s)}function se(e,t){if(!r.isCallExpression(t)||!r.isMemberExpression(t.callee)||t.callee.computed||!r.isIdentifier(t.callee.property)||!r.isMemberExpression(t.callee.object)||t.callee.object.computed||!r.isIdentifier(t.callee.object.property,{name:"collections"})||!r.isIdentifier(t.callee.object.object))return null;let n=e.scope.getBinding(t.callee.object.object.name);return!n?.constant||!n.path.isImportSpecifier()||!r.isIdentifier(n.path.node.imported,{name:"cms"})||n.path.parentPath.node.source.value!=="@/lib/cms"?null:["listStrict","list"].includes(t.callee.property.name)&&r.isStringLiteral(t.arguments[0])?{operation:"list",slug:t.arguments[0].value,strict:t.callee.property.name==="listStrict"}:t.callee.property.name==="getByUrlStrict"?{operation:"detail"}:t.callee.property.name==="get"&&r.isStringLiteral(t.arguments[0])?{operation:"detail",slug:t.arguments[0].value}:null}function Ie(e){return!e.findParent(t=>t.isJSXElement())}function Ce(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 Pe(e,t,n){return`${e}::${t}::${n}`}function we(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),i=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(i&&n.startsWith(`${i}/`))return n.slice(i.length+1);for(let[o,u]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let d=n.indexOf(o);if(d>=0)return n.slice(d+u)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function oe(e){return r.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function N(e){return r.isJSXIdentifier(e)?e.name:r.isJSXMemberExpression(e)?ce(e):null}function Ae(e,t){let n=new Set;for(let i of e.program.body)if(!(!r.isImportDeclaration(i)||!Ne(i.source.value,t)))for(let s of i.specifiers)n.add(s.local.name);return n}function Je(e,t){let n=e.split(".")[0]??e;return t.has(n)}function T(e){if(!e)return!1;let t=q(e);return t===j||t.startsWith(`${j}/`)||t.includes(`/${j}/`)||t.endsWith(`/${j}`)}function Ne(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?T(e.slice(2)):e.startsWith("./")||e.startsWith("../")?T(q(`${Xe(t)}/${e}`)):T(e):!1}function q(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),i=[];for(let s of n.split("/"))if(!(!s||s===".")){if(s===".."){i.pop();continue}i.push(s)}return i.join("/")}function Xe(e){let t=q(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function Le(e){let t=N(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!de.has(t)}function V(e,t){return e.attributes.some(n=>r.isJSXAttribute(n)&&r.isJSXIdentifier(n.name,{name:t}))}function G(e,t,n){ae(e,r.jsxAttribute(r.jsxIdentifier(t),r.stringLiteral(n)))}function Y(e,t){V(e,t)||ae(e,r.jsxAttribute(r.jsxIdentifier(t),null))}function ae(e,t){let n=e.attributes.findIndex(i=>r.isJSXSpreadAttribute(i));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function ce(e){return`${r.isJSXIdentifier(e.object)?e.object.name:ce(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 Re(e){return e.some(t=>r.isJSXElement(t)||r.isJSXFragment(t))}var ee=new WeakMap,M=new WeakMap,W=new WeakMap;function Te(e){let t=ee.get(e.node);if(t!==void 0)return t;let n=[],i=e;for(;i;){if(i.isJSXElement()){let o=Me(i);o&&n.unshift(o)}i=i.parentPath}let s=n.join("/");return ee.set(e.node,s),s}function Me(e){let t=N(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${te(e,t)}`:`${t}#${te(e,t)}`}function te(e,t){let n=ue(e)??e.getFunctionParent();if(!n)return 0;let i=W.get(n.node)?.get(t)?.get(e.node);if(i!==void 0)return i;let s=W.get(n.node);s||(s=new Map,W.set(n.node,s));let o=s.get(t);o||(o=new WeakMap,s.set(t,o));let u=0,d=n.isJSXElement()||n.isJSXFragment()?k(n):ke(n);for(let l of d)if(N(l.node.openingElement.name)===t){if(o.set(l.node,u),l.node===e.node)return u;u+=1}return o.get(e.node)??0}function ke(e){let t=M.get(e.node);if(t)return t;let n=[];return e.traverse({JSXElement(i){i.getFunctionParent()?.node===e.node&&!ue(i)&&n.push(i)}}),M.set(e.node,n),n}function ue(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 k(e){let t=M.get(e.node);if(t)return t;let n=[],i=e.get("children");for(let s of i)if(!Array.isArray(s)){if(s.isJSXElement()){n.push(s);continue}if(s.isJSXFragment()){n.push(...k(s));continue}s.isJSXExpressionContainer()&&n.push(...b(s.get("expression")))}return M.set(e.node,n),n}function b(e){return e.isJSXElement()?[e]:e.isJSXFragment()?k(e):e.isParenthesizedExpression()?b(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?b(e.get("right")):e.isConditionalExpression()?[...b(e.get("consequent")),...b(e.get("alternate"))]:e.isCallExpression()&&Ue(e.node)?Oe(e.get("arguments")[0]):[]}function Oe(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return k(t);if(t.isParenthesizedExpression())return b(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let i of t.get("body")){if(i.isVariableDeclaration())for(let o of i.get("declarations")){let u=o.get("init");(u.isJSXElement()||u.isJSXFragment())&&n.push(...b(u))}if(!i.isReturnStatement())continue;let s=i.get("argument");return s.node&&n.push(...b(s)),n}return n}function Ue(e){return r.isMemberExpression(e.callee)&&r.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}module.exports=Ee;module.exports.instrumentSiteEditRuntimeAttributes=re;
@@ -1 +1 @@
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();
1
+ "use strict";var de=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var pe=de((We,K)=>{"use strict";var F=require("@babel/generator"),fe=require("@babel/parser"),B=require("@babel/traverse"),r=require("@babel/types"),Q=require("node:fs"),m=require("node:path"),me=typeof F=="function"?F:F.default,D=typeof B=="function"?B:B.default,re={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},ge=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]),Ee="suppressHydrationWarning",Se=new Set(["SiteEditBootstrap"]),Z="data-vcp-source-location",be="data-vcp-ui-component",j="components/ui";function he(e,t){this.cacheable?.();let n=this.async();try{if(!ye(this.resourcePath)){n(null,e,t);return}let i=this.getOptions?.()??{},s=ie({source:e,file:this.resourcePath,projectRoot:i.projectRoot,sourceLocations:i.sourceLocations===!0,cmsPreviewModulePath:xe(i.projectRoot)});n(null,s.code,s.code===e?t:null)}catch(i){n(i)}}function xe(e){try{let t=require.resolve("@vcp-dev/site-edit-bridge/auto-bootstrap",{paths:[e||process.cwd()]});for(let n of[m.dirname(t),m.resolve(m.dirname(t),"../dist")]){let i=m.join(n,"cms-preview-record.js");if(Q.existsSync(i)&&Q.existsSync(m.join(n,"cms-preview-probe.js")))return i}return}catch{return}}function ye(e){return typeof e=="string"&&/\.[jt]sx?$/.test(e)&&!e.replace(/\\/g,"/").includes("/node_modules/")&&!e.endsWith(".d.ts")}function ie(e){let t=Ne(e.file,e.projectRoot),n=Ae(e.source)&&!/\.ts$/.test(t),i=e.cmsPreviewModulePath&&e.source.includes("@/lib/cms");if(!n&&!i||T(t))return{code:e.source,elements:[]};let s=e.attributes??re,o=fe.parse(e.source,{sourceType:"module",plugins:["typescript",.../\.ts$/.test(t)?[]:["jsx"]]}),u=[],d=Xe(o,t);D(o,{JSXElement(E){let f=E.node.openingElement,y=f.name;if(!Te(y)||V(f,s.key)&&!e.sourceLocations)return;let h=Me(E)??"default",P=Oe(E),x=Je(t,h,P),v=N(y)??"unknown",S=ae(y)?"jsx":"component-call";if(S==="component-call"&&!ke(E.node.children)&&Se.has(v))return;let O=S==="component-call"&&Le(v,d);if(e.sourceLocations&&(f.attributes=f.attributes.filter(p=>!(r.isJSXAttribute(p)&&r.isJSXIdentifier(p.name)&&(p.name.name===s.key||p.name.name===Z))),f.loc)){let{start:p,end:a}=f.loc;Y(f,Z,encodeURIComponent(JSON.stringify({key:x,sourceFile:t,componentName:h,structuralPath:P,openingElementRange:{startLine:p.line,startColumn:p.column,endLine:a.line,endColumn:a.column}})))}Y(f,s.key,x),O&&ee(f,be),we(E)&&ee(f,Ee),u.push({key:x,tag:v,component_name:h,source_file:t,source_kind:S})}});let l=e.cmsPreviewModulePath?ve(o,e.cmsPreviewModulePath,t,e.file,e.projectRoot):!1;return u.length===0&&!l?{code:e.source,elements:u}:{code:me(o,{jsescOption:{minimal:!0}}).code,elements:u}}function H(e,t,n){if(!m.isAbsolute(e))return e;let i=m.isAbsolute(t)?t:m.resolve(n||process.cwd(),t),s=m.relative(m.dirname(i),e).split(m.sep).join("/");return s.startsWith(".")?s:`./${s}`}function ve(e,t,n,i,s){let o;if(D(e,{Program(a){o=a,a.stop()}}),!o)return!1;let u=o.scope.generateUidIdentifier("vcpAttachCmsPreviewRecord"),d=o.scope.generateUidIdentifier("vcpAttachCmsPreviewListResult"),l=o.scope.generateUidIdentifier("vcpAttachCmsPreviewListView"),E=o.scope.generateUidIdentifier("vcpStripCmsPreviewMetadata"),f=o.scope.generateUidIdentifier("vcpReadCmsPreviewCandidate"),y=o.scope.generateUidIdentifier("VcpCmsPreviewProbe"),h=!1,P=!1,x=[],v=!1,S=!1,O=/(?:^|\/)(?:[^/]+-)?(?: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)));D(e,{CallExpression(a){let c=a.node,g=oe(a,c);if(g?.operation==="list"&&x.push({path:a,list:g}),r.isMemberExpression(c.callee)&&!c.callee.computed&&r.isIdentifier(c.callee.property,{name:"map"})&&c.arguments.length===1&&r.isIdentifier(c.arguments[0])){let C=G(a,c.arguments[0].name),L=z(a,c.callee.object);if(C&&(!L||L.operation==="list"&&L.slug===C.slug)){let _=L?.operation==="list",$=a.scope.generateUidIdentifier("vcpCmsRecord");c.arguments[0]=r.arrowFunctionExpression([$],r.callExpression(_?u:l,[r.callExpression(r.cloneNode(c.arguments[0]),[r.cloneNode($)]),r.cloneNode($),r.stringLiteral(C.slug),..._?[r.stringLiteral("list")]:[]])),_?h=!0:P=!0,a.skip()}return}if(!r.isIdentifier(c.callee)||c.arguments.length!==1)return;let I=G(a,c.callee.name),w=r.isIdentifier(c.arguments[0]),A=w?c.arguments[0].name:R(c.arguments[0],["data"]),J=A&&se(a,A);if(!I||J?.operation!=="detail"||(w?J.slug!==I.slug:J.slug!==void 0))return;let X=r.cloneNode(c,!0),U=r.cloneNode(c.arguments[0],!0);a.replaceWith(r.callExpression(u,[X,U,r.stringLiteral(I.slug),r.stringLiteral("detail")])),h=!0,a.skip()},JSXSpreadAttribute(a){a.node.argument=r.callExpression(E,[a.node.argument]),v=!0},JSXElement:{exit(a){let c=a.node.openingElement;if(!V(c,re.key))return;let g=Ie(a);if(!g||!O&&(!ae(c.name)||a.scope.getBinding(g.base)?.kind!=="param"))return;let I=c.attributes.findIndex(C=>r.isJSXAttribute(C)&&r.isJSXIdentifier(C.name,{name:"key"})),w=I<0?null:c.attributes.splice(I,1)[0],A=[r.identifier(g.base),r.stringLiteral(g.field)];g.index&&A.push(r.cloneNode(g.index,!0));let J=[...w?[w]:[],r.jsxAttribute(r.jsxIdentifier("candidate"),r.jsxExpressionContainer(r.callExpression(f,A)))],X=r.jsxIdentifier(y.name),U=r.jsxElement(r.jsxOpeningElement(r.cloneNode(X),J,!1),r.jsxClosingElement(r.cloneNode(X)),[a.node]);a.replaceWith(U),S=!0,a.skip()}}});let p=[];if(x.length){p.push(r.importSpecifier(d,r.identifier("attachCmsPreviewListResult")));for(let{path:a,list:c}of x){let g=a.scope.generateUidIdentifier("vcpCmsList");a.replaceWith(r.callExpression(r.memberExpression(r.cloneNode(a.node,!0),r.identifier("then")),[r.arrowFunctionExpression([g],r.callExpression(d,[r.cloneNode(g),r.stringLiteral(c.slug),r.booleanLiteral(c.strict)]))]))}}return h&&p.push(r.importSpecifier(u,r.identifier("attachCmsPreviewRecord"))),P&&p.push(r.importSpecifier(l,r.identifier("attachCmsPreviewListView"))),v&&p.push(r.importSpecifier(E,r.identifier("stripCmsPreviewMetadata"))),S&&p.push(r.importSpecifier(f,r.identifier("readCmsPreviewCandidate"))),p.length&&e.program.body.unshift(r.importDeclaration(p,r.stringLiteral(H(t,i,s)))),S&&e.program.body.unshift(r.importDeclaration([r.importSpecifier(y,r.identifier("CmsPreviewProbe"))],r.stringLiteral(H(m.join(m.dirname(t),"cms-preview-probe.js"),i,s)))),p.length>0||S}function Ie(e){let t=e.node,n=t.openingElement.name,i=N(n);if(!i)return null;let s=t.openingElement.attributes.find(l=>r.isJSXAttribute(l)&&r.isJSXIdentifier(l.name,{name:"src"})),o=t.openingElement.attributes.find(l=>r.isJSXAttribute(l)&&r.isJSXIdentifier(l.name,{name:"dangerouslySetInnerHTML"})),u=i==="img"||/^[A-Z]/.test(i)&&s,d=u?r.isJSXAttribute(s)&&r.isJSXExpressionContainer(s.value)&&r.isExpression(s.value.expression)?[s.value.expression]:[]:r.isJSXAttribute(o)&&r.isJSXExpressionContainer(o.value)&&r.isExpression(o.value.expression)?[o.value.expression]:t.children.flatMap(l=>r.isJSXExpressionContainer(l)&&r.isExpression(l.expression)?[l.expression]:[]);return d.length!==1?null:u&&r.isIdentifier(d[0])&&e.scope.hasBinding(d[0].name)?{base:d[0].name,field:"url"}:Ce(d[0],e)}function Ce(e,t){let n=e,i=[];for(;r.isMemberExpression(n)||r.isOptionalMemberExpression(n);){if(!n.computed&&r.isIdentifier(n.property))i.unshift({property:n.property.name});else if(n.computed&&r.isNumericLiteral(n.property)&&Number.isSafeInteger(n.property.value)&&n.property.value>=0)i.unshift({index:n.property});else if(n.computed&&r.isIdentifier(n.property)&&t.scope.hasBinding(n.property.name))i.unshift({index:n.property});else return null;n=n.object}if(!r.isIdentifier(n)||!t.scope.hasBinding(n.name)||(i[0]?.property==="fields"&&i.shift(),!i[0]?.property||i.slice(2).some(o=>o.index)))return null;let s=i[1];return{base:n.name,field:i[0].property,...s?.index?{index:s.index}:{}}}function G(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isImportSpecifier())return null;let i=n.path.node;if(!r.isIdentifier(i.imported)||!/^to[A-Za-z0-9_$]+View$/.test(i.imported.name))return null;let s=n.path.parentPath.node.source.value,o=typeof s=="string"&&s.match(/^@\/lib\/cms\/generated\/([a-z0-9][a-z0-9-]*)$/);return o?{slug:o[1]}:null}function R(e,t){let n=e;for(let i of[...t].reverse()){if(!r.isMemberExpression(n)||n.computed||!r.isIdentifier(n.property,{name:i}))return null;n=n.object}return r.isIdentifier(n)?n.name:null}function Pe(e){if(r.isConditionalExpression(e)){let t=R(e.consequent,["data","items"]);return!t||!r.isArrayExpression(e.alternate)||e.alternate.elements.length!==0||!r.isBinaryExpression(e.test,{operator:"==="})||R(e.test.left,["kind"])!==t||!r.isStringLiteral(e.test.right,{value:"ok"})?null:t}return R(e,["data","items"])}function z(e,t,n=new Set){let i=Pe(t);if(i)return se(e,i);if(n.size>=20)return null;if(r.isIdentifier(t)){let s=e.scope.getBinding(t.name);return!s?.constant||!s.path.isVariableDeclarator()||!s.path.node.init||n.has(s)?null:(n.add(s),z(e,s.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),z(e,t.callee.object,n)):null}function se(e,t){let n=e.scope.getBinding(t);if(!n?.constant||!n.path.isVariableDeclarator())return null;let i=n.path.node.init,s=r.isAwaitExpression(i)?i.argument:null;return oe(e,s)}function oe(e,t){if(!r.isCallExpression(t)||!r.isMemberExpression(t.callee)||t.callee.computed||!r.isIdentifier(t.callee.property)||!r.isMemberExpression(t.callee.object)||t.callee.object.computed||!r.isIdentifier(t.callee.object.property,{name:"collections"})||!r.isIdentifier(t.callee.object.object))return null;let n=e.scope.getBinding(t.callee.object.object.name);return!n?.constant||!n.path.isImportSpecifier()||!r.isIdentifier(n.path.node.imported,{name:"cms"})||n.path.parentPath.node.source.value!=="@/lib/cms"?null:["listStrict","list"].includes(t.callee.property.name)&&r.isStringLiteral(t.arguments[0])?{operation:"list",slug:t.arguments[0].value,strict:t.callee.property.name==="listStrict"}:t.callee.property.name==="getByUrlStrict"?{operation:"detail"}:t.callee.property.name==="get"&&r.isStringLiteral(t.arguments[0])?{operation:"detail",slug:t.arguments[0].value}:null}function we(e){return!e.findParent(t=>t.isJSXElement())}function Ae(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 Je(e,t,n){return`${e}::${t}::${n}`}function Ne(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),i=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(i&&n.startsWith(`${i}/`))return n.slice(i.length+1);for(let[o,u]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let d=n.indexOf(o);if(d>=0)return n.slice(d+u)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function ae(e){return r.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function N(e){return r.isJSXIdentifier(e)?e.name:r.isJSXMemberExpression(e)?ue(e):null}function Xe(e,t){let n=new Set;for(let i of e.program.body)if(!(!r.isImportDeclaration(i)||!je(i.source.value,t)))for(let s of i.specifiers)n.add(s.local.name);return n}function Le(e,t){let n=e.split(".")[0]??e;return t.has(n)}function T(e){if(!e)return!1;let t=q(e);return t===j||t.startsWith(`${j}/`)||t.includes(`/${j}/`)||t.endsWith(`/${j}`)}function je(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?T(e.slice(2)):e.startsWith("./")||e.startsWith("../")?T(q(`${Re(t)}/${e}`)):T(e):!1}function q(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),i=[];for(let s of n.split("/"))if(!(!s||s===".")){if(s===".."){i.pop();continue}i.push(s)}return i.join("/")}function Re(e){let t=q(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function Te(e){let t=N(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!ge.has(t)}function V(e,t){return e.attributes.some(n=>r.isJSXAttribute(n)&&r.isJSXIdentifier(n.name,{name:t}))}function Y(e,t,n){ce(e,r.jsxAttribute(r.jsxIdentifier(t),r.stringLiteral(n)))}function ee(e,t){V(e,t)||ce(e,r.jsxAttribute(r.jsxIdentifier(t),null))}function ce(e,t){let n=e.attributes.findIndex(i=>r.isJSXSpreadAttribute(i));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function ue(e){return`${r.isJSXIdentifier(e.object)?e.object.name:ue(e.object)}.${e.property.name}`}function Me(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 ke(e){return e.some(t=>r.isJSXElement(t)||r.isJSXFragment(t))}var te=new WeakMap,M=new WeakMap,W=new WeakMap;function Oe(e){let t=te.get(e.node);if(t!==void 0)return t;let n=[],i=e;for(;i;){if(i.isJSXElement()){let o=Ue(i);o&&n.unshift(o)}i=i.parentPath}let s=n.join("/");return te.set(e.node,s),s}function Ue(e){let t=N(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${ne(e,t)}`:`${t}#${ne(e,t)}`}function ne(e,t){let n=le(e)??e.getFunctionParent();if(!n)return 0;let i=W.get(n.node)?.get(t)?.get(e.node);if(i!==void 0)return i;let s=W.get(n.node);s||(s=new Map,W.set(n.node,s));let o=s.get(t);o||(o=new WeakMap,s.set(t,o));let u=0,d=n.isJSXElement()||n.isJSXFragment()?k(n):_e(n);for(let l of d)if(N(l.node.openingElement.name)===t){if(o.set(l.node,u),l.node===e.node)return u;u+=1}return o.get(e.node)??0}function _e(e){let t=M.get(e.node);if(t)return t;let n=[];return e.traverse({JSXElement(i){i.getFunctionParent()?.node===e.node&&!le(i)&&n.push(i)}}),M.set(e.node,n),n}function le(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 k(e){let t=M.get(e.node);if(t)return t;let n=[],i=e.get("children");for(let s of i)if(!Array.isArray(s)){if(s.isJSXElement()){n.push(s);continue}if(s.isJSXFragment()){n.push(...k(s));continue}s.isJSXExpressionContainer()&&n.push(...b(s.get("expression")))}return M.set(e.node,n),n}function b(e){return e.isJSXElement()?[e]:e.isJSXFragment()?k(e):e.isParenthesizedExpression()?b(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?b(e.get("right")):e.isConditionalExpression()?[...b(e.get("consequent")),...b(e.get("alternate"))]:e.isCallExpression()&&Fe(e.node)?$e(e.get("arguments")[0]):[]}function $e(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return k(t);if(t.isParenthesizedExpression())return b(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let i of t.get("body")){if(i.isVariableDeclaration())for(let o of i.get("declarations")){let u=o.get("init");(u.isJSXElement()||u.isJSXFragment())&&n.push(...b(u))}if(!i.isReturnStatement())continue;let s=i.get("argument");return s.node&&n.push(...b(s)),n}return n}function Fe(e){return r.isMemberExpression(e.callee)&&r.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}K.exports=he;K.exports.instrumentSiteEditRuntimeAttributes=ie});module.exports=pe();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcp-dev/site-edit-engine",
3
- "version": "0.11.43",
3
+ "version": "0.11.45",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -57,7 +57,7 @@
57
57
  "@babel/types": "^7.29.0",
58
58
  "@csstools/css-tokenizer": "3.0.4",
59
59
  "@jridgewell/sourcemap-codec": "1.5.5",
60
- "@vcp-dev/platform-shared": "0.11.43",
60
+ "@vcp-dev/platform-shared": "0.11.45",
61
61
  "postcss": "8.5.23",
62
62
  "rollup": "npm:@rollup/wasm-node@4.60.4",
63
63
  "typescript": "5.9.3",