marko 6.0.3 → 6.0.5

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/dom.js CHANGED
@@ -24,6 +24,8 @@ __export(dom_exports, {
24
24
  attrsEvents: () => attrsEvents,
25
25
  awaitTag: () => awaitTag,
26
26
  classAttr: () => classAttr,
27
+ classItem: () => classItem,
28
+ classItems: () => classItems,
27
29
  compat: () => compat,
28
30
  conditional: () => conditional,
29
31
  conditionalClosure: () => conditionalClosure,
@@ -76,6 +78,9 @@ __export(dom_exports, {
76
78
  setTagVarChange: () => setTagVarChange,
77
79
  state: () => state,
78
80
  styleAttr: () => styleAttr,
81
+ styleItem: () => styleItem,
82
+ styleItemValue: () => styleItemValue,
83
+ styleItems: () => styleItems,
79
84
  tagVarSignal: () => tagVarSignal,
80
85
  tagVarSignalChange: () => tagVarSignalChange,
81
86
  textContent: () => textContent,
@@ -114,39 +119,30 @@ function forTo(to, from, step, cb) {
114
119
  }
115
120
 
116
121
  // src/common/helpers.ts
117
- function classValue(value2) {
118
- return toDelimitedString(value2, " ", stringifyClassObject);
122
+ function classValue(classValue2) {
123
+ return toDelimitedString(classValue2, " ", stringifyClassObject);
119
124
  }
120
125
  function stringifyClassObject(name, value2) {
121
126
  return value2 ? name : "";
122
127
  }
123
- function styleValue(value2) {
124
- return toDelimitedString(value2, ";", stringifyStyleObject);
128
+ function styleValue(styleValue2) {
129
+ return toDelimitedString(styleValue2, ";", stringifyStyleObject);
125
130
  }
126
131
  function stringifyStyleObject(name, value2) {
127
- return value2 || value2 === 0 ? `${name}:${typeof value2 == "number" && value2 && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value2 + "px" : value2}` : "";
132
+ return value2 || value2 === 0 ? `${name}:${value2 && typeof value2 == "number" && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value2 + "px" : value2}` : "";
128
133
  }
129
134
  function toDelimitedString(val, delimiter, stringify) {
130
- switch (typeof val) {
131
- case "string":
132
- return val;
133
- case "object":
134
- if (val !== null) {
135
- let result = "", curDelimiter = "";
136
- if (Array.isArray(val))
137
- for (let v of val) {
138
- let part = toDelimitedString(v, delimiter, stringify);
139
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
140
- }
141
- else
142
- for (let name in val) {
143
- let v = val[name], part = stringify(name, v);
144
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
145
- }
146
- return result;
147
- }
148
- }
149
- return "";
135
+ let str = "", sep = "", part;
136
+ if (val)
137
+ if (typeof val != "object")
138
+ str += val;
139
+ else if (Array.isArray(val))
140
+ for (let v of val)
141
+ part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
142
+ else
143
+ for (let name in val)
144
+ part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
145
+ return str;
150
146
  }
151
147
  function isEventHandler(name) {
152
148
  return /^on[A-Z-]/.test(name);
@@ -208,27 +204,20 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
208
204
  // src/dom/resume.ts
209
205
  var registeredValues = {};
210
206
  function init(runtimeId = DEFAULT_RUNTIME_ID) {
211
- let renders = window[runtimeId], defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
207
+ let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
212
208
  defineRuntime({
213
209
  value: resumeRender = (renderId) => {
214
210
  let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, branchStack = [], scopeLookup = render.s = {}, serializeContext = {
215
211
  _: registeredValues
216
- }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEffect, currentBranchId, $global, lastScopeId = 0;
212
+ }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), branchEnd = (branchId, reference) => {
213
+ let branch = scopeLookup[branchId] ||= {}, endNode = reference, prevNode;
214
+ for (; (prevNode = endNode.previousSibling) !== branch.h && ~visits.indexOf(endNode = prevNode); ) ;
215
+ return branch.j = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode, branch.h ||= lastEndNode, branchIds.add(branchId), branch;
216
+ }, currentBranchId, $global, lastScopeId = 0, lastEffect, lastEndNode, visits, resumes;
217
217
  return render.w = () => {
218
- walk2.call(render);
219
- let visits = render.v, resumes = render.r;
220
- if (visits.length) {
221
- let visitNodes = new Set(visits), lastEndNode;
222
- visits.length = 0;
223
- let branchEnd = (branchId, reference) => {
224
- let branch = scopeLookup[branchId] ||= {}, endNode = reference;
225
- for (; endNode.previousSibling !== branch.h && visitNodes.has(endNode = endNode.previousSibling); ) ;
226
- return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
227
- new Text(),
228
- reference
229
- )), branch.j = lastEndNode = endNode, branch.h ||= endNode, branchIds.add(branchId), branch;
230
- };
231
- for (let visit of visitNodes) {
218
+ try {
219
+ walk2.call(render), isResuming = 1;
220
+ for (let visit of visits = render.v) {
232
221
  let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = +commentText.slice(
233
222
  commentPrefixLen + 1,
234
223
  dataIndex ? dataIndex - 1 : commentText.length
@@ -260,41 +249,37 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
260
249
  }
261
250
  }
262
251
  }
263
- }
264
- if (resumes)
265
- try {
266
- render.r = [], isResuming = 1;
267
- for (let i = 0; i < resumes.length; i++) {
268
- let serialized = resumes[i];
269
- if (typeof serialized == "function")
270
- for (let scope of serialized(serializeContext))
271
- if (!$global)
272
- $global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.o = 1e6;
273
- else if (typeof scope == "number")
274
- lastScopeId += scope;
275
- else {
276
- let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
277
- scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
278
- scope,
279
- prevScope
252
+ for (let serialized of resumes = render.r || [])
253
+ if (typeof serialized == "string")
254
+ lastEffect = serialized;
255
+ else if (typeof serialized == "number")
256
+ registeredValues[lastEffect](
257
+ scopeLookup[serialized],
258
+ scopeLookup[serialized]
259
+ );
260
+ else
261
+ for (let scope of serialized(serializeContext))
262
+ if (!$global)
263
+ $global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.o = 1e6;
264
+ else if (typeof scope == "number")
265
+ lastScopeId += scope;
266
+ else {
267
+ let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
268
+ scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
269
+ scope,
270
+ prevScope
271
+ ));
272
+ let parentBranchId = scope.g || parentBranchIds.get(scopeId);
273
+ if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
274
+ let branch = scope, parentBranch = branch.k;
275
+ scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
276
+ branch
280
277
  ));
281
- let parentBranchId = scope.g || parentBranchIds.get(scopeId);
282
- if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
283
- let branch = scope, parentBranch = branch.k;
284
- scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
285
- branch
286
- ));
287
- }
288
278
  }
289
- else
290
- typeof serialized == "string" && (lastEffect = serialized, serialized = resumes[++i]), registeredValues[lastEffect](
291
- scopeLookup[serialized],
292
- scopeLookup[serialized]
293
- );
294
- }
295
- } finally {
296
- isResuming = 0;
297
- }
279
+ }
280
+ } finally {
281
+ isResuming = visits.length = resumes.length = 0;
282
+ }
298
283
  }, render;
