@wular/pnext 0.1.5 → 0.1.7
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/bin/pnext +9 -2
- package/dist/server/_chunks/aliases-j47a10ce.js +44 -0
- package/dist/server/_chunks/analyze-arswqe6s.js +445 -0
- package/dist/server/_chunks/boot-af0mv3dy.js +36 -0
- package/dist/server/_chunks/build-spy3dxp4.js +84 -0
- package/dist/server/_chunks/build-t9h0hec3.js +3550 -0
- package/dist/server/_chunks/build-tier-m7yvqz61.js +2472 -0
- package/dist/server/_chunks/compile-53j02j27.js +22 -0
- package/dist/server/_chunks/config-1yzwexq6.js +27 -0
- package/dist/server/_chunks/config-n2z7yxps.js +22 -0
- package/dist/server/_chunks/create-meec9hs6.js +134 -0
- package/dist/server/_chunks/dev-fjmqg6en.js +220 -0
- package/dist/server/_chunks/esbuild-yyktfrtt.js +15 -0
- package/dist/server/_chunks/generate-n9sh6hzt.js +21 -0
- package/dist/server/_chunks/index-0374j2b9.js +66 -0
- package/dist/server/_chunks/index-06nyqntx.js +213 -0
- package/dist/server/_chunks/index-1011cscr.js +5263 -0
- package/dist/server/_chunks/index-11sfk4hb.js +170 -0
- package/dist/server/_chunks/index-20ppawv7.js +297 -0
- package/dist/server/_chunks/index-2dv4y4wd.js +1065 -0
- package/dist/server/_chunks/index-2vz0wzdn.js +59 -0
- package/dist/server/_chunks/index-2wfv4kvx.js +182 -0
- package/dist/server/_chunks/index-357na4a8.js +109 -0
- package/dist/server/_chunks/index-3b3at80h.js +109 -0
- package/dist/server/_chunks/index-3tf1xjsp.js +6166 -0
- package/dist/server/_chunks/index-3xbr4eyv.js +105 -0
- package/dist/server/_chunks/index-4399bvd2.js +18 -0
- package/dist/server/_chunks/index-4hgjrqh7.js +851 -0
- package/dist/server/_chunks/index-4q2gbfwk.js +2530 -0
- package/dist/server/_chunks/index-4t92hdxd.js +172 -0
- package/dist/server/_chunks/index-4zzebszd.js +10 -0
- package/dist/server/_chunks/index-5gyr4emz.js +107 -0
- package/dist/server/_chunks/index-5hr4062s.js +70 -0
- package/dist/server/_chunks/index-68m3mwbd.js +84 -0
- package/dist/server/_chunks/index-6b009mt0.js +56 -0
- package/dist/server/_chunks/index-6e4fqv30.js +588 -0
- package/dist/server/_chunks/index-6gex3pfa.js +15 -0
- package/dist/server/_chunks/index-6kp9r0d9.js +11 -0
- package/dist/server/_chunks/index-6q7zvrap.js +134 -0
- package/dist/server/_chunks/index-73z4esab.js +38 -0
- package/dist/server/_chunks/index-79ngvam8.js +60 -0
- package/dist/server/_chunks/index-7wc9n8be.js +25 -0
- package/dist/server/_chunks/index-8k7pfejn.js +1599 -0
- package/dist/server/_chunks/index-8kcxdfya.js +206 -0
- package/dist/server/_chunks/index-91x12ykq.js +274 -0
- package/dist/server/_chunks/index-9ch50vtq.js +18 -0
- package/dist/server/_chunks/index-9hx2641q.js +28 -0
- package/dist/server/_chunks/index-9n2914ww.js +535 -0
- package/dist/server/_chunks/index-9ych9ma8.js +207 -0
- package/dist/server/_chunks/index-b6wtkdp4.js +24 -0
- package/dist/server/_chunks/index-bcws5eh2.js +35 -0
- package/dist/server/_chunks/index-c0g2wf3z.js +92 -0
- package/dist/server/_chunks/index-cf4rvxv6.js +95 -0
- package/dist/server/_chunks/index-cjgqs13g.js +65 -0
- package/dist/server/_chunks/index-ckkdpht5.js +41 -0
- package/dist/server/_chunks/index-cyfednwb.js +87 -0
- package/dist/server/_chunks/index-danncfhy.js +311 -0
- package/dist/server/_chunks/index-dg0f05zs.js +199 -0
- package/dist/server/_chunks/index-e3a6yx84.js +18 -0
- package/dist/server/_chunks/index-e88tyv35.js +45 -0
- package/dist/server/_chunks/index-eajaspjk.js +1253 -0
- package/dist/server/_chunks/index-eeaanp2e.js +483 -0
- package/dist/server/_chunks/index-egykcqg3.js +101 -0
- package/dist/server/_chunks/index-en7n9f7m.js +22 -0
- package/dist/server/_chunks/index-ezgj0tr1.js +88 -0
- package/dist/server/_chunks/index-fkp000p1.js +590 -0
- package/dist/server/_chunks/index-fn1chkkd.js +214 -0
- package/dist/server/_chunks/index-fp8r0sqs.js +64 -0
- package/dist/server/_chunks/index-ggk2j965.js +9432 -0
- package/dist/server/_chunks/index-grta8ap3.js +238 -0
- package/dist/server/_chunks/index-h2a70tg4.js +7 -0
- package/dist/server/_chunks/index-h4xy648y.js +51 -0
- package/dist/server/_chunks/index-hkdfj58q.js +92 -0
- package/dist/server/_chunks/index-j2zrcp1k.js +66 -0
- package/dist/server/_chunks/index-jcsjq3d1.js +20 -0
- package/dist/server/_chunks/index-jepjvcrf.js +198 -0
- package/dist/server/_chunks/index-jks0x0a1.js +14 -0
- package/dist/server/_chunks/index-jx7bqvw1.js +57 -0
- package/dist/server/_chunks/index-k1g3epw0.js +1299 -0
- package/dist/server/_chunks/index-knp0s912.js +7 -0
- package/dist/server/_chunks/index-kq8kpzye.js +472 -0
- package/dist/server/_chunks/index-kqyy1d4f.js +50 -0
- package/dist/server/_chunks/index-kresp2n8.js +445 -0
- package/dist/server/_chunks/index-ms9v9tnx.js +31 -0
- package/dist/server/_chunks/index-n4hxpng2.js +11 -0
- package/dist/server/_chunks/index-ncnes8c6.js +17 -0
- package/dist/server/_chunks/index-nqh3xhdc.js +57 -0
- package/dist/server/_chunks/index-nyrba2kr.js +4130 -0
- package/dist/server/_chunks/index-p77b4kcx.js +296 -0
- package/dist/server/_chunks/index-pym1cezq.js +39 -0
- package/dist/server/_chunks/index-q738kkhj.js +100 -0
- package/dist/server/_chunks/index-qjj6gddn.js +54 -0
- package/dist/server/_chunks/index-qm6kmhqs.js +110 -0
- package/dist/server/_chunks/index-qn4z5s3c.js +819 -0
- package/dist/server/_chunks/index-qpwsgt3a.js +158 -0
- package/dist/server/_chunks/index-r97ptz1q.js +97 -0
- package/dist/server/_chunks/index-ras0sdab.js +26 -0
- package/dist/server/_chunks/index-rcs322t1.js +19 -0
- package/dist/server/_chunks/index-rn8dyr1f.js +126 -0
- package/dist/server/_chunks/index-rt9qq1va.js +4 -0
- package/dist/server/_chunks/index-rthrsed5.js +356 -0
- package/dist/server/_chunks/index-sctcgyvv.js +185 -0
- package/dist/server/_chunks/index-sjpckxqn.js +213 -0
- package/dist/server/_chunks/index-sq3kvz3g.js +200 -0
- package/dist/server/_chunks/index-stbk3jhn.js +31 -0
- package/dist/server/_chunks/index-sv8m6789.js +266 -0
- package/dist/server/_chunks/index-tgcakdxc.js +125 -0
- package/dist/server/_chunks/index-tgsfjmep.js +74 -0
- package/dist/server/_chunks/index-tq0pc7eg.js +154 -0
- package/dist/server/_chunks/index-tq1f96v7.js +51 -0
- package/dist/server/_chunks/index-tqn2qnnn.js +241 -0
- package/dist/server/_chunks/index-tvqkq6e6.js +128 -0
- package/dist/server/_chunks/index-v1ags1na.js +132 -0
- package/dist/server/_chunks/index-vvmmknm1.js +1431 -0
- package/dist/server/_chunks/index-vvq7rqtn.js +329 -0
- package/dist/server/_chunks/index-vz0km5qk.js +33 -0
- package/dist/server/_chunks/index-w6h8m6vp.js +138 -0
- package/dist/server/_chunks/index-web361b8.js +138 -0
- package/dist/server/_chunks/index-wpfhfbs4.js +194 -0
- package/dist/server/_chunks/index-x0y005nh.js +283 -0
- package/dist/server/_chunks/index-x3yn4ywm.js +22 -0
- package/dist/server/_chunks/index-x93hv0sc.js +271 -0
- package/dist/server/_chunks/index-xvj80c3a.js +30 -0
- package/dist/server/_chunks/index-xywjg2vc.js +100 -0
- package/dist/server/_chunks/index-y2jr2n72.js +152 -0
- package/dist/server/_chunks/index-y36a0ybw.js +57 -0
- package/dist/server/_chunks/index-ye9hmsvf.js +47 -0
- package/dist/server/_chunks/index-yhxkxghe.js +56 -0
- package/dist/server/_chunks/index-ym67zqxp.js +130 -0
- package/dist/server/_chunks/index-ytjvpbm2.js +736 -0
- package/dist/server/_chunks/index-yz54pxrh.js +960 -0
- package/dist/server/_chunks/index-z4z9zv3b.js +733 -0
- package/dist/server/_chunks/index-z84ab1w0.js +1270 -0
- package/dist/server/_chunks/index-z88qv16t.js +11 -0
- package/dist/server/_chunks/index-zqpqyg8p.js +666 -0
- package/dist/server/_chunks/loader-7yw0j98z.js +78 -0
- package/dist/server/_chunks/modules-jn8bmbn8.js +74 -0
- package/dist/server/_chunks/pipeline-yy9jhydf.js +832 -0
- package/dist/server/_chunks/production-jar9ztm3.js +44 -0
- package/dist/server/_chunks/proxy-config-j84dgksn.js +21 -0
- package/dist/server/_chunks/proxy-w1d0wmsn.js +33 -0
- package/dist/server/_chunks/router-k1reahfn.js +498 -0
- package/dist/server/_chunks/routes-2s277fc6.js +64 -0
- package/dist/server/_chunks/run-pvd8bs1t.js +696 -0
- package/dist/server/_chunks/server-mt4a994c.js +1835 -0
- package/dist/server/_chunks/tsconfig-defaults-1nb3308g.js +20 -0
- package/dist/server/_chunks/typegen-0qr0459b.js +35 -0
- package/dist/server/api/client-cache.js +14 -0
- package/dist/server/cli/index.js +378 -0
- package/dist/server/cli/start.js +137 -0
- package/dist/server/client/reference.js +16 -0
- package/dist/server/compat/next/cache.js +56 -0
- package/dist/server/compat/next/canonical-url.js +13 -0
- package/dist/server/compat/next/client-cache.js +57 -0
- package/dist/server/compat/next/client-navigation.js +232 -0
- package/dist/server/compat/next/client-only.js +1 -0
- package/dist/server/compat/next/client-script.js +178 -0
- package/dist/server/compat/next/client-server.js +34 -0
- package/dist/server/compat/next/config-headers.js +32 -0
- package/dist/server/compat/next/config-loader.js +25 -0
- package/dist/server/compat/next/config.js +10 -0
- package/dist/server/compat/next/constants.js +18 -0
- package/dist/server/compat/next/custom-server.js +10 -0
- package/dist/server/compat/next/dist/client/components/app-router-headers.js +48 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/revalidate.js +27 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-cache.js +25 -0
- package/dist/server/compat/next/dist/server/web/spec-extension/unstable-no-store.js +25 -0
- package/dist/server/compat/next/dynamic.js +32 -0
- package/dist/server/compat/next/error.js +112 -0
- package/dist/server/compat/next/font/cache.js +14 -0
- package/dist/server/compat/next/font/google.js +3 -0
- package/dist/server/compat/next/font/index.js +1 -0
- package/dist/server/compat/next/font/local.js +22 -0
- package/dist/server/compat/next/font/runtime-client.js +33 -0
- package/dist/server/compat/next/font/runtime.js +41 -0
- package/dist/server/compat/next/font/shared.js +22 -0
- package/dist/server/compat/next/form.js +129 -0
- package/dist/server/compat/next/head.js +10 -0
- package/dist/server/compat/next/headers.js +30 -0
- package/dist/server/compat/next/image/client.js +11 -0
- package/dist/server/compat/next/image/config.js +18 -0
- package/dist/server/compat/next/image/optimizer.js +25 -0
- package/dist/server/compat/next/image/patterns.js +12 -0
- package/dist/server/compat/next/image/props.js +16 -0
- package/dist/server/compat/next/image/shared.js +86 -0
- package/dist/server/compat/next/image/static-metadata.js +32 -0
- package/dist/server/compat/next/image/validate.js +8 -0
- package/dist/server/compat/next/image.js +59 -0
- package/dist/server/compat/next/index.js +1 -0
- package/dist/server/compat/next/legacy-image.js +78 -0
- package/dist/server/compat/next/legacy-request-apis.js +24 -0
- package/dist/server/compat/next/link-transform.js +14 -0
- package/dist/server/compat/next/link.js +14 -0
- package/dist/server/compat/next/navigation.js +190 -0
- package/dist/server/compat/next/offline.js +45 -0
- package/dist/server/compat/next/og.js +8 -0
- package/dist/server/compat/next/preferred-region.js +8 -0
- package/dist/server/compat/next/redirects.js +30 -0
- package/dist/server/compat/next/resource-hints.js +30 -0
- package/dist/server/compat/next/rewrites.js +41 -0
- package/dist/server/compat/next/root-params.js +121 -0
- package/dist/server/compat/next/route-state.js +23 -0
- package/dist/server/compat/next/router.js +103 -0
- package/dist/server/compat/next/script.js +37 -0
- package/dist/server/compat/next/server-only.js +1 -0
- package/dist/server/compat/next/server.js +131 -0
- package/dist/server/compat/next/svgr.js +14 -0
- package/dist/server/compat/next/telemetry.js +10 -0
- package/dist/server/compat/next/usage.js +13 -0
- package/dist/server/compat/next/user-agent.js +12 -0
- package/dist/server/compat/next/web-vitals.js +35 -0
- package/dist/server/compat/react/action-state.js +11 -0
- package/dist/server/compat/react/client-lite.js +83 -0
- package/dist/server/compat/react/client.js +131 -0
- package/dist/server/compat/react/compiler-runtime.js +42 -0
- package/dist/server/compat/react/dom-client.js +106 -0
- package/dist/server/compat/react/dom-react-server.js +37 -0
- package/dist/server/compat/react/dom-server.js +40 -0
- package/dist/server/compat/react/dom.js +52 -0
- package/dist/server/compat/react/hooks-extra.js +12 -0
- package/dist/server/compat/react/internals.js +14 -0
- package/dist/server/compat/react/parity.js +11 -0
- package/dist/server/compat/react/preact.js +113 -0
- package/dist/server/compat/react/react-server.js +133 -0
- package/dist/server/compat/react/router-shim.js +8 -0
- package/dist/server/compat/react/server-component-use.js +14 -0
- package/dist/server/compat/react/server-inserted-html.js +14 -0
- package/dist/server/compat/react/server.js +194 -0
- package/dist/server/compat/react/style-values.js +10 -0
- package/dist/server/compat/react/use.js +10 -0
- package/dist/server/compat/react/view-transition.js +12 -0
- package/dist/server/generation.json +1 -0
- package/package.json +4 -1
- package/src/api/dynamic.tsx +2 -0
- package/src/api/server.ts +24 -6
- package/src/cli/adapters/vercel-warm.ts +315 -61
- package/src/cli/adapters/vercel.ts +348 -71
- package/src/cli/build.ts +58 -33
- package/src/cli/index.ts +23 -10
- package/src/cli/serve/entry.ts +21 -159
- package/src/cli/serve/immutable.ts +31 -0
- package/src/cli/serve/pipeline.ts +82 -84
- package/src/cli/start.ts +3 -1
- package/src/client/chunk-fold.ts +19 -6
- package/src/client/react-tier.ts +3 -2
- package/src/client/reference-stub.ts +21 -2
- package/src/compat/actions/client-plugin.ts +4 -2
- package/src/compat/actions/config.ts +6 -5
- package/src/compat/actions/extensions.ts +2 -3
- package/src/compat/aliases.ts +8 -1
- package/src/compat/bundler/config.ts +88 -0
- package/src/compat/bundler/optimize-package-imports.ts +86 -26
- package/src/compat/bundler/relay-transform.ts +15 -3
- package/src/compat/cache-control.ts +16 -8
- package/src/compat/css/modules.ts +18 -5
- package/src/compat/lifecycle/error-funnel.ts +1 -1
- package/src/compat/lifecycle/instrumentation.ts +117 -24
- package/src/compat/lifecycle/testmode.ts +3 -2
- package/src/compat/next/config-loader.ts +137 -13
- package/src/compat/next/font/runtime.ts +22 -2
- package/src/compat/next/og.ts +3 -3
- package/src/compat/next/usage.ts +3 -2
- package/src/compat/pages/api.ts +83 -14
- package/src/compat/pages/router.ts +30 -14
- package/src/compat/register/bundler.ts +3 -1
- package/src/compat/register/middleware.ts +1 -1
- package/src/compat/register/otel.ts +5 -9
- package/src/compat/register/render.ts +3 -1
- package/src/compat/register/use-cache.ts +3 -1
- package/src/compat/release.ts +46 -0
- package/src/compat/segment/serve.ts +1 -1
- package/src/compat/validation/validate.ts +10 -7
- package/src/config.ts +51 -7
- package/src/css/assets.ts +213 -0
- package/src/css/build.ts +174 -238
- package/src/dev/server.ts +27 -8
- package/src/extensions.ts +4 -0
- package/src/render/hooks.ts +13 -0
- package/src/render/renderer.ts +52 -32
- package/src/request/context.ts +9 -0
- package/src/resolve/dynamic.ts +3 -1
- package/src/resolve/imports.ts +12 -52
- package/src/resolve/package-json.ts +56 -0
- package/src/resolve/scan-facts.ts +65 -0
- package/src/routing/href.ts +10 -3
- package/src/routing/match.ts +287 -0
- package/src/routing/metadata-files.ts +19 -5
- package/src/routing/proxy-config.ts +137 -0
- package/src/routing/proxy.ts +35 -134
- package/src/routing/routes.ts +22 -281
- package/src/runtime/fingerprint.ts +23 -8
- package/src/runtime/load.ts +170 -0
- package/src/runtime/loader.ts +215 -43
- package/src/runtime/module-cache.ts +13 -0
- package/src/runtime/modules.ts +370 -81
- package/src/runtime/prebundle.ts +81 -0
- package/src/runtime/production.ts +391 -0
- package/src/runtime/release-graph.ts +334 -0
- package/src/runtime/vendor-build.ts +724 -13
- package/src/runtime/vendor.ts +16 -3
- package/src/types.ts +2 -0
- package/src/utils/fs.ts +89 -3
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/compat/next/image/props.ts
|
|
3
|
+
var DEFAULT_IMAGES_CONFIG = {
|
|
4
|
+
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
5
|
+
imageSizes: [32, 48, 64, 96, 128, 256, 384],
|
|
6
|
+
allSizes: [32, 48, 64, 96, 128, 256, 384, 640, 750, 828, 1080, 1200, 1920, 2048, 3840],
|
|
7
|
+
qualities: [75],
|
|
8
|
+
formats: ["image/webp"],
|
|
9
|
+
path: "/_next/image",
|
|
10
|
+
loader: "default",
|
|
11
|
+
loaderFile: "",
|
|
12
|
+
domains: [],
|
|
13
|
+
disableStaticImages: false,
|
|
14
|
+
minimumCacheTTL: 14400,
|
|
15
|
+
maximumRedirects: 3,
|
|
16
|
+
maximumResponseBody: 50000000,
|
|
17
|
+
dangerouslyAllowLocalIP: false,
|
|
18
|
+
dangerouslyAllowSVG: false,
|
|
19
|
+
contentSecurityPolicy: `script-src 'none'; frame-src 'none'; sandbox;`,
|
|
20
|
+
contentDispositionType: "attachment",
|
|
21
|
+
localPatterns: undefined,
|
|
22
|
+
remotePatterns: [],
|
|
23
|
+
unoptimized: false,
|
|
24
|
+
customCacheHandler: false
|
|
25
|
+
};
|
|
26
|
+
var INVALID_BACKGROUND_SIZE = new Set([
|
|
27
|
+
"-moz-initial",
|
|
28
|
+
"fill",
|
|
29
|
+
"none",
|
|
30
|
+
"scale-down",
|
|
31
|
+
undefined
|
|
32
|
+
]);
|
|
33
|
+
function unwrapStaticImport(src) {
|
|
34
|
+
return "default" in src ? src.default : src;
|
|
35
|
+
}
|
|
36
|
+
function toNumber(value) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
return;
|
|
39
|
+
if (typeof value === "number")
|
|
40
|
+
return value;
|
|
41
|
+
const n = parseInt(value, 10);
|
|
42
|
+
return Number.isNaN(n) ? undefined : n;
|
|
43
|
+
}
|
|
44
|
+
function getImagesConfig() {
|
|
45
|
+
return typeof __PNEXT_IMAGE_CONFIG_INLINED__ === "boolean" ? __PNEXT_IMAGE_CONFIG_INLINE__ : globalThis.__PNEXT_IMAGE_CONFIG__ ?? DEFAULT_IMAGES_CONFIG;
|
|
46
|
+
}
|
|
47
|
+
function defaultLoader(config, src, width, quality) {
|
|
48
|
+
const q = findClosestQuality(config, quality);
|
|
49
|
+
return `${config.path}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
50
|
+
}
|
|
51
|
+
function findClosestQuality(config, quality) {
|
|
52
|
+
const qualities = config.qualities;
|
|
53
|
+
if (!qualities || qualities.length === 0)
|
|
54
|
+
return quality ?? 75;
|
|
55
|
+
if (quality === undefined)
|
|
56
|
+
return closest(qualities, 75);
|
|
57
|
+
return closest(qualities, quality);
|
|
58
|
+
}
|
|
59
|
+
function closest(values, target) {
|
|
60
|
+
let best = values[0];
|
|
61
|
+
let bestDelta = Math.abs(best - target);
|
|
62
|
+
for (const value of values) {
|
|
63
|
+
const delta = Math.abs(value - target);
|
|
64
|
+
if (delta < bestDelta) {
|
|
65
|
+
best = value;
|
|
66
|
+
bestDelta = delta;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return best;
|
|
70
|
+
}
|
|
71
|
+
function getWidths(config, width, sizes) {
|
|
72
|
+
const { deviceSizes, allSizes } = config;
|
|
73
|
+
if (sizes) {
|
|
74
|
+
const viewportWidthRe = /(^|\s)(1?\d?\d)vw/g;
|
|
75
|
+
const percentSizes = [];
|
|
76
|
+
for (let match;match = viewportWidthRe.exec(sizes); ) {
|
|
77
|
+
percentSizes.push(parseInt(match[2], 10));
|
|
78
|
+
}
|
|
79
|
+
if (percentSizes.length) {
|
|
80
|
+
const smallestRatio = Math.min(...percentSizes) * 0.01;
|
|
81
|
+
return {
|
|
82
|
+
widths: allSizes.filter((s) => s >= deviceSizes[0] * smallestRatio),
|
|
83
|
+
kind: "w"
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { widths: allSizes, kind: "w" };
|
|
87
|
+
}
|
|
88
|
+
if (typeof width !== "number")
|
|
89
|
+
return { widths: deviceSizes, kind: "w" };
|
|
90
|
+
const widths = [
|
|
91
|
+
...new Set([width, width * 2].map((w) => allSizes.find((p) => p >= w) || allSizes[allSizes.length - 1]))
|
|
92
|
+
];
|
|
93
|
+
return { widths, kind: "x" };
|
|
94
|
+
}
|
|
95
|
+
function generateImgAttrs(params) {
|
|
96
|
+
const { config, src, unoptimized, width, quality, sizes, loader } = params;
|
|
97
|
+
if (unoptimized)
|
|
98
|
+
return { src, srcSet: undefined, sizes: undefined };
|
|
99
|
+
const { widths, kind } = getWidths(config, width, sizes);
|
|
100
|
+
const last = widths.length - 1;
|
|
101
|
+
return {
|
|
102
|
+
sizes: !sizes && kind === "w" ? "100vw" : sizes,
|
|
103
|
+
srcSet: widths.map((w, i) => `${loader({ config, src, quality, width: w })} ${kind === "w" ? w : i + 1}${kind}`).join(", "),
|
|
104
|
+
src: loader({ config, src, quality, width: widths[last] })
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function getImageBlurSvg(params) {
|
|
108
|
+
const { widthInt, heightInt, blurWidth, blurHeight, blurDataURL, objectFit } = params;
|
|
109
|
+
const std = 20;
|
|
110
|
+
const svgWidth = blurWidth ? blurWidth * 40 : widthInt;
|
|
111
|
+
const svgHeight = blurHeight ? blurHeight * 40 : heightInt;
|
|
112
|
+
const viewBox = svgWidth && svgHeight ? `viewBox='0 0 ${svgWidth} ${svgHeight}'` : "";
|
|
113
|
+
const preserveAspectRatio = viewBox ? "none" : objectFit === "contain" ? "xMidYMid" : objectFit === "cover" ? "xMidYMid slice" : "none";
|
|
114
|
+
return `%3Csvg xmlns='http://www.w3.org/2000/svg' ${viewBox}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='${std}'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='${std}'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${preserveAspectRatio}' style='filter: url(%23b);' href='${blurDataURL}'/%3E%3C/svg%3E`;
|
|
115
|
+
}
|
|
116
|
+
function getImageProps(imageProps) {
|
|
117
|
+
const resolved = resolveImageProps(imageProps, getImagesConfig());
|
|
118
|
+
return { props: resolved.props };
|
|
119
|
+
}
|
|
120
|
+
function unstable_getImgProps(imageProps) {
|
|
121
|
+
return getImageProps(imageProps);
|
|
122
|
+
}
|
|
123
|
+
function resolveImageProps(imageProps, config, blurComplete = false, showAltText = false) {
|
|
124
|
+
const {
|
|
125
|
+
src: rawSrc,
|
|
126
|
+
alt = "",
|
|
127
|
+
width: widthProp,
|
|
128
|
+
height: heightProp,
|
|
129
|
+
fill: fillProp = false,
|
|
130
|
+
loader,
|
|
131
|
+
quality: qualityProp,
|
|
132
|
+
priority = false,
|
|
133
|
+
preload = false,
|
|
134
|
+
loading,
|
|
135
|
+
placeholder = "empty",
|
|
136
|
+
blurDataURL: blurDataURLProp,
|
|
137
|
+
unoptimized: unoptimizedProp,
|
|
138
|
+
overrideSrc,
|
|
139
|
+
sizes: sizesProp,
|
|
140
|
+
fetchPriority,
|
|
141
|
+
decoding = "async",
|
|
142
|
+
style: styleProp,
|
|
143
|
+
layout,
|
|
144
|
+
objectFit,
|
|
145
|
+
objectPosition,
|
|
146
|
+
onLoad: _onLoad,
|
|
147
|
+
onError: _onError,
|
|
148
|
+
onLoadingComplete: _onLoadingComplete,
|
|
149
|
+
...rest
|
|
150
|
+
} = imageProps;
|
|
151
|
+
let fill = fillProp;
|
|
152
|
+
let sizes = sizesProp;
|
|
153
|
+
let userStyle = normalizeStyle(styleProp);
|
|
154
|
+
if (layout) {
|
|
155
|
+
if (layout === "fill")
|
|
156
|
+
fill = true;
|
|
157
|
+
const layoutStyle = layout === "intrinsic" ? { maxWidth: "100%", height: "auto" } : layout === "responsive" ? { width: "100%", height: "auto" } : undefined;
|
|
158
|
+
if (layoutStyle)
|
|
159
|
+
userStyle = { ...userStyle, ...layoutStyle };
|
|
160
|
+
if (!sizes && (layout === "responsive" || layout === "fill"))
|
|
161
|
+
sizes = "100vw";
|
|
162
|
+
}
|
|
163
|
+
const staticData = rawSrc && typeof rawSrc !== "string" ? unwrapStaticImport(rawSrc) : undefined;
|
|
164
|
+
const src = typeof rawSrc === "string" ? rawSrc : staticData?.src ?? "";
|
|
165
|
+
let width = toNumber(widthProp);
|
|
166
|
+
let height = toNumber(heightProp);
|
|
167
|
+
if (staticData) {
|
|
168
|
+
if (width === undefined && height === undefined) {
|
|
169
|
+
width = staticData.width;
|
|
170
|
+
height = staticData.height;
|
|
171
|
+
} else if (width !== undefined && height === undefined) {
|
|
172
|
+
height = Math.round(staticData.height / staticData.width * width);
|
|
173
|
+
} else if (height !== undefined && width === undefined) {
|
|
174
|
+
width = Math.round(staticData.width / staticData.height * height);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const blurDataURL = blurDataURLProp ?? staticData?.blurDataURL;
|
|
178
|
+
const quality = toNumber(qualityProp);
|
|
179
|
+
let unoptimized = Boolean(unoptimizedProp ?? config.unoptimized);
|
|
180
|
+
if (!src || src.startsWith("data:") || src.startsWith("blob:"))
|
|
181
|
+
unoptimized = true;
|
|
182
|
+
const isDefaultLoader = !loader && !config.loaderFile;
|
|
183
|
+
if (isDefaultLoader && !config.dangerouslyAllowSVG && (src.split("?", 1)[0] ?? "").endsWith(".svg")) {
|
|
184
|
+
unoptimized = true;
|
|
185
|
+
}
|
|
186
|
+
if (!unoptimized)
|
|
187
|
+
validateLocalSrc(config, src);
|
|
188
|
+
const activeLoader = loader ? ({ src: s, width: w, quality: q }) => loader({ src: s, width: w, quality: q }) : ({ config: c, src: s, width: w, quality: q }) => defaultLoader(c, s, w, q);
|
|
189
|
+
const imgAttrs = generateImgAttrs({
|
|
190
|
+
config,
|
|
191
|
+
src,
|
|
192
|
+
unoptimized,
|
|
193
|
+
width: fill ? undefined : width,
|
|
194
|
+
quality,
|
|
195
|
+
sizes,
|
|
196
|
+
loader: activeLoader
|
|
197
|
+
});
|
|
198
|
+
const isBlur = placeholder === "blur" && Boolean(blurDataURL);
|
|
199
|
+
const imgStyle = {
|
|
200
|
+
...fill ? { ...fillStyle(), objectFit, objectPosition } : {},
|
|
201
|
+
...showAltText ? {} : { color: "transparent" },
|
|
202
|
+
...userStyle
|
|
203
|
+
};
|
|
204
|
+
const objectFitVal = typeof imgStyle.objectFit === "string" ? imgStyle.objectFit : undefined;
|
|
205
|
+
const backgroundImage = !blurComplete && placeholder !== "empty" ? placeholder === "blur" ? (typeof __PNEXT_IMAGE_BLUR__ === "boolean" ? __PNEXT_IMAGE_BLUR__ : true) && blurDataURL ? `url("data:image/svg+xml;charset=utf-8,${getImageBlurSvg({
|
|
206
|
+
widthInt: fill ? undefined : width,
|
|
207
|
+
heightInt: fill ? undefined : height,
|
|
208
|
+
blurWidth: staticData?.blurWidth,
|
|
209
|
+
blurHeight: staticData?.blurHeight,
|
|
210
|
+
blurDataURL,
|
|
211
|
+
objectFit: objectFitVal
|
|
212
|
+
})}")` : undefined : `url("${placeholder}")` : undefined;
|
|
213
|
+
let backgroundSize = "cover";
|
|
214
|
+
if (objectFitVal === "fill")
|
|
215
|
+
backgroundSize = "100% 100%";
|
|
216
|
+
else if (objectFitVal && !INVALID_BACKGROUND_SIZE.has(objectFitVal))
|
|
217
|
+
backgroundSize = objectFitVal;
|
|
218
|
+
const placeholderStyle = backgroundImage ? {
|
|
219
|
+
backgroundSize,
|
|
220
|
+
backgroundPosition: imgStyle.objectPosition || "50% 50%",
|
|
221
|
+
backgroundRepeat: "no-repeat",
|
|
222
|
+
backgroundImage
|
|
223
|
+
} : {};
|
|
224
|
+
const style = serializeStyle({ ...imgStyle, ...placeholderStyle });
|
|
225
|
+
const resolvedSrc = (overrideSrc ?? imgAttrs.src) || undefined;
|
|
226
|
+
const props = {
|
|
227
|
+
...rest,
|
|
228
|
+
alt,
|
|
229
|
+
...resolvedSrc !== undefined ? { src: resolvedSrc } : {},
|
|
230
|
+
...imgAttrs.srcSet ? { srcSet: imgAttrs.srcSet } : {},
|
|
231
|
+
...imgAttrs.sizes ? { sizes: imgAttrs.sizes } : {},
|
|
232
|
+
decoding,
|
|
233
|
+
style
|
|
234
|
+
};
|
|
235
|
+
if (!fill) {
|
|
236
|
+
if (width !== undefined)
|
|
237
|
+
props.width = width;
|
|
238
|
+
if (height !== undefined)
|
|
239
|
+
props.height = height;
|
|
240
|
+
}
|
|
241
|
+
if (loading !== undefined)
|
|
242
|
+
props.loading = loading;
|
|
243
|
+
else if (!priority && !preload)
|
|
244
|
+
props.loading = "lazy";
|
|
245
|
+
if (fetchPriority !== undefined)
|
|
246
|
+
props.fetchpriority = fetchPriority;
|
|
247
|
+
return {
|
|
248
|
+
props,
|
|
249
|
+
meta: {
|
|
250
|
+
preload: preload || priority,
|
|
251
|
+
fill,
|
|
252
|
+
unoptimized,
|
|
253
|
+
placeholder: isBlur ? "blur" : String(placeholder),
|
|
254
|
+
imgAttributes: {
|
|
255
|
+
src: resolvedSrc ?? "",
|
|
256
|
+
...imgAttrs.srcSet ? { srcSet: imgAttrs.srcSet } : {},
|
|
257
|
+
...imgAttrs.sizes ? { sizes: imgAttrs.sizes } : {}
|
|
258
|
+
},
|
|
259
|
+
...backgroundImage ? { loadedStyle: serializeStyle(imgStyle) } : {}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function normalizeStyle(style) {
|
|
264
|
+
if (!style)
|
|
265
|
+
return {};
|
|
266
|
+
if (typeof style !== "string")
|
|
267
|
+
return { ...style };
|
|
268
|
+
const out = {};
|
|
269
|
+
for (const decl of style.split(";")) {
|
|
270
|
+
const [k, v] = decl.split(":");
|
|
271
|
+
if (k && v)
|
|
272
|
+
out[camel(k.trim())] = v.trim();
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
function fillStyle() {
|
|
277
|
+
return {
|
|
278
|
+
position: "absolute",
|
|
279
|
+
height: "100%",
|
|
280
|
+
width: "100%",
|
|
281
|
+
left: "0",
|
|
282
|
+
top: "0",
|
|
283
|
+
right: "0",
|
|
284
|
+
bottom: "0"
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function validateLocalSrc(config, src) {
|
|
288
|
+
if (!src.startsWith("/") || src.startsWith("//") || config.localPatterns !== undefined)
|
|
289
|
+
return;
|
|
290
|
+
const search = new URL(src, "http://n").search;
|
|
291
|
+
if (!search)
|
|
292
|
+
return;
|
|
293
|
+
throw new Error(`Image with src "${src}" is using a query string which is not configured in images.localPatterns.
|
|
294
|
+
Read more: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`);
|
|
295
|
+
}
|
|
296
|
+
function camel(prop) {
|
|
297
|
+
return prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
298
|
+
}
|
|
299
|
+
var UNITLESS_STYLE_PROPS = new Set([
|
|
300
|
+
"animationIterationCount",
|
|
301
|
+
"aspectRatio",
|
|
302
|
+
"borderImageOutset",
|
|
303
|
+
"borderImageSlice",
|
|
304
|
+
"borderImageWidth",
|
|
305
|
+
"boxFlex",
|
|
306
|
+
"boxFlexGroup",
|
|
307
|
+
"boxOrdinalGroup",
|
|
308
|
+
"columnCount",
|
|
309
|
+
"columns",
|
|
310
|
+
"flex",
|
|
311
|
+
"flexGrow",
|
|
312
|
+
"flexPositive",
|
|
313
|
+
"flexShrink",
|
|
314
|
+
"flexNegative",
|
|
315
|
+
"flexOrder",
|
|
316
|
+
"gridArea",
|
|
317
|
+
"gridRow",
|
|
318
|
+
"gridRowEnd",
|
|
319
|
+
"gridRowSpan",
|
|
320
|
+
"gridRowStart",
|
|
321
|
+
"gridColumn",
|
|
322
|
+
"gridColumnEnd",
|
|
323
|
+
"gridColumnSpan",
|
|
324
|
+
"gridColumnStart",
|
|
325
|
+
"fontWeight",
|
|
326
|
+
"lineClamp",
|
|
327
|
+
"lineHeight",
|
|
328
|
+
"opacity",
|
|
329
|
+
"order",
|
|
330
|
+
"orphans",
|
|
331
|
+
"tabSize",
|
|
332
|
+
"widows",
|
|
333
|
+
"zIndex",
|
|
334
|
+
"zoom",
|
|
335
|
+
"fillOpacity",
|
|
336
|
+
"floodOpacity",
|
|
337
|
+
"stopOpacity",
|
|
338
|
+
"strokeDasharray",
|
|
339
|
+
"strokeDashoffset",
|
|
340
|
+
"strokeMiterlimit",
|
|
341
|
+
"strokeOpacity",
|
|
342
|
+
"strokeWidth"
|
|
343
|
+
]);
|
|
344
|
+
function serializeStyle(style) {
|
|
345
|
+
return Object.entries(style).filter(([, v]) => v !== undefined && v !== "").map(([k, v]) => `${kebab(k)}:${cssValue(k, v)}`).join(";");
|
|
346
|
+
}
|
|
347
|
+
function cssValue(prop, value) {
|
|
348
|
+
if (typeof value === "number" && value !== 0 && !UNITLESS_STYLE_PROPS.has(prop))
|
|
349
|
+
return `${value}px`;
|
|
350
|
+
return String(value);
|
|
351
|
+
}
|
|
352
|
+
function kebab(prop) {
|
|
353
|
+
return prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export { getImagesConfig, findClosestQuality, getImageProps, unstable_getImgProps, resolveImageProps };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
assertDraftModeToggleAllowedInAfter,
|
|
4
|
+
assertRequestApiAllowedInAfter,
|
|
5
|
+
lifecycleError
|
|
6
|
+
} from "./index-2vz0wzdn.js";
|
|
7
|
+
import {
|
|
8
|
+
withSyncAccess
|
|
9
|
+
} from "./index-0374j2b9.js";
|
|
10
|
+
import {
|
|
11
|
+
assertNoDynamicApiInsideCache,
|
|
12
|
+
currentRenderCacheMeta
|
|
13
|
+
} from "./index-9n2914ww.js";
|
|
14
|
+
import {
|
|
15
|
+
currentRequest,
|
|
16
|
+
currentResponseHeaders,
|
|
17
|
+
getWorkUnit,
|
|
18
|
+
legacyRequestAPIs,
|
|
19
|
+
requestApiPromise,
|
|
20
|
+
requireRequest
|
|
21
|
+
} from "./index-grta8ap3.js";
|
|
22
|
+
|
|
23
|
+
// src/compat/next/headers.ts
|
|
24
|
+
var COOKIE_MUTATION_ERROR = "Cookies can only be modified in a Server Action or Route Handler. " + "Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options";
|
|
25
|
+
function assertCookieMutationAllowed() {
|
|
26
|
+
const unit = getWorkUnit();
|
|
27
|
+
if (!unit)
|
|
28
|
+
return;
|
|
29
|
+
if (unit.phase === "action")
|
|
30
|
+
return;
|
|
31
|
+
if (unit.phase !== "after" && unit.routeKind === "route-handler")
|
|
32
|
+
return;
|
|
33
|
+
throw new Error(COOKIE_MUTATION_ERROR);
|
|
34
|
+
}
|
|
35
|
+
var HEADERS_MUTATION_ERROR = "Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers";
|
|
36
|
+
function readonlyHeaders(source) {
|
|
37
|
+
return new Proxy(source, {
|
|
38
|
+
get(target, prop) {
|
|
39
|
+
if (prop === "append" || prop === "set" || prop === "delete") {
|
|
40
|
+
return () => {
|
|
41
|
+
throw new Error(HEADERS_MUTATION_ERROR);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (prop === "getSetCookie")
|
|
45
|
+
return () => [];
|
|
46
|
+
const value = Reflect.get(target, prop, target);
|
|
47
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function headers() {
|
|
52
|
+
assertRequestApiAllowedInAfter("headers()");
|
|
53
|
+
assertDynamicErrorRequestApi("headers()");
|
|
54
|
+
assertNoDynamicApiInsideCache("headers()");
|
|
55
|
+
const produce = () => readonlyHeaders(new Headers(requireRequest("headers()").headers));
|
|
56
|
+
const promise = requestApiPromise("headers()", produce);
|
|
57
|
+
return legacyRequestAPIs() ? withSyncAccess(promise, "headers", produce) : promise;
|
|
58
|
+
}
|
|
59
|
+
function cookies() {
|
|
60
|
+
assertRequestApiAllowedInAfter("cookies()");
|
|
61
|
+
assertDynamicErrorRequestApi("cookies()");
|
|
62
|
+
assertNoDynamicApiInsideCache("cookies()");
|
|
63
|
+
const produce = () => wrapCookieJar(requireRequest("cookies()").cookies);
|
|
64
|
+
const promise = requestApiPromise("cookies()", produce);
|
|
65
|
+
return legacyRequestAPIs() ? withSyncAccess(promise, "cookies", produce) : promise;
|
|
66
|
+
}
|
|
67
|
+
function assertDynamicErrorRequestApi(api) {
|
|
68
|
+
const meta = currentRenderCacheMeta();
|
|
69
|
+
if (!meta?.dynamicError)
|
|
70
|
+
return;
|
|
71
|
+
throw lifecycleError(`Route ${meta.route ?? ""} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${api}\`.`);
|
|
72
|
+
}
|
|
73
|
+
function wrapCookieJar(jar) {
|
|
74
|
+
return {
|
|
75
|
+
get: (name) => jar.get(cookieName(name)),
|
|
76
|
+
getAll: (name) => name === undefined ? jar.getAll() : jar.getAll(cookieName(name)),
|
|
77
|
+
has: (name) => jar.has(cookieName(name)),
|
|
78
|
+
get size() {
|
|
79
|
+
return jar.getAll().length;
|
|
80
|
+
},
|
|
81
|
+
[Symbol.iterator]() {
|
|
82
|
+
return jar.getAll().map((cookie) => [cookie.name, cookie])[Symbol.iterator]();
|
|
83
|
+
},
|
|
84
|
+
set(nameOrOptions, value, options) {
|
|
85
|
+
assertCookieMutationAllowed();
|
|
86
|
+
const parsed = normalizeSetArgs(nameOrOptions, value, options);
|
|
87
|
+
jar.set(parsed.name, parsed.value);
|
|
88
|
+
currentResponseHeaders()?.append("set-cookie", serializeSetCookie(parsed));
|
|
89
|
+
return this;
|
|
90
|
+
},
|
|
91
|
+
delete(name) {
|
|
92
|
+
assertCookieMutationAllowed();
|
|
93
|
+
const resolved = cookieName(name);
|
|
94
|
+
const existed = jar.delete(resolved);
|
|
95
|
+
currentResponseHeaders()?.append("set-cookie", serializeSetCookie({ name: resolved, value: "", path: "/", maxAge: 0 }));
|
|
96
|
+
return existed;
|
|
97
|
+
},
|
|
98
|
+
clear() {
|
|
99
|
+
for (const cookie of jar.getAll())
|
|
100
|
+
this.delete(cookie.name);
|
|
101
|
+
return this;
|
|
102
|
+
},
|
|
103
|
+
toString() {
|
|
104
|
+
return jar.getAll().map((cookie) => `${cookie.name}=${encodeURIComponent(cookie.value)}`).join("; ");
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function cookieName(arg) {
|
|
109
|
+
if (typeof arg === "string")
|
|
110
|
+
return arg;
|
|
111
|
+
return typeof arg?.name === "string" ? arg.name : "";
|
|
112
|
+
}
|
|
113
|
+
function normalizeSetArgs(nameOrOptions, value, options) {
|
|
114
|
+
if (typeof nameOrOptions === "string") {
|
|
115
|
+
return { ...options ?? {}, name: nameOrOptions, value: stringifyCookieValue(value) };
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
...nameOrOptions,
|
|
119
|
+
name: String(nameOrOptions.name ?? ""),
|
|
120
|
+
value: String(nameOrOptions.value ?? "")
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function stringifyCookieValue(raw) {
|
|
124
|
+
if (raw === undefined || raw === null)
|
|
125
|
+
return "";
|
|
126
|
+
if (typeof raw === "string")
|
|
127
|
+
return raw;
|
|
128
|
+
if (typeof raw === "number" || typeof raw === "boolean" || typeof raw === "bigint") {
|
|
129
|
+
return String(raw);
|
|
130
|
+
}
|
|
131
|
+
return JSON.stringify(raw) ?? "";
|
|
132
|
+
}
|
|
133
|
+
function serializeSetCookie(cookie) {
|
|
134
|
+
const parts = [`${cookie.name}=${encodeURIComponent(cookie.value)}`];
|
|
135
|
+
parts.push(`Path=${cookie.path ?? "/"}`);
|
|
136
|
+
if (cookie.maxAge !== undefined)
|
|
137
|
+
parts.push(`Max-Age=${cookie.maxAge}`);
|
|
138
|
+
if (cookie.expires !== undefined) {
|
|
139
|
+
const date = cookie.expires instanceof Date ? cookie.expires : new Date(cookie.expires);
|
|
140
|
+
parts.push(`Expires=${date.toUTCString()}`);
|
|
141
|
+
}
|
|
142
|
+
if (cookie.domain)
|
|
143
|
+
parts.push(`Domain=${cookie.domain}`);
|
|
144
|
+
if (cookie.httpOnly)
|
|
145
|
+
parts.push("HttpOnly");
|
|
146
|
+
if (cookie.secure)
|
|
147
|
+
parts.push("Secure");
|
|
148
|
+
if (cookie.sameSite) {
|
|
149
|
+
const value = cookie.sameSite === true ? "Strict" : capitalize(cookie.sameSite);
|
|
150
|
+
parts.push(`SameSite=${value}`);
|
|
151
|
+
}
|
|
152
|
+
return parts.join("; ");
|
|
153
|
+
}
|
|
154
|
+
function capitalize(value) {
|
|
155
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
156
|
+
}
|
|
157
|
+
var draftCookieName = "__prerender_bypass";
|
|
158
|
+
function draftMode() {
|
|
159
|
+
const request = currentRequest();
|
|
160
|
+
const requestCookies = request?.cookies;
|
|
161
|
+
const draft = {
|
|
162
|
+
get isEnabled() {
|
|
163
|
+
return requestCookies?.has(draftCookieName) ?? false;
|
|
164
|
+
},
|
|
165
|
+
enable() {
|
|
166
|
+
assertDraftModeToggleAllowedInAfter("enable");
|
|
167
|
+
const cookies2 = requireRequest("draftMode().enable()").cookies;
|
|
168
|
+
const value = cookies2.get(draftCookieName)?.value || bypassToken();
|
|
169
|
+
cookies2.set(draftCookieName, value);
|
|
170
|
+
currentResponseHeaders()?.append("set-cookie", `${draftCookieName}=${value}; Path=/; HttpOnly; SameSite=None; Secure`);
|
|
171
|
+
},
|
|
172
|
+
disable() {
|
|
173
|
+
assertDraftModeToggleAllowedInAfter("disable");
|
|
174
|
+
requireRequest("draftMode().disable()").cookies.delete(draftCookieName);
|
|
175
|
+
currentResponseHeaders()?.append("set-cookie", `${draftCookieName}=; Path=/; Max-Age=0; HttpOnly; SameSite=None; Secure`);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const promise = Promise.resolve(draft);
|
|
179
|
+
return legacyRequestAPIs() ? withSyncAccess(promise, "draftMode", () => draft) : promise;
|
|
180
|
+
}
|
|
181
|
+
function bypassToken() {
|
|
182
|
+
return globalThis.crypto?.randomUUID?.().replace(/-/g, "") ?? Math.random().toString(36).slice(2);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export { headers, cookies, assertDynamicErrorRequestApi, draftMode };
|