@fifthbell/brokaw 0.1.65 → 0.1.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -5
- package/dist/cronkite-manifest.d.ts +80 -0
- package/dist/cronkite-manifest.js +124 -0
- package/dist/cronkite-manifest.json +139 -0
- package/dist/json-schema-formats.d.ts +2 -0
- package/dist/json-schema-formats.js +19 -0
- package/dist/layouts.d.ts +13 -0
- package/dist/layouts.js +12 -0
- package/dist/live-program-page/index.html +2 -2
- package/dist/live-program-page/live-program-manifest.json +4 -4
- package/dist/live-program-release.d.ts +3 -0
- package/dist/live-program-release.js +76 -0
- package/dist/manifest-validation.d.ts +10 -0
- package/dist/manifest-validation.js +27 -0
- package/dist/renderer.core.d.ts +2 -1
- package/dist/renderer.core.js +2 -1
- package/dist/renderer.d.ts +3 -0
- package/dist/renderer.js +2 -0
- package/dist/renderer.node.js +7 -12
- package/dist/schemas/canonical-document.schema.json +1071 -0
- package/dist/schemas/cronkite-manifest.schema.json +501 -0
- package/dist/schemas/feed-renderable-input.schema.json +16 -0
- package/dist/schemas/live-program-release-input.schema.json +34 -0
- package/dist/types/canonical-article.d.ts +8 -262
- package/dist/types/canonical-article.js +21 -245
- package/dist/types/canonical-document-schema.generated.d.ts +1634 -0
- package/dist/types/canonical-document-schema.generated.js +1730 -0
- package/dist/types/canonical-document.generated.d.ts +541 -0
- package/dist/types/canonical-document.generated.js +3 -0
- package/dist/types/cronkite-manifest.generated.d.ts +339 -0
- package/dist/types/cronkite-manifest.generated.js +3 -0
- package/dist/types/live-program-release-input.generated.d.ts +5 -0
- package/dist/types/live-program-release-input.generated.js +3 -0
- package/dist/video/Root.d.ts +1 -0
- package/dist/video/Root.js +40 -0
- package/dist/video/ShortVideo.d.ts +3 -0
- package/dist/video/ShortVideo.js +92 -0
- package/dist/video/index.d.ts +2 -0
- package/dist/video/index.js +4 -0
- package/dist/video/types.d.ts +37 -0
- package/dist/video/types.js +1 -0
- package/package.json +19 -4
- /package/dist/live-program-page/{live-program.v0.1.65.css → live-program.v0.1.67.css} +0 -0
- /package/dist/live-program-page/{live-program.v0.1.65.js → live-program.v0.1.67.js} +0 -0
package/README.md
CHANGED
|
@@ -5,9 +5,12 @@ Server-side renderer and Handlebars template bundle for fifthbell pages.
|
|
|
5
5
|
## What it does
|
|
6
6
|
|
|
7
7
|
- Renders canonical content documents into HTML
|
|
8
|
-
- Supports
|
|
8
|
+
- Supports every layout declared by the packaged Cronkite manifest, including
|
|
9
|
+
article, homepage, category, search, 404, live-story, link-in-bio, media, and
|
|
10
|
+
standalone pages
|
|
9
11
|
- Ships reusable Handlebars templates, partial dependency metadata, and compiled CSS
|
|
10
12
|
- Ships the complete Fifthbell live-program page, renderer media, local fonts, and a versioned integrity manifest
|
|
13
|
+
- Ships a CLS-owned social-image renderable and provider-neutral Remotion short-video renderable
|
|
11
14
|
|
|
12
15
|
## Installation
|
|
13
16
|
|
|
@@ -18,12 +21,15 @@ npm install @fifthbell/brokaw
|
|
|
18
21
|
## Basic usage
|
|
19
22
|
|
|
20
23
|
```ts
|
|
21
|
-
import { render } from
|
|
24
|
+
import { render } from "@fifthbell/brokaw";
|
|
22
25
|
|
|
23
26
|
const html = render(doc);
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
`doc` must match the canonical schema
|
|
29
|
+
`doc` must match the normative canonical schema in
|
|
30
|
+
[src/schemas/canonical-document.schema.json](src/schemas/canonical-document.schema.json).
|
|
31
|
+
TypeScript declarations are generated from that schema; runtime rendering validates
|
|
32
|
+
against the same artifact.
|
|
27
33
|
|
|
28
34
|
### Optional real user monitoring
|
|
29
35
|
|
|
@@ -34,17 +40,36 @@ When enabled, the shared standard and 404 shells collect only performance and fi
|
|
|
34
40
|
## Exports
|
|
35
41
|
|
|
36
42
|
- `@fifthbell/brokaw` -> renderer entrypoint
|
|
43
|
+
- `@fifthbell/brokaw/cronkite-manifest.json` -> data-only CLS capability manifest
|
|
44
|
+
- `@fifthbell/brokaw/video` -> bundleable Remotion short-video entrypoint
|
|
45
|
+
- `@fifthbell/brokaw/schemas/canonical-document.schema.json` -> canonical input contract
|
|
46
|
+
- `@fifthbell/brokaw/schemas/cronkite-manifest.schema.json` -> CLS manifest contract
|
|
47
|
+
- `@fifthbell/brokaw/schemas/feed-renderable-input.schema.json` -> CMS-owned feed renderable input boundary
|
|
48
|
+
- `@fifthbell/brokaw/schemas/live-program-release-input.schema.json` -> generic live-program release input
|
|
37
49
|
- `@fifthbell/brokaw/partial-deps.json` -> partial-to-layout dependency map
|
|
38
50
|
|
|
51
|
+
The root module also exports `cronkiteManifest`, `outletConfig`, `version`,
|
|
52
|
+
`render`, `fontFiles`, `buildInstagramImageHtml`, and
|
|
53
|
+
`liveProgramReleaseFiles`. See [docs/cronkite-compatibility.md](docs/cronkite-compatibility.md)
|
|
54
|
+
for ownership, validation, system-page, asset, and release-ordering details.
|
|
55
|
+
|
|
39
56
|
## Fifthbell live-program bundle
|
|
40
57
|
|
|
41
58
|
`liveProgramPageFiles()` returns the deployable bundle as deterministic `{ key, body, contentType }` entries. It includes `index.html`, versioned JavaScript and CSS, every image/audio/font dependency, and `live-program-manifest.json`. The manifest records the Brokaw package version, renderer schema version, file byte sizes, content types, and SHA-256 digests. It is also an `alcantara.program-template` contract: it declares the renderer entrypoint, supported capabilities, accepted signals, and the runtime parameters Alcantara supplies. A publisher such as Cronkite must upload every returned key under the same public prefix; the relative URLs then work at any Cronkite-owned path.
|
|
42
59
|
|
|
60
|
+
`liveProgramReleaseFiles({ programId, apiBaseUrl })` is the manifest-declared
|
|
61
|
+
request renderable. It preserves the raw bundle export, emits versioned release
|
|
62
|
+
objects, and places the configured `html/program.html` commit point last.
|
|
63
|
+
|
|
43
64
|
```ts
|
|
44
|
-
import { liveProgramPageFiles } from
|
|
65
|
+
import { liveProgramPageFiles } from "@fifthbell/brokaw";
|
|
45
66
|
|
|
46
67
|
for (const file of liveProgramPageFiles()) {
|
|
47
|
-
await publish({
|
|
68
|
+
await publish({
|
|
69
|
+
key: file.key,
|
|
70
|
+
body: file.body,
|
|
71
|
+
contentType: file.contentType,
|
|
72
|
+
});
|
|
48
73
|
}
|
|
49
74
|
```
|
|
50
75
|
|
|
@@ -70,6 +95,7 @@ npm install
|
|
|
70
95
|
npm run typecheck
|
|
71
96
|
npm run test:unit
|
|
72
97
|
npm run build
|
|
98
|
+
npm run verify:packed-remotion
|
|
73
99
|
npm pack --dry-run
|
|
74
100
|
npm run storybook
|
|
75
101
|
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare const cronkiteManifest: {
|
|
2
|
+
readonly contract: "cronkite.cls";
|
|
3
|
+
readonly contractVersion: 1;
|
|
4
|
+
readonly package: "@fifthbell/brokaw";
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly layouts: ["article-page" | "homepage" | "category-page" | "search-page" | "404" | "live-story" | "link-in-bio" | "media-page" | "standalone-page", ...("article-page" | "homepage" | "category-page" | "search-page" | "404" | "live-story" | "link-in-bio" | "media-page" | "standalone-page")[]];
|
|
7
|
+
readonly languages: ["en", "es", "it"];
|
|
8
|
+
readonly collections: {
|
|
9
|
+
readonly "article-page": "json/articles";
|
|
10
|
+
readonly "standalone-page": "json/pages";
|
|
11
|
+
readonly "media-page": "json/media";
|
|
12
|
+
};
|
|
13
|
+
readonly systemPages: import("./types/cronkite-manifest.generated.js").SystemPage[];
|
|
14
|
+
readonly renderables: {
|
|
15
|
+
readonly homepage: {
|
|
16
|
+
readonly engine: "handlebars";
|
|
17
|
+
readonly export: "render";
|
|
18
|
+
readonly contentType: "text/html; charset=utf-8";
|
|
19
|
+
readonly inputSchema: "dist/schemas/feed-renderable-input.schema.json";
|
|
20
|
+
};
|
|
21
|
+
readonly "category-page": {
|
|
22
|
+
readonly engine: "handlebars";
|
|
23
|
+
readonly export: "render";
|
|
24
|
+
readonly contentType: "text/html; charset=utf-8";
|
|
25
|
+
readonly inputSchema: "dist/schemas/feed-renderable-input.schema.json";
|
|
26
|
+
};
|
|
27
|
+
readonly "search-page": {
|
|
28
|
+
readonly engine: "handlebars";
|
|
29
|
+
readonly export: "render";
|
|
30
|
+
readonly contentType: "text/html; charset=utf-8";
|
|
31
|
+
readonly inputSchema: "dist/schemas/feed-renderable-input.schema.json";
|
|
32
|
+
};
|
|
33
|
+
readonly "live-story": {
|
|
34
|
+
readonly engine: "handlebars";
|
|
35
|
+
readonly export: "render";
|
|
36
|
+
readonly contentType: "text/html; charset=utf-8";
|
|
37
|
+
readonly inputSchema: "dist/schemas/feed-renderable-input.schema.json";
|
|
38
|
+
};
|
|
39
|
+
readonly "link-in-bio": {
|
|
40
|
+
readonly engine: "handlebars";
|
|
41
|
+
readonly export: "render";
|
|
42
|
+
readonly contentType: "text/html; charset=utf-8";
|
|
43
|
+
readonly inputSchema: "dist/schemas/feed-renderable-input.schema.json";
|
|
44
|
+
};
|
|
45
|
+
readonly "social-image": {
|
|
46
|
+
readonly engine: "html-raster";
|
|
47
|
+
readonly export: "buildInstagramImageHtml";
|
|
48
|
+
readonly contentType: "image/jpeg";
|
|
49
|
+
readonly width: 1080;
|
|
50
|
+
readonly height: 1350;
|
|
51
|
+
};
|
|
52
|
+
readonly "short-video": {
|
|
53
|
+
readonly engine: "remotion";
|
|
54
|
+
readonly entry: "dist/video/index.js";
|
|
55
|
+
readonly compositionId: "BrokawShort";
|
|
56
|
+
readonly contentType: "video/mp4";
|
|
57
|
+
};
|
|
58
|
+
readonly "live-program": {
|
|
59
|
+
readonly engine: "handlebars";
|
|
60
|
+
readonly export: "liveProgramReleaseFiles";
|
|
61
|
+
readonly outputMode: "files";
|
|
62
|
+
readonly lifecycle: "request";
|
|
63
|
+
readonly inputSchema: "dist/schemas/live-program-release-input.schema.json";
|
|
64
|
+
readonly contract: {
|
|
65
|
+
readonly kind: "alcantara.program-template";
|
|
66
|
+
readonly version: 1;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly capabilities: {
|
|
71
|
+
readonly fonts: {
|
|
72
|
+
readonly export: "fontFiles";
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
readonly writeOrdering: {
|
|
76
|
+
readonly "live-program": {
|
|
77
|
+
readonly last: ["html/program.html"];
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { layoutNames } from "./layouts.js";
|
|
2
|
+
import { outletConfig } from "./outlet-config.js";
|
|
3
|
+
import { PROGRAM_TEMPLATE_CONTRACT_VERSION, PROGRAM_TEMPLATE_KIND, } from "./program-template-manifest.js";
|
|
4
|
+
import { version } from "./version.js";
|
|
5
|
+
const systemPages = [
|
|
6
|
+
{
|
|
7
|
+
layout: "404",
|
|
8
|
+
route: "/{language}/404",
|
|
9
|
+
key: "html/{language}/404/index.html",
|
|
10
|
+
cacheControl: "public, max-age=0, must-revalidate",
|
|
11
|
+
perLanguage: true,
|
|
12
|
+
copy: {
|
|
13
|
+
en: {
|
|
14
|
+
title: "Page Not Found",
|
|
15
|
+
description: "The page you are looking for does not exist.",
|
|
16
|
+
},
|
|
17
|
+
es: {
|
|
18
|
+
title: "Página no encontrada",
|
|
19
|
+
description: "La página que buscas no existe.",
|
|
20
|
+
},
|
|
21
|
+
it: {
|
|
22
|
+
title: "Pagina non trovata",
|
|
23
|
+
description: "La pagina che stai cercando non esiste.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
layout: "search-page",
|
|
29
|
+
route: "/{language}/search",
|
|
30
|
+
key: "html/{language}/search/index.html",
|
|
31
|
+
cacheControl: "public, max-age=0, must-revalidate",
|
|
32
|
+
perLanguage: true,
|
|
33
|
+
copy: {
|
|
34
|
+
en: {
|
|
35
|
+
title: "Search",
|
|
36
|
+
description: outletConfig.searchDescriptions.en,
|
|
37
|
+
},
|
|
38
|
+
es: {
|
|
39
|
+
title: "Buscar",
|
|
40
|
+
description: outletConfig.searchDescriptions.es,
|
|
41
|
+
},
|
|
42
|
+
it: {
|
|
43
|
+
title: "Cerca",
|
|
44
|
+
description: outletConfig.searchDescriptions.it,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
export const cronkiteManifest = {
|
|
50
|
+
contract: "cronkite.cls",
|
|
51
|
+
contractVersion: 1,
|
|
52
|
+
package: "@fifthbell/brokaw",
|
|
53
|
+
version,
|
|
54
|
+
layouts: [...layoutNames],
|
|
55
|
+
languages: [...outletConfig.supportedLanguages],
|
|
56
|
+
collections: {
|
|
57
|
+
"article-page": "json/articles",
|
|
58
|
+
"standalone-page": "json/pages",
|
|
59
|
+
"media-page": "json/media",
|
|
60
|
+
},
|
|
61
|
+
systemPages,
|
|
62
|
+
renderables: {
|
|
63
|
+
homepage: {
|
|
64
|
+
engine: "handlebars",
|
|
65
|
+
export: "render",
|
|
66
|
+
contentType: "text/html; charset=utf-8",
|
|
67
|
+
inputSchema: "dist/schemas/feed-renderable-input.schema.json",
|
|
68
|
+
},
|
|
69
|
+
"category-page": {
|
|
70
|
+
engine: "handlebars",
|
|
71
|
+
export: "render",
|
|
72
|
+
contentType: "text/html; charset=utf-8",
|
|
73
|
+
inputSchema: "dist/schemas/feed-renderable-input.schema.json",
|
|
74
|
+
},
|
|
75
|
+
"search-page": {
|
|
76
|
+
engine: "handlebars",
|
|
77
|
+
export: "render",
|
|
78
|
+
contentType: "text/html; charset=utf-8",
|
|
79
|
+
inputSchema: "dist/schemas/feed-renderable-input.schema.json",
|
|
80
|
+
},
|
|
81
|
+
"live-story": {
|
|
82
|
+
engine: "handlebars",
|
|
83
|
+
export: "render",
|
|
84
|
+
contentType: "text/html; charset=utf-8",
|
|
85
|
+
inputSchema: "dist/schemas/feed-renderable-input.schema.json",
|
|
86
|
+
},
|
|
87
|
+
"link-in-bio": {
|
|
88
|
+
engine: "handlebars",
|
|
89
|
+
export: "render",
|
|
90
|
+
contentType: "text/html; charset=utf-8",
|
|
91
|
+
inputSchema: "dist/schemas/feed-renderable-input.schema.json",
|
|
92
|
+
},
|
|
93
|
+
"social-image": {
|
|
94
|
+
engine: "html-raster",
|
|
95
|
+
export: "buildInstagramImageHtml",
|
|
96
|
+
contentType: "image/jpeg",
|
|
97
|
+
width: 1080,
|
|
98
|
+
height: 1350,
|
|
99
|
+
},
|
|
100
|
+
"short-video": {
|
|
101
|
+
engine: "remotion",
|
|
102
|
+
entry: "dist/video/index.js",
|
|
103
|
+
compositionId: "BrokawShort",
|
|
104
|
+
contentType: "video/mp4",
|
|
105
|
+
},
|
|
106
|
+
"live-program": {
|
|
107
|
+
engine: "handlebars",
|
|
108
|
+
export: "liveProgramReleaseFiles",
|
|
109
|
+
outputMode: "files",
|
|
110
|
+
lifecycle: "request",
|
|
111
|
+
inputSchema: "dist/schemas/live-program-release-input.schema.json",
|
|
112
|
+
contract: {
|
|
113
|
+
kind: PROGRAM_TEMPLATE_KIND,
|
|
114
|
+
version: PROGRAM_TEMPLATE_CONTRACT_VERSION,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
capabilities: {
|
|
119
|
+
fonts: { export: "fontFiles" },
|
|
120
|
+
},
|
|
121
|
+
writeOrdering: {
|
|
122
|
+
"live-program": { last: ["html/program.html"] },
|
|
123
|
+
},
|
|
124
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": "cronkite.cls",
|
|
3
|
+
"contractVersion": 1,
|
|
4
|
+
"package": "@fifthbell/brokaw",
|
|
5
|
+
"version": "0.1.67",
|
|
6
|
+
"layouts": [
|
|
7
|
+
"404",
|
|
8
|
+
"article-page",
|
|
9
|
+
"homepage",
|
|
10
|
+
"category-page",
|
|
11
|
+
"search-page",
|
|
12
|
+
"live-story",
|
|
13
|
+
"link-in-bio",
|
|
14
|
+
"media-page",
|
|
15
|
+
"standalone-page"
|
|
16
|
+
],
|
|
17
|
+
"languages": [
|
|
18
|
+
"en",
|
|
19
|
+
"es",
|
|
20
|
+
"it"
|
|
21
|
+
],
|
|
22
|
+
"collections": {
|
|
23
|
+
"article-page": "json/articles",
|
|
24
|
+
"standalone-page": "json/pages",
|
|
25
|
+
"media-page": "json/media"
|
|
26
|
+
},
|
|
27
|
+
"systemPages": [
|
|
28
|
+
{
|
|
29
|
+
"layout": "404",
|
|
30
|
+
"route": "/{language}/404",
|
|
31
|
+
"key": "html/{language}/404/index.html",
|
|
32
|
+
"cacheControl": "public, max-age=0, must-revalidate",
|
|
33
|
+
"perLanguage": true,
|
|
34
|
+
"copy": {
|
|
35
|
+
"en": {
|
|
36
|
+
"title": "Page Not Found",
|
|
37
|
+
"description": "The page you are looking for does not exist."
|
|
38
|
+
},
|
|
39
|
+
"es": {
|
|
40
|
+
"title": "Página no encontrada",
|
|
41
|
+
"description": "La página que buscas no existe."
|
|
42
|
+
},
|
|
43
|
+
"it": {
|
|
44
|
+
"title": "Pagina non trovata",
|
|
45
|
+
"description": "La pagina che stai cercando non esiste."
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"layout": "search-page",
|
|
51
|
+
"route": "/{language}/search",
|
|
52
|
+
"key": "html/{language}/search/index.html",
|
|
53
|
+
"cacheControl": "public, max-age=0, must-revalidate",
|
|
54
|
+
"perLanguage": true,
|
|
55
|
+
"copy": {
|
|
56
|
+
"en": {
|
|
57
|
+
"title": "Search",
|
|
58
|
+
"description": "Search stories from Fifthbell."
|
|
59
|
+
},
|
|
60
|
+
"es": {
|
|
61
|
+
"title": "Buscar",
|
|
62
|
+
"description": "Busca noticias de Fifthbell."
|
|
63
|
+
},
|
|
64
|
+
"it": {
|
|
65
|
+
"title": "Cerca",
|
|
66
|
+
"description": "Cerca notizie Fifthbell."
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"renderables": {
|
|
72
|
+
"homepage": {
|
|
73
|
+
"engine": "handlebars",
|
|
74
|
+
"export": "render",
|
|
75
|
+
"contentType": "text/html; charset=utf-8",
|
|
76
|
+
"inputSchema": "dist/schemas/feed-renderable-input.schema.json"
|
|
77
|
+
},
|
|
78
|
+
"category-page": {
|
|
79
|
+
"engine": "handlebars",
|
|
80
|
+
"export": "render",
|
|
81
|
+
"contentType": "text/html; charset=utf-8",
|
|
82
|
+
"inputSchema": "dist/schemas/feed-renderable-input.schema.json"
|
|
83
|
+
},
|
|
84
|
+
"search-page": {
|
|
85
|
+
"engine": "handlebars",
|
|
86
|
+
"export": "render",
|
|
87
|
+
"contentType": "text/html; charset=utf-8",
|
|
88
|
+
"inputSchema": "dist/schemas/feed-renderable-input.schema.json"
|
|
89
|
+
},
|
|
90
|
+
"live-story": {
|
|
91
|
+
"engine": "handlebars",
|
|
92
|
+
"export": "render",
|
|
93
|
+
"contentType": "text/html; charset=utf-8",
|
|
94
|
+
"inputSchema": "dist/schemas/feed-renderable-input.schema.json"
|
|
95
|
+
},
|
|
96
|
+
"link-in-bio": {
|
|
97
|
+
"engine": "handlebars",
|
|
98
|
+
"export": "render",
|
|
99
|
+
"contentType": "text/html; charset=utf-8",
|
|
100
|
+
"inputSchema": "dist/schemas/feed-renderable-input.schema.json"
|
|
101
|
+
},
|
|
102
|
+
"social-image": {
|
|
103
|
+
"engine": "html-raster",
|
|
104
|
+
"export": "buildInstagramImageHtml",
|
|
105
|
+
"contentType": "image/jpeg",
|
|
106
|
+
"width": 1080,
|
|
107
|
+
"height": 1350
|
|
108
|
+
},
|
|
109
|
+
"short-video": {
|
|
110
|
+
"engine": "remotion",
|
|
111
|
+
"entry": "dist/video/index.js",
|
|
112
|
+
"compositionId": "BrokawShort",
|
|
113
|
+
"contentType": "video/mp4"
|
|
114
|
+
},
|
|
115
|
+
"live-program": {
|
|
116
|
+
"engine": "handlebars",
|
|
117
|
+
"export": "liveProgramReleaseFiles",
|
|
118
|
+
"outputMode": "files",
|
|
119
|
+
"lifecycle": "request",
|
|
120
|
+
"inputSchema": "dist/schemas/live-program-release-input.schema.json",
|
|
121
|
+
"contract": {
|
|
122
|
+
"kind": "alcantara.program-template",
|
|
123
|
+
"version": 1
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"capabilities": {
|
|
128
|
+
"fonts": {
|
|
129
|
+
"export": "fontFiles"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"writeOrdering": {
|
|
133
|
+
"live-program": {
|
|
134
|
+
"last": [
|
|
135
|
+
"html/program.html"
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function addContractFormats(ajv) {
|
|
2
|
+
ajv.addFormat("date-time", {
|
|
3
|
+
type: "string",
|
|
4
|
+
validate: (value) => /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/.test(value) && !Number.isNaN(Date.parse(value)),
|
|
5
|
+
});
|
|
6
|
+
ajv.addFormat("uri", {
|
|
7
|
+
type: "string",
|
|
8
|
+
validate: (value) => {
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(value);
|
|
11
|
+
return Boolean(url.protocol);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
ajv.addFormat("uuid", /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const layoutFiles: {
|
|
2
|
+
readonly "article-page": "article-page.hbs";
|
|
3
|
+
readonly homepage: "homepage.hbs";
|
|
4
|
+
readonly "category-page": "category-page.hbs";
|
|
5
|
+
readonly "search-page": "search-page.hbs";
|
|
6
|
+
readonly "404": "404.hbs";
|
|
7
|
+
readonly "live-story": "live-story.hbs";
|
|
8
|
+
readonly "link-in-bio": "link-in-bio.hbs";
|
|
9
|
+
readonly "media-page": "media-page.hbs";
|
|
10
|
+
readonly "standalone-page": "standalone-page.hbs";
|
|
11
|
+
};
|
|
12
|
+
export type LayoutName = keyof typeof layoutFiles;
|
|
13
|
+
export declare const layoutNames: readonly ["article-page" | "homepage" | "category-page" | "search-page" | "404" | "live-story" | "link-in-bio" | "media-page" | "standalone-page", ...("article-page" | "homepage" | "category-page" | "search-page" | "404" | "live-story" | "link-in-bio" | "media-page" | "standalone-page")[]];
|
package/dist/layouts.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const layoutFiles = {
|
|
2
|
+
"article-page": "article-page.hbs",
|
|
3
|
+
homepage: "homepage.hbs",
|
|
4
|
+
"category-page": "category-page.hbs",
|
|
5
|
+
"search-page": "search-page.hbs",
|
|
6
|
+
"404": "404.hbs",
|
|
7
|
+
"live-story": "live-story.hbs",
|
|
8
|
+
"link-in-bio": "link-in-bio.hbs",
|
|
9
|
+
"media-page": "media-page.hbs",
|
|
10
|
+
"standalone-page": "standalone-page.hbs",
|
|
11
|
+
};
|
|
12
|
+
export const layoutNames = Object.freeze(Object.keys(layoutFiles));
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
6
6
|
<title>Live Program | fifthbell</title>
|
|
7
|
-
<script type="module" crossorigin src="./live-program.v0.1.
|
|
8
|
-
<link rel="stylesheet" crossorigin href="./live-program.v0.1.
|
|
7
|
+
<script type="module" crossorigin src="./live-program.v0.1.67.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="./live-program.v0.1.67.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
47
|
"package": "@fifthbell/brokaw",
|
|
48
|
-
"bundleVersion": "0.1.
|
|
48
|
+
"bundleVersion": "0.1.67",
|
|
49
49
|
"schemaVersion": 1,
|
|
50
50
|
"statePath": "state",
|
|
51
51
|
"eventsPath": "events",
|
|
@@ -390,16 +390,16 @@
|
|
|
390
390
|
"key": "index.html",
|
|
391
391
|
"contentType": "text/html; charset=utf-8",
|
|
392
392
|
"bytes": 446,
|
|
393
|
-
"sha256": "
|
|
393
|
+
"sha256": "1249e8b7b564917ef85414584c8be83102d9923d15a9d4a2c27d7f92f3b2c0d8"
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
|
-
"key": "live-program.v0.1.
|
|
396
|
+
"key": "live-program.v0.1.67.css",
|
|
397
397
|
"contentType": "text/css; charset=utf-8",
|
|
398
398
|
"bytes": 77695,
|
|
399
399
|
"sha256": "2457b6cae3d9e7d6004c8c8649c8cbcfddb8eca00a63ddb7ab7e74bb585384a6"
|
|
400
400
|
},
|
|
401
401
|
{
|
|
402
|
-
"key": "live-program.v0.1.
|
|
402
|
+
"key": "live-program.v0.1.67.js",
|
|
403
403
|
"contentType": "application/javascript; charset=utf-8",
|
|
404
404
|
"bytes": 294937,
|
|
405
405
|
"sha256": "3e1abe4ffb61cdef6c9fbf441548df60b972821aa4c4e119a5741a664ff089b0"
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type LiveProgramFileEntry } from "./renderer.node.js";
|
|
2
|
+
import type { FifthbellLiveProgramReleaseInput } from "./types/live-program-release-input.generated.js";
|
|
3
|
+
export declare function liveProgramReleaseFiles(input: FifthbellLiveProgramReleaseInput): LiveProgramFileEntry[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { liveProgramPageFiles, } from "./renderer.node.js";
|
|
2
|
+
import { version } from "./version.js";
|
|
3
|
+
const PROGRAM_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
4
|
+
function validateInput(input) {
|
|
5
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
6
|
+
throw new Error("live-program release input must be an object");
|
|
7
|
+
}
|
|
8
|
+
const values = input;
|
|
9
|
+
const keys = Object.keys(values).sort();
|
|
10
|
+
if (keys.join(",") !== "apiBaseUrl,programId") {
|
|
11
|
+
throw new Error("live-program release input requires only apiBaseUrl and programId");
|
|
12
|
+
}
|
|
13
|
+
if (typeof values.programId !== "string" ||
|
|
14
|
+
!PROGRAM_ID.test(values.programId) ||
|
|
15
|
+
values.programId.length > 128) {
|
|
16
|
+
throw new Error("live-program programId is invalid");
|
|
17
|
+
}
|
|
18
|
+
if (typeof values.apiBaseUrl !== "string") {
|
|
19
|
+
throw new Error("live-program apiBaseUrl must be an absolute URL");
|
|
20
|
+
}
|
|
21
|
+
let apiBaseUrl;
|
|
22
|
+
try {
|
|
23
|
+
apiBaseUrl = new URL(values.apiBaseUrl);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error("live-program apiBaseUrl must be an absolute URL");
|
|
27
|
+
}
|
|
28
|
+
const localHttp = apiBaseUrl.protocol === "http:" &&
|
|
29
|
+
(apiBaseUrl.hostname === "localhost" ||
|
|
30
|
+
apiBaseUrl.hostname === "127.0.0.1");
|
|
31
|
+
if ((apiBaseUrl.protocol !== "https:" && !localHttp) ||
|
|
32
|
+
apiBaseUrl.username ||
|
|
33
|
+
apiBaseUrl.password ||
|
|
34
|
+
apiBaseUrl.search ||
|
|
35
|
+
apiBaseUrl.hash) {
|
|
36
|
+
throw new Error("live-program apiBaseUrl must use HTTPS outside local development and cannot contain credentials, query parameters, or a fragment");
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
programId: values.programId,
|
|
40
|
+
apiBaseUrl: values.apiBaseUrl.replace(/\/$/, ""),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function configureCanonicalDocument(html, releasePrefix, input) {
|
|
44
|
+
const head = html.match(/<head(?:\s[^>]*)?>/i)?.[0];
|
|
45
|
+
if (!head)
|
|
46
|
+
throw new Error("live-program index.html is missing <head>");
|
|
47
|
+
const runtimeConfig = JSON.stringify(input)
|
|
48
|
+
.replaceAll("<", "\\u003c")
|
|
49
|
+
.replaceAll("\u2028", "\\u2028")
|
|
50
|
+
.replaceAll("\u2029", "\\u2029");
|
|
51
|
+
const injection = [
|
|
52
|
+
`<base href="./${releasePrefix}/">`,
|
|
53
|
+
`<script>window.__FIFTHBELL_LIVE_PROGRAM_CONFIG__=${runtimeConfig};</script>`,
|
|
54
|
+
].join("\n ");
|
|
55
|
+
return html.replace(head, `${head}\n ${injection}`);
|
|
56
|
+
}
|
|
57
|
+
export function liveProgramReleaseFiles(input) {
|
|
58
|
+
const validated = validateInput(input);
|
|
59
|
+
const bundleFiles = liveProgramPageFiles();
|
|
60
|
+
const index = bundleFiles.find((file) => file.key === "index.html");
|
|
61
|
+
if (!index)
|
|
62
|
+
throw new Error("live-program bundle is missing index.html");
|
|
63
|
+
const relativeReleasePrefix = `live-program.v${version}`;
|
|
64
|
+
const releasePrefix = `html/${relativeReleasePrefix}`;
|
|
65
|
+
return [
|
|
66
|
+
...bundleFiles.map((file) => ({
|
|
67
|
+
...file,
|
|
68
|
+
key: `${releasePrefix}/${file.key}`,
|
|
69
|
+
})),
|
|
70
|
+
{
|
|
71
|
+
key: "html/program.html",
|
|
72
|
+
body: Buffer.from(configureCanonicalDocument(index.body.toString("utf8"), relativeReleasePrefix, validated)),
|
|
73
|
+
contentType: index.contentType,
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CronkiteCLSManifest } from "./types/cronkite-manifest.generated.js";
|
|
2
|
+
export type ManifestAlignmentSources = {
|
|
3
|
+
layouts: readonly string[];
|
|
4
|
+
languages: readonly string[];
|
|
5
|
+
defaultLanguage: string;
|
|
6
|
+
packageName: string;
|
|
7
|
+
packageVersion: string;
|
|
8
|
+
exportedVersion: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function assertManifestAlignment(manifest: CronkiteCLSManifest, sources: ManifestAlignmentSources): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function assertSameOrderedValues(label, manifestValues, sourceValues) {
|
|
2
|
+
if (manifestValues.length !== sourceValues.length ||
|
|
3
|
+
manifestValues.some((value, index) => value !== sourceValues[index])) {
|
|
4
|
+
throw new Error(`${label} drift: manifest=${JSON.stringify(manifestValues)} source=${JSON.stringify(sourceValues)}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function assertManifestAlignment(manifest, sources) {
|
|
8
|
+
assertSameOrderedValues("layout", manifest.layouts, sources.layouts);
|
|
9
|
+
assertSameOrderedValues("language", manifest.languages, sources.languages);
|
|
10
|
+
if (manifest.package !== sources.packageName ||
|
|
11
|
+
manifest.version !== sources.packageVersion ||
|
|
12
|
+
manifest.version !== sources.exportedVersion) {
|
|
13
|
+
throw new Error(`package identity drift: manifest=${manifest.package}@${manifest.version} package=${sources.packageName}@${sources.packageVersion} export=${sources.exportedVersion}`);
|
|
14
|
+
}
|
|
15
|
+
if (!manifest.languages.includes(sources.defaultLanguage)) {
|
|
16
|
+
throw new Error("outletConfig.defaultLanguage is not declared by the manifest");
|
|
17
|
+
}
|
|
18
|
+
for (const page of manifest.systemPages ?? []) {
|
|
19
|
+
if (!manifest.layouts.includes(page.layout)) {
|
|
20
|
+
throw new Error(`system page uses undeclared layout: ${page.layout}`);
|
|
21
|
+
}
|
|
22
|
+
const expectedLanguages = page.perLanguage
|
|
23
|
+
? manifest.languages
|
|
24
|
+
: [sources.defaultLanguage];
|
|
25
|
+
assertSameOrderedValues(`system page ${page.layout} copy`, Object.keys(page.copy).sort(), [...expectedLanguages].sort());
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/renderer.core.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type LayoutName } from './layouts.js';
|
|
1
2
|
import { type CanonicalDocument } from './types/canonical-article.js';
|
|
2
|
-
export type LayoutName
|
|
3
|
+
export type { LayoutName } from './layouts.js';
|
|
3
4
|
export type RendererAssets = {
|
|
4
5
|
layouts: Record<LayoutName, string>;
|
|
5
6
|
partials: Record<string, string>;
|
package/dist/renderer.core.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Handlebars from 'handlebars';
|
|
2
|
+
import { layoutNames } from './layouts.js';
|
|
2
3
|
import { canonicalArticleSchema } from './types/canonical-article.js';
|
|
3
4
|
import { distributeHomepageArticles } from './homepage-distributor.js';
|
|
4
5
|
import { buildSofascoreAttackMomentumUrl, buildSofascoreMatchUrl } from './utils/sofascore.js';
|
|
@@ -335,7 +336,7 @@ export function renderWithAssets(doc, assets) {
|
|
|
335
336
|
}
|
|
336
337
|
const requestedLayout = doc.layout;
|
|
337
338
|
if (!requestedLayout || !layoutCache.has(requestedLayout)) {
|
|
338
|
-
throw new Error(`Unknown layout "${requestedLayout ?? 'undefined'}". Expected one of:
|
|
339
|
+
throw new Error(`Unknown layout "${requestedLayout ?? 'undefined'}". Expected one of: ${layoutNames.join(', ')}`);
|
|
339
340
|
}
|
|
340
341
|
const parsed = canonicalArticleSchema.parse(normalizeDocument(doc));
|
|
341
342
|
const template = layoutCache.get(parsed.layout);
|