@vcp-dev/site-edit-engine 0.10.4 → 0.10.6
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.
- package/dist/index.js +5 -5
- package/dist/internal/protocol/render.d.ts +1 -0
- package/dist/preview-runtime.d.ts +1 -0
- package/dist/runtime.d.ts +1 -0
- package/dist/site-edit-instrumentation-loader.cjs +1 -1
- package/dist/site-edit-instrumentation-loader.d.cts +27 -27
- package/dist/webpack-loader.cjs +1 -1
- package/dist/webpack-loader.d.cts +3 -3
- package/package.json +2 -2
|
@@ -74,6 +74,7 @@ export interface DynamicDataDetailView {
|
|
|
74
74
|
export interface DynamicDataSummaryView {
|
|
75
75
|
hasDynamicData: boolean;
|
|
76
76
|
sourceKinds: DynamicSourceKindView[];
|
|
77
|
+
collections?: string[];
|
|
77
78
|
primaryEndpoint?: string;
|
|
78
79
|
primaryCollection?: string;
|
|
79
80
|
primaryFieldPath?: string;
|
|
@@ -35,6 +35,7 @@ export declare class PreviewFileSystemSiteEditEngineRuntime implements PreviewSi
|
|
|
35
35
|
dynamicDataSummary?: {
|
|
36
36
|
hasDynamicData: boolean;
|
|
37
37
|
sourceKinds: ("vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api")[];
|
|
38
|
+
collections?: string[] | undefined;
|
|
38
39
|
primaryEndpoint?: string | undefined;
|
|
39
40
|
primaryCollection?: string | undefined;
|
|
40
41
|
primaryFieldPath?: string | undefined;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare class SnapshotSiteEditEngineRuntime implements SiteEditEngineRunt
|
|
|
28
28
|
dynamicDataSummary?: {
|
|
29
29
|
hasDynamicData: boolean;
|
|
30
30
|
sourceKinds: ("vcp-cms-collection" | "vcp-cms-form" | "vcp-cms-settings" | "vcp-cms-navigation" | "site-api-route" | "external-api" | "unknown-api")[];
|
|
31
|
+
collections?: string[] | undefined;
|
|
31
32
|
primaryEndpoint?: string | undefined;
|
|
32
33
|
primaryCollection?: string | undefined;
|
|
33
34
|
primaryFieldPath?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var S=require("@babel/generator"),v=require("@babel/parser"),h=require("@babel/traverse"),s=require("@babel/types"),j=typeof S=="function"?S:S.default,k=typeof h=="function"?h:h.default,O={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},
|
|
1
|
+
"use strict";var S=require("@babel/generator"),v=require("@babel/parser"),h=require("@babel/traverse"),s=require("@babel/types"),j=typeof S=="function"?S:S.default,k=typeof h=="function"?h:h.default,O={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},F=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]);var M="suppressHydrationWarning",$=new Set(["SiteEditBootstrap"]),L="data-vcp-ui-component",f="components/ui";function W(e,t){this.cacheable?.();let n=this.async();try{if(!U(this.resourcePath)){n(null,e,t);return}let r=this.getOptions?.()??{},i=J({source:e,file:this.resourcePath,projectRoot:r.projectRoot});n(null,i.code,i.code===e?t:null)}catch(r){n(r)}}function U(e){return typeof e=="string"&&/\.(jsx|tsx)$/.test(e)&&!e.includes("/node_modules/")&&!e.endsWith(".d.ts")}function J(e){let t=q(e.file,e.projectRoot);if(!z(e.source)||d(t))return{code:e.source,elements:[]};let n=e.attributes??O,r=v.parse(e.source,{sourceType:"module",plugins:["jsx","typescript"]}),i=[],u=V(r,t);return k(r,{JSXElement(o){let c=o.node.openingElement,l=c.name;if(!G(l)||A(c,n.key))return;let y=ee(o)??"default",R=ne(o),P=B(t,y,R),g=m(l)??"unknown",E=K(l)?"jsx":"component-call";if(E==="component-call"&&!te(o.node.children)&&$.has(g))return;let _=E==="component-call"&&H(g,u);Y(c,n.key,P),_&&C(c,L),D(o)&&C(c,M),i.push({key:P,tag:g,component_name:y,source_file:t,source_kind:E})}}),i.length===0?{code:e.source,elements:i}:{code:j(r,{jsescOption:{minimal:!0}}).code,elements:i}}function D(e){return!e.findParent(t=>t.isJSXElement())}function z(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 B(e,t,n){return`${e}::${t}::${n}`}function q(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),r=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(r&&n.startsWith(`${r}/`))return n.slice(r.length+1);for(let[u,o]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let c=n.indexOf(u);if(c>=0)return n.slice(c+o)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function K(e){return s.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function m(e){return s.isJSXIdentifier(e)?e.name:s.isJSXMemberExpression(e)?w(e):null}function V(e,t){let n=new Set;for(let r of e.program.body)if(!(!s.isImportDeclaration(r)||!Q(r.source.value,t)))for(let i of r.specifiers)n.add(i.local.name);return n}function H(e,t){let n=e.split(".")[0]??e;return t.has(n)}function d(e){if(!e)return!1;let t=x(e);return t===f||t.startsWith(`${f}/`)||t.includes(`/${f}/`)||t.endsWith(`/${f}`)}function Q(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?d(e.slice(2)):e.startsWith("./")||e.startsWith("../")?d(x(`${Z(t)}/${e}`)):d(e):!1}function x(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),r=[];for(let i of n.split("/"))if(!(!i||i===".")){if(i===".."){r.pop();continue}r.push(i)}return r.join("/")}function Z(e){let t=x(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function G(e){let t=m(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!F.has(t)}function A(e,t){return e.attributes.some(n=>s.isJSXAttribute(n)&&s.isJSXIdentifier(n.name,{name:t}))}function Y(e,t,n){X(e,s.jsxAttribute(s.jsxIdentifier(t),s.stringLiteral(n)))}function C(e,t){A(e,t)||X(e,s.jsxAttribute(s.jsxIdentifier(t),null))}function X(e,t){let n=e.attributes.findIndex(r=>s.isJSXSpreadAttribute(r));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function w(e){return`${s.isJSXIdentifier(e.object)?e.object.name:w(e.object)}.${e.property.name}`}function ee(e){let t=e;for(;t;){if(t.isFunctionDeclaration()||t.isClassDeclaration())return t.node.id?.name??null;if(t.isVariableDeclarator()&&s.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 te(e){return e.some(t=>s.isJSXElement(t)||s.isJSXFragment(t))}var I=new WeakMap,T=new WeakMap,b=new WeakMap;function ne(e){let t=I.get(e.node);if(t!==void 0)return t;let n=[],r=e;for(;r;){if(r.isJSXElement()){let u=re(r);u&&n.unshift(u)}r=r.parentPath}let i=n.join("/");return I.set(e.node,i),i}function re(e){let t=m(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${N(e,t)}`:`${t}#${N(e,t)}`}function N(e,t){let n=ie(e);if(!n)return 0;let r=b.get(n.node)?.get(t)?.get(e.node);if(r!==void 0)return r;let i=b.get(n.node);i||(i=new Map,b.set(n.node,i));let u=i.get(t);u||(u=new WeakMap,i.set(t,u));let o=0;for(let c of p(n))if(m(c.node.openingElement.name)===t){if(u.set(c.node,o),c.node===e.node)return o;o+=1}return u.get(e.node)??0}function ie(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 p(e){let t=T.get(e.node);if(t)return t;let n=[],r=e.get("children");for(let i of r)if(!Array.isArray(i)){if(i.isJSXElement()){n.push(i);continue}if(i.isJSXFragment()){n.push(...p(i));continue}i.isJSXExpressionContainer()&&n.push(...a(i.get("expression")))}return T.set(e.node,n),n}function a(e){return e.isJSXElement()?[e]:e.isJSXFragment()?p(e):e.isParenthesizedExpression()?a(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?a(e.get("right")):e.isConditionalExpression()?[...a(e.get("consequent")),...a(e.get("alternate"))]:e.isCallExpression()&&oe(e.node)?se(e.get("arguments")[0]):[]}function se(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return p(t);if(t.isParenthesizedExpression())return a(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let r of t.get("body")){if(r.isVariableDeclaration())for(let u of r.get("declarations")){let o=u.get("init");(o.isJSXElement()||o.isJSXFragment())&&n.push(...a(o))}if(!r.isReturnStatement())continue;let i=r.get("argument");return i.node&&n.push(...a(i)),n}return n}function oe(e){return s.isMemberExpression(e.callee)&&s.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}module.exports=W;module.exports.instrumentSiteEditRuntimeAttributes=J;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SiteEditInstrumentationOptions,
|
|
3
|
-
SiteEditInstrumentationResult,
|
|
4
|
-
} from "./site-edit-instrumentation.js";
|
|
5
|
-
|
|
6
|
-
declare function siteEditInstrumentationLoader(
|
|
7
|
-
this: {
|
|
8
|
-
cacheable?: () => void;
|
|
9
|
-
async?: () => (
|
|
10
|
-
error?: Error | null,
|
|
11
|
-
code?: string,
|
|
12
|
-
inputSourceMap?: unknown,
|
|
13
|
-
) => void;
|
|
14
|
-
resourcePath?: string;
|
|
15
|
-
getOptions?: () => { projectRoot?: string };
|
|
16
|
-
},
|
|
17
|
-
source: string,
|
|
18
|
-
inputSourceMap?: unknown,
|
|
19
|
-
): void;
|
|
20
|
-
|
|
21
|
-
declare namespace siteEditInstrumentationLoader {
|
|
22
|
-
function instrumentSiteEditRuntimeAttributes(
|
|
23
|
-
options: SiteEditInstrumentationOptions,
|
|
24
|
-
): SiteEditInstrumentationResult;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export = siteEditInstrumentationLoader;
|
|
1
|
+
import type {
|
|
2
|
+
SiteEditInstrumentationOptions,
|
|
3
|
+
SiteEditInstrumentationResult,
|
|
4
|
+
} from "./site-edit-instrumentation.js";
|
|
5
|
+
|
|
6
|
+
declare function siteEditInstrumentationLoader(
|
|
7
|
+
this: {
|
|
8
|
+
cacheable?: () => void;
|
|
9
|
+
async?: () => (
|
|
10
|
+
error?: Error | null,
|
|
11
|
+
code?: string,
|
|
12
|
+
inputSourceMap?: unknown,
|
|
13
|
+
) => void;
|
|
14
|
+
resourcePath?: string;
|
|
15
|
+
getOptions?: () => { projectRoot?: string };
|
|
16
|
+
},
|
|
17
|
+
source: string,
|
|
18
|
+
inputSourceMap?: unknown,
|
|
19
|
+
): void;
|
|
20
|
+
|
|
21
|
+
declare namespace siteEditInstrumentationLoader {
|
|
22
|
+
function instrumentSiteEditRuntimeAttributes(
|
|
23
|
+
options: SiteEditInstrumentationOptions,
|
|
24
|
+
): SiteEditInstrumentationResult;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export = siteEditInstrumentationLoader;
|
package/dist/webpack-loader.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var _=k((fe,y)=>{"use strict";var S=require("@babel/generator"),O=require("@babel/parser"),h=require("@babel/traverse"),s=require("@babel/types"),
|
|
1
|
+
"use strict";var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var _=k((fe,y)=>{"use strict";var S=require("@babel/generator"),O=require("@babel/parser"),h=require("@babel/traverse"),s=require("@babel/types"),F=typeof S=="function"?S:S.default,M=typeof h=="function"?h:h.default,$={key:"data-vcp-edit-key",parentKey:"data-vcp-edit-parent-key",movable:"data-vcp-movable",removable:"data-vcp-removable",flags:"data-vcp-flags"},L=new Set(["base","body","head","html","link","meta","noscript","script","style","template","title"]),W="suppressHydrationWarning",U=new Set(["SiteEditBootstrap"]),D="data-vcp-ui-component",f="components/ui";function z(e,t){this.cacheable?.();let n=this.async();try{if(!B(this.resourcePath)){n(null,e,t);return}let r=this.getOptions?.()??{},i=A({source:e,file:this.resourcePath,projectRoot:r.projectRoot});n(null,i.code,i.code===e?t:null)}catch(r){n(r)}}function B(e){return typeof e=="string"&&/\.(jsx|tsx)$/.test(e)&&!e.includes("/node_modules/")&&!e.endsWith(".d.ts")}function A(e){let t=H(e.file,e.projectRoot);if(!K(e.source)||d(t))return{code:e.source,elements:[]};let n=e.attributes??$,r=O.parse(e.source,{sourceType:"module",plugins:["jsx","typescript"]}),i=[],u=Z(r,t);return M(r,{JSXElement(o){let c=o.node.openingElement,l=c.name;if(!te(l)||X(c,n.key))return;let P=re(o)??"default",v=se(o),C=V(t,P,v),g=m(l)??"unknown",E=Q(l)?"jsx":"component-call";if(E==="component-call"&&!ie(o.node.children)&&U.has(g))return;let j=E==="component-call"&&G(g,u);ne(c,n.key,C),j&&I(c,D),q(o)&&I(c,W),i.push({key:C,tag:g,component_name:P,source_file:t,source_kind:E})}}),i.length===0?{code:e.source,elements:i}:{code:F(r,{jsescOption:{minimal:!0}}).code,elements:i}}function q(e){return!e.findParent(t=>t.isJSXElement())}function K(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 V(e,t,n){return`${e}::${t}::${n}`}function H(e,t){let n=e.replace(/\\/g,"/").replace(/^\.\//,""),r=t?.replace(/\\/g,"/").replace(/\/+$/,"");if(r&&n.startsWith(`${r}/`))return n.slice(r.length+1);for(let[u,o]of[["/src/app/",1],["/src/components/",1],["/app/",1],["/components/",1]]){let c=n.indexOf(u);if(c>=0)return n.slice(c+o)}return n.match(/(?:^|\/)((?:src\/app|src\/components|app|components)\/.+)$/)?.[1]??n}function Q(e){return s.isJSXIdentifier(e)&&/^[a-z]/.test(e.name)}function m(e){return s.isJSXIdentifier(e)?e.name:s.isJSXMemberExpression(e)?R(e):null}function Z(e,t){let n=new Set;for(let r of e.program.body)if(!(!s.isImportDeclaration(r)||!Y(r.source.value,t)))for(let i of r.specifiers)n.add(i.local.name);return n}function G(e,t){let n=e.split(".")[0]??e;return t.has(n)}function d(e){if(!e)return!1;let t=x(e);return t===f||t.startsWith(`${f}/`)||t.includes(`/${f}/`)||t.endsWith(`/${f}`)}function Y(e,t){return e?e.startsWith("@/")||e.startsWith("~/")?d(e.slice(2)):e.startsWith("./")||e.startsWith("../")?d(x(`${ee(t)}/${e}`)):d(e):!1}function x(e){let n=(e.split("?")[0]??e).replace(/\\/g,"/").replace(/^\.\//,""),r=[];for(let i of n.split("/"))if(!(!i||i===".")){if(i===".."){r.pop();continue}r.push(i)}return r.join("/")}function ee(e){let t=x(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n):""}function te(e){let t=m(e);return!t||t==="Fragment"||t.endsWith(".Fragment")?!1:!L.has(t)}function X(e,t){return e.attributes.some(n=>s.isJSXAttribute(n)&&s.isJSXIdentifier(n.name,{name:t}))}function ne(e,t,n){w(e,s.jsxAttribute(s.jsxIdentifier(t),s.stringLiteral(n)))}function I(e,t){X(e,t)||w(e,s.jsxAttribute(s.jsxIdentifier(t),null))}function w(e,t){let n=e.attributes.findIndex(r=>s.isJSXSpreadAttribute(r));if(n>=0){e.attributes.splice(n,0,t);return}e.attributes.push(t)}function R(e){return`${s.isJSXIdentifier(e.object)?e.object.name:R(e.object)}.${e.property.name}`}function re(e){let t=e;for(;t;){if(t.isFunctionDeclaration()||t.isClassDeclaration())return t.node.id?.name??null;if(t.isVariableDeclarator()&&s.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 ie(e){return e.some(t=>s.isJSXElement(t)||s.isJSXFragment(t))}var T=new WeakMap,N=new WeakMap,b=new WeakMap;function se(e){let t=T.get(e.node);if(t!==void 0)return t;let n=[],r=e;for(;r;){if(r.isJSXElement()){let u=oe(r);u&&n.unshift(u)}r=r.parentPath}let i=n.join("/");return T.set(e.node,i),i}function oe(e){let t=m(e.node.openingElement.name);return!t||t==="Fragment"||t.endsWith(".Fragment")?null:/^[A-Z]/.test(t)?`component:${t}#${J(e,t)}`:`${t}#${J(e,t)}`}function J(e,t){let n=ue(e);if(!n)return 0;let r=b.get(n.node)?.get(t)?.get(e.node);if(r!==void 0)return r;let i=b.get(n.node);i||(i=new Map,b.set(n.node,i));let u=i.get(t);u||(u=new WeakMap,i.set(t,u));let o=0;for(let c of p(n))if(m(c.node.openingElement.name)===t){if(u.set(c.node,o),c.node===e.node)return o;o+=1}return u.get(e.node)??0}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 p(e){let t=N.get(e.node);if(t)return t;let n=[],r=e.get("children");for(let i of r)if(!Array.isArray(i)){if(i.isJSXElement()){n.push(i);continue}if(i.isJSXFragment()){n.push(...p(i));continue}i.isJSXExpressionContainer()&&n.push(...a(i.get("expression")))}return N.set(e.node,n),n}function a(e){return e.isJSXElement()?[e]:e.isJSXFragment()?p(e):e.isParenthesizedExpression()?a(e.get("expression")):e.isLogicalExpression()&&e.node.operator==="&&"?a(e.get("right")):e.isConditionalExpression()?[...a(e.get("consequent")),...a(e.get("alternate"))]:e.isCallExpression()&&ae(e.node)?ce(e.get("arguments")[0]):[]}function ce(e){if(!e?.isArrowFunctionExpression()&&!e?.isFunctionExpression())return[];let t=e.get("body");if(t.isJSXElement())return[t];if(t.isJSXFragment())return p(t);if(t.isParenthesizedExpression())return a(t.get("expression"));if(!t.isBlockStatement())return[];let n=[];for(let r of t.get("body")){if(r.isVariableDeclaration())for(let u of r.get("declarations")){let o=u.get("init");(o.isJSXElement()||o.isJSXFragment())&&n.push(...a(o))}if(!r.isReturnStatement())continue;let i=r.get("argument");return i.node&&n.push(...a(i)),n}return n}function ae(e){return s.isMemberExpression(e.callee)&&s.isIdentifier(e.callee.property)&&e.callee.property.name==="map"}y.exports=z;y.exports.instrumentSiteEditRuntimeAttributes=A});module.exports=_();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import siteEditInstrumentationLoader = require("./site-edit-instrumentation-loader.cjs");
|
|
2
|
-
|
|
3
|
-
export = siteEditInstrumentationLoader;
|
|
1
|
+
import siteEditInstrumentationLoader = require("./site-edit-instrumentation-loader.cjs");
|
|
2
|
+
|
|
3
|
+
export = siteEditInstrumentationLoader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcp-dev/site-edit-engine",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@babel/parser": "^7.29.3",
|
|
61
61
|
"@babel/traverse": "^7.29.0",
|
|
62
62
|
"@babel/types": "^7.29.0",
|
|
63
|
-
"@vcp-dev/contracts": "0.10.
|
|
63
|
+
"@vcp-dev/contracts": "0.10.6",
|
|
64
64
|
"yaml": "^2.9.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|