@agimon-ai/po-web-dashboard 0.0.0-alpha.147 → 0.0.0-alpha.148

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.
@@ -63,8 +63,8 @@ function BackdropSettings() {
63
63
  const configured = require_templateStore.configuredBackdrop(configuration);
64
64
  const shown = require_templateCatalog.resolveBackdrop(fills, configured);
65
65
  const current = shown === void 0 ? _agimon_ai_po_core_web.NO_BACKDROP : require_templateCatalog.backdropId(shown);
66
- const meadow = fills.find((fill) => require_templateCatalog.backdropId(fill) === _agimon_ai_po_core_web.DEFAULT_BACKDROP_ID);
67
- const fromPlugins = fills.filter((fill) => fill !== meadow);
66
+ const bamboo = fills.find((fill) => require_templateCatalog.backdropId(fill) === _agimon_ai_po_core_web.DEFAULT_BACKDROP_ID);
67
+ const fromPlugins = fills.filter((fill) => fill !== bamboo);
68
68
  const busy = configuration.saving || configuration.loading || configuration.config === void 0;
69
69
  const choose = (value) => {
70
70
  require_templateStore.saveBackdropDefault(value).then((saved) => {
@@ -82,10 +82,10 @@ function BackdropSettings() {
82
82
  value: current,
83
83
  onValueChange: choose,
84
84
  disabled: busy,
85
- children: [meadow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackdropCard, {
85
+ children: [bamboo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackdropCard, {
86
86
  value: _agimon_ai_po_core_web.DEFAULT_BACKDROP_ID,
87
- ...describe(meadow),
88
- fill: meadow,
87
+ ...describe(bamboo),
88
+ fill: bamboo,
89
89
  selected: current === _agimon_ai_po_core_web.DEFAULT_BACKDROP_ID
90
90
  }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackdropCard, {
91
91
  value: _agimon_ai_po_core_web.NO_BACKDROP,
@@ -1 +1 @@
1
- {"version":3,"file":"BackdropSettings.cjs","names":["backdropId","usePluginSlotProps","ToolRendererBoundary","RadioGroupCard","CheckIcon","useTemplateConfiguration","hostSlotFills","HOST_SLOTS","configuredBackdrop","resolveBackdrop","NO_BACKDROP","DEFAULT_BACKDROP_ID","saveBackdropDefault","reloadWebTemplateDecision","SettingsSection","SettingsSectionHeader","SettingsSectionTitle","SettingsSectionDescription","RadioGroup","SettingsNote"],"sources":["../../../../src/web/features/settings/BackdropSettings.tsx"],"sourcesContent":["import { DEFAULT_BACKDROP_ID, HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport {\n CheckIcon,\n RadioGroup,\n RadioGroupCard,\n SettingsNote,\n SettingsSection,\n SettingsSectionDescription,\n SettingsSectionHeader,\n SettingsSectionTitle,\n} from '@agimon-ai/po-web-components';\n\nimport { reloadWebTemplateDecision } from '../../lib/pluginCompositions';\nimport { hostSlotFills, type ResolvedFill } from '../../lib/pluginRegistry';\nimport { backdropId, resolveBackdrop } from '../../lib/templateCatalog';\nimport { ToolRendererBoundary } from '../../lib/ToolRendererBoundary';\nimport { configuredBackdrop, saveBackdropDefault, useTemplateConfiguration } from '../../stores/templateStore';\nimport { usePluginSlotProps } from '../../stores/usePluginSlotProps';\nimport { useWebPluginRegistry } from '../../stores/useWebPluginRegistry';\n\n/** A backdrop names itself with `data: { label, description }` on its fill; its id stands in otherwise. */\nfunction describe(fill: ResolvedFill): { label: string; description?: string } {\n const data = (typeof fill.data === 'object' && fill.data !== null ? fill.data : {}) as Record<string, unknown>;\n return {\n label: typeof data.label === 'string' ? data.label : backdropId(fill),\n ...(typeof data.description === 'string' ? { description: data.description } : {}),\n };\n}\n\n/** The backdrop itself, live and small: a backdrop fills whatever box it is given. */\nfunction Preview({ fill }: { fill?: ResolvedFill }) {\n const props = usePluginSlotProps(null);\n const Fill = fill?.component;\n return (\n <div aria-hidden className=\"relative aspect-video w-full overflow-hidden rounded border border-po-border bg-po-bg\">\n {fill && Fill ? (\n <ToolRendererBoundary toolName={backdropId(fill)}>\n {(failed) => (failed ? null : <Fill {...props} />)}\n </ToolRendererBoundary>\n ) : null}\n </div>\n );\n}\n\nfunction BackdropCard({\n value,\n label,\n description,\n fill,\n selected,\n}: {\n value: string;\n label: string;\n description?: string;\n fill?: ResolvedFill;\n selected: boolean;\n}) {\n return (\n <RadioGroupCard\n value={value}\n data-testid={`backdrop-${value}`}\n data-selected={selected}\n className=\"flex flex-col gap-3 rounded-lg p-3\"\n >\n <Preview fill={fill} />\n <span className=\"flex items-center gap-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate text-base font-semibold text-po-hi\">{label}</span>\n {description ? <span className=\"text-sm text-po-dim\">{description}</span> : null}\n </span>\n {selected ? <CheckIcon className=\"size-4 shrink-0 text-po-green\" /> : null}\n </span>\n </RadioGroupCard>\n );\n}\n\n/**\n * The one background behind every template. Picking a card saves it to the global config at once,\n * like a theme, so there is nothing to confirm. Exactly one shows; installing a package never\n * switches it on its own.\n */\nexport function BackdropSettings() {\n useWebPluginRegistry();\n const configuration = useTemplateConfiguration();\n const fills = hostSlotFills(HOST_SLOTS.backdrop).filter((fill) => fill.component !== undefined);\n const configured = configuredBackdrop(configuration);\n const shown = resolveBackdrop(fills, configured);\n const current = shown === undefined ? NO_BACKDROP : backdropId(shown);\n const meadow = fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID);\n const fromPlugins = fills.filter((fill) => fill !== meadow);\n const busy = configuration.saving || configuration.loading || configuration.config === undefined;\n const choose = (value: string): void => {\n void saveBackdropDefault(value).then((saved) => {\n if (saved) void reloadWebTemplateDecision();\n });\n };\n const group = 'grid grid-cols-1 gap-3 min-[480px]:grid-cols-2 lg:grid-cols-3';\n return (\n <SettingsSection data-testid=\"backdrop-settings\">\n <SettingsSectionHeader>\n <SettingsSectionTitle>Background</SettingsSectionTitle>\n <SettingsSectionDescription>\n What Po shows behind every layout. Applies straight away and is saved to your Po config.\n </SettingsSectionDescription>\n </SettingsSectionHeader>\n <RadioGroup aria-label=\"Background\" className={group} value={current} onValueChange={choose} disabled={busy}>\n {meadow ? (\n <BackdropCard\n value={DEFAULT_BACKDROP_ID}\n {...describe(meadow)}\n fill={meadow}\n selected={current === DEFAULT_BACKDROP_ID}\n />\n ) : null}\n <BackdropCard\n value={NO_BACKDROP}\n label=\"Plain\"\n description=\"Just the theme colour.\"\n selected={current === NO_BACKDROP}\n />\n </RadioGroup>\n {fromPlugins.length > 0 ? (\n <>\n <SettingsSectionTitle>From your plugins</SettingsSectionTitle>\n <RadioGroup\n aria-label=\"Backgrounds from your plugins\"\n className={group}\n value={current}\n onValueChange={choose}\n disabled={busy}\n >\n {fromPlugins.map((fill) => (\n <BackdropCard\n key={backdropId(fill)}\n value={backdropId(fill)}\n {...describe(fill)}\n fill={fill}\n selected={current === backdropId(fill)}\n />\n ))}\n </RadioGroup>\n </>\n ) : null}\n {configured !== undefined && configured !== NO_BACKDROP && configured !== current ? (\n <output className=\"block text-sm text-po-yellow\">\n The background <code className=\"font-mono\">{configured}</code> is not installed here, so{' '}\n {shown === undefined ? 'the plain one' : describe(shown).label} shows instead.\n </output>\n ) : null}\n {configuration.error ? (\n <p role=\"alert\" data-testid=\"backdrop-save-error\" className=\"text-sm text-po-red\">\n {configuration.error}\n </p>\n ) : null}\n <SettingsNote>\n Saved to <code className=\"font-mono\">~/.po/config.yaml</code> as <code className=\"font-mono\">web.backdrop</code>\n . Add your own from a global plugin with a <code className=\"font-mono\">backdrop</code> fill.\n </SettingsNote>\n </SettingsSection>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAS,SAAS,MAA6D;CAC7E,MAAM,OAAQ,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,OAAO,KAAK,OAAO,CAAC;CACjF,OAAO;EACL,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQA,wBAAAA,WAAW,IAAI;EACpE,GAAI,OAAO,KAAK,gBAAgB,WAAW,EAAE,aAAa,KAAK,YAAY,IAAI,CAAC;CAClF;AACF;;AAGA,SAAS,QAAQ,EAAE,QAAiC;CAClD,MAAM,QAAQC,2BAAAA,mBAAmB,IAAI;CACrC,M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WAAU;KAAY,UAAA;IAAc,CAAA;IAAC;GAC1E,EAAA,CAAA;EACC;;AAErB"}
1
+ {"version":3,"file":"BackdropSettings.cjs","names":["backdropId","usePluginSlotProps","ToolRendererBoundary","RadioGroupCard","CheckIcon","useTemplateConfiguration","hostSlotFills","HOST_SLOTS","configuredBackdrop","resolveBackdrop","NO_BACKDROP","DEFAULT_BACKDROP_ID","saveBackdropDefault","reloadWebTemplateDecision","SettingsSection","SettingsSectionHeader","SettingsSectionTitle","SettingsSectionDescription","RadioGroup","SettingsNote"],"sources":["../../../../src/web/features/settings/BackdropSettings.tsx"],"sourcesContent":["import { DEFAULT_BACKDROP_ID, HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport {\n CheckIcon,\n RadioGroup,\n RadioGroupCard,\n SettingsNote,\n SettingsSection,\n SettingsSectionDescription,\n SettingsSectionHeader,\n SettingsSectionTitle,\n} from '@agimon-ai/po-web-components';\n\nimport { reloadWebTemplateDecision } from '../../lib/pluginCompositions';\nimport { hostSlotFills, type ResolvedFill } from '../../lib/pluginRegistry';\nimport { backdropId, resolveBackdrop } from '../../lib/templateCatalog';\nimport { ToolRendererBoundary } from '../../lib/ToolRendererBoundary';\nimport { configuredBackdrop, saveBackdropDefault, useTemplateConfiguration } from '../../stores/templateStore';\nimport { usePluginSlotProps } from '../../stores/usePluginSlotProps';\nimport { useWebPluginRegistry } from '../../stores/useWebPluginRegistry';\n\n/** A backdrop names itself with `data: { label, description }` on its fill; its id stands in otherwise. */\nfunction describe(fill: ResolvedFill): { label: string; description?: string } {\n const data = (typeof fill.data === 'object' && fill.data !== null ? fill.data : {}) as Record<string, unknown>;\n return {\n label: typeof data.label === 'string' ? data.label : backdropId(fill),\n ...(typeof data.description === 'string' ? { description: data.description } : {}),\n };\n}\n\n/** The backdrop itself, live and small: a backdrop fills whatever box it is given. */\nfunction Preview({ fill }: { fill?: ResolvedFill }) {\n const props = usePluginSlotProps(null);\n const Fill = fill?.component;\n return (\n <div aria-hidden className=\"relative aspect-video w-full overflow-hidden rounded border border-po-border bg-po-bg\">\n {fill && Fill ? (\n <ToolRendererBoundary toolName={backdropId(fill)}>\n {(failed) => (failed ? null : <Fill {...props} />)}\n </ToolRendererBoundary>\n ) : null}\n </div>\n );\n}\n\nfunction BackdropCard({\n value,\n label,\n description,\n fill,\n selected,\n}: {\n value: string;\n label: string;\n description?: string;\n fill?: ResolvedFill;\n selected: boolean;\n}) {\n return (\n <RadioGroupCard\n value={value}\n data-testid={`backdrop-${value}`}\n data-selected={selected}\n className=\"flex flex-col gap-3 rounded-lg p-3\"\n >\n <Preview fill={fill} />\n <span className=\"flex items-center gap-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate text-base font-semibold text-po-hi\">{label}</span>\n {description ? <span className=\"text-sm text-po-dim\">{description}</span> : null}\n </span>\n {selected ? <CheckIcon className=\"size-4 shrink-0 text-po-green\" /> : null}\n </span>\n </RadioGroupCard>\n );\n}\n\n/**\n * The one background behind every template. Picking a card saves it to the global config at once,\n * like a theme, so there is nothing to confirm. Exactly one shows; installing a package never\n * switches it on its own.\n */\nexport function BackdropSettings() {\n useWebPluginRegistry();\n const configuration = useTemplateConfiguration();\n const fills = hostSlotFills(HOST_SLOTS.backdrop).filter((fill) => fill.component !== undefined);\n const configured = configuredBackdrop(configuration);\n const shown = resolveBackdrop(fills, configured);\n const current = shown === undefined ? NO_BACKDROP : backdropId(shown);\n const bamboo = fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID);\n const fromPlugins = fills.filter((fill) => fill !== bamboo);\n const busy = configuration.saving || configuration.loading || configuration.config === undefined;\n const choose = (value: string): void => {\n void saveBackdropDefault(value).then((saved) => {\n if (saved) void reloadWebTemplateDecision();\n });\n };\n const group = 'grid grid-cols-1 gap-3 min-[480px]:grid-cols-2 lg:grid-cols-3';\n return (\n <SettingsSection data-testid=\"backdrop-settings\">\n <SettingsSectionHeader>\n <SettingsSectionTitle>Background</SettingsSectionTitle>\n <SettingsSectionDescription>\n What Po shows behind every layout. Applies straight away and is saved to your Po config.\n </SettingsSectionDescription>\n </SettingsSectionHeader>\n <RadioGroup aria-label=\"Background\" className={group} value={current} onValueChange={choose} disabled={busy}>\n {bamboo ? (\n <BackdropCard\n value={DEFAULT_BACKDROP_ID}\n {...describe(bamboo)}\n fill={bamboo}\n selected={current === DEFAULT_BACKDROP_ID}\n />\n ) : null}\n <BackdropCard\n value={NO_BACKDROP}\n label=\"Plain\"\n description=\"Just the theme colour.\"\n selected={current === NO_BACKDROP}\n />\n </RadioGroup>\n {fromPlugins.length > 0 ? (\n <>\n <SettingsSectionTitle>From your plugins</SettingsSectionTitle>\n <RadioGroup\n aria-label=\"Backgrounds from your plugins\"\n className={group}\n value={current}\n onValueChange={choose}\n disabled={busy}\n >\n {fromPlugins.map((fill) => (\n <BackdropCard\n key={backdropId(fill)}\n value={backdropId(fill)}\n {...describe(fill)}\n fill={fill}\n selected={current === backdropId(fill)}\n />\n ))}\n </RadioGroup>\n </>\n ) : null}\n {configured !== undefined && configured !== NO_BACKDROP && configured !== current ? (\n <output className=\"block text-sm text-po-yellow\">\n The background <code className=\"font-mono\">{configured}</code> is not installed here, so{' '}\n {shown === undefined ? 'the plain one' : describe(shown).label} shows instead.\n </output>\n ) : null}\n {configuration.error ? (\n <p role=\"alert\" data-testid=\"backdrop-save-error\" className=\"text-sm text-po-red\">\n {configuration.error}\n </p>\n ) : null}\n <SettingsNote>\n Saved to <code className=\"font-mono\">~/.po/config.yaml</code> as <code className=\"font-mono\">web.backdrop</code>\n . Add your own from a global plugin with a <code className=\"font-mono\">backdrop</code> fill.\n </SettingsNote>\n </SettingsSection>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAS,SAAS,MAA6D;CAC7E,MAAM,OAAQ,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,OAAO,KAAK,OAAO,CAAC;CACjF,OAAO;EACL,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQA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C,QAAD;KAAM,WAAU;KAAY,UAAA;IAAuB,CAAA;IAAC;IAAI,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;KAAY,UAAA;IAAkB,CAAA;IAAC;IACrE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;KAAY,UAAA;IAAc,CAAA;IAAC;GAC1E,EAAA,CAAA;EACC;;AAErB"}
@@ -63,8 +63,8 @@ function BackdropSettings() {
63
63
  const configured = configuredBackdrop(configuration);
64
64
  const shown = resolveBackdrop(fills, configured);
65
65
  const current = shown === void 0 ? NO_BACKDROP : backdropId(shown);
66
- const meadow = fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID);
67
- const fromPlugins = fills.filter((fill) => fill !== meadow);
66
+ const bamboo = fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID);
67
+ const fromPlugins = fills.filter((fill) => fill !== bamboo);
68
68
  const busy = configuration.saving || configuration.loading || configuration.config === void 0;
69
69
  const choose = (value) => {
70
70
  saveBackdropDefault(value).then((saved) => {
@@ -82,10 +82,10 @@ function BackdropSettings() {
82
82
  value: current,
83
83
  onValueChange: choose,
84
84
  disabled: busy,
85
- children: [meadow ? /* @__PURE__ */ jsx(BackdropCard, {
85
+ children: [bamboo ? /* @__PURE__ */ jsx(BackdropCard, {
86
86
  value: DEFAULT_BACKDROP_ID,
87
- ...describe(meadow),
88
- fill: meadow,
87
+ ...describe(bamboo),
88
+ fill: bamboo,
89
89
  selected: current === DEFAULT_BACKDROP_ID
90
90
  }) : null, /* @__PURE__ */ jsx(BackdropCard, {
91
91
  value: NO_BACKDROP,
@@ -1 +1 @@
1
- {"version":3,"file":"BackdropSettings.mjs","names":[],"sources":["../../../../src/web/features/settings/BackdropSettings.tsx"],"sourcesContent":["import { DEFAULT_BACKDROP_ID, HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport {\n CheckIcon,\n RadioGroup,\n RadioGroupCard,\n SettingsNote,\n SettingsSection,\n SettingsSectionDescription,\n SettingsSectionHeader,\n SettingsSectionTitle,\n} from '@agimon-ai/po-web-components';\n\nimport { reloadWebTemplateDecision } from '../../lib/pluginCompositions';\nimport { hostSlotFills, type ResolvedFill } from '../../lib/pluginRegistry';\nimport { backdropId, resolveBackdrop } from '../../lib/templateCatalog';\nimport { ToolRendererBoundary } from '../../lib/ToolRendererBoundary';\nimport { configuredBackdrop, saveBackdropDefault, useTemplateConfiguration } from '../../stores/templateStore';\nimport { usePluginSlotProps } from '../../stores/usePluginSlotProps';\nimport { useWebPluginRegistry } from '../../stores/useWebPluginRegistry';\n\n/** A backdrop names itself with `data: { label, description }` on its fill; its id stands in otherwise. */\nfunction describe(fill: ResolvedFill): { label: string; description?: string } {\n const data = (typeof fill.data === 'object' && fill.data !== null ? fill.data : {}) as Record<string, unknown>;\n return {\n label: typeof data.label === 'string' ? data.label : backdropId(fill),\n ...(typeof data.description === 'string' ? { description: data.description } : {}),\n };\n}\n\n/** The backdrop itself, live and small: a backdrop fills whatever box it is given. */\nfunction Preview({ fill }: { fill?: ResolvedFill }) {\n const props = usePluginSlotProps(null);\n const Fill = fill?.component;\n return (\n <div aria-hidden className=\"relative aspect-video w-full overflow-hidden rounded border border-po-border bg-po-bg\">\n {fill && Fill ? (\n <ToolRendererBoundary toolName={backdropId(fill)}>\n {(failed) => (failed ? null : <Fill {...props} />)}\n </ToolRendererBoundary>\n ) : null}\n </div>\n );\n}\n\nfunction BackdropCard({\n value,\n label,\n description,\n fill,\n selected,\n}: {\n value: string;\n label: string;\n description?: string;\n fill?: ResolvedFill;\n selected: boolean;\n}) {\n return (\n <RadioGroupCard\n value={value}\n data-testid={`backdrop-${value}`}\n data-selected={selected}\n className=\"flex flex-col gap-3 rounded-lg p-3\"\n >\n <Preview fill={fill} />\n <span className=\"flex items-center gap-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate text-base font-semibold text-po-hi\">{label}</span>\n {description ? <span className=\"text-sm text-po-dim\">{description}</span> : null}\n </span>\n {selected ? <CheckIcon className=\"size-4 shrink-0 text-po-green\" /> : null}\n </span>\n </RadioGroupCard>\n );\n}\n\n/**\n * The one background behind every template. Picking a card saves it to the global config at once,\n * like a theme, so there is nothing to confirm. Exactly one shows; installing a package never\n * switches it on its own.\n */\nexport function BackdropSettings() {\n useWebPluginRegistry();\n const configuration = useTemplateConfiguration();\n const fills = hostSlotFills(HOST_SLOTS.backdrop).filter((fill) => fill.component !== undefined);\n const configured = configuredBackdrop(configuration);\n const shown = resolveBackdrop(fills, configured);\n const current = shown === undefined ? NO_BACKDROP : backdropId(shown);\n const meadow = fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID);\n const fromPlugins = fills.filter((fill) => fill !== meadow);\n const busy = configuration.saving || configuration.loading || configuration.config === undefined;\n const choose = (value: string): void => {\n void saveBackdropDefault(value).then((saved) => {\n if (saved) void reloadWebTemplateDecision();\n });\n };\n const group = 'grid grid-cols-1 gap-3 min-[480px]:grid-cols-2 lg:grid-cols-3';\n return (\n <SettingsSection data-testid=\"backdrop-settings\">\n <SettingsSectionHeader>\n <SettingsSectionTitle>Background</SettingsSectionTitle>\n <SettingsSectionDescription>\n What Po shows behind every layout. Applies straight away and is saved to your Po config.\n </SettingsSectionDescription>\n </SettingsSectionHeader>\n <RadioGroup aria-label=\"Background\" className={group} value={current} onValueChange={choose} disabled={busy}>\n {meadow ? (\n <BackdropCard\n value={DEFAULT_BACKDROP_ID}\n {...describe(meadow)}\n fill={meadow}\n selected={current === DEFAULT_BACKDROP_ID}\n />\n ) : null}\n <BackdropCard\n value={NO_BACKDROP}\n label=\"Plain\"\n description=\"Just the theme colour.\"\n selected={current === NO_BACKDROP}\n />\n </RadioGroup>\n {fromPlugins.length > 0 ? (\n <>\n <SettingsSectionTitle>From your plugins</SettingsSectionTitle>\n <RadioGroup\n aria-label=\"Backgrounds from your plugins\"\n className={group}\n value={current}\n onValueChange={choose}\n disabled={busy}\n >\n {fromPlugins.map((fill) => (\n <BackdropCard\n key={backdropId(fill)}\n value={backdropId(fill)}\n {...describe(fill)}\n fill={fill}\n selected={current === backdropId(fill)}\n />\n ))}\n </RadioGroup>\n </>\n ) : null}\n {configured !== undefined && configured !== NO_BACKDROP && configured !== current ? (\n <output className=\"block text-sm text-po-yellow\">\n The background <code className=\"font-mono\">{configured}</code> is not installed here, so{' '}\n {shown === undefined ? 'the plain one' : describe(shown).label} shows instead.\n </output>\n ) : null}\n {configuration.error ? (\n <p role=\"alert\" data-testid=\"backdrop-save-error\" className=\"text-sm text-po-red\">\n {configuration.error}\n </p>\n ) : null}\n <SettingsNote>\n Saved to <code className=\"font-mono\">~/.po/config.yaml</code> as <code className=\"font-mono\">web.backdrop</code>\n . Add your own from a global plugin with a <code className=\"font-mono\">backdrop</code> fill.\n </SettingsNote>\n </SettingsSection>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAS,SAAS,MAA6D;CAC7E,MAAM,OAAQ,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,OAAO,KAAK,OAAO,CAAC;CACjF,OAAO;EACL,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,WAAW,IAAI;EACpE,GAAI,OAAO,KAAK,gBAAgB,WAAW,EAAE,aAAa,KAAK,YAAY,IAAI,CAAC;CAClF;AACF;;AAGA,SAAS,QAAQ,EAAE,QAAiC;CAClD,MAAM,QAAQ,mBAAmB,IAAI;CACrC,MAAM,OAAO,MAAM;CACnB,OACE,oBAAC,OAAD;EAAK,eAAA;EAAY,WAAU;EACxB,UAAA,QAAQ,OACP,oBAAC,sBAAD;GAAsB,UAAU,WAAW,IAAI;GAC3C,WAAA,WAAY,SAAS,OAAO,oBAAC,MAAD,EAAM,GAAI,MAAQ,CAAA;EAC5B,CAAA,IACpB;CACD,CAAA;AAET;AAEA,SAAS,aAAa,EACpB,OACA,OACA,aACA,MACA,YAOC;CACD,OACE,qBAAC,gBAAD;EACS;EACP,eAAa,YAAY;EACzB,i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"sources":["../../../../src/web/features/settings/BackdropSettings.tsx"],"sourcesContent":["import { DEFAULT_BACKDROP_ID, HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport {\n CheckIcon,\n RadioGroup,\n RadioGroupCard,\n SettingsNote,\n SettingsSection,\n SettingsSectionDescription,\n SettingsSectionHeader,\n SettingsSectionTitle,\n} from '@agimon-ai/po-web-components';\n\nimport { reloadWebTemplateDecision } from '../../lib/pluginCompositions';\nimport { hostSlotFills, type ResolvedFill } from '../../lib/pluginRegistry';\nimport { backdropId, resolveBackdrop } from '../../lib/templateCatalog';\nimport { ToolRendererBoundary } from '../../lib/ToolRendererBoundary';\nimport { configuredBackdrop, saveBackdropDefault, useTemplateConfiguration } from '../../stores/templateStore';\nimport { usePluginSlotProps } from '../../stores/usePluginSlotProps';\nimport { useWebPluginRegistry } from '../../stores/useWebPluginRegistry';\n\n/** A backdrop names itself with `data: { label, description }` on its fill; its id stands in otherwise. */\nfunction describe(fill: ResolvedFill): { label: string; description?: string } {\n const data = (typeof fill.data === 'object' && fill.data !== null ? fill.data : {}) as Record<string, unknown>;\n return {\n label: typeof data.label === 'string' ? data.label : backdropId(fill),\n ...(typeof data.description === 'string' ? { description: data.description } : {}),\n };\n}\n\n/** The backdrop itself, live and small: a backdrop fills whatever box it is given. */\nfunction Preview({ fill }: { fill?: ResolvedFill }) {\n const props = usePluginSlotProps(null);\n const Fill = fill?.component;\n return (\n <div aria-hidden className=\"relative aspect-video w-full overflow-hidden rounded border border-po-border bg-po-bg\">\n {fill && Fill ? (\n <ToolRendererBoundary toolName={backdropId(fill)}>\n {(failed) => (failed ? null : <Fill {...props} />)}\n </ToolRendererBoundary>\n ) : null}\n </div>\n );\n}\n\nfunction BackdropCard({\n value,\n label,\n description,\n fill,\n selected,\n}: {\n value: string;\n label: string;\n description?: string;\n fill?: ResolvedFill;\n selected: boolean;\n}) {\n return (\n <RadioGroupCard\n value={value}\n data-testid={`backdrop-${value}`}\n data-selected={selected}\n className=\"flex flex-col gap-3 rounded-lg p-3\"\n >\n <Preview fill={fill} />\n <span className=\"flex items-center gap-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <span className=\"truncate text-base font-semibold text-po-hi\">{label}</span>\n {description ? <span className=\"text-sm text-po-dim\">{description}</span> : null}\n </span>\n {selected ? <CheckIcon className=\"size-4 shrink-0 text-po-green\" /> : null}\n </span>\n </RadioGroupCard>\n );\n}\n\n/**\n * The one background behind every template. Picking a card saves it to the global config at once,\n * like a theme, so there is nothing to confirm. Exactly one shows; installing a package never\n * switches it on its own.\n */\nexport function BackdropSettings() {\n useWebPluginRegistry();\n const configuration = useTemplateConfiguration();\n const fills = hostSlotFills(HOST_SLOTS.backdrop).filter((fill) => fill.component !== undefined);\n const configured = configuredBackdrop(configuration);\n const shown = resolveBackdrop(fills, configured);\n const current = shown === undefined ? NO_BACKDROP : backdropId(shown);\n const bamboo = fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID);\n const fromPlugins = fills.filter((fill) => fill !== bamboo);\n const busy = configuration.saving || configuration.loading || configuration.config === undefined;\n const choose = (value: string): void => {\n void saveBackdropDefault(value).then((saved) => {\n if (saved) void reloadWebTemplateDecision();\n });\n };\n const group = 'grid grid-cols-1 gap-3 min-[480px]:grid-cols-2 lg:grid-cols-3';\n return (\n <SettingsSection data-testid=\"backdrop-settings\">\n <SettingsSectionHeader>\n <SettingsSectionTitle>Background</SettingsSectionTitle>\n <SettingsSectionDescription>\n What Po shows behind every layout. Applies straight away and is saved to your Po config.\n </SettingsSectionDescription>\n </SettingsSectionHeader>\n <RadioGroup aria-label=\"Background\" className={group} value={current} onValueChange={choose} disabled={busy}>\n {bamboo ? (\n <BackdropCard\n value={DEFAULT_BACKDROP_ID}\n {...describe(bamboo)}\n fill={bamboo}\n selected={current === DEFAULT_BACKDROP_ID}\n />\n ) : null}\n <BackdropCard\n value={NO_BACKDROP}\n label=\"Plain\"\n description=\"Just the theme colour.\"\n selected={current === NO_BACKDROP}\n />\n </RadioGroup>\n {fromPlugins.length > 0 ? (\n <>\n <SettingsSectionTitle>From your plugins</SettingsSectionTitle>\n <RadioGroup\n aria-label=\"Backgrounds from your plugins\"\n className={group}\n value={current}\n onValueChange={choose}\n disabled={busy}\n >\n {fromPlugins.map((fill) => (\n <BackdropCard\n key={backdropId(fill)}\n value={backdropId(fill)}\n {...describe(fill)}\n fill={fill}\n selected={current === backdropId(fill)}\n />\n ))}\n </RadioGroup>\n </>\n ) : null}\n {configured !== undefined && configured !== NO_BACKDROP && configured !== current ? (\n <output className=\"block text-sm text-po-yellow\">\n The background <code className=\"font-mono\">{configured}</code> is not installed here, so{' '}\n {shown === undefined ? 'the plain one' : describe(shown).label} shows instead.\n </output>\n ) : null}\n {configuration.error ? (\n <p role=\"alert\" data-testid=\"backdrop-save-error\" className=\"text-sm text-po-red\">\n {configuration.error}\n </p>\n ) : null}\n <SettingsNote>\n Saved to <code className=\"font-mono\">~/.po/config.yaml</code> as <code className=\"font-mono\">web.backdrop</code>\n . Add your own from a global plugin with a <code className=\"font-mono\">backdrop</code> fill.\n </SettingsNote>\n </SettingsSection>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAS,SAAS,MAA6D;CAC7E,MAAM,OAAQ,OAAO,KAAK,SAAS,YAAY,KAAK,SAAS,OAAO,KAAK,OAAO,CAAC;CACjF,OAAO;EACL,OAAO,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ,WAAW,IAAI;EACpE,GAAI,OAAO,KAAK,gBAAgB,WAAW,EAAE,aAAa,KAAK,YAAY,IAAI,CAAC;CAClF;AACF;;AAGA,SAAS,QAAQ,EAAE,QAAiC;CAClD,MAAM,QAAQ,mBAAmB,IAAI;CACrC,MAAM,OAAO,MAAM;CACnB,OACE,oBAAC,OAAD;EAAK,eAAA;EAAY,WAAU;EACxB,UAAA,QAAQ,OACP,oBAAC,sBAAD;GAAsB,UAAU,WAAW,IAAI;GAC3C,WAAA,WAAY,SAAS,OAAO,oBAA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M,WAAU;KAAY,UAAA;IAAkB,CAAA;IAAC;IACrE,oBAAC,QAAD;KAAM,WAAU;KAAY,UAAA;IAAc,CAAA;IAAC;GAC1E,EAAA,CAAA;EACC;;AAErB"}
@@ -121,7 +121,7 @@ function backdropId(fill) {
121
121
  return `${fill.pluginId}/${fill.id}`;
122
122
  }
123
123
  /**
124
- * The one background to show, never a stack: the configured fill, else Po's meadow, else none; `none` shows
124
+ * The one background to show, never a stack: the configured fill, else Po's bamboo, else none; `none` shows
125
125
  * none. A configured fill that is not installed stays in config, since another workspace may still provide it.
126
126
  */
127
127
  function resolveBackdrop(fills, configured) {
@@ -1 +1 @@
1
- {"version":3,"file":"templateCatalog.cjs","names":["parseWebTemplate","pluginsAtScope","parseNativeTemplate","DEFAULT_TEMPLATE_ID","NO_BACKDROP","DEFAULT_BACKDROP_ID"],"sources":["../../../src/web/lib/templateCatalog.ts"],"sourcesContent":["import {\n DEFAULT_BACKDROP_ID,\n DEFAULT_TEMPLATE_ID,\n NO_BACKDROP,\n parseNativeTemplate,\n parseWebTemplate,\n type NativeTemplateContribution,\n type WebPluginDefinition,\n type WebPluginScope,\n type WebTemplateContribution,\n} from '@agimon-ai/po-core/web';\n\nimport { pluginsAtScope } from './pluginScopes';\nexport interface InstalledWebTemplate extends WebTemplateContribution {\n pluginId: string;\n}\n\nexport interface WebTemplateDiagnostic {\n kind: 'invalid-template' | 'duplicate-template';\n pluginId: string;\n message: string;\n}\n\nexport interface WebTemplateCatalog {\n templates: InstalledWebTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledTemplates: readonly WebPluginDefinition[] = [];\n\n/** The host supplies its bundled recovery application, avoiding a library-to-template dependency. */\nexport function bindBundledWebTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledTemplates = plugins;\n}\n\n/**\n * One plugin field of template contributions, parsed entry by entry; the first owner of an id wins.\n * Bundled plugins only fill gaps: an id the host already provides is skipped without a diagnostic.\n */\nfunction collectTemplates<T extends { id: string }>(\n plugins: readonly WebPluginDefinition[],\n field: 'templates' | 'nativeTemplates',\n parse: (value: unknown) => T | undefined,\n bundled: readonly WebPluginDefinition[] = [],\n): { templates: (T & { pluginId: string })[]; diagnostics: WebTemplateDiagnostic[] } {\n const templates = new Map<string, T & { pluginId: string }>();\n const diagnostics: WebTemplateDiagnostic[] = [];\n const collect = (plugin: WebPluginDefinition, fillsGaps: boolean): void => {\n let entries: unknown;\n try {\n entries = plugin[field];\n } catch {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Template metadata from '${plugin.id}' could not be read.`,\n });\n return;\n }\n if (entries === undefined) return;\n if (!Array.isArray(entries)) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' must declare ${field} as an array.`,\n });\n return;\n }\n for (const entry of entries) {\n let template: T | undefined;\n try {\n template = parse(entry);\n } catch {\n template = undefined;\n }\n if (template === undefined) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' declares an invalid template or an unsupported template contract.`,\n });\n continue;\n }\n const owner = templates.get(template.id);\n if (owner !== undefined && fillsGaps) continue;\n if (owner !== undefined) {\n diagnostics.push({\n kind: 'duplicate-template',\n pluginId: plugin.id,\n message: `Template '${template.id}' is already provided by '${owner.pluginId}'; keeping the first.`,\n });\n continue;\n }\n templates.set(template.id, { ...template, pluginId: plugin.id });\n }\n };\n\n for (const plugin of plugins) collect(plugin, false);\n for (const plugin of bundled) collect(plugin, true);\n return { templates: [...templates.values()], diagnostics };\n}\n\n/** Read scoped templates, then add any bundled template the scope does not provide. */\nexport function collectWebTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): WebTemplateCatalog {\n return collectTemplates(\n plugins,\n 'templates',\n parseWebTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledTemplates, scope),\n );\n}\n\nexport interface InstalledNativeTemplate extends NativeTemplateContribution {\n pluginId: string;\n}\n\nexport interface NativeTemplateCatalog {\n templates: InstalledNativeTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledNativeTemplates: readonly WebPluginDefinition[] = [];\n\n/** The phone app's bundled default layout, bound by the host exactly as the cockpit binds its own. */\nexport function bindBundledNativeTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledNativeTemplates = plugins;\n}\n\n/** Phone layouts from `nativeTemplates`, then any bundled layout the scope does not provide. */\nexport function collectNativeTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): NativeTemplateCatalog {\n return collectTemplates(\n plugins,\n 'nativeTemplates',\n parseNativeTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledNativeTemplates, scope),\n );\n}\n\n/** The phone app's own copy of a bundled layout, valid at the global scope, for screens no host owns. */\nexport function bundledNativeTemplate(id: string): NativeTemplateContribution | undefined {\n return collectTemplates(\n [],\n 'nativeTemplates',\n parseNativeTemplate,\n pluginsAtScope(bundledNativeTemplates, 'host'),\n ).templates.find((template) => template.id === id);\n}\n\n/** The cockpit's choice rule for the phone: configured, then the default, then the first by id. */\nexport function resolveNativeTemplate(\n templates: readonly InstalledNativeTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): InstalledNativeTemplate | undefined {\n const available = templates.filter((template) => !failed.includes(template.id));\n return (\n available.find((template) => template.id === configured) ??\n available.find((template) => template.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0]\n );\n}\n\n/** A missing default stays in config, since another workspace may still provide it. */\nexport function resolveWebTemplate(\n templates: readonly InstalledWebTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): { template: InstalledWebTemplate | undefined; warning: string | undefined } {\n const available = templates.filter((template) => !failed.includes(template.id));\n const preferred = available.find((template) => template.id === configured);\n const template =\n preferred ??\n available.find((candidate) => candidate.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0];\n if (!template)\n return {\n template: undefined,\n warning: 'No compatible web template is available. Add a template package to modes.yaml and run po sync.',\n };\n if (configured && !preferred)\n return { template, warning: `Configured template '${configured}' is unavailable; showing '${template.label}'.` };\n if (failed.length > 0)\n return { template, warning: 'A template could not render. A different available template is being shown.' };\n return { template, warning: undefined };\n}\n\n/** A background's `web.backdrop` value: the `<pluginId>/<fillId>` of its `backdrop` fill. */\nexport function backdropId(fill: { pluginId: string; id: string }): string {\n return `${fill.pluginId}/${fill.id}`;\n}\n\n/**\n * The one background to show, never a stack: the configured fill, else Po's meadow, else none; `none` shows\n * none. A configured fill that is not installed stays in config, since another workspace may still provide it.\n */\nexport function resolveBackdrop<Fill extends { pluginId: string; id: string }>(\n fills: readonly Fill[],\n configured: string | undefined,\n): Fill | undefined {\n if (configured === NO_BACKDROP) return undefined;\n return (\n fills.find((fill) => backdropId(fill) === configured) ??\n fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID)\n );\n}\n"],"mappings":";;;AA4BA,IAAI,mBAAmD,CAAC;;AAGxD,SAAgB,wBAAwB,SAA+C;CACrF,mBAAmB;AACrB;;;;;AAMA,SAAS,iBACP,SACA,OACA,OACA,UAA0C,CAAC,GACwC;CACnF,MAAM,4BAAY,IAAI,IAAsC;CAC5D,MAAM,cAAuC,CAAC;CAC9C,MAAM,WAAW,QAA6B,cAA6B;EACzE,IAAI;EACJ,IAAI;GACF,UAAU,OAAO;EACnB,QAAQ;GACN,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,2BAA2B,OAAO,GAAG;GAChD,CAAC;GACD;EACF;EACA,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;GAC3B,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,WAAW,OAAO,GAAG,iBAAiB,MAAM;GACvD,CAAC;GACD;EACF;EACA,KAAK,MAAM,SAAS,SAAS;GAC3B,IAAI;GACJ,IAAI;IACF,WA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s","names":["parseWebTemplate","pluginsAtScope","parseNativeTemplate","DEFAULT_TEMPLATE_ID","NO_BACKDROP","DEFAULT_BACKDROP_ID"],"sources":["../../../src/web/lib/templateCatalog.ts"],"sourcesContent":["import {\n DEFAULT_BACKDROP_ID,\n DEFAULT_TEMPLATE_ID,\n NO_BACKDROP,\n parseNativeTemplate,\n parseWebTemplate,\n type NativeTemplateContribution,\n type WebPluginDefinition,\n type WebPluginScope,\n type WebTemplateContribution,\n} from '@agimon-ai/po-core/web';\n\nimport { pluginsAtScope } from './pluginScopes';\nexport interface InstalledWebTemplate extends WebTemplateContribution {\n pluginId: string;\n}\n\nexport interface WebTemplateDiagnostic {\n kind: 'invalid-template' | 'duplicate-template';\n pluginId: string;\n message: string;\n}\n\nexport interface WebTemplateCatalog {\n templates: InstalledWebTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledTemplates: readonly WebPluginDefinition[] = [];\n\n/** The host supplies its bundled recovery application, avoiding a library-to-template dependency. */\nexport function bindBundledWebTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledTemplates = plugins;\n}\n\n/**\n * One plugin field of template contributions, parsed entry by entry; the first owner of an id wins.\n * Bundled plugins only fill gaps: an id the host already provides is skipped without a diagnostic.\n */\nfunction collectTemplates<T extends { id: string }>(\n plugins: readonly WebPluginDefinition[],\n field: 'templates' | 'nativeTemplates',\n parse: (value: unknown) => T | undefined,\n bundled: readonly WebPluginDefinition[] = [],\n): { templates: (T & { pluginId: string })[]; diagnostics: WebTemplateDiagnostic[] } {\n const templates = new Map<string, T & { pluginId: string }>();\n const diagnostics: WebTemplateDiagnostic[] = [];\n const collect = (plugin: WebPluginDefinition, fillsGaps: boolean): void => {\n let entries: unknown;\n try {\n entries = plugin[field];\n } catch {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Template metadata from '${plugin.id}' could not be read.`,\n });\n return;\n }\n if (entries === undefined) return;\n if (!Array.isArray(entries)) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' must declare ${field} as an array.`,\n });\n return;\n }\n for (const entry of entries) {\n let template: T | undefined;\n try {\n template = parse(entry);\n } catch {\n template = undefined;\n }\n if (template === undefined) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' declares an invalid template or an unsupported template contract.`,\n });\n continue;\n }\n const owner = templates.get(template.id);\n if (owner !== undefined && fillsGaps) continue;\n if (owner !== undefined) {\n diagnostics.push({\n kind: 'duplicate-template',\n pluginId: plugin.id,\n message: `Template '${template.id}' is already provided by '${owner.pluginId}'; keeping the first.`,\n });\n continue;\n }\n templates.set(template.id, { ...template, pluginId: plugin.id });\n }\n };\n\n for (const plugin of plugins) collect(plugin, false);\n for (const plugin of bundled) collect(plugin, true);\n return { templates: [...templates.values()], diagnostics };\n}\n\n/** Read scoped templates, then add any bundled template the scope does not provide. */\nexport function collectWebTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): WebTemplateCatalog {\n return collectTemplates(\n plugins,\n 'templates',\n parseWebTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledTemplates, scope),\n );\n}\n\nexport interface InstalledNativeTemplate extends NativeTemplateContribution {\n pluginId: string;\n}\n\nexport interface NativeTemplateCatalog {\n templates: InstalledNativeTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledNativeTemplates: readonly WebPluginDefinition[] = [];\n\n/** The phone app's bundled default layout, bound by the host exactly as the cockpit binds its own. */\nexport function bindBundledNativeTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledNativeTemplates = plugins;\n}\n\n/** Phone layouts from `nativeTemplates`, then any bundled layout the scope does not provide. */\nexport function collectNativeTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): NativeTemplateCatalog {\n return collectTemplates(\n plugins,\n 'nativeTemplates',\n parseNativeTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledNativeTemplates, scope),\n );\n}\n\n/** The phone app's own copy of a bundled layout, valid at the global scope, for screens no host owns. */\nexport function bundledNativeTemplate(id: string): NativeTemplateContribution | undefined {\n return collectTemplates(\n [],\n 'nativeTemplates',\n parseNativeTemplate,\n pluginsAtScope(bundledNativeTemplates, 'host'),\n ).templates.find((template) => template.id === id);\n}\n\n/** The cockpit's choice rule for the phone: configured, then the default, then the first by id. */\nexport function resolveNativeTemplate(\n templates: readonly InstalledNativeTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): InstalledNativeTemplate | undefined {\n const available = templates.filter((template) => !failed.includes(template.id));\n return (\n available.find((template) => template.id === configured) ??\n available.find((template) => template.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0]\n );\n}\n\n/** A missing default stays in config, since another workspace may still provide it. */\nexport function resolveWebTemplate(\n templates: readonly InstalledWebTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): { template: InstalledWebTemplate | undefined; warning: string | undefined } {\n const available = templates.filter((template) => !failed.includes(template.id));\n const preferred = available.find((template) => template.id === configured);\n const template =\n preferred ??\n available.find((candidate) => candidate.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0];\n if (!template)\n return {\n template: undefined,\n warning: 'No compatible web template is available. Add a template package to modes.yaml and run po sync.',\n };\n if (configured && !preferred)\n return { template, warning: `Configured template '${configured}' is unavailable; showing '${template.label}'.` };\n if (failed.length > 0)\n return { template, warning: 'A template could not render. A different available template is being shown.' };\n return { template, warning: undefined };\n}\n\n/** A background's `web.backdrop` value: the `<pluginId>/<fillId>` of its `backdrop` fill. */\nexport function backdropId(fill: { pluginId: string; id: string }): string {\n return `${fill.pluginId}/${fill.id}`;\n}\n\n/**\n * The one background to show, never a stack: the configured fill, else Po's bamboo, else none; `none` shows\n * none. A configured fill that is not installed stays in config, since another workspace may still provide it.\n */\nexport function resolveBackdrop<Fill extends { pluginId: string; id: string }>(\n fills: readonly Fill[],\n configured: string | undefined,\n): Fill | undefined {\n if (configured === NO_BACKDROP) return undefined;\n return (\n fills.find((fill) => backdropId(fill) === configured) ??\n fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID)\n );\n}\n"],"mappings":";;;AA4BA,IAAI,mBAAmD,CAAC;;AAGxD,SAAgB,wBAAwB,SAA+C;CACrF,mBAAmB;AACrB;;;;;AAMA,SAAS,iBACP,SACA,OACA,OACA,UAA0C,CAAC,GACwC;CACnF,MAAM,4BAAY,IAAI,IAAsC;CAC5D,MAAM,cAAuC,CAAC;CAC9C,MAAM,WAAW,QAA6B,cAA6B;EACzE,IAAI;EACJ,IAAI;GACF,UAAU,OAAO;EACnB,QAAQ;GACN,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,2BAA2B,OAAO,GAAG;GAChD,CAAC;GACD;EACF;EACA,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;GAC3B,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,WAAW,OAAO,GAAG,iBAAiB,MAAM;GACvD,CAAC;GACD;EACF;EACA,KAAK,MAAM,SAAS,SAAS;GAC3B,IAAI;GACJ,IAAI;IACF,WAAW,MAAM,KAAK;GACxB,QAAQ;IACN,WAAW,KAAA;GACb;GACA,IAAI,aAAa,KAAA,GAAW;IAC1B,YAAY,KAAK;KACf,MAAM;KACN,UAAU,OAAO;KACjB,SAAS,WAAW,OAAO,GAAG;IAChC,CAAC;IACD;GACF;GACA,MAAM,QAAQ,UAAU,IAAI,SAAS,EAAE;GACvC,IAAI,UAAU,KAAA,KAAa,WAAW;GACtC,IAAI,UAAU,KAAA,GAAW;IACvB,YAAY,KAAK;KACf,MAAM;KACN,UAAU,OAAO;KACjB,SAAS,aAAa,SAAS,GAAG,4BAA4B,MAAM,SAAS;IAC/E,CAAC;IACD;GACF;GACA,UAAU,IAAI,SAAS,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C;CAC9E,MAAM,YAAY,UAAU,MAAM,aAAa,SAAS,OAAO,UAAU;CACzE,MAAM,WACJ,aACA,UAAU,MAAM,cAAc,UAAU,OAAOA,uBAAAA,mBAAmB,KAClE,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,MAAM,UAAU,KAAK,GAAG,cAAc,MAAM,EAAE,CAAC,CAAC,CAAC;CACxE,IAAI,CAAC,UACH,OAAO;EACL,UAAU,KAAA;EACV,SAAS;CACX;CACF,IAAI,cAAc,CAAC,WACjB,OAAO;EAAE;EAAU,SAAS,wBAAwB,WAAW,6BAA6B,SAAS,MAAM;CAAI;CACjH,IAAI,OAAO,SAAS,GAClB,OAAO;EAAE;EAAU,SAAS;CAA8E;CAC5G,OAAO;EAAE;EAAU,SAAS,KAAA;CAAU;AACxC;;AAGA,SAAgB,WAAW,MAAgD;CACzE,OAAO,GAAG,KAAK,SAAS,GAAG,KAAK;AAClC;;;;;AAMA,SAAgB,gBACd,OACA,YACkB;CAClB,IAAI,eAAeC,uBAAAA,aAAa,OAAO,KAAA;CACvC,OACE,MAAM,MAAM,SAAS,WAAW,IAAI,MAAM,UAAU,KACpD,MAAM,MAAM,SAAS,WAAW,IAAI,MAAMC,uBAAAA,mBAAmB;AAEjE"}
@@ -42,7 +42,7 @@ export declare function backdropId(fill: {
42
42
  id: string;
43
43
  }): string;
44
44
  /**
45
- * The one background to show, never a stack: the configured fill, else Po's meadow, else none; `none` shows
45
+ * The one background to show, never a stack: the configured fill, else Po's bamboo, else none; `none` shows
46
46
  * none. A configured fill that is not installed stays in config, since another workspace may still provide it.
47
47
  */
48
48
  export declare function resolveBackdrop<Fill extends {
@@ -121,7 +121,7 @@ function backdropId(fill) {
121
121
  return `${fill.pluginId}/${fill.id}`;
122
122
  }
123
123
  /**
124
- * The one background to show, never a stack: the configured fill, else Po's meadow, else none; `none` shows
124
+ * The one background to show, never a stack: the configured fill, else Po's bamboo, else none; `none` shows
125
125
  * none. A configured fill that is not installed stays in config, since another workspace may still provide it.
126
126
  */
127
127
  function resolveBackdrop(fills, configured) {
@@ -1 +1 @@
1
- {"version":3,"file":"templateCatalog.mjs","names":[],"sources":["../../../src/web/lib/templateCatalog.ts"],"sourcesContent":["import {\n DEFAULT_BACKDROP_ID,\n DEFAULT_TEMPLATE_ID,\n NO_BACKDROP,\n parseNativeTemplate,\n parseWebTemplate,\n type NativeTemplateContribution,\n type WebPluginDefinition,\n type WebPluginScope,\n type WebTemplateContribution,\n} from '@agimon-ai/po-core/web';\n\nimport { pluginsAtScope } from './pluginScopes';\nexport interface InstalledWebTemplate extends WebTemplateContribution {\n pluginId: string;\n}\n\nexport interface WebTemplateDiagnostic {\n kind: 'invalid-template' | 'duplicate-template';\n pluginId: string;\n message: string;\n}\n\nexport interface WebTemplateCatalog {\n templates: InstalledWebTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledTemplates: readonly WebPluginDefinition[] = [];\n\n/** The host supplies its bundled recovery application, avoiding a library-to-template dependency. */\nexport function bindBundledWebTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledTemplates = plugins;\n}\n\n/**\n * One plugin field of template contributions, parsed entry by entry; the first owner of an id wins.\n * Bundled plugins only fill gaps: an id the host already provides is skipped without a diagnostic.\n */\nfunction collectTemplates<T extends { id: string }>(\n plugins: readonly WebPluginDefinition[],\n field: 'templates' | 'nativeTemplates',\n parse: (value: unknown) => T | undefined,\n bundled: readonly WebPluginDefinition[] = [],\n): { templates: (T & { pluginId: string })[]; diagnostics: WebTemplateDiagnostic[] } {\n const templates = new Map<string, T & { pluginId: string }>();\n const diagnostics: WebTemplateDiagnostic[] = [];\n const collect = (plugin: WebPluginDefinition, fillsGaps: boolean): void => {\n let entries: unknown;\n try {\n entries = plugin[field];\n } catch {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Template metadata from '${plugin.id}' could not be read.`,\n });\n return;\n }\n if (entries === undefined) return;\n if (!Array.isArray(entries)) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' must declare ${field} as an array.`,\n });\n return;\n }\n for (const entry of entries) {\n let template: T | undefined;\n try {\n template = parse(entry);\n } catch {\n template = undefined;\n }\n if (template === undefined) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' declares an invalid template or an unsupported template contract.`,\n });\n continue;\n }\n const owner = templates.get(template.id);\n if (owner !== undefined && fillsGaps) continue;\n if (owner !== undefined) {\n diagnostics.push({\n kind: 'duplicate-template',\n pluginId: plugin.id,\n message: `Template '${template.id}' is already provided by '${owner.pluginId}'; keeping the first.`,\n });\n continue;\n }\n templates.set(template.id, { ...template, pluginId: plugin.id });\n }\n };\n\n for (const plugin of plugins) collect(plugin, false);\n for (const plugin of bundled) collect(plugin, true);\n return { templates: [...templates.values()], diagnostics };\n}\n\n/** Read scoped templates, then add any bundled template the scope does not provide. */\nexport function collectWebTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): WebTemplateCatalog {\n return collectTemplates(\n plugins,\n 'templates',\n parseWebTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledTemplates, scope),\n );\n}\n\nexport interface InstalledNativeTemplate extends NativeTemplateContribution {\n pluginId: string;\n}\n\nexport interface NativeTemplateCatalog {\n templates: InstalledNativeTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledNativeTemplates: readonly WebPluginDefinition[] = [];\n\n/** The phone app's bundled default layout, bound by the host exactly as the cockpit binds its own. */\nexport function bindBundledNativeTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledNativeTemplates = plugins;\n}\n\n/** Phone layouts from `nativeTemplates`, then any bundled layout the scope does not provide. */\nexport function collectNativeTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): NativeTemplateCatalog {\n return collectTemplates(\n plugins,\n 'nativeTemplates',\n parseNativeTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledNativeTemplates, scope),\n );\n}\n\n/** The phone app's own copy of a bundled layout, valid at the global scope, for screens no host owns. */\nexport function bundledNativeTemplate(id: string): NativeTemplateContribution | undefined {\n return collectTemplates(\n [],\n 'nativeTemplates',\n parseNativeTemplate,\n pluginsAtScope(bundledNativeTemplates, 'host'),\n ).templates.find((template) => template.id === id);\n}\n\n/** The cockpit's choice rule for the phone: configured, then the default, then the first by id. */\nexport function resolveNativeTemplate(\n templates: readonly InstalledNativeTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): InstalledNativeTemplate | undefined {\n const available = templates.filter((template) => !failed.includes(template.id));\n return (\n available.find((template) => template.id === configured) ??\n available.find((template) => template.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0]\n );\n}\n\n/** A missing default stays in config, since another workspace may still provide it. */\nexport function resolveWebTemplate(\n templates: readonly InstalledWebTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): { template: InstalledWebTemplate | undefined; warning: string | undefined } {\n const available = templates.filter((template) => !failed.includes(template.id));\n const preferred = available.find((template) => template.id === configured);\n const template =\n preferred ??\n available.find((candidate) => candidate.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0];\n if (!template)\n return {\n template: undefined,\n warning: 'No compatible web template is available. Add a template package to modes.yaml and run po sync.',\n };\n if (configured && !preferred)\n return { template, warning: `Configured template '${configured}' is unavailable; showing '${template.label}'.` };\n if (failed.length > 0)\n return { template, warning: 'A template could not render. A different available template is being shown.' };\n return { template, warning: undefined };\n}\n\n/** A background's `web.backdrop` value: the `<pluginId>/<fillId>` of its `backdrop` fill. */\nexport function backdropId(fill: { pluginId: string; id: string }): string {\n return `${fill.pluginId}/${fill.id}`;\n}\n\n/**\n * The one background to show, never a stack: the configured fill, else Po's meadow, else none; `none` shows\n * none. A configured fill that is not installed stays in config, since another workspace may still provide it.\n */\nexport function resolveBackdrop<Fill extends { pluginId: string; id: string }>(\n fills: readonly Fill[],\n configured: string | undefined,\n): Fill | undefined {\n if (configured === NO_BACKDROP) return undefined;\n return (\n fills.find((fill) => backdropId(fill) === configured) ??\n fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID)\n );\n}\n"],"mappings":";;;AA4BA,IAAI,mBAAmD,CAAC;;AAGxD,SAAgB,wBAAwB,SAA+C;CACrF,mBAAmB;AACrB;;;;;AAMA,SAAS,iBACP,SACA,OACA,OACA,UAA0C,CAAC,GACwC;CACnF,MAAM,4BAAY,IAAI,IAAsC;CAC5D,MAAM,cAAuC,CAAC;CAC9C,MAAM,WAAW,QAA6B,cAA6B;EACzE,IAAI;EACJ,IAAI;GACF,UAAU,OAAO;EACnB,QAAQ;GACN,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,2BAA2B,OAAO,GAAG;GAChD,CAAC;GACD;EACF;EACA,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;GAC3B,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,WAAW,OAAO,GAAG,iBAAiB,MAAM;GACvD,CAAC;GACD;EACF;EACA,KAAK,MAAM,SAAS,SAAS;GAC3B,IAAI;GACJ,IAAI;IACF,WAAW,MAAM,KAAK;GACxB,QAAQ;IACN,WAAW,KAAA;GACb;GACA,IAAI,aAAa,KAAA,GAAW;IAC1B,YAAY,KAAK;KACf,MAAM;KACN,UAAU,OAAO;KACjB,SAAS,WAAW,OAAO,GAAG;IAChC,CAAC;IACD;GACF;GACA,MAAM,QAAQ,UAAU,IAAI,SAAS,EAAE;GACvC,IAAI,UAAU,KAAA,KAAa,WAAW;GACtC,IAAI,UAAU,KAAA,GAAW;IACvB,YAAY,KAAK;KACf,MAAM;KACN,UAAU,OAAO;KACjB,SAAS,aAAa,SAAS,GAAG,4BAA4B,MAAM,SAAS;IAC/E,CAAC;IACD;GACF;GACA,UAAU,IAAI,SAAS,IAAI;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J,aACA,UAAU,MAAM,cAAc,UAAU,OAAO,mBAAmB,KAClE,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,MAAM,UAAU,KAAK,GAAG,cAAc,MAAM,EAAE,CAAC,CAAC,CAAC;CACxE,IAAI,CAAC,UACH,OAAO;EACL,UAAU,KAAA;EACV,SAAS;CACX;CACF,IAAI,cAAc,CAAC,WACjB,OAAO;EAAE;EAAU,SAAS,wBAAwB,WAAW,6BAA6B,SAAS,MAAM;CAAI;CACjH,IAAI,OAAO,SAAS,GAClB,OAAO;EAAE;EAAU,SAAS;CAA8E;CAC5G,OAAO;EAAE;EAAU,SAAS,KAAA;CAAU;AACxC;;AAGA,SAAgB,WAAW,MAAgD;CACzE,OAAO,GAAG,KAAK,SAAS,GAAG,KAAK;AAClC;;;;;AAMA,SAAgB,gBACd,OACA,YACkB;CAClB,IAAI,eAAe,aAAa,OAAO,KAAA;CACvC,OACE,MAAM,MAAM,SAAS,WAAW,IAAI,MAAM,UAAU,KACpD,MAAM,MAAM,SAAS,WAAW,IAAI,MAAM,mBAAmB;AAEjE"}
1
+ {"version":3,"file":"templateCatalog.mjs","names":[],"sources":["../../../src/web/lib/templateCatalog.ts"],"sourcesContent":["import {\n DEFAULT_BACKDROP_ID,\n DEFAULT_TEMPLATE_ID,\n NO_BACKDROP,\n parseNativeTemplate,\n parseWebTemplate,\n type NativeTemplateContribution,\n type WebPluginDefinition,\n type WebPluginScope,\n type WebTemplateContribution,\n} from '@agimon-ai/po-core/web';\n\nimport { pluginsAtScope } from './pluginScopes';\nexport interface InstalledWebTemplate extends WebTemplateContribution {\n pluginId: string;\n}\n\nexport interface WebTemplateDiagnostic {\n kind: 'invalid-template' | 'duplicate-template';\n pluginId: string;\n message: string;\n}\n\nexport interface WebTemplateCatalog {\n templates: InstalledWebTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledTemplates: readonly WebPluginDefinition[] = [];\n\n/** The host supplies its bundled recovery application, avoiding a library-to-template dependency. */\nexport function bindBundledWebTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledTemplates = plugins;\n}\n\n/**\n * One plugin field of template contributions, parsed entry by entry; the first owner of an id wins.\n * Bundled plugins only fill gaps: an id the host already provides is skipped without a diagnostic.\n */\nfunction collectTemplates<T extends { id: string }>(\n plugins: readonly WebPluginDefinition[],\n field: 'templates' | 'nativeTemplates',\n parse: (value: unknown) => T | undefined,\n bundled: readonly WebPluginDefinition[] = [],\n): { templates: (T & { pluginId: string })[]; diagnostics: WebTemplateDiagnostic[] } {\n const templates = new Map<string, T & { pluginId: string }>();\n const diagnostics: WebTemplateDiagnostic[] = [];\n const collect = (plugin: WebPluginDefinition, fillsGaps: boolean): void => {\n let entries: unknown;\n try {\n entries = plugin[field];\n } catch {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Template metadata from '${plugin.id}' could not be read.`,\n });\n return;\n }\n if (entries === undefined) return;\n if (!Array.isArray(entries)) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' must declare ${field} as an array.`,\n });\n return;\n }\n for (const entry of entries) {\n let template: T | undefined;\n try {\n template = parse(entry);\n } catch {\n template = undefined;\n }\n if (template === undefined) {\n diagnostics.push({\n kind: 'invalid-template',\n pluginId: plugin.id,\n message: `Plugin '${plugin.id}' declares an invalid template or an unsupported template contract.`,\n });\n continue;\n }\n const owner = templates.get(template.id);\n if (owner !== undefined && fillsGaps) continue;\n if (owner !== undefined) {\n diagnostics.push({\n kind: 'duplicate-template',\n pluginId: plugin.id,\n message: `Template '${template.id}' is already provided by '${owner.pluginId}'; keeping the first.`,\n });\n continue;\n }\n templates.set(template.id, { ...template, pluginId: plugin.id });\n }\n };\n\n for (const plugin of plugins) collect(plugin, false);\n for (const plugin of bundled) collect(plugin, true);\n return { templates: [...templates.values()], diagnostics };\n}\n\n/** Read scoped templates, then add any bundled template the scope does not provide. */\nexport function collectWebTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): WebTemplateCatalog {\n return collectTemplates(\n plugins,\n 'templates',\n parseWebTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledTemplates, scope),\n );\n}\n\nexport interface InstalledNativeTemplate extends NativeTemplateContribution {\n pluginId: string;\n}\n\nexport interface NativeTemplateCatalog {\n templates: InstalledNativeTemplate[];\n diagnostics: WebTemplateDiagnostic[];\n}\n\nlet bundledNativeTemplates: readonly WebPluginDefinition[] = [];\n\n/** The phone app's bundled default layout, bound by the host exactly as the cockpit binds its own. */\nexport function bindBundledNativeTemplates(plugins: readonly WebPluginDefinition[]): void {\n bundledNativeTemplates = plugins;\n}\n\n/** Phone layouts from `nativeTemplates`, then any bundled layout the scope does not provide. */\nexport function collectNativeTemplates(\n plugins: readonly WebPluginDefinition[],\n scope?: WebPluginScope,\n): NativeTemplateCatalog {\n return collectTemplates(\n plugins,\n 'nativeTemplates',\n parseNativeTemplate,\n scope === undefined ? [] : pluginsAtScope(bundledNativeTemplates, scope),\n );\n}\n\n/** The phone app's own copy of a bundled layout, valid at the global scope, for screens no host owns. */\nexport function bundledNativeTemplate(id: string): NativeTemplateContribution | undefined {\n return collectTemplates(\n [],\n 'nativeTemplates',\n parseNativeTemplate,\n pluginsAtScope(bundledNativeTemplates, 'host'),\n ).templates.find((template) => template.id === id);\n}\n\n/** The cockpit's choice rule for the phone: configured, then the default, then the first by id. */\nexport function resolveNativeTemplate(\n templates: readonly InstalledNativeTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): InstalledNativeTemplate | undefined {\n const available = templates.filter((template) => !failed.includes(template.id));\n return (\n available.find((template) => template.id === configured) ??\n available.find((template) => template.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0]\n );\n}\n\n/** A missing default stays in config, since another workspace may still provide it. */\nexport function resolveWebTemplate(\n templates: readonly InstalledWebTemplate[],\n configured: string | undefined,\n failed: readonly string[] = [],\n): { template: InstalledWebTemplate | undefined; warning: string | undefined } {\n const available = templates.filter((template) => !failed.includes(template.id));\n const preferred = available.find((template) => template.id === configured);\n const template =\n preferred ??\n available.find((candidate) => candidate.id === DEFAULT_TEMPLATE_ID) ??\n [...available].sort((left, right) => left.id.localeCompare(right.id))[0];\n if (!template)\n return {\n template: undefined,\n warning: 'No compatible web template is available. Add a template package to modes.yaml and run po sync.',\n };\n if (configured && !preferred)\n return { template, warning: `Configured template '${configured}' is unavailable; showing '${template.label}'.` };\n if (failed.length > 0)\n return { template, warning: 'A template could not render. A different available template is being shown.' };\n return { template, warning: undefined };\n}\n\n/** A background's `web.backdrop` value: the `<pluginId>/<fillId>` of its `backdrop` fill. */\nexport function backdropId(fill: { pluginId: string; id: string }): string {\n return `${fill.pluginId}/${fill.id}`;\n}\n\n/**\n * The one background to show, never a stack: the configured fill, else Po's bamboo, else none; `none` shows\n * none. A configured fill that is not installed stays in config, since another workspace may still provide it.\n */\nexport function resolveBackdrop<Fill extends { pluginId: string; id: string }>(\n fills: readonly Fill[],\n configured: string | undefined,\n): Fill | undefined {\n if (configured === NO_BACKDROP) return undefined;\n return (\n fills.find((fill) => backdropId(fill) === configured) ??\n fills.find((fill) => backdropId(fill) === DEFAULT_BACKDROP_ID)\n );\n}\n"],"mappings":";;;AA4BA,IAAI,mBAAmD,CAAC;;AAGxD,SAAgB,wBAAwB,SAA+C;CACrF,mBAAmB;AACrB;;;;;AAMA,SAAS,iBACP,SACA,OACA,OACA,UAA0C,CAAC,GACwC;CACnF,MAAM,4BAAY,IAAI,IAAsC;CAC5D,MAAM,cAAuC,CAAC;CAC9C,MAAM,WAAW,QAA6B,cAA6B;EACzE,IAAI;EACJ,IAAI;GACF,UAAU,OAAO;EACnB,QAAQ;GACN,YAAY,KAAK;IACf,MAAM;IACN,UAAU,OAAO;IACjB,SAAS,2BAA2B,OAAO,GAAG;GAChD,CAAC;GACD;EACF;EACA,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,CAAC,MAAM,QAAQ,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AU,KACpD,MAAM,MAAM,SAAS,WAAW,IAAI,MAAM,mBAAmB;AAEjE"}
@@ -87,7 +87,7 @@ async function saveTemplateDefault(id, workspaceId) {
87
87
  workspaceId
88
88
  }).templates.some((template) => template.id === id), workspaceId);
89
89
  }
90
- /** `null` clears the choice so Po's meadow shows; `none` shows no background. */
90
+ /** `null` clears the choice so Po's bamboo shows; `none` shows no background. */
91
91
  async function saveBackdropDefault(choice, workspaceId) {
92
92
  return await saveWebChoice("backdrop", choice, choice === null || choice === _agimon_ai_po_core_web.NO_BACKDROP || require_pluginRegistry.hostSlotFills(_agimon_ai_po_core_web.HOST_SLOTS.backdrop).some((fill) => require_templateCatalog.backdropId(fill) === choice), workspaceId);
93
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"templateStore.cjs","names":["traceStore","Store","readSettingsConfig","useStore","onHubConnected","webTemplateCatalog","NO_BACKDROP","hostSlotFills","HOST_SLOTS","backdropId","writeSettingsValue"],"sources":["../../../src/web/stores/templateStore.ts"],"sourcesContent":["import { HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\nimport { useEffect } from 'react';\n\nimport type { SettingsConfigView } from '../../types/settings';\nimport { hostSlotFills, webTemplateCatalog } from '../lib/pluginRegistry';\nimport { readSettingsConfig, writeSettingsValue } from '../lib/settingsApi';\nimport { backdropId } from '../lib/templateCatalog';\nimport { onHubConnected } from '../lib/transport';\nimport { traceStore } from '../lib/uiTrace';\n\nexport interface TemplateConfiguration {\n config?: SettingsConfigView;\n error?: string;\n loading: boolean;\n saving: boolean;\n}\n\nconst EMPTY: TemplateConfiguration = { loading: true, saving: false };\nconst HOST = 'host';\nconst KEY = 'web.template';\nconst BACKDROP_KEY = 'web.backdrop';\nconst requests = new Map<string, number>();\nconst pendingRequests = new Map<string, Promise<void>>();\n\n/** Preferences belong to Po config; this store caches only scoped API responses. */\nexport const templateStore = traceStore('templates', new Store<Record<string, TemplateConfiguration>>({}));\n\nfunction scopeKey(workspaceId?: string): string {\n return workspaceId === undefined ? HOST : `workspace:${workspaceId}`;\n}\n\nfunction patch(key: string, update: Partial<TemplateConfiguration>): void {\n templateStore.setState((state) => ({ ...state, [key]: { ...(state[key] ?? EMPTY), ...update } }));\n}\n\nexport function refreshTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n const request = (requests.get(key) ?? 0) + 1;\n requests.set(key, request);\n patch(key, { loading: true, error: undefined });\n const pending = (async () => {\n try {\n const result = await readSettingsConfig('', [KEY, BACKDROP_KEY], workspaceId);\n if (requests.get(key) !== request) return;\n if (result.ok) patch(key, { config: result.config, loading: false, error: undefined });\n else patch(key, { loading: false, error: result.error });\n } catch (error) {\n if (requests.get(key) === request)\n patch(key, { loading: false, error: error instanceof Error ? error.message : String(error) });\n } finally {\n if (requests.get(key) === request) pendingRequests.delete(key);\n }\n })();\n pendingRequests.set(key, pending);\n return pending;\n}\n\n/** Initial consumers share a read and reuse resolved config; explicit refreshes can supersede it. */\nexport function ensureTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n return (\n pendingRequests.get(key) ??\n (templateStore.state[key]?.config === undefined ? refreshTemplateConfiguration(workspaceId) : Promise.resolve())\n );\n}\n\nexport function useTemplateConfiguration(workspaceId?: string): TemplateConfiguration {\n const key = scopeKey(workspaceId);\n const entry = useStore(templateStore, (state) => state[key] ?? EMPTY);\n useEffect(() => {\n void ensureTemplateConfiguration(workspaceId);\n return onHubConnected(() => {\n void (pendingRequests.get(key) ?? refreshTemplateConfiguration(workspaceId));\n });\n }, [key, workspaceId]);\n return entry;\n}\n\n/** Refuse unavailable choices before attempting the existing authorized, hash-checked write. */\nexport async function saveTemplateDefault(id: string | null, workspaceId?: string): Promise<boolean> {\n const mount = workspaceId === undefined ? { scope: 'host' as const } : { scope: 'workspace' as const, workspaceId };\n const available = id === null || webTemplateCatalog(mount).templates.some((template) => template.id === id);\n return await saveWebChoice('template', id, available, workspaceId);\n}\n\n/** `null` clears the choice so Po's meadow shows; `none` shows no background. */\nexport async function saveBackdropDefault(choice: string | null, workspaceId?: string): Promise<boolean> {\n const available =\n choice === null ||\n choice === NO_BACKDROP ||\n hostSlotFills(HOST_SLOTS.backdrop).some((fill) => backdropId(fill) === choice);\n return await saveWebChoice('backdrop', choice, available, workspaceId);\n}\n\nasync function saveWebChoice(\n field: 'template' | 'backdrop',\n value: string | null,\n available: boolean,\n workspaceId: string | undefined,\n): Promise<boolean> {\n const key = scopeKey(workspaceId);\n const entry = templateStore.state[key];\n if (entry?.saving) return false;\n if (entry?.config === undefined) {\n patch(key, { error: `Load the configuration before saving a ${field} default.` });\n return false;\n }\n if (!available) {\n patch(key, { error: `That ${field} is no longer available in this composition.` });\n return false;\n }\n const scope = workspaceId === undefined ? 'host' : 'repository';\n patch(key, { saving: true, error: undefined });\n const result = await writeSettingsValue(\n {\n repoRoot: entry.config.repoRoot,\n scope,\n keyPath: ['web', field],\n value,\n expectedHash: entry.config.hashes[scope],\n },\n workspaceId,\n );\n if (!result.ok) {\n // Keep the conflict visible. A reload is explicit, never an automatic overwrite.\n patch(key, { saving: false, error: result.error });\n return false;\n }\n requests.set(key, (requests.get(key) ?? 0) + 1);\n pendingRequests.delete(key);\n patch(key, { config: result.config, saving: false, loading: false, error: undefined });\n // Workspace views may inherit a newly saved host value.\n if (workspaceId === undefined) {\n await Promise.all(\n Object.keys(templateStore.state)\n .filter((cached) => cached.startsWith('workspace:'))\n .map((cached) => refreshTemplateConfiguration(cached.slice('workspace:'.length))),\n );\n }\n return true;\n}\n\nexport function configuredTemplate(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[KEY]?.value;\n}\n\nexport function configuredBackdrop(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[BACKDROP_KEY]?.value;\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,QAA+B;CAAE,SAAS;CAAM,QAAQ;AAAM;AACpE,MAAM,OAAO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,WAAW;EACd,MAAM,KAAK,EAAE,OAAO,QAAQ,MAAM,8CAA8C,CAAC;EACjF,OAAO;CACT;CACA,MAAM,QAAQ,gBAAgB,KAAA,IAAY,SAAS;CACnD,MAAM,KAAK;EAAE,QAAQ;EAAM,OAAO,KAAA;CAAU,CAAC;CAC7C,MAAM,SAAS,MAAMC,oBAAAA,mBACnB;EACE,UAAU,MAAM,OAAO;EACvB;EACA,SAAS,CAAC,OAAO,KAAK;EACtB;EACA,cAAc,MAAM,OAAO,OAAO;CACpC,GACA,WACF;CACA,IAAI,CAAC,OAAO,IAAI;EAEd,MAAM,KAAK;GAAE,QAAQ;GAAO,OAAO,OAAO;EAAM,CAAC;EACjD,OAAO;CACT;CACA,SAAS,IAAI,MAAM,SAAS,IAAI,GAAG,KAAK,KAAK,CAAC;CAC9C,gBAAgB,OAAO,GAAG;CAC1B,MAAM,KAAK;EAAE,QAAQ,OAAO;EAAQ,QAAQ;EAAO,SAAS;EAAO,OAAO,KAAA;CAAU,CAAC;CAErF,IAAI,gBAAgB,KAAA,GAClB,MAAM,QAAQ,IACZ,OAAO,KAAK,cAAc,KAAK,CAAC,CAC7B,QAAQ,WAAW,OAAO,WAAW,YAAY,CAAC,CAAC,CACnD,KAAK,WAAW,6BAA6B,OAAO,MAAM,EAAmB,CAAC,CAAC,CACpF;CAEF,OAAO;AACT;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,IAAI,EAAE;AACpC;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,aAAa,EAAE;AAC7C"}
1
+ {"version":3,"file":"templateStore.cjs","names":["traceStore","Store","readSettingsConfig","useStore","onHubConnected","webTemplateCatalog","NO_BACKDROP","hostSlotFills","HOST_SLOTS","backdropId","writeSettingsValue"],"sources":["../../../src/web/stores/templateStore.ts"],"sourcesContent":["import { HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\nimport { useEffect } from 'react';\n\nimport type { SettingsConfigView } from '../../types/settings';\nimport { hostSlotFills, webTemplateCatalog } from '../lib/pluginRegistry';\nimport { readSettingsConfig, writeSettingsValue } from '../lib/settingsApi';\nimport { backdropId } from '../lib/templateCatalog';\nimport { onHubConnected } from '../lib/transport';\nimport { traceStore } from '../lib/uiTrace';\n\nexport interface TemplateConfiguration {\n config?: SettingsConfigView;\n error?: string;\n loading: boolean;\n saving: boolean;\n}\n\nconst EMPTY: TemplateConfiguration = { loading: true, saving: false };\nconst HOST = 'host';\nconst KEY = 'web.template';\nconst BACKDROP_KEY = 'web.backdrop';\nconst requests = new Map<string, number>();\nconst pendingRequests = new Map<string, Promise<void>>();\n\n/** Preferences belong to Po config; this store caches only scoped API responses. */\nexport const templateStore = traceStore('templates', new Store<Record<string, TemplateConfiguration>>({}));\n\nfunction scopeKey(workspaceId?: string): string {\n return workspaceId === undefined ? HOST : `workspace:${workspaceId}`;\n}\n\nfunction patch(key: string, update: Partial<TemplateConfiguration>): void {\n templateStore.setState((state) => ({ ...state, [key]: { ...(state[key] ?? EMPTY), ...update } }));\n}\n\nexport function refreshTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n const request = (requests.get(key) ?? 0) + 1;\n requests.set(key, request);\n patch(key, { loading: true, error: undefined });\n const pending = (async () => {\n try {\n const result = await readSettingsConfig('', [KEY, BACKDROP_KEY], workspaceId);\n if (requests.get(key) !== request) return;\n if (result.ok) patch(key, { config: result.config, loading: false, error: undefined });\n else patch(key, { loading: false, error: result.error });\n } catch (error) {\n if (requests.get(key) === request)\n patch(key, { loading: false, error: error instanceof Error ? error.message : String(error) });\n } finally {\n if (requests.get(key) === request) pendingRequests.delete(key);\n }\n })();\n pendingRequests.set(key, pending);\n return pending;\n}\n\n/** Initial consumers share a read and reuse resolved config; explicit refreshes can supersede it. */\nexport function ensureTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n return (\n pendingRequests.get(key) ??\n (templateStore.state[key]?.config === undefined ? refreshTemplateConfiguration(workspaceId) : Promise.resolve())\n );\n}\n\nexport function useTemplateConfiguration(workspaceId?: string): TemplateConfiguration {\n const key = scopeKey(workspaceId);\n const entry = useStore(templateStore, (state) => state[key] ?? EMPTY);\n useEffect(() => {\n void ensureTemplateConfiguration(workspaceId);\n return onHubConnected(() => {\n void (pendingRequests.get(key) ?? refreshTemplateConfiguration(workspaceId));\n });\n }, [key, workspaceId]);\n return entry;\n}\n\n/** Refuse unavailable choices before attempting the existing authorized, hash-checked write. */\nexport async function saveTemplateDefault(id: string | null, workspaceId?: string): Promise<boolean> {\n const mount = workspaceId === undefined ? { scope: 'host' as const } : { scope: 'workspace' as const, workspaceId };\n const available = id === null || webTemplateCatalog(mount).templates.some((template) => template.id === id);\n return await saveWebChoice('template', id, available, workspaceId);\n}\n\n/** `null` clears the choice so Po's bamboo shows; `none` shows no background. */\nexport async function saveBackdropDefault(choice: string | null, workspaceId?: string): Promise<boolean> {\n const available =\n choice === null ||\n choice === NO_BACKDROP ||\n hostSlotFills(HOST_SLOTS.backdrop).some((fill) => backdropId(fill) === choice);\n return await saveWebChoice('backdrop', choice, available, workspaceId);\n}\n\nasync function saveWebChoice(\n field: 'template' | 'backdrop',\n value: string | null,\n available: boolean,\n workspaceId: string | undefined,\n): Promise<boolean> {\n const key = scopeKey(workspaceId);\n const entry = templateStore.state[key];\n if (entry?.saving) return false;\n if (entry?.config === undefined) {\n patch(key, { error: `Load the configuration before saving a ${field} default.` });\n return false;\n }\n if (!available) {\n patch(key, { error: `That ${field} is no longer available in this composition.` });\n return false;\n }\n const scope = workspaceId === undefined ? 'host' : 'repository';\n patch(key, { saving: true, error: undefined });\n const result = await writeSettingsValue(\n {\n repoRoot: entry.config.repoRoot,\n scope,\n keyPath: ['web', field],\n value,\n expectedHash: entry.config.hashes[scope],\n },\n workspaceId,\n );\n if (!result.ok) {\n // Keep the conflict visible. A reload is explicit, never an automatic overwrite.\n patch(key, { saving: false, error: result.error });\n return false;\n }\n requests.set(key, (requests.get(key) ?? 0) + 1);\n pendingRequests.delete(key);\n patch(key, { config: result.config, saving: false, loading: false, error: undefined });\n // Workspace views may inherit a newly saved host value.\n if (workspaceId === undefined) {\n await Promise.all(\n Object.keys(templateStore.state)\n .filter((cached) => cached.startsWith('workspace:'))\n .map((cached) => refreshTemplateConfiguration(cached.slice('workspace:'.length))),\n );\n }\n return true;\n}\n\nexport function configuredTemplate(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[KEY]?.value;\n}\n\nexport function configuredBackdrop(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[BACKDROP_KEY]?.value;\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,QAA+B;CAAE,SAAS;CAAM,QAAQ;AAAM;AACpE,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,eAAe;AACrB,MAAM,2BAAW,IAAI,IAAoB;AACzC,MAAM,kCAAkB,IAAI,IAA2B;;AAGvD,MAAa,gBAAgBA,gBAAAA,WAAW,aAAa,IAAIC,gBAAAA,MAA6C,CAAC,CAAC,CAAC;AAEzG,SAAS,SAAS,aAA8B;CAC9C,OAAO,gBAAgB,KAAA,IAAY,OAAO,aAAa;AACzD;AAEA,SAAS,MAAM,KAAa,QAA8C;CACxE,cAAc,UAAU,WAAW;EAAE,GAAG;GAAQ,MAAM;GAAE,GAAI,MAAM,QAAQ;GAAQ,GAAG;EAAO;CAAE,EAAE;AAClG;AAEA,SAAgB,6BAA6B,aAAqC;CAChF,MAAM,MAAM,SAAS,WAAW;CAChC,MAAM,WAAW,SAAS,IAAI,GAAG,KAAK,KAAK;CAC3C,SAAS,IAAI,KAAK,OAAO;CACzB,MAAM,KAAK;EAAE,SAAS;EAAM,OAAO,KAAA;CAAU,CAAC;CAC9C,MAAM,WAAW,YAAY;EAC3B,IAAI;GACF,MAAM,SAAS,MAAMC,oBAAAA,mBAAmB,IAAI,CAAC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AK,CAAC,CAC7B,QAAQ,WAAW,OAAO,WAAW,YAAY,CAAC,CAAC,CACnD,KAAK,WAAW,6BAA6B,OAAO,MAAM,EAAmB,CAAC,CAAC,CACpF;CAEF,OAAO;AACT;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,IAAI,EAAE;AACpC;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,aAAa,EAAE;AAC7C"}
@@ -15,7 +15,7 @@ export declare function ensureTemplateConfiguration(workspaceId?: string): Promi
15
15
  export declare function useTemplateConfiguration(workspaceId?: string): TemplateConfiguration;
16
16
  /** Refuse unavailable choices before attempting the existing authorized, hash-checked write. */
17
17
  export declare function saveTemplateDefault(id: string | null, workspaceId?: string): Promise<boolean>;
18
- /** `null` clears the choice so Po's meadow shows; `none` shows no background. */
18
+ /** `null` clears the choice so Po's bamboo shows; `none` shows no background. */
19
19
  export declare function saveBackdropDefault(choice: string | null, workspaceId?: string): Promise<boolean>;
20
20
  export declare function configuredTemplate(entry: TemplateConfiguration): string | undefined;
21
21
  export declare function configuredBackdrop(entry: TemplateConfiguration): string | undefined;
@@ -87,7 +87,7 @@ async function saveTemplateDefault(id, workspaceId) {
87
87
  workspaceId
88
88
  }).templates.some((template) => template.id === id), workspaceId);
89
89
  }
90
- /** `null` clears the choice so Po's meadow shows; `none` shows no background. */
90
+ /** `null` clears the choice so Po's bamboo shows; `none` shows no background. */
91
91
  async function saveBackdropDefault(choice, workspaceId) {
92
92
  return await saveWebChoice("backdrop", choice, choice === null || choice === NO_BACKDROP || hostSlotFills(HOST_SLOTS.backdrop).some((fill) => backdropId(fill) === choice), workspaceId);
93
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"templateStore.mjs","names":[],"sources":["../../../src/web/stores/templateStore.ts"],"sourcesContent":["import { HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\nimport { useEffect } from 'react';\n\nimport type { SettingsConfigView } from '../../types/settings';\nimport { hostSlotFills, webTemplateCatalog } from '../lib/pluginRegistry';\nimport { readSettingsConfig, writeSettingsValue } from '../lib/settingsApi';\nimport { backdropId } from '../lib/templateCatalog';\nimport { onHubConnected } from '../lib/transport';\nimport { traceStore } from '../lib/uiTrace';\n\nexport interface TemplateConfiguration {\n config?: SettingsConfigView;\n error?: string;\n loading: boolean;\n saving: boolean;\n}\n\nconst EMPTY: TemplateConfiguration = { loading: true, saving: false };\nconst HOST = 'host';\nconst KEY = 'web.template';\nconst BACKDROP_KEY = 'web.backdrop';\nconst requests = new Map<string, number>();\nconst pendingRequests = new Map<string, Promise<void>>();\n\n/** Preferences belong to Po config; this store caches only scoped API responses. */\nexport const templateStore = traceStore('templates', new Store<Record<string, TemplateConfiguration>>({}));\n\nfunction scopeKey(workspaceId?: string): string {\n return workspaceId === undefined ? HOST : `workspace:${workspaceId}`;\n}\n\nfunction patch(key: string, update: Partial<TemplateConfiguration>): void {\n templateStore.setState((state) => ({ ...state, [key]: { ...(state[key] ?? EMPTY), ...update } }));\n}\n\nexport function refreshTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n const request = (requests.get(key) ?? 0) + 1;\n requests.set(key, request);\n patch(key, { loading: true, error: undefined });\n const pending = (async () => {\n try {\n const result = await readSettingsConfig('', [KEY, BACKDROP_KEY], workspaceId);\n if (requests.get(key) !== request) return;\n if (result.ok) patch(key, { config: result.config, loading: false, error: undefined });\n else patch(key, { loading: false, error: result.error });\n } catch (error) {\n if (requests.get(key) === request)\n patch(key, { loading: false, error: error instanceof Error ? error.message : String(error) });\n } finally {\n if (requests.get(key) === request) pendingRequests.delete(key);\n }\n })();\n pendingRequests.set(key, pending);\n return pending;\n}\n\n/** Initial consumers share a read and reuse resolved config; explicit refreshes can supersede it. */\nexport function ensureTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n return (\n pendingRequests.get(key) ??\n (templateStore.state[key]?.config === undefined ? refreshTemplateConfiguration(workspaceId) : Promise.resolve())\n );\n}\n\nexport function useTemplateConfiguration(workspaceId?: string): TemplateConfiguration {\n const key = scopeKey(workspaceId);\n const entry = useStore(templateStore, (state) => state[key] ?? EMPTY);\n useEffect(() => {\n void ensureTemplateConfiguration(workspaceId);\n return onHubConnected(() => {\n void (pendingRequests.get(key) ?? refreshTemplateConfiguration(workspaceId));\n });\n }, [key, workspaceId]);\n return entry;\n}\n\n/** Refuse unavailable choices before attempting the existing authorized, hash-checked write. */\nexport async function saveTemplateDefault(id: string | null, workspaceId?: string): Promise<boolean> {\n const mount = workspaceId === undefined ? { scope: 'host' as const } : { scope: 'workspace' as const, workspaceId };\n const available = id === null || webTemplateCatalog(mount).templates.some((template) => template.id === id);\n return await saveWebChoice('template', id, available, workspaceId);\n}\n\n/** `null` clears the choice so Po's meadow shows; `none` shows no background. */\nexport async function saveBackdropDefault(choice: string | null, workspaceId?: string): Promise<boolean> {\n const available =\n choice === null ||\n choice === NO_BACKDROP ||\n hostSlotFills(HOST_SLOTS.backdrop).some((fill) => backdropId(fill) === choice);\n return await saveWebChoice('backdrop', choice, available, workspaceId);\n}\n\nasync function saveWebChoice(\n field: 'template' | 'backdrop',\n value: string | null,\n available: boolean,\n workspaceId: string | undefined,\n): Promise<boolean> {\n const key = scopeKey(workspaceId);\n const entry = templateStore.state[key];\n if (entry?.saving) return false;\n if (entry?.config === undefined) {\n patch(key, { error: `Load the configuration before saving a ${field} default.` });\n return false;\n }\n if (!available) {\n patch(key, { error: `That ${field} is no longer available in this composition.` });\n return false;\n }\n const scope = workspaceId === undefined ? 'host' : 'repository';\n patch(key, { saving: true, error: undefined });\n const result = await writeSettingsValue(\n {\n repoRoot: entry.config.repoRoot,\n scope,\n keyPath: ['web', field],\n value,\n expectedHash: entry.config.hashes[scope],\n },\n workspaceId,\n );\n if (!result.ok) {\n // Keep the conflict visible. A reload is explicit, never an automatic overwrite.\n patch(key, { saving: false, error: result.error });\n return false;\n }\n requests.set(key, (requests.get(key) ?? 0) + 1);\n pendingRequests.delete(key);\n patch(key, { config: result.config, saving: false, loading: false, error: undefined });\n // Workspace views may inherit a newly saved host value.\n if (workspaceId === undefined) {\n await Promise.all(\n Object.keys(templateStore.state)\n .filter((cached) => cached.startsWith('workspace:'))\n .map((cached) => refreshTemplateConfiguration(cached.slice('workspace:'.length))),\n );\n }\n return true;\n}\n\nexport function configuredTemplate(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[KEY]?.value;\n}\n\nexport function configuredBackdrop(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[BACKDROP_KEY]?.value;\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,QAA+B;CAAE,SAAS;CAAM,QAAQ;AAAM;AACpE,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,eAAe;AACrB,MAAM,2BAAW,IAAI,IAAoB;AACzC,MAAM,kCAAkB,IAAI,IAA2B;;AAGvD,MAAa,gBAAgB,WAAW,aAAa,IAAI,MAA6C,CAAC,CAAC,CAAC;AAEzG,SAAS,SAAS,aAA8B;CAC9C,OAAO,gBAAgB,KAAA,IAAY,OAAO,aAAa;AACzD;AAEA,SAAS,MAAM,KAAa,QAA8C;CACxE,cAAc,UAAU,WAAW;EAAE,GAAG;GAAQ,MAAM;GAAE,GAAI,MAAM,QAAQ;GAAQ,GAAG;EAAO;CAAE,EAAE;AAClG;AAEA,SAAgB,6BAA6B,aAAqC;CAChF,MAAM,MAAM,SAAS,WAAW;CAChC,MAAM,WAAW,SAAS,IAAI,GAAG,KAAK,KAAK;CAC3C,SAAS,IAAI,KAAK,OAAO;CACzB,MAAM,KAAK;EAAE,SAAS;EAAM,OAAO,KAAA;CAAU,CAAC;CAC9C,MAAM,WAAW,YAAY;EAC3B,IAAI;GACF,MAAM,SAAS,MAAM,mBAAmB,IAAI,CAAC,KAAK,YAAY,GAAG,WAAW;GAC5E,IAAI,SAAS,IAAI,G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,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,IAAI,EAAE;AACpC;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,aAAa,EAAE;AAC7C"}
1
+ {"version":3,"file":"templateStore.mjs","names":[],"sources":["../../../src/web/stores/templateStore.ts"],"sourcesContent":["import { HOST_SLOTS, NO_BACKDROP } from '@agimon-ai/po-core/web';\nimport { useStore } from '@tanstack/react-store';\nimport { Store } from '@tanstack/store';\nimport { useEffect } from 'react';\n\nimport type { SettingsConfigView } from '../../types/settings';\nimport { hostSlotFills, webTemplateCatalog } from '../lib/pluginRegistry';\nimport { readSettingsConfig, writeSettingsValue } from '../lib/settingsApi';\nimport { backdropId } from '../lib/templateCatalog';\nimport { onHubConnected } from '../lib/transport';\nimport { traceStore } from '../lib/uiTrace';\n\nexport interface TemplateConfiguration {\n config?: SettingsConfigView;\n error?: string;\n loading: boolean;\n saving: boolean;\n}\n\nconst EMPTY: TemplateConfiguration = { loading: true, saving: false };\nconst HOST = 'host';\nconst KEY = 'web.template';\nconst BACKDROP_KEY = 'web.backdrop';\nconst requests = new Map<string, number>();\nconst pendingRequests = new Map<string, Promise<void>>();\n\n/** Preferences belong to Po config; this store caches only scoped API responses. */\nexport const templateStore = traceStore('templates', new Store<Record<string, TemplateConfiguration>>({}));\n\nfunction scopeKey(workspaceId?: string): string {\n return workspaceId === undefined ? HOST : `workspace:${workspaceId}`;\n}\n\nfunction patch(key: string, update: Partial<TemplateConfiguration>): void {\n templateStore.setState((state) => ({ ...state, [key]: { ...(state[key] ?? EMPTY), ...update } }));\n}\n\nexport function refreshTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n const request = (requests.get(key) ?? 0) + 1;\n requests.set(key, request);\n patch(key, { loading: true, error: undefined });\n const pending = (async () => {\n try {\n const result = await readSettingsConfig('', [KEY, BACKDROP_KEY], workspaceId);\n if (requests.get(key) !== request) return;\n if (result.ok) patch(key, { config: result.config, loading: false, error: undefined });\n else patch(key, { loading: false, error: result.error });\n } catch (error) {\n if (requests.get(key) === request)\n patch(key, { loading: false, error: error instanceof Error ? error.message : String(error) });\n } finally {\n if (requests.get(key) === request) pendingRequests.delete(key);\n }\n })();\n pendingRequests.set(key, pending);\n return pending;\n}\n\n/** Initial consumers share a read and reuse resolved config; explicit refreshes can supersede it. */\nexport function ensureTemplateConfiguration(workspaceId?: string): Promise<void> {\n const key = scopeKey(workspaceId);\n return (\n pendingRequests.get(key) ??\n (templateStore.state[key]?.config === undefined ? refreshTemplateConfiguration(workspaceId) : Promise.resolve())\n );\n}\n\nexport function useTemplateConfiguration(workspaceId?: string): TemplateConfiguration {\n const key = scopeKey(workspaceId);\n const entry = useStore(templateStore, (state) => state[key] ?? EMPTY);\n useEffect(() => {\n void ensureTemplateConfiguration(workspaceId);\n return onHubConnected(() => {\n void (pendingRequests.get(key) ?? refreshTemplateConfiguration(workspaceId));\n });\n }, [key, workspaceId]);\n return entry;\n}\n\n/** Refuse unavailable choices before attempting the existing authorized, hash-checked write. */\nexport async function saveTemplateDefault(id: string | null, workspaceId?: string): Promise<boolean> {\n const mount = workspaceId === undefined ? { scope: 'host' as const } : { scope: 'workspace' as const, workspaceId };\n const available = id === null || webTemplateCatalog(mount).templates.some((template) => template.id === id);\n return await saveWebChoice('template', id, available, workspaceId);\n}\n\n/** `null` clears the choice so Po's bamboo shows; `none` shows no background. */\nexport async function saveBackdropDefault(choice: string | null, workspaceId?: string): Promise<boolean> {\n const available =\n choice === null ||\n choice === NO_BACKDROP ||\n hostSlotFills(HOST_SLOTS.backdrop).some((fill) => backdropId(fill) === choice);\n return await saveWebChoice('backdrop', choice, available, workspaceId);\n}\n\nasync function saveWebChoice(\n field: 'template' | 'backdrop',\n value: string | null,\n available: boolean,\n workspaceId: string | undefined,\n): Promise<boolean> {\n const key = scopeKey(workspaceId);\n const entry = templateStore.state[key];\n if (entry?.saving) return false;\n if (entry?.config === undefined) {\n patch(key, { error: `Load the configuration before saving a ${field} default.` });\n return false;\n }\n if (!available) {\n patch(key, { error: `That ${field} is no longer available in this composition.` });\n return false;\n }\n const scope = workspaceId === undefined ? 'host' : 'repository';\n patch(key, { saving: true, error: undefined });\n const result = await writeSettingsValue(\n {\n repoRoot: entry.config.repoRoot,\n scope,\n keyPath: ['web', field],\n value,\n expectedHash: entry.config.hashes[scope],\n },\n workspaceId,\n );\n if (!result.ok) {\n // Keep the conflict visible. A reload is explicit, never an automatic overwrite.\n patch(key, { saving: false, error: result.error });\n return false;\n }\n requests.set(key, (requests.get(key) ?? 0) + 1);\n pendingRequests.delete(key);\n patch(key, { config: result.config, saving: false, loading: false, error: undefined });\n // Workspace views may inherit a newly saved host value.\n if (workspaceId === undefined) {\n await Promise.all(\n Object.keys(templateStore.state)\n .filter((cached) => cached.startsWith('workspace:'))\n .map((cached) => refreshTemplateConfiguration(cached.slice('workspace:'.length))),\n );\n }\n return true;\n}\n\nexport function configuredTemplate(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[KEY]?.value;\n}\n\nexport function configuredBackdrop(entry: TemplateConfiguration): string | undefined {\n return entry.config?.values[BACKDROP_KEY]?.value;\n}\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,QAA+B;CAAE,SAAS;CAAM,QAAQ;AAAM;AACpE,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,eAAe;AACrB,MAAM,2BAAW,IAAI,IAAoB;AACzC,MAAM,kCAAkB,IAAI,IAA2B;;AAGvD,MAAa,gBAAgB,WAAW,aAAa,IAAI,MAA6C,CAAC,CAAC,CAAC;AAEzG,SAAS,SAAS,aAA8B;CAC9C,OAAO,gBAAgB,KAAA,IAAY,OAAO,aAAa;AACzD;AAEA,SAAS,MAAM,KAAa,QAA8C;CACxE,cAAc,UAAU,WAAW;EAAE,GAAG;GAAQ,MAAM;GAAE,GAAI,MAAM,QAAQ;GAAQ,GAAG;EAAO;CAAE,EAAE;AAClG;AAEA,SAAgB,6BAA6B,aAAqC;CA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Q,OAAO;EAAQ,QAAQ;EAAO,SAAS;EAAO,OAAO,KAAA;CAAU,CAAC;CAErF,IAAI,gBAAgB,KAAA,GAClB,MAAM,QAAQ,IACZ,OAAO,KAAK,cAAc,KAAK,CAAC,CAC7B,QAAQ,WAAW,OAAO,WAAW,YAAY,CAAC,CAAC,CACnD,KAAK,WAAW,6BAA6B,OAAO,MAAM,EAAmB,CAAC,CAAC,CACpF;CAEF,OAAO;AACT;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,IAAI,EAAE;AACpC;AAEA,SAAgB,mBAAmB,OAAkD;CACnF,OAAO,MAAM,QAAQ,OAAO,aAAa,EAAE;AAC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-web-dashboard",
3
- "version": "0.0.0-alpha.147",
3
+ "version": "0.0.0-alpha.148",
4
4
  "description": "Shared browser state, actions and optional views for Po dashboard templates.",
5
5
  "keywords": [
6
6
  "ai",
@@ -61,9 +61,9 @@
61
61
  "access": "public"
62
62
  },
63
63
  "dependencies": {
64
- "@agimon-ai/po-core": "0.0.0-alpha.147",
65
- "@agimon-ai/po-web-components": "0.0.0-alpha.147",
66
- "@agimon-ai/po-web-security": "0.0.0-alpha.147",
64
+ "@agimon-ai/po-core": "0.0.0-alpha.148",
65
+ "@agimon-ai/po-web-components": "0.0.0-alpha.148",
66
+ "@agimon-ai/po-web-security": "0.0.0-alpha.148",
67
67
  "@earendil-works/chord": "1.5.1",
68
68
  "@simplewebauthn/browser": "^14.0.0",
69
69
  "@tanstack/react-router": "1.170.45",
@@ -73,7 +73,7 @@
73
73
  "qrcode-generator": "^2.0.4"
74
74
  },
75
75
  "devDependencies": {
76
- "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.147",
76
+ "@agimon-ai/vibe-lint-plugin-po-web": "0.0.0-alpha.148",
77
77
  "@types/node": "26.6.5",
78
78
  "@types/react": "19.3.0",
79
79
  "@types/react-dom": "19.3.0",