@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/providers/index.js
CHANGED
|
@@ -9458,14 +9458,16 @@ function Canvas2D({
|
|
|
9458
9458
|
cameraPos,
|
|
9459
9459
|
bgColor
|
|
9460
9460
|
}) {
|
|
9461
|
+
const instanceId = useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
9462
|
+
function isDrawableLayer(node) {
|
|
9463
|
+
return node.type === "draw-sprite-layer" || node.type === "draw-shape-layer" || node.type === "draw-text-layer";
|
|
9464
|
+
}
|
|
9461
9465
|
const layerSummaries = drawables?.map((d) => {
|
|
9462
|
-
if (!d
|
|
9463
|
-
|
|
9464
|
-
return { type: rec.type, itemsLen: Array.isArray(rec.items) ? rec.items.length : void 0, firstItem: Array.isArray(rec.items) ? rec.items[0] : void 0 };
|
|
9466
|
+
if (!isDrawableLayer(d)) return { type: d.type };
|
|
9467
|
+
return { type: d.type, itemsLen: d.items.length, firstItem: d.items[0] };
|
|
9465
9468
|
});
|
|
9466
|
-
|
|
9469
|
+
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 });
|
|
9467
9470
|
const backgroundImage = normalizeBackdrop(backgroundImageRaw);
|
|
9468
|
-
const instanceId = useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
9469
9471
|
const isFree = projection === "free";
|
|
9470
9472
|
const squareGrid = projection === "flat" || isFree || projection === "side";
|
|
9471
9473
|
const layout = projection === "side" ? "free" : projection;
|
|
@@ -9600,7 +9602,7 @@ function Canvas2D({
|
|
|
9600
9602
|
}
|
|
9601
9603
|
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
9602
9604
|
const canvasRect = canvas.getBoundingClientRect();
|
|
9603
|
-
|
|
9605
|
+
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 });
|
|
9604
9606
|
const painter = createWebPainter(ctx, bumpAtlas);
|
|
9605
9607
|
painter.save();
|
|
9606
9608
|
painter.translate(viewportSize.width / 2, viewportSize.height / 2);
|
|
@@ -9812,6 +9814,7 @@ function Canvas2D({
|
|
|
9812
9814
|
}
|
|
9813
9815
|
);
|
|
9814
9816
|
}
|
|
9817
|
+
var canvas2DLog;
|
|
9815
9818
|
var init_Canvas2D = __esm({
|
|
9816
9819
|
"components/game/molecules/Canvas2D.tsx"() {
|
|
9817
9820
|
"use client";
|
|
@@ -9833,6 +9836,7 @@ var init_Canvas2D = __esm({
|
|
|
9833
9836
|
init_paintDispatch();
|
|
9834
9837
|
init_hitTest();
|
|
9835
9838
|
init_isometric();
|
|
9839
|
+
canvas2DLog = createLogger("almadar:ui:game-canvas");
|
|
9836
9840
|
Canvas2D.displayName = "Canvas2D";
|
|
9837
9841
|
}
|
|
9838
9842
|
});
|
|
@@ -9871,7 +9875,7 @@ function Canvas({
|
|
|
9871
9875
|
keyMap,
|
|
9872
9876
|
keyUpMap
|
|
9873
9877
|
}) {
|
|
9874
|
-
|
|
9878
|
+
canvasLog.debug("Canvas render", { mode, drawablesCount: drawables?.length, projection, camera: camera ? JSON.stringify(camera) : void 0 });
|
|
9875
9879
|
const zoom = camera?.zoom;
|
|
9876
9880
|
if (mode === "3d") {
|
|
9877
9881
|
const props3d = {
|
|
@@ -9924,7 +9928,7 @@ function Canvas({
|
|
|
9924
9928
|
}
|
|
9925
9929
|
);
|
|
9926
9930
|
}
|
|
9927
|
-
var Canvas3DHost;
|
|
9931
|
+
var Canvas3DHost, canvasLog;
|
|
9928
9932
|
var init_Canvas = __esm({
|
|
9929
9933
|
"components/game/molecules/Canvas.tsx"() {
|
|
9930
9934
|
"use client";
|
|
@@ -9932,6 +9936,7 @@ var init_Canvas = __esm({
|
|
|
9932
9936
|
Canvas3DHost = lazy(
|
|
9933
9937
|
() => import('@almadar/ui/components/molecules/game/three').then((m) => ({ default: m.Canvas3DHost }))
|
|
9934
9938
|
);
|
|
9939
|
+
canvasLog = createLogger("almadar:ui:game-canvas");
|
|
9935
9940
|
Canvas.displayName = "Canvas";
|
|
9936
9941
|
}
|
|
9937
9942
|
});
|
package/dist/runtime/index.cjs
CHANGED
|
@@ -9850,14 +9850,16 @@ function Canvas2D({
|
|
|
9850
9850
|
cameraPos,
|
|
9851
9851
|
bgColor
|
|
9852
9852
|
}) {
|
|
9853
|
+
const instanceId = React81.useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
9854
|
+
function isDrawableLayer(node) {
|
|
9855
|
+
return node.type === "draw-sprite-layer" || node.type === "draw-shape-layer" || node.type === "draw-text-layer";
|
|
9856
|
+
}
|
|
9853
9857
|
const layerSummaries = drawables?.map((d) => {
|
|
9854
|
-
if (!d
|
|
9855
|
-
|
|
9856
|
-
return { type: rec.type, itemsLen: Array.isArray(rec.items) ? rec.items.length : void 0, firstItem: Array.isArray(rec.items) ? rec.items[0] : void 0 };
|
|
9858
|
+
if (!isDrawableLayer(d)) return { type: d.type };
|
|
9859
|
+
return { type: d.type, itemsLen: d.items.length, firstItem: d.items[0] };
|
|
9857
9860
|
});
|
|
9858
|
-
|
|
9861
|
+
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 });
|
|
9859
9862
|
const backgroundImage = normalizeBackdrop(backgroundImageRaw);
|
|
9860
|
-
const instanceId = React81.useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
9861
9863
|
const isFree = projection === "free";
|
|
9862
9864
|
const squareGrid = projection === "flat" || isFree || projection === "side";
|
|
9863
9865
|
const layout = projection === "side" ? "free" : projection;
|
|
@@ -9992,7 +9994,7 @@ function Canvas2D({
|
|
|
9992
9994
|
}
|
|
9993
9995
|
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
9994
9996
|
const canvasRect = canvas.getBoundingClientRect();
|
|
9995
|
-
|
|
9997
|
+
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 });
|
|
9996
9998
|
const painter = createWebPainter(ctx, bumpAtlas);
|
|
9997
9999
|
painter.save();
|
|
9998
10000
|
painter.translate(viewportSize.width / 2, viewportSize.height / 2);
|
|
@@ -10204,6 +10206,7 @@ function Canvas2D({
|
|
|
10204
10206
|
}
|
|
10205
10207
|
);
|
|
10206
10208
|
}
|
|
10209
|
+
var canvas2DLog;
|
|
10207
10210
|
var init_Canvas2D = __esm({
|
|
10208
10211
|
"components/game/molecules/Canvas2D.tsx"() {
|
|
10209
10212
|
"use client";
|
|
@@ -10225,6 +10228,7 @@ var init_Canvas2D = __esm({
|
|
|
10225
10228
|
init_paintDispatch();
|
|
10226
10229
|
init_hitTest();
|
|
10227
10230
|
init_isometric();
|
|
10231
|
+
canvas2DLog = logger.createLogger("almadar:ui:game-canvas");
|
|
10228
10232
|
Canvas2D.displayName = "Canvas2D";
|
|
10229
10233
|
}
|
|
10230
10234
|
});
|
|
@@ -10263,7 +10267,7 @@ function Canvas({
|
|
|
10263
10267
|
keyMap,
|
|
10264
10268
|
keyUpMap
|
|
10265
10269
|
}) {
|
|
10266
|
-
|
|
10270
|
+
canvasLog.debug("Canvas render", { mode, drawablesCount: drawables?.length, projection, camera: camera ? JSON.stringify(camera) : void 0 });
|
|
10267
10271
|
const zoom = camera?.zoom;
|
|
10268
10272
|
if (mode === "3d") {
|
|
10269
10273
|
const props3d = {
|
|
@@ -10316,7 +10320,7 @@ function Canvas({
|
|
|
10316
10320
|
}
|
|
10317
10321
|
);
|
|
10318
10322
|
}
|
|
10319
|
-
var Canvas3DHost;
|
|
10323
|
+
var Canvas3DHost, canvasLog;
|
|
10320
10324
|
var init_Canvas = __esm({
|
|
10321
10325
|
"components/game/molecules/Canvas.tsx"() {
|
|
10322
10326
|
"use client";
|
|
@@ -10324,6 +10328,7 @@ var init_Canvas = __esm({
|
|
|
10324
10328
|
Canvas3DHost = React81.lazy(
|
|
10325
10329
|
() => import('@almadar/ui/components/molecules/game/three').then((m) => ({ default: m.Canvas3DHost }))
|
|
10326
10330
|
);
|
|
10331
|
+
canvasLog = logger.createLogger("almadar:ui:game-canvas");
|
|
10327
10332
|
Canvas.displayName = "Canvas";
|
|
10328
10333
|
}
|
|
10329
10334
|
});
|
|
@@ -44237,6 +44242,8 @@ var flushLog = logger.createLogger("almadar:ui:slot-flush");
|
|
|
44237
44242
|
var stateLog = logger.createLogger("almadar:ui:state-transitions");
|
|
44238
44243
|
var tickLog = logger.createLogger("almadar:ui:tick-effects");
|
|
44239
44244
|
logger.setNamespaceLevel("almadar:ui:tick-effects", "WARN");
|
|
44245
|
+
var sharedEntityLog = logger.createLogger("almadar:ui:shared-entity");
|
|
44246
|
+
logger.setNamespaceLevel("almadar:ui:shared-entity", "WARN");
|
|
44240
44247
|
var SYNC_TICK_OPERATORS = /* @__PURE__ */ new Set([
|
|
44241
44248
|
"set",
|
|
44242
44249
|
"emit",
|
|
@@ -44331,7 +44338,7 @@ function createSharedEntityWriter(binding, tick, traitStatesRef, emit) {
|
|
|
44331
44338
|
function getBindingConfig(binding) {
|
|
44332
44339
|
const raw = binding.config;
|
|
44333
44340
|
const normalized = runtime.normalizeCallSiteConfigToValues(raw);
|
|
44334
|
-
|
|
44341
|
+
sharedEntityLog.debug("getBindingConfig", { traitName: binding.trait.name, rawKeys: raw ? Object.keys(raw) : void 0, hasTiles: raw ? "tiles" in raw : false });
|
|
44335
44342
|
return normalized;
|
|
44336
44343
|
}
|
|
44337
44344
|
function evalFieldDefault(value) {
|
|
@@ -44346,7 +44353,7 @@ function evalFieldDefault(value) {
|
|
|
44346
44353
|
}
|
|
44347
44354
|
}
|
|
44348
44355
|
function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
44349
|
-
|
|
44356
|
+
sharedEntityLog.debug("useTraitStateMachine start", { traitBindingsCount: traitBindings.length, traitNames: traitBindings.map((b) => b.trait.name) });
|
|
44350
44357
|
const eventBus = useEventBus();
|
|
44351
44358
|
const { entities } = providers.useEntitySchema();
|
|
44352
44359
|
const traitConfigsByName = options?.traitConfigsByName;
|
|
@@ -44365,10 +44372,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44365
44372
|
if (!group) {
|
|
44366
44373
|
let defaults;
|
|
44367
44374
|
for (const field of entityDef.fields) {
|
|
44368
|
-
if (field.default !== void 0) {
|
|
44375
|
+
if (field.default !== void 0 && field.default !== null) {
|
|
44369
44376
|
const evaluated = evalFieldDefault(field.default);
|
|
44370
44377
|
if (field.name === "tiles") {
|
|
44371
|
-
|
|
44378
|
+
sharedEntityLog.debug("seed tiles", {
|
|
44379
|
+
linkedEntityName,
|
|
44380
|
+
type: typeof evaluated,
|
|
44381
|
+
length: Array.isArray(evaluated) ? evaluated?.length : void 0,
|
|
44382
|
+
head: Array.isArray(evaluated) && evaluated.length > 0 ? JSON.stringify(evaluated[0]).slice(0, 80) : void 0
|
|
44383
|
+
});
|
|
44372
44384
|
}
|
|
44373
44385
|
(defaults ?? (defaults = {}))[field.name] = evaluated;
|
|
44374
44386
|
}
|
|
@@ -44385,7 +44397,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44385
44397
|
for (const group of sharedGroups.values()) {
|
|
44386
44398
|
if (group.defaults) {
|
|
44387
44399
|
sharedEntityStore.seed(group.storeKey, group.defaults);
|
|
44388
|
-
|
|
44400
|
+
sharedEntityLog.debug("shared-seed", {
|
|
44401
|
+
storeKey: group.storeKey,
|
|
44402
|
+
writers: group.writerBindings.map((b) => b.trait.name),
|
|
44403
|
+
renderers: group.renderBindings.map((b) => b.trait.name),
|
|
44404
|
+
tilesLength: Array.isArray(group.defaults.tiles) ? group.defaults.tiles.length : group.defaults.tiles
|
|
44405
|
+
});
|
|
44389
44406
|
}
|
|
44390
44407
|
}
|
|
44391
44408
|
const sharedKeyByTraitNameRef = React81.useRef(/* @__PURE__ */ new Map());
|
|
@@ -44396,7 +44413,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44396
44413
|
for (const binding of group.renderBindings) map.set(binding.trait.name, group.storeKey);
|
|
44397
44414
|
}
|
|
44398
44415
|
sharedKeyByTraitNameRef.current = map;
|
|
44399
|
-
|
|
44416
|
+
sharedEntityLog.debug("shared-map", { map: Array.from(map.entries()).map(([k, v]) => `${k}->${v}`) });
|
|
44400
44417
|
}, [sharedGroups]);
|
|
44401
44418
|
const manager = React81.useMemo(() => {
|
|
44402
44419
|
const traitDefs = traitBindings.map(toTraitDefinition);
|
|
@@ -44586,7 +44603,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44586
44603
|
const entityId = payload?.entityId;
|
|
44587
44604
|
const sharedKey = sharedKeyByTraitNameRef.current.get(traitName);
|
|
44588
44605
|
if (traitName === "Hero" || traitName === "Authority") {
|
|
44589
|
-
|
|
44606
|
+
sharedEntityLog.debug("executeTransitionEffects sharedKey", { traitName, sharedKey, storeTilesLength: sharedKey ? sharedEntityStore.getSnapshot(sharedKey).tiles?.length : void 0 });
|
|
44590
44607
|
}
|
|
44591
44608
|
let liveEntity;
|
|
44592
44609
|
if (sharedKey !== void 0) {
|
|
@@ -44613,10 +44630,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44613
44630
|
addPattern: (slot, pattern, props) => {
|
|
44614
44631
|
if (traitName === "Hero" && slot === "main" && props && typeof props === "object") {
|
|
44615
44632
|
const canvasChild = Array.isArray(props.children) ? props.children[0] : null;
|
|
44616
|
-
const grandChildren = canvasChild && typeof canvasChild === "object" ? canvasChild.children : null;
|
|
44633
|
+
const grandChildren = canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.children : null;
|
|
44617
44634
|
const firstLayer = Array.isArray(grandChildren) && grandChildren.length > 0 ? grandChildren[0] : null;
|
|
44618
|
-
const firstLayerItems = firstLayer && typeof firstLayer === "object" ? firstLayer.items : null;
|
|
44619
|
-
|
|
44635
|
+
const firstLayerItems = firstLayer && typeof firstLayer === "object" && !Array.isArray(firstLayer) ? firstLayer.items : null;
|
|
44636
|
+
sharedEntityLog.debug("render-ui main slot", {
|
|
44637
|
+
traitName,
|
|
44638
|
+
slot,
|
|
44639
|
+
canvasChildType: canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.type : "none",
|
|
44640
|
+
firstLayerItemsLength: Array.isArray(firstLayerItems) ? firstLayerItems.length : firstLayerItems
|
|
44641
|
+
});
|
|
44620
44642
|
}
|
|
44621
44643
|
const existing = pendingSlots.get(slot) || [];
|
|
44622
44644
|
existing.push({ pattern, props: props || {} });
|
|
@@ -44708,7 +44730,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44708
44730
|
};
|
|
44709
44731
|
}
|
|
44710
44732
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
44711
|
-
|
|
44733
|
+
sharedEntityLog.debug("executeTransitionEffects config tiles", {
|
|
44734
|
+
traitName,
|
|
44735
|
+
tilesType: typeof bindingCtx.config?.tiles,
|
|
44736
|
+
tilesLength: Array.isArray(bindingCtx.config?.tiles) ? bindingCtx.config?.tiles?.length : void 0,
|
|
44737
|
+
configKeys: bindingCtx.config ? Object.keys(bindingCtx.config) : void 0
|
|
44738
|
+
});
|
|
44712
44739
|
}
|
|
44713
44740
|
const effectContext = {
|
|
44714
44741
|
traitName,
|
|
@@ -44727,13 +44754,23 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44727
44754
|
}
|
|
44728
44755
|
};
|
|
44729
44756
|
if (traitName === "Hero") {
|
|
44730
|
-
|
|
44757
|
+
sharedEntityLog.debug("executeTransitionEffects effects summary", {
|
|
44758
|
+
traitName,
|
|
44759
|
+
effectsCount: effects.length,
|
|
44760
|
+
hasRenderUI: typeof handlers.renderUI === "function",
|
|
44761
|
+
effectHeads: effects.map((e) => Array.isArray(e) ? String(e[0]) : "??")
|
|
44762
|
+
});
|
|
44731
44763
|
}
|
|
44732
44764
|
const executor = new runtime.EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
|
|
44733
44765
|
try {
|
|
44734
44766
|
await executor.executeAll(effects);
|
|
44735
44767
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
44736
|
-
|
|
44768
|
+
sharedEntityLog.debug("executeTransitionEffects after executeAll", {
|
|
44769
|
+
traitName,
|
|
44770
|
+
tilesType: typeof liveEntity.tiles,
|
|
44771
|
+
tilesLength: Array.isArray(liveEntity.tiles) ? liveEntity.tiles?.length : void 0,
|
|
44772
|
+
firstTilePos: Array.isArray(liveEntity.tiles) && liveEntity.tiles.length > 0 ? JSON.stringify(liveEntity.tiles[0]).slice(0, 120) : void 0
|
|
44773
|
+
});
|
|
44737
44774
|
}
|
|
44738
44775
|
if (sharedKey !== void 0) {
|
|
44739
44776
|
sharedEntityStore.commit(sharedKey, liveEntity);
|
|
@@ -45697,6 +45734,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
45697
45734
|
hadPrev: prevTraitsRef.current !== void 0
|
|
45698
45735
|
}));
|
|
45699
45736
|
if (refChanged) {
|
|
45737
|
+
navLog.info("page:traits-reset", { traitsCount: Array.isArray(traits2) ? traits2.length : -1 });
|
|
45700
45738
|
uiSlots.clearAll();
|
|
45701
45739
|
initSentRef.current = false;
|
|
45702
45740
|
}
|
package/dist/runtime/index.js
CHANGED
|
@@ -9805,14 +9805,16 @@ function Canvas2D({
|
|
|
9805
9805
|
cameraPos,
|
|
9806
9806
|
bgColor
|
|
9807
9807
|
}) {
|
|
9808
|
+
const instanceId = useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
9809
|
+
function isDrawableLayer(node) {
|
|
9810
|
+
return node.type === "draw-sprite-layer" || node.type === "draw-shape-layer" || node.type === "draw-text-layer";
|
|
9811
|
+
}
|
|
9808
9812
|
const layerSummaries = drawables?.map((d) => {
|
|
9809
|
-
if (!d
|
|
9810
|
-
|
|
9811
|
-
return { type: rec.type, itemsLen: Array.isArray(rec.items) ? rec.items.length : void 0, firstItem: Array.isArray(rec.items) ? rec.items[0] : void 0 };
|
|
9813
|
+
if (!isDrawableLayer(d)) return { type: d.type };
|
|
9814
|
+
return { type: d.type, itemsLen: d.items.length, firstItem: d.items[0] };
|
|
9812
9815
|
});
|
|
9813
|
-
|
|
9816
|
+
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 });
|
|
9814
9817
|
const backgroundImage = normalizeBackdrop(backgroundImageRaw);
|
|
9815
|
-
const instanceId = useMemo(() => Math.random().toString(36).slice(2, 8), []);
|
|
9816
9818
|
const isFree = projection === "free";
|
|
9817
9819
|
const squareGrid = projection === "flat" || isFree || projection === "side";
|
|
9818
9820
|
const layout = projection === "side" ? "free" : projection;
|
|
@@ -9947,7 +9949,7 @@ function Canvas2D({
|
|
|
9947
9949
|
}
|
|
9948
9950
|
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
9949
9951
|
const canvasRect = canvas.getBoundingClientRect();
|
|
9950
|
-
|
|
9952
|
+
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 });
|
|
9951
9953
|
const painter = createWebPainter(ctx, bumpAtlas);
|
|
9952
9954
|
painter.save();
|
|
9953
9955
|
painter.translate(viewportSize.width / 2, viewportSize.height / 2);
|
|
@@ -10159,6 +10161,7 @@ function Canvas2D({
|
|
|
10159
10161
|
}
|
|
10160
10162
|
);
|
|
10161
10163
|
}
|
|
10164
|
+
var canvas2DLog;
|
|
10162
10165
|
var init_Canvas2D = __esm({
|
|
10163
10166
|
"components/game/molecules/Canvas2D.tsx"() {
|
|
10164
10167
|
"use client";
|
|
@@ -10180,6 +10183,7 @@ var init_Canvas2D = __esm({
|
|
|
10180
10183
|
init_paintDispatch();
|
|
10181
10184
|
init_hitTest();
|
|
10182
10185
|
init_isometric();
|
|
10186
|
+
canvas2DLog = createLogger("almadar:ui:game-canvas");
|
|
10183
10187
|
Canvas2D.displayName = "Canvas2D";
|
|
10184
10188
|
}
|
|
10185
10189
|
});
|
|
@@ -10218,7 +10222,7 @@ function Canvas({
|
|
|
10218
10222
|
keyMap,
|
|
10219
10223
|
keyUpMap
|
|
10220
10224
|
}) {
|
|
10221
|
-
|
|
10225
|
+
canvasLog.debug("Canvas render", { mode, drawablesCount: drawables?.length, projection, camera: camera ? JSON.stringify(camera) : void 0 });
|
|
10222
10226
|
const zoom = camera?.zoom;
|
|
10223
10227
|
if (mode === "3d") {
|
|
10224
10228
|
const props3d = {
|
|
@@ -10271,7 +10275,7 @@ function Canvas({
|
|
|
10271
10275
|
}
|
|
10272
10276
|
);
|
|
10273
10277
|
}
|
|
10274
|
-
var Canvas3DHost;
|
|
10278
|
+
var Canvas3DHost, canvasLog;
|
|
10275
10279
|
var init_Canvas = __esm({
|
|
10276
10280
|
"components/game/molecules/Canvas.tsx"() {
|
|
10277
10281
|
"use client";
|
|
@@ -10279,6 +10283,7 @@ var init_Canvas = __esm({
|
|
|
10279
10283
|
Canvas3DHost = lazy(
|
|
10280
10284
|
() => import('@almadar/ui/components/molecules/game/three').then((m) => ({ default: m.Canvas3DHost }))
|
|
10281
10285
|
);
|
|
10286
|
+
canvasLog = createLogger("almadar:ui:game-canvas");
|
|
10282
10287
|
Canvas.displayName = "Canvas";
|
|
10283
10288
|
}
|
|
10284
10289
|
});
|
|
@@ -44192,6 +44197,8 @@ var flushLog = createLogger("almadar:ui:slot-flush");
|
|
|
44192
44197
|
var stateLog = createLogger("almadar:ui:state-transitions");
|
|
44193
44198
|
var tickLog = createLogger("almadar:ui:tick-effects");
|
|
44194
44199
|
setNamespaceLevel("almadar:ui:tick-effects", "WARN");
|
|
44200
|
+
var sharedEntityLog = createLogger("almadar:ui:shared-entity");
|
|
44201
|
+
setNamespaceLevel("almadar:ui:shared-entity", "WARN");
|
|
44195
44202
|
var SYNC_TICK_OPERATORS = /* @__PURE__ */ new Set([
|
|
44196
44203
|
"set",
|
|
44197
44204
|
"emit",
|
|
@@ -44286,7 +44293,7 @@ function createSharedEntityWriter(binding, tick, traitStatesRef, emit) {
|
|
|
44286
44293
|
function getBindingConfig(binding) {
|
|
44287
44294
|
const raw = binding.config;
|
|
44288
44295
|
const normalized = normalizeCallSiteConfigToValues(raw);
|
|
44289
|
-
|
|
44296
|
+
sharedEntityLog.debug("getBindingConfig", { traitName: binding.trait.name, rawKeys: raw ? Object.keys(raw) : void 0, hasTiles: raw ? "tiles" in raw : false });
|
|
44290
44297
|
return normalized;
|
|
44291
44298
|
}
|
|
44292
44299
|
function evalFieldDefault(value) {
|
|
@@ -44301,7 +44308,7 @@ function evalFieldDefault(value) {
|
|
|
44301
44308
|
}
|
|
44302
44309
|
}
|
|
44303
44310
|
function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
44304
|
-
|
|
44311
|
+
sharedEntityLog.debug("useTraitStateMachine start", { traitBindingsCount: traitBindings.length, traitNames: traitBindings.map((b) => b.trait.name) });
|
|
44305
44312
|
const eventBus = useEventBus();
|
|
44306
44313
|
const { entities } = useEntitySchema();
|
|
44307
44314
|
const traitConfigsByName = options?.traitConfigsByName;
|
|
@@ -44320,10 +44327,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44320
44327
|
if (!group) {
|
|
44321
44328
|
let defaults;
|
|
44322
44329
|
for (const field of entityDef.fields) {
|
|
44323
|
-
if (field.default !== void 0) {
|
|
44330
|
+
if (field.default !== void 0 && field.default !== null) {
|
|
44324
44331
|
const evaluated = evalFieldDefault(field.default);
|
|
44325
44332
|
if (field.name === "tiles") {
|
|
44326
|
-
|
|
44333
|
+
sharedEntityLog.debug("seed tiles", {
|
|
44334
|
+
linkedEntityName,
|
|
44335
|
+
type: typeof evaluated,
|
|
44336
|
+
length: Array.isArray(evaluated) ? evaluated?.length : void 0,
|
|
44337
|
+
head: Array.isArray(evaluated) && evaluated.length > 0 ? JSON.stringify(evaluated[0]).slice(0, 80) : void 0
|
|
44338
|
+
});
|
|
44327
44339
|
}
|
|
44328
44340
|
(defaults ?? (defaults = {}))[field.name] = evaluated;
|
|
44329
44341
|
}
|
|
@@ -44340,7 +44352,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44340
44352
|
for (const group of sharedGroups.values()) {
|
|
44341
44353
|
if (group.defaults) {
|
|
44342
44354
|
sharedEntityStore.seed(group.storeKey, group.defaults);
|
|
44343
|
-
|
|
44355
|
+
sharedEntityLog.debug("shared-seed", {
|
|
44356
|
+
storeKey: group.storeKey,
|
|
44357
|
+
writers: group.writerBindings.map((b) => b.trait.name),
|
|
44358
|
+
renderers: group.renderBindings.map((b) => b.trait.name),
|
|
44359
|
+
tilesLength: Array.isArray(group.defaults.tiles) ? group.defaults.tiles.length : group.defaults.tiles
|
|
44360
|
+
});
|
|
44344
44361
|
}
|
|
44345
44362
|
}
|
|
44346
44363
|
const sharedKeyByTraitNameRef = useRef(/* @__PURE__ */ new Map());
|
|
@@ -44351,7 +44368,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44351
44368
|
for (const binding of group.renderBindings) map.set(binding.trait.name, group.storeKey);
|
|
44352
44369
|
}
|
|
44353
44370
|
sharedKeyByTraitNameRef.current = map;
|
|
44354
|
-
|
|
44371
|
+
sharedEntityLog.debug("shared-map", { map: Array.from(map.entries()).map(([k, v]) => `${k}->${v}`) });
|
|
44355
44372
|
}, [sharedGroups]);
|
|
44356
44373
|
const manager = useMemo(() => {
|
|
44357
44374
|
const traitDefs = traitBindings.map(toTraitDefinition);
|
|
@@ -44541,7 +44558,7 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44541
44558
|
const entityId = payload?.entityId;
|
|
44542
44559
|
const sharedKey = sharedKeyByTraitNameRef.current.get(traitName);
|
|
44543
44560
|
if (traitName === "Hero" || traitName === "Authority") {
|
|
44544
|
-
|
|
44561
|
+
sharedEntityLog.debug("executeTransitionEffects sharedKey", { traitName, sharedKey, storeTilesLength: sharedKey ? sharedEntityStore.getSnapshot(sharedKey).tiles?.length : void 0 });
|
|
44545
44562
|
}
|
|
44546
44563
|
let liveEntity;
|
|
44547
44564
|
if (sharedKey !== void 0) {
|
|
@@ -44568,10 +44585,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44568
44585
|
addPattern: (slot, pattern, props) => {
|
|
44569
44586
|
if (traitName === "Hero" && slot === "main" && props && typeof props === "object") {
|
|
44570
44587
|
const canvasChild = Array.isArray(props.children) ? props.children[0] : null;
|
|
44571
|
-
const grandChildren = canvasChild && typeof canvasChild === "object" ? canvasChild.children : null;
|
|
44588
|
+
const grandChildren = canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.children : null;
|
|
44572
44589
|
const firstLayer = Array.isArray(grandChildren) && grandChildren.length > 0 ? grandChildren[0] : null;
|
|
44573
|
-
const firstLayerItems = firstLayer && typeof firstLayer === "object" ? firstLayer.items : null;
|
|
44574
|
-
|
|
44590
|
+
const firstLayerItems = firstLayer && typeof firstLayer === "object" && !Array.isArray(firstLayer) ? firstLayer.items : null;
|
|
44591
|
+
sharedEntityLog.debug("render-ui main slot", {
|
|
44592
|
+
traitName,
|
|
44593
|
+
slot,
|
|
44594
|
+
canvasChildType: canvasChild && typeof canvasChild === "object" && !Array.isArray(canvasChild) ? canvasChild.type : "none",
|
|
44595
|
+
firstLayerItemsLength: Array.isArray(firstLayerItems) ? firstLayerItems.length : firstLayerItems
|
|
44596
|
+
});
|
|
44575
44597
|
}
|
|
44576
44598
|
const existing = pendingSlots.get(slot) || [];
|
|
44577
44599
|
existing.push({ pattern, props: props || {} });
|
|
@@ -44663,7 +44685,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44663
44685
|
};
|
|
44664
44686
|
}
|
|
44665
44687
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
44666
|
-
|
|
44688
|
+
sharedEntityLog.debug("executeTransitionEffects config tiles", {
|
|
44689
|
+
traitName,
|
|
44690
|
+
tilesType: typeof bindingCtx.config?.tiles,
|
|
44691
|
+
tilesLength: Array.isArray(bindingCtx.config?.tiles) ? bindingCtx.config?.tiles?.length : void 0,
|
|
44692
|
+
configKeys: bindingCtx.config ? Object.keys(bindingCtx.config) : void 0
|
|
44693
|
+
});
|
|
44667
44694
|
}
|
|
44668
44695
|
const effectContext = {
|
|
44669
44696
|
traitName,
|
|
@@ -44682,13 +44709,23 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
|
|
|
44682
44709
|
}
|
|
44683
44710
|
};
|
|
44684
44711
|
if (traitName === "Hero") {
|
|
44685
|
-
|
|
44712
|
+
sharedEntityLog.debug("executeTransitionEffects effects summary", {
|
|
44713
|
+
traitName,
|
|
44714
|
+
effectsCount: effects.length,
|
|
44715
|
+
hasRenderUI: typeof handlers.renderUI === "function",
|
|
44716
|
+
effectHeads: effects.map((e) => Array.isArray(e) ? String(e[0]) : "??")
|
|
44717
|
+
});
|
|
44686
44718
|
}
|
|
44687
44719
|
const executor = new EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
|
|
44688
44720
|
try {
|
|
44689
44721
|
await executor.executeAll(effects);
|
|
44690
44722
|
if (traitName === "Authority" || traitName === "Hero") {
|
|
44691
|
-
|
|
44723
|
+
sharedEntityLog.debug("executeTransitionEffects after executeAll", {
|
|
44724
|
+
traitName,
|
|
44725
|
+
tilesType: typeof liveEntity.tiles,
|
|
44726
|
+
tilesLength: Array.isArray(liveEntity.tiles) ? liveEntity.tiles?.length : void 0,
|
|
44727
|
+
firstTilePos: Array.isArray(liveEntity.tiles) && liveEntity.tiles.length > 0 ? JSON.stringify(liveEntity.tiles[0]).slice(0, 120) : void 0
|
|
44728
|
+
});
|
|
44692
44729
|
}
|
|
44693
44730
|
if (sharedKey !== void 0) {
|
|
44694
44731
|
sharedEntityStore.commit(sharedKey, liveEntity);
|
|
@@ -45652,6 +45689,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
|
|
|
45652
45689
|
hadPrev: prevTraitsRef.current !== void 0
|
|
45653
45690
|
}));
|
|
45654
45691
|
if (refChanged) {
|
|
45692
|
+
navLog.info("page:traits-reset", { traitsCount: Array.isArray(traits2) ? traits2.length : -1 });
|
|
45655
45693
|
uiSlots.clearAll();
|
|
45656
45694
|
initSentRef.current = false;
|
|
45657
45695
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/ui",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.113.0",
|
|
4
4
|
"description": "React UI components, hooks, and providers for Almadar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@almadar/core": "^10.28.0",
|
|
121
121
|
"@almadar/evaluator": "^2.29.0",
|
|
122
122
|
"@almadar/logger": "^1.9.0",
|
|
123
|
-
"@almadar/runtime": "^6.
|
|
123
|
+
"@almadar/runtime": "^6.32.0",
|
|
124
124
|
"@almadar/std": "^16.138.0",
|
|
125
125
|
"@almadar/syntax": "^1.11.0",
|
|
126
126
|
"@dnd-kit/core": "^6.3.1",
|