@constela/runtime 2.0.8 → 2.0.9

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/index.d.ts CHANGED
@@ -509,6 +509,7 @@ interface RenderContext {
509
509
  query: Record<string, string>;
510
510
  path: string;
511
511
  };
512
+ styles?: Record<string, StylePreset>;
512
513
  }
513
514
  declare function render(node: CompiledNode, ctx: RenderContext): Node;
514
515
 
package/dist/index.js CHANGED
@@ -15171,7 +15171,7 @@ function renderElement(node, ctx) {
15171
15171
  }
15172
15172
  } else {
15173
15173
  const cleanup = createEffect(() => {
15174
- const value = evaluate(propValue, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } });
15174
+ const value = evaluate(propValue, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } });
15175
15175
  applyProp(el, propName, value, useSvgNamespace);
15176
15176
  });
15177
15177
  ctx.cleanups?.push(cleanup);
@@ -15226,7 +15226,7 @@ function applyProp(el, propName, value, isSvg = false) {
15226
15226
  function renderText(node, ctx) {
15227
15227
  const textNode = document.createTextNode("");
15228
15228
  const cleanup = createEffect(() => {
15229
- const value = evaluate(node.value, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } });
15229
+ const value = evaluate(node.value, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } });
15230
15230
  textNode.textContent = formatValue(value);
15231
15231
  });
15232
15232
  ctx.cleanups?.push(cleanup);
@@ -15247,7 +15247,7 @@ function renderIf(node, ctx) {
15247
15247
  let currentBranch = "none";
15248
15248
  let branchCleanups = [];
15249
15249
  const effectCleanup = createEffect(() => {
15250
- const condition = evaluate(node.condition, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } });
15250
+ const condition = evaluate(node.condition, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } });
15251
15251
  const shouldShowThen = Boolean(condition);
15252
15252
  const newBranch = shouldShowThen ? "then" : node.else ? "else" : "none";
15253
15253
  if (newBranch !== currentBranch) {
@@ -15325,7 +15325,7 @@ function renderEach(node, ctx) {
15325
15325
  let currentNodes = [];
15326
15326
  let itemCleanups = [];
15327
15327
  const effectCleanup = createEffect(() => {
15328
- const items = evaluate(node.items, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } });
15328
+ const items = evaluate(node.items, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } });
15329
15329
  if (!hasKey || !node.key) {
15330
15330
  for (const cleanup of itemCleanups) {
15331
15331
  cleanup();
@@ -15384,7 +15384,8 @@ function renderEach(node, ctx) {
15384
15384
  locals: tempLocals,
15385
15385
  ...ctx.refs && { refs: ctx.refs },
15386
15386
  ...ctx.imports && { imports: ctx.imports },
15387
- ...ctx.route && { route: ctx.route }
15387
+ ...ctx.route && { route: ctx.route },
15388
+ ...ctx.styles && { styles: ctx.styles }
15388
15389
  });
15389
15390
  if (seenKeys.has(keyValue)) {
15390
15391
  if (typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production") {
@@ -15476,7 +15477,7 @@ function renderMarkdown(node, ctx) {
15476
15477
  const container = document.createElement("div");
15477
15478
  container.className = "constela-markdown";
15478
15479
  const cleanup = createEffect(() => {
15479
- const content = evaluate(node.content, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } });
15480
+ const content = evaluate(node.content, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } });
15480
15481
  const html6 = parseMarkdown(String(content ?? ""));
15481
15482
  container.innerHTML = html6;
15482
15483
  });
@@ -15491,8 +15492,8 @@ function renderCode(node, ctx) {
15491
15492
  container.appendChild(pre);
15492
15493
  pre.appendChild(codeEl);
15493
15494
  const cleanup = createEffect(() => {
15494
- const language = String(evaluate(node.language, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } }) ?? "plaintext");
15495
- const content = String(evaluate(node.content, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route } }) ?? "");
15495
+ const language = String(evaluate(node.language, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } }) ?? "plaintext");
15496
+ const content = String(evaluate(node.content, { state: ctx.state, locals: ctx.locals, ...ctx.refs && { refs: ctx.refs }, ...ctx.imports && { imports: ctx.imports }, ...ctx.route && { route: ctx.route }, ...ctx.styles && { styles: ctx.styles } }) ?? "");
15496
15497
  codeEl.className = `language-${language || "plaintext"}`;
15497
15498
  codeEl.dataset["language"] = language || "plaintext";
15498
15499
  container.dataset["language"] = language || "plaintext";
@@ -15557,6 +15558,7 @@ function createLocalStateStore(stateDefs, ctx) {
15557
15558
  };
