@constela/runtime 2.0.5 → 2.0.7

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -3
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1596,7 +1596,9 @@ function getLinePoints(data, valueKey, width, height, padding) {
1596
1596
  if (!Array.isArray(data) || data.length === 0) return void 0;
1597
1597
  if (typeof valueKey !== "string") return void 0;
1598
1598
  if (typeof width !== "number" || typeof height !== "number") return void 0;
1599
+ if (width <= 0 || height <= 0) return void 0;
1599
1600
  const pad = typeof padding === "number" ? padding : 40;
1601
+ if (typeof padding !== "undefined" && typeof padding !== "number") return void 0;
1600
1602
  const bounds = getChartBounds(data, valueKey);
1601
1603
  if (!bounds) return void 0;
1602
1604
  const { min, max } = bounds;
@@ -1605,7 +1607,7 @@ function getLinePoints(data, valueKey, width, height, padding) {
1605
1607
  return data.map((item, idx) => {
1606
1608
  const value = item[valueKey];
1607
1609
  if (typeof value !== "number") return { x: 0, y: 0 };
1608
- const x2 = pad + (data.length > 1 ? idx / (data.length - 1) * chartWidth : chartWidth / 2);
1610
+ const x2 = data.length === 1 ? pad : pad + idx / (data.length - 1) * chartWidth;
1609
1611
  const y2 = min === max ? pad + chartHeight / 2 : pad + chartHeight - scaleValue(value, min, max, 0, chartHeight);
1610
1612
  return { x: x2, y: y2 };
1611
1613
  });
@@ -15566,13 +15568,17 @@ function renderPortal(node, ctx) {
15566
15568
  }
15567
15569
  function createLocalStateStore(stateDefs, ctx) {
15568
15570
  const signals = {};
15571
+ const evaluatedValues = {};
15569
15572
  for (const [name, def] of Object.entries(stateDefs)) {
15570
15573
  const initial = def.initial;
15571
15574
  let initialValue;
15572
15575
  if (initial && typeof initial === "object" && "expr" in initial) {
15573
15576
  const evalCtx = {
15574
15577
  state: ctx.state,
15575
- locals: ctx.locals
15578
+ locals: {
15579
+ ...ctx.locals,
15580
+ ...evaluatedValues
15581
+ }
15576
15582
  };
15577
15583
  if (ctx.route) evalCtx.route = ctx.route;
15578
15584
  if (ctx.imports) evalCtx.imports = ctx.imports;
@@ -15581,6 +15587,7 @@ function createLocalStateStore(stateDefs, ctx) {
15581
15587
  initialValue = initial;
15582
15588
  }
15583
15589
  signals[name] = createSignal(initialValue);
15590
+ evaluatedValues[name] = initialValue;
15584
15591
  }
15585
15592
  return {
15586
15593
  get(name) {
@@ -15911,13 +15918,17 @@ function createReactiveLocals2(baseLocals, itemSignal, indexSignal, itemName, in
15911
15918
  }
15912
15919
  function createLocalStateStore2(stateDefs, ctx) {
15913
15920
  const signals = {};
15921
+ const evaluatedValues = {};
15914
15922
  for (const [name, def] of Object.entries(stateDefs)) {
15915
15923
  const initial = def.initial;
15916
15924
  let initialValue;
15917
15925
  if (initial && typeof initial === "object" && "expr" in initial) {
15918
15926
  const evalCtx = {
15919
15927
  state: ctx.state,
15920
- locals: ctx.locals
15928
+ locals: {
15929
+ ...ctx.locals,
15930
+ ...evaluatedValues
15931
+ }
15921
15932
  };
15922
15933
  if (ctx.route) evalCtx.route = ctx.route;
15923
15934
  if (ctx.imports) evalCtx.imports = ctx.imports;
@@ -15926,6 +15937,7 @@ function createLocalStateStore2(stateDefs, ctx) {
15926
15937
  initialValue = initial;
15927
15938
  }
15928
15939
  signals[name] = createSignal(initialValue);
15940
+ evaluatedValues[name] = initialValue;
15929
15941
  }
15930
15942
  return {
15931
15943
  get(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/runtime",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "Runtime DOM renderer for Constela UI framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,8 +18,8 @@
18
18
  "dompurify": "^3.3.1",
19
19
  "marked": "^17.0.1",
20
20
  "shiki": "^3.20.0",
21
- "@constela/core": "0.18.2",
22
- "@constela/compiler": "0.15.8"
21
+ "@constela/compiler": "0.15.10",
22
+ "@constela/core": "0.18.4"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/dompurify": "^3.2.0",
@@ -29,10 +29,10 @@
29
29
  "tsup": "^8.0.0",
30
30
  "typescript": "^5.3.0",
31
31
  "vitest": "^2.0.0",
32
- "@constela/server": "14.0.3"
32
+ "@constela/server": "14.0.5"
33
33
  },
34
34
  "peerDependencies": {
35
- "@constela/ai": "3.0.2"
35
+ "@constela/ai": "3.0.4"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@constela/ai": {