@almadar/ui 5.142.0 → 5.143.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.
@@ -9826,6 +9826,83 @@ var init_DrawText = __esm({
9826
9826
  };
9827
9827
  }
9828
9828
  });
9829
+ function isAnimatedGroup(node) {
9830
+ return Boolean(node.animation && node.animation.durationMs > 0 && node.animation.keyframes.length > 0);
9831
+ }
9832
+ function DrawGroup(props) {
9833
+ const register = React85.useContext(DrawableRegistryContext);
9834
+ if (register) register({ ...props, type: "draw-group" });
9835
+ return null;
9836
+ }
9837
+ var init_DrawGroup = __esm({
9838
+ "components/game/atoms/DrawGroup.tsx"() {
9839
+ "use client";
9840
+ init_registry();
9841
+ }
9842
+ });
9843
+ function applyMeshAnimation(node, timeMs) {
9844
+ const anim = node.animation;
9845
+ if (!anim || !(anim.durationMs > 0) || anim.keyframes.length === 0) return null;
9846
+ const frames = [...anim.keyframes].sort((a, b) => a.at - b.at);
9847
+ const cycle = timeMs / anim.durationMs;
9848
+ const t = anim.loop === false ? Math.min(cycle, 1) : cycle - Math.floor(cycle);
9849
+ const trackValue = (key) => {
9850
+ const defined = frames.filter((f3) => f3[key] !== void 0);
9851
+ if (defined.length === 0) return void 0;
9852
+ let prev;
9853
+ let next;
9854
+ for (const f3 of defined) {
9855
+ if (f3.at <= t) prev = f3;
9856
+ else if (!next) next = f3;
9857
+ }
9858
+ if (!prev) return defined[0][key];
9859
+ if (!next) return prev[key];
9860
+ const span = next.at - prev.at;
9861
+ const k = span > 0 ? (t - prev.at) / span : 1;
9862
+ const a = prev[key];
9863
+ const b = next[key];
9864
+ if (typeof a === "number" && typeof b === "number") return lerp2(a, b, k);
9865
+ return a;
9866
+ };
9867
+ const num = {};
9868
+ for (const key of NUMERIC_TRACKS2) {
9869
+ const v = trackValue(key);
9870
+ if (v !== void 0) num[key] = v;
9871
+ }
9872
+ return {
9873
+ offset: [num.offsetX ?? 0, num.offsetY ?? 0, num.offsetZ ?? 0],
9874
+ rotate: [num.rotateX ?? 0, num.rotateY ?? 0, num.rotateZ ?? 0],
9875
+ scale: num.scale ?? 1,
9876
+ opacity: num.opacity,
9877
+ emissiveIntensity: num.emissiveIntensity,
9878
+ color: trackValue("color"),
9879
+ emissive: trackValue("emissive")
9880
+ };
9881
+ }
9882
+ function DrawMesh(props) {
9883
+ const register = React85.useContext(DrawableRegistryContext);
9884
+ if (register) register({ ...props, type: "draw-mesh" });
9885
+ return null;
9886
+ }
9887
+ var lerp2, NUMERIC_TRACKS2;
9888
+ var init_DrawMesh = __esm({
9889
+ "components/game/atoms/DrawMesh.tsx"() {
9890
+ "use client";
9891
+ init_registry();
9892
+ lerp2 = (a, b, k) => a + (b - a) * k;
9893
+ NUMERIC_TRACKS2 = [
9894
+ "offsetX",
9895
+ "offsetY",
9896
+ "offsetZ",
9897
+ "rotateX",
9898
+ "rotateY",
9899
+ "rotateZ",
9900
+ "scale",
9901
+ "opacity",
9902
+ "emissiveIntensity"
9903
+ ];
9904
+ }
9905
+ });
9829
9906
 
9830
9907
  // components/game/molecules/DrawSpriteLayer.tsx
