tempest-react-sdk 0.82.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/bin/lib/openapi/generate.hostile.test.mjs +91 -0
- package/bin/lib/openapi/generate.mjs +42 -3
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +135 -132
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +124 -75
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/upload-with-progress.cjs +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js +100 -44
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/query/offline-persistence.cjs +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/offline-persistence.js +57 -44
- package/dist/query/offline-persistence.js.map +1 -1
- package/dist/sw/cache.cjs +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js +82 -32
- package/dist/sw/cache.js.map +1 -1
- package/dist/sw.d.ts +21 -1
- package/dist/tempest-react-sdk.d.ts +90 -6
- package/dist/vite/base-url.cjs +1 -1
- package/dist/vite/base-url.cjs.map +1 -1
- package/dist/vite/base-url.js +5 -1
- package/dist/vite/base-url.js.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.js +96 -31
- package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
- package/dist/vite/tempest-pwa-manifest.cjs +2 -2
- package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
- package/dist/vite/tempest-pwa-manifest.js +32 -16
- package/dist/vite/tempest-pwa-manifest.js.map +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.ts +63 -12
- package/dist/vite.js +4 -4
- package/package.json +1 -1
|
@@ -1,42 +1,58 @@
|
|
|
1
|
-
import { basePrefix as e } from "./base-url.js";
|
|
1
|
+
import { basePrefix as e, toOutputFile as t } from "./base-url.js";
|
|
2
|
+
import { PWA_WORKER_PLUGIN_NAME as n } from "./tempest-pwa-dev-sw.js";
|
|
3
|
+
import { join as r } from "node:path";
|
|
4
|
+
import { existsSync as i, statSync as a } from "node:fs";
|
|
2
5
|
//#region src/vite/tempest-pwa-manifest.ts
|
|
3
|
-
function
|
|
6
|
+
function o(e, n, o, s) {
|
|
7
|
+
let c = t(n, e);
|
|
8
|
+
if (c in o) return !0;
|
|
9
|
+
if (!s) return !1;
|
|
10
|
+
let l = r(s, c);
|
|
11
|
+
return i(l) && a(l).isFile();
|
|
12
|
+
}
|
|
13
|
+
function s(t, n) {
|
|
4
14
|
return `${e(t)}${n}`.replace(/([^:]\/)\/+/g, "$1");
|
|
5
15
|
}
|
|
6
|
-
function
|
|
16
|
+
function c(t, n) {
|
|
7
17
|
let r = e(t);
|
|
8
18
|
return r === "/" ? n.startsWith("/") ? n : `/${n}` : n.startsWith(r) ? n : `${r}${n.replace(/^\//, "")}`;
|
|
9
19
|
}
|
|
10
|
-
function
|
|
20
|
+
function l(e) {
|
|
11
21
|
let t = 5381;
|
|
12
22
|
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) >>> 0;
|
|
13
23
|
return t.toString(16);
|
|
14
24
|
}
|
|
15
|
-
function
|
|
16
|
-
let { fileName:
|
|
25
|
+
function u(e = {}) {
|
|
26
|
+
let { fileName: r = "precache-manifest.json", additionalUrls: i = [], exclude: a = /\.map$/, includeHtml: u = !0, appShell: d = "/index.html", serviceWorker: f } = e, p = "/", m = "", h = "/sw.js";
|
|
17
27
|
return {
|
|
18
28
|
name: "tempest-pwa-manifest",
|
|
19
29
|
apply: "build",
|
|
20
30
|
configResolved(e) {
|
|
21
|
-
|
|
31
|
+
p = e.base ?? "/", m = e.publicDir ?? "";
|
|
32
|
+
let t = (e.plugins ?? []).find((e) => e.name === n)?.api;
|
|
33
|
+
h = f === void 0 ? t ? t.build ? t.swUrl : !1 : "/sw.js" : f;
|
|
22
34
|
},
|
|
23
|
-
generateBundle(e,
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
for (let e of Object.keys(
|
|
27
|
-
let
|
|
35
|
+
generateBundle(e, t) {
|
|
36
|
+
let n = new Set(i.map((e) => c(p, e)));
|
|
37
|
+
d && n.add(c(p, d));
|
|
38
|
+
for (let e of Object.keys(t)) e !== r && (a.test(e) || (u || !e.endsWith(".html")) && n.add(s(p, e)));
|
|
39
|
+
let o = [...n].sort(), f = l(o.join("\n"));
|
|
28
40
|
this.emitFile({
|
|
29
41
|
type: "asset",
|
|
30
|
-
fileName:
|
|
42
|
+
fileName: r,
|
|
31
43
|
source: JSON.stringify({
|
|
32
|
-
version:
|
|
33
|
-
urls:
|
|
44
|
+
version: f,
|
|
45
|
+
urls: o
|
|
34
46
|
})
|
|
35
47
|
});
|
|
48
|
+
},
|
|
49
|
+
writeBundle(e, n) {
|
|
50
|
+
let a = i.filter((e) => !/^[a-z][a-z\d+.-]*:/i.test(e) && !o(e, p, n, m));
|
|
51
|
+
a.length > 0 && this.error(`[tempest-pwa-manifest] additionalUrls lists ${a.join(", ")}, which is neither in public/ nor in the build output. In production that URL answers with the SPA fallback or a 404, so the precache would store index.html under its name or fail the worker install. Move the file into public/, or drop the entry — a file Vite hashes into assets/ (a web manifest linked from index.html) is already precached.`), h !== !1 && (t(p, h) in n || this.error(`[tempest-pwa-manifest] the build emitted ${r} but no service worker at ${h}. In production the registration 404s and navigator.serviceWorker.ready never resolves (push, updates and offline hang without an error). Add tempestPwaDevSw() — it bundles src/sw.ts into this build — or, if a separate step bundles the worker after this one, pass tempestPwaManifest({ serviceWorker: false }) or tempestPwaDevSw({ build: false }).`));
|
|
36
52
|
}
|
|
37
53
|
};
|
|
38
54
|
}
|
|
39
55
|
//#endregion
|
|
40
|
-
export {
|
|
56
|
+
export { u as tempestPwaManifest };
|
|
41
57
|
|
|
42
58
|
//# sourceMappingURL=tempest-pwa-manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tempest-pwa-manifest.js","names":["joinBase","basePrefix","base","file","withBase","prefix","url","hash","h","i","input","tempestPwaManifest","options","config","urls","additionalUrls","appShell","bundle","fileName","exclude","includeHtml","list","version"],"sources":["../../src/vite/tempest-pwa-manifest.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\nimport { basePrefix } from \"./base-url\";\n\n/**\n * A Vite plugin object. Typed loosely so the SDK's published declarations stay\n * free of `vite`'s internal types (which the `.d.ts` rollup can't analyze);\n * assign the result straight into a `plugins: [...]` array.\n */\nexport type TempestVitePlugin = { name: string } & Record<string, unknown>;\n\n/** Options for {@link tempestPwaManifest}. */\nexport interface TempestPwaManifestOptions {\n /** Output file name (under the build root). Default `precache-manifest.json`. */\n fileName?: string;\n /**\n * Extra URLs to precache that Vite doesn't emit into the bundle — typically\n * `public/` assets like the web manifest and icons. Default `[]`.\n *\n * Write these relative to the site root (`/icon.svg`); the resolved Vite\n * `base` is prefixed for you. An entry that already carries the base is\n * left alone, so spelling it out by hand is still correct.\n */\n additionalUrls?: string[];\n /** Emitted files matching this are skipped. Default `/\\.map$/` (source maps). */\n exclude?: RegExp;\n /** Include emitted `.html` documents (the app shell). Default `true`. */\n includeHtml?: boolean;\n /**\n * App-shell document always added to the manifest, even if Vite emits it\n * after this plugin runs. Must match `installPrecache`'s `navigateFallback`\n * so offline navigations resolve. Pass `false` to disable. Default `/index.html`.\n *\n * Like {@link TempestPwaManifestOptions.additionalUrls}, this is prefixed\n * with the resolved Vite `base`.\n */\n appShell?: string | false;\n}\n\nfunction joinBase(base: string, file: string): string {\n return `${basePrefix(base)}${file}`.replace(/([^:]\\/)\\/+/g, \"$1\");\n}\n\n/**\n * Prefix a caller-supplied, root-absolute URL with the resolved Vite `base`.\n *\n * Idempotent: a URL that already starts with the base is returned untouched,\n * so configs written before this was applied — spelling the base out by hand —\n * keep producing the same manifest instead of gaining a doubled prefix.\n */\nfunction withBase(base: string, url: string): string {\n const prefix = basePrefix(base);\n if (prefix === \"/\") return url.startsWith(\"/\") ? url : `/${url}`;\n if (url.startsWith(prefix)) return url;\n return `${prefix}${url.replace(/^\\//, \"\")}`;\n}\n\n/** Deterministic djb2 hash → hex. Stable across rebuilds with the same assets. */\nfunction hash(input: string): string {\n let h = 5381;\n for (let i = 0; i < input.length; i++) {\n h = ((h << 5) + h + input.charCodeAt(i)) >>> 0;\n }\n return h.toString(16);\n}\n\n/**\n * Vite build plugin that emits a `precache-manifest.json` listing every built\n * asset (plus any `additionalUrls`) as root-absolute URLs, with a content-based\n * `version`. It is the dependency-free counterpart to Workbox's `__WB_MANIFEST`:\n * `installPrecache` (from `tempest-react-sdk/sw`) reads this file at the service\n * worker's `install` event to cache the app shell for offline use.\n *\n * @example\n * // vite.config.ts\n * import { createViteConfig, tempestPwaManifest } from \"tempest-react-sdk/vite\";\n *\n * export default createViteConfig({\n * plugins: [tempestPwaManifest({ additionalUrls: [\"/manifest.webmanifest\", \"/icon.svg\"] })],\n * });\n */\nexport function tempestPwaManifest(options: TempestPwaManifestOptions = {}): TempestVitePlugin {\n const {\n fileName = \"precache-manifest.json\",\n additionalUrls = [],\n exclude = /\\.map$/,\n includeHtml = true,\n appShell = \"/index.html\",\n } = options;\n\n let base = \"/\";\n\n const plugin: Plugin = {\n name: \"tempest-pwa-manifest\",\n apply: \"build\",\n configResolved(config) {\n base = config.base ?? \"/\";\n },\n generateBundle(_outputOptions, bundle) {\n const urls = new Set<string>(additionalUrls.map((url) => withBase(base, url)));\n // Vite may emit index.html after this hook, so guarantee the shell.\n if (appShell) urls.add(withBase(base, appShell));\n for (const file of Object.keys(bundle)) {\n if (file === fileName) continue;\n if (exclude.test(file)) continue;\n if (!includeHtml && file.endsWith(\".html\")) continue;\n urls.add(joinBase(base, file));\n }\n\n const list = [...urls].sort();\n const version = hash(list.join(\"\\n\"));\n this.emitFile({\n type: \"asset\",\n fileName,\n source: JSON.stringify({ version, urls: list }),\n });\n },\n };\n\n return plugin as TempestVitePlugin;\n}\n"],"mappings":";;AAsCA,SAASA,EAAS,GAAc,GAAsB;CAClD,OAAO,GAAGC,EAAWC,CAAI,IAAIC,IAAO,QAAQ,gBAAgB,IAAI;AACpE;AASA,SAASC,EAAS,GAAc,GAAqB;CACjD,IAAMC,IAASJ,EAAWC,CAAI;CAG9B,OAFIG,MAAW,MAAYC,EAAI,WAAW,GAAG,IAAIA,IAAM,IAAIA,MACvDA,EAAI,WAAWD,CAAM,IAAUC,IAC5B,GAAGD,IAASC,EAAI,QAAQ,OAAO,EAAE;AAC5C;AAGA,SAASC,EAAK,GAAuB;CACjC,IAAIC,IAAI;CACR,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAM,QAAQ,KAC9B,KAAMF,KAAK,KAAKA,IAAIE,EAAM,WAAWD,CAAC,MAAO;CAEjD,OAAOD,EAAE,SAAS,EAAE;AACxB;AAiBA,SAAgBG,EAAmB,IAAqC,CAAC,GAAsB;CAC3F,IAAM,EACF,cAAW,0BACX,oBAAiB,CAAC,GAClB,aAAU,UACV,iBAAc,IACd,cAAW,kBACXC,GAEAV,IAAO;CA6BX,OAAO;EA1BH,MAAM;EACN,OAAO;EACP,eAAe,GAAQ;GACnB,IAAOW,EAAO,QAAQ;EAC1B;EACA,eAAe,GAAgB,GAAQ;GACnC,IAAMC,IAAO,IAAI,IAAYC,EAAe,KAAK,MAAQX,EAASF,GAAMI,CAAG,CAAC,CAAC;GAE7E,AAAIU,KAAUF,EAAK,IAAIV,EAASF,GAAMc,CAAQ,CAAC;GAC/C,KAAK,IAAMb,KAAQ,OAAO,KAAKc,CAAM,GACjC,AAAId,MAASe,MACTC,EAAQ,KAAKhB,CAAI,MAChBiB,KAAe,GAAK,SAAS,OAAO,MACzCN,EAAK,IAAId,EAASE,GAAMC,CAAI,CAAC;GAGjC,IAAMkB,IAAO,CAAC,GAAGP,CAAI,CAAC,CAAC,KAAK,GACtBQ,IAAUf,EAAKc,EAAK,KAAK,IAAI,CAAC;GACpC,KAAK,SAAS;IACV,MAAM;IACN;IACA,QAAQ,KAAK,UAAU;KAAE;KAAS,MAAMA;IAAK,CAAC;GAClD,CAAC;EACL;CAGG;AACX"}
|
|
1
|
+
{"version":3,"file":"tempest-pwa-manifest.js","names":["resolvesToFile","file","toOutputFile","base","url","bundle","publicDir","path","join","existsSync","statSync","joinBase","basePrefix","withBase","prefix","hash","h","i","input","tempestPwaManifest","options","expectedWorker","config","worker","item","PWA_WORKER_PLUGIN_NAME","serviceWorker","urls","additionalUrls","appShell","fileName","exclude","includeHtml","list","version","missing"],"sources":["../../src/vite/tempest-pwa-manifest.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { basePrefix, toOutputFile } from \"./base-url\";\nimport { PWA_WORKER_PLUGIN_NAME } from \"./tempest-pwa-dev-sw\";\nimport type { TempestPwaWorkerApi } from \"./tempest-pwa-dev-sw\";\n\n/**\n * A Vite plugin object. Typed loosely so the SDK's published declarations stay\n * free of `vite`'s internal types (which the `.d.ts` rollup can't analyze);\n * assign the result straight into a `plugins: [...]` array.\n */\nexport type TempestVitePlugin = { name: string } & Record<string, unknown>;\n\n/** Options for {@link tempestPwaManifest}. */\nexport interface TempestPwaManifestOptions {\n /** Output file name (under the build root). Default `precache-manifest.json`. */\n fileName?: string;\n /**\n * Extra URLs to precache that Vite doesn't emit into the bundle — typically\n * `public/` assets like the web manifest and icons. Default `[]`.\n *\n * Write these relative to the site root (`/icon.svg`); the resolved Vite\n * `base` is prefixed for you. An entry that already carries the base is\n * left alone, so spelling it out by hand is still correct.\n *\n * Every same-origin entry must be a file in `public/` or in the bundle, or\n * the build fails. A URL that resolves to nothing is answered in production\n * by the SPA fallback (`index.html`) or a 404, so the precache would store\n * the app shell under that name, or fail the worker's install outright. The\n * usual culprit is a web manifest linked from `index.html` but kept outside\n * `public/`: Vite hashes it into `assets/`, where it is already precached.\n * Absolute `http(s):` URLs are not checked.\n */\n additionalUrls?: string[];\n /** Emitted files matching this are skipped. Default `/\\.map$/` (source maps). */\n exclude?: RegExp;\n /** Include emitted `.html` documents (the app shell). Default `true`. */\n includeHtml?: boolean;\n /**\n * App-shell document always added to the manifest, even if Vite emits it\n * after this plugin runs. Must match `installPrecache`'s `navigateFallback`\n * so offline navigations resolve. Pass `false` to disable. Default `/index.html`.\n *\n * Like {@link TempestPwaManifestOptions.additionalUrls}, this is prefixed\n * with the resolved Vite `base`.\n */\n appShell?: string | false;\n /**\n * URL of the service worker that reads this manifest. The build fails when\n * no file is emitted at that URL. Default: the `swUrl` of\n * {@link tempestPwaDevSw} when it is in the plugin list, `/sw.js` otherwise.\n *\n * A precache manifest is only read by a worker, and a build that ships the\n * manifest without the worker exits 0 while registration 404s in\n * production — `navigator.serviceWorker.ready` never resolves and push,\n * updates and offline all hang without a message. Pass `false` when the\n * worker is bundled by a separate step after this build (a second\n * `vite build --config vite.sw.config.ts`); `tempestPwaDevSw({ build: false })`\n * already says the same and needs nothing here.\n */\n serviceWorker?: string | false;\n}\n\n/**\n * Whether `url` names something the build can serve: a bundle entry or a file\n * in the public directory.\n *\n * @param url - The URL as written in `additionalUrls`.\n * @param base - Vite's resolved `base`.\n * @param bundle - The final output bundle.\n * @param publicDir - The resolved public directory, or `\"\"` when disabled.\n * @returns `true` when the URL resolves to a real file.\n */\nfunction resolvesToFile(\n url: string,\n base: string,\n bundle: Record<string, unknown>,\n publicDir: string,\n): boolean {\n const file = toOutputFile(base, url);\n if (file in bundle) return true;\n if (!publicDir) return false;\n const path = join(publicDir, file);\n return existsSync(path) && statSync(path).isFile();\n}\n\nfunction joinBase(base: string, file: string): string {\n return `${basePrefix(base)}${file}`.replace(/([^:]\\/)\\/+/g, \"$1\");\n}\n\n/**\n * Prefix a caller-supplied, root-absolute URL with the resolved Vite `base`.\n *\n * Idempotent: a URL that already starts with the base is returned untouched,\n * so configs written before this was applied — spelling the base out by hand —\n * keep producing the same manifest instead of gaining a doubled prefix.\n */\nfunction withBase(base: string, url: string): string {\n const prefix = basePrefix(base);\n if (prefix === \"/\") return url.startsWith(\"/\") ? url : `/${url}`;\n if (url.startsWith(prefix)) return url;\n return `${prefix}${url.replace(/^\\//, \"\")}`;\n}\n\n/** Deterministic djb2 hash → hex. Stable across rebuilds with the same assets. */\nfunction hash(input: string): string {\n let h = 5381;\n for (let i = 0; i < input.length; i++) {\n h = ((h << 5) + h + input.charCodeAt(i)) >>> 0;\n }\n return h.toString(16);\n}\n\n/**\n * Vite build plugin that emits a `precache-manifest.json` listing every built\n * asset (plus any `additionalUrls`) as root-absolute URLs, with a content-based\n * `version`. It is the dependency-free counterpart to Workbox's `__WB_MANIFEST`:\n * `installPrecache` (from `tempest-react-sdk/sw`) reads this file at the service\n * worker's `install` event to cache the app shell for offline use.\n *\n * Two mistakes that used to ship in silence now fail the build, after the bundle\n * is written: no service worker emitted at\n * {@link TempestPwaManifestOptions.serviceWorker}, and an `additionalUrls`\n * entry that is neither in `public/` nor in the bundle. Pair it with\n * {@link tempestPwaDevSw}, which bundles `src/sw.ts` into the same build.\n *\n * @example\n * // vite.config.ts\n * import { createViteConfig, tempestPwaDevSw, tempestPwaManifest } from \"tempest-react-sdk/vite\";\n *\n * export default createViteConfig({\n * plugins: [\n * tempestPwaManifest({ additionalUrls: [\"/manifest.webmanifest\", \"/icon.svg\"] }),\n * tempestPwaDevSw(),\n * ],\n * });\n */\nexport function tempestPwaManifest(options: TempestPwaManifestOptions = {}): TempestVitePlugin {\n const {\n fileName = \"precache-manifest.json\",\n additionalUrls = [],\n exclude = /\\.map$/,\n includeHtml = true,\n appShell = \"/index.html\",\n serviceWorker,\n } = options;\n\n let base = \"/\";\n let publicDir = \"\";\n let expectedWorker: string | false = \"/sw.js\";\n\n const plugin: Plugin = {\n name: \"tempest-pwa-manifest\",\n apply: \"build\",\n configResolved(config) {\n base = config.base ?? \"/\";\n publicDir = config.publicDir ?? \"\";\n const worker = (config.plugins ?? []).find(\n (item) => item.name === PWA_WORKER_PLUGIN_NAME,\n )?.api as TempestPwaWorkerApi | undefined;\n if (serviceWorker !== undefined) expectedWorker = serviceWorker;\n else if (worker) expectedWorker = worker.build ? worker.swUrl : false;\n else expectedWorker = \"/sw.js\";\n },\n generateBundle(_outputOptions, bundle) {\n const urls = new Set<string>(additionalUrls.map((url) => withBase(base, url)));\n // Vite may emit index.html after this hook, so guarantee the shell.\n if (appShell) urls.add(withBase(base, appShell));\n for (const file of Object.keys(bundle)) {\n if (file === fileName) continue;\n if (exclude.test(file)) continue;\n if (!includeHtml && file.endsWith(\".html\")) continue;\n urls.add(joinBase(base, file));\n }\n\n const list = [...urls].sort();\n const version = hash(list.join(\"\\n\"));\n this.emitFile({\n type: \"asset\",\n fileName,\n source: JSON.stringify({ version, urls: list }),\n });\n },\n writeBundle(_outputOptions, bundle) {\n const missing = additionalUrls.filter(\n (url) =>\n !/^[a-z][a-z\\d+.-]*:/i.test(url) &&\n !resolvesToFile(url, base, bundle, publicDir),\n );\n if (missing.length > 0) {\n this.error(\n `[tempest-pwa-manifest] additionalUrls lists ${missing.join(\", \")}, which is ` +\n \"neither in public/ nor in the build output. In production that URL \" +\n \"answers with the SPA fallback or a 404, so the precache would store \" +\n \"index.html under its name or fail the worker install. Move the file \" +\n \"into public/, or drop the entry — a file Vite hashes into assets/ \" +\n \"(a web manifest linked from index.html) is already precached.\",\n );\n }\n\n if (expectedWorker === false) return;\n if (toOutputFile(base, expectedWorker) in bundle) return;\n this.error(\n `[tempest-pwa-manifest] the build emitted ${fileName} but no service worker ` +\n `at ${expectedWorker}. In production the registration 404s and ` +\n \"navigator.serviceWorker.ready never resolves (push, updates and offline \" +\n \"hang without an error). Add tempestPwaDevSw() — it bundles src/sw.ts into \" +\n \"this build — or, if a separate step bundles the worker after this one, \" +\n \"pass tempestPwaManifest({ serviceWorker: false }) or \" +\n \"tempestPwaDevSw({ build: false }).\",\n );\n },\n };\n\n return plugin as TempestVitePlugin;\n}\n"],"mappings":";;;;;AA0EA,SAASA,EACL,GACA,GACA,GACA,GACO;CACP,IAAMC,IAAOC,EAAaC,GAAMC,CAAG;CACnC,IAAIH,KAAQI,GAAQ,OAAO;CAC3B,IAAI,CAACC,GAAW,OAAO;CACvB,IAAMC,IAAOC,EAAKF,GAAWL,CAAI;CACjC,OAAOQ,EAAWF,CAAI,KAAKG,EAASH,CAAI,CAAC,CAAC,OAAO;AACrD;AAEA,SAASI,EAAS,GAAc,GAAsB;CAClD,OAAO,GAAGC,EAAWT,CAAI,IAAIF,IAAO,QAAQ,gBAAgB,IAAI;AACpE;AASA,SAASY,EAAS,GAAc,GAAqB;CACjD,IAAMC,IAASF,EAAWT,CAAI;CAG9B,OAFIW,MAAW,MAAYV,EAAI,WAAW,GAAG,IAAIA,IAAM,IAAIA,MACvDA,EAAI,WAAWU,CAAM,IAAUV,IAC5B,GAAGU,IAASV,EAAI,QAAQ,OAAO,EAAE;AAC5C;AAGA,SAASW,EAAK,GAAuB;CACjC,IAAIC,IAAI;CACR,KAAK,IAAIC,IAAI,GAAGA,IAAIC,EAAM,QAAQ,KAC9B,KAAMF,KAAK,KAAKA,IAAIE,EAAM,WAAWD,CAAC,MAAO;CAEjD,OAAOD,EAAE,SAAS,EAAE;AACxB;AA0BA,SAAgBG,EAAmB,IAAqC,CAAC,GAAsB;CAC3F,IAAM,EACF,cAAW,0BACX,oBAAiB,CAAC,GAClB,aAAU,UACV,iBAAc,IACd,cAAW,eACX,qBACAC,GAEAjB,IAAO,KACPG,IAAY,IACZe,IAAiC;CAiErC,OAAO;EA9DH,MAAM;EACN,OAAO;EACP,eAAe,GAAQ;GAEnB,AADA,IAAOC,EAAO,QAAQ,KACtB,IAAYA,EAAO,aAAa;GAChC,IAAMC,KAAUD,EAAO,WAAW,CAAC,EAAA,CAAG,MACjC,MAASE,EAAK,SAASC,CAC5B,CAAC,EAAE;GACH,AAAiCJ,IAA7BK,MAAkB,KAAA,IACbH,IAAyBA,EAAO,QAAQA,EAAO,QAAQ,KAC1C,WAF4BG;EAGtD;EACA,eAAe,GAAgB,GAAQ;GACnC,IAAMC,IAAO,IAAI,IAAYC,EAAe,KAAK,MAAQf,EAASV,GAAMC,CAAG,CAAC,CAAC;GAE7E,AAAIyB,KAAUF,EAAK,IAAId,EAASV,GAAM0B,CAAQ,CAAC;GAC/C,KAAK,IAAM5B,KAAQ,OAAO,KAAKI,CAAM,GACjC,AAAIJ,MAAS6B,MACTC,EAAQ,KAAK9B,CAAI,MAChB+B,KAAe,GAAK,SAAS,OAAO,MACzCL,EAAK,IAAIhB,EAASR,GAAMF,CAAI,CAAC;GAGjC,IAAMgC,IAAO,CAAC,GAAGN,CAAI,CAAC,CAAC,KAAK,GACtBO,IAAUnB,EAAKkB,EAAK,KAAK,IAAI,CAAC;GACpC,KAAK,SAAS;IACV,MAAM;IACN;IACA,QAAQ,KAAK,UAAU;KAAE;KAAS,MAAMA;IAAK,CAAC;GAClD,CAAC;EACL;EACA,YAAY,GAAgB,GAAQ;GAChC,IAAME,IAAUP,EAAe,QAC1B,MACG,CAAC,sBAAsB,KAAKxB,CAAG,KAC/B,CAACJ,EAAeI,GAAKD,GAAME,GAAQC,CAAS,CACpD;GAYA,AAXI6B,EAAQ,SAAS,KACjB,KAAK,MACD,+CAA+CA,EAAQ,KAAK,IAAI,EAAE,sVAMtE,GAGAd,MAAmB,OACnBnB,EAAaC,GAAMkB,CAAc,KAAKhB,KAC1C,KAAK,MACD,4CAA4CyB,EAAS,4BAC3CT,EAAe,2VAM7B;EACJ;CAGG;AACX"}
|
package/dist/vite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vite/tempest-icons.cjs"),t=require("./vite/tempest-vitest.cjs"),n=require("./vite/create-vite-config.cjs"),r=require("./vite/tempest-pwa-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vite/tempest-icons.cjs"),t=require("./vite/tempest-vitest.cjs"),n=require("./vite/create-vite-config.cjs"),r=require("./vite/tempest-pwa-dev-sw.cjs"),i=require("./vite/tempest-pwa-manifest.cjs"),a=require("./vite/tempest-pwa-icons.cjs"),o=require("./vite/tempest-styles.cjs"),s=require("./vite/tempest-csp.cjs");exports.createViteConfig=n.createViteConfig,exports.tempestCsp=s.tempestCsp,exports.tempestIcons=e.tempestIcons,exports.tempestPwaDevSw=r.tempestPwaDevSw,exports.tempestPwaIcons=a.tempestPwaIcons,exports.tempestPwaManifest=i.tempestPwaManifest,exports.tempestStyles=o.tempestStyles,exports.tempestVitest=t.tempestVitest;
|
package/dist/vite.d.ts
CHANGED
|
@@ -300,20 +300,31 @@ export declare interface TempestIconsOptions {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* dev there is no `/sw.js` to register. This plugin compiles `swSrc` on the
|
|
307
|
-
* with esbuild — through one incremental context, not a cold build per
|
|
308
|
-
* and serves it as a classic worker, plus an empty
|
|
309
|
-
*
|
|
310
|
-
*
|
|
303
|
+
* Service-worker plugin: serves `swSrc` under `npm run dev` and bundles it into
|
|
304
|
+
* the production build.
|
|
305
|
+
*
|
|
306
|
+
* In dev there is no `/sw.js` to register. This plugin compiles `swSrc` on the
|
|
307
|
+
* fly with esbuild — through one incremental context, not a cold build per
|
|
308
|
+
* request — and serves it as a classic worker, plus an empty
|
|
309
|
+
* `precache-manifest.json` (there are no hashed build assets to precache in
|
|
310
|
+
* dev — push and runtime caching still work).
|
|
311
|
+
*
|
|
312
|
+
* In `vite build` it bundles the same entry with Vite's own `build()` (IIFE, so
|
|
313
|
+
* it registers as a classic worker, exactly what the old `vite.sw.config.ts`
|
|
314
|
+
* produced) and emits it at `swUrl`. Before 0.83.0 it was serve-only: an app
|
|
315
|
+
* with this plugin and {@link tempestPwaManifest} worked in dev and shipped a
|
|
316
|
+
* production build with no `sw.js` and a zero exit code, so registration
|
|
317
|
+
* 404'd and `navigator.serviceWorker.ready` never resolved. The emitted worker
|
|
318
|
+
* starts with the precache `version` (see {@link precacheVersionBanner}), so
|
|
319
|
+
* every deploy that changes the precache changes the worker bytes and the
|
|
320
|
+
* browser installs it. Pass `build: false` when another step bundles the
|
|
321
|
+
* worker.
|
|
311
322
|
*
|
|
312
323
|
* @example
|
|
313
324
|
* // vite.config.ts
|
|
314
|
-
* import { createViteConfig, tempestPwaDevSw } from "tempest-react-sdk/vite";
|
|
325
|
+
* import { createViteConfig, tempestPwaDevSw, tempestPwaManifest } from "tempest-react-sdk/vite";
|
|
315
326
|
*
|
|
316
|
-
* export default createViteConfig({ plugins: [tempestPwaDevSw()] });
|
|
327
|
+
* export default createViteConfig({ plugins: [tempestPwaManifest(), tempestPwaDevSw()] });
|
|
317
328
|
*/
|
|
318
329
|
export declare function tempestPwaDevSw(options?: TempestPwaDevSwOptions): TempestVitePlugin;
|
|
319
330
|
|
|
@@ -337,6 +348,15 @@ export declare interface TempestPwaDevSwOptions {
|
|
|
337
348
|
manifestUrl?: string;
|
|
338
349
|
/** Serve the worker in dev. Default `true`; set `false` to opt out. */
|
|
339
350
|
enabled?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Bundle `swSrc` into the production build as `swUrl`. Default `true`.
|
|
353
|
+
*
|
|
354
|
+
* Set `false` only when another step bundles the worker (a second
|
|
355
|
+
* `vite build --config vite.sw.config.ts`, `vite-plugin-pwa`). That is also
|
|
356
|
+
* what tells {@link tempestPwaManifest} the worker is external, so its
|
|
357
|
+
* missing-worker check stands down.
|
|
358
|
+
*/
|
|
359
|
+
build?: boolean;
|
|
340
360
|
}
|
|
341
361
|
|
|
342
362
|
/**
|
|
@@ -395,12 +415,21 @@ export declare interface TempestPwaIconsOptions {
|
|
|
395
415
|
* `installPrecache` (from `tempest-react-sdk/sw`) reads this file at the service
|
|
396
416
|
* worker's `install` event to cache the app shell for offline use.
|
|
397
417
|
*
|
|
418
|
+
* Two mistakes that used to ship in silence now fail the build, after the bundle
|
|
419
|
+
* is written: no service worker emitted at
|
|
420
|
+
* {@link TempestPwaManifestOptions.serviceWorker}, and an `additionalUrls`
|
|
421
|
+
* entry that is neither in `public/` nor in the bundle. Pair it with
|
|
422
|
+
* {@link tempestPwaDevSw}, which bundles `src/sw.ts` into the same build.
|
|
423
|
+
*
|
|
398
424
|
* @example
|
|
399
425
|
* // vite.config.ts
|
|
400
|
-
* import { createViteConfig, tempestPwaManifest } from "tempest-react-sdk/vite";
|
|
426
|
+
* import { createViteConfig, tempestPwaDevSw, tempestPwaManifest } from "tempest-react-sdk/vite";
|
|
401
427
|
*
|
|
402
428
|
* export default createViteConfig({
|
|
403
|
-
* plugins: [
|
|
429
|
+
* plugins: [
|
|
430
|
+
* tempestPwaManifest({ additionalUrls: ["/manifest.webmanifest", "/icon.svg"] }),
|
|
431
|
+
* tempestPwaDevSw(),
|
|
432
|
+
* ],
|
|
404
433
|
* });
|
|
405
434
|
*/
|
|
406
435
|
export declare function tempestPwaManifest(options?: TempestPwaManifestOptions): TempestVitePlugin;
|
|
@@ -416,6 +445,14 @@ export declare interface TempestPwaManifestOptions {
|
|
|
416
445
|
* Write these relative to the site root (`/icon.svg`); the resolved Vite
|
|
417
446
|
* `base` is prefixed for you. An entry that already carries the base is
|
|
418
447
|
* left alone, so spelling it out by hand is still correct.
|
|
448
|
+
*
|
|
449
|
+
* Every same-origin entry must be a file in `public/` or in the bundle, or
|
|
450
|
+
* the build fails. A URL that resolves to nothing is answered in production
|
|
451
|
+
* by the SPA fallback (`index.html`) or a 404, so the precache would store
|
|
452
|
+
* the app shell under that name, or fail the worker's install outright. The
|
|
453
|
+
* usual culprit is a web manifest linked from `index.html` but kept outside
|
|
454
|
+
* `public/`: Vite hashes it into `assets/`, where it is already precached.
|
|
455
|
+
* Absolute `http(s):` URLs are not checked.
|
|
419
456
|
*/
|
|
420
457
|
additionalUrls?: string[];
|
|
421
458
|
/** Emitted files matching this are skipped. Default `/\.map$/` (source maps). */
|
|
@@ -431,6 +468,20 @@ export declare interface TempestPwaManifestOptions {
|
|
|
431
468
|
* with the resolved Vite `base`.
|
|
432
469
|
*/
|
|
433
470
|
appShell?: string | false;
|
|
471
|
+
/**
|
|
472
|
+
* URL of the service worker that reads this manifest. The build fails when
|
|
473
|
+
* no file is emitted at that URL. Default: the `swUrl` of
|
|
474
|
+
* {@link tempestPwaDevSw} when it is in the plugin list, `/sw.js` otherwise.
|
|
475
|
+
*
|
|
476
|
+
* A precache manifest is only read by a worker, and a build that ships the
|
|
477
|
+
* manifest without the worker exits 0 while registration 404s in
|
|
478
|
+
* production — `navigator.serviceWorker.ready` never resolves and push,
|
|
479
|
+
* updates and offline all hang without a message. Pass `false` when the
|
|
480
|
+
* worker is bundled by a separate step after this build (a second
|
|
481
|
+
* `vite build --config vite.sw.config.ts`); `tempestPwaDevSw({ build: false })`
|
|
482
|
+
* already says the same and needs nothing here.
|
|
483
|
+
*/
|
|
484
|
+
serviceWorker?: string | false;
|
|
434
485
|
}
|
|
435
486
|
|
|
436
487
|
/**
|
package/dist/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { tempestIcons as e } from "./vite/tempest-icons.js";
|
|
2
2
|
import { tempestVitest as t } from "./vite/tempest-vitest.js";
|
|
3
3
|
import { createViteConfig as n } from "./vite/create-vite-config.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { tempestPwaDevSw as r } from "./vite/tempest-pwa-dev-sw.js";
|
|
5
|
+
import { tempestPwaManifest as i } from "./vite/tempest-pwa-manifest.js";
|
|
6
|
+
import { tempestPwaIcons as a } from "./vite/tempest-pwa-icons.js";
|
|
7
7
|
import { tempestStyles as o } from "./vite/tempest-styles.js";
|
|
8
8
|
import { tempestCsp as s } from "./vite/tempest-csp.js";
|
|
9
|
-
export { n as createViteConfig, s as tempestCsp, e as tempestIcons,
|
|
9
|
+
export { n as createViteConfig, s as tempestCsp, e as tempestIcons, r as tempestPwaDevSw, a as tempestPwaIcons, i as tempestPwaManifest, o as tempestStyles, t as tempestVitest };
|