@bison-lab/payload-core 3.13.0 → 3.14.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 +23 -16
- package/dist/access-B3LglN2J.mjs +662 -0
- package/dist/access-B3LglN2J.mjs.map +1 -0
- package/dist/admin.d.mts +25 -5
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +443 -178
- package/dist/admin.mjs.map +1 -1
- package/dist/{identity-LAzSeorC.mjs → identity-Dwyq8519.mjs} +1 -1
- package/dist/{identity-LAzSeorC.mjs.map → identity-Dwyq8519.mjs.map} +1 -1
- package/dist/index.d.mts +73 -46
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +55 -557
- package/dist/index.mjs.map +1 -1
- package/dist/{looks-C6kTjvk3.d.mts → looks-Xs6v5vYU.d.mts} +1 -1
- package/dist/{looks-C6kTjvk3.d.mts.map → looks-Xs6v5vYU.d.mts.map} +1 -1
- package/dist/metadata.d.mts +1 -1
- package/dist/metadata.mjs +1 -1
- package/dist/{share-image-C4ILz4p2.mjs → share-image-BlFAJLnd.mjs} +1 -1
- package/dist/{share-image-C4ILz4p2.mjs.map → share-image-BlFAJLnd.mjs.map} +1 -1
- package/dist/theme.d.mts +1 -1
- package/dist/theme.mjs +1 -1
- package/dist/{title-B2-gWQZd.d.mts → title-sWwcCqHT.d.mts} +1 -1
- package/dist/{title-B2-gWQZd.d.mts.map → title-sWwcCqHT.d.mts.map} +1 -1
- package/package.json +3 -3
|
@@ -426,4 +426,4 @@ function resolveThemeIdentity(doc, fallback) {
|
|
|
426
426
|
//#endregion
|
|
427
427
|
export { THEME_FONT_FIELD as A, validateThemeHex as C, THEME_COLOR_SCALE_FIELD as D, THEME_COLOR_FIELD as E, THEME_PUBLISH_FIELD as F, THEME_SAVE_BUTTON as I, THEME_SECTION_HEADING as L, THEME_IDENTITY_FALLBACK as M, THEME_LIBRARY_FIELD as N, THEME_CONTRAST_REPORT as O, THEME_PAIRING_FIELD as P, headingSelectValue as R, validateSourceIncluded as S, THEME_APPEARANCE_FIELD as T, THEME_SLUG as _, pageEditorLooks as a, stateFromColorDoc as b, findColorTokens as c, rewriteColorToken as d, themeColorKeys as f, THEME_IDENTITY_SLUG as g, THEME_COLORS_SLUG as h, PAGE_EDITOR_SYSTEM_KEYS as i, THEME_GREY_SCALE_FIELD as j, THEME_DOCUMENT_CONTROLS as k, rewriteColorTokens as l, THEME_APPEARANCE_SLUG as m, colorTokenField as n, pageEditorTokens as o, SYSTEM_COLOR_KEYS as p, lookField as r, themeLibraryFromDoc as s, resolveThemeIdentity as t, deleteLibraryColor as u, THEME_TYPOGRAPHY_SLUG as v, LOOK_FIELD as w, themeConfigFromDoc as x, docFromConfig as y };
|
|
428
428
|
|
|
429
|
-
//# sourceMappingURL=identity-
|
|
429
|
+
//# sourceMappingURL=identity-Dwyq8519.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-LAzSeorC.mjs","names":[],"sources":["../src/theme/fields.ts","../src/theme/map.ts","../src/theme/types.ts","../src/theme/library.ts","../src/theme/color-tokens.ts","../src/theme/looks.ts","../src/theme/look-field.ts","../src/theme/identity.ts"],"sourcesContent":["import type { ThemeConfig } from \"@bison-lab/tokens\";\n\nimport type { EditableTheme } from \"./types\";\n\nexport const THEME_COLOR_FIELD = \"@bison-lab/payload-core/admin#ColorField\";\nexport const THEME_COLOR_SCALE_FIELD = \"@bison-lab/payload-core/admin#ColorScaleField\";\nexport const THEME_LIBRARY_FIELD = \"@bison-lab/payload-core/admin#LibraryField\";\nexport const THEME_FONT_FIELD = \"@bison-lab/payload-core/admin#FontField\";\nexport const THEME_PAIRING_FIELD = \"@bison-lab/payload-core/admin#PairingField\";\nexport const THEME_APPEARANCE_FIELD = \"@bison-lab/payload-core/admin#AppearanceField\";\nexport const THEME_GREY_SCALE_FIELD = \"@bison-lab/payload-core/admin#GreyScaleField\";\nexport const THEME_CONTRAST_REPORT = \"@bison-lab/payload-core/admin#ContrastReport\";\nexport const THEME_SECTION_HEADING = \"@bison-lab/payload-core/admin#SectionHeading\";\nexport const THEME_PUBLISH_FIELD = \"@bison-lab/payload-core/admin#PublishChild\";\nexport const THEME_SAVE_BUTTON = \"@bison-lab/payload-core/admin#HiddenSaveButton\";\nexport const THEME_DOCUMENT_CONTROLS = \"@bison-lab/payload-core/admin#ThemeDocumentControls\";\nexport const THEME_IDENTITY_FALLBACK = \"@bison-lab/payload-core/admin#IdentityFallback\";\nexport const LOOK_FIELD = \"@bison-lab/payload-core/admin#LookField\";\n\n/**\n * Document path for each editable `ThemeConfig` key. Locked with `satisfies`\n * so a new config field without a Theme field (or the reverse) fails at\n * compile time. `darkSelector` and `fontWeights` are seed-only.\n */\nexport const THEME_FIELD_PATHS = {\n brandPrimary: \"colors.brand.primary.hex\",\n brandSecondary: \"colors.brand.secondary.hex\",\n brandAccent: \"colors.brand.accent.hex\",\n brandHighlight: \"colors.brand.highlight.hex\",\n brandSuccess: \"colors.brand.success.hex\",\n brandDestructive: \"colors.brand.destructive.hex\",\n greyScale: \"colors.greyScale\",\n defaultTheme: \"appearance.defaultTheme\",\n radius: \"appearance.radius\",\n shadow: \"appearance.shadow\",\n motion: \"appearance.motion\",\n density: \"appearance.density\",\n fontBody: \"typography.body\",\n fontHeading: \"typography.heading\",\n} as const satisfies Record<keyof EditableTheme, string>;\n\nexport type ThemeFieldPath = (typeof THEME_FIELD_PATHS)[keyof typeof THEME_FIELD_PATHS];\n\n/** Empty select value for heading: same family as body. */\nexport const SAME_AS_BODY = \"\";\n\nexport function headingSelectValue(heading: ThemeConfig[\"fontHeading\"]): string {\n return heading ?? SAME_AS_BODY;\n}\n","import {\n createColorScale,\n DESTRUCTIVE_SCALE_HEX,\n generateColorScale,\n isThemeHex,\n SHADE_STEPS,\n type ColorScale,\n type ColorScaleInclude,\n type ColorScaleState,\n type ShadeStep,\n type ThemeConfig,\n} from \"@bison-lab/tokens\";\n\nimport { SAME_AS_BODY } from \"./fields\";\nimport type { ThemeColorDoc, ThemeDoc } from \"./types\";\n\nfunction pick<T>(value: T | null | undefined, fallback: T): T {\n return value == null ? fallback : value;\n}\n\nfunction headingFromDoc(\n heading: string | null | undefined,\n seed: ThemeConfig[\"fontHeading\"],\n): string | null {\n if (heading === undefined) return seed;\n if (heading === null || heading === SAME_AS_BODY) return null;\n return heading;\n}\n\nfunction hexFromColor(value: ThemeColorDoc | string | null | undefined, fallback: string): string {\n if (typeof value === \"string\") return value || fallback;\n return pick(value?.hex, fallback);\n}\n\nexport function colorDocFromHex(hex: string, sourceStep: ShadeStep = 500): ThemeColorDoc {\n return colorDocFromState(createColorScale(hex, sourceStep));\n}\n\nexport function colorDocFromState(state: ColorScaleState): ThemeColorDoc {\n return {\n hex: state.hex,\n sourceStep: state.sourceStep,\n scale: state.scale,\n stale: state.stale,\n include: Array.isArray(state.include) ? \"custom\" : state.include,\n includedSteps: Array.isArray(state.include) ? [...state.include] : undefined,\n };\n}\n\nexport function stateFromColorDoc(\n doc: ThemeColorDoc | null | undefined,\n fallbackHex = \"#000000\",\n): ColorScaleState {\n const hex = isThemeHex(doc?.hex) ? doc.hex : fallbackHex;\n const sourceStep = (Number(doc?.sourceStep) || 500) as ShadeStep;\n const include = includeFromDoc(doc, sourceStep);\n const scale =\n doc?.scale && typeof doc.scale === \"object\" ? (doc.scale as ColorScale) : generateColorScale(hex, sourceStep);\n return { hex, sourceStep, scale, stale: Boolean(doc?.stale), include };\n}\n\nfunction includeFromDoc(doc: ThemeColorDoc | null | undefined, sourceStep: ShadeStep): ColorScaleInclude {\n if (doc?.include === \"source\") return \"source\";\n if (doc?.include === \"custom\" && Array.isArray(doc.includedSteps)) {\n const steps = doc.includedSteps.map(Number).filter((step): step is ShadeStep => SHADE_STEPS.includes(step as ShadeStep));\n if (!steps.includes(sourceStep)) steps.push(sourceStep);\n return steps;\n }\n return \"all\";\n}\n\n/**\n * Nested Theme document → flat `ThemeConfig`. Null or missing editor\n * fields take the seed; `darkSelector` and `fontWeights` always come from\n * the seed. Reads the BIS-87 groups and the pre-BIS-87 flat fields.\n */\nexport function themeConfigFromDoc(doc: ThemeDoc | null | undefined, seed: ThemeConfig): ThemeConfig {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const typography = doc?.typography ?? doc?.fonts;\n const appearance = doc?.appearance;\n return {\n brandPrimary: hexFromColor(brand?.primary, seed.brandPrimary),\n brandSecondary: hexFromColor(brand?.secondary, seed.brandSecondary),\n brandAccent: hexFromColor(brand?.accent, seed.brandAccent),\n brandHighlight: hexFromColor(brand?.highlight, seed.brandHighlight),\n brandSuccess: hexFromColor(brand?.success, seed.brandSuccess),\n brandDestructive:\n hexFromColor(brand?.destructive, seed.brandDestructive ?? DESTRUCTIVE_SCALE_HEX) ||\n seed.brandDestructive ||\n DESTRUCTIVE_SCALE_HEX,\n greyScale: pick(doc?.colors?.greyScale ?? doc?.greyScale, seed.greyScale),\n radius: pick(appearance?.radius ?? doc?.radius, seed.radius),\n shadow: pick(appearance?.shadow ?? doc?.shadow, seed.shadow),\n motion: pick(appearance?.motion ?? doc?.motion, seed.motion),\n density: pick(appearance?.density ?? doc?.density, seed.density),\n defaultTheme: pick(appearance?.defaultTheme ?? doc?.defaultTheme, seed.defaultTheme),\n fontBody: pick(typography?.body, seed.fontBody),\n fontHeading: headingFromDoc(typography?.heading, seed.fontHeading),\n darkSelector: seed.darkSelector,\n fontWeights: seed.fontWeights,\n };\n}\n\n/** The document `seedTheme` writes so a fresh Global matches the seed config. */\nexport function docFromConfig(config: ThemeConfig, destructive?: string): ThemeDoc {\n const destructiveHex = destructive ?? config.brandDestructive ?? DESTRUCTIVE_SCALE_HEX;\n return {\n colors: {\n brand: {\n primary: colorDocFromHex(config.brandPrimary),\n secondary: colorDocFromHex(config.brandSecondary),\n accent: colorDocFromHex(config.brandAccent),\n highlight: colorDocFromHex(config.brandHighlight),\n success: colorDocFromHex(config.brandSuccess),\n destructive: colorDocFromHex(destructiveHex),\n },\n library: [],\n greyScale: config.greyScale,\n },\n typography: {\n body: config.fontBody,\n heading: config.fontHeading,\n },\n appearance: {\n defaultTheme: config.defaultTheme,\n radius: config.radius,\n shadow: config.shadow,\n motion: config.motion,\n density: config.density,\n },\n };\n}\n\nexport function validateThemeHex(value: unknown): true | string {\n if (!isThemeHex(value)) return \"Enter a six-digit hex colour like #1e3a5f\";\n return true;\n}\n\nexport function validateSourceIncluded(\n value: unknown,\n { siblingData }: { siblingData?: { sourceStep?: unknown; include?: unknown } },\n): true | string {\n const include = siblingData?.include;\n if (include === \"all\" || include === \"source\") return true;\n const source = Number(siblingData?.sourceStep);\n const steps = Array.isArray(value) ? value.map(Number) : [];\n if (!SHADE_STEPS.includes(source as ShadeStep)) return true;\n if (!steps.includes(source)) return \"The source step cannot be excluded\";\n return true;\n}\n","import type { Access } from \"payload\";\nimport type { FontEntry } from \"@bison-lab/fonts\";\nimport type { ColorScale, ColorScaleInclude, ShadeStep, ThemeConfig } from \"@bison-lab/tokens\";\n\nimport type { ResolvedThemeIdentity, ThemeIdentityFallback } from \"./identity\";\n\n/**\n * The Theme document a site's generated types will describe. Optional and\n * nullable, no index signature: a generated Global is assignable to this,\n * never the reverse.\n *\n * Legacy flat `brand.*` hexes, `fonts`, and preset fields at the root stay\n * readable so `getPublishedTheme` still maps a pre-BIS-87 row.\n */\nexport interface ThemeColorDoc {\n hex?: string | null;\n sourceStep?: ShadeStep | string | null;\n scale?: ColorScale | null;\n stale?: boolean | null;\n include?: ColorScaleInclude | \"custom\" | null;\n includedSteps?: ShadeStep[] | string[] | null;\n}\n\nexport interface ThemeLibraryColorDoc extends ThemeColorDoc {\n key?: string | null;\n label?: string | null;\n}\n\nexport interface ThemeDoc {\n colors?: {\n brand?: {\n primary?: ThemeColorDoc | string | null;\n secondary?: ThemeColorDoc | string | null;\n accent?: ThemeColorDoc | string | null;\n highlight?: ThemeColorDoc | string | null;\n success?: ThemeColorDoc | string | null;\n destructive?: ThemeColorDoc | string | null;\n } | null;\n library?: ThemeLibraryColorDoc[] | null;\n greyScale?: ThemeConfig[\"greyScale\"] | null;\n } | null;\n typography?: {\n body?: string | null;\n heading?: string | null;\n } | null;\n appearance?: {\n defaultTheme?: ThemeConfig[\"defaultTheme\"] | null;\n radius?: ThemeConfig[\"radius\"] | null;\n shadow?: ThemeConfig[\"shadow\"] | null;\n motion?: ThemeConfig[\"motion\"] | null;\n density?: ThemeConfig[\"density\"] | null;\n } | null;\n /** @deprecated Pre-BIS-87 flat brand hexes. */\n brand?: {\n primary?: ThemeColorDoc | string | null;\n secondary?: ThemeColorDoc | string | null;\n accent?: ThemeColorDoc | string | null;\n highlight?: ThemeColorDoc | string | null;\n success?: ThemeColorDoc | string | null;\n destructive?: ThemeColorDoc | string | null;\n } | null;\n /** @deprecated Pre-BIS-87; now `colors.greyScale`. */\n greyScale?: ThemeConfig[\"greyScale\"] | null;\n /** @deprecated Pre-BIS-87; now `appearance.*`. */\n radius?: ThemeConfig[\"radius\"] | null;\n shadow?: ThemeConfig[\"shadow\"] | null;\n motion?: ThemeConfig[\"motion\"] | null;\n density?: ThemeConfig[\"density\"] | null;\n defaultTheme?: ThemeConfig[\"defaultTheme\"] | null;\n /** @deprecated Pre-BIS-87; now `typography`. */\n fonts?: {\n body?: string | null;\n heading?: string | null;\n } | null;\n logo?: number | string | ThemeUploadDoc | null;\n favicon?: number | string | ThemeUploadDoc | null;\n logoMark?: number | string | ThemeUploadDoc | null;\n}\n\nexport interface ThemeUploadDoc {\n id?: number | string | null;\n url?: string | null;\n alt?: string | null;\n}\n\n/**\n * What an editor can change. `darkSelector` and `fontWeights` stay on the\n * seed — they mean nothing in the admin — and `themeConfigFromDoc` puts\n * them back.\n */\nexport type EditableTheme = Omit<ThemeConfig, \"darkSelector\" | \"fontWeights\">;\n\nexport interface CreateThemeOptions {\n /**\n * Required, no default. Pass `canManageBrand` as `update` (and typically\n * `isAuthenticated` as `read`). Theme does not read the Roles Global.\n */\n access: { read: Access; update: Access };\n /** The site's `bison.config.json`. Every field's `defaultValue`, and the fallback `getPublishedTheme` returns. */\n seed: ThemeConfig;\n /**\n * Destructive seed hex. Falls back to `seed.brandDestructive`, then\n * the library's `DESTRUCTIVE_SCALE_HEX` (`#ef4444`).\n */\n destructive?: string;\n /** Default: the whole catalogue. */\n fonts?: readonly FontEntry[];\n /** Where the site's `serveFont` route answers, for the picker's specimens. Default `\"/fonts\"`. */\n fontsBaseUrl?: string;\n /** Fill + automatic label target. Default `7`. Warnings never block save. */\n contrastTarget?: number;\n /**\n * @deprecated Theme has no preview pane (SPI-56 canceled). Kept so a\n * site that still passes it does not fail to boot.\n */\n previewPath?: string;\n /**\n * Adds the Identity page (logo, favicon, mobile-menu mark) when given.\n * Pass `BRAND_ASSETS_SLUG` (or the slug you gave `createBrandAssets`).\n * Save on that page writes only those uploads onto the stored Theme row.\n */\n logo?: { collection: string };\n /**\n * Fallback art when logo, favicon, or mobile-menu mark is empty. The\n * site passes today's files; `--color-primary-mark` is not a Theme field.\n */\n identity?: { fallback?: ThemeIdentityFallback };\n /** Fires from `afterChange` on every save — Theme has no draft mode. */\n onPublish?: (theme: ThemeConfig, doc: ThemeDoc) => void | Promise<void>;\n /**\n * Slugs that store `lookField` / `colorTokenField` values. Colors\n * Delete scans these (drafts included) before dropping a custom row.\n * Omit or pass empty: every additional color is unused and deletes\n * immediately. A new look surface is added here, not copied into a\n * site helper — site adopt names the slugs (SPI-93).\n */\n colorUsages?: {\n collections?: string[];\n globals?: string[];\n };\n}\n\nexport interface ThemeHeadOptions {\n fontsBaseUrl?: string;\n attribute?: \"class\" | \"data-theme\";\n identity?: ResolvedThemeIdentity;\n /**\n * Custom Colors rows. `themeHead` emits their 50–950 variables and\n * `[data-look]` bindings so a picker key paints without a package bump.\n */\n library?: ThemeLibraryColorDoc[] | null;\n}\n\nexport interface ThemeHead {\n css: string;\n preloads: { href: string; type: \"font/woff2\" }[];\n identity?: ResolvedThemeIdentity;\n}\n\nexport const THEME_SLUG = \"theme\";\nexport const THEME_COLORS_SLUG = \"theme-colors\";\nexport const THEME_TYPOGRAPHY_SLUG = \"theme-typography\";\nexport const THEME_APPEARANCE_SLUG = \"theme-appearance\";\nexport const THEME_IDENTITY_SLUG = \"theme-identity\";\n\nexport const SYSTEM_COLOR_KEYS = [\n \"primary\",\n \"secondary\",\n \"accent\",\n \"highlight\",\n \"success\",\n \"destructive\",\n] as const;\n\nexport type SystemColorKey = (typeof SYSTEM_COLOR_KEYS)[number];\n","import { SHADE_STEPS, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { SYSTEM_COLOR_KEYS, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * Payload's array form state stores the row count (`0`, `2`, …), not the\n * rows. A custom Field that treats that number as the list will throw\n * `rows.filter is not a function` on an empty Theme library.\n */\nexport function asLibraryRows(value: unknown): ThemeLibraryColorDoc[] {\n return Array.isArray(value) ? value : [];\n}\n\nconst STEP_SET = new Set<number>(SHADE_STEPS);\n\n/**\n * Page editors pick `coral-400`, never a raw hex. Rewrite every use of\n * `fromKey` onto `toKey` at the same step: `coral-400` → `highlight-400`.\n * A bare key (`coral`) becomes `toKey`. Anything else is left alone.\n */\nexport function rewriteColorToken(token: string, fromKey: string, toKey: string): string {\n if (token === fromKey) return toKey;\n const dash = token.lastIndexOf(\"-\");\n if (dash <= 0) return token;\n const key = token.slice(0, dash);\n const step = Number(token.slice(dash + 1));\n if (key !== fromKey || !STEP_SET.has(step)) return token;\n return `${toKey}-${step as ShadeStep}`;\n}\n\nexport function themeColorKeys(doc: ThemeDoc | null | undefined): string[] {\n const custom = asLibraryRows(doc?.colors?.library)\n .map((row) => row.key?.trim())\n .filter((key): key is string => Boolean(key));\n return [...SYSTEM_COLOR_KEYS, ...custom];\n}\n\n/**\n * Remove a custom color. Unused: omit `replacement` and the row is gone.\n * In use: pass another system or custom key; the caller rewrites page\n * tokens with `rewriteColorToken`. After this, no library row still\n * has `key`.\n */\nexport function deleteLibraryColor(doc: ThemeDoc, key: string, replacement?: string): ThemeDoc {\n const library = [...asLibraryRows(doc.colors?.library)];\n const index = library.findIndex((row) => row.key === key);\n if (index === -1) {\n throw new Error(`No custom color named ${JSON.stringify(key)}`);\n }\n library.splice(index, 1);\n const next: ThemeDoc = {\n ...doc,\n colors: { ...doc.colors, library },\n };\n if (replacement !== undefined) {\n if (replacement === key) {\n throw new Error(\"Replacement must be a different color\");\n }\n if (!themeColorKeys(next).includes(replacement)) {\n throw new Error(`Replacement ${JSON.stringify(replacement)} is not a system or remaining custom color`);\n }\n }\n return next;\n}\n","import { rewriteColorToken } from \"./library\";\n\nexport interface ColorTokenHit {\n path: string;\n token: string;\n}\n\n/**\n * A string `rewriteColorToken` would change: `coral`, `coral-400`.\n * `#FF5A2D` and `coral-ish` are not tokens.\n */\nexport function isColorToken(value: string, key: string): boolean {\n return rewriteColorToken(value, key, `\\0${key}`) !== value;\n}\n\nexport function findColorTokens(value: unknown, key: string): ColorTokenHit[] {\n const hits: ColorTokenHit[] = [];\n walk(value, \"\", (path, token) => {\n if (isColorToken(token, key)) hits.push({ path, token });\n });\n return hits;\n}\n\nexport function rewriteColorTokens<T>(value: T, fromKey: string, toKey: string): T {\n return rewriteValue(value, fromKey, toKey) as T;\n}\n\nfunction rewriteValue(value: unknown, fromKey: string, toKey: string): unknown {\n if (typeof value === \"string\") return rewriteColorToken(value, fromKey, toKey);\n if (Array.isArray(value)) return value.map((item) => rewriteValue(item, fromKey, toKey));\n if (value && typeof value === \"object\") {\n const next: Record<string, unknown> = {};\n for (const [name, child] of Object.entries(value)) {\n next[name] = rewriteValue(child, fromKey, toKey);\n }\n return next;\n }\n return value;\n}\n\nfunction walk(value: unknown, path: string, visit: (path: string, token: string) => void): void {\n if (typeof value === \"string\") {\n visit(path, value);\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => walk(item, join(path, String(index)), visit));\n return;\n }\n if (value && typeof value === \"object\") {\n for (const [name, child] of Object.entries(value)) {\n walk(child, join(path, name), visit);\n }\n }\n}\n\nfunction join(path: string, segment: string): string {\n return path ? `${path}.${segment}` : segment;\n}\n","import { includedShadeSteps, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { stateFromColorDoc } from \"./map\";\nimport { THEME_SLUG, type ThemeColorDoc, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * System colors Color Settings offers as page-editor fills. Success and\n * Destructive stay off this list — they are theme chrome only.\n */\nexport const PAGE_EDITOR_SYSTEM_KEYS = [\"primary\", \"secondary\", \"accent\", \"highlight\"] as const;\n\nexport type PageEditorSystemKey = (typeof PAGE_EDITOR_SYSTEM_KEYS)[number];\n\nexport interface LookOption {\n label: string;\n value: string;\n}\n\nconst SYSTEM_LABELS: Record<PageEditorSystemKey, string> = {\n primary: \"Primary\",\n secondary: \"Secondary\",\n accent: \"Accent\",\n highlight: \"Highlight\",\n};\n\nfunction brandColor(doc: ThemeDoc | null | undefined, key: PageEditorSystemKey): ThemeColorDoc | null {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const value = brand?.[key];\n if (typeof value === \"string\" || value == null) return value == null ? null : { hex: value };\n return value;\n}\n\nexport function themeLibraryFromDoc(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return Array.isArray(doc?.colors?.library) ? doc.colors.library : [];\n}\n\nfunction libraryRows(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return themeLibraryFromDoc(doc);\n}\n\nfunction titleCase(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1);\n}\n\nfunction stepsFor(color: ThemeColorDoc | null | undefined, fallbackHex: string): ShadeStep[] {\n return includedShadeSteps(stateFromColorDoc(color, fallbackHex));\n}\n\n/**\n * Family keys a `lookField()` may offer: the page-editor system scales\n * plus every custom color on Colors. Adding Coral on Theme makes `coral`\n * appear here with no `@bison-lab/*` release.\n */\nexport function pageEditorLooks(doc: ThemeDoc | null | undefined): LookOption[] {\n const system = PAGE_EDITOR_SYSTEM_KEYS.map((value) => ({\n label: SYSTEM_LABELS[value],\n value,\n }));\n const custom = libraryRows(doc)\n .map((row) => {\n const value = row.key?.trim();\n if (!value) return null;\n return { label: row.label?.trim() || titleCase(value), value };\n })\n .filter((option): option is LookOption => option !== null);\n return [...system, ...custom];\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear. System\n * scales with no stored include list offer the full 50–950 ramp.\n */\nexport function pageEditorTokens(doc: ThemeDoc | null | undefined): LookOption[] {\n const tokens: LookOption[] = [];\n for (const key of PAGE_EDITOR_SYSTEM_KEYS) {\n const label = SYSTEM_LABELS[key];\n for (const step of stepsFor(brandColor(doc, key), \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n for (const row of libraryRows(doc)) {\n const key = row.key?.trim();\n if (!key) continue;\n const label = row.label?.trim() || titleCase(key);\n for (const step of stepsFor(row, row.hex ?? \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n return tokens;\n}\n\nexport async function themeDocFromRequest(req: {\n payload?: {\n findGlobal?: (args: {\n slug: string;\n depth?: number;\n overrideAccess?: boolean;\n }) => Promise<ThemeDoc | null | undefined>;\n };\n}): Promise<ThemeDoc | null> {\n try {\n const doc = await req.payload?.findGlobal?.({\n slug: THEME_SLUG,\n depth: 0,\n overrideAccess: true,\n });\n return doc ?? null;\n } catch {\n return null;\n }\n}\n","import type { StaticLabel, TextField, TextFieldSingleValidation } from \"payload\";\n\nimport { LOOK_FIELD } from \"./fields\";\nimport { pageEditorLooks, pageEditorTokens, themeDocFromRequest } from \"./looks\";\n\nexport interface LookFieldOptions {\n name?: string;\n label?: StaticLabel;\n required?: boolean;\n admin?: TextField[\"admin\"];\n validate?: TextFieldSingleValidation;\n}\n\nexport type LookFieldMode = \"look\" | \"token\";\n\nexport const validateLook: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick a look from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorLooks(doc).some((look) => look.value === value)) return true;\n return \"Pick a look from Theme → Colors\";\n};\n\nexport const validateColorToken: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick an included step from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorTokens(doc).some((token) => token.value === value)) return true;\n return \"Pick an included step from Theme → Colors\";\n};\n\nfunction pickerField(\n defaults: { name: string; label: string; mode: LookFieldMode; validate: TextFieldSingleValidation },\n overrides: LookFieldOptions,\n): TextField {\n const { name = defaults.name, label = defaults.label, admin, required, validate = defaults.validate } = overrides;\n return {\n name,\n type: \"text\",\n label,\n required,\n validate,\n admin: {\n ...admin,\n components: { Field: LOOK_FIELD, ...admin?.components },\n custom: { mode: defaults.mode, ...admin?.custom },\n },\n };\n}\n\n/**\n * A picker any collection or global can offer. Options come from the\n * published Theme at request time: page-editor system scales plus custom\n * Colors. Payload select options are a static list, so this is a text\n * field with an admin picker — adding Coral does not need a schema change.\n */\nexport function lookField(overrides: LookFieldOptions = {}): TextField {\n return pickerField({ name: \"look\", label: \"Look\", mode: \"look\", validate: validateLook }, overrides);\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear.\n */\nexport function colorTokenField(overrides: LookFieldOptions = {}): TextField {\n return pickerField(\n { name: \"color\", label: \"Color\", mode: \"token\", validate: validateColorToken },\n overrides,\n );\n}\n","import type { ThemeDoc, ThemeUploadDoc } from \"./types\";\n\nexport interface ThemeIdentityAsset {\n url: string;\n alt: string;\n}\n\nexport interface ThemeIdentityFallback {\n lockup?: ThemeIdentityAsset;\n mark?: ThemeIdentityAsset;\n favicon?: ThemeIdentityAsset;\n}\n\nexport interface ResolvedThemeIdentity {\n lockup: ThemeIdentityAsset | null;\n mark: ThemeIdentityAsset | null;\n favicon: ThemeIdentityAsset | null;\n}\n\nfunction fromUpload(value: ThemeDoc[\"logo\"], fallback?: ThemeIdentityAsset): ThemeIdentityAsset | null {\n if (value && typeof value === \"object\") {\n const upload = value as ThemeUploadDoc;\n if (upload.url) {\n return { url: upload.url, alt: upload.alt ?? fallback?.alt ?? \"\" };\n }\n }\n return fallback ?? null;\n}\n\n/**\n * Uploaded logo, favicon, and mobile-menu mark, or the fallback the site\n * passed into `createTheme`. Empty fields keep the fallback;\n * `--color-primary-mark` is not a Theme field.\n */\nexport function resolveThemeIdentity(\n doc: ThemeDoc | null | undefined,\n fallback?: ThemeIdentityFallback,\n): ResolvedThemeIdentity {\n return {\n lockup: fromUpload(doc?.logo, fallback?.lockup),\n mark: fromUpload(doc?.logoMark, fallback?.mark),\n favicon: fromUpload(doc?.favicon, fallback?.favicon),\n };\n}\n"],"mappings":";;AAIA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,yBAAyB;AACtC,MAAa,yBAAyB;AACtC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;AACnC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;AACvC,MAAa,aAAa;AA6B1B,SAAgB,mBAAmB,SAA6C;AAC9E,QAAO,WAAA;;;;AC/BT,SAAS,KAAQ,OAA6B,UAAgB;AAC5D,QAAO,SAAS,OAAO,WAAW;;AAGpC,SAAS,eACP,SACA,MACe;AACf,KAAI,YAAY,KAAA,EAAW,QAAO;AAClC,KAAI,YAAY,QAAQ,YAAA,GAA0B,QAAO;AACzD,QAAO;;AAGT,SAAS,aAAa,OAAkD,UAA0B;AAChG,KAAI,OAAO,UAAU,SAAU,QAAO,SAAS;AAC/C,QAAO,KAAK,OAAO,KAAK,SAAS;;AAGnC,SAAgB,gBAAgB,KAAa,aAAwB,KAAoB;AACvF,QAAO,kBAAkB,iBAAiB,KAAK,WAAW,CAAC;;AAG7D,SAAgB,kBAAkB,OAAuC;AACvE,QAAO;EACL,KAAK,MAAM;EACX,YAAY,MAAM;E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AU,QAAO;AAEtC,KAAI,iBADQ,MAAM,oBAAoB,IAAI,CACjB,CAAC,MAAM,UAAU,MAAM,UAAU,MAAM,CAAE,QAAO;AACzE,QAAO;;AAGT,SAAS,YACP,UACA,WACW;CACX,MAAM,EAAE,OAAO,SAAS,MAAM,QAAQ,SAAS,OAAO,OAAO,UAAU,WAAW,SAAS,aAAa;AACxG,QAAO;EACL;EACA,MAAM;EACN;EACA;EACA;EACA,OAAO;GACL,GAAG;GACH,YAAY;IAAE,OAAO;IAAY,GAAG,OAAO;IAAY;GACvD,QAAQ;IAAE,MAAM,SAAS;IAAM,GAAG,OAAO;IAAQ;GAClD;EACF;;;;;;;;AASH,SAAgB,UAAU,YAA8B,EAAE,EAAa;AACrE,QAAO,YAAY;EAAE,MAAM;EAAQ,OAAO;EAAQ,MAAM;EAAQ,UAAU;EAAc,EAAE,UAAU;;;;;AAMtG,SAAgB,gBAAgB,YAA8B,EAAE,EAAa;AAC3E,QAAO,YACL;EAAE,MAAM;EAAS,OAAO;EAAS,MAAM;EAAS,UAAU;EAAoB,EAC9E,UACD;;;;AChDH,SAAS,WAAW,OAAyB,UAA0D;AACrG,KAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,SAAS;AACf,MAAI,OAAO,IACT,QAAO;GAAE,KAAK,OAAO;GAAK,KAAK,OAAO,OAAO,UAAU,OAAO;GAAI;;AAGtE,QAAO,YAAY;;;;;;;AAQrB,SAAgB,qBACd,KACA,UACuB;AACvB,QAAO;EACL,QAAQ,WAAW,KAAK,MAAM,UAAU,OAAO;EAC/C,MAAM,WAAW,KAAK,UAAU,UAAU,KAAK;EAC/C,SAAS,WAAW,KAAK,SAAS,UAAU,QAAQ;EACrD"}
|
|
1
|
+
{"version":3,"file":"identity-Dwyq8519.mjs","names":[],"sources":["../src/theme/fields.ts","../src/theme/map.ts","../src/theme/types.ts","../src/theme/library.ts","../src/theme/color-tokens.ts","../src/theme/looks.ts","../src/theme/look-field.ts","../src/theme/identity.ts"],"sourcesContent":["import type { ThemeConfig } from \"@bison-lab/tokens\";\n\nimport type { EditableTheme } from \"./types\";\n\nexport const THEME_COLOR_FIELD = \"@bison-lab/payload-core/admin#ColorField\";\nexport const THEME_COLOR_SCALE_FIELD = \"@bison-lab/payload-core/admin#ColorScaleField\";\nexport const THEME_LIBRARY_FIELD = \"@bison-lab/payload-core/admin#LibraryField\";\nexport const THEME_FONT_FIELD = \"@bison-lab/payload-core/admin#FontField\";\nexport const THEME_PAIRING_FIELD = \"@bison-lab/payload-core/admin#PairingField\";\nexport const THEME_APPEARANCE_FIELD = \"@bison-lab/payload-core/admin#AppearanceField\";\nexport const THEME_GREY_SCALE_FIELD = \"@bison-lab/payload-core/admin#GreyScaleField\";\nexport const THEME_CONTRAST_REPORT = \"@bison-lab/payload-core/admin#ContrastReport\";\nexport const THEME_SECTION_HEADING = \"@bison-lab/payload-core/admin#SectionHeading\";\nexport const THEME_PUBLISH_FIELD = \"@bison-lab/payload-core/admin#PublishChild\";\nexport const THEME_SAVE_BUTTON = \"@bison-lab/payload-core/admin#HiddenSaveButton\";\nexport const THEME_DOCUMENT_CONTROLS = \"@bison-lab/payload-core/admin#ThemeDocumentControls\";\nexport const THEME_IDENTITY_FALLBACK = \"@bison-lab/payload-core/admin#IdentityFallback\";\nexport const LOOK_FIELD = \"@bison-lab/payload-core/admin#LookField\";\n\n/**\n * Document path for each editable `ThemeConfig` key. Locked with `satisfies`\n * so a new config field without a Theme field (or the reverse) fails at\n * compile time. `darkSelector` and `fontWeights` are seed-only.\n */\nexport const THEME_FIELD_PATHS = {\n brandPrimary: \"colors.brand.primary.hex\",\n brandSecondary: \"colors.brand.secondary.hex\",\n brandAccent: \"colors.brand.accent.hex\",\n brandHighlight: \"colors.brand.highlight.hex\",\n brandSuccess: \"colors.brand.success.hex\",\n brandDestructive: \"colors.brand.destructive.hex\",\n greyScale: \"colors.greyScale\",\n defaultTheme: \"appearance.defaultTheme\",\n radius: \"appearance.radius\",\n shadow: \"appearance.shadow\",\n motion: \"appearance.motion\",\n density: \"appearance.density\",\n fontBody: \"typography.body\",\n fontHeading: \"typography.heading\",\n} as const satisfies Record<keyof EditableTheme, string>;\n\nexport type ThemeFieldPath = (typeof THEME_FIELD_PATHS)[keyof typeof THEME_FIELD_PATHS];\n\n/** Empty select value for heading: same family as body. */\nexport const SAME_AS_BODY = \"\";\n\nexport function headingSelectValue(heading: ThemeConfig[\"fontHeading\"]): string {\n return heading ?? SAME_AS_BODY;\n}\n","import {\n createColorScale,\n DESTRUCTIVE_SCALE_HEX,\n generateColorScale,\n isThemeHex,\n SHADE_STEPS,\n type ColorScale,\n type ColorScaleInclude,\n type ColorScaleState,\n type ShadeStep,\n type ThemeConfig,\n} from \"@bison-lab/tokens\";\n\nimport { SAME_AS_BODY } from \"./fields\";\nimport type { ThemeColorDoc, ThemeDoc } from \"./types\";\n\nfunction pick<T>(value: T | null | undefined, fallback: T): T {\n return value == null ? fallback : value;\n}\n\nfunction headingFromDoc(\n heading: string | null | undefined,\n seed: ThemeConfig[\"fontHeading\"],\n): string | null {\n if (heading === undefined) return seed;\n if (heading === null || heading === SAME_AS_BODY) return null;\n return heading;\n}\n\nfunction hexFromColor(value: ThemeColorDoc | string | null | undefined, fallback: string): string {\n if (typeof value === \"string\") return value || fallback;\n return pick(value?.hex, fallback);\n}\n\nexport function colorDocFromHex(hex: string, sourceStep: ShadeStep = 500): ThemeColorDoc {\n return colorDocFromState(createColorScale(hex, sourceStep));\n}\n\nexport function colorDocFromState(state: ColorScaleState): ThemeColorDoc {\n return {\n hex: state.hex,\n sourceStep: state.sourceStep,\n scale: state.scale,\n stale: state.stale,\n include: Array.isArray(state.include) ? \"custom\" : state.include,\n includedSteps: Array.isArray(state.include) ? [...state.include] : undefined,\n };\n}\n\nexport function stateFromColorDoc(\n doc: ThemeColorDoc | null | undefined,\n fallbackHex = \"#000000\",\n): ColorScaleState {\n const hex = isThemeHex(doc?.hex) ? doc.hex : fallbackHex;\n const sourceStep = (Number(doc?.sourceStep) || 500) as ShadeStep;\n const include = includeFromDoc(doc, sourceStep);\n const scale =\n doc?.scale && typeof doc.scale === \"object\" ? (doc.scale as ColorScale) : generateColorScale(hex, sourceStep);\n return { hex, sourceStep, scale, stale: Boolean(doc?.stale), include };\n}\n\nfunction includeFromDoc(doc: ThemeColorDoc | null | undefined, sourceStep: ShadeStep): ColorScaleInclude {\n if (doc?.include === \"source\") return \"source\";\n if (doc?.include === \"custom\" && Array.isArray(doc.includedSteps)) {\n const steps = doc.includedSteps.map(Number).filter((step): step is ShadeStep => SHADE_STEPS.includes(step as ShadeStep));\n if (!steps.includes(sourceStep)) steps.push(sourceStep);\n return steps;\n }\n return \"all\";\n}\n\n/**\n * Nested Theme document → flat `ThemeConfig`. Null or missing editor\n * fields take the seed; `darkSelector` and `fontWeights` always come from\n * the seed. Reads the BIS-87 groups and the pre-BIS-87 flat fields.\n */\nexport function themeConfigFromDoc(doc: ThemeDoc | null | undefined, seed: ThemeConfig): ThemeConfig {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const typography = doc?.typography ?? doc?.fonts;\n const appearance = doc?.appearance;\n return {\n brandPrimary: hexFromColor(brand?.primary, seed.brandPrimary),\n brandSecondary: hexFromColor(brand?.secondary, seed.brandSecondary),\n brandAccent: hexFromColor(brand?.accent, seed.brandAccent),\n brandHighlight: hexFromColor(brand?.highlight, seed.brandHighlight),\n brandSuccess: hexFromColor(brand?.success, seed.brandSuccess),\n brandDestructive:\n hexFromColor(brand?.destructive, seed.brandDestructive ?? DESTRUCTIVE_SCALE_HEX) ||\n seed.brandDestructive ||\n DESTRUCTIVE_SCALE_HEX,\n greyScale: pick(doc?.colors?.greyScale ?? doc?.greyScale, seed.greyScale),\n radius: pick(appearance?.radius ?? doc?.radius, seed.radius),\n shadow: pick(appearance?.shadow ?? doc?.shadow, seed.shadow),\n motion: pick(appearance?.motion ?? doc?.motion, seed.motion),\n density: pick(appearance?.density ?? doc?.density, seed.density),\n defaultTheme: pick(appearance?.defaultTheme ?? doc?.defaultTheme, seed.defaultTheme),\n fontBody: pick(typography?.body, seed.fontBody),\n fontHeading: headingFromDoc(typography?.heading, seed.fontHeading),\n darkSelector: seed.darkSelector,\n fontWeights: seed.fontWeights,\n };\n}\n\n/** The document `seedTheme` writes so a fresh Global matches the seed config. */\nexport function docFromConfig(config: ThemeConfig, destructive?: string): ThemeDoc {\n const destructiveHex = destructive ?? config.brandDestructive ?? DESTRUCTIVE_SCALE_HEX;\n return {\n colors: {\n brand: {\n primary: colorDocFromHex(config.brandPrimary),\n secondary: colorDocFromHex(config.brandSecondary),\n accent: colorDocFromHex(config.brandAccent),\n highlight: colorDocFromHex(config.brandHighlight),\n success: colorDocFromHex(config.brandSuccess),\n destructive: colorDocFromHex(destructiveHex),\n },\n library: [],\n greyScale: config.greyScale,\n },\n typography: {\n body: config.fontBody,\n heading: config.fontHeading,\n },\n appearance: {\n defaultTheme: config.defaultTheme,\n radius: config.radius,\n shadow: config.shadow,\n motion: config.motion,\n density: config.density,\n },\n };\n}\n\nexport function validateThemeHex(value: unknown): true | string {\n if (!isThemeHex(value)) return \"Enter a six-digit hex colour like #1e3a5f\";\n return true;\n}\n\nexport function validateSourceIncluded(\n value: unknown,\n { siblingData }: { siblingData?: { sourceStep?: unknown; include?: unknown } },\n): true | string {\n const include = siblingData?.include;\n if (include === \"all\" || include === \"source\") return true;\n const source = Number(siblingData?.sourceStep);\n const steps = Array.isArray(value) ? value.map(Number) : [];\n if (!SHADE_STEPS.includes(source as ShadeStep)) return true;\n if (!steps.includes(source)) return \"The source step cannot be excluded\";\n return true;\n}\n","import type { Access } from \"payload\";\nimport type { FontEntry } from \"@bison-lab/fonts\";\nimport type { ColorScale, ColorScaleInclude, ShadeStep, ThemeConfig } from \"@bison-lab/tokens\";\n\nimport type { ResolvedThemeIdentity, ThemeIdentityFallback } from \"./identity\";\n\n/**\n * The Theme document a site's generated types will describe. Optional and\n * nullable, no index signature: a generated Global is assignable to this,\n * never the reverse.\n *\n * Legacy flat `brand.*` hexes, `fonts`, and preset fields at the root stay\n * readable so `getPublishedTheme` still maps a pre-BIS-87 row.\n */\nexport interface ThemeColorDoc {\n hex?: string | null;\n sourceStep?: ShadeStep | string | null;\n scale?: ColorScale | null;\n stale?: boolean | null;\n include?: ColorScaleInclude | \"custom\" | null;\n includedSteps?: ShadeStep[] | string[] | null;\n}\n\nexport interface ThemeLibraryColorDoc extends ThemeColorDoc {\n key?: string | null;\n label?: string | null;\n}\n\nexport interface ThemeDoc {\n colors?: {\n brand?: {\n primary?: ThemeColorDoc | string | null;\n secondary?: ThemeColorDoc | string | null;\n accent?: ThemeColorDoc | string | null;\n highlight?: ThemeColorDoc | string | null;\n success?: ThemeColorDoc | string | null;\n destructive?: ThemeColorDoc | string | null;\n } | null;\n library?: ThemeLibraryColorDoc[] | null;\n greyScale?: ThemeConfig[\"greyScale\"] | null;\n } | null;\n typography?: {\n body?: string | null;\n heading?: string | null;\n } | null;\n appearance?: {\n defaultTheme?: ThemeConfig[\"defaultTheme\"] | null;\n radius?: ThemeConfig[\"radius\"] | null;\n shadow?: ThemeConfig[\"shadow\"] | null;\n motion?: ThemeConfig[\"motion\"] | null;\n density?: ThemeConfig[\"density\"] | null;\n } | null;\n /** @deprecated Pre-BIS-87 flat brand hexes. */\n brand?: {\n primary?: ThemeColorDoc | string | null;\n secondary?: ThemeColorDoc | string | null;\n accent?: ThemeColorDoc | string | null;\n highlight?: ThemeColorDoc | string | null;\n success?: ThemeColorDoc | string | null;\n destructive?: ThemeColorDoc | string | null;\n } | null;\n /** @deprecated Pre-BIS-87; now `colors.greyScale`. */\n greyScale?: ThemeConfig[\"greyScale\"] | null;\n /** @deprecated Pre-BIS-87; now `appearance.*`. */\n radius?: ThemeConfig[\"radius\"] | null;\n shadow?: ThemeConfig[\"shadow\"] | null;\n motion?: ThemeConfig[\"motion\"] | null;\n density?: ThemeConfig[\"density\"] | null;\n defaultTheme?: ThemeConfig[\"defaultTheme\"] | null;\n /** @deprecated Pre-BIS-87; now `typography`. */\n fonts?: {\n body?: string | null;\n heading?: string | null;\n } | null;\n logo?: number | string | ThemeUploadDoc | null;\n favicon?: number | string | ThemeUploadDoc | null;\n logoMark?: number | string | ThemeUploadDoc | null;\n}\n\nexport interface ThemeUploadDoc {\n id?: number | string | null;\n url?: string | null;\n alt?: string | null;\n}\n\n/**\n * What an editor can change. `darkSelector` and `fontWeights` stay on the\n * seed — they mean nothing in the admin — and `themeConfigFromDoc` puts\n * them back.\n */\nexport type EditableTheme = Omit<ThemeConfig, \"darkSelector\" | \"fontWeights\">;\n\nexport interface CreateThemeOptions {\n /**\n * Required, no default. Pass `canManageBrand` as `update` (and typically\n * `isAuthenticated` as `read`). Theme does not read the Roles Global.\n */\n access: { read: Access; update: Access };\n /** The site's `bison.config.json`. Every field's `defaultValue`, and the fallback `getPublishedTheme` returns. */\n seed: ThemeConfig;\n /**\n * Destructive seed hex. Falls back to `seed.brandDestructive`, then\n * the library's `DESTRUCTIVE_SCALE_HEX` (`#ef4444`).\n */\n destructive?: string;\n /** Default: the whole catalogue. */\n fonts?: readonly FontEntry[];\n /** Where the site's `serveFont` route answers, for the picker's specimens. Default `\"/fonts\"`. */\n fontsBaseUrl?: string;\n /** Fill + automatic label target. Default `7`. Warnings never block save. */\n contrastTarget?: number;\n /**\n * @deprecated Theme has no preview pane (SPI-56 canceled). Kept so a\n * site that still passes it does not fail to boot.\n */\n previewPath?: string;\n /**\n * Adds the Identity page (logo, favicon, mobile-menu mark) when given.\n * Pass `BRAND_ASSETS_SLUG` (or the slug you gave `createBrandAssets`).\n * Save on that page writes only those uploads onto the stored Theme row.\n */\n logo?: { collection: string };\n /**\n * Fallback art when logo, favicon, or mobile-menu mark is empty. The\n * site passes today's files; `--color-primary-mark` is not a Theme field.\n */\n identity?: { fallback?: ThemeIdentityFallback };\n /** Fires from `afterChange` on every save — Theme has no draft mode. */\n onPublish?: (theme: ThemeConfig, doc: ThemeDoc) => void | Promise<void>;\n /**\n * Slugs that store `lookField` / `colorTokenField` values. Colors\n * Delete scans these (drafts included) before dropping a custom row.\n * Omit or pass empty: every additional color is unused and deletes\n * immediately. A new look surface is added here, not copied into a\n * site helper — site adopt names the slugs (SPI-93).\n */\n colorUsages?: {\n collections?: string[];\n globals?: string[];\n };\n}\n\nexport interface ThemeHeadOptions {\n fontsBaseUrl?: string;\n attribute?: \"class\" | \"data-theme\";\n identity?: ResolvedThemeIdentity;\n /**\n * Custom Colors rows. `themeHead` emits their 50–950 variables and\n * `[data-look]` bindings so a picker key paints without a package bump.\n */\n library?: ThemeLibraryColorDoc[] | null;\n}\n\nexport interface ThemeHead {\n css: string;\n preloads: { href: string; type: \"font/woff2\" }[];\n identity?: ResolvedThemeIdentity;\n}\n\nexport const THEME_SLUG = \"theme\";\nexport const THEME_COLORS_SLUG = \"theme-colors\";\nexport const THEME_TYPOGRAPHY_SLUG = \"theme-typography\";\nexport const THEME_APPEARANCE_SLUG = \"theme-appearance\";\nexport const THEME_IDENTITY_SLUG = \"theme-identity\";\n\nexport const SYSTEM_COLOR_KEYS = [\n \"primary\",\n \"secondary\",\n \"accent\",\n \"highlight\",\n \"success\",\n \"destructive\",\n] as const;\n\nexport type SystemColorKey = (typeof SYSTEM_COLOR_KEYS)[number];\n","import { SHADE_STEPS, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { SYSTEM_COLOR_KEYS, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * Payload's array form state stores the row count (`0`, `2`, …), not the\n * rows. A custom Field that treats that number as the list will throw\n * `rows.filter is not a function` on an empty Theme library.\n */\nexport function asLibraryRows(value: unknown): ThemeLibraryColorDoc[] {\n return Array.isArray(value) ? value : [];\n}\n\nconst STEP_SET = new Set<number>(SHADE_STEPS);\n\n/**\n * Page editors pick `coral-400`, never a raw hex. Rewrite every use of\n * `fromKey` onto `toKey` at the same step: `coral-400` → `highlight-400`.\n * A bare key (`coral`) becomes `toKey`. Anything else is left alone.\n */\nexport function rewriteColorToken(token: string, fromKey: string, toKey: string): string {\n if (token === fromKey) return toKey;\n const dash = token.lastIndexOf(\"-\");\n if (dash <= 0) return token;\n const key = token.slice(0, dash);\n const step = Number(token.slice(dash + 1));\n if (key !== fromKey || !STEP_SET.has(step)) return token;\n return `${toKey}-${step as ShadeStep}`;\n}\n\nexport function themeColorKeys(doc: ThemeDoc | null | undefined): string[] {\n const custom = asLibraryRows(doc?.colors?.library)\n .map((row) => row.key?.trim())\n .filter((key): key is string => Boolean(key));\n return [...SYSTEM_COLOR_KEYS, ...custom];\n}\n\n/**\n * Remove a custom color. Unused: omit `replacement` and the row is gone.\n * In use: pass another system or custom key; the caller rewrites page\n * tokens with `rewriteColorToken`. After this, no library row still\n * has `key`.\n */\nexport function deleteLibraryColor(doc: ThemeDoc, key: string, replacement?: string): ThemeDoc {\n const library = [...asLibraryRows(doc.colors?.library)];\n const index = library.findIndex((row) => row.key === key);\n if (index === -1) {\n throw new Error(`No custom color named ${JSON.stringify(key)}`);\n }\n library.splice(index, 1);\n const next: ThemeDoc = {\n ...doc,\n colors: { ...doc.colors, library },\n };\n if (replacement !== undefined) {\n if (replacement === key) {\n throw new Error(\"Replacement must be a different color\");\n }\n if (!themeColorKeys(next).includes(replacement)) {\n throw new Error(`Replacement ${JSON.stringify(replacement)} is not a system or remaining custom color`);\n }\n }\n return next;\n}\n","import { rewriteColorToken } from \"./library\";\n\nexport interface ColorTokenHit {\n path: string;\n token: string;\n}\n\n/**\n * A string `rewriteColorToken` would change: `coral`, `coral-400`.\n * `#FF5A2D` and `coral-ish` are not tokens.\n */\nexport function isColorToken(value: string, key: string): boolean {\n return rewriteColorToken(value, key, `\\0${key}`) !== value;\n}\n\nexport function findColorTokens(value: unknown, key: string): ColorTokenHit[] {\n const hits: ColorTokenHit[] = [];\n walk(value, \"\", (path, token) => {\n if (isColorToken(token, key)) hits.push({ path, token });\n });\n return hits;\n}\n\nexport function rewriteColorTokens<T>(value: T, fromKey: string, toKey: string): T {\n return rewriteValue(value, fromKey, toKey) as T;\n}\n\nfunction rewriteValue(value: unknown, fromKey: string, toKey: string): unknown {\n if (typeof value === \"string\") return rewriteColorToken(value, fromKey, toKey);\n if (Array.isArray(value)) return value.map((item) => rewriteValue(item, fromKey, toKey));\n if (value && typeof value === \"object\") {\n const next: Record<string, unknown> = {};\n for (const [name, child] of Object.entries(value)) {\n next[name] = rewriteValue(child, fromKey, toKey);\n }\n return next;\n }\n return value;\n}\n\nfunction walk(value: unknown, path: string, visit: (path: string, token: string) => void): void {\n if (typeof value === \"string\") {\n visit(path, value);\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => walk(item, join(path, String(index)), visit));\n return;\n }\n if (value && typeof value === \"object\") {\n for (const [name, child] of Object.entries(value)) {\n walk(child, join(path, name), visit);\n }\n }\n}\n\nfunction join(path: string, segment: string): string {\n return path ? `${path}.${segment}` : segment;\n}\n","import { includedShadeSteps, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { stateFromColorDoc } from \"./map\";\nimport { THEME_SLUG, type ThemeColorDoc, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * System colors Color Settings offers as page-editor fills. Success and\n * Destructive stay off this list — they are theme chrome only.\n */\nexport const PAGE_EDITOR_SYSTEM_KEYS = [\"primary\", \"secondary\", \"accent\", \"highlight\"] as const;\n\nexport type PageEditorSystemKey = (typeof PAGE_EDITOR_SYSTEM_KEYS)[number];\n\nexport interface LookOption {\n label: string;\n value: string;\n}\n\nconst SYSTEM_LABELS: Record<PageEditorSystemKey, string> = {\n primary: \"Primary\",\n secondary: \"Secondary\",\n accent: \"Accent\",\n highlight: \"Highlight\",\n};\n\nfunction brandColor(doc: ThemeDoc | null | undefined, key: PageEditorSystemKey): ThemeColorDoc | null {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const value = brand?.[key];\n if (typeof value === \"string\" || value == null) return value == null ? null : { hex: value };\n return value;\n}\n\nexport function themeLibraryFromDoc(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return Array.isArray(doc?.colors?.library) ? doc.colors.library : [];\n}\n\nfunction libraryRows(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return themeLibraryFromDoc(doc);\n}\n\nfunction titleCase(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1);\n}\n\nfunction stepsFor(color: ThemeColorDoc | null | undefined, fallbackHex: string): ShadeStep[] {\n return includedShadeSteps(stateFromColorDoc(color, fallbackHex));\n}\n\n/**\n * Family keys a `lookField()` may offer: the page-editor system scales\n * plus every custom color on Colors. Adding Coral on Theme makes `coral`\n * appear here with no `@bison-lab/*` release.\n */\nexport function pageEditorLooks(doc: ThemeDoc | null | undefined): LookOption[] {\n const system = PAGE_EDITOR_SYSTEM_KEYS.map((value) => ({\n label: SYSTEM_LABELS[value],\n value,\n }));\n const custom = libraryRows(doc)\n .map((row) => {\n const value = row.key?.trim();\n if (!value) return null;\n return { label: row.label?.trim() || titleCase(value), value };\n })\n .filter((option): option is LookOption => option !== null);\n return [...system, ...custom];\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear. System\n * scales with no stored include list offer the full 50–950 ramp.\n */\nexport function pageEditorTokens(doc: ThemeDoc | null | undefined): LookOption[] {\n const tokens: LookOption[] = [];\n for (const key of PAGE_EDITOR_SYSTEM_KEYS) {\n const label = SYSTEM_LABELS[key];\n for (const step of stepsFor(brandColor(doc, key), \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n for (const row of libraryRows(doc)) {\n const key = row.key?.trim();\n if (!key) continue;\n const label = row.label?.trim() || titleCase(key);\n for (const step of stepsFor(row, row.hex ?? \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n return tokens;\n}\n\nexport async function themeDocFromRequest(req: {\n payload?: {\n findGlobal?: (args: {\n slug: string;\n depth?: number;\n overrideAccess?: boolean;\n }) => Promise<ThemeDoc | null | undefined>;\n };\n}): Promise<ThemeDoc | null> {\n try {\n const doc = await req.payload?.findGlobal?.({\n slug: THEME_SLUG,\n depth: 0,\n overrideAccess: true,\n });\n return doc ?? null;\n } catch {\n return null;\n }\n}\n","import type { StaticLabel, TextField, TextFieldSingleValidation } from \"payload\";\n\nimport { LOOK_FIELD } from \"./fields\";\nimport { pageEditorLooks, pageEditorTokens, themeDocFromRequest } from \"./looks\";\n\nexport interface LookFieldOptions {\n name?: string;\n label?: StaticLabel;\n required?: boolean;\n admin?: TextField[\"admin\"];\n validate?: TextFieldSingleValidation;\n}\n\nexport type LookFieldMode = \"look\" | \"token\";\n\nexport const validateLook: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick a look from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorLooks(doc).some((look) => look.value === value)) return true;\n return \"Pick a look from Theme → Colors\";\n};\n\nexport const validateColorToken: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick an included step from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorTokens(doc).some((token) => token.value === value)) return true;\n return \"Pick an included step from Theme → Colors\";\n};\n\nfunction pickerField(\n defaults: { name: string; label: string; mode: LookFieldMode; validate: TextFieldSingleValidation },\n overrides: LookFieldOptions,\n): TextField {\n const { name = defaults.name, label = defaults.label, admin, required, validate = defaults.validate } = overrides;\n return {\n name,\n type: \"text\",\n label,\n required,\n validate,\n admin: {\n ...admin,\n components: { Field: LOOK_FIELD, ...admin?.components },\n custom: { mode: defaults.mode, ...admin?.custom },\n },\n };\n}\n\n/**\n * A picker any collection or global can offer. Options come from the\n * published Theme at request time: page-editor system scales plus custom\n * Colors. Payload select options are a static list, so this is a text\n * field with an admin picker — adding Coral does not need a schema change.\n */\nexport function lookField(overrides: LookFieldOptions = {}): TextField {\n return pickerField({ name: \"look\", label: \"Look\", mode: \"look\", validate: validateLook }, overrides);\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear.\n */\nexport function colorTokenField(overrides: LookFieldOptions = {}): TextField {\n return pickerField(\n { name: \"color\", label: \"Color\", mode: \"token\", validate: validateColorToken },\n overrides,\n );\n}\n","import type { ThemeDoc, ThemeUploadDoc } from \"./types\";\n\nexport interface ThemeIdentityAsset {\n url: string;\n alt: string;\n}\n\nexport interface ThemeIdentityFallback {\n lockup?: ThemeIdentityAsset;\n mark?: ThemeIdentityAsset;\n favicon?: ThemeIdentityAsset;\n}\n\nexport interface ResolvedThemeIdentity {\n lockup: ThemeIdentityAsset | null;\n mark: ThemeIdentityAsset | null;\n favicon: ThemeIdentityAsset | null;\n}\n\nfunction fromUpload(value: ThemeDoc[\"logo\"], fallback?: ThemeIdentityAsset): ThemeIdentityAsset | null {\n if (value && typeof value === \"object\") {\n const upload = value as ThemeUploadDoc;\n if (upload.url) {\n return { url: upload.url, alt: upload.alt ?? fallback?.alt ?? \"\" };\n }\n }\n return fallback ?? null;\n}\n\n/**\n * Uploaded logo, favicon, and mobile-menu mark, or the fallback the site\n * passed into `createTheme`. Empty fields keep the fallback;\n * `--color-primary-mark` is not a Theme field.\n */\nexport function resolveThemeIdentity(\n doc: ThemeDoc | null | undefined,\n fallback?: ThemeIdentityFallback,\n): ResolvedThemeIdentity {\n return {\n lockup: fromUpload(doc?.logo, fallback?.lockup),\n mark: fromUpload(doc?.logoMark, fallback?.mark),\n favicon: fromUpload(doc?.favicon, fallback?.favicon),\n };\n}\n"],"mappings":";;AAIA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,sBAAsB;AACnC,MAAa,yBAAyB;AACtC,MAAa,yBAAyB;AACtC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;AACnC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;AACvC,MAAa,aAAa;AA6B1B,SAAgB,mBAAmB,SAA6C;AAC9E,QA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,MAAM,SAAS;AACf,MAAI,OAAO,IACT,QAAO;GAAE,KAAK,OAAO;GAAK,KAAK,OAAO,OAAO,UAAU,OAAO;GAAI;;AAGtE,QAAO,YAAY;;;;;;;AAQrB,SAAgB,qBACd,KACA,UACuB;AACvB,QAAO;EACL,QAAQ,WAAW,KAAK,MAAM,UAAU,OAAO;EAC/C,MAAM,WAAW,KAAK,UAAU,UAAU,KAAK;EAC/C,SAAS,WAAW,KAAK,SAAS,UAAU,QAAQ;EACrD"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as SeoImageSize, i as SeoImageDoc, n as titleTemplate, o as SeoImageValue, r as MediaId, s as SeoMeta, t as documentTitle } from "./title-
|
|
2
|
-
import { A as ThemeLibraryColorDoc, C as THEME_IDENTITY_SLUG, D as ThemeDoc, E as ThemeColorDoc, M as ResolvedThemeIdentity, N as ThemeIdentityFallback, P as resolveThemeIdentity, S as THEME_COLORS_SLUG, T as THEME_TYPOGRAPHY_SLUG, _ as CreateThemeOptions, a as pageEditorTokens, b as SystemColorKey, c as LookFieldOptions, d as ColorTokenHit, f as findColorTokens, g as themeColorKeys, h as rewriteColorToken, i as pageEditorLooks, j as ThemeUploadDoc, l as colorTokenField, m as deleteLibraryColor, n as PAGE_EDITOR_SYSTEM_KEYS, o as themeLibraryFromDoc, p as rewriteColorTokens, r as PageEditorSystemKey, s as LookFieldMode, t as LookOption, u as lookField, v as EditableTheme, w as THEME_SLUG, x as THEME_APPEARANCE_SLUG, y as SYSTEM_COLOR_KEYS } from "./looks-
|
|
1
|
+
import { a as SeoImageSize, i as SeoImageDoc, n as titleTemplate, o as SeoImageValue, r as MediaId, s as SeoMeta, t as documentTitle } from "./title-sWwcCqHT.mjs";
|
|
2
|
+
import { A as ThemeLibraryColorDoc, C as THEME_IDENTITY_SLUG, D as ThemeDoc, E as ThemeColorDoc, M as ResolvedThemeIdentity, N as ThemeIdentityFallback, P as resolveThemeIdentity, S as THEME_COLORS_SLUG, T as THEME_TYPOGRAPHY_SLUG, _ as CreateThemeOptions, a as pageEditorTokens, b as SystemColorKey, c as LookFieldOptions, d as ColorTokenHit, f as findColorTokens, g as themeColorKeys, h as rewriteColorToken, i as pageEditorLooks, j as ThemeUploadDoc, l as colorTokenField, m as deleteLibraryColor, n as PAGE_EDITOR_SYSTEM_KEYS, o as themeLibraryFromDoc, p as rewriteColorTokens, r as PageEditorSystemKey, s as LookFieldMode, t as LookOption, u as lookField, v as EditableTheme, w as THEME_SLUG, x as THEME_APPEARANCE_SLUG, y as SYSTEM_COLOR_KEYS } from "./looks-Xs6v5vYU.mjs";
|
|
3
3
|
import { ThemeConfig } from "@bison-lab/tokens";
|
|
4
4
|
import * as payload from "payload";
|
|
5
5
|
import { Access, Block, CheckboxField, CollectionConfig, CollectionSlug, GlobalConfig, ImageSize, PayloadRequest, Plugin, TextField, UploadCollectionSlug } from "payload";
|
|
@@ -294,8 +294,12 @@ declare const LOOK_FIELD = "@bison-lab/payload-core/admin#LookField";
|
|
|
294
294
|
declare const ROLES: readonly ["developer", "admin", "designer", "author"];
|
|
295
295
|
type Role = (typeof ROLES)[number];
|
|
296
296
|
declare const ROLE_LABELS: Record<Role, string>;
|
|
297
|
+
/** Capability aliases over feature grants. Brand is any Theme-group leaf. */
|
|
297
298
|
declare const CAPABILITIES: readonly ["content", "brand", "publish", "users"];
|
|
298
299
|
type Capability = (typeof CAPABILITIES)[number];
|
|
300
|
+
declare const THEME_FEATURE_SLUGS: readonly ["theme-colors", "theme-typography", "theme-appearance", "theme-identity", "brand-assets"];
|
|
301
|
+
declare const CAPABILITY_FEATURES: Record<Capability, readonly string[]>;
|
|
302
|
+
declare const DEFAULT_ROLE_GRANTS: Record<Role, readonly string[]>;
|
|
299
303
|
/**
|
|
300
304
|
* A site-defined row passed into `createRoles({ extras })`. The slug is the
|
|
301
305
|
* stored key; the label is what Settings → Roles and Users show.
|
|
@@ -303,19 +307,13 @@ type Capability = (typeof CAPABILITIES)[number];
|
|
|
303
307
|
interface RoleExtra {
|
|
304
308
|
role: string;
|
|
305
309
|
label: string;
|
|
306
|
-
|
|
307
|
-
brand: boolean;
|
|
308
|
-
publish: boolean;
|
|
309
|
-
users: boolean;
|
|
310
|
+
grants?: readonly string[];
|
|
310
311
|
}
|
|
311
312
|
interface RoleRow {
|
|
312
313
|
id?: string | null;
|
|
313
314
|
role: string;
|
|
314
315
|
label?: string | null;
|
|
315
|
-
|
|
316
|
-
brand: boolean;
|
|
317
|
-
publish: boolean;
|
|
318
|
-
users: boolean;
|
|
316
|
+
grants: string[];
|
|
319
317
|
}
|
|
320
318
|
interface RolesDoc {
|
|
321
319
|
roles?: RoleRow[] | null;
|
|
@@ -330,22 +328,29 @@ type MaybeUser = {
|
|
|
330
328
|
roles?: readonly string[] | null;
|
|
331
329
|
} | null | undefined;
|
|
332
330
|
declare function isRole(value: unknown): value is Role;
|
|
333
|
-
/** Lowercase slug: `
|
|
331
|
+
/** Lowercase slug from a letters-and-spaces name: `designer`, `the-designer`. */
|
|
334
332
|
declare function isRoleSlug(value: unknown): value is string;
|
|
333
|
+
/** Display name: letters and single spaces only. `The Greatest Designer`. */
|
|
334
|
+
declare function isRoleName(value: unknown): value is string;
|
|
335
|
+
/** Strip digits and punctuation as the name is typed. Trailing space stays. */
|
|
336
|
+
declare function sanitizeRoleNameInput(value: string): string;
|
|
337
|
+
/** Name → stored key. `The Greatest Designer` → `the-greatest-designer`. */
|
|
338
|
+
declare function slugifyRoleName(value: unknown): string;
|
|
335
339
|
declare function roleLabel(role: string, label?: string | null): string;
|
|
336
340
|
//#endregion
|
|
337
341
|
//#region src/roles/global.d.ts
|
|
338
342
|
interface CreateRolesOptions {
|
|
339
343
|
/**
|
|
340
344
|
* Extra catalogue rows after the seed four. Each is a slug, a display
|
|
341
|
-
* label, and default
|
|
345
|
+
* label, and default grants. A site that passes nothing still gets
|
|
342
346
|
* Developer / Admin / Designer / Author.
|
|
343
347
|
*/
|
|
344
348
|
extras?: readonly RoleExtra[];
|
|
345
349
|
}
|
|
346
350
|
/**
|
|
347
|
-
* Settings → Roles. Rank is the array order (Payload's drag handle).
|
|
348
|
-
* are
|
|
351
|
+
* Settings → Roles. Rank is the array order (Payload's drag handle).
|
|
352
|
+
* Ticks are released catalogue rows. Developer is implicit and shown
|
|
353
|
+
* only to a Developer, with every catalogue tick locked on.
|
|
349
354
|
*/
|
|
350
355
|
declare function createRoles({
|
|
351
356
|
extras
|
|
@@ -369,42 +374,50 @@ declare function seedRoles(payload: SeedRolesPayload, extras?: readonly RoleExtr
|
|
|
369
374
|
declare const ROLES_MATRIX_FIELD = "@bison-lab/payload-core/admin#RolesMatrixField";
|
|
370
375
|
declare const ROLES_ROW_LABEL = "@bison-lab/payload-core/admin#RolesRowLabel";
|
|
371
376
|
declare const ROLE_SLUG_FIELD = "@bison-lab/payload-core/admin#RoleSlugField";
|
|
377
|
+
declare const ROLE_NAME_FIELD = "@bison-lab/payload-core/admin#RoleNameField";
|
|
372
378
|
declare const ROLES_FIELD = "@bison-lab/payload-core/admin#RolesField";
|
|
379
|
+
declare const ROLES_GRANTS_FIELD = "@bison-lab/payload-core/admin#RolesGrantsField";
|
|
373
380
|
//#endregion
|
|
374
381
|
//#region src/features/types.d.ts
|
|
375
382
|
declare const FEATURES_SLUG = "features";
|
|
376
|
-
declare const
|
|
383
|
+
declare const FEATURE_GROUPS: readonly ["pages", "media", "theme", "users"];
|
|
384
|
+
type FeatureGroupId = (typeof FEATURE_GROUPS)[number];
|
|
385
|
+
declare const FEATURE_GROUP_LABELS: Record<FeatureGroupId, string>;
|
|
386
|
+
declare const PACKAGE_FEATURE_SLUGS: readonly ["content", "publish", "api-tab", "media", "theme-colors", "theme-typography", "theme-appearance", "theme-identity", "brand-assets", "users", "roles"];
|
|
377
387
|
type PackageFeatureSlug = (typeof PACKAGE_FEATURE_SLUGS)[number];
|
|
378
388
|
interface PackageFeature {
|
|
379
389
|
slug: PackageFeatureSlug;
|
|
380
390
|
label: string;
|
|
381
|
-
|
|
382
|
-
|
|
391
|
+
group: FeatureGroupId;
|
|
392
|
+
defaultReleased: boolean;
|
|
383
393
|
}
|
|
384
394
|
/**
|
|
385
|
-
* Package catalogue.
|
|
386
|
-
*
|
|
387
|
-
* Brand assets, Users → Users/Roles/Features).
|
|
395
|
+
* Package catalogue. Features itself is not a row — that screen is
|
|
396
|
+
* Developer-only in code. Empty Global falls back to these defaults.
|
|
388
397
|
*/
|
|
389
398
|
declare const PACKAGE_FEATURES: readonly PackageFeature[];
|
|
390
399
|
/** A site-only row. Other sites never see this slug. */
|
|
391
400
|
interface FeatureExtra {
|
|
392
401
|
slug: string;
|
|
393
402
|
label: string;
|
|
403
|
+
group?: FeatureGroupId;
|
|
404
|
+
defaultReleased?: boolean;
|
|
394
405
|
}
|
|
395
406
|
interface FeatureRow {
|
|
396
407
|
id?: string | null;
|
|
397
408
|
slug: string;
|
|
398
409
|
label?: string | null;
|
|
399
|
-
|
|
400
|
-
|
|
410
|
+
group?: string | null;
|
|
411
|
+
released: boolean;
|
|
401
412
|
}
|
|
402
413
|
interface FeaturesDoc {
|
|
403
414
|
features?: FeatureRow[] | null;
|
|
404
415
|
}
|
|
416
|
+
declare function isFeatureGroupId(value: unknown): value is FeatureGroupId;
|
|
405
417
|
declare function isPackageFeatureSlug(value: unknown): value is PackageFeatureSlug;
|
|
406
418
|
declare function isFeatureSlug(value: unknown): value is string;
|
|
407
|
-
|
|
419
|
+
/** @deprecated Locks are gone; the release switch is the valve. */
|
|
420
|
+
declare function isLockedFeature(_slug: string, _locked?: boolean | null): boolean;
|
|
408
421
|
//#endregion
|
|
409
422
|
//#region src/features/global.d.ts
|
|
410
423
|
interface CreateFeaturesOptions {
|
|
@@ -415,8 +428,9 @@ interface CreateFeaturesOptions {
|
|
|
415
428
|
extras?: readonly FeatureExtra[];
|
|
416
429
|
}
|
|
417
430
|
/**
|
|
418
|
-
* Settings → Features.
|
|
419
|
-
*
|
|
431
|
+
* Settings → Features. One release switch per catalogue row. Off hides
|
|
432
|
+
* the tick on Roles; Developer still has the feature. This screen is
|
|
433
|
+
* not itself a row.
|
|
420
434
|
*/
|
|
421
435
|
declare function createFeatures({
|
|
422
436
|
extras
|
|
@@ -454,6 +468,7 @@ declare function hasRole(user: MaybeUser, role: string): boolean;
|
|
|
454
468
|
/** Not a tick. True only when `developer` is stored on the row. */
|
|
455
469
|
declare function isDeveloper(user: MaybeUser): boolean;
|
|
456
470
|
declare function hasCapability(user: MaybeUser, capability: Capability, matrix?: readonly RoleRow[]): boolean;
|
|
471
|
+
declare function hasGrant(user: MaybeUser, slug: string, matrix?: readonly RoleRow[]): boolean;
|
|
457
472
|
/**
|
|
458
473
|
* Reads the saved Roles Global, falling back to the seed when the row is
|
|
459
474
|
* empty, missing, or unreadable. Always override-access so a Designer
|
|
@@ -463,18 +478,21 @@ declare function getRolesMatrix(req?: AccessArgs$1["req"], extras?: readonly Rol
|
|
|
463
478
|
declare const canManageContent: CapabilityPredicate;
|
|
464
479
|
declare const canManageBrand: CapabilityPredicate;
|
|
465
480
|
declare const canPublish: CapabilityPredicate;
|
|
466
|
-
/** Users
|
|
481
|
+
/** Users grant on any held role (Developer is implicit). */
|
|
467
482
|
declare const isAdmin: CapabilityPredicate;
|
|
468
|
-
/** This role id currently has the Users
|
|
483
|
+
/** This role id currently has the Users grant, or is Developer. */
|
|
469
484
|
declare function isPrivilegedRole(role: unknown, matrix?: readonly RoleRow[]): boolean;
|
|
470
485
|
declare function isAuthenticated(user: MaybeUser): boolean;
|
|
471
486
|
declare function isAuthenticated(args: AccessArgs$1): boolean;
|
|
472
487
|
declare const isAdminOrSelf: Access;
|
|
473
488
|
declare const authenticatedOrPublished: Access;
|
|
474
|
-
/**
|
|
489
|
+
/**
|
|
490
|
+
* API tab condition. Unreleased (the default) is Developer only.
|
|
491
|
+
* After Features releases it, whoever holds the grant sees it.
|
|
492
|
+
*/
|
|
475
493
|
declare function isDeveloperTab({
|
|
476
494
|
req
|
|
477
|
-
}: AccessArgs$1): boolean
|
|
495
|
+
}: AccessArgs$1): boolean | Promise<boolean>;
|
|
478
496
|
//#endregion
|
|
479
497
|
//#region src/features/access.d.ts
|
|
480
498
|
type AccessArgs = {
|
|
@@ -488,13 +506,14 @@ type FeaturePredicate = {
|
|
|
488
506
|
(args: AccessArgs): boolean | Promise<boolean>;
|
|
489
507
|
};
|
|
490
508
|
/**
|
|
491
|
-
* True when
|
|
492
|
-
*
|
|
509
|
+
* True when the feature is released and a held role is granted it.
|
|
510
|
+
* Developer is always allowed. An empty Global falls back to catalogue
|
|
511
|
+
* defaults. A group slug (`pages`, `theme`) is true when any child is.
|
|
493
512
|
*/
|
|
494
513
|
declare function hasFeature(user: MaybeUser, slug: string, features?: readonly FeatureRow[] | null, matrix?: readonly RoleRow[]): boolean;
|
|
495
514
|
/**
|
|
496
515
|
* Reads the saved Features Global. `null` means empty or unreadable — callers
|
|
497
|
-
* fall back to
|
|
516
|
+
* fall back to catalogue defaults. Always override-access.
|
|
498
517
|
*/
|
|
499
518
|
declare function getFeaturesMatrix(req?: AccessArgs["req"]): Promise<FeatureRow[] | null>;
|
|
500
519
|
/**
|
|
@@ -509,16 +528,16 @@ declare function hideUnlessFeature(slug: string): (args: {
|
|
|
509
528
|
}) => boolean | Promise<boolean>;
|
|
510
529
|
//#endregion
|
|
511
530
|
//#region src/features/matrix.d.ts
|
|
512
|
-
declare const MISSING_PACKAGE_FEATURES_MESSAGE = "Features must include
|
|
513
|
-
declare const LOCKED_FEATURE_MESSAGE = "Users, Roles, and Features cannot be turned off. Developer stays allowed on every row.";
|
|
531
|
+
declare const MISSING_PACKAGE_FEATURES_MESSAGE = "Features must include Content, Publish, API tab, Media, Theme screens, Brand assets, Users, and Roles.";
|
|
514
532
|
interface FeatureCatalogueEntry {
|
|
515
533
|
slug: string;
|
|
516
534
|
label: string;
|
|
517
|
-
|
|
518
|
-
|
|
535
|
+
group: FeatureGroupId;
|
|
536
|
+
defaultReleased: boolean;
|
|
519
537
|
}
|
|
520
538
|
declare function featureCatalogue(extras?: readonly FeatureExtra[]): FeatureCatalogueEntry[];
|
|
521
|
-
declare function defaultFeaturesFieldValue(extras?: readonly FeatureExtra[]
|
|
539
|
+
declare function defaultFeaturesFieldValue(extras?: readonly FeatureExtra[]): FeatureRow[];
|
|
540
|
+
declare function stampFeatureCatalogue(value: unknown, extras?: readonly FeatureExtra[]): FeatureRow[];
|
|
522
541
|
declare function parseFeaturesMatrix(value: unknown): {
|
|
523
542
|
ok: true;
|
|
524
543
|
rows: FeatureRow[];
|
|
@@ -526,7 +545,8 @@ declare function parseFeaturesMatrix(value: unknown): {
|
|
|
526
545
|
ok: false;
|
|
527
546
|
message: string;
|
|
528
547
|
};
|
|
529
|
-
declare function validateFeaturesMatrix(value: unknown, extras?: readonly FeatureExtra[]
|
|
548
|
+
declare function validateFeaturesMatrix(value: unknown, extras?: readonly FeatureExtra[]): true | string;
|
|
549
|
+
declare function featureGroupLabel(group: string): string;
|
|
530
550
|
//#endregion
|
|
531
551
|
//#region src/collections/pages.d.ts
|
|
532
552
|
interface PagesOptions {
|
|
@@ -658,16 +678,18 @@ declare const adminOnlyApiTab: () => payload.Plugin;
|
|
|
658
678
|
//#region src/roles/matrix.d.ts
|
|
659
679
|
declare const ROLES_SLUG = "roles";
|
|
660
680
|
declare const ROLES_GLOBAL_DESCRIPTION = "Who may do what. Drag to change rank.";
|
|
661
|
-
declare const ROLES_FIELD_DESCRIPTION = "Drag to change rank. Ticks are
|
|
681
|
+
declare const ROLES_FIELD_DESCRIPTION = "Drag to change rank. Ticks are features released on Features. Developer has the whole catalogue.";
|
|
662
682
|
/**
|
|
663
|
-
* Default rank and
|
|
664
|
-
*
|
|
683
|
+
* Default rank and grants. Developer is implicit (empty grants). Brand
|
|
684
|
+
* screens default to Designer. The API tab is not granted until released.
|
|
665
685
|
*/
|
|
666
686
|
declare const DEFAULT_ROLE_MATRIX: readonly RoleRow[];
|
|
667
|
-
declare const DEVELOPER_DESCRIPTION = "Everything
|
|
668
|
-
declare const LAST_USERS_TICK_MESSAGE = "Keep Users
|
|
687
|
+
declare const DEVELOPER_DESCRIPTION = "Everything, including features not released for assignment.";
|
|
688
|
+
declare const LAST_USERS_TICK_MESSAGE = "Keep Users granted on at least one of Admin or Developer.";
|
|
669
689
|
declare const MISSING_SEED_ROLES_MESSAGE = "Roles must include Developer, Admin, Designer, and Author.";
|
|
670
690
|
declare const DUPLICATE_ROLE_SLUG_MESSAGE = "Each role needs a unique slug.";
|
|
691
|
+
declare const DUPLICATE_ROLE_NAME_MESSAGE = "Each role needs a unique name.";
|
|
692
|
+
declare const INVALID_ROLE_NAME_MESSAGE = "Use letters and spaces only.";
|
|
671
693
|
declare function seedRoleRows(extras?: readonly RoleExtra[]): RoleRow[];
|
|
672
694
|
declare function defaultRolesFieldValue(extras?: readonly RoleExtra[]): RoleRow[];
|
|
673
695
|
declare function parseRolesMatrix(value: unknown): {
|
|
@@ -677,6 +699,11 @@ declare function parseRolesMatrix(value: unknown): {
|
|
|
677
699
|
ok: false;
|
|
678
700
|
message: string;
|
|
679
701
|
};
|
|
702
|
+
/**
|
|
703
|
+
* Mint a slug from the name only when the row has none yet. An existing
|
|
704
|
+
* key — seed or custom — stays put so a rename cannot orphan users.
|
|
705
|
+
*/
|
|
706
|
+
declare function applyRoleSlugsFromNames(value: unknown): unknown;
|
|
680
707
|
declare function validateRolesMatrix(value: unknown): true | string;
|
|
681
708
|
/**
|
|
682
709
|
* Developer is exclusive. Admin does not swallow Designer: both store.
|
|
@@ -688,12 +715,12 @@ declare function roleSelectOptions(matrix?: readonly RoleRow[]): {
|
|
|
688
715
|
label: string;
|
|
689
716
|
value: string;
|
|
690
717
|
}[];
|
|
691
|
-
/**
|
|
718
|
+
/** Grant copy only. Developer names the unreleased catalogue; nothing about MCP or seed. */
|
|
692
719
|
declare function roleDescription(role: string, matrix?: readonly RoleRow[]): string;
|
|
693
720
|
/**
|
|
694
|
-
* Seed
|
|
721
|
+
* Seed grants and package labels come back; extra rows stay as they are.
|
|
695
722
|
*/
|
|
696
723
|
declare function resetRolesMatrix(current: unknown): RoleRow[];
|
|
697
724
|
//#endregion
|
|
698
|
-
export { BRAND_ASSETS_MIME_TYPES, BRAND_ASSETS_SLUG, CAPABILITIES, type Capability, type ColorTokenHit, type ColorUsage, type ColorUsagesOption, type CreateBrandAssetsOptions, type CreateFeaturesOptions, type CreateRolesOptions, type CreateThemeOptions, DEFAULT_ROLE_MATRIX, DESCRIPTION_LENGTH, DEVELOPER_DESCRIPTION, DUPLICATE_ROLE_SLUG_MESSAGE, type EditableTheme, FEATURES_MATRIX_FIELD, FEATURES_SLUG, type FeatureExtra, type FeatureRow, type FeaturesDoc, LAST_ADMIN_DELETE_MESSAGE, LAST_ADMIN_DEMOTE_MESSAGE, LAST_USERS_TICK_MESSAGE,
|
|
725
|
+
export { BRAND_ASSETS_MIME_TYPES, BRAND_ASSETS_SLUG, CAPABILITIES, CAPABILITY_FEATURES, type Capability, type ColorTokenHit, type ColorUsage, type ColorUsagesOption, type CreateBrandAssetsOptions, type CreateFeaturesOptions, type CreateRolesOptions, type CreateThemeOptions, DEFAULT_ROLE_GRANTS, DEFAULT_ROLE_MATRIX, DESCRIPTION_LENGTH, DEVELOPER_DESCRIPTION, DUPLICATE_ROLE_NAME_MESSAGE, DUPLICATE_ROLE_SLUG_MESSAGE, type EditableTheme, FEATURES_MATRIX_FIELD, FEATURES_SLUG, FEATURE_GROUPS, FEATURE_GROUP_LABELS, type FeatureExtra, type FeatureGroupId, type FeatureRow, type FeaturesDoc, INVALID_ROLE_NAME_MESSAGE, LAST_ADMIN_DELETE_MESSAGE, LAST_ADMIN_DEMOTE_MESSAGE, LAST_USERS_TICK_MESSAGE, LOOK_FIELD, type LookFieldMode, type LookFieldOptions, type LookOption, MISSING_PACKAGE_FEATURES_MESSAGE, MISSING_SEED_ROLES_MESSAGE, type MaybeUser, type MediaId, type MediaOptions, PACKAGE_FEATURES, PACKAGE_FEATURE_SLUGS, PAGE_EDITOR_SYSTEM_KEYS, type PackageFeature, type PackageFeatureSlug, type PageEditorSystemKey, type PagesOptions, ROLES, ROLES_FIELD, ROLES_FIELD_DESCRIPTION, ROLES_GLOBAL_DESCRIPTION, ROLES_GRANTS_FIELD, ROLES_MATRIX_FIELD, ROLES_ROW_LABEL, ROLES_SLUG, ROLE_LABELS, ROLE_NAME_FIELD, ROLE_SLUG_FIELD, type ResolvedThemeIdentity, type Role, type RoleExtra, type RoleRow, type RolesDoc, SHARE_IMAGE_SIZE, SYSTEM_COLOR_KEYS, type SeoDoc, type SeoImageDoc, type SeoImageSize, type SeoImageValue, type SeoMeta, type SeoPluginOptions, type SlugFieldOptions, type SystemColorKey, THEME_APPEARANCE_FIELD, THEME_APPEARANCE_SLUG, THEME_COLORS_SLUG, THEME_COLOR_FIELD, THEME_COLOR_SCALE_FIELD, THEME_CONTRAST_REPORT, THEME_DOCUMENT_CONTROLS, THEME_FEATURE_SLUGS, THEME_FONT_FIELD, THEME_GREY_SCALE_FIELD, THEME_IDENTITY_FALLBACK, THEME_IDENTITY_SLUG, THEME_LIBRARY_FIELD, THEME_PAIRING_FIELD, THEME_PREVIEW_BREAKPOINTS, THEME_PUBLISH_FIELD, THEME_SAVE_BUTTON, THEME_SECTION_HEADING, THEME_SLUG, THEME_TYPOGRAPHY_SLUG, type ThemeChild, type ThemeColorDoc, type ThemeDoc, type ThemeIdentityFallback, type ThemeLibraryColorDoc, type ThemeUploadDoc, type UsersOptions, adminOnlyApiTab, applyRoleSlugsFromNames, authenticatedOrPublished, canManageBrand, canManageContent, canPublish, canUseFeature, colorTokenField, createBrandAssets, createFeatures, createMedia, createPages, createRoles, createTheme, createUsers, defaultFeaturesFieldValue, defaultRolesFieldValue, deleteLibraryColor, documentTitle, featureCatalogue, featureGroupLabel, findColorTokens, findColorUsages, firstImageIn, getFeaturesMatrix, getRolesMatrix, hasCapability, hasFeature, hasGrant, hasRole, hideUnlessFeature, isAdmin, isAdminOrSelf, isAuthenticated, isDeveloper, isDeveloperTab, isFeatureGroupId, isFeatureSlug, isLockedFeature, isPackageFeatureSlug, isPrivilegedRole, isRole, isRoleName, isRoleSlug, lookField, noIndexField, normalizeSlug, normalizeStoredRoles, pageEditorLooks, pageEditorTokens, parseFeaturesMatrix, parseRolesMatrix, persistThemeChild, publishThemeChild, resetRolesMatrix, resolveThemeIdentity, rewriteColorToken, rewriteColorTokens, rewriteColorUsages, roleDescription, roleLabel, roleSelectOptions, sanitizeRoleNameInput, sanitizeSvg, seedFeatures, seedRoleRows, seedRoles, seedTheme, seoPlugin, slugField, slugifyRoleName, stampFeatureCatalogue, storedRoles, themeColorKeys, themeLibraryFromDoc, titleTemplate, truncateAtWord, validateFeaturesMatrix, validateRolesMatrix };
|
|
699
726
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/seo/plugin.ts","../src/seo/fields.ts","../src/seo/share-image.ts","../src/seo/text.ts","../src/theme/global.ts","../src/brand-assets/collection.ts","../src/brand-assets/sanitize.ts","../src/theme/seed.ts","../src/theme/color-usages.ts","../src/theme/preview.ts","../src/theme/publish.ts","../src/theme/fields.ts","../src/roles/types.ts","../src/roles/global.ts","../src/roles/seed.ts","../src/roles/fields.ts","../src/features/types.ts","../src/features/global.ts","../src/features/seed.ts","../src/features/fields.ts","../src/roles/access.ts","../src/features/access.ts","../src/features/matrix.ts","../src/collections/pages.ts","../src/collections/users.ts","../src/collections/media.ts","../src/fields/slug.ts","../src/plugins/admin-only-api-tab.ts","../src/roles/matrix.ts"],"mappings":";;;;;;;;;;;;AAoBA;UAAiB,MAAA;EACf,KAAA;AAAA;AAAA,UAGe,gBAAA,cAA8B,MAAA,GAAS,MAAA;EAAvC;EAEf,QAAA;EAF+B;;;;;;EAS/B,MAAA,GAAS,GAAA,EAAK,IAAA;EAeA;;;;;EATd,YAAA,IAAgB,GAAA,EAAK,IAAA;EAfiC;;;;;;EAsBtD,QAAA,IAAY,GAAA,EAAK,IAAA,KAAS,OAAA;EAPV;EAShB,WAAA,GAAc,cAAA;EAFG;EAIjB,iBAAA,GAAoB,oBAAA;AAAA;;;;;;;AAetB;;;;;;iBAAgB,SAAA,cAAuB,MAAA,GAAS,MAAA,CAAA,CAAA;EAC9C,QAAA;EACA,MAAA;EACA,YAAA;EACA,QAAA;EACA,WAAA;EACA;AAAA,GACC,gBAAA,CAAiB,IAAA,IAAQ,MAAA;;;;;;;iBA6BZ,YAAA,CACd,MAAA,WACA,KAAA,YACC,OAAA;;;;;;;;cCjGU,YAAA,EAAc,aAAA;;;;;;;;;;ADa3B;cEVa,gBAAA;;;;;;;;;cCTA,kBAAA;;;;;;AHmBb;iBGXgB,cAAA,CAAe,IAAA,UAAc,GAAA;;;;;;;;AHW7C;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/seo/plugin.ts","../src/seo/fields.ts","../src/seo/share-image.ts","../src/seo/text.ts","../src/theme/global.ts","../src/brand-assets/collection.ts","../src/brand-assets/sanitize.ts","../src/theme/seed.ts","../src/theme/color-usages.ts","../src/theme/preview.ts","../src/theme/publish.ts","../src/theme/fields.ts","../src/roles/types.ts","../src/roles/global.ts","../src/roles/seed.ts","../src/roles/fields.ts","../src/features/types.ts","../src/features/global.ts","../src/features/seed.ts","../src/features/fields.ts","../src/roles/access.ts","../src/features/access.ts","../src/features/matrix.ts","../src/collections/pages.ts","../src/collections/users.ts","../src/collections/media.ts","../src/fields/slug.ts","../src/plugins/admin-only-api-tab.ts","../src/roles/matrix.ts"],"mappings":";;;;;;;;;;;;AAoBA;UAAiB,MAAA;EACf,KAAA;AAAA;AAAA,UAGe,gBAAA,cAA8B,MAAA,GAAS,MAAA;EAAvC;EAEf,QAAA;EAF+B;;;;;;EAS/B,MAAA,GAAS,GAAA,EAAK,IAAA;EAeA;;;;;EATd,YAAA,IAAgB,GAAA,EAAK,IAAA;EAfiC;;;;;;EAsBtD,QAAA,IAAY,GAAA,EAA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