marko 6.0.50 → 6.0.52

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.
@@ -1821,6 +1821,9 @@ function resumeClosestBranch(scopeId) {
1821
1821
  }
1822
1822
  }
1823
1823
  var branchIdKey = Symbol();
1824
+ function isInResumedBranch() {
1825
+ return $chunk?.context?.[branchIdKey] !== void 0;
1826
+ }
1824
1827
  function withBranchId(branchId, cb) {
1825
1828
  return withContext(branchIdKey, branchId, cb);
1826
1829
  }
@@ -2402,7 +2405,6 @@ var Chunk = class {
2402
2405
  }
2403
2406
  }
2404
2407
  flushScript() {
2405
- flushSerializer(this.boundary);
2406
2408
  const { boundary, effects } = this;
2407
2409
  const { state } = boundary;
2408
2410
  const { $global: $global2, runtimePrefix, nonceAttr } = state;
@@ -3058,7 +3060,7 @@ var ServerRendered = class {
3058
3060
  if (boundary.signal.aborted) {
3059
3061
  boundary.onNext = NOOP2;
3060
3062
  reject(boundary.signal.reason);
3061
- } else if (boundary.done) {
3063
+ } else if (!boundary.count && boundary.done) {
3062
3064
  resolve(head.consume().flushHTML());
3063
3065
  }
3064
3066
  })();
@@ -3128,48 +3130,51 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3128
3130
  let result;