9831
9908
  function DrawSpriteLayer(_props) {
@@ -9892,18 +9969,22 @@ function paintDrawable(painter, node, dctx) {
9892
9969
  if (!isValidScenePos(node.position)) break;
9893
9970
  if (!Array.isArray(node.items)) break;
9894
9971
  const p = dctx.projector.project(node.position);
9972
+ const anim = dctx.time > 0 && isAnimatedGroup(node) ? applyMeshAnimation(node, dctx.time) : null;
9973
+ const tw = dctx.projector.tileWidth;
9895
9974
  painter.save();
9896
- painter.translate(p.x, p.y);
9897
- if (node.scale !== void 0) painter.scale(node.scale, node.scale);
9898
- if (node.rotate !== void 0) painter.rotate(node.rotate);
9899
- if (node.opacity !== void 0 && node.opacity !== 1) painter.setAlpha(node.opacity);
9975
+ painter.translate(p.x + (anim ? anim.offset[0] * tw : 0), p.y + (anim ? anim.offset[1] * tw : 0));
9976
+ const scale = (node.scale ?? 1) * (anim?.scale ?? 1);
9977
+ if (scale !== 1) painter.scale(scale, scale);
9978
+ const rotate = (node.rotate ?? 0) + (node.rotation?.[2] ?? 0) + (anim?.rotate[2] ?? 0);
9979
+ if (rotate !== 0) painter.rotate(rotate);
9980
+ const opacity = (node.opacity ?? 1) * (anim?.opacity ?? 1);
9981
+ if (opacity !== 1) painter.setAlpha(opacity);
9900
9982
  if (node.clip) {
9901
- const tw = dctx.projector.tileWidth;
9902
9983
  painter.scale(tw, tw);
9903
9984
  painter.clipPath(node.clip);
9904
9985
  painter.scale(1 / tw, 1 / tw);
9905
9986
  }
9906
- const childCtx = node.scale !== void 0 && node.scale !== 1 ? { ...dctx, groupScale: (dctx.groupScale ?? 1) * node.scale } : dctx;
9987
+ const childCtx = scale !== 1 ? { ...dctx, groupScale: (dctx.groupScale ?? 1) * scale } : dctx;
9907
9988
  for (const item of node.items) paintDrawable(painter, item, childCtx);
9908
9989
  painter.restore();
9909
9990
  break;
@@ -9929,6 +10010,8 @@ var init_paintDispatch = __esm({
9929
10010
  init_DrawSprite();
9930
10011
  init_DrawShape();
9931
10012
  init_DrawText();
10013
+ init_DrawGroup();
10014
+ init_DrawMesh();
9932
10015
  init_DrawSpriteLayer();
9933
10016
  init_DrawShapeLayer();
9934
10017
  init_DrawTextLayer();
@@ -10175,7 +10258,8 @@ function Canvas2D({
10175
10258
  const miniMapHeight = gridExtent.height || 10;
10176
10259
  const drawableIsAnimated = (node) => {
10177
10260
  if (node.type === "draw-shape") return isAnimatedShape(node);
10178
- if (node.type === "draw-group") return Array.isArray(node.items) && node.items.some(drawableIsAnimated);
10261
+ if (node.type === "draw-group")
10262
+ return isAnimatedGroup(node) || Array.isArray(node.items) && node.items.some(drawableIsAnimated);
10179
10263
  if (node.type === "draw-shape-layer") return Array.isArray(node.items) && node.items.some(isAnimatedShape);
10180
10264
  return false;
10181
10265
  };
@@ -10517,6 +10601,7 @@ var init_Canvas2D = __esm({
10517
10601
  init_projector();
10518
10602
  init_paintDispatch();
10519
10603
  init_DrawShape();
10604
+ init_DrawGroup();
10520
10605
  init_registry();
10521
10606
  init_hitTest();
10522
10607
  init_isometric();
@@ -38419,28 +38504,6 @@ var init_DetailPanel = __esm({
38419
38504
  DetailPanel.displayName = "DetailPanel";
38420
38505
  }
38421
38506
  });
38422
- function DrawGroup(props) {
38423
- const register = React85.useContext(DrawableRegistryContext);
38424
- if (register) register({ ...props, type: "draw-group" });
38425
- return null;
38426
- }
38427
- var init_DrawGroup = __esm({
38428
- "components/game/atoms/DrawGroup.tsx"() {
38429
- "use client";
38430
- init_registry();
38431
- }
38432
- });
38433
- function DrawMesh(props) {
38434
- const register = React85.useContext(DrawableRegistryContext);
38435
- if (register) register({ ...props, type: "draw-mesh" });
38436
- return null;
38437
- }
38438
- var init_DrawMesh = __esm({
38439
- "components/game/atoms/DrawMesh.tsx"() {
38440
- "use client";
38441
- init_registry();
38442
- }
38443
- });
38444
38507
  function extractTitle(children) {
38445
38508
  if (!React85__namespace.default.isValidElement(children)) return void 0;
38446
38509
  const props = children.props;
@@ -9752,6 +9752,83 @@ var init_DrawText = __esm({
9752
9752
  };
9753
9753
  }
9754
9754
  });
9755
+ function isAnimatedGroup(node) {
9756
+ return Boolean(node.animation && node.animation.durationMs > 0 && node.animation.keyframes.length > 0);
9757
+ }
9758
+ function DrawGroup(props) {
9759
+ const register = useContext(DrawableRegistryContext);
9760
+ if (register) register({ ...props, type: "draw-group" });
9761
+ return null;
9762
+ }
9763
+ var init_DrawGroup = __esm({
9764
+ "components/game/atoms/DrawGroup.tsx"() {
9765
+ "use client";
9766
+ init_registry();
9767
+ }
9768
+ });
9769
+ function applyMeshAnimation(node, timeMs) {
9770
+ const anim = node.animation;
9771
+ if (!anim || !(anim.durationMs > 0) || anim.keyframes.length === 0) return null;
9772
+ const frames = [...anim.keyframes].sort((a, b) => a.at - b.at);
9773
+ const cycle = timeMs / anim.durationMs;
9774
+ const t = anim.loop === false ? Math.min(cycle, 1) : cycle - Math.floor(cycle);
9775
+ const trackValue = (key) => {
9776
+ const defined = frames.filter((f3) => f3[key] !== void 0);
9777
+ if (defined.length === 0) return void 0;
9778
+ let prev;
9779
+ let next;
9780
+ for (const f3 of defined) {
9781
+ if (f3.at <= t) prev = f3;
9782
+ else if (!next) next = f3;
9783
+ }
9784
+ if (!prev) return defined[0][key];
9785
+ if (!next) return prev[key];
9786
+ const span = next.at - prev.at;
9787
+ const k = span > 0 ? (t - prev.at) / span : 1;
9788
+ const a = prev[key];
9789
+ const b = next[key];
9790
+ if (typeof a === "number" && typeof b === "number") return lerp2(a, b, k);
9791
+ return a;
9792
+ };
9793
+ const num = {};
9794
+ for (const key of NUMERIC_TRACKS2) {
9795
+ const v = trackValue(key);
9796
+ if (v !== void 0) num[key] = v;
9797
+ }
9798
+ return {
9799
+ offset: [num.offsetX ?? 0, num.offsetY ?? 0, num.offsetZ ?? 0],
9800
+ rotate: [num.rotateX ?? 0, num.rotateY ?? 0, num.rotateZ ?? 0],
9801
+ scale: num.scale ?? 1,
9802
+ opacity: num.opacity,
9803
+ emissiveIntensity: num.emissiveIntensity,
9804
+ color: trackValue("color"),
9805
+ emissive: trackValue("emissive")
9806
+ };
9807
+ }
9808
+ function DrawMesh(props) {
9809
+ const register = useContext(DrawableRegistryContext);
9810
+ if (register) register({ ...props, type: "draw-mesh" });
9811
+ return null;
9812
+ }
9813
+ var lerp2, NUMERIC_TRACKS2;
9814
+ var init_DrawMesh = __esm({
9815
+ "components/game/atoms/DrawMesh.tsx"() {
9816
+ "use client";
9817
+ init_registry();
9818
+ lerp2 = (a, b, k) => a + (b - a) * k;
9819
+ NUMERIC_TRACKS2 = [
9820
+ "offsetX",
9821
+ "offsetY",
9822
+ "offsetZ",
9823
+ "rotateX",
9824
+ "rotateY",
9825
+ "rotateZ",
9826
+ "scale",
9827
+ "opacity",
9828
+ "emissiveIntensity"
9829
+ ];
9830
+ }
9831
+ });
9755
9832
 
9756
9833
  // components/game/molecules/DrawSpriteLayer.tsx
9757
9834
  function DrawSpriteLayer(_props) {
@@ -9818,18 +9895,22 @@ function paintDrawable(painter, node, dctx) {
9818
9895
  if (!isValidScenePos(node.position)) break;
9819
9896
  if (!Array.isArray(node.items)) break;
9820
9897
  const p = dctx.projector.project(node.position);
9898
+ const anim = dctx.time > 0 && isAnimatedGroup(node) ? applyMeshAnimation(node, dctx.time) : null;
9899
+ const tw = dctx.projector.tileWidth;
9821
9900
  painter.save();
9822
- painter.translate(p.x, p.y);
9823
- if (node.scale !== void 0) painter.scale(node.scale, node.scale);
9824
- if (node.rotate !== void 0) painter.rotate(node.rotate);
9825
- if (node.opacity !== void 0 && node.opacity !== 1) painter.setAlpha(node.opacity);
9901
+ painter.translate(p.x + (anim ? anim.offset[0] * tw : 0), p.y + (anim ? anim.offset[1] * tw : 0));
9902
+ const scale = (node.scale ?? 1) * (anim?.scale ?? 1);
9903
+ if (scale !== 1) painter.scale(scale, scale);
9904
+ const rotate = (node.rotate ?? 0) + (node.rotation?.[2] ?? 0) + (anim?.rotate[2] ?? 0);
9905
+ if (rotate !== 0) painter.rotate(rotate);
9906
+ const opacity = (node.opacity ?? 1) * (anim?.opacity ?? 1);
9907
+ if (opacity !== 1) painter.setAlpha(opacity);
9826
9908
  if (node.clip) {
9827
- const tw = dctx.projector.tileWidth;
9828
9909
  painter.scale(tw, tw);
9829
9910
  painter.clipPath(node.clip);
9830
9911
  painter.scale(1 / tw, 1 / tw);
9831
9912
  }
9832
- const childCtx = node.scale !== void 0 && node.scale !== 1 ? { ...dctx, groupScale: (dctx.groupScale ?? 1) * node.scale } : dctx;
9913
+ const childCtx = scale !== 1 ? { ...dctx, groupScale: (dctx.groupScale ?? 1) * scale } : dctx;
9833
9914
  for (const item of node.items) paintDrawable(painter, item, childCtx);
9834
9915
  painter.restore();
9835
9916
  break;
@@ -9855,6 +9936,8 @@ var init_paintDispatch = __esm({
9855
9936
  init_DrawSprite();
9856
9937
  init_DrawShape();
9857
9938
  init_DrawText();
9939
+ init_DrawGroup();
9940
+ init_DrawMesh();
9858
9941
  init_DrawSpriteLayer();
9859
9942
  init_DrawShapeLayer();
9860
9943
  init_DrawTextLayer();
@@ -10101,7 +10184,8 @@ function Canvas2D({
10101
10184
  const miniMapHeight = gridExtent.height || 10;
10102
10185
  const drawableIsAnimated = (node) => {
10103
10186
  if (node.type === "draw-shape") return isAnimatedShape(node);
10104
- if (node.type === "draw-group") return Array.isArray(node.items) && node.items.some(drawableIsAnimated);
10187
+ if (node.type === "draw-group")
10188
+ return isAnimatedGroup(node) || Array.isArray(node.items) && node.items.some(drawableIsAnimated);
10105
10189
  if (node.type === "draw-shape-layer") return Array.isArray(node.items) && node.items.some(isAnimatedShape);
10106
10190
  return false;
10107
10191
  };
@@ -10443,6 +10527,7 @@ var init_Canvas2D = __esm({
10443
10527
  init_projector();
10444
10528
  init_paintDispatch();
10445
10529
  init_DrawShape();
10530
+ init_DrawGroup();
10446
10531
  init_registry();
10447
10532
  init_hitTest();
10448
10533
  init_isometric();
@@ -38345,28 +38430,6 @@ var init_DetailPanel = __esm({
38345
38430
  DetailPanel.displayName = "DetailPanel";
38346
38431
  }
38347
38432
  });
38348
- function DrawGroup(props) {
38349
- const register = useContext(DrawableRegistryContext);
38350
- if (register) register({ ...props, type: "draw-group" });
38351
- return null;
38352
- }
38353
- var init_DrawGroup = __esm({
38354
- "components/game/atoms/DrawGroup.tsx"() {
38355
- "use client";
38356
- init_registry();
38357
- }
38358
- });
38359
- function DrawMesh(props) {
38360
- const register = useContext(DrawableRegistryContext);
38361
- if (register) register({ ...props, type: "draw-mesh" });
38362
- return null;
38363
- }
38364
- var init_DrawMesh = __esm({
38365
- "components/game/atoms/DrawMesh.tsx"() {
38366
- "use client";
38367
- init_registry();
38368
- }
38369
- });
38370
38433
  function extractTitle(children) {
38371
38434
  if (!React85__default.isValidElement(children)) return void 0;
38372
38435
  const props = children.props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "5.142.0",
3
+ "version": "5.143.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -118,12 +118,12 @@
118
118
  "access": "public"
119
119
  },
120
120
  "dependencies": {
121
- "@almadar/core": "^10.48.0",
122
- "@almadar/evaluator": "^2.38.0",
123
- "@almadar/logger": "^1.10.0",
124
- "@almadar/runtime": "^6.48.0",
125
- "@almadar/std": "^16.158.0",
126
- "@almadar/syntax": "^1.13.0",
121
+ "@almadar/core": "^10.49.0",
122
+ "@almadar/evaluator": "^2.39.0",
123
+ "@almadar/logger": "^1.11.0",
124
+ "@almadar/runtime": "^6.49.0",
125
+ "@almadar/std": "^16.160.0",
126
+ "@almadar/syntax": "^1.14.0",
127
127
  "@dnd-kit/core": "^6.3.1",
128
128
  "@dnd-kit/sortable": "^10.0.0",
129
129
  "@dnd-kit/utilities": "^3.2.2",
@@ -189,7 +189,7 @@
189
189
  "@types/react-dom": "^19.0.0",
190
190
  "@types/react-syntax-highlighter": "^15.5.0",
191
191
  "@types/three": "^0.160.0",
192
- "@typescript-eslint/parser": "8.56.0",
192
+ "@typescript-eslint/parser": "8.65.0",
193
193
  "@vitejs/plugin-react": "^4.2.0",
194
194
  "@vitest/ui": "^3.2.6",
195
195
  "autoprefixer": "^10.4.0",