@marko/runtime-tags 0.1.25 → 0.2.1

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.
@@ -32,6 +32,7 @@ export declare enum AccessorChar {
32
32
  LifecycleAbortController = "-",
33
33
  DynamicPlaceholderLastChild = "-",
34
34
  TagVariable = "/",
35
+ TagVariableChange = "@",
35
36
  ConditionalScope = "!",
36
37
  ConditionalRenderer = "(",
37
38
  LoopScopeArray = "!",
package/dist/debug/dom.js CHANGED
@@ -78,9 +78,11 @@ __export(dom_exports, {
78
78
  resetAbortSignal: () => resetAbortSignal,
79
79
  run: () => run,
80
80
  setTagVar: () => setTagVar,
81
+ setTagVarChange: () => setTagVarChange,
81
82
  state: () => state,
82
83
  styleAttr: () => styleAttr,
83
84
  tagVarSignal: () => tagVarSignal,
85
+ tagVarSignalChange: () => tagVarSignalChange,
84
86
  value: () => value
85
87
  });
86
88
  module.exports = __toCommonJS(dom_exports);
@@ -606,6 +608,10 @@ function setTagVar(scope, childAccessor, tagVarSignal2) {
606
608
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
607
609
  }
608
610
  var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
611
+ function setTagVarChange(scope, changeHandler) {
612
+ scope["@" /* TagVariableChange */] = changeHandler;
613
+ }
614
+ var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
609
615
  var renderBodyClosures = (renderBody, childScope, op) => {
610
616
  const signals = renderBody?.___closureSignals;
611
617
  if (signals) {
@@ -519,6 +519,10 @@ function setTagVar(scope, childAccessor, tagVarSignal2) {
519
519
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
520
520
  }
521
521
  var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
522
+ function setTagVarChange(scope, changeHandler) {
523
+ scope["@" /* TagVariableChange */] = changeHandler;
524
+ }
525
+ var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
522
526
  var renderBodyClosures = (renderBody, childScope, op) => {
523
527
  const signals = renderBody?.___closureSignals;
524
528
  if (signals) {
@@ -2063,8 +2067,10 @@ export {
2063
2067
  resetAbortSignal,
2064
2068
  run,
2065
2069
  setTagVar,
2070
+ setTagVarChange,
2066
2071
  state,
2067
2072
  styleAttr,
2068
2073
  tagVarSignal,
2074
+ tagVarSignalChange,
2069
2075
  value
2070
2076
  };
@@ -1954,8 +1954,15 @@ function prepareChunk(chunk) {
1954
1954
  }
1955
1955
  function flushChunk(head) {
1956
1956
  const { html, scripts } = head;
1957
+ const { $global: $global2 } = head.boundary.state;
1958
+ const { __flush__ } = $global2;
1959
+ const result = scripts ? html + "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : html;
1957
1960
  head.html = head.scripts = "";
1958
- return html + (scripts ? "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : "");
1961
+ if (__flush__) {
1962
+ $global2.__flush__ = void 0;
1963
+ return __flush__($global2, result);
1964
+ }
1965
+ return result;
1959
1966
  }
1960
1967
  function concatEffects(a, b) {
1961
1968
  return a ? b ? a + "," + b : a : b;
@@ -1882,8 +1882,15 @@ function prepareChunk(chunk) {
1882
1882
  }
1883
1883
  function flushChunk(head) {
1884
1884
  const { html, scripts } = head;
1885
+ const { $global: $global2 } = head.boundary.state;
1886
+ const { __flush__ } = $global2;
1887
+ const result = scripts ? html + "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : html;
1885
1888
  head.html = head.scripts = "";
1886
- return html + (scripts ? "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : "");
1889
+ if (__flush__) {
1890
+ $global2.__flush__ = void 0;
1891
+ return __flush__($global2, result);
1892
+ }
1893
+ return result;
1887
1894
  }
1888
1895
  function concatEffects(a, b) {
1889
1896
  return a ? b ? a + "," + b : a : b;
@@ -29,6 +29,8 @@ export declare function childClosures(closureSignals: IntersectionSignal[], chil
29
29
  export declare function dynamicSubscribers(valueAccessor: Accessor): (scope: Scope, op: SignalOp) => void;
30
30
  export declare function setTagVar(scope: Scope, childAccessor: Accessor, tagVarSignal: ValueSignal): void;
31
31
  export declare const tagVarSignal: (scope: Scope, valueOrOp: unknown | SignalOp) => any;
32
+ export declare function setTagVarChange(scope: Scope, changeHandler: (value: unknown) => void): void;
33
+ export declare const tagVarSignalChange: (scope: Scope, value: unknown) => any;
32
34
  export declare const renderBodyClosures: (renderBody: Renderer | string | undefined, childScope: Scope, op: SignalOp) => void;
33
35
  export declare const inMany: (scopes: Scope[], op: SignalOp, signal: IntersectionSignal) => void;
34
36
  export declare function nextTagId({ $global }: Scope): string;
package/dist/dom.d.ts CHANGED
@@ -11,5 +11,5 @@ export { run } from "./dom/queue";
11
11
  export { createRenderer, createRendererWithOwner, dynamicTagAttrs, } from "./dom/renderer";
12
12
  export { init, nodeRef, register, registerBoundSignal, registerSubscriber, } from "./dom/resume";
13
13
  export { createScope } from "./dom/scope";
14
- export { childClosures, closure, dynamicClosure, dynamicSubscribers, effect, inChild, intersection, intersections, nextTagId, setTagVar, state, tagVarSignal, value, } from "./dom/signals";
14
+ export { childClosures, closure, dynamicClosure, dynamicSubscribers, effect, inChild, intersection, intersections, nextTagId, setTagVar, setTagVarChange, state, tagVarSignal, tagVarSignalChange, value, } from "./dom/signals";
15
15
  export { createTemplate } from "./dom/template";
package/dist/dom.js CHANGED
@@ -75,9 +75,11 @@ __export(dom_exports, {
75
75
  resetAbortSignal: () => resetAbortSignal,
76
76
  run: () => run,
77
77
  setTagVar: () => setTagVar,
78
+ setTagVarChange: () => setTagVarChange,
78
79
  state: () => state,
79
80
  styleAttr: () => styleAttr,
80
81
  tagVarSignal: () => tagVarSignal,
82
+ tagVarSignalChange: () => tagVarSignalChange,
81
83
  value: () => value
82
84
  });
83
85
  module.exports = __toCommonJS(dom_exports);
@@ -381,7 +383,11 @@ function dynamicSubscribers(valueAccessor) {
381
383
  function setTagVar(scope, childAccessor, tagVarSignal2) {
382
384
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
383
385
  }
384
- var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp), renderBodyClosures = (renderBody, childScope, op) => {
386
+ var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
387
+ function setTagVarChange(scope, changeHandler) {
388
+ scope["@" /* TagVariableChange */] = changeHandler;
389
+ }
390
+ var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2), renderBodyClosures = (renderBody, childScope, op) => {
385
391
  let signals = renderBody?.c;
386
392
  if (signals)
387
393
  for (let signal of signals)
package/dist/dom.mjs CHANGED
@@ -297,7 +297,11 @@ function dynamicSubscribers(valueAccessor) {
297
297
  function setTagVar(scope, childAccessor, tagVarSignal2) {
298
298
  scope[childAccessor]["/" /* TagVariable */] = (valueOrOp) => tagVarSignal2(scope, valueOrOp);
299
299
  }
300
- var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp), renderBodyClosures = (renderBody, childScope, op) => {
300
+ var tagVarSignal = (scope, valueOrOp) => scope["/" /* TagVariable */]?.(valueOrOp);
301
+ function setTagVarChange(scope, changeHandler) {
302
+ scope["@" /* TagVariableChange */] = changeHandler;
303
+ }
304
+ var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2), renderBodyClosures = (renderBody, childScope, op) => {
301
305
  let signals = renderBody?.c;
302
306
  if (signals)
303
307
  for (let signal of signals)
@@ -1328,8 +1332,10 @@ export {
1328
1332
  resetAbortSignal,
1329
1333
  run,
1330
1334
  setTagVar,
1335
+ setTagVarChange,
1331
1336
  state,
1332
1337
  styleAttr,
1333
1338
  tagVarSignal,
1339
+ tagVarSignalChange,
1334
1340
  value
1335
1341
  };
@@ -1,4 +1,4 @@
1
- import type { Accessor } from "../common/types";
1
+ import type { $Global, Accessor } from "../common/types";
2
2
  import { Serializer } from "./serializer";
3
3
  export type PartialScope = Record<Accessor, unknown>;
4
4
  type ScopeInternals = PartialScope & {
@@ -36,7 +36,7 @@ export declare function markResumeCleanup(scopeId: number): string;
36
36
  export declare function writeScope(scopeId: number, partialScope: PartialScope): ScopeInternals;
37
37
  export declare function writeExistingScope(scope: ScopeInternals): ScopeInternals;
38
38
  export declare function ensureScopeWithId(scopeId: number): PartialScope;
39
- export declare function $global(): Record<string, unknown> & {
39
+ export declare function $global(): $Global & {
40
40
  renderId: string;
41
41
  runtimeId: string;
42
42
  };
@@ -44,7 +44,7 @@ export declare function fork<T>(promise: Promise<T> | T, renderBody: (value: T)
44
44
  export declare function tryPlaceholder(renderBody: () => void, renderPlaceholder: () => void): void;
45
45
  export declare function tryCatch(renderBody: () => void, renderCatch: (err: unknown) => void): void;
46
46
  export declare class State {
47
- $global: Record<string, unknown> & {
47
+ $global: $Global & {
48
48
  renderId: string;
49
49
  runtimeId: string;
50
50
  };
@@ -62,7 +62,7 @@ export declare class State {
62
62
  writeScopes: null | (Record<number, PartialScope> & {
63
63
  $?: unknown;
64
64
  });
65
- constructor($global: Record<string, unknown> & {
65
+ constructor($global: $Global & {
66
66
  renderId: string;
67
67
  runtimeId: string;
68
68
  });
package/dist/html.js CHANGED
@@ -1273,8 +1273,8 @@ function prepareChunk(chunk) {
1273
1273
  return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
1274
1274
  }
1275
1275
  function flushChunk(head) {
1276
- let { html, scripts } = head;
1277
- return head.html = head.scripts = "", html + (scripts ? "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : "");
1276
+ let { html, scripts } = head, { $global: $global2 } = head.boundary.state, { __flush__ } = $global2, result = scripts ? html + "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : html;
1277
+ return head.html = head.scripts = "", __flush__ ? ($global2.__flush__ = void 0, __flush__($global2, result)) : result;
1278
1278
  }
1279
1279
  function concatEffects(a, b) {
1280
1280
  return a ? b ? a + "," + b : a : b;
package/dist/html.mjs CHANGED
@@ -1204,8 +1204,8 @@ function prepareChunk(chunk) {
1204
1204
  return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
1205
1205
  }
1206
1206
  function flushChunk(head) {
1207
- let { html, scripts } = head;
1208
- return head.html = head.scripts = "", html + (scripts ? "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : "");
1207
+ let { html, scripts } = head, { $global: $global2 } = head.boundary.state, { __flush__ } = $global2, result = scripts ? html + "<script" + (head.boundary.state.$global.cspNonce ? " nonce=" + escapeAttrValue(head.boundary.state.$global.cspNonce + "") : "") + ">" + scripts + "</script>" : html;
1208
+ return head.html = head.scripts = "", __flush__ ? ($global2.__flush__ = void 0, __flush__($global2, result)) : result;
1209
1209
  }
1210
1210
  function concatEffects(a, b) {
1211
1211
  return a ? b ? a + "," + b : a : b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "0.1.25",
3
+ "version": "0.2.1",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",