marko 6.0.0-next.3.85 → 6.0.0

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
@@ -1048,7 +1048,10 @@ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
1048
1048
  }
1049
1049
  function closure(valueAccessor, fn, getOwnerScope) {
1050
1050
  return (scope) => {
1051
- fn(scope, (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]);
1051
+ fn(
1052
+ scope,
1053
+ (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
1054
+ );
1052
1055
  };
1053
1056
  }
1054
1057
  function setTagVar(scope, childAccessor, tagVarSignal2) {
@@ -1166,14 +1169,14 @@ function createTry(nodeAccessor, tryContent) {
1166
1169
  function renderCatch(scope, error) {
1167
1170
  let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
1168
1171
  if (tryWithCatch) {
1169
- let placeholderBranch = tryWithCatch.c;
1170
- placeholderBranch && (tryWithCatch.n = 0, tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1171
- tryWithCatch._,
1172
+ let owner = tryWithCatch._, placeholderBranch = tryWithCatch.c;
1173
+ placeholderBranch && (tryWithCatch.n = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1174
+ owner,
1172
1175
  tryWithCatch.a,
1173
1176
  tryWithCatch.b,
1174
1177
  createAndSetupBranch
1175
1178
  ), tryWithCatch.b.l?.(
1176
- tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
1179
+ owner["d" /* ConditionalScope */ + tryWithCatch.a],
1177
1180
  [error]
1178
1181
  );
1179
1182
  } else
package/dist/dom.mjs CHANGED
@@ -963,7 +963,10 @@ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
963
963
  }
964
964
  function closure(valueAccessor, fn, getOwnerScope) {
965
965
  return (scope) => {
966
- fn(scope, (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]);
966
+ fn(
967
+ scope,
968
+ (getOwnerScope ? getOwnerScope(scope) : scope._)[valueAccessor]
969
+ );
967
970
  };
968
971
  }
969
972
  function setTagVar(scope, childAccessor, tagVarSignal2) {
@@ -1081,14 +1084,14 @@ function createTry(nodeAccessor, tryContent) {
1081
1084
  function renderCatch(scope, error) {
1082
1085
  let tryWithCatch = findBranchWithKey(scope, "b" /* CatchContent */);
1083
1086
  if (tryWithCatch) {
1084
- let placeholderBranch = tryWithCatch.c;
1085
- placeholderBranch && (tryWithCatch.n = 0, tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1086
- tryWithCatch._,
1087
+ let owner = tryWithCatch._, placeholderBranch = tryWithCatch.c;
1088
+ placeholderBranch && (tryWithCatch.n = 0, owner["d" /* ConditionalScope */ + tryWithCatch.a] = placeholderBranch, destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), setConditionalRenderer(
1089
+ owner,
1087
1090
  tryWithCatch.a,
1088
1091
  tryWithCatch.b,
1089
1092
  createAndSetupBranch
1090
1093
  ), tryWithCatch.b.l?.(
1091
- tryWithCatch._["d" /* ConditionalScope */ + tryWithCatch.a],
1094
+ owner["d" /* ConditionalScope */ + tryWithCatch.a],
1092
1095
  [error]
1093
1096
  );
1094
1097
  } else
@@ -1,5 +1,5 @@
1
1
  import { patchDynamicTag } from "./dynamic-tag";
2
- import type { ServerRenderer } from "./template";
2
+ import { type ServerRenderer } from "./template";
3
3
  import { fork, nextScopeId, write, writeScript } from "./writer";
4
4
  export declare const compat: {
5
5
  fork: typeof fork;
@@ -1,10 +1,10 @@
1
1
  import { type Accessor } from "../common/types";
2
- import type { ServerRenderer } from "./template";
2
+ import { type ServerRenderer } from "./template";
3
3
  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, resume?: 1) => unknown;
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;
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;
@@ -3,3 +3,4 @@ export type ServerRenderer = ((...args: unknown[]) => unknown) & {
3
3
  ___id?: string;
4
4
  };
5
5
  export declare const createTemplate: (templateId: string, renderer: ServerRenderer) => Template;
6
+ export declare function isTemplate(renderer: ServerRenderer | Template): renderer is ServerRenderer & Template;
@@ -18,14 +18,16 @@ export declare function write(html: string): void;
18
18
  export declare function writeScript(script: string): void;
19
19
  export declare function writeEffect(scopeId: number, registryId: string): void;
20
20
  export declare function withContext<T>(key: PropertyKey, value: unknown, cb: () => T): T;
21
- export declare function setTagVar(parentScopeId: number, scopeOffsetAccessor: Accessor, childScope: PartialScope, registryId: string): void;
21
+ export declare function setTagVar(parentScopeId: number, scopeOffsetAccessor: Accessor, childScopeId: number, registryId: string): void;
22
22
  export declare function register<T extends WeakKey>(val: T, id: string, scopeId?: number): T;
23
23
  export declare function nextTagId(): string;
24
24
  export declare function nextScopeId(): number;
25
25
  export declare function peekNextScopeId(): number;
26
- export declare function peekNextScope(): PartialScope;
27
26
  export declare function getScopeById(scopeId: number | undefined): PartialScope | undefined;
28
- export declare function markResumeNode(scopeId: number, accessor: Accessor): string;
27
+ export declare function serializeIf(condition: undefined | 1 | Record<string, 1>, key: string): 1 | undefined;
28
+ export declare function serializeGuard(condition: undefined | 1 | Record<string, 1>, key: string): 0 | 1;
29
+ export declare function markResumeNode(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
30
+ export declare function commentSeparator(shouldResume: 0 | 1): "" | "<!>";
29
31
  export declare function nodeRef(scopeId: number, id?: string): () => void;
30
32
  export declare function hoist(scopeId: number, id?: string): {
31
33
  (): void;
@@ -33,17 +35,17 @@ export declare function hoist(scopeId: number, id?: string): {
33
35
  };
34
36
  export declare function resumeClosestBranch(scopeId: number): void;
35
37
  export declare function withBranchId<T>(branchId: number, cb: () => T): T;
36
- 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): void;
37
- 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, onlyChildInParent?: 1): void;
38
- export declare function resumeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor): void;
39
- export declare function resumeSingleNodeForIn(obj: Falsy | {}, cb: (key: string, value: unknown) => void, by: Falsy | ((key: string, v: unknown) => unknown), scopeId: number, accessor: Accessor, onlyChild?: 1): void;
40
- 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): void;
41
- 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, onlyChild?: 1): void;
42
- export declare function resumeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, dynamic?: 1): void;
43
- export declare function resumeSingleNodeConditional(cb: () => void | number, scopeId: number, accessor: Accessor, dynamic?: 0 | 1, onlyChild?: 1): 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): 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;
44
46
  declare let writeScope: (scopeId: number, partialScope: PartialScope) => ScopeInternals;
45
47
  export { writeScope };
46
- export declare function writeExistingScope(scope: ScopeInternals): ScopeInternals;
48
+ export declare function writeExistingScope(scopeId: number): ScopeInternals;
47
49
  export declare function ensureScopeWithId(scopeId: number): PartialScope;
48
50
  export declare function $global(): $Global & {
49
51
  renderId: string;
package/dist/html.d.ts CHANGED
@@ -5,4 +5,4 @@ export { escapeScript, escapeStyle, escapeXML, toString } from "./html/content";
5
5
  export { createContent, dynamicTag, registerContent } from "./html/dynamic-tag";
6
6
  export { forIn, forInBy, forOf, forOfBy, forTo, forToBy } from "./html/for";
7
7
  export { createTemplate } from "./html/template";
8
- export { $global, ensureScopeWithId, fork, getScopeById, hoist, markResumeNode, nextScopeId, nextTagId, nodeRef, peekNextScope, register, resumeClosestBranch, resumeConditional, resumeForIn, resumeForOf, resumeForTo, resumeSingleNodeConditional, resumeSingleNodeForIn, resumeSingleNodeForOf, resumeSingleNodeForTo, setTagVar, tryContent, write, writeEffect, writeExistingScope, writeScope, writeSubscribe, writeTrailers, } from "./html/writer";
8
+ export { $global, commentSeparator, ensureScopeWithId, fork, getScopeById, hoist, markResumeNode, nextScopeId, nextTagId, nodeRef, peekNextScopeId, register, resumeClosestBranch, resumeConditional, resumeForIn, resumeForOf, resumeForTo, resumeSingleNodeConditional, resumeSingleNodeForIn, resumeSingleNodeForOf, resumeSingleNodeForTo, serializeGuard, serializeIf, setTagVar, tryContent, write, writeEffect, writeExistingScope, writeScope, writeSubscribe, writeTrailers, } from "./html/writer";
package/dist/html.js CHANGED
@@ -23,6 +23,7 @@ __export(html_exports, {
23
23
  attrTags: () => attrTags,
24
24
  attrs: () => attrs,
25
25
  classAttr: () => classAttr,
26
+ commentSeparator: () => commentSeparator,
26
27
  compat: () => compat,
27
28
  controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
28
29
  controllable_input_checked: () => controllable_input_checked,
@@ -52,7 +53,7 @@ __export(html_exports, {
52
53
  nodeRef: () => nodeRef,
53
54
  optionValueAttr: () => optionValueAttr,
54
55
  partialAttrs: () => partialAttrs,
55
- peekNextScope: () => peekNextScope,
56
+ peekNextScopeId: () => peekNextScopeId,
56
57
  register: () => register2,
57
58
  registerContent: () => registerContent,
58
59
  resumeClosestBranch: () => resumeClosestBranch,
@@ -64,6 +65,8 @@ __export(html_exports, {
64
65
  resumeSingleNodeForIn: () => resumeSingleNodeForIn,
65
66
  resumeSingleNodeForOf: () => resumeSingleNodeForOf,
66
67
  resumeSingleNodeForTo: () => resumeSingleNodeForTo,
68
+ serializeGuard: () => serializeGuard,
69
+ serializeIf: () => serializeIf,
67
70
  setTagVar: () => setTagVar,
68
71
  styleAttr: () => styleAttr,
69
72
  toString: () => toString,
@@ -1111,8 +1114,8 @@ function withContext(key, value, cb) {
1111
1114
  ctx[kPendingContexts]--, ctx[key] = prev;
1112
1115
  }
1113
1116
  }
1114
- function setTagVar(parentScopeId, scopeOffsetAccessor, childScope, registryId) {
1115
- ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), childScope.e = register2(
1117
+ function setTagVar(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
1118
+ ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), ensureScopeWithId(childScopeId).e = register2(
1116
1119
  {},
1117
1120
  registryId,
1118
1121
  parentScopeId
@@ -1131,17 +1134,24 @@ function nextScopeId() {
1131
1134
  function peekNextScopeId() {
1132
1135
  return $chunk.boundary.state.scopeId;
1133
1136
  }
1134
- function peekNextScope() {
1135
- return ensureScopeWithId(peekNextScopeId());
1136
- }
1137
1137
  function getScopeById(scopeId) {
1138
1138
  if (scopeId !== void 0)
1139
1139
  return $chunk.boundary.state.scopes.get(scopeId);
1140
1140
  }
1141
- function markResumeNode(scopeId, accessor) {
1141
+ function serializeIf(condition, key) {
1142
+ return condition && (condition === 1 || condition[key]) ? 1 : void 0;
1143
+ }
1144
+ function serializeGuard(condition, key) {
1145
+ return condition && (condition === 1 || condition[key]) ? 1 : 0;
1146
+ }
1147
+ function markResumeNode(scopeId, accessor, shouldResume) {
1148
+ if (shouldResume === 0) return "";
1142
1149
  let { state } = $chunk.boundary;
1143
1150
  return state.needsMainRuntime = !0, state.mark("*" /* Node */, scopeId + " " + accessor);
1144
1151
  }
1152
+ function commentSeparator(shouldResume) {
1153
+ return shouldResume === 0 ? "" : "<!>";
1154
+ }
1145
1155
  function nodeRef(scopeId, id) {
1146
1156
  let getter = () => {
1147
1157
  };
@@ -1160,7 +1170,9 @@ var branchIdKey = Symbol();
1160
1170
  function withBranchId(branchId, cb) {
1161
1171
  return withContext(branchIdKey, branchId, cb);
1162
1172
  }
1163
- function resumeForOf(list, cb, by, scopeId, accessor) {
1173
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
1174
+ if (serializeBranch === 0)
1175
+ return forOf(list, cb);
1164
1176
  let loopScopes = /* @__PURE__ */ new Map();
1165
1177
  forOf(list, (item, index) => {
1166
1178
  let branchId = peekNextScopeId();
@@ -1181,7 +1193,9 @@ function resumeForOf(list, cb, by, scopeId, accessor) {
1181
1193
  )
1182
1194
  );
1183
1195
  }
1184
- function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
1196
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
1197
+ if (serializeBranch === 0)
1198
+ return forOf(list, cb);
1185
1199
  let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1186
1200
  forOf(list, (item, index) => {
1187
1201
  let branchId = peekNextScopeId();
@@ -1200,7 +1214,9 @@ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParen
1200
1214
  function forOfBy(by, item, index) {
1201
1215
  return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1202
1216
  }
1203
- function resumeForIn(obj, cb, by, scopeId, accessor) {
1217
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
1218
+ if (serializeBranch === 0)
1219
+ return forIn(obj, cb);
1204
1220
  let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1205
1221
  forIn(obj, (key, value) => {
1206
1222
  let branchId = peekNextScopeId();
@@ -1218,7 +1234,9 @@ function resumeForIn(obj, cb, by, scopeId, accessor) {
1218
1234
  )
1219
1235
  );
1220
1236
  }
1221
- function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1237
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1238
+ if (serializeBranch === 0)
1239
+ return forIn(obj, cb);
1222
1240
  let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1223
1241
  forIn(obj, (key, value) => {
1224
1242
  let branchId = peekNextScopeId();
@@ -1237,7 +1255,9 @@ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
1237
1255
  function forInBy(by, name, value) {
1238
1256
  return by ? by(name, value) : name;
1239
1257
  }
1240
- function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1258
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
1259
+ if (serializeBranch === 0)
1260
+ return forTo(to, from, step, cb);
1241
1261
  let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1242
1262
  forTo(to, from, step, (index) => {
1243
1263
  let branchId = peekNextScopeId();
@@ -1255,7 +1275,9 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
1255
1275
  )
1256
1276
  );
1257
1277
  }
1258
- function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
1278
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1279
+ if (serializeBranch === 0)
1280
+ return forTo(to, from, step, cb);
1259
1281
  let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1260
1282
  forTo(to, from, step, (index) => {
1261
1283
  let branchId = peekNextScopeId();
@@ -1274,28 +1296,32 @@ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyCh
1274
1296
  function forToBy(by, index) {
1275
1297
  return by ? by(index) : index;
1276
1298
  }
1277
- function resumeConditional(cb, scopeId, accessor, dynamic) {
1299
+ function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1300
+ if (serializeBranch === 0)
1301
+ return cb();
1278
1302
  let branchId = peekNextScopeId();
1279
- dynamic && $chunk.writeHTML(
1303
+ serializeMarker && $chunk.writeHTML(
1280
1304
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1281
1305
  );
1282
1306
  let branchIndex = withBranchId(branchId, cb);
1283
1307
  branchIndex !== void 0 ? writeScope(scopeId, {
1284
- ["c" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1308
+ ["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1285
1309
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1286
- }) : nextScopeId(), dynamic && $chunk.writeHTML(
1310
+ }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1287
1311
  $chunk.boundary.state.mark(
1288
1312
  "]" /* BranchEnd */,
1289
1313
  scopeId + " " + accessor
1290
1314
  )
1291
1315
  );
1292
1316
  }
1293
- function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
1317
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
1318
+ if (serializeBranch === 0)
1319
+ return cb();
1294
1320
  let branchId = peekNextScopeId(), branchIndex = withBranchId(branchId, cb), rendered = branchIndex !== void 0;
1295
1321
  rendered ? writeScope(scopeId, {
1296
- ["c" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
1322
+ ["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1297
1323
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1298
- }) : nextScopeId(), dynamic && $chunk.writeHTML(
1324
+ }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1299
1325
  $chunk.boundary.state.mark(
1300
1326
  onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1301
1327
  scopeId + " " + accessor + (rendered ? " " + branchId : "")
@@ -1306,8 +1332,8 @@ var writeScope = (scopeId, partialScope) => {
1306
1332
  let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
1307
1333
  return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.writeScopes = { [scopeId]: scope }, scope;
1308
1334
  };
1309
- function writeExistingScope(scope) {
1310
- return writeScope(scope[K_SCOPE_ID], scope);
1335
+ function writeExistingScope(scopeId) {
1336
+ return writeScope(scopeId, ensureScopeWithId(scopeId));
1311
1337
  }
1312
1338
  function ensureScopeWithId(scopeId) {
1313
1339
  let { state } = $chunk.boundary, scope = state.scopes.get(scopeId);
@@ -1855,153 +1881,11 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
1855
1881
  // src/common/meta.ts
1856
1882
  var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1857
1883
 
1858
- // src/html/dynamic-tag.ts
1859
- var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
1860
- let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
1861
- if (typeof renderer == "string") {
1862
- let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
1863
- nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), voidElementsReg.test(renderer) || (withBranchId(branchId, () => {
1864
- renderer === "textarea" ? write(
1865
- controllable_textarea_value(
1866
- scopeId,
1867
- accessor,
1868
- input.value,
1869
- input.valueChange
1870
- )
1871
- ) : content && (renderer === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
1872
- scopeId,
1873
- accessor,
1874
- input.value,
1875
- input.valueChange,
1876
- content
1877
- ) : content());
1878
- }), write(`</${renderer}>`)), resume && write(
1879
- state.mark(
1880
- "|" /* BranchSingleNode */,
1881
- scopeId + " " + accessor + " " + branchId
1882
- )
1883
- );
1884
- } else
1885
- resume && write(state.mark("[" /* BranchStart */, branchId + "")), result = withBranchId(branchId, () => {
1886
- if (renderer)
1887
- return inputIsArgs ? renderer(...inputOrArgs) : renderer(
1888
- content ? { ...inputOrArgs, content } : inputOrArgs
1889
- );
1890
- if (content)
1891
- return content();
1892
- }), resume && write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
1893
- return peekNextScopeId() !== branchId ? resume && writeScope(scopeId, {
1894
- ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
1895
- ["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
1896
- }) : nextScopeId(), result;
1897
- };
1898
- function createContent(id, fn) {
1899
- return fn.h = id, fn;
1900
- }
1901
- function registerContent(id, fn, scopeId) {
1902
- return register2(createContent(id, fn), id, scopeId);
1903
- }
1904
- function patchDynamicTag(patch) {
1905
- dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
1906
- let patched = patch(scopeId, accessor, tag);
1907
- return patched.h = tag, originalDynamicTag(
1908
- scopeId,
1909
- accessor,
1910
- patched,
1911
- input,
1912
- content,
1913
- inputIsArgs,
1914
- resume
1915
- );
1916
- })(dynamicTag);
1917
- }
1918
-
1919
- // src/html/compat.ts
1920
- var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
1921
- fork,
1922
- write,
1923
- writeScript,
1924
- nextScopeId,
1925
- isTagsAPI(fn) {
1926
- return !!fn.h;
1927
- },
1928
- patchDynamicTag,
1929
- writeSetScopeForComponent(m5c) {
1930
- let scopeId = nextScopeId();
1931
- writeScope(scopeId, { m5c }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
1932
- },
1933
- toJSON() {
1934
- let compatRegistered = COMPAT_REGISTRY.get(this);
1935
- if (!compatRegistered) {
1936
- let registered = getRegistered(this);
1937
- if (registered) {
1938
- let scopeId = getScopeId(registered.scope);
1939
- scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
1940
- this,
1941
- compatRegistered = [registered.id, scopeId]
1942
- );
1943
- }
1944
- }
1945
- return compatRegistered;
1946
- },
1947
- render(renderer, willRerender, classAPIOut, component, input) {
1948
- let $global2 = classAPIOut.global, state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
1949
- state || ($global2.runtimeId ||= DEFAULT_RUNTIME_ID, $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID, $global2[K_TAGS_API_STATE] = state = new State2($global2));
1950
- let boundary = new Boundary(state), head = new Chunk(
1951
- boundary,
1952
- null,
1953
- null
1954
- ), normalizedInput = input;
1955
- if ("renderBody" in input) {
1956
- normalizedInput = {};
1957
- for (let key in input)
1958
- normalizedInput[key === "renderBody" ? "content" : key] = input[key];
1959
- }
1960
- head.render(() => {
1961
- if (willRerender) {
1962
- let scopeId = peekNextScopeId();
1963
- writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
1964
- }
1965
- renderer(normalizedInput);
1966
- });
1967
- let asyncOut = classAPIOut.beginAsync();
1968
- queueMicrotask(
1969
- boundary.onNext = () => {
1970
- if (boundary.signal.aborted)
1971
- asyncOut.error(boundary.signal.reason);
1972
- else if (boundary.done) {
1973
- let { scripts, html } = head.consume().flushScript();
1974
- asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
1975
- }
1976
- }
1977
- );
1978
- },
1979
- registerRenderer(renderer, id) {
1980
- return register(
1981
- RENDERER_REGISTER_ID,
1982
- renderer,
1983
- register(id, () => {
1984
- })
1985
- );
1986
- },
1987
- registerRenderBody(fn) {
1988
- register(RENDER_BODY_ID, fn);
1989
- }
1990
- };
1991
-
1992
- // src/html/for.ts
1993
- function forOfBy2(by, item, index) {
1994
- return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1995
- }
1996
- function forInBy2(by, name, value) {
1997
- return by ? by(name, value) : name;
1998
- }
1999
- function forToBy2(by, index) {
2000
- return by ? by(index) : index;
2001
- }
2002
-
2003
1884
  // src/html/template.ts
2004
1885
  var createTemplate = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, registerContent(templateId, renderer));
1886
+ function isTemplate(renderer) {
1887
+ return !!renderer._;
1888
+ }
2005
1889
  function render(input = {}) {
2006
1890
  let { $global: $global2 } = input;
2007
1891
  $global2 ? ({ $global: $global2, ...input } = input, $global2 = {
@@ -2138,6 +2022,165 @@ var ServerRendered = class {
2138
2022
  };
2139
2023
  function NOOP2() {
2140
2024
  }
2025
+
2026
+ // src/html/dynamic-tag.ts
2027
+ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
2028
+ let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
2029
+ if (typeof renderer == "string") {
2030
+ let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2031
+ if (nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), !voidElementsReg.test(renderer)) {
2032
+ let renderNativeTag = () => {
2033
+ renderer === "textarea" ? write(
2034
+ controllable_textarea_value(
2035
+ scopeId,
2036
+ accessor,
2037
+ input.value,
2038
+ input.valueChange
2039
+ )
2040
+ ) : content && (renderer === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
2041
+ scopeId,
2042
+ accessor,
2043
+ input.value,
2044
+ input.valueChange,
2045
+ content
2046
+ ) : content());
2047
+ };
2048
+ shouldResume ? withBranchId(branchId, renderNativeTag) : renderNativeTag(), write(`</${renderer}>`);
2049
+ }
2050
+ shouldResume && write(
2051
+ state.mark(
2052
+ "|" /* BranchSingleNode */,
2053
+ scopeId + " " + accessor + " " + branchId
2054
+ )
2055
+ );
2056
+ } else {
2057
+ shouldResume && write(state.mark("[" /* BranchStart */, branchId + ""));
2058
+ let render2 = () => {
2059
+ if (renderer) {
2060
+ if (isTemplate(renderer)) {
2061
+ let input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
2062
+ return renderer(
2063
+ content ? { ...input, content } : input,
2064
+ shouldResume
2065
+ );
2066
+ }
2067
+ return inputIsArgs ? renderer(...inputOrArgs) : renderer(
2068
+ content ? { ...inputOrArgs, content } : inputOrArgs
2069
+ );
2070
+ } else if (content)
2071
+ return content();
2072
+ };
2073
+ result = shouldResume ? withBranchId(branchId, render2) : render2(), shouldResume && write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
2074
+ }
2075
+ return peekNextScopeId() !== branchId ? shouldResume && writeScope(scopeId, {
2076
+ ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
2077
+ ["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
2078
+ }) : nextScopeId(), result;
2079
+ };
2080
+ function createContent(id, fn) {
2081
+ return fn.h = id, fn;
2082
+ }
2083
+ function registerContent(id, fn, scopeId) {
2084
+ return register2(createContent(id, fn), id, scopeId);
2085
+ }
2086
+ function patchDynamicTag(patch) {
2087
+ dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
2088
+ let patched = patch(scopeId, accessor, tag);
2089
+ return patched.h = tag, originalDynamicTag(
2090
+ scopeId,
2091
+ accessor,
2092
+ patched,
2093
+ input,
2094
+ content,
2095
+ inputIsArgs,
2096
+ resume
2097
+ );
2098
+ })(dynamicTag);
2099
+ }
2100
+
2101
+ // src/html/compat.ts
2102
+ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
2103
+ fork,
2104
+ write,
2105
+ writeScript,
2106
+ nextScopeId,
2107
+ isTagsAPI(fn) {
2108
+ return !!fn.h;
2109
+ },
2110
+ patchDynamicTag,
2111
+ writeSetScopeForComponent(m5c) {
2112
+ let scopeId = nextScopeId();
2113
+ writeScope(scopeId, { m5c }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
2114
+ },
2115
+ toJSON() {
2116
+ let compatRegistered = COMPAT_REGISTRY.get(this);
2117
+ if (!compatRegistered) {
2118
+ let registered = getRegistered(this);
2119
+ if (registered) {
2120
+ let scopeId = getScopeId(registered.scope);
2121
+ scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
2122
+ this,
2123
+ compatRegistered = [registered.id, scopeId]
2124
+ );
2125
+ }
2126
+ }
2127
+ return compatRegistered;
2128
+ },
2129
+ render(renderer, willRerender, classAPIOut, component, input) {
2130
+ let $global2 = classAPIOut.global, state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
2131
+ state || ($global2.runtimeId ||= DEFAULT_RUNTIME_ID, $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID, $global2[K_TAGS_API_STATE] = state = new State2($global2));
2132
+ let boundary = new Boundary(state), head = new Chunk(
2133
+ boundary,
2134
+ null,
2135
+ null
2136
+ ), normalizedInput = input;
2137
+ if ("renderBody" in input) {
2138
+ normalizedInput = {};
2139
+ for (let key in input)
2140
+ normalizedInput[key === "renderBody" ? "content" : key] = input[key];
2141
+ }
2142
+ head.render(() => {
2143
+ if (willRerender) {
2144
+ let scopeId = peekNextScopeId();
2145
+ writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
2146
+ }
2147
+ isTemplate(renderer) && willRerender ? renderer(normalizedInput, 1) : renderer(normalizedInput);
2148
+ });
2149
+ let asyncOut = classAPIOut.beginAsync();
2150
+ queueMicrotask(
2151
+ boundary.onNext = () => {
2152
+ if (boundary.signal.aborted)
2153
+ asyncOut.error(boundary.signal.reason);
2154
+ else if (boundary.done) {
2155
+ let { scripts, html } = head.consume().flushScript();
2156
+ asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
2157
+ }
2158
+ }
2159
+ );
2160
+ },
2161
+ registerRenderer(renderer, id) {
2162
+ return register(
2163
+ RENDERER_REGISTER_ID,
2164
+ renderer,
2165
+ register(id, () => {
2166
+ })
2167
+ );
2168
+ },
2169
+ registerRenderBody(fn) {
2170
+ register(RENDER_BODY_ID, fn);
2171
+ }
2172
+ };
2173
+
2174
+ // src/html/for.ts
2175
+ function forOfBy2(by, item, index) {
2176
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
2177
+ }
2178
+ function forInBy2(by, name, value) {
2179
+ return by ? by(name, value) : name;
2180
+ }
2181
+ function forToBy2(by, index) {
2182
+ return by ? by(index) : index;
2183
+ }
2141
2184
  // Annotate the CommonJS export names for ESM import in node:
2142
2185
  0 && (module.exports = {
2143
2186
  $global,
@@ -2146,6 +2189,7 @@ function NOOP2() {
2146
2189
  attrTags,
2147
2190
  attrs,
2148
2191
  classAttr,
2192
+ commentSeparator,
2149
2193
  compat,
2150
2194
  controllable_detailsOrDialog_open,
2151
2195
  controllable_input_checked,
@@ -2175,7 +2219,7 @@ function NOOP2() {
2175
2219
  nodeRef,
2176
2220
  optionValueAttr,
2177
2221
  partialAttrs,
2178
- peekNextScope,
2222
+ peekNextScopeId,
2179
2223
  register,
2180
2224
  registerContent,
2181
2225
  resumeClosestBranch,
@@ -2187,6 +2231,8 @@ function NOOP2() {
2187
2231
  resumeSingleNodeForIn,
2188
2232
  resumeSingleNodeForOf,
2189
2233
  resumeSingleNodeForTo,
2234
+ serializeGuard,
2235
+ serializeIf,
2190
2236
  setTagVar,
2191
2237
  styleAttr,
2192
2238
  toString,