@protoyard/decks-ui 1.2.4 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,8 @@ DeckApp adds what is Protoyard's own:
50
50
  | `debugSource` | `null` | Where the deck came from, for the agent reference |
51
51
  | `customSlides` | — | A generated deck's `src/custom-slides.ts` registry |
52
52
  | `resolveAvatar` | — | Library avatar id → URL (`avatarUrl` from `@protoyard/renderer-svelte`) |
53
+ | `messages` | — | Partial `DeckStageMessages` overrides for the stage and print view (`{ 'stage.closeOverview': 'Cerrar vista general' }`) |
54
+ | `designSystems` | — | `deckDesignSystems(compiled)` (the `compiled` that `protoyard ds use` exports): the stage paints that design system and DeckApp skips the deck theme |
53
55
 
54
56
  The wrapper keeps `data-py-deck-app`, `data-slide-id` and `data-slide-step`
55
57
  (they follow the stage's controller, including a deep link's first position),
@@ -11,13 +11,18 @@ import {
11
11
  parseDeckHash,
12
12
  parseDeckRoute,
13
13
  } from '@texuli/deck/engine';
14
- import { DeckStageCore, type DeckThemeLoader } from '@texuli/slides/stage-core';
14
+ import {
15
+ DeckStageCore,
16
+ type DeckStageMessages,
17
+ type DeckThemeLoader,
18
+ } from '@texuli/slides/stage-core';
15
19
  import { flushSync, onMount, untrack } from 'svelte';
16
20
  import { Button, IconButton } from 'texuli/button';
17
21
  import { LucideIcon } from 'texuli/icons/lucide';
18
22
  import { type DeckDebugSetting, deckDebugAvailable, isDevBuild } from '../debug/availability.js';
19
23
  import type { CustomSlideRegistry } from '../layouts/custom-slides.js';
20
24
  import { setDeckHostContext } from './context.js';
25
+ import type { DeckDesignSystems } from './design-systems.js';
21
26
  import { createProtoyardRenderers } from './renderers.js';