3129
3131
  if (typeof renderer === "string") {
3130
3132
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
3131
- const renderContent = content || normalizeDynamicRenderer(input.content);
3132
3133
  nextScopeId();
3133
- write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
3134
+ write(
3135
+ `<${renderer}${attrs(input, true ? `#${renderer}/0` : 0, branchId, renderer)}>`
3136
+ );
3134
3137
  if (!voidElementsReg.test(renderer)) {
3135
- const renderNativeTag = () => {
3136
- if (renderer === "textarea") {
3137
- if (content) {
3138
- throw new Error(
3139
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
3140
- );
3141
- }
3142
- write(
3143
- controllable_textarea_value(
3144
- scopeId,
3145
- accessor,
3146
- input.value,
3147
- input.valueChange
3148
- )
3138
+ const renderContent = content || normalizeDynamicRenderer(input.content);
3139
+ if (renderer === "textarea") {
3140
+ if (renderContent) {
3141
+ throw new Error(
3142
+ "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
3143
+ );
3144
+ }
3145
+ write(
3146
+ controllable_textarea_value(
3147
+ branchId,
3148
+ true ? `#${renderer}/0` : 0,
3149
+ input.value,
3150
+ input.valueChange
3151
+ )
3152
+ );
3153
+ } else if (renderContent) {
3154
+ if (typeof renderContent !== "function") {
3155
+ throw new Error(
3156
+ `Body content is not supported for the \`<${renderer}>\` tag.`
3157
+ );
3158
+ }
3159
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) {
3160
+ controllable_select_value(
3161
+ branchId,
3162
+ true ? `#${renderer}/0` : 0,
3163
+ input.value,
3164
+ input.valueChange,
3165
+ renderContent
3166
+ );
3167
+ } else {
3168
+ dynamicTag(
3169
+ branchId,
3170
+ true ? `#${renderer}/0` : 0,
3171
+ renderContent,
3172
+ [],
3173
+ 0,
3174
+ 1,
3175
+ serializeReason
3149
3176
  );
3150
- } else if (renderContent) {
3151
- if (typeof renderContent !== "function") {
3152
- throw new Error(
3153
- `Body content is not supported for the \`<${renderer}>\` tag.`
3154
- );
3155
- }
3156
- if (renderer === "select" && ("value" in input || "valueChange" in input)) {
3157
- controllable_select_value(
3158
- scopeId,
3159
- accessor,
3160
- input.value,
3161
- input.valueChange,
3162
- renderContent
3163
- );
3164
- } else {
3165
- renderContent();
3166
- }
3167
3177
  }
3168
- };
3169
- if (shouldResume) {
3170
- withBranchId(branchId, renderNativeTag);
3171
- } else {
3172
- renderNativeTag();
3173
3178
  }
3174
3179
  write(`</${renderer}>`);
3175
3180
  } else if (content) {
@@ -3180,7 +3185,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3180
3185
  if (shouldResume) {
3181
3186
  write(
3182
3187
  state.mark(
3183
- "|" /* BranchSingleNode */,
3188
+ "'" /* BranchNativeTag */,
3184
3189
  scopeId + " " + accessor + " " + branchId
3185
3190
  )
3186
3191
  );
@@ -3233,7 +3238,7 @@ function registerContent(id, fn, scopeId) {
3233
3238
  function patchDynamicTag(patch) {
3234
3239
  dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
3235
3240
  const patched = patch(scopeId, accessor, tag);
3236
- patched.___id = tag;
3241
+ if (patched !== tag) patched.___id = tag;
3237
3242
  return originalDynamicTag(
3238
3243
  scopeId,
3239
3244
  accessor,
@@ -3256,9 +3261,17 @@ var compat = {
3256
3261
  writeScript,
3257
3262
  nextScopeId,
3258
3263
  peekNextScopeId,
3264
+ isInResumedBranch,
3259
3265
  isTagsAPI(fn) {
3260
3266
  return !!fn.___id;
3261
3267
  },
3268
+ onFlush(fn) {
3269
+ const { flushHTML } = Chunk.prototype;
3270
+ Chunk.prototype.flushHTML = function() {
3271
+ fn(this);
3272
+ return flushHTML.call(this);
3273
+ };
3274
+ },
3262
3275
  patchDynamicTag,
3263
3276
  writeSetScopeForComponent(branchId, m5c) {
3264
3277
  writeScope(branchId, { m5c });
@@ -3281,7 +3294,7 @@ var compat = {
3281
3294
  }
3282
3295
  return compatRegistered;
3283
3296
  },
3284
- render(renderer, willRerender, classAPIOut, component, input) {
3297
+ render(renderer, willRerender, classAPIOut, component, input, toStringEvent) {
3285
3298
  const $global2 = classAPIOut.global;
3286
3299
  let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
3287
3300
  if (!state) {
@@ -3290,7 +3303,7 @@ var compat = {
3290
3303
  $global2[K_TAGS_API_STATE] = state = new State2($global2);
3291
3304
  }
3292
3305
  const boundary = new Boundary(state);
3293
- const head = new Chunk(
3306
+ let head = new Chunk(
3294
3307
  boundary,
3295
3308
  null,
3296
3309
  null
@@ -3313,22 +3326,30 @@ var compat = {
3313
3326
  } else {
3314
3327
  renderer(normalizedInput);
3315
3328
  }
3316
- });
3317
- const asyncOut = classAPIOut.beginAsync();
3318
- queueMicrotask(
3319
- boundary.onNext = () => {
3329
+ const asyncOut = classAPIOut.beginAsync();
3330
+ (boundary.onNext = () => {
3320
3331
  if (boundary.signal.aborted) {
3321
3332
  asyncOut.error(boundary.signal.reason);
3322
- } else if (boundary.done) {
3323
- const { scripts, html } = head.consume().flushScript();
3324
- asyncOut.script(scripts);
3325
- asyncOut.write(html);
3326
- if (boundary.done) {
3327
- asyncOut.end();
3328
- }
3333
+ boundary.onNext = NOOP3;
3334
+ } else if (!boundary.count) {
3335
+ asyncOut.once(toStringEvent, (writer) => {
3336
+ if (boundary.done) {
3337
+ const { html, scripts } = head.flushScript();
3338
+ writer.script(scripts);
3339
+ writer.write(html);
3340
+ } else {
3341
+ asyncOut.error(
3342
+ new Error("Cannot serialize promises with class/tags interop.")
3343
+ );
3344
+ }
3345
+ });
3346
+ head = head.consume();
3347
+ asyncOut.write(head.html);
3348
+ asyncOut.end();
3349
+ head.html = "";
3329
3350
  }
3330
- }
3331
- );
3351
+ })();
3352
+ });
3332
3353
  },
3333
3354
  registerRenderer(renderer, id) {
3334
3355
  return register(
@@ -3342,6 +3363,8 @@ var compat = {
3342
3363
  register(RENDER_BODY_ID, fn);
3343
3364
  }
3344
3365
  };
3366
+ function NOOP3() {
3367
+ }
3345
3368
  // Annotate the CommonJS export names for ESM import in node:
3346
3369
  0 && (module.exports = {
3347
3370
  $global,
@@ -1737,6 +1737,9 @@ function resumeClosestBranch(scopeId) {
1737
1737
  }
1738
1738
  }
1739
1739
  var branchIdKey = Symbol();
1740
+ function isInResumedBranch() {
1741
+ return $chunk?.context?.[branchIdKey] !== void 0;
1742
+ }
1740
1743
  function withBranchId(branchId, cb) {
1741
1744
  return withContext(branchIdKey, branchId, cb);
1742
1745
  }
@@ -2318,7 +2321,6 @@ var Chunk = class {
2318
2321
  }
2319
2322
  }
2320
2323
  flushScript() {
2321
- flushSerializer(this.boundary);
2322
2324
  const { boundary, effects } = this;
2323
2325
  const { state } = boundary;
2324
2326
  const { $global: $global2, runtimePrefix, nonceAttr } = state;
@@ -2974,7 +2976,7 @@ var ServerRendered = class {
2974
2976
  if (boundary.signal.aborted) {
2975
2977
  boundary.onNext = NOOP2;
2976
2978
  reject(boundary.signal.reason);
2977
- } else if (boundary.done) {
2979
+ } else if (!boundary.count && boundary.done) {
2978
2980
  resolve(head.consume().flushHTML());
2979
2981
  }
2980
2982
  })();
@@ -3044,48 +3046,51 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3044
3046
  let result;
3045
3047
  if (typeof renderer === "string") {
3046
3048
  const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
3047
- const renderContent = content || normalizeDynamicRenderer(input.content);
3048
3049
  nextScopeId();
3049
- write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
3050
+ write(
3051
+ `<${renderer}${attrs(input, true ? `#${renderer}/0` : 0, branchId, renderer)}>`
3052
+ );
3050
3053
  if (!voidElementsReg.test(renderer)) {
3051
- const renderNativeTag = () => {
3052
- if (renderer === "textarea") {
3053
- if (content) {
3054
- throw new Error(
3055
- "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
3056
- );
3057
- }
3058
- write(
3059
- controllable_textarea_value(
3060
- scopeId,
3061
- accessor,
3062
- input.value,
3063
- input.valueChange
3064
- )
3054
+ const renderContent = content || normalizeDynamicRenderer(input.content);
3055
+ if (renderer === "textarea") {
3056
+ if (renderContent) {
3057
+ throw new Error(
3058
+ "A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
3059
+ );
3060
+ }
3061
+ write(
3062
+ controllable_textarea_value(
3063
+ branchId,
3064
+ true ? `#${renderer}/0` : 0,
3065
+ input.value,
3066
+ input.valueChange
3067
+ )
3068
+ );
3069
+ } else if (renderContent) {
3070
+ if (typeof renderContent !== "function") {
3071
+ throw new Error(
3072
+ `Body content is not supported for the \`<${renderer}>\` tag.`
3073
+ );
3074
+ }
3075
+ if (renderer === "select" && ("value" in input || "valueChange" in input)) {
3076
+ controllable_select_value(
3077
+ branchId,
3078
+ true ? `#${renderer}/0` : 0,
3079
+ input.value,
3080
+ input.valueChange,
3081
+ renderContent
3082
+ );
3083
+ } else {
3084
+ dynamicTag(
3085
+ branchId,
3086
+ true ? `#${renderer}/0` : 0,
3087
+ renderContent,
3088
+ [],
3089
+ 0,
3090
+ 1,
3091
+ serializeReason
3065
3092
  );
3066
- } else if (renderContent) {
3067
- if (typeof renderContent !== "function") {
3068
- throw new Error(
3069
- `Body content is not supported for the \`<${renderer}>\` tag.`
3070
- );
3071
- }
3072
- if (renderer === "select" && ("value" in input || "valueChange" in input)) {
3073
- controllable_select_value(
3074
- scopeId,
3075
- accessor,
3076
- input.value,
3077
- input.valueChange,
3078
- renderContent
3079
- );
3080
- } else {
3081
- renderContent();
3082
- }
3083
3093
  }
3084
- };
3085
- if (shouldResume) {
3086
- withBranchId(branchId, renderNativeTag);
3087
- } else {
3088
- renderNativeTag();
3089
3094
  }
3090
3095
  write(`</${renderer}>`);
3091
3096
  } else if (content) {
@@ -3096,7 +3101,7 @@ var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, ser
3096
3101
  if (shouldResume) {
3097
3102
  write(
3098
3103
  state.mark(
3099
- "|" /* BranchSingleNode */,
3104
+ "'" /* BranchNativeTag */,
3100
3105
  scopeId + " " + accessor + " " + branchId
3101
3106
  )
3102
3107
  );
@@ -3149,7 +3154,7 @@ function registerContent(id, fn, scopeId) {
3149
3154
  function patchDynamicTag(patch) {
3150
3155
  dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
3151
3156
  const patched = patch(scopeId, accessor, tag);
3152
- patched.___id = tag;
3157
+ if (patched !== tag) patched.___id = tag;
3153
3158
  return originalDynamicTag(
3154
3159
  scopeId,
3155
3160
  accessor,
@@ -3172,9 +3177,17 @@ var compat = {
3172
3177
  writeScript,
3173
3178
  nextScopeId,
3174
3179
  peekNextScopeId,
3180
+ isInResumedBranch,
3175
3181
  isTagsAPI(fn) {
3176
3182
  return !!fn.___id;
3177
3183
  },
3184
+ onFlush(fn) {
3185
+ const { flushHTML } = Chunk.prototype;
3186
+ Chunk.prototype.flushHTML = function() {
3187
+ fn(this);
3188
+ return flushHTML.call(this);
3189
+ };
3190
+ },
3178
3191
  patchDynamicTag,
3179
3192
  writeSetScopeForComponent(branchId, m5c) {
3180
3193
  writeScope(branchId, { m5c });
@@ -3197,7 +3210,7 @@ var compat = {
3197
3210
  }
3198
3211
  return compatRegistered;
3199
3212
  },
3200
- render(renderer, willRerender, classAPIOut, component, input) {
3213
+ render(renderer, willRerender, classAPIOut, component, input, toStringEvent) {
3201
3214
  const $global2 = classAPIOut.global;
3202
3215
  let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
3203
3216
  if (!state) {
@@ -3206,7 +3219,7 @@ var compat = {
3206
3219
  $global2[K_TAGS_API_STATE] = state = new State2($global2);
3207
3220
  }
3208
3221
  const boundary = new Boundary(state);
3209
- const head = new Chunk(
3222
+ let head = new Chunk(
3210
3223
  boundary,
3211
3224
  null,
3212
3225
  null
@@ -3229,22 +3242,30 @@ var compat = {
3229
3242
  } else {
3230
3243
  renderer(normalizedInput);
3231
3244
  }
3232
- });
3233
- const asyncOut = classAPIOut.beginAsync();
3234
- queueMicrotask(
3235
- boundary.onNext = () => {
3245
+ const asyncOut = classAPIOut.beginAsync();
3246
+ (boundary.onNext = () => {
3236
3247
  if (boundary.signal.aborted) {
3237
3248
  asyncOut.error(boundary.signal.reason);
3238
- } else if (boundary.done) {
3239
- const { scripts, html } = head.consume().flushScript();
3240
- asyncOut.script(scripts);
3241
- asyncOut.write(html);
3242
- if (boundary.done) {
3243
- asyncOut.end();
3244
- }
3249
+ boundary.onNext = NOOP3;
3250
+ } else if (!boundary.count) {
3251
+ asyncOut.once(toStringEvent, (writer) => {
3252
+ if (boundary.done) {
3253
+ const { html, scripts } = head.flushScript();
3254
+ writer.script(scripts);
3255
+ writer.write(html);
3256
+ } else {
3257
+ asyncOut.error(
3258
+ new Error("Cannot serialize promises with class/tags interop.")
3259
+ );
3260
+ }
3261
+ });
3262
+ head = head.consume();
3263
+ asyncOut.write(head.html);
3264
+ asyncOut.end();
3265
+ head.html = "";
3245
3266
  }
3246
- }
3247
- );
3267
+ })();
3268
+ });
3248
3269
  },
3249
3270
  registerRenderer(renderer, id) {
3250
3271
  return register(
@@ -3258,6 +3279,8 @@ var compat = {
3258
3279
  register(RENDER_BODY_ID, fn);
3259
3280
  }
3260
3281
  };
3282
+ function NOOP3() {
3283
+ }
3261
3284
  export {
3262
3285
  $global,
3263
3286
  attr,
@@ -1,3 +1,4 @@
1
1
  import { type BranchScope } from "../common/types";
2
2
  export declare const walker: TreeWalker;
3
3
  export declare function walk(startNode: Node, walkCodes: string, branch: BranchScope): void;
4
+ export declare function getDebugKey(index: number, node: Node | string): string | number;