@aglyn/aglyn 1.2.0 → 1.3.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.
Files changed (28) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
  3. package/src/lib/app-utils/docs-help.generated.js +2 -0
  4. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  5. package/src/lib/app-utils/docs-index.generated.js +31 -10
  6. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  7. package/src/lib/app-utils/lockdown.js +4 -1
  8. package/src/lib/app-utils/lockdown.js.map +1 -1
  9. package/src/lib/app-utils/plan-entitlements.d.ts +5 -0
  10. package/src/lib/app-utils/plan-entitlements.js +6 -0
  11. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  12. package/src/lib/app-utils/plugin-sale.d.ts +36 -0
  13. package/src/lib/app-utils/plugin-sale.js +37 -0
  14. package/src/lib/app-utils/plugin-sale.js.map +1 -0
  15. package/src/lib/app-utils/site-starter-pick.d.ts +11 -0
  16. package/src/lib/app-utils/site-starter-pick.js +17 -1
  17. package/src/lib/app-utils/site-starter-pick.js.map +1 -1
  18. package/src/lib/app-utils/site-starter-theme.d.ts +28 -1
  19. package/src/lib/app-utils/site-starter-theme.js +78 -4
  20. package/src/lib/app-utils/site-starter-theme.js.map +1 -1
  21. package/src/lib/app-utils/site-styles.d.ts +11 -0
  22. package/src/lib/app-utils/site-styles.js +11 -0
  23. package/src/lib/app-utils/site-styles.js.map +1 -1
  24. package/src/lib/app-utils/site-unavailable.d.ts +22 -2
  25. package/src/lib/app-utils/site-unavailable.js +19 -3
  26. package/src/lib/app-utils/site-unavailable.js.map +1 -1
  27. package/src/lib/plugin-manager/feature-plugins.d.ts +6 -1
  28. package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * THE CHARGE IS NOT THE PLATFORM'S OWN REVENUE (AGL-4049).
19
+ *
20
+ * A plugin can raise an invoice on a workspace's own billing customer for a
21
+ * sale that is not one of Aglyn's own charges: the card on file pays for it,
22
+ * and the plugin records it in its own ledger, with its own tax row.
23
+ *
24
+ * Everything the platform webhook does for an invoice on a workspace's
25
+ * customer assumes the opposite. It would book the whole sale as Aglyn's
26
+ * revenue beside the plugin's ledger, so the same tax would be filed twice, and
27
+ * it would warn a workspace about a failed attempt the buyer is looking at.
28
+ * This marker is how the plugin says "mine": one metadata field on the invoice
29
+ * and on its PaymentIntent, which Stripe copies onto the charge, so the refund
30
+ * event carries it too. Core names no plugin to read it.
31
+ */
32
+ export declare const PLUGIN_SALE_METADATA_KEY = "pluginSale";
33
+ /** The metadata value that marks a plugin's sale. */
34
+ export declare const PLUGIN_SALE_METADATA_VALUE = "true";
35
+ /** Whether a Stripe object (an invoice, a charge) carries the marker. */
36
+ export declare function isPluginSale(stripeObject: unknown): boolean;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * THE CHARGE IS NOT THE PLATFORM'S OWN REVENUE (AGL-4049).
18
+ *
19
+ * A plugin can raise an invoice on a workspace's own billing customer for a
20
+ * sale that is not one of Aglyn's own charges: the card on file pays for it,
21
+ * and the plugin records it in its own ledger, with its own tax row.
22
+ *
23
+ * Everything the platform webhook does for an invoice on a workspace's
24
+ * customer assumes the opposite. It would book the whole sale as Aglyn's
25
+ * revenue beside the plugin's ledger, so the same tax would be filed twice, and
26
+ * it would warn a workspace about a failed attempt the buyer is looking at.
27
+ * This marker is how the plugin says "mine": one metadata field on the invoice
28
+ * and on its PaymentIntent, which Stripe copies onto the charge, so the refund
29
+ * event carries it too. Core names no plugin to read it.
30
+ */ export const PLUGIN_SALE_METADATA_KEY = 'pluginSale';
31
+ /** The metadata value that marks a plugin's sale. */ export const PLUGIN_SALE_METADATA_VALUE = 'true';
32
+ /** Whether a Stripe object (an invoice, a charge) carries the marker. */ export function isPluginSale(stripeObject) {
33
+ const metadata = stripeObject == null ? void 0 : stripeObject.metadata;
34
+ return (metadata == null ? void 0 : metadata[PLUGIN_SALE_METADATA_KEY]) === PLUGIN_SALE_METADATA_VALUE;
35
+ }
36
+
37
+ //# sourceMappingURL=plugin-sale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-sale.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * THE CHARGE IS NOT THE PLATFORM'S OWN REVENUE (AGL-4049).\n *\n * A plugin can raise an invoice on a workspace's own billing customer for a\n * sale that is not one of Aglyn's own charges: the card on file pays for it,\n * and the plugin records it in its own ledger, with its own tax row.\n *\n * Everything the platform webhook does for an invoice on a workspace's\n * customer assumes the opposite. It would book the whole sale as Aglyn's\n * revenue beside the plugin's ledger, so the same tax would be filed twice, and\n * it would warn a workspace about a failed attempt the buyer is looking at.\n * This marker is how the plugin says \"mine\": one metadata field on the invoice\n * and on its PaymentIntent, which Stripe copies onto the charge, so the refund\n * event carries it too. Core names no plugin to read it.\n */\nexport const PLUGIN_SALE_METADATA_KEY = 'pluginSale'\n\n/** The metadata value that marks a plugin's sale. */\nexport const PLUGIN_SALE_METADATA_VALUE = 'true'\n\n/** Whether a Stripe object (an invoice, a charge) carries the marker. */\nexport function isPluginSale(stripeObject: unknown): boolean {\n const metadata = (stripeObject as { metadata?: Record<string, unknown> } | null | undefined)\n ?.metadata\n return metadata?.[PLUGIN_SALE_METADATA_KEY] === PLUGIN_SALE_METADATA_VALUE\n}\n"],"names":["PLUGIN_SALE_METADATA_KEY","PLUGIN_SALE_METADATA_VALUE","isPluginSale","stripeObject","metadata"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMA,2BAA2B,aAAY;AAEpD,mDAAmD,GACnD,OAAO,MAAMC,6BAA6B,OAAM;AAEhD,uEAAuE,GACvE,OAAO,SAASC,aAAaC,YAAqB;IAChD,MAAMC,WAAYD,gCAAD,AAACA,aACdC,QAAQ;IACZ,OAAOA,CAAAA,4BAAAA,QAAU,CAACJ,yBAAyB,MAAKC;AAClD"}
@@ -21,6 +21,17 @@ import type { SiteStarterSummary } from '../plugin-manager/plugin-site-starters'
21
21
  * create's refusal of it asks for. Pure, so every surface that offers the
22
22
  * picker — the console, the native apps — decides the same way.
23
23
  */
