marko 6.0.79 → 6.0.80
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/debug/dom.js +8 -0
- package/dist/debug/dom.mjs +8 -0
- package/dist/debug/html.js +261 -252
- package/dist/debug/html.mjs +259 -252
- package/dist/dom/signals.d.ts +7 -0
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +6 -0
- package/dist/dom.mjs +6 -0
- package/dist/html/compat.d.ts +1 -1
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/writer.d.ts +3 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +168 -157
- package/dist/html.mjs +166 -157
- package/dist/translator/index.js +1767 -1394
- package/dist/translator/util/binding-prop-tree.d.ts +8 -0
- package/dist/translator/util/generate-uid.d.ts +2 -1
- package/dist/translator/util/known-tag.d.ts +23 -0
- package/dist/translator/util/nested-attribute-tags.d.ts +1 -0
- package/dist/translator/util/optional.d.ts +2 -1
- package/dist/translator/util/references.d.ts +5 -2
- package/dist/translator/util/sections.d.ts +5 -2
- package/dist/translator/util/serialize-guard.d.ts +5 -0
- package/dist/translator/util/serialize-reasons.d.ts +6 -2
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/util/writer.d.ts +7 -3
- package/dist/translator/visitors/program/html.d.ts +0 -4
- package/dist/translator/visitors/program/index.d.ts +10 -17
- package/dist/translator/visitors/tag/custom-tag.d.ts +0 -12
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +2 -0
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
@@ -50,6 +50,7 @@ __export(dom_exports, {
|
|
50
50
|
_attrs_partial_content: () => _attrs_partial_content,
|
51
51
|
_attrs_script: () => _attrs_script,
|
52
52
|
_await: () => _await,
|
53
|
+
_child_setup: () => _child_setup,
|
53
54
|
_closure: () => _closure,
|
54
55
|
_closure_get: () => _closure_get,
|
55
56
|
_const: () => _const,
|
@@ -1063,6 +1064,13 @@ function closure(valueAccessor, fn, getOwnerScope) {
|
|
1063
1064
|
);
|
1064
1065
|
};
|
1065
1066
|
}
|
1067
|
+
function _child_setup(setup) {
|
1068
|
+
setup._ = (scope, owner) => {
|
1069
|
+
scope["_" /* Owner */] = owner;
|
1070
|
+
queueRender(scope, setup, -1);
|
1071
|
+
};
|
1072
|
+
return setup;
|
1073
|
+
}
|
1066
1074
|
function _var(scope, childAccessor, signal) {
|
1067
1075
|
scope[childAccessor]["#TagVariable" /* TagVariable */] = (value) => signal(scope, value);
|
1068
1076
|
}
|
package/dist/debug/dom.mjs
CHANGED
@@ -964,6 +964,13 @@ function closure(valueAccessor, fn, getOwnerScope) {
|
|
964
964
|
);
|
965
965
|
};
|
966
966
|
}
|
967
|
+
function _child_setup(setup) {
|
968
|
+
setup._ = (scope, owner) => {
|
969
|
+
scope["_" /* Owner */] = owner;
|
970
|
+
queueRender(scope, setup, -1);
|
971
|
+
};
|
972
|
+
return setup;
|
973
|
+
}
|
967
974
|
function _var(scope, childAccessor, signal) {
|
968
975
|
scope[childAccessor]["#TagVariable" /* TagVariable */] = (value) => signal(scope, value);
|
969
976
|
}
|
@@ -2315,6 +2322,7 @@ export {
|
|
2315
2322
|
_attrs_partial_content,
|
2316
2323
|
_attrs_script,
|
2317
2324
|
_await,
|
2325
|
+
_child_setup,
|
2318
2326
|
_closure,
|
2319
2327
|
_closure_get,
|
2320
2328
|
_const,
|
package/dist/debug/html.js
CHANGED
@@ -52,6 +52,7 @@ __export(html_exports, {
|
|
52
52
|
_for_of: () => _for_of,
|
53
53
|
_for_to: () => _for_to,
|
54
54
|
_for_until: () => _for_until,
|
55
|
+
_get_serialize_reason: () => _get_serialize_reason,
|
55
56
|
_hoist: () => _hoist,
|
56
57
|
_html: () => _html,
|
57
58
|
_id: () => _id,
|
@@ -66,6 +67,7 @@ __export(html_exports, {
|
|
66
67
|
_sep: () => _sep,
|
67
68
|
_serialize_guard: () => _serialize_guard,
|
68
69
|
_serialize_if: () => _serialize_if,
|
70
|
+
_set_serialize_reason: () => _set_serialize_reason,
|
69
71
|
_subscribe: () => _subscribe,
|
70
72
|
_template: () => _template,
|
71
73
|
_trailers: () => _trailers,
|
@@ -1794,6 +1796,14 @@ function getScopeById(scopeId) {
|
|
1794
1796
|
return $chunk.boundary.state.scopes.get(scopeId);
|
1795
1797
|
}
|
1796
1798
|
}
|
1799
|
+
function _set_serialize_reason(reason) {
|
1800
|
+
$chunk.boundary.state.serializeReason = reason;
|
1801
|
+
}
|
1802
|
+
function _get_serialize_reason() {
|
1803
|
+
const reason = $chunk.boundary.state.serializeReason;
|
1804
|
+
$chunk.boundary.state.serializeReason = void 0;
|
1805
|
+
return reason;
|
1806
|
+
}
|
1797
1807
|
function _serialize_if(condition, key) {
|
1798
1808
|
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
1799
1809
|
}
|
@@ -2289,6 +2299,7 @@ var State2 = class {
|
|
2289
2299
|
writeReorders = null;
|
2290
2300
|
scopes = /* @__PURE__ */ new Map();
|
2291
2301
|
writeScopes = null;
|
2302
|
+
serializeReason;
|
2292
2303
|
get runtimePrefix() {
|
2293
2304
|
const { $global: $global2 } = this;
|
2294
2305
|
return $global2.runtimeId + "." + $global2.renderId;
|
@@ -2930,245 +2941,6 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
|
2930
2941
|
var DEFAULT_RUNTIME_ID = "M";
|
2931
2942
|
var DEFAULT_RENDER_ID = "_";
|
2932
2943
|
|
2933
|
-
// src/html/template.ts
|
2934
|
-
var _template = (templateId, renderer) => {
|
2935
|
-
renderer.render = render;
|
2936
|
-
renderer._ = renderer;
|
2937
|
-
if (true) {
|
2938
|
-
renderer.mount = () => {
|
2939
|
-
throw new Error(
|
2940
|
-
`mount() is not implemented for the HTML compilation of a Marko template`
|
2941
|
-
);
|
2942
|
-
};
|
2943
|
-
}
|
2944
|
-
return _content_resume(templateId, renderer);
|
2945
|
-
};
|
2946
|
-
function isTemplate(renderer) {
|
2947
|
-
return !!renderer._;
|
2948
|
-
}
|
2949
|
-
function render(input = {}) {
|
2950
|
-
let { $global: $global2 } = input;
|
2951
|
-
if ($global2) {
|
2952
|
-
({ $global: $global2, ...input } = input);
|
2953
|
-
$global2 = {
|
2954
|
-
runtimeId: DEFAULT_RUNTIME_ID,
|
2955
|
-
renderId: DEFAULT_RENDER_ID,
|
2956
|
-
...$global2
|
2957
|
-
};
|
2958
|
-
if (true) {
|
2959
|
-
if (!String($global2.runtimeId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
2960
|
-
throw new Error(
|
2961
|
-
`Invalid runtimeId: "${$global2.runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
2962
|
-
);
|
2963
|
-
}
|
2964
|
-
if (!String($global2.renderId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
2965
|
-
throw new Error(
|
2966
|
-
`Invalid renderId: "${$global2.renderId}". The renderId must be a valid JavaScript identifier.`
|
2967
|
-
);
|
2968
|
-
}
|
2969
|
-
}
|
2970
|
-
} else {
|
2971
|
-
$global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
|
2972
|
-
}
|
2973
|
-
const head = new Chunk(
|
2974
|
-
new Boundary(new State2($global2), $global2.signal),
|
2975
|
-
null,
|
2976
|
-
null
|
2977
|
-
);
|
2978
|
-
head.render(this, input);
|
2979
|
-
return new ServerRendered(head);
|
2980
|
-
}
|
2981
|
-
var ServerRendered = class {
|
2982
|
-
#head;
|
2983
|
-
#cachedPromise = null;
|
2984
|
-
constructor(head) {
|
2985
|
-
this.#head = head;
|
2986
|
-
}
|
2987
|
-
[Symbol.asyncIterator]() {
|
2988
|
-
let resolve;
|
2989
|
-
let reject;
|
2990
|
-
let value = "";
|
2991
|
-
let done = false;
|
2992
|
-
let aborted = false;
|
2993
|
-
let reason;
|
2994
|
-
const boundary = this.#read(
|
2995
|
-
(html) => {
|
2996
|
-
value += html;
|
2997
|
-
if (resolve) {
|
2998
|
-
resolve({ value, done });
|
2999
|
-
value = "";
|
3000
|
-
}
|
3001
|
-
},
|
3002
|
-
(err) => {
|
3003
|
-
aborted = true;
|
3004
|
-
reason = err;
|
3005
|
-
if (reject) {
|
3006
|
-
reject(err);
|
3007
|
-
}
|
3008
|
-
},
|
3009
|
-
() => {
|
3010
|
-
done = true;
|
3011
|
-
if (resolve) {
|
3012
|
-
resolve({ value, done: !value });
|
3013
|
-
value = "";
|
3014
|
-
}
|
3015
|
-
}
|
3016
|
-
);
|
3017
|
-
return {
|
3018
|
-
next() {
|
3019
|
-
if (aborted) {
|
3020
|
-
return Promise.reject(reason);
|
3021
|
-
} else if (value) {
|
3022
|
-
const result = { value, done: false };
|
3023
|
-
value = "";
|
3024
|
-
return Promise.resolve(result);
|
3025
|
-
} else if (done) {
|
3026
|
-
return Promise.resolve({ value: "", done });
|
3027
|
-
} else {
|
3028
|
-
return new Promise(exec);
|
3029
|
-
}
|
3030
|
-
},
|
3031
|
-
throw(error) {
|
3032
|
-
if (!(done || aborted)) {
|
3033
|
-
boundary?.abort(error);
|
3034
|
-
}
|
3035
|
-
return Promise.resolve({ value: "", done: true });
|
3036
|
-
},
|
3037
|
-
return(value2) {
|
3038
|
-
if (!(done || aborted)) {
|
3039
|
-
boundary?.abort(new Error("Iterator returned before consumed."));
|
3040
|
-
}
|
3041
|
-
return Promise.resolve({ value: value2, done: true });
|
3042
|
-
}
|
3043
|
-
};
|
3044
|
-
function exec(_resolve, _reject) {
|
3045
|
-
resolve = _resolve;
|
3046
|
-
reject = _reject;
|
3047
|
-
}
|
3048
|
-
}
|
3049
|
-
pipe(stream) {
|
3050
|
-
this.#read(
|
3051
|
-
(html) => {
|
3052
|
-
stream.write(html);
|
3053
|
-
},
|
3054
|
-
(err) => {
|
3055
|
-
const socket = "socket" in stream && stream.socket;
|
3056
|
-
if (socket && typeof socket.destroySoon === "function") {
|
3057
|
-
socket.destroySoon();
|
3058
|
-
}
|
3059
|
-
if (!stream.emit?.("error", err)) {
|
3060
|
-
throw err;
|
3061
|
-
}
|
3062
|
-
},
|
3063
|
-
() => {
|
3064
|
-
stream.end();
|
3065
|
-
}
|
3066
|
-
);
|
3067
|
-
}
|
3068
|
-
toReadable() {
|
3069
|
-
let cancelled = false;
|
3070
|
-
let boundary;
|
3071
|
-
const encoder = new TextEncoder();
|
3072
|
-
return new ReadableStream({
|
3073
|
-
start: (ctrl) => {
|
3074
|
-
boundary = this.#read(
|
3075
|
-
(html) => {
|
3076
|
-
ctrl.enqueue(encoder.encode(html));
|
3077
|
-
},
|
3078
|
-
(err) => {
|
3079
|
-
boundary = void 0;
|
3080
|
-
if (!cancelled) {
|
3081
|
-
ctrl.error(err);
|
3082
|
-
}
|
3083
|
-
},
|
3084
|
-
() => {
|
3085
|
-
boundary = void 0;
|
3086
|
-
ctrl.close();
|
3087
|
-
}
|
3088
|
-
);
|
3089
|
-
},
|
3090
|
-
cancel: (reason) => {
|
3091
|
-
cancelled = true;
|
3092
|
-
boundary?.abort(reason);
|
3093
|
-
}
|
3094
|
-
});
|
3095
|
-
}
|
3096
|
-
then(onfulfilled, onrejected) {
|
3097
|
-
return this.#promise().then(onfulfilled, onrejected);
|
3098
|
-
}
|
3099
|
-
catch(onrejected) {
|
3100
|
-
return this.#promise().catch(onrejected);
|
3101
|
-
}
|
3102
|
-
finally(onfinally) {
|
3103
|
-
return this.#promise().finally(onfinally);
|
3104
|
-
}
|
3105
|
-
#promise() {
|
3106
|
-
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
3107
|
-
const head = this.#head;
|
3108
|
-
this.#head = null;
|
3109
|
-
if (!head) {
|
3110
|
-
return reject(new Error("Cannot read from a consumed render result"));
|
3111
|
-
}
|
3112
|
-
const { boundary } = head;
|
3113
|
-
(boundary.onNext = () => {
|
3114
|
-
if (boundary.signal.aborted) {
|
3115
|
-
boundary.onNext = NOOP2;
|
3116
|
-
reject(boundary.signal.reason);
|
3117
|
-
} else if (!boundary.count && boundary.done) {
|
3118
|
-
resolve(head.consume().flushHTML());
|
3119
|
-
}
|
3120
|
-
})();
|
3121
|
-
});
|
3122
|
-
}
|
3123
|
-
#read(onWrite, onAbort, onClose) {
|
3124
|
-
let tick2 = true;
|
3125
|
-
let head = this.#head;
|
3126
|
-
this.#head = null;
|
3127
|
-
if (!head) {
|
3128
|
-
onAbort(new Error("Cannot read from a consumed render result"));
|
3129
|
-
return;
|
3130
|
-
}
|
3131
|
-
const { boundary } = head;
|
3132
|
-
const onNext = boundary.onNext = (write) => {
|
3133
|
-
if (boundary.signal.aborted) {
|
3134
|
-
if (!tick2) offTick(onNext);
|
3135
|
-
boundary.onNext = NOOP2;
|
3136
|
-
onAbort(boundary.signal.reason);
|
3137
|
-
} else {
|
3138
|
-
const { done } = boundary;
|
3139
|
-
if (done || write) {
|
3140
|
-
const html = (head = head.consume()).flushHTML();
|
3141
|
-
if (html) onWrite(html);
|
3142
|
-
if (done) {
|
3143
|
-
if (!tick2) offTick(onNext);
|
3144
|
-
onClose();
|
3145
|
-
} else {
|
3146
|
-
tick2 = true;
|
3147
|
-
}
|
3148
|
-
} else if (tick2) {
|
3149
|
-
tick2 = false;
|
3150
|
-
queueTick(onNext);
|
3151
|
-
}
|
3152
|
-
}
|
3153
|
-
};
|
3154
|
-
onNext();
|
3155
|
-
return boundary;
|
3156
|
-
}
|
3157
|
-
toString() {
|
3158
|
-
const head = this.#head;
|
3159
|
-
this.#head = null;
|
3160
|
-
if (!head) throw new Error("Cannot read from a consumed render result");
|
3161
|
-
const { boundary } = head;
|
3162
|
-
if (!boundary.done) {
|
3163
|
-
throw new Error("Cannot consume asynchronous render with 'toString'");
|
3164
|
-
}
|
3165
|
-
if (boundary.signal.aborted) throw boundary.signal.reason;
|
3166
|
-
return head.consume().flushHTML();
|
3167
|
-
}
|
3168
|
-
};
|
3169
|
-
function NOOP2() {
|
3170
|
-
}
|
3171
|
-
|
3172
2944
|
// src/html/dynamic-tag.ts
|
3173
2945
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
3174
2946
|
var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
@@ -3252,16 +3024,14 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
3252
3024
|
}
|
3253
3025
|
const render2 = () => {
|
3254
3026
|
if (renderer) {
|
3255
|
-
|
3256
|
-
|
3257
|
-
return renderer(
|
3258
|
-
content ? { ...
|
3259
|
-
shouldResume ? 1 : 0
|
3027
|
+
try {
|
3028
|
+
_set_serialize_reason(shouldResume ? 1 : 0);
|
3029
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
3030
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
3260
3031
|
);
|
3032
|
+
} finally {
|
3033
|
+
_set_serialize_reason(void 0);
|
3261
3034
|
}
|
3262
|
-
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
3263
|
-
content ? { ...inputOrArgs, content } : inputOrArgs
|
3264
|
-
);
|
3265
3035
|
} else if (content) {
|
3266
3036
|
return content();
|
3267
3037
|
}
|
@@ -3395,19 +3165,20 @@ var compat = {
|
|
3395
3165
|
writeScope(scopeId, { m5c: component.id });
|
3396
3166
|
_script(scopeId, SET_SCOPE_REGISTER_ID);
|
3397
3167
|
}
|
3398
|
-
|
3399
|
-
|
3400
|
-
} else {
|
3168
|
+
_set_serialize_reason(willRerender ? 1 : 0);
|
3169
|
+
try {
|
3401
3170
|
renderer(normalizedInput);
|
3171
|
+
} finally {
|
3172
|
+
_set_serialize_reason(void 0);
|
3402
3173
|
}
|
3403
3174
|
const asyncOut = classAPIOut.beginAsync({ last: true, timeout: -1 });
|
3404
3175
|
classAPIOut.onLast((next) => {
|
3405
3176
|
(boundary.onNext = () => {
|
3406
3177
|
if (boundary.signal.aborted) {
|
3407
3178
|
asyncOut.error(boundary.signal.reason);
|
3408
|
-
boundary.onNext =
|
3179
|
+
boundary.onNext = NOOP2;
|
3409
3180
|
} else if (!boundary.count) {
|
3410
|
-
boundary.onNext =
|
3181
|
+
boundary.onNext = NOOP2;
|
3411
3182
|
head = head.consume();
|
3412
3183
|
asyncOut.write(head.html);
|
3413
3184
|
asyncOut.script(head.scripts);
|
@@ -3432,6 +3203,242 @@ var compat = {
|
|
3432
3203
|
register(RENDER_BODY_ID, fn);
|
3433
3204
|
}
|
3434
3205
|
};
|
3206
|
+
function NOOP2() {
|
3207
|
+
}
|
3208
|
+
|
3209
|
+
// src/html/template.ts
|
3210
|
+
var _template = (templateId, renderer) => {
|
3211
|
+
renderer.render = render;
|
3212
|
+
renderer._ = renderer;
|
3213
|
+
if (true) {
|
3214
|
+
renderer.mount = () => {
|
3215
|
+
throw new Error(
|
3216
|
+
`mount() is not implemented for the HTML compilation of a Marko template`
|
3217
|
+
);
|
3218
|
+
};
|
3219
|
+
}
|
3220
|
+
return _content_resume(templateId, renderer);
|
3221
|
+
};
|
3222
|
+
function render(input = {}) {
|
3223
|
+
let { $global: $global2 } = input;
|
3224
|
+
if ($global2) {
|
3225
|
+
({ $global: $global2, ...input } = input);
|
3226
|
+
$global2 = {
|
3227
|
+
runtimeId: DEFAULT_RUNTIME_ID,
|
3228
|
+
renderId: DEFAULT_RENDER_ID,
|
3229
|
+
...$global2
|
3230
|
+
};
|
3231
|
+
if (true) {
|
3232
|
+
if (!String($global2.runtimeId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
3233
|
+
throw new Error(
|
3234
|
+
`Invalid runtimeId: "${$global2.runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
3235
|
+
);
|
3236
|
+
}
|
3237
|
+
if (!String($global2.renderId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
3238
|
+
throw new Error(
|
3239
|
+
`Invalid renderId: "${$global2.renderId}". The renderId must be a valid JavaScript identifier.`
|
3240
|
+
);
|
3241
|
+
}
|
3242
|
+
}
|
3243
|
+
} else {
|
3244
|
+
$global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
|
3245
|
+
}
|
3246
|
+
const head = new Chunk(
|
3247
|
+
new Boundary(new State2($global2), $global2.signal),
|
3248
|
+
null,
|
3249
|
+
null
|
3250
|
+
);
|
3251
|
+
head.render(this, input);
|
3252
|
+
return new ServerRendered(head);
|
3253
|
+
}
|
3254
|
+
var ServerRendered = class {
|
3255
|
+
#head;
|
3256
|
+
#cachedPromise = null;
|
3257
|
+
constructor(head) {
|
3258
|
+
this.#head = head;
|
3259
|
+
}
|
3260
|
+
[Symbol.asyncIterator]() {
|
3261
|
+
let resolve;
|
3262
|
+
let reject;
|
3263
|
+
let value = "";
|
3264
|
+
let done = false;
|
3265
|
+
let aborted = false;
|
3266
|
+
let reason;
|
3267
|
+
const boundary = this.#read(
|
3268
|
+
(html) => {
|
3269
|
+
value += html;
|
3270
|
+
if (resolve) {
|
3271
|
+
resolve({ value, done });
|
3272
|
+
value = "";
|
3273
|
+
}
|
3274
|
+
},
|
3275
|
+
(err) => {
|
3276
|
+
aborted = true;
|
3277
|
+
reason = err;
|
3278
|
+
if (reject) {
|
3279
|
+
reject(err);
|
3280
|
+
}
|
3281
|
+
},
|
3282
|
+
() => {
|
3283
|
+
done = true;
|
3284
|
+
if (resolve) {
|
3285
|
+
resolve({ value, done: !value });
|
3286
|
+
value = "";
|
3287
|
+
}
|
3288
|
+
}
|
3289
|
+
);
|
3290
|
+
return {
|
3291
|
+
next() {
|
3292
|
+
if (aborted) {
|
3293
|
+
return Promise.reject(reason);
|
3294
|
+
} else if (value) {
|
3295
|
+
const result = { value, done: false };
|
3296
|
+
value = "";
|
3297
|
+
return Promise.resolve(result);
|
3298
|
+
} else if (done) {
|
3299
|
+
return Promise.resolve({ value: "", done });
|
3300
|
+
} else {
|
3301
|
+
return new Promise(exec);
|
3302
|
+
}
|
3303
|
+
},
|
3304
|
+
throw(error) {
|
3305
|
+
if (!(done || aborted)) {
|
3306
|
+
boundary?.abort(error);
|
3307
|
+
}
|
3308
|
+
return Promise.resolve({ value: "", done: true });
|
3309
|
+
},
|
3310
|
+
return(value2) {
|
3311
|
+
if (!(done || aborted)) {
|
3312
|
+
boundary?.abort(new Error("Iterator returned before consumed."));
|
3313
|
+
}
|
3314
|
+
return Promise.resolve({ value: value2, done: true });
|
3315
|
+
}
|
3316
|
+
};
|
3317
|
+
function exec(_resolve, _reject) {
|
3318
|
+
resolve = _resolve;
|
3319
|
+
reject = _reject;
|
3320
|
+
}
|
3321
|
+
}
|
3322
|
+
pipe(stream) {
|
3323
|
+
this.#read(
|
3324
|
+
(html) => {
|
3325
|
+
stream.write(html);
|
3326
|
+
},
|
3327
|
+
(err) => {
|
3328
|
+
const socket = "socket" in stream && stream.socket;
|
3329
|
+
if (socket && typeof socket.destroySoon === "function") {
|
3330
|
+
socket.destroySoon();
|
3331
|
+
}
|
3332
|
+
if (!stream.emit?.("error", err)) {
|
3333
|
+
throw err;
|
3334
|
+
}
|
3335
|
+
},
|
3336
|
+
() => {
|
3337
|
+
stream.end();
|
3338
|
+
}
|
3339
|
+
);
|
3340
|
+
}
|
3341
|
+
toReadable() {
|
3342
|
+
let cancelled = false;
|
3343
|
+
let boundary;
|
3344
|
+
const encoder = new TextEncoder();
|
3345
|
+
return new ReadableStream({
|
3346
|
+
start: (ctrl) => {
|
3347
|
+
boundary = this.#read(
|
3348
|
+
(html) => {
|
3349
|
+
ctrl.enqueue(encoder.encode(html));
|
3350
|
+
},
|
3351
|
+
(err) => {
|
3352
|
+
boundary = void 0;
|
3353
|
+
if (!cancelled) {
|
3354
|
+
ctrl.error(err);
|
3355
|
+
}
|
3356
|
+
},
|
3357
|
+
() => {
|
3358
|
+
boundary = void 0;
|
3359
|
+
ctrl.close();
|
3360
|
+
}
|
3361
|
+
);
|
3362
|
+
},
|
3363
|
+
cancel: (reason) => {
|
3364
|
+
cancelled = true;
|
3365
|
+
boundary?.abort(reason);
|
3366
|
+
}
|
3367
|
+
});
|
3368
|
+
}
|
3369
|
+
then(onfulfilled, onrejected) {
|
3370
|
+
return this.#promise().then(onfulfilled, onrejected);
|
3371
|
+
}
|
3372
|
+
catch(onrejected) {
|
3373
|
+
return this.#promise().catch(onrejected);
|
3374
|
+
}
|
3375
|
+
finally(onfinally) {
|
3376
|
+
return this.#promise().finally(onfinally);
|
3377
|
+
}
|
3378
|
+
#promise() {
|
3379
|
+
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
3380
|
+
const head = this.#head;
|
3381
|
+
this.#head = null;
|
3382
|
+
if (!head) {
|
3383
|
+
return reject(new Error("Cannot read from a consumed render result"));
|
3384
|
+
}
|
3385
|
+
const { boundary } = head;
|
3386
|
+
(boundary.onNext = () => {
|
3387
|
+
if (boundary.signal.aborted) {
|
3388
|
+
boundary.onNext = NOOP3;
|
3389
|
+
reject(boundary.signal.reason);
|
3390
|
+
} else if (!boundary.count && boundary.done) {
|
3391
|
+
resolve(head.consume().flushHTML());
|
3392
|
+
}
|
3393
|
+
})();
|
3394
|
+
});
|
3395
|
+
}
|
3396
|
+
#read(onWrite, onAbort, onClose) {
|
3397
|
+
let tick2 = true;
|
3398
|
+
let head = this.#head;
|
3399
|
+
this.#head = null;
|
3400
|
+
if (!head) {
|
3401
|
+
onAbort(new Error("Cannot read from a consumed render result"));
|
3402
|
+
return;
|
3403
|
+
}
|
3404
|
+
const { boundary } = head;
|
3405
|
+
const onNext = boundary.onNext = (write) => {
|
3406
|
+
if (boundary.signal.aborted) {
|
3407
|
+
if (!tick2) offTick(onNext);
|
3408
|
+
boundary.onNext = NOOP3;
|
3409
|
+
onAbort(boundary.signal.reason);
|
3410
|
+
} else {
|
3411
|
+
const { done } = boundary;
|
3412
|
+
if (done || write) {
|
3413
|
+
const html = (head = head.consume()).flushHTML();
|
3414
|
+
if (html) onWrite(html);
|
3415
|
+
if (done) {
|
3416
|
+
if (!tick2) offTick(onNext);
|
3417
|
+
onClose();
|
3418
|
+
} else {
|
3419
|
+
tick2 = true;
|
3420
|
+
}
|
3421
|
+
} else if (tick2) {
|
3422
|
+
tick2 = false;
|
3423
|
+
queueTick(onNext);
|
3424
|
+
}
|
3425
|
+
}
|
3426
|
+
};
|
3427
|
+
onNext();
|
3428
|
+
return boundary;
|
3429
|
+
}
|
3430
|
+
toString() {
|
3431
|
+
const head = this.#head;
|
3432
|
+
this.#head = null;
|
3433
|
+
if (!head) throw new Error("Cannot read from a consumed render result");
|
3434
|
+
const { boundary } = head;
|
3435
|
+
if (!boundary.done) {
|
3436
|
+
throw new Error("Cannot consume asynchronous render with 'toString'");
|
3437
|
+
}
|
3438
|
+
if (boundary.signal.aborted) throw boundary.signal.reason;
|
3439
|
+
return head.consume().flushHTML();
|
3440
|
+
}
|
3441
|
+
};
|
3435
3442
|
function NOOP3() {
|
3436
3443
|
}
|
3437
3444
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -3468,6 +3475,7 @@ function NOOP3() {
|
|
3468
3475
|
_for_of,
|
3469
3476
|
_for_to,
|
3470
3477
|
_for_until,
|
3478
|
+
_get_serialize_reason,
|
3471
3479
|
_hoist,
|
3472
3480
|
_html,
|
3473
3481
|
_id,
|
@@ -3482,6 +3490,7 @@ function NOOP3() {
|
|
3482
3490
|
_sep,
|
3483
3491
|
_serialize_guard,
|
3484
3492
|
_serialize_if,
|
3493
|
+
_set_serialize_reason,
|
3485
3494
|
_subscribe,
|
3486
3495
|
_template,
|
3487
3496
|
_trailers,
|