adjacent-core 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## Unpublished
4
+
5
+ ### 🛠 Breaking changes
6
+
7
+ ### 🎉 New features
8
+
9
+ ### 🐛 Bug fixes
10
+
11
+ ### 💡 Others
12
+
13
+ ## 0.1.0 - 2026-08-29
14
+
15
+ _This version does not introduce any user-facing changes._
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eric Kweyunga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # adjacent-core
2
+
3
+ Configuration contract, web app manifest, and metadata primitives for Adjacent.
4
+
5
+ ## Documentation
6
+
7
+ - [Application configuration](https://github.com/erickweyunga/adjacent-framework/blob/main/docs/configuration.md)
8
+ - [All the documentation](https://github.com/erickweyunga/adjacent-framework/blob/main/docs/README.md)
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install adjacent-core
14
+ ```
15
+
16
+ Most projects get this through the CLI instead, which installs and wires it up:
17
+
18
+ ```bash
19
+ npx adjacent-cli init
20
+ ```
21
+
22
+ One `app.config.ts` is the source for the web app manifest, the Next.js
23
+ metadata and viewport, and the offline policy the service worker is generated
24
+ from. Everything is validated before any of it is derived, so an invalid
25
+ configuration fails the build rather than producing a half-valid PWA.
26
+
27
+ ## Issues
28
+
29
+ If you hit a problem using this package, please
30
+ [report it here](https://github.com/erickweyunga/adjacent-framework/issues/new).
31
+
32
+ ## Contributing
33
+
34
+ Issues and pull requests are welcome. Please read the
35
+ [contributing guide](https://github.com/erickweyunga/adjacent-framework/blob/main/CONTRIBUTING.md)
36
+ first.
37
+
38
+ ## License
39
+
40
+ MIT
@@ -0,0 +1,281 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Wrapper chrome the web manifest has no vocabulary for. A web manifest carries
4
+ * a single `theme_color` and no notion of the Android navigation bar, so these
5
+ * reach the Android wrapper through Adjacent rather than through the manifest.
6
+ */
7
+ export declare const AndroidConfigSchema: z.ZodObject<{
8
+ navigationColor: z.ZodOptional<z.ZodString>;
9
+ navigationColorDark: z.ZodOptional<z.ZodString>;
10
+ navigationDividerColor: z.ZodOptional<z.ZodString>;
11
+ navigationDividerColorDark: z.ZodOptional<z.ZodString>;
12
+ themeColorDark: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strict>;
14
+ export declare const AdjacentConfigSchema: z.ZodObject<{
15
+ android: z.ZodOptional<z.ZodObject<{
16
+ navigationColor: z.ZodOptional<z.ZodString>;
17
+ navigationColorDark: z.ZodOptional<z.ZodString>;
18
+ navigationDividerColor: z.ZodOptional<z.ZodString>;
19
+ navigationDividerColorDark: z.ZodOptional<z.ZodString>;
20
+ themeColorDark: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strict>>;
22
+ app: z.ZodObject<{
23
+ description: z.ZodOptional<z.ZodString>;
24
+ dir: z.ZodOptional<z.ZodEnum<{
25
+ auto: "auto";
26
+ ltr: "ltr";
27
+ rtl: "rtl";
28
+ }>>;
29
+ id: z.ZodOptional<z.ZodString>;
30
+ lang: z.ZodOptional<z.ZodString>;
31
+ name: z.ZodString;
32
+ shortName: z.ZodOptional<z.ZodString>;
33
+ slug: z.ZodString;
34
+ version: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strict>;
36
+ appearance: z.ZodOptional<z.ZodObject<{
37
+ backgroundColor: z.ZodOptional<z.ZodString>;
38
+ display: z.ZodOptional<z.ZodEnum<{
39
+ browser: "browser";
40
+ fullscreen: "fullscreen";
41
+ "minimal-ui": "minimal-ui";
42
+ standalone: "standalone";
43
+ }>>;
44
+ orientation: z.ZodOptional<z.ZodEnum<{
45
+ any: "any";
46
+ landscape: "landscape";
47
+ "landscape-primary": "landscape-primary";
48
+ "landscape-secondary": "landscape-secondary";
49
+ natural: "natural";
50
+ portrait: "portrait";
51
+ "portrait-primary": "portrait-primary";
52
+ "portrait-secondary": "portrait-secondary";
53
+ }>>;
54
+ themeColor: z.ZodOptional<z.ZodString>;
55
+ themeColorDark: z.ZodOptional<z.ZodString>;
56
+ }, z.core.$strict>>;
57
+ manifest: z.ZodOptional<z.ZodObject<{
58
+ categories: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ displayOverride: z.ZodOptional<z.ZodArray<z.ZodEnum<{
60
+ browser: "browser";
61
+ fullscreen: "fullscreen";
62
+ "minimal-ui": "minimal-ui";
63
+ standalone: "standalone";
64
+ tabbed: "tabbed";
65
+ "window-controls-overlay": "window-controls-overlay";
66
+ }>>>;
67
+ edgeSidePanel: z.ZodOptional<z.ZodObject<{
68
+ preferredWidth: z.ZodOptional<z.ZodNumber>;
69
+ }, z.core.$strict>>;
70
+ fileHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
71
+ accept: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
72
+ action: z.ZodString;
73
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
74
+ purpose: z.ZodOptional<z.ZodArray<z.ZodEnum<{
75
+ any: "any";
76
+ maskable: "maskable";
77
+ monochrome: "monochrome";
78
+ }>>>;
79
+ sizes: z.ZodOptional<z.ZodString>;
80
+ src: z.ZodString;
81
+ type: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strict>>>;
83
+ launchType: z.ZodOptional<z.ZodEnum<{
84
+ "multiple-clients": "multiple-clients";
85
+ "single-client": "single-client";
86
+ }>>;
87
+ }, z.core.$strict>>>;
88
+ iarcRatingId: z.ZodOptional<z.ZodString>;
89
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
+ purpose: z.ZodOptional<z.ZodArray<z.ZodEnum<{
91
+ any: "any";
92
+ maskable: "maskable";
93
+ monochrome: "monochrome";
94
+ }>>>;
95
+ sizes: z.ZodOptional<z.ZodString>;
96
+ src: z.ZodString;
97
+ type: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strict>>>;
99
+ launchHandler: z.ZodOptional<z.ZodObject<{
100
+ clientMode: z.ZodUnion<readonly [z.ZodEnum<{
101
+ auto: "auto";
102
+ "focus-existing": "focus-existing";
103
+ "navigate-existing": "navigate-existing";
104
+ "navigate-new": "navigate-new";
105
+ }>, z.ZodArray<z.ZodEnum<{
106
+ auto: "auto";
107
+ "focus-existing": "focus-existing";
108
+ "navigate-existing": "navigate-existing";
109
+ "navigate-new": "navigate-new";
110
+ }>>]>;
111
+ }, z.core.$strict>>;
112
+ localized: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
113
+ description: z.ZodOptional<z.ZodString>;
114
+ name: z.ZodOptional<z.ZodString>;
115
+ shortName: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strict>>>;
117
+ noteTaking: z.ZodOptional<z.ZodObject<{
118
+ newNoteUrl: z.ZodString;
119
+ }, z.core.$strict>>;
120
+ preferRelatedApplications: z.ZodOptional<z.ZodBoolean>;
121
+ protocolHandlers: z.ZodOptional<z.ZodArray<z.ZodObject<{
122
+ protocol: z.ZodString;
123
+ url: z.ZodString;
124
+ }, z.core.$strict>>>;
125
+ relatedApplications: z.ZodOptional<z.ZodArray<z.ZodObject<{
126
+ id: z.ZodOptional<z.ZodString>;
127
+ platform: z.ZodString;
128
+ url: z.ZodOptional<z.ZodString>;
129
+ }, z.core.$strict>>>;
130
+ scopeExtensions: z.ZodOptional<z.ZodArray<z.ZodObject<{
131
+ origin: z.ZodString;
132
+ }, z.core.$strict>>>;
133
+ screenshots: z.ZodOptional<z.ZodArray<z.ZodObject<{
134
+ type: z.ZodOptional<z.ZodString>;
135
+ sizes: z.ZodOptional<z.ZodString>;
136
+ src: z.ZodString;
137
+ formFactor: z.ZodOptional<z.ZodEnum<{
138
+ narrow: "narrow";
139
+ wide: "wide";
140
+ }>>;
141
+ label: z.ZodOptional<z.ZodString>;
142
+ platform: z.ZodOptional<z.ZodEnum<{
143
+ android: "android";
144
+ chrome_web_store: "chrome_web_store";
145
+ chromeos: "chromeos";
146
+ ios: "ios";
147
+ ipados: "ipados";
148
+ itunes: "itunes";
149
+ kaios: "kaios";
150
+ macos: "macos";
151
+ "microsoft-inbox": "microsoft-inbox";
152
+ "microsoft-store": "microsoft-store";
153
+ play: "play";
154
+ windows: "windows";
155
+ xbox: "xbox";
156
+ }>>;
157
+ }, z.core.$strict>>>;
158
+ shareTarget: z.ZodOptional<z.ZodObject<{
159
+ action: z.ZodString;
160
+ enctype: z.ZodOptional<z.ZodEnum<{
161
+ "application/x-www-form-urlencoded": "application/x-www-form-urlencoded";
162
+ "multipart/form-data": "multipart/form-data";
163
+ }>>;
164
+ method: z.ZodOptional<z.ZodEnum<{
165
+ GET: "GET";
166
+ POST: "POST";
167
+ }>>;
168
+ params: z.ZodObject<{
169
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
170
+ accept: z.ZodArray<z.ZodString>;
171
+ name: z.ZodString;
172
+ }, z.core.$strict>>>;
173
+ text: z.ZodOptional<z.ZodString>;
174
+ title: z.ZodOptional<z.ZodString>;
175
+ url: z.ZodOptional<z.ZodString>;
176
+ }, z.core.$strict>;
177
+ }, z.core.$strict>>;
178
+ shortcuts: z.ZodOptional<z.ZodArray<z.ZodObject<{
179
+ description: z.ZodOptional<z.ZodString>;
180
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
181
+ purpose: z.ZodOptional<z.ZodArray<z.ZodEnum<{
182
+ any: "any";
183
+ maskable: "maskable";
184
+ monochrome: "monochrome";
185
+ }>>>;
186
+ sizes: z.ZodOptional<z.ZodString>;
187
+ src: z.ZodString;
188
+ type: z.ZodOptional<z.ZodString>;
189
+ }, z.core.$strict>>>;
190
+ name: z.ZodString;
191
+ shortName: z.ZodOptional<z.ZodString>;
192
+ url: z.ZodString;
193
+ }, z.core.$strict>>>;
194
+ widgets: z.ZodOptional<z.ZodArray<z.ZodObject<{
195
+ backgrounds: z.ZodOptional<z.ZodArray<z.ZodObject<{
196
+ purpose: z.ZodOptional<z.ZodArray<z.ZodEnum<{
197
+ any: "any";
198
+ maskable: "maskable";
199
+ monochrome: "monochrome";
200
+ }>>>;
201
+ sizes: z.ZodOptional<z.ZodString>;
202
+ src: z.ZodString;
203
+ type: z.ZodOptional<z.ZodString>;
204
+ }, z.core.$strict>>>;
205
+ data: z.ZodString;
206
+ description: z.ZodString;
207
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
208
+ purpose: z.ZodOptional<z.ZodArray<z.ZodEnum<{
209
+ any: "any";
210
+ maskable: "maskable";
211
+ monochrome: "monochrome";
212
+ }>>>;
213
+ sizes: z.ZodOptional<z.ZodString>;
214
+ src: z.ZodString;
215
+ type: z.ZodOptional<z.ZodString>;
216
+ }, z.core.$strict>>>;
217
+ msAcTemplate: z.ZodString;
218
+ multiple: z.ZodOptional<z.ZodBoolean>;
219
+ name: z.ZodString;
220
+ screenshots: z.ZodOptional<z.ZodArray<z.ZodObject<{
221
+ type: z.ZodOptional<z.ZodString>;
222
+ sizes: z.ZodOptional<z.ZodString>;
223
+ src: z.ZodString;
224
+ formFactor: z.ZodOptional<z.ZodEnum<{
225
+ narrow: "narrow";
226
+ wide: "wide";
227
+ }>>;
228
+ label: z.ZodOptional<z.ZodString>;
229
+ platform: z.ZodOptional<z.ZodEnum<{
230
+ android: "android";
231
+ chrome_web_store: "chrome_web_store";
232
+ chromeos: "chromeos";
233
+ ios: "ios";
234
+ ipados: "ipados";
235
+ itunes: "itunes";
236
+ kaios: "kaios";
237
+ macos: "macos";
238
+ "microsoft-inbox": "microsoft-inbox";
239
+ "microsoft-store": "microsoft-store";
240
+ play: "play";
241
+ windows: "windows";
242
+ xbox: "xbox";
243
+ }>>;
244
+ }, z.core.$strict>>>;
245
+ shortName: z.ZodOptional<z.ZodString>;
246
+ tag: z.ZodString;
247
+ type: z.ZodOptional<z.ZodString>;
248
+ update: z.ZodOptional<z.ZodNumber>;
249
+ }, z.core.$strict>>>;
250
+ }, z.core.$strict>>;
251
+ navigation: z.ZodOptional<z.ZodObject<{
252
+ scope: z.ZodOptional<z.ZodCustom<`/${string}`, `/${string}`>>;
253
+ startUrl: z.ZodOptional<z.ZodCustom<`/${string}`, `/${string}`>>;
254
+ }, z.core.$strict>>;
255
+ selfDestroying: z.ZodOptional<z.ZodBoolean>;
256
+ offline: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
257
+ assetLimit: z.ZodOptional<z.ZodNumber>;
258
+ exclude: z.ZodOptional<z.ZodArray<z.ZodCustom<`/${string}`, `/${string}`>>>;
259
+ fallback: z.ZodOptional<z.ZodCustom<`/${string}`, `/${string}`>>;
260
+ navigation: z.ZodOptional<z.ZodEnum<{
261
+ "cache-first": "cache-first";
262
+ "network-first": "network-first";
263
+ }>>;
264
+ }, z.core.$strict>]>>;
265
+ plugins: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>], null>]>>>>;
266
+ }, z.core.$strict>;
267
+ export type AdjacentConfig = z.infer<typeof AdjacentConfigSchema>;
268
+ export type AndroidConfig = z.infer<typeof AndroidConfigSchema>;
269
+ export type AdjacentCommand = "build" | "dev" | "doctor" | "export";
270
+ export interface ConfigContext {
271
+ readonly command: AdjacentCommand;
272
+ readonly mode: "development" | "production" | "test";
273
+ readonly projectRoot: string;
274
+ }
275
+ export type AdjacentConfigFactory = (context: ConfigContext) => AdjacentConfig | Promise<AdjacentConfig>;
276
+ export type AdjacentConfigExport = AdjacentConfig | AdjacentConfigFactory;
277
+ export declare function defineConfig(config: AdjacentConfig): AdjacentConfig;
278
+ export declare function defineConfig(config: AdjacentConfigFactory): AdjacentConfigFactory;
279
+ export declare function parseConfig(config: unknown): AdjacentConfig;
280
+ export declare function resolveConfig(exportedConfig: AdjacentConfigExport, context: ConfigContext): Promise<AdjacentConfig>;
281
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;kBAM9B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA8F/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACpE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,YAAY,GAAG,MAAM,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AACD,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,aAAa,KACnB,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC9C,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAE1E,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAAC;AACrE,wBAAgB,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CAAC;AAKnF,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAE3D;AAED,wBAAsB,aAAa,CACjC,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAOzB"}
package/dist/config.js ADDED
@@ -0,0 +1,117 @@
1
+ import { z } from "zod";
2
+ import { ManifestConfigSchema } from "./manifest/schema.js";
3
+ const CssColorSchema = z.string().trim().min(1, "Expected a CSS color value");
4
+ const PathSchema = z.custom((value) => typeof value === "string" && value.startsWith("/"), "Expected an absolute URL path beginning with /");
5
+ /**
6
+ * Wrapper chrome the web manifest has no vocabulary for. A web manifest carries
7
+ * a single `theme_color` and no notion of the Android navigation bar, so these
8
+ * reach the Android wrapper through Adjacent rather than through the manifest.
9
+ */
10
+ export const AndroidConfigSchema = z.strictObject({
11
+ navigationColor: CssColorSchema.optional(),
12
+ navigationColorDark: CssColorSchema.optional(),
13
+ navigationDividerColor: CssColorSchema.optional(),
14
+ navigationDividerColorDark: CssColorSchema.optional(),
15
+ themeColorDark: CssColorSchema.optional(),
16
+ });
17
+ export const AdjacentConfigSchema = z.strictObject({
18
+ android: AndroidConfigSchema.optional(),
19
+ app: z.strictObject({
20
+ description: z.string().min(1).optional(),
21
+ /** Which way the name and description read, for a host that mixes scripts. */
22
+ dir: z.enum(["auto", "ltr", "rtl"]).optional(),
23
+ id: z.string().min(1).optional(),
24
+ /** BCP 47 tag for the language the name and description are written in. */
25
+ lang: z
26
+ .string()
27
+ .regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/, "Expected a BCP 47 language tag")
28
+ .optional(),
29
+ name: z.string().min(2),
30
+ shortName: z.string().min(1).max(12).optional(),
31
+ slug: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
32
+ version: z.string().min(1).optional(),
33
+ }),
34
+ appearance: z
35
+ .strictObject({
36
+ backgroundColor: CssColorSchema.optional(),
37
+ display: z.enum(["browser", "fullscreen", "minimal-ui", "standalone"]).optional(),
38
+ orientation: z
39
+ .enum([
40
+ "any",
41
+ "landscape",
42
+ "landscape-primary",
43
+ "landscape-secondary",
44
+ "natural",
45
+ "portrait",
46
+ "portrait-primary",
47
+ "portrait-secondary",
48
+ ])
49
+ .optional(),
50
+ themeColor: CssColorSchema.optional(),
51
+ /**
52
+ * The browser's own chrome in dark mode. Emitted as a second
53
+ * `theme-color` discriminated by `prefers-color-scheme`, which is the
54
+ * only way one document can offer two. The Android wrapper falls back to
55
+ * it when `android.themeColorDark` says nothing.
56
+ */
57
+ themeColorDark: CssColorSchema.optional(),
58
+ })
59
+ .optional(),
60
+ manifest: ManifestConfigSchema.optional(),
61
+ navigation: z
62
+ .strictObject({
63
+ scope: PathSchema.optional(),
64
+ startUrl: PathSchema.optional(),
65
+ })
66
+ .optional(),
67
+ /**
68
+ * Replaces the service worker with one that removes itself: it unregisters,
69
+ * deletes the caches Adjacent made, and reloads open windows. Ship it to
70
+ * retire a progressive web app, because simply not serving a worker leaves
71
+ * the installed one in charge of every visitor who already has it.
72
+ */
73
+ selfDestroying: z.boolean().optional(),
74
+ offline: z
75
+ .union([
76
+ z.boolean(),
77
+ z.strictObject({
78
+ /**
79
+ * How many assets the runtime cache keeps. Without a bound it grows
80
+ * until the origin's storage quota is reached, and a media-heavy
81
+ * application reaches it.
82
+ */
83
+ assetLimit: z.number().int().positive().optional(),
84
+ /**
85
+ * Paths this application never wants cached, beyond the ones Adjacent
86
+ * already leaves alone. A path matches itself and everything under it,
87
+ * so `/admin` covers `/admin` and `/admin/users`.
88
+ */
89
+ exclude: z
90
+ .array(PathSchema.refine((path) => path !== "/", "Excluding / would exclude everything; use offline: false instead"))
91
+ .optional(),
92
+ fallback: PathSchema.optional(),
93
+ navigation: z.enum(["cache-first", "network-first"]).optional(),
94
+ }),
95
+ ])
96
+ .optional(),
97
+ plugins: z
98
+ .array(z.union([
99
+ z.string().min(1),
100
+ z.tuple([z.string().min(1), z.record(z.string(), z.unknown())]),
101
+ ]))
102
+ .readonly()
103
+ .optional(),
104
+ });
105
+ export function defineConfig(config) {
106
+ return config;
107
+ }
108
+ export function parseConfig(config) {
109
+ return AdjacentConfigSchema.parse(config);
110
+ }
111
+ export async function resolveConfig(exportedConfig, context) {
112
+ const config = typeof exportedConfig === "function"
113
+ ? await exportedConfig(context)
114
+ : exportedConfig;
115
+ return parseConfig(config);
116
+ }
117
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC,CA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: "ADJACENT_DEV_CLEAR_CACHE";
4
+ readonly navigate: "ADJACENT_DEV_NAVIGATE";
5
+ readonly reload: "ADJACENT_DEV_RELOAD";
6
+ };
7
+ export declare const AdjacentDevCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
+ type: z.ZodLiteral<"ADJACENT_DEV_RELOAD">;
9
+ }, z.core.$strict>, z.ZodObject<{
10
+ type: z.ZodLiteral<"ADJACENT_DEV_CLEAR_CACHE">;
11
+ }, z.core.$strict>, z.ZodObject<{
12
+ path: z.ZodCustom<`/${string}`, `/${string}`>;
13
+ type: z.ZodLiteral<"ADJACENT_DEV_NAVIGATE">;
14
+ }, z.core.$strict>], "type">;
15
+ export type AdjacentDevCommand = z.infer<typeof AdjacentDevCommandSchema>;
16
+ export type AdjacentDevCommandType = AdjacentDevCommand["type"];
17
+ export declare function parseDevCommand(value: unknown): AdjacentDevCommand;
18
+ export declare function safeParseDevCommand(value: unknown): AdjacentDevCommand | undefined;
19
+ //# sourceMappingURL=dev-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-protocol.d.ts","sourceRoot":"","sources":["../src/dev-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAWX,eAAO,MAAM,wBAAwB;;;;;;;4BAOnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEhE,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAElE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GACb,kBAAkB,GAAG,SAAS,CAGhC"}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ export const DEV_COMMAND = {
3
+ clearCache: "ADJACENT_DEV_CLEAR_CACHE",
4
+ navigate: "ADJACENT_DEV_NAVIGATE",
5
+ reload: "ADJACENT_DEV_RELOAD",
6
+ };
7
+ const DevPathSchema = z.custom((value) => typeof value === "string" &&
8
+ value.startsWith("/") &&
9
+ value[1] !== "/" &&
10
+ value[1] !== "\\", "Expected a same-origin path beginning with a single /");
11
+ export const AdjacentDevCommandSchema = z.discriminatedUnion("type", [
12
+ z.strictObject({ type: z.literal(DEV_COMMAND.reload) }),
13
+ z.strictObject({ type: z.literal(DEV_COMMAND.clearCache) }),
14
+ z.strictObject({
15
+ path: DevPathSchema,
16
+ type: z.literal(DEV_COMMAND.navigate),
17
+ }),
18
+ ]);
19
+ export function parseDevCommand(value) {
20
+ return AdjacentDevCommandSchema.parse(value);
21
+ }
22
+ export function safeParseDevCommand(value) {
23
+ const result = AdjacentDevCommandSchema.safeParse(value);
24
+ return result.success ? result.data : undefined;
25
+ }
26
+ //# sourceMappingURL=dev-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-protocol.js","sourceRoot":"","sources":["../src/dev-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,0BAA0B;IACtC,QAAQ,EAAE,uBAAuB;IACjC,MAAM,EAAE,qBAAqB;CACrB,CAAC;AAEX,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAC5B,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;IACrB,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG;IAChB,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EACnB,uDAAuD,CACxD,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACnE,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;IACvD,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;IAC3D,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;KACtC,CAAC;CACH,CAAC,CAAC;AAKH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,wBAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,MAAM,MAAM,GAAG,wBAAwB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { defineConfig, parseConfig, resolveConfig, type AdjacentCommand, type AdjacentConfig, type AdjacentConfigExport, type AdjacentConfigFactory, type AndroidConfig, type ConfigContext, } from "./config.js";
2
+ export { ANDROID_MANIFEST_KEY, resolveManifest, type ResolvedManifest, } from "./manifest/resolve-manifest.js";
3
+ export { AdjacentDevCommandSchema, DEV_COMMAND, parseDevCommand, safeParseDevCommand, type AdjacentDevCommand, type AdjacentDevCommandType, } from "./dev-protocol.js";
4
+ export { resolveMetadata, resolveViewport, type ResolvedMetadata, type ResolvedViewport, } from "./metadata.js";
5
+ export type { FileHandler, ImageResource, ManifestConfig, ManifestShortcut, Screenshot, ShareTarget, } from "./manifest/schema.js";
6
+ export { WORKER_COMMAND, type AdjacentCacheTarget, type AdjacentWorkerCommand, type AdjacentWorkerResponse, } from "./worker-protocol.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,KAAK,gBAAgB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { defineConfig, parseConfig, resolveConfig, } from "./config.js";
2
+ export { ANDROID_MANIFEST_KEY, resolveManifest, } from "./manifest/resolve-manifest.js";
3
+ export { AdjacentDevCommandSchema, DEV_COMMAND, parseDevCommand, safeParseDevCommand, } from "./dev-protocol.js";
4
+ export { resolveMetadata, resolveViewport, } from "./metadata.js";
5
+ export { WORKER_COMMAND, } from "./worker-protocol.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,GAOd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,eAAe,GAEhB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,WAAW,EACX,eAAe,EACf,mBAAmB,GAGpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,eAAe,GAGhB,MAAM,eAAe,CAAC;AASvB,OAAO,EACL,cAAc,GAIf,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { AdjacentConfig } from "../config.js";
2
+ export interface ResolvedManifest extends Record<string, unknown> {
3
+ readonly background_color: string;
4
+ readonly display: string;
5
+ readonly icons: readonly Record<string, unknown>[];
6
+ readonly name: string;
7
+ readonly short_name: string;
8
+ readonly start_url: string;
9
+ readonly theme_color: string;
10
+ }
11
+ /**
12
+ * The key the Android wrapper settings travel under. Unknown members are
13
+ * ignored by browsers, so the manifest stays valid while the CLI can read
14
+ * values it must never import from `app.config.ts`.
15
+ */
16
+ export declare const ANDROID_MANIFEST_KEY = "adjacent_android";
17
+ export declare function resolveManifest(config: AdjacentConfig): ResolvedManifest;
18
+ //# sourceMappingURL=resolve-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-manifest.d.ts","sourceRoot":"","sources":["../../src/manifest/resolve-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQnD,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAuED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAcvD,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAkExE"}