24
+ /** The heading's words, for the starters or for the styles drawn in their place. */
25
+ export declare const CHOOSE_STARTER_COPY: {
26
+ readonly starters: {
27
+ readonly title: "Choose your starter";
28
+ readonly lede: string;
29
+ };
30
+ readonly styles: {
31
+ readonly title: "Choose a style";
32
+ readonly lede: string;
33
+ };
34
+ };
24
35
  /**
25
36
  * What stands between a pick and Create site: nothing picked (`none`), or a
26
37
  * price the workspace has not paid (`purchase`); `null` when the site can be
@@ -13,7 +13,23 @@
13
13
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
- */ export function siteStarterPickBlock(pick, owned) {
16
+ */ import { PLATFORM_BRAND_NAME } from "./platform-brand.js";
17
+ /**
18
+ * A starter picked in "Choose your starter" (AGL-4049), as Create site
19
+ * decides about it: whether a site can be created from it yet, and what the
20
+ * create's refusal of it asks for. Pure, so every surface that offers the
21
+ * picker — the console, the native apps — decides the same way.
22
+ */ /** The heading's words, for the starters or for the styles drawn in their place. */ export const CHOOSE_STARTER_COPY = {
23
+ starters: {
24
+ title: 'Choose your starter',
25
+ lede: `${PLATFORM_BRAND_NAME}'s styles come first, then starters from the marketplace. ` + 'Nothing is chosen for you, and you can change everything later.'
26
+ },
27
+ styles: {
28
+ title: 'Choose a style',
29
+ lede: 'Your site starts with a home page, a header and a footer in the style you choose. ' + 'You can change everything later.'
30
+ }
31
+ };
32
+ export function siteStarterPickBlock(pick, owned) {
17
33
  if (!pick) return 'none';
18
34
  if (pick.priceUsd > 0 && !(owned != null ? owned : pick.owned === true)) return 'purchase';
19
35
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-starter-pick.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SiteStarterSummary } from '../plugin-manager/plugin-site-starters'\n\n/**\n * A starter picked in \"Choose your starter\" (AGL-4049), as Create site\n * decides about it: whether a site can be created from it yet, and what the\n * create's refusal of it asks for. Pure, so every surface that offers the\n * picker — the console, the native apps — decides the same way.\n */\n\n/**\n * What stands between a pick and Create site: nothing picked (`none`), or a\n * price the workspace has not paid (`purchase`); `null` when the site can be\n * created from it. `owned` is what the surface knows better than the\n * search's own answer (the person just paid, or the create still asked for\n * payment); absent, the summary's `owned` stands.\n */\nexport type SiteStarterPickBlock = 'none' | 'purchase'\n\nexport function siteStarterPickBlock(\n pick: SiteStarterSummary | null | undefined,\n owned?: boolean,\n): SiteStarterPickBlock | null {\n if (!pick) return 'none'\n if (pick.priceUsd > 0 && !(owned ?? pick.owned === true)) return 'purchase'\n return null\n}\n\n/** What Create site does with a create that refused the starter it was asked for. */\nexport interface SiteStarterPickRefused {\n /** The pick stays: it can still be created from, once bought. */\n keep: boolean\n /** It is the price that stands in the way, so buying it is offered. */\n purchase: boolean\n /** The create's own words for why. */\n message: string\n}\n\n/**\n * The create's refusal of THIS pick, or `null` for a refusal about anything\n * else (the name, the address, the plan's site count), which Create site\n * answers as it always has. A refusal of a pick names its listing: a 402 is\n * a price to pay, and the pick stays with \"Buy and continue\"; anything else\n * (the release not open to the workspace, a starter that is gone, one with\n * more pages than the plan holds, an AI starter where the AI start is not\n * offered) clears the pick, with the reason said.\n */\nexport function readSiteStarterPickRefusal(\n status: number,\n payload: unknown,\n listingId: string,\n): SiteStarterPickRefused | null {\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return null\n const body = payload as Record<string, unknown>\n if (!listingId || body['listingId'] !== listingId) return null\n const error = body['error']\n const message = typeof error === 'string' && error.trim() ? error.trim() : 'That starter cannot be used.'\n if (status === 402) return { keep: true, purchase: true, message }\n return { keep: false, purchase: false, message }\n}\n"],"names":["siteStarterPickBlock","pick","owned","priceUsd","readSiteStarterPickRefusal","status","payload","listingId","Array","isArray","body","error","message","trim","keep","purchase"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAoBD,OAAO,SAASA,qBACdC,IAA2C,EAC3CC,KAAe;IAEf,IAAI,CAACD,MAAM,OAAO;IAClB,IAAIA,KAAKE,QAAQ,GAAG,KAAK,EAAED,gBAAAA,QAASD,KAAKC,KAAK,KAAK,OAAO,OAAO;IACjE,OAAO;AACT;AAYA;;;;;;;;CAQC,GACD,OAAO,SAASE,2BACdC,MAAc,EACdC,OAAgB,EAChBC,SAAiB;IAEjB,IAAI,CAACD,WAAW,OAAOA,YAAY,YAAYE,MAAMC,OAAO,CAACH,UAAU,OAAO;IAC9E,MAAMI,OAAOJ;IACb,IAAI,CAACC,aAAaG,IAAI,CAAC,YAAY,KAAKH,WAAW,OAAO;IAC1D,MAAMI,QAAQD,IAAI,CAAC,QAAQ;IAC3B,MAAME,UAAU,OAAOD,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAK;IAC3E,IAAIR,WAAW,KAAK,OAAO;QAAES,MAAM;QAAMC,UAAU;QAAMH;IAAQ;IACjE,OAAO;QAAEE,MAAM;QAAOC,UAAU;QAAOH;IAAQ;AACjD"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-starter-pick.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SiteStarterSummary } from '../plugin-manager/plugin-site-starters'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\n\n/**\n * A starter picked in \"Choose your starter\" (AGL-4049), as Create site\n * decides about it: whether a site can be created from it yet, and what the\n * create's refusal of it asks for. Pure, so every surface that offers the\n * picker — the console, the native apps — decides the same way.\n */\n\n/** The heading's words, for the starters or for the styles drawn in their place. */\nexport const CHOOSE_STARTER_COPY = {\n starters: {\n title: 'Choose your starter',\n lede:\n `${PLATFORM_BRAND_NAME}'s styles come first, then starters from the marketplace. ` +\n 'Nothing is chosen for you, and you can change everything later.',\n },\n styles: {\n title: 'Choose a style',\n lede:\n 'Your site starts with a home page, a header and a footer in the style you choose. ' +\n 'You can change everything later.',\n },\n} as const\n\n/**\n * What stands between a pick and Create site: nothing picked (`none`), or a\n * price the workspace has not paid (`purchase`); `null` when the site can be\n * created from it. `owned` is what the surface knows better than the\n * search's own answer (the person just paid, or the create still asked for\n * payment); absent, the summary's `owned` stands.\n */\nexport type SiteStarterPickBlock = 'none' | 'purchase'\n\nexport function siteStarterPickBlock(\n pick: SiteStarterSummary | null | undefined,\n owned?: boolean,\n): SiteStarterPickBlock | null {\n if (!pick) return 'none'\n if (pick.priceUsd > 0 && !(owned ?? pick.owned === true)) return 'purchase'\n return null\n}\n\n/** What Create site does with a create that refused the starter it was asked for. */\nexport interface SiteStarterPickRefused {\n /** The pick stays: it can still be created from, once bought. */\n keep: boolean\n /** It is the price that stands in the way, so buying it is offered. */\n purchase: boolean\n /** The create's own words for why. */\n message: string\n}\n\n/**\n * The create's refusal of THIS pick, or `null` for a refusal about anything\n * else (the name, the address, the plan's site count), which Create site\n * answers as it always has. A refusal of a pick names its listing: a 402 is\n * a price to pay, and the pick stays with \"Buy and continue\"; anything else\n * (the release not open to the workspace, a starter that is gone, one with\n * more pages than the plan holds, an AI starter where the AI start is not\n * offered) clears the pick, with the reason said.\n */\nexport function readSiteStarterPickRefusal(\n status: number,\n payload: unknown,\n listingId: string,\n): SiteStarterPickRefused | null {\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) return null\n const body = payload as Record<string, unknown>\n if (!listingId || body['listingId'] !== listingId) return null\n const error = body['error']\n const message = typeof error === 'string' && error.trim() ? error.trim() : 'That starter cannot be used.'\n if (status === 402) return { keep: true, purchase: true, message }\n return { keep: false, purchase: false, message }\n}\n"],"names":["PLATFORM_BRAND_NAME","CHOOSE_STARTER_COPY","starters","title","lede","styles","siteStarterPickBlock","pick","owned","priceUsd","readSiteStarterPickRefusal","status","payload","listingId","Array","isArray","body","error","message","trim","keep","purchase"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,mBAAmB,QAAQ,sBAAkB;AAEtD;;;;;CAKC,GAED,kFAAkF,GAClF,OAAO,MAAMC,sBAAsB;IACjCC,UAAU;QACRC,OAAO;QACPC,MACE,GAAGJ,oBAAoB,0DAA0D,CAAC,GAClF;IACJ;IACAK,QAAQ;QACNF,OAAO;QACPC,MACE,uFACA;IACJ;AACF,EAAU;AAWV,OAAO,SAASE,qBACdC,IAA2C,EAC3CC,KAAe;IAEf,IAAI,CAACD,MAAM,OAAO;IAClB,IAAIA,KAAKE,QAAQ,GAAG,KAAK,EAAED,gBAAAA,QAASD,KAAKC,KAAK,KAAK,OAAO,OAAO;IACjE,OAAO;AACT;AAYA;;;;;;;;CAQC,GACD,OAAO,SAASE,2BACdC,MAAc,EACdC,OAAgB,EAChBC,SAAiB;IAEjB,IAAI,CAACD,WAAW,OAAOA,YAAY,YAAYE,MAAMC,OAAO,CAACH,UAAU,OAAO;IAC9E,MAAMI,OAAOJ;IACb,IAAI,CAACC,aAAaG,IAAI,CAAC,YAAY,KAAKH,WAAW,OAAO;IAC1D,MAAMI,QAAQD,IAAI,CAAC,QAAQ;IAC3B,MAAME,UAAU,OAAOD,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAK;IAC3E,IAAIR,WAAW,KAAK,OAAO;QAAES,MAAM;QAAMC,UAAU;QAAMH;IAAQ;IACjE,OAAO;QAAEE,MAAM;QAAOC,UAAU;QAAOH;IAAQ;AACjD"}
@@ -17,7 +17,7 @@
17
17
  import type { HostTheme } from '@aglyn/shared-data-types';
18
18
  import type { ConsoleThemePreset } from '../plugin-manager/feature-plugins';
19
19
  import type { SiteStarterTheme } from './site-starter';
20
- import { type ThemeLibraryEntryWrite } from './theme-library';
20
+ import { type ThemeLibraryEntryWrite, type ThemeLibraryHost } from './theme-library';
21
21
  /**
22
22
  * A site starter's theme on the site it creates (AGL-4049).
23
23
  *
@@ -87,4 +87,31 @@ export declare function planSiteStarterTheme(input: {
87
87
  };
88
88
  newId: () => string;
89
89
  }): SiteStarterThemePlan;
90
+ /** A site's built-in theme as a starter would carry it. */
91
+ export interface SiteStarterBuiltinReading {
92
+ theme: BuiltinStarterTheme;
93
+ /** What the site's theme library calls the built-in it wears. */
94
+ baseName: string;
95
+ /**
96
+ * False when the site sets fonts that no pairing names: a built-in starter
97
+ * names its fonts by pairing, so the starter wears the base's own fonts
98
+ * and only the full theme keeps the site's.
99
+ */
100
+ fontsCarried: boolean;
101
+ }
102
+ /**
103
+ * The built-in theme a site wears, as a starter's `builtin` theme, or `null`
104
+ * when it wears no built-in a starter can name: its own theme, a marketplace
105
+ * theme, the platform default, or a built-in another plugin contributes.
106
+ *
107
+ * - `base` is the built-in the site picked (`themeSelection`), or `starter`
108
+ * for the theme every new site is born with, unchanged as its own.
109
+ * - `brand` holds, per scheme, each of the three brand colors whose `main`
110
+ * the site changed from the base's.
111
+ * - `fonts` is the pairing whose families the site sets, or `null` when it
112
+ * sets the base's own (or a pair no pairing names: `fontsCarried` false).
113
+ *
114
+ * Pure: reads the host document only.
115
+ */
116
+ export declare function siteStarterBuiltinThemeOf(host: ThemeLibraryHost | null | undefined): SiteStarterBuiltinReading | null;
90
117
  export {};
@@ -14,12 +14,12 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */ import { _ as _extends } from "@swc/helpers/_/_extends";
17
- import { writeThemeFonts } from "@aglyn/shared-util-tools/theme-fonts";
17
+ import { readThemeFonts, writeThemeFonts } from "@aglyn/shared-util-tools/theme-fonts";
18
18
  import { diffOverride, overrideWriteValue } from "./artifact-overrides.js";
19
19
  import { DEFAULT_SITE_THEME } from "./default-site.js";