15558
15559
  if (ctx.route) evalCtx.route = ctx.route;
15559
15560
  if (ctx.imports) evalCtx.imports = ctx.imports;
15561
+ if (ctx.styles) evalCtx.styles = ctx.styles;
15560
15562
  initialValue = evaluate(initial, evalCtx);
15561
15563
  } else {
15562
15564
  initialValue = initial;
@@ -15678,7 +15680,9 @@ function createApp(program, mount) {
15678
15680
  actions,
15679
15681
  locals: {},
15680
15682
  cleanups,
15681
- refs
15683
+ refs,
15684
+ ...program.importData && { imports: program.importData },
15685
+ ...program.styles && { styles: program.styles }
15682
15686
  };
15683
15687
  const rootNode = render(program.view, ctx);
15684
15688
  mount.appendChild(rootNode);
@@ -15902,6 +15906,7 @@ function createLocalStateStore2(stateDefs, ctx) {
15902
15906
  };
15903
15907
  if (ctx.route) evalCtx.route = ctx.route;
15904
15908
  if (ctx.imports) evalCtx.imports = ctx.imports;
15909
+ if (ctx.styles) evalCtx.styles = ctx.styles;
15905
15910
  initialValue = evaluate(initial, evalCtx);
15906
15911
  } else {
15907
15912
  initialValue = initial;
@@ -16007,7 +16012,8 @@ function hydrateApp(options) {
16007
16012
  cleanups,
16008
16013
  refs,
16009
16014
  ...program.importData && { imports: program.importData },
16010
- ...route && { route }
16015
+ ...route && { route },
16016
+ ...program.styles && { styles: program.styles }
16011
16017
  };
16012
16018
  const firstChild = container.firstElementChild;
16013
16019
  if (firstChild) {
@@ -16155,7 +16161,8 @@ function hydrateElement(node, el, ctx) {
16155
16161
  state: ctx.state,
16156
16162
  locals: ctx.locals,
16157
16163
  ...ctx.imports && { imports: ctx.imports },
16158
- ...ctx.route && { route: ctx.route }
16164
+ ...ctx.route && { route: ctx.route },
16165
+ ...ctx.styles && { styles: ctx.styles }
16159
16166
  });
16160
16167
  applyProp2(el, propName, value);
16161
16168
  });
@@ -16225,7 +16232,8 @@ function hydrateChildren(children, parent, ctx) {
16225
16232
  state: ctx.state,
16226
16233
  locals: ctx.locals,
16227
16234
  ...ctx.imports && { imports: ctx.imports },
16228
- ...ctx.route && { route: ctx.route }
16235
+ ...ctx.route && { route: ctx.route },
16236
+ ...ctx.styles && { styles: ctx.styles }
16229
16237
  });
16230
16238
  const clientBranch = Boolean(clientCondition) ? "then" : ifNode.else ? "else" : "none";
16231
16239
  const ssrInfo = ifMarkerIndex < ifMarkers.length ? ifMarkers[ifMarkerIndex] : null;
@@ -16258,7 +16266,8 @@ function hydrateChildren(children, parent, ctx) {
16258
16266
  state: ctx.state,
16259
16267
  locals: ctx.locals,
16260
16268
  ...ctx.imports && { imports: ctx.imports },
16261
- ...ctx.route && { route: ctx.route }
16269
+ ...ctx.route && { route: ctx.route },
16270
+ ...ctx.styles && { styles: ctx.styles }
16262
16271
  });
16263
16272
  const itemCount = Array.isArray(items) ? items.length : 0;
16264
16273
  if (itemCount > 0) {
@@ -16287,7 +16296,8 @@ function hydrateTextGroup(nodes, textNode, ctx) {
16287
16296
  state: ctx.state,
16288
16297
  locals: ctx.locals,
16289
16298
  ...ctx.imports && { imports: ctx.imports },
16290
- ...ctx.route && { route: ctx.route }
16299
+ ...ctx.route && { route: ctx.route },
16300
+ ...ctx.styles && { styles: ctx.styles }
16291
16301
  });
16292
16302
  combinedText += formatValue2(value);
16293
16303
  }
@@ -16328,7 +16338,8 @@ function hydrateText(node, textNode, ctx) {
16328
16338
  state: ctx.state,
16329
16339
  locals: ctx.locals,
16330
16340
  ...ctx.imports && { imports: ctx.imports },
16331
- ...ctx.route && { route: ctx.route }
16341
+ ...ctx.route && { route: ctx.route },
16342
+ ...ctx.styles && { styles: ctx.styles }
16332
16343
  });
16333
16344
  textNode.textContent = formatValue2(value);
16334
16345
  });
