@mark1russell7/site-pages 0.8.0 → 0.8.2
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 +56 -1
- package/build/chunks/offline-header.js +11 -0
- package/build/chunks/offline-header.js.map +1 -0
- package/build/cli.js +130 -6
- package/build/cli.js.map +1 -1
- package/build/offline/index.d.ts +198 -0
- package/build/offline/index.d.ts.map +1 -0
- package/build/offline/index.js +254 -0
- package/build/offline/index.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The offline shell of a built site. Import this module from `@mark1russell7/site-pages/offline` in `vite.config.ts`.
|
|
3
|
+
* It is for Node.js, not for a browser.
|
|
4
|
+
*
|
|
5
|
+
* - `siteOffline` is the Vite plugin. It writes the web manifest and a service worker that keeps the built files.
|
|
6
|
+
* - The pure parts are also here: the list of the kept files, the name of the cache, the source of the worker and the manifest.
|
|
7
|
+
* - `site-pages check --offline` is the gate. It opens the pages of the built site with the network off.
|
|
8
|
+
*
|
|
9
|
+
* The worker keeps only the built files. The data of a site goes offline through its own store, not through this module.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The header of the home page that the service worker of the offline shell gives in place of a page that it does not keep.
|
|
13
|
+
* The gate `site-pages check --offline` reads it. Thus a page of the check that the worker does not keep fails.
|
|
14
|
+
*
|
|
15
|
+
* This file is in the folder of the check, because the site-pages action starts the check from a sparse checkout of this folder.
|
|
16
|
+
*/
|
|
17
|
+
export declare const FALLBACK_HEADER = "x-site-offline";
|
|
18
|
+
/** The file of the service worker, in the root of the built site. */
|
|
19
|
+
export declare const SERVICE_WORKER_FILE = "service-worker.js";
|
|
20
|
+
/** The file of the web manifest, in the root of the built site. */
|
|
21
|
+
export declare const MANIFEST_FILE = "manifest.webmanifest";
|
|
22
|
+
/** The default limit of the size of one kept file: 10 MiB. A larger file stays out of the cache. */
|
|
23
|
+
export declare const MAX_FILE_BYTES: number;
|
|
24
|
+
/** One file of the built site: its path from the root of the folder, with `/`, and its size. */
|
|
25
|
+
interface OfflineFile {
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly bytes: number;
|
|
28
|
+
}
|
|
29
|
+
/** The options of `precacheList`. */
|
|
30
|
+
interface PrecacheOptions {
|
|
31
|
+
/** The path of the site home, for example `/` or `/client/`. */
|
|
32
|
+
readonly base: string;
|
|
33
|
+
/** The limit of the size of one kept file. The default is `MAX_FILE_BYTES`. */
|
|
34
|
+
readonly maxFileBytes?: number | undefined;
|
|
35
|
+
/** The patterns of the paths that stay out of the cache. A pattern examines the path from the root, for example `media/big.mp4`. */
|
|
36
|
+
readonly exclude?: readonly RegExp[] | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** A file that stays out of the cache, and the reason. */
|
|
39
|
+
interface SkippedFile {
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly reason: string;
|
|
42
|
+
}
|
|
43
|
+
/** The result of `precacheList`: the URL paths that the worker keeps, in order, and the files that stay out. */
|
|
44
|
+
interface PrecacheList {
|
|
45
|
+
readonly urls: readonly string[];
|
|
46
|
+
readonly skipped: readonly SkippedFile[];
|
|
47
|
+
}
|
|
48
|
+
/** This function gives the base with one `/` at the start and one `/` at the end. */
|
|
49
|
+
export declare function offlineBase(base: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* This function gives the list of the files that the service worker keeps. The list has the URL path of each file, in
|
|
52
|
+
* order. These files stay out: a source map, the worker, and a file with a dot at the start of a name in its path.
|
|
53
|
+
* A file larger than the limit and a file that a pattern of `exclude` matches also stay out.
|
|
54
|
+
*
|
|
55
|
+
* @throws RangeError when a path is absolute or goes up a folder, or when the limit is not a positive number
|
|
56
|
+
*/
|
|
57
|
+
export declare function precacheList(files: readonly OfflineFile[], options: PrecacheOptions): PrecacheList;
|
|
58
|
+
/**
|
|
59
|
+
* This function gives the name of the cache of a build. The name has a prefix with the base. Then it has the first 16
|
|
60
|
+
* hexadecimal digits of the SHA-256 hash of the kept files. A change of a kept file gives a new name. The worker of the new build then removes the old
|
|
61
|
+
* cache of the same base, and only that cache.
|
|
62
|
+
*/
|
|
63
|
+
export declare function offlineCacheName(base: string, files: readonly {
|
|
64
|
+
readonly url: string;
|
|
65
|
+
readonly content: Uint8Array | string;
|
|
66
|
+
}[]): string;
|
|
67
|
+
/** This function gives the prefix of the names of the caches of a base. The worker removes an old cache only when it has this prefix. */
|
|
68
|
+
export declare function cachePrefix(base: string): string;
|
|
69
|
+
/** The input of `serviceWorkerSource`. */
|
|
70
|
+
interface ServiceWorkerInput {
|
|
71
|
+
/** The path of the site home, for example `/` or `/client/`. */
|
|
72
|
+
readonly base: string;
|
|
73
|
+
/** The name of the cache, from `offlineCacheName`. */
|
|
74
|
+
readonly cache: string;
|
|
75
|
+
/** The URL paths that the worker keeps, from `precacheList`. */
|
|
76
|
+
readonly urls: readonly string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* This function gives the source of the service worker. The worker keeps each URL of the list when it installs. Then it
|
|
80
|
+
* answers a request of a kept URL from the cache. A page of a folder (a path that ends with `/`) is its `index.html`.
|
|
81
|
+
*
|
|
82
|
+
* A navigation to a URL that is not kept goes to the network. With no network, it gets the home page from the cache, with the
|
|
83
|
+
* header `FALLBACK_HEADER`. The worker does not answer other requests, so they go to the network as usual.
|
|
84
|
+
*
|
|
85
|
+
* @throws RangeError when the cache name does not start with the prefix of the base
|
|
86
|
+
*/
|
|
87
|
+
export declare function serviceWorkerSource(input: ServiceWorkerInput): string;
|
|
88
|
+
/** An icon of the web manifest. */
|
|
89
|
+
interface OfflineIcon {
|
|
90
|
+
/** The URL of the icon. A path with no `/` at the start is a path from the site home. */
|
|
91
|
+
readonly src: string;
|
|
92
|
+
/** The sizes, for example `192x192`, or `any` for an SVG file. */
|
|
93
|
+
readonly sizes: string;
|
|
94
|
+
/** The media type, for example `image/png` or `image/svg+xml`. */
|
|
95
|
+
readonly type: string;
|
|
96
|
+
readonly purpose?: "any" | "maskable" | "monochrome" | undefined;
|
|
97
|
+
}
|
|
98
|
+
/** The options of `webManifest`. */
|
|
99
|
+
interface WebManifestOptions {
|
|
100
|
+
/** The name of the app on the screen of the phone. */
|
|
101
|
+
readonly name: string;
|
|
102
|
+
/** The short name, under the icon. The default is the name. */
|
|
103
|
+
readonly shortName?: string | undefined;
|
|
104
|
+
readonly description?: string | undefined;
|
|
105
|
+
/** The color of the bar of the app, a CSS color. */
|
|
106
|
+
readonly themeColor?: string | undefined;
|
|
107
|
+
/** The color of the screen before the first paint, a CSS color. */
|
|
108
|
+
readonly backgroundColor?: string | undefined;
|
|
109
|
+
readonly icons?: readonly OfflineIcon[] | undefined;
|
|
110
|
+
}
|
|
111
|
+
/** The web manifest of a site, as a JSON value. */
|
|
112
|
+
interface WebManifest {
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly short_name: string;
|
|
115
|
+
readonly description?: string;
|
|
116
|
+
readonly start_url: string;
|
|
117
|
+
readonly scope: string;
|
|
118
|
+
readonly display: "standalone";
|
|
119
|
+
readonly theme_color?: string;
|
|
120
|
+
readonly background_color?: string;
|
|
121
|
+
readonly icons: readonly OfflineIcon[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* This function gives the web manifest of the site: the app starts at the site home, and its scope is the site home.
|
|
125
|
+
*
|
|
126
|
+
* @throws RangeError when the name is empty
|
|
127
|
+
*/
|
|
128
|
+
export declare function webManifest(options: WebManifestOptions, base: string): WebManifest;
|
|
129
|
+
/**
|
|
130
|
+
* This function gives the script that registers the service worker, for a `<script type="module">` of a page. A failure
|
|
131
|
+
* goes to `console.warn`, because a browser with no service worker shows the page as usual.
|
|
132
|
+
*/
|
|
133
|
+
export declare function registerScript(base: string): string;
|
|
134
|
+
/** The options of `siteOffline`. */
|
|
135
|
+
interface SiteOfflineOptions {
|
|
136
|
+
/** The fields of the web manifest. The value `false` writes no manifest and adds no manifest link. */
|
|
137
|
+
readonly manifest: WebManifestOptions | false;
|
|
138
|
+
/** The limit of the size of one kept file. The default is `MAX_FILE_BYTES`. */
|
|
139
|
+
readonly maxFileBytes?: number | undefined;
|
|
140
|
+
/** The patterns of the paths, from the root of the folder, that stay out of the cache. */
|
|
141
|
+
readonly exclude?: readonly RegExp[] | undefined;
|
|
142
|
+
/** This function gets the list of the kept files and of the files that stay out, after each build. */
|
|
143
|
+
readonly onList?: ((list: PrecacheList & {
|
|
144
|
+
readonly cache: string;
|
|
145
|
+
}) => void) | undefined;
|
|
146
|
+
}
|
|
147
|
+
/** The part of the resolved Vite config that `siteOffline` reads. */
|
|
148
|
+
interface SiteOfflineConfig {
|
|
149
|
+
readonly root: string;
|
|
150
|
+
readonly base: string;
|
|
151
|
+
/** The build options. With `write: false`, Vite writes no folder, so the plugin writes no file. */
|
|
152
|
+
readonly build: {
|
|
153
|
+
readonly outDir: string;
|
|
154
|
+
readonly write?: boolean | undefined;
|
|
155
|
+
};
|
|
156
|
+
readonly logger?: {
|
|
157
|
+
info(message: string): void;
|
|
158
|
+
} | undefined;
|
|
159
|
+
}
|
|
160
|
+
/** A tag that `siteOffline` adds to each HTML page. */
|
|
161
|
+
type SiteOfflineTag = {
|
|
162
|
+
readonly tag: "link";
|
|
163
|
+
readonly attrs: {
|
|
164
|
+
readonly rel: "manifest";
|
|
165
|
+
readonly href: string;
|
|
166
|
+
};
|
|
167
|
+
readonly injectTo: "head";
|
|
168
|
+
} | {
|
|
169
|
+
readonly tag: "script";
|
|
170
|
+
readonly attrs: {
|
|
171
|
+
readonly type: "module";
|
|
172
|
+
};
|
|
173
|
+
readonly children: string;
|
|
174
|
+
readonly injectTo: "body";
|
|
175
|
+
};
|
|
176
|
+
/** The Vite plugin that `siteOffline` gives. */
|
|
177
|
+
interface SiteOfflinePlugin {
|
|
178
|
+
readonly name: string;
|
|
179
|
+
readonly apply: "build";
|
|
180
|
+
readonly enforce: "post";
|
|
181
|
+
configResolved(config: SiteOfflineConfig): void;
|
|
182
|
+
transformIndexHtml(): SiteOfflineTag[];
|
|
183
|
+
closeBundle(): void;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* This function makes the Vite plugin of the offline shell. The plugin operates only in a build. It does these three operations:
|
|
187
|
+
*
|
|
188
|
+
* - It adds a manifest link and the script that registers the service worker to each HTML page.
|
|
189
|
+
* - It writes `manifest.webmanifest` into the root of the built site.
|
|
190
|
+
* - It writes `service-worker.js` into the root of the built site. The worker keeps each file of the folder, also the files of the public folder and of later plugins.
|
|
191
|
+
*
|
|
192
|
+
* Put the plugin last. A file that a step after the Vite build adds is not in the list of the worker.
|
|
193
|
+
*
|
|
194
|
+
* @throws Error at the start of the build when the base of the site is not a path. Examples are `./` and a URL of another origin.
|
|
195
|
+
*/
|
|
196
|
+
export declare function siteOffline(options: SiteOfflineOptions): SiteOfflinePlugin;
|
|
197
|
+
export type { OfflineFile, OfflineIcon, PrecacheList, PrecacheOptions, ServiceWorkerInput, SiteOfflineConfig, SiteOfflineOptions, SiteOfflinePlugin, SiteOfflineTag, SkippedFile, WebManifest, WebManifestOptions };
|
|
198
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/check/offline-header.ts","../../src/offline/shell.ts","../../src/offline/plugin.ts"],"mappings":";;;;;;;;;;;;;;;;qBAMa;;qBCOA;;qBAGA;;qBAGA;;UAGI;WACN;WACA;;;UAIM;;WAEN;;WAEA;;WAEA,mBAAmB;;;UAIb;WACN;WACA;;;UAIM;WACN;WACA,kBAAkB;;;wBAIb,YAAY;;;;;;;;wBAiBZ,aAAa,gBAAgB,eAAe,SAAS,kBAAkB;;;;;;wBAmCvE,iBAAiB,cAAc;WAA2B;WAAsB,SAAS;;;wBAYzF,YAAY;;UAKX;;WAEN;;WAEA;;WAEA;;;;;;;;;;;wBAYK,oBAAoB,OAAO;;UAoD1B;;WAEN;;WAEA;;WAEA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;WAEA;WACA,iBAAiB;;;UAIX;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,gBAAgB;;;;;;;wBAQX,YAAY,SAAS,oBAAoB,eAAe;;;;;wBAqBxD,eAAe;;UCrOd;;WAEN,UAAU;;WAEV;;WAEA,mBAAmB;;WAEnB,WAAW,MAAM;aAA0B;;;;UAIrC;WACN;WACA;;WAEA;aAAkB;aAAyB;;WAC3C;IAAW,KAAK;;;;KAIf;WACG;WAAsB;aAAkB;aAA0B;;WAAyB;;WAC3F;WAAwB;aAAkB;;WAA2B;WAA2B;;;UAG9F;WACN;WACA;WACA;EACT,eAAe,QAAQ;EACvB,sBAAsB;EACtB;;;;;;;;;;;;;wBAcc,YAAY,SAAS,qBAAqB"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { t as FALLBACK_HEADER } from "../chunks/offline-header.js";
|
|
2
|
+
import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
// src/offline/shell.ts
|
|
6
|
+
/**
|
|
7
|
+
* The parts of the offline shell of a built site, as pure functions. They give the list of the files that the service worker
|
|
8
|
+
* keeps and the name of its cache. They also give the source of the worker, the web manifest and the script that registers the worker.
|
|
9
|
+
*
|
|
10
|
+
* The service worker keeps only the built files. It keeps no data of the site.
|
|
11
|
+
*/
|
|
12
|
+
/** The file of the service worker, in the root of the built site. */
|
|
13
|
+
const SERVICE_WORKER_FILE = "service-worker.js";
|
|
14
|
+
/** The file of the web manifest, in the root of the built site. */
|
|
15
|
+
const MANIFEST_FILE = "manifest.webmanifest";
|
|
16
|
+
/** The default limit of the size of one kept file: 10 MiB. A larger file stays out of the cache. */
|
|
17
|
+
const MAX_FILE_BYTES = 10485760;
|
|
18
|
+
/** This function gives the base with one `/` at the start and one `/` at the end. */
|
|
19
|
+
function offlineBase(base) {
|
|
20
|
+
let start = 0;
|
|
21
|
+
let end = base.length;
|
|
22
|
+
while (start < end && base[start] === "/") start += 1;
|
|
23
|
+
while (end > start && base[end - 1] === "/") end -= 1;
|
|
24
|
+
const inner = base.slice(start, end);
|
|
25
|
+
return inner === "" ? "/" : `/${inner}/`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* This function gives the list of the files that the service worker keeps. The list has the URL path of each file, in
|
|
29
|
+
* order. These files stay out: a source map, the worker, and a file with a dot at the start of a name in its path.
|
|
30
|
+
* A file larger than the limit and a file that a pattern of `exclude` matches also stay out.
|
|
31
|
+
*
|
|
32
|
+
* @throws RangeError when a path is absolute or goes up a folder, or when the limit is not a positive number
|
|
33
|
+
*/
|
|
34
|
+
function precacheList(files, options) {
|
|
35
|
+
const base = offlineBase(options.base);
|
|
36
|
+
const limit = options.maxFileBytes ?? 10485760;
|
|
37
|
+
if (!(limit > 0)) throw new RangeError("The limit of the size of a file is not a positive number");
|
|
38
|
+
const urls = [];
|
|
39
|
+
const skipped = [];
|
|
40
|
+
for (const file of files) {
|
|
41
|
+
const path = file.path.replaceAll("\\", "/");
|
|
42
|
+
const parts = path.split("/");
|
|
43
|
+
if (path.startsWith("/") || /^[A-Za-z]:/.test(path) || parts.includes("..")) throw new RangeError(`The path ${path} is not a path in the folder of the site`);
|
|
44
|
+
const reason = path === "service-worker.js" ? "the service worker" : path.endsWith(".map") ? "a source map" : parts.some((part) => part.startsWith(".")) ? "a name that starts with a dot" : file.bytes > limit ? `larger than ${limit} bytes` : options.exclude?.some((pattern) => pattern.test(path)) ? "a pattern of exclude" : void 0;
|
|
45
|
+
if (reason === void 0) urls.push(base + path);
|
|
46
|
+
else skipped.push({
|
|
47
|
+
path,
|
|
48
|
+
reason
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
urls.sort();
|
|
52
|
+
skipped.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
53
|
+
return {
|
|
54
|
+
urls,
|
|
55
|
+
skipped
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* This function gives the name of the cache of a build. The name has a prefix with the base. Then it has the first 16
|
|
60
|
+
* hexadecimal digits of the SHA-256 hash of the kept files. A change of a kept file gives a new name. The worker of the new build then removes the old
|
|
61
|
+
* cache of the same base, and only that cache.
|
|
62
|
+
*/
|
|
63
|
+
function offlineCacheName(base, files) {
|
|
64
|
+
const hash = createHash("sha256");
|
|
65
|
+
for (const file of [...files].sort((a, b) => a.url < b.url ? -1 : a.url > b.url ? 1 : 0)) {
|
|
66
|
+
hash.update(file.url);
|
|
67
|
+
hash.update("\0");
|
|
68
|
+
hash.update(file.content);
|
|
69
|
+
hash.update("\0");
|
|
70
|
+
}
|
|
71
|
+
return `${cachePrefix(base)}${hash.digest("hex").slice(0, 16)}`;
|
|
72
|
+
}
|
|
73
|
+
/** This function gives the prefix of the names of the caches of a base. The worker removes an old cache only when it has this prefix. */
|
|
74
|
+
function cachePrefix(base) {
|
|
75
|
+
return `site-offline ${offlineBase(base)} `;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* This function gives the source of the service worker. The worker keeps each URL of the list when it installs. Then it
|
|
79
|
+
* answers a request of a kept URL from the cache. A page of a folder (a path that ends with `/`) is its `index.html`.
|
|
80
|
+
*
|
|
81
|
+
* A navigation to a URL that is not kept goes to the network. With no network, it gets the home page from the cache, with the
|
|
82
|
+
* header `FALLBACK_HEADER`. The worker does not answer other requests, so they go to the network as usual.
|
|
83
|
+
*
|
|
84
|
+
* @throws RangeError when the cache name does not start with the prefix of the base
|
|
85
|
+
*/
|
|
86
|
+
function serviceWorkerSource(input) {
|
|
87
|
+
const base = offlineBase(input.base);
|
|
88
|
+
const prefix = cachePrefix(base);
|
|
89
|
+
if (!input.cache.startsWith(prefix)) throw new RangeError(`The cache name does not start with "${prefix}"`);
|
|
90
|
+
const start = `${base}index.html`;
|
|
91
|
+
return `// The service worker of the offline copy of this site. @mark1russell7/site-pages/offline made it at the build.
|
|
92
|
+
const CACHE = ${JSON.stringify(input.cache)};
|
|
93
|
+
const PREFIX = ${JSON.stringify(prefix)};
|
|
94
|
+
const START = ${JSON.stringify(start)};
|
|
95
|
+
const URLS = ${JSON.stringify(input.urls)};
|
|
96
|
+
const KEPT = new Set(URLS);
|
|
97
|
+
const FALLBACK = ${JSON.stringify(FALLBACK_HEADER)};
|
|
98
|
+
|
|
99
|
+
function keyOf(url) {
|
|
100
|
+
return url.pathname.endsWith("/") ? url.pathname + "index.html" : url.pathname;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function marked(response) {
|
|
104
|
+
const headers = new Headers(response.headers);
|
|
105
|
+
headers.set(FALLBACK, "fallback");
|
|
106
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
self.addEventListener("install", (event) => {
|
|
110
|
+
event.waitUntil(caches.open(CACHE).then((cache) => cache.addAll(URLS)).then(() => self.skipWaiting()));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
self.addEventListener("activate", (event) => {
|
|
114
|
+
event.waitUntil(
|
|
115
|
+
caches
|
|
116
|
+
.keys()
|
|
117
|
+
.then((names) => Promise.all(names.filter((name) => name.startsWith(PREFIX) && name !== CACHE).map((name) => caches.delete(name))))
|
|
118
|
+
.then(() => self.clients.claim()),
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
self.addEventListener("fetch", (event) => {
|
|
123
|
+
const request = event.request;
|
|
124
|
+
if (request.method !== "GET") return;
|
|
125
|
+
const url = new URL(request.url);
|
|
126
|
+
if (url.origin !== self.location.origin) return;
|
|
127
|
+
const key = keyOf(url);
|
|
128
|
+
if (KEPT.has(key)) {
|
|
129
|
+
event.respondWith(caches.open(CACHE).then((cache) => cache.match(key)).then((kept) => kept || fetch(request)));
|
|
130
|
+
} else if (request.mode === "navigate") {
|
|
131
|
+
event.respondWith(fetch(request).catch(() => caches.open(CACHE).then((cache) => cache.match(START)).then((kept) => (kept ? marked(kept) : Response.error()))));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* This function gives the web manifest of the site: the app starts at the site home, and its scope is the site home.
|
|
138
|
+
*
|
|
139
|
+
* @throws RangeError when the name is empty
|
|
140
|
+
*/
|
|
141
|
+
function webManifest(options, base) {
|
|
142
|
+
const home = offlineBase(base);
|
|
143
|
+
if (options.name.trim() === "") throw new RangeError("The web manifest has no name");
|
|
144
|
+
const icons = (options.icons ?? []).map((icon) => ({
|
|
145
|
+
...icon,
|
|
146
|
+
src: /^(\/|[a-z][a-z0-9+.-]*:)/i.test(icon.src) ? icon.src : home + icon.src
|
|
147
|
+
}));
|
|
148
|
+
return {
|
|
149
|
+
name: options.name,
|
|
150
|
+
short_name: options.shortName ?? options.name,
|
|
151
|
+
...options.description === void 0 ? {} : { description: options.description },
|
|
152
|
+
start_url: home,
|
|
153
|
+
scope: home,
|
|
154
|
+
display: "standalone",
|
|
155
|
+
...options.themeColor === void 0 ? {} : { theme_color: options.themeColor },
|
|
156
|
+
...options.backgroundColor === void 0 ? {} : { background_color: options.backgroundColor },
|
|
157
|
+
icons
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* This function gives the script that registers the service worker, for a `<script type="module">` of a page. A failure
|
|
162
|
+
* goes to `console.warn`, because a browser with no service worker shows the page as usual.
|
|
163
|
+
*/
|
|
164
|
+
function registerScript(base) {
|
|
165
|
+
const home = offlineBase(base);
|
|
166
|
+
return `if ("serviceWorker" in navigator) navigator.serviceWorker.register(${JSON.stringify(home + SERVICE_WORKER_FILE)}, { scope: ${JSON.stringify(home)} }).catch((error) => console.warn("The offline copy of the site is not ready:", error));`;
|
|
167
|
+
}
|
|
168
|
+
// src/offline/plugin.ts
|
|
169
|
+
/**
|
|
170
|
+
* The Vite plugin of the offline shell. After the build, it writes the web manifest and the service worker into the
|
|
171
|
+
* folder of the site. The worker keeps the built files, so the site opens with no network.
|
|
172
|
+
*
|
|
173
|
+
* This module does not import Vite. The types of the plugin are the small part that it uses.
|
|
174
|
+
*/
|
|
175
|
+
/**
|
|
176
|
+
* This function makes the Vite plugin of the offline shell. The plugin operates only in a build. It does these three operations:
|
|
177
|
+
*
|
|
178
|
+
* - It adds a manifest link and the script that registers the service worker to each HTML page.
|
|
179
|
+
* - It writes `manifest.webmanifest` into the root of the built site.
|
|
180
|
+
* - It writes `service-worker.js` into the root of the built site. The worker keeps each file of the folder, also the files of the public folder and of later plugins.
|
|
181
|
+
*
|
|
182
|
+
* Put the plugin last. A file that a step after the Vite build adds is not in the list of the worker.
|
|
183
|
+
*
|
|
184
|
+
* @throws Error at the start of the build when the base of the site is not a path. Examples are `./` and a URL of another origin.
|
|
185
|
+
*/
|
|
186
|
+
function siteOffline(options) {
|
|
187
|
+
let config;
|
|
188
|
+
const base = () => offlineBase(config?.base ?? "/");
|
|
189
|
+
return {
|
|
190
|
+
name: "site-pages-offline",
|
|
191
|
+
apply: "build",
|
|
192
|
+
enforce: "post",
|
|
193
|
+
configResolved(resolved) {
|
|
194
|
+
if (!resolved.base.startsWith("/")) throw new Error(`The offline shell needs a base that is a path from the root of the origin, not "${resolved.base}".`);
|
|
195
|
+
config = resolved;
|
|
196
|
+
},
|
|
197
|
+
transformIndexHtml() {
|
|
198
|
+
const tags = [];
|
|
199
|
+
if (options.manifest !== false) tags.push({
|
|
200
|
+
tag: "link",
|
|
201
|
+
attrs: {
|
|
202
|
+
rel: "manifest",
|
|
203
|
+
href: base() + MANIFEST_FILE
|
|
204
|
+
},
|
|
205
|
+
injectTo: "head"
|
|
206
|
+
});
|
|
207
|
+
tags.push({
|
|
208
|
+
tag: "script",
|
|
209
|
+
attrs: { type: "module" },
|
|
210
|
+
children: registerScript(base()),
|
|
211
|
+
injectTo: "body"
|
|
212
|
+
});
|
|
213
|
+
return tags;
|
|
214
|
+
},
|
|
215
|
+
closeBundle() {
|
|
216
|
+
if (config === void 0) throw new Error("The offline shell has no config: Vite did not call configResolved.");
|
|
217
|
+
if (config.build.write === false) return;
|
|
218
|
+
const folder = resolve(config.root, config.build.outDir);
|
|
219
|
+
if (options.manifest !== false) writeFileSync(join(folder, MANIFEST_FILE), `${JSON.stringify(webManifest(options.manifest, base()), null, 2)}\n`);
|
|
220
|
+
const files = readdirSync(folder, {
|
|
221
|
+
recursive: true,
|
|
222
|
+
encoding: "utf8"
|
|
223
|
+
}).map((name) => join(folder, name)).filter((file) => statSync(file).isFile()).map((file) => ({
|
|
224
|
+
file,
|
|
225
|
+
path: relative(folder, file).split(sep).join("/"),
|
|
226
|
+
bytes: statSync(file).size
|
|
227
|
+
}));
|
|
228
|
+
const list = precacheList(files, {
|
|
229
|
+
base: base(),
|
|
230
|
+
maxFileBytes: options.maxFileBytes,
|
|
231
|
+
exclude: options.exclude
|
|
232
|
+
});
|
|
233
|
+
const kept = new Set(list.urls);
|
|
234
|
+
const contents = files.filter((file) => kept.has(base() + file.path)).map((file) => ({
|
|
235
|
+
url: base() + file.path,
|
|
236
|
+
content: readFileSync(file.file)
|
|
237
|
+
}));
|
|
238
|
+
const cache = offlineCacheName(base(), contents);
|
|
239
|
+
writeFileSync(join(folder, SERVICE_WORKER_FILE), serviceWorkerSource({
|
|
240
|
+
base: base(),
|
|
241
|
+
cache,
|
|
242
|
+
urls: list.urls
|
|
243
|
+
}));
|
|
244
|
+
config.logger?.info(`site-pages offline: the service worker keeps ${list.urls.length} files, and ${list.skipped.length} files stay out.`);
|
|
245
|
+
options.onList?.({
|
|
246
|
+
...list,
|
|
247
|
+
cache
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export { FALLBACK_HEADER, MANIFEST_FILE, MAX_FILE_BYTES, SERVICE_WORKER_FILE, cachePrefix, offlineBase, offlineCacheName, precacheList, registerScript, serviceWorkerSource, siteOffline, webManifest };
|
|
253
|
+
|
|
254
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/offline/shell.ts","../../src/offline/plugin.ts"],"sourcesContent":["/**\n * The parts of the offline shell of a built site, as pure functions. They give the list of the files that the service worker\n * keeps and the name of its cache. They also give the source of the worker, the web manifest and the script that registers the worker.\n *\n * The service worker keeps only the built files. It keeps no data of the site.\n */\n\nimport { createHash } from \"node:crypto\";\nimport { FALLBACK_HEADER } from \"../check/offline-header.ts\";\n\nexport { FALLBACK_HEADER };\n\n/** The file of the service worker, in the root of the built site. */\nexport const SERVICE_WORKER_FILE = \"service-worker.js\";\n\n/** The file of the web manifest, in the root of the built site. */\nexport const MANIFEST_FILE = \"manifest.webmanifest\";\n\n/** The default limit of the size of one kept file: 10 MiB. A larger file stays out of the cache. */\nexport const MAX_FILE_BYTES: number = 10 * 1024 * 1024;\n\n/** One file of the built site: its path from the root of the folder, with `/`, and its size. */\nexport interface OfflineFile {\n readonly path: string;\n readonly bytes: number;\n}\n\n/** The options of `precacheList`. */\nexport interface PrecacheOptions {\n /** The path of the site home, for example `/` or `/client/`. */\n readonly base: string;\n /** The limit of the size of one kept file. The default is `MAX_FILE_BYTES`. */\n readonly maxFileBytes?: number | undefined;\n /** The patterns of the paths that stay out of the cache. A pattern examines the path from the root, for example `media/big.mp4`. */\n readonly exclude?: readonly RegExp[] | undefined;\n}\n\n/** A file that stays out of the cache, and the reason. */\nexport interface SkippedFile {\n readonly path: string;\n readonly reason: string;\n}\n\n/** The result of `precacheList`: the URL paths that the worker keeps, in order, and the files that stay out. */\nexport interface PrecacheList {\n readonly urls: readonly string[];\n readonly skipped: readonly SkippedFile[];\n}\n\n/** This function gives the base with one `/` at the start and one `/` at the end. */\nexport function offlineBase(base: string): string {\n // A loop, not a regular expression: the time of /\\/+$/ grows as the square of the count of \"/\" (CodeQL js/polynomial-redos).\n let start = 0;\n let end = base.length;\n while (start < end && base[start] === \"/\") start += 1;\n while (end > start && base[end - 1] === \"/\") end -= 1;\n const inner = base.slice(start, end);\n return inner === \"\" ? \"/\" : `/${inner}/`;\n}\n\n/**\n * This function gives the list of the files that the service worker keeps. The list has the URL path of each file, in\n * order. These files stay out: a source map, the worker, and a file with a dot at the start of a name in its path.\n * A file larger than the limit and a file that a pattern of `exclude` matches also stay out.\n *\n * @throws RangeError when a path is absolute or goes up a folder, or when the limit is not a positive number\n */\nexport function precacheList(files: readonly OfflineFile[], options: PrecacheOptions): PrecacheList {\n const base = offlineBase(options.base);\n const limit = options.maxFileBytes ?? MAX_FILE_BYTES;\n if (!(limit > 0)) throw new RangeError(\"The limit of the size of a file is not a positive number\");\n const urls: string[] = [];\n const skipped: SkippedFile[] = [];\n for (const file of files) {\n const path = file.path.replaceAll(\"\\\\\", \"/\");\n const parts = path.split(\"/\");\n if (path.startsWith(\"/\") || /^[A-Za-z]:/.test(path) || parts.includes(\"..\")) throw new RangeError(`The path ${path} is not a path in the folder of the site`);\n const reason =\n path === SERVICE_WORKER_FILE\n ? \"the service worker\"\n : path.endsWith(\".map\")\n ? \"a source map\"\n : parts.some((part) => part.startsWith(\".\"))\n ? \"a name that starts with a dot\"\n : file.bytes > limit\n ? `larger than ${limit} bytes`\n : options.exclude?.some((pattern) => pattern.test(path))\n ? \"a pattern of exclude\"\n : undefined;\n if (reason === undefined) urls.push(base + path);\n else skipped.push({ path, reason });\n }\n urls.sort();\n skipped.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));\n return { urls, skipped };\n}\n\n/**\n * This function gives the name of the cache of a build. The name has a prefix with the base. Then it has the first 16\n * hexadecimal digits of the SHA-256 hash of the kept files. A change of a kept file gives a new name. The worker of the new build then removes the old\n * cache of the same base, and only that cache.\n */\nexport function offlineCacheName(base: string, files: readonly { readonly url: string; readonly content: Uint8Array | string }[]): string {\n const hash = createHash(\"sha256\");\n for (const file of [...files].sort((a, b) => (a.url < b.url ? -1 : a.url > b.url ? 1 : 0))) {\n hash.update(file.url);\n hash.update(\"\\0\");\n hash.update(file.content);\n hash.update(\"\\0\");\n }\n return `${cachePrefix(base)}${hash.digest(\"hex\").slice(0, 16)}`;\n}\n\n/** This function gives the prefix of the names of the caches of a base. The worker removes an old cache only when it has this prefix. */\nexport function cachePrefix(base: string): string {\n return `site-offline ${offlineBase(base)} `;\n}\n\n/** The input of `serviceWorkerSource`. */\nexport interface ServiceWorkerInput {\n /** The path of the site home, for example `/` or `/client/`. */\n readonly base: string;\n /** The name of the cache, from `offlineCacheName`. */\n readonly cache: string;\n /** The URL paths that the worker keeps, from `precacheList`. */\n readonly urls: readonly string[];\n}\n\n/**\n * This function gives the source of the service worker. The worker keeps each URL of the list when it installs. Then it\n * answers a request of a kept URL from the cache. A page of a folder (a path that ends with `/`) is its `index.html`.\n *\n * A navigation to a URL that is not kept goes to the network. With no network, it gets the home page from the cache, with the\n * header `FALLBACK_HEADER`. The worker does not answer other requests, so they go to the network as usual.\n *\n * @throws RangeError when the cache name does not start with the prefix of the base\n */\nexport function serviceWorkerSource(input: ServiceWorkerInput): string {\n const base = offlineBase(input.base);\n const prefix = cachePrefix(base);\n if (!input.cache.startsWith(prefix)) throw new RangeError(`The cache name does not start with \"${prefix}\"`);\n const start = `${base}index.html`;\n return `// The service worker of the offline copy of this site. @mark1russell7/site-pages/offline made it at the build.\nconst CACHE = ${JSON.stringify(input.cache)};\nconst PREFIX = ${JSON.stringify(prefix)};\nconst START = ${JSON.stringify(start)};\nconst URLS = ${JSON.stringify(input.urls)};\nconst KEPT = new Set(URLS);\nconst FALLBACK = ${JSON.stringify(FALLBACK_HEADER)};\n\nfunction keyOf(url) {\n return url.pathname.endsWith(\"/\") ? url.pathname + \"index.html\" : url.pathname;\n}\n\nfunction marked(response) {\n const headers = new Headers(response.headers);\n headers.set(FALLBACK, \"fallback\");\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers });\n}\n\nself.addEventListener(\"install\", (event) => {\n event.waitUntil(caches.open(CACHE).then((cache) => cache.addAll(URLS)).then(() => self.skipWaiting()));\n});\n\nself.addEventListener(\"activate\", (event) => {\n event.waitUntil(\n caches\n .keys()\n .then((names) => Promise.all(names.filter((name) => name.startsWith(PREFIX) && name !== CACHE).map((name) => caches.delete(name))))\n .then(() => self.clients.claim()),\n );\n});\n\nself.addEventListener(\"fetch\", (event) => {\n const request = event.request;\n if (request.method !== \"GET\") return;\n const url = new URL(request.url);\n if (url.origin !== self.location.origin) return;\n const key = keyOf(url);\n if (KEPT.has(key)) {\n event.respondWith(caches.open(CACHE).then((cache) => cache.match(key)).then((kept) => kept || fetch(request)));\n } else if (request.mode === \"navigate\") {\n event.respondWith(fetch(request).catch(() => caches.open(CACHE).then((cache) => cache.match(START)).then((kept) => (kept ? marked(kept) : Response.error()))));\n }\n});\n`;\n}\n\n/** An icon of the web manifest. */\nexport interface OfflineIcon {\n /** The URL of the icon. A path with no `/` at the start is a path from the site home. */\n readonly src: string;\n /** The sizes, for example `192x192`, or `any` for an SVG file. */\n readonly sizes: string;\n /** The media type, for example `image/png` or `image/svg+xml`. */\n readonly type: string;\n readonly purpose?: \"any\" | \"maskable\" | \"monochrome\" | undefined;\n}\n\n/** The options of `webManifest`. */\nexport interface WebManifestOptions {\n /** The name of the app on the screen of the phone. */\n readonly name: string;\n /** The short name, under the icon. The default is the name. */\n readonly shortName?: string | undefined;\n readonly description?: string | undefined;\n /** The color of the bar of the app, a CSS color. */\n readonly themeColor?: string | undefined;\n /** The color of the screen before the first paint, a CSS color. */\n readonly backgroundColor?: string | undefined;\n readonly icons?: readonly OfflineIcon[] | undefined;\n}\n\n/** The web manifest of a site, as a JSON value. */\nexport interface WebManifest {\n readonly name: string;\n readonly short_name: string;\n readonly description?: string;\n readonly start_url: string;\n readonly scope: string;\n readonly display: \"standalone\";\n readonly theme_color?: string;\n readonly background_color?: string;\n readonly icons: readonly OfflineIcon[];\n}\n\n/**\n * This function gives the web manifest of the site: the app starts at the site home, and its scope is the site home.\n *\n * @throws RangeError when the name is empty\n */\nexport function webManifest(options: WebManifestOptions, base: string): WebManifest {\n const home = offlineBase(base);\n if (options.name.trim() === \"\") throw new RangeError(\"The web manifest has no name\");\n const icons = (options.icons ?? []).map((icon) => ({ ...icon, src: /^(\\/|[a-z][a-z0-9+.-]*:)/i.test(icon.src) ? icon.src : home + icon.src }));\n return {\n name: options.name,\n short_name: options.shortName ?? options.name,\n ...(options.description === undefined ? {} : { description: options.description }),\n start_url: home,\n scope: home,\n display: \"standalone\",\n ...(options.themeColor === undefined ? {} : { theme_color: options.themeColor }),\n ...(options.backgroundColor === undefined ? {} : { background_color: options.backgroundColor }),\n icons,\n };\n}\n\n/**\n * This function gives the script that registers the service worker, for a `<script type=\"module\">` of a page. A failure\n * goes to `console.warn`, because a browser with no service worker shows the page as usual.\n */\nexport function registerScript(base: string): string {\n const home = offlineBase(base);\n return `if (\"serviceWorker\" in navigator) navigator.serviceWorker.register(${JSON.stringify(home + SERVICE_WORKER_FILE)}, { scope: ${JSON.stringify(home)} }).catch((error) => console.warn(\"The offline copy of the site is not ready:\", error));`;\n}\n","/**\n * The Vite plugin of the offline shell. After the build, it writes the web manifest and the service worker into the\n * folder of the site. The worker keeps the built files, so the site opens with no network.\n *\n * This module does not import Vite. The types of the plugin are the small part that it uses.\n */\n\nimport { readdirSync, readFileSync, statSync, writeFileSync } from \"node:fs\";\nimport { join, relative, resolve, sep } from \"node:path\";\nimport {\n MANIFEST_FILE,\n offlineBase,\n offlineCacheName,\n precacheList,\n registerScript,\n serviceWorkerSource,\n SERVICE_WORKER_FILE,\n webManifest,\n type PrecacheList,\n type WebManifestOptions,\n} from \"./shell.ts\";\n\n/** The options of `siteOffline`. */\nexport interface SiteOfflineOptions {\n /** The fields of the web manifest. The value `false` writes no manifest and adds no manifest link. */\n readonly manifest: WebManifestOptions | false;\n /** The limit of the size of one kept file. The default is `MAX_FILE_BYTES`. */\n readonly maxFileBytes?: number | undefined;\n /** The patterns of the paths, from the root of the folder, that stay out of the cache. */\n readonly exclude?: readonly RegExp[] | undefined;\n /** This function gets the list of the kept files and of the files that stay out, after each build. */\n readonly onList?: ((list: PrecacheList & { readonly cache: string }) => void) | undefined;\n}\n\n/** The part of the resolved Vite config that `siteOffline` reads. */\nexport interface SiteOfflineConfig {\n readonly root: string;\n readonly base: string;\n /** The build options. With `write: false`, Vite writes no folder, so the plugin writes no file. */\n readonly build: { readonly outDir: string; readonly write?: boolean | undefined };\n readonly logger?: { info(message: string): void } | undefined;\n}\n\n/** A tag that `siteOffline` adds to each HTML page. */\nexport type SiteOfflineTag =\n | { readonly tag: \"link\"; readonly attrs: { readonly rel: \"manifest\"; readonly href: string }; readonly injectTo: \"head\" }\n | { readonly tag: \"script\"; readonly attrs: { readonly type: \"module\" }; readonly children: string; readonly injectTo: \"body\" };\n\n/** The Vite plugin that `siteOffline` gives. */\nexport interface SiteOfflinePlugin {\n readonly name: string;\n readonly apply: \"build\";\n readonly enforce: \"post\";\n configResolved(config: SiteOfflineConfig): void;\n transformIndexHtml(): SiteOfflineTag[];\n closeBundle(): void;\n}\n\n/**\n * This function makes the Vite plugin of the offline shell. The plugin operates only in a build. It does these three operations:\n *\n * - It adds a manifest link and the script that registers the service worker to each HTML page.\n * - It writes `manifest.webmanifest` into the root of the built site.\n * - It writes `service-worker.js` into the root of the built site. The worker keeps each file of the folder, also the files of the public folder and of later plugins.\n *\n * Put the plugin last. A file that a step after the Vite build adds is not in the list of the worker.\n *\n * @throws Error at the start of the build when the base of the site is not a path. Examples are `./` and a URL of another origin.\n */\nexport function siteOffline(options: SiteOfflineOptions): SiteOfflinePlugin {\n let config: SiteOfflineConfig | undefined;\n const base = (): string => offlineBase(config?.base ?? \"/\");\n return {\n name: \"site-pages-offline\",\n apply: \"build\",\n enforce: \"post\",\n configResolved(resolved) {\n if (!resolved.base.startsWith(\"/\")) throw new Error(`The offline shell needs a base that is a path from the root of the origin, not \"${resolved.base}\".`);\n config = resolved;\n },\n transformIndexHtml() {\n const tags: SiteOfflineTag[] = [];\n if (options.manifest !== false) tags.push({ tag: \"link\", attrs: { rel: \"manifest\", href: base() + MANIFEST_FILE }, injectTo: \"head\" });\n tags.push({ tag: \"script\", attrs: { type: \"module\" }, children: registerScript(base()), injectTo: \"body\" });\n return tags;\n },\n closeBundle() {\n if (config === undefined) throw new Error(\"The offline shell has no config: Vite did not call configResolved.\");\n if (config.build.write === false) return;\n const folder = resolve(config.root, config.build.outDir);\n if (options.manifest !== false) writeFileSync(join(folder, MANIFEST_FILE), `${JSON.stringify(webManifest(options.manifest, base()), null, 2)}\\n`);\n const files = readdirSync(folder, { recursive: true, encoding: \"utf8\" })\n .map((name) => join(folder, name))\n .filter((file) => statSync(file).isFile())\n .map((file) => ({ file, path: relative(folder, file).split(sep).join(\"/\"), bytes: statSync(file).size }));\n const list = precacheList(files, { base: base(), maxFileBytes: options.maxFileBytes, exclude: options.exclude });\n const kept = new Set(list.urls);\n const contents = files.filter((file) => kept.has(base() + file.path)).map((file) => ({ url: base() + file.path, content: readFileSync(file.file) }));\n const cache = offlineCacheName(base(), contents);\n writeFileSync(join(folder, SERVICE_WORKER_FILE), serviceWorkerSource({ base: base(), cache, urls: list.urls }));\n config.logger?.info(`site-pages offline: the service worker keeps ${list.urls.length} files, and ${list.skipped.length} files stay out.`);\n options.onList?.({ ...list, cache });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBAAsB;;AAGnC,MAAa,gBAAgB;;AAG7B,MAAa,iBAAyB;;AA+BtC,SAAgB,YAAY,MAAsB;CAEhD,IAAI,QAAQ;CACZ,IAAI,MAAM,KAAK;CACf,OAAO,QAAQ,OAAO,KAAK,WAAW,KAAK,SAAS;CACpD,OAAO,MAAM,SAAS,KAAK,MAAM,OAAO,KAAK,OAAO;CACpD,MAAM,QAAQ,KAAK,MAAM,OAAO,GAAG;CACnC,OAAO,UAAU,KAAK,MAAM,IAAI,MAAM;AACxC;;;;;;;;AASA,SAAgB,aAAa,OAA+B,SAAwC;CAClG,MAAM,OAAO,YAAY,QAAQ,IAAI;CACrC,MAAM,QAAQ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AAE;IAAM,MAAM,SAAS,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;IAAG,OAAO,SAAS,IAAI,CAAC,CAAC;GAAK,EAAE;GAC1G,MAAM,OAAO,aAAa,OAAO;IAAE,MAAM,KAAK;IAAG,cAAc,QAAQ;IAAc,SAAS,QAAQ;GAAQ,CAAC;GAC/G,MAAM,OAAO,IAAI,IAAI,KAAK,IAAI;GAC9B,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;IAAE,KAAK,KAAK,IAAI,KAAK;IAAM,SAAS,aAAa,KAAK,IAAI;GAAE,EAAE;GACnJ,MAAM,QAAQ,iBAAiB,KAAK,GAAG,QAAQ;GAC/C,cAAc,KAAK,QAAQ,mBAAmB,GAAG,oBAAoB;IAAE,MAAM,KAAK;IAAG;IAAO,MAAM,KAAK;GAAK,CAAC,CAAC;GAC9G,OAAO,QAAQ,KAAK,gDAAgD,KAAK,KAAK,OAAO,cAAc,KAAK,QAAQ,OAAO,iBAAiB;GACxI,QAAQ,SAAS;IAAE,GAAG;IAAM;GAAM,CAAC;EACrC;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/site-pages",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.2",
|
|
5
5
|
"description": "A release timeline page and a live status page for the site of a GitHub repository: JSON data and standalone HTML, made at deploy time.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"github-pages",
|
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
"import": "./build/vite.js",
|
|
58
58
|
"default": "./build/vite.js"
|
|
59
59
|
},
|
|
60
|
+
"./offline": {
|
|
61
|
+
"types": "./build/offline/index.d.ts",
|
|
62
|
+
"import": "./build/offline/index.js",
|
|
63
|
+
"default": "./build/offline/index.js"
|
|
64
|
+
},
|
|
60
65
|
"./scroll-cue.css": "./styles/scroll-cue.css",
|
|
61
66
|
"./shell.css": "./styles/shell.css",
|
|
62
67
|
"./explorer.css": "./styles/explorer.css",
|