@almadar/ui 5.112.0 → 5.113.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/avl/index.cjs +59 -21
- package/dist/avl/index.js +59 -21
- package/dist/{avl-schema-parser-DKRm-nyh.d.cts → avl-schema-parser-B8Onmfsu.d.cts} +2 -220
- package/dist/{avl-schema-parser-DKRm-nyh.d.ts → avl-schema-parser-B8Onmfsu.d.ts} +2 -220
- package/dist/{cn-BbPvQLHt.d.ts → cn-BkQrMR01.d.cts} +2 -1
- package/dist/{cn-BbPvQLHt.d.cts → cn-CTEFm9PC.d.ts} +2 -1
- package/dist/components/index.cjs +13 -8
- package/dist/components/index.d.cts +5 -4
- package/dist/components/index.d.ts +5 -4
- package/dist/components/index.js +13 -8
- package/dist/lib/drawable/three/index.d.cts +3 -2
- package/dist/lib/drawable/three/index.d.ts +3 -2
- package/dist/lib/index.d.cts +2 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/paintDispatch-DR942knx.d.cts +221 -0
- package/dist/paintDispatch-DR942knx.d.ts +221 -0
- package/dist/providers/index.cjs +13 -8
- package/dist/providers/index.js +13 -8
- package/dist/runtime/index.cjs +59 -21
- package/dist/runtime/index.js +59 -21
- package/package.json +2 -2
package/dist/avl/index.cjs
CHANGED
|
@@ -13258,14 +13258,16 @@ function Canvas2D({
|
|
|
13258
13258
|
cameraPos,
|
|
13259
13259
|
bgColor
|
|
13260
13260
|
}) {
|
|
13261
|
+
const instanceId = React90.useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
13262
|
+
function isDrawableLayer(node) {
|
|
13263
|
+
return node.type === "draw-sprite-layer" || node.type === "draw-shape-layer" || node.type === "draw-text-layer";
|
|
13264
|
+
}
|
|
13261
13265
|
const layerSummaries = drawables?.map((d) => {
|
|
13262
|
-
if (!d
|
|
13263
|
-
|
|
13264
|
-
return { type: rec.type, itemsLen: Array.isArray(rec.items) ? rec.items.length : void 0, firstItem: Array.isArray(rec.items) ? rec.items[0] : void 0 };
|
|
13266
|
+
if (!isDrawableLayer(d)) return { type: d.type };
|
|
13267
|
+
return { type: d.type, itemsLen: d.items.length, firstItem: d.items[0] };
|
|
13265
13268
|
});
|
|
13266
|
-
|
|
13269
|
+
canvas2DLog.debug("Canvas2D render", { instanceId, projection, scale, cameraMode: camera, cameraPos: cameraPos ? JSON.stringify(cameraPos) : void 0, drawablesCount: drawables?.length, layerSummaries: layerSummaries ? JSON.stringify(layerSummaries) : void 0 });
|
|
13267
13270
|
const backgroundImage = normalizeBackdrop(backgroundImageRaw);
|
|
13268
|
-
const instanceId = React90.useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
13269
13271
|
const isFree = projection === "free";
|
|
13270
13272
|
const squareGrid = projection === "flat" || isFree || projection === "side";
|
|
13271
13273
|
const layout = projection === "side" ? "free" : projection;
|
|
@@ -13400,7 +13402,7 @@ function Canvas2D({
|
|
|
13400
13402
|
}
|
|
13401
13403
|
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
13402
13404
|
const canvasRect = canvas.getBoundingClientRect();
|
|
13403
|
-
|
|
13405
|
+
canvas2DLog.debug("Canvas2D draw", { instanceId, viewportSize, baseOffsetX, cam: { x: cam.x, y: cam.y, zoom: cam.zoom }, cameraPos: cameraPos ? JSON.stringify(cameraPos) : void 0, containerRect: containerRect ? { width: containerRect.width, height: containerRect.height } : null, canvasRect: canvasRect ? { width: canvasRect.width, height: canvasRect.height } : null });
|
|
13404
13406
|
const painter = createWebPainter(ctx, bumpAtlas);
|
|
13405
13407
|
painter.save();
|
|
13406
13408
|
painter.translate(viewportSize.width / 2, viewportSize.height / 2);
|
|
@@ -13612,6 +13614,7 @@ function Canvas2D({
|
|
|
13612
13614
|
}
|
|
13613
13615
|
);
|
|
13614
13616
|
}
|
|
13617
|
+
var canvas2DLog;
|
|
13615
13618
|
var init_Canvas2D = __esm({
|
|
13616
13619
|
"components/game/molecules/Canvas2D.tsx"() {
|
|
13617
13620
|
"use client";
|
|
@@ -13633,6 +13636,7 @@ var init_Canvas2D = __esm({
|
|
|
13633
13636
|
init_paintDispatch();
|
|
13634
13637
|
init_hitTest();
|
|
13635
13638
|
init_isometric();
|
|
13639
|
+
canvas2DLog = logger.createLogger("almadar:ui:game-canvas");
|
|
13636
13640
|
Canvas2D.displayName = "Canvas2D";
|
|
13637
13641
|
}
|
|
13638
13642
|
});
|
|
@@ -13671,7 +13675,7 @@ function Canvas({
|
|
|
13671
13675
|
keyMap,
|
|
13672
13676
|
keyUpMap
|
|
13673
13677
|
}) {
|
|
13674
|
-
|
|
13678
|
+
canvasLog.debug("Canvas render", { mode, drawablesCount: drawables?.length, projection, camera: camera ? JSON.stringify(camera) : void 0 });
|
|
13675
13679
|
const zoom = camera?.zoom;
|
|
13676
13680
|
if (mode === "3d") {
|
|
13677
13681
|
const props3d = {
|
|
@@ -13724,7 +13728,7 @@ function Canvas({
|
|
|
13724
13728
|
}
|
|
13725
13729
|
);
|
|
13726
13730
|
}
|
|
13727
|
-
var Canvas3DHost;
|
|
13731
|
+
var Canvas3DHost, canvasLog;
|
|
13728
13732
|
var init_Canvas = __esm({
|
|
13729
13733
|
"components/game/molecules/Canvas.tsx"() {
|
|
13730
13734
|
"use client";
|
|
@@ -13732,6 +13736,7 @@ var init_Canvas = __esm({
|
|
|
13732
13736
|
Canvas3DHost = React90.lazy(
|
|
13733
13737
|
() => import('@almadar/ui/components/molecules/game/three').then((m) => ({ default: m.Canvas3DHost }))
|
|
13734
13738
|
);
|
|
13739
|
+
canvasLog = logger.createLogger("almadar:ui:game-canvas");
|
|
13735
13740
|
Canvas.displayName = "Canvas";
|
|
13736
13741
|
}
|
|
13737
13742
|
});
|
|
@@ -50194,6 +50199,8 @@ var flushLog = logger.createLogger("almadar:ui:slot-flush");
|
|
|
50194
50199
|
var stateLog = logger.createLogger("almadar:ui:state-transitions");
|
|
50195
50200
|
var tickLog = logger.createLogger("almadar:ui:tick-effects");
|
|
50196
50201
|
logger.setNamespaceLevel("almadar:ui:tick-effects", "WARN");
|
|
50202
|
+
var sharedEntityLog = logger.createLogger("almadar:ui:shared-entity");
|
|
50203
|
+
logger.setNamespaceLevel("almadar:ui:shared-entity", "WARN");
|
|
50197
50204
|
var SYNC_TICK_OPERATORS = /* @__PURE__ */ new Set([
|
|
50198
50205
|
"set",
|
|
50199
50206
|
"emit",
|
|
@@ -50288,7 +50295,7 @@ function createSharedEntityWriter(binding, tick, traitStatesRef, emit) {
|
|
|
50288
50295
|
function getBindingConfig(binding) {
|
|
50289
50296
|
const raw = binding.config;
|
|
50290
50297
|
const normalized = runtime.normalizeCallSiteConfigToValues(raw);
|
|
50291
|
-
|
|
50298
|
+
sharedEntityLog.debug("getBindingConfig", { traitName: binding.trait.name, rawKeys: raw ? Object.keys(raw) : void 0, hasTiles: raw ? "tiles" in raw : false });
|
|
50292
50299
|
return normalized;
|
|
50293
50300
|
}
|
|
50294
50301
|
function evalFieldDefault(value) {
|
|
@@ -50303,7 +50310,7 @@ function evalFieldDefault(value) {
|
|
|
50303
50310
|
}
|
|
50304
50311
|
}
|
|
50305
50312
|
function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
50306
|
-
|
|
50313
|
+
sharedEntityLog.debug("useTraitStateMachine start", { traitBindingsCount: traitBindings.length, traitNames: traitBindings.map((b) => b.trait.name) });
|
|
50307
50314
|
const eventBus = useEventBus();
|
|
50308
50315
|
const { entities } = providers.useEntitySchema();
|
|
50309
50316
|
const traitConfigsByName = options?.traitConfigsByName;
|
|
@@ -50322,10 +50329,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50322
50329
|
if (!group) {
|
|
50323
50330
|
let defaults;
|
|
50324
50331
|
for (const field of entityDef.fields) {
|
|
50325
|
-
if (field.default !== void 0) {
|
|
50332
|
+
if (field.default !== void 0 && field.default !== null) {
|
|
50326
50333
|
const evaluated = evalFieldDefault(field.default);
|
|
50327
50334
|
if (field.name === "tiles") {
|
|
50328
|
-
|
|
50335
|
+
sharedEntityLog.debug("seed tiles", {
|
|
50336
|
+
linkedEntityName,
|
|
50337
|
+
type: typeof evaluated,
|
|
50338
|
+
length: Array.isArray(evaluated) ? evaluated?.length : void 0,
|
|
50339
|
+
head: Array.isArray(evaluated) && evaluated.length > 0 ? JSON.stringify(evaluated[0]).slice(0, 80) : void 0
|
|
50340
|
+
});
|
|
50329
50341
|
}
|
|
50330
50342
|
(defaults ?? (defaults = {}))[field.name] = evaluated;
|
|
50331
50343
|
}
|
|
@@ -50342,7 +50354,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50342
50354
|
for (const group of sharedGroups.values()) {
|
|
50343
50355
|
if (group.defaults) {
|
|
50344
50356
|
sharedEntityStore.seed(group.storeKey, group.defaults);
|
|
50345
|
-
|
|
50357
|
+
sharedEntityLog.debug("shared-seed", {
|
|
50358
|
+
storeKey: group.storeKey,
|
|
50359
|
+
writers: group.writerBindings.map((b) => b.trait.name),
|
|
50360
|
+
renderers: group.renderBindings.map((b) => b.trait.name),
|
|
50361
|
+
tilesLength: Array.isArray(group.defaults.tiles) ? group.defaults.tiles.length : group.defaults.tiles
|
|
50362
|
+
});
|
|
50346
50363
|
}
|
|
50347
50364
|
}
|
|
50348
50365
|
const sharedKeyByTraitNameRef = React90.useRef(/* @__PURE__ */ new Map());
|
|
@@ -50353,7 +50370,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50353
50370
|
for (const binding of group.renderBindings) map.set(binding.trait.name, group.storeKey);
|
|
50354
50371
|
}
|
|
50355
50372
|
sharedKeyByTraitNameRef.current = map;
|
|
50356
|
-
|
|
50373
|
+
sharedEntityLog.debug("shared-map", { map: Array.from(map.entries()).map(([k, v]) => `${k}->${v}`) });
|
|
50357
50374
|
}, [sharedGroups]);
|
|
50358
50375
|
const manager = React90.useMemo(() => {
|
|
50359
50376
|
const traitDefs = traitBindings.map(toTraitDefinition);
|
|
@@ -50543,7 +50560,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50543
50560
|
const entityId = payload?.entityId;
|
|
50544
50561
|
const sharedKey = sharedKeyByTraitNameRef.current.get(traitName);
|
|
50545
50562
|
if (traitName === "Hero" || traitName === "Authority") {
|
|
50546
|
-
|
|
50563
|
+
sharedEntityLog.debug("executeTransitionEffects sharedKey", { traitName, sharedKey, storeTilesLength: sharedKey ? sharedEntityStore.getSnapshot(sharedKey).tiles?.length : void 0 });
|
|
50547
50564
|
}
|
|
50548
50565
|
let liveEntity;
|
|
50549
50566
|
if (sharedKey !== void 0) {
|
|
@@ -50570,10 +50587,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50570
50587
|
addPattern: (slot, pattern, props) => {
|
|
50571
50588
|
if (traitName === "Hero" && slot === "main" && props && typeof props === "object") {
|
|
50572
50589
|
const canvasChild = Array.isArray(props.children) ? props.children[0] : null;
|
|
50573
|
-
const grandChildren = canvasChild && typeof canvasChild === "object" ? canvasChild.children : null;
|
|
50590
|
+
const grandChildren = canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.children : null;
|
|
50574
50591
|
const firstLayer = Array.isArray(grandChildren) && grandChildren.length > 0 ? grandChildren[0] : null;
|
|
50575
|
-
const firstLayerItems = firstLayer && typeof firstLayer === "object" ? firstLayer.items : null;
|
|
50576
|
-
|
|
50592
|
+
const firstLayerItems = firstLayer && typeof firstLayer === "object" && !Array.isArray(firstLayer) ? firstLayer.items : null;
|
|
50593
|
+
sharedEntityLog.debug("render-ui main slot", {
|
|
50594
|
+
traitName,
|
|
50595
|
+
slot,
|
|
50596
|
+
canvasChildType: canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.type : "none",
|
|
50597
|
+
firstLayerItemsLength: Array.isArray(firstLayerItems) ? firstLayerItems.length : firstLayerItems
|
|
50598
|
+
});
|
|
50577
50599
|
}
|
|
50578
50600
|
const existing = pendingSlots.get(slot) || [];
|
|
50579
50601
|
existing.push({ pattern, props: props || {} });
|
|
@@ -50665,7 +50687,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50665
50687
|
};
|
|
50666
50688
|
}
|
|
50667
50689
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
50668
|
-
|
|
50690
|
+
sharedEntityLog.debug("executeTransitionEffects config tiles", {
|
|
50691
|
+
traitName,
|
|
50692
|
+
tilesType: typeof bindingCtx.config?.tiles,
|
|
50693
|
+
tilesLength: Array.isArray(bindingCtx.config?.tiles) ? bindingCtx.config?.tiles?.length : void 0,
|
|
50694
|
+
configKeys: bindingCtx.config ? Object.keys(bindingCtx.config) : void 0
|
|
50695
|
+
});
|
|
50669
50696
|
}
|
|
50670
50697
|
const effectContext = {
|
|
50671
50698
|
traitName,
|
|
@@ -50684,13 +50711,23 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50684
50711
|
}
|
|
50685
50712
|
};
|
|
50686
50713
|
if (traitName === "Hero") {
|
|
50687
|
-
|
|
50714
|
+
sharedEntityLog.debug("executeTransitionEffects effects summary", {
|
|
50715
|
+
traitName,
|
|
50716
|
+
effectsCount: effects.length,
|
|
50717
|
+
hasRenderUI: typeof handlers.renderUI === "function",
|
|
50718
|
+
effectHeads: effects.map((e) => Array.isArray(e) ? String(e[0]) : "??")
|
|
50719
|
+
});
|
|
50688
50720
|
}
|
|
50689
50721
|
const executor = new runtime.EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
|
|
50690
50722
|
try {
|
|
50691
50723
|
await executor.executeAll(effects);
|
|
50692
50724
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
50693
|
-
|
|
50725
|
+
sharedEntityLog.debug("executeTransitionEffects after executeAll", {
|
|
50726
|
+
traitName,
|
|
50727
|
+
tilesType: typeof liveEntity.tiles,
|
|
50728
|
+
tilesLength: Array.isArray(liveEntity.tiles) ? liveEntity.tiles?.length : void 0,
|
|
50729
|
+
firstTilePos: Array.isArray(liveEntity.tiles) && liveEntity.tiles.length > 0 ? JSON.stringify(liveEntity.tiles[0]).slice(0, 120) : void 0
|
|
50730
|
+
});
|
|
50694
50731
|
}
|
|
50695
50732
|
if (sharedKey !== void 0) {
|
|
50696
50733
|
sharedEntityStore.commit(sharedKey, liveEntity);
|
|
@@ -51438,6 +51475,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
51438
51475
|
hadPrev: prevTraitsRef.current !== void 0
|
|
51439
51476
|
}));
|
|
51440
51477
|
if (refChanged) {
|
|
51478
|
+
navLog.info("page:traits-reset", { traitsCount: Array.isArray(traits2) ? traits2.length : -1 });
|
|
51441
51479
|
uiSlots.clearAll();
|
|
51442
51480
|
initSentRef.current = false;
|
|
51443
51481
|
}
|
package/dist/avl/index.js
CHANGED
|
@@ -13212,14 +13212,16 @@ function Canvas2D({
|
|
|
13212
13212
|
cameraPos,
|
|
13213
13213
|
bgColor
|
|
13214
13214
|
}) {
|
|
13215
|
+
const instanceId = useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
13216
|
+
function isDrawableLayer(node) {
|
|
13217
|
+
return node.type === "draw-sprite-layer" || node.type === "draw-shape-layer" || node.type === "draw-text-layer";
|
|
13218
|
+
}
|
|
13215
13219
|
const layerSummaries = drawables?.map((d) => {
|
|
13216
|
-
if (!d
|
|
13217
|
-
|
|
13218
|
-
return { type: rec.type, itemsLen: Array.isArray(rec.items) ? rec.items.length : void 0, firstItem: Array.isArray(rec.items) ? rec.items[0] : void 0 };
|
|
13220
|
+
if (!isDrawableLayer(d)) return { type: d.type };
|
|
13221
|
+
return { type: d.type, itemsLen: d.items.length, firstItem: d.items[0] };
|
|
13219
13222
|
});
|
|
13220
|
-
|
|
13223
|
+
canvas2DLog.debug("Canvas2D render", { instanceId, projection, scale, cameraMode: camera, cameraPos: cameraPos ? JSON.stringify(cameraPos) : void 0, drawablesCount: drawables?.length, layerSummaries: layerSummaries ? JSON.stringify(layerSummaries) : void 0 });
|
|
13221
13224
|
const backgroundImage = normalizeBackdrop(backgroundImageRaw);
|
|
13222
|
-
const instanceId = useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
13223
13225
|
const isFree = projection === "free";
|
|
13224
13226
|
const squareGrid = projection === "flat" || isFree || projection === "side";
|
|
13225
13227
|
const layout = projection === "side" ? "free" : projection;
|
|
@@ -13354,7 +13356,7 @@ function Canvas2D({
|
|
|
13354
13356
|
}
|
|
13355
13357
|
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
13356
13358
|
const canvasRect = canvas.getBoundingClientRect();
|
|
13357
|
-
|
|
13359
|
+
canvas2DLog.debug("Canvas2D draw", { instanceId, viewportSize, baseOffsetX, cam: { x: cam.x, y: cam.y, zoom: cam.zoom }, cameraPos: cameraPos ? JSON.stringify(cameraPos) : void 0, containerRect: containerRect ? { width: containerRect.width, height: containerRect.height } : null, canvasRect: canvasRect ? { width: canvasRect.width, height: canvasRect.height } : null });
|
|
13358
13360
|
const painter = createWebPainter(ctx, bumpAtlas);
|
|
13359
13361
|
painter.save();
|
|
13360
13362
|
painter.translate(viewportSize.width / 2, viewportSize.height / 2);
|
|
@@ -13566,6 +13568,7 @@ function Canvas2D({
|
|
|
13566
13568
|
}
|
|
13567
13569
|
);
|
|
13568
13570
|
}
|
|
13571
|
+
var canvas2DLog;
|
|
13569
13572
|
var init_Canvas2D = __esm({
|
|
13570
13573
|
"components/game/molecules/Canvas2D.tsx"() {
|
|
13571
13574
|
"use client";
|
|
@@ -13587,6 +13590,7 @@ var init_Canvas2D = __esm({
|
|
|
13587
13590
|
init_paintDispatch();
|
|
13588
13591
|
init_hitTest();
|
|
13589
13592
|
init_isometric();
|
|
13593
|
+
canvas2DLog = createLogger("almadar:ui:game-canvas");
|
|
13590
13594
|
Canvas2D.displayName = "Canvas2D";
|
|
13591
13595
|
}
|
|
13592
13596
|
});
|
|
@@ -13625,7 +13629,7 @@ function Canvas({
|
|
|
13625
13629
|
keyMap,
|
|
13626
13630
|
keyUpMap
|
|
13627
13631
|
}) {
|
|
13628
|
-
|
|
13632
|
+
canvasLog.debug("Canvas render", { mode, drawablesCount: drawables?.length, projection, camera: camera ? JSON.stringify(camera) : void 0 });
|
|
13629
13633
|
const zoom = camera?.zoom;
|
|
13630
13634
|
if (mode === "3d") {
|
|
13631
13635
|
const props3d = {
|
|
@@ -13678,7 +13682,7 @@ function Canvas({
|
|
|
13678
13682
|
}
|
|
13679
13683
|
);
|
|
13680
13684
|
}
|
|
13681
|
-
var Canvas3DHost;
|
|
13685
|
+
var Canvas3DHost, canvasLog;
|
|
13682
13686
|
var init_Canvas = __esm({
|
|
13683
13687
|
"components/game/molecules/Canvas.tsx"() {
|
|
13684
13688
|
"use client";
|
|
@@ -13686,6 +13690,7 @@ var init_Canvas = __esm({
|
|
|
13686
13690
|
Canvas3DHost = lazy(
|
|
13687
13691
|
() => import('@almadar/ui/components/molecules/game/three').then((m) => ({ default: m.Canvas3DHost }))
|
|
13688
13692
|
);
|
|
13693
|
+
canvasLog = createLogger("almadar:ui:game-canvas");
|
|
13689
13694
|
Canvas.displayName = "Canvas";
|
|
13690
13695
|
}
|
|
13691
13696
|
});
|
|
@@ -50148,6 +50153,8 @@ var flushLog = createLogger("almadar:ui:slot-flush");
|
|
|
50148
50153
|
var stateLog = createLogger("almadar:ui:state-transitions");
|
|
50149
50154
|
var tickLog = createLogger("almadar:ui:tick-effects");
|
|
50150
50155
|
setNamespaceLevel("almadar:ui:tick-effects", "WARN");
|
|
50156
|
+
var sharedEntityLog = createLogger("almadar:ui:shared-entity");
|
|
50157
|
+
setNamespaceLevel("almadar:ui:shared-entity", "WARN");
|
|
50151
50158
|
var SYNC_TICK_OPERATORS = /* @__PURE__ */ new Set([
|
|
50152
50159
|
"set",
|
|
50153
50160
|
"emit",
|
|
@@ -50242,7 +50249,7 @@ function createSharedEntityWriter(binding, tick, traitStatesRef, emit) {
|
|
|
50242
50249
|
function getBindingConfig(binding) {
|
|
50243
50250
|
const raw = binding.config;
|
|
50244
50251
|
const normalized = normalizeCallSiteConfigToValues(raw);
|
|
50245
|
-
|
|
50252
|
+
sharedEntityLog.debug("getBindingConfig", { traitName: binding.trait.name, rawKeys: raw ? Object.keys(raw) : void 0, hasTiles: raw ? "tiles" in raw : false });
|
|
50246
50253
|
return normalized;
|
|
50247
50254
|
}
|
|
50248
50255
|
function evalFieldDefault(value) {
|
|
@@ -50257,7 +50264,7 @@ function evalFieldDefault(value) {
|
|
|
50257
50264
|
}
|
|
50258
50265
|
}
|
|
50259
50266
|
function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
50260
|
-
|
|
50267
|
+
sharedEntityLog.debug("useTraitStateMachine start", { traitBindingsCount: traitBindings.length, traitNames: traitBindings.map((b) => b.trait.name) });
|
|
50261
50268
|
const eventBus = useEventBus();
|
|
50262
50269
|
const { entities } = useEntitySchema();
|
|
50263
50270
|
const traitConfigsByName = options?.traitConfigsByName;
|
|
@@ -50276,10 +50283,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50276
50283
|
if (!group) {
|
|
50277
50284
|
let defaults;
|
|
50278
50285
|
for (const field of entityDef.fields) {
|
|
50279
|
-
if (field.default !== void 0) {
|
|
50286
|
+
if (field.default !== void 0 && field.default !== null) {
|
|
50280
50287
|
const evaluated = evalFieldDefault(field.default);
|
|
50281
50288
|
if (field.name === "tiles") {
|
|
50282
|
-
|
|
50289
|
+
sharedEntityLog.debug("seed tiles", {
|
|
50290
|
+
linkedEntityName,
|
|
50291
|
+
type: typeof evaluated,
|
|
50292
|
+
length: Array.isArray(evaluated) ? evaluated?.length : void 0,
|
|
50293
|
+
head: Array.isArray(evaluated) && evaluated.length > 0 ? JSON.stringify(evaluated[0]).slice(0, 80) : void 0
|
|
50294
|
+
});
|
|
50283
50295
|
}
|
|
50284
50296
|
(defaults ?? (defaults = {}))[field.name] = evaluated;
|
|
50285
50297
|
}
|
|
@@ -50296,7 +50308,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50296
50308
|
for (const group of sharedGroups.values()) {
|
|
50297
50309
|
if (group.defaults) {
|
|
50298
50310
|
sharedEntityStore.seed(group.storeKey, group.defaults);
|
|
50299
|
-
|
|
50311
|
+
sharedEntityLog.debug("shared-seed", {
|
|
50312
|
+
storeKey: group.storeKey,
|
|
50313
|
+
writers: group.writerBindings.map((b) => b.trait.name),
|
|
50314
|
+
renderers: group.renderBindings.map((b) => b.trait.name),
|
|
50315
|
+
tilesLength: Array.isArray(group.defaults.tiles) ? group.defaults.tiles.length : group.defaults.tiles
|
|
50316
|
+
});
|
|
50300
50317
|
}
|
|
50301
50318
|
}
|
|
50302
50319
|
const sharedKeyByTraitNameRef = useRef(/* @__PURE__ */ new Map());
|
|
@@ -50307,7 +50324,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50307
50324
|
for (const binding of group.renderBindings) map.set(binding.trait.name, group.storeKey);
|
|
50308
50325
|
}
|
|
50309
50326
|
sharedKeyByTraitNameRef.current = map;
|
|
50310
|
-
|
|
50327
|
+
sharedEntityLog.debug("shared-map", { map: Array.from(map.entries()).map(([k, v]) => `${k}->${v}`) });
|
|
50311
50328
|
}, [sharedGroups]);
|
|
50312
50329
|
const manager = useMemo(() => {
|
|
50313
50330
|
const traitDefs = traitBindings.map(toTraitDefinition);
|
|
@@ -50497,7 +50514,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50497
50514
|
const entityId = payload?.entityId;
|
|
50498
50515
|
const sharedKey = sharedKeyByTraitNameRef.current.get(traitName);
|
|
50499
50516
|
if (traitName === "Hero" || traitName === "Authority") {
|
|
50500
|
-
|
|
50517
|
+
sharedEntityLog.debug("executeTransitionEffects sharedKey", { traitName, sharedKey, storeTilesLength: sharedKey ? sharedEntityStore.getSnapshot(sharedKey).tiles?.length : void 0 });
|
|
50501
50518
|
}
|
|
50502
50519
|
let liveEntity;
|
|
50503
50520
|
if (sharedKey !== void 0) {
|
|
@@ -50524,10 +50541,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50524
50541
|
addPattern: (slot, pattern, props) => {
|
|
50525
50542
|
if (traitName === "Hero" && slot === "main" && props && typeof props === "object") {
|
|
50526
50543
|
const canvasChild = Array.isArray(props.children) ? props.children[0] : null;
|
|
50527
|
-
const grandChildren = canvasChild && typeof canvasChild === "object" ? canvasChild.children : null;
|
|
50544
|
+
const grandChildren = canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.children : null;
|
|
50528
50545
|
const firstLayer = Array.isArray(grandChildren) && grandChildren.length > 0 ? grandChildren[0] : null;
|
|
50529
|
-
const firstLayerItems = firstLayer && typeof firstLayer === "object" ? firstLayer.items : null;
|
|
50530
|
-
|
|
50546
|
+
const firstLayerItems = firstLayer && typeof firstLayer === "object" && !Array.isArray(firstLayer) ? firstLayer.items : null;
|
|
50547
|
+
sharedEntityLog.debug("render-ui main slot", {
|
|
50548
|
+
traitName,
|
|
50549
|
+
slot,
|
|
50550
|
+
canvasChildType: canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.type : "none",
|
|
50551
|
+
firstLayerItemsLength: Array.isArray(firstLayerItems) ? firstLayerItems.length : firstLayerItems
|
|
50552
|
+
});
|
|
50531
50553
|
}
|
|
50532
50554
|
const existing = pendingSlots.get(slot) || [];
|
|
50533
50555
|
existing.push({ pattern, props: props || {} });
|
|
@@ -50619,7 +50641,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50619
50641
|
};
|
|
50620
50642
|
}
|
|
50621
50643
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
50622
|
-
|
|
50644
|
+
sharedEntityLog.debug("executeTransitionEffects config tiles", {
|
|
50645
|
+
traitName,
|
|
50646
|
+
tilesType: typeof bindingCtx.config?.tiles,
|
|
50647
|
+
tilesLength: Array.isArray(bindingCtx.config?.tiles) ? bindingCtx.config?.tiles?.length : void 0,
|
|
50648
|
+
configKeys: bindingCtx.config ? Object.keys(bindingCtx.config) : void 0
|
|
50649
|
+
});
|
|
50623
50650
|
}
|
|
50624
50651
|
const effectContext = {
|
|
50625
50652
|
traitName,
|
|
@@ -50638,13 +50665,23 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
50638
50665
|
}
|
|
50639
50666
|
};
|
|
50640
50667
|
if (traitName === "Hero") {
|
|
50641
|
-
|
|
50668
|
+
sharedEntityLog.debug("executeTransitionEffects effects summary", {
|
|
50669
|
+
traitName,
|
|
50670
|
+
effectsCount: effects.length,
|
|
50671
|
+
hasRenderUI: typeof handlers.renderUI === "function",
|
|
50672
|
+
effectHeads: effects.map((e) => Array.isArray(e) ? String(e[0]) : "??")
|
|
50673
|
+
});
|
|
50642
50674
|
}
|
|
50643
50675
|
const executor = new EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
|
|
50644
50676
|
try {
|
|
50645
50677
|
await executor.executeAll(effects);
|
|
50646
50678
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
50647
|
-
|
|
50679
|
+
sharedEntityLog.debug("executeTransitionEffects after executeAll", {
|
|
50680
|
+
traitName,
|
|
50681
|
+
tilesType: typeof liveEntity.tiles,
|
|
50682
|
+
tilesLength: Array.isArray(liveEntity.tiles) ? liveEntity.tiles?.length : void 0,
|
|
50683
|
+
firstTilePos: Array.isArray(liveEntity.tiles) && liveEntity.tiles.length > 0 ? JSON.stringify(liveEntity.tiles[0]).slice(0, 120) : void 0
|
|
50684
|
+
});
|
|
50648
50685
|
}
|
|
50649
50686
|
if (sharedKey !== void 0) {
|
|
50650
50687
|
sharedEntityStore.commit(sharedKey, liveEntity);
|
|
@@ -51392,6 +51429,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
51392
51429
|
hadPrev: prevTraitsRef.current !== void 0
|
|
51393
51430
|
}));
|
|
51394
51431
|
if (refChanged) {
|
|
51432
|
+
navLog.info("page:traits-reset", { traitsCount: Array.isArray(traits2) ? traits2.length : -1 });
|
|
51395
51433
|
uiSlots.clearAll();
|
|
51396
51434
|
initSentRef.current = false;
|
|
51397
51435
|
}
|