22
27
  import {
23
28
  prepareStageDeck,
@@ -57,6 +62,8 @@ let {
57
62
  debugSource = null,
58
63
  customSlides,
59
64
  resolveAvatar,
65
+ messages,
66
+ designSystems,
60
67
  }: {
61
68
  /** Validated deck document (`DeckSchema`). */
62
69
  deck: Deck;
@@ -89,6 +96,18 @@ let {
89
96
  customSlides?: CustomSlideRegistry;
90
97
  /** Resolves a library avatar id (`av-012`) to its image URL (team and people slides). */
91
98
  resolveAvatar?: (id: string) => string | undefined;
99
+ /**
100
+ * Partial overrides of the stage's words (`DeckStageMessages`, English
101
+ * defaults: `stage.closeOverview`, `stage.label`…), for the stage and the
102
+ * print view. Placeholders use `{name}`.
103
+ */
104
+ messages?: DeckStageMessages;
105
+ /**
106
+ * A design-system resolver for the stage (`deckDesignSystems(compiled)`).
107
+ * With a `ref`, the deck follows that design system: the stage paints its
108
+ * compiled variables and DeckApp does not load the deck's `style` theme.
109
+ */
110
+ designSystems?: DeckDesignSystems;
92
111
  } = $props();
93
112
 
94
113
  const stage = $derived(toStageDeck(deck));
@@ -109,7 +128,7 @@ setDeckHostContext({
109
128
  * stage's first render, with no migration or validation chunk. A deck that does not
110
129
  * prepare goes to the stage as it is, which shows its diagnostics instead of slides.
111
130
  */
112
- const prepared = $derived(prepareStageDeck(stage.input));
131
+ const prepared = $derived(prepareStageDeck(stage.input, designSystems?.ref));
113
132
  const stageDeck = $derived(prepared.ok ? prepared : stage.input);
114
133
  /** What the print view paints: the prepared model v2 deck. */
115
134
  const printDeck = $derived(prepared.ok ? prepared.deck : stage.input);
@@ -329,6 +348,7 @@ onMount(() => {
329
348
  {renderers}
330
349
  tier="developer"
331
350
  {loadTheme}
351
+ {messages}
332
352
  {resolveAvatar}
333
353
  />
334
354
  </div>
@@ -362,7 +382,9 @@ onMount(() => {
362
382
  {syncHash}
363
383
  {autofocus}
364
384
  {namespace}
365
- {loadTheme}
385
+ loadTheme={designSystems?.ref ? null : loadTheme}
386
+ designSystems={designSystems ?? null}
387
+ {messages}
366
388
  {resolveAvatar}
367
389
  {renderers}
368
390
  defaultRenderers={false}
@@ -416,6 +438,7 @@ onMount(() => {
416
438
  {renderers}
417
439
  tier="developer"
418
440
  {loadTheme}
441
+ {messages}
419
442
  {resolveAvatar}
420
443
  />
421
444
  </div>
@@ -1,8 +1,10 @@
1
1
  import '@texuli/slides/styles.css';
2
2
  import type { AgentReferenceSource } from '@protoyard/decks/agent';
3
3
  import type { Deck } from '@protoyard/decks/schema';
4
+ import { type DeckStageMessages } from '@texuli/slides/stage-core';
4
5
  import { type DeckDebugSetting } from '../debug/availability.ts';
5
6
  import type { CustomSlideRegistry } from '../layouts/custom-slides.ts';
7
+ import type { DeckDesignSystems } from './design-systems.ts';
6
8
  type $$ComponentProps = {
7
9
  /** Validated deck document (`DeckSchema`). */
8
10
  deck: Deck;
@@ -35,6 +37,18 @@ type $$ComponentProps = {
35
37
  customSlides?: CustomSlideRegistry;
36
38
  /** Resolves a library avatar id (`av-012`) to its image URL (team and people slides). */
37
39
  resolveAvatar?: (id: string) => string | undefined;
40
+ /**
41
+ * Partial overrides of the stage's words (`DeckStageMessages`, English
42
+ * defaults: `stage.closeOverview`, `stage.label`…), for the stage and the
43
+ * print view. Placeholders use `{name}`.
44
+ */
45
+ messages?: DeckStageMessages;
46
+ /**
47
+ * A design-system resolver for the stage (`deckDesignSystems(compiled)`).
48
+ * With a `ref`, the deck follows that design system: the stage paints its
49
+ * compiled variables and DeckApp does not load the deck's `style` theme.
50
+ */
51
+ designSystems?: DeckDesignSystems;
38
52
  };
39
53
  declare const DeckApp: import("svelte").Component<$$ComponentProps, {}, "">;
40
54
  type DeckApp = ReturnType<typeof DeckApp>;
@@ -0,0 +1,35 @@
1
+ import type { DeckStageCore } from '@texuli/slides/stage-core';
2
+ import type { ComponentProps } from 'svelte';
3
+ /**
4
+ * The stage's design-system resolver (`@texuli/player` `PlayerDesignSystems`:
5
+ * `resolve(ref)` and an optional `mode`), read off `DeckStageCore` so this
6
+ * package needs no direct dependency on `@texuli/player`.
7
+ */
8
+ export type PlayerDesignSystems = NonNullable<ComponentProps<typeof DeckStageCore>['designSystems']>;
9
+ /**
10
+ * What DeckApp's `designSystems` takes: the stage's resolver, plus the `ref`
11
+ * (`id@x.y.z`) the deck follows. A Protoyard deck document has no
12
+ * `designSystem` field, so DeckApp puts `{ ref }` on the deck it hands the
13
+ * stage; without `ref` the resolver is only forwarded.
14
+ */
15
+ export interface DeckDesignSystems extends PlayerDesignSystems {
16
+ readonly ref?: string;
17
+ }
18
+ /** The fields of a compiled design system this helper reads (`ShippedDesignSystem` has them). */
19
+ export interface DeckCompiledDesignSystem {
20
+ readonly id: string;
21
+ readonly version: string;
22
+ readonly vars: Readonly<Record<string, Readonly<Record<string, string>> | undefined>>;
23
+ }
24
+ /**
25
+ * A deck resolver for one compiled design system (the `compiled` that
26
+ * `protoyard ds use` exports): `ref` is `<id>@<version>`, and `resolve`
27
+ * returns the compiled design system for that ref only (never a fetch).
28
+ * Pass it to `<DeckApp designSystems={…}>`; the deck's own theme is then not
29
+ * loaded, and the design system's variables paint the stage.
30
+ */
31
+ export declare function deckDesignSystems(compiled: DeckCompiledDesignSystem, options?: {
32
+ mode?: 'light' | 'dark';
33
+ }): DeckDesignSystems & {
34
+ readonly ref: string;
35
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A deck resolver for one compiled design system (the `compiled` that
3
+ * `protoyard ds use` exports): `ref` is `<id>@<version>`, and `resolve`
4
+ * returns the compiled design system for that ref only (never a fetch).
5
+ * Pass it to `<DeckApp designSystems={…}>`; the deck's own theme is then not
6
+ * loaded, and the design system's variables paint the stage.
7
+ */
8
+ export function deckDesignSystems(compiled, options = {}) {
9
+ const ref = `${compiled.id}@${compiled.version}`;
10
+ return {
11
+ ref,
12
+ resolve: (asked) => asked === ref ? compiled : undefined,
13
+ ...(options.mode ? { mode: options.mode } : {}),
14
+ };
15
+ }
@@ -4,3 +4,4 @@
4
4
  */
5
5
  export type { CustomSlideComponent, CustomSlideLoader, CustomSlideProps, CustomSlideRegistry, } from '../layouts/custom-slides.ts';
6
6
  export { default as DeckApp } from './DeckApp.svelte';
7
+ export { type DeckCompiledDesignSystem, type DeckDesignSystems, deckDesignSystems, type PlayerDesignSystems, } from './design-systems.ts';
package/dist/app/index.js CHANGED
@@ -3,3 +3,4 @@
3
3
  * player's deck entry and generated deck prototypes both mount (ADR-038).
4
4
  */
5
5
  export { default as DeckApp } from './DeckApp.svelte';
6
+ export { deckDesignSystems, } from "./design-systems.js";
@@ -36,5 +36,6 @@ export declare function stageDeck(deck: Deck): StageDeck;
36
36
  * prepared deck: at the `developer` tier the stage paints it on its first render
37
37
  * without migrating or validating it again, and loads no validation chunk for it.
38
38
  * Never throws: a deck that does not validate comes back with its issues.
39
+ * `designSystemRef` (`id@x.y.z`) sets the deck model's `designSystem`.
39
40
  */
40
- export declare function prepareStageDeck(input: Record<string, unknown>): PreparedDeck;
41
+ export declare function prepareStageDeck(input: Record<string, unknown>, designSystemRef?: string): PreparedDeck;
@@ -59,7 +59,11 @@ export function stageDeck(deck) {
59
59
  * prepared deck: at the `developer` tier the stage paints it on its first render
60
60
  * without migrating or validating it again, and loads no validation chunk for it.
61
61
  * Never throws: a deck that does not validate comes back with its issues.
62
+ * `designSystemRef` (`id@x.y.z`) sets the deck model's `designSystem`.
62
63
  */
63
- export function prepareStageDeck(input) {
64
- return prepareDeckV2(toTexuliDeck(input), { validateBlock: validateProtoyardBlock });
64
+ export function prepareStageDeck(input, designSystemRef) {
65
+ const deck = toTexuliDeck(input);
66
+ // A Protoyard deck has no `designSystem`; the host's resolver names the one it follows.
67
+ const withSystem = designSystemRef ? { ...deck, designSystem: { ref: designSystemRef } } : deck;
68
+ return prepareDeckV2(withSystem, { validateBlock: validateProtoyardBlock });
65
69
  }
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { type CanvasFit as DeckCanvasFit, fitDeckCanvas } from '@texuli/deck/engine';
2
+ export { type DeckCompiledDesignSystem, type DeckDesignSystems, deckDesignSystems, type PlayerDesignSystems, } from './app/design-systems.ts';
package/dist/index.js CHANGED
@@ -5,3 +5,4 @@
5
5
  * `@texuli/slides` (Texuli ADR-009).
6
6
  */
7
7
  export { fitDeckCanvas } from '@texuli/deck/engine';
8
+ export { deckDesignSystems, } from "./app/design-systems.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protoyard/decks-ui",
3
- "version": "1.2.4",
3
+ "version": "1.4.0",
4
4
  "description": "Svelte 5 deck host for Protoyard: DeckApp on the @texuli/slides stage, with Protoyard's free and custom slides, Deck Studio and the Debug for agents panel, each on its own lazy subpath.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@lucide/svelte": "^1.64.0",
52
- "@protoyard/blocks": "1.2.4",
53
- "@protoyard/blocks-ui": "1.2.4",
54
- "@protoyard/decks": "1.2.4",
55
- "@texuli/deck": "0.13.1",
56
- "@texuli/slides": "0.13.1",
57
- "texuli": "0.13.1"
52
+ "@protoyard/blocks": "1.4.0",
53
+ "@protoyard/blocks-ui": "1.4.0",
54
+ "@protoyard/decks": "1.4.0",
55
+ "@texuli/deck": "0.14.1",
56
+ "@texuli/slides": "0.14.1",
57
+ "texuli": "0.14.1"
58
58
  },
59
59
  "devDependencies": {
60
60
  "svelte": "^5.57.3"