@@ -16358,7 +16369,8 @@ function hydrateIf(node, initialDomNode, ctx, branchInfo) {
16358
16369
  state: ctx.state,
16359
16370
  locals: ctx.locals,
16360
16371
  ...ctx.imports && { imports: ctx.imports },
16361
- ...ctx.route && { route: ctx.route }
16372
+ ...ctx.route && { route: ctx.route },
16373
+ ...ctx.styles && { styles: ctx.styles }
16362
16374
  });
16363
16375
  currentBranch = Boolean(initialCondition) ? "then" : node.else ? "else" : "none";
16364
16376
  }
@@ -16380,7 +16392,8 @@ function hydrateIf(node, initialDomNode, ctx, branchInfo) {
16380
16392
  state: ctx.state,
16381
16393
  locals: ctx.locals,
16382
16394
  ...ctx.imports && { imports: ctx.imports },
16383
- ...ctx.route && { route: ctx.route }
16395
+ ...ctx.route && { route: ctx.route },
16396
+ ...ctx.styles && { styles: ctx.styles }
16384
16397
  });
16385
16398
  const shouldShowThen = Boolean(condition);
16386
16399
  const newBranch = shouldShowThen ? "then" : node.else ? "else" : "none";
@@ -16405,7 +16418,8 @@ function hydrateIf(node, initialDomNode, ctx, branchInfo) {
16405
16418
  actions: ctx.actions,
16406
16419
  locals: ctx.locals,
16407
16420
  cleanups: localCleanups,
16408
- ...ctx.imports && { imports: ctx.imports }
16421
+ ...ctx.imports && { imports: ctx.imports },
16422
+ ...ctx.styles && { styles: ctx.styles }
16409
16423
  };
16410
16424
  if (newBranch === "then") {
16411
16425
  currentNode = render(node.then, branchCtx);
@@ -16446,7 +16460,8 @@ function hydrateIfWithoutDom(node, parent, nextSibling, ctx, branchInfo) {
16446
16460
  state: ctx.state,
16447
16461
  locals: ctx.locals,
16448
16462
  ...ctx.imports && { imports: ctx.imports },
16449
- ...ctx.route && { route: ctx.route }
16463
+ ...ctx.route && { route: ctx.route },
16464
+ ...ctx.styles && { styles: ctx.styles }
16450
16465
  });
16451
16466
  const shouldShowThen = Boolean(condition);
16452
16467
  const newBranch = shouldShowThen ? "then" : node.else ? "else" : "none";
@@ -16472,7 +16487,8 @@ function hydrateIfWithoutDom(node, parent, nextSibling, ctx, branchInfo) {
16472
16487
  locals: ctx.locals,
16473
16488
  cleanups: localCleanups,
16474
16489
  ...ctx.imports && { imports: ctx.imports },
16475
- ...ctx.route && { route: ctx.route }
16490
+ ...ctx.route && { route: ctx.route },
16491
+ ...ctx.styles && { styles: ctx.styles }
16476
16492
  };
16477
16493
  if (newBranch === "then") {
16478
16494
  currentNode = render(node.then, branchCtx);
@@ -16512,7 +16528,8 @@ function hydrateEachEmpty(node, parent, insertBefore, ctx) {
16512
16528
  state: ctx.state,
16513
16529
  locals: ctx.locals,
16514
16530
  ...ctx.imports && { imports: ctx.imports },
16515
- ...ctx.route && { route: ctx.route }
16531
+ ...ctx.route && { route: ctx.route },
16532
+ ...ctx.styles && { styles: ctx.styles }
16516
16533
  });
