@almadar/ui 2.0.4 → 2.1.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/dist/ThemeContext-D9xUORq5.d.ts +105 -0
- package/dist/{chunk-QU4JHKVC.js → chunk-BTXQJGFB.js} +24 -24
- package/dist/{chunk-JZ55M7DV.js → chunk-FZJ73RDM.js} +2 -2
- package/dist/cn-BoBXsxuX.d.ts +194 -0
- package/dist/components/index.d.ts +7080 -0
- package/dist/components/index.js +8 -8
- package/dist/components/organisms/game/three/index.d.ts +1227 -0
- package/dist/context/index.d.ts +208 -0
- package/dist/context/index.js +2 -2
- package/dist/event-bus-types-CjJduURa.d.ts +73 -0
- package/dist/hooks/index.d.ts +1091 -0
- package/dist/hooks/index.js +2 -2
- package/dist/isometric-ynNHVPZx.d.ts +111 -0
- package/dist/lib/index.d.ts +427 -0
- package/dist/locales/index.d.ts +22 -0
- package/dist/offline-executor-CHr4uAhf.d.ts +401 -0
- package/dist/providers/index.d.ts +465 -0
- package/dist/providers/index.js +4 -4
- package/dist/renderer/index.d.ts +525 -0
- package/dist/stores/index.d.ts +151 -0
- package/dist/useUISlots-D0mttBSP.d.ts +85 -0
- package/package.json +1 -1
- package/dist/{chunk-BKC4XU44.js → chunk-6WHMUKED.js} +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unified ThemeContext - Single provider for theme and color mode
|
|
5
|
+
*
|
|
6
|
+
* Combines design theme selection (ocean, wireframe, etc.) with
|
|
7
|
+
* color mode (light/dark) into a single, simple system.
|
|
8
|
+
*
|
|
9
|
+
* Uses a single data attribute: data-theme="ocean-light" or data-theme="ocean-dark"
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Color mode preference */
|
|
15
|
+
type ColorMode = "light" | "dark" | "system";
|
|
16
|
+
/** Resolved color mode (what's actually applied) */
|
|
17
|
+
type ResolvedMode = "light" | "dark";
|
|
18
|
+
/** Theme definition */
|
|
19
|
+
interface ThemeDefinition {
|
|
20
|
+
/** Theme identifier (e.g., "ocean", "wireframe") */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Display name for UI (e.g., "Ocean Blue") */
|
|
23
|
+
displayName?: string;
|
|
24
|
+
/** Whether this theme has light mode styles */
|
|
25
|
+
hasLightMode?: boolean;
|
|
26
|
+
/** Whether this theme has dark mode styles */
|
|
27
|
+
hasDarkMode?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Built-in themes available in the design system */
|
|
30
|
+
declare const BUILT_IN_THEMES: ThemeDefinition[];
|
|
31
|
+
/** Theme context value */
|
|
32
|
+
interface ThemeContextValue {
|
|
33
|
+
/** Current theme name */
|
|
34
|
+
theme: string;
|
|
35
|
+
/** Current color mode setting (may be 'system') */
|
|
36
|
+
mode: ColorMode;
|
|
37
|
+
/** Resolved color mode (always 'light' or 'dark') */
|
|
38
|
+
resolvedMode: ResolvedMode;
|
|
39
|
+
/** Set the theme */
|
|
40
|
+
setTheme: (theme: string) => void;
|
|
41
|
+
/** Set the color mode */
|
|
42
|
+
setMode: (mode: ColorMode) => void;
|
|
43
|
+
/** Toggle between light and dark modes */
|
|
44
|
+
toggleMode: () => void;
|
|
45
|
+
/** Available themes */
|
|
46
|
+
availableThemes: ThemeDefinition[];
|
|
47
|
+
/** The full theme string applied to data-theme (e.g., "ocean-light") */
|
|
48
|
+
appliedTheme: string;
|
|
49
|
+
}
|
|
50
|
+
declare const ThemeContext: React__default.Context<ThemeContextValue | undefined>;
|
|
51
|
+
interface ThemeProviderProps {
|
|
52
|
+
children: React__default.ReactNode;
|
|
53
|
+
/** Available themes (will be merged with built-in themes) */
|
|
54
|
+
themes?: readonly ThemeDefinition[] | ThemeDefinition[];
|
|
55
|
+
/** Default theme name */
|
|
56
|
+
defaultTheme?: string;
|
|
57
|
+
/** Default color mode */
|
|
58
|
+
defaultMode?: ColorMode;
|
|
59
|
+
/** Optional target element ref — when provided, theme attributes are applied to this element instead of document.documentElement */
|
|
60
|
+
targetRef?: React__default.RefObject<HTMLElement>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Unified ThemeProvider component
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* // Basic usage with built-in themes
|
|
68
|
+
* <ThemeProvider defaultTheme="wireframe" defaultMode="light">
|
|
69
|
+
* <App />
|
|
70
|
+
* </ThemeProvider>
|
|
71
|
+
*
|
|
72
|
+
* // With custom themes from orbital schema
|
|
73
|
+
* import { THEMES } from './generated/theme-manifest';
|
|
74
|
+
* <ThemeProvider themes={THEMES} defaultTheme="ocean" defaultMode="system">
|
|
75
|
+
* <App />
|
|
76
|
+
* </ThemeProvider>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
|
|
80
|
+
/**
|
|
81
|
+
* Hook for accessing theme context
|
|
82
|
+
*
|
|
83
|
+
* @returns Theme context value
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* const { theme, resolvedMode, toggleMode, setTheme } = useTheme();
|
|
88
|
+
*
|
|
89
|
+
* // Toggle dark mode
|
|
90
|
+
* <button onClick={toggleMode}>
|
|
91
|
+
* {resolvedMode === 'dark' ? 'Light' : 'Dark'}
|
|
92
|
+
* </button>
|
|
93
|
+
*
|
|
94
|
+
* // Change theme
|
|
95
|
+
* <select value={theme} onChange={(e) => setTheme(e.target.value)}>
|
|
96
|
+
* {availableThemes.map(t => (
|
|
97
|
+
* <option key={t.name} value={t.name}>{t.displayName || t.name}</option>
|
|
98
|
+
* ))}
|
|
99
|
+
* </select>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function useTheme(): ThemeContextValue;
|
|
103
|
+
type DesignTheme = ThemeDefinition;
|
|
104
|
+
|
|
105
|
+
export { BUILT_IN_THEMES as B, type ColorMode as C, type DesignTheme as D, type ResolvedMode as R, type ThemeProviderProps as T, ThemeContext as a, type ThemeDefinition as b, ThemeProvider as c, useTheme as u };
|
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
import { useUISlotManager } from './chunk-7NEWMNNU.js';
|
|
2
|
-
import { createContext, useMemo,
|
|
2
|
+
import { createContext, useMemo, useState, useEffect, useCallback, useContext } from 'react';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
|
-
var UISlotContext = createContext(null);
|
|
6
|
-
function UISlotProvider({ children }) {
|
|
7
|
-
const slotManager = useUISlotManager();
|
|
8
|
-
const contextValue = useMemo(() => slotManager, [slotManager]);
|
|
9
|
-
return /* @__PURE__ */ jsx(UISlotContext.Provider, { value: contextValue, children });
|
|
10
|
-
}
|
|
11
|
-
function useUISlots() {
|
|
12
|
-
const context = useContext(UISlotContext);
|
|
13
|
-
if (!context) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
"useUISlots must be used within a UISlotProvider. Make sure your component tree is wrapped with <UISlotProvider>."
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return context;
|
|
19
|
-
}
|
|
20
|
-
function useSlotContent(slot) {
|
|
21
|
-
const { getContent } = useUISlots();
|
|
22
|
-
return getContent(slot);
|
|
23
|
-
}
|
|
24
|
-
function useSlotHasContent(slot) {
|
|
25
|
-
const { hasContent } = useUISlots();
|
|
26
|
-
return hasContent(slot);
|
|
27
|
-
}
|
|
28
5
|
var BUILT_IN_THEMES = [
|
|
29
6
|
{
|
|
30
7
|
name: "wireframe",
|
|
@@ -275,5 +252,28 @@ function useTheme() {
|
|
|
275
252
|
return context;
|
|
276
253
|
}
|
|
277
254
|
var ThemeContext_default = ThemeContext;
|
|
255
|
+
var UISlotContext = createContext(null);
|
|
256
|
+
function UISlotProvider({ children }) {
|
|
257
|
+
const slotManager = useUISlotManager();
|
|
258
|
+
const contextValue = useMemo(() => slotManager, [slotManager]);
|
|
259
|
+
return /* @__PURE__ */ jsx(UISlotContext.Provider, { value: contextValue, children });
|
|
260
|
+
}
|
|
261
|
+
function useUISlots() {
|
|
262
|
+
const context = useContext(UISlotContext);
|
|
263
|
+
if (!context) {
|
|
264
|
+
throw new Error(
|
|
265
|
+
"useUISlots must be used within a UISlotProvider. Make sure your component tree is wrapped with <UISlotProvider>."
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
return context;
|
|
269
|
+
}
|
|
270
|
+
function useSlotContent(slot) {
|
|
271
|
+
const { getContent } = useUISlots();
|
|
272
|
+
return getContent(slot);
|
|
273
|
+
}
|
|
274
|
+
function useSlotHasContent(slot) {
|
|
275
|
+
const { hasContent } = useUISlots();
|
|
276
|
+
return hasContent(slot);
|
|
277
|
+
}
|
|
278
278
|
|
|
279
279
|
export { BUILT_IN_THEMES, ThemeContext_default, ThemeProvider, UISlotContext, UISlotProvider, useSlotContent, useSlotHasContent, useTheme, useUISlots };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useTheme, useUISlots } from './chunk-
|
|
2
|
-
import { cn, debugGroup, debug, debugGroupEnd, getNestedValue, isDebugEnabled } from './chunk-KKCVDUK7.js';
|
|
1
|
+
import { useTheme, useUISlots } from './chunk-BTXQJGFB.js';
|
|
3
2
|
import { useTranslate, useQuerySingleton, useEntityList } from './chunk-PE2H3NAW.js';
|
|
4
3
|
import { useEventBus } from './chunk-YXZM3WCF.js';
|
|
4
|
+
import { cn, debugGroup, debug, debugGroupEnd, getNestedValue, isDebugEnabled } from './chunk-KKCVDUK7.js';
|
|
5
5
|
import { __publicField } from './chunk-PKBMQBKP.js';
|
|
6
6
|
import * as React41 from 'react';
|
|
7
7
|
import React41__default, { useCallback, useRef, useState, useLayoutEffect, useEffect, createContext, useMemo, useContext, Suspense } from 'react';
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Orbital State Machine Visualizer
|
|
5
|
+
*
|
|
6
|
+
* Renders SVG diagrams from Orbital schemas and Trait definitions.
|
|
7
|
+
* Can be used in documentation, IDE previews, and other tools.
|
|
8
|
+
*/
|
|
9
|
+
interface VisualizerConfig {
|
|
10
|
+
nodeRadius: number;
|
|
11
|
+
nodeSpacing: number;
|
|
12
|
+
initialIndicatorOffset: number;
|
|
13
|
+
arrowSize: number;
|
|
14
|
+
colors: {
|
|
15
|
+
background: string;
|
|
16
|
+
node: string;
|
|
17
|
+
nodeBorder: string;
|
|
18
|
+
nodeText: string;
|
|
19
|
+
initialNode: string;
|
|
20
|
+
finalNode: string;
|
|
21
|
+
arrow: string;
|
|
22
|
+
arrowText: string;
|
|
23
|
+
effectText: string;
|
|
24
|
+
guardText: string;
|
|
25
|
+
initial: string;
|
|
26
|
+
};
|
|
27
|
+
fonts: {
|
|
28
|
+
node: string;
|
|
29
|
+
event: string;
|
|
30
|
+
effect: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface StateDefinition {
|
|
34
|
+
name: string;
|
|
35
|
+
isInitial?: boolean;
|
|
36
|
+
isFinal?: boolean;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
interface TransitionDefinition {
|
|
40
|
+
from: string;
|
|
41
|
+
to: string;
|
|
42
|
+
event: string;
|
|
43
|
+
guard?: unknown;
|
|
44
|
+
effects?: unknown[];
|
|
45
|
+
}
|
|
46
|
+
interface StateMachineDefinition {
|
|
47
|
+
states: StateDefinition[];
|
|
48
|
+
transitions: TransitionDefinition[];
|
|
49
|
+
}
|
|
50
|
+
interface EntityDefinition {
|
|
51
|
+
name: string;
|
|
52
|
+
fields?: (string | {
|
|
53
|
+
name: string;
|
|
54
|
+
})[];
|
|
55
|
+
}
|
|
56
|
+
interface RenderOptions {
|
|
57
|
+
title?: string;
|
|
58
|
+
entity?: EntityDefinition;
|
|
59
|
+
}
|
|
60
|
+
/** Position data for a state node in DOM layout */
|
|
61
|
+
interface DomStateNode {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
radius: number;
|
|
67
|
+
isInitial: boolean;
|
|
68
|
+
isFinal: boolean;
|
|
69
|
+
description?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Position data for a transition arrow */
|
|
72
|
+
interface DomTransitionPath {
|
|
73
|
+
id: string;
|
|
74
|
+
from: string;
|
|
75
|
+
to: string;
|
|
76
|
+
/** SVG path data for the curved arrow */
|
|
77
|
+
pathData: string;
|
|
78
|
+
/** Midpoint for label positioning */
|
|
79
|
+
labelX: number;
|
|
80
|
+
labelY: number;
|
|
81
|
+
}
|
|
82
|
+
/** Position data for a transition label with guard/effect details */
|
|
83
|
+
interface DomTransitionLabel {
|
|
84
|
+
id: string;
|
|
85
|
+
from: string;
|
|
86
|
+
to: string;
|
|
87
|
+
event: string;
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
/** Human-readable guard text (e.g., "if amount > 100") */
|
|
91
|
+
guardText?: string;
|
|
92
|
+
/** Human-readable effect texts */
|
|
93
|
+
effectTexts: string[];
|
|
94
|
+
/** Whether this transition has details to show in tooltip */
|
|
95
|
+
hasDetails: boolean;
|
|
96
|
+
}
|
|
97
|
+
/** Entity input box data */
|
|
98
|
+
interface DomEntityBox {
|
|
99
|
+
name: string;
|
|
100
|
+
fields: string[];
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
}
|
|
106
|
+
/** Output effects box data */
|
|
107
|
+
interface DomOutputsBox {
|
|
108
|
+
outputs: string[];
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
}
|
|
114
|
+
/** Complete DOM layout data for rendering */
|
|
115
|
+
interface DomLayoutData {
|
|
116
|
+
width: number;
|
|
117
|
+
height: number;
|
|
118
|
+
title?: string;
|
|
119
|
+
states: DomStateNode[];
|
|
120
|
+
paths: DomTransitionPath[];
|
|
121
|
+
labels: DomTransitionLabel[];
|
|
122
|
+
entity?: DomEntityBox;
|
|
123
|
+
outputs?: DomOutputsBox;
|
|
124
|
+
config: VisualizerConfig;
|
|
125
|
+
}
|
|
126
|
+
declare const DEFAULT_CONFIG: VisualizerConfig;
|
|
127
|
+
declare function formatGuard(guard: unknown): string;
|
|
128
|
+
declare function getEffectSummary(effects: unknown[]): string;
|
|
129
|
+
declare function extractOutputsFromTransitions(transitions: TransitionDefinition[]): string[];
|
|
130
|
+
/**
|
|
131
|
+
* Render a state machine to an SVG string.
|
|
132
|
+
* Works in both browser and Node.js environments.
|
|
133
|
+
*/
|
|
134
|
+
declare function renderStateMachineToSvg(stateMachine: StateMachineDefinition, options?: RenderOptions, config?: VisualizerConfig): string;
|
|
135
|
+
/**
|
|
136
|
+
* Extract state machine from various data formats (Trait, Orbital, or raw)
|
|
137
|
+
*/
|
|
138
|
+
declare function extractStateMachine(data: unknown): StateMachineDefinition | null;
|
|
139
|
+
/**
|
|
140
|
+
* Render a state machine to DOM layout data.
|
|
141
|
+
* This is used by the DOM-based visualizer component for hybrid SVG/DOM rendering.
|
|
142
|
+
* Unlike renderStateMachineToSvg, this returns structured data instead of an SVG string.
|
|
143
|
+
*/
|
|
144
|
+
declare function renderStateMachineToDomData(stateMachine: StateMachineDefinition, options?: RenderOptions, config?: VisualizerConfig): DomLayoutData;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Content Segment Parsing Utilities
|
|
148
|
+
*
|
|
149
|
+
* Parses rich content with code blocks and quiz tags into structured
|
|
150
|
+
* segments for rendering. Detects orbital schemas in JSON code blocks
|
|
151
|
+
* and marks them for JazariStateMachine rendering.
|
|
152
|
+
*/
|
|
153
|
+
/** Segment types for content rendering */
|
|
154
|
+
type ContentSegment = {
|
|
155
|
+
type: 'markdown';
|
|
156
|
+
content: string;
|
|
157
|
+
} | {
|
|
158
|
+
type: 'code';
|
|
159
|
+
language: string;
|
|
160
|
+
content: string;
|
|
161
|
+
} | {
|
|
162
|
+
type: 'orbital';
|
|
163
|
+
language: string;
|
|
164
|
+
content: string;
|
|
165
|
+
schema: unknown;
|
|
166
|
+
} | {
|
|
167
|
+
type: 'quiz';
|
|
168
|
+
question: string;
|
|
169
|
+
answer: string;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Parse markdown content to extract code blocks.
|
|
173
|
+
*
|
|
174
|
+
* Splits markdown into segments of plain markdown and fenced code blocks.
|
|
175
|
+
* JSON/orb code blocks containing orbital schemas are tagged as 'orbital'.
|
|
176
|
+
*/
|
|
177
|
+
declare function parseMarkdownWithCodeBlocks(content: string | undefined | null): ContentSegment[];
|
|
178
|
+
/**
|
|
179
|
+
* Parse content to extract all segments including quiz tags and code blocks.
|
|
180
|
+
*
|
|
181
|
+
* Supported tags:
|
|
182
|
+
* - <question>q</question><answer>a</answer> — Quiz Q&A
|
|
183
|
+
*
|
|
184
|
+
* Also handles fenced code blocks (```language...```) with orbital detection.
|
|
185
|
+
*/
|
|
186
|
+
declare function parseContentSegments(content: string | undefined | null): ContentSegment[];
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Utility function to merge Tailwind CSS classes
|
|
190
|
+
* Combines clsx for conditional classes with tailwind-merge to handle conflicts
|
|
191
|
+
*/
|
|
192
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
193
|
+
|
|
194
|
+
export { type ContentSegment as C, DEFAULT_CONFIG as D, type EntityDefinition as E, type RenderOptions as R, type StateDefinition as S, type TransitionDefinition as T, type VisualizerConfig as V, type DomEntityBox as a, type DomLayoutData as b, type DomOutputsBox as c, type DomStateNode as d, type DomTransitionLabel as e, type DomTransitionPath as f, type StateMachineDefinition as g, cn as h, extractOutputsFromTransitions as i, extractStateMachine as j, formatGuard as k, getEffectSummary as l, parseMarkdownWithCodeBlocks as m, renderStateMachineToSvg as n, parseContentSegments as p, renderStateMachineToDomData as r };
|