@takazudo/zudo-sg 0.3.4 → 0.3.6
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/CHANGELOG.md +31 -0
- package/README.md +13 -3
- package/dist/config/index.js +2 -1
- package/dist/plugins/routes.js +2 -1
- package/dist/registry/registry.d.ts +3 -0
- package/dist/registry/registry.js +4 -2
- package/dist/safelist.css +1 -1
- package/dist/sg-routes.d.ts +6 -0
- package/dist/sg-routes.js +16 -0
- package/dist/token-tweak/bootstrap-preview-token-panel.js +6 -1
- package/dist/token-tweak/index.d.ts +1 -0
- package/dist/token-tweak/index.js +3 -0
- package/dist/token-tweak/preview-token-panel-capture.d.ts +13 -0
- package/dist/token-tweak/preview-token-panel-capture.js +21 -0
- package/dist/token-tweak/token-panel-native-bootstrap.d.ts +1 -1
- package/dist/token-tweak/token-panel-native-bootstrap.js +2 -2
- package/package.json +3 -3
- package/routes-src/_registry.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,37 @@ All notable changes to `@takazudo/zudo-sg` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on Keep a Changelog, and release notes are generated from the changelog MDX pages.
|
|
6
6
|
|
|
7
|
+
## [0.3.6] - 2026-09-25
|
|
8
|
+
|
|
9
|
+
This release updates the supported zfb toolchain to 2.20.3 so staged
|
|
10
|
+
workspace packages share one Preact runtime during server rendering.
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- Raise the zfb peer floor to `^2.20.3`, picking up the upstream fix for
|
|
15
|
+
hooks and provider context in package-owned routes.
|
|
16
|
+
- Align the documented installation command and verified starter toolchain
|
|
17
|
+
with the updated zfb runtime and Markdown packages.
|
|
18
|
+
|
|
19
|
+
## [0.3.5] - 2026-09-25
|
|
20
|
+
|
|
21
|
+
This release makes the public preview trigger reliable during SPA navigation
|
|
22
|
+
and keeps story detail routes distinct from the iframe preview endpoint.
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- Capture clicks on a visible preview-token header trigger before the load
|
|
27
|
+
island is ready, then replay the pending toggle exactly once.
|
|
28
|
+
- Allocate distinct story slugs when a default or custom preview endpoint
|
|
29
|
+
occupies a component detail URL. Route options now stay consistent across
|
|
30
|
+
the catalog, detail pages, and host registry.
|
|
31
|
+
|
|
32
|
+
### Verification
|
|
33
|
+
|
|
34
|
+
- Exercise the packed engine in an independent host, including a deterministic
|
|
35
|
+
early-click browser check and rendered story identities for default and
|
|
36
|
+
custom preview routes.
|
|
37
|
+
|
|
7
38
|
## [0.3.4] - 2026-09-24
|
|
8
39
|
|
|
9
40
|
This release aligns the engine's peer requirements with the tested zfb,
|
package/README.md
CHANGED
|
@@ -88,7 +88,11 @@ preview/control combinations, and missing references fail generation before
|
|
|
88
88
|
writing output. Run `pnpm gen-token-manifest` after changing CSS or the spec,
|
|
89
89
|
then `pnpm gen-token-manifest --check` in CI. The complete foreign configuration lives in `fixtures/foreign-tokens/`. The packed foreign-host
|
|
90
90
|
proof is `node scripts/verify-styleguide-install.mjs` from
|
|
91
|
-
this repository (a guarded heavy check).
|
|
91
|
+
this repository (a guarded heavy check). It installs the packed tarball with
|
|
92
|
+
pinned peers outside the workspace, builds at `/styleguide/`, checks the
|
|
93
|
+
default, custom-collision, and outside-namespace configurations, and runs
|
|
94
|
+
browser checks for early preview-panel clicks plus the rendered identity
|
|
95
|
+
inside detail-page iframes.
|
|
92
96
|
|
|
93
97
|
## Framework scope
|
|
94
98
|
|
|
@@ -126,10 +130,10 @@ output as drift and never writes it.
|
|
|
126
130
|
## Installation
|
|
127
131
|
|
|
128
132
|
```sh
|
|
129
|
-
pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^2.20.
|
|
133
|
+
pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^2.20.3 @takazudo/zfb-md-wasm@^2.20.3 @takazudo/zfb-runtime@^2.20.3 @takazudo/zudo-doc@^5.27.0 @takazudo/zdtp@^0.8.2 diff@^8.0.4 katex@^0.16.38 preact@^10.29.8 preact-render-to-string@^6.6.6 tailwindcss@^4.2.0 zod@^4.3.6
|
|
130
134
|
```
|
|
131
135
|
|
|
132
|
-
The engine peers are `@takazudo/zfb ^2.20.
|
|
136
|
+
The engine peers are `@takazudo/zfb ^2.20.3`, `@takazudo/zudo-doc ^5.27.0`,
|
|
133
137
|
`@takazudo/zdtp ^0.8.2`, and `preact ^10.29.8`. `@takazudo/zdtp` is required:
|
|
134
138
|
the injected `/tokens` route imports its dashboard at build time. The
|
|
135
139
|
`@takazudo/zfb-md-wasm`, `@takazudo/zfb-runtime`, `diff`, `katex`, and `zod`
|
|
@@ -187,6 +191,12 @@ usage snippets and catalog labels; when omitted, scaffolded usage snippets
|
|
|
187
191
|
import the component from its own relative module. The generated registry's
|
|
188
192
|
`StoryModule` type always comes from `@takazudo/zudo-sg/stories`.
|
|
189
193
|
|
|
194
|
+
If a host calls `createRegistry()` directly, pass the same `routes` overrides
|
|
195
|
+
used by `withZudoSg()`. The default preview endpoint occupies the detail URL
|
|
196
|
+
for the slug `preview`, so a story titled “Preview” gets `preview-2`. Custom
|
|
197
|
+
preview endpoints within the detail route pattern are reserved the same way;
|
|
198
|
+
endpoints outside that pattern do not change story slugs.
|
|
199
|
+
|
|
190
200
|
Full option shape, virtual modules, and every locked constant:
|
|
191
201
|
`docs/adr/styleguide-engine.md` in this repository.
|
|
192
202
|
|
package/dist/config/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "../registry/component-docs.js";
|
|
6
6
|
import { DEFAULT_PREVIEW_CSS_URL } from "../sg-context.js";
|
|
7
7
|
import { resolveSgRoutes } from "../sg-routes.js";
|
|
8
|
+
import { PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT } from "../token-tweak/preview-token-panel-capture.js";
|
|
8
9
|
const ROUTES_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/routes";
|
|
9
10
|
const PREVIEW_CSS_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/preview-css";
|
|
10
11
|
const ZDTP_APPLY_PROXY_PLUGIN_NAME = "@takazudo/zudo-sg/plugins/zdtp-apply-proxy";
|
|
@@ -52,7 +53,7 @@ const PREVIEW_TOKEN_PANEL_EVENT = "toggle-preview-token-panel";
|
|
|
52
53
|
const ENGINE_ROUTE_ATTR = "data-sg-engine-route";
|
|
53
54
|
const TRIGGER_INSTALLED_FLAG = "__sgPreviewTokensTriggerInstalled";
|
|
54
55
|
const SLIDERS_GLYPH = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="4" y1="6" x2="20" y2="6"></line><line x1="4" y1="12" x2="20" y2="12"></line><line x1="4" y1="18" x2="20" y2="18"></line><circle cx="9" cy="6" r="2.4" fill="currentColor" stroke="none"></circle><circle cx="15" cy="12" r="2.4" fill="currentColor" stroke="none"></circle><circle cx="8" cy="18" r="2.4" fill="currentColor" stroke="none"></circle></svg>';
|
|
55
|
-
const HEADER_TOKEN_TRIGGER_HTML = `<button id="${HEADER_TOKEN_TRIGGER_ID}" type="button" hidden class="flex items-center justify-center text-muted transition-colors hover:text-fg cursor-pointer" aria-label="Open component tokens panel" title="Component tokens" onclick="window.dispatchEvent(new CustomEvent('${PREVIEW_TOKEN_PANEL_EVENT}'))">` + SLIDERS_GLYPH +
|
|
56
|
+
const HEADER_TOKEN_TRIGGER_HTML = `<button id="${HEADER_TOKEN_TRIGGER_ID}" type="button" hidden class="flex items-center justify-center text-muted transition-colors hover:text-fg cursor-pointer" aria-label="Open component tokens panel" title="Component tokens" onclick="window.dispatchEvent(new CustomEvent('${PREVIEW_TOKEN_PANEL_EVENT}'))">` + SLIDERS_GLYPH + "</button><script>(function(){" + PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT + `if(window.${TRIGGER_INSTALLED_FLAG})return;window.${TRIGGER_INSTALLED_FLAG}=true;function sync(){var btn=document.getElementById(${JSON.stringify(HEADER_TOKEN_TRIGGER_ID)});if(!btn)return;btn.hidden=!document.querySelector(${JSON.stringify(`[${ENGINE_ROUTE_ATTR}]`)});}sync();if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",sync);document.addEventListener(${JSON.stringify(AFTER_NAVIGATE_EVENT)},sync);})();</script>`;
|
|
56
57
|
const HEADER_TOKEN_TRIGGER_ITEM = {
|
|
57
58
|
type: "html",
|
|
58
59
|
html: HEADER_TOKEN_TRIGGER_HTML
|
package/dist/plugins/routes.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
DEFAULT_CATALOG_TITLE,
|
|
7
7
|
DEFAULT_PREVIEW_CSS_URL
|
|
8
8
|
} from "../sg-context.js";
|
|
9
|
-
import { DEFAULT_SG_ROUTES } from "../sg-routes.js";
|
|
9
|
+
import { DEFAULT_SG_ROUTES, previewCollisionSlug } from "../sg-routes.js";
|
|
10
10
|
const PLUGIN_NAME = "@takazudo/zudo-sg/plugins/routes";
|
|
11
11
|
const ZUDO_DOC_ROUTES_PLUGIN_NAME = "@takazudo/zudo-doc/plugins/routes";
|
|
12
12
|
const CONTEXT_MODULE_ID = "virtual:zudo-sg-context";
|
|
@@ -68,6 +68,7 @@ function normalizeRoutes(value) {
|
|
|
68
68
|
if (!routes.componentsSlug.includes("[slug]")) {
|
|
69
69
|
fail(`option "routes.componentsSlug" = "${routes.componentsSlug}" must contain the "[slug]" segment`);
|
|
70
70
|
}
|
|
71
|
+
previewCollisionSlug(routes);
|
|
71
72
|
const seen = /* @__PURE__ */ new Map();
|
|
72
73
|
for (const key of ROUTE_KEYS) {
|
|
73
74
|
const other = seen.get(routes[key]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Story, StoryMeta, StoryModule } from "../stories/types.js";
|
|
2
|
+
import { type SgRoutes } from "../sg-routes.js";
|
|
2
3
|
/**
|
|
3
4
|
* Slugs reserved by the styleguide chrome — Overview (the components index
|
|
4
5
|
* route) and Design Tokens (the tokens route). They are NOT story slugs: a
|
|
@@ -44,6 +45,8 @@ export interface CreateRegistryOptions {
|
|
|
44
45
|
categoryOrder?: readonly string[];
|
|
45
46
|
/** Codegen-emitted source order of each story file's exports, keyed like `storyModules`. */
|
|
46
47
|
storyExportOrder?: Readonly<Record<string, readonly string[]>>;
|
|
48
|
+
/** The same route overrides passed to `withZudoSg()`; defaults are used when omitted. */
|
|
49
|
+
routes?: Partial<SgRoutes>;
|
|
47
50
|
}
|
|
48
51
|
export interface Registry {
|
|
49
52
|
/** Full group order: `categoryOrder` (deduped) + unlisted used categories, alphabetical. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { previewCollisionSlug } from "../sg-routes.js";
|
|
1
2
|
const OVERVIEW_SLUG = "";
|
|
2
3
|
const TOKENS_SLUG = "tokens";
|
|
3
4
|
const RESERVED_NAV_SLUGS = [OVERVIEW_SLUG, TOKENS_SLUG];
|
|
@@ -21,9 +22,10 @@ function computeCategoryOrder(storyModules, declared = []) {
|
|
|
21
22
|
}
|
|
22
23
|
return [...listed, ...[...unlisted].sort((a, b) => a.localeCompare(b))];
|
|
23
24
|
}
|
|
24
|
-
function buildEntries(storyModules, storyExportOrder) {
|
|
25
|
+
function buildEntries(storyModules, storyExportOrder, previewSlug) {
|
|
25
26
|
const entries = [];
|
|
26
27
|
const seenSlugs = new Set(RESERVED_NAV_SLUGS);
|
|
28
|
+
if (previewSlug !== null) seenSlugs.add(previewSlug);
|
|
27
29
|
for (const [path, mod] of Object.entries(storyModules)) {
|
|
28
30
|
const meta = readMeta(mod);
|
|
29
31
|
if (!meta) continue;
|
|
@@ -51,7 +53,7 @@ function buildEntries(storyModules, storyExportOrder) {
|
|
|
51
53
|
}
|
|
52
54
|
function createRegistry(storyModules, options = {}) {
|
|
53
55
|
const categoryOrder = computeCategoryOrder(storyModules, options.categoryOrder);
|
|
54
|
-
const storyEntries = buildEntries(storyModules, options.storyExportOrder ?? {});
|
|
56
|
+
const storyEntries = buildEntries(storyModules, options.storyExportOrder ?? {}, previewCollisionSlug(options.routes));
|
|
55
57
|
const entryBySlug = new Map(storyEntries.map((e) => [e.slug, e]));
|
|
56
58
|
function getCategoryGroups() {
|
|
57
59
|
const byCategory = /* @__PURE__ */ new Map();
|
package/dist/safelist.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* generated by gen-safelist.mjs — do not edit by hand */
|
|
2
|
-
@source inline("-components [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state accept across add adjusted after alias all allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are arguments aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array arrays as aside assumes async at authored await back bar barrel barrel-export base be because before below beneath bg bg-[var(--sg-accent)] bg-[var(--sg-bg)] bg-[var(--sg-surface)] bg-[var(--sg-surface-2)] bg-bg block body bogus boolean border border-[color:var(--sg-accent)] border-[color:var(--sg-border)] border-[color:var(--sg-border-strong)] border-b border-t border-transparent both break build builds but button by cache-control cannot canvas carries cascading case catalog catch categories category caution change changing checkbox children circle clamp class classes clear-css-vars clickable client code codegen collapsing collection collides color colors command commit compact compare compile compiled component components components2026 config configured confirm const contain content-type continue control copy count counts css cursor-pointer custom custom-property danger dark dashboard dashboards data-category data-copied data-keywords data-name data-sg-card data-sg-catalog data-sg-catalog-intro data-sg-code-panel-hidden data-sg-code-panel-resizer data-sg-empty data-sg-engine-route data-sg-injected-css data-sg-preview-css data-sg-preview-doc data-sg-preview-loading data-sg-preview-scope data-sg-section data-sg-stage-grid data-sg-tile data-sg-tile-size data-sg-variant-root data-theme data-zudo-sg-tokens-empty date debugger declaration declarations declare declared default defaults delete demo derived describe description descriptors design design-token desktop detail detect dev different differs digit directory disabled discovered display distinct div do doc doc-chrome does drift driven dual-scheme duplicate duration each edit editing edits either el element else empty en endpoint engine entries entry entrypoint enum equivalent eval every exists expected explicit export exported exports exposes expressions extends extension failed fails false family fg field file files filled finally find finite first first-authored five fixed flag flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--sg-focus)] focus-visible:outline-offset-2 follow followed follows font font-bold font-family font-medium font-semibold font-size font-size-lh font-weight for form found frame frames free-form from frost full function g gap-hsp-2xs gap-hsp-3xs gap-hsp-md gap-hsp-sm gap-hsp-xs gap-vsp-2xs gap-vsp-lg gap-vsp-md gap-x-hsp-xl gap-y-vsp-xl gate gen-registry gen-token-manifest gen:sg-registry generated get give glob-relative grid grid-cols-1 grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))] group groups guards h-[1.5rem] h-full h1 h2 h3 hand handle hands has have head header headers height here hex hidden hold host hover:text-[color:var(--sg-fg)] hover:text-fg hsp html human-friendly id if iframe iframes implements import important in include including inert info init inject inline-block inline-flex input inserting inserts inside installed instanceof instead interface into intro invalid inventory is isolated it items-center items-start its itself justify-between justify-center kebab-case keeps key key-enumeration keyboard keydown keyed kind known label large layout lazy leading leading-normal left length let lh light like line line-beauty-accent line-beauty-accent-dark line-beauty-hover line-beauty-hover-dark line-height line-laser-accent line-laser-accent-dark line-laser-hover line-laser-hover-dark line-meeting-accent line-meeting-accent-dark line-meeting-hover line-meeting-hover-dark line-process-accent line-process-accent-dark line-process-hover line-process-hover-dark line-vacuum-accent line-vacuum-accent-dark line-vacuum-hover line-vacuum-hover-dark link lint:tokens list listed lists live load loading m-0 m21 makes manifest map marker markers match matching material max-w-[56rem] may mb-vsp-2xs mb-vsp-lg mb-vsp-sm mb-vsp-xl message meta metadata min-h-0 mirroring missing mobile mode mode-dependent mode-independent model module ms ms-auto mt-vsp-2xs mt-vsp-3xs mt-vsp-xl mt-vsp-xs must mx-auto name name/value named named-export names namespace navigation needs neutral-0 neutral-1 neutral-2 neutral-3 never new new-component new:component no no-store node:crypto node:fs node:fs/promises node:module node:path node:url noindex non-empty none not note nowhere null number object of off oklch omit omitted on once one one-sentence only option options opts or order ordered other out outline-none overflow-auto overflow-hidden overflow-x-auto overriding p p-hsp-2xs p-hsp-md p-hsp-sm package pages pairs palette palette- panel panels parse parsed parser pass passes path per-element per-variant pick pill placeholders plain plugin plugins pnpm polite polyline portable positive postcss pre preact-render-to-string preact/hooks preact/jsx-runtime presentation preserve preview previews primary private property protected pt-vsp-xl public pushes px px-hsp-2xs px-hsp-md px-hsp-sm px-hsp-xs py-vsp-2xs py-vsp-3xs py-vsp-xs radius rail ramp ramps range raw re-executed re-run read-only readonly ready real recover rect reference references regenerated region registration relative rem rem-aware rem-based renamed/removed render rendered renders replace require required requires resolve resolved return returns rhythm robots root-absolute round rounded rounded-full rounded-md rounded-sm route router routes routes-src row rows run runtime s same saved scaffold scaffolds screen scrim script search secondary section segment segments select semantic separator set settings sg-catalog-tile-size sg-chip sg-chip-row sg-code-panel sg-code-panel-hidden sg-code-panel-resizer sg-code-panel-width sg-copy-btn sg-filter sg-filter-row sg-gallery-section sg-grid sg-injected- sg-preview-design-token-panel-modal sg-preview-design-tokens sg-preview-design-tokens/v1 sg-preview-tokens-trigger sg-preview-tweak sg-registry sg-search-clear sg-search-field sg-search-input sg-seg sg-seg-btn sg-thumb sg-thumb-inner sg-thumb-note sg-tile sg-tile-count sg-tile-desc sg-tile-meta sg-tile-title sg-workbench-toolbar sg:height sg:ready sgt- shadow shape shared show shown shrink-0 sidebar sidebar- single-axis site size skipped skips slider slug so solid sorts source spacing span spec specimen stacked starting state state-danger state-danger-dark state-info state-info-dark state-success state-success-dark state-warning state-warning-dark static stay step still story string strings stroke-linecap stroke-linejoin stroke-width style stylesheet super supplies supply support supported surface surfaces svg swaps swatch switch tab tablet tablist tabs tabular-nums text text-2xl text-[color:var(--sg-accent)] text-[color:var(--sg-fg)] text-[color:var(--sg-muted)] text-[color:var(--sg-on-accent)] text-caption text-fg text-heading text-muted text-right text-sm text-small text-xl text-xs text/icons textarea that the their them theme then these this three-tier throw tier tier-model tile time tip title to toggle toggle-design-token-panel toggle-preview-token-panel token tokens total tracking-wide transition-colors true try tsx tweaks twice two type typechecks typeof ui- ui-color ui-defaults-dark ui-defaults-light ui-defaults-shared undefined under underline underline-offset-2 unique unit unitless units unknown unsupported unwired up uppercase us use used uses utf-8 utf8 valid value values var variant variants vertical via viewport views virtual:zudo-doc-chrome-bindings virtual:zudo-doc-route-context virtual:zudo-sg-context virtual:zudo-sg-preview-token-panel virtual:zudo-sg-registry virtual:zudo-sg-tokens visible visit void vs vsp w-[2.5rem] w-[5rem] warning was weight were what when which while whole whose will window with without would written yield you your zd-content zdtp-preview-prehydrate zfb zfb:after-swap zudo-doc zudo-doc-sidebar-width zudo-sg zudo-sg-token-tweak-bridge");
|
|
2
|
+
@source inline("-components [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state accept across add adjusted after alias all allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are arguments aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array arrays as aside assumes async at authored await back bar barrel barrel-export base be because before below beneath bg bg-[var(--sg-accent)] bg-[var(--sg-bg)] bg-[var(--sg-surface)] bg-[var(--sg-surface-2)] bg-bg block body bogus boolean border border-[color:var(--sg-accent)] border-[color:var(--sg-border)] border-[color:var(--sg-border-strong)] border-b border-t border-transparent both break build builds but button by cache-control cannot canvas carries cascading case catalog catch categories category caution change changing checkbox children circle clamp class classes clear-css-vars clickable client code codegen collapsing collection collides color colors command commit compact compare compile compiled component components components2026 config configured confirm const contain content-type continue control copy count counts css cursor-pointer custom custom-property danger dark dashboard dashboards data-category data-copied data-keywords data-name data-sg-card data-sg-catalog data-sg-catalog-intro data-sg-code-panel-hidden data-sg-code-panel-resizer data-sg-empty data-sg-engine-route data-sg-injected-css data-sg-preview-css data-sg-preview-doc data-sg-preview-loading data-sg-preview-scope data-sg-section data-sg-stage-grid data-sg-tile data-sg-tile-size data-sg-variant-root data-theme data-zudo-sg-tokens-empty date debugger declaration declarations declare declared default defaults delete demo derived describe description descriptors design design-token desktop detail detect dev different differs digit directory disabled discovered display distinct div do doc doc-chrome does drift driven dual-scheme duplicate duration each edit editing edits either el element else empty en endpoint engine entries entry entrypoint enum equivalent eval every exactly exists expected explicit export exported exports exposes expressions extends extension failed fails false family fg field file files filled finally find finite first first-authored five fixed flag flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[color:var(--sg-focus)] focus-visible:outline-offset-2 follow followed follows font font-bold font-family font-medium font-semibold font-size font-size-lh font-weight for form found frame frames free-form from frost full function g gap-hsp-2xs gap-hsp-3xs gap-hsp-md gap-hsp-sm gap-hsp-xs gap-vsp-2xs gap-vsp-lg gap-vsp-md gap-x-hsp-xl gap-y-vsp-xl gate gen-registry gen-token-manifest gen:sg-registry generated get give glob-relative grid grid-cols-1 grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))] group groups guards h-[1.5rem] h-full h1 h2 h3 hand handle hands has have head header headers height here hex hidden hold host hover:text-[color:var(--sg-fg)] hover:text-fg hsp html human-friendly id if iframe iframes implements import important in include including inert info init inject inline-block inline-flex input inserting inserts inside installed instanceof instead interface into intro invalid inventory is isolated it items-center items-start its itself justify-between justify-center kebab-case keeps key key-enumeration keyboard keydown keyed kind known label large layout lazy leading leading-normal left length let lh light like line line-beauty-accent line-beauty-accent-dark line-beauty-hover line-beauty-hover-dark line-height line-laser-accent line-laser-accent-dark line-laser-hover line-laser-hover-dark line-meeting-accent line-meeting-accent-dark line-meeting-hover line-meeting-hover-dark line-process-accent line-process-accent-dark line-process-hover line-process-hover-dark line-vacuum-accent line-vacuum-accent-dark line-vacuum-hover line-vacuum-hover-dark link lint:tokens list listed lists live load loading m-0 m21 makes manifest map marker markers match matching material max-w-[56rem] may mb-vsp-2xs mb-vsp-lg mb-vsp-sm mb-vsp-xl message meta metadata min-h-0 mirroring missing mobile mode mode-dependent mode-independent model module ms ms-auto mt-vsp-2xs mt-vsp-3xs mt-vsp-xl mt-vsp-xs must mx-auto name name/value named named-export names namespace navigation needs neutral-0 neutral-1 neutral-2 neutral-3 never new new-component new:component no no-store node:crypto node:fs node:fs/promises node:module node:path node:url noindex non-empty none not note nowhere null number object of off oklch omit omitted on once one one-sentence only option options opts or order ordered other out outline-none overflow-auto overflow-hidden overflow-x-auto overriding p p-hsp-2xs p-hsp-md p-hsp-sm package pages pairs palette palette- panel panels parse parsed parser pass passes path per-element per-variant pick pill placeholder placeholders plain plugin plugins pnpm polite polyline portable positive postcss pre preact-render-to-string preact/hooks preact/jsx-runtime presentation preserve preview previews primary private property protected pt-vsp-xl public pushes px px-hsp-2xs px-hsp-md px-hsp-sm px-hsp-xs py-vsp-2xs py-vsp-3xs py-vsp-xs radius rail ramp ramps range raw re-executed re-run read-only readonly ready real recover rect reference references regenerated region registration relative rem rem-aware rem-based renamed/removed render rendered renders replace require required requires resolve resolved return returns rhythm robots root-absolute round rounded rounded-full rounded-md rounded-sm route router routes routes-src row rows run runtime s same saved scaffold scaffolds screen scrim script search secondary section segment segments select semantic separator set settings sg-catalog-tile-size sg-chip sg-chip-row sg-code-panel sg-code-panel-hidden sg-code-panel-resizer sg-code-panel-width sg-copy-btn sg-filter sg-filter-row sg-gallery-section sg-grid sg-injected- sg-preview-design-token-panel-modal sg-preview-design-tokens sg-preview-design-tokens/v1 sg-preview-tokens-trigger sg-preview-tweak sg-registry sg-search-clear sg-search-field sg-search-input sg-seg sg-seg-btn sg-thumb sg-thumb-inner sg-thumb-note sg-tile sg-tile-count sg-tile-desc sg-tile-meta sg-tile-title sg-workbench-toolbar sg:height sg:ready sgt- shadow shape shared show shown shrink-0 sidebar sidebar- single-axis site size skipped skips slider slug so solid sorts source spacing span spec specimen stacked starting state state-danger state-danger-dark state-info state-info-dark state-success state-success-dark state-warning state-warning-dark static stay step still story string strings stroke-linecap stroke-linejoin stroke-width style stylesheet super supplies supply support supported surface surfaces svg swaps swatch switch tab tablet tablist tabs tabular-nums text text-2xl text-[color:var(--sg-accent)] text-[color:var(--sg-fg)] text-[color:var(--sg-muted)] text-[color:var(--sg-on-accent)] text-caption text-fg text-heading text-muted text-right text-sm text-small text-xl text-xs text/icons textarea that the their them theme then these this three-tier throw tier tier-model tile time tip title to toggle toggle-design-token-panel toggle-preview-token-panel token tokens total tracking-wide transition-colors true try tsx tweaks twice two type typechecks typeof ui- ui-color ui-defaults-dark ui-defaults-light ui-defaults-shared undefined under underline underline-offset-2 unique unit unitless units unknown unsupported unwired up uppercase us use used uses utf-8 utf8 valid value values var variant variants vertical via viewport views virtual:zudo-doc-chrome-bindings virtual:zudo-doc-route-context virtual:zudo-sg-context virtual:zudo-sg-preview-token-panel virtual:zudo-sg-registry virtual:zudo-sg-tokens visible visit void vs vsp w-[2.5rem] w-[5rem] warning was weight were what when which while whole whose will window with without would written yield you your zd-content zdtp-preview-prehydrate zfb zfb:after-swap zudo-doc zudo-doc-sidebar-width zudo-sg zudo-sg-token-tweak-bridge");
|
package/dist/sg-routes.d.ts
CHANGED
|
@@ -10,3 +10,9 @@ export declare const DEFAULT_SG_ROUTES: Readonly<SgRoutes>;
|
|
|
10
10
|
export declare function resolveSgRoutes(routes?: Partial<SgRoutes>): SgRoutes;
|
|
11
11
|
/** Substitutes `[slug]` in `routes.componentsSlug` (`"/components/[slug]"` + `"button"` → `"/components/button"`). */
|
|
12
12
|
export declare function componentHref(routes: Pick<SgRoutes, "componentsSlug">, slug: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The story slug occupied by the preview endpoint, if that endpoint falls
|
|
15
|
+
* inside the detail route pattern. Paths with and without a trailing slash
|
|
16
|
+
* name the same static page. An outside-namespace preview reserves nothing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function previewCollisionSlug(routes?: Partial<SgRoutes>): string | null;
|
package/dist/sg-routes.js
CHANGED
|
@@ -10,8 +10,24 @@ function resolveSgRoutes(routes = {}) {
|
|
|
10
10
|
function componentHref(routes, slug) {
|
|
11
11
|
return routes.componentsSlug.replace("[slug]", slug);
|
|
12
12
|
}
|
|
13
|
+
function previewCollisionSlug(routes = {}) {
|
|
14
|
+
const resolved = resolveSgRoutes(routes);
|
|
15
|
+
const pattern = resolved.componentsSlug.replace(/\/+$/, "");
|
|
16
|
+
const preview = resolved.componentsPreview.replace(/\/+$/, "");
|
|
17
|
+
const marker = "[slug]";
|
|
18
|
+
const index = pattern.indexOf(marker);
|
|
19
|
+
if (index < 0 || pattern.indexOf(marker, index + marker.length) >= 0) {
|
|
20
|
+
throw new Error(`[zudo-sg] routes.componentsSlug must contain exactly one "${marker}" placeholder`);
|
|
21
|
+
}
|
|
22
|
+
const prefix = pattern.slice(0, index);
|
|
23
|
+
const suffix = pattern.slice(index + marker.length);
|
|
24
|
+
if (!preview.startsWith(prefix) || !preview.endsWith(suffix)) return null;
|
|
25
|
+
const slug = preview.slice(prefix.length, suffix ? -suffix.length : void 0);
|
|
26
|
+
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug) ? slug : null;
|
|
27
|
+
}
|
|
13
28
|
export {
|
|
14
29
|
DEFAULT_SG_ROUTES,
|
|
15
30
|
componentHref,
|
|
31
|
+
previewCollisionSlug,
|
|
16
32
|
resolveSgRoutes
|
|
17
33
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bootstrapDesignTokenPanel } from "@takazudo/zudo-doc/design-token-panel-bootstrap";
|
|
2
2
|
import { PREVIEW_TOKEN_PANEL_TOGGLE_EVENT } from "./preview-token-panel-config.js";
|
|
3
|
+
import { drainPreviewTokenPanelCapture } from "./preview-token-panel-capture.js";
|
|
3
4
|
import { drainPrehydrationToggle, installOwnerConsoleHelpers } from "./token-panel-native-bootstrap.js";
|
|
4
5
|
const PREVIEW_TOKEN_PANEL_PREHYDRATE_SCRIPT_ID = "zdtp-preview-prehydrate";
|
|
5
6
|
let bootstrapped = false;
|
|
@@ -10,7 +11,11 @@ function bootstrapPreviewTokenPanel(getConfig) {
|
|
|
10
11
|
bootstrapDesignTokenPanel(getConfig);
|
|
11
12
|
installOwnerConsoleHelpers(getConfig);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
const capture = drainPreviewTokenPanelCapture();
|
|
15
|
+
drainPrehydrationToggle(PREVIEW_TOKEN_PANEL_PREHYDRATE_SCRIPT_ID, PREVIEW_TOKEN_PANEL_TOGGLE_EVENT, !capture.installed);
|
|
16
|
+
if (capture.pending % 2 === 1) {
|
|
17
|
+
window.dispatchEvent(new CustomEvent(PREVIEW_TOKEN_PANEL_TOGGLE_EVENT));
|
|
18
|
+
}
|
|
14
19
|
}
|
|
15
20
|
export {
|
|
16
21
|
PREVIEW_TOKEN_PANEL_PREHYDRATE_SCRIPT_ID,
|
|
@@ -4,3 +4,4 @@ export { applyPreviewVars, clearPreviewVars, registerPreviewIframe, unregisterPr
|
|
|
4
4
|
export { PREVIEW_TOKEN_PANEL_TOGGLE_EVENT, createPreviewTokenPanelConfig, } from "./preview-token-panel-config.js";
|
|
5
5
|
export type { PreviewTokenPanelConfigOptions, PreviewTokenPanelManifest, } from "./preview-token-panel-config.js";
|
|
6
6
|
export { drainPrehydrationToggle, installOwnerConsoleHelpers, loadZdtp } from "./token-panel-native-bootstrap.js";
|
|
7
|
+
export { PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT, previewTokenPanelCaptureScript } from "./preview-token-panel-capture.js";
|
|
@@ -17,8 +17,10 @@ import {
|
|
|
17
17
|
createPreviewTokenPanelConfig
|
|
18
18
|
} from "./preview-token-panel-config.js";
|
|
19
19
|
import { drainPrehydrationToggle, installOwnerConsoleHelpers, loadZdtp } from "./token-panel-native-bootstrap.js";
|
|
20
|
+
import { PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT, previewTokenPanelCaptureScript } from "./preview-token-panel-capture.js";
|
|
20
21
|
export {
|
|
21
22
|
BRIDGE_SOURCE,
|
|
23
|
+
PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT,
|
|
22
24
|
PREVIEW_TOKEN_PANEL_TOGGLE_EVENT,
|
|
23
25
|
applyPreviewVars,
|
|
24
26
|
clearPreviewVars,
|
|
@@ -29,6 +31,7 @@ export {
|
|
|
29
31
|
isBridgeMessage,
|
|
30
32
|
loadZdtp,
|
|
31
33
|
onIframeReady,
|
|
34
|
+
previewTokenPanelCaptureScript,
|
|
32
35
|
registerPreviewIframe,
|
|
33
36
|
sendApplyCssVars,
|
|
34
37
|
sendClearCssVars,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline, package-owned capture installed before a delayed panel island.
|
|
3
|
+
* The state belongs to the window because an SPA may replace the script node
|
|
4
|
+
* while retaining its header and event listeners.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT: string;
|
|
7
|
+
/** Embed before the load island when a host supplies its own header trigger. */
|
|
8
|
+
export declare function previewTokenPanelCaptureScript(): string;
|
|
9
|
+
/** Returns whether the package capture was installed; replay runs after native bootstrap. */
|
|
10
|
+
export declare function drainPreviewTokenPanelCapture(): {
|
|
11
|
+
installed: boolean;
|
|
12
|
+
pending: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PREVIEW_TOKEN_PANEL_TOGGLE_EVENT } from "./preview-token-panel-config.js";
|
|
2
|
+
const PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT = `(function(){if(window.__sgPreviewTokenPanelCapture)return;var state={pending:0,ready:false,listener:null};state.listener=function(){if(!state.ready)state.pending++};window.addEventListener(${JSON.stringify(PREVIEW_TOKEN_PANEL_TOGGLE_EVENT)},state.listener);window.__sgPreviewTokenPanelCapture=state;})();`;
|
|
3
|
+
function previewTokenPanelCaptureScript() {
|
|
4
|
+
return PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT;
|
|
5
|
+
}
|
|
6
|
+
function drainPreviewTokenPanelCapture() {
|
|
7
|
+
if (typeof window === "undefined") return { installed: false, pending: 0 };
|
|
8
|
+
const captureWindow = window;
|
|
9
|
+
const state = captureWindow.__sgPreviewTokenPanelCapture;
|
|
10
|
+
if (!state) return { installed: false, pending: 0 };
|
|
11
|
+
state.ready = true;
|
|
12
|
+
window.removeEventListener(PREVIEW_TOKEN_PANEL_TOGGLE_EVENT, state.listener);
|
|
13
|
+
const pending = state.pending;
|
|
14
|
+
state.pending = 0;
|
|
15
|
+
return { installed: true, pending };
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
PREVIEW_TOKEN_PANEL_CAPTURE_SCRIPT,
|
|
19
|
+
drainPreviewTokenPanelCapture,
|
|
20
|
+
previewTokenPanelCaptureScript
|
|
21
|
+
};
|
|
@@ -11,7 +11,7 @@ export declare function loadZdtp(importer?: () => Promise<ZdtpModule>): Promise<
|
|
|
11
11
|
* State lives on the script element, not in a window-global queue, so two
|
|
12
12
|
* panel instances cannot overwrite each other's bootstrap channel.
|
|
13
13
|
*/
|
|
14
|
-
export declare function drainPrehydrationToggle(scriptId: string, toggleEvent: string): void;
|
|
14
|
+
export declare function drainPrehydrationToggle(scriptId: string, toggleEvent: string, replay?: boolean): void;
|
|
15
15
|
/** Preserve the owner-autoload console helpers without eagerly importing zdtp. */
|
|
16
16
|
export declare function installOwnerConsoleHelpers(getConfig: () => PanelConfig, importer?: () => Promise<ZdtpModule>): void;
|
|
17
17
|
export {};
|
|
@@ -9,7 +9,7 @@ async function loadZdtp(importer = () => import("@takazudo/zdtp")) {
|
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function drainPrehydrationToggle(scriptId, toggleEvent) {
|
|
12
|
+
function drainPrehydrationToggle(scriptId, toggleEvent, replay = true) {
|
|
13
13
|
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
14
14
|
const script = document.getElementById(scriptId);
|
|
15
15
|
const listener = script?.__zdtpPrehydrateListener;
|
|
@@ -19,7 +19,7 @@ function drainPrehydrationToggle(scriptId, toggleEvent) {
|
|
|
19
19
|
delete script.__zdtpPrehydrateListener;
|
|
20
20
|
const pending = Number(script.dataset.pending ?? "0");
|
|
21
21
|
delete script.dataset.pending;
|
|
22
|
-
if (Number.isFinite(pending) && pending % 2 === 1) {
|
|
22
|
+
if (replay && Number.isFinite(pending) && pending % 2 === 1) {
|
|
23
23
|
window.dispatchEvent(new CustomEvent(toggleEvent));
|
|
24
24
|
}
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takazudo/zudo-sg",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "zudo-sg styleguide engine — story registry, catalog routes and preview machinery for zfb + zudo-doc hosts.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -138,14 +138,14 @@
|
|
|
138
138
|
"@tailwindcss/oxide": "^4.3.3"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@takazudo/zfb": "^2.20.
|
|
141
|
+
"@takazudo/zfb": "^2.20.3",
|
|
142
142
|
"@takazudo/zdtp": "^0.8.2",
|
|
143
143
|
"@takazudo/zudo-doc": "^5.27.0",
|
|
144
144
|
"preact": "^10.29.8"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
147
|
"@takazudo/zdtp": "0.8.2",
|
|
148
|
-
"@takazudo/zfb": "2.20.
|
|
148
|
+
"@takazudo/zfb": "2.20.3",
|
|
149
149
|
"@takazudo/zudo-doc": "5.27.0",
|
|
150
150
|
"@testing-library/jest-dom": "^6.9.1",
|
|
151
151
|
"@testing-library/preact": "^3.2.4",
|