299
284
  }
300
285
  });
@@ -526,9 +511,26 @@ function setAttribute(element, name, value2) {
526
511
  function classAttr(element, value2) {
527
512
  setAttribute(element, "class", classValue(value2) || void 0);
528
513
  }
514
+ function classItems(element, items) {
515
+ for (let key in items)
516
+ classItem(element, key, items[key]);
517
+ }
518
+ function classItem(element, name, value2) {
519
+ element.classList.toggle(name, !!value2);
520
+ }
529
521
  function styleAttr(element, value2) {
530
522
  setAttribute(element, "style", styleValue(value2) || void 0);
531
523
  }
524
+ function styleItems(element, items) {
525
+ for (let key in items)
526
+ styleItem(element, key, items[key]);
527
+ }
528
+ function styleItem(element, name, value2) {
529
+ element.style.setProperty(name, value2 || value2 === 0 ? value2 + "" : "");
530
+ }
531
+ function styleItemValue(value2) {
532
+ return value2 && typeof value2 == "number" ? value2 + "px" : value2;
533
+ }
532
534
  function data(node, value2) {
533
535
  let normalizedValue = normalizeString(value2);
534
536
  node.data !== normalizedValue && (node.data = normalizedValue);
@@ -708,7 +710,6 @@ function toInsertNode(startNode, endNode) {
708
710
  }
709
711
 
710
712
  // src/dom/scope.ts
711
- var pendingScopes = [];
712
713
  function createScope($global, closestBranch) {
713
714
  let scope = {
714
715
  m: $global.o++,
@@ -721,11 +722,6 @@ function createScope($global, closestBranch) {
721
722
  function skipScope(scope) {
722
723
  return scope.$global.o++;
723
724
  }
724
- function finishPendingScopes() {
725
- for (let scope of pendingScopes)
726
- scope.p = 0;
727
- pendingScopes = [];
728
- }
729
725
  function findBranchWithKey(scope, key) {
730
726
  let branch = scope.k;
731
727
  for (; branch && !branch[key]; )
@@ -951,12 +947,7 @@ function createCloneableHTML(html2, ns) {
951
947
  }
952
948
 
953
949
  // src/dom/schedule.ts
954
- var port2 = /* @__PURE__ */ (() => {
955
- let { port1, port2: port22 } = new MessageChannel();
956
- return port1.onmessage = () => {
957
- isScheduled = 0, run();
958
- }, port22;
959
- })(), isScheduled;
950
+ var isScheduled, channel;
960
951
  function schedule() {
961
952
  isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
962
953
  }
@@ -964,7 +955,9 @@ function flushAndWaitFrame() {
964
955
  run(), requestAnimationFrame(triggerMacroTask);
965
956
  }
966
957
  function triggerMacroTask() {
967
- port2.postMessage(0);
958
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
959
+ isScheduled = 0, run();
960
+ }), channel.port2.postMessage(0);
968
961
  }
969
962
 
970
963
  // src/dom/signals.ts
@@ -1313,7 +1306,7 @@ function byFirstArg(name) {
1313
1306
  }
1314
1307
 
1315
1308
  // src/dom/queue.ts
1316
- var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering, scopeKeyOffset = 1e3;
1309
+ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
1317
1310
  function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
1318
1311
  let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
1319
1312
  if (existingRender)
@@ -1377,7 +1370,9 @@ function runRenders() {
1377
1370
  }
1378
1371
  render.D.k?.A || runRender(render);
1379
1372
  }
1380
- finishPendingScopes();
1373
+ for (let scope of pendingScopes)
1374
+ scope.p = 0;
1375
+ pendingScopes = [];
1381
1376
  }
1382
1377
  var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
1383
1378
  enableCatch = () => {
@@ -1453,7 +1448,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1453
1448
  }) {
1454
1449
  return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
1455
1450
  value2[0],
1456
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.s[value2[1]]
1451
+ value2.length === 2 && self[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.s[value2[1]]
1457
1452
  ) : value2;
1458
1453
  },
1459
1454
  createRenderer(params, clone) {
package/dist/dom.mjs CHANGED
@@ -29,39 +29,30 @@ function forTo(to, from, step, cb) {
29
29
  }
30
30
 
31
31
  // src/common/helpers.ts
32
- function classValue(value2) {
33
- return toDelimitedString(value2, " ", stringifyClassObject);
32
+ function classValue(classValue2) {
33
+ return toDelimitedString(classValue2, " ", stringifyClassObject);
34
34
  }
35
35
  function stringifyClassObject(name, value2) {
36
36
  return value2 ? name : "";
37
37
  }
38
- function styleValue(value2) {
39
- return toDelimitedString(value2, ";", stringifyStyleObject);
38
+ function styleValue(styleValue2) {
39
+ return toDelimitedString(styleValue2, ";", stringifyStyleObject);
40
40
  }
41
41
  function stringifyStyleObject(name, value2) {
42
- return value2 || value2 === 0 ? `${name}:${typeof value2 == "number" && value2 && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value2 + "px" : value2}` : "";
42
+ return value2 || value2 === 0 ? `${name}:${value2 && typeof value2 == "number" && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value2 + "px" : value2}` : "";
43
43
  }
44
44
  function toDelimitedString(val, delimiter, stringify) {
45
- switch (typeof val) {
46
- case "string":
47
- return val;
48
- case "object":
49
- if (val !== null) {
50
- let result = "", curDelimiter = "";
51
- if (Array.isArray(val))
52
- for (let v of val) {
53
- let part = toDelimitedString(v, delimiter, stringify);
54
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
55
- }
56
- else
57
- for (let name in val) {
58
- let v = val[name], part = stringify(name, v);
59
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
60
- }
61
- return result;
62
- }
63
- }
64
- return "";
45
+ let str = "", sep = "", part;
46
+ if (val)
47
+ if (typeof val != "object")
48
+ str += val;
49
+ else if (Array.isArray(val))
50
+ for (let v of val)
51
+ part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
52
+ else
53
+ for (let name in val)
54
+ part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
55
+ return str;
65
56
  }
66
57
  function isEventHandler(name) {
67
58
  return /^on[A-Z-]/.test(name);
@@ -123,27 +114,20 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
123
114
  // src/dom/resume.ts
124
115
  var registeredValues = {};
125
116
  function init(runtimeId = DEFAULT_RUNTIME_ID) {
126
- let renders = window[runtimeId], defineRuntime = (desc) => Object.defineProperty(window, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
117
+ let renders = self[runtimeId], defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc), resumeRender, initRuntime = (renders2) => {
127
118
  defineRuntime({
128
119
  value: resumeRender = (renderId) => {
129
120
  let render = resumeRender[renderId] = renders2[renderId] || renders2(renderId), walk2 = render.w, commentPrefixLen = render.i.length, branchStack = [], scopeLookup = render.s = {}, serializeContext = {
130
121
  _: registeredValues
131
- }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), lastEffect, currentBranchId, $global, lastScopeId = 0;
122
+ }, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map(), branchEnd = (branchId, reference) => {
123
+ let branch = scopeLookup[branchId] ||= {}, endNode = reference, prevNode;
124
+ for (; (prevNode = endNode.previousSibling) !== branch.h && ~visits.indexOf(endNode = prevNode); ) ;
125
+ return branch.j = lastEndNode = endNode === lastEndNode ? reference.parentNode.insertBefore(new Text(), reference) : endNode, branch.h ||= lastEndNode, branchIds.add(branchId), branch;
126
+ }, currentBranchId, $global, lastScopeId = 0, lastEffect, lastEndNode, visits, resumes;
132
127
  return render.w = () => {
133
- walk2.call(render);
134
- let visits = render.v, resumes = render.r;
135
- if (visits.length) {
136
- let visitNodes = new Set(visits), lastEndNode;
137
- visits.length = 0;
138
- let branchEnd = (branchId, reference) => {
139
- let branch = scopeLookup[branchId] ||= {}, endNode = reference;
140
- for (; endNode.previousSibling !== branch.h && visitNodes.has(endNode = endNode.previousSibling); ) ;
141
- return endNode === lastEndNode && (endNode = reference.parentNode.insertBefore(
142
- new Text(),
143
- reference
144
- )), branch.j = lastEndNode = endNode, branch.h ||= endNode, branchIds.add(branchId), branch;
145
- };
146
- for (let visit of visitNodes) {
128
+ try {
129
+ walk2.call(render), isResuming = 1;
130
+ for (let visit of visits = render.v) {
147
131
  let commentText = visit.data, dataIndex = commentText.indexOf(" ") + 1, scopeId = +commentText.slice(
148
132
  commentPrefixLen + 1,
149
133
  dataIndex ? dataIndex - 1 : commentText.length
@@ -175,41 +159,37 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
175
159
  }
176
160
  }
177
161
  }
178
- }
179
- if (resumes)
180
- try {
181
- render.r = [], isResuming = 1;
182
- for (let i = 0; i < resumes.length; i++) {
183
- let serialized = resumes[i];
184
- if (typeof serialized == "function")
185
- for (let scope of serialized(serializeContext))
186
- if (!$global)
187
- $global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.o = 1e6;
188
- else if (typeof scope == "number")
189
- lastScopeId += scope;
190
- else {
191
- let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
192
- scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
193
- scope,
194
- prevScope
162
+ for (let serialized of resumes = render.r || [])
163
+ if (typeof serialized == "string")
164
+ lastEffect = serialized;
165
+ else if (typeof serialized == "number")
166
+ registeredValues[lastEffect](
167
+ scopeLookup[serialized],
168
+ scopeLookup[serialized]
169
+ );
170
+ else
171
+ for (let scope of serialized(serializeContext))
172
+ if (!$global)
173
+ $global = scope || {}, $global.runtimeId = runtimeId, $global.renderId = renderId, $global.o = 1e6;
174
+ else if (typeof scope == "number")
175
+ lastScopeId += scope;
176
+ else {
177
+ let scopeId = ++lastScopeId, prevScope = scopeLookup[scopeId];
178
+ scope.$global = $global, scope.m = scopeId, prevScope !== scope && (scopeLookup[scopeId] = Object.assign(
179
+ scope,
180
+ prevScope
181
+ ));
182
+ let parentBranchId = scope.g || parentBranchIds.get(scopeId);
183
+ if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
184
+ let branch = scope, parentBranch = branch.k;
185
+ scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
186
+ branch
195
187
  ));
196
- let parentBranchId = scope.g || parentBranchIds.get(scopeId);
197
- if (parentBranchId && (scope.k = scopeLookup[parentBranchId]), branchIds.has(scopeId)) {
198
- let branch = scope, parentBranch = branch.k;
199
- scope.k = branch, parentBranch && (branch.t = parentBranch, (parentBranch.z ||= /* @__PURE__ */ new Set()).add(
200
- branch
201
- ));
202
- }
203
188
  }
204
- else
205
- typeof serialized == "string" && (lastEffect = serialized, serialized = resumes[++i]), registeredValues[lastEffect](
206
- scopeLookup[serialized],
207
- scopeLookup[serialized]
208
- );
209
- }
210
- } finally {
211
- isResuming = 0;
212
- }
189
+ }
190
+ } finally {
191
+ isResuming = visits.length = resumes.length = 0;
192
+ }
213
193
  }, render;
214
194
  }
215
195
  });
@@ -441,9 +421,26 @@ function setAttribute(element, name, value2) {
441
421
  function classAttr(element, value2) {
442
422
  setAttribute(element, "class", classValue(value2) || void 0);
443
423
  }
424
+ function classItems(element, items) {
425
+ for (let key in items)
426
+ classItem(element, key, items[key]);
427
+ }
428
+ function classItem(element, name, value2) {
429
+ element.classList.toggle(name, !!value2);
430
+ }
444
431
  function styleAttr(element, value2) {
445
432
  setAttribute(element, "style", styleValue(value2) || void 0);
446
433
  }
434
+ function styleItems(element, items) {
435
+ for (let key in items)
436
+ styleItem(element, key, items[key]);
437
+ }
438
+ function styleItem(element, name, value2) {
439
+ element.style.setProperty(name, value2 || value2 === 0 ? value2 + "" : "");
440
+ }
441
+ function styleItemValue(value2) {
442
+ return value2 && typeof value2 == "number" ? value2 + "px" : value2;
443
+ }
447
444
  function data(node, value2) {
448
445
  let normalizedValue = normalizeString(value2);
449
446
  node.data !== normalizedValue && (node.data = normalizedValue);
@@ -623,7 +620,6 @@ function toInsertNode(startNode, endNode) {
623
620
  }
624
621
 
625
622
  // src/dom/scope.ts
626
- var pendingScopes = [];
627
623
  function createScope($global, closestBranch) {
628
624
  let scope = {
629
625
  m: $global.o++,
@@ -636,11 +632,6 @@ function createScope($global, closestBranch) {
636
632
  function skipScope(scope) {
637
633
  return scope.$global.o++;
638
634
  }
639
- function finishPendingScopes() {
640
- for (let scope of pendingScopes)
641
- scope.p = 0;
642
- pendingScopes = [];
643
- }
644
635
  function findBranchWithKey(scope, key) {
645
636
  let branch = scope.k;
646
637
  for (; branch && !branch[key]; )
@@ -866,12 +857,7 @@ function createCloneableHTML(html2, ns) {
866
857
  }
867
858
 
868
859
  // src/dom/schedule.ts
869
- var port2 = /* @__PURE__ */ (() => {
870
- let { port1, port2: port22 } = new MessageChannel();
871
- return port1.onmessage = () => {
872
- isScheduled = 0, run();
873
- }, port22;
874
- })(), isScheduled;
860
+ var isScheduled, channel;
875
861
  function schedule() {
876
862
  isScheduled || (isScheduled = 1, queueMicrotask(flushAndWaitFrame));
877
863
  }
@@ -879,7 +865,9 @@ function flushAndWaitFrame() {
879
865
  run(), requestAnimationFrame(triggerMacroTask);
880
866
  }
881
867
  function triggerMacroTask() {
882
- port2.postMessage(0);
868
+ channel || (channel = new MessageChannel(), channel.port1.onmessage = () => {
869
+ isScheduled = 0, run();
870
+ }), channel.port2.postMessage(0);
883
871
  }
884
872
 
885
873
  // src/dom/signals.ts
@@ -1228,7 +1216,7 @@ function byFirstArg(name) {
1228
1216
  }
1229
1217
 
1230
1218
  // src/dom/queue.ts
1231
- var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], rendering, scopeKeyOffset = 1e3;
1219
+ var pendingRenders = [], pendingRendersLookup = /* @__PURE__ */ new Map(), caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingScopes = [], rendering, scopeKeyOffset = 1e3;
1232
1220
  function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
1233
1221
  let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
1234
1222
  if (existingRender)
@@ -1292,7 +1280,9 @@ function runRenders() {
1292
1280
  }
1293
1281
  render.D.k?.A || runRender(render);
1294
1282
  }
1295
- finishPendingScopes();
1283
+ for (let scope of pendingScopes)
1284
+ scope.p = 0;
1285
+ pendingScopes = [];
1296
1286
  }
1297
1287
  var runRender = (render) => render.L(render.D, render.I), enableCatch = () => {
1298
1288
  enableCatch = () => {
@@ -1368,7 +1358,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
1368
1358
  }) {
1369
1359
  return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
1370
1360
  value2[0],
1371
- value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.s[value2[1]]
1361
+ value2.length === 2 && self[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.s[value2[1]]
1372
1362
  ) : value2;
1373
1363
  },
1374
1364
  createRenderer(params, clone) {
@@ -1466,6 +1456,8 @@ export {
1466
1456
  attrsEvents,
1467
1457
  awaitTag,
1468
1458
  classAttr,
1459
+ classItem,
1460
+ classItems,
1469
1461
  compat,
1470
1462
  conditional,
1471
1463
  conditionalClosure,
@@ -1518,6 +1510,9 @@ export {
1518
1510
  setTagVarChange,
1519
1511
  state,
1520
1512
  styleAttr,
1513
+ styleItem,
1514
+ styleItemValue,
1515
+ styleItems,
1521
1516
  tagVarSignal,
1522
1517
  tagVarSignalChange,
1523
1518
  textContent,
@@ -4,7 +4,7 @@ interface BodyContentObject {
4
4
  [x: PropertyKey]: unknown;
5
5
  content: ServerRenderer;
6
6
  }
7
- export declare let dynamicTag: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, inputOrArgs: unknown, content?: (() => void) | 0, inputIsArgs?: 1, shouldResume?: 1 | 0) => unknown;
7
+ export declare let dynamicTag: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject, inputOrArgs: unknown, content?: (() => void) | 0, inputIsArgs?: 1, serializeReason?: 1 | 0) => unknown;
8
8
  export declare function createContent(id: string, fn: ServerRenderer): ServerRenderer;
9
9
  export declare function registerContent(id: string, fn: ServerRenderer, scopeId?: number): ServerRenderer;
10
10
  export declare function patchDynamicTag(patch: (scopeId: number, accessor: Accessor, tag: unknown | string | ServerRenderer | BodyContentObject) => unknown): void;
@@ -35,14 +35,14 @@ export declare function hoist(scopeId: number, id?: string): {
35
35
  };
36
36
  export declare function resumeClosestBranch(scopeId: number): void;
37
37
  export declare function withBranchId<T>(branchId: number, cb: () => T): T;
38
- export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1): void;
39
- export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, onlyChildInParent?: 1): void;
40
- export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1): void;
41
- export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, onlyChild?: 1): void;
42
- export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1): void;
43
- export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, onlyChild?: 1): void;
44
- export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 1): number | void;
45
- export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChild?: 1): number | void;
38
+ export declare function resumeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
39
+ export declare function resumeSingleNodeForOf(list: Falsy | Iterable<unknown>, cb: (item: unknown, index: number) => void, by: Falsy | ((item: unknown, index: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
40
+ export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
41
+ export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
42
+ export declare function resumeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
43
+ export declare function resumeSingleNodeForTo(to: number, from: number | Falsy, step: number | Falsy, cb: (index: number) => void, by: Falsy | ((v: number) => unknown), scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
44
+ export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1): void;
45
+ export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, serializeBranch?: 0 | 1, serializeMarker?: 0 | 1, onlyChildInParent?: 1): void;
46
46
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
47
47
  export { writeScope };
48
48
  export declare function writeExistingScope(scopeId: number): ScopeInternals;