@constela/runtime 2.0.1 → 2.0.3

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 +40 -6
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1183,6 +1183,14 @@ function evaluate(expr, ctx) {
1183
1183
  const arrayExpr = expr;
1184
1184
  return arrayExpr.elements.map((elem) => evaluate(elem, ctx));
1185
1185
  }
1186
+ case "obj": {
1187
+ const objExpr = expr;
1188
+ const result = {};
1189
+ for (const [key2, value] of Object.entries(objExpr.props)) {
1190
+ result[key2] = evaluate(value, ctx);
1191
+ }
1192
+ return result;
1193
+ }
1186
1194
  default: {
1187
1195
  const _exhaustiveCheck = expr;
1188
1196
  throw new Error(`Unknown expression type: ${JSON.stringify(_exhaustiveCheck)}`);
@@ -15537,10 +15545,23 @@ function renderPortal(node, ctx) {
15537
15545
  });
15538
15546
  return document.createComment("portal");
15539
15547
  }
15540
- function createLocalStateStore(stateDefs) {
15548
+ function createLocalStateStore(stateDefs, ctx) {
15541
15549
  const signals = {};
15542
15550
  for (const [name, def] of Object.entries(stateDefs)) {
15543
- signals[name] = createSignal(def.initial);
15551
+ const initial = def.initial;
15552
+ let initialValue;
15553
+ if (initial && typeof initial === "object" && "expr" in initial) {
15554
+ const evalCtx = {
15555
+ state: ctx.state,
15556
+ locals: ctx.locals
15557
+ };
15558
+ if (ctx.route) evalCtx.route = ctx.route;
15559
+ if (ctx.imports) evalCtx.imports = ctx.imports;
15560
+ initialValue = evaluate(initial, evalCtx);
15561
+ } else {
15562
+ initialValue = initial;
15563
+ }
15564
+ signals[name] = createSignal(initialValue);
15544
15565
  }
15545
15566
  return {
15546
15567
  get(name) {
@@ -15614,7 +15635,7 @@ function createStateWithLocalState(globalState, localStore) {
15614
15635
  };
15615
15636
  }
15616
15637
  function renderLocalState(node, ctx) {
15617
- const localStore = createLocalStateStore(node.state);
15638
+ const localStore = createLocalStateStore(node.state, ctx);
15618
15639
  const mergedLocals = createLocalsWithLocalState(ctx.locals, localStore);
15619
15640
  const mergedState = createStateWithLocalState(ctx.state, localStore);
15620
15641
  const mergedActions = { ...ctx.actions };
@@ -15869,10 +15890,23 @@ function createReactiveLocals2(baseLocals, itemSignal, indexSignal, itemName, in
15869
15890
  }
15870
15891
  });
15871
15892
  }
15872
- function createLocalStateStore2(stateDefs) {
15893
+ function createLocalStateStore2(stateDefs, ctx) {
15873
15894
  const signals = {};
15874
15895
  for (const [name, def] of Object.entries(stateDefs)) {
15875
- signals[name] = createSignal(def.initial);
15896
+ const initial = def.initial;
15897
+ let initialValue;
15898
+ if (initial && typeof initial === "object" && "expr" in initial) {
15899
+ const evalCtx = {
15900
+ state: ctx.state,
15901
+ locals: ctx.locals
15902
+ };
15903
+ if (ctx.route) evalCtx.route = ctx.route;
15904
+ if (ctx.imports) evalCtx.imports = ctx.imports;
15905
+ initialValue = evaluate(initial, evalCtx);
15906
+ } else {
15907
+ initialValue = initial;
15908
+ }
15909
+ signals[name] = createSignal(initialValue);
15876
15910
  }
15877
15911
  return {
15878
15912
  get(name) {
@@ -16051,7 +16085,7 @@ function hydrate(node, domNode, ctx) {
16051
16085
  }
16052
16086
  }
16053
16087
  function hydrateLocalState(node, domNode, ctx) {
16054
- const localStore = createLocalStateStore2(node.state);
16088
+ const localStore = createLocalStateStore2(node.state, ctx);
16055
16089
  const mergedLocals = createLocalsWithLocalState2(ctx.locals, localStore);
16056
16090
  const mergedState = createStateWithLocalState2(ctx.state, localStore);
16057
16091
  const mergedActions = { ...ctx.actions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/runtime",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
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/compiler": "0.15.7",
22
- "@constela/core": "0.18.1"
21
+ "@constela/core": "0.18.2",
22
+ "@constela/compiler": "0.15.8"
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.1"
32
+ "@constela/server": "14.0.3"
33
33
  },
34
34
  "peerDependencies": {
35
- "@constela/ai": "3.0.1"
35
+ "@constela/ai": "3.0.2"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@constela/ai": {