16517
16534
  if (!hasKey || !node.key) {
16518
16535
  for (const cleanup of itemCleanups) {
@@ -16540,7 +16557,8 @@ function hydrateEachEmpty(node, parent, insertBefore, ctx) {
16540
16557
  actions: ctx.actions,
16541
16558
  locals: itemLocals,
16542
16559
  cleanups: localCleanups,
16543
- ...ctx.imports && { imports: ctx.imports }
16560
+ ...ctx.imports && { imports: ctx.imports },
16561
+ ...ctx.styles && { styles: ctx.styles }
16544
16562
  };
16545
16563
  const itemNode = render(node.body, itemCtx);
16546
16564
  currentNodes.push(itemNode);
@@ -16573,7 +16591,8 @@ function hydrateEachEmpty(node, parent, insertBefore, ctx) {
16573
16591
  state: ctx.state,
16574
16592
  locals: tempLocals,
16575
16593
  ...ctx.imports && { imports: ctx.imports },
16576
- ...ctx.route && { route: ctx.route }
16594
+ ...ctx.route && { route: ctx.route },
16595
+ ...ctx.styles && { styles: ctx.styles }
16577
16596
  });
16578
16597
  if (seenKeys.has(keyValue)) {
16579
16598
  if (typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production") {
@@ -16603,7 +16622,8 @@ function hydrateEachEmpty(node, parent, insertBefore, ctx) {
16603
16622
  actions: ctx.actions,
16604
16623
  locals: reactiveLocals,
16605
16624
  cleanups: localCleanups,
16606
- ...ctx.imports && { imports: ctx.imports }
16625
+ ...ctx.imports && { imports: ctx.imports },
16626
+ ...ctx.styles && { styles: ctx.styles }
16607
16627
  };
16608
16628
  const itemNode = render(node.body, itemCtx);
16609
16629
  const newState = {
@@ -16665,7 +16685,8 @@ function hydrateEach(node, firstItemDomNode, ctx) {
16665
16685
  state: ctx.state,
16666
16686
  locals: ctx.locals,
16667
16687
  ...ctx.imports && { imports: ctx.imports },
16668
- ...ctx.route && { route: ctx.route }
16688
+ ...ctx.route && { route: ctx.route },
16689
+ ...ctx.styles && { styles: ctx.styles }
16669
16690
  });
16670
16691
  let isFirstRun = true;
16671
16692
  if (Array.isArray(initialItems) && initialItems.length > 0) {
@@ -16683,7 +16704,8 @@ function hydrateEach(node, firstItemDomNode, ctx) {
16683
16704
  state: ctx.state,
16684
16705
  locals: tempLocals,
16685
16706
  ...ctx.imports && { imports: ctx.imports },
16686
- ...ctx.route && { route: ctx.route }
16707
+ ...ctx.route && { route: ctx.route },
16708
+ ...ctx.styles && { styles: ctx.styles }
16687
16709
  });
16688
16710
  if (seenKeys.has(keyValue)) {
16689
16711
  if (typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production") {
@@ -16755,7 +16777,8 @@ function hydrateEach(node, firstItemDomNode, ctx) {
16755
16777
  state: ctx.state,
16756
16778
  locals: ctx.locals,
16757
16779
  ...ctx.imports && { imports: ctx.imports },
16758
- ...ctx.route && { route: ctx.route }
16780
+ ...ctx.route && { route: ctx.route },
16781
+ ...ctx.styles && { styles: ctx.styles }
16759
16782
  });
16760
16783
  if (isFirstRun) {
16761
16784
  isFirstRun = false;
@@ -16787,7 +16810,8 @@ function hydrateEach(node, firstItemDomNode, ctx) {
16787
16810
  actions: ctx.actions,
16788
16811
  locals: itemLocals,
16789
16812
  cleanups: localCleanups,
16790
- ...ctx.imports && { imports: ctx.imports }
16813
+ ...ctx.imports && { imports: ctx.imports },
16814
+ ...ctx.styles && { styles: ctx.styles }
16791
16815
  };
16792
16816
  const itemNode = render(node.body, itemCtx);
16793
16817
  currentNodes.push(itemNode);
@@ -16820,7 +16844,8 @@ function hydrateEach(node, firstItemDomNode, ctx) {
16820
16844
  state: ctx.state,
16821
16845
  locals: tempLocals,
16822
16846
  ...ctx.imports && { imports: ctx.imports },
16823
- ...ctx.route && { route: ctx.route }
16847
+ ...ctx.route && { route: ctx.route },
16848
+ ...ctx.styles && { styles: ctx.styles }
16824
16849
  });
16825
16850
  if (seenKeys.has(keyValue)) {
16826
16851
  if (typeof process !== "undefined" && process.env?.["NODE_ENV"] !== "production") {
@@ -16850,7 +16875,8 @@ function hydrateEach(node, firstItemDomNode, ctx) {
16850
16875
  actions: ctx.actions,
16851
16876
  locals: reactiveLocals,
16852
16877
  cleanups: localCleanups,
16853
- ...ctx.imports && { imports: ctx.imports }
16878
+ ...ctx.imports && { imports: ctx.imports },
16879
+ ...ctx.styles && { styles: ctx.styles }
16854
16880
  };
16855
16881
  const itemNode = render(node.body, itemCtx);
16856
16882
  const newState = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/runtime",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "Runtime DOM renderer for Constela UI framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "dompurify": "^3.3.1",
19
19
  "marked": "^17.0.1",
20
20
  "shiki": "^3.20.0",
21
- "@constela/compiler": "0.15.11",
21
+ "@constela/compiler": "0.15.12",
22
22
  "@constela/core": "0.18.5"
23
23
  },
24
24
  "devDependencies": {