@serwist/turbopack 9.5.8 → 9.5.9
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/chunks/index.schema-RVDaKxz4.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.react.d.mts +2 -2
- package/dist/index.react.d.mts.map +1 -1
- package/dist/index.react.mjs +109 -46
- package/dist/index.react.mjs.map +1 -1
- package/dist/index.worker.mjs.map +1 -1
- package/package.json +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.schema-RVDaKxz4.js","names":["z"],"sources":["../../src/lib/constants.ts","../../src/lib/logger.ts","../../src/lib/utils.ts","../../src/index.schema.ts"],"sourcesContent":["import type { BuildOptions } from \"esbuild-wasm\";\n\nexport const SUPPORTED_ESBUILD_OPTIONS = [\n // CommonOptions\n \"sourcemap\",\n \"legalComments\",\n \"sourceRoot\",\n \"sourcesContent\",\n \"format\",\n \"globalName\",\n \"target\",\n \"supported\",\n \"define\",\n \"treeShaking\",\n \"minify\",\n \"mangleProps\",\n \"reserveProps\",\n \"mangleQuoted\",\n \"mangleCache\",\n \"drop\",\n \"dropLabels\",\n \"minifyWhitespace\",\n \"minifyIdentifiers\",\n \"minifySyntax\",\n \"lineLimit\",\n \"charset\",\n \"ignoreAnnotations\",\n \"jsx\",\n \"jsxFactory\",\n \"jsxFragment\",\n \"jsxImportSource\",\n \"jsxDev\",\n \"jsxSideEffects\",\n \"pure\",\n \"keepNames\",\n \"absPaths\",\n \"color\",\n \"logLevel\",\n \"logLimit\",\n \"logOverride\",\n \"tsconfigRaw\",\n // BuildOptions\n \"bundle\",\n \"splitting\",\n \"preserveSymlinks\",\n \"external\",\n \"packages\",\n \"alias\",\n \"loader\",\n \"resolveExtensions\",\n \"mainFields\",\n \"conditions\",\n \"allowOverwrite\",\n \"tsconfig\",\n \"outExtension\",\n \"publicPath\",\n \"inject\",\n \"banner\",\n \"footer\",\n \"plugins\",\n] as const satisfies readonly (keyof BuildOptions)[];\n","import { createRequire } from \"node:module\";\nimport { bold, green, red, white, yellow } from \"kolorist\";\nimport semver from \"semver\";\n\nconst require = createRequire(import.meta.url);\n\nexport const NEXT_VERSION = require(\"next/package.json\").version as string;\n\nconst LOGGING_SPACE_PREFIX = semver.gte(NEXT_VERSION, \"16.0.0\") ? \"\" : \" \";\n\nexport type LoggingMethods = \"wait\" | \"error\" | \"warn\" | \"info\" | \"event\";\n\nconst prefixedLog = (prefixType: LoggingMethods, ...message: any[]) => {\n let prefix: string;\n let consoleMethod: keyof Console;\n\n switch (prefixType) {\n case \"wait\":\n prefix = `${white(bold(\"○\"))} (serwist)`;\n consoleMethod = \"log\";\n break;\n case \"error\":\n prefix = `${red(bold(\"X\"))} (serwist)`;\n consoleMethod = \"error\";\n break;\n case \"warn\":\n prefix = `${yellow(bold(\"⚠\"))} (serwist)`;\n consoleMethod = \"warn\";\n break;\n case \"info\":\n prefix = `${white(bold(\"○\"))} (serwist)`;\n consoleMethod = \"log\";\n break;\n case \"event\":\n prefix = `${green(bold(\"✓\"))} (serwist)`;\n consoleMethod = \"log\";\n break;\n }\n\n if ((message[0] === \"\" || message[0] === undefined) && message.length === 1) {\n message.shift();\n }\n\n // If there's no message, don't print the prefix but a new line\n if (message.length === 0) {\n console[consoleMethod](\"\");\n } else {\n console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);\n }\n};\n\nexport const wait = (...message: any[]) => prefixedLog(\"wait\", ...message);\n\nexport const error = (...message: any[]) => prefixedLog(\"error\", ...message);\n\nexport const warn = (...message: any[]) => prefixedLog(\"warn\", ...message);\n\nexport const info = (...message: any[]) => prefixedLog(\"info\", ...message);\n\nexport const event = (...message: any[]) => prefixedLog(\"event\", ...message);\n","import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from \"next/constants.js\";\n\nexport const loadNextConfig = async (cwd: string, isDev: boolean) => {\n const nextPhase = isDev ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;\n // webpackIgnore is only supported by Next.js 15 and above, but it is necessary\n // for loading `next/dist/server/config.js`.\n const nextConfig = await import(/* webpackIgnore: true */ \"next/dist/server/config.js\");\n // 1) what does `default.default` even mean\n const loadConfig =\n typeof nextConfig.default === \"function\" ? (nextConfig.default as unknown as typeof nextConfig.default.default) : nextConfig.default.default;\n return loadConfig(nextPhase, cwd, { silent: false });\n};\n\nexport const generateGlobPatterns = (distDir: string) => [\n `${distDir}static/**/*.{js,css,html,ico,apng,png,avif,jpg,jpeg,jfif,pjpeg,pjp,gif,svg,webp,json,webmanifest}`,\n \"public/**/*\",\n];\n","import path from \"node:path\";\nimport { assertType, basePartial, type Equals, globPartial, injectPartial } from \"@serwist/build/schema\";\nimport semver from \"semver\";\nimport z from \"zod\";\nimport { SUPPORTED_ESBUILD_OPTIONS } from \"./lib/constants.js\";\nimport { NEXT_VERSION } from \"./lib/logger.js\";\nimport { generateGlobPatterns, loadNextConfig } from \"./lib/utils.js\";\nimport type { InjectManifestOptions, InjectManifestOptionsComplete, TurboPartial, TurboResolved } from \"./types.js\";\n\nexport const turboPartial = z.strictObject({\n cwd: z.string().prefault(process.cwd()),\n nextConfig: z\n .object({\n assetPrefix: z.string().optional(),\n basePath: z.string().optional(),\n distDir: z.string().optional(),\n })\n .optional(),\n useNativeEsbuild: z.boolean().prefault(process.platform === \"win32\"),\n rebuildOnChange: z.boolean().prefault(true),\n esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({}),\n});\n\nexport const injectManifestOptions = z\n .strictObject({\n ...basePartial.shape,\n ...globPartial.shape,\n ...injectPartial.shape,\n ...turboPartial.shape,\n globPatterns: z.array(z.string()).optional(),\n globDirectory: z.string().optional(),\n })\n .omit({ disablePrecacheManifest: true })\n .transform(async (input) => {\n // TODO: remove in semver check in Serwist 10\n // webpackIgnore is only supported by Next.js 15 and above, but it is necessary\n // for loading `next/dist/server/config.js`.\n const nextConfig = semver.gte(NEXT_VERSION, \"15.0.0\")\n ? {\n ...(await loadNextConfig(input.cwd, process.env.NODE_ENV === \"development\")),\n ...input.nextConfig,\n }\n : {\n distDir: input.nextConfig?.distDir ?? \".next\",\n basePath: input.nextConfig?.basePath ?? \"/\",\n assetPrefix: input.nextConfig?.assetPrefix ?? input.nextConfig?.basePath ?? \"\",\n };\n let distDir = nextConfig.distDir;\n if (distDir[0] === \"/\") distDir = distDir.slice(1);\n if (distDir[distDir.length - 1] !== \"/\") distDir += \"/\";\n return {\n ...input,\n swSrc: path.isAbsolute(input.swSrc) ? input.swSrc : path.join(input.cwd, input.swSrc),\n globPatterns: input.globPatterns ?? generateGlobPatterns(distDir),\n globDirectory: input.globDirectory ?? input.cwd,\n dontCacheBustURLsMatching: input.dontCacheBustURLsMatching ?? new RegExp(`^${distDir}static/`),\n nextConfig: {\n ...nextConfig,\n distDir,\n // Next.js, by default, set `basePath` to an empty string.\n basePath: nextConfig.basePath || \"/\",\n },\n };\n });\n\nassertType<Equals<TurboPartial, z.input<typeof turboPartial>>>();\nassertType<Equals<TurboResolved, z.output<typeof turboPartial>>>();\nassertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();\nassertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAa,4BAA4B;CAEvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;ACtDD,MAAa,eAFG,cAAc,OAAO,KAAK,IAEd,CAAQ,oBAAoB,CAAC;AAEzD,MAAM,uBAAuB,OAAO,I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AM,MAAM,GAAG,MAAM,QAAQ,KAAK,KAAK,MAAM,KAAK,MAAM,MAAM;EACrF,cAAc,MAAM,gBAAgB,qBAAqB,QAAQ;EACjE,eAAe,MAAM,iBAAiB,MAAM;EAC5C,2BAA2B,MAAM,6BAA6B,IAAI,OAAO,IAAI,QAAQ,SAAS;EAC9F,YAAY;GACV,GAAG;GACH;GAEA,UAAU,WAAW,YAAY;GAClC;EACF;EACD;AAEJ,YAAgE;AAChE,YAAkE;AAClE,YAAkF;AAClF,YAA2F"}
|
|
1
|
+
{"version":3,"file":"index.schema-RVDaKxz4.js","names":["BuildOptions","SUPPORTED_ESBUILD_OPTIONS","const","createRequire","bold","green","red","white","yellow","semver","require","import","meta","url","NEXT_VERSION","version","LOGGING_SPACE_PREFIX","gte","LoggingMethods","prefixedLog","prefixType","message","prefix","consoleMethod","Console","undefined","length","shift","console","wait","error","warn","info","event","PHASE_DEVELOPMENT_SERVER","PHASE_PRODUCTION_BUILD","loadNextConfig","cwd","isDev","nextPhase","nextConfig","loadConfig","default","silent","generateGlobPatterns","distDir","path","assertType","basePartial","Equals","globPartial","injectPartial","semver","z","SUPPORTED_ESBUILD_OPTIONS","NEXT_VERSION","generateGlobPatterns","loadNextConfig","InjectManifestOptions","InjectManifestOptionsComplete","TurboPartial","TurboResolved","turboPartial","strictObject","cwd","string","prefault","process","nextConfig","object","assetPrefix","optional","basePath","distDir","useNativeEsbuild","boolean","platform","rebuildOnChange","esbuildOptions","partialRecord","literal","any","injectManifestOptions","shape","globPatterns","array","globDirectory","omit","disablePrecacheManifest","transform","input","gte","env","NODE_ENV","slice","length","swSrc","isAbsolute","join","dontCacheBustURLsMatching","RegExp","output"],"sources":["../../src/lib/constants.ts","../../src/lib/logger.ts","../../src/lib/utils.ts","../../src/index.schema.ts"],"sourcesContent":["import type { BuildOptions } from \"esbuild-wasm\";\n\nexport const SUPPORTED_ESBUILD_OPTIONS = [\n // CommonOptions\n \"sourcemap\",\n \"legalComments\",\n \"sourceRoot\",\n \"sourcesContent\",\n \"format\",\n \"globalName\",\n \"target\",\n \"supported\",\n \"define\",\n \"treeShaking\",\n \"minify\",\n \"mangleProps\",\n \"reserveProps\",\n \"mangleQuoted\",\n \"mangleCache\",\n \"drop\",\n \"dropLabels\",\n \"minifyWhitespace\",\n \"minifyIdentifiers\",\n \"minifySyntax\",\n \"lineLimit\",\n \"charset\",\n \"ignoreAnnotations\",\n \"jsx\",\n \"jsxFactory\",\n \"jsxFragment\",\n \"jsxImportSource\",\n \"jsxDev\",\n \"jsxSideEffects\",\n \"pure\",\n \"keepNames\",\n \"absPaths\",\n \"color\",\n \"logLevel\",\n \"logLimit\",\n \"logOverride\",\n \"tsconfigRaw\",\n // BuildOptions\n \"bundle\",\n \"splitting\",\n \"preserveSymlinks\",\n \"external\",\n \"packages\",\n \"alias\",\n \"loader\",\n \"resolveExtensions\",\n \"mainFields\",\n \"conditions\",\n \"allowOverwrite\",\n \"tsconfig\",\n \"outExtension\",\n \"publicPath\",\n \"inject\",\n \"banner\",\n \"footer\",\n \"plugins\",\n] as const satisfies readonly (keyof BuildOptions)[];\n","import { createRequire } from \"node:module\";\nimport { bold, green, red, white, yellow } from \"kolorist\";\nimport semver from \"semver\";\n\nconst require = createRequire(import.meta.url);\n\nexport const NEXT_VERSION = require(\"next/package.json\").version as string;\n\nconst LOGGING_SPACE_PREFIX = semver.gte(NEXT_VERSION, \"16.0.0\") ? \"\" : \" \";\n\nexport type LoggingMethods = \"wait\" | \"error\" | \"warn\" | \"info\" | \"event\";\n\nconst prefixedLog = (prefixType: LoggingMethods, ...message: any[]) => {\n let prefix: string;\n let consoleMethod: keyof Console;\n\n switch (prefixType) {\n case \"wait\":\n prefix = `${white(bold(\"○\"))} (serwist)`;\n consoleMethod = \"log\";\n break;\n case \"error\":\n prefix = `${red(bold(\"X\"))} (serwist)`;\n consoleMethod = \"error\";\n break;\n case \"warn\":\n prefix = `${yellow(bold(\"⚠\"))} (serwist)`;\n consoleMethod = \"warn\";\n break;\n case \"info\":\n prefix = `${white(bold(\"○\"))} (serwist)`;\n consoleMethod = \"log\";\n break;\n case \"event\":\n prefix = `${green(bold(\"✓\"))} (serwist)`;\n consoleMethod = \"log\";\n break;\n }\n\n if ((message[0] === \"\" || message[0] === undefined) && message.length === 1) {\n message.shift();\n }\n\n // If there's no message, don't print the prefix but a new line\n if (message.length === 0) {\n console[consoleMethod](\"\");\n } else {\n console[consoleMethod](`${LOGGING_SPACE_PREFIX}${prefix}`, ...message);\n }\n};\n\nexport const wait = (...message: any[]) => prefixedLog(\"wait\", ...message);\n\nexport const error = (...message: any[]) => prefixedLog(\"error\", ...message);\n\nexport const warn = (...message: any[]) => prefixedLog(\"warn\", ...message);\n\nexport const info = (...message: any[]) => prefixedLog(\"info\", ...message);\n\nexport const event = (...message: any[]) => prefixedLog(\"event\", ...message);\n","import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from \"next/constants.js\";\n\nexport const loadNextConfig = async (cwd: string, isDev: boolean) => {\n const nextPhase = isDev ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;\n // webpackIgnore is only supported by Next.js 15 and above, but it is necessary\n // for loading `next/dist/server/config.js`.\n const nextConfig = await import(/* webpackIgnore: true */ \"next/dist/server/config.js\");\n // 1) what does `default.default` even mean\n const loadConfig =\n typeof nextConfig.default === \"function\" ? (nextConfig.default as unknown as typeof nextConfig.default.default) : nextConfig.default.default;\n return loadConfig(nextPhase, cwd, { silent: false });\n};\n\nexport const generateGlobPatterns = (distDir: string) => [\n `${distDir}static/**/*.{js,css,html,ico,apng,png,avif,jpg,jpeg,jfif,pjpeg,pjp,gif,svg,webp,json,webmanifest}`,\n \"public/**/*\",\n];\n","import path from \"node:path\";\nimport { assertType, basePartial, type Equals, globPartial, injectPartial } from \"@serwist/build/schema\";\nimport semver from \"semver\";\nimport z from \"zod\";\nimport { SUPPORTED_ESBUILD_OPTIONS } from \"./lib/constants.js\";\nimport { NEXT_VERSION } from \"./lib/logger.js\";\nimport { generateGlobPatterns, loadNextConfig } from \"./lib/utils.js\";\nimport type { InjectManifestOptions, InjectManifestOptionsComplete, TurboPartial, TurboResolved } from \"./types.js\";\n\nexport const turboPartial = z.strictObject({\n cwd: z.string().prefault(process.cwd()),\n nextConfig: z\n .object({\n assetPrefix: z.string().optional(),\n basePath: z.string().optional(),\n distDir: z.string().optional(),\n })\n .optional(),\n useNativeEsbuild: z.boolean().prefault(process.platform === \"win32\"),\n rebuildOnChange: z.boolean().prefault(true),\n esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({}),\n});\n\nexport const injectManifestOptions = z\n .strictObject({\n ...basePartial.shape,\n ...globPartial.shape,\n ...injectPartial.shape,\n ...turboPartial.shape,\n globPatterns: z.array(z.string()).optional(),\n globDirectory: z.string().optional(),\n })\n .omit({ disablePrecacheManifest: true })\n .transform(async (input) => {\n // TODO: remove in semver check in Serwist 10\n // webpackIgnore is only supported by Next.js 15 and above, but it is necessary\n // for loading `next/dist/server/config.js`.\n const nextConfig = semver.gte(NEXT_VERSION, \"15.0.0\")\n ? {\n ...(await loadNextConfig(input.cwd, process.env.NODE_ENV === \"development\")),\n ...input.nextConfig,\n }\n : {\n distDir: input.nextConfig?.distDir ?? \".next\",\n basePath: input.nextConfig?.basePath ?? \"/\",\n assetPrefix: input.nextConfig?.assetPrefix ?? input.nextConfig?.basePath ?? \"\",\n };\n let distDir = nextConfig.distDir;\n if (distDir[0] === \"/\") distDir = distDir.slice(1);\n if (distDir[distDir.length - 1] !== \"/\") distDir += \"/\";\n return {\n ...input,\n swSrc: path.isAbsolute(input.swSrc) ? input.swSrc : path.join(input.cwd, input.swSrc),\n globPatterns: input.globPatterns ?? generateGlobPatterns(distDir),\n globDirectory: input.globDirectory ?? input.cwd,\n dontCacheBustURLsMatching: input.dontCacheBustURLsMatching ?? new RegExp(`^${distDir}static/`),\n nextConfig: {\n ...nextConfig,\n distDir,\n // Next.js, by default, set `basePath` to an empty string.\n basePath: nextConfig.basePath || \"/\",\n },\n };\n });\n\nassertType<Equals<TurboPartial, z.input<typeof turboPartial>>>();\nassertType<Equals<TurboResolved, z.output<typeof turboPartial>>>();\nassertType<Equals<InjectManifestOptions, z.input<typeof injectManifestOptions>>>();\nassertType<Equals<InjectManifestOptionsComplete, z.output<typeof injectManifestOptions>>>();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAaC,4BAA4B;CAEvC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;ACtDD,MAAaa,eAFGX,cAAcQ,OAAOC,KAAKC,IAEdH,CAAQ,oBAAoB,CAACK;AAEzD,MAAMC,uBAAuBP,OAAOQ,IAAIH,cAAc,SAAS,GAAG,KAAK;AAIvE,MAAMK,eAAeC,YAA4B,GAAGC,YAAmB;CACrE,IAAIC;CACJ,IAAIC;AAEJ,SAAQH,YAAR;EACE,KAAK;AACHE,YAAS,GAAGf,MAAMH,KAAK,IAAI,CAAC,CAAA;AAC5BmB,mBAAgB;AAChB;EACF,KAAK;AACHD,YAAS,GAAGhB,IAAIF,KAAK,IAAI,CAAC,CAAA;AAC1BmB,mBAAgB;AAChB;EACF,KAAK;AACHD,YAAS,GAAGd,OAAOJ,KAAK,IAAI,CAAC,CAAA;AAC7BmB,mBAAgB;AAChB;EACF,KAAK;AACHD,YAAS,GAAGf,MAAMH,KAAK,IAAI,CAAC,CAAA;AAC5BmB,mBAAgB;AAChB;EACF,KAAK;AACHD,YAAS,GAAGjB,MAAMD,KAAK,IAAI,CAAC,CAAA;AAC5BmB,mBAAgB;AAChB;;AAGJ,M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nC;EACD;EACD;AAEJzB,YAAgE;AAChEA,YAAkE;AAClEA,YAAkF;AAClFA,YAA2F"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["// Workaround for Next.js + Turbopack, while plugins are still\n// not supported. This relies on Next.js Route Handlers and file\n// name determinism.\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { type BuildResult, getFileManifestEntries, rebasePath } from \"@serwist/build\";\nimport { SerwistConfigError, validationErrorMap } from \"@serwist/build/schema\";\nimport { browserslistToEsbuild } from \"@serwist/utils\";\nimport browserslist from \"browserslist\";\nimport { cyan, dim, yellow } from \"kolorist\";\nimport type { NextConfig } from \"next\";\nimport { MODERN_BROWSERSLIST_TARGET } from \"next/constants.js\";\nimport { NextResponse } from \"next/server.js\";\nimport { z } from \"zod\";\nimport { injectManifestOptions } from \"./index.schema.js\";\nimport { logger } from \"./lib/index.js\";\nimport type { LoggingMethods } from \"./lib/logger.js\";\nimport type { InjectManifestOptions, InjectManifestOptionsComplete } from \"./types.js\";\n\nlet esbuildWasm: Promise<typeof import(\"esbuild-wasm\")> | null = null;\nlet esbuildNative: Promise<typeof import(\"esbuild\")> | null = null;\n\nconst logSerwistResult = (filePath: string, buildResult: Pick<BuildResult, \"count\" | \"size\" | \"warnings\">) => {\n const { count, size, warnings } = buildResult;\n const hasWarnings = warnings && warnings.length > 0;\n // The route is reinitiated for each `path` param, so we only log results\n // if we're prerendering for sw.js.\n if (filePath === \"sw.js\" && (hasWarnings || count > 0)) {\n logger[hasWarnings ? \"warn\" : \"event\"](\n `${cyan(count)} precache entries ${dim(`(${(size / 1024).toFixed(2)} KiB)`)}${\n hasWarnings ? `\\n${yellow([\"⚠ warnings\", ...warnings.map((w) => ` ${w}`), \"\"].join(\"\\n\"))}` : \"\"\n }`,\n );\n }\n};\n\nconst validateGetManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {\n const result = await injectManifestOptions.spa(input, {\n error: validationErrorMap,\n });\n if (!result.success) {\n throw new SerwistConfigError({\n moduleName: \"@serwist/turbopack\",\n message: z.prettifyError(result.error),\n });\n }\n return result.data;\n};\n\nconst isDev = process.env.NODE_ENV === \"development\";\n\nconst contentTypeMap: Record<string, string> = {\n \".js\": \"application/javascript\",\n \".map\": \"application/json; charset=UTF-8\",\n};\n\n/**\n * Creates a Route Handler for Serwist files.\n * @param options Options for {@linkcode getFileManifestEntries}.\n */\nexport const createSerwistRoute = (options: InjectManifestOptions) => {\n const dynamic = \"force-static\" as const,\n dynamicParams = false as const,\n revalidate = false as const;\n const validation = validateGetManifestOptions(options).then((config) => {\n return {\n ...config,\n disablePrecacheManifest: isDev,\n additionalPrecacheEntries: isDev ? [] : config.additionalPrecacheEntries,\n globIgnores: [\n ...config.globIgnores,\n // Make sure we leave swSrc out of the precache manifest.\n rebasePath({\n file: config.swSrc,\n baseDirectory: config.globDirectory,\n }),\n ],\n manifestTransforms: [\n ...(config.manifestTransforms ?? []),\n async (manifestEntries) => {\n const manifest = manifestEntries.map((m) => {\n // Replace all references to \"$(distDir)\" with \"$(assetPrefix)/_next/\".\n if (m.url.startsWith(config.nextConfig.distDir)) {\n m.url = `${config.nextConfig.assetPrefix}/_next/${m.url.slice(config.nextConfig.distDir.length)}`;\n }\n // Replace all references to public/ with \"$(basePath)/\".\n if (m.url.startsWith(\"public/\")) {\n m.url = path.posix.join(config.nextConfig.basePath, m.url.slice(7));\n }\n return m;\n });\n return { manifest, warnings: [] };\n },\n ],\n };\n });\n let lastHash: string | null = null;\n let map: Map<string, string> | null = null;\n // NOTE: ALL FILES MUST HAVE DETERMINISTIC NAMES. THIS IS BECAUSE\n // THE FOLLOWING MAP IS LOADED SEPARATELY FOR `generateStaticParams`\n // AND EVERY `GET` REQUEST TO EACH OF THE FILES.\n const loadMap = async (filePath: string) => {\n const config = await validation;\n const { count, size, manifestEntries, warnings } = await getFileManifestEntries(config);\n // See https://github.com/GoogleChrome/workbox/issues/2230\n const injectionPoint = config.injectionPoint || \"\";\n const manifestString = manifestEntries === undefined ? \"undefined\" : JSON.stringify(manifestEntries, null, 2);\n const log = (type: LoggingMethods, ...message: any[]) => {\n if (filePath === \"sw.js\") {\n logger[type](...message);\n }\n };\n let esbuild: typeof import(\"esbuild\");\n if (config.useNativeEsbuild) {\n log(\"info\", \"Using esbuild to bundle the service worker.\");\n if (!esbuildNative) esbuildNative = import(/* webpackIgnore: true */ \"esbuild\");\n esbuild = await esbuildNative;\n } else {\n log(\"info\", \"Using esbuild-wasm to bundle the service worker.\");\n if (!esbuildWasm) esbuildWasm = import(/* webpackIgnore: true */ \"esbuild-wasm\");\n esbuild = await esbuildWasm;\n }\n logSerwistResult(filePath, { count, size, warnings });\n const result = await esbuild.build({\n sourcemap: true,\n format: \"esm\",\n treeShaking: true,\n minify: !isDev,\n bundle: true,\n ...config.esbuildOptions,\n target: config.esbuildOptions?.target ?? browserslistToEsbuild(browserslist, config.cwd, MODERN_BROWSERSLIST_TARGET),\n platform: \"browser\",\n define: {\n ...config.esbuildOptions.define,\n ...(injectionPoint ? { [injectionPoint]: manifestString } : {}),\n },\n outdir: config.cwd,\n write: false,\n entryNames: \"[name]\",\n // Asset and chunk names must be at the top, as our path is `/serwist/[path]`,\n // not `/serwist/[...path]`, meaning that we can't resolve paths deeper\n // than one level.\n assetNames: \"[name]-[hash]\",\n chunkNames: \"[name]-[hash]\",\n entryPoints: [{ in: config.swSrc, out: \"sw\" }],\n });\n if (result.errors.length) {\n console.error(\"Failed to build the service worker.\", result.errors);\n throw new Error();\n }\n if (result.warnings.length) {\n console.warn(result.warnings);\n }\n return new Map(result.outputFiles.map((e) => [e.path, e.text]));\n };\n const generateStaticParams = async () => {\n const config = await validation;\n if (!map) map = await loadMap(\"root\");\n return [...map.keys()].map((e) => ({ path: path.relative(config.cwd, e) }));\n };\n const GET = async (_: Request, { params }: { params: Promise<{ path: string }> }) => {\n const { path: filePath } = await params;\n const config = await validation;\n if (isDev && config.rebuildOnChange) {\n const swContent = fs.readFileSync(config.swSrc, \"utf-8\");\n const currentHash = crypto.createHash(\"sha256\").update(swContent).digest(\"hex\");\n if (!map || lastHash !== currentHash) {\n map = await loadMap(filePath);\n lastHash = currentHash;\n }\n } else if (!map) map = await loadMap(filePath);\n return new NextResponse(map.get(path.join(config.cwd, filePath)), {\n headers: {\n \"Content-Type\": contentTypeMap[path.extname(filePath)] || \"text/plain\",\n \"Service-Worker-Allowed\": \"/\",\n },\n });\n };\n return { dynamic, dynamicParams, revalidate, generateStaticParams, GET };\n};\n\nexport const withSerwist = (nextConfig: NextConfig = {}): NextConfig => ({\n ...nextConfig,\n serverExternalPackages: [...(nextConfig.serverExternalPackages ?? []), \"esbuild\", \"esbuild-wasm\"],\n});\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAI,cAA6D;AACjE,IAAI,gBAA0D;AAE9D,MAAM,oBAAoB,UAAkB,gBAAkE;CAC5G,MAAM,EAAE,OAAO,MAAM,aAAa;CAClC,MAAM,cAAc,YAAY,SAAS,SAAS;AAGlD,KAAI,aAAa,YAAY,eAAe,QAAQ,GAClD,gBAAO,cAAc,SAAS,SAC5B,GAAG,KAAK,MAAM,CAAC,oBAAoB,IAAI,KAAK,OAAO,MAAM,QAAQ,EAAE,CAAC,OAAO,GACzE,cAAc,KAAK,OAAO;EAAC;EAAc,GAAG,SAAS,KAAK,MAAM,KAAK,IAAI;EAAE;EAAG,CAAC,KAAK,KAAK,CAAC,KAAK,KAElG;;AAIL,MAAM,6BAA6B,OAAO,UAA2D;CACnG,MAAM,SAAS,MAAM,sBAAsB,IAAI,OAAO,EACpD,OAAO,oBACR,CAAC;AACF,KAAI,CAAC,OAAO,QACV,OAAM,IAAI,mBAAmB;EAC3B,YAAY;EACZ,SAAS,EAAE,cAAc,OAAO,MAAM;EACvC,CAAC;AAEJ,QAAO,OAAO;;AAGhB,MAAM,QAAQ,QAAQ,IAAI,aAAa;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AAM,YAAY,GAAG,aAAa,OAAO,OAAO,QAAQ;GACxD,MAAM,cAAc,OAAO,WAAW,SAAS,CAAC,OAAO,UAAU,CAAC,OAAO,MAAM;AAC/E,OAAI,CAAC,OAAO,aAAa,aAAa;AACpC,UAAM,MAAM,QAAQ,SAAS;AAC7B,eAAW;;aAEJ,CAAC,IAAK,OAAM,MAAM,QAAQ,SAAS;AAC9C,SAAO,IAAI,aAAa,IAAI,IAAI,KAAK,KAAK,OAAO,KAAK,SAAS,CAAC,EAAE,EAChE,SAAS;GACP,gBAAgB,eAAe,KAAK,QAAQ,SAAS,KAAK;GAC1D,0BAA0B;GAC3B,EACF,CAAC;;AAEJ,QAAO;EAAE;EAAS;EAAe;EAAY;EAAsB;EAAK;;AAG1E,MAAa,eAAe,aAAyB,EAAE,MAAkB;CACvE,GAAG;CACH,wBAAwB;EAAC,GAAI,WAAW,0BAA0B,EAAE;EAAG;EAAW;EAAe;CAClG"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["crypto","fs","path","BuildResult","getFileManifestEntries","rebasePath","SerwistConfigError","validationErrorMap","browserslistToEsbuild","browserslist","cyan","dim","yellow","NextConfig","MODERN_BROWSERSLIST_TARGET","NextResponse","z","injectManifestOptions","logger","LoggingMethods","InjectManifestOptions","InjectManifestOptionsComplete","esbuildWasm","Promise","esbuildNative","logSerwistResult","filePath","buildResult","Pick","count","size","warnings","hasWarnings","length","toFixed","map","w","join","validateGetManifestOptions","input","result","spa","error","success","moduleName","message","prettifyError","data","isDev","process","env","NODE_ENV","contentTypeMap","Record","createSerwistRoute","options","dynamic","const","dynamicParams","revalidate","validation","then","config","disablePrecacheManifest","additionalPrecacheEntries","globIgnores","file","swSrc","baseDirectory","globDirectory","manifestTransforms","manifestEntries","manifest","m","url","startsWith","nextConfig","distDir","assetPrefix","slice","posix","basePath","lastHash","Map","loadMap","injectionPoint","manifestString","undefined","JSON","stringify","log","type","esbuild","useNativeEsbuild","build","sourcemap","format","treeShaking","minify","bundle","esbuildOptions","target","cwd","platform","define","outdir","write","entryNames","assetNames","chunkNames","entryPoints","in","out","errors","console","Error","warn","outputFiles","e","text","generateStaticParams","keys","relative","GET","_","Request","params","rebuildOnChange","swContent","readFileSync","currentHash","createHash","update","digest","get","headers","extname","withSerwist","serverExternalPackages"],"sources":["../src/index.ts"],"sourcesContent":["// Workaround for Next.js + Turbopack, while plugins are still\n// not supported. This relies on Next.js Route Handlers and file\n// name determinism.\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { type BuildResult, getFileManifestEntries, rebasePath } from \"@serwist/build\";\nimport { SerwistConfigError, validationErrorMap } from \"@serwist/build/schema\";\nimport { browserslistToEsbuild } from \"@serwist/utils\";\nimport browserslist from \"browserslist\";\nimport { cyan, dim, yellow } from \"kolorist\";\nimport type { NextConfig } from \"next\";\nimport { MODERN_BROWSERSLIST_TARGET } from \"next/constants.js\";\nimport { NextResponse } from \"next/server.js\";\nimport { z } from \"zod\";\nimport { injectManifestOptions } from \"./index.schema.js\";\nimport { logger } from \"./lib/index.js\";\nimport type { LoggingMethods } from \"./lib/logger.js\";\nimport type { InjectManifestOptions, InjectManifestOptionsComplete } from \"./types.js\";\n\nlet esbuildWasm: Promise<typeof import(\"esbuild-wasm\")> | null = null;\nlet esbuildNative: Promise<typeof import(\"esbuild\")> | null = null;\n\nconst logSerwistResult = (filePath: string, buildResult: Pick<BuildResult, \"count\" | \"size\" | \"warnings\">) => {\n const { count, size, warnings } = buildResult;\n const hasWarnings = warnings && warnings.length > 0;\n // The route is reinitiated for each `path` param, so we only log results\n // if we're prerendering for sw.js.\n if (filePath === \"sw.js\" && (hasWarnings || count > 0)) {\n logger[hasWarnings ? \"warn\" : \"event\"](\n `${cyan(count)} precache entries ${dim(`(${(size / 1024).toFixed(2)} KiB)`)}${\n hasWarnings ? `\\n${yellow([\"⚠ warnings\", ...warnings.map((w) => ` ${w}`), \"\"].join(\"\\n\"))}` : \"\"\n }`,\n );\n }\n};\n\nconst validateGetManifestOptions = async (input: unknown): Promise<InjectManifestOptionsComplete> => {\n const result = await injectManifestOptions.spa(input, {\n error: validationErrorMap,\n });\n if (!result.success) {\n throw new SerwistConfigError({\n moduleName: \"@serwist/turbopack\",\n message: z.prettifyError(result.error),\n });\n }\n return result.data;\n};\n\nconst isDev = process.env.NODE_ENV === \"development\";\n\nconst contentTypeMap: Record<string, string> = {\n \".js\": \"application/javascript\",\n \".map\": \"application/json; charset=UTF-8\",\n};\n\n/**\n * Creates a Route Handler for Serwist files.\n * @param options Options for {@linkcode getFileManifestEntries}.\n */\nexport const createSerwistRoute = (options: InjectManifestOptions) => {\n const dynamic = \"force-static\" as const,\n dynamicParams = false as const,\n revalidate = false as const;\n const validation = validateGetManifestOptions(options).then((config) => {\n return {\n ...config,\n disablePrecacheManifest: isDev,\n additionalPrecacheEntries: isDev ? [] : config.additionalPrecacheEntries,\n globIgnores: [\n ...config.globIgnores,\n // Make sure we leave swSrc out of the precache manifest.\n rebasePath({\n file: config.swSrc,\n baseDirectory: config.globDirectory,\n }),\n ],\n manifestTransforms: [\n ...(config.manifestTransforms ?? []),\n async (manifestEntries) => {\n const manifest = manifestEntries.map((m) => {\n // Replace all references to \"$(distDir)\" with \"$(assetPrefix)/_next/\".\n if (m.url.startsWith(config.nextConfig.distDir)) {\n m.url = `${config.nextConfig.assetPrefix}/_next/${m.url.slice(config.nextConfig.distDir.length)}`;\n }\n // Replace all references to public/ with \"$(basePath)/\".\n if (m.url.startsWith(\"public/\")) {\n m.url = path.posix.join(config.nextConfig.basePath, m.url.slice(7));\n }\n return m;\n });\n return { manifest, warnings: [] };\n },\n ],\n };\n });\n let lastHash: string | null = null;\n let map: Map<string, string> | null = null;\n // NOTE: ALL FILES MUST HAVE DETERMINISTIC NAMES. THIS IS BECAUSE\n // THE FOLLOWING MAP IS LOADED SEPARATELY FOR `generateStaticParams`\n // AND EVERY `GET` REQUEST TO EACH OF THE FILES.\n const loadMap = async (filePath: string) => {\n const config = await validation;\n const { count, size, manifestEntries, warnings } = await getFileManifestEntries(config);\n // See https://github.com/GoogleChrome/workbox/issues/2230\n const injectionPoint = config.injectionPoint || \"\";\n const manifestString = manifestEntries === undefined ? \"undefined\" : JSON.stringify(manifestEntries, null, 2);\n const log = (type: LoggingMethods, ...message: any[]) => {\n if (filePath === \"sw.js\") {\n logger[type](...message);\n }\n };\n let esbuild: typeof import(\"esbuild\");\n if (config.useNativeEsbuild) {\n log(\"info\", \"Using esbuild to bundle the service worker.\");\n if (!esbuildNative) esbuildNative = import(/* webpackIgnore: true */ \"esbuild\");\n esbuild = await esbuildNative;\n } else {\n log(\"info\", \"Using esbuild-wasm to bundle the service worker.\");\n if (!esbuildWasm) esbuildWasm = import(/* webpackIgnore: true */ \"esbuild-wasm\");\n esbuild = await esbuildWasm;\n }\n logSerwistResult(filePath, { count, size, warnings });\n const result = await esbuild.build({\n sourcemap: true,\n format: \"esm\",\n treeShaking: true,\n minify: !isDev,\n bundle: true,\n ...config.esbuildOptions,\n target: config.esbuildOptions?.target ?? browserslistToEsbuild(browserslist, config.cwd, MODERN_BROWSERSLIST_TARGET),\n platform: \"browser\",\n define: {\n ...config.esbuildOptions.define,\n ...(injectionPoint ? { [injectionPoint]: manifestString } : {}),\n },\n outdir: config.cwd,\n write: false,\n entryNames: \"[name]\",\n // Asset and chunk names must be at the top, as our path is `/serwist/[path]`,\n // not `/serwist/[...path]`, meaning that we can't resolve paths deeper\n // than one level.\n assetNames: \"[name]-[hash]\",\n chunkNames: \"[name]-[hash]\",\n entryPoints: [{ in: config.swSrc, out: \"sw\" }],\n });\n if (result.errors.length) {\n console.error(\"Failed to build the service worker.\", result.errors);\n throw new Error();\n }\n if (result.warnings.length) {\n console.warn(result.warnings);\n }\n return new Map(result.outputFiles.map((e) => [e.path, e.text]));\n };\n const generateStaticParams = async () => {\n const config = await validation;\n if (!map) map = await loadMap(\"root\");\n return [...map.keys()].map((e) => ({ path: path.relative(config.cwd, e) }));\n };\n const GET = async (_: Request, { params }: { params: Promise<{ path: string }> }) => {\n const { path: filePath } = await params;\n const config = await validation;\n if (isDev && config.rebuildOnChange) {\n const swContent = fs.readFileSync(config.swSrc, \"utf-8\");\n const currentHash = crypto.createHash(\"sha256\").update(swContent).digest(\"hex\");\n if (!map || lastHash !== currentHash) {\n map = await loadMap(filePath);\n lastHash = currentHash;\n }\n } else if (!map) map = await loadMap(filePath);\n return new NextResponse(map.get(path.join(config.cwd, filePath)), {\n headers: {\n \"Content-Type\": contentTypeMap[path.extname(filePath)] || \"text/plain\",\n \"Service-Worker-Allowed\": \"/\",\n },\n });\n };\n return { dynamic, dynamicParams, revalidate, generateStaticParams, GET };\n};\n\nexport const withSerwist = (nextConfig: NextConfig = {}): NextConfig => ({\n ...nextConfig,\n serverExternalPackages: [...(nextConfig.serverExternalPackages ?? []), \"esbuild\", \"esbuild-wasm\"],\n});\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAIsB,cAA6D;AACjE,IAAIE,gBAA0D;AAE9D,MAAMC,oBAAoBC,UAAkBC,gBAAkE;CAC5G,MAAM,EAAEE,OAAOC,MAAMC,aAAaJ;CAClC,MAAMK,cAAcD,YAAYA,SAASE,SAAS;AAGlD,KAAIP,aAAa,YAAYM,eAAeH,QAAQ,GAClDX,gBAAOc,cAAc,SAAS,SAC5B,GAAGtB,KAAKmB,MAAM,CAAA,oBAAqBlB,IAAI,KAAKmB,OAAO,MAAMI,QAAQ,EAAE,CAAA,OAAQ,GACzEF,cAAc,KAAKpB,OAAO;EAAC;EAAc,GAAGmB,SAASI,KAAKC,MAAM,KAAKA,IAAI;EAAE;EAAG,CAACC,KAAK,KAAK,CAAC,KAAK,KAElG;;AAIL,MAAMC,6BAA6B,OAAOC,UAA2D;CACnG,MAAMC,SAAS,MAAMvB,sBAAsBwB,IAAIF,OAAO,EACpDG,OAAOnC,oBACR,CAAC;AACF,KAAI,CAACiC,OAAOG,QACV,OAAM,IAAIrC,mBAAmB;EAC3BsC,YAAY;EACZC,SAAS7B,EA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from "react";
|
|
3
2
|
import { ReactNode } from "react";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/context.d.ts
|
|
6
6
|
interface SerwistContextValues {
|
|
@@ -36,7 +36,7 @@ declare function SerwistProvider({
|
|
|
36
36
|
reloadOnOnline,
|
|
37
37
|
options,
|
|
38
38
|
children
|
|
39
|
-
}: SerwistProviderProps): _$
|
|
39
|
+
}: SerwistProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { SerwistProvider, SerwistProviderProps, useSerwist };
|
|
42
42
|
//# sourceMappingURL=index.react.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.react.d.mts","names":[],"sources":["../src/lib/context.ts","../src/index.react.tsx"],"mappings":";;;;;UAGiB,oBAAA;EACf,OAAA,EAAS,OAAA;AAAA;AAAA,cAKE,UAAA,QAAU,oBAAA;;;UCJN,oBAAA;EACf,KAAA;EACA,OAAA;EACA,QAAA;EACA,iBAAA;EACA,cAAA;EACA,OAAA,GAAU,mBAAA;EACV,QAAA,GAAW,SAAA;AAAA;AAAA,QAGL,MAAA;EAAA,UACI,MAAA;IACR,OAAA,EAAS,OAAA;EAAA;AAAA;;AAZb;;;;iBAqBgB,eAAA,CAAA;EACd,KAAA;EACA,OAAA;EACA,QAAA;EACA,iBAAA;EACA,cAAA;EACA,OAAA;EACA;AAAA,GACC,oBAAA,GAAoB,
|
|
1
|
+
{"version":3,"file":"index.react.d.mts","names":[],"sources":["../src/lib/context.ts","../src/index.react.tsx"],"mappings":";;;;;UAGiB,oBAAA;EACf,OAAA,EAAS,OAAA;AAAA;AAAA,cAKE,UAAA,QAAU,oBAAA;;;UCJN,oBAAA;EACf,KAAA;EACA,OAAA;EACA,QAAA;EACA,iBAAA;EACA,cAAA;EACA,OAAA,GAAU,mBAAA;EACV,QAAA,GAAW,SAAA;AAAA;AAAA,QAGL,MAAA;EAAA,UACI,MAAA;IACR,OAAA,EAAS,OAAA;EAAA;AAAA;;AAZb;;;;iBAqBgB,eAAA,CAAA;EACd,KAAA;EACA,OAAA;EACA,QAAA;EACA,iBAAA;EACA,cAAA;EACA,OAAA;EACA;AAAA,GACC,oBAAA,GAAoB,oBAAA,CAAA,GAAA,CAAA,OAAA"}
|
package/dist/index.react.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import { Serwist } from "@serwist/window";
|
|
2
3
|
import { isCurrentPageOutOfScope } from "@serwist/window/internal";
|
|
3
4
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
6
|
//#region src/lib/context.ts
|
|
5
7
|
const SerwistContext = createContext(null);
|
|
6
8
|
const useSerwist = () => {
|
|
@@ -15,57 +17,118 @@ const useSerwist = () => {
|
|
|
15
17
|
* @param options
|
|
16
18
|
* @returns
|
|
17
19
|
*/
|
|
18
|
-
function SerwistProvider(
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
function SerwistProvider(t0) {
|
|
21
|
+
const $ = c(17);
|
|
22
|
+
const { swUrl, disable: t1, register: t2, cacheOnNavigation: t3, reloadOnOnline: t4, options, children } = t0;
|
|
23
|
+
const disable = t1 === void 0 ? false : t1;
|
|
24
|
+
const register = t2 === void 0 ? true : t2;
|
|
25
|
+
const cacheOnNavigation = t3 === void 0 ? true : t3;
|
|
26
|
+
const reloadOnOnline = t4 === void 0 ? true : t4;
|
|
27
|
+
let t5;
|
|
28
|
+
if ($[0] !== disable || $[1] !== options || $[2] !== register || $[3] !== swUrl) {
|
|
29
|
+
t5 = () => {
|
|
30
|
+
if (typeof window === "undefined") return null;
|
|
31
|
+
if (disable) return null;
|
|
32
|
+
const scope = options?.scope || "/";
|
|
33
|
+
if (!(window.serwist && window.serwist instanceof Serwist) && "serviceWorker" in navigator) {
|
|
34
|
+
window.serwist = new Serwist(swUrl, {
|
|
35
|
+
...options,
|
|
36
|
+
scope,
|
|
37
|
+
type: options?.type || "module"
|
|
38
|
+
});
|
|
39
|
+
if (register && !isCurrentPageOutOfScope(scope)) window.serwist.register();
|
|
40
|
+
}
|
|
41
|
+
return window.serwist ?? null;
|
|
40
42
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
$[0] = disable;
|
|
44
|
+
$[1] = options;
|
|
45
|
+
$[2] = register;
|
|
46
|
+
$[3] = swUrl;
|
|
47
|
+
$[4] = t5;
|
|
48
|
+
} else t5 = $[4];
|
|
49
|
+
const [serwist] = useState(t5);
|
|
50
|
+
let t6;
|
|
51
|
+
let t7;
|
|
52
|
+
if ($[5] !== cacheOnNavigation || $[6] !== serwist) {
|
|
53
|
+
t6 = () => {
|
|
54
|
+
const cacheUrls = async (url) => {
|
|
55
|
+
if (!window.navigator.onLine || !url) return;
|
|
56
|
+
serwist?.messageSW({
|
|
57
|
+
type: "CACHE_URLS",
|
|
58
|
+
payload: { urlsToCache: [url] }
|
|
59
|
+
});
|
|
48
60
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
const cacheCurrentPathname = () => cacheUrls(window.location.pathname);
|
|
62
|
+
const pushState = history.pushState;
|
|
63
|
+
const replaceState = history.replaceState;
|
|
64
|
+
if (cacheOnNavigation) {
|
|
65
|
+
history.pushState = (...t8) => {
|
|
66
|
+
const args = t8;
|
|
67
|
+
pushState.apply(history, args);
|
|
68
|
+
cacheUrls(args[2]);
|
|
69
|
+
};
|
|
70
|
+
history.replaceState = (...t9) => {
|
|
71
|
+
const args_0 = t9;
|
|
72
|
+
replaceState.apply(history, args_0);
|
|
73
|
+
cacheUrls(args_0[2]);
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener("online", cacheCurrentPathname);
|
|
76
|
+
}
|
|
77
|
+
return () => {
|
|
78
|
+
history.pushState = pushState;
|
|
79
|
+
history.replaceState = replaceState;
|
|
80
|
+
window.removeEventListener("online", cacheCurrentPathname);
|
|
52
81
|
};
|
|
53
|
-
window.addEventListener("online", cacheCurrentPathname);
|
|
54
|
-
}
|
|
55
|
-
return () => {
|
|
56
|
-
history.pushState = pushState;
|
|
57
|
-
history.replaceState = replaceState;
|
|
58
|
-
window.removeEventListener("online", cacheCurrentPathname);
|
|
59
82
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
t7 = [serwist, cacheOnNavigation];
|
|
84
|
+
$[5] = cacheOnNavigation;
|
|
85
|
+
$[6] = serwist;
|
|
86
|
+
$[7] = t6;
|
|
87
|
+
$[8] = t7;
|
|
88
|
+
} else {
|
|
89
|
+
t6 = $[7];
|
|
90
|
+
t7 = $[8];
|
|
91
|
+
}
|
|
92
|
+
useEffect(t6, t7);
|
|
93
|
+
let t8;
|
|
94
|
+
let t9;
|
|
95
|
+
if ($[9] !== reloadOnOnline) {
|
|
96
|
+
t8 = () => {
|
|
97
|
+
const reload = _temp;
|
|
98
|
+
if (reloadOnOnline) window.addEventListener("online", reload);
|
|
99
|
+
return () => {
|
|
100
|
+
window.removeEventListener("online", reload);
|
|
101
|
+
};
|
|
66
102
|
};
|
|
67
|
-
|
|
68
|
-
|
|
103
|
+
t9 = [reloadOnOnline];
|
|
104
|
+
$[9] = reloadOnOnline;
|
|
105
|
+
$[10] = t8;
|
|
106
|
+
$[11] = t9;
|
|
107
|
+
} else {
|
|
108
|
+
t8 = $[10];
|
|
109
|
+
t9 = $[11];
|
|
110
|
+
}
|
|
111
|
+
useEffect(t8, t9);
|
|
112
|
+
let t10;
|
|
113
|
+
if ($[12] !== serwist) {
|
|
114
|
+
t10 = { serwist };
|
|
115
|
+
$[12] = serwist;
|
|
116
|
+
$[13] = t10;
|
|
117
|
+
} else t10 = $[13];
|
|
118
|
+
let t11;
|
|
119
|
+
if ($[14] !== children || $[15] !== t10) {
|
|
120
|
+
t11 = /* @__PURE__ */ jsx(SerwistContext.Provider, {
|
|
121
|
+
value: t10,
|
|
122
|
+
children
|
|
123
|
+
});
|
|
124
|
+
$[14] = children;
|
|
125
|
+
$[15] = t10;
|
|
126
|
+
$[16] = t11;
|
|
127
|
+
} else t11 = $[16];
|
|
128
|
+
return t11;
|
|
129
|
+
}
|
|
130
|
+
function _temp() {
|
|
131
|
+
return location.reload();
|
|
69
132
|
}
|
|
70
133
|
//#endregion
|
|
71
134
|
export { SerwistProvider, useSerwist };
|
package/dist/index.react.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.react.mjs","names":[],"sources":["../src/lib/context.ts","../src/index.react.tsx"],"sourcesContent":["import type { Serwist } from \"@serwist/window\";\nimport { createContext, useContext } from \"react\";\n\nexport interface SerwistContextValues {\n serwist: Serwist | null;\n}\n\nexport const SerwistContext = createContext<SerwistContextValues>(null!);\n\nexport const useSerwist = () => {\n const context = useContext(SerwistContext);\n if (!context) {\n throw new Error(\"[useSerwist]: 'SerwistContext' is not available.\");\n }\n return context;\n};\n","import { Serwist } from \"@serwist/window\";\nimport { isCurrentPageOutOfScope } from \"@serwist/window/internal\";\nimport { type ReactNode, useEffect, useState } from \"react\";\nimport { SerwistContext, useSerwist } from \"./lib/context.js\";\n\nexport interface SerwistProviderProps {\n swUrl: string;\n disable?: boolean;\n register?: boolean;\n cacheOnNavigation?: boolean;\n reloadOnOnline?: boolean;\n options?: RegistrationOptions;\n children?: ReactNode;\n}\n\ndeclare global {\n interface Window {\n serwist: Serwist;\n }\n}\n\n/**\n * `@serwist/window` provider for Next.js apps.\n * @param options\n * @returns\n */\nexport function SerwistProvider({\n swUrl,\n disable = false,\n register = true,\n cacheOnNavigation = true,\n reloadOnOnline = true,\n options,\n children,\n}: SerwistProviderProps) {\n const [serwist] = useState(() => {\n if (typeof window === \"undefined\") return null;\n if (disable) return null;\n const scope = options?.scope || \"/\";\n if (!(window.serwist && window.serwist instanceof Serwist) && \"serviceWorker\" in navigator) {\n window.serwist = new Serwist(swUrl, { ...options, scope, type: options?.type || \"module\" });\n if (register && !isCurrentPageOutOfScope(scope)) {\n void window.serwist.register();\n }\n }\n return window.serwist ?? null;\n });\n useEffect(() => {\n const cacheUrls = async (url?: string | URL | null | undefined) => {\n if (!window.navigator.onLine || !url) {\n return;\n }\n serwist?.messageSW({\n type: \"CACHE_URLS\",\n payload: { urlsToCache: [url] },\n });\n };\n const cacheCurrentPathname = () => cacheUrls(window.location.pathname);\n const pushState = history.pushState;\n const replaceState = history.replaceState;\n\n if (cacheOnNavigation) {\n history.pushState = (...args) => {\n pushState.apply(history, args);\n cacheUrls(args[2]);\n };\n history.replaceState = (...args) => {\n replaceState.apply(history, args);\n cacheUrls(args[2]);\n };\n window.addEventListener(\"online\", cacheCurrentPathname);\n }\n\n return () => {\n history.pushState = pushState;\n history.replaceState = replaceState;\n window.removeEventListener(\"online\", cacheCurrentPathname);\n };\n }, [serwist, cacheOnNavigation]);\n useEffect(() => {\n const reload = () => location.reload();\n if (reloadOnOnline) {\n window.addEventListener(\"online\", reload);\n }\n return () => {\n window.removeEventListener(\"online\", reload);\n };\n }, [reloadOnOnline]);\n return <SerwistContext.Provider value={{ serwist }}>{children}</SerwistContext.Provider>;\n}\n\nexport { useSerwist };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.react.mjs","names":["Serwist","createContext","useContext","SerwistContextValues","serwist","SerwistContext","useSerwist","context","Error","Serwist","isCurrentPageOutOfScope","ReactNode","useEffect","useState","SerwistContext","useSerwist","SerwistProviderProps","swUrl","disable","register","cacheOnNavigation","reloadOnOnline","options","RegistrationOptions","children","global","Window","serwist","SerwistProvider","t0","$","_c","t1","t2","t3","t4","undefined","t5","window","scope","navigator","type","t6","t7","cacheUrls","url","onLine","messageSW","payload","urlsToCache","cacheCurrentPathname","location","pathname","pushState","history","replaceState","t8","args","apply","t9","args_0","addEventListener","removeEventListener","reload","_temp","t10","t11"],"sources":["../src/lib/context.ts","../src/index.react.tsx"],"sourcesContent":["import type { Serwist } from \"@serwist/window\";\nimport { createContext, useContext } from \"react\";\n\nexport interface SerwistContextValues {\n serwist: Serwist | null;\n}\n\nexport const SerwistContext = createContext<SerwistContextValues>(null!);\n\nexport const useSerwist = () => {\n const context = useContext(SerwistContext);\n if (!context) {\n throw new Error(\"[useSerwist]: 'SerwistContext' is not available.\");\n }\n return context;\n};\n","import { Serwist } from \"@serwist/window\";\nimport { isCurrentPageOutOfScope } from \"@serwist/window/internal\";\nimport { type ReactNode, useEffect, useState } from \"react\";\nimport { SerwistContext, useSerwist } from \"./lib/context.js\";\n\nexport interface SerwistProviderProps {\n swUrl: string;\n disable?: boolean;\n register?: boolean;\n cacheOnNavigation?: boolean;\n reloadOnOnline?: boolean;\n options?: RegistrationOptions;\n children?: ReactNode;\n}\n\ndeclare global {\n interface Window {\n serwist: Serwist;\n }\n}\n\n/**\n * `@serwist/window` provider for Next.js apps.\n * @param options\n * @returns\n */\nexport function SerwistProvider({\n swUrl,\n disable = false,\n register = true,\n cacheOnNavigation = true,\n reloadOnOnline = true,\n options,\n children,\n}: SerwistProviderProps) {\n const [serwist] = useState(() => {\n if (typeof window === \"undefined\") return null;\n if (disable) return null;\n const scope = options?.scope || \"/\";\n if (!(window.serwist && window.serwist instanceof Serwist) && \"serviceWorker\" in navigator) {\n window.serwist = new Serwist(swUrl, { ...options, scope, type: options?.type || \"module\" });\n if (register && !isCurrentPageOutOfScope(scope)) {\n void window.serwist.register();\n }\n }\n return window.serwist ?? null;\n });\n useEffect(() => {\n const cacheUrls = async (url?: string | URL | null | undefined) => {\n if (!window.navigator.onLine || !url) {\n return;\n }\n serwist?.messageSW({\n type: \"CACHE_URLS\",\n payload: { urlsToCache: [url] },\n });\n };\n const cacheCurrentPathname = () => cacheUrls(window.location.pathname);\n const pushState = history.pushState;\n const replaceState = history.replaceState;\n\n if (cacheOnNavigation) {\n history.pushState = (...args) => {\n pushState.apply(history, args);\n cacheUrls(args[2]);\n };\n history.replaceState = (...args) => {\n replaceState.apply(history, args);\n cacheUrls(args[2]);\n };\n window.addEventListener(\"online\", cacheCurrentPathname);\n }\n\n return () => {\n history.pushState = pushState;\n history.replaceState = replaceState;\n window.removeEventListener(\"online\", cacheCurrentPathname);\n };\n }, [serwist, cacheOnNavigation]);\n useEffect(() => {\n const reload = () => location.reload();\n if (reloadOnOnline) {\n window.addEventListener(\"online\", reload);\n }\n return () => {\n window.removeEventListener(\"online\", reload);\n };\n }, [reloadOnOnline]);\n return <SerwistContext.Provider value={{ serwist }}>{children}</SerwistContext.Provider>;\n}\n\nexport { useSerwist };\n"],"mappings":";;;;;;AAOA,MAAaK,iBAAiBJ,cAAoC,KAAM;AAExE,MAAaK,mBAAa;CACxB,MAAAC,UAAgBL,WAAWG,eAAe;AAC1C,KAAI,CAACE,QACH,OAAM,IAAIC,MAAM,mDAAmD;AACpE,QACMD;;;;;;;;;ACYT,SAAOqB,gBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAyB,MAAA,EAAAd,OAAAC,SAAAc,IAAAb,UAAAc,IAAAb,mBAAAc,IAAAb,gBAAAc,IAAAb,SAAAE,aAAAK;CAE9B,MAAAX,UAAAc,OAAAI,KAAAA,IAAA,QAAAJ;CACA,MAAAb,WAAAc,OAAAG,KAAAA,IAAA,OAAAH;CACA,MAAAb,oBAAAc,OAAAE,KAAAA,IAAA,OAAAF;CACA,MAAAb,iBAAAc,OAAAC,KAAAA,IAAA,OAAAD;CAAqB,IAAAE;AAAA,KAAAP,EAAA,OAAAZ,WAAAY,EAAA,OA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ker.mjs","names":[],"sources":["../src/index.worker.ts"],"sourcesContent":["import type { RuntimeCaching } from \"serwist\";\nimport { CacheFirst, ExpirationPlugin, NetworkFirst, NetworkOnly, RangeRequestsPlugin, StaleWhileRevalidate } from \"serwist\";\n\nexport const PAGES_CACHE_NAME = {\n rscPrefetch: \"pages-rsc-prefetch\",\n rsc: \"pages-rsc\",\n html: \"pages\",\n} as const;\n\n/**\n * The default, recommended list of caching strategies for applications\n * built with Next.js.\n *\n * @see https://serwist.pages.dev/docs/next/worker-exports#default-cache\n */\nexport const defaultCache: RuntimeCaching[] =\n process.env.NODE_ENV !== \"production\"\n ? [\n {\n matcher: /.*/i,\n handler: new NetworkOnly(),\n },\n ]\n : [\n {\n matcher: /^https:\\/\\/fonts\\.(?:gstatic)\\.com\\/.*/i,\n handler: new CacheFirst({\n cacheName: \"google-fonts-webfonts\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /^https:\\/\\/fonts\\.(?:googleapis)\\.com\\/.*/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"google-fonts-stylesheets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-font-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-image-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/static.+\\.js$/i,\n handler: new CacheFirst({\n cacheName: \"next-static-js-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/image\\?url=.+$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"next-image\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:mp3|wav|ogg)$/i,\n handler: new CacheFirst({\n cacheName: \"static-audio-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n new RangeRequestsPlugin(),\n ],\n }),\n },\n {\n matcher: /\\.(?:mp4|webm)$/i,\n handler: new CacheFirst({\n cacheName: \"static-video-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n new RangeRequestsPlugin(),\n ],\n }),\n },\n {\n matcher: /\\.(?:js)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-js-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 48,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:css|less)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-style-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/data\\/.+\\/.+\\.json$/i,\n handler: new NetworkFirst({\n cacheName: \"next-data\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:json|xml|csv)$/i,\n handler: new NetworkFirst({\n cacheName: \"static-data-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n // Exclude /api/auth/* to fix auth callback\n // https://github.com/serwist/serwist/discussions/28\n matcher: /\\/api\\/auth\\/.*/,\n handler: new NetworkOnly({\n networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds\n }),\n },\n {\n matcher: ({ sameOrigin, url: { pathname } }) => sameOrigin && pathname.startsWith(\"/api/\"),\n method: \"GET\",\n handler: new NetworkFirst({\n cacheName: \"apis\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 16,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) =>\n request.headers.get(\"RSC\") === \"1\" && request.headers.get(\"Next-Router-Prefetch\") === \"1\" && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.rscPrefetch,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get(\"RSC\") === \"1\" && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.rsc,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) =>\n request.headers.get(\"Content-Type\")?.includes(\"text/html\") && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.html,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ url: { pathname }, sameOrigin }) => sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: \"others\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ sameOrigin }) => !sameOrigin,\n handler: new NetworkFirst({\n cacheName: \"cross-origin\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 60 * 60, // 1 hour\n }),\n ],\n networkTimeoutSeconds: 10,\n }),\n },\n {\n matcher: /.*/i,\n method: \"GET\",\n handler: new NetworkOnly(),\n },\n ];\n"],"mappings":";;AAGA,MAAa,mBAAmB;CAC9B,aAAa;CACb,KAAK;CACL,MAAM;CACP;;;;;;;AAQD,MAAa,eACX,QAAQ,IAAI,aAAa,eACrB,CACE;CACE,SAAS;CACT,SAAS,IAAI,aAAa;CAC3B,CACF,GACD;CACE;EACE,SAAS;EACT,SAAS,IAAI,WAAW;GACtB,WAAW;GACX,SAAS,CACP,IAAI,iBAAiB;IACnB,YAAY;IACZ,eAAe,MAAM,KAAK,KAAK;IAC/B,YAAY;IACb,CAAC,CACH;GACF,CAAC;EACH;CACD;EACE,SAAS;EACT,SAAS,IAAI,qBAAqB;GAChC,WAAW;GACX,SAAS,CACP,IAAI,iBAAiB;IACnB,YAAY;IACZ,eAAe,QAAc;IAC7B,YAAY;IACb,CAAC,CACH;GACF,CAAC;EACH;CACD;EACE,SAAS;EACT,SAAS,IAAI,qBAAqB;GA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,SAAS,KAAK,EAAE,YAAY,iBACtC,QAAQ,QAAQ,IAAI,eAAe,EAAE,SAAS,YAAY,IAAI,cAAc,CAAC,SAAS,WAAW,QAAQ;EAC3G,SAAS,IAAI,aAAa;GACxB,WAAW,iBAAiB;GAC5B,SAAS,CACP,IAAI,iBAAiB;IACnB,YAAY;IACZ,eAAe,OAAU;IAC1B,CAAC,CACH;GACF,CAAC;EACH;CACD;EACE,UAAU,EAAE,KAAK,EAAE,YAAY,iBAAiB,cAAc,CAAC,SAAS,WAAW,QAAQ;EAC3F,SAAS,IAAI,aAAa;GACxB,WAAW;GACX,SAAS,CACP,IAAI,iBAAiB;IACnB,YAAY;IACZ,eAAe,OAAU;IAC1B,CAAC,CACH;GACF,CAAC;EACH;CACD;EACE,UAAU,EAAE,iBAAiB,CAAC;EAC9B,SAAS,IAAI,aAAa;GACxB,WAAW;GACX,SAAS,CACP,IAAI,iBAAiB;IACnB,YAAY;IACZ,eAAe;IAChB,CAAC,CACH;GACD,uBAAuB;GACxB,CAAC;EACH;CACD;EACE,SAAS;EACT,QAAQ;EACR,SAAS,IAAI,aAAa;EAC3B;CACF"}
|
|
1
|
+
{"version":3,"file":"index.worker.mjs","names":["RuntimeCaching","CacheFirst","ExpirationPlugin","NetworkFirst","NetworkOnly","RangeRequestsPlugin","StaleWhileRevalidate","PAGES_CACHE_NAME","rscPrefetch","rsc","html","const","defaultCache","process","env","NODE_ENV","matcher","handler","cacheName","plugins","maxEntries","maxAgeSeconds","maxAgeFrom","networkTimeoutSeconds","sameOrigin","url","pathname","startsWith","method","request","headers","get","includes"],"sources":["../src/index.worker.ts"],"sourcesContent":["import type { RuntimeCaching } from \"serwist\";\nimport { CacheFirst, ExpirationPlugin, NetworkFirst, NetworkOnly, RangeRequestsPlugin, StaleWhileRevalidate } from \"serwist\";\n\nexport const PAGES_CACHE_NAME = {\n rscPrefetch: \"pages-rsc-prefetch\",\n rsc: \"pages-rsc\",\n html: \"pages\",\n} as const;\n\n/**\n * The default, recommended list of caching strategies for applications\n * built with Next.js.\n *\n * @see https://serwist.pages.dev/docs/next/worker-exports#default-cache\n */\nexport const defaultCache: RuntimeCaching[] =\n process.env.NODE_ENV !== \"production\"\n ? [\n {\n matcher: /.*/i,\n handler: new NetworkOnly(),\n },\n ]\n : [\n {\n matcher: /^https:\\/\\/fonts\\.(?:gstatic)\\.com\\/.*/i,\n handler: new CacheFirst({\n cacheName: \"google-fonts-webfonts\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /^https:\\/\\/fonts\\.(?:googleapis)\\.com\\/.*/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"google-fonts-stylesheets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-font-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 4,\n maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-image-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/static.+\\.js$/i,\n handler: new CacheFirst({\n cacheName: \"next-static-js-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/image\\?url=.+$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"next-image\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 64,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:mp3|wav|ogg)$/i,\n handler: new CacheFirst({\n cacheName: \"static-audio-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n new RangeRequestsPlugin(),\n ],\n }),\n },\n {\n matcher: /\\.(?:mp4|webm)$/i,\n handler: new CacheFirst({\n cacheName: \"static-video-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n new RangeRequestsPlugin(),\n ],\n }),\n },\n {\n matcher: /\\.(?:js)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-js-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 48,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:css|less)$/i,\n handler: new StaleWhileRevalidate({\n cacheName: \"static-style-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\/_next\\/data\\/.+\\/.+\\.json$/i,\n handler: new NetworkFirst({\n cacheName: \"next-data\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n matcher: /\\.(?:json|xml|csv)$/i,\n handler: new NetworkFirst({\n cacheName: \"static-data-assets\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n }),\n },\n {\n // Exclude /api/auth/* to fix auth callback\n // https://github.com/serwist/serwist/discussions/28\n matcher: /\\/api\\/auth\\/.*/,\n handler: new NetworkOnly({\n networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds\n }),\n },\n {\n matcher: ({ sameOrigin, url: { pathname } }) => sameOrigin && pathname.startsWith(\"/api/\"),\n method: \"GET\",\n handler: new NetworkFirst({\n cacheName: \"apis\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 16,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n maxAgeFrom: \"last-used\",\n }),\n ],\n networkTimeoutSeconds: 10, // fallback to cache if API does not response within 10 seconds\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) =>\n request.headers.get(\"RSC\") === \"1\" && request.headers.get(\"Next-Router-Prefetch\") === \"1\" && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.rscPrefetch,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) => request.headers.get(\"RSC\") === \"1\" && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.rsc,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ request, url: { pathname }, sameOrigin }) =>\n request.headers.get(\"Content-Type\")?.includes(\"text/html\") && sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: PAGES_CACHE_NAME.html,\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ url: { pathname }, sameOrigin }) => sameOrigin && !pathname.startsWith(\"/api/\"),\n handler: new NetworkFirst({\n cacheName: \"others\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 24 * 60 * 60, // 24 hours\n }),\n ],\n }),\n },\n {\n matcher: ({ sameOrigin }) => !sameOrigin,\n handler: new NetworkFirst({\n cacheName: \"cross-origin\",\n plugins: [\n new ExpirationPlugin({\n maxEntries: 32,\n maxAgeSeconds: 60 * 60, // 1 hour\n }),\n ],\n networkTimeoutSeconds: 10,\n }),\n },\n {\n matcher: /.*/i,\n method: \"GET\",\n handler: new NetworkOnly(),\n },\n ];\n"],"mappings":";;AAGA,MAAaO,mBAAmB;CAC9BC,aAAa;CACbC,KAAK;CACLC,MAAM;CACP;;;;;;;AAQD,MAAaE,eACXC,QAAQC,IAAIC,aAAa,eACrB,CACE;CACEC,SAAS;CACTC,SAAS,IAAIb,aAAY;CAC1B,CACF,GACD;CACE;EACEY,SAAS;EACTC,SAAS,IAAIhB,WAAW;GACtBiB,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,MAAM,KAAK,KAAK;IAC/BC,YAAY;IACb,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEN,SAAS;EACTC,SAAS,IAAIX,qBAAqB;GAChCY,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,QAAc;IAC7BC,YAAY;IACb,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEN,SAAS;EACTC,SAAS,IAAIX,qBAAqB;GAChCY,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,QAAc;IAC7BC,YAAY;IACb,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEN,SAAS;EACTC,SAAS,IAAIX,qBAAqB;GAChCY,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAi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,EAAEa,SAASJ,KAAK,EAAEC,YAAYF,iBACtCK,QAAQC,QAAQC,IAAI,eAAe,EAAEC,SAAS,YAAY,IAAIR,cAAc,CAACE,SAASC,WAAW,QAAQ;EAC3GV,SAAS,IAAId,aAAa;GACxBe,WAAWX,iBAAiBG;GAC5BS,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,OAAU;IAC1B,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEL,UAAU,EAAES,KAAK,EAAEC,YAAYF,iBAAiBA,cAAc,CAACE,SAASC,WAAW,QAAQ;EAC3FV,SAAS,IAAId,aAAa;GACxBe,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe,OAAU;IAC1B,CAAC,CAAA;GAEL,CAAA;EACF;CACD;EACEL,UAAU,EAAEQ,iBAAiB,CAACA;EAC9BP,SAAS,IAAId,aAAa;GACxBe,WAAW;GACXC,SAAS,CACP,IAAIjB,iBAAiB;IACnBkB,YAAY;IACZC,eAAe;IAChB,CAAC,CACH;GACDE,uBAAuB;GACxB,CAAA;EACF;CACD;EACEP,SAAS;EACTY,QAAQ;EACRX,SAAS,IAAIb,aAAY;EAC1B;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/turbopack",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "A module that integrates Serwist into your Next.js / Turbopack application.",
|
|
@@ -71,15 +71,18 @@
|
|
|
71
71
|
"kolorist": "1.8.0",
|
|
72
72
|
"semver": "7.7.4",
|
|
73
73
|
"zod": "4.3.6",
|
|
74
|
-
"@serwist/
|
|
75
|
-
"serwist": "9.5.
|
|
76
|
-
"@serwist/window": "9.5.
|
|
77
|
-
"@serwist/
|
|
74
|
+
"@serwist/utils": "9.5.9",
|
|
75
|
+
"serwist": "9.5.9",
|
|
76
|
+
"@serwist/window": "9.5.9",
|
|
77
|
+
"@serwist/build": "9.5.9"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
+
"@rolldown/plugin-babel": "0.2.3",
|
|
80
81
|
"@types/node": "25.6.0",
|
|
81
82
|
"@types/react": "19.2.14",
|
|
82
83
|
"@types/semver": "7.7.1",
|
|
84
|
+
"@vitejs/plugin-react": "6.0.1",
|
|
85
|
+
"babel-plugin-react-compiler": "1.0.0",
|
|
83
86
|
"esbuild": "0.28.0",
|
|
84
87
|
"esbuild-wasm": "0.28.0",
|
|
85
88
|
"next": "16.2.4",
|