marko 6.0.78 → 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 +2 -2
package/dist/debug/html.mjs
CHANGED
@@ -1707,6 +1707,14 @@ function getScopeById(scopeId) {
|
|
1707
1707
|
return $chunk.boundary.state.scopes.get(scopeId);
|
1708
1708
|
}
|
1709
1709
|
}
|
1710
|
+
function _set_serialize_reason(reason) {
|
1711
|
+
$chunk.boundary.state.serializeReason = reason;
|
1712
|
+
}
|
1713
|
+
function _get_serialize_reason() {
|
1714
|
+
const reason = $chunk.boundary.state.serializeReason;
|
1715
|
+
$chunk.boundary.state.serializeReason = void 0;
|
1716
|
+
return reason;
|
1717
|
+
}
|
1710
1718
|
function _serialize_if(condition, key) {
|
1711
1719
|
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
1712
1720
|
}
|
@@ -2202,6 +2210,7 @@ var State2 = class {
|
|
2202
2210
|
writeReorders = null;
|
2203
2211
|
scopes = /* @__PURE__ */ new Map();
|
2204
2212
|
writeScopes = null;
|
2213
|
+
serializeReason;
|
2205
2214
|
get runtimePrefix() {
|
2206
2215
|
const { $global: $global2 } = this;
|
2207
2216
|
return $global2.runtimeId + "." + $global2.renderId;
|
@@ -2843,245 +2852,6 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
|
2843
2852
|
var DEFAULT_RUNTIME_ID = "M";
|
2844
2853
|
var DEFAULT_RENDER_ID = "_";
|
2845
2854
|
|
2846
|
-
// src/html/template.ts
|
2847
|
-
var _template = (templateId, renderer) => {
|
2848
|
-
renderer.render = render;
|
2849
|
-
renderer._ = renderer;
|
2850
|
-
if (true) {
|
2851
|
-
renderer.mount = () => {
|
2852
|
-
throw new Error(
|
2853
|
-
`mount() is not implemented for the HTML compilation of a Marko template`
|
2854
|
-
);
|
2855
|
-
};
|
2856
|
-
}
|
2857
|
-
return _content_resume(templateId, renderer);
|
2858
|
-
};
|
2859
|
-
function isTemplate(renderer) {
|
2860
|
-
return !!renderer._;
|
2861
|
-
}
|
2862
|
-
function render(input = {}) {
|
2863
|
-
let { $global: $global2 } = input;
|
2864
|
-
if ($global2) {
|
2865
|
-
({ $global: $global2, ...input } = input);
|
2866
|
-
$global2 = {
|
2867
|
-
runtimeId: DEFAULT_RUNTIME_ID,
|
2868
|
-
renderId: DEFAULT_RENDER_ID,
|
2869
|
-
...$global2
|
2870
|
-
};
|
2871
|
-
if (true) {
|
2872
|
-
if (!String($global2.runtimeId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
2873
|
-
throw new Error(
|
2874
|
-
`Invalid runtimeId: "${$global2.runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
2875
|
-
);
|
2876
|
-
}
|
2877
|
-
if (!String($global2.renderId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
2878
|
-
throw new Error(
|
2879
|
-
`Invalid renderId: "${$global2.renderId}". The renderId must be a valid JavaScript identifier.`
|
2880
|
-
);
|
2881
|
-
}
|
2882
|
-
}
|
2883
|
-
} else {
|
2884
|
-
$global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
|
2885
|
-
}
|
2886
|
-
const head = new Chunk(
|
2887
|
-
new Boundary(new State2($global2), $global2.signal),
|
2888
|
-
null,
|
2889
|
-
null
|
2890
|
-
);
|
2891
|
-
head.render(this, input);
|
2892
|
-
return new ServerRendered(head);
|
2893
|
-
}
|
2894
|
-
var ServerRendered = class {
|
2895
|
-
#head;
|
2896
|
-
#cachedPromise = null;
|
2897
|
-
constructor(head) {
|
2898
|
-
this.#head = head;
|
2899
|
-
}
|
2900
|
-
[Symbol.asyncIterator]() {
|
2901
|
-
let resolve;
|
2902
|
-
let reject;
|
2903
|
-
let value = "";
|
2904
|
-
let done = false;
|
2905
|
-
let aborted = false;
|
2906
|
-
let reason;
|
2907
|
-
const boundary = this.#read(
|
2908
|
-
(html) => {
|
2909
|
-
value += html;
|
2910
|
-
if (resolve) {
|
2911
|
-
resolve({ value, done });
|
2912
|
-
value = "";
|
2913
|
-
}
|
2914
|
-
},
|
2915
|
-
(err) => {
|
2916
|
-
aborted = true;
|
2917
|
-
reason = err;
|
2918
|
-
if (reject) {
|
2919
|
-
reject(err);
|
2920
|
-
}
|
2921
|
-
},
|
2922
|
-
() => {
|
2923
|
-
done = true;
|
2924
|
-
if (resolve) {
|
2925
|
-
resolve({ value, done: !value });
|
2926
|
-
value = "";
|
2927
|
-
}
|
2928
|
-
}
|
2929
|
-
);
|
2930
|
-
return {
|
2931
|
-
next() {
|
2932
|
-
if (aborted) {
|
2933
|
-
return Promise.reject(reason);
|
2934
|
-
} else if (value) {
|
2935
|
-
const result = { value, done: false };
|
2936
|
-
value = "";
|
2937
|
-
return Promise.resolve(result);
|
2938
|
-
} else if (done) {
|
2939
|
-
return Promise.resolve({ value: "", done });
|
2940
|
-
} else {
|
2941
|
-
return new Promise(exec);
|
2942
|
-
}
|
2943
|
-
},
|
2944
|
-
throw(error) {
|
2945
|
-
if (!(done || aborted)) {
|
2946
|
-
boundary?.abort(error);
|
2947
|
-
}
|
2948
|
-
return Promise.resolve({ value: "", done: true });
|
2949
|
-
},
|
2950
|
-
return(value2) {
|
2951
|
-
if (!(done || aborted)) {
|
2952
|
-
boundary?.abort(new Error("Iterator returned before consumed."));
|
2953
|
-
}
|
2954
|
-
return Promise.resolve({ value: value2, done: true });
|
2955
|
-
}
|
2956
|
-
};
|
2957
|
-
function exec(_resolve, _reject) {
|
2958
|
-
resolve = _resolve;
|
2959
|
-
reject = _reject;
|
2960
|
-
}
|
2961
|
-
}
|
2962
|
-
pipe(stream) {
|
2963
|
-
this.#read(
|
2964
|
-
(html) => {
|
2965
|
-
stream.write(html);
|
2966
|
-
},
|
2967
|
-
(err) => {
|
2968
|
-
const socket = "socket" in stream && stream.socket;
|
2969
|
-
if (socket && typeof socket.destroySoon === "function") {
|
2970
|
-
socket.destroySoon();
|
2971
|
-
}
|
2972
|
-
if (!stream.emit?.("error", err)) {
|
2973
|
-
throw err;
|
2974
|
-
}
|
2975
|
-
},
|
2976
|
-
() => {
|
2977
|
-
stream.end();
|
2978
|
-
}
|
2979
|
-
);
|
2980
|
-
}
|
2981
|
-
toReadable() {
|
2982
|
-
let cancelled = false;
|
2983
|
-
let boundary;
|
2984
|
-
const encoder = new TextEncoder();
|
2985
|
-
return new ReadableStream({
|
2986
|
-
start: (ctrl) => {
|
2987
|
-
boundary = this.#read(
|
2988
|
-
(html) => {
|
2989
|
-
ctrl.enqueue(encoder.encode(html));
|
2990
|
-
},
|
2991
|
-
(err) => {
|
2992
|
-
boundary = void 0;
|
2993
|
-
if (!cancelled) {
|
2994
|
-
ctrl.error(err);
|
2995
|
-
}
|
2996
|
-
},
|
2997
|
-
() => {
|
2998
|
-
boundary = void 0;
|
2999
|
-
ctrl.close();
|
3000
|
-
}
|
3001
|
-
);
|
3002
|
-
},
|
3003
|
-
cancel: (reason) => {
|
3004
|
-
cancelled = true;
|
3005
|
-
boundary?.abort(reason);
|
3006
|
-
}
|
3007
|
-
});
|
3008
|
-
}
|
3009
|
-
then(onfulfilled, onrejected) {
|
3010
|
-
return this.#promise().then(onfulfilled, onrejected);
|
3011
|
-
}
|
3012
|
-
catch(onrejected) {
|
3013
|
-
return this.#promise().catch(onrejected);
|
3014
|
-
}
|
3015
|
-
finally(onfinally) {
|
3016
|
-
return this.#promise().finally(onfinally);
|
3017
|
-
}
|
3018
|
-
#promise() {
|
3019
|
-
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
3020
|
-
const head = this.#head;
|
3021
|
-
this.#head = null;
|
3022
|
-
if (!head) {
|
3023
|
-
return reject(new Error("Cannot read from a consumed render result"));
|
3024
|
-
}
|
3025
|
-
const { boundary } = head;
|
3026
|
-
(boundary.onNext = () => {
|
3027
|
-
if (boundary.signal.aborted) {
|
3028
|
-
boundary.onNext = NOOP2;
|
3029
|
-
reject(boundary.signal.reason);
|
3030
|
-
} else if (!boundary.count && boundary.done) {
|
3031
|
-
resolve(head.consume().flushHTML());
|
3032
|
-
}
|
3033
|
-
})();
|
3034
|
-
});
|
3035
|
-
}
|
3036
|
-
#read(onWrite, onAbort, onClose) {
|
3037
|
-
let tick2 = true;
|
3038
|
-
let head = this.#head;
|
3039
|
-
this.#head = null;
|
3040
|
-
if (!head) {
|
3041
|
-
onAbort(new Error("Cannot read from a consumed render result"));
|
3042
|
-
return;
|
3043
|
-
}
|
3044
|
-
const { boundary } = head;
|
3045
|
-
const onNext = boundary.onNext = (write) => {
|
3046
|
-
if (boundary.signal.aborted) {
|
3047
|
-
if (!tick2) offTick(onNext);
|
3048
|
-
boundary.onNext = NOOP2;
|
3049
|
-
onAbort(boundary.signal.reason);
|
3050
|
-
} else {
|
3051
|
-
const { done } = boundary;
|
3052
|
-
if (done || write) {
|
3053
|
-
const html = (head = head.consume()).flushHTML();
|
3054
|
-
if (html) onWrite(html);
|
3055
|
-
if (done) {
|
3056
|
-
if (!tick2) offTick(onNext);
|
3057
|
-
onClose();
|
3058
|
-
} else {
|
3059
|
-
tick2 = true;
|
3060
|
-
}
|
3061
|
-
} else if (tick2) {
|
3062
|
-
tick2 = false;
|
3063
|
-
queueTick(onNext);
|
3064
|
-
}
|
3065
|
-
}
|
3066
|
-
};
|
3067
|
-
onNext();
|
3068
|
-
return boundary;
|
3069
|
-
}
|
3070
|
-
toString() {
|
3071
|
-
const head = this.#head;
|
3072
|
-
this.#head = null;
|
3073
|
-
if (!head) throw new Error("Cannot read from a consumed render result");
|
3074
|
-
const { boundary } = head;
|
3075
|
-
if (!boundary.done) {
|
3076
|
-
throw new Error("Cannot consume asynchronous render with 'toString'");
|
3077
|
-
}
|
3078
|
-
if (boundary.signal.aborted) throw boundary.signal.reason;
|
3079
|
-
return head.consume().flushHTML();
|
3080
|
-
}
|
3081
|
-
};
|
3082
|
-
function NOOP2() {
|
3083
|
-
}
|
3084
|
-
|
3085
2855
|
// src/html/dynamic-tag.ts
|
3086
2856
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
3087
2857
|
var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
@@ -3165,16 +2935,14 @@ var _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
3165
2935
|
}
|
3166
2936
|
const render2 = () => {
|
3167
2937
|
if (renderer) {
|
3168
|
-
|
3169
|
-
|
3170
|
-
return renderer(
|
3171
|
-
content ? { ...
|
3172
|
-
shouldResume ? 1 : 0
|
2938
|
+
try {
|
2939
|
+
_set_serialize_reason(shouldResume ? 1 : 0);
|
2940
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
2941
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
3173
2942
|
);
|
2943
|
+
} finally {
|
2944
|
+
_set_serialize_reason(void 0);
|
3174
2945
|
}
|
3175
|
-
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
3176
|
-
content ? { ...inputOrArgs, content } : inputOrArgs
|
3177
|
-
);
|
3178
2946
|
} else if (content) {
|
3179
2947
|
return content();
|
3180
2948
|
}
|
@@ -3308,19 +3076,20 @@ var compat = {
|
|
3308
3076
|
writeScope(scopeId, { m5c: component.id });
|
3309
3077
|
_script(scopeId, SET_SCOPE_REGISTER_ID);
|
3310
3078
|
}
|
3311
|
-
|
3312
|
-
|
3313
|
-
} else {
|
3079
|
+
_set_serialize_reason(willRerender ? 1 : 0);
|
3080
|
+
try {
|
3314
3081
|
renderer(normalizedInput);
|
3082
|
+
} finally {
|
3083
|
+
_set_serialize_reason(void 0);
|
3315
3084
|
}
|
3316
3085
|
const asyncOut = classAPIOut.beginAsync({ last: true, timeout: -1 });
|
3317
3086
|
classAPIOut.onLast((next) => {
|
3318
3087
|
(boundary.onNext = () => {
|
3319
3088
|
if (boundary.signal.aborted) {
|
3320
3089
|
asyncOut.error(boundary.signal.reason);
|
3321
|
-
boundary.onNext =
|
3090
|
+
boundary.onNext = NOOP2;
|
3322
3091
|
} else if (!boundary.count) {
|
3323
|
-
boundary.onNext =
|
3092
|
+
boundary.onNext = NOOP2;
|
3324
3093
|
head = head.consume();
|
3325
3094
|
asyncOut.write(head.html);
|
3326
3095
|
asyncOut.script(head.scripts);
|
@@ -3345,6 +3114,242 @@ var compat = {
|
|
3345
3114
|
register(RENDER_BODY_ID, fn);
|
3346
3115
|
}
|
3347
3116
|
};
|
3117
|
+
function NOOP2() {
|
3118
|
+
}
|
3119
|
+
|
3120
|
+
// src/html/template.ts
|
3121
|
+
var _template = (templateId, renderer) => {
|
3122
|
+
renderer.render = render;
|
3123
|
+
renderer._ = renderer;
|
3124
|
+
if (true) {
|
3125
|
+
renderer.mount = () => {
|
3126
|
+
throw new Error(
|
3127
|
+
`mount() is not implemented for the HTML compilation of a Marko template`
|
3128
|
+
);
|
3129
|
+
};
|
3130
|
+
}
|
3131
|
+
return _content_resume(templateId, renderer);
|
3132
|
+
};
|
3133
|
+
function render(input = {}) {
|
3134
|
+
let { $global: $global2 } = input;
|
3135
|
+
if ($global2) {
|
3136
|
+
({ $global: $global2, ...input } = input);
|
3137
|
+
$global2 = {
|
3138
|
+
runtimeId: DEFAULT_RUNTIME_ID,
|
3139
|
+
renderId: DEFAULT_RENDER_ID,
|
3140
|
+
...$global2
|
3141
|
+
};
|
3142
|
+
if (true) {
|
3143
|
+
if (!String($global2.runtimeId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
3144
|
+
throw new Error(
|
3145
|
+
`Invalid runtimeId: "${$global2.runtimeId}". The runtimeId must be a valid JavaScript identifier.`
|
3146
|
+
);
|
3147
|
+
}
|
3148
|
+
if (!String($global2.renderId).match(/^[_$a-z][_$a-z0-9]*$/i)) {
|
3149
|
+
throw new Error(
|
3150
|
+
`Invalid renderId: "${$global2.renderId}". The renderId must be a valid JavaScript identifier.`
|
3151
|
+
);
|
3152
|
+
}
|
3153
|
+
}
|
3154
|
+
} else {
|
3155
|
+
$global2 = { runtimeId: DEFAULT_RUNTIME_ID, renderId: DEFAULT_RENDER_ID };
|
3156
|
+
}
|
3157
|
+
const head = new Chunk(
|
3158
|
+
new Boundary(new State2($global2), $global2.signal),
|
3159
|
+
null,
|
3160
|
+
null
|
3161
|
+
);
|
3162
|
+
head.render(this, input);
|
3163
|
+
return new ServerRendered(head);
|
3164
|
+
}
|
3165
|
+
var ServerRendered = class {
|
3166
|
+
#head;
|
3167
|
+
#cachedPromise = null;
|
3168
|
+
constructor(head) {
|
3169
|
+
this.#head = head;
|
3170
|
+
}
|
3171
|
+
[Symbol.asyncIterator]() {
|
3172
|
+
let resolve;
|
3173
|
+
let reject;
|
3174
|
+
let value = "";
|
3175
|
+
let done = false;
|
3176
|
+
let aborted = false;
|
3177
|
+
let reason;
|
3178
|
+
const boundary = this.#read(
|
3179
|
+
(html) => {
|
3180
|
+
value += html;
|
3181
|
+
if (resolve) {
|
3182
|
+
resolve({ value, done });
|
3183
|
+
value = "";
|
3184
|
+
}
|
3185
|
+
},
|
3186
|
+
(err) => {
|
3187
|
+
aborted = true;
|
3188
|
+
reason = err;
|
3189
|
+
if (reject) {
|
3190
|
+
reject(err);
|
3191
|
+
}
|
3192
|
+
},
|
3193
|
+
() => {
|
3194
|
+
done = true;
|
3195
|
+
if (resolve) {
|
3196
|
+
resolve({ value, done: !value });
|
3197
|
+
value = "";
|
3198
|
+
}
|
3199
|
+
}
|
3200
|
+
);
|
3201
|
+
return {
|
3202
|
+
next() {
|
3203
|
+
if (aborted) {
|
3204
|
+
return Promise.reject(reason);
|
3205
|
+
} else if (value) {
|
3206
|
+
const result = { value, done: false };
|
3207
|
+
value = "";
|
3208
|
+
return Promise.resolve(result);
|
3209
|
+
} else if (done) {
|
3210
|
+
return Promise.resolve({ value: "", done });
|
3211
|
+
} else {
|
3212
|
+
return new Promise(exec);
|
3213
|
+
}
|
3214
|
+
},
|
3215
|
+
throw(error) {
|
3216
|
+
if (!(done || aborted)) {
|
3217
|
+
boundary?.abort(error);
|
3218
|
+
}
|
3219
|
+
return Promise.resolve({ value: "", done: true });
|
3220
|
+
},
|
3221
|
+
return(value2) {
|
3222
|
+
if (!(done || aborted)) {
|
3223
|
+
boundary?.abort(new Error("Iterator returned before consumed."));
|
3224
|
+
}
|
3225
|
+
return Promise.resolve({ value: value2, done: true });
|
3226
|
+
}
|
3227
|
+
};
|
3228
|
+
function exec(_resolve, _reject) {
|
3229
|
+
resolve = _resolve;
|
3230
|
+
reject = _reject;
|
3231
|
+
}
|
3232
|
+
}
|
3233
|
+
pipe(stream) {
|
3234
|
+
this.#read(
|
3235
|
+
(html) => {
|
3236
|
+
stream.write(html);
|
3237
|
+
},
|
3238
|
+
(err) => {
|
3239
|
+
const socket = "socket" in stream && stream.socket;
|
3240
|
+
if (socket && typeof socket.destroySoon === "function") {
|
3241
|
+
socket.destroySoon();
|
3242
|
+
}
|
3243
|
+
if (!stream.emit?.("error", err)) {
|
3244
|
+
throw err;
|
3245
|
+
}
|
3246
|
+
},
|
3247
|
+
() => {
|
3248
|
+
stream.end();
|
3249
|
+
}
|
3250
|
+
);
|
3251
|
+
}
|
3252
|
+
toReadable() {
|
3253
|
+
let cancelled = false;
|
3254
|
+
let boundary;
|
3255
|
+
const encoder = new TextEncoder();
|
3256
|
+
return new ReadableStream({
|
3257
|
+
start: (ctrl) => {
|
3258
|
+
boundary = this.#read(
|
3259
|
+
(html) => {
|
3260
|
+
ctrl.enqueue(encoder.encode(html));
|
3261
|
+
},
|
3262
|
+
(err) => {
|
3263
|
+
boundary = void 0;
|
3264
|
+
if (!cancelled) {
|
3265
|
+
ctrl.error(err);
|
3266
|
+
}
|
3267
|
+
},
|
3268
|
+
() => {
|
3269
|
+
boundary = void 0;
|
3270
|
+
ctrl.close();
|
3271
|
+
}
|
3272
|
+
);
|
3273
|
+
},
|
3274
|
+
cancel: (reason) => {
|
3275
|
+
cancelled = true;
|
3276
|
+
boundary?.abort(reason);
|
3277
|
+
}
|
3278
|
+
});
|
3279
|
+
}
|
3280
|
+
then(onfulfilled, onrejected) {
|
3281
|
+
return this.#promise().then(onfulfilled, onrejected);
|
3282
|
+
}
|
3283
|
+
catch(onrejected) {
|
3284
|
+
return this.#promise().catch(onrejected);
|
3285
|
+
}
|
3286
|
+
finally(onfinally) {
|
3287
|
+
return this.#promise().finally(onfinally);
|
3288
|
+
}
|
3289
|
+
#promise() {
|
3290
|
+
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
3291
|
+
const head = this.#head;
|
3292
|
+
this.#head = null;
|
3293
|
+
if (!head) {
|
3294
|
+
return reject(new Error("Cannot read from a consumed render result"));
|
3295
|
+
}
|
3296
|
+
const { boundary } = head;
|
3297
|
+
(boundary.onNext = () => {
|
3298
|
+
if (boundary.signal.aborted) {
|
3299
|
+
boundary.onNext = NOOP3;
|
3300
|
+
reject(boundary.signal.reason);
|
3301
|
+
} else if (!boundary.count && boundary.done) {
|
3302
|
+
resolve(head.consume().flushHTML());
|
3303
|
+
}
|
3304
|
+
})();
|
3305
|
+
});
|
3306
|
+
}
|
3307
|
+
#read(onWrite, onAbort, onClose) {
|
3308
|
+
let tick2 = true;
|
3309
|
+
let head = this.#head;
|
3310
|
+
this.#head = null;
|
3311
|
+
if (!head) {
|
3312
|
+
onAbort(new Error("Cannot read from a consumed render result"));
|
3313
|
+
return;
|
3314
|
+
}
|
3315
|
+
const { boundary } = head;
|
3316
|
+
const onNext = boundary.onNext = (write) => {
|
3317
|
+
if (boundary.signal.aborted) {
|
3318
|
+
if (!tick2) offTick(onNext);
|
3319
|
+
boundary.onNext = NOOP3;
|
3320
|
+
onAbort(boundary.signal.reason);
|
3321
|
+
} else {
|
3322
|
+
const { done } = boundary;
|
3323
|
+
if (done || write) {
|
3324
|
+
const html = (head = head.consume()).flushHTML();
|
3325
|
+
if (html) onWrite(html);
|
3326
|
+
if (done) {
|
3327
|
+
if (!tick2) offTick(onNext);
|
3328
|
+
onClose();
|
3329
|
+
} else {
|
3330
|
+
tick2 = true;
|
3331
|
+
}
|
3332
|
+
} else if (tick2) {
|
3333
|
+
tick2 = false;
|
3334
|
+
queueTick(onNext);
|
3335
|
+
}
|
3336
|
+
}
|
3337
|
+
};
|
3338
|
+
onNext();
|
3339
|
+
return boundary;
|
3340
|
+
}
|
3341
|
+
toString() {
|
3342
|
+
const head = this.#head;
|
3343
|
+
this.#head = null;
|
3344
|
+
if (!head) throw new Error("Cannot read from a consumed render result");
|
3345
|
+
const { boundary } = head;
|
3346
|
+
if (!boundary.done) {
|
3347
|
+
throw new Error("Cannot consume asynchronous render with 'toString'");
|
3348
|
+
}
|
3349
|
+
if (boundary.signal.aborted) throw boundary.signal.reason;
|
3350
|
+
return head.consume().flushHTML();
|
3351
|
+
}
|
3352
|
+
};
|
3348
3353
|
function NOOP3() {
|
3349
3354
|
}
|
3350
3355
|
export {
|
@@ -3380,6 +3385,7 @@ export {
|
|
3380
3385
|
_for_of,
|
3381
3386
|
_for_to,
|
3382
3387
|
_for_until,
|
3388
|
+
_get_serialize_reason,
|
3383
3389
|
_hoist,
|
3384
3390
|
_html,
|
3385
3391
|
_id,
|
@@ -3394,6 +3400,7 @@ export {
|
|
3394
3400
|
_sep,
|
3395
3401
|
_serialize_guard,
|
3396
3402
|
_serialize_if,
|
3403
|
+
_set_serialize_reason,
|
3397
3404
|
_subscribe,
|
3398
3405
|
_template,
|
3399
3406
|
_trailers,
|
package/dist/dom/signals.d.ts
CHANGED
@@ -15,6 +15,13 @@ export declare function _closure_get<T>(valueAccessor: Accessor, fn: Signal<T>,
|
|
15
15
|
___signalIndexAccessor: string;
|
16
16
|
___index: number;
|
17
17
|
};
|
18
|
+
export declare function _child_setup(setup: Signal<never> & {
|
19
|
+
_: Signal<Scope>;
|
20
|
+
}): SignalFn<never> & {
|
21
|
+
___subscribe?(scope: Scope): void;
|
22
|
+
} & {
|
23
|
+
_: Signal<Scope>;
|
24
|
+
};
|
18
25
|
export declare function _var(scope: Scope, childAccessor: Accessor, signal: Signal<unknown>): void;
|
19
26
|
export declare const _return: (scope: Scope, value: unknown) => any;
|
20
27
|
export declare function _return_change(scope: Scope, changeHandler?: ((value: unknown) => void) | null | false): void;
|
package/dist/dom.d.ts
CHANGED
@@ -9,5 +9,5 @@ export { _on } from "./dom/event";
|
|
9
9
|
export { _enable_catch as _enable_catch, run } from "./dom/queue";
|
10
10
|
export { _content, _content_branch, _content_closures, _content_resume, } from "./dom/renderer";
|
11
11
|
export { _el, _resume, _var_resume, init } from "./dom/resume";
|
12
|
-
export { _closure, _closure_get, _const, _for_closure, _hoist, _id, _if_closure, _let, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
12
|
+
export { _child_setup, _closure, _closure_get, _const, _for_closure, _hoist, _id, _if_closure, _let, _or, _return, _return_change, _script, _var, _var_change, } from "./dom/signals";
|
13
13
|
export { _template } from "./dom/template";
|
package/dist/dom.js
CHANGED
@@ -47,6 +47,7 @@ __export(dom_exports, {
|
|
47
47
|
_attrs_partial_content: () => _attrs_partial_content,
|
48
48
|
_attrs_script: () => _attrs_script,
|
49
49
|
_await: () => _await,
|
50
|
+
_child_setup: () => _child_setup,
|
50
51
|
_closure: () => _closure,
|
51
52
|
_closure_get: () => _closure_get,
|
52
53
|
_const: () => _const,
|
@@ -686,6 +687,11 @@ function closure(valueAccessor, fn, getOwnerScope) {
|
|
686
687
|
);
|
687
688
|
};
|
688
689
|
}
|
690
|
+
function _child_setup(setup) {
|
691
|
+
return setup._ = (scope, owner) => {
|
692
|
+
scope._ = owner, queueRender(scope, setup, -1);
|
693
|
+
}, setup;
|
694
|
+
}
|
689
695
|
function _var(scope, childAccessor, signal) {
|
690
696
|
scope[childAccessor].e = (value) => signal(scope, value);
|
691
697
|
}
|
package/dist/dom.mjs
CHANGED
@@ -590,6 +590,11 @@ function closure(valueAccessor, fn, getOwnerScope) {
|
|
590
590
|
);
|
591
591
|
};
|
592
592
|
}
|
593
|
+
function _child_setup(setup) {
|
594
|
+
return setup._ = (scope, owner) => {
|
595
|
+
scope._ = owner, queueRender(scope, setup, -1);
|
596
|
+
}, setup;
|
597
|
+
}
|
593
598
|
function _var(scope, childAccessor, signal) {
|
594
599
|
scope[childAccessor].e = (value) => signal(scope, value);
|
595
600
|
}
|
@@ -1489,6 +1494,7 @@ export {
|
|
1489
1494
|
_attrs_partial_content,
|
1490
1495
|
_attrs_script,
|
1491
1496
|
_await,
|
1497
|
+
_child_setup,
|
1492
1498
|
_closure,
|
1493
1499
|
_closure_get,
|
1494
1500
|
_const,
|
package/dist/html/compat.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { patchDynamicTag } from "./dynamic-tag";
|
2
|
-
import {
|
2
|
+
import type { ServerRenderer } from "./template";
|
3
3
|
import { _await, _html, _peek_scope_id, _scope_id, $global, Chunk, isInResumedBranch, State, writeScript } from "./writer";
|
4
4
|
export declare const compat: {
|
5
5
|
$global: typeof $global;
|
package/dist/html/writer.d.ts
CHANGED
@@ -27,6 +27,8 @@ export declare function _id(): string;
|
|
27
27
|
export declare function _scope_id(): number;
|
28
28
|
export declare function _peek_scope_id(): number;
|
29
29
|
export declare function getScopeById(scopeId: number | undefined): PartialScope | undefined;
|
30
|
+
export declare function _set_serialize_reason(reason: undefined | 0 | 1): void;
|
31
|
+
export declare function _get_serialize_reason(): 0 | 1 | undefined;
|
30
32
|
export declare function _serialize_if(condition: undefined | 1 | Record<string, 1>, key: string): 1 | undefined;
|
31
33
|
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string): 0 | 1;
|
32
34
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
@@ -84,6 +86,7 @@ export declare class State {
|
|
84
86
|
writeReorders: Chunk[] | null;
|
85
87
|
scopes: Map<number, PartialScope>;
|
86
88
|
writeScopes: null | Record<number, PartialScope>;
|
89
|
+
serializeReason: undefined | 0 | 1;
|
87
90
|
constructor($global: $Global & {
|
88
91
|
renderId: string;
|
89
92
|
runtimeId: string;
|
package/dist/html.d.ts
CHANGED
@@ -5,4 +5,4 @@ export { _escape, _escape_script, _escape_style, _escape_textarea_value, _unesca
|
|
5
5
|
export { _content, _content_resume, _dynamic_tag } from "./html/dynamic-tag";
|
6
6
|
export { forIn, forInBy, forOf, forOfBy, forStepBy, forTo, forUntil, } from "./html/for";
|
7
7
|
export { _template } from "./html/template";
|
8
|
-
export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
|
8
|
+
export { _attr_content, _await, _el, _el_resume, _existing_scope, _for_in, _for_of, _for_to, _for_until, _get_serialize_reason, _hoist, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _scope, _scope_id, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _subscribe, _trailers, _try, _var, $global, } from "./html/writer";
|