20
- import { siteFontPairing } from "./site-font-pairings.js";
21
- import { themeArtifactContent } from "./site-theme.js";
22
- import { planThemeLibraryAction, THEME_FIELD_DELETE } from "./theme-library.js";
20
+ import { SITE_FONT_PAIRINGS, siteFontPairing } from "./site-font-pairings.js";
21
+ import { parseColor, resolveSiteTheme, themeArtifactContent } from "./site-theme.js";
22
+ import { planThemeLibraryAction, presetEntryId, readThemeSelection, THEME_FIELD_DELETE } from "./theme-library.js";
23
23
  /**
24
24
  * A site starter's theme on the site it creates (AGL-4049).
25
25
  *
@@ -237,5 +237,79 @@ const isRecord = (value)=>!!value && typeof value === 'object' && !Array.isArray
237
237
  entries: []
238
238
  };
239
239
  }
240
+ /** The `themeSelection` id a built-in starter base is picked under. */ const STARTER_PRESET_SELECTION = presetEntryId(siteStarterPresetId(''));
241
+ /** The `main` of one palette color, as the theme stores it. */ function paletteMain(colors, key) {
242
+ const value = colors == null ? void 0 : colors[key];
243
+ const main = isRecord(value) ? value['main'] : undefined;
244
+ return typeof main === 'string' && main.trim() ? main.trim() : null;
245
+ }
246
+ /** A font selection's families, as one comparable key. */ const fontKey = (fonts)=>{
247
+ var _ref, _ref1;
248
+ var _fonts_body, _fonts_heading;
249
+ return `${(_ref = (_fonts_body = fonts.body) == null ? void 0 : _fonts_body.family.trim().toLowerCase()) != null ? _ref : ''}|${(_ref1 = (_fonts_heading = fonts.heading) == null ? void 0 : _fonts_heading.family.trim().toLowerCase()) != null ? _ref1 : ''}`;
250
+ };
251
+ /** A pairing's families, keyed as `readThemeFonts` reads them back once written. */ const pairingKey = (pairing)=>{
252
+ const body = pairing.body.family.trim().toLowerCase();
253
+ const heading = pairing.heading.family.trim().toLowerCase();
254
+ return `${body}|${heading === body ? '' : heading}`;
255
+ };
256
+ /**
257
+ * The built-in theme a site wears, as a starter's `builtin` theme, or `null`
258
+ * when it wears no built-in a starter can name: its own theme, a marketplace
259
+ * theme, the platform default, or a built-in another plugin contributes.
260
+ *
261
+ * - `base` is the built-in the site picked (`themeSelection`), or `starter`
262
+ * for the theme every new site is born with, unchanged as its own.
263
+ * - `brand` holds, per scheme, each of the three brand colors whose `main`
264
+ * the site changed from the base's.
265
+ * - `fonts` is the pairing whose families the site sets, or `null` when it
266
+ * sets the base's own (or a pair no pairing names: `fontsCarried` false).
267
+ *
268
+ * Pure: reads the host document only.
269
+ */ export function siteStarterBuiltinThemeOf(host) {
270
+ var _resolveSiteTheme, _SITE_FONT_PAIRINGS_find, _ref;
271
+ if (!isRecord(host)) return null;
272
+ const base = themeArtifactContent(host.theme);
273
+ const selection = readThemeSelection(host);
274
+ let baseId = null;
275
+ if (selection.kind === 'preset' && selection.id.startsWith(STARTER_PRESET_SELECTION)) {
276
+ const id = selection.id.slice(STARTER_PRESET_SELECTION.length);
277
+ // A built-in registered under the starter's own name is never what
278
+ // `starter` creates (`planSiteStarterTheme`).
279
+ baseId = id && id !== 'starter' ? id : null;
280
+ } else if (selection.kind === 'custom' && diffOverride(base, themeArtifactContent(DEFAULT_SITE_THEME)) === undefined) {
281
+ baseId = 'starter';
282
+ }
283
+ if (!baseId) return null;
284
+ const wears = (_resolveSiteTheme = resolveSiteTheme(host)) != null ? _resolveSiteTheme : {};
285
+ const brandOf = (scheme)=>{
286
+ const out = {};
287
+ for (const key of SITE_STARTER_BRAND_KEYS){
288
+ var _wears_colorSchemes, _paletteMain, _base_colorSchemes;
289
+ const main = paletteMain((_wears_colorSchemes = wears.colorSchemes) == null ? void 0 : _wears_colorSchemes[scheme], key);
290
+ if (!main || !parseColor(main)) continue;
291
+ if (main.toLowerCase() === ((_paletteMain = paletteMain((_base_colorSchemes = base.colorSchemes) == null ? void 0 : _base_colorSchemes[scheme], key)) == null ? void 0 : _paletteMain.toLowerCase())) continue;
292
+ out[key] = main;
293
+ }
294
+ return out;
295
+ };
296
+ const siteFonts = readThemeFonts(wears);
297
+ const sameFonts = fontKey(siteFonts) === fontKey(readThemeFonts(base));
298
+ const pairing = sameFonts ? null : (_SITE_FONT_PAIRINGS_find = SITE_FONT_PAIRINGS.find((entry)=>pairingKey(entry) === fontKey(siteFonts))) != null ? _SITE_FONT_PAIRINGS_find : null;
299
+ return {
300
+ theme: {
301
+ kind: 'builtin',
302
+ base: baseId,
303
+ // Both schemes always: a `dark` left out would be colored with `light`.
304
+ brand: {
305
+ light: brandOf('light'),
306
+ dark: brandOf('dark')
307
+ },
308
+ fonts: (_ref = pairing == null ? void 0 : pairing.id) != null ? _ref : null
309
+ },
310
+ baseName: selection.name,
311
+ fontsCarried: sameFonts || !!pairing
312
+ };
313
+ }
240
314
 
