payload-live-preview 2.0.6 → 2.1.0
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/README.md +141 -38
- package/dist/adapters/astro/FragmentBridge.astro +25 -0
- package/dist/adapters/astro/PreviewBoundary.astro +2 -4
- package/dist/adapters/astro/RichText.astro +26 -5
- package/dist/adapters/astro/index.d.ts +41 -9
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.d.ts +3 -3
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.d.ts +17 -12
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +11 -6
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/nuxt/module.d.ts +64 -13
- package/dist/adapters/nuxt/module.js +1 -1
- package/dist/adapters/nuxt/module.js.map +1 -1
- package/dist/adapters/react/index.d.ts +11 -7
- package/dist/adapters/react/index.js +1 -1
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +10 -5
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +10 -7
- package/dist/adapters/vue/index.js +1 -1
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/annotate.d.ts +15 -2
- package/dist/annotate.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +367 -266
- package/dist/client.d.ts +367 -266
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/codegen-cli.js.map +1 -1
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.d.cts +7 -1
- package/dist/codegen.d.ts +7 -1
- package/dist/codegen.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +544 -392
- package/dist/core.d.ts +544 -392
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/doctor-cli.d.ts +1 -1
- package/dist/doctor-cli.js +1 -1
- package/dist/doctor-cli.js.map +1 -1
- package/dist/doctor.d.ts +2 -2
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/{document-session-BfBfLVpg.d.ts → document-session-DWi9H3Qk.d.ts} +7 -0
- package/dist/{fragment-endpoint-DATKU183.d.ts → fragment-endpoint-B2qcRw5T.d.ts} +22 -7
- package/dist/fragment.cjs +1 -1
- package/dist/fragment.cjs.map +1 -1
- package/dist/fragment.d.cts +37 -16
- package/dist/fragment.d.ts +37 -16
- package/dist/fragment.js +1 -1
- package/dist/fragment.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +598 -400
- package/dist/index.d.ts +598 -400
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +1 -1
- package/dist/lean.cjs.map +1 -1
- package/dist/lean.d.cts +5 -2
- package/dist/lean.d.ts +5 -2
- package/dist/lean.js +1 -1
- package/dist/lean.js.map +1 -1
- package/dist/lexical.cjs +1 -1
- package/dist/lexical.cjs.map +1 -1
- package/dist/lexical.d.cts +32 -11
- package/dist/lexical.d.ts +32 -11
- package/dist/lexical.js +1 -1
- package/dist/lexical.js.map +1 -1
- package/dist/{locals-CNUGYbA_.d.ts → locals-B1mF3aTb.d.ts} +1 -1
- package/dist/{middleware-CWObDO37.d.ts → middleware-BGobLN9P.d.ts} +11 -5
- package/dist/migrate.js +1 -1
- package/dist/migrate.js.map +1 -1
- package/dist/{options-uHKrDM2U.d.ts → options-Cm8fC7dj.d.ts} +31 -1
- package/dist/payload.cjs +1 -1
- package/dist/payload.cjs.map +1 -1
- package/dist/payload.d.cts +18 -2
- package/dist/payload.d.ts +18 -2
- package/dist/payload.js +1 -1
- package/dist/payload.js.map +1 -1
- package/dist/plugin.cjs +2 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +30 -0
- package/dist/plugin.d.ts +30 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +102 -29
- package/dist/plugins.d.ts +102 -29
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{probe-Bzm4fYFL.d.ts → probe-DGPDsnbj.d.ts} +6 -2
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +43 -4
- package/dist/server.d.ts +43 -4
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/structural.cjs +2 -2
- package/dist/structural.cjs.map +1 -1
- package/dist/structural.d.cts +61 -13
- package/dist/structural.d.ts +61 -13
- package/dist/structural.js +2 -2
- package/dist/structural.js.map +1 -1
- package/package.json +33 -4
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { e as PreviewAuthorizationRequest, f as AuthorizedPreviewScope, A as AuthorizedPreviewContext, P as PreviewAdapterOptions } from './options-
|
|
1
|
+
import { e as PreviewAuthorizationRequest, f as AuthorizedPreviewScope, A as AuthorizedPreviewContext, P as PreviewAdapterOptions } from './options-Cm8fC7dj.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The `payload-session` strategy: forward exactly one named cookie to
|
|
5
5
|
* `GET <serverURL>/api/<usersSlug>/me` and authorize when a user comes back.
|
|
6
|
+
* A cookie-only request preserves working Payload 2 sessions. When `/me`
|
|
7
|
+
* reports no user, one retry adds an `Origin` for Payload 3's CSRF check.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
/** A `fetch`-compatible function, injectable for tests. */
|
|
@@ -22,6 +24,12 @@ interface PayloadSessionStrategy {
|
|
|
22
24
|
readonly usersSlug?: string;
|
|
23
25
|
/** Cookie name; Payload's default is `payload-token`. */
|
|
24
26
|
readonly cookieName?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Send this listed origin with the cookie from the first request. Without
|
|
29
|
+
* it, try the existing cookie-only request, then the origin of `serverURL`
|
|
30
|
+
* once when `/me` reports a null user. Draft reads keep the accepted headers.
|
|
31
|
+
*/
|
|
32
|
+
readonly origin?: string;
|
|
25
33
|
/** Upper bound for the `/me` round trip. Below 250 ms is raised to 250 ms; default 3000. */
|
|
26
34
|
readonly timeoutMs?: number;
|
|
27
35
|
/** Longest cookie value accepted; longer ones are refused as `missing-credential`. Default 4096. */
|
|
@@ -71,7 +79,7 @@ interface PreviewTokenReplayStore {
|
|
|
71
79
|
consume(id: string, expiresAt: number): Promise<boolean> | boolean;
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
74
|
-
* @deprecated The
|
|
82
|
+
* @deprecated The store shape of the 2.0 beta, removed in 3.0. Its two calls cannot be one
|
|
75
83
|
* step, so two requests with the same token that arrive together both pass
|
|
76
84
|
* `isUsed` before either reaches `markUsed`. Implement
|
|
77
85
|
* {@link PreviewTokenReplayStore.consume} instead.
|
|
@@ -127,9 +135,8 @@ type PreviewAuthorizationStrategy = PayloadSessionStrategy | SignedTokenStrategy
|
|
|
127
135
|
*
|
|
128
136
|
* Everything here is framework-neutral — method and origin checks, the body
|
|
129
137
|
* limit, the protocol, authorization, the registry lookup, the timeouts and the
|
|
130
|
-
* response shape.
|
|
131
|
-
*
|
|
132
|
-
* the two, and each is a few dozen lines because this file is the endpoint.
|
|
138
|
+
* response shape. Each server adapter binds one renderer and its native route
|
|
139
|
+
* shape; Astro, Next.js, SvelteKit and Nuxt all delegate the decisions here.
|
|
133
140
|
*/
|
|
134
141
|
|
|
135
142
|
/** Everything a registry entry may use to compute its props. */
|
|
@@ -143,7 +150,11 @@ interface FragmentRenderInput {
|
|
|
143
150
|
readonly globalSlug: string | undefined;
|
|
144
151
|
readonly route: string;
|
|
145
152
|
readonly authorization: AuthorizedPreviewContext;
|
|
153
|
+
/** Aborts when the request, its total deadline, or a render phase ends early. */
|
|
154
|
+
readonly signal: AbortSignal;
|
|
146
155
|
readonly request: Request;
|
|
156
|
+
/** What the framework's server code put on this request: Astro `locals`, SvelteKit `event.locals`, Nuxt `event.context`; Next.js none (ADR 0029). */
|
|
157
|
+
readonly locals: unknown;
|
|
147
158
|
}
|
|
148
159
|
/**
|
|
149
160
|
* `Props extends object`, not `Record<string, unknown>`: an `interface` has no
|
|
@@ -179,10 +190,14 @@ interface FragmentEndpointOptions<Component> {
|
|
|
179
190
|
/** Origins besides the page's own that may call the endpoint. Default: none. */
|
|
180
191
|
readonly allowedOrigins?: readonly string[];
|
|
181
192
|
readonly limits?: {
|
|
182
|
-
/** Largest request body. Default 64 KiB. */
|
|
193
|
+
/** Largest streamed request body in bytes. Default 64 KiB. */
|
|
183
194
|
readonly bodyBytes?: number;
|
|
184
|
-
/**
|
|
195
|
+
/** Body-read and per-render-phase timeout. Default 5000 ms. */
|
|
185
196
|
readonly timeoutMs?: number;
|
|
197
|
+
/** Maximum nesting depth of `fields`. Integer from 0 to 64; default 64. */
|
|
198
|
+
readonly fieldDepth?: number;
|
|
199
|
+
/** One deadline across body, authorization, props and rendering. Default: disabled. */
|
|
200
|
+
readonly totalTimeoutMs?: number;
|
|
186
201
|
};
|
|
187
202
|
}
|
|
188
203
|
|
package/dist/fragment.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e,t){const n=new AbortController;let r=!1;const o=()=>{n.abort()};e.addEventListener("abort",o,{once:!0});const i=setTimeout(()=>{r=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>r,dispose:()=>{clearTimeout(i),e.removeEventListener("abort",o)}}}function t(e){return e instanceof Error?e.message:String(e)}var n="data-payload-island";function r(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(n)}(e)&&!("patch"===e.getAttribute(n))}function isInsideIsland(e){let t=e;for(;null!==t;){if(r(t))return!0;t=t.parentElement}return!1}function o(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const r of e.split(/[\s,]+/)){const e=r.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}var i="data-payload-fragment",a="data-payload-fragment-key";function s(e){const t=e.getAttribute(i);if(null===t||0===t.length)return null;const n=e.getAttribute(a);return{element:e,id:t,key:null===n||0===n.length?void 0:n,dependsOn:o(e.getAttribute("data-payload-depends"))}}function l(e,t){const n=[];for(const r of e.querySelectorAll(`[${i}]`)){const e=s(r);null===e||isInsideIsland(r)||e.dependsOn.length>0&&!e.dependsOn.some(e=>t.has(e))||n.push(e)}return n}var u="x-payload-fragment-version";function c(e,t){if(t>64||"object"!=typeof e||null===e)return t;let n=t;for(const r of Object.values(e))if(n=Math.max(n,c(r,t+1)),n>64)break;return n}function d(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function f(e){if(!d(e))return null;const{html:t,boundary:n,revision:r,metadata:o}=e;return"string"!=typeof t?null:d(n)&&"string"==typeof n.id?void 0!==n.key&&"string"!=typeof n.key||"number"!=typeof r?null:d(o)&&"string"==typeof o.renderedAt&&"string"==typeof o.renderer?e:null:null}var g={status:"superseded"};function p(e,t){return{status:"failed",code:e,reason:t}}function m(n){const r=function(e){const t=()=>{throw new TypeError('createFragmentStrategy: endpoint must be a same-origin path starting with "/"')};if(("string"!=typeof e||!e.startsWith("/")||e.startsWith("//")||e.includes("\\"))&&t(),"undefined"!=typeof location){let n;try{n=new URL(e,location.href)}catch{n=void 0}n?.origin!==location.origin&&t()}return e}(n.endpoint),o=n.timeoutMs??5e3,i=n.maxResponseBytes??524288,a=function(e){let t=0;const n=[];return async r=>{t<e?t+=1:await new Promise(e=>{n.push(e)});try{return await r()}finally{(()=>{const e=n.shift();void 0===e?t-=1:e()})()}}}(Math.max(1,n.maxConcurrent??4)),s=/* @__PURE__ */new Map;return(l,c)=>{const d=`${c.id} ${c.key??""} ${String(l.revision)}`,m=s.get(d);if(void 0!==m)return m;const h=a(()=>async function(a,s){const l=()=>a.signal.aborted;if(l())return g;const c=n.location??location,d=function(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}({fragment:s.id,key:s.key,route:c.pathname,search:c.search,revision:a.revision,locale:a.locale,collectionSlug:a.collectionSlug,globalSlug:a.globalSlug,fields:a.fields}),m=e(a.signal,o),h=e=>l()?g:m.timedOut()?p("LP0801",`timeout after ${String(o)} ms`):p("LP0801",t(e));try{let e;try{e=await(n.fetch??fetch)(r,{method:"POST",credentials:"same-origin",headers:{...n.headers,accept:"application/json","content-type":"application/json",[u]:String(1)},body:JSON.stringify(d),signal:m.signal})}catch(e){return h(e)}if(l())return g;if(401===e.status||403===e.status)return p("LP0803",`endpoint refused the preview (${String(e.status)})`);if(!e.ok)return p("LP0801",`endpoint answered ${String(e.status)}`);const t=e.headers.get("content-type")??"";if(!t.toLowerCase().startsWith("application/json"))return p("LP0802",`unexpected content type "${t}"`);if(Number(e.headers.get("content-length")??"0")>i)return p("LP0802","response exceeds the size limit");let c,y;try{c=await async function(e,t,n){const r=e.body;if("object"!=typeof(o=r)||null===o||"function"!=typeof o.getReader){const n=await e.text();return(new TextEncoder).encode(n).byteLength>t?null:n}var o;const i=r.getReader(),a=()=>{i.cancel().catch(()=>{})};n.addEventListener("abort",a,{once:!0});const s=new TextDecoder;let l="",u=0;try{for(;;){const{done:e,value:n}=await i.read();if(e)break;if(u+=n.byteLength,u>t)return a(),null;l+=s.decode(n,{stream:!0})}}finally{n.removeEventListener("abort",a)}return l+s.decode()}(e,i,m.signal)}catch(e){return h(e)}if(l())return g;if(m.timedOut())return p("LP0801",`timeout after ${String(o)} ms`);if(null===c)return p("LP0802","response exceeds the size limit");try{y=JSON.parse(c)}catch{return p("LP0802","response is not JSON")}const b=f(y);return null===b?p("LP0802","response has the wrong shape"):b.boundary.id!==s.id?p("LP0802","response is for another boundary"):b.revision!==a.revision?g:{status:"rendered",html:b.html,metadata:b.metadata}}finally{m.dispose()}}(l,c));s.set(d,h);const y=()=>{s.get(d)===h&&s.delete(d)};return h.then(y,y),h}}var h=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",UnknownValueFormat:"LP0408",SanitizerDroppedAttribute:"LP0409",UnrenderedBlockKept:"LP0410",UnfaithfulPatch:"LP0411",ServerFormatReplaced:"LP0412",UnrenderedBlockLost:"LP0413",MessageRejected:"LP0501",TokenRejected:"LP0502",ProtocolShapeUnknown:"LP0503",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",HydrationWaitTimedOut:"LP0607",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708",FragmentRequestFailed:"LP0801",FragmentResponseInvalid:"LP0802",FragmentUnauthorized:"LP0803",FragmentSuperseded:"LP0804",RouteRefreshLoop:"LP0805",FragmentStrategyUnavailable:"LP0806",UnboundChangeRefresh:"LP0807",EscalationUnavailable:"LP0808",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),y="data-payload-owned",b=/* @__PURE__ */new Set(["open","value","checked","selected"]);function v(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function L(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(n)||e.hasAttribute(y))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function P(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!L(e)&&!L(t)}(e,t))return t;const r=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||b.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}(e,t),!0!==n.retainChildrenOf?.(e,t)&&function(e,t,n){const r=function(e,t){const n=/* @__PURE__ */new Map;let r;for(const o of Array.from(e.children)){const e=v(o,t);void 0!==e&&(n.has(e)?r??=e.slice(e.indexOf("=")+1):n.set(e,o))}return void 0!==r&&t.onDuplicateKey?.(e,r),n}(e,n),o=new Set(r.values()),i=Array.from(e.childNodes).filter(e=>!o.has(e)),a=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let u=e.firstChild,c=0;for(let t=0;t<l.length;t+=1){const o=l[t];let d=null,f=o instanceof Element?v(o,n):void 0;if(void 0!==f&&s.has(f)&&(f=void 0),void 0!==f){s.add(f);const e=r.get(f);if(void 0!==e&&!a.has(e)&&(d=A(e,o,n)===e?e:null,null===d)){e.replaceWith(o),a.add(o),u=o.nextSibling;continue}}else{for(;c<i.length;){const r=i[c];if(c+=1,!a.has(r)){if(w(r,o)){d=A(r,o,n)===r?r:null,null===d&&(e.replaceChild(o,r),a.add(o),u=o.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(o instanceof Element)||void 0!==n&&w(r,n)){c-=1;break}e.replaceChild(o,r),a.add(o),u=o.nextSibling;break}if(!(o instanceof Element)){e.replaceChild(o,r),a.add(o),u=o.nextSibling;break}}}if(null===d&&a.has(o))continue}const g=d??o;for(a.add(g);null!==u&&u!==g&&!a.has(u)&&S(u);)u=u.nextSibling;g!==u&&e.insertBefore(g,u),u=g.nextSibling}for(const t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,r]=n??[null,null];null!==e&&null!==r&&t.setSelectionRange(e,r)}catch{}}(r),e}function A(e,t,n){return e instanceof Element&&t instanceof Element?L(e)&&L(t)?e:P(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function S(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function w(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var E="data-payload-strategy",x="data-payload-field",R="x-payload-live-preview";function T(e){const t=e.getAttribute(E);return null!==t?"route"===t:null!==e.closest("head")}function O(e){const t=e.getAttribute(x),n=o(e.getAttribute("data-payload-depends"));return null===t||0===t.length?n:[t,...n]}function k(e){if("META"===e.tagName){const t=e.getAttribute("name")??e.getAttribute("property");return null===t?null:`meta:${t}`}return"LINK"===e.tagName&&"canonical"===e.getAttribute("rel")?"link:canonical":null}function N(e){return{plan:(e,t)=>l(e,t).map(e=>e.element),async render(n,r){const o={rendered:0,failed:0,superseded:0},i={revision:n.revision,receivedAt:n.receivedAt,fields:n.fields,locale:n.locale,collectionSlug:n.collectionSlug,globalSlug:n.globalSlug,signal:n.signal};return await Promise.all(r.map(async r=>{const a=s(r);if(null===a)return;let l;try{l=await e(i,a)}catch(e){l={status:"failed",code:"LP0801",reason:t(e)}}return n.isCurrent()&&"superseded"!==l.status?"rendered"===l.status?(n.morph(r,l.html),n.rendered(r,a.id,a.key),void(o.rendered+=1)):(n.failed(r,a.id,a.key,l.code,l.reason),n.isCurrent()&&n.patch(r),void(o.failed+=1)):(o.superseded+=1,void n.log("LP0804",`fragment "${a.id}" for revision ${String(i.revision)} discarded as superseded`))})),o}}}exports.DIAGNOSTIC_CODES=h,exports.FRAGMENT_ATTRIBUTE=i,exports.FRAGMENT_KEY_ATTRIBUTE=a,exports.FRAGMENT_PROTOCOL_VERSION=1,exports.FRAGMENT_VERSION_HEADER=u,exports.ROUTE_REFRESH_HEADER=R,exports.collectFragmentBoundaries=l,exports.createFragmentHandler=m,exports.createFragmentStrategy=function(e){return N(m(e))},exports.createRouteStrategy=function(n={}){const r=n.timeoutMs??8e3,o=n.minIntervalMs??1e3;let s=-1/0;return{plan(e,t){for(const n of e.querySelectorAll(`[${x}], [${E}="route"]`)){if(!T(n))continue;const e=O(n);if(0===e.length||e.some(e=>t.has(e)))return!0}return!1},async refresh(l){const u=Date.now(),c=o-(u-s);if(c>0)return l.retryAfter?.(c),l.log("LP0805",`route refresh for revision ${String(l.revision)} refused: the previous one was ${String(u-s)} ms ago`),"refused";s=u;const d=n.document??document,f=n.location??location,g=n.window??window,p=e(l.signal,r),m=e=>{if(l.signal.aborted)return"superseded";const n=p.timedOut()?`route refresh timed out after ${String(r)} ms`:t(e);return l.log("LP0801",n),"failed"};try{const e=("undefined"==typeof window?void 0:window)?.__livePreviewRouteRefresh;if(void 0!==e){try{await e()}catch(e){return m(e)}return l.isCurrent()?"refreshed":"superseded"}let t;try{t=await(n.fetch??fetch)(f.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[R]:"route"},signal:p.signal})}catch(e){return m(e)}if(l.signal.aborted)return"superseded";if(!t.ok||!(t.headers.get("content-type")??"").includes("text/html"))return l.log("LP0802",`route answered ${String(t.status)} ${t.headers.get("content-type")??""}`),"failed";try{const e=await t.text();if(!l.isCurrent())return"superseded";const n=(new DOMParser).parseFromString(e,"text/html"),r=g.scrollX,o=g.scrollY;return function(e,t){t.title!==e.title&&(e.title=t.title);const n=/* @__PURE__ */new Map;for(const t of e.head.querySelectorAll("meta, link")){const e=k(t);null===e||n.has(e)||n.set(e,t)}const r=/* @__PURE__ */new Set;for(const o of t.head.querySelectorAll("meta, link")){const t=k(o);if(null===t)continue;r.add(t);const i=n.get(t);if(void 0!==i){if(!i.hasAttribute(y))for(const e of Array.from(o.attributes))i.getAttribute(e.name)!==e.value&&i.setAttribute(e.name,e.value)}else e.head.append(e.importNode(o,!0))}for(const[e,t]of n)r.has(e)||t.hasAttribute(y)||t.remove()}(d,n),P(d.body,n.body,{keyAttributes:["data-payload-key",a,i],retainChildrenOf:e=>e.hasAttribute(i)}),g.scrollTo(r,o),"refreshed"}catch(e){return m(e)}}finally{p.dispose()}}}},exports.describeBoundary=s,exports.fragmentStrategyFrom=N,exports.isRouteBound=T,exports.parseFragmentRequest=function(e){if(!d(e))return null;const t=e.fragment;if("string"!=typeof t||!/^[a-z][a-z0-9-]{0,63}$/iu.test(t))return null;const n=e.key;if(void 0!==n&&("string"!=typeof n||n.length>128))return null;const r=e.route;if("string"!=typeof r||!r.startsWith("/")||r.length>2048)return null;const o=e.search;if("string"!=typeof o||o.length>4096||""!==o&&!o.startsWith("?"))return null;const i=e.revision;if("number"!=typeof i||!Number.isInteger(i)||i<0)return null;const a=[];for(const t of["locale","collectionSlug","globalSlug"]){const n=e[t];if(void 0!==n){if("string"!=typeof n||n.length>128)return null;a.push(n)}else a.push(void 0)}const[s,l,u]=a,f=e.fields;return!d(f)||c(f,0)>64?null:{fragment:t,..."string"==typeof n?{key:n}:{},route:r,search:o,revision:i,...void 0!==s?{locale:s}:{},...void 0!==l?{collectionSlug:l}:{},...void 0!==u?{globalSlug:u}:{},fields:f}},exports.parseFragmentResponse=f,exports.resolveStrategy=function(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==function(e){return e.closest(`[${i}]`)}(e)?"fragment":null!==e.closest("head")?"route":"patch"};
|
|
1
|
+
"use strict";function e(e,t){const n=new AbortController;let r=!1;const o=()=>{n.abort()};e.addEventListener("abort",o,{once:!0});const i=setTimeout(()=>{r=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>r,dispose:()=>{clearTimeout(i),e.removeEventListener("abort",o)}}}function t(e){return e instanceof Error?e.message:String(e)}var n="data-payload-island",r="data-payload-owned";function o(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(i(e)||e.hasAttribute(r))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function i(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(n)}(e)&&!("patch"===e.getAttribute(n))}function isInsideIsland(e){let t=e;for(;null!==t;){if(i(t))return!0;t=t.parentElement}return!1}var a=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],s=/* @__PURE__ */new WeakMap,l=/* @__PURE__ */new WeakSet;function u(e){return"astro-island"===e.tagName.toLowerCase()}function c(e){let t="";for(const n of e.querySelectorAll("astro-slot, template[data-astro-template]"))n.parentElement?.closest("astro-island")===e&&(t+=`${n.getAttribute("name")??n.getAttribute("data-astro-template")??""}\0${n.innerHTML}\0`);return t}function d(e,t){if(!u(e)||!u(t))return!0;const n=c(t);if(!a.every(n=>e.getAttribute(n)===t.getAttribute(n))||(s.get(e)??c(e))!==n||e.getAttribute("props")!==t.getAttribute("props")&&!function(e){const t=e.ownerDocument.defaultView?.customElements.get("astro-island");return void 0!==t&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}(e))return s.set(t,n),!1;s.set(e,n);const r=t.getAttribute("props");return r!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===r?e.removeAttribute("props"):e.setAttribute("props",r)),!0}function f(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const r of e.split(/[\s,]+/)){const e=r.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}var p="data-payload-fragment",g="data-payload-fragment-key";function m(e){const t=e.getAttribute(p);if(null===t||0===t.length)return null;const n=e.getAttribute(g);return{element:e,id:t,key:null===n||0===n.length?void 0:n,dependsOn:f(e.getAttribute("data-payload-depends"))}}function h(e,t){const n=[];for(const r of e.querySelectorAll(`[${p}]`)){const e=m(r);null===e||isInsideIsland(r)||e.dependsOn.length>0&&!e.dependsOn.some(e=>t.has(e))||n.push(e)}return n}var y="x-payload-fragment-version";function b(e,t,n){if(t>n||"object"!=typeof e||null===e)return t;let r=t;for(const o of Object.values(e))if(r=Math.max(r,b(o,t+1,n)),r>n)break;return r}function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function A(e){if(!v(e))return null;const{html:t,boundary:n,revision:r,metadata:o}=e;return"string"!=typeof t?null:v(n)&&"string"==typeof n.id?void 0!==n.key&&"string"!=typeof n.key||"number"!=typeof r?null:v(o)&&"string"==typeof o.renderedAt&&"string"==typeof o.renderer?e:null:null}function L(e){return e.reason instanceof Error?e.reason:new DOMException("The operation was aborted.","AbortError")}function P(e){return!0===e?.aborted}var S={status:"superseded"};function w(e,t){return{status:"failed",code:e,reason:t}}function E(n){const r=function(e){const t=()=>{throw new TypeError('createFragmentStrategy: endpoint must be a same-origin path starting with "/"')};if(("string"!=typeof e||!e.startsWith("/")||e.startsWith("//")||e.includes("\\"))&&t(),"undefined"!=typeof location){let n;try{n=new URL(e,location.href)}catch{n=void 0}n?.origin!==location.origin&&t()}return e}(n.endpoint),o=n.timeoutMs??5e3,i=n.maxResponseBytes??524288,a=function(e){let t=0;const n=[],r=()=>{const e=n.shift();void 0===e?t-=1:e.resume()};return async(o,i)=>{if(void 0!==i&&P(i))throw L(i);if(t<e)t+=1;else if(await new Promise((e,t)=>{let r=()=>{};const o={resume:()=>{r(),e()}};if(n.push(o),void 0!==i){const e=()=>{const e=n.indexOf(o);-1!==e&&(n.splice(e,1),r(),t(L(i)))};r=()=>{i.removeEventListener("abort",e)},i.addEventListener("abort",e,{once:!0}),P(i)&&e()}}),void 0!==i&&P(i))throw r(),L(i);try{return await o()}finally{r()}}}(Math.max(1,n.maxConcurrent??4)),s=/* @__PURE__ */new Map,l=/* @__PURE__ */new WeakMap;let u=0;const c=e=>{const t=l.get(e);return void 0!==t?t:(u+=1,l.set(e,u),u)};return(l,u)=>{const d=JSON.stringify([c(l.signal),u.id,u.key,l.revision]),f=s.get(d);if(void 0!==f)return f;let p=!1;const g=a(()=>(p=!0,async function(a,s){const l=()=>a.signal.aborted;if(l())return S;const u=n.location??location,c=function(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}({fragment:s.id,key:s.key,route:u.pathname,search:u.search,revision:a.revision,locale:a.locale,collectionSlug:a.collectionSlug,globalSlug:a.globalSlug,fields:a.fields}),d=e(a.signal,o),f=e=>l()?S:d.timedOut()?w("LP0801",`timeout after ${String(o)} ms`):w("LP0801",t(e));let p,g=!1;try{try{p=await(n.fetch??fetch)(r,{method:"POST",credentials:"same-origin",headers:{...n.headers,accept:"application/json","content-type":"application/json",[y]:String(1)},body:JSON.stringify(c),signal:d.signal})}catch(e){return f(e)}if(l())return S;if(401===p.status||403===p.status)return w("LP0803",`endpoint refused the preview (${String(p.status)})`);if(!p.ok)return w("LP0801",`endpoint answered ${String(p.status)}`);const e=p.headers.get("content-type")??"";if(!e.toLowerCase().startsWith("application/json"))return w("LP0802",`unexpected content type "${e}"`);if(Number(p.headers.get("content-length")??"0")>i)return w("LP0802","response exceeds the size limit");if(d.signal.aborted)return f(d.signal.reason);let t,u;try{g=!0,t=await async function(e,t,n){const r=e.body;if("object"!=typeof(o=r)||null===o||"function"!=typeof o.getReader){const n=await e.text();return(new TextEncoder).encode(n).byteLength>t?null:n}var o;const i=r.getReader(),a=()=>{i.cancel().catch(()=>{})};n.addEventListener("abort",a,{once:!0});const s=new TextDecoder;let l="",u=0;try{for(;;){const{done:e,value:n}=await i.read();if(e)break;if(u+=n.byteLength,u>t)return a(),null;l+=s.decode(n,{stream:!0})}}finally{n.removeEventListener("abort",a),i.releaseLock()}return l+s.decode()}(p,i,d.signal)}catch(e){return f(e)}if(l())return S;if(d.timedOut())return w("LP0801",`timeout after ${String(o)} ms`);if(null===t)return w("LP0802","response exceeds the size limit");try{u=JSON.parse(t)}catch{return w("LP0802","response is not JSON")}const m=A(u);return null===m?w("LP0802","response has the wrong shape"):m.boundary.id!==s.id||m.boundary.key!==s.key?w("LP0802","response is for another boundary"):m.revision!==a.revision?S:{status:"rendered",html:m.html,metadata:m.metadata}}finally{if(d.dispose(),void 0!==p&&!g)try{p.body?.cancel().catch(()=>{})}catch{}}}(l,u)),l.signal).catch(e=>{if(!p&&l.signal.aborted)return S;throw e});s.set(d,g);const m=()=>{s.get(d)===g&&s.delete(d)};return g.then(m,m),g}}var T=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",UnknownValueFormat:"LP0408",SanitizerDroppedAttribute:"LP0409",UnrenderedBlockKept:"LP0410",UnfaithfulPatch:"LP0411",ServerFormatReplaced:"LP0412",UnrenderedBlockLost:"LP0413",MessageRejected:"LP0501",TokenRejected:"LP0502",ProtocolShapeUnknown:"LP0503",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",HydrationWaitTimedOut:"LP0607",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708",FragmentRequestFailed:"LP0801",FragmentResponseInvalid:"LP0802",FragmentUnauthorized:"LP0803",FragmentSuperseded:"LP0804",RouteRefreshLoop:"LP0805",FragmentStrategyUnavailable:"LP0806",UnboundChangeRefresh:"LP0807",EscalationUnavailable:"LP0808",IslandStartUnavailable:"LP0809",RouteRefreshUnconfirmed:"LP0810",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),x=/* @__PURE__ */new Set(["open","value","checked","selected"]);function R(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function N(e,t,n){if(!F(e,t))return t;const r=n.boundary??o,i=r(e),a=r(t);if(i||a)return i&&a&&(n.retainBoundary?.(e,t)??1)?e:t;const s=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||x.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}(e,t),!0!==n.retainChildrenOf?.(e,t)&&function(e,t,n){const r=function(e,t){const n=/* @__PURE__ */new Map;let r;for(const o of Array.from(e.children)){const e=R(o,t);void 0!==e&&(n.has(e)?r??=e.slice(e.indexOf("=")+1):n.set(e,o))}return void 0!==r&&t.onDuplicateKey?.(e,r),n}(e,n),o=new Set(r.values()),i=Array.from(e.childNodes).filter(e=>!o.has(e)),a=/* @__PURE__ */new Set,s=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let u=e.firstChild,c=0;for(let t=0;t<l.length;t+=1){const o=l[t];let d=null,f=o instanceof Element?R(o,n):void 0;if(void 0!==f&&s.has(f)&&(f=void 0),void 0!==f){s.add(f);const e=r.get(f);if(void 0!==e&&!a.has(e)&&(d=O(e,o,n)===e?e:null,null===d)){e.replaceWith(o),a.add(o),u=o.nextSibling;continue}}else{for(;c<i.length;){const r=i[c];if(c+=1,!a.has(r)){if(F(r,o)){d=O(r,o,n)===r?r:null,null===d&&(e.replaceChild(o,r),a.add(o),u=o.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(o instanceof Element)||void 0!==n&&F(r,n)){c-=1;break}e.replaceChild(o,r),a.add(o),u=o.nextSibling;break}if(!(o instanceof Element)){e.replaceChild(o,r),a.add(o),u=o.nextSibling;break}}}if(null===d&&a.has(o))continue}const p=d??o;for(a.add(p);null!==u&&u!==p&&!a.has(u)&&k(u);)u=u.nextSibling;p!==u&&e.insertBefore(p,u),u=p.nextSibling}for(const t of Array.from(e.childNodes))a.has(t)||t.remove()}(e,t,n),function(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,r]=n??[null,null];null!==e&&null!==r&&t.setSelectionRange(e,r)}catch{}}(s),e}function O(e,t,n){return e instanceof Element&&t instanceof Element?N(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function k(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function F(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var C="data-payload-strategy",U="data-payload-field",M="x-payload-live-preview";function I(e){const t=e.getAttribute(C);return null!==t?"route"===t:null!==e.closest("head")}function $(e){const t=e.getAttribute(U),n=f(e.getAttribute("data-payload-depends"));return null===t||0===t.length?n:[t,...n]}function D(e){return!e.hasAttribute(r)&&("META"===e.tagName?e.hasAttribute("name")||e.hasAttribute("property"):"LINK"===e.tagName&&"canonical"===e.getAttribute("rel"))}function B(e){return{plan:(e,t)=>h(e,t).map(e=>e.element),async render(n,r){const o={rendered:0,failed:0,superseded:0},i={revision:n.revision,receivedAt:n.receivedAt,fields:n.fields,locale:n.locale,collectionSlug:n.collectionSlug,globalSlug:n.globalSlug,signal:n.signal};return await Promise.all(r.map(async r=>{const a=m(r);if(null===a)return;let s;try{s=await e(i,a)}catch(e){s={status:"failed",code:"LP0801",reason:t(e)}}return n.isCurrent()&&"superseded"!==s.status?"rendered"===s.status?(n.morph(r,s.html),n.rendered(r,a.id,a.key),void(o.rendered+=1)):(n.failed(r,a.id,a.key,s.code,s.reason),n.isCurrent()&&n.patch(r),void(o.failed+=1)):(o.superseded+=1,void n.log("LP0804",`fragment "${a.id}" for revision ${String(i.revision)} discarded as superseded`))})),o}}}exports.DIAGNOSTIC_CODES=T,exports.FRAGMENT_ATTRIBUTE=p,exports.FRAGMENT_KEY_ATTRIBUTE=g,exports.FRAGMENT_PROTOCOL_VERSION=1,exports.FRAGMENT_VERSION_HEADER=y,exports.ROUTE_REFRESH_HEADER=M,exports.collectFragmentBoundaries=h,exports.createFragmentHandler=E,exports.createFragmentStrategy=function(e){return B(E(e))},exports.createRouteStrategy=function(n={}){const i=n.timeoutMs??8e3,a=n.minIntervalMs??1e3;let s=-1/0,u=!1;return{plan(e,t,n){for(const r of e.querySelectorAll(`[${U}], [${C}="route"]`)){if(!I(r)||!1===n?.inScope(r))continue;const e=$(r);if(0===e.length||e.some(e=>t.has(e)))return!0}return!1},async refresh(c){const f=Date.now(),m=a-(f-s);if(m>0)return c.retryAfter?.(m),c.log("LP0805",`route refresh for revision ${String(c.revision)} refused: the previous one was ${String(f-s)} ms ago`),"refused";s=f;const h=n.document??document,y=n.location??location,b=n.window??window,v=e(c.signal,i),A=e=>{if(c.signal.aborted)return"superseded";const n=v.timedOut()?`route refresh timed out after ${String(i)} ms`:t(e);return c.log("LP0801",n),"failed"};try{const e=("undefined"==typeof window?void 0:window)?.__livePreviewRouteRefresh;if(void 0!==e){try{const t=e();"function"==typeof t?.then||u||(u=!0,c.log("LP0810","route refresh returned no promise; re-applied before the host committed (see LivePreviewRouteRefresh)")),await t}catch(e){return A(e)}return c.isCurrent()?"partial":"superseded"}let t;try{t=await(n.fetch??fetch)(y.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[M]:"route"},signal:v.signal})}catch(e){return A(e)}if(c.signal.aborted)return"superseded";if(!t.ok||!(t.headers.get("content-type")??"").includes("text/html"))return c.log("LP0802",`route answered ${String(t.status)} ${t.headers.get("content-type")??""}`),"failed";try{const e=await t.text();if(!c.isCurrent())return"superseded";const n=(new DOMParser).parseFromString(e,"text/html"),i=b.scrollX,a=b.scrollY;!function(e,t){const n=Array.from(e.head.children).find(e=>"TITLE"===e.tagName),o=Array.from(t.head.children).find(e=>"TITLE"===e.tagName);n?.hasAttribute(r)||o?.hasAttribute(r)||t.title===e.title||(e.title=t.title);const i=Array.from(e.head.children).filter(D),a=Array.from(t.head.children).filter(D),s=Math.min(i.length,a.length);i.slice(0,s).forEach((t,n)=>{const r=a[n];if(void 0===r)return;if(t.tagName===r.tagName){for(const e of Array.from(t.attributes))r.hasAttribute(e.name)||t.removeAttribute(e.name);for(const e of Array.from(r.attributes))t.getAttribute(e.name)!==e.value&&t.setAttribute(e.name,e.value);return}const o=e.importNode(r,!0);t.replaceWith(o),i[n]=o});let l=i.at(-1);for(const t of a.slice(i.length)){const n=e.importNode(t,!0);void 0===l?e.head.append(n):l.after(n),l=n}for(const e of i.slice(a.length))e.remove()}(h,n);const s=(L=h.body,Array.from(L.querySelectorAll("astro-island")));return N(h.body,n.body,{boundary:o,retainBoundary:d,keyAttributes:["data-payload-key",g,p],retainChildrenOf:e=>e.hasAttribute(p)}),function(e){for(const t of e)t.isConnected||l.has(t)||(l.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}(s),b.scrollTo(i,a),"partial"}catch(e){return A(e)}}finally{v.dispose()}var L}}},exports.describeBoundary=m,exports.fragmentStrategyFrom=B,exports.isRouteBound=I,exports.parseFragmentRequest=function(e,t=64){const n=function(e,t=64){if(!Number.isInteger(t)||t<0||t>64)return null;if(!v(e))return null;const n=e.fragment;if("string"!=typeof n||!/^[a-z][a-z0-9-]{0,63}$/iu.test(n))return null;const r=e.key;if(void 0!==r&&("string"!=typeof r||r.length>128))return null;const o=e.route;if("string"!=typeof o||!o.startsWith("/")||o.length>2048)return null;const i=e.search;if("string"!=typeof i||i.length>4096||""!==i&&!i.startsWith("?"))return null;const a=e.revision;if("number"!=typeof a||!Number.isInteger(a)||a<0)return null;const s=[];for(const t of["locale","collectionSlug","globalSlug"]){const n=e[t];if(void 0!==n){if("string"!=typeof n||n.length>128)return null;s.push(n)}else s.push(void 0)}const[l,u,c]=s,d=e.fields;return v(d)?b(d,0,t)>t?"field-depth":{fragment:n,..."string"==typeof r?{key:r}:{},route:o,search:i,revision:a,...void 0!==l?{locale:l}:{},...void 0!==u?{collectionSlug:u}:{},...void 0!==c?{globalSlug:c}:{},fields:d}:null}(e,t);return"field-depth"===n?null:n},exports.parseFragmentResponse=A,exports.resolveStrategy=function(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==function(e){return e.closest(`[${p}]`)}(e)?"fragment":null!==e.closest("head")?"route":"patch"};
|
|
2
2
|
//# sourceMappingURL=fragment.cjs.map
|