@almadar/ui 2.1.11 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-7NEWMNNU.js → chunk-3JGAROCW.js} +2 -0
- package/dist/{chunk-6OACETQB.js → chunk-42WRQA7T.js} +2 -2
- package/dist/{chunk-BTXQJGFB.js → chunk-DKQN5FVU.js} +1 -1
- package/dist/{chunk-JLEMVREZ.js → chunk-GOZKH7QW.js} +6 -3
- package/dist/{chunk-CTNDYHXY.js → chunk-HWZL7IZG.js} +1981 -640
- package/dist/chunk-K2D5D3WK.js +1033 -0
- package/dist/chunk-TSETXL2E.js +103 -0
- package/dist/components/index.d.ts +454 -34
- package/dist/components/index.js +227 -148
- package/dist/components/organisms/game/three/index.d.ts +7 -1
- package/dist/context/index.d.ts +2 -2
- package/dist/context/index.js +3 -3
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +4 -3
- package/dist/locales/index.js +1 -102
- package/dist/providers/index.js +7 -6
- package/dist/renderer/index.d.ts +1 -1
- package/dist/renderer/index.js +1 -613
- package/dist/{useUISlots-D0mttBSP.d.ts → useUISlots-BBjNvQtb.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-PL7MD6GF.js +0 -426
package/dist/renderer/index.js
CHANGED
|
@@ -1,614 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { OfflineExecutor, createOfflineExecutor, executeClientEffects, filterEffectsByType, getEmitEffects, getNavigateEffects, getNotifyEffects, getRenderUIEffects, parseClientEffect, parseClientEffects, useOfflineExecutor } from '../chunk-PL7MD6GF.js';
|
|
1
|
+
export { ALL_SLOTS, ClientEffectConfigContext, ClientEffectConfigProvider, NavigationProvider, OfflineExecutor, SLOT_DEFINITIONS, createFetchedDataContext, createOfflineExecutor, executeClientEffects, extractRouteParams, filterEffectsByType, findPageByName, findPageByPath, getAllPages, getDefaultPage, getEmitEffects, getInlineSlots, getKnownPatterns, getNavigateEffects, getNotifyEffects, getPatternDefinition, getPatternMapping, getPatternsByCategory, getPortalSlots, getRenderUIEffects, getSlotDefinition, getSlotsByType, hasEntities, initializePatternResolver, initializePatterns, isInlineSlot, isKnownPattern, isPortalSlot, matchPath, mergeDataContexts, parseClientEffect, parseClientEffects, pathMatches, resolveEntityById, resolveEntityCount, resolveEntityData, resolveEntityDataWithQuery, resolvePattern, setComponentMapping, setPatternRegistry, useActivePage, useClientEffectConfig, useClientEffectConfigOptional, useClientEffects, useInitPayload, useNavigateTo, useNavigation, useNavigationId, useNavigationState, useOfflineExecutor } from '../chunk-K2D5D3WK.js';
|
|
3
2
|
import '../chunk-PKBMQBKP.js';
|
|
4
|
-
import { createContext, useRef, useCallback, useEffect, useContext, useMemo, useState } from 'react';
|
|
5
|
-
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { componentMapping as componentMapping$1, patternsRegistry } from '@almadar/patterns';
|
|
7
|
-
|
|
8
|
-
// renderer/pattern-resolver.ts
|
|
9
|
-
var componentMapping = {};
|
|
10
|
-
var patternRegistry = {};
|
|
11
|
-
function initializePatternResolver(config) {
|
|
12
|
-
componentMapping = config.componentMapping;
|
|
13
|
-
patternRegistry = config.patternRegistry;
|
|
14
|
-
}
|
|
15
|
-
function setComponentMapping(mapping) {
|
|
16
|
-
componentMapping = mapping;
|
|
17
|
-
}
|
|
18
|
-
function setPatternRegistry(registry) {
|
|
19
|
-
patternRegistry = registry;
|
|
20
|
-
}
|
|
21
|
-
function resolvePattern(config) {
|
|
22
|
-
const { type, ...props } = config;
|
|
23
|
-
const mapping = componentMapping[type];
|
|
24
|
-
if (!mapping) {
|
|
25
|
-
if (Object.keys(componentMapping).length === 0) {
|
|
26
|
-
console.warn(
|
|
27
|
-
"[PatternResolver] Component mapping not initialized. Call initializePatternResolver() at app startup."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
throw new Error(`Unknown pattern type: ${type}`);
|
|
31
|
-
}
|
|
32
|
-
if (mapping.deprecated) {
|
|
33
|
-
console.warn(
|
|
34
|
-
`[PatternResolver] Pattern "${type}" is deprecated.` + (mapping.replacedBy ? ` Use "${mapping.replacedBy}" instead.` : "")
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
const validatedProps = validatePatternProps(type, props);
|
|
38
|
-
return {
|
|
39
|
-
component: mapping.component,
|
|
40
|
-
importPath: mapping.importPath,
|
|
41
|
-
category: mapping.category,
|
|
42
|
-
validatedProps
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function validatePatternProps(patternType, props) {
|
|
46
|
-
const definition = patternRegistry[patternType];
|
|
47
|
-
if (!definition || !definition.propsSchema) {
|
|
48
|
-
return props;
|
|
49
|
-
}
|
|
50
|
-
const validated = { ...props };
|
|
51
|
-
const schema = definition.propsSchema;
|
|
52
|
-
for (const [propName, propDef] of Object.entries(schema)) {
|
|
53
|
-
if (propDef.required && !(propName in validated)) {
|
|
54
|
-
console.warn(
|
|
55
|
-
`[PatternResolver] Missing required prop "${propName}" for pattern "${patternType}"`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return validated;
|
|
60
|
-
}
|
|
61
|
-
function isKnownPattern(type) {
|
|
62
|
-
return type in componentMapping;
|
|
63
|
-
}
|
|
64
|
-
function getKnownPatterns() {
|
|
65
|
-
return Object.keys(componentMapping);
|
|
66
|
-
}
|
|
67
|
-
function getPatternsByCategory(category) {
|
|
68
|
-
return Object.entries(componentMapping).filter(([, mapping]) => mapping.category === category).map(([type]) => type);
|
|
69
|
-
}
|
|
70
|
-
function getPatternMapping(type) {
|
|
71
|
-
return componentMapping[type];
|
|
72
|
-
}
|
|
73
|
-
function getPatternDefinition(type) {
|
|
74
|
-
return patternRegistry[type];
|
|
75
|
-
}
|
|
76
|
-
function useClientEffects(effects, options) {
|
|
77
|
-
const {
|
|
78
|
-
enabled = true,
|
|
79
|
-
debug = false,
|
|
80
|
-
onComplete,
|
|
81
|
-
...config
|
|
82
|
-
} = options;
|
|
83
|
-
const executedRef = useRef(/* @__PURE__ */ new Set());
|
|
84
|
-
const executingRef = useRef(false);
|
|
85
|
-
const executedCountRef = useRef(0);
|
|
86
|
-
const getEffectKey = useCallback((effect) => {
|
|
87
|
-
return JSON.stringify(effect);
|
|
88
|
-
}, []);
|
|
89
|
-
const execute = useCallback((effectsToExecute) => {
|
|
90
|
-
if (executingRef.current || effectsToExecute.length === 0) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
executingRef.current = true;
|
|
94
|
-
const newEffects = effectsToExecute.filter((effect) => {
|
|
95
|
-
const key = getEffectKey(effect);
|
|
96
|
-
if (executedRef.current.has(key)) {
|
|
97
|
-
if (debug) {
|
|
98
|
-
console.log("[useClientEffects] Skipping duplicate effect:", effect);
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
103
|
-
});
|
|
104
|
-
if (newEffects.length === 0) {
|
|
105
|
-
executingRef.current = false;
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (debug) {
|
|
109
|
-
console.log("[useClientEffects] Executing effects:", newEffects);
|
|
110
|
-
}
|
|
111
|
-
newEffects.forEach((effect) => {
|
|
112
|
-
executedRef.current.add(getEffectKey(effect));
|
|
113
|
-
});
|
|
114
|
-
executeClientEffects(newEffects, {
|
|
115
|
-
...config,
|
|
116
|
-
onComplete: () => {
|
|
117
|
-
executedCountRef.current = newEffects.length;
|
|
118
|
-
executingRef.current = false;
|
|
119
|
-
onComplete?.();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}, [config, debug, getEffectKey, onComplete]);
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (!enabled || !effects || effects.length === 0) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
execute(effects);
|
|
128
|
-
}, [effects, enabled, execute]);
|
|
129
|
-
const prevEffectsRef = useRef(void 0);
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (effects !== prevEffectsRef.current) {
|
|
132
|
-
prevEffectsRef.current = effects;
|
|
133
|
-
}
|
|
134
|
-
}, [effects]);
|
|
135
|
-
return {
|
|
136
|
-
executedCount: executedCountRef.current,
|
|
137
|
-
executing: executingRef.current,
|
|
138
|
-
execute
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
var ClientEffectConfigContext = createContext(null);
|
|
142
|
-
var ClientEffectConfigProvider = ClientEffectConfigContext.Provider;
|
|
143
|
-
function useClientEffectConfig() {
|
|
144
|
-
const context = useContext(ClientEffectConfigContext);
|
|
145
|
-
if (!context) {
|
|
146
|
-
throw new Error(
|
|
147
|
-
"useClientEffectConfig must be used within a ClientEffectConfigProvider. Make sure your component tree is wrapped with OrbitalProvider."
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
return context;
|
|
151
|
-
}
|
|
152
|
-
function useClientEffectConfigOptional() {
|
|
153
|
-
return useContext(ClientEffectConfigContext);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// renderer/data-resolver.ts
|
|
157
|
-
function resolveEntityData(entityName, context) {
|
|
158
|
-
if (context.fetchedData && entityName in context.fetchedData) {
|
|
159
|
-
const data = context.fetchedData[entityName];
|
|
160
|
-
return {
|
|
161
|
-
data: Array.isArray(data) ? data : [],
|
|
162
|
-
loading: false
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
if (context.entityStore) {
|
|
166
|
-
try {
|
|
167
|
-
const data = context.entityStore.getRecords(entityName);
|
|
168
|
-
return {
|
|
169
|
-
data: Array.isArray(data) ? data : [],
|
|
170
|
-
loading: false
|
|
171
|
-
};
|
|
172
|
-
} catch (error) {
|
|
173
|
-
console.warn(
|
|
174
|
-
`[DataResolver] Error getting records from entity store for "${entityName}":`,
|
|
175
|
-
error
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
const hasAnySources = context.fetchedData || context.entityStore;
|
|
180
|
-
return {
|
|
181
|
-
data: [],
|
|
182
|
-
loading: !hasAnySources
|
|
183
|
-
// Only loading if no sources configured
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function resolveEntityDataWithQuery(entityName, queryRef, context) {
|
|
187
|
-
const resolution = resolveEntityData(entityName, context);
|
|
188
|
-
if (!queryRef || !context.querySingleton) {
|
|
189
|
-
return resolution;
|
|
190
|
-
}
|
|
191
|
-
try {
|
|
192
|
-
const filters = context.querySingleton.getFilters(queryRef);
|
|
193
|
-
const filteredData = applyFilters(resolution.data, filters);
|
|
194
|
-
return {
|
|
195
|
-
...resolution,
|
|
196
|
-
data: filteredData
|
|
197
|
-
};
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.warn(
|
|
200
|
-
`[DataResolver] Error applying query filters for "${queryRef}":`,
|
|
201
|
-
error
|
|
202
|
-
);
|
|
203
|
-
return resolution;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function applyFilters(data, filters) {
|
|
207
|
-
if (!filters || Object.keys(filters).length === 0) {
|
|
208
|
-
return data;
|
|
209
|
-
}
|
|
210
|
-
return data.filter((item) => {
|
|
211
|
-
if (typeof item !== "object" || item === null) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
const record = item;
|
|
215
|
-
return Object.entries(filters).every(([key, value]) => {
|
|
216
|
-
if (value === void 0 || value === null) {
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
const recordValue = record[key];
|
|
220
|
-
if (Array.isArray(value)) {
|
|
221
|
-
return value.includes(recordValue);
|
|
222
|
-
}
|
|
223
|
-
if (typeof value === "string" && typeof recordValue === "string") {
|
|
224
|
-
if (value.startsWith("*") && value.endsWith("*")) {
|
|
225
|
-
const pattern = value.slice(1, -1);
|
|
226
|
-
return recordValue.toLowerCase().includes(pattern.toLowerCase());
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return recordValue === value;
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
function resolveEntityById(entityName, id, context) {
|
|
234
|
-
const { data } = resolveEntityData(entityName, context);
|
|
235
|
-
return data.find((item) => {
|
|
236
|
-
if (typeof item !== "object" || item === null) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
const record = item;
|
|
240
|
-
return record.id === id || record._id === id;
|
|
241
|
-
}) ?? null;
|
|
242
|
-
}
|
|
243
|
-
function resolveEntityCount(entityName, context, filters) {
|
|
244
|
-
const { data } = resolveEntityData(entityName, context);
|
|
245
|
-
if (filters) {
|
|
246
|
-
return applyFilters(data, filters).length;
|
|
247
|
-
}
|
|
248
|
-
return data.length;
|
|
249
|
-
}
|
|
250
|
-
function hasEntities(entityName, context) {
|
|
251
|
-
const { data } = resolveEntityData(entityName, context);
|
|
252
|
-
return data.length > 0;
|
|
253
|
-
}
|
|
254
|
-
function createFetchedDataContext(data) {
|
|
255
|
-
return { fetchedData: data };
|
|
256
|
-
}
|
|
257
|
-
function mergeDataContexts(...contexts) {
|
|
258
|
-
const merged = {};
|
|
259
|
-
for (const context of contexts) {
|
|
260
|
-
if (context.fetchedData) {
|
|
261
|
-
merged.fetchedData = {
|
|
262
|
-
...merged.fetchedData,
|
|
263
|
-
...context.fetchedData
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
if (context.entityStore) {
|
|
267
|
-
merged.entityStore = context.entityStore;
|
|
268
|
-
}
|
|
269
|
-
if (context.querySingleton) {
|
|
270
|
-
merged.querySingleton = context.querySingleton;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return merged;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// renderer/slot-definitions.ts
|
|
277
|
-
var SLOT_DEFINITIONS = {
|
|
278
|
-
// -------------------------------------------------------------------------
|
|
279
|
-
// Inline Slots - Render in place within the component tree
|
|
280
|
-
// -------------------------------------------------------------------------
|
|
281
|
-
main: {
|
|
282
|
-
name: "main",
|
|
283
|
-
type: "inline"
|
|
284
|
-
},
|
|
285
|
-
sidebar: {
|
|
286
|
-
name: "sidebar",
|
|
287
|
-
type: "inline"
|
|
288
|
-
},
|
|
289
|
-
// -------------------------------------------------------------------------
|
|
290
|
-
// Portal Slots - Render to document.body via React Portal
|
|
291
|
-
// -------------------------------------------------------------------------
|
|
292
|
-
modal: {
|
|
293
|
-
name: "modal",
|
|
294
|
-
type: "portal",
|
|
295
|
-
portalTarget: "body",
|
|
296
|
-
zIndex: 1e3
|
|
297
|
-
},
|
|
298
|
-
drawer: {
|
|
299
|
-
name: "drawer",
|
|
300
|
-
type: "portal",
|
|
301
|
-
portalTarget: "body",
|
|
302
|
-
zIndex: 900
|
|
303
|
-
},
|
|
304
|
-
overlay: {
|
|
305
|
-
name: "overlay",
|
|
306
|
-
type: "portal",
|
|
307
|
-
portalTarget: "body",
|
|
308
|
-
zIndex: 1100
|
|
309
|
-
},
|
|
310
|
-
center: {
|
|
311
|
-
name: "center",
|
|
312
|
-
type: "portal",
|
|
313
|
-
portalTarget: "body",
|
|
314
|
-
zIndex: 1e3
|
|
315
|
-
},
|
|
316
|
-
toast: {
|
|
317
|
-
name: "toast",
|
|
318
|
-
type: "portal",
|
|
319
|
-
portalTarget: "body",
|
|
320
|
-
zIndex: 1200
|
|
321
|
-
},
|
|
322
|
-
// -------------------------------------------------------------------------
|
|
323
|
-
// Game HUD Slots - Portal for game overlay UI
|
|
324
|
-
// -------------------------------------------------------------------------
|
|
325
|
-
"hud-top": {
|
|
326
|
-
name: "hud-top",
|
|
327
|
-
type: "portal",
|
|
328
|
-
portalTarget: "body",
|
|
329
|
-
zIndex: 500
|
|
330
|
-
},
|
|
331
|
-
"hud-bottom": {
|
|
332
|
-
name: "hud-bottom",
|
|
333
|
-
type: "portal",
|
|
334
|
-
portalTarget: "body",
|
|
335
|
-
zIndex: 500
|
|
336
|
-
},
|
|
337
|
-
floating: {
|
|
338
|
-
name: "floating",
|
|
339
|
-
type: "portal",
|
|
340
|
-
portalTarget: "body",
|
|
341
|
-
zIndex: 800
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
function getSlotDefinition(slot) {
|
|
345
|
-
return SLOT_DEFINITIONS[slot];
|
|
346
|
-
}
|
|
347
|
-
function isPortalSlot(slot) {
|
|
348
|
-
return SLOT_DEFINITIONS[slot]?.type === "portal";
|
|
349
|
-
}
|
|
350
|
-
function isInlineSlot(slot) {
|
|
351
|
-
return SLOT_DEFINITIONS[slot]?.type === "inline";
|
|
352
|
-
}
|
|
353
|
-
function getSlotsByType(type) {
|
|
354
|
-
return Object.entries(SLOT_DEFINITIONS).filter(([, def]) => def.type === type).map(([name]) => name);
|
|
355
|
-
}
|
|
356
|
-
function getInlineSlots() {
|
|
357
|
-
return getSlotsByType("inline");
|
|
358
|
-
}
|
|
359
|
-
function getPortalSlots() {
|
|
360
|
-
return getSlotsByType("portal");
|
|
361
|
-
}
|
|
362
|
-
var ALL_SLOTS = Object.keys(SLOT_DEFINITIONS);
|
|
363
|
-
function matchPath(pattern, path) {
|
|
364
|
-
const normalizeSegment = (p) => {
|
|
365
|
-
let normalized = p.trim();
|
|
366
|
-
if (!normalized.startsWith("/")) normalized = "/" + normalized;
|
|
367
|
-
if (normalized.length > 1 && normalized.endsWith("/")) {
|
|
368
|
-
normalized = normalized.slice(0, -1);
|
|
369
|
-
}
|
|
370
|
-
return normalized;
|
|
371
|
-
};
|
|
372
|
-
const normalizedPattern = normalizeSegment(pattern);
|
|
373
|
-
const normalizedPath = normalizeSegment(path);
|
|
374
|
-
const patternParts = normalizedPattern.split("/").filter(Boolean);
|
|
375
|
-
const pathParts = normalizedPath.split("/").filter(Boolean);
|
|
376
|
-
if (patternParts.length !== pathParts.length) {
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
const params = {};
|
|
380
|
-
for (let i = 0; i < patternParts.length; i++) {
|
|
381
|
-
const patternPart = patternParts[i];
|
|
382
|
-
const pathPart = pathParts[i];
|
|
383
|
-
if (patternPart.startsWith(":")) {
|
|
384
|
-
const paramName = patternPart.slice(1);
|
|
385
|
-
params[paramName] = decodeURIComponent(pathPart);
|
|
386
|
-
} else if (patternPart !== pathPart) {
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
return params;
|
|
391
|
-
}
|
|
392
|
-
function extractRouteParams(pattern, path) {
|
|
393
|
-
return matchPath(pattern, path) || {};
|
|
394
|
-
}
|
|
395
|
-
function pathMatches(pattern, path) {
|
|
396
|
-
return matchPath(pattern, path) !== null;
|
|
397
|
-
}
|
|
398
|
-
function isInlineOrbital(orbital) {
|
|
399
|
-
return "name" in orbital && typeof orbital.name === "string";
|
|
400
|
-
}
|
|
401
|
-
function isInlinePage(page) {
|
|
402
|
-
return typeof page === "object" && page !== null && "name" in page && typeof page.name === "string";
|
|
403
|
-
}
|
|
404
|
-
function findPageByPath(schema, path) {
|
|
405
|
-
if (!schema.orbitals) return null;
|
|
406
|
-
for (const orbital of schema.orbitals) {
|
|
407
|
-
if (!isInlineOrbital(orbital)) continue;
|
|
408
|
-
if (!orbital.pages) continue;
|
|
409
|
-
for (const pageRef of orbital.pages) {
|
|
410
|
-
if (!isInlinePage(pageRef)) continue;
|
|
411
|
-
const page = pageRef;
|
|
412
|
-
const pagePath = page.path;
|
|
413
|
-
if (!pagePath) continue;
|
|
414
|
-
const params = matchPath(pagePath, path);
|
|
415
|
-
if (params !== null) {
|
|
416
|
-
return { page, params, orbitalName: orbital.name };
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
function findPageByName(schema, pageName) {
|
|
423
|
-
if (!schema.orbitals) return null;
|
|
424
|
-
for (const orbital of schema.orbitals) {
|
|
425
|
-
if (!isInlineOrbital(orbital)) continue;
|
|
426
|
-
if (!orbital.pages) continue;
|
|
427
|
-
for (const pageRef of orbital.pages) {
|
|
428
|
-
if (!isInlinePage(pageRef)) continue;
|
|
429
|
-
const page = pageRef;
|
|
430
|
-
if (page.name === pageName) {
|
|
431
|
-
return { page, orbitalName: orbital.name };
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
return null;
|
|
436
|
-
}
|
|
437
|
-
function getDefaultPage(schema) {
|
|
438
|
-
if (!schema.orbitals) return null;
|
|
439
|
-
for (const orbital of schema.orbitals) {
|
|
440
|
-
if (!isInlineOrbital(orbital)) continue;
|
|
441
|
-
if (!orbital.pages) continue;
|
|
442
|
-
for (const pageRef of orbital.pages) {
|
|
443
|
-
if (isInlinePage(pageRef)) {
|
|
444
|
-
return { page: pageRef, orbitalName: orbital.name };
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
return null;
|
|
449
|
-
}
|
|
450
|
-
function getAllPages(schema) {
|
|
451
|
-
const pages = [];
|
|
452
|
-
if (!schema.orbitals) return pages;
|
|
453
|
-
for (const orbital of schema.orbitals) {
|
|
454
|
-
if (!isInlineOrbital(orbital)) continue;
|
|
455
|
-
if (!orbital.pages) continue;
|
|
456
|
-
for (const pageRef of orbital.pages) {
|
|
457
|
-
if (isInlinePage(pageRef)) {
|
|
458
|
-
pages.push({ page: pageRef, orbitalName: orbital.name });
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return pages;
|
|
463
|
-
}
|
|
464
|
-
var NavigationContext = createContext(null);
|
|
465
|
-
function NavigationProvider({
|
|
466
|
-
schema,
|
|
467
|
-
initialPage,
|
|
468
|
-
updateUrl = true,
|
|
469
|
-
onNavigate,
|
|
470
|
-
children
|
|
471
|
-
}) {
|
|
472
|
-
const initialState = useMemo(() => {
|
|
473
|
-
let page = null;
|
|
474
|
-
let path = "/";
|
|
475
|
-
if (initialPage) {
|
|
476
|
-
const found = findPageByName(schema, initialPage);
|
|
477
|
-
if (found) {
|
|
478
|
-
page = found.page;
|
|
479
|
-
path = page.path || "/";
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
if (!page) {
|
|
483
|
-
const defaultPage = getDefaultPage(schema);
|
|
484
|
-
if (defaultPage) {
|
|
485
|
-
page = defaultPage.page;
|
|
486
|
-
path = page.path || "/";
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
return {
|
|
490
|
-
activePage: page?.name || "",
|
|
491
|
-
currentPath: path,
|
|
492
|
-
initPayload: {},
|
|
493
|
-
navigationId: 0
|
|
494
|
-
};
|
|
495
|
-
}, [schema, initialPage]);
|
|
496
|
-
const [state, setState] = useState(initialState);
|
|
497
|
-
const navigateTo = useCallback((path, payload) => {
|
|
498
|
-
const result = findPageByPath(schema, path);
|
|
499
|
-
if (!result) {
|
|
500
|
-
console.error(`[Navigation] No page found for path: ${path}`);
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
const { page, params } = result;
|
|
504
|
-
const finalPayload = { ...params, ...payload };
|
|
505
|
-
console.log("[Navigation] Navigating to:", {
|
|
506
|
-
path,
|
|
507
|
-
page: page.name,
|
|
508
|
-
params,
|
|
509
|
-
payload,
|
|
510
|
-
finalPayload
|
|
511
|
-
});
|
|
512
|
-
setState((prev) => ({
|
|
513
|
-
activePage: page.name,
|
|
514
|
-
currentPath: path,
|
|
515
|
-
initPayload: finalPayload,
|
|
516
|
-
navigationId: prev.navigationId + 1
|
|
517
|
-
}));
|
|
518
|
-
if (updateUrl && typeof window !== "undefined") {
|
|
519
|
-
try {
|
|
520
|
-
window.history.pushState(finalPayload, "", path);
|
|
521
|
-
} catch (e) {
|
|
522
|
-
console.warn("[Navigation] Could not update URL:", e);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
if (onNavigate) {
|
|
526
|
-
onNavigate(page.name, path, finalPayload);
|
|
527
|
-
}
|
|
528
|
-
}, [schema, updateUrl, onNavigate]);
|
|
529
|
-
const navigateToPage = useCallback((pageName, payload) => {
|
|
530
|
-
const result = findPageByName(schema, pageName);
|
|
531
|
-
if (!result) {
|
|
532
|
-
console.error(`[Navigation] No page found with name: ${pageName}`);
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
const { page } = result;
|
|
536
|
-
const path = page.path || `/${pageName.toLowerCase()}`;
|
|
537
|
-
console.log("[Navigation] Navigating to page:", {
|
|
538
|
-
pageName,
|
|
539
|
-
path,
|
|
540
|
-
payload
|
|
541
|
-
});
|
|
542
|
-
setState((prev) => ({
|
|
543
|
-
activePage: page.name,
|
|
544
|
-
currentPath: path,
|
|
545
|
-
initPayload: payload || {},
|
|
546
|
-
navigationId: prev.navigationId + 1
|
|
547
|
-
}));
|
|
548
|
-
if (updateUrl && typeof window !== "undefined") {
|
|
549
|
-
try {
|
|
550
|
-
window.history.pushState(payload || {}, "", path);
|
|
551
|
-
} catch (e) {
|
|
552
|
-
console.warn("[Navigation] Could not update URL:", e);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (onNavigate) {
|
|
556
|
-
onNavigate(page.name, path, payload || {});
|
|
557
|
-
}
|
|
558
|
-
}, [schema, updateUrl, onNavigate]);
|
|
559
|
-
const contextValue = useMemo(() => ({
|
|
560
|
-
state,
|
|
561
|
-
navigateTo,
|
|
562
|
-
navigateToPage,
|
|
563
|
-
schema,
|
|
564
|
-
isReady: !!state.activePage
|
|
565
|
-
}), [state, navigateTo, navigateToPage, schema]);
|
|
566
|
-
return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: contextValue, children });
|
|
567
|
-
}
|
|
568
|
-
function useNavigation() {
|
|
569
|
-
return useContext(NavigationContext);
|
|
570
|
-
}
|
|
571
|
-
function useNavigateTo() {
|
|
572
|
-
const context = useContext(NavigationContext);
|
|
573
|
-
const noOp = useCallback((path, _payload) => {
|
|
574
|
-
console.warn(`[Navigation] navigateTo called outside NavigationProvider. Path: ${path}`);
|
|
575
|
-
}, []);
|
|
576
|
-
return context?.navigateTo || noOp;
|
|
577
|
-
}
|
|
578
|
-
function useNavigationState() {
|
|
579
|
-
const context = useContext(NavigationContext);
|
|
580
|
-
return context?.state || null;
|
|
581
|
-
}
|
|
582
|
-
function useInitPayload() {
|
|
583
|
-
const context = useContext(NavigationContext);
|
|
584
|
-
return context?.state.initPayload || {};
|
|
585
|
-
}
|
|
586
|
-
function useActivePage() {
|
|
587
|
-
const context = useContext(NavigationContext);
|
|
588
|
-
return context?.state.activePage || null;
|
|
589
|
-
}
|
|
590
|
-
function useNavigationId() {
|
|
591
|
-
const context = useContext(NavigationContext);
|
|
592
|
-
return context?.state.navigationId || 0;
|
|
593
|
-
}
|
|
594
|
-
function initializePatterns() {
|
|
595
|
-
console.log("[PatternResolver] initializePatterns called");
|
|
596
|
-
console.log("[PatternResolver] componentMappingJson:", componentMapping$1);
|
|
597
|
-
console.log("[PatternResolver] registryJson keys:", Object.keys(patternsRegistry));
|
|
598
|
-
const componentMappingData = componentMapping$1;
|
|
599
|
-
const componentMapping2 = componentMappingData.mappings || {};
|
|
600
|
-
console.log("[PatternResolver] Extracted mappings count:", Object.keys(componentMapping2).length);
|
|
601
|
-
console.log("[PatternResolver] Sample mappings:", Object.keys(componentMapping2).slice(0, 5));
|
|
602
|
-
const registryData = patternsRegistry;
|
|
603
|
-
const patternRegistry2 = registryData.patterns || {};
|
|
604
|
-
console.log("[PatternResolver] Extracted patterns count:", Object.keys(patternRegistry2).length);
|
|
605
|
-
initializePatternResolver({
|
|
606
|
-
componentMapping: componentMapping2,
|
|
607
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
608
|
-
patternRegistry: patternRegistry2
|
|
609
|
-
});
|
|
610
|
-
console.log(`[PatternResolver] Initialized with ${Object.keys(componentMapping2).length} component mappings and ${Object.keys(patternRegistry2).length} pattern definitions`);
|
|
611
|
-
return Object.keys(componentMapping2).length;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
export { ALL_SLOTS, ClientEffectConfigContext, ClientEffectConfigProvider, NavigationProvider, SLOT_DEFINITIONS, createFetchedDataContext, extractRouteParams, findPageByName, findPageByPath, getAllPages, getDefaultPage, getInlineSlots, getKnownPatterns, getPatternDefinition, getPatternMapping, getPatternsByCategory, getPortalSlots, getSlotDefinition, getSlotsByType, hasEntities, initializePatternResolver, initializePatterns, isInlineSlot, isKnownPattern, isPortalSlot, matchPath, mergeDataContexts, pathMatches, resolveEntityById, resolveEntityCount, resolveEntityData, resolveEntityDataWithQuery, resolvePattern, setComponentMapping, setPatternRegistry, useActivePage, useClientEffectConfig, useClientEffectConfigOptional, useClientEffects, useInitPayload, useNavigateTo, useNavigation, useNavigationId, useNavigationState };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Valid UI slot names
|
|
3
3
|
*/
|
|
4
|
-
type UISlot = 'main' | 'sidebar' | 'modal' | 'drawer' | 'overlay' | 'center' | 'toast' | 'hud-top' | 'hud-bottom' | 'floating';
|
|
4
|
+
type UISlot = 'main' | 'sidebar' | 'modal' | 'drawer' | 'overlay' | 'center' | 'toast' | 'hud-top' | 'hud-bottom' | 'hud-left' | 'hud-right' | 'floating';
|
|
5
5
|
/**
|
|
6
6
|
* Animation types for slot transitions
|
|
7
7
|
*/
|