241
315
  //# sourceMappingURL=site-starter-theme.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-starter-theme.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HostTheme, HostThemeSchemeColors } from '@aglyn/shared-data-types'\nimport { writeThemeFonts } from '@aglyn/shared-util-tools/theme-fonts'\nimport type { ConsoleThemePreset } from '../plugin-manager/feature-plugins'\nimport { diffOverride, overrideWriteValue } from './artifact-overrides'\nimport { DEFAULT_SITE_THEME } from './default-site'\nimport { siteFontPairing } from './site-font-pairings'\nimport type { SiteStarterTheme } from './site-starter'\nimport { themeArtifactContent } from './site-theme'\nimport {\n planThemeLibraryAction,\n THEME_FIELD_DELETE,\n type ThemeLibraryAction,\n type ThemeLibraryEntryWrite,\n} from './theme-library'\n\n/**\n * A site starter's theme on the site it creates (AGL-4049).\n *\n * A starter names its look one of two ways (`SiteStarterTheme`): a built-in\n * theme with its brand colors and font pairing over it, or a full theme of\n * its author's own. Either way the new site's theme is stored the way a\n * person's own pick is: the built-in picked through the theme library with\n * the starter's colors and fonts as the override over it, or the full theme\n * installed into the library as a marketplace theme is. So the Theme page\n * names the base a site came from, and every edit there starts from it.\n *\n * Planned against an EMPTY host, because the site does not exist yet: the\n * create writes these fields in the same `set` that makes the host, and the\n * library entries beside it, in one transaction.\n *\n * Pure: no I/O. The caller passes the built-in themes it has registered.\n */\n\n/**\n * The palette keys a built-in starter's brand sets: its three brand colors.\n * The status colors (error, warning, info, success) stay the base theme's,\n * since they mean the same thing on every site, and surfaces and text are the\n * base's design.\n */\nexport const SITE_STARTER_BRAND_KEYS = ['primary', 'secondary', 'tertiary'] as const\n\n/** The built-in theme a starter's `base` names, as the themes plugin registers it. */\nexport const siteStarterPresetId = (base: string) => `theme-presets.${base}`\n\ntype BuiltinStarterTheme = Extract<SiteStarterTheme, { kind: 'builtin' }>\ntype Scheme = 'light' | 'dark'\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === 'object' && !Array.isArray(value)\n\n/**\n * One scheme's colors with the brand over them, each brand color written the\n * way the theme editor writes a palette color (`writeThemeColor`): a record of\n * `main` alone, so MUI derives its light, dark and contrast text from it, and\n * the base's tint for that color dropped, since it was a wash of the old one.\n */\nfunction brandScheme(\n colors: HostThemeSchemeColors | undefined,\n brand: Record<string, string> | undefined,\n): HostThemeSchemeColors | undefined {\n let next: HostThemeSchemeColors | undefined = colors\n for (const key of SITE_STARTER_BRAND_KEYS) {\n const hex = brand?.[key]\n if (typeof hex !== 'string' || !hex.trim()) continue\n next = { ...next, [key]: { main: hex.trim() } }\n const tint = next.tint as Record<string, string> | undefined\n if (tint && key in tint) {\n const rest = { ...tint }\n delete rest[key]\n if (Object.keys(rest).length) next.tint = rest as HostThemeSchemeColors['tint']\n else delete next.tint\n }\n }\n return next\n}\n\n/**\n * A built-in base with the starter's brand colors and font pairing over it,\n * modeled on the AI start's look (`aiSiteTheme`) but driven by the starter's\n * `brand` and `fonts` rather than a style. Everything the base sets beyond\n * those stays the base's: its status colors, surfaces, shapes and component\n * styles. A brand with no `dark` map colors both schemes with `light`; a\n * `fonts` of `null`, or a pairing id the platform does not have, keeps the\n * base's own fonts.\n */\nexport function siteStarterTheme(theme: BuiltinStarterTheme, base: HostTheme): HostTheme {\n const brand = isRecord(theme?.brand) ? theme.brand : { light: {} }\n const light = isRecord(brand.light) ? brand.light : {}\n const dark = isRecord(brand.dark) ? brand.dark : light\n const brandFor: Record<Scheme, Record<string, string>> = { light, dark }\n const colorSchemes = { ...base.colorSchemes }\n for (const scheme of ['light', 'dark'] as const) {\n const colors = brandScheme(base.colorSchemes?.[scheme], brandFor[scheme])\n if (colors) colorSchemes[scheme] = colors\n }\n let next: HostTheme = { ...base }\n if (Object.keys(colorSchemes).length) next.colorSchemes = colorSchemes\n\n const pairing = siteFontPairing(theme?.fonts)\n if (!pairing) return next\n // The same write the AI site look makes for a pairing: the body family,\n // and the heading family where it differs.\n const sameFamily = pairing.heading.family === pairing.body.family\n next = writeThemeFonts(next, {\n body: {\n family: pairing.body.family,\n category: pairing.body.category,\n weights: [...pairing.body.weights],\n source: 'google',\n },\n heading: sameFamily\n ? null\n : {\n family: pairing.heading.family,\n category: pairing.heading.category,\n weights: [...new Set([pairing.heading.weight, pairing.heading.sub])].sort((a, b) => a - b),\n source: 'google',\n },\n })\n // A pairing whose heading is the body family loads the heading weights too.\n if (sameFamily && next.fonts?.[0]) {\n next.fonts = [\n {\n ...next.fonts[0],\n weights: [\n ...new Set([...(next.fonts[0].weights ?? []), pairing.heading.weight, pairing.heading.sub]),\n ].sort((a, b) => a - b),\n },\n ...next.fonts.slice(1),\n ]\n }\n return next\n}\n\n/** What a new site's host document and theme library start with. */\nexport interface SiteStarterThemePlan {\n /** Host fields, written in the `set` that creates the host. */\n host: Record<string, unknown>\n /** Library entries to create under `hosts/{id}/themes`. */\n entries: ThemeLibraryEntryWrite[]\n}\n\n/**\n * A plan's host fields as a new document takes them: a field the plan\n * deletes is simply not written, since an empty host has nothing to delete,\n * and an empty override is no field at all.\n */\nfunction creatable(fields: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(fields).filter(([, value]) => value !== THEME_FIELD_DELETE && value !== null),\n )\n}\n\n/** The override a built-in starter stores over `base`, or `null` when it changes nothing. */\nfunction starterOverride(theme: BuiltinStarterTheme, base: HostTheme): unknown {\n return overrideWriteValue(diffOverride(base, siteStarterTheme(theme, base)), null)\n}\n\n/**\n * The host fields and library entries a new site is born with for a\n * starter's theme, planned against an empty host through the same planner\n * the theme library runs (`planThemeLibraryAction`):\n *\n * - a full theme is installed, as the marketplace installs a theme, its\n * entry named after the starter and its provenance the starter's listing;\n * - a built-in theme is picked as a preset, with the brand and fonts as the\n * override over it;\n * - the `starter` base, or a base this deployment has no built-in for, is\n * the theme every new site is born with (`DEFAULT_SITE_THEME`), with the\n * brand and fonts as the override over it, and no library entry.\n */\nexport function planSiteStarterTheme(input: {\n theme: SiteStarterTheme\n presets: readonly ConsoleThemePreset[]\n listing: { listingId: string; version: string | number; displayName: string }\n newId: () => string\n}): SiteStarterThemePlan {\n // `source`, not `listing`: this is the starter's id/version/name, not the\n // listing document the listing write-deny guard partitions (AGL-1361).\n const { theme, presets, listing: source, newId } = input\n const plan = (action: ThemeLibraryAction) => {\n const planned = planThemeLibraryAction({ host: {}, entries: {}, newId, action })\n return planned.ok === false ? null : planned\n }\n\n if (theme?.kind === 'full' && isRecord(theme.theme)) {\n const planned = plan({\n action: 'install',\n listingId: source.listingId,\n name: `${source.displayName} theme`,\n theme: themeArtifactContent(theme.theme),\n installedFrom: {\n listingId: source.listingId,\n version: source.version,\n artifactType: 'siteStarter',\n },\n })\n if (planned) return { host: creatable(planned.host), entries: planned.entries }\n }\n\n const builtin: BuiltinStarterTheme =\n theme?.kind === 'builtin' ? theme : { kind: 'builtin', base: 'starter', brand: { light: {} }, fonts: null }\n const preset =\n builtin.base === 'starter'\n ? null\n : (presets.find((entry) => entry?.id === siteStarterPresetId(builtin.base)) ?? null)\n if (preset) {\n const base = themeArtifactContent(preset.theme)\n const planned = plan({\n action: 'select',\n target: { kind: 'preset', id: preset.id, name: preset.name, theme: base },\n })\n if (planned) {\n return {\n host: creatable({ ...planned.host, themeOverride: starterOverride(builtin, base) }),\n entries: planned.entries,\n }\n }\n }\n return {\n host: creatable({\n theme: DEFAULT_SITE_THEME,\n themeOverride: starterOverride(builtin, DEFAULT_SITE_THEME),\n }),\n entries: [],\n }\n}\n"],"names":["writeThemeFonts","diffOverride","overrideWriteValue","DEFAULT_SITE_THEME","siteFontPairing","themeArtifactContent","planThemeLibraryAction","THEME_FIELD_DELETE","SITE_STARTER_BRAND_KEYS","siteStarterPresetId","base","isRecord","value","Array","isArray","brandScheme","colors","brand","next","key","hex","trim","main","tint","rest","Object","keys","length","siteStarterTheme","theme","light","dark","brandFor","colorSchemes","scheme","pairing","fonts","sameFamily","heading","family","body","category","weights","source","Set","weight","sub","sort","a","b","slice","creatable","fields","fromEntries","entries","filter","starterOverride","planSiteStarterTheme","input","presets","listing","newId","plan","action","planned","host","ok","kind","listingId","name","displayName","installedFrom","version","artifactType","builtin","preset","find","entry","id","target","themeOverride"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,eAAe,QAAQ,uCAAsC;AAEtE,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,0BAAsB;AACvE,SAASC,kBAAkB,QAAQ,oBAAgB;AACnD,SAASC,eAAe,QAAQ,0BAAsB;AAEtD,SAASC,oBAAoB,QAAQ,kBAAc;AACnD,SACEC,sBAAsB,EACtBC,kBAAkB,QAGb,qBAAiB;AAExB;;;;;;;;;;;;;;;;CAgBC,GAED;;;;;CAKC,GACD,OAAO,MAAMC,0BAA0B;IAAC;IAAW;IAAa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AAO;YAAEC,MAAMd,UAAUa,QAAQC,IAAI;YAAGX,SAASU,QAAQV,OAAO;QAAC;IAChF;IAEA,MAAMoB,UACJ7C,CAAAA,yBAAAA,MAAOsC,IAAI,MAAK,YAAYtC,QAAQ;QAAEsC,MAAM;QAAWzD,MAAM;QAAWO,OAAO;YAAEa,OAAO,CAAC;QAAE;QAAGM,OAAO;IAAK;IAC5G,MAAMuC,SACJD,QAAQhE,IAAI,KAAK,YACb,QACCiD,gBAAAA,QAAQiB,IAAI,CAAC,CAACC,QAAUA,CAAAA,yBAAAA,MAAOC,EAAE,MAAKrE,oBAAoBiE,QAAQhE,IAAI,cAAtEiD,gBAA4E;IACnF,IAAIgB,QAAQ;QACV,MAAMjE,OAAOL,qBAAqBsE,OAAO9C,KAAK;QAC9C,MAAMmC,UAAUF,KAAK;YACnBC,QAAQ;YACRgB,QAAQ;gBAAEZ,MAAM;gBAAUW,IAAIH,OAAOG,EAAE;gBAAET,MAAMM,OAAON,IAAI;gBAAExC,OAAOnB;YAAK;QAC1E;QACA,IAAIsD,SAAS;YACX,OAAO;gBACLC,MAAMd,UAAU,aAAKa,QAAQC,IAAI;oBAAEe,eAAexB,gBAAgBkB,SAAShE;;gBAC3E4C,SAASU,QAAQV,OAAO;YAC1B;QACF;IACF;IACA,OAAO;QACLW,MAAMd,UAAU;YACdtB,OAAO1B;YACP6E,eAAexB,gBAAgBkB,SAASvE;QAC1C;QACAmD,SAAS,EAAE;IACb;AACF"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-starter-theme.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { HostTheme, HostThemeSchemeColors } from '@aglyn/shared-data-types'\nimport {\n readThemeFonts,\n writeThemeFonts,\n type ThemeFontSelection,\n} from '@aglyn/shared-util-tools/theme-fonts'\nimport type { ConsoleThemePreset } from '../plugin-manager/feature-plugins'\nimport { diffOverride, overrideWriteValue } from './artifact-overrides'\nimport { DEFAULT_SITE_THEME } from './default-site'\nimport { SITE_FONT_PAIRINGS, siteFontPairing, type SiteFontPairing } from './site-font-pairings'\nimport type { SiteStarterTheme } from './site-starter'\nimport { parseColor, resolveSiteTheme, themeArtifactContent } from './site-theme'\nimport {\n planThemeLibraryAction,\n presetEntryId,\n readThemeSelection,\n THEME_FIELD_DELETE,\n type ThemeLibraryAction,\n type ThemeLibraryEntryWrite,\n type ThemeLibraryHost,\n} from './theme-library'\n\n/**\n * A site starter's theme on the site it creates (AGL-4049).\n *\n * A starter names its look one of two ways (`SiteStarterTheme`): a built-in\n * theme with its brand colors and font pairing over it, or a full theme of\n * its author's own. Either way the new site's theme is stored the way a\n * person's own pick is: the built-in picked through the theme library with\n * the starter's colors and fonts as the override over it, or the full theme\n * installed into the library as a marketplace theme is. So the Theme page\n * names the base a site came from, and every edit there starts from it.\n *\n * Planned against an EMPTY host, because the site does not exist yet: the\n * create writes these fields in the same `set` that makes the host, and the\n * library entries beside it, in one transaction.\n *\n * Pure: no I/O. The caller passes the built-in themes it has registered.\n */\n\n/**\n * The palette keys a built-in starter's brand sets: its three brand colors.\n * The status colors (error, warning, info, success) stay the base theme's,\n * since they mean the same thing on every site, and surfaces and text are the\n * base's design.\n */\nexport const SITE_STARTER_BRAND_KEYS = ['primary', 'secondary', 'tertiary'] as const\n\n/** The built-in theme a starter's `base` names, as the themes plugin registers it. */\nexport const siteStarterPresetId = (base: string) => `theme-presets.${base}`\n\ntype BuiltinStarterTheme = Extract<SiteStarterTheme, { kind: 'builtin' }>\ntype Scheme = 'light' | 'dark'\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n !!value && typeof value === 'object' && !Array.isArray(value)\n\n/**\n * One scheme's colors with the brand over them, each brand color written the\n * way the theme editor writes a palette color (`writeThemeColor`): a record of\n * `main` alone, so MUI derives its light, dark and contrast text from it, and\n * the base's tint for that color dropped, since it was a wash of the old one.\n */\nfunction brandScheme(\n colors: HostThemeSchemeColors | undefined,\n brand: Record<string, string> | undefined,\n): HostThemeSchemeColors | undefined {\n let next: HostThemeSchemeColors | undefined = colors\n for (const key of SITE_STARTER_BRAND_KEYS) {\n const hex = brand?.[key]\n if (typeof hex !== 'string' || !hex.trim()) continue\n next = { ...next, [key]: { main: hex.trim() } }\n const tint = next.tint as Record<string, string> | undefined\n if (tint && key in tint) {\n const rest = { ...tint }\n delete rest[key]\n if (Object.keys(rest).length) next.tint = rest as HostThemeSchemeColors['tint']\n else delete next.tint\n }\n }\n return next\n}\n\n/**\n * A built-in base with the starter's brand colors and font pairing over it,\n * modeled on the AI start's look (`aiSiteTheme`) but driven by the starter's\n * `brand` and `fonts` rather than a style. Everything the base sets beyond\n * those stays the base's: its status colors, surfaces, shapes and component\n * styles. A brand with no `dark` map colors both schemes with `light`; a\n * `fonts` of `null`, or a pairing id the platform does not have, keeps the\n * base's own fonts.\n */\nexport function siteStarterTheme(theme: BuiltinStarterTheme, base: HostTheme): HostTheme {\n const brand = isRecord(theme?.brand) ? theme.brand : { light: {} }\n const light = isRecord(brand.light) ? brand.light : {}\n const dark = isRecord(brand.dark) ? brand.dark : light\n const brandFor: Record<Scheme, Record<string, string>> = { light, dark }\n const colorSchemes = { ...base.colorSchemes }\n for (const scheme of ['light', 'dark'] as const) {\n const colors = brandScheme(base.colorSchemes?.[scheme], brandFor[scheme])\n if (colors) colorSchemes[scheme] = colors\n }\n let next: HostTheme = { ...base }\n if (Object.keys(colorSchemes).length) next.colorSchemes = colorSchemes\n\n const pairing = siteFontPairing(theme?.fonts)\n if (!pairing) return next\n // The same write the AI site look makes for a pairing: the body family,\n // and the heading family where it differs.\n const sameFamily = pairing.heading.family === pairing.body.family\n next = writeThemeFonts(next, {\n body: {\n family: pairing.body.family,\n category: pairing.body.category,\n weights: [...pairing.body.weights],\n source: 'google',\n },\n heading: sameFamily\n ? null\n : {\n family: pairing.heading.family,\n category: pairing.heading.category,\n weights: [...new Set([pairing.heading.weight, pairing.heading.sub])].sort((a, b) => a - b),\n source: 'google',\n },\n })\n // A pairing whose heading is the body family loads the heading weights too.\n if (sameFamily && next.fonts?.[0]) {\n next.fonts = [\n {\n ...next.fonts[0],\n weights: [\n ...new Set([...(next.fonts[0].weights ?? []), pairing.heading.weight, pairing.heading.sub]),\n ].sort((a, b) => a - b),\n },\n ...next.fonts.slice(1),\n ]\n }\n return next\n}\n\n/** What a new site's host document and theme library start with. */\nexport interface SiteStarterThemePlan {\n /** Host fields, written in the `set` that creates the host. */\n host: Record<string, unknown>\n /** Library entries to create under `hosts/{id}/themes`. */\n entries: ThemeLibraryEntryWrite[]\n}\n\n/**\n * A plan's host fields as a new document takes them: a field the plan\n * deletes is simply not written, since an empty host has nothing to delete,\n * and an empty override is no field at all.\n */\nfunction creatable(fields: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(fields).filter(([, value]) => value !== THEME_FIELD_DELETE && value !== null),\n )\n}\n\n/** The override a built-in starter stores over `base`, or `null` when it changes nothing. */\nfunction starterOverride(theme: BuiltinStarterTheme, base: HostTheme): unknown {\n return overrideWriteValue(diffOverride(base, siteStarterTheme(theme, base)), null)\n}\n\n/**\n * The host fields and library entries a new site is born with for a\n * starter's theme, planned against an empty host through the same planner\n * the theme library runs (`planThemeLibraryAction`):\n *\n * - a full theme is installed, as the marketplace installs a theme, its\n * entry named after the starter and its provenance the starter's listing;\n * - a built-in theme is picked as a preset, with the brand and fonts as the\n * override over it;\n * - the `starter` base, or a base this deployment has no built-in for, is\n * the theme every new site is born with (`DEFAULT_SITE_THEME`), with the\n * brand and fonts as the override over it, and no library entry.\n */\nexport function planSiteStarterTheme(input: {\n theme: SiteStarterTheme\n presets: readonly ConsoleThemePreset[]\n listing: { listingId: string; version: string | number; displayName: string }\n newId: () => string\n}): SiteStarterThemePlan {\n // `source`, not `listing`: this is the starter's id/version/name, not the\n // listing document the listing write-deny guard partitions (AGL-1361).\n const { theme, presets, listing: source, newId } = input\n const plan = (action: ThemeLibraryAction) => {\n const planned = planThemeLibraryAction({ host: {}, entries: {}, newId, action })\n return planned.ok === false ? null : planned\n }\n\n if (theme?.kind === 'full' && isRecord(theme.theme)) {\n const planned = plan({\n action: 'install',\n listingId: source.listingId,\n name: `${source.displayName} theme`,\n theme: themeArtifactContent(theme.theme),\n installedFrom: {\n listingId: source.listingId,\n version: source.version,\n artifactType: 'siteStarter',\n },\n })\n if (planned) return { host: creatable(planned.host), entries: planned.entries }\n }\n\n const builtin: BuiltinStarterTheme =\n theme?.kind === 'builtin' ? theme : { kind: 'builtin', base: 'starter', brand: { light: {} }, fonts: null }\n const preset =\n builtin.base === 'starter'\n ? null\n : (presets.find((entry) => entry?.id === siteStarterPresetId(builtin.base)) ?? null)\n if (preset) {\n const base = themeArtifactContent(preset.theme)\n const planned = plan({\n action: 'select',\n target: { kind: 'preset', id: preset.id, name: preset.name, theme: base },\n })\n if (planned) {\n return {\n host: creatable({ ...planned.host, themeOverride: starterOverride(builtin, base) }),\n entries: planned.entries,\n }\n }\n }\n return {\n host: creatable({\n theme: DEFAULT_SITE_THEME,\n themeOverride: starterOverride(builtin, DEFAULT_SITE_THEME),\n }),\n entries: [],\n }\n}\n\n/*==========================================\n * A SITE'S OWN BUILT-IN, READ BACK AS A STARTER THEME (AGL-4049).\n *\n * \"Publish as a starter\" offers a site that wears a built-in theme the\n * starter's built-in shape: the base it picked, the brand colors it set over\n * it, and its font pairing. Read so that a site created from the starter\n * wears what the publisher's site wears: a color the site never changed is\n * left to the base (its hand-tuned shades kept), each scheme names its own\n * colors (so a light brand never recolors the base's dark scheme), and fonts\n * the site never changed name no pairing.\n *=========================================*/\n\n/** A site's built-in theme as a starter would carry it. */\nexport interface SiteStarterBuiltinReading {\n theme: BuiltinStarterTheme\n /** What the site's theme library calls the built-in it wears. */\n baseName: string\n /**\n * False when the site sets fonts that no pairing names: a built-in starter\n * names its fonts by pairing, so the starter wears the base's own fonts\n * and only the full theme keeps the site's.\n */\n fontsCarried: boolean\n}\n\n/** The `themeSelection` id a built-in starter base is picked under. */\nconst STARTER_PRESET_SELECTION = presetEntryId(siteStarterPresetId(''))\n\n/** The `main` of one palette color, as the theme stores it. */\nfunction paletteMain(colors: HostThemeSchemeColors | undefined, key: string): string | null {\n const value = (colors as Record<string, unknown> | undefined)?.[key]\n const main = isRecord(value) ? value['main'] : undefined\n return typeof main === 'string' && main.trim() ? main.trim() : null\n}\n\n/** A font selection's families, as one comparable key. */\nconst fontKey = (fonts: ThemeFontSelection) =>\n `${fonts.body?.family.trim().toLowerCase() ?? ''}|${fonts.heading?.family.trim().toLowerCase() ?? ''}`\n\n/** A pairing's families, keyed as `readThemeFonts` reads them back once written. */\nconst pairingKey = (pairing: SiteFontPairing) => {\n const body = pairing.body.family.trim().toLowerCase()\n const heading = pairing.heading.family.trim().toLowerCase()\n return `${body}|${heading === body ? '' : heading}`\n}\n\n/**\n * The built-in theme a site wears, as a starter's `builtin` theme, or `null`\n * when it wears no built-in a starter can name: its own theme, a marketplace\n * theme, the platform default, or a built-in another plugin contributes.\n *\n * - `base` is the built-in the site picked (`themeSelection`), or `starter`\n * for the theme every new site is born with, unchanged as its own.\n * - `brand` holds, per scheme, each of the three brand colors whose `main`\n * the site changed from the base's.\n * - `fonts` is the pairing whose families the site sets, or `null` when it\n * sets the base's own (or a pair no pairing names: `fontsCarried` false).\n *\n * Pure: reads the host document only.\n */\nexport function siteStarterBuiltinThemeOf(\n host: ThemeLibraryHost | null | undefined,\n): SiteStarterBuiltinReading | null {\n if (!isRecord(host)) return null\n const base = themeArtifactContent(host.theme)\n const selection = readThemeSelection(host)\n let baseId: string | null = null\n if (selection.kind === 'preset' && selection.id.startsWith(STARTER_PRESET_SELECTION)) {\n const id = selection.id.slice(STARTER_PRESET_SELECTION.length)\n // A built-in registered under the starter's own name is never what\n // `starter` creates (`planSiteStarterTheme`).\n baseId = id && id !== 'starter' ? id : null\n } else if (\n selection.kind === 'custom' &&\n diffOverride(base, themeArtifactContent(DEFAULT_SITE_THEME)) === undefined\n ) {\n baseId = 'starter'\n }\n if (!baseId) return null\n\n const wears = resolveSiteTheme(host) ?? {}\n const brandOf = (scheme: Scheme): Record<string, string> => {\n const out: Record<string, string> = {}\n for (const key of SITE_STARTER_BRAND_KEYS) {\n const main = paletteMain(wears.colorSchemes?.[scheme], key)\n if (!main || !parseColor(main)) continue\n if (main.toLowerCase() === paletteMain(base.colorSchemes?.[scheme], key)?.toLowerCase()) continue\n out[key] = main\n }\n return out\n }\n\n const siteFonts = readThemeFonts(wears)\n const sameFonts = fontKey(siteFonts) === fontKey(readThemeFonts(base))\n const pairing = sameFonts\n ? null\n : (SITE_FONT_PAIRINGS.find((entry) => pairingKey(entry) === fontKey(siteFonts)) ?? null)\n\n return {\n theme: {\n kind: 'builtin',\n base: baseId,\n // Both schemes always: a `dark` left out would be colored with `light`.\n brand: { light: brandOf('light'), dark: brandOf('dark') },\n fonts: pairing?.id ?? null,\n },\n baseName: selection.name,\n fontsCarried: sameFonts || !!pairing,\n }\n}\n"],"names":["readThemeFonts","writeThemeFonts","diffOverride","overrideWriteValue","DEFAULT_SITE_THEME","SITE_FONT_PAIRINGS","siteFontPairing","parseColor","resolveSiteTheme","themeArtifactContent","planThemeLibraryAction","presetEntryId","readThemeSelection","THEME_FIELD_DELETE","SITE_STARTER_BRAND_KEYS","siteStarterPresetId","base","isRecord","value","Array","isArray","brandScheme","colors","brand","next","key","hex","trim","main","tint","rest","Object","keys","length","siteStarterTheme","theme","light","dark","brandFor","colorSchemes","scheme","pairing","fonts","sameFamily","heading","family","body","category","weights","source","Set","weight","sub","sort","a","b","slice","creatable","fields","fromEntries","entries","filter","starterOverride","planSiteStarterTheme","input","presets","listing","newId","plan","action","planned","host","ok","kind","listingId","name","displayName","installedFrom","version","artifactType","builtin","preset","find","entry","id","target","themeOverride","STARTER_PRESET_SELECTION","paletteMain","undefined","fontKey","toLowerCase","pairingKey","siteStarterBuiltinThemeOf","selection","baseId","startsWith","wears","brandOf","out","siteFonts","sameFonts","baseName","fontsCarried"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,cAAc,EACdC,eAAe,QAEV,uCAAsC;AAE7C,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,0BAAsB;AACvE,SAASC,kBAAkB,QAAQ,oBAAgB;AACnD,SAASC,kBAAkB,EAAEC,eAAe,QAA8B,0BAAsB;AAEhG,SAASC,UAAU,EAAEC,gBAAgB,EAAEC,oBAAoB,QAAQ,kBAAc;AACjF,SACEC,sBAAsB,EACtBC,aAAa,EACbC,kBAAkB,EAClBC,kBAAkB,QAIb,qBAAiB;AAExB;;;;;;;;;;;;;;;;CAgBC,GAED;;;;;CAKC,GACD,OAAO,MAAMC,0BAA0B;IAAC;IAAW;IAAa;CAAW,CAAS;AAEpF,oFAAoF,GACpF,OAAO,MAAMC,sBAAsB,CAACC,OAAiB,CAAC,cAAc,EAAEA,MAAM,CAAA;AAK5E,MAAMC,WAAW,CAACC,QAChB,CAAC,CAACA,SAAS,OAAOA,UAAU,YAAY,CAACC,MAAMC,OAAO,CAACF;AAEzD;;;;;CAKC,GACD,SAASG,YACPC,MAAyC,EACzCC,KAAyC;IAEzC,IAAIC,OAA0CF;IAC9C,KAAK,MAAMG,OAAOX,wBAAyB;QACzC,MAAMY,MAAMH,yBAAAA,KAAO,CAACE,IAAI;QACxB,IAAI,OAAOC,QAAQ,YAAY,CAACA,IAAIC,IAAI,IAAI;QAC5CH,OAAO,aAAKA;YAAM,CAACC,IAAI,EAAE;gBAAEG,MAAMF,IAAIC,IAAI;YAAG;;QAC5C,MAAME,OAAOL,KAAKK,IAAI;QACtB,IAAIA,QAAQJ,O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QAAQU,uBAAjE/F,2BAAgF;IAErF,OAAO;QACL8B,OAAO;YACLsC,MAAM;YACNzD,MAAM+E;YACN,wEAAwE;YACxExE,OAAO;gBAAEa,OAAO8D,QAAQ;gBAAU7D,MAAM6D,QAAQ;YAAQ;YACxDxD,KAAK,UAAED,2BAAAA,QAAS2C,EAAE,mBAAI;QACxB;QACAkB,UAAUR,UAAUnB,IAAI;QACxB4B,cAAcF,aAAa,CAAC,CAAC5D;IAC/B;AACF"}
