@vcp-dev/site-edit-bridge 0.11.44 → 0.11.46
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/auto-bootstrap.js +13 -13
- package/dist/cms-preview-record.d.ts +2 -0
- package/dist/cms-preview-record.js +1 -1
- package/dist/index.js +17 -17
- package/package.json +3 -3
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CmsPreviewIdentityCandidate } from "./cms-preview-identity-registry.js";
|
|
2
2
|
/** Only injected into development-preview data flow by the preview compiler. */
|
|
3
3
|
export declare function attachCmsPreviewRecord<T extends object>(view: T, raw: unknown, appSlug: string, operation: "list" | "detail"): T;
|
|
4
|
+
export declare function attachCmsPreviewListResult<T>(result: T, appSlug: string, strict: boolean): T;
|
|
5
|
+
export declare function attachCmsPreviewListView<T extends object>(view: T, item: unknown, appSlug: string): T;
|
|
4
6
|
/** Extract a candidate, never an authorization. The Engine and CMS validate it separately. */
|
|
5
7
|
export declare function readCmsPreviewCandidate(value: unknown, field: string, mediaIndex?: number): CmsPreviewIdentityCandidate | null;
|
|
6
8
|
/** The compiler uses this on intrinsic JSX spreads so preview metadata never becomes an HTML attribute. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function P(o,i){if(!Array.isArray(o))return i.map(()=>null);let n=new Map;return o.forEach((e,r)=>{!e||typeof e!="object"||n.set(e,n.has(e)?null:r)}),i.map(e=>{if(!e||typeof e!="object")return null;let r=n.get(e);if(r==null)return null;let t=e,f=t.resource&&typeof t.resource=="object"?t.resource:void 0,a=t.url??f?.url;if(typeof a!="string"||!a.trim())return null;let c=f?.id??t.resource_id??t.id;return typeof c!="string"&&typeof c!="number"||!/^[1-9]\d*$/.test(String(c))||!Number.isSafeInteger(Number(c))?null:{resourceId:String(c),currentUrl:a}})}var p="__vcpCmsPreview",w="vcp-preview-record-v1";function d(o){if(!o||typeof o!="object"||Array.isArray(o))return null;let i=Object.getPrototypeOf(o);return i===Object.prototype||i===null?o:null}function A(o,i,n,e){let r=d(o),t=d(i),f=d(t?.fields);if(!r||!t||!f||Object.hasOwn(r,p)||typeof t.id!="number"||!Number.isSafeInteger(t.id)||t.id<=0||r.id!==t.id||!n.trim())return o;let a={kind:w,appSlug:n,recordId:String(t.id),operation:e,...typeof t.url=="string"&&t.url.trim()?{recordUrl:t.url}:{}},c=new Map;for(let s of Object.keys(f)){let u=r===t?s:["id","url","seo"].includes(s)?`${s}_field`:s;c.set(u,c.has(u)?null:s)}let m=(s,u)=>{let y=f[s];if(!Array.isArray(y))return u;let l=Array.isArray(u),k=l?u:[u],h=P(y,k),v=new Set(y),O=k.map((j,K)=>{let g=d(j),S=h[K];return!g||!v.has(j)||Object.hasOwn(g,p)?j:{...g,[p]:{...a,fieldKey:s,...S??{}}}});return l?O:O[0]},b={...r};for(let s of Object.keys(f)){let u=["id","url","seo"].includes(s)?`${s}_field`:s;r!==t&&c.get(u)===s&&Object.hasOwn(r,u)&&(b[u]=m(s,r[u]))}if(r===t){let s={...f};for(let u of Object.keys(f))s[u]=m(u,f[u]);b.fields=s}return b[p]={...a,fields:Object.fromEntries([...c].filter(s=>s[1]!==null)),...r===t?{direct:!0}:{}},b}function M(o,i,n){let e=d(o);if(!e||n&&e.kind!=="ok")return o;let r=n?d(e.data):e;if(!r||!Array.isArray(r.items)||r.items.length===0)return o;let t=r.items.map(a=>{let c=d(a);return c?A(c,c,i,"list"):a}),f={...r,items:t};return n?{...e,data:f}:f}function E(o,i,n){let e=d(d(i)?.[p]);return e?.kind===w&&e.appSlug===n&&e.operation==="list"?A(o,i,n,"list"):o}function R(o,i,n){let e=d(o),r=d(e?.[p]);if(!e||!r)return null;let{fields:t,kind:f,direct:a,...c}=r;if(f!==w)return null;if(t&&d(t)){let m=t[i];if(!m)return null;let b=a?d(e.fields):e,s=y=>{let l=_(y);return l&&l.appSlug===c.appSlug&&l.recordId===c.recordId&&l.operation===c.operation&&l.fieldKey===m?l:null};if(n!==void 0){let y=b?.[i];return Array.isArray(y)&&Number.isSafeInteger(n)&&n>=0?s(y[n]):null}let u=s(b?.[i]);return u||{...c,fieldKey:m}}return c.fieldKey?c:null}function _(o){let i=d(o),n=d(i?.[p]);if(!n||n.kind!==w||n.fields!==void 0||!n.fieldKey)return null;let{kind:e,...r}=n;return r}function N(o){let i=d(o),n=d(i?.[p]);if(!i||n?.kind!==w)return o;let{[p]:e,...r}=i;return r}export{M as attachCmsPreviewListResult,E as attachCmsPreviewListView,A as attachCmsPreviewRecord,R as readCmsPreviewCandidate,N as stripCmsPreviewMetadata};
|