netjes 0.0.4 → 0.0.6
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 +12 -8
- package/cli/commands.mjs +94 -15
- package/cli/process-io.mjs +2 -2
- package/cli/scaffold.mjs +89 -8
- package/dist/actions.d.ts +3 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +5 -4
- package/dist/actions.js.map +1 -1
- package/dist/client-entry.js +4 -1
- package/dist/client-entry.js.map +1 -1
- package/dist/document.d.ts +3 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +4 -3
- package/dist/document.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lang.d.ts +10 -0
- package/dist/lang.d.ts.map +1 -0
- package/dist/lang.js +26 -0
- package/dist/lang.js.map +1 -0
- package/dist/link.d.ts +15 -3
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +15 -9
- package/dist/link.js.map +1 -1
- package/dist/locale.d.ts +5 -0
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +4 -0
- package/dist/locale.js.map +1 -1
- package/dist/metadata.d.ts +81 -4
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +129 -7
- package/dist/metadata.js.map +1 -1
- package/dist/modules.d.ts +6 -1
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +15 -1
- package/dist/modules.js.map +1 -1
- package/dist/mounted.d.ts +3 -7
- package/dist/mounted.d.ts.map +1 -1
- package/dist/mounted.js.map +1 -1
- package/dist/navigation-guard.d.ts +59 -0
- package/dist/navigation-guard.d.ts.map +1 -0
- package/dist/navigation-guard.js +116 -0
- package/dist/navigation-guard.js.map +1 -0
- package/dist/offline.d.ts +11 -0
- package/dist/offline.d.ts.map +1 -0
- package/dist/offline.js +98 -0
- package/dist/offline.js.map +1 -0
- package/dist/payload.d.ts +38 -2
- package/dist/payload.d.ts.map +1 -1
- package/dist/payload.js +54 -7
- package/dist/payload.js.map +1 -1
- package/dist/render-document.d.ts +8 -1
- package/dist/render-document.d.ts.map +1 -1
- package/dist/render-document.js +2 -0
- package/dist/render-document.js.map +1 -1
- package/dist/root.d.ts.map +1 -1
- package/dist/root.js +10 -1
- package/dist/root.js.map +1 -1
- package/dist/route-tree.d.ts +2 -1
- package/dist/route-tree.d.ts.map +1 -1
- package/dist/route-tree.js +14 -7
- package/dist/route-tree.js.map +1 -1
- package/dist/router.d.ts +101 -20
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +590 -68
- package/dist/router.js.map +1 -1
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -0
- package/dist/schema.js.map +1 -1
- package/dist/service-worker.d.ts +81 -0
- package/dist/service-worker.d.ts.map +1 -0
- package/dist/service-worker.js +584 -0
- package/dist/service-worker.js.map +1 -0
- package/dist/testing.d.ts +18 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +63 -22
- package/dist/testing.js.map +1 -1
- package/package.json +16 -5
- package/sidecar/server.mjs +105 -16
- package/skills/netjes/SKILL.md +5 -3
- package/skills/netjes/references/caching-and-streaming.md +22 -1
- package/skills/netjes/references/data-and-actions.md +5 -4
- package/skills/netjes/references/deployment.md +3 -3
- package/skills/netjes/references/routing.md +14 -6
- package/skills/netjes/references/testing.md +6 -3
- package/src/actions.tsx +5 -4
- package/src/client-entry.tsx +4 -1
- package/src/document.tsx +17 -5
- package/src/index.ts +12 -2
- package/src/lang.ts +28 -0
- package/src/link.tsx +37 -9
- package/src/locale.ts +5 -0
- package/src/metadata.tsx +207 -11
- package/src/modules.ts +19 -3
- package/src/mounted.tsx +3 -3
- package/src/navigation-guard.ts +136 -0
- package/src/offline.ts +97 -0
- package/src/payload.ts +78 -8
- package/src/render-document.tsx +10 -1
- package/src/root.tsx +22 -10
- package/src/route-tree.tsx +18 -7
- package/src/router.tsx +765 -104
- package/src/schema.ts +11 -0
- package/src/service-worker.ts +632 -0
- package/src/testing-vitest.ts +1 -1
- package/src/testing.tsx +68 -15
- package/template/Dockerfile +1 -1
- package/template/Dockerfile.pnpm +68 -0
- package/template/Dockerfile.workspace +52 -0
- package/template/Dockerfile.workspace.dockerignore +15 -0
- package/template/README.md +6 -2
- package/template/_AGENTS.md +9 -3
- package/template/app/layout.tsx +0 -1
- package/template/docker-compose.override.yml +15 -3
- package/template/generated/netjes.ts +1 -1
- package/tsconfig.strict-app.json +27 -0
- package/vite/packages.mjs +97 -0
- package/vite/plugin.d.ts +8 -1
- package/vite/plugin.mjs +156 -9
- /package/template/{public/favicon.svg → app/icon.svg} +0 -0
package/src/metadata.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The Next.js Metadata API: `export const metadata` from pages and layouts, plus metadata sent by the C# loader
|
|
2
2
|
// (`.WithMetadata(...)`, the counterpart of generateMetadata). React 19 hoists the tags into <head>.
|
|
3
3
|
|
|
4
|
-
import { Fragment } from 'react';
|
|
4
|
+
import { Fragment, createContext } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A title, a layout's `template` (`'%s · Site'`) and `default`, or an `absolute` title that skips templates. A
|
|
@@ -38,15 +38,68 @@ export type Metadata = {
|
|
|
38
38
|
};
|
|
39
39
|
twitter?: { card?: 'summary' | 'summary_large_image' | 'app' | 'player'; site?: string; creator?: string; title?: string; description?: string; images?: MetadataImages };
|
|
40
40
|
icons?: { icon?: string; apple?: string };
|
|
41
|
+
/** Prefer `viewport.themeColor` (`export const viewport`), which wins over this one. */
|
|
41
42
|
themeColor?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The base the relative URLs of `alternates`, `openGraph.url` and the Open Graph and Twitter images resolve against,
|
|
45
|
+
* under the app's base path. Default: the server's `NetjesOptions.SiteUrl`; `null` leaves the URLs as they are.
|
|
46
|
+
*/
|
|
47
|
+
metadataBase?: string | URL | null;
|
|
48
|
+
/** A web app manifest's URL, linked with `<link rel="manifest">`. A `manifest.webmanifest` or `manifest.json` file at the root of `app/` wins. */
|
|
49
|
+
manifest?: string;
|
|
50
|
+
/** How the page behaves added to an iPhone's or iPad's home screen. */
|
|
51
|
+
appleWebApp?: {
|
|
52
|
+
/** Writes `<meta name="mobile-web-app-capable" content="yes">`: opened from the home screen, the page has no browser UI. */
|
|
53
|
+
capable?: boolean;
|
|
54
|
+
title?: string;
|
|
55
|
+
statusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
56
|
+
/** A startup screen's image, or one per screen size, each a URL or `{ url, media }`. */
|
|
57
|
+
startupImage?: string | (string | { url: string; media?: string })[];
|
|
58
|
+
};
|
|
42
59
|
other?: Record<string, string>;
|
|
43
60
|
};
|
|
44
61
|
|
|
62
|
+
/** A theme color, for the color schemes or screens its `media` query matches. */
|
|
63
|
+
export type ThemeColorDescriptor = { color: string; media?: string };
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The type of `export const viewport` in layouts and pages: the `<meta name="viewport">`, `theme-color` and
|
|
67
|
+
* `color-scheme` tags, merged from the layouts down to the page (later fields win). Every document has exactly one
|
|
68
|
+
* viewport tag; without any of these it is `width=device-width, initial-scale=1`.
|
|
69
|
+
*/
|
|
70
|
+
export type Viewport = {
|
|
71
|
+
width?: string | number;
|
|
72
|
+
height?: string | number;
|
|
73
|
+
initialScale?: number;
|
|
74
|
+
minimumScale?: number;
|
|
75
|
+
maximumScale?: number;
|
|
76
|
+
userScalable?: boolean;
|
|
77
|
+
viewportFit?: 'auto' | 'cover' | 'contain';
|
|
78
|
+
interactiveWidget?: 'resizes-visual' | 'resizes-content' | 'overlays-content';
|
|
79
|
+
/** One color, or one per color scheme: `[{ color: '#fff', media: '(prefers-color-scheme: light)' }, …]`. Wins over `metadata.themeColor`. */
|
|
80
|
+
themeColor?: string | ThemeColorDescriptor | ThemeColorDescriptor[];
|
|
81
|
+
colorScheme?: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** What the document tells the head about the app: the metadata base, the base path and its metadata files. */
|
|
85
|
+
export type HeadInfo = {
|
|
86
|
+
/** The server's `NetjesOptions.SiteUrl`, the default metadata base. */
|
|
87
|
+
siteUrl?: string | undefined;
|
|
88
|
+
basePath: string;
|
|
89
|
+
/** The app has a manifest file, which the document links: `metadata.manifest` is left out. */
|
|
90
|
+
manifestFile: boolean;
|
|
91
|
+
/** The app has icon files, which the document links. */
|
|
92
|
+
iconFiles: boolean;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** Provided by the document's root; a tree without one (a component test) has no metadata base and no files. */
|
|
96
|
+
export const HeadContext = createContext<HeadInfo>({ basePath: '', manifestFile: false, iconFiles: false });
|
|
97
|
+
|
|
45
98
|
type OpenGraph = NonNullable<Metadata['openGraph']>;
|
|
46
99
|
type Twitter = NonNullable<Metadata['twitter']>;
|
|
47
100
|
|
|
48
101
|
/** The merged result: one title string, the images as a list, everything else merged field by field (later wins). */
|
|
49
|
-
export type ResolvedMetadata = Omit<Metadata, 'title' | 'openGraph' | 'twitter'> & {
|
|
102
|
+
export type ResolvedMetadata = Omit<Metadata, 'title' | 'openGraph' | 'twitter' | 'metadataBase'> & {
|
|
50
103
|
title?: string;
|
|
51
104
|
openGraph?: Omit<OpenGraph, 'images'> & { images?: ResolvedImage[] };
|
|
52
105
|
twitter?: Omit<Twitter, 'images'> & { images?: ResolvedImage[] };
|
|
@@ -86,13 +139,21 @@ function withImages<T extends { images?: MetadataImages }>(group: T): Omit<T, 'i
|
|
|
86
139
|
* title and never through its own; on a layout it is the title when nothing below sets one. `title.absolute` skips
|
|
87
140
|
* templates.
|
|
88
141
|
*/
|
|
89
|
-
export function resolveMetadata(
|
|
142
|
+
export function resolveMetadata(
|
|
143
|
+
layouts: readonly (Metadata | undefined)[],
|
|
144
|
+
page: Metadata | undefined,
|
|
145
|
+
server?: Metadata,
|
|
146
|
+
base: { siteUrl?: string | undefined; basePath?: string | undefined; localeAlternates?: Record<string, string> | undefined } = {},
|
|
147
|
+
): ResolvedMetadata {
|
|
90
148
|
let resolved: ResolvedMetadata = {};
|
|
91
149
|
let template: string | undefined;
|
|
150
|
+
let metadataBase: string | URL | null | undefined = base.siteUrl;
|
|
92
151
|
for (const metadata of [...layouts, page, server]) {
|
|
93
152
|
if (!metadata) continue;
|
|
94
|
-
const { title, openGraph, twitter, alternates, icons, other, ...rest } = metadata;
|
|
153
|
+
const { title, openGraph, twitter, alternates, icons, other, metadataBase: ownBase, appleWebApp, ...rest } = metadata;
|
|
95
154
|
resolved = { ...resolved, ...rest };
|
|
155
|
+
if (ownBase !== undefined) metadataBase = ownBase;
|
|
156
|
+
if (appleWebApp) resolved.appleWebApp = { ...resolved.appleWebApp, ...appleWebApp };
|
|
96
157
|
if (title !== undefined) {
|
|
97
158
|
// The template from above applies to every title but an absolute one, a default included. This title's own
|
|
98
159
|
// template is stored after its title is written, so it applies only to the titles below.
|
|
@@ -106,7 +167,114 @@ export function resolveMetadata(layouts: readonly (Metadata | undefined)[], page
|
|
|
106
167
|
if (icons) resolved.icons = { ...resolved.icons, ...icons };
|
|
107
168
|
if (other) resolved.other = { ...resolved.other, ...other };
|
|
108
169
|
}
|
|
109
|
-
|
|
170
|
+
const generatedLanguages = resolved.alternates?.languages === undefined ? base.localeAlternates : undefined;
|
|
171
|
+
if (generatedLanguages !== undefined) resolved.alternates = { ...resolved.alternates, languages: generatedLanguages };
|
|
172
|
+
return fillTwitter(withAbsoluteUrls(resolved, metadataBase ?? null, base.basePath ?? '', generatedLanguages !== undefined));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Warnings given in this process (development only): each once. */
|
|
176
|
+
const warned = new Set<string>();
|
|
177
|
+
|
|
178
|
+
export function warnOnce(key: string, message: string) {
|
|
179
|
+
if (process.env.NODE_ENV === 'production' || warned.has(key)) return;
|
|
180
|
+
warned.add(key);
|
|
181
|
+
console.warn(message);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A URL with a scheme (`https:`, `data:`): never resolved. */
|
|
185
|
+
const ABSOLUTE = /^[a-z][a-z\d+.-]*:/i;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The listed URLs made absolute against `base` (ADR 0073): a root-relative path under the base path, unless it starts
|
|
189
|
+
* with it already, as `<Link>` does; another relative one against the base path's folder. Without a base they stay as
|
|
190
|
+
* given, and a relative image, which a link preview cannot load, is warned about once in development.
|
|
191
|
+
*/
|
|
192
|
+
function withAbsoluteUrls(resolved: ResolvedMetadata, base: string | URL | null, basePath: string, appRelativeLanguages: boolean): ResolvedMetadata {
|
|
193
|
+
const root = base === null ? null : String(base).replace(/\/+$/, '');
|
|
194
|
+
const absolute = (url: string): string => {
|
|
195
|
+
if (root === null || url === '' || ABSOLUTE.test(url)) return url;
|
|
196
|
+
// A network-path reference (//cdn.example/x) takes the base's scheme only: it names its own host.
|
|
197
|
+
if (url.startsWith('//')) return new URL(url, `${root}/`).href;
|
|
198
|
+
if (!url.startsWith('/')) return new URL(url, `${root}${basePath}/`).href;
|
|
199
|
+
const under = basePath && (url === basePath || url.startsWith(`${basePath}/`) || url.startsWith(`${basePath}?`) || url.startsWith(`${basePath}#`));
|
|
200
|
+
return `${root}${under ? '' : basePath}${url}`;
|
|
201
|
+
};
|
|
202
|
+
const images = (list: ResolvedImage[] | undefined) => {
|
|
203
|
+
if (root === null && list?.some((image) => !ABSOLUTE.test(image.url) && !image.url.startsWith('//'))) {
|
|
204
|
+
warnOnce(
|
|
205
|
+
'relative-image',
|
|
206
|
+
'netjes: a page has a relative og:image or twitter:image, and no metadata base to resolve it against, so link previews cannot load it. ' +
|
|
207
|
+
'Set Netjes:SiteUrl on the server (NetjesOptions.SiteUrl), or metadataBase in the metadata.',
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return list?.map((image) => ({ ...image, url: absolute(image.url) }));
|
|
211
|
+
};
|
|
212
|
+
const result: ResolvedMetadata = { ...resolved };
|
|
213
|
+
if (resolved.alternates) {
|
|
214
|
+
const { canonical, languages } = resolved.alternates;
|
|
215
|
+
// Generated paths are known to be below the app's base path, even when their first segment has the same name.
|
|
216
|
+
const languageUrl = (path: string) => appRelativeLanguages ? `${root ?? ''}${basePath}${path}` : absolute(path);
|
|
217
|
+
result.alternates = {
|
|
218
|
+
...resolved.alternates,
|
|
219
|
+
...(canonical !== undefined ? { canonical: absolute(canonical) } : {}),
|
|
220
|
+
...(languages ? { languages: Object.fromEntries(Object.entries(languages).map(([lang, href]) => [lang, languageUrl(href)])) } : {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (resolved.openGraph) {
|
|
224
|
+
const ogImages = images(resolved.openGraph.images);
|
|
225
|
+
result.openGraph = {
|
|
226
|
+
...resolved.openGraph,
|
|
227
|
+
...(resolved.openGraph.url !== undefined ? { url: absolute(resolved.openGraph.url) } : {}),
|
|
228
|
+
...(ogImages ? { images: ogImages } : {}),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (resolved.twitter?.images) result.twitter = { ...resolved.twitter, images: images(resolved.twitter.images)! };
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The merged viewport: the layouts' and the page's, later fields winning, over `width=device-width, initial-scale=1`. */
|
|
236
|
+
export function resolveViewport(layouts: readonly (Viewport | undefined)[], page: Viewport | undefined): Viewport {
|
|
237
|
+
let resolved: Viewport = { width: 'device-width', initialScale: 1 };
|
|
238
|
+
for (const viewport of [...layouts, page]) if (viewport) resolved = { ...resolved, ...viewport };
|
|
239
|
+
return resolved;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** The `content` of the viewport tag, as Next.js writes it. */
|
|
243
|
+
export function viewportContent(viewport: Viewport): string {
|
|
244
|
+
const parts: [string, string | number | boolean | undefined][] = [
|
|
245
|
+
['width', viewport.width],
|
|
246
|
+
['height', viewport.height],
|
|
247
|
+
['initial-scale', viewport.initialScale],
|
|
248
|
+
['minimum-scale', viewport.minimumScale],
|
|
249
|
+
['maximum-scale', viewport.maximumScale],
|
|
250
|
+
['user-scalable', viewport.userScalable === undefined ? undefined : viewport.userScalable ? 'yes' : 'no'],
|
|
251
|
+
['viewport-fit', viewport.viewportFit],
|
|
252
|
+
['interactive-widget', viewport.interactiveWidget],
|
|
253
|
+
];
|
|
254
|
+
return parts.filter(([, value]) => value !== undefined && value !== '').map(([key, value]) => `${key}=${String(value)}`).join(', ');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function themeColors(color: Viewport['themeColor']): ThemeColorDescriptor[] {
|
|
258
|
+
if (color === undefined || color === '') return [];
|
|
259
|
+
return (Array.isArray(color) ? color : [typeof color === 'string' ? { color } : color]).filter((entry) => !!entry?.color);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Every tag a route puts in the head besides the document's own: the one viewport tag, the theme colors (the
|
|
264
|
+
* viewport's, or else the metadata's) and the color scheme, then the metadata's tags when it has any.
|
|
265
|
+
*/
|
|
266
|
+
export function HeadTags({ viewport, metadata, head }: { viewport: Viewport; metadata?: ResolvedMetadata | undefined; head: HeadInfo }) {
|
|
267
|
+
const colors = themeColors(viewport.themeColor ?? metadata?.themeColor);
|
|
268
|
+
return (
|
|
269
|
+
<>
|
|
270
|
+
<meta name="viewport" content={viewportContent(viewport)} />
|
|
271
|
+
{colors.map((entry, index) => (
|
|
272
|
+
<meta key={`${index}:${entry.color}`} name="theme-color" content={entry.color} {...(entry.media ? { media: entry.media } : {})} />
|
|
273
|
+
))}
|
|
274
|
+
{viewport.colorScheme && <meta name="color-scheme" content={viewport.colorScheme} />}
|
|
275
|
+
{metadata && <MetadataTags metadata={metadata} manifestFile={head.manifestFile} />}
|
|
276
|
+
</>
|
|
277
|
+
);
|
|
110
278
|
}
|
|
111
279
|
|
|
112
280
|
/**
|
|
@@ -139,14 +307,34 @@ function robotsContent(robots: Metadata['robots']): string | undefined {
|
|
|
139
307
|
return `${robots.index === false ? 'noindex' : 'index'}, ${robots.follow === false ? 'nofollow' : 'follow'}`;
|
|
140
308
|
}
|
|
141
309
|
|
|
142
|
-
/**
|
|
143
|
-
|
|
310
|
+
/**
|
|
311
|
+
* A `viewport` among `other`'s names, in any case: the route tree writes the one viewport tag every document has, from
|
|
312
|
+
* `export const viewport`, so a second one is left out, with a warning in development.
|
|
313
|
+
*/
|
|
314
|
+
function isViewport(name: string): boolean {
|
|
315
|
+
if (name.trim().toLowerCase() !== 'viewport') return false;
|
|
316
|
+
warnOnce(
|
|
317
|
+
'other-viewport',
|
|
318
|
+
"netjes: metadata.other sets a viewport, which Netjes leaves out: every document has one viewport tag. Set it with export const viewport in a layout or page.",
|
|
319
|
+
);
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The tags for resolved metadata; rendered anywhere, React puts them in <head>. The theme color is written with the
|
|
325
|
+
* viewport (`HeadTags`), and `metadata.manifest` is left out when the app has a manifest file, which the document links.
|
|
326
|
+
*/
|
|
327
|
+
export function MetadataTags({ metadata, manifestFile = false }: { metadata: ResolvedMetadata; manifestFile?: boolean }) {
|
|
144
328
|
const og = metadata.openGraph;
|
|
145
329
|
const twitter = metadata.twitter;
|
|
146
330
|
const robots = robotsContent(metadata.robots);
|
|
147
331
|
// As in Next.js, an empty Open Graph title or description counts as not set, and an empty tag is not written.
|
|
148
332
|
const ogTitle = og ? og.title || metadata.title : undefined;
|
|
149
333
|
const ogDescription = og ? og.description || metadata.description : undefined;
|
|
334
|
+
const apple = metadata.appleWebApp;
|
|
335
|
+
const startupImages = (apple?.startupImage === undefined ? [] : Array.isArray(apple.startupImage) ? apple.startupImage : [apple.startupImage])
|
|
336
|
+
.map((image) => (typeof image === 'string' ? { url: image } : image))
|
|
337
|
+
.filter((image): image is { url: string; media?: string } => !!image?.url);
|
|
150
338
|
return (
|
|
151
339
|
<>
|
|
152
340
|
{metadata.title !== undefined && <title>{metadata.title}</title>}
|
|
@@ -154,13 +342,19 @@ export function MetadataTags({ metadata }: { metadata: ResolvedMetadata }) {
|
|
|
154
342
|
{metadata.keywords && <meta name="keywords" content={metadata.keywords.join(', ')} />}
|
|
155
343
|
{metadata.authors?.map((author) => <meta key={author.name} name="author" content={author.name} />)}
|
|
156
344
|
{robots && <meta name="robots" content={robots} />}
|
|
157
|
-
{metadata.themeColor && <meta name="theme-color" content={metadata.themeColor} />}
|
|
158
345
|
{metadata.alternates?.canonical && <link rel="canonical" href={metadata.alternates.canonical} />}
|
|
159
346
|
{Object.entries(metadata.alternates?.languages ?? {}).map(([lang, href]) => (
|
|
160
347
|
<link key={lang} rel="alternate" hrefLang={lang} href={href} />
|
|
161
348
|
))}
|
|
162
349
|
{metadata.icons?.icon && <link rel="icon" href={metadata.icons.icon} />}
|
|
163
350
|
{metadata.icons?.apple && <link rel="apple-touch-icon" href={metadata.icons.apple} />}
|
|
351
|
+
{metadata.manifest && !manifestFile && <link rel="manifest" href={metadata.manifest} />}
|
|
352
|
+
{apple?.capable && <meta name="mobile-web-app-capable" content="yes" />}
|
|
353
|
+
{apple?.title && <meta name="apple-mobile-web-app-title" content={apple.title} />}
|
|
354
|
+
{apple?.statusBarStyle && <meta name="apple-mobile-web-app-status-bar-style" content={apple.statusBarStyle} />}
|
|
355
|
+
{startupImages.map((image, index) => (
|
|
356
|
+
<link key={`${index}:${image.url}`} rel="apple-touch-startup-image" href={image.url} {...(image.media ? { media: image.media } : {})} />
|
|
357
|
+
))}
|
|
164
358
|
{ogTitle && <meta property="og:title" content={ogTitle} />}
|
|
165
359
|
{ogDescription && <meta property="og:description" content={ogDescription} />}
|
|
166
360
|
{og?.url && <meta property="og:url" content={og.url} />}
|
|
@@ -186,9 +380,11 @@ export function MetadataTags({ metadata }: { metadata: ResolvedMetadata }) {
|
|
|
186
380
|
{!!image.alt && <meta name="twitter:image:alt" content={image.alt} />}
|
|
187
381
|
</Fragment>
|
|
188
382
|
))}
|
|
189
|
-
{Object.entries(metadata.other ?? {})
|
|
190
|
-
|
|
191
|
-
|
|
383
|
+
{Object.entries(metadata.other ?? {})
|
|
384
|
+
.filter(([name]) => !isViewport(name))
|
|
385
|
+
.map(([name, content]) => (
|
|
386
|
+
<meta key={name} name={name} content={content} />
|
|
387
|
+
))}
|
|
192
388
|
</>
|
|
193
389
|
);
|
|
194
390
|
}
|
package/src/modules.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import type { Metadata } from './metadata.tsx';
|
|
2
|
+
import type { Metadata, Viewport } from './metadata.tsx';
|
|
3
3
|
import type { Params, SegmentRef } from './payload.ts';
|
|
4
4
|
|
|
5
5
|
export type PageComponent = ComponentType<Record<string, unknown>>;
|
|
@@ -26,6 +26,8 @@ export type LoadedSegment = {
|
|
|
26
26
|
id: string;
|
|
27
27
|
/** The layout's `export const metadata`. */
|
|
28
28
|
metadata?: Metadata;
|
|
29
|
+
/** The layout's `export const viewport`. */
|
|
30
|
+
viewport?: Viewport;
|
|
29
31
|
Layout?: LayoutComponent;
|
|
30
32
|
Template?: ComponentType<{ children: ReactNode }>;
|
|
31
33
|
Loading?: ComponentType;
|
|
@@ -37,12 +39,14 @@ export type LoadedSegment = {
|
|
|
37
39
|
/** What `import.meta.glob` produces: root-relative paths (`/app/x/page.tsx`) to lazy imports. */
|
|
38
40
|
export type ModuleMap = Record<string, () => Promise<unknown>>;
|
|
39
41
|
|
|
40
|
-
export type RouteModules = { page: PageComponent | null; segments: LoadedSegment[]; pageMetadata?: Metadata };
|
|
42
|
+
export type RouteModules = { page: PageComponent | null; segments: LoadedSegment[]; pageMetadata?: Metadata; pageViewport?: Viewport };
|
|
41
43
|
|
|
42
44
|
export type ModuleLoader = {
|
|
43
45
|
load(file: string): Promise<ComponentType<never>>;
|
|
44
46
|
/** A loaded module's `export const metadata`, if any. */
|
|
45
47
|
metadataOf(file: string): Metadata | undefined;
|
|
48
|
+
/** A loaded module's `export const viewport`, if any. */
|
|
49
|
+
viewportOf(file: string): Viewport | undefined;
|
|
46
50
|
loadRoute(route: { page: string | null; segments: readonly SegmentRef[] }): Promise<RouteModules>;
|
|
47
51
|
};
|
|
48
52
|
|
|
@@ -87,6 +91,7 @@ function isComponent(value: unknown): value is ComponentType<never> {
|
|
|
87
91
|
export function createModuleLoader(modules: ModuleMap, options: ModuleLoaderOptions = {}): ModuleLoader {
|
|
88
92
|
const cache = new Map<string, Promise<ComponentType<never>>>();
|
|
89
93
|
const metadata = new Map<string, Metadata>();
|
|
94
|
+
const viewports = new Map<string, Viewport>();
|
|
90
95
|
|
|
91
96
|
function load(file: string): Promise<ComponentType<never>> {
|
|
92
97
|
const cached = cache.get(file);
|
|
@@ -99,6 +104,8 @@ export function createModuleLoader(modules: ModuleMap, options: ModuleLoaderOpti
|
|
|
99
104
|
if (!isComponent(component)) throw new Error(`netjes: ${file} must have a default export that is a React component`);
|
|
100
105
|
const exported = (module as { metadata?: unknown }).metadata;
|
|
101
106
|
if (typeof exported === 'object' && exported !== null) metadata.set(file, exported as Metadata);
|
|
107
|
+
const viewport = (module as { viewport?: unknown }).viewport;
|
|
108
|
+
if (typeof viewport === 'object' && viewport !== null) viewports.set(file, viewport as Viewport);
|
|
102
109
|
return component;
|
|
103
110
|
},
|
|
104
111
|
(error: unknown) => {
|
|
@@ -113,6 +120,7 @@ export function createModuleLoader(modules: ModuleMap, options: ModuleLoaderOpti
|
|
|
113
120
|
return {
|
|
114
121
|
load,
|
|
115
122
|
metadataOf: (file) => metadata.get(file),
|
|
123
|
+
viewportOf: (file) => viewports.get(file),
|
|
116
124
|
async loadRoute(route) {
|
|
117
125
|
const optional = (file: string | undefined) => (file ? load(file) : Promise.resolve(undefined));
|
|
118
126
|
const [page, segments] = await Promise.all([
|
|
@@ -131,6 +139,8 @@ export function createModuleLoader(modules: ModuleMap, options: ModuleLoaderOpti
|
|
|
131
139
|
}
|
|
132
140
|
const layoutMetadata = segment.layout ? metadata.get(segment.layout) : undefined;
|
|
133
141
|
if (layoutMetadata) loaded.metadata = layoutMetadata;
|
|
142
|
+
const layoutViewport = segment.layout ? viewports.get(segment.layout) : undefined;
|
|
143
|
+
if (layoutViewport) loaded.viewport = layoutViewport;
|
|
134
144
|
if (Layout) loaded.Layout = Layout as LayoutComponent;
|
|
135
145
|
if (Template) loaded.Template = Template as LoadedSegment['Template'] & object;
|
|
136
146
|
if (Loading) loaded.Loading = Loading as ComponentType;
|
|
@@ -140,7 +150,13 @@ export function createModuleLoader(modules: ModuleMap, options: ModuleLoaderOpti
|
|
|
140
150
|
),
|
|
141
151
|
]);
|
|
142
152
|
const pageMetadata = route.page ? metadata.get(route.page) : undefined;
|
|
143
|
-
|
|
153
|
+
const pageViewport = route.page ? viewports.get(route.page) : undefined;
|
|
154
|
+
return {
|
|
155
|
+
page: (page ?? null) as PageComponent | null,
|
|
156
|
+
segments,
|
|
157
|
+
...(pageMetadata ? { pageMetadata } : {}),
|
|
158
|
+
...(pageViewport ? { pageViewport } : {}),
|
|
159
|
+
};
|
|
144
160
|
},
|
|
145
161
|
};
|
|
146
162
|
}
|
package/src/mounted.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { Form, type FormAction, type FormProps, SubmitButton, type SubmitButtonP
|
|
|
3
3
|
import { type Href, isHrefShape } from './href.ts';
|
|
4
4
|
import { Link, type LinkProps } from './link.tsx';
|
|
5
5
|
import { isDotSegment } from './payload.ts';
|
|
6
|
-
import { type Router, useHref, usePagePayload, usePathname, useRouter } from './router.tsx';
|
|
6
|
+
import { type NavigateOptions, type Router, useHref, usePagePayload, usePathname, useRouter } from './router.tsx';
|
|
7
7
|
|
|
8
8
|
/** The props of a page package's `<Link>`: those of the core `<Link>`, with an href below the package's mount. */
|
|
9
9
|
export type MountedLinkProps<THref extends string = string> = Omit<LinkProps, 'href'> & { href: THref };
|
|
@@ -18,8 +18,8 @@ export type MountedSubmitButtonProps<THref extends string = string> = Omit<Submi
|
|
|
18
18
|
|
|
19
19
|
/** The client router, as a page package's `useRouter()` returns it: `push`, `replace` and `prefetch` go below its mount. */
|
|
20
20
|
export type MountedRouter<THref extends string = string> = Omit<Router, 'push' | 'replace' | 'prefetch'> & {
|
|
21
|
-
push(href: THref, options?:
|
|
22
|
-
replace(href: THref, options?:
|
|
21
|
+
push(href: THref, options?: NavigateOptions): Promise<void>;
|
|
22
|
+
replace(href: THref, options?: NavigateOptions): Promise<void>;
|
|
23
23
|
prefetch(href: THref): void;
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** How a navigation a guard holds would go: adding or replacing an entry, or through history, either way. */
|
|
2
|
+
export type NavigationAttemptType = 'push' | 'replace' | 'back' | 'forward';
|
|
3
|
+
|
|
4
|
+
/** A navigation `useNavigationGuard` holds: where it goes, how, and the two answers to it. */
|
|
5
|
+
export type NavigationAttempt = {
|
|
6
|
+
/** Where it goes: the path, query and fragment, without the base path, as `usePathname()` and the routes read them. */
|
|
7
|
+
to: string;
|
|
8
|
+
type: NavigationAttemptType;
|
|
9
|
+
/** Lets it go on: to the next guard that holds, if any, then to the page. */
|
|
10
|
+
proceed(): void;
|
|
11
|
+
/** Keeps the page on screen: the navigation does not happen. */
|
|
12
|
+
stay(): void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** What `useNavigationGuard` takes. */
|
|
16
|
+
export type NavigationGuardOptions = {
|
|
17
|
+
/** Whether to hold navigations now: a form with changes that are not saved, files on their way up. */
|
|
18
|
+
when: boolean;
|
|
19
|
+
/** Called with each navigation held, which waits until it calls `proceed()` or `stay()`. */
|
|
20
|
+
onAttempt(attempt: NavigationAttempt): void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Guard = { read(): NavigationGuardOptions };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The guards of one router: the ones that hold now, in the order they started to, and the attempt being asked about.
|
|
27
|
+
* Each navigation a guard holds asks the guards in turn, the one that started to hold last first, and runs once every
|
|
28
|
+
* one of them has let it proceed. A newer attempt takes the place of one still being asked about, so a guard that never
|
|
29
|
+
* answers keeps no navigation from being asked again, and so does a navigation that goes at once because no guard holds
|
|
30
|
+
* any more: the earlier attempt's answers then do nothing.
|
|
31
|
+
*
|
|
32
|
+
* While any guard holds, `beforeunload` has the browser ask its own question before the document unloads: a reload,
|
|
33
|
+
* closing the tab, typing an address, a link to another site. The listener is there only then, as such a listener has
|
|
34
|
+
* kept pages out of some browsers' back-forward cache.
|
|
35
|
+
*/
|
|
36
|
+
export class NavigationGuards {
|
|
37
|
+
private readonly guards: Guard[] = [];
|
|
38
|
+
/** The attempt being asked about: dropping it ends it, as a stay does. */
|
|
39
|
+
private asking: { drop(): void } | null = null;
|
|
40
|
+
/** The next unload is a full page load the guards let through: the browser does not ask about it again. */
|
|
41
|
+
private unloadLetThrough = false;
|
|
42
|
+
|
|
43
|
+
private readonly onBeforeUnload = (event: BeforeUnloadEvent) => {
|
|
44
|
+
if (this.unloadLetThrough) {
|
|
45
|
+
this.unloadLetThrough = false;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
// What browsers from before preventDefault() asked for.
|
|
50
|
+
event.returnValue = true;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Whether any guard holds now. */
|
|
54
|
+
get holding(): boolean {
|
|
55
|
+
return this.guards.length > 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Holds navigations until the function it returns is called; `read` gives the latest options. */
|
|
59
|
+
register(read: () => NavigationGuardOptions): () => void {
|
|
60
|
+
const guard: Guard = { read };
|
|
61
|
+
this.guards.push(guard);
|
|
62
|
+
if (this.guards.length === 1) {
|
|
63
|
+
this.unloadLetThrough = false;
|
|
64
|
+
window.addEventListener('beforeunload', this.onBeforeUnload);
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
const at = this.guards.indexOf(guard);
|
|
68
|
+
if (at < 0) return;
|
|
69
|
+
this.guards.splice(at, 1);
|
|
70
|
+
if (this.guards.length === 0) window.removeEventListener('beforeunload', this.onBeforeUnload);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A navigation the guards let through is about to load a document (the router hands it to the browser): the
|
|
76
|
+
* `beforeunload` that follows does not ask again. Only that one.
|
|
77
|
+
*/
|
|
78
|
+
letUnloadThrough(): void {
|
|
79
|
+
if (this.guards.length > 0) this.unloadLetThrough = true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Drops the attempt still waiting for its answer, whose answers then do nothing: Back or Forward to another page took
|
|
84
|
+
* its place, whether a guard holds that step (and asks about it once its entry is put back) or it went on.
|
|
85
|
+
*/
|
|
86
|
+
dropAttempt(): void {
|
|
87
|
+
this.asking?.drop();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Takes the place of the attempt still waiting for its answer, if any. Then runs `go` at once while no guard holds;
|
|
92
|
+
* else asks the guards that hold, newest first, and runs it once each has let it proceed. Resolves with `go`'s
|
|
93
|
+
* promise, or once a guard keeps the page or a newer attempt takes its place.
|
|
94
|
+
*/
|
|
95
|
+
attempt(to: string, type: NavigationAttemptType, go: () => Promise<void>): Promise<void> {
|
|
96
|
+
this.asking?.drop();
|
|
97
|
+
if (this.guards.length === 0) return go();
|
|
98
|
+
return new Promise<void>((resolve) => {
|
|
99
|
+
const queue = [...this.guards].reverse();
|
|
100
|
+
const asking = {
|
|
101
|
+
drop: () => {
|
|
102
|
+
if (this.asking === asking) this.asking = null;
|
|
103
|
+
resolve();
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
this.asking = asking;
|
|
107
|
+
const next = () => {
|
|
108
|
+
if (this.asking !== asking) return;
|
|
109
|
+
// A guard that stopped holding while an earlier one was asked has nothing to say any more.
|
|
110
|
+
let guard = queue.shift();
|
|
111
|
+
while (guard && !this.guards.includes(guard)) guard = queue.shift();
|
|
112
|
+
if (!guard) {
|
|
113
|
+
this.asking = null;
|
|
114
|
+
resolve(go());
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let answered = false;
|
|
118
|
+
guard.read().onAttempt({
|
|
119
|
+
to,
|
|
120
|
+
type,
|
|
121
|
+
proceed: () => {
|
|
122
|
+
if (answered) return;
|
|
123
|
+
answered = true;
|
|
124
|
+
next();
|
|
125
|
+
},
|
|
126
|
+
stay: () => {
|
|
127
|
+
if (answered) return;
|
|
128
|
+
answered = true;
|
|
129
|
+
asking.drop();
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
next();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
package/src/offline.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
import { type Href, isHrefShape } from './href.ts';
|
|
4
|
+
import { DATA_ELEMENT_ID } from './payload.ts';
|
|
5
|
+
import { withBasePath } from './router.tsx';
|
|
6
|
+
|
|
7
|
+
declare const __NETJES_DEV__: boolean;
|
|
8
|
+
|
|
9
|
+
const KEEP_TIMEOUT_MS = 30_000;
|
|
10
|
+
type OfflineMessage = { type: 'netjes:keep'; urls: string[] };
|
|
11
|
+
|
|
12
|
+
function basePath(): string {
|
|
13
|
+
const json = document.getElementById(DATA_ELEMENT_ID)?.textContent;
|
|
14
|
+
if (!json) return '';
|
|
15
|
+
const data: unknown = JSON.parse(json);
|
|
16
|
+
const path = data && typeof data === 'object' && 'basePath' in data ? data.basePath : undefined;
|
|
17
|
+
return typeof path === 'string' && path.startsWith('/') && isHrefShape(path) && !/[?#\\]/.test(path)
|
|
18
|
+
? path.replace(/\/+$/, '')
|
|
19
|
+
: '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function serviceWorkers(): ServiceWorkerContainer | undefined {
|
|
23
|
+
return typeof window === 'undefined' ? undefined : navigator.serviceWorker;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Registers the app's production worker under the current Netjes base path. */
|
|
27
|
+
export async function registerServiceWorker(url?: string): Promise<ServiceWorkerRegistration | undefined> {
|
|
28
|
+
const development = typeof __NETJES_DEV__ === 'undefined' ? import.meta.env?.DEV : __NETJES_DEV__;
|
|
29
|
+
if (development) return undefined;
|
|
30
|
+
const workers = serviceWorkers();
|
|
31
|
+
if (!workers) return undefined;
|
|
32
|
+
const base = basePath();
|
|
33
|
+
return workers.register(url ?? `${base}/sw.js`, { scope: `${base}/` });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function registrationFor(workers: ServiceWorkerContainer, base: string): Promise<ServiceWorkerRegistration | undefined> {
|
|
37
|
+
const scope = new URL(`${base}/`, window.location.href).href;
|
|
38
|
+
const registration = await workers.getRegistration(scope);
|
|
39
|
+
// getRegistration can return a parent registration that also covers this URL.
|
|
40
|
+
return registration?.scope === scope ? registration : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function send(worker: ServiceWorker | null, message: OfflineMessage, timeoutMs: number): Promise<void> {
|
|
44
|
+
if (!worker) throw new Error('netjes: the service worker is not active');
|
|
45
|
+
const channel = new MessageChannel();
|
|
46
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
47
|
+
try {
|
|
48
|
+
await new Promise<void>((resolve, reject) => {
|
|
49
|
+
timeout = setTimeout(() => reject(new Error('netjes: the service worker did not acknowledge the offline request')), timeoutMs);
|
|
50
|
+
channel.port1.onmessage = ({ data }: MessageEvent<unknown>) => {
|
|
51
|
+
if (typeof data !== 'object' || data === null || !('type' in data)) return;
|
|
52
|
+
if (data.type === 'netjes:failed') reject(new Error('netjes: the service worker could not complete the offline request'));
|
|
53
|
+
if (data.type === 'netjes:done') resolve();
|
|
54
|
+
};
|
|
55
|
+
worker.postMessage(message, [channel.port2]);
|
|
56
|
+
});
|
|
57
|
+
} finally {
|
|
58
|
+
clearTimeout(timeout);
|
|
59
|
+
channel.port1.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Asks this app's worker to keep one or more pages, and waits for it to finish. */
|
|
64
|
+
export async function keepOffline(href: Href | readonly Href[]): Promise<void> {
|
|
65
|
+
const workers = serviceWorkers();
|
|
66
|
+
if (!workers) return;
|
|
67
|
+
const base = basePath();
|
|
68
|
+
const registration = await registrationFor(workers, base);
|
|
69
|
+
if (!registration) return;
|
|
70
|
+
const urls = (typeof href === 'string' ? [href] : href).map((url) => {
|
|
71
|
+
if (!url.startsWith('?') && !url.startsWith('#')) return withBasePath(url, base);
|
|
72
|
+
const current = new URL(url, window.location.href);
|
|
73
|
+
return current.pathname + current.search + current.hash;
|
|
74
|
+
});
|
|
75
|
+
await send(registration.active, { type: 'netjes:keep', urls }, KEEP_TIMEOUT_MS);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What follows `<prefix>:pages:` in a page cache's name: the visitor's scope and the cache's random id, nothing more. */
|
|
79
|
+
const PAGE_CACHE_REST = /^[A-Za-z0-9_-]{1,64}:[0-9a-f]{32}$/;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Deletes this app's stored pages: every cache the worker named as a page cache of the app's base path, listed again
|
|
83
|
+
* until none is left. It needs no worker and sends no message. Sign the visitor out first, then await it.
|
|
84
|
+
*/
|
|
85
|
+
export async function clearOffline(): Promise<void> {
|
|
86
|
+
if (typeof caches === 'undefined') return;
|
|
87
|
+
// The worker names a visitor's cache `netjes-offline:<registration scope>:pages:<scope>:<id>`, registered at the base
|
|
88
|
+
// path. The whole name counts: a nested app at `/docs/:pages:x` has caches that start with this prefix too.
|
|
89
|
+
const prefix = `netjes-offline:${new URL(`${basePath()}/`, window.location.href).href}:pages:`;
|
|
90
|
+
const isPageCache = (name: string) => name.startsWith(prefix) && PAGE_CACHE_REST.test(name.slice(prefix.length));
|
|
91
|
+
// A worker can open a cache after a listing; it opens at most one per page response, so this ends.
|
|
92
|
+
for (;;) {
|
|
93
|
+
const names = (await caches.keys()).filter(isPageCache);
|
|
94
|
+
if (names.length === 0) return;
|
|
95
|
+
await Promise.all(names.map((name) => caches.delete(name)));
|
|
96
|
+
}
|
|
97
|
+
}
|