@moonwitness/ui 7.1.1 → 7.1.4

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
@@ -15,7 +15,7 @@ export function App() {
15
15
  return (
16
16
  <ThemeProvider
17
17
  defaultMode="dark"
18
- defaultSkin="signal-riot"
18
+ defaultSkin="moonwitness-riot"
19
19
  defaultDensity="comfortable"
20
20
  >
21
21
  <Card variant="elevated">
@@ -141,8 +141,8 @@ Use real product copy and data on production pages. Dashboard percentage trends
141
141
 
142
142
  ## Checks
143
143
 
144
- - `npm run lint` verifies `'use client'` directives, zero Tailwind leakage in `packages/ui/src/components`, URL sanitization on dynamic links, token hygiene, and `package.json` export parity.
145
- - `npm run typecheck`, `npm run test`, and `npm run test:e2e` validate TypeScript types, package unit/accessibility contracts, and Playwright browser integration tests.
144
+ - `bun run lint` verifies `'use client'` directives, zero Tailwind leakage in `packages/ui/src/components`, URL sanitization on dynamic links, token hygiene, and `package.json` export parity.
145
+ - `bun run typecheck`, `bun run test`, and `bun run test:e2e` validate TypeScript types, package unit/accessibility contracts, and Playwright browser integration tests.
146
146
  - Visual acceptance uses reviewed screenshots and responsive specimens in `apps/ui-catalog`.
147
147
 
148
148
  See [`TOKENS.md`](./TOKENS.md) for semantic token values, theme behavior, typography, and contrast targets, and [`CHANGELOG.md`](./CHANGELOG.md) for release notes.
@@ -16,7 +16,7 @@ export type RiotStickerProps = Omit<ComponentPropsWithoutRef<"img">, "src" | "al
16
16
  /** Resolve a stickers-pack PNG for a slug (die-cut paper halo included in the asset). */
17
17
  export declare function getRiotStickerSrc(slug: RiotStickerSlug, basePath?: string): string;
18
18
  /** Street-comic die-cut sticker from the stickers-pack; tilt is decorative and never animates. */
19
- export declare const RiotSticker: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref">, "width" | "height" | "alt" | "src"> & {
19
+ export declare const RiotSticker: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref">, "src" | "width" | "height" | "alt"> & {
20
20
  slug: RiotStickerSlug;
21
21
  size?: RiotStickerSize;
22
22
  tilt?: RiotStickerTilt;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * CSS export utilities for @moonwitness/ui.
3
+ *
4
+ * Provides CSS-first token artifacts generated at build time.
5
+ * These exports are pure CSS/JSON — no React runtime required.
6
+ * Consumers can import via:
7
+ * - @moonwitness/ui/styles.css (legacy, includes all tokens)
8
+ * - @moonwitness/ui/styles/tokens.css (source tokens.css)
9
+ * - @moonwitness/ui/tokens.generated.css (generated core + skin CSS)
10
+ * - @moonwitness/ui/tailwind-preset.css (Tailwind v4 @theme)
11
+ * - @moonwitness/ui/skin-tokens.js (skin token JS module)
12
+ */
13
+ /**
14
+ * Core design tokens as CSS custom properties (:root + .dark).
15
+ * Generated at build time from the token exporter.
16
+ */
17
+ export declare const coreTokensCss: string;
18
+ /**
19
+ * All skin overrides as [data-skin] and [data-skin].dark CSS blocks.
20
+ * Generated at build time from the token exporter.
21
+ */
22
+ export declare const skinOverridesCss: string;
23
+ /**
24
+ * Complete token CSS bundle (core + skins).
25
+ * This is the same as tokens.generated.css which includes both.
26
+ */
27
+ export declare const completeTokensCss: string;
28
+ /**
29
+ * Tailwind v4 @theme preset using CSS variable references.
30
+ * Generated at build time.
31
+ */
32
+ export declare const tailwindPresetCss: string;
33
+ /**
34
+ * Read W3C Design Tokens JSON bundle.
35
+ */
36
+ export declare function readW3cTokens(): object;
37
+ /**
38
+ * Read full design token bundle JSON.
39
+ */
40
+ export declare function readTokenBundle(): object;
41
+ /**
42
+ * All documented CSS export entry points for consumers.
43
+ * These paths are available in package.json exports.
44
+ */
45
+ export declare const CSS_EXPORT_PATHS: {
46
+ /** Full design tokens including all skins — primary CSS entry */
47
+ readonly tokens: "./tokens.generated.css";
48
+ /** Tailwind v4 @theme preset */
49
+ readonly tailwind: "./tailwind-preset.css";
50
+ /** Skin token overrides (included in tokens.generated.css) */
51
+ readonly skins: "./tokens.generated.css";
52
+ /** Source tokens.css (framework-agnostic, no skin overrides) */
53
+ readonly source: "./src/styles/tokens.css";
54
+ /** W3C Design Tokens JSON */
55
+ readonly w3c: "./dist/tokens.w3c.json";
56
+ /** Full design token bundle JSON */
57
+ readonly bundle: "./dist/tokens.bundle.json";
58
+ /** Skin tokens JS module (for runtime skin switching) */
59
+ readonly skinTokens: "./skin-tokens.js";
60
+ };
61
+ /**
62
+ * Type for the CSS export paths.
63
+ */
64
+ export type CssExportPaths = typeof CSS_EXPORT_PATHS;
65
+ /**
66
+ * Verify that all CSS artifacts exist and are readable.
67
+ * Useful for CI/build verification.
68
+ */
69
+ export declare function verifyCssArtifacts(): {
70
+ ok: boolean;
71
+ missing: string[];
72
+ };
73
+ /**
74
+ * Get the import path for a CSS artifact.
75
+ * Use this to document consumer import paths.
76
+ */
77
+ export declare function getImportPath(artifact: keyof CssExportPaths): string;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * CSS export utilities for @moonwitness/ui.
3
+ *
4
+ * Provides CSS-first token artifacts generated at build time.
5
+ * These exports are pure CSS/JSON — no React runtime required.
6
+ * Consumers can import via:
7
+ * - @moonwitness/ui/styles.css (legacy, includes all tokens)
8
+ * - @moonwitness/ui/styles/tokens.css (source tokens.css)
9
+ * - @moonwitness/ui/tokens.generated.css (generated core + skin CSS)
10
+ * - @moonwitness/ui/tailwind-preset.css (Tailwind v4 @theme)
11
+ * - @moonwitness/ui/skin-tokens.js (skin token JS module)
12
+ */
13
+ import { readFileSync } from "node:fs";
14
+ import { join, resolve } from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ const uiRoot = resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
17
+ const distDir = join(uiRoot, "dist");
18
+ const srcStylesDir = join(uiRoot, "src", "styles");
19
+ /**
20
+ * Read a generated CSS artifact from dist/ or fall back to source.
21
+ */
22
+ function readCssArtifact(filename, fallbackPath) {
23
+ const distPath = join(distDir, filename);
24
+ try {
25
+ return readFileSync(distPath, "utf8");
26
+ }
27
+ catch {
28
+ if (fallbackPath) {
29
+ return readFileSync(fallbackPath, "utf8");
30
+ }
31
+ throw new Error(`CSS artifact not found: ${filename}. Run build first.`);
32
+ }
33
+ }
34
+ /**
35
+ * Core design tokens as CSS custom properties (:root + .dark).
36
+ * Generated at build time from the token exporter.
37
+ */
38
+ export const coreTokensCss = readCssArtifact("tokens.generated.css", join(srcStylesDir, "tokens.css"));
39
+ /**
40
+ * All skin overrides as [data-skin] and [data-skin].dark CSS blocks.
41
+ * Generated at build time from the token exporter.
42
+ */
43
+ export const skinOverridesCss = readCssArtifact("tokens.generated.css");
44
+ /**
45
+ * Complete token CSS bundle (core + skins).
46
+ * This is the same as tokens.generated.css which includes both.
47
+ */
48
+ export const completeTokensCss = readCssArtifact("tokens.generated.css", join(srcStylesDir, "tokens.css"));
49
+ /**
50
+ * Tailwind v4 @theme preset using CSS variable references.
51
+ * Generated at build time.
52
+ */
53
+ export const tailwindPresetCss = readCssArtifact("tailwind-preset.css", join(srcStylesDir, "tokens.css"));
54
+ /**
55
+ * Read W3C Design Tokens JSON bundle.
56
+ */
57
+ export function readW3cTokens() {
58
+ const path = join(distDir, "tokens.w3c.json");
59
+ return JSON.parse(readFileSync(path, "utf8"));
60
+ }
61
+ /**
62
+ * Read full design token bundle JSON.
63
+ */
64
+ export function readTokenBundle() {
65
+ const path = join(distDir, "tokens.bundle.json");
66
+ return JSON.parse(readFileSync(path, "utf8"));
67
+ }
68
+ /**
69
+ * All documented CSS export entry points for consumers.
70
+ * These paths are available in package.json exports.
71
+ */
72
+ export const CSS_EXPORT_PATHS = {
73
+ /** Full design tokens including all skins — primary CSS entry */
74
+ tokens: "./tokens.generated.css",
75
+ /** Tailwind v4 @theme preset */
76
+ tailwind: "./tailwind-preset.css",
77
+ /** Skin token overrides (included in tokens.generated.css) */
78
+ skins: "./tokens.generated.css",
79
+ /** Source tokens.css (framework-agnostic, no skin overrides) */
80
+ source: "./src/styles/tokens.css",
81
+ /** W3C Design Tokens JSON */
82
+ w3c: "./dist/tokens.w3c.json",
83
+ /** Full design token bundle JSON */
84
+ bundle: "./dist/tokens.bundle.json",
85
+ /** Skin tokens JS module (for runtime skin switching) */
86
+ skinTokens: "./skin-tokens.js",
87
+ };
88
+ /**
89
+ * Verify that all CSS artifacts exist and are readable.
90
+ * Useful for CI/build verification.
91
+ */
92
+ export function verifyCssArtifacts() {
93
+ const required = [
94
+ "tokens.generated.css",
95
+ "tailwind-preset.css",
96
+ "tokens.w3c.json",
97
+ "tokens.bundle.json",
98
+ ];
99
+ const missing = [];
100
+ for (const file of required) {
101
+ try {
102
+ readFileSync(join(distDir, file), "utf8");
103
+ }
104
+ catch {
105
+ missing.push(file);
106
+ }
107
+ }
108
+ return { ok: missing.length === 0, missing };
109
+ }
110
+ /**
111
+ * Get the import path for a CSS artifact.
112
+ * Use this to document consumer import paths.
113
+ */
114
+ export function getImportPath(artifact) {
115
+ return CSS_EXPORT_PATHS[artifact];
116
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * pixelfx-boundary.ts
3
+ *
4
+ * Safe boundary for optional pixelfx dependency.
5
+ * All pixelfx imports go through this module so consumers without pixelfx
6
+ * installed don't crash at import time.
7
+ */
8
+ export interface PixelFxFrame {
9
+ w: number;
10
+ h: number;
11
+ ox: number;
12
+ oy: number;
13
+ color: Uint32Array;
14
+ light: Uint32Array;
15
+ }
16
+ export interface PixelFxMeta {
17
+ name?: string;
18
+ desc?: string;
19
+ tags?: string[];
20
+ size?: [number, number];
21
+ origin?: [number, number];
22
+ duration?: number;
23
+ loop?: boolean;
24
+ fps?: number;
25
+ bg?: string;
26
+ actor?: number | boolean;
27
+ options?: Record<string, unknown>;
28
+ }
29
+ export interface PixelFxModule {
30
+ meta?: PixelFxMeta;
31
+ create?: (options: Record<string, unknown>) => {
32
+ update?: (dt: number, options: Record<string, unknown>) => void;
33
+ draw: (painter: unknown, t: number, options: Record<string, unknown>) => void;
34
+ drawBack?: (painter: unknown, t: number, options: Record<string, unknown>) => void;
35
+ };
36
+ draw?: (painter: unknown, t: number, options: Record<string, unknown>) => void;
37
+ drawBack?: (painter: unknown, t: number, options: Record<string, unknown>) => void;
38
+ }
39
+ export interface PixelFxInstance {
40
+ meta: PixelFxMeta;
41
+ options: Record<string, unknown>;
42
+ readonly t: number;
43
+ update: (dt: number) => void;
44
+ draw: (frame: PixelFxFrame, layer?: "front" | "back") => void;
45
+ stop: () => void;
46
+ done: () => boolean;
47
+ }
48
+ /**
49
+ * Attempts to load the pixelfx runtime. Returns true if successful,
50
+ * false if pixelfx is not available. Safe to call multiple times.
51
+ */
52
+ export declare function ensurePixelfxLoaded(): Promise<boolean>;
53
+ /**
54
+ * Creates a frame - returns a minimal valid frame if pixelfx unavailable.
55
+ * Callers should check `ensurePixelfxLoaded()` first for real effects.
56
+ */
57
+ export declare function createFrame(w: number, h: number, ox?: number, oy?: number): PixelFxFrame;
58
+ /**
59
+ * Clears a frame - no-op if pixelfx unavailable.
60
+ */
61
+ export declare function clearFrame(frame: PixelFxFrame): PixelFxFrame;
62
+ /**
63
+ * Creates an effect instance - returns null if pixelfx unavailable.
64
+ * Callers must handle null return.
65
+ */
66
+ export declare function createFx(mod: PixelFxModule, options?: Record<string, unknown>): PixelFxInstance | null;
67
+ /**
68
+ * Composites a frame to image data - no-op if pixelfx unavailable.
69
+ */
70
+ export declare function composite(frame: PixelFxFrame, out: Uint8ClampedArray, bg?: number | Uint32Array | null, lightK?: number): Uint8ClampedArray;
71
+ /**
72
+ * Checks if pixelfx is available at runtime.
73
+ */
74
+ export declare function isPixelfxAvailable(): boolean;
75
+ /**
76
+ * Loads a specific pixelfx effect module dynamically.
77
+ * Returns null if pixelfx is unavailable or the effect doesn't exist.
78
+ */
79
+ export declare function loadEffectModule(effectId: string): Promise<PixelFxModule | null>;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * pixelfx-boundary.ts
3
+ *
4
+ * Safe boundary for optional pixelfx dependency.
5
+ * All pixelfx imports go through this module so consumers without pixelfx
6
+ * installed don't crash at import time.
7
+ */
8
+ // Runtime functions - loaded dynamically only when pixelfx is available
9
+ let _pixelfxModule = null;
10
+ let _loadPromise = null;
11
+ let _loadFailed = false;
12
+ /**
13
+ * Attempts to load the pixelfx runtime. Returns true if successful,
14
+ * false if pixelfx is not available. Safe to call multiple times.
15
+ */
16
+ export async function ensurePixelfxLoaded() {
17
+ if (_pixelfxModule)
18
+ return true;
19
+ if (_loadFailed)
20
+ return false;
21
+ if (_loadPromise) {
22
+ await _loadPromise;
23
+ return !!_pixelfxModule;
24
+ }
25
+ _loadPromise = (async () => {
26
+ try {
27
+ // Dynamic import - won't crash if pixelfx isn't installed
28
+ const mod = await import("pixelfx");
29
+ _pixelfxModule = {
30
+ createFrame: mod.createFrame,
31
+ clearFrame: mod.clearFrame,
32
+ createFx: mod.createFx,
33
+ composite: mod.composite,
34
+ };
35
+ }
36
+ catch {
37
+ _loadFailed = true;
38
+ _pixelfxModule = null;
39
+ }
40
+ })();
41
+ await _loadPromise;
42
+ return !!_pixelfxModule;
43
+ }
44
+ /**
45
+ * Creates a frame - returns a minimal valid frame if pixelfx unavailable.
46
+ * Callers should check `ensurePixelfxLoaded()` first for real effects.
47
+ */
48
+ export function createFrame(w, h, ox, oy) {
49
+ if (_pixelfxModule) {
50
+ return _pixelfxModule.createFrame(w, h, ox, oy);
51
+ }
52
+ // Fallback minimal frame structure
53
+ return {
54
+ w,
55
+ h,
56
+ ox: ox ?? Math.floor(w / 2),
57
+ oy: oy ?? Math.floor(h / 2),
58
+ color: new Uint32Array(w * h),
59
+ light: new Uint32Array(w * h),
60
+ };
61
+ }
62
+ /**
63
+ * Clears a frame - no-op if pixelfx unavailable.
64
+ */
65
+ export function clearFrame(frame) {
66
+ if (_pixelfxModule) {
67
+ return _pixelfxModule.clearFrame(frame);
68
+ }
69
+ // Zero out the arrays
70
+ frame.color.fill(0);
71
+ frame.light.fill(0);
72
+ return frame;
73
+ }
74
+ /**
75
+ * Creates an effect instance - returns null if pixelfx unavailable.
76
+ * Callers must handle null return.
77
+ */
78
+ export function createFx(mod, options) {
79
+ if (!_pixelfxModule)
80
+ return null;
81
+ return _pixelfxModule.createFx(mod, options);
82
+ }
83
+ /**
84
+ * Composites a frame to image data - no-op if pixelfx unavailable.
85
+ */
86
+ export function composite(frame, out, bg, lightK) {
87
+ if (_pixelfxModule) {
88
+ return _pixelfxModule.composite(frame, out, bg, lightK);
89
+ }
90
+ return out;
91
+ }
92
+ /**
93
+ * Checks if pixelfx is available at runtime.
94
+ */
95
+ export function isPixelfxAvailable() {
96
+ return !!_pixelfxModule;
97
+ }
98
+ /**
99
+ * Loads a specific pixelfx effect module dynamically.
100
+ * Returns null if pixelfx is unavailable or the effect doesn't exist.
101
+ */
102
+ export async function loadEffectModule(effectId) {
103
+ const loaded = await ensurePixelfxLoaded();
104
+ if (!loaded)
105
+ return null;
106
+ try {
107
+ // Dynamic import of the specific effect
108
+ const mod = await import(`pixelfx/fx/${effectId}`);
109
+ return mod.default;
110
+ }
111
+ catch {
112
+ return null;
113
+ }
114
+ }
package/dist/pixelfx.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type CSSProperties, type ElementType, type HTMLAttributes, type MouseEvent, type ReactNode } from "react";
2
- import { type PixelFxModule } from "pixelfx";
2
+ import { type PixelFxModule } from "./pixelfx-boundary.js";
3
3
  import { type ComponentFxKind, type EmpirePaletteId, type PixelFxEffectId, type PixelFxProp, type PixelFxTransitionEffectId, type ResolvedComponentFx } from "./pixelfx-registry.js";
4
- export declare function loadPixelFxModule(id: PixelFxEffectId): Promise<PixelFxModule>;
4
+ export declare function loadPixelFxModule(id: PixelFxEffectId): Promise<PixelFxModule | null>;
5
5
  /**
6
6
  * Idle-preloads the core above-the-fold and primary interaction PixelFX modules
7
7
  * so first clicks fire with 0ms dynamic import delay.
package/dist/pixelfx.js CHANGED
@@ -1,46 +1,57 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
- import { clearFrame, composite, createFrame, createFx, } from "pixelfx";
3
+ import { clearFrame, composite, createFrame, createFx, loadEffectModule, ensurePixelfxLoaded, } from "./pixelfx-boundary.js";
4
4
  import { resolveComponentFxProp, resolveEmpirePalette, } from "./pixelfx-registry.js";
5
5
  import { cn } from "./utils.js";
6
6
  const EFFECT_LOADERS = {
7
- "shadow/eclipse": () => import("pixelfx/fx/shadow/eclipse"),
8
- "lightning/tesla-coil": () => import("pixelfx/fx/lightning/tesla-coil"),
9
- "holy/blessing": () => import("pixelfx/fx/holy/blessing"),
10
- "nature/healing-bloom": () => import("pixelfx/fx/nature/healing-bloom"),
11
- "explosions/cartoon-pow": () => import("pixelfx/fx/explosions/cartoon-pow"),
12
- "ui/confetti": () => import("pixelfx/fx/ui/confetti"),
13
- "arcane/magic-circle-cast": () => import("pixelfx/fx/arcane/magic-circle-cast"),
14
- "shadow/hex-sigil": () => import("pixelfx/fx/shadow/hex-sigil"),
15
- "holy/feather-burst": () => import("pixelfx/fx/holy/feather-burst"),
16
- "weather/shooting-stars": () => import("pixelfx/fx/weather/shooting-stars"),
17
- "weather/cherry-blossoms": () => import("pixelfx/fx/weather/cherry-blossoms"),
18
- "weather/aurora": () => import("pixelfx/fx/weather/aurora"),
19
- "weather/god-rays": () => import("pixelfx/fx/weather/god-rays"),
20
- "weather/rain": () => import("pixelfx/fx/weather/rain"),
21
- "weather/fireflies": () => import("pixelfx/fx/weather/fireflies"),
22
- "holy/halo": () => import("pixelfx/fx/holy/halo"),
23
- "holy/sunburst": () => import("pixelfx/fx/holy/sunburst"),
24
- "lightning/spark-arc": () => import("pixelfx/fx/lightning/spark-arc"),
25
- "lightning/zap-hit": () => import("pixelfx/fx/lightning/zap-hit"),
26
- "scifi/hologram": () => import("pixelfx/fx/scifi/hologram"),
27
- "scifi/glitch": () => import("pixelfx/fx/scifi/glitch"),
28
- "melee/double-slash": () => import("pixelfx/fx/melee/double-slash"),
29
- "impacts/impact-frame": () => import("pixelfx/fx/impacts/impact-frame"),
30
- "ui/level-up": () => import("pixelfx/fx/ui/level-up"),
31
- "transitions/glitch-wipe": () => import("pixelfx/fx/transitions/glitch-wipe"),
32
- "transitions/slash-wipe": () => import("pixelfx/fx/transitions/slash-wipe"),
33
- "transitions/burn-away": () => import("pixelfx/fx/transitions/burn-away"),
34
- "transitions/diamond-wipe": () => import("pixelfx/fx/transitions/diamond-wipe"),
7
+ "shadow/eclipse": () => loadEffectModule("shadow/eclipse"),
8
+ "lightning/tesla-coil": () => loadEffectModule("lightning/tesla-coil"),
9
+ "holy/blessing": () => loadEffectModule("holy/blessing"),
10
+ "nature/healing-bloom": () => loadEffectModule("nature/healing-bloom"),
11
+ "explosions/cartoon-pow": () => loadEffectModule("explosions/cartoon-pow"),
12
+ "ui/confetti": () => loadEffectModule("ui/confetti"),
13
+ "arcane/magic-circle-cast": () => loadEffectModule("arcane/magic-circle-cast"),
14
+ "shadow/hex-sigil": () => loadEffectModule("shadow/hex-sigil"),
15
+ "holy/feather-burst": () => loadEffectModule("holy/feather-burst"),
16
+ "weather/shooting-stars": () => loadEffectModule("weather/shooting-stars"),
17
+ "weather/cherry-blossoms": () => loadEffectModule("weather/cherry-blossoms"),
18
+ "weather/aurora": () => loadEffectModule("weather/aurora"),
19
+ "weather/god-rays": () => loadEffectModule("weather/god-rays"),
20
+ "weather/rain": () => loadEffectModule("weather/rain"),
21
+ "weather/fireflies": () => loadEffectModule("weather/fireflies"),
22
+ "holy/halo": () => loadEffectModule("holy/halo"),
23
+ "holy/sunburst": () => loadEffectModule("holy/sunburst"),
24
+ "lightning/spark-arc": () => loadEffectModule("lightning/spark-arc"),
25
+ "lightning/zap-hit": () => loadEffectModule("lightning/zap-hit"),
26
+ "scifi/hologram": () => loadEffectModule("scifi/hologram"),
27
+ "scifi/glitch": () => loadEffectModule("scifi/glitch"),
28
+ "melee/double-slash": () => loadEffectModule("melee/double-slash"),
29
+ "impacts/impact-frame": () => loadEffectModule("impacts/impact-frame"),
30
+ "ui/level-up": () => loadEffectModule("ui/level-up"),
31
+ "transitions/glitch-wipe": () => loadEffectModule("transitions/glitch-wipe"),
32
+ "transitions/slash-wipe": () => loadEffectModule("transitions/slash-wipe"),
33
+ "transitions/burn-away": () => loadEffectModule("transitions/burn-away"),
34
+ "transitions/diamond-wipe": () => loadEffectModule("transitions/diamond-wipe"),
35
35
  };
36
36
  const moduleCache = new Map();
37
37
  export async function loadPixelFxModule(id) {
38
38
  const cached = moduleCache.get(id);
39
39
  if (cached)
40
40
  return cached;
41
- const mod = await EFFECT_LOADERS[id]();
42
- moduleCache.set(id, mod);
43
- return mod;
41
+ const loaded = await ensurePixelfxLoaded();
42
+ if (!loaded)
43
+ return null;
44
+ try {
45
+ const mod = await EFFECT_LOADERS[id]();
46
+ if (mod) {
47
+ moduleCache.set(id, mod);
48
+ return mod;
49
+ }
50
+ }
51
+ catch {
52
+ // Effect not available
53
+ }
54
+ return null;
44
55
  }
45
56
  const CORE_PRELOAD_EFFECTS = [
46
57
  "weather/shooting-stars",
@@ -167,7 +178,7 @@ function resolveRuntimePaletteStops(paletteId) {
167
178
  return staticStops;
168
179
  }
169
180
  const skin = document.documentElement.dataset.skin;
170
- if (!skin || skin === "empire-of-light" || skin === "moonwitness-ink") {
181
+ if (!skin || skin === "moonwitness-ink") {
171
182
  return staticStops;
172
183
  }
173
184
  // Dynamically adapt accent peak stop to the active skin's live CSS variable
@@ -288,6 +299,10 @@ export function PixelFxCanvas({ effectId, paletteId, layer = "all", loop = true,
288
299
  });
289
300
  loadPixelFxModule(effectId)
290
301
  .then((mod) => {
302
+ if (!mod) {
303
+ // pixelfx not available - silently skip effect rendering
304
+ return;
305
+ }
291
306
  if (cancelled)
292
307
  return;
293
308
  const meta = mod.meta ?? {};
@@ -322,7 +337,13 @@ export function PixelFxCanvas({ effectId, paletteId, layer = "all", loop = true,
322
337
  ? { split: "#ff148a", color: "#05060b" }
323
338
  : {}),
324
339
  });
325
- fx = buildInstance();
340
+ const fxInstance = buildInstance();
341
+ if (!fxInstance) {
342
+ // pixelfx not available - silently skip effect rendering
343
+ return;
344
+ }
345
+ fx = fxInstance;
346
+ // TypeScript narrowing: fx is now definitely PixelFxInstance
326
347
  if (effectiveReducedMotion) {
327
348
  const mid = Math.min(0.45, (meta.duration ?? 1) * 0.35);
328
349
  fx.update(mid);
@@ -346,7 +367,10 @@ export function PixelFxCanvas({ effectId, paletteId, layer = "all", loop = true,
346
367
  fx.update(rawDt * speed * fpsDivisor);
347
368
  if (fx.done()) {
348
369
  if (loop) {
349
- fx = buildInstance();
370
+ const nextFx = buildInstance();
371
+ if (!nextFx)
372
+ return;
373
+ fx = nextFx;
350
374
  fx.update(1 / 60);
351
375
  }
352
376
  else {
@@ -5,7 +5,7 @@ import { type SkinDensity, type SkinId, type ThemeMode } from "./themes.js";
5
5
  export interface MoonWitnessProviderProps {
6
6
  /** Color mode. Defaults to `"dark"` (Empire of Light obsidian ink). */
7
7
  mode?: ThemeMode;
8
- /** Design skin. Defaults to `"empire-of-light"`. */
8
+ /** Design skin. Defaults to `"moonwitness-ink"`. */
9
9
  skin?: SkinId;
10
10
  /** Spacing density. Defaults to `"comfortable"`. */
11
11
  density?: SkinDensity;
package/dist/provider.js CHANGED
@@ -8,7 +8,7 @@ import { ThemeProvider, } from "./themes.js";
8
8
  * Bundles ThemeProvider (Empire of Light dark obsidian default), PixelFxProvider,
9
9
  * SoundProvider, and TooltipProvider in one wrapper so beginners never juggle nested providers.
10
10
  */
11
- export function MoonWitnessProvider({ mode = "dark", skin = "empire-of-light", density = "comfortable", fx = true, fxPalette = "default", fxQuality = "balanced", children, }) {
11
+ export function MoonWitnessProvider({ mode = "dark", skin = "moonwitness-ink", density = "comfortable", fx = true, fxPalette = "default", fxQuality = "balanced", children, }) {
12
12
  return (_jsx(ThemeProvider, { defaultMode: mode, defaultSkin: skin, defaultDensity: density, children: _jsx(PixelFxProvider, { defaultEnabled: fx, defaultPalette: fxPalette, defaultQuality: fxQuality, children: _jsx(SoundProvider, { children: _jsx(TooltipProvider, { children: children }) }) }) }));
13
13
  }
14
14
  /** Ergonomic alias for MoonWitnessProvider. */
@@ -17,4 +17,15 @@ export declare const themeRegistry: ThemeRegistry;
17
17
  export interface SkinInitScriptOptions {
18
18
  storageKey?: string;
19
19
  }
20
+ /**
21
+ * Validates a skin ID against the registry.
22
+ * Throws if the skin ID is not registered.
23
+ * Does NOT silently fall back — callers must handle or let it throw.
24
+ */
25
+ export declare function validateSkinId(skinId: string, registry?: ThemeRegistry): void;
26
+ /**
27
+ * Validates a skin ID and returns the resolved skin metadata.
28
+ * Throws if the skin ID is not registered.
29
+ */
30
+ export declare function resolveValidSkin(skinId?: string | null, registry?: ThemeRegistry): SkinMetadata;
20
31
  export declare function createSkinInitScript(options?: SkinInitScriptOptions): string;
@@ -208,6 +208,33 @@ export function createThemeRegistry(initialSkins = BUILTIN_SKINS, defaultSkinId
208
208
  };
209
209
  }
210
210
  export const themeRegistry = createThemeRegistry(BUILTIN_SKINS, DEFAULT_SKIN_ID);
211
+ /**
212
+ * Validates a skin ID against the registry.
213
+ * Throws if the skin ID is not registered.
214
+ * Does NOT silently fall back — callers must handle or let it throw.
215
+ */
216
+ export function validateSkinId(skinId, registry = themeRegistry) {
217
+ if (!registry.has(skinId)) {
218
+ const available = registry.list().map((s) => s.id).join(", ");
219
+ throw new Error(`Unknown skin ID "${skinId}". Available skins: ${available}`);
220
+ }
221
+ }
222
+ /**
223
+ * Validates a skin ID and returns the resolved skin metadata.
224
+ * Throws if the skin ID is not registered.
225
+ */
226
+ export function resolveValidSkin(skinId, registry = themeRegistry) {
227
+ if (typeof skinId === "string" && registry.has(skinId)) {
228
+ return registry.get(skinId);
229
+ }
230
+ if (skinId !== undefined && skinId !== null) {
231
+ // Explicit but invalid skin ID — throw, don't silently fall back
232
+ const available = registry.list().map((s) => s.id).join(", ");
233
+ throw new Error(`Unknown skin ID "${skinId}". Available skins: ${available}`);
234
+ }
235
+ // No skin specified — use default
236
+ return registry.get(registry.defaultSkinId);
237
+ }
211
238
  export function createSkinInitScript(options = {}) {
212
239
  const skinIds = JSON.stringify(themeRegistry.list().map((skin) => skin.id));
213
240
  const primaryKey = JSON.stringify(options.storageKey ?? "mw-ui-theme");