@@ -35,6 +35,15 @@
35
35
  */
36
36
  /** Where the console serves each style's picture: `<dir>/<id>.webp`. */
37
37
  export declare const SITE_STYLE_PREVIEW_DIR = "/_static/starter/styles";
38
+ /**
39
+ * Where an app reads the same pictures. The console's bot protection answers
40
+ * `/_static` with a challenge a browser solves and URLSession and OkHttp
41
+ * cannot, so a picture fetched from there never loads in the native apps; the
42
+ * public media path has that challenge lifted for every caller. `next.config.js`
43
+ * rewrites this directory onto {@link SITE_STYLE_PREVIEW_DIR}, one file for one
44
+ * file, and `site-style-app-pictures.spec.ts` holds the two together.
45
+ */
46
+ export declare const SITE_STYLE_APP_PREVIEW_DIR = "/api/media/cdn/site-styles";
38
47
  /** The width and height every style picture is drawn at. */
39
48
  export declare const SITE_STYLE_PREVIEW_SIZE: {
40
49
  readonly width: 800;
@@ -62,6 +71,8 @@ export declare const SITE_STYLES: readonly SiteStyle[];
62
71
  * card, so a site created with the starter always names a real style.
63
72
  */
64
73
  export declare const SITE_STYLE_AUTO = "auto";
74
+ /** A style's picture as an app reads it: see {@link SITE_STYLE_APP_PREVIEW_DIR}. */
75
+ export declare function siteStyleAppPreview(id: string): string;
65
76
  /** Whether a value names one of the {@link SITE_STYLES}. */
66
77
  export declare function isSiteStyleId(value: unknown): value is string;
67
78
  /** The style an id names, or `null`. */
@@ -32,6 +32,14 @@
32
32
  *
33
33
  * Pure data and readers, safe for any surface to import.
34
34
  */ /** Where the console serves each style's picture: `<dir>/<id>.webp`. */ export const SITE_STYLE_PREVIEW_DIR = '/_static/starter/styles';
35
+ /**
36
+ * Where an app reads the same pictures. The console's bot protection answers
37
+ * `/_static` with a challenge a browser solves and URLSession and OkHttp
38
+ * cannot, so a picture fetched from there never loads in the native apps; the
39
+ * public media path has that challenge lifted for every caller. `next.config.js`
40
+ * rewrites this directory onto {@link SITE_STYLE_PREVIEW_DIR}, one file for one
41
+ * file, and `site-style-app-pictures.spec.ts` holds the two together.
42
+ */ export const SITE_STYLE_APP_PREVIEW_DIR = '/api/media/cdn/site-styles';
35
43
  /** The width and height every style picture is drawn at. */ export const SITE_STYLE_PREVIEW_SIZE = {
36
44
  width: 800,
37
45
  height: 800
@@ -72,6 +80,9 @@ const style = (id, name, blurb, alt)=>({
72
80
  * something can pick for them (the AI start); the starter site has no such
73
81
  * card, so a site created with the starter always names a real style.
74
82
  */ export const SITE_STYLE_AUTO = 'auto';
83
+ /** A style's picture as an app reads it: see {@link SITE_STYLE_APP_PREVIEW_DIR}. */ export function siteStyleAppPreview(id) {
84
+ return `${SITE_STYLE_APP_PREVIEW_DIR}/${id}.webp`;
85
+ }
75
86
  /** Whether a value names one of the {@link SITE_STYLES}. */ export function isSiteStyleId(value) {
76
87
  return typeof value === 'string' && SITE_STYLES.some((entry)=>entry.id === value);
77
88
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-styles.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The styles a new site can start in (AGL-4049), and the record of which one\n * a site was created with.\n *\n * Nothing in \"Create site\" is chosen for a person: a site is created only\n * once they have picked a style. A style is a kind of site's look — the same\n * 21 the AI start's Style step offers, each with an example home page as its\n * picture — so the starter site and the AI start speak one vocabulary.\n *\n * This module is the LIST: what a person may choose on any surface, the\n * native apps included (the derived-values generator emits it). The LOOK a\n * style gives a site is the AI plugin's, behind the `core.site-style-looks`\n * seam (`plugin-manager/plugin-site-style-looks.ts`); with no plugin\n * answering, a site still starts in the default theme and the choice is\n * still recorded. The AI plugin's own kinds are held to this list, id for id\n * and in order, by `ai-site-kinds.spec.ts`.\n *\n * Pure data and readers, safe for any surface to import.\n */\n\n/** Where the console serves each style's picture: `<dir>/<id>.webp`. */\nexport const SITE_STYLE_PREVIEW_DIR = '/_static/starter/styles'\n\n/** The width and height every style picture is drawn at. */\nexport const SITE_STYLE_PREVIEW_SIZE = { width: 800, height: 800 } as const\n\n/** One style a site can start in. */\nexport interface SiteStyle {\n /** A persisted identifier: the AI start's kind id, stored on the site. */\n id: string\n /** The card's title. */\n name: string\n /** One line under it. */\n blurb: string\n /** The example home page's picture, as a path on the console's origin. */\n preview: string\n /** What the picture shows, for a reader who cannot see it. */\n alt: string\n}\n\nconst style = (id: string, name: string, blurb: string, alt: string): SiteStyle => ({\n id,\n name,\n blurb,\n preview: `${SITE_STYLE_PREVIEW_DIR}/${id}.webp`,\n alt,\n})\n\n/** Every style, in the order a person is shown them. */\nexport const SITE_STYLES: readonly SiteStyle[] = [\n style('business', 'Business & services', 'Say what you do, why choose you, and how to reach you', \"A cleaning company's home page: its heading beside a photo of gloved hands wiping a desk, then its services as cards\"),\n style('trades', 'Home services & trades', 'Roofers, plumbers, towing, landscaping: bold, direct, built on trust', \"A roofer's home page: a bold heading over a full-width photo of a roofer carrying shingles, then roofing services\"),\n style('professional', 'Law, finance & consulting', 'Law firms, accountants, advisers: calm, established, credible', \"A consulting firm's home page: its heading on a white card over a full-width photo of a team at a planning board\"),\n style('wellness', 'Health & wellness', 'Therapists, clinics, dentists, coaches: warm, reassuring, clear', \"A therapy practice's home page: half the page a photo of a calm, sunlit room, its heading in the other half, then its sessions\"),\n style('restaurant', 'Restaurant & café', 'Warm, photo-led pages for food, drink and a place to visit', \"A café's home page: its heading centered over a photo of the owner at the counter, then menu highlights\"),\n style('store', 'Online store', 'Product-first pages for things you sell', \"A handmade goods shop's home page: its heading beside two overlapping photos of wax seals, then featured products\"),\n style('portfolio', 'Portfolio', 'Minimal, image-led pages that put the work first', \"A prop stylist's home page: a large heading over a grid of three styled sets\"),\n style('studio', 'Design studio & agency', 'Bold type and case studies for creative teams', \"A design studio's home page: an oversized heading on black over a wide photo of the team at a brand board\"),\n style('photography', 'Photography', 'Galleries first, words second', \"A photographer's home page: its heading on black over a gallery of a wedding, a portrait and a maker\"),\n style('blog', 'Blog & writing', 'Reading-first pages with a calm serif voice', \"A food journal's home page: its heading centered in a narrow column over a wide photo of vegetables on a cutting board\"),\n style('events', 'Events & weddings', 'Dates, places and the details guests need', \"A festival's home page: two overlapping photos of a lantern-lit night market beside its dates, then the program\"),\n style('fitness', 'Fitness & sports', 'Gyms, trainers and studios with energy', \"A gym's home page: a bold heading on black beside a photo of rows of dumbbells, then this week's classes\"),\n style('yoga', 'Yoga & mindfulness', 'Calm, spacious pages for classes and retreats', \"A yoga studio's home page: a quiet centered heading over a wide photo of a class stretching on mats\"),\n style('beauty', 'Beauty & salon', 'Salons, barbers, spas and studios with style', \"A hair salon's home page: its heading beside two overlapping photos of a stylist at work and the salon's chairs\"),\n style('realestate', 'Real estate', 'Agents, brokers and property: polished and local', \"A real estate agent's home page: its heading on a white card over a photo of a white house, then new listings\"),\n style('education', 'Courses & education', 'Tutors, schools and courses, clear and encouraging', \"A tutoring center's home page: a photo of a tutor at the whiteboard beside its heading, then its courses\"),\n style('nonprofit', 'Nonprofit & community', 'A cause, its impact and how to help', \"A food bank's home page: its heading over a full-width photo of volunteers sorting donations, then the ways to help\"),\n style('music', 'Music & bands', 'Artists, bands and DJs, loud and visual', \"A band's home page: its name in large type over a photo of a band under stage lights, then its tour dates\"),\n style('personal', 'Personal & resume', 'A simple page about you and your work', \"A product manager's personal page: a round portrait over her centered introduction, then her experience\"),\n style('landing', 'Landing page', 'One page that leads to one action', \"A budgeting app's landing page: its pitch centered on a colored band over a photo of a couple planning on a phone\"),\n style('coming-soon', 'Coming soon', 'A placeholder that collects interest', \"A café's coming soon page: its heading and notify button centered over a photo of the café's coffee shelves\"),\n]\n\n/**\n * \"Pick for me\": the AI start's style card that lets the answers decide. It\n * is a card a person CLICKS, never a default, and it exists only where\n * something can pick for them (the AI start); the starter site has no such\n * card, so a site created with the starter always names a real style.\n */\nexport const SITE_STYLE_AUTO = 'auto'\n\n/** Whether a value names one of the {@link SITE_STYLES}. */\nexport function isSiteStyleId(value: unknown): value is string {\n return typeof value === 'string' && SITE_STYLES.some((entry) => entry.id === value)\n}\n\n/** The style an id names, or `null`. */\nexport function siteStyleOf(id: unknown): SiteStyle | null {\n return SITE_STYLES.find((entry) => entry.id === id) ?? null\n}\n\n// ── What a site was created with ────────────────────────────────────────────\n\n/**\n * How a site was started: the starter site (`starter`), the AI start (`ai`),\n * a site brought in from somewhere else (`import`), or a program through the\n * public API (`api`), which keeps the default and chooses no style.\n */\nexport type HostStarterStart = 'starter' | 'ai' | 'import' | 'api'\n\nexport const HOST_STARTER_STARTS: readonly HostStarterStart[] = ['starter', 'ai', 'import', 'api']\n\n/**\n * `hosts/{id}.starterChoice` (AGL-4049): what a site was created with, written\n * by the server in the create's own transaction and never by a client, so\n * which styles people choose can be counted, and a site created and then left\n * alone can be told apart from one that was built on.\n *\n * - `kind`: the style id; {@link SITE_STYLE_AUTO} when the AI start's \"Pick\n * for me\" was chosen; `null` when none was (the API, a seed);\n * - `listingId` / `version`: the marketplace starter picked, or `null`;\n * - `mode`: `base` copies a starter's pages, `ai` writes them for the business.\n */\nexport interface HostStarterChoice {\n listingId: string | null\n version: string | null\n kind: string | null\n mode: 'base' | 'ai'\n start: HostStarterStart\n}\n\n/** A choice with its unset parts filled: no listing, no style, `base`. */\nexport function hostStarterChoice(input: Partial<HostStarterChoice> & { start: HostStarterStart }): HostStarterChoice {\n return {\n listingId: input.listingId ?? null,\n version: input.version == null ? null : String(input.version),\n kind: input.kind ?? null,\n mode: input.mode === 'ai' ? 'ai' : 'base',\n start: input.start,\n }\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\n\n/** A stored or answered choice, read defensively; `null` when it is not one. */\nexport function readHostStarterChoice(value: unknown): HostStarterChoice | null {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null\n const record = value as Record<string, unknown>\n const start = record['start']\n if (!(HOST_STARTER_STARTS as readonly unknown[]).includes(start)) return null\n return hostStarterChoice({\n listingId: textOrNull(record['listingId']),\n version: textOrNull(record['version']),\n kind: textOrNull(record['kind']),\n mode: record['mode'] === 'ai' ? 'ai' : 'base',\n start: start as HostStarterStart,\n })\n}\n\n/**\n * The `host_created` event's parameters for a site's choice: how it was\n * started (`unknown` when the create's answer did not say), its style\n * (`auto` for \"Pick for me\", `none` for no style) and the starter listing\n * (`none` for none). Ids only, never a name a person typed.\n */\nexport function hostCreatedEventParams(choice: HostStarterChoice | null): {\n start: string\n starter_kind: string\n starter_listing: string\n} {\n return {\n start: choice?.start ?? 'unknown',\n starter_kind: choice?.kind ?? 'none',\n starter_listing: choice?.listingId ?? 'none',\n }\n}\n"],"names":["SITE_STYLE_PREVIEW_DIR","SITE_STYLE_PREVIEW_SIZE","width","height","style","id","name","blurb","alt","preview","SITE_STYLES","SITE_STYLE_AUTO","isSiteStyleId","value","some","entry","siteStyleOf","find","HOST_STARTER_STARTS","hostStarterChoice","input","listingId","version","String","kind","mode","start","textOrNull","trim","readHostStarterChoice","Array","isArray","record","includes","hostCreatedEventParams","choice","starter_kind","starter_listing"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;CAkBC,GAED,sEAAsE,GACtE,OAAO,MAAMA,yBAAyB,0BAAyB;AAE/D,0DAA0D,G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xBU,YAAY,WAAED,0BAAAA,OAAQX,IAAI,oBAAI;QAC9Ba,eAAe,WAAEF,0BAAAA,OAAQd,SAAS,oBAAI;IACxC;AACF"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/site-styles.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * The styles a new site can start in (AGL-4049), and the record of which one\n * a site was created with.\n *\n * Nothing in \"Create site\" is chosen for a person: a site is created only\n * once they have picked a style. A style is a kind of site's look — the same\n * 21 the AI start's Style step offers, each with an example home page as its\n * picture — so the starter site and the AI start speak one vocabulary.\n *\n * This module is the LIST: what a person may choose on any surface, the\n * native apps included (the derived-values generator emits it). The LOOK a\n * style gives a site is the AI plugin's, behind the `core.site-style-looks`\n * seam (`plugin-manager/plugin-site-style-looks.ts`); with no plugin\n * answering, a site still starts in the default theme and the choice is\n * still recorded. The AI plugin's own kinds are held to this list, id for id\n * and in order, by `ai-site-kinds.spec.ts`.\n *\n * Pure data and readers, safe for any surface to import.\n */\n\n/** Where the console serves each style's picture: `<dir>/<id>.webp`. */\nexport const SITE_STYLE_PREVIEW_DIR = '/_static/starter/styles'\n\n/**\n * Where an app reads the same pictures. The console's bot protection answers\n * `/_static` with a challenge a browser solves and URLSession and OkHttp\n * cannot, so a picture fetched from there never loads in the native apps; the\n * public media path has that challenge lifted for every caller. `next.config.js`\n * rewrites this directory onto {@link SITE_STYLE_PREVIEW_DIR}, one file for one\n * file, and `site-style-app-pictures.spec.ts` holds the two together.\n */\nexport const SITE_STYLE_APP_PREVIEW_DIR = '/api/media/cdn/site-styles'\n\n/** The width and height every style picture is drawn at. */\nexport const SITE_STYLE_PREVIEW_SIZE = { width: 800, height: 800 } as const\n\n/** One style a site can start in. */\nexport interface SiteStyle {\n /** A persisted identifier: the AI start's kind id, stored on the site. */\n id: string\n /** The card's title. */\n name: string\n /** One line under it. */\n blurb: string\n /** The example home page's picture, as a path on the console's origin. */\n preview: string\n /** What the picture shows, for a reader who cannot see it. */\n alt: string\n}\n\nconst style = (id: string, name: string, blurb: string, alt: string): SiteStyle => ({\n id,\n name,\n blurb,\n preview: `${SITE_STYLE_PREVIEW_DIR}/${id}.webp`,\n alt,\n})\n\n/** Every style, in the order a person is shown them. */\nexport const SITE_STYLES: readonly SiteStyle[] = [\n style('business', 'Business & services', 'Say what you do, why choose you, and how to reach you', \"A cleaning company's home page: its heading beside a photo of gloved hands wiping a desk, then its services as cards\"),\n style('trades', 'Home services & trades', 'Roofers, plumbers, towing, landscaping: bold, direct, built on trust', \"A roofer's home page: a bold heading over a full-width photo of a roofer carrying shingles, then roofing services\"),\n style('professional', 'Law, finance & consulting', 'Law firms, accountants, advisers: calm, established, credible', \"A consulting firm's home page: its heading on a white card over a full-width photo of a team at a planning board\"),\n style('wellness', 'Health & wellness', 'Therapists, clinics, dentists, coaches: warm, reassuring, clear', \"A therapy practice's home page: half the page a photo of a calm, sunlit room, its heading in the other half, then its sessions\"),\n style('restaurant', 'Restaurant & café', 'Warm, photo-led pages for food, drink and a place to visit', \"A café's home page: its heading centered over a photo of the owner at the counter, then menu highlights\"),\n style('store', 'Online store', 'Product-first pages for things you sell', \"A handmade goods shop's home page: its heading beside two overlapping photos of wax seals, then featured products\"),\n style('portfolio', 'Portfolio', 'Minimal, image-led pages that put the work first', \"A prop stylist's home page: a large heading over a grid of three styled sets\"),\n style('studio', 'Design studio & agency', 'Bold type and case studies for creative teams', \"A design studio's home page: an oversized heading on black over a wide photo of the team at a brand board\"),\n style('photography', 'Photography', 'Galleries first, words second', \"A photographer's home page: its heading on black over a gallery of a wedding, a portrait and a maker\"),\n style('blog', 'Blog & writing', 'Reading-first pages with a calm serif voice', \"A food journal's home page: its heading centered in a narrow column over a wide photo of vegetables on a cutting board\"),\n style('events', 'Events & weddings', 'Dates, places and the details guests need', \"A festival's home page: two overlapping photos of a lantern-lit night market beside its dates, then the program\"),\n style('fitness', 'Fitness & sports', 'Gyms, trainers and studios with energy', \"A gym's home page: a bold heading on black beside a photo of rows of dumbbells, then this week's classes\"),\n style('yoga', 'Yoga & mindfulness', 'Calm, spacious pages for classes and retreats', \"A yoga studio's home page: a quiet centered heading over a wide photo of a class stretching on mats\"),\n style('beauty', 'Beauty & salon', 'Salons, barbers, spas and studios with style', \"A hair salon's home page: its heading beside two overlapping photos of a stylist at work and the salon's chairs\"),\n style('realestate', 'Real estate', 'Agents, brokers and property: polished and local', \"A real estate agent's home page: its heading on a white card over a photo of a white house, then new listings\"),\n style('education', 'Courses & education', 'Tutors, schools and courses, clear and encouraging', \"A tutoring center's home page: a photo of a tutor at the whiteboard beside its heading, then its courses\"),\n style('nonprofit', 'Nonprofit & community', 'A cause, its impact and how to help', \"A food bank's home page: its heading over a full-width photo of volunteers sorting donations, then the ways to help\"),\n style('music', 'Music & bands', 'Artists, bands and DJs, loud and visual', \"A band's home page: its name in large type over a photo of a band under stage lights, then its tour dates\"),\n style('personal', 'Personal & resume', 'A simple page about you and your work', \"A product manager's personal page: a round portrait over her centered introduction, then her experience\"),\n style('landing', 'Landing page', 'One page that leads to one action', \"A budgeting app's landing page: its pitch centered on a colored band over a photo of a couple planning on a phone\"),\n style('coming-soon', 'Coming soon', 'A placeholder that collects interest', \"A café's coming soon page: its heading and notify button centered over a photo of the café's coffee shelves\"),\n]\n\n/**\n * \"Pick for me\": the AI start's style card that lets the answers decide. It\n * is a card a person CLICKS, never a default, and it exists only where\n * something can pick for them (the AI start); the starter site has no such\n * card, so a site created with the starter always names a real style.\n */\nexport const SITE_STYLE_AUTO = 'auto'\n\n/** A style's picture as an app reads it: see {@link SITE_STYLE_APP_PREVIEW_DIR}. */\nexport function siteStyleAppPreview(id: string): string {\n return `${SITE_STYLE_APP_PREVIEW_DIR}/${id}.webp`\n}\n\n/** Whether a value names one of the {@link SITE_STYLES}. */\nexport function isSiteStyleId(value: unknown): value is string {\n return typeof value === 'string' && SITE_STYLES.some((entry) => entry.id === value)\n}\n\n/** The style an id names, or `null`. */\nexport function siteStyleOf(id: unknown): SiteStyle | null {\n return SITE_STYLES.find((entry) => entry.id === id) ?? null\n}\n\n// ── What a site was created with ────────────────────────────────────────────\n\n/**\n * How a site was started: the starter site (`starter`), the AI start (`ai`),\n * a site brought in from somewhere else (`import`), or a program through the\n * public API (`api`), which keeps the default and chooses no style.\n */\nexport type HostStarterStart = 'starter' | 'ai' | 'import' | 'api'\n\nexport const HOST_STARTER_STARTS: readonly HostStarterStart[] = ['starter', 'ai', 'import', 'api']\n\n/**\n * `hosts/{id}.starterChoice` (AGL-4049): what a site was created with, written\n * by the server in the create's own transaction and never by a client, so\n * which styles people choose can be counted, and a site created and then left\n * alone can be told apart from one that was built on.\n *\n * - `kind`: the style id; {@link SITE_STYLE_AUTO} when the AI start's \"Pick\n * for me\" was chosen; `null` when none was (the API, a seed);\n * - `listingId` / `version`: the marketplace starter picked, or `null`;\n * - `mode`: `base` copies a starter's pages, `ai` writes them for the business.\n */\nexport interface HostStarterChoice {\n listingId: string | null\n version: string | null\n kind: string | null\n mode: 'base' | 'ai'\n start: HostStarterStart\n}\n\n/** A choice with its unset parts filled: no listing, no style, `base`. */\nexport function hostStarterChoice(input: Partial<HostStarterChoice> & { start: HostStarterStart }): HostStarterChoice {\n return {\n listingId: input.listingId ?? null,\n version: input.version == null ? null : String(input.version),\n kind: input.kind ?? null,\n mode: input.mode === 'ai' ? 'ai' : 'base',\n start: input.start,\n }\n}\n\nconst textOrNull = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\n\n/** A stored or answered choice, read defensively; `null` when it is not one. */\nexport function readHostStarterChoice(value: unknown): HostStarterChoice | null {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null\n const record = value as Record<string, unknown>\n const start = record['start']\n if (!(HOST_STARTER_STARTS as readonly unknown[]).includes(start)) return null\n return hostStarterChoice({\n listingId: textOrNull(record['listingId']),\n version: textOrNull(record['version']),\n kind: textOrNull(record['kind']),\n mode: record['mode'] === 'ai' ? 'ai' : 'base',\n start: start as HostStarterStart,\n })\n}\n\n/**\n * The `host_created` event's parameters for a site's choice: how it was\n * started (`unknown` when the create's answer did not say), its style\n * (`auto` for \"Pick for me\", `none` for no style) and the starter listing\n * (`none` for none). Ids only, never a name a person typed.\n */\nexport function hostCreatedEventParams(choice: HostStarterChoice | null): {\n start: string\n starter_kind: string\n starter_listing: string\n} {\n return {\n start: choice?.start ?? 'unknown',\n starter_kind: choice?.kind ?? 'none',\n starter_listing: choice?.listingId ?? 'none',\n }\n}\n"],"names":["SITE_STYLE_PREVIEW_DIR","SITE_STYLE_APP_PREVIEW_DIR","SITE_STYLE_PREVIEW_SIZE","width","height","style","id","name","blurb","alt","preview","SITE_STYLES","SITE_STYLE_AUTO","siteStyleAppPreview","isSiteStyleId","value","some","entry","siteStyleOf","find","HOST_STARTER_STARTS","hostStarterChoice","input","listingId","version","String","kind","mode","start","textOrNull","trim","readHostStarterChoice","Array","isArray","record","includes","hostCreatedEventParams","choice","starter_kind","starter_listing"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;CAkBC,GAED,sEAAsE,GACtE,OAAO,MAAMA,yBAAyB,0BAAyB;AAE/D;;;;;;;CAOC,GACD,OAAO,MAAMC,6BAA6B,6BAA4B;AAEtE,0DAA0D,GAC1D,OAAO,MAAMC,0BAA0B;IAAEC,OAAO;IAAKC,QAAQ;AAAI,EAAU;AAgB3E,MAAMC,QAAQ,CAACC,IAAYC,MAAcC,OAAeC,MAA4B,CAAA;QAClFH;QACAC;QACAC;QACAE,SAAS,GAAGV,uBAAuB,CAAC,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,0BAAAA,OAAQd,SAAS,oBAAI;IACxC;AACF"}
@@ -28,8 +28,10 @@
28
28
  * The body still comes from the ISR-cached catch-all, exactly as before; only
29
29
  * the tenant middleware can set the status, because an App Router page has no
30
30
  * status lever and the middleware is the one layer that runs ahead of the
31
- * cache on every request. It asks {@link siteUnavailableForRequest} and
32
- * rewrites with the status, so a cached page body never decides it.
31
+ * cache on every request. It asks {@link siteUnavailableForRequest}, reads the
32
+ * page, and sends it as a 503, so a cached page body never decides the status.
33
+ * Why it reads the page rather than putting the status on its rewrite is the
34
+ * note beside that code: on Vercel that rewrite loses the page.
33
35
  *
34
36
  * DEPENDENCY-FREE ON PURPOSE, like `site-preview.ts`: the middleware runs on
35
37
  * the edge and deep-imports this leaf, so it imports nothing.
@@ -47,6 +49,20 @@
47
49
  * visits re-reading "not yet".
48
50
  */
49
51
  export declare const SITE_UNAVAILABLE_RETRY_AFTER_SECONDS = 3600;
52
+ /**
53
+ * Marks the middleware's own read of the notice page, which comes back through
54
+ * the middleware and must take the plain rewrite rather than read it again.
55
+ *
56
+ * Not a secret, and nothing is withheld behind it: a stranger who sends it gets
57
+ * the same notice with a 200.
58
+ */
59
+ export declare const SITE_NOTICE_REQUEST_HEADER = "x-aglyn-site-notice";
60
+ /**
61
+ * How long a visitor waits on that read, in milliseconds, before being served
62
+ * the plain rewrite. Generous, as the verdict's deadline is: a cold render
63
+ * answers inside it, and the page still arrives if it does not.
64
+ */
65
+ export declare const SITE_NOTICE_DEADLINE_MS = 8000;
50
66
  /**
51
67
  * Is the site in maintenance mode (AGL-131)?
52
68
  *
@@ -73,6 +89,8 @@ export interface SiteUnavailableRouting {
73
89
  * route, which shows the team the site.
74
90
  */
75
91
  teamPreview: boolean;
92
+ /** The middleware's own read of the notice page, not a visitor. */
93
+ noticeRequest?: boolean;
76
94
  }
77
95
  /**
78
96
  * Does this page request get the site's 503 answer as an HTTP 503?
@@ -88,6 +106,8 @@ export interface SiteUnavailableRouting {
88
106
  * 503 set here would only argue with that redirect.
89
107
  * - **One page in preview: no.** The public gets the site's 404 there, and the
90
108
  * render's own 404 decides that status.
109
+ * - **The middleware's own read of the page: no.** That is how the body of the
110
+ * 503 is fetched, and it would otherwise fetch itself.
91
111
  *
92
112
  * Nothing here is a permission. The body is the loader's decision, and a
93
113
  * request this answers `false` for is one whose body is already the site, or
@@ -27,8 +27,10 @@
27
27
  * The body still comes from the ISR-cached catch-all, exactly as before; only
28
28
  * the tenant middleware can set the status, because an App Router page has no
29
29
  * status lever and the middleware is the one layer that runs ahead of the
30
- * cache on every request. It asks {@link siteUnavailableForRequest} and
31
- * rewrites with the status, so a cached page body never decides it.
30
+ * cache on every request. It asks {@link siteUnavailableForRequest}, reads the
31
+ * page, and sends it as a 503, so a cached page body never decides the status.
32
+ * Why it reads the page rather than putting the status on its rewrite is the
33
+ * note beside that code: on Vercel that rewrite loses the page.
32
34
  *
33
35
  * DEPENDENCY-FREE ON PURPOSE, like `site-preview.ts`: the middleware runs on
34
36
  * the edge and deep-imports this leaf, so it imports nothing.
@@ -44,6 +46,18 @@
44
46
  * recoverable direction, and long enough that a crawler does not spend its
45
47
  * visits re-reading "not yet".
46
48
  */ export const SITE_UNAVAILABLE_RETRY_AFTER_SECONDS = 3600;
49
+ /**
50
+ * Marks the middleware's own read of the notice page, which comes back through
51
+ * the middleware and must take the plain rewrite rather than read it again.
52
+ *
53
+ * Not a secret, and nothing is withheld behind it: a stranger who sends it gets
54
+ * the same notice with a 200.
55
+ */ export const SITE_NOTICE_REQUEST_HEADER = 'x-aglyn-site-notice';
56
+ /**
57
+ * How long a visitor waits on that read, in milliseconds, before being served
58
+ * the plain rewrite. Generous, as the verdict's deadline is: a cold render
59
+ * answers inside it, and the page still arrives if it does not.
60
+ */ export const SITE_NOTICE_DEADLINE_MS = 8000;
47
61
  /**
48
62
  * Is the site in maintenance mode (AGL-131)?
49
63
  *
@@ -67,12 +81,14 @@
67
81
  * 503 set here would only argue with that redirect.
68
82
  * - **One page in preview: no.** The public gets the site's 404 there, and the
69
83
  * render's own 404 decides that status.
84
+ * - **The middleware's own read of the page: no.** That is how the body of the
85
+ * 503 is fetched, and it would otherwise fetch itself.
70
86
  *
71
87
  * Nothing here is a permission. The body is the loader's decision, and a
72
88
  * request this answers `false` for is one whose body is already the site, or
73
89
  * an answer with a status of its own.
74
90
  */ export function siteUnavailableForRequest(verdict, routing) {
75
- if (!verdict || routing.entryPreview) return false;
91
+ if (!verdict || routing.entryPreview || routing.noticeRequest) return false;
76
92
  if (verdict.maintenance === true) return true;
77
93
  return verdict.preview === true && !routing.teamPreview;
78
94
  }