@constela/runtime 2.0.2 → 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 +32 -6
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -15545,10 +15545,23 @@ function renderPortal(node, ctx) {
15545
15545
  });
15546
15546
  return document.createComment("portal");
15547
15547
  }
15548
- function createLocalStateStore(stateDefs) {
15548
+ function createLocalStateStore(stateDefs, ctx) {
15549
15549
  const signals = {};
15550
15550
  for (const [name, def] of Object.entries(stateDefs)) {
15551
- 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);
15552
15565
  }
15553
15566
  return {
15554
15567
  get(name) {
@@ -15622,7 +15635,7 @@ function createStateWithLocalState(globalState, localStore) {
15622
15635
  };
15623
15636
  }
15624
15637
  function renderLocalState(node, ctx) {
15625
- const localStore = createLocalStateStore(node.state);
15638
+ const localStore = createLocalStateStore(node.state, ctx);
15626
15639
  const mergedLocals = createLocalsWithLocalState(ctx.locals, localStore);
15627
15640
  const mergedState = createStateWithLocalState(ctx.state, localStore);
15628
15641
  const mergedActions = { ...ctx.actions };
@@ -15877,10 +15890,23 @@ function createReactiveLocals2(baseLocals, itemSignal, indexSignal, itemName, in
15877
15890
  }
15878
15891
  });
15879
15892
  }
15880
- function createLocalStateStore2(stateDefs) {
15893
+ function createLocalStateStore2(stateDefs, ctx) {
15881
15894
  const signals = {};
15882
15895
  for (const [name, def] of Object.entries(stateDefs)) {
15883
- 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);
15884
15910
  }
15885
15911
  return {
15886
15912
  get(name) {
@@ -16059,7 +16085,7 @@ function hydrate(node, domNode, ctx) {
16059
16085
  }
16060
16086
  }
16061
16087
  function hydrateLocalState(node, domNode, ctx) {
16062
- const localStore = createLocalStateStore2(node.state);
16088
+ const localStore = createLocalStateStore2(node.state, ctx);
16063
16089
  const mergedLocals = createLocalsWithLocalState2(ctx.locals, localStore);
16064
16090
  const mergedState = createStateWithLocalState2(ctx.state, localStore);
16065
16091
  const mergedActions = { ...ctx.actions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/runtime",
3
- "version": "2.0.2",
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.8",
22
- "@constela/core": "0.18.2"
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,7 +29,7 @@
29
29
  "tsup": "^8.0.0",
30
30
  "typescript": "^5.3.0",
31
31
  "vitest": "^2.0.0",
32
- "@constela/server": "14.0.2"
32
+ "@constela/server": "14.0.3"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@constela/ai": "3.0.2"