inlaycms 0.5.0 → 0.6.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/assets/admin/admin.css +1 -1
- package/assets/admin/admin.js +1 -1
- package/dist/adapters/admin/publish.js +2 -2
- package/dist/adapters/admin/screens/editor.js +4 -2
- package/dist/adapters/admin/screens/releases.js +8 -3
- package/dist/adapters/admin/views/data-table.js +1 -1
- package/dist/adapters/admin/views/layout.d.ts +1 -1
- package/dist/adapters/admin/views/layout.js +12 -2
- package/dist/adapters/cli/main.js +12 -2
- package/dist/adapters/mcp/agent-refs.d.ts +2 -1
- package/dist/adapters/mcp/agent-refs.js +4 -4
- package/dist/adapters/mcp/tools/publish.js +1 -1
- package/dist/adapters/mcp/tools/read.js +2 -2
- package/dist/adapters/mcp/tools/write.js +1 -1
- package/dist/adapters/site/context.d.ts +4 -1
- package/dist/adapters/site/context.js +9 -7
- package/dist/adapters/site/head.d.ts +2 -0
- package/dist/adapters/site/head.js +6 -6
- package/dist/adapters/site/plugin.js +15 -7
- package/dist/adapters/site/preview.d.ts +2 -0
- package/dist/adapters/site/preview.js +10 -5
- package/dist/adapters/site/render.js +7 -2
- package/dist/adapters/site/routes.js +4 -3
- package/dist/adapters/site/sitemap.d.ts +2 -1
- package/dist/adapters/site/sitemap.js +3 -3
- package/dist/core/messages/en.d.ts +10 -2
- package/dist/core/messages/en.js +10 -2
- package/dist/core/registry/define.d.ts +5 -0
- package/dist/core/registry/define.js +1 -0
- package/dist/core/registry/render.d.ts +6 -1
- package/dist/core/release/manifest.d.ts +0 -5
- package/dist/core/release/manifest.js +0 -24
- package/dist/core/release/read.d.ts +2 -2
- package/dist/core/release/read.js +11 -12
- package/dist/core/release/window.d.ts +11 -0
- package/dist/core/release/window.js +34 -0
- package/dist/core/site/paths.d.ts +5 -0
- package/dist/core/site/paths.js +32 -0
- package/dist/core/site/resolve.js +17 -6
- package/dist/core/version.d.ts +4 -0
- package/dist/core/version.js +4 -0
- package/dist/host/activate.js +2 -1
- package/dist/host/push.d.ts +5 -1
- package/dist/host/push.js +17 -5
- package/dist/host/worker.js +9 -3
- package/dist/site.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/messages/en.js
CHANGED
|
@@ -312,7 +312,8 @@ export const en = {
|
|
|
312
312
|
'error.markdownRenderImage': "This page's Markdown couldn't be shown. Line {line}: the image {src} can't be used. Use an image from the media library, or put the Markdown in a .md file the site imports and name the picture by its path from there.",
|
|
313
313
|
'error.releaseSignature': "This release isn't signed by a trusted key, so it wasn't opened.",
|
|
314
314
|
'error.releaseInvalid': "This release file is damaged or wasn't made by inlaycms pack.",
|
|
315
|
-
'error.
|
|
315
|
+
'error.releaseTooOld': 'This release was packed with Inlay {packed}. Inlay {version} runs releases packed with Inlay {oldest} or later. Pack the site again with this version and push it.',
|
|
316
|
+
'error.releaseTooNew': 'This release was packed with Inlay {packed}, which is newer than the Inlay {version} on this server. Upgrade Inlay on the server, then push it again.',
|
|
316
317
|
'error.releaseNoSite': "The site code in this release doesn't export a site as its default export.",
|
|
317
318
|
'error.releaseDirNotEmpty': 'The folder {dir} to open the release into must be empty.',
|
|
318
319
|
'error.releaseDirMissing': "The folder {dir} to open the release into doesn't exist.",
|
|
@@ -343,6 +344,8 @@ export const en = {
|
|
|
343
344
|
'error.pushContentType': 'Send the release file as the request body, with the content type application/gzip.',
|
|
344
345
|
'error.pushTooLarge': 'This release file is larger than {mb} MB, so it wasn\'t accepted.',
|
|
345
346
|
'error.pushFailed': 'The release couldn\'t be received: {problem}',
|
|
347
|
+
'release.packAgain': 'Packed with Inlay {packed}. The next version of Inlay that changes what sites use won\'t run it: pack the site again with this version and push it.',
|
|
348
|
+
'push.packAgain': 'This release was packed with Inlay {packed}. The next version of Inlay that changes what sites use won\'t run it: pack the site again with this version.',
|
|
346
349
|
'push.diffUnavailable': "What this release would change in your existing content couldn't be worked out: {reason} The rest of the report is complete.",
|
|
347
350
|
'error.pushDiffTimeout': 'The preview of the release took more than {seconds} seconds to answer.',
|
|
348
351
|
'error.pushDiffAnswer': 'The preview of the release answered with an error (status {status}).',
|
|
@@ -418,6 +421,7 @@ export const en = {
|
|
|
418
421
|
'cli.activateNotFound': "There's no release file at {path} and no release with the ID {id}.",
|
|
419
422
|
'cli.activateName': '--name names a release file as it is stored. Leave it out when activating a stored release by its ID.',
|
|
420
423
|
'cli.releasesNone': 'There are no releases on this server yet.',
|
|
424
|
+
'cli.releaseWarning': ' {warning}',
|
|
421
425
|
'cli.releaseLine': '{id} {name} {state} pushed {pushedAt} made live {activatedAt}',
|
|
422
426
|
'cli.releaseNeverLive': 'never',
|
|
423
427
|
'cli.releaseState.staged': 'not live yet',
|
|
@@ -613,6 +617,7 @@ export const en = {
|
|
|
613
617
|
'admin.error.tooLarge': 'What you sent is too large for the site to accept. Go back, make it smaller (for example, fewer or smaller images, or less text), and try again.',
|
|
614
618
|
'admin.error.badRequest.title': "This couldn't be sent",
|
|
615
619
|
'admin.error.badRequest': "The site couldn't read what your browser sent. Go back, reload the page and try again.",
|
|
620
|
+
'admin.notice.dismiss': 'Dismiss',
|
|
616
621
|
'admin.notice.saved': 'Your changes are saved.',
|
|
617
622
|
'admin.notice.unchanged': 'Nothing had changed, so there was nothing to save.',
|
|
618
623
|
'admin.notice.created': 'Created.',
|
|
@@ -702,6 +707,7 @@ export const en = {
|
|
|
702
707
|
'admin.notice.releaseDeleted': 'The release is deleted.',
|
|
703
708
|
'admin.releases.title': 'Releases',
|
|
704
709
|
'admin.releases.intro': 'A release is a version of the site\'s design and code. Upload or push a new one, check what it changes, then activate it to make it live.',
|
|
710
|
+
'admin.releases.packAgainBadge': 'Pack again',
|
|
705
711
|
'admin.releases.table': 'Releases',
|
|
706
712
|
'admin.releases.empty': 'No releases yet. Push one from the command line or upload a release file.',
|
|
707
713
|
'admin.releases.name': 'Name',
|
|
@@ -1411,7 +1417,9 @@ export const en = {
|
|
|
1411
1417
|
'host.workerGaveUp': 'The site kept stopping, so visitors now see the "temporarily unavailable" page. The admin still works. Look at the messages above for the cause, then make a release live again or restart the server.',
|
|
1412
1418
|
'host.noSiteFailed': 'Even the page shown while the site is down kept stopping, so the server has stopped. Look at the messages above for the cause.',
|
|
1413
1419
|
'host.releaseMissing': 'The live release {name} is missing from this server, so visitors see the "temporarily unavailable" page. Make it live again with inlaycms activate <file> to bring the site back.',
|
|
1414
|
-
'host.
|
|
1420
|
+
'host.releaseTooOld': 'The live release {name} was packed with Inlay {packed}, and Inlay {version} runs releases packed with Inlay {oldest} or later, so visitors see the "temporarily unavailable" page. Pack the site again with this version and push it, or make another release live.',
|
|
1421
|
+
'host.releasePackAgain': 'The live release {name} was packed with Inlay {packed}. The next version of Inlay that changes what sites use won\'t run it: pack the site again with this version and push it.',
|
|
1422
|
+
'host.releaseTooNew': 'The live release {name} was packed with Inlay {packed}, which is newer than the Inlay {version} on this server, so visitors see the "temporarily unavailable" page. Upgrade Inlay on the server, or make another release live.',
|
|
1415
1423
|
'host.servingUnavailable': 'The site is running at {url}, but visitors see the "temporarily unavailable" page until the problem above is fixed.',
|
|
1416
1424
|
'host.pointerRepaired': 'The note of which release is live was out of date. It now names {name} again, as the database does.',
|
|
1417
1425
|
'host.pointerUnreadable': "The note of which release is live couldn't be read: {problem}",
|
|
@@ -6,6 +6,8 @@ import type { ShippedContent } from './content.js';
|
|
|
6
6
|
import type { ReleaseMigration } from './migration.js';
|
|
7
7
|
import type { PageInfo, RenderContext } from './render.js';
|
|
8
8
|
import type { RouteDef } from './route.js';
|
|
9
|
+
import type { TrailingSlash } from '../site/paths.js';
|
|
10
|
+
export type { TrailingSlash };
|
|
9
11
|
export interface BlockDef<S extends z.ZodObject = z.ZodObject> {
|
|
10
12
|
kind: 'block';
|
|
11
13
|
name: string;
|
|
@@ -140,6 +142,8 @@ export interface SiteDefinition {
|
|
|
140
142
|
globals: GlobalDef[];
|
|
141
143
|
/** Serve the default-locale page when a translation is missing (default `true`). */
|
|
142
144
|
translationFallback: boolean;
|
|
145
|
+
/** `'always'` serves and writes page URLs with a trailing slash (default `'never'`). */
|
|
146
|
+
trailingSlash: TrailingSlash;
|
|
143
147
|
/** Content shipped with the site, activated by editions. */
|
|
144
148
|
content: ShippedContent[];
|
|
145
149
|
guide?: string;
|
|
@@ -175,6 +179,7 @@ export interface SiteInput {
|
|
|
175
179
|
collections?: CollectionDef[];
|
|
176
180
|
globals?: GlobalDef[];
|
|
177
181
|
translationFallback?: boolean;
|
|
182
|
+
trailingSlash?: TrailingSlash;
|
|
178
183
|
content?: ShippedContent[];
|
|
179
184
|
guide?: string;
|
|
180
185
|
admin?: AdminSettings;
|
|
@@ -30,6 +30,7 @@ export function defineSite(def) {
|
|
|
30
30
|
collections: def.collections ?? [],
|
|
31
31
|
globals: def.globals ?? [],
|
|
32
32
|
translationFallback: def.translationFallback ?? true,
|
|
33
|
+
trailingSlash: def.trailingSlash ?? 'never',
|
|
33
34
|
content: def.content ?? [],
|
|
34
35
|
admin: def.admin ?? {},
|
|
35
36
|
seo: def.seo ?? {},
|
|
@@ -40,7 +40,7 @@ export interface Entry<F = Record<string, unknown>> {
|
|
|
40
40
|
/** The locale whose content is shown. */
|
|
41
41
|
locale: string;
|
|
42
42
|
fallback: boolean;
|
|
43
|
-
/** The encoded site
|
|
43
|
+
/** The encoded page URL, with the trailing slash when the site asks for it, or `null` for data entries. */
|
|
44
44
|
url: string | null;
|
|
45
45
|
title: string;
|
|
46
46
|
slug: string | null;
|
|
@@ -75,6 +75,8 @@ export interface PageInfo {
|
|
|
75
75
|
fallback: boolean;
|
|
76
76
|
/** The decoded site path; `''` for a page without one. */
|
|
77
77
|
path: string;
|
|
78
|
+
/** The encoded page URL, with the trailing slash when the site asks for it; `''` for a page without one. */
|
|
79
|
+
url: string;
|
|
78
80
|
/** When Inlay first published the page's document; `null` for a route or a never-published draft. */
|
|
79
81
|
publishedAt: string | null;
|
|
80
82
|
page: number;
|
|
@@ -129,7 +131,10 @@ export interface RenderContext {
|
|
|
129
131
|
script: ScriptApi;
|
|
130
132
|
alternates: Array<{
|
|
131
133
|
locale: string;
|
|
134
|
+
/** The decoded site path. */
|
|
132
135
|
path: string;
|
|
136
|
+
/** The encoded page URL, with the trailing slash when the site asks for it. */
|
|
137
|
+
url: string;
|
|
133
138
|
fallback: boolean;
|
|
134
139
|
}>;
|
|
135
140
|
/**
|
|
@@ -122,11 +122,6 @@ export declare const manifestSchema: z.ZodObject<{
|
|
|
122
122
|
slots: z.ZodArray<z.ZodString>;
|
|
123
123
|
}, z.core.$strict>>;
|
|
124
124
|
}, z.core.$strict>;
|
|
125
|
-
/**
|
|
126
|
-
* Whether `version` falls in `range`, which is `^MAJOR.MINOR.PATCH`: for major 0, the same minor and a patch at
|
|
127
|
-
* least as high; otherwise the same major and a minor and patch at least as high.
|
|
128
|
-
*/
|
|
129
|
-
export declare function satisfies(version: string, range: string): boolean;
|
|
130
125
|
export declare function sha256Hex(bytes: Uint8Array): string;
|
|
131
126
|
/** Where a release keeps a shipped file: named by its sha256, keeping its extension. */
|
|
132
127
|
export declare function contentPath(file: string, bytes: Uint8Array): string;
|
|
@@ -43,30 +43,6 @@ export const manifestSchema = z.strictObject({
|
|
|
43
43
|
locales: z.array(z.string()),
|
|
44
44
|
types: z.record(z.string(), z.strictObject({ kind: z.enum(['singleton', 'collection', 'global']), slots: z.array(z.string()) })),
|
|
45
45
|
});
|
|
46
|
-
const VERSION = /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/;
|
|
47
|
-
function parts(version) {
|
|
48
|
-
const m = VERSION.exec(version);
|
|
49
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Whether `version` falls in `range`, which is `^MAJOR.MINOR.PATCH`: for major 0, the same minor and a patch at
|
|
53
|
-
* least as high; otherwise the same major and a minor and patch at least as high.
|
|
54
|
-
*/
|
|
55
|
-
export function satisfies(version, range) {
|
|
56
|
-
if (!range.startsWith('^'))
|
|
57
|
-
return false;
|
|
58
|
-
const want = parts(range.slice(1));
|
|
59
|
-
const have = parts(version);
|
|
60
|
-
if (!want || !have)
|
|
61
|
-
return false;
|
|
62
|
-
const [major, minor, patch] = want;
|
|
63
|
-
const [hMajor, hMinor, hPatch] = have;
|
|
64
|
-
if (hMajor !== major)
|
|
65
|
-
return false;
|
|
66
|
-
if (major === 0)
|
|
67
|
-
return hMinor === minor && hPatch >= patch;
|
|
68
|
-
return hMinor > minor || (hMinor === minor && hPatch >= patch);
|
|
69
|
-
}
|
|
70
46
|
export function sha256Hex(bytes) {
|
|
71
47
|
return createHash('sha256').update(bytes).digest('hex');
|
|
72
48
|
}
|
|
@@ -15,8 +15,8 @@ export interface LoadedRelease {
|
|
|
15
15
|
* package (from `src/` the package's own `exports` name `dist/`): field definitions are checked by identity.
|
|
16
16
|
*/
|
|
17
17
|
export declare const INLAY_ENTRIES: Readonly<Record<string, string>>;
|
|
18
|
-
/** Throws `error.
|
|
19
|
-
export declare function checkInlayVersion(
|
|
18
|
+
/** Throws `error.releaseTooOld` or `error.releaseTooNew` when a release packed with Inlay `packed` doesn't run on Inlay `version` (default: the running one). */
|
|
19
|
+
export declare function checkInlayVersion(packed: string, version?: string): void;
|
|
20
20
|
/**
|
|
21
21
|
* Opens the release file at `file` into the empty folder `opts.dir` without running any of it. The signature is
|
|
22
22
|
* checked against `opts.trustedKeys` before anything but the manifest is read, the Inlay version range next, and
|
|
@@ -9,8 +9,9 @@ import { InlayError } from '../errors.js';
|
|
|
9
9
|
import { buildRegistry } from '../registry/registry.js';
|
|
10
10
|
import { inlayVersion as currentVersion } from '../version.js';
|
|
11
11
|
import { fingerprint, verify } from './keys.js';
|
|
12
|
-
import { manifestSchema,
|
|
12
|
+
import { manifestSchema, sha256Hex } from './manifest.js';
|
|
13
13
|
import { SITE_DIR_EXPORT } from './site-dir.js';
|
|
14
|
+
import { releaseFit, runningWindow } from './window.js';
|
|
14
15
|
const SIGNED = new Set(['manifest.json', 'manifest.sig']);
|
|
15
16
|
/** `.ts` when running from `src/` (tsx, vitest), `.js` from `dist/`. */
|
|
16
17
|
const EXT = import.meta.url.endsWith('.ts') ? '.ts' : '.js';
|
|
@@ -84,16 +85,14 @@ function invalid() {
|
|
|
84
85
|
function releasePath(path) {
|
|
85
86
|
return path === 'site.js' || path.startsWith('content/') || path.startsWith('public/');
|
|
86
87
|
}
|
|
87
|
-
/** `
|
|
88
|
-
function
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!satisfies(version, range))
|
|
96
|
-
throw new InlayError('release', 'error.releaseVersion', { range, version, ...series(range) });
|
|
88
|
+
/** Throws `error.releaseTooOld` or `error.releaseTooNew` when a release packed with Inlay `packed` doesn't run on Inlay `version` (default: the running one). */
|
|
89
|
+
export function checkInlayVersion(packed, version = currentVersion()) {
|
|
90
|
+
const window = { ...runningWindow(), version };
|
|
91
|
+
const fit = releaseFit(packed, window);
|
|
92
|
+
if (fit === 'tooOld')
|
|
93
|
+
throw new InlayError('release', 'error.releaseTooOld', { packed, version, oldest: window.oldest });
|
|
94
|
+
if (fit === 'tooNew')
|
|
95
|
+
throw new InlayError('release', 'error.releaseTooNew', { packed, version });
|
|
97
96
|
}
|
|
98
97
|
/** The manifest and signature are small; anything bigger is refused before the signature is checked. */
|
|
99
98
|
const SIGNED_MAX_BYTES = 1024 ** 2;
|
|
@@ -183,7 +182,7 @@ async function checkRelease(file, dir, opts) {
|
|
|
183
182
|
catch {
|
|
184
183
|
throw invalid();
|
|
185
184
|
}
|
|
186
|
-
checkInlayVersion(manifest.inlay.
|
|
185
|
+
checkInlayVersion(manifest.inlay.version, opts.inlayVersion);
|
|
187
186
|
const listed = Object.keys(manifest.files);
|
|
188
187
|
if (!Object.hasOwn(manifest.files, 'site.js') || !listed.every(releasePath))
|
|
189
188
|
throw invalid();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ReleaseWindow {
|
|
2
|
+
version: string;
|
|
3
|
+
oldest: string;
|
|
4
|
+
nextOldest: string | null;
|
|
5
|
+
}
|
|
6
|
+
export type ReleaseFit = 'ok' | 'warn' | 'tooOld' | 'tooNew';
|
|
7
|
+
export declare function runningWindow(): ReleaseWindow;
|
|
8
|
+
/** Whether a release packed with `packed` runs in `window`: packed with the oldest version or later, and not a newer minor than the host. */
|
|
9
|
+
export declare function releaseFit(packed: string, window?: ReleaseWindow): ReleaseFit;
|
|
10
|
+
/** A stored release's `inlay_range` without its leading caret. */
|
|
11
|
+
export declare function packedVersion(range: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { inlayVersion, NEXT_OLDEST_RELEASE, OLDEST_RELEASE } from '../version.js';
|
|
2
|
+
const VERSION = /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/;
|
|
3
|
+
function parts(version) {
|
|
4
|
+
const m = VERSION.exec(version);
|
|
5
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
6
|
+
}
|
|
7
|
+
function compare(a, b) {
|
|
8
|
+
return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
|
|
9
|
+
}
|
|
10
|
+
export function runningWindow() {
|
|
11
|
+
return { version: inlayVersion(), oldest: OLDEST_RELEASE, nextOldest: NEXT_OLDEST_RELEASE };
|
|
12
|
+
}
|
|
13
|
+
/** Whether a release packed with `packed` runs in `window`: packed with the oldest version or later, and not a newer minor than the host. */
|
|
14
|
+
export function releaseFit(packed, window = runningWindow()) {
|
|
15
|
+
const have = parts(packed);
|
|
16
|
+
if (!have)
|
|
17
|
+
return 'tooOld';
|
|
18
|
+
const host = parts(window.version);
|
|
19
|
+
const oldest = parts(window.oldest);
|
|
20
|
+
if (!host || !oldest)
|
|
21
|
+
return 'tooOld';
|
|
22
|
+
if (have[0] > host[0] || (have[0] === host[0] && have[1] > host[1]))
|
|
23
|
+
return 'tooNew';
|
|
24
|
+
if (compare(have, oldest) < 0)
|
|
25
|
+
return 'tooOld';
|
|
26
|
+
const next = window.nextOldest === null ? null : parts(window.nextOldest);
|
|
27
|
+
if (next && compare(have, next) < 0)
|
|
28
|
+
return 'warn';
|
|
29
|
+
return 'ok';
|
|
30
|
+
}
|
|
31
|
+
/** A stored release's `inlay_range` without its leading caret. */
|
|
32
|
+
export function packedVersion(range) {
|
|
33
|
+
return range.startsWith('^') ? range.slice(1) : range;
|
|
34
|
+
}
|
|
@@ -19,3 +19,8 @@ export declare function withLocale(registry: Registry, locale: string, path: str
|
|
|
19
19
|
export declare function singletonPath(def: SingletonDef, locale: string, defaultLocale: string): string | null;
|
|
20
20
|
export declare function routeRegExp(route: string): RegExp;
|
|
21
21
|
export declare function routePath(route: string, slug: string): string;
|
|
22
|
+
export type TrailingSlash = 'always' | 'never';
|
|
23
|
+
/** A decoded, normalized path (optionally with a `?query`) in the form the site presents. */
|
|
24
|
+
export declare function presentPath(path: string, mode: TrailingSlash): string;
|
|
25
|
+
/** The same for an encoded site-relative href; other hrefs come back unchanged. */
|
|
26
|
+
export declare function presentHref(href: string, mode: TrailingSlash): string;
|
package/dist/core/site/paths.js
CHANGED
|
@@ -75,3 +75,35 @@ export function routeRegExp(route) {
|
|
|
75
75
|
export function routePath(route, slug) {
|
|
76
76
|
return route.replace(':slug', slug);
|
|
77
77
|
}
|
|
78
|
+
function slashable(path) {
|
|
79
|
+
if (path === '/' || path.endsWith('/') || isReserved(path))
|
|
80
|
+
return false;
|
|
81
|
+
return !(path.split('/').at(-1) ?? '').includes('.');
|
|
82
|
+
}
|
|
83
|
+
/** A decoded, normalized path (optionally with a `?query`) in the form the site presents. */
|
|
84
|
+
export function presentPath(path, mode) {
|
|
85
|
+
if (mode !== 'always')
|
|
86
|
+
return path;
|
|
87
|
+
const q = path.indexOf('?');
|
|
88
|
+
const bare = q === -1 ? path : path.slice(0, q);
|
|
89
|
+
if (!slashable(bare))
|
|
90
|
+
return path;
|
|
91
|
+
return `${bare}/${q === -1 ? '' : path.slice(q)}`;
|
|
92
|
+
}
|
|
93
|
+
/** The same for an encoded site-relative href; other hrefs come back unchanged. */
|
|
94
|
+
export function presentHref(href, mode) {
|
|
95
|
+
if (mode !== 'always' || !href.startsWith('/') || href.startsWith('//'))
|
|
96
|
+
return href;
|
|
97
|
+
const q = href.indexOf('?');
|
|
98
|
+
const bare = q === -1 ? href : href.slice(0, q);
|
|
99
|
+
let decoded;
|
|
100
|
+
try {
|
|
101
|
+
decoded = decodeURIComponent(bare);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return href;
|
|
105
|
+
}
|
|
106
|
+
if (!slashable(decoded))
|
|
107
|
+
return href;
|
|
108
|
+
return `${bare}/${q === -1 ? '' : href.slice(q)}`;
|
|
109
|
+
}
|
|
@@ -158,14 +158,14 @@ function lookupLocales(deps, locale) {
|
|
|
158
158
|
export async function resolvePath(deps, rawPath, opts = {}) {
|
|
159
159
|
const res = await resolveSite(deps, rawPath, opts);
|
|
160
160
|
if (res.kind === 'canonical') {
|
|
161
|
-
// A mixed-case path that would 404 once canonical goes where the lowercase fallback lands, in one 301.
|
|
162
161
|
const { canonical } = res;
|
|
162
|
+
const at = await atCanonical(deps, canonical, opts);
|
|
163
|
+
if (at?.kind === 'redirect')
|
|
164
|
+
return at;
|
|
165
|
+
// A mixed-case path that would 404 once canonical goes where the lowercase fallback lands, in one 301.
|
|
163
166
|
const lower = lowercaseFallback(canonical);
|
|
164
|
-
if (lower !== null &&
|
|
165
|
-
!deps.registry.getRoutePaths.has(canonical) &&
|
|
166
|
-
(await resolveRules(deps, encodePath(canonical), opts)).kind === 'not_found') {
|
|
167
|
+
if (lower !== null && at?.kind === 'not_found')
|
|
167
168
|
return (await landing(deps, lower, opts)) ?? redirect(canonical);
|
|
168
|
-
}
|
|
169
169
|
return redirect(canonical);
|
|
170
170
|
}
|
|
171
171
|
if (res.kind !== 'rules')
|
|
@@ -191,6 +191,13 @@ async function resolveRules(deps, rawPath, opts) {
|
|
|
191
191
|
return res;
|
|
192
192
|
return (await matchRedirect(deps, res, opts)) ?? notFound(res.locale);
|
|
193
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* What steps 1–7b answer at the target of a step 2–3 redirect, so a rule there is reached in the
|
|
196
|
+
* same 301; `null` at a GET code route, which no rule can shadow.
|
|
197
|
+
*/
|
|
198
|
+
async function atCanonical(deps, canonical, opts) {
|
|
199
|
+
return deps.registry.getRoutePaths.has(canonical) ? null : resolveRules(deps, encodePath(canonical), opts);
|
|
200
|
+
}
|
|
194
201
|
/**
|
|
195
202
|
* Where the lowercase fallback for a request lands, given its lowercase form `lower`: a GET code
|
|
196
203
|
* route or a page there, a redirect that steps 2–6 or a rule would give, or `null` when nothing
|
|
@@ -202,8 +209,12 @@ async function landing(deps, lower, opts) {
|
|
|
202
209
|
const res = await resolveSite(deps, encodePath(lower), opts);
|
|
203
210
|
if (res.kind === 'page')
|
|
204
211
|
return redirect(lower);
|
|
205
|
-
if (res.kind === 'canonical')
|
|
212
|
+
if (res.kind === 'canonical') {
|
|
213
|
+
const at = await atCanonical(deps, res.canonical, opts);
|
|
214
|
+
if (at?.kind === 'redirect')
|
|
215
|
+
return at;
|
|
206
216
|
return (await answers(deps, res.canonical, opts)) ? redirect(res.canonical) : null;
|
|
217
|
+
}
|
|
207
218
|
if (res.kind === 'redirect')
|
|
208
219
|
return res;
|
|
209
220
|
if (res.kind !== 'rules')
|
package/dist/core/version.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
1
|
export declare function inlayVersion(): string;
|
|
2
|
+
/** The oldest Inlay version whose releases this one still runs. See the upgrades spec and CLAUDE.md. */
|
|
3
|
+
export declare const OLDEST_RELEASE = "0.5.0";
|
|
4
|
+
/** The oldest version the next window will keep, when already decided: older releases get a "pack again" warning. */
|
|
5
|
+
export declare const NEXT_OLDEST_RELEASE: string | null;
|
package/dist/core/version.js
CHANGED
|
@@ -3,3 +3,7 @@ export function inlayVersion() {
|
|
|
3
3
|
const url = new URL('../../package.json', import.meta.url);
|
|
4
4
|
return JSON.parse(readFileSync(url, 'utf8')).version;
|
|
5
5
|
}
|
|
6
|
+
/** The oldest Inlay version whose releases this one still runs. See the upgrades spec and CLAUDE.md. */
|
|
7
|
+
export const OLDEST_RELEASE = '0.5.0';
|
|
8
|
+
/** The oldest version the next window will keep, when already decided: older releases get a "pack again" warning. */
|
|
9
|
+
export const NEXT_OLDEST_RELEASE = null;
|
package/dist/host/activate.js
CHANGED
|
@@ -8,6 +8,7 @@ import { DEFAULT_MAX_BYTES, DEFAULT_UPLOAD_TYPES } from '../core/media/detect.js
|
|
|
8
8
|
import { fileMediaStore } from '../core/media/store.js';
|
|
9
9
|
import { buildRegistry } from '../core/registry/registry.js';
|
|
10
10
|
import { checkInlayVersion } from '../core/release/read.js';
|
|
11
|
+
import { packedVersion } from '../core/release/window.js';
|
|
11
12
|
import { currentRelease, getRelease, readCurrentPointer, writeCurrentPointer } from './store.js';
|
|
12
13
|
const noShipped = () => ({ created: [], replaced: [], skipped: [], deletedRefs: [], warnings: [] });
|
|
13
14
|
/** An activation's result as counts, for the worker that asked for it. */
|
|
@@ -105,7 +106,7 @@ export async function activateRelease(deps, releaseId) {
|
|
|
105
106
|
throw new InlayError('not_found', 'error.releaseUnknown', { id: releaseId });
|
|
106
107
|
if (row.state === 'deleted')
|
|
107
108
|
throw new InlayError('release', 'error.releaseDeleted', { name: row.name });
|
|
108
|
-
checkInlayVersion(row.inlay_range);
|
|
109
|
+
checkInlayVersion(packedVersion(row.inlay_range));
|
|
109
110
|
if (row.state === 'current') {
|
|
110
111
|
// A retry after a commit whose pointer write was lost: the database already says it's current.
|
|
111
112
|
const pointer = await readCurrentPointer(deps.releasesDir).catch(() => null);
|
package/dist/host/push.d.ts
CHANGED
|
@@ -62,7 +62,11 @@ export declare const RELEASE_NAME_MAX = 100;
|
|
|
62
62
|
/** With `activate`, how long the content half of the diff may take in all (preview start and answer): the activation waits. */
|
|
63
63
|
export declare const ACTIVATE_DIFF_TIMEOUT_MS = 10000;
|
|
64
64
|
/** A release row as the push API sends it: without the schema JSON, which is only kept for the record. */
|
|
65
|
-
export type ReleaseInfo = Omit<ReleaseRow, 'schema'
|
|
65
|
+
export type ReleaseInfo = Omit<ReleaseRow, 'schema'> & {
|
|
66
|
+
warning?: string;
|
|
67
|
+
};
|
|
68
|
+
/** The advance "pack again" warning for a release packed with the version in `row.inlay_range`, or null. */
|
|
69
|
+
export declare function packAgainWarning(row: Pick<ReleaseRow, 'inlay_range' | 'state'>): string | null;
|
|
66
70
|
export declare function releaseInfo(row: ReleaseRow): ReleaseInfo;
|
|
67
71
|
/**
|
|
68
72
|
* The manifest of what the site runs now: the current release's, or, for a site run from source with no current
|
package/dist/host/push.js
CHANGED
|
@@ -9,6 +9,7 @@ import { openDatabase } from '../core/db/connection.js';
|
|
|
9
9
|
import { InlayError } from '../core/errors.js';
|
|
10
10
|
import { t } from '../core/messages/index.js';
|
|
11
11
|
import { manifestOfRegistry, manifestSchema } from '../core/release/manifest.js';
|
|
12
|
+
import { packedVersion, releaseFit } from '../core/release/window.js';
|
|
12
13
|
import { structuralDiff } from './diff.js';
|
|
13
14
|
import { currentRelease, deleteRelease, getRelease, listReleases, releaseDir, storeRelease } from './store.js';
|
|
14
15
|
/** The largest release file a push may send. */
|
|
@@ -23,9 +24,17 @@ const RELEASE_TYPES = new Set(['application/gzip', 'application/x-gzip', 'applic
|
|
|
23
24
|
const DIFF_PATH = '/_inlay/internal/diff';
|
|
24
25
|
const DIFF_TIMEOUT_MS = 60_000;
|
|
25
26
|
const problemOf = (e) => (e instanceof Error ? e.message : String(e));
|
|
27
|
+
/** The advance "pack again" warning for a release packed with the version in `row.inlay_range`, or null. */
|
|
28
|
+
export function packAgainWarning(row) {
|
|
29
|
+
if (row.state === 'deleted')
|
|
30
|
+
return null;
|
|
31
|
+
const packed = packedVersion(row.inlay_range);
|
|
32
|
+
return releaseFit(packed) === 'warn' ? t('release.packAgain', { packed }) : null;
|
|
33
|
+
}
|
|
26
34
|
export function releaseInfo(row) {
|
|
27
35
|
const { schema: _schema, ...info } = row;
|
|
28
|
-
|
|
36
|
+
const warning = packAgainWarning(row);
|
|
37
|
+
return warning === null ? info : { ...info, warning };
|
|
29
38
|
}
|
|
30
39
|
async function readManifest(file) {
|
|
31
40
|
return manifestSchema.parse(JSON.parse(await readFile(file, 'utf8')));
|
|
@@ -161,12 +170,14 @@ export async function pushRelease(opts, file, push) {
|
|
|
161
170
|
throw new InlayError('release', 'error.releaseSecretsMissing', { names: missing.join(', ') });
|
|
162
171
|
const staged = await readManifest(join(releaseDir(work, row.id), 'manifest.json'));
|
|
163
172
|
const structural = structuralDiff(await currentManifest(opts), staged);
|
|
173
|
+
const packed = staged.inlay.version;
|
|
174
|
+
const packAgain = releaseFit(packed) === 'warn' ? [t('push.packAgain', { packed })] : [];
|
|
164
175
|
if (push.dryRun) {
|
|
165
176
|
if (opts.host?.startPreview === undefined)
|
|
166
|
-
return { release: null, diff: { structural, content: null }, warnings:
|
|
177
|
+
return { release: null, diff: { structural, content: null }, warnings: packAgain };
|
|
167
178
|
try {
|
|
168
179
|
const { content, warnings } = await contentDiff(opts, row.id, { dir: work });
|
|
169
|
-
return { release: null, diff: { structural, content }, warnings };
|
|
180
|
+
return { release: null, diff: { structural, content }, warnings: [...warnings, ...packAgain] };
|
|
170
181
|
}
|
|
171
182
|
finally {
|
|
172
183
|
await opts.host.stopPreview?.(row.id).catch(() => { });
|
|
@@ -190,7 +201,7 @@ export async function pushRelease(opts, file, push) {
|
|
|
190
201
|
}
|
|
191
202
|
structural.migrations = await pendingMigrations(opts.db, row.id, structural.migrations);
|
|
192
203
|
const { content, warnings } = await contentDiff(opts, row.id, push.activate ? { deadlineMs: opts.activateDiffTimeoutMs ?? ACTIVATE_DIFF_TIMEOUT_MS } : {});
|
|
193
|
-
return { release: row, diff: { structural, content }, warnings };
|
|
204
|
+
return { release: row, diff: { structural, content }, warnings: [...warnings, ...packAgain] };
|
|
194
205
|
}
|
|
195
206
|
finally {
|
|
196
207
|
await scratch.destroy();
|
|
@@ -249,7 +260,8 @@ function statusOf(e) {
|
|
|
249
260
|
switch (e.messageId) {
|
|
250
261
|
case 'error.releaseSignature':
|
|
251
262
|
return 403;
|
|
252
|
-
case 'error.
|
|
263
|
+
case 'error.releaseTooOld':
|
|
264
|
+
case 'error.releaseTooNew':
|
|
253
265
|
case 'error.releaseSecretsMissing':
|
|
254
266
|
case 'error.releaseCurrent':
|
|
255
267
|
case 'error.releaseDeleted':
|
package/dist/host/worker.js
CHANGED
|
@@ -5,6 +5,7 @@ import { openDatabase } from '../core/db/connection.js';
|
|
|
5
5
|
import { InlayError } from '../core/errors.js';
|
|
6
6
|
import { t } from '../core/messages/index.js';
|
|
7
7
|
import { checkInlayVersion, loadRelease } from '../core/release/read.js';
|
|
8
|
+
import { packedVersion, releaseFit } from '../core/release/window.js';
|
|
8
9
|
import { activateRelease, summarize } from './activate.js';
|
|
9
10
|
import { createSiteApp } from './app.js';
|
|
10
11
|
import { drainable } from './drain.js';
|
|
@@ -82,12 +83,14 @@ async function chooseRelease(config, log) {
|
|
|
82
83
|
log('host.pointerRepaired', { name: row.name });
|
|
83
84
|
}
|
|
84
85
|
try {
|
|
85
|
-
checkInlayVersion(row.inlay_range);
|
|
86
|
+
checkInlayVersion(packedVersion(row.inlay_range));
|
|
86
87
|
}
|
|
87
88
|
catch (e) {
|
|
88
|
-
if (!(e instanceof InlayError)
|
|
89
|
+
if (!(e instanceof InlayError))
|
|
89
90
|
throw e;
|
|
90
|
-
|
|
91
|
+
if (e.messageId !== 'error.releaseTooOld' && e.messageId !== 'error.releaseTooNew')
|
|
92
|
+
throw e;
|
|
93
|
+
log(e.messageId === 'error.releaseTooOld' ? 'host.releaseTooOld' : 'host.releaseTooNew', { ...e.params, name: row.name });
|
|
91
94
|
return { page: 'unavailable', id: row.id };
|
|
92
95
|
}
|
|
93
96
|
const opened = await openCurrentRelease({ releasesDir: config.paths.releases });
|
|
@@ -95,6 +98,9 @@ async function chooseRelease(config, log) {
|
|
|
95
98
|
log('host.releaseMissing', { name: row.name });
|
|
96
99
|
return { page: 'unavailable', id: row.id };
|
|
97
100
|
}
|
|
101
|
+
const packed = packedVersion(row.inlay_range);
|
|
102
|
+
if (releaseFit(packed) === 'warn')
|
|
103
|
+
log('host.releasePackAgain', { name: row.name, packed });
|
|
98
104
|
return { loaded: opened.loaded, id: row.id, name: row.name };
|
|
99
105
|
}
|
|
100
106
|
/**
|
package/dist/site.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { defineConfig, type InlayConfig } from './config.js';
|
|
|
12
12
|
export { escapeHtml, raw, SafeHtml, type Html, type Renderable } from './jsx/html.js';
|
|
13
13
|
export { defineField, type AdminWidget, type FieldMeta, type FormValues, type WidgetProps } from './core/fields/define.js';
|
|
14
14
|
export { defineContent, defineEntries, type ShippedContent, type ShippedDocument, type ShippedDocumentRef, } from './core/registry/content.js';
|
|
15
|
-
export { defineBlock, defineCollection, defineGlobal, defineSingleton, defineSite, defineTemplate, type AdminSettings, type BlockDef, type CollectionDef, type GlobalDef, type SingletonDef, type SingletonPath, type SiteDefinition, type OgType, type RedirectDef, type SeoSettings, type SiteInput, type SlotDef, type TemplateDef, type TemplateRenderProps, type TypeDef, } from './core/registry/define.js';
|
|
15
|
+
export { defineBlock, defineCollection, defineGlobal, defineSingleton, defineSite, defineTemplate, type AdminSettings, type BlockDef, type CollectionDef, type GlobalDef, type SingletonDef, type SingletonPath, type SiteDefinition, type OgType, type RedirectDef, type SeoSettings, type SiteInput, type SlotDef, type TemplateDef, type TemplateRenderProps, type TrailingSlash, type TypeDef, } from './core/registry/define.js';
|
|
16
16
|
export { defineIntegration, type ConsentCategory, type CspDirective, type CspSources, type IntegrationDef, type IntegrationPage, type IntegrationRender, } from './core/registry/integration.js';
|
|
17
17
|
export { defineRoute, type QueryApi, type RouteContext, type RouteDef, type RouteMethod, type RouteRequest, type RouteResponse, } from './core/registry/route.js';
|
|
18
18
|
export { defineMigration, type MigrationContext, type MigrationDocument, type ReleaseMigration, } from './core/registry/migration.js';
|