@sovereignbase/pwa 0.0.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/LICENSE +201 -0
- package/README.md +0 -0
- package/dist/htmlDocument-Cx-dprM5.cjs +225 -0
- package/dist/htmlDocument-Cx-dprM5.cjs.map +1 -0
- package/dist/htmlDocument-DABSNDvf.js +220 -0
- package/dist/htmlDocument-DABSNDvf.js.map +1 -0
- package/dist/index.cjs +258 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +170 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +257 -0
- package/dist/index.js.map +1 -0
- package/dist/serviceWorker/entrypoint.cjs +128 -0
- package/dist/serviceWorker/entrypoint.cjs.map +1 -0
- package/dist/serviceWorker/entrypoint.d.cts +2 -0
- package/dist/serviceWorker/entrypoint.d.ts +2 -0
- package/dist/serviceWorker/entrypoint.js +129 -0
- package/dist/serviceWorker/entrypoint.js.map +1 -0
- package/package.json +85 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
|
|
2
|
+
import { PathLike } from "node:fs";
|
|
3
|
+
import { BCP47LanguageTag, OpenGraphLocale } from "@sovereignbase/utils";
|
|
4
|
+
//#region src/.types/index.d.ts
|
|
5
|
+
type URLPath = `/${string}`;
|
|
6
|
+
type HTTPSUrl = `https://${string}`;
|
|
7
|
+
interface DocumentMarkupOptions {
|
|
8
|
+
/** Language of the document. */
|
|
9
|
+
language: BCP47LanguageTag;
|
|
10
|
+
/** Document title. */
|
|
11
|
+
title: string;
|
|
12
|
+
/** Application name used by installed/mobile browser UI. */
|
|
13
|
+
applicationName: string;
|
|
14
|
+
/** Theme color used by supported browser chrome. */
|
|
15
|
+
themeColor: string;
|
|
16
|
+
/** CSP nonce applied to inline styles and scripts. */
|
|
17
|
+
nonce: string;
|
|
18
|
+
/** Complete markup rendered inside `<body>`. */
|
|
19
|
+
bodyMarkup: string;
|
|
20
|
+
/** Additional markup inserted into `<head>`. */
|
|
21
|
+
headMarkup?: string;
|
|
22
|
+
/** Critical CSS rendered inline during initial document load. */
|
|
23
|
+
stylesheet?: string;
|
|
24
|
+
/** JavaScript module rendered inline into the document. */
|
|
25
|
+
entrypoint?: string;
|
|
26
|
+
/** Favicon URL. */
|
|
27
|
+
iconUrl?: URLPath;
|
|
28
|
+
/** Apple touch icon URL. */
|
|
29
|
+
appleTouchIconUrl?: URLPath;
|
|
30
|
+
/** Safari pinned-tab mask icon URL. */
|
|
31
|
+
maskIconUrl?: URLPath;
|
|
32
|
+
/** Web App Manifest URL. */
|
|
33
|
+
manifestUrl?: URLPath;
|
|
34
|
+
/** Safari pinned-tab icon color. Defaults to `themeColor`. */
|
|
35
|
+
maskIconColor?: string;
|
|
36
|
+
/** Preferred document color schemes. */
|
|
37
|
+
colorScheme?: 'light' | 'dark' | 'light dark' | 'dark light';
|
|
38
|
+
/** Apple standalone status bar appearance. */
|
|
39
|
+
appleStatusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
40
|
+
/** Search and social metadata rendered with the SEO component builders. */
|
|
41
|
+
seo: DocumentSEO;
|
|
42
|
+
}
|
|
43
|
+
interface DocumentSEO {
|
|
44
|
+
jsonLD: JSONLDMarkup;
|
|
45
|
+
languageLinks: LanguageLinksMarkupOptions;
|
|
46
|
+
openGraph: OpenGraphMarkupOptions;
|
|
47
|
+
twitter: TwitterMarkupOptions;
|
|
48
|
+
}
|
|
49
|
+
interface LanguageLinksMarkupOptions {
|
|
50
|
+
host: `${string}.${string}`;
|
|
51
|
+
defaultLanguage: BCP47LanguageTag;
|
|
52
|
+
canonicalLanguage: BCP47LanguageTag;
|
|
53
|
+
alternateLanguages: BCP47LanguageTag[];
|
|
54
|
+
pathSuffix?: '' | `/${string}`;
|
|
55
|
+
}
|
|
56
|
+
interface OpenGraphMarkupOptions {
|
|
57
|
+
locale: OpenGraphLocale;
|
|
58
|
+
siteName: string;
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
url: HTTPSUrl;
|
|
62
|
+
imageUrl: string;
|
|
63
|
+
imageAlt: string;
|
|
64
|
+
imageWidth?: number;
|
|
65
|
+
imageHeight?: number;
|
|
66
|
+
}
|
|
67
|
+
interface TwitterMarkupOptions {
|
|
68
|
+
title: string;
|
|
69
|
+
description: string;
|
|
70
|
+
url: HTTPSUrl;
|
|
71
|
+
imageUrl: string;
|
|
72
|
+
imageAlt: string;
|
|
73
|
+
site: `@${string}`;
|
|
74
|
+
creator: `@${string}`;
|
|
75
|
+
}
|
|
76
|
+
interface JSONLDMarkup {
|
|
77
|
+
site: {
|
|
78
|
+
name: string;
|
|
79
|
+
url: HTTPSUrl;
|
|
80
|
+
};
|
|
81
|
+
application: {
|
|
82
|
+
name: string;
|
|
83
|
+
url: HTTPSUrl;
|
|
84
|
+
inLanguage: BCP47LanguageTag[];
|
|
85
|
+
applicationCategory?: string;
|
|
86
|
+
operatingSystem?: string;
|
|
87
|
+
browserRequirements?: string;
|
|
88
|
+
featureList?: string[];
|
|
89
|
+
screenshot?: HTTPSUrl[];
|
|
90
|
+
};
|
|
91
|
+
page: {
|
|
92
|
+
name: string;
|
|
93
|
+
description: string;
|
|
94
|
+
url: HTTPSUrl;
|
|
95
|
+
inLanguage: BCP47LanguageTag;
|
|
96
|
+
};
|
|
97
|
+
organization: {
|
|
98
|
+
name: string;
|
|
99
|
+
url: HTTPSUrl;
|
|
100
|
+
logo: HTTPSUrl;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/webManifest/index.d.ts
|
|
105
|
+
type Path = `/${string}`;
|
|
106
|
+
type ImageURL = Path | `https://${string}`;
|
|
107
|
+
interface WebManifestScreenshot {
|
|
108
|
+
src: ImageURL;
|
|
109
|
+
sizes: `${number}x${number}`;
|
|
110
|
+
type?: `image/${string}`;
|
|
111
|
+
form_factor?: 'narrow' | 'wide';
|
|
112
|
+
label?: string;
|
|
113
|
+
}
|
|
114
|
+
interface WebManifestShortcut {
|
|
115
|
+
name: string;
|
|
116
|
+
url: Path;
|
|
117
|
+
description?: string;
|
|
118
|
+
icons?: {
|
|
119
|
+
src: ImageURL;
|
|
120
|
+
sizes: `${number}x${number}` | 'any';
|
|
121
|
+
type?: `image/${string}`;
|
|
122
|
+
}[];
|
|
123
|
+
}
|
|
124
|
+
interface WebManifestOptions {
|
|
125
|
+
name: string;
|
|
126
|
+
shortName: string;
|
|
127
|
+
description: string;
|
|
128
|
+
startUrl: Path;
|
|
129
|
+
themeColor: string;
|
|
130
|
+
icon192: ImageURL;
|
|
131
|
+
icon512: ImageURL;
|
|
132
|
+
maskableIcon512: ImageURL;
|
|
133
|
+
id?: Path;
|
|
134
|
+
scope?: Path;
|
|
135
|
+
backgroundColor?: string;
|
|
136
|
+
lang?: BCP47LanguageTag;
|
|
137
|
+
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
138
|
+
orientation?: 'any' | 'natural' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape' | 'landscape-primary' | 'landscape-secondary';
|
|
139
|
+
categories?: string[];
|
|
140
|
+
screenshots?: WebManifestScreenshot[];
|
|
141
|
+
shortcuts?: WebManifestShortcut[];
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/index.d.ts
|
|
145
|
+
declare function pwaize(config: PWAizeConfig): Promise<void>;
|
|
146
|
+
type PWAizeConfig = {
|
|
147
|
+
defaultLanguage: BCP47LanguageTag;
|
|
148
|
+
canonicalLanguage: BCP47LanguageTag;
|
|
149
|
+
alternateLanguages: BCP47LanguageTag[];
|
|
150
|
+
languages: Record<string, {
|
|
151
|
+
document: Omit<DocumentMarkupOptions, 'entrypoint' | 'language' | 'manifestUrl' | 'stylesheet'>;
|
|
152
|
+
manifest: Omit<WebManifestOptions, 'lang'>;
|
|
153
|
+
}>;
|
|
154
|
+
stylesheet: PathLike;
|
|
155
|
+
entrypoint: PathLike;
|
|
156
|
+
outDir: PathLike;
|
|
157
|
+
assetsDir?: PathLike;
|
|
158
|
+
i18nDir?: PathLike;
|
|
159
|
+
minifyPasses?: number;
|
|
160
|
+
serviceWorker?: {
|
|
161
|
+
bypass?: Array<string | RegExp>;
|
|
162
|
+
precache?: `/${string}`[];
|
|
163
|
+
initialize?: () => void;
|
|
164
|
+
waitUntil?: () => Promise<void>;
|
|
165
|
+
};
|
|
166
|
+
_headersFile?: boolean;
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
169
|
+
export { PWAizeConfig, pwaize };
|
|
170
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/.types/index.ts","../src/webManifest/index.ts","../src/index.ts"],"mappings":";;;;KACY;KACA;UAEK;;EAEf,UAAU;;EAGV;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,UAAU;;EAGV,oBAAoB;;EAGpB,cAAc;;EAGd,cAAc;;EAGd;;EAGA;;EAGA;;EAGA,KAAK;;UAGU;EACf,QAAQ;EACR,eAAe;EACf,WAAW;EACX,SAAS;;UAGM;EACf;EACA,iBAAiB;EACjB,mBAAmB;EACnB,oBAAoB;EACpB;;UAGe;EACf,QAAQ;EACR;EACA;EACA;EACA,KAAK;EACL;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA,KAAK;EACL;EACA;EACA;EACA;;UAGe;EACf;IACE;IACA,KAAK;;EAGP;IACE;IACA,KAAK;IACL,YAAY;IACZ;IACA;IACA;IACA;IACA,aAAa;;EAGf;IACE;IACA;IACA,KAAK;IACL,YAAY;;EAGd;IACE;IACA,KAAK;IACL,MAAM;;;;;KCvHL;KACA,WAAW;UAEC;EACf,KAAK;EACL;EACA;EACA;EACA;;UAGe;EACf;EACA,KAAK;EACL;EACA;IACE,KAAK;IACL;IACA;;;UAIa;EACf;EACA;EACA;EACA,UAAU;EACV;EACA,SAAS;EACT,SAAS;EACT,iBAAiB;EACjB,KAAK;EACL,QAAQ;EACR;EACA,OAAO;EACP;EACA;EASA;EACA,cAAc;EACd,YAAY;;;;iBCtCQ,OAAO,QAAQ,eAAe;KA+LxC;EACV,iBAAiB;EACjB,mBAAmB;EACnB,oBAAoB;EAEpB,WAAW;IAGP,UAAU,KACR;IAGF,UAAU,KAAK;;EAInB,YAAY;EACZ,YAAY;EACZ,QAAQ;EAER,YAAY;EACZ,UAAU;EACV;EAEA;IACE,SAAS,eAAe;IACxB;IACA;IACA,kBAAkB;;EAGpB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
|
|
2
|
+
import { PathLike } from "node:fs";
|
|
3
|
+
import { BCP47LanguageTag, OpenGraphLocale } from "@sovereignbase/utils";
|
|
4
|
+
//#region src/.types/index.d.ts
|
|
5
|
+
type URLPath = `/${string}`;
|
|
6
|
+
type HTTPSUrl = `https://${string}`;
|
|
7
|
+
interface DocumentMarkupOptions {
|
|
8
|
+
/** Language of the document. */
|
|
9
|
+
language: BCP47LanguageTag;
|
|
10
|
+
/** Document title. */
|
|
11
|
+
title: string;
|
|
12
|
+
/** Application name used by installed/mobile browser UI. */
|
|
13
|
+
applicationName: string;
|
|
14
|
+
/** Theme color used by supported browser chrome. */
|
|
15
|
+
themeColor: string;
|
|
16
|
+
/** CSP nonce applied to inline styles and scripts. */
|
|
17
|
+
nonce: string;
|
|
18
|
+
/** Complete markup rendered inside `<body>`. */
|
|
19
|
+
bodyMarkup: string;
|
|
20
|
+
/** Additional markup inserted into `<head>`. */
|
|
21
|
+
headMarkup?: string;
|
|
22
|
+
/** Critical CSS rendered inline during initial document load. */
|
|
23
|
+
stylesheet?: string;
|
|
24
|
+
/** JavaScript module rendered inline into the document. */
|
|
25
|
+
entrypoint?: string;
|
|
26
|
+
/** Favicon URL. */
|
|
27
|
+
iconUrl?: URLPath;
|
|
28
|
+
/** Apple touch icon URL. */
|
|
29
|
+
appleTouchIconUrl?: URLPath;
|
|
30
|
+
/** Safari pinned-tab mask icon URL. */
|
|
31
|
+
maskIconUrl?: URLPath;
|
|
32
|
+
/** Web App Manifest URL. */
|
|
33
|
+
manifestUrl?: URLPath;
|
|
34
|
+
/** Safari pinned-tab icon color. Defaults to `themeColor`. */
|
|
35
|
+
maskIconColor?: string;
|
|
36
|
+
/** Preferred document color schemes. */
|
|
37
|
+
colorScheme?: 'light' | 'dark' | 'light dark' | 'dark light';
|
|
38
|
+
/** Apple standalone status bar appearance. */
|
|
39
|
+
appleStatusBarStyle?: 'default' | 'black' | 'black-translucent';
|
|
40
|
+
/** Search and social metadata rendered with the SEO component builders. */
|
|
41
|
+
seo: DocumentSEO;
|
|
42
|
+
}
|
|
43
|
+
interface DocumentSEO {
|
|
44
|
+
jsonLD: JSONLDMarkup;
|
|
45
|
+
languageLinks: LanguageLinksMarkupOptions;
|
|
46
|
+
openGraph: OpenGraphMarkupOptions;
|
|
47
|
+
twitter: TwitterMarkupOptions;
|
|
48
|
+
}
|
|
49
|
+
interface LanguageLinksMarkupOptions {
|
|
50
|
+
host: `${string}.${string}`;
|
|
51
|
+
defaultLanguage: BCP47LanguageTag;
|
|
52
|
+
canonicalLanguage: BCP47LanguageTag;
|
|
53
|
+
alternateLanguages: BCP47LanguageTag[];
|
|
54
|
+
pathSuffix?: '' | `/${string}`;
|
|
55
|
+
}
|
|
56
|
+
interface OpenGraphMarkupOptions {
|
|
57
|
+
locale: OpenGraphLocale;
|
|
58
|
+
siteName: string;
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
url: HTTPSUrl;
|
|
62
|
+
imageUrl: string;
|
|
63
|
+
imageAlt: string;
|
|
64
|
+
imageWidth?: number;
|
|
65
|
+
imageHeight?: number;
|
|
66
|
+
}
|
|
67
|
+
interface TwitterMarkupOptions {
|
|
68
|
+
title: string;
|
|
69
|
+
description: string;
|
|
70
|
+
url: HTTPSUrl;
|
|
71
|
+
imageUrl: string;
|
|
72
|
+
imageAlt: string;
|
|
73
|
+
site: `@${string}`;
|
|
74
|
+
creator: `@${string}`;
|
|
75
|
+
}
|
|
76
|
+
interface JSONLDMarkup {
|
|
77
|
+
site: {
|
|
78
|
+
name: string;
|
|
79
|
+
url: HTTPSUrl;
|
|
80
|
+
};
|
|
81
|
+
application: {
|
|
82
|
+
name: string;
|
|
83
|
+
url: HTTPSUrl;
|
|
84
|
+
inLanguage: BCP47LanguageTag[];
|
|
85
|
+
applicationCategory?: string;
|
|
86
|
+
operatingSystem?: string;
|
|
87
|
+
browserRequirements?: string;
|
|
88
|
+
featureList?: string[];
|
|
89
|
+
screenshot?: HTTPSUrl[];
|
|
90
|
+
};
|
|
91
|
+
page: {
|
|
92
|
+
name: string;
|
|
93
|
+
description: string;
|
|
94
|
+
url: HTTPSUrl;
|
|
95
|
+
inLanguage: BCP47LanguageTag;
|
|
96
|
+
};
|
|
97
|
+
organization: {
|
|
98
|
+
name: string;
|
|
99
|
+
url: HTTPSUrl;
|
|
100
|
+
logo: HTTPSUrl;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/webManifest/index.d.ts
|
|
105
|
+
type Path = `/${string}`;
|
|
106
|
+
type ImageURL = Path | `https://${string}`;
|
|
107
|
+
interface WebManifestScreenshot {
|
|
108
|
+
src: ImageURL;
|
|
109
|
+
sizes: `${number}x${number}`;
|
|
110
|
+
type?: `image/${string}`;
|
|
111
|
+
form_factor?: 'narrow' | 'wide';
|
|
112
|
+
label?: string;
|
|
113
|
+
}
|
|
114
|
+
interface WebManifestShortcut {
|
|
115
|
+
name: string;
|
|
116
|
+
url: Path;
|
|
117
|
+
description?: string;
|
|
118
|
+
icons?: {
|
|
119
|
+
src: ImageURL;
|
|
120
|
+
sizes: `${number}x${number}` | 'any';
|
|
121
|
+
type?: `image/${string}`;
|
|
122
|
+
}[];
|
|
123
|
+
}
|
|
124
|
+
interface WebManifestOptions {
|
|
125
|
+
name: string;
|
|
126
|
+
shortName: string;
|
|
127
|
+
description: string;
|
|
128
|
+
startUrl: Path;
|
|
129
|
+
themeColor: string;
|
|
130
|
+
icon192: ImageURL;
|
|
131
|
+
icon512: ImageURL;
|
|
132
|
+
maskableIcon512: ImageURL;
|
|
133
|
+
id?: Path;
|
|
134
|
+
scope?: Path;
|
|
135
|
+
backgroundColor?: string;
|
|
136
|
+
lang?: BCP47LanguageTag;
|
|
137
|
+
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
138
|
+
orientation?: 'any' | 'natural' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape' | 'landscape-primary' | 'landscape-secondary';
|
|
139
|
+
categories?: string[];
|
|
140
|
+
screenshots?: WebManifestScreenshot[];
|
|
141
|
+
shortcuts?: WebManifestShortcut[];
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/index.d.ts
|
|
145
|
+
declare function pwaize(config: PWAizeConfig): Promise<void>;
|
|
146
|
+
type PWAizeConfig = {
|
|
147
|
+
defaultLanguage: BCP47LanguageTag;
|
|
148
|
+
canonicalLanguage: BCP47LanguageTag;
|
|
149
|
+
alternateLanguages: BCP47LanguageTag[];
|
|
150
|
+
languages: Record<string, {
|
|
151
|
+
document: Omit<DocumentMarkupOptions, 'entrypoint' | 'language' | 'manifestUrl' | 'stylesheet'>;
|
|
152
|
+
manifest: Omit<WebManifestOptions, 'lang'>;
|
|
153
|
+
}>;
|
|
154
|
+
stylesheet: PathLike;
|
|
155
|
+
entrypoint: PathLike;
|
|
156
|
+
outDir: PathLike;
|
|
157
|
+
assetsDir?: PathLike;
|
|
158
|
+
i18nDir?: PathLike;
|
|
159
|
+
minifyPasses?: number;
|
|
160
|
+
serviceWorker?: {
|
|
161
|
+
bypass?: Array<string | RegExp>;
|
|
162
|
+
precache?: `/${string}`[];
|
|
163
|
+
initialize?: () => void;
|
|
164
|
+
waitUntil?: () => Promise<void>;
|
|
165
|
+
};
|
|
166
|
+
_headersFile?: boolean;
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
169
|
+
export { PWAizeConfig, pwaize };
|
|
170
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/.types/index.ts","../src/webManifest/index.ts","../src/index.ts"],"mappings":";;;;KACY;KACA;UAEK;;EAEf,UAAU;;EAGV;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA;;EAGA,UAAU;;EAGV,oBAAoB;;EAGpB,cAAc;;EAGd,cAAc;;EAGd;;EAGA;;EAGA;;EAGA,KAAK;;UAGU;EACf,QAAQ;EACR,eAAe;EACf,WAAW;EACX,SAAS;;UAGM;EACf;EACA,iBAAiB;EACjB,mBAAmB;EACnB,oBAAoB;EACpB;;UAGe;EACf,QAAQ;EACR;EACA;EACA;EACA,KAAK;EACL;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA,KAAK;EACL;EACA;EACA;EACA;;UAGe;EACf;IACE;IACA,KAAK;;EAGP;IACE;IACA,KAAK;IACL,YAAY;IACZ;IACA;IACA;IACA;IACA,aAAa;;EAGf;IACE;IACA;IACA,KAAK;IACL,YAAY;;EAGd;IACE;IACA,KAAK;IACL,MAAM;;;;;KCvHL;KACA,WAAW;UAEC;EACf,KAAK;EACL;EACA;EACA;EACA;;UAGe;EACf;EACA,KAAK;EACL;EACA;IACE,KAAK;IACL;IACA;;;UAIa;EACf;EACA;EACA;EACA,UAAU;EACV;EACA,SAAS;EACT,SAAS;EACT,iBAAiB;EACjB,KAAK;EACL,QAAQ;EACR;EACA,OAAO;EACP;EACA;EASA;EACA,cAAc;EACd,YAAY;;;;iBCtCQ,OAAO,QAAQ,eAAe;KA+LxC;EACV,iBAAiB;EACjB,mBAAmB;EACnB,oBAAoB;EAEpB,WAAW;IAGP,UAAU,KACR;IAGF,UAAU,KAAK;;EAInB,YAAY;EACZ,YAAY;EACZ,QAAQ;EAER,YAAY;EACZ,UAAU;EACV;EAEA;IACE,SAAS,eAAe;IACxB;IACA;IACA,kBAAkB;;EAGpB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Sovereignbase
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { t as documentMarkup } from "./htmlDocument-DABSNDvf.js";
|
|
18
|
+
import { existsSync } from "node:fs";
|
|
19
|
+
import { cp, mkdir, readdir, writeFile } from "node:fs/promises";
|
|
20
|
+
import { basename, join, relative, sep } from "node:path";
|
|
21
|
+
import { build } from "esbuild";
|
|
22
|
+
import { transform } from "lightningcss";
|
|
23
|
+
import { minify } from "html-minifier-terser";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
import { minify as minify$1 } from "terser";
|
|
26
|
+
//#region src/minifyCss/index.ts
|
|
27
|
+
/** Bundles and minifies a CSS entrypoint into a dense string. */
|
|
28
|
+
async function minifyCss(entrypoint) {
|
|
29
|
+
const bundled = await build({
|
|
30
|
+
entryPoints: [entrypoint.toString()],
|
|
31
|
+
bundle: true,
|
|
32
|
+
legalComments: "none",
|
|
33
|
+
minify: true,
|
|
34
|
+
treeShaking: true,
|
|
35
|
+
write: false
|
|
36
|
+
});
|
|
37
|
+
const { code } = transform({
|
|
38
|
+
code: bundled.outputFiles[0].contents,
|
|
39
|
+
filename: entrypoint.toString(),
|
|
40
|
+
minify: true
|
|
41
|
+
});
|
|
42
|
+
return new TextDecoder().decode(code).trim();
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/minifyHtml/index.ts
|
|
46
|
+
/** Minifies a complete HTML document, including inline CSS and JavaScript. */
|
|
47
|
+
async function minifyHtml(source) {
|
|
48
|
+
return minify(source, {
|
|
49
|
+
collapseBooleanAttributes: true,
|
|
50
|
+
collapseInlineTagWhitespace: true,
|
|
51
|
+
collapseWhitespace: true,
|
|
52
|
+
decodeEntities: true,
|
|
53
|
+
html5: true,
|
|
54
|
+
minifyCSS: true,
|
|
55
|
+
minifyJS: {
|
|
56
|
+
compress: {
|
|
57
|
+
dead_code: true,
|
|
58
|
+
passes: 3,
|
|
59
|
+
toplevel: true,
|
|
60
|
+
unused: true
|
|
61
|
+
},
|
|
62
|
+
mangle: { toplevel: true },
|
|
63
|
+
module: true,
|
|
64
|
+
toplevel: true
|
|
65
|
+
},
|
|
66
|
+
removeAttributeQuotes: true,
|
|
67
|
+
removeComments: true,
|
|
68
|
+
removeEmptyAttributes: true,
|
|
69
|
+
removeRedundantAttributes: true,
|
|
70
|
+
sortAttributes: true,
|
|
71
|
+
sortClassName: true,
|
|
72
|
+
useShortDoctype: true
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/minifyJs/index.ts
|
|
77
|
+
/** Bundles, tree-shakes, mangles, and repeatedly minifies JavaScript. */
|
|
78
|
+
async function minifyJs(input, { define, passes = 3 } = {}) {
|
|
79
|
+
let output = (await build({
|
|
80
|
+
...typeof input === "object" && "source" in input ? { stdin: {
|
|
81
|
+
contents: input.source,
|
|
82
|
+
resolveDir: process.cwd()
|
|
83
|
+
} } : { entryPoints: [input instanceof URL ? fileURLToPath(input) : input.toString()] },
|
|
84
|
+
bundle: true,
|
|
85
|
+
define,
|
|
86
|
+
format: "esm",
|
|
87
|
+
legalComments: "none",
|
|
88
|
+
minify: true,
|
|
89
|
+
platform: "browser",
|
|
90
|
+
treeShaking: true,
|
|
91
|
+
write: false
|
|
92
|
+
})).outputFiles[0].text;
|
|
93
|
+
for (let round = 0; round < passes; round += 1) {
|
|
94
|
+
const result = await minify$1(output, {
|
|
95
|
+
compress: {
|
|
96
|
+
dead_code: true,
|
|
97
|
+
passes,
|
|
98
|
+
toplevel: true,
|
|
99
|
+
unused: true
|
|
100
|
+
},
|
|
101
|
+
ecma: 2024,
|
|
102
|
+
format: {
|
|
103
|
+
beautify: false,
|
|
104
|
+
comments: false
|
|
105
|
+
},
|
|
106
|
+
mangle: { toplevel: true },
|
|
107
|
+
module: true,
|
|
108
|
+
toplevel: true
|
|
109
|
+
});
|
|
110
|
+
if (result.code === void 0) throw new Error("Terser did not produce JavaScript output");
|
|
111
|
+
output = result.code;
|
|
112
|
+
}
|
|
113
|
+
return output;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/webManifest/index.ts
|
|
117
|
+
/**
|
|
118
|
+
* Generates a standards-based Web App Manifest JSON string.
|
|
119
|
+
*/
|
|
120
|
+
const webManifest = ({ name, shortName, description, startUrl, themeColor, icon192, icon512, maskableIcon512, id = "/", scope = "/", backgroundColor = themeColor, lang, display = "standalone", orientation, categories, screenshots, shortcuts }) => JSON.stringify({
|
|
121
|
+
id,
|
|
122
|
+
name,
|
|
123
|
+
short_name: shortName,
|
|
124
|
+
description,
|
|
125
|
+
start_url: startUrl,
|
|
126
|
+
scope,
|
|
127
|
+
display,
|
|
128
|
+
theme_color: themeColor,
|
|
129
|
+
background_color: backgroundColor,
|
|
130
|
+
...lang ? { lang } : {},
|
|
131
|
+
...orientation ? { orientation } : {},
|
|
132
|
+
...categories?.length ? { categories } : {},
|
|
133
|
+
...screenshots?.length ? { screenshots } : {},
|
|
134
|
+
...shortcuts?.length ? { shortcuts } : {},
|
|
135
|
+
icons: [
|
|
136
|
+
{
|
|
137
|
+
src: icon192,
|
|
138
|
+
sizes: "192x192",
|
|
139
|
+
type: "image/png",
|
|
140
|
+
purpose: "any"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
src: icon512,
|
|
144
|
+
sizes: "512x512",
|
|
145
|
+
type: "image/png",
|
|
146
|
+
purpose: "any"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
src: maskableIcon512,
|
|
150
|
+
sizes: "512x512",
|
|
151
|
+
type: "image/png",
|
|
152
|
+
purpose: "maskable"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
});
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/index.ts
|
|
158
|
+
async function pwaize(config) {
|
|
159
|
+
const outputDirectory = join(config.outDir.toString(), "web");
|
|
160
|
+
const buildId = crypto.randomUUID();
|
|
161
|
+
const minifyPasses = config.minifyPasses ?? 3;
|
|
162
|
+
const serviceWorkerPath = "/ServiceWorker";
|
|
163
|
+
await mkdir(outputDirectory, { recursive: true });
|
|
164
|
+
for (const directory of [config.assetsDir, config.i18nDir]) {
|
|
165
|
+
if (directory === void 0) continue;
|
|
166
|
+
const sourceDirectory = directory.toString();
|
|
167
|
+
await cp(sourceDirectory, join(outputDirectory, basename(sourceDirectory)), { recursive: true });
|
|
168
|
+
}
|
|
169
|
+
const stylesheet = await minifyCss(config.stylesheet);
|
|
170
|
+
const entrypoint = await minifyJs(config.entrypoint, { passes: minifyPasses });
|
|
171
|
+
const installer = await minifyJs({ source: `const registration=await navigator.serviceWorker.register(${JSON.stringify(serviceWorkerPath)},{scope:"/",type:"module"});await navigator.serviceWorker.ready;if(!navigator.serviceWorker.controller)location.reload();` }, { passes: minifyPasses });
|
|
172
|
+
const languages = [config.defaultLanguage, ...config.alternateLanguages];
|
|
173
|
+
for (const language of languages) {
|
|
174
|
+
const localized = config.languages[language];
|
|
175
|
+
if (localized === void 0) throw new Error(`Missing PWA configuration for language "${language}"`);
|
|
176
|
+
const languageDirectory = join(outputDirectory, language);
|
|
177
|
+
const manifestPath = `/${language}/manifest.webmanifest`;
|
|
178
|
+
const manifest = webManifest({
|
|
179
|
+
...localized.manifest,
|
|
180
|
+
lang: language
|
|
181
|
+
});
|
|
182
|
+
await mkdir(languageDirectory, { recursive: true });
|
|
183
|
+
await writeFile(join(languageDirectory, "manifest.webmanifest"), manifest);
|
|
184
|
+
const installerDocument = await minifyHtml(await documentMarkup({
|
|
185
|
+
...localized.document,
|
|
186
|
+
language,
|
|
187
|
+
stylesheet: "",
|
|
188
|
+
entrypoint: installer,
|
|
189
|
+
manifestUrl: manifestPath
|
|
190
|
+
}));
|
|
191
|
+
await writeFile(join(languageDirectory, "index.html"), installerDocument);
|
|
192
|
+
if (language === config.defaultLanguage) {
|
|
193
|
+
await writeFile(join(outputDirectory, "index.html"), installerDocument);
|
|
194
|
+
await writeFile(join(outputDirectory, "manifest.webmanifest"), manifest);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const buildIdPath = join(outputDirectory, "@sovereignbase", "pwa", "pwaize-build-id.txt");
|
|
198
|
+
await mkdir(join(outputDirectory, "@sovereignbase", "pwa"), { recursive: true });
|
|
199
|
+
await writeFile(buildIdPath, buildId);
|
|
200
|
+
if (config._headersFile === true) await writeFile(join(outputDirectory, "_headers"), `/${serviceWorkerPath.slice(1)}\n Cache-Control: no-cache\n Content-Type: text/javascript;charset=UTF-8\n\n/*\n X-Content-Type-Options: nosniff\n`);
|
|
201
|
+
const precache = [...await publicFiles(outputDirectory), ...config.serviceWorker?.precache ?? []];
|
|
202
|
+
const bypassRules = (config.serviceWorker?.bypass ?? []).map(globRule);
|
|
203
|
+
const compiledServiceWorker = new URL("./serviceWorker/entrypoint.js", import.meta.url);
|
|
204
|
+
const serviceWorker = await minifyJs(existsSync(compiledServiceWorker) ? compiledServiceWorker : new URL("./serviceWorker/entrypoint.ts", import.meta.url), {
|
|
205
|
+
define: {
|
|
206
|
+
buildId: JSON.stringify(buildId),
|
|
207
|
+
buildIdUrl: JSON.stringify("/@sovereignbase/pwa/pwaize-build-id.txt"),
|
|
208
|
+
bypassRules: JSON.stringify(bypassRules),
|
|
209
|
+
customInitialize: config.serviceWorker?.initialize === void 0 ? "undefined" : `(${config.serviceWorker.initialize.toString()})`,
|
|
210
|
+
customWaitUntil: config.serviceWorker?.waitUntil === void 0 ? "undefined" : `(${config.serviceWorker.waitUntil.toString()})`,
|
|
211
|
+
defaultLanguage: JSON.stringify(config.defaultLanguage),
|
|
212
|
+
documentOptions: JSON.stringify(Object.fromEntries(languages.map((language) => [language, config.languages[language].document]))),
|
|
213
|
+
entrypoint: JSON.stringify(entrypoint),
|
|
214
|
+
precache: JSON.stringify(precache),
|
|
215
|
+
stylesheet: JSON.stringify(stylesheet)
|
|
216
|
+
},
|
|
217
|
+
passes: minifyPasses
|
|
218
|
+
});
|
|
219
|
+
await writeFile(join(outputDirectory, serviceWorkerPath.slice(1)), serviceWorker);
|
|
220
|
+
}
|
|
221
|
+
async function publicFiles(directory, root = directory) {
|
|
222
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
223
|
+
const files = [];
|
|
224
|
+
for (const entry of entries) {
|
|
225
|
+
const path = join(directory, entry.name);
|
|
226
|
+
if (entry.isDirectory()) files.push(...await publicFiles(path, root));
|
|
227
|
+
else if (entry.isFile() && entry.name !== "_headers") files.push(`/${relative(root, path).split(sep).join("/")}`);
|
|
228
|
+
}
|
|
229
|
+
return files.sort();
|
|
230
|
+
}
|
|
231
|
+
function globRule(pattern) {
|
|
232
|
+
if (pattern instanceof RegExp) return {
|
|
233
|
+
absolute: true,
|
|
234
|
+
flags: pattern.flags,
|
|
235
|
+
source: pattern.source
|
|
236
|
+
};
|
|
237
|
+
let source = "^";
|
|
238
|
+
for (let index = 0; index < pattern.length; index += 1) {
|
|
239
|
+
const character = pattern[index];
|
|
240
|
+
if (character === "*") {
|
|
241
|
+
if (pattern[index + 1] === "*") {
|
|
242
|
+
source += ".*";
|
|
243
|
+
index += 1;
|
|
244
|
+
} else source += "[^/]*";
|
|
245
|
+
} else if (character === "?") source += ".";
|
|
246
|
+
else source += character.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
absolute: pattern.includes("://"),
|
|
250
|
+
flags: "",
|
|
251
|
+
source: `${source}$`
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
export { pwaize };
|
|
256
|
+
|
|
257
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["minify"],"sources":["../src/minifyCss/index.ts","../src/minifyHtml/index.ts","../src/minifyJs/index.ts","../src/webManifest/index.ts","../src/index.ts"],"sourcesContent":["import type { PathLike } from 'node:fs'\nimport { build } from 'esbuild'\nimport { transform } from 'lightningcss'\n\n/** Bundles and minifies a CSS entrypoint into a dense string. */\nexport default async function minifyCss(entrypoint: PathLike): Promise<string> {\n const bundled = await build({\n entryPoints: [entrypoint.toString()],\n bundle: true,\n legalComments: 'none',\n minify: true,\n treeShaking: true,\n write: false,\n })\n const { code } = transform({\n code: bundled.outputFiles[0].contents,\n filename: entrypoint.toString(),\n minify: true,\n })\n\n return new TextDecoder().decode(code).trim()\n}\n","import { minify } from 'html-minifier-terser'\n\n/** Minifies a complete HTML document, including inline CSS and JavaScript. */\nexport default async function minifyHtml(source: string): Promise<string> {\n return minify(source, {\n collapseBooleanAttributes: true,\n collapseInlineTagWhitespace: true,\n collapseWhitespace: true,\n decodeEntities: true,\n html5: true,\n minifyCSS: true,\n minifyJS: {\n compress: {\n dead_code: true,\n passes: 3,\n toplevel: true,\n unused: true,\n },\n mangle: {\n toplevel: true,\n },\n module: true,\n toplevel: true,\n },\n removeAttributeQuotes: true,\n removeComments: true,\n removeEmptyAttributes: true,\n removeRedundantAttributes: true,\n sortAttributes: true,\n sortClassName: true,\n useShortDoctype: true,\n })\n}\n","import type { PathLike } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { build } from 'esbuild'\nimport { minify } from 'terser'\n\ntype JavaScriptInput = PathLike | { source: string }\n\ntype MinifyJsOptions = {\n define?: Record<string, string>\n passes?: number\n}\n\n/** Bundles, tree-shakes, mangles, and repeatedly minifies JavaScript. */\nexport default async function minifyJs(\n input: JavaScriptInput,\n { define, passes = 3 }: MinifyJsOptions = {}\n): Promise<string> {\n const bundled = await build({\n ...(typeof input === 'object' && 'source' in input\n ? { stdin: { contents: input.source, resolveDir: process.cwd() } }\n : {\n entryPoints: [\n input instanceof URL ? fileURLToPath(input) : input.toString(),\n ],\n }),\n bundle: true,\n define,\n format: 'esm',\n legalComments: 'none',\n minify: true,\n platform: 'browser',\n treeShaking: true,\n write: false,\n })\n\n let output = bundled.outputFiles[0].text\n\n for (let round = 0; round < passes; round += 1) {\n const result = await minify(output, {\n compress: {\n dead_code: true,\n passes,\n toplevel: true,\n unused: true,\n },\n ecma: 2024,\n format: {\n beautify: false,\n comments: false,\n },\n mangle: {\n toplevel: true,\n },\n module: true,\n toplevel: true,\n })\n\n if (result.code === undefined) {\n throw new Error('Terser did not produce JavaScript output')\n }\n\n output = result.code\n }\n\n return output\n}\n","import type { BCP47LanguageTag } from '@sovereignbase/utils'\n\ntype Path = `/${string}`\ntype ImageURL = Path | `https://${string}`\n\nexport interface WebManifestScreenshot {\n src: ImageURL\n sizes: `${number}x${number}`\n type?: `image/${string}`\n form_factor?: 'narrow' | 'wide'\n label?: string\n}\n\nexport interface WebManifestShortcut {\n name: string\n url: Path\n description?: string\n icons?: {\n src: ImageURL\n sizes: `${number}x${number}` | 'any'\n type?: `image/${string}`\n }[]\n}\n\nexport interface WebManifestOptions {\n name: string\n shortName: string\n description: string\n startUrl: Path\n themeColor: string\n icon192: ImageURL\n icon512: ImageURL\n maskableIcon512: ImageURL\n id?: Path\n scope?: Path\n backgroundColor?: string\n lang?: BCP47LanguageTag\n display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser'\n orientation?:\n | 'any'\n | 'natural'\n | 'portrait'\n | 'portrait-primary'\n | 'portrait-secondary'\n | 'landscape'\n | 'landscape-primary'\n | 'landscape-secondary'\n categories?: string[]\n screenshots?: WebManifestScreenshot[]\n shortcuts?: WebManifestShortcut[]\n}\n\n/**\n * Generates a standards-based Web App Manifest JSON string.\n */\nexport const webManifest = ({\n name,\n shortName,\n description,\n startUrl,\n themeColor,\n icon192,\n icon512,\n maskableIcon512,\n id = '/',\n scope = '/',\n backgroundColor = themeColor,\n lang,\n display = 'standalone',\n orientation,\n categories,\n screenshots,\n shortcuts,\n}: WebManifestOptions): string =>\n JSON.stringify({\n id,\n name,\n short_name: shortName,\n description,\n start_url: startUrl,\n scope,\n display,\n theme_color: themeColor,\n background_color: backgroundColor,\n ...(lang ? { lang } : {}),\n ...(orientation ? { orientation } : {}),\n ...(categories?.length ? { categories } : {}),\n ...(screenshots?.length ? { screenshots } : {}),\n ...(shortcuts?.length ? { shortcuts } : {}),\n icons: [\n {\n src: icon192,\n sizes: '192x192',\n type: 'image/png',\n purpose: 'any',\n },\n {\n src: icon512,\n sizes: '512x512',\n type: 'image/png',\n purpose: 'any',\n },\n {\n src: maskableIcon512,\n sizes: '512x512',\n type: 'image/png',\n purpose: 'maskable',\n },\n ],\n })\n","import { existsSync, type PathLike } from 'node:fs'\nimport { cp, mkdir, readdir, writeFile } from 'node:fs/promises'\nimport { basename, join, relative, sep } from 'node:path'\nimport type { BCP47LanguageTag } from '@sovereignbase/utils'\nimport type { DocumentMarkupOptions } from './.types/index.js'\nimport { documentMarkup } from './htmlDocument/index.js'\nimport minifyCss from './minifyCss/index.js'\nimport minifyHtml from './minifyHtml/index.js'\nimport minifyJs from './minifyJs/index.js'\nimport { webManifest, type WebManifestOptions } from './webManifest/index.js'\n\nexport async function pwaize(config: PWAizeConfig): Promise<void> {\n const outputDirectory = join(config.outDir.toString(), 'web')\n const buildId = crypto.randomUUID()\n const minifyPasses = config.minifyPasses ?? 3\n const serviceWorkerPath = '/ServiceWorker'\n\n await mkdir(outputDirectory, { recursive: true })\n\n for (const directory of [config.assetsDir, config.i18nDir]) {\n if (directory === undefined) continue\n\n const sourceDirectory = directory.toString()\n await cp(\n sourceDirectory,\n join(outputDirectory, basename(sourceDirectory)),\n {\n recursive: true,\n }\n )\n }\n\n const stylesheet = await minifyCss(config.stylesheet)\n const entrypoint = await minifyJs(config.entrypoint, {\n passes: minifyPasses,\n })\n const installer = await minifyJs(\n {\n source: `const registration=await navigator.serviceWorker.register(${JSON.stringify(serviceWorkerPath)},{scope:\"/\",type:\"module\"});await navigator.serviceWorker.ready;if(!navigator.serviceWorker.controller)location.reload();`,\n },\n { passes: minifyPasses }\n )\n const languages = [config.defaultLanguage, ...config.alternateLanguages]\n\n for (const language of languages) {\n const localized = config.languages[language]\n if (localized === undefined) {\n throw new Error(`Missing PWA configuration for language \"${language}\"`)\n }\n\n const languageDirectory = join(outputDirectory, language)\n const manifestPath = `/${language}/manifest.webmanifest` as const\n const manifest = webManifest({\n ...localized.manifest,\n lang: language,\n })\n\n await mkdir(languageDirectory, { recursive: true })\n await writeFile(join(languageDirectory, 'manifest.webmanifest'), manifest)\n\n const installerDocument = await minifyHtml(\n await documentMarkup({\n ...localized.document,\n language,\n stylesheet: '',\n entrypoint: installer,\n manifestUrl: manifestPath,\n })\n )\n\n await writeFile(join(languageDirectory, 'index.html'), installerDocument)\n\n if (language === config.defaultLanguage) {\n await writeFile(join(outputDirectory, 'index.html'), installerDocument)\n await writeFile(join(outputDirectory, 'manifest.webmanifest'), manifest)\n }\n }\n\n const buildIdPath = join(\n outputDirectory,\n '@sovereignbase',\n 'pwa',\n 'pwaize-build-id.txt'\n )\n await mkdir(join(outputDirectory, '@sovereignbase', 'pwa'), {\n recursive: true,\n })\n await writeFile(buildIdPath, buildId)\n\n if (config._headersFile === true) {\n await writeFile(\n join(outputDirectory, '_headers'),\n `/${serviceWorkerPath.slice(1)}\\n Cache-Control: no-cache\\n Content-Type: text/javascript;charset=UTF-8\\n\\n/*\\n X-Content-Type-Options: nosniff\\n`\n )\n }\n\n const precache = [\n ...(await publicFiles(outputDirectory)),\n ...(config.serviceWorker?.precache ?? []),\n ]\n const bypassRules = (config.serviceWorker?.bypass ?? []).map(globRule)\n const compiledServiceWorker = new URL(\n './serviceWorker/entrypoint.js',\n import.meta.url\n )\n const serviceWorker = await minifyJs(\n existsSync(compiledServiceWorker)\n ? compiledServiceWorker\n : new URL('./serviceWorker/entrypoint.ts', import.meta.url),\n {\n define: {\n buildId: JSON.stringify(buildId),\n buildIdUrl: JSON.stringify('/@sovereignbase/pwa/pwaize-build-id.txt'),\n bypassRules: JSON.stringify(bypassRules),\n customInitialize:\n config.serviceWorker?.initialize === undefined\n ? 'undefined'\n : `(${config.serviceWorker.initialize.toString()})`,\n customWaitUntil:\n config.serviceWorker?.waitUntil === undefined\n ? 'undefined'\n : `(${config.serviceWorker.waitUntil.toString()})`,\n defaultLanguage: JSON.stringify(config.defaultLanguage),\n documentOptions: JSON.stringify(\n Object.fromEntries(\n languages.map((language) => [\n language,\n config.languages[language].document,\n ])\n )\n ),\n entrypoint: JSON.stringify(entrypoint),\n precache: JSON.stringify(precache),\n stylesheet: JSON.stringify(stylesheet),\n },\n passes: minifyPasses,\n }\n )\n\n await writeFile(\n join(outputDirectory, serviceWorkerPath.slice(1)),\n serviceWorker\n )\n}\n\nasync function publicFiles(\n directory: string,\n root = directory\n): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true })\n const files: string[] = []\n\n for (const entry of entries) {\n const path = join(directory, entry.name)\n if (entry.isDirectory()) {\n files.push(...(await publicFiles(path, root)))\n } else if (entry.isFile() && entry.name !== '_headers') {\n files.push(`/${relative(root, path).split(sep).join('/')}`)\n }\n }\n\n return files.sort()\n}\n\nfunction globRule(pattern: string | RegExp): {\n absolute: boolean\n flags: string\n source: string\n} {\n if (pattern instanceof RegExp) {\n return {\n absolute: true,\n flags: pattern.flags,\n source: pattern.source,\n }\n }\n\n let source = '^'\n for (let index = 0; index < pattern.length; index += 1) {\n const character = pattern[index]\n\n if (character === '*') {\n if (pattern[index + 1] === '*') {\n source += '.*'\n index += 1\n } else {\n source += '[^/]*'\n }\n } else if (character === '?') {\n source += '.'\n } else {\n source += character.replace(/[|\\\\{}()[\\]^$+?.]/g, '\\\\$&')\n }\n }\n\n return {\n absolute: pattern.includes('://'),\n flags: '',\n source: `${source}$`,\n }\n}\n\nexport type PWAizeConfig = {\n defaultLanguage: BCP47LanguageTag\n canonicalLanguage: BCP47LanguageTag\n alternateLanguages: BCP47LanguageTag[]\n\n languages: Record<\n string,\n {\n document: Omit<\n DocumentMarkupOptions,\n 'entrypoint' | 'language' | 'manifestUrl' | 'stylesheet'\n >\n manifest: Omit<WebManifestOptions, 'lang'>\n }\n >\n\n stylesheet: PathLike\n entrypoint: PathLike\n outDir: PathLike\n\n assetsDir?: PathLike\n i18nDir?: PathLike\n minifyPasses?: number\n\n serviceWorker?: {\n bypass?: Array<string | RegExp>\n precache?: `/${string}`[]\n initialize?: () => void\n waitUntil?: () => Promise<void>\n }\n\n _headersFile?: boolean\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,eAA8B,UAAU,YAAuC;CAC7E,MAAM,UAAU,MAAM,MAAM;EAC1B,aAAa,CAAC,WAAW,SAAS,CAAC;EACnC,QAAQ;EACR,eAAe;EACf,QAAQ;EACR,aAAa;EACb,OAAO;CACT,CAAC;CACD,MAAM,EAAE,SAAS,UAAU;EACzB,MAAM,QAAQ,YAAY,EAAE,CAAC;EAC7B,UAAU,WAAW,SAAS;EAC9B,QAAQ;CACV,CAAC;CAED,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK;AAC7C;;;;AClBA,eAA8B,WAAW,QAAiC;CACxE,OAAO,OAAO,QAAQ;EACpB,2BAA2B;EAC3B,6BAA6B;EAC7B,oBAAoB;EACpB,gBAAgB;EAChB,OAAO;EACP,WAAW;EACX,UAAU;GACR,UAAU;IACR,W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