create-ailk 0.47.0 → 0.48.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/README.md +180 -43
- package/component-catalog.json +223 -285
- package/component-catalog.md +1 -1
- package/dist/apply-design.d.ts +26 -68
- package/dist/apply-design.js +150 -322
- package/dist/cli.js +152 -17
- package/dist/compare-chrome.d.ts +108 -0
- package/dist/compare-chrome.js +481 -0
- package/dist/compare-look.d.ts +94 -0
- package/dist/compare-look.js +378 -0
- package/dist/copy.js +1 -1
- package/dist/design-compile.d.ts +17 -21
- package/dist/design-compile.js +32 -56
- package/dist/design-files.d.ts +93 -0
- package/dist/design-files.js +312 -0
- package/dist/design-home.d.ts +4 -2
- package/dist/design-home.js +88 -6
- package/dist/design-names.d.ts +13 -0
- package/dist/design-names.js +76 -0
- package/dist/design-package.d.ts +46 -56
- package/dist/design-package.js +285 -288
- package/dist/design-presets.d.ts +41 -0
- package/dist/design-presets.js +83 -4
- package/dist/design-scaffold.d.ts +12 -2
- package/dist/design-scaffold.js +72 -34
- package/dist/generated/design-settings.d.ts +56 -0
- package/dist/generated/design-settings.js +237 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/inventory.d.ts +3 -2
- package/dist/inventory.js +10 -4
- package/dist/lib/design-checks.d.ts +46 -0
- package/dist/lib/design-checks.js +79 -1
- package/dist/lib/env-catalog.js +1 -1
- package/dist/lib/module-license-gate.d.ts +1 -1
- package/dist/lib/module-license-gate.js +1 -1
- package/dist/lib/render-verdict.d.ts +13 -1
- package/dist/lib/render-verdict.js +41 -1
- package/dist/look-hub.d.ts +44 -0
- package/dist/look-hub.js +130 -0
- package/dist/look-record.d.ts +35 -0
- package/dist/look-record.js +85 -0
- package/dist/look-samples.d.ts +66 -0
- package/dist/look-samples.js +456 -0
- package/dist/look-settings.d.ts +53 -0
- package/dist/look-settings.js +363 -0
- package/dist/module-architecture.js +12 -0
- package/dist/parse-args.d.ts +10 -6
- package/dist/parse-args.js +26 -13
- package/dist/programmatic.d.ts +1 -19
- package/dist/programmatic.js +65 -103
- package/dist/retired-design-bodies.d.ts +29 -0
- package/dist/retired-design-bodies.js +51 -0
- package/dist/seed-flows.d.ts +1 -1
- package/dist/seed-flows.js +12 -14
- package/dist/seed-workspace.d.ts +4 -1
- package/dist/seed-workspace.js +139 -17
- package/dist/site-chrome.d.ts +41 -41
- package/dist/site-chrome.js +50 -70
- package/dist/site-fonts.d.ts +10 -14
- package/dist/site-fonts.js +5 -1
- package/dist/starter-grid.d.ts +2 -2
- package/dist/strip-look-copies.d.ts +67 -0
- package/dist/strip-look-copies.js +591 -0
- package/dist/template-manifest.d.ts +6 -14
- package/dist/template-manifest.js +0 -9
- package/dist/template-record.d.ts +3 -1
- package/dist/template-record.js +3 -1
- package/dist/topology.d.ts +15 -0
- package/dist/topology.js +60 -0
- package/dist/update.d.ts +57 -1
- package/dist/update.js +742 -13
- package/package.json +3 -4
- package/site-templates/aliases/hub.TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/designs/minimalism/DESIGN.md +163 -297
- package/site-templates/designs/minimalism/LOOK.md +42 -0
- package/site-templates/designs/minimalism/design.yaml +167 -0
- package/site-templates/designs/standard/DESIGN.md +145 -149
- package/site-templates/designs/standard/LOOK.md +42 -0
- package/site-templates/designs/standard/design.yaml +72 -0
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/marketing-site-free/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/local-business-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/organization-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.json +2 -31
- package/site-templates/shapes/person-service/TEMPLATE-MANIFEST.md +1 -25
- package/site-templates/shapes/person-service/content/_site.mdx +0 -26
- package/templates/.claude/rules/extending.md +3 -2
- package/templates/.env.example +11 -4
- package/templates/CLAUDE.md +1 -1
- package/templates/DESIGN.md +145 -149
- package/templates/README.md +15 -16
- package/templates/apps/api/.env.example +11 -4
- package/templates/apps/api/CLAUDE.md +6 -4
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +15 -5
- package/templates/apps/mcp/CLAUDE.md +4 -2
- package/templates/apps/web/.env.example +10 -3
- package/templates/apps/web/CLAUDE.md +14 -3
- package/templates/apps/web/app/[locale]/layout.tsx +53 -50
- package/templates/apps/web/app/not-found.tsx +11 -11
- package/templates/apps/web/auth.ts +48 -35
- package/templates/apps/web/jest.config.cjs +5 -0
- package/templates/apps/web/lib/__tests__/hub-site-config.test.ts +179 -31
- package/templates/apps/web/lib/__tests__/library-fonts.test.ts +35 -0
- package/templates/apps/web/lib/__tests__/page-chrome-navigation.test.ts +71 -32
- package/templates/apps/web/lib/__tests__/page-chrome.test.ts +123 -26
- package/templates/apps/web/lib/__tests__/section-look.test.ts +150 -0
- package/templates/apps/web/lib/__tests__/site-theme.test.ts +81 -289
- package/templates/apps/web/lib/deck-page.ts +3 -10
- package/templates/apps/web/lib/deploy-fonts.ts +12 -0
- package/templates/apps/web/lib/hub-site-config.ts +97 -14
- package/templates/apps/web/lib/library-fonts.ts +41 -0
- package/templates/apps/web/lib/mcp-oauth.ts +11 -4
- package/templates/apps/web/lib/page-chrome.ts +52 -34
- package/templates/apps/web/lib/section-look.ts +28 -0
- package/templates/apps/web/lib/site-design.ts +205 -0
- package/templates/apps/web/lib/site-theme-head.ts +98 -13
- package/templates/apps/web/lib/site-theme.ts +40 -62
- package/templates/apps/web/messages/en.json +0 -6
- package/templates/apps/web/next.config.mjs +195 -6
- package/templates/apps/web/package.json +2 -0
- package/templates/apps/web/site-pages.config.tsx +4 -2
- package/templates/content/_site.mdx +0 -26
- package/templates/design.yaml +75 -0
- package/templates/project.yaml +14 -0
- package/versions.json +52 -51
- package/site-templates/marketing-site/DESIGN.md +0 -259
- package/site-templates/marketing-site-free/DESIGN.md +0 -259
- package/site-templates/saas-product/DESIGN.md +0 -259
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +0 -288
- package/templates/apps/web/lib/__tests__/site-theme-head.test.ts +0 -70
- package/templates/apps/web/lib/site-chrome.ts +0 -46
- package/templates/apps/web/lib/site-fonts.ts +0 -15
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// GENERATED by tools/generate-design-settings.ts — do not edit by hand.
|
|
2
|
+
// Source: packages/validation/src/schemas/design-settings.ts (#12470 D1). Regenerate with `pnpm design-settings:generate`;
|
|
3
|
+
// `pnpm design-settings:check` fails when this file drifts from its source.
|
|
4
|
+
export const BREAK_OR_CONTROL_REGEX = /[\p{Cc}\u2028\u2029\u202A-\u202E\u2066-\u2069]/u;
|
|
5
|
+
export const BUTTON_SHAPE_VALUES = ["control", "pill"];
|
|
6
|
+
export const CHECKMARKS_VALUES = ["circle", "plain"];
|
|
7
|
+
export const CHROME_STYLE_VALUES = ["default", "minimal"];
|
|
8
|
+
export const CLOSING_FOOTER_PATHS_MAX = 20;
|
|
9
|
+
export const CLOSING_FOOTER_PATH_MAX = 200;
|
|
10
|
+
export const CLOSING_FOOTER_PATH_REGEX = /^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]*$/;
|
|
11
|
+
export const CLOSING_FOOTER_PATH_SEGMENTS_MAX = 20;
|
|
12
|
+
export const COLOR_KEYS_BAND = [
|
|
13
|
+
"bg-band",
|
|
14
|
+
"fg-band",
|
|
15
|
+
"surface-band",
|
|
16
|
+
"surface-secondary-band",
|
|
17
|
+
"border-band",
|
|
18
|
+
"text-muted-band",
|
|
19
|
+
"brand-band",
|
|
20
|
+
"fg-on-brand-band",
|
|
21
|
+
"accent-band",
|
|
22
|
+
];
|
|
23
|
+
export const COLOR_KEYS_DARK = [
|
|
24
|
+
"bg-dark",
|
|
25
|
+
"fg-dark",
|
|
26
|
+
"surface-dark",
|
|
27
|
+
"surface-secondary-dark",
|
|
28
|
+
"border-dark",
|
|
29
|
+
"text-muted-dark",
|
|
30
|
+
"brand-dark",
|
|
31
|
+
"fg-on-brand-dark",
|
|
32
|
+
"accent-dark",
|
|
33
|
+
];
|
|
34
|
+
export const COLOR_KEYS_LIGHT = [
|
|
35
|
+
"bg",
|
|
36
|
+
"fg",
|
|
37
|
+
"surface",
|
|
38
|
+
"surface-secondary",
|
|
39
|
+
"border",
|
|
40
|
+
"text-muted",
|
|
41
|
+
"brand",
|
|
42
|
+
"fg-on-brand",
|
|
43
|
+
"accent",
|
|
44
|
+
];
|
|
45
|
+
export const COLOR_VALUE_REGEX = /^(?:#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|(?:rgba?|hsla?)\((?:[0-9.,%/ +-]|deg|turn){1,60}\)|var\(--[a-z0-9-]{1,40}\))$/;
|
|
46
|
+
export const COMPILED_PALETTE_KEYS = [
|
|
47
|
+
"bg",
|
|
48
|
+
"bgMuted",
|
|
49
|
+
"surface",
|
|
50
|
+
"border",
|
|
51
|
+
"text",
|
|
52
|
+
"textMuted",
|
|
53
|
+
"primary",
|
|
54
|
+
"primaryFg",
|
|
55
|
+
"accent",
|
|
56
|
+
"accentFg",
|
|
57
|
+
"destructive",
|
|
58
|
+
"destructiveFg",
|
|
59
|
+
];
|
|
60
|
+
export const COMPILED_TYPE_ROLES = [
|
|
61
|
+
"display",
|
|
62
|
+
"heading-section",
|
|
63
|
+
"heading-item",
|
|
64
|
+
"body",
|
|
65
|
+
"eyebrow",
|
|
66
|
+
];
|
|
67
|
+
export const COPY_DENSITY_VALUES = ["standard", "sparse"];
|
|
68
|
+
export const CORNERS_VALUES = ["rounded", "square"];
|
|
69
|
+
export const CSS_LENGTH_REGEX = /^(0|(\d{1,4}|\d{0,4}\.\d{1,4})(rem|px|em|%|vw|vh|ch))$/;
|
|
70
|
+
export const DARK_INK_VALUES = ["fg", "accent"];
|
|
71
|
+
export const DECK_ANCHORS_VALUES = ["prefixed", "bare"];
|
|
72
|
+
export const DECK_GROUNDS_MAX = 20;
|
|
73
|
+
export const DECK_GROUND_VALUES = [
|
|
74
|
+
"none",
|
|
75
|
+
"gray-100",
|
|
76
|
+
"wash",
|
|
77
|
+
"wash-secondary",
|
|
78
|
+
"gradient-brand",
|
|
79
|
+
"gradient-dark",
|
|
80
|
+
"solid-dark",
|
|
81
|
+
];
|
|
82
|
+
export const DESCRIPTION_MAX = 400;
|
|
83
|
+
export const DIAL_MAP_MAX = 24;
|
|
84
|
+
export const DIAL_NAME_REGEX = /^[a-z][a-z0-9-]{0,31}$/;
|
|
85
|
+
export const EYEBROW_CASE_VALUES = ["upper", "sentence"];
|
|
86
|
+
export const FIGURES_VALUES = ["platform", "display"];
|
|
87
|
+
export const FONT_FAMILY_REGEX = /^(?:[A-Za-z0-9 ._-]+|'[A-Za-z0-9 ._-]+'|"[A-Za-z0-9 ._-]+")$/;
|
|
88
|
+
export const FONT_SIZE_MOBILE_ROLES = [
|
|
89
|
+
"display",
|
|
90
|
+
"heading-section",
|
|
91
|
+
"heading-item",
|
|
92
|
+
];
|
|
93
|
+
export const FONT_SOURCE_ROLES = ["display", "body"];
|
|
94
|
+
export const FONT_SOURCE_VALUES = ["google"];
|
|
95
|
+
export const FONT_STACK_LENGTH_MAX = 512;
|
|
96
|
+
export const FONT_STACK_MAX = 8;
|
|
97
|
+
export const FOOTER_STYLES = [
|
|
98
|
+
"columns",
|
|
99
|
+
"centered",
|
|
100
|
+
"closing",
|
|
101
|
+
"none",
|
|
102
|
+
];
|
|
103
|
+
export const GOOGLE_FAMILY_REGEX = /^[A-Za-z][A-Za-z0-9 ]*$/;
|
|
104
|
+
export const GROUND_HEX_REGEX = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
105
|
+
export const HEADER_STYLES = ["full", "mark-only", "bare", "none"];
|
|
106
|
+
export const HOME_VALUES = ["default", "deck"];
|
|
107
|
+
export const INNER_PAGES_VALUES = ["default", "bare"];
|
|
108
|
+
export const LAYOUT_OPTIONAL_KEYS = [
|
|
109
|
+
"deckGrounds",
|
|
110
|
+
"innerPages",
|
|
111
|
+
"deckPresentation",
|
|
112
|
+
"deckAnchors",
|
|
113
|
+
"chromeStyle",
|
|
114
|
+
"closingFooterPaths",
|
|
115
|
+
];
|
|
116
|
+
export const LAYOUT_REQUIRED_KEYS = [
|
|
117
|
+
"nav",
|
|
118
|
+
"footer",
|
|
119
|
+
"announcementBanner",
|
|
120
|
+
"home",
|
|
121
|
+
];
|
|
122
|
+
export const LINE_HEIGHT_MOBILE_ROLES = ["display"];
|
|
123
|
+
export const LOOK_FIELDS_PER_SECTION_MAX = 20;
|
|
124
|
+
export const NAME_MAX = 80;
|
|
125
|
+
export const PLACEHOLDERS_VALUES = ["outline", "fill"];
|
|
126
|
+
export const SECTIONS_PER_PAGE_MAX = 20;
|
|
127
|
+
export const SECTION_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]{0,39}$/;
|
|
128
|
+
export const SECTION_PAGE_TYPES = [
|
|
129
|
+
"HomePage",
|
|
130
|
+
"AboutPage",
|
|
131
|
+
"Product",
|
|
132
|
+
"Service",
|
|
133
|
+
"ContactPage",
|
|
134
|
+
"FAQPage",
|
|
135
|
+
"ProductsList",
|
|
136
|
+
"ServicesList",
|
|
137
|
+
"ProjectsList",
|
|
138
|
+
"Project",
|
|
139
|
+
"TermsPage",
|
|
140
|
+
"PrivacyPage",
|
|
141
|
+
"WorkingAgreementPage",
|
|
142
|
+
"GlossaryList",
|
|
143
|
+
"TeamList",
|
|
144
|
+
"TeamMember",
|
|
145
|
+
"Person",
|
|
146
|
+
"Partner",
|
|
147
|
+
"PartnersList",
|
|
148
|
+
"UseCasesList",
|
|
149
|
+
"FeaturesList",
|
|
150
|
+
"PortfolioList",
|
|
151
|
+
"ResourceDetail",
|
|
152
|
+
"ResourcesHub",
|
|
153
|
+
"DownloadsList",
|
|
154
|
+
"Integration",
|
|
155
|
+
"IntegrationsList",
|
|
156
|
+
"ClientsList",
|
|
157
|
+
"TestimonialsList",
|
|
158
|
+
"HowTo",
|
|
159
|
+
"TechArticle",
|
|
160
|
+
"Whitepaper",
|
|
161
|
+
"SoftwareProduct",
|
|
162
|
+
"JobPosting",
|
|
163
|
+
"CareersList",
|
|
164
|
+
"CaseStudy",
|
|
165
|
+
"CaseStudiesList",
|
|
166
|
+
"Course",
|
|
167
|
+
"CoursesList",
|
|
168
|
+
"Event",
|
|
169
|
+
"EventsList",
|
|
170
|
+
"BlogPosting",
|
|
171
|
+
"BlogList",
|
|
172
|
+
"BookCall",
|
|
173
|
+
"NewsletterSignup",
|
|
174
|
+
"DemoRequest",
|
|
175
|
+
"TrialSignup",
|
|
176
|
+
"Waitlist",
|
|
177
|
+
"Assessment",
|
|
178
|
+
"Calculator",
|
|
179
|
+
"CampaignLP",
|
|
180
|
+
"LocationsList",
|
|
181
|
+
"Location",
|
|
182
|
+
"ServiceAreaPage",
|
|
183
|
+
"DocsList",
|
|
184
|
+
"DocsDetail",
|
|
185
|
+
"LandingPage",
|
|
186
|
+
"UseCase",
|
|
187
|
+
"Feature",
|
|
188
|
+
"PortfolioItem",
|
|
189
|
+
"Pricing",
|
|
190
|
+
"ThankYouPage",
|
|
191
|
+
"ReportPage",
|
|
192
|
+
"PurchasePolicyPage",
|
|
193
|
+
"ComparisonPage",
|
|
194
|
+
"ComparisonsList",
|
|
195
|
+
"ReportsList",
|
|
196
|
+
"TemplatePage",
|
|
197
|
+
"TemplatesList",
|
|
198
|
+
];
|
|
199
|
+
export const SECTION_PAGE_TYPES_MAX = 40;
|
|
200
|
+
export const SECTION_TOKEN_REGEX = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
201
|
+
export const SETTINGS_KEYS = [
|
|
202
|
+
"name",
|
|
203
|
+
"version",
|
|
204
|
+
"description",
|
|
205
|
+
"colors",
|
|
206
|
+
"typography",
|
|
207
|
+
"rounded",
|
|
208
|
+
"spacing",
|
|
209
|
+
"layout",
|
|
210
|
+
"treatments",
|
|
211
|
+
"sections",
|
|
212
|
+
"copy",
|
|
213
|
+
];
|
|
214
|
+
export const SETTINGS_REQUIRED_KEYS = [
|
|
215
|
+
"name",
|
|
216
|
+
"version",
|
|
217
|
+
"description",
|
|
218
|
+
"colors",
|
|
219
|
+
"typography",
|
|
220
|
+
"rounded",
|
|
221
|
+
"spacing",
|
|
222
|
+
"layout",
|
|
223
|
+
];
|
|
224
|
+
export const SETTINGS_VERSION_MAX = 2147483647;
|
|
225
|
+
export const TYPE_SCALE_VALUES = ["platform", "design"];
|
|
226
|
+
export const TYPE_SIZE_REGEX = /^(?:\d+|\d*\.\d+)(?:rem|px|em)$/;
|
|
227
|
+
export const TYPOGRAPHY_ROLES_MAX = 12;
|
|
228
|
+
export const TYPOGRAPHY_ROLE_KEYS = [
|
|
229
|
+
"fontFamily",
|
|
230
|
+
"fontSize",
|
|
231
|
+
"fontWeight",
|
|
232
|
+
"lineHeight",
|
|
233
|
+
"letterSpacing",
|
|
234
|
+
"fontSource",
|
|
235
|
+
"lineHeightMobile",
|
|
236
|
+
"fontSizeMobile",
|
|
237
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { DEFAULT_AILK_MODULE_REGISTRY_URL, FetchModuleError, fetchModule, type F
|
|
|
10
10
|
export { extractModuleBundle, type ExistingFilePolicy, type ExtractModuleBundleOptions, type InstallReportRow, } from "./lib/extract-module-bundle.js";
|
|
11
11
|
export { ADD_MODULE_HELP, AddModuleRefusedError, applyModuleToScaffold, formatAddModuleReport, parseAddModuleArgs, type AddModuleReportRow, type AddModuleResult, type ApplyModuleOptions, } from "./add-module.js";
|
|
12
12
|
export { REMOVABLE_MODULES, REMOVE_MODULE_HELP, RemoveModuleRefusedError, formatRemoveModuleReport, parseRemoveModuleArgs, removeModuleFromScaffold, type RemoveModuleOptions, type RemoveModuleResult, } from "./remove-module.js";
|
|
13
|
-
export { APPLY_DESIGN_HELP,
|
|
13
|
+
export { APPLY_DESIGN_HELP, ApplyDesignRefusedError, applyDesign, formatApplyDesignReport, parseApplyDesignArgs, type ApplyDesignArgs, type ApplyDesignOptions, type ApplyDesignResult, } from "./apply-design.js";
|
|
14
14
|
export type { HomeSeedOutcome } from "./design-home.js";
|
|
15
15
|
export { SITE_ROSTER_PATH, readSiteRoster, siteRosterProblems, } from "./site-roster.js";
|
|
16
16
|
export { SYNC_ROUTES_HELP, formatSyncRoutesReport, listTemplateRouteDirs, parseSyncRoutesArgs, syncRoutes, type RouteReport, type SyncRoutesOptions, type SyncRoutesResult, } from "./sync-routes.js";
|
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ export { ADD_MODULE_HELP, AddModuleRefusedError, applyModuleToScaffold, formatAd
|
|
|
18
18
|
// marketing and docs-blog modules. The pure core, beside add-module's.
|
|
19
19
|
export { REMOVABLE_MODULES, REMOVE_MODULE_HELP, RemoveModuleRefusedError, formatRemoveModuleReport, parseRemoveModuleArgs, removeModuleFromScaffold, } from "./remove-module.js";
|
|
20
20
|
// `create-ailk apply-design` (#6819) — make an existing site wear a design,
|
|
21
|
-
//
|
|
22
|
-
export { APPLY_DESIGN_HELP,
|
|
21
|
+
// by writing its hub design record (#12477). The pure core, beside `add-module`'s.
|
|
22
|
+
export { APPLY_DESIGN_HELP, ApplyDesignRefusedError, applyDesign, formatApplyDesignReport, parseApplyDesignArgs, } from "./apply-design.js";
|
|
23
23
|
// The site's page roster of record and its install-diff check (#6682).
|
|
24
24
|
export { SITE_ROSTER_PATH, readSiteRoster, siteRosterProblems, } from "./site-roster.js";
|
|
25
25
|
// `create-ailk sync-routes` (#4986) — the template-route drift check + copy.
|
package/dist/inventory.d.ts
CHANGED
|
@@ -102,7 +102,8 @@ export interface WorkspaceRow {
|
|
|
102
102
|
export declare function given(value: string | undefined): string | undefined;
|
|
103
103
|
/**
|
|
104
104
|
* The key, workspace and API origin, as `migrate-content` reads them, plus the
|
|
105
|
-
* spoke key on a spoke
|
|
105
|
+
* spoke key on a spoke — where the workspace and origin must be the ones the
|
|
106
|
+
* spoke's env files name. Every miss is refused through `refuse`, before any
|
|
106
107
|
* request.
|
|
107
108
|
*/
|
|
108
109
|
export declare function resolveWorkspaceAccess(targetDir: string, o: {
|
|
@@ -211,6 +212,6 @@ export interface InventoryArgs {
|
|
|
211
212
|
workspaceId: string | undefined;
|
|
212
213
|
help: boolean;
|
|
213
214
|
}
|
|
214
|
-
export declare const INVENTORY_HELP = "create-ailk inventory \u2014 freeze what a site serves today, and audit it against its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk inventory [<dir>] --origin <url> [--refreeze] [--docs-path <path>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --origin <url> The site as served today. Needed to freeze; a\n frozen inventory keeps its own.\n --refreeze Crawl again. The operator's joins and exclusions\n are kept; the inventory's own are recomputed.\n --docs-path <path> Where the site serves its docs. Default /docs.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL.\n --workspace <wksp_id> The workspace. Else AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nThe first run writes .ailk-cutover/inventory.json: every URL the sitemap,\na crawl of the site and the route roster name, each probed with no\nredirect followed. A direct 200 is frozen with its prose status and its\nimages; anything else is listed as not frozen with its status. A later\nrun reads that file and crawls nothing. Commit it.\n\nEvery run writes .ailk-cutover/audit.json: each frozen page joined to its\nworkspace page \u2014 by the inventory's \"joins\", then the roster, then /blog and\nthe docs path \u2014 and whether it is published and whether its words are in\nits Markdown. The agent key needs the content-edit grant; on a spoke,\nAILK_SPOKE_KEY is needed too. Exit 0 when every prose page
|
|
215
|
+
export declare const INVENTORY_HELP = "create-ailk inventory \u2014 freeze what a site serves today, and audit it against its workspace.\n\nUsage:\n AILK_AGENT_KEY=<key> create-ailk inventory [<dir>] --origin <url> [--refreeze] [--docs-path <path>] [--api-url <origin>] [--workspace <wksp_id>]\n\nArguments:\n <dir> The site. Defaults to the current dir.\n\nOptions:\n --origin <url> The site as served today. Needed to freeze; a\n frozen inventory keeps its own.\n --refreeze Crawl again. The operator's joins and exclusions\n are kept; the inventory's own are recomputed.\n --docs-path <path> Where the site serves its docs. Default /docs.\n --api-url <origin> The API origin that holds the workspace \u2014 on a\n spoke, its hub's. Else AILK_API_URL.\n --workspace <wksp_id> The workspace. Else AILK_WORKSPACE_ID.\n -h, --help Show this help.\n\nThe first run writes .ailk-cutover/inventory.json: every URL the sitemap,\na crawl of the site and the route roster name, each probed with no\nredirect followed. A direct 200 is frozen with its prose status and its\nimages; anything else is listed as not frozen with its status. A later\nrun reads that file and crawls nothing. Commit it.\n\nEvery run writes .ailk-cutover/audit.json: each frozen page joined to its\nworkspace page \u2014 by the inventory's \"joins\", then the roster, then /blog and\nthe docs path \u2014 and whether it is published and whether its words are in\nits Markdown. The agent key needs the content-edit grant; on a spoke,\nAILK_SPOKE_KEY is needed too, and the workspace and API origin must be the\nones its apps/web/.env or .env.local names. Exit 0 when every prose page\npasses, 1 when any does not (one line each), 2 on a refusal.\n";
|
|
215
216
|
export declare function parseInventoryArgs(argv: string[]): InventoryArgs;
|
|
216
217
|
export {};
|
package/dist/inventory.js
CHANGED
|
@@ -35,7 +35,7 @@ import { sitemapLocPaths } from "./lib/scaffold-render-sweep.js";
|
|
|
35
35
|
import { ParseError } from "./parse-args.js";
|
|
36
36
|
import { AGENT_KEY_ENV_VAR, WORKSPACE_ID_ENV_VAR } from "./seed-workspace.js";
|
|
37
37
|
import { readSiteRoster } from "./site-roster.js";
|
|
38
|
-
import { HUB_ORIGIN_ENV_VAR, TopologyError, normalizeHubUrl, readSiteTopology, } from "./topology.js";
|
|
38
|
+
import { HUB_ORIGIN_ENV_VAR, TopologyError, normalizeHubUrl, readSiteTopology, spokeOriginMismatch, spokeWorkspaceMismatch, } from "./topology.js";
|
|
39
39
|
/** The kit's directory in the site: committed, unlike `.ailk/`. */
|
|
40
40
|
export const CUTOVER_DIR = ".ailk-cutover";
|
|
41
41
|
export const INVENTORY_FILE = "inventory.json";
|
|
@@ -77,7 +77,8 @@ const KEY_SHAPE = /^[\x21-\x7e]+$/;
|
|
|
77
77
|
const WORKSPACE_ID = /^wksp_[0-9a-f-]{36}$/;
|
|
78
78
|
/**
|
|
79
79
|
* The key, workspace and API origin, as `migrate-content` reads them, plus the
|
|
80
|
-
* spoke key on a spoke
|
|
80
|
+
* spoke key on a spoke — where the workspace and origin must be the ones the
|
|
81
|
+
* spoke's env files name. Every miss is refused through `refuse`, before any
|
|
81
82
|
* request.
|
|
82
83
|
*/
|
|
83
84
|
export function resolveWorkspaceAccess(targetDir, o, refuse) {
|
|
@@ -113,6 +114,10 @@ export function resolveWorkspaceAccess(targetDir, o, refuse) {
|
|
|
113
114
|
}
|
|
114
115
|
if (topology !== "spoke")
|
|
115
116
|
return { origin, workspaceId, apiKey };
|
|
117
|
+
// A spoke reaches only the workspace and hub its own env files name (#12477).
|
|
118
|
+
const mismatch = spokeWorkspaceMismatch(targetDir, workspaceId) ?? spokeOriginMismatch(targetDir, origin);
|
|
119
|
+
if (mismatch !== undefined)
|
|
120
|
+
refuse(`${mismatch}.`);
|
|
116
121
|
const spokeKey = given(o.env[SPOKE_KEY_ENV_VAR]);
|
|
117
122
|
if (spokeKey === undefined || !KEY_SHAPE.test(spokeKey)) {
|
|
118
123
|
refuse(`this site is a spoke: set ${SPOKE_KEY_ENV_VAR} so the hub's public read answers its workspace.`);
|
|
@@ -794,8 +799,9 @@ Every run writes ${CUTOVER_DIR}/${AUDIT_FILE}: each frozen page joined to its
|
|
|
794
799
|
workspace page — by the inventory's "joins", then the roster, then /blog and
|
|
795
800
|
the docs path — and whether it is published and whether its words are in
|
|
796
801
|
its Markdown. The agent key needs the content-edit grant; on a spoke,
|
|
797
|
-
AILK_SPOKE_KEY is needed too
|
|
798
|
-
|
|
802
|
+
AILK_SPOKE_KEY is needed too, and the workspace and API origin must be the
|
|
803
|
+
ones its apps/web/.env or .env.local names. Exit 0 when every prose page
|
|
804
|
+
passes, 1 when any does not (one line each), 2 on a refusal.
|
|
799
805
|
`;
|
|
800
806
|
export function parseInventoryArgs(argv) {
|
|
801
807
|
let parsed;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { CompiledDesignTheme } from "../design-compile.js";
|
|
2
|
+
import { type LookRecord } from "../look-record.js";
|
|
3
|
+
import { type TemplateLayout } from "../site-chrome.js";
|
|
1
4
|
/** One row of theme's contrast audit, as the audit script prints it. */
|
|
2
5
|
export interface ContrastRow {
|
|
3
6
|
name: string;
|
|
@@ -85,6 +88,12 @@ export interface MeasureApplyDesignDriftOptions {
|
|
|
85
88
|
* gates a non-Free design on.
|
|
86
89
|
*/
|
|
87
90
|
licenseKey?: string;
|
|
91
|
+
/**
|
|
92
|
+
* #12477 D8 — the hub `apply-design` writes the record to: the fixture
|
|
93
|
+
* hub's `AILK_API_URL`, `AILK_WORKSPACE_ID` and `AILK_AGENT_KEY`, passed to
|
|
94
|
+
* its child only.
|
|
95
|
+
*/
|
|
96
|
+
env?: NodeJS.ProcessEnv;
|
|
88
97
|
}
|
|
89
98
|
/**
|
|
90
99
|
* Scaffold an `organization-product` site on `standard` — keyed when
|
|
@@ -97,3 +106,40 @@ export declare function measureApplyDesignDrift(opts: MeasureApplyDesignDriftOpt
|
|
|
97
106
|
after: ComposedPages;
|
|
98
107
|
applyStdout: string;
|
|
99
108
|
};
|
|
109
|
+
export type ScaffoldLookVerdict = {
|
|
110
|
+
ok: true;
|
|
111
|
+
record: LookRecord;
|
|
112
|
+
} | {
|
|
113
|
+
ok: false;
|
|
114
|
+
reason: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A scaffold's look: it holds none of `apps/web/lib/site-chrome.ts`,
|
|
118
|
+
* `apps/web/lib/site-fonts.ts` or a `theme:` key in `content/_site.mdx`, and
|
|
119
|
+
* the record its seed writes (`lookRecordFor(readLookInputs(…))`) names
|
|
120
|
+
* `design`, its `changes.layout` exactly `layoutChanges(starterLayout,
|
|
121
|
+
* designLayout)` (no `changes` when that is empty) — or, for a `design` that
|
|
122
|
+
* is no shipped look, is a look of its own whose layout is the starter's over
|
|
123
|
+
* the look's.
|
|
124
|
+
*/
|
|
125
|
+
export declare function assessScaffoldLook(siteDir: string, opts: {
|
|
126
|
+
design: string;
|
|
127
|
+
starterLayout: TemplateLayout | undefined;
|
|
128
|
+
designLayout: TemplateLayout;
|
|
129
|
+
designsDir: string;
|
|
130
|
+
}): ScaffoldLookVerdict;
|
|
131
|
+
export type RenderedLookVerdict = {
|
|
132
|
+
ok: true;
|
|
133
|
+
} | {
|
|
134
|
+
ok: false;
|
|
135
|
+
reason: string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* A rendered page wears `theme`'s look from its record: it carries
|
|
139
|
+
* `<meta name="ailk-design-source" content="record">` (the layout's stamp of
|
|
140
|
+
* a record it rendered, #12476 D7) and its `<style data-ailk="theme-vars">`
|
|
141
|
+
* text carries the theme's compiled light `bg`. The colour alone cannot tell
|
|
142
|
+
* a look whose `bg` is the theme's own default (`standard`'s white) from the
|
|
143
|
+
* base look, so the stamp is checked too.
|
|
144
|
+
*/
|
|
145
|
+
export declare function assessRenderedLook(html: string, theme: CompiledDesignTheme): RenderedLookVerdict;
|
|
@@ -23,11 +23,22 @@
|
|
|
23
23
|
* when the seeded home is exactly that, so any other change still counts.
|
|
24
24
|
* Likewise a design that seeds the contact page renames and re-describes it
|
|
25
25
|
* (#8661 D11); `admitSeededContactPage` admits only those two fields.
|
|
26
|
+
*
|
|
27
|
+
* LOOK (#12477 D8) — a scaffold carries no look file, and its look is the
|
|
28
|
+
* record its seed writes: `assessScaffoldLook` checks a scaffold holds none of
|
|
29
|
+
* the three retired sources and that the record built from it names the
|
|
30
|
+
* leg's design with exactly the starter's layout changes, and
|
|
31
|
+
* `assessRenderedLook` checks a rendered page wears that look rather than the
|
|
32
|
+
* base look — which carries no design overlay.
|
|
26
33
|
*/
|
|
27
34
|
import { execFileSync } from "node:child_process";
|
|
28
35
|
import { join } from "node:path";
|
|
29
36
|
import { isDeepStrictEqual } from "node:util";
|
|
30
37
|
import { CONTACT_PAGE_PATH } from "../design-home.js";
|
|
38
|
+
import { shippedDesigns } from "../design-names.js";
|
|
39
|
+
import { retiredLookSources } from "../look-hub.js";
|
|
40
|
+
import { layoutChanges, lookRecordFor, readLookInputs } from "../look-record.js";
|
|
41
|
+
import { resolveSiteChrome } from "../site-chrome.js";
|
|
31
42
|
import { TEAM_SEED_MEMBERS } from "../team-profiles.js";
|
|
32
43
|
function describePair(row) {
|
|
33
44
|
const measured = row.status === "unmeasurable" || row.ratio === null
|
|
@@ -233,7 +244,74 @@ export function measureApplyDesignDrift(opts) {
|
|
|
233
244
|
...(opts.licenseKey === undefined ? [] : ["--license", opts.licenseKey]),
|
|
234
245
|
], registryEnv);
|
|
235
246
|
const before = compose("compose JSON-LD before apply-design");
|
|
236
|
-
const applyStdout = exec(`apply-design ${opts.design}`, process.execPath, [opts.cliPath, "apply-design", opts.design, "--target", site],
|
|
247
|
+
const applyStdout = exec(`apply-design ${opts.design}`, process.execPath, [opts.cliPath, "apply-design", opts.design, "--target", site], {
|
|
248
|
+
...(opts.registryUrl === undefined ? {} : { AILK_MODULE_REGISTRY_URL: opts.registryUrl }),
|
|
249
|
+
...opts.env,
|
|
250
|
+
});
|
|
237
251
|
const after = compose("compose JSON-LD after apply-design");
|
|
238
252
|
return { before, after, applyStdout };
|
|
239
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* A scaffold's look: it holds none of `apps/web/lib/site-chrome.ts`,
|
|
256
|
+
* `apps/web/lib/site-fonts.ts` or a `theme:` key in `content/_site.mdx`, and
|
|
257
|
+
* the record its seed writes (`lookRecordFor(readLookInputs(…))`) names
|
|
258
|
+
* `design`, its `changes.layout` exactly `layoutChanges(starterLayout,
|
|
259
|
+
* designLayout)` (no `changes` when that is empty) — or, for a `design` that
|
|
260
|
+
* is no shipped look, is a look of its own whose layout is the starter's over
|
|
261
|
+
* the look's.
|
|
262
|
+
*/
|
|
263
|
+
export function assessScaffoldLook(siteDir, opts) {
|
|
264
|
+
const carried = retiredLookSources(siteDir);
|
|
265
|
+
if (carried.length > 0) {
|
|
266
|
+
return { ok: false, reason: `the scaffold still carries retired look sources: ${carried.join(", ")}` };
|
|
267
|
+
}
|
|
268
|
+
const inputs = readLookInputs(siteDir, opts.designsDir);
|
|
269
|
+
if (inputs === undefined)
|
|
270
|
+
return { ok: false, reason: "the scaffold records no design, so no look record is written" };
|
|
271
|
+
const record = lookRecordFor(inputs);
|
|
272
|
+
// A look of the site's own (an admission candidate's directory): its whole
|
|
273
|
+
// settings, the starter's layout over the look's.
|
|
274
|
+
if (record.from === null) {
|
|
275
|
+
if (shippedDesigns().includes(opts.design)) {
|
|
276
|
+
return { ok: false, reason: `the look record names a look of its own, not the library look ${opts.design}` };
|
|
277
|
+
}
|
|
278
|
+
const layout = record.settings?.["layout"];
|
|
279
|
+
const expected = resolveSiteChrome(opts.starterLayout, opts.designLayout);
|
|
280
|
+
return isDeepStrictEqual(layout, expected)
|
|
281
|
+
? { ok: true, record }
|
|
282
|
+
: { ok: false, reason: `the look record's layout is ${JSON.stringify(layout)}, not ${JSON.stringify(expected)}` };
|
|
283
|
+
}
|
|
284
|
+
if (record.from.look !== opts.design) {
|
|
285
|
+
return { ok: false, reason: `the look record names ${JSON.stringify(record.from.look)}, not ${opts.design}` };
|
|
286
|
+
}
|
|
287
|
+
const expected = layoutChanges(opts.starterLayout, opts.designLayout);
|
|
288
|
+
const actual = record.changes?.layout ?? {};
|
|
289
|
+
if (!isDeepStrictEqual(actual, expected)) {
|
|
290
|
+
return {
|
|
291
|
+
ok: false,
|
|
292
|
+
reason: `the look record's layout changes are ${JSON.stringify(actual)}, not the starter's ${JSON.stringify(expected)}`,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
return { ok: true, record };
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* A rendered page wears `theme`'s look from its record: it carries
|
|
299
|
+
* `<meta name="ailk-design-source" content="record">` (the layout's stamp of
|
|
300
|
+
* a record it rendered, #12476 D7) and its `<style data-ailk="theme-vars">`
|
|
301
|
+
* text carries the theme's compiled light `bg`. The colour alone cannot tell
|
|
302
|
+
* a look whose `bg` is the theme's own default (`standard`'s white) from the
|
|
303
|
+
* base look, so the stamp is checked too.
|
|
304
|
+
*/
|
|
305
|
+
export function assessRenderedLook(html, theme) {
|
|
306
|
+
const source = /<meta[^>]*name="ailk-design-source"[^>]*>/.exec(html)?.[0];
|
|
307
|
+
if (source === undefined || !/content="record"/.test(source)) {
|
|
308
|
+
return { ok: false, reason: "the page does not render its look from a design record (ailk-design-source is not record) — it renders the base look" };
|
|
309
|
+
}
|
|
310
|
+
const vars = /<style[^>]*data-ailk="theme-vars"[^>]*>([\s\S]*?)<\/style>/.exec(html);
|
|
311
|
+
if (vars === null)
|
|
312
|
+
return { ok: false, reason: 'the page has no <style data-ailk="theme-vars">' };
|
|
313
|
+
const bg = theme.colors.light.bg;
|
|
314
|
+
return vars[1].toLowerCase().includes(bg.toLowerCase())
|
|
315
|
+
? { ok: true }
|
|
316
|
+
: { ok: false, reason: `the page's theme-vars do not carry the look's light bg ${bg} — it renders another look than its record's` };
|
|
317
|
+
}
|
package/dist/lib/env-catalog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const ENV_CATALOG = {
|
|
2
2
|
AILK_ADMIN_URL: {
|
|
3
|
-
description: "
|
|
3
|
+
description: "Required when the Admin is not at admin.<this site's host>: the hub Admin's absolute https URL, where team invitations are accepted. Unset uses admin.<this site's host>.",
|
|
4
4
|
secret: false,
|
|
5
5
|
},
|
|
6
6
|
AILK_API_URL: {
|
|
@@ -57,7 +57,7 @@ export declare function assertReleased(axis: ReleaseAxis, names: readonly (strin
|
|
|
57
57
|
export declare function assertKeyedOrFreeReleased(licenseKey?: string | undefined): void;
|
|
58
58
|
/**
|
|
59
59
|
* Design names every level renders (#6760 D1). Anything else in
|
|
60
|
-
* `
|
|
60
|
+
* `shippedDesigns()` is Pro and up. A path design's Free-ness is decided by
|
|
61
61
|
* `resolveDesign`'s identity rule (#6813 D2), never by this list directly —
|
|
62
62
|
* `assertDesignAllowed`'s `free` parameter carries that verdict in.
|
|
63
63
|
*/
|
|
@@ -136,7 +136,7 @@ export function assertKeyedOrFreeReleased(licenseKey = process.env["AILK_LICENSE
|
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Design names every level renders (#6760 D1). Anything else in
|
|
139
|
-
* `
|
|
139
|
+
* `shippedDesigns()` is Pro and up. A path design's Free-ness is decided by
|
|
140
140
|
* `resolveDesign`'s identity rule (#6813 D2), never by this list directly —
|
|
141
141
|
* `assertDesignAllowed`'s `free` parameter carries that verdict in.
|
|
142
142
|
*/
|
|
@@ -48,5 +48,17 @@ export declare const RENDER_TIMEOUT_MS = 60000;
|
|
|
48
48
|
* requested URL, never a side `fetch` — so a redirect cannot pass as a render.
|
|
49
49
|
* A failed navigation takes no screenshot; a screenshot that throws counts
|
|
50
50
|
* as no PNG written — never a stale one left at `pngPath` by an earlier run.
|
|
51
|
+
*
|
|
52
|
+
* #12472 D5 — `settle`, when given, runs between the load and the screenshot
|
|
53
|
+
* (the design leg scrolls the page so its lazy pictures load). A settle that
|
|
54
|
+
* throws leaves the page as it loaded; the leg's own record names any
|
|
55
|
+
* picture that did not draw.
|
|
51
56
|
*/
|
|
52
|
-
export declare function renderRoute(page:
|
|
57
|
+
export declare function renderRoute<P extends RenderPage>(page: P, base: string, route: string, pngPath: string, settle?: (page: P) => Promise<void>): Promise<RenderVerdict>;
|
|
58
|
+
/**
|
|
59
|
+
* #12472 D5 — the sample file an image source names, for look `look`: the
|
|
60
|
+
* file name when `src` — or the `url` parameter of a `/_next/image` address,
|
|
61
|
+
* decoded — is `/look/<look>/<file>`; else undefined. `src` may be absolute
|
|
62
|
+
* (an `img`'s `currentSrc`) or a site path; only its path is read.
|
|
63
|
+
*/
|
|
64
|
+
export declare function lookSampleFile(src: string, look: string): string | undefined;
|
|
@@ -49,8 +49,13 @@ export const RENDER_TIMEOUT_MS = 60_000;
|
|
|
49
49
|
* requested URL, never a side `fetch` — so a redirect cannot pass as a render.
|
|
50
50
|
* A failed navigation takes no screenshot; a screenshot that throws counts
|
|
51
51
|
* as no PNG written — never a stale one left at `pngPath` by an earlier run.
|
|
52
|
+
*
|
|
53
|
+
* #12472 D5 — `settle`, when given, runs between the load and the screenshot
|
|
54
|
+
* (the design leg scrolls the page so its lazy pictures load). A settle that
|
|
55
|
+
* throws leaves the page as it loaded; the leg's own record names any
|
|
56
|
+
* picture that did not draw.
|
|
52
57
|
*/
|
|
53
|
-
export async function renderRoute(page, base, route, pngPath) {
|
|
58
|
+
export async function renderRoute(page, base, route, pngPath, settle) {
|
|
54
59
|
let status;
|
|
55
60
|
try {
|
|
56
61
|
const response = await page.goto(base + route, { waitUntil: "load", timeout: RENDER_TIMEOUT_MS });
|
|
@@ -65,6 +70,14 @@ export async function renderRoute(page, base, route, pngPath) {
|
|
|
65
70
|
pngBytes: undefined,
|
|
66
71
|
});
|
|
67
72
|
}
|
|
73
|
+
if (settle !== undefined) {
|
|
74
|
+
try {
|
|
75
|
+
await settle(page);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Falls through to the screenshot: the page as it loaded.
|
|
79
|
+
}
|
|
80
|
+
}
|
|
68
81
|
rmSync(pngPath, { force: true });
|
|
69
82
|
try {
|
|
70
83
|
await page.screenshot({ path: pngPath, fullPage: true });
|
|
@@ -75,3 +88,30 @@ export async function renderRoute(page, base, route, pngPath) {
|
|
|
75
88
|
const pngBytes = existsSync(pngPath) ? statSync(pngPath).size : undefined;
|
|
76
89
|
return assessRender({ route, status, finalUrl: page.url(), pngBytes });
|
|
77
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* #12472 D5 — the sample file an image source names, for look `look`: the
|
|
93
|
+
* file name when `src` — or the `url` parameter of a `/_next/image` address,
|
|
94
|
+
* decoded — is `/look/<look>/<file>`; else undefined. `src` may be absolute
|
|
95
|
+
* (an `img`'s `currentSrc`) or a site path; only its path is read.
|
|
96
|
+
*/
|
|
97
|
+
export function lookSampleFile(src, look) {
|
|
98
|
+
let url;
|
|
99
|
+
try {
|
|
100
|
+
url = new URL(src, "http://localhost");
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
let path = url.pathname;
|
|
106
|
+
if (path === "/_next/image") {
|
|
107
|
+
const inner = url.searchParams.get("url");
|
|
108
|
+
if (inner === null || !inner.startsWith("/"))
|
|
109
|
+
return undefined;
|
|
110
|
+
path = new URL(inner, "http://localhost").pathname;
|
|
111
|
+
}
|
|
112
|
+
const prefix = `/look/${look}/`;
|
|
113
|
+
if (!path.startsWith(prefix))
|
|
114
|
+
return undefined;
|
|
115
|
+
const file = path.slice(prefix.length);
|
|
116
|
+
return /^[a-z0-9-]+\.(?:jpg|png)$/.test(file) ? file : undefined;
|
|
117
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** `value` when it matches `re`, else `<unexpected>`. */
|
|
2
|
+
export declare function printable(value: unknown, re: RegExp): string;
|
|
3
|
+
/** One hub answer: its status, its `data` on a 200 `{ ok: true }` body, and a printable code and path on an error body. */
|
|
4
|
+
export interface HubAnswer {
|
|
5
|
+
/** The HTTP status; 0 when the request could not be sent. */
|
|
6
|
+
status: number;
|
|
7
|
+
/** A 200 answer carrying the `{ ok: true, data }` envelope. */
|
|
8
|
+
ok: boolean;
|
|
9
|
+
/** The envelope's `data`, as sent; `undefined` unless `ok`. */
|
|
10
|
+
data: unknown;
|
|
11
|
+
code: string | undefined;
|
|
12
|
+
path: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One request to `url` with the agent key, `redirect: "manual"`. Never
|
|
16
|
+
* throws for a network failure (status 0) or a body that is not JSON.
|
|
17
|
+
*/
|
|
18
|
+
export declare function hubRequest(fetchImpl: typeof globalThis.fetch, url: string, apiKey: string, init?: {
|
|
19
|
+
method: "GET";
|
|
20
|
+
} | {
|
|
21
|
+
method: "PUT";
|
|
22
|
+
body: unknown;
|
|
23
|
+
}): Promise<HubAnswer>;
|
|
24
|
+
/** What a failed answer prints: `400 <code> at <path>`, `<status> <code>`, or the status alone ("not sent" for no answer). */
|
|
25
|
+
export declare function describeAnswer(answer: HubAnswer): string;
|
|
26
|
+
/** The member design route for `workspaceId` at `origin`. */
|
|
27
|
+
export declare function designUrl(origin: string, workspaceId: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* A design or navigation answer's `version`: an integer, `null` (none
|
|
30
|
+
* stored), or `undefined` (neither — not such an answer, or not `ok`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function storedVersion(answer: HubAnswer): number | null | undefined;
|
|
33
|
+
/** The site's `_site.mdx`, where a `theme:` block once held its colours. */
|
|
34
|
+
export declare const SITE_MDX_PATH = "content/_site.mdx";
|
|
35
|
+
/** `text` holds a frontmatter `theme:` key, in any form. */
|
|
36
|
+
export declare function carriesThemeKey(text: string): boolean;
|
|
37
|
+
/** `text`'s `theme:` key is the block `removeThemeBlock` removes. */
|
|
38
|
+
export declare function themeBlockRemovable(text: string, file: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The retired look sources `siteDir` still carries (#12477): `site-chrome.ts`,
|
|
41
|
+
* `site-fonts.ts` and a `theme:` key in `content/_site.mdx`, as site-relative
|
|
42
|
+
* paths. Empty for a site on its hub record.
|
|
43
|
+
*/
|
|
44
|
+
export declare function retiredLookSources(siteDir: string): string[];
|