@mmapp/react 0.1.0-alpha.18 → 0.1.0-alpha.20
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/actions-HOXZPBTT.mjs +116 -0
- package/dist/actions-MFI2V4DX.mjs +116 -0
- package/dist/atoms/index.d.mts +2 -2
- package/dist/atoms/index.d.ts +2 -2
- package/dist/atoms/index.js +1 -1
- package/dist/atoms/index.mjs +1 -1
- package/dist/builtin-atoms-C-sNyYJl.d.mts +647 -0
- package/dist/builtin-atoms-C-sNyYJl.d.ts +647 -0
- package/dist/builtin-atoms-DCKrjG7i.d.mts +96 -0
- package/dist/builtin-atoms-DCKrjG7i.d.ts +96 -0
- package/dist/builtin-atoms-DRD3EwG6.d.mts +648 -0
- package/dist/builtin-atoms-DRD3EwG6.d.ts +648 -0
- package/dist/builtin-atoms-jt04b7Rw.d.mts +643 -0
- package/dist/builtin-atoms-jt04b7Rw.d.ts +643 -0
- package/dist/chunk-247T4GDJ.mjs +677 -0
- package/dist/chunk-3H6CR7E7.mjs +1924 -0
- package/dist/chunk-3PL6FL6I.mjs +96 -0
- package/dist/chunk-3SJSW3C4.mjs +2039 -0
- package/dist/chunk-5OI2VI57.mjs +1964 -0
- package/dist/chunk-CL6FYZ43.mjs +105 -0
- package/dist/chunk-ENQOCZI5.mjs +1938 -0
- package/dist/chunk-FB3WCZAU.mjs +512 -0
- package/dist/chunk-FBKUGKQI.mjs +1938 -0
- package/dist/chunk-GLJ7VC7Z.mjs +684 -0
- package/dist/chunk-HHMWR6NA.mjs +504 -0
- package/dist/chunk-HULEMSN2.mjs +120 -0
- package/dist/chunk-J5MW6CRU.mjs +1938 -0
- package/dist/chunk-PNTTKNYU.mjs +677 -0
- package/dist/chunk-TY5OTJP4.mjs +684 -0
- package/dist/chunk-WV7DVCP6.mjs +513 -0
- package/dist/chunk-YFMPTGUF.mjs +677 -0
- package/dist/chunk-ZAHMWAER.mjs +1960 -0
- package/dist/{chunk-2VJQJM7S.mjs → chunk-ZDWACXZN.mjs} +1 -1
- package/dist/composition-BJ6QQTWT.mjs +12 -0
- package/dist/composition-XBGKKCI7.mjs +57 -0
- package/dist/content-QVPFUG4P.mjs +246 -0
- package/dist/control-flow-CBREHWJW.mjs +35 -0
- package/dist/control-flow-FWBOI6SM.mjs +35 -0
- package/dist/control-flow-ZWUGCDSP.mjs +35 -0
- package/dist/data-WCMIZYKD.mjs +97 -0
- package/dist/grouping-E6F377VZ.mjs +204 -0
- package/dist/grouping-FRPOEXO3.mjs +233 -0
- package/dist/index.d.mts +4 -433
- package/dist/index.d.ts +4 -433
- package/dist/index.js +3671 -582
- package/dist/index.mjs +335 -1040
- package/dist/input-PUOZDNSI.mjs +222 -0
- package/dist/layout-RATDMCLP.mjs +106 -0
- package/dist/navigation-VCT7ZBMA.mjs +15 -0
- package/dist/navigation-WFV7YWOU.mjs +14 -0
- package/dist/player/index.d.mts +37 -11
- package/dist/player/index.d.ts +37 -11
- package/dist/player/index.js +3321 -193
- package/dist/player/index.mjs +55 -5
- package/package.json +4 -4
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Player Runtime Types
|
|
6
|
+
*
|
|
7
|
+
* Core type system for the player IR interpreter.
|
|
8
|
+
* Covers experience nodes, data sources, resolvers, scopes, and actions.
|
|
9
|
+
*
|
|
10
|
+
* Backward compatible — original ComponentNode/ComponentTree/AtomRegistry still exported.
|
|
11
|
+
*/
|
|
12
|
+
interface ComponentNode {
|
|
13
|
+
type?: string;
|
|
14
|
+
component?: string;
|
|
15
|
+
props?: Record<string, unknown>;
|
|
16
|
+
config?: Record<string, unknown>;
|
|
17
|
+
id?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
children?: ComponentNode[] | string;
|
|
20
|
+
$if?: string;
|
|
21
|
+
$for?: {
|
|
22
|
+
each: string;
|
|
23
|
+
as: string;
|
|
24
|
+
key?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
type ComponentTree = ComponentNode | ComponentNode[];
|
|
28
|
+
type AtomComponent = React.ComponentType<Record<string, unknown>>;
|
|
29
|
+
type AtomRegistry = Record<string, AtomComponent>;
|
|
30
|
+
interface WorkflowInstance {
|
|
31
|
+
id: string;
|
|
32
|
+
definition_id?: string;
|
|
33
|
+
definition_slug?: string;
|
|
34
|
+
current_state: string;
|
|
35
|
+
status?: string;
|
|
36
|
+
state_data: Record<string, unknown>;
|
|
37
|
+
memory?: Record<string, unknown>;
|
|
38
|
+
action_results?: Record<string, unknown>;
|
|
39
|
+
context?: Record<string, unknown>;
|
|
40
|
+
created_at?: string;
|
|
41
|
+
updated_at?: string;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
interface WorkflowDefinition {
|
|
45
|
+
id: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
name?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
version?: string;
|
|
50
|
+
category?: string;
|
|
51
|
+
fields?: FieldDefinition[];
|
|
52
|
+
states?: StateDefinition[];
|
|
53
|
+
transitions?: TransitionDefinition[];
|
|
54
|
+
roles?: RoleDefinition[];
|
|
55
|
+
experience?: ExperienceNode;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
interface FieldDefinition {
|
|
60
|
+
name: string;
|
|
61
|
+
field_type?: string;
|
|
62
|
+
type?: string;
|
|
63
|
+
required?: boolean;
|
|
64
|
+
default?: unknown;
|
|
65
|
+
label?: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
options?: Array<{
|
|
68
|
+
value: string;
|
|
69
|
+
label: string;
|
|
70
|
+
}>;
|
|
71
|
+
visible_when?: string;
|
|
72
|
+
editable_when?: string;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
interface StateDefinition {
|
|
76
|
+
name: string;
|
|
77
|
+
type?: string;
|
|
78
|
+
on_enter?: ActionDefinition[];
|
|
79
|
+
on_exit?: ActionDefinition[];
|
|
80
|
+
metadata?: Record<string, unknown>;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
interface TransitionDefinition {
|
|
84
|
+
name: string;
|
|
85
|
+
from: string | string[];
|
|
86
|
+
to: string;
|
|
87
|
+
condition?: string;
|
|
88
|
+
required_roles?: string[];
|
|
89
|
+
required_fields?: string[];
|
|
90
|
+
actions?: ActionDefinition[];
|
|
91
|
+
metadata?: Record<string, unknown>;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
interface RoleDefinition {
|
|
95
|
+
name: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
assigned_when?: string;
|
|
98
|
+
permissions?: string[];
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
interface ActionDefinition {
|
|
102
|
+
id?: string;
|
|
103
|
+
type?: string;
|
|
104
|
+
action_type?: string;
|
|
105
|
+
config?: Record<string, unknown>;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
interface TransitionInfo {
|
|
109
|
+
name: string;
|
|
110
|
+
from: string | string[];
|
|
111
|
+
to: string;
|
|
112
|
+
condition?: string;
|
|
113
|
+
required_roles?: string[];
|
|
114
|
+
metadata?: Record<string, unknown>;
|
|
115
|
+
}
|
|
116
|
+
interface DataSourceBase {
|
|
117
|
+
name: string;
|
|
118
|
+
fields?: FieldDefinition[];
|
|
119
|
+
}
|
|
120
|
+
interface WorkflowDataSource extends DataSourceBase {
|
|
121
|
+
type: 'workflow';
|
|
122
|
+
slug?: string;
|
|
123
|
+
query: 'latest' | 'list' | 'count';
|
|
124
|
+
instanceId?: string;
|
|
125
|
+
entity?: {
|
|
126
|
+
type: string;
|
|
127
|
+
id: string;
|
|
128
|
+
} | null;
|
|
129
|
+
paginated?: boolean;
|
|
130
|
+
pageSize?: number;
|
|
131
|
+
pageKey?: string;
|
|
132
|
+
filters?: Record<string, string | {
|
|
133
|
+
bind: string;
|
|
134
|
+
}>;
|
|
135
|
+
filter?: Record<string, string>;
|
|
136
|
+
filterKey?: string;
|
|
137
|
+
autoStart?: boolean;
|
|
138
|
+
initialData?: Record<string, unknown>;
|
|
139
|
+
includeDefinition?: boolean;
|
|
140
|
+
includeMemory?: boolean;
|
|
141
|
+
facets?: string[];
|
|
142
|
+
sort?: string;
|
|
143
|
+
search?: string;
|
|
144
|
+
searchFields?: string[];
|
|
145
|
+
range?: Record<string, {
|
|
146
|
+
min?: unknown;
|
|
147
|
+
max?: unknown;
|
|
148
|
+
}>;
|
|
149
|
+
aggregate?: string;
|
|
150
|
+
groupBy?: string;
|
|
151
|
+
parentInstanceId?: string;
|
|
152
|
+
}
|
|
153
|
+
interface ApiDataSource extends DataSourceBase {
|
|
154
|
+
type: 'api';
|
|
155
|
+
endpoint: string;
|
|
156
|
+
method?: 'GET' | 'POST';
|
|
157
|
+
body?: Record<string, unknown>;
|
|
158
|
+
headers?: Record<string, string>;
|
|
159
|
+
mapping?: {
|
|
160
|
+
id?: string;
|
|
161
|
+
state?: string;
|
|
162
|
+
data?: string;
|
|
163
|
+
items?: string;
|
|
164
|
+
total?: string;
|
|
165
|
+
};
|
|
166
|
+
staleTime?: number;
|
|
167
|
+
}
|
|
168
|
+
interface StaticDataSource extends DataSourceBase {
|
|
169
|
+
type: 'static';
|
|
170
|
+
data: Record<string, unknown> | Record<string, unknown>[];
|
|
171
|
+
}
|
|
172
|
+
interface RefDataSource extends DataSourceBase {
|
|
173
|
+
type: 'ref';
|
|
174
|
+
expression: string;
|
|
175
|
+
}
|
|
176
|
+
type DataSource = WorkflowDataSource | ApiDataSource | StaticDataSource | RefDataSource;
|
|
177
|
+
interface FacetEntry {
|
|
178
|
+
value: string | null;
|
|
179
|
+
count: number;
|
|
180
|
+
}
|
|
181
|
+
interface DataSourceResult {
|
|
182
|
+
instance?: InstanceData;
|
|
183
|
+
instances?: InstanceData[];
|
|
184
|
+
definition?: WorkflowDefinition;
|
|
185
|
+
pagination?: {
|
|
186
|
+
total: number;
|
|
187
|
+
page: number;
|
|
188
|
+
pageSize: number;
|
|
189
|
+
};
|
|
190
|
+
facets?: Record<string, FacetEntry[]>;
|
|
191
|
+
aggregates?: Record<string, Record<string, number>>;
|
|
192
|
+
grouped?: Array<Record<string, unknown>>;
|
|
193
|
+
loading: boolean;
|
|
194
|
+
error: Error | null;
|
|
195
|
+
}
|
|
196
|
+
/** Normalized instance shape used in scope */
|
|
197
|
+
interface InstanceData {
|
|
198
|
+
id: string;
|
|
199
|
+
state: string;
|
|
200
|
+
fields: Record<string, unknown>;
|
|
201
|
+
slug?: string;
|
|
202
|
+
created_at?: string;
|
|
203
|
+
updated_at?: string;
|
|
204
|
+
[key: string]: unknown;
|
|
205
|
+
}
|
|
206
|
+
interface ExperienceNode {
|
|
207
|
+
id: string;
|
|
208
|
+
displayName?: string;
|
|
209
|
+
experienceId?: string;
|
|
210
|
+
component?: string;
|
|
211
|
+
slot?: string;
|
|
212
|
+
dataSources?: DataSource[];
|
|
213
|
+
dataScope?: string;
|
|
214
|
+
children?: ExperienceNode[];
|
|
215
|
+
config?: Record<string, unknown>;
|
|
216
|
+
layout?: string;
|
|
217
|
+
className?: string;
|
|
218
|
+
style?: Record<string, unknown>;
|
|
219
|
+
overrides?: Record<string, unknown>;
|
|
220
|
+
bindings?: Record<string, string>;
|
|
221
|
+
visible_when?: string;
|
|
222
|
+
type?: string;
|
|
223
|
+
props?: Record<string, unknown>;
|
|
224
|
+
$if?: string;
|
|
225
|
+
$for?: {
|
|
226
|
+
each: string;
|
|
227
|
+
as: string;
|
|
228
|
+
key?: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
interface QueryParams {
|
|
232
|
+
state?: string | string[];
|
|
233
|
+
status?: string;
|
|
234
|
+
filter?: Record<string, unknown>;
|
|
235
|
+
search?: string;
|
|
236
|
+
searchFields?: string[];
|
|
237
|
+
sort?: Array<{
|
|
238
|
+
field: string;
|
|
239
|
+
direction: 'asc' | 'desc';
|
|
240
|
+
}> | string;
|
|
241
|
+
limit?: number;
|
|
242
|
+
page?: number;
|
|
243
|
+
offset?: number;
|
|
244
|
+
facets?: string[];
|
|
245
|
+
aggregate?: {
|
|
246
|
+
fn: string;
|
|
247
|
+
field: string;
|
|
248
|
+
groupBy?: string;
|
|
249
|
+
};
|
|
250
|
+
includeDefinition?: boolean;
|
|
251
|
+
entity?: {
|
|
252
|
+
type: string;
|
|
253
|
+
id: string;
|
|
254
|
+
} | null;
|
|
255
|
+
parentInstanceId?: string;
|
|
256
|
+
}
|
|
257
|
+
interface QueryResult {
|
|
258
|
+
data: InstanceData[];
|
|
259
|
+
total: number;
|
|
260
|
+
page: number;
|
|
261
|
+
pageSize: number;
|
|
262
|
+
definition?: WorkflowDefinition;
|
|
263
|
+
facets?: Record<string, FacetEntry[]>;
|
|
264
|
+
aggregates?: Record<string, Record<string, number>>;
|
|
265
|
+
grouped?: Array<Record<string, unknown>>;
|
|
266
|
+
}
|
|
267
|
+
interface TransitionResult {
|
|
268
|
+
success: boolean;
|
|
269
|
+
instance?: WorkflowInstance;
|
|
270
|
+
from_state?: string;
|
|
271
|
+
to_state?: string;
|
|
272
|
+
error?: string;
|
|
273
|
+
}
|
|
274
|
+
interface PlayerResolver {
|
|
275
|
+
query(slug: string, params: QueryParams): Promise<QueryResult>;
|
|
276
|
+
getInstance(id: string): Promise<InstanceData>;
|
|
277
|
+
getDefinition(slug: string): Promise<WorkflowDefinition>;
|
|
278
|
+
create(slug: string, data?: Record<string, unknown>): Promise<string>;
|
|
279
|
+
update(id: string, fields: Record<string, unknown>): Promise<void>;
|
|
280
|
+
transition(id: string, name: string, data?: Record<string, unknown>): Promise<TransitionResult>;
|
|
281
|
+
remove(id: string): Promise<void>;
|
|
282
|
+
availableTransitions(id: string): Promise<TransitionInfo[]>;
|
|
283
|
+
fetch?(endpoint: string, config: {
|
|
284
|
+
method?: string;
|
|
285
|
+
body?: unknown;
|
|
286
|
+
headers?: Record<string, string>;
|
|
287
|
+
}): Promise<unknown>;
|
|
288
|
+
subscribe?(channel: string, callback: (event: unknown) => void): () => void;
|
|
289
|
+
}
|
|
290
|
+
interface PlayerAuth {
|
|
291
|
+
userId?: string;
|
|
292
|
+
roles?: string[];
|
|
293
|
+
token?: string | (() => string | null);
|
|
294
|
+
}
|
|
295
|
+
interface PlayerRouter {
|
|
296
|
+
push(path: string): void;
|
|
297
|
+
replace?(path: string): void;
|
|
298
|
+
back?(): void;
|
|
299
|
+
pathname?: string;
|
|
300
|
+
}
|
|
301
|
+
interface ScopeData {
|
|
302
|
+
$instance?: InstanceData;
|
|
303
|
+
$instances?: InstanceData[];
|
|
304
|
+
$definition?: WorkflowDefinition;
|
|
305
|
+
$pagination?: {
|
|
306
|
+
total: number;
|
|
307
|
+
page: number;
|
|
308
|
+
pageSize: number;
|
|
309
|
+
};
|
|
310
|
+
$entity?: {
|
|
311
|
+
type: string;
|
|
312
|
+
id: string;
|
|
313
|
+
};
|
|
314
|
+
$local: Record<string, unknown>;
|
|
315
|
+
$user: {
|
|
316
|
+
id?: string;
|
|
317
|
+
roles: string[];
|
|
318
|
+
};
|
|
319
|
+
$fn: Record<string, (...args: unknown[]) => unknown>;
|
|
320
|
+
$action: ActionScope;
|
|
321
|
+
$item?: unknown;
|
|
322
|
+
$index?: number;
|
|
323
|
+
state_data?: Record<string, unknown>;
|
|
324
|
+
memory?: Record<string, unknown>;
|
|
325
|
+
context?: Record<string, unknown>;
|
|
326
|
+
[key: string]: unknown;
|
|
327
|
+
}
|
|
328
|
+
interface ActionScope {
|
|
329
|
+
transition(name: string, instanceId?: string, data?: Record<string, unknown>): Promise<void>;
|
|
330
|
+
create(slug: string, data?: Record<string, unknown>): Promise<string>;
|
|
331
|
+
update(instanceId: string, fields: Record<string, unknown>): Promise<void>;
|
|
332
|
+
remove(instanceId: string): Promise<void>;
|
|
333
|
+
setLocal(key: string, value: unknown): void;
|
|
334
|
+
navigate(path: string): void;
|
|
335
|
+
toast(message: string, variant?: 'default' | 'success' | 'error' | 'warning'): void;
|
|
336
|
+
refreshQuery(dataSourceName?: string): void;
|
|
337
|
+
scrollTo(elementId: string): void;
|
|
338
|
+
openModal(modalId: string): void;
|
|
339
|
+
closeModal(modalId: string): void;
|
|
340
|
+
emit(event: string, payload?: unknown): void;
|
|
341
|
+
[key: string]: unknown;
|
|
342
|
+
}
|
|
343
|
+
interface AtomRegistryInterface {
|
|
344
|
+
register(name: string, loader: () => Promise<{
|
|
345
|
+
default: React.ComponentType<Record<string, unknown>>;
|
|
346
|
+
}>): void;
|
|
347
|
+
resolve(name: string): React.LazyExoticComponent<React.ComponentType<Record<string, unknown>>> | null;
|
|
348
|
+
has(name: string): boolean;
|
|
349
|
+
list(): string[];
|
|
350
|
+
merge(other: AtomRegistryInterface): AtomRegistryInterface;
|
|
351
|
+
/** Get as flat record for backward compat with ComponentTreeRenderer */
|
|
352
|
+
toRecord(): AtomRegistry;
|
|
353
|
+
}
|
|
354
|
+
type ExprClass$1 = 'literal' | 'path' | 'function' | 'action' | 'condition';
|
|
355
|
+
interface BindingClass {
|
|
356
|
+
type: ExprClass$1;
|
|
357
|
+
value?: unknown;
|
|
358
|
+
root?: string;
|
|
359
|
+
rest?: string;
|
|
360
|
+
name?: string;
|
|
361
|
+
rawArgs?: string[];
|
|
362
|
+
expression?: string;
|
|
363
|
+
}
|
|
364
|
+
interface ExpressionEvaluator {
|
|
365
|
+
evaluate(expr: string, context: Record<string, unknown>): unknown;
|
|
366
|
+
classify(expr: string): ExprClass$1;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* ExperienceRenderer — Full IR interpreter for compiled experience trees.
|
|
371
|
+
*
|
|
372
|
+
* Per-node pipeline:
|
|
373
|
+
* 1. Check visibility (visible_when expression)
|
|
374
|
+
* 2. Resolve dataSources (fetch via PlayerResolver)
|
|
375
|
+
* 3. Initialize $local state (from config.localDefaults)
|
|
376
|
+
* 4. Build scope chain ($instance, $local, $action, $user, $fn, $entity)
|
|
377
|
+
* 5. Evaluate bindings (classify + resolve each expression)
|
|
378
|
+
* 6. Merge props (config + resolved bindings)
|
|
379
|
+
* 7. Resolve atom (look up component name in registry)
|
|
380
|
+
* 8. Render with ErrorBoundary + Suspense
|
|
381
|
+
* 9. Recurse for children
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
interface ExperienceRendererProps {
|
|
385
|
+
tree: ExperienceNode | ExperienceNode[];
|
|
386
|
+
initialScope?: Partial<ScopeData>;
|
|
387
|
+
entity?: {
|
|
388
|
+
type: string;
|
|
389
|
+
id: string;
|
|
390
|
+
};
|
|
391
|
+
fallback?: React__default.ReactNode;
|
|
392
|
+
className?: string;
|
|
393
|
+
}
|
|
394
|
+
declare const ExperienceRenderer: React__default.FC<ExperienceRendererProps>;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* PlayerProvider — Top-level context provider for the ExperienceRenderer.
|
|
398
|
+
*
|
|
399
|
+
* Bridges the player runtime with:
|
|
400
|
+
* - PlayerResolver (data fetching / mutations)
|
|
401
|
+
* - AtomRegistryInterface (component lookup)
|
|
402
|
+
* - Auth context ($user)
|
|
403
|
+
* - Router integration (navigate)
|
|
404
|
+
* - Toast/notification system
|
|
405
|
+
* - Event bus
|
|
406
|
+
*
|
|
407
|
+
* Also wires into the existing DI hooks (setQueryResolver, setMutationResolver)
|
|
408
|
+
* so that useQuery/useMutation work inside player-rendered components.
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
interface PlayerContextValue {
|
|
412
|
+
resolver: PlayerResolver | null;
|
|
413
|
+
atomRegistry: AtomRegistryInterface;
|
|
414
|
+
auth?: PlayerAuth;
|
|
415
|
+
router?: PlayerRouter;
|
|
416
|
+
toast?: (message: string, variant?: 'default' | 'success' | 'error' | 'warning') => void;
|
|
417
|
+
onEvent?: (event: string, payload?: unknown) => void;
|
|
418
|
+
}
|
|
419
|
+
declare function usePlayerContext(): PlayerContextValue | null;
|
|
420
|
+
interface PlayerProviderProps {
|
|
421
|
+
/** Backend resolver for data fetching and mutations */
|
|
422
|
+
resolver?: PlayerResolver;
|
|
423
|
+
/** Atom registry (defaults to core atoms) */
|
|
424
|
+
atomRegistry?: AtomRegistryInterface;
|
|
425
|
+
/** Auth context — populates $user in scope */
|
|
426
|
+
auth?: PlayerAuth;
|
|
427
|
+
/** Router integration for $action.navigate */
|
|
428
|
+
router?: PlayerRouter;
|
|
429
|
+
/** Toast handler for $action.toast */
|
|
430
|
+
toast?: (message: string, variant?: 'default' | 'success' | 'error' | 'warning') => void;
|
|
431
|
+
/** Event handler for $action.emit */
|
|
432
|
+
onEvent?: (event: string, payload?: unknown) => void;
|
|
433
|
+
/** Children */
|
|
434
|
+
children: React__default.ReactNode;
|
|
435
|
+
}
|
|
436
|
+
declare const PlayerProvider: React__default.FC<PlayerProviderProps>;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Player Resolvers — Default backend implementations.
|
|
440
|
+
*
|
|
441
|
+
* Factory function for creating PlayerResolver instances:
|
|
442
|
+
* - createApiResolver: HTTP API backend (mm-api)
|
|
443
|
+
*/
|
|
444
|
+
|
|
445
|
+
interface ApiResolverConfig {
|
|
446
|
+
baseUrl: string;
|
|
447
|
+
token?: string | (() => string | null);
|
|
448
|
+
fetch?: typeof globalThis.fetch;
|
|
449
|
+
defaults?: {
|
|
450
|
+
limit?: number;
|
|
451
|
+
staleTime?: number;
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
declare function createApiResolver(config: ApiResolverConfig): PlayerResolver;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Expression Engine — Three-tier evaluation strategy.
|
|
458
|
+
*
|
|
459
|
+
* Tier 1: Fast-path for literals and dot-paths (no compilation)
|
|
460
|
+
* Tier 2: WASM mm-compute evaluation (if available)
|
|
461
|
+
* Tier 3: JS Function compilation with LRU cache (fallback)
|
|
462
|
+
*
|
|
463
|
+
* Ported from packages/frontend/src/services/expression.service.ts
|
|
464
|
+
* with all frontend coupling removed.
|
|
465
|
+
*/
|
|
466
|
+
interface WasmModule {
|
|
467
|
+
evaluateExpressionSync(expr: string, contextJson: string): string;
|
|
468
|
+
}
|
|
469
|
+
declare function setWasmModule(module: WasmModule | null): void;
|
|
470
|
+
type ExprClass = 'literal' | 'path' | 'function' | 'action' | 'condition';
|
|
471
|
+
declare const builtinFunctions: Record<string, (...args: unknown[]) => unknown>;
|
|
472
|
+
/**
|
|
473
|
+
* Evaluate an expression against a context object.
|
|
474
|
+
* Uses three-tier strategy: WASM → JS compiled → fast-path.
|
|
475
|
+
*/
|
|
476
|
+
declare function evaluateExpression(expr: string, context: Record<string, unknown>): unknown;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Binding Resolver — Resolves $-prefix expression bindings to concrete values.
|
|
480
|
+
*
|
|
481
|
+
* Ported from packages/frontend/src/experiences/binding-resolver.ts
|
|
482
|
+
* with all frontend coupling removed (no @/ imports, no QueryClient, no React Router).
|
|
483
|
+
*
|
|
484
|
+
* Classification is cached per expression string (parse once, resolve fast).
|
|
485
|
+
* Literal/path bindings are fast-path (no Function compilation).
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
interface BindingClassification {
|
|
489
|
+
type: ExprClass;
|
|
490
|
+
value?: unknown;
|
|
491
|
+
root?: string;
|
|
492
|
+
rest?: string;
|
|
493
|
+
name?: string;
|
|
494
|
+
rawArgs?: string[];
|
|
495
|
+
expression?: string;
|
|
496
|
+
}
|
|
497
|
+
declare function classifyBinding(expr: string): BindingClassification;
|
|
498
|
+
/**
|
|
499
|
+
* Resolve a single binding expression against a scope.
|
|
500
|
+
*/
|
|
501
|
+
declare function resolveBinding(expr: string, scope: ScopeData): unknown;
|
|
502
|
+
/**
|
|
503
|
+
* Resolve all bindings for a node, returning a props object.
|
|
504
|
+
*/
|
|
505
|
+
declare function resolveAllBindings(bindings: Record<string, string>, scope: ScopeData): Record<string, unknown>;
|
|
506
|
+
/**
|
|
507
|
+
* Build a flat evaluation context from scoped data.
|
|
508
|
+
* Merges all scope namespaces into a single object for expression evaluation.
|
|
509
|
+
*/
|
|
510
|
+
declare function buildEvalContext(scope: ScopeData): Record<string, unknown>;
|
|
511
|
+
interface BuildActionScopeOptions {
|
|
512
|
+
resolver: PlayerResolver;
|
|
513
|
+
instanceId?: string;
|
|
514
|
+
slug?: string;
|
|
515
|
+
setLocal: (key: string, value: unknown) => void;
|
|
516
|
+
router?: PlayerRouter;
|
|
517
|
+
toast?: (message: string, variant?: string) => void;
|
|
518
|
+
refreshQuery?: (dataSourceName?: string) => void;
|
|
519
|
+
onEvent?: (event: string, payload?: unknown) => void;
|
|
520
|
+
}
|
|
521
|
+
declare function buildActionScope(opts: BuildActionScopeOptions): ActionScope;
|
|
522
|
+
|
|
523
|
+
declare const ScopeContext: React$1.Context<ScopeData>;
|
|
524
|
+
declare function useScope(): ScopeData;
|
|
525
|
+
interface BuildScopeOptions {
|
|
526
|
+
/** DataSource results keyed by name */
|
|
527
|
+
dataSources?: Record<string, DataSourceResult>;
|
|
528
|
+
/** Local state values */
|
|
529
|
+
localState?: Record<string, unknown>;
|
|
530
|
+
/** Auth context */
|
|
531
|
+
auth?: PlayerAuth;
|
|
532
|
+
/** Entity context */
|
|
533
|
+
entity?: {
|
|
534
|
+
type: string;
|
|
535
|
+
id: string;
|
|
536
|
+
};
|
|
537
|
+
/** Parent scope to inherit from */
|
|
538
|
+
parentScope?: ScopeData;
|
|
539
|
+
/** Action scope */
|
|
540
|
+
actionScope?: ActionScope;
|
|
541
|
+
/** Custom $fn additions */
|
|
542
|
+
functions?: Record<string, (...args: unknown[]) => unknown>;
|
|
543
|
+
}
|
|
544
|
+
declare function buildScope(opts: BuildScopeOptions): ScopeData;
|
|
545
|
+
/**
|
|
546
|
+
* Merge a child scope into a parent scope.
|
|
547
|
+
* Child values override parent values.
|
|
548
|
+
*/
|
|
549
|
+
declare function mergeScope(parent: ScopeData, child: Partial<ScopeData>): ScopeData;
|
|
550
|
+
/**
|
|
551
|
+
* Create a loop iteration scope with $item and $index.
|
|
552
|
+
* Also adds the item under the `as` variable name.
|
|
553
|
+
*/
|
|
554
|
+
declare function buildLoopScope(parent: ScopeData, item: unknown, index: number, as: string): ScopeData;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Atom Registry — Lazy-loaded component resolution.
|
|
558
|
+
*
|
|
559
|
+
* Instance-based (not module-singleton) so multiple PlayerProvider
|
|
560
|
+
* instances don't conflict. Each registry maintains its own lazy cache.
|
|
561
|
+
*/
|
|
562
|
+
|
|
563
|
+
type ComponentLoader = () => Promise<{
|
|
564
|
+
default: React__default.ComponentType<Record<string, unknown>>;
|
|
565
|
+
}>;
|
|
566
|
+
declare class AtomRegistryImpl implements AtomRegistryInterface {
|
|
567
|
+
private loaders;
|
|
568
|
+
private lazyCache;
|
|
569
|
+
private eagerCache;
|
|
570
|
+
register(name: string, loader: ComponentLoader): void;
|
|
571
|
+
registerEager(name: string, component: React__default.ComponentType<Record<string, unknown>>): void;
|
|
572
|
+
resolve(name: string): React__default.LazyExoticComponent<React__default.ComponentType<Record<string, unknown>>> | null;
|
|
573
|
+
resolveSync(name: string): React__default.ComponentType<Record<string, unknown>> | null;
|
|
574
|
+
has(name: string): boolean;
|
|
575
|
+
list(): string[];
|
|
576
|
+
merge(other: AtomRegistryInterface): AtomRegistryInterface;
|
|
577
|
+
toRecord(): AtomRegistry;
|
|
578
|
+
}
|
|
579
|
+
declare function createCoreAtomRegistry(): AtomRegistryImpl;
|
|
580
|
+
declare function mergeRegistries(...registries: AtomRegistryInterface[]): AtomRegistryInterface;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Standalone ComponentTreeRenderer for the dev player.
|
|
584
|
+
*
|
|
585
|
+
* Renders a JSON component tree (IR experience nodes) to React elements.
|
|
586
|
+
* Uses the minimal evaluator and accepts an AtomRegistry for component resolution.
|
|
587
|
+
*/
|
|
588
|
+
|
|
589
|
+
interface ComponentTreeRendererProps {
|
|
590
|
+
/** The component tree to render */
|
|
591
|
+
tree: ComponentTree;
|
|
592
|
+
/** Data scopes for expression evaluation */
|
|
593
|
+
scopes: Partial<ScopeData>;
|
|
594
|
+
/** Runtime atom registry — maps type names to React components */
|
|
595
|
+
atoms?: AtomRegistry;
|
|
596
|
+
/** Event handlers */
|
|
597
|
+
onEvent?: (eventName: string, payload?: unknown) => void;
|
|
598
|
+
/** Error boundary fallback */
|
|
599
|
+
fallback?: React__default.ReactNode;
|
|
600
|
+
}
|
|
601
|
+
declare const ComponentTreeRenderer: React__default.FC<ComponentTreeRendererProps>;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* DevPlayer — Development shell for previewing workflow component trees.
|
|
605
|
+
*
|
|
606
|
+
* Provides:
|
|
607
|
+
* - ComponentTreeRenderer with built-in atoms
|
|
608
|
+
* - Scope inspector panel (collapsible)
|
|
609
|
+
* - Event log
|
|
610
|
+
* - HMR integration (listens to __mm_dev WebSocket for live reload)
|
|
611
|
+
* - Error boundary with dev-friendly error display
|
|
612
|
+
*/
|
|
613
|
+
|
|
614
|
+
interface DevPlayerProps {
|
|
615
|
+
/** The component tree to render */
|
|
616
|
+
tree: ComponentTree;
|
|
617
|
+
/** Data scopes for expression evaluation */
|
|
618
|
+
scopes?: Partial<ScopeData>;
|
|
619
|
+
/** Additional atoms (merged with built-ins; overrides win) */
|
|
620
|
+
atoms?: AtomRegistry;
|
|
621
|
+
/** Title shown in the dev chrome */
|
|
622
|
+
title?: string;
|
|
623
|
+
/** Hide the dev toolbar (render tree only) */
|
|
624
|
+
bare?: boolean;
|
|
625
|
+
/** WebSocket URL for HMR (default: auto-detect from window.location) */
|
|
626
|
+
wsUrl?: string;
|
|
627
|
+
/** Called when the tree is reloaded via HMR */
|
|
628
|
+
onReload?: () => void;
|
|
629
|
+
/** Called on every atom event */
|
|
630
|
+
onEvent?: (eventName: string, payload?: unknown) => void;
|
|
631
|
+
}
|
|
632
|
+
declare const DevPlayer: React__default.FC<DevPlayerProps>;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Built-in atom components for the standalone player.
|
|
636
|
+
*
|
|
637
|
+
* These are minimal HTML-based implementations of the core layout and
|
|
638
|
+
* display atoms. Projects can override any of these via the AtomRegistry.
|
|
639
|
+
*/
|
|
640
|
+
|
|
641
|
+
declare const builtinAtoms: AtomRegistry;
|
|
642
|
+
|
|
643
|
+
export { type StateDefinition as $, type ApiResolverConfig as A, type PlayerResolver as B, ComponentTreeRenderer as C, DevPlayer as D, ExperienceRenderer as E, type PlayerAuth as F, type PlayerRouter as G, type ScopeData as H, type InstanceData as I, type ActionScope as J, type AtomRegistryInterface as K, type ExprClass$1 as L, type BindingClass as M, setWasmModule as N, classifyBinding as O, PlayerProvider as P, type BuildScopeOptions as Q, type DataSource as R, ScopeContext as S, type DataSourceResult as T, type ApiDataSource as U, type StaticDataSource as V, type WorkflowDataSource as W, type RefDataSource as X, type WorkflowDefinition as Y, type WorkflowInstance as Z, type FieldDefinition as _, type ExperienceRendererProps as a, type TransitionDefinition as a0, type RoleDefinition as a1, type ActionDefinition as a2, type TransitionInfo as a3, type TransitionResult as a4, type QueryParams as a5, type QueryResult as a6, type ExpressionEvaluator as a7, type FacetEntry as a8, type PlayerProviderProps as b, type PlayerContextValue as c, createApiResolver as d, evaluateExpression as e, builtinFunctions as f, resolveAllBindings as g, buildActionScope as h, buildEvalContext as i, useScope as j, buildScope as k, buildLoopScope as l, mergeScope as m, AtomRegistryImpl as n, createCoreAtomRegistry as o, mergeRegistries as p, type ComponentTreeRendererProps as q, resolveBinding as r, type DevPlayerProps as s, builtinAtoms as t, usePlayerContext as u, type ComponentNode as v, type ComponentTree as w, type AtomComponent as x, type AtomRegistry as y, type ExperienceNode as z };
|