marko 6.0.7 → 6.0.9
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 +60 -52
- package/dist/debug/dom.mjs +60 -52
- package/dist/debug/html.js +1 -1
- package/dist/debug/html.mjs +1 -1
- package/dist/dom/dom.d.ts +0 -1
- package/dist/dom/resume.d.ts +2 -0
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +39 -37
- package/dist/dom.mjs +39 -37
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/dist/translator/index.js +725 -637
- package/dist/translator/util/optional.d.ts +1 -0
- package/dist/translator/util/references.d.ts +16 -5
- package/dist/translator/util/serialize-reasons.d.ts +10 -12
- package/dist/translator/util/with-comment.d.ts +2 -0
- package/dist/translator/visitors/program/html.d.ts +4 -3
- package/dist/translator/visitors/program/index.d.ts +9 -5
- package/package.json +1 -1
- package/dist/translator/util/css-px-props.d.ts +0 -2
package/dist/translator/index.js
CHANGED
@@ -235,6 +235,268 @@ function isNullableExpr(expr) {
|
|
235
235
|
var import_compiler24 = require("@marko/compiler");
|
236
236
|
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
237
237
|
|
238
|
+
// src/html/serializer.ts
|
239
|
+
var kTouchedIterator = Symbol();
|
240
|
+
var { hasOwnProperty } = {};
|
241
|
+
var Generator = function* () {
|
242
|
+
}().constructor;
|
243
|
+
var AsyncGenerator = async function* () {
|
244
|
+
}().constructor;
|
245
|
+
patchIteratorNext(Generator.prototype);
|
246
|
+
patchIteratorNext(AsyncGenerator.prototype);
|
247
|
+
var KNOWN_SYMBOLS = (() => {
|
248
|
+
const KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
|
249
|
+
for (const name2 of Object.getOwnPropertyNames(Symbol)) {
|
250
|
+
const symbol = Symbol[name2];
|
251
|
+
if (typeof symbol === "symbol") {
|
252
|
+
KNOWN_SYMBOLS2.set(symbol, "Symbol." + name2);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
return KNOWN_SYMBOLS2;
|
256
|
+
})();
|
257
|
+
var KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
|
258
|
+
// This is by no means an exhaustive list,
|
259
|
+
// but it should cover most of the built-in functions.
|
260
|
+
[AggregateError, "AggregateError"],
|
261
|
+
[Array, "Array"],
|
262
|
+
[Array.from, "Array.from"],
|
263
|
+
[Array.isArray, "Array.isArray"],
|
264
|
+
[Array.of, "Array.of"],
|
265
|
+
[ArrayBuffer, "ArrayBuffer"],
|
266
|
+
[ArrayBuffer.isView, "ArrayBuffer.isView"],
|
267
|
+
[Atomics.add, "Atomics.add"],
|
268
|
+
[Atomics.and, "Atomics.and"],
|
269
|
+
[Atomics.compareExchange, "Atomics.compareExchange"],
|
270
|
+
[Atomics.exchange, "Atomics.exchange"],
|
271
|
+
[Atomics.isLockFree, "Atomics.isLockFree"],
|
272
|
+
[Atomics.load, "Atomics.load"],
|
273
|
+
[Atomics.notify, "Atomics.notify"],
|
274
|
+
[Atomics.or, "Atomics.or"],
|
275
|
+
[Atomics.store, "Atomics.store"],
|
276
|
+
[Atomics.sub, "Atomics.sub"],
|
277
|
+
[Atomics.wait, "Atomics.wait"],
|
278
|
+
[BigInt, "BigInt"],
|
279
|
+
[BigInt.asIntN, "BigInt.asIntN"],
|
280
|
+
[BigInt.asUintN, "BigInt.asUintN"],
|
281
|
+
[BigInt64Array, "BigInt64Array"],
|
282
|
+
[BigInt64Array.from, "BigInt64Array.from"],
|
283
|
+
[BigInt64Array.of, "BigInt64Array.of"],
|
284
|
+
[BigUint64Array, "BigUint64Array"],
|
285
|
+
[BigUint64Array.from, "BigUint64Array.from"],
|
286
|
+
[BigUint64Array.of, "BigUint64Array.of"],
|
287
|
+
[Boolean, "Boolean"],
|
288
|
+
[console.assert, "console.assert"],
|
289
|
+
[console.clear, "console.clear"],
|
290
|
+
[console.count, "console.count"],
|
291
|
+
[console.countReset, "console.countReset"],
|
292
|
+
[console.debug, "console.debug"],
|
293
|
+
[console.dir, "console.dir"],
|
294
|
+
[console.dirxml, "console.dirxml"],
|
295
|
+
[console.error, "console.error"],
|
296
|
+
[console.group, "console.group"],
|
297
|
+
[console.groupCollapsed, "console.groupCollapsed"],
|
298
|
+
[console.groupEnd, "console.groupEnd"],
|
299
|
+
[console.info, "console.info"],
|
300
|
+
[console.log, "console.log"],
|
301
|
+
[console.table, "console.table"],
|
302
|
+
[console.time, "console.time"],
|
303
|
+
[console.timeEnd, "console.timeEnd"],
|
304
|
+
[console.timeLog, "console.timeLog"],
|
305
|
+
[console.timeStamp, "console.timeStamp"],
|
306
|
+
[console.trace, "console.trace"],
|
307
|
+
[console.warn, "console.warn"],
|
308
|
+
[DataView, "DataView"],
|
309
|
+
[Date, "Date"],
|
310
|
+
[Date.now, "Date.now"],
|
311
|
+
[Date.parse, "Date.parse"],
|
312
|
+
[Date.UTC, "Date.UTC"],
|
313
|
+
[decodeURI, "decodeURI"],
|
314
|
+
[decodeURIComponent, "decodeURIComponent"],
|
315
|
+
[encodeURI, "encodeURI"],
|
316
|
+
[encodeURIComponent, "encodeURIComponent"],
|
317
|
+
[Error, "Error"],
|
318
|
+
[EvalError, "EvalError"],
|
319
|
+
[Float32Array, "Float32Array"],
|
320
|
+
[Float32Array.from, "Float32Array.from"],
|
321
|
+
[Float32Array.of, "Float32Array.of"],
|
322
|
+
[Float64Array, "Float64Array"],
|
323
|
+
[Float64Array.from, "Float64Array.from"],
|
324
|
+
[Float64Array.of, "Float64Array.of"],
|
325
|
+
[Function, "Function"],
|
326
|
+
[globalThis.atob, "atob"],
|
327
|
+
[globalThis.btoa, "btoa"],
|
328
|
+
[globalThis.clearImmediate, "clearImmediate"],
|
329
|
+
[globalThis.clearInterval, "clearInterval"],
|
330
|
+
[globalThis.clearTimeout, "clearTimeout"],
|
331
|
+
[globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
|
332
|
+
[globalThis.crypto?.randomUUID, "crypto.randomUUID"],
|
333
|
+
[globalThis.fetch, "fetch"],
|
334
|
+
[globalThis.performance?.now, "performance.now"],
|
335
|
+
[globalThis.queueMicrotask, "queueMicrotask"],
|
336
|
+
[globalThis.setImmediate, "setImmediate"],
|
337
|
+
[globalThis.setInterval, "setInterval"],
|
338
|
+
[globalThis.setTimeout, "setTimeout"],
|
339
|
+
[globalThis.structuredClone, "structuredClone"],
|
340
|
+
[globalThis.URL, "URL"],
|
341
|
+
[globalThis.URLSearchParams, "URLSearchParams"],
|
342
|
+
[globalThis.WritableStream, "WritableStream"],
|
343
|
+
[Int16Array, "Int16Array"],
|
344
|
+
[Int16Array.from, "Int16Array.from"],
|
345
|
+
[Int16Array.of, "Int16Array.of"],
|
346
|
+
[Int32Array, "Int32Array"],
|
347
|
+
[Int32Array.from, "Int32Array.from"],
|
348
|
+
[Int32Array.of, "Int32Array.of"],
|
349
|
+
[Int8Array, "Int8Array"],
|
350
|
+
[Int8Array.from, "Int8Array.from"],
|
351
|
+
[Int8Array.of, "Int8Array.of"],
|
352
|
+
[Intl.Collator, "Intl.Collator"],
|
353
|
+
[Intl.DateTimeFormat, "Intl.DateTimeFormat"],
|
354
|
+
[Intl.DisplayNames, "Intl.DisplayNames"],
|
355
|
+
[Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
|
356
|
+
[Intl.ListFormat, "Intl.ListFormat"],
|
357
|
+
[Intl.Locale, "Intl.Locale"],
|
358
|
+
[Intl.NumberFormat, "Intl.NumberFormat"],
|
359
|
+
[Intl.PluralRules, "Intl.PluralRules"],
|
360
|
+
[Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
|
361
|
+
[Intl.Segmenter, "Intl.Segmenter"],
|
362
|
+
[Intl.supportedValuesOf, "Intl.supportedValuesOf"],
|
363
|
+
[isFinite, "isFinite"],
|
364
|
+
[isNaN, "isNaN"],
|
365
|
+
[JSON.parse, "JSON.parse"],
|
366
|
+
[JSON.stringify, "JSON.stringify"],
|
367
|
+
[Map, "Map"],
|
368
|
+
[Map.groupBy, "Map.groupBy"],
|
369
|
+
[Math.abs, "Math.abs"],
|
370
|
+
[Math.acos, "Math.acos"],
|
371
|
+
[Math.acosh, "Math.acosh"],
|
372
|
+
[Math.asin, "Math.asin"],
|
373
|
+
[Math.asinh, "Math.asinh"],
|
374
|
+
[Math.atan, "Math.atan"],
|
375
|
+
[Math.atan2, "Math.atan2"],
|
376
|
+
[Math.atanh, "Math.atanh"],
|
377
|
+
[Math.cbrt, "Math.cbrt"],
|
378
|
+
[Math.ceil, "Math.ceil"],
|
379
|
+
[Math.clz32, "Math.clz32"],
|
380
|
+
[Math.cos, "Math.cos"],
|
381
|
+
[Math.cosh, "Math.cosh"],
|
382
|
+
[Math.exp, "Math.exp"],
|
383
|
+
[Math.expm1, "Math.expm1"],
|
384
|
+
[Math.floor, "Math.floor"],
|
385
|
+
[Math.fround, "Math.fround"],
|
386
|
+
[Math.hypot, "Math.hypot"],
|
387
|
+
[Math.imul, "Math.imul"],
|
388
|
+
[Math.log, "Math.log"],
|
389
|
+
[Math.log10, "Math.log10"],
|
390
|
+
[Math.log1p, "Math.log1p"],
|
391
|
+
[Math.log2, "Math.log2"],
|
392
|
+
[Math.max, "Math.max"],
|
393
|
+
[Math.min, "Math.min"],
|
394
|
+
[Math.pow, "Math.pow"],
|
395
|
+
[Math.random, "Math.random"],
|
396
|
+
[Math.round, "Math.round"],
|
397
|
+
[Math.sign, "Math.sign"],
|
398
|
+
[Math.sin, "Math.sin"],
|
399
|
+
[Math.sinh, "Math.sinh"],
|
400
|
+
[Math.sqrt, "Math.sqrt"],
|
401
|
+
[Math.tan, "Math.tan"],
|
402
|
+
[Math.tanh, "Math.tanh"],
|
403
|
+
[Math.trunc, "Math.trunc"],
|
404
|
+
[Number, "Number"],
|
405
|
+
[Number.isFinite, "Number.isFinite"],
|
406
|
+
[Number.isInteger, "Number.isInteger"],
|
407
|
+
[Number.isNaN, "Number.isNaN"],
|
408
|
+
[Number.isSafeInteger, "Number.isSafeInteger"],
|
409
|
+
[Number.parseFloat, "Number.parseFloat"],
|
410
|
+
[Number.parseInt, "Number.parseInt"],
|
411
|
+
[Object, "Object"],
|
412
|
+
[Object.assign, "Object.assign"],
|
413
|
+
[Object.create, "Object.create"],
|
414
|
+
[Object.defineProperties, "Object.defineProperties"],
|
415
|
+
[Object.defineProperty, "Object.defineProperty"],
|
416
|
+
[Object.entries, "Object.entries"],
|
417
|
+
[Object.freeze, "Object.freeze"],
|
418
|
+
[Object.fromEntries, "Object.fromEntries"],
|
419
|
+
[Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
|
420
|
+
[Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
|
421
|
+
[Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
|
422
|
+
[Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
|
423
|
+
[Object.getPrototypeOf, "Object.getPrototypeOf"],
|
424
|
+
[Object.is, "Object.is"],
|
425
|
+
[Object.isExtensible, "Object.isExtensible"],
|
426
|
+
[Object.isFrozen, "Object.isFrozen"],
|
427
|
+
[Object.isSealed, "Object.isSealed"],
|
428
|
+
[Object.keys, "Object.keys"],
|
429
|
+
[Object.preventExtensions, "Object.preventExtensions"],
|
430
|
+
[Object.seal, "Object.seal"],
|
431
|
+
[Object.setPrototypeOf, "Object.setPrototypeOf"],
|
432
|
+
[Object.values, "Object.values"],
|
433
|
+
[parseFloat, "parseFloat"],
|
434
|
+
[parseInt, "parseInt"],
|
435
|
+
[Promise, "Promise"],
|
436
|
+
[Proxy, "Proxy"],
|
437
|
+
[RangeError, "RangeError"],
|
438
|
+
[ReferenceError, "ReferenceError"],
|
439
|
+
[Reflect.apply, "Reflect.apply"],
|
440
|
+
[Reflect.construct, "Reflect.construct"],
|
441
|
+
[Reflect.defineProperty, "Reflect.defineProperty"],
|
442
|
+
[Reflect.deleteProperty, "Reflect.deleteProperty"],
|
443
|
+
[Reflect.get, "Reflect.get"],
|
444
|
+
[Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
|
445
|
+
[Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
|
446
|
+
[Reflect.has, "Reflect.has"],
|
447
|
+
[Reflect.isExtensible, "Reflect.isExtensible"],
|
448
|
+
[Reflect.ownKeys, "Reflect.ownKeys"],
|
449
|
+
[Reflect.preventExtensions, "Reflect.preventExtensions"],
|
450
|
+
[Reflect.set, "Reflect.set"],
|
451
|
+
[Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
|
452
|
+
[RegExp, "RegExp"],
|
453
|
+
[Set, "Set"],
|
454
|
+
[String, "String"],
|
455
|
+
[String.fromCharCode, "String.fromCharCode"],
|
456
|
+
[String.fromCodePoint, "String.fromCodePoint"],
|
457
|
+
[String.raw, "String.raw"],
|
458
|
+
[Symbol, "Symbol"],
|
459
|
+
[Symbol.for, "Symbol.for"],
|
460
|
+
[SyntaxError, "SyntaxError"],
|
461
|
+
[TypeError, "TypeError"],
|
462
|
+
[Uint16Array, "Uint16Array"],
|
463
|
+
[Uint16Array.from, "Uint16Array.from"],
|
464
|
+
[Uint16Array.of, "Uint16Array.of"],
|
465
|
+
[Uint32Array, "Uint32Array"],
|
466
|
+
[Uint32Array.from, "Uint32Array.from"],
|
467
|
+
[Uint32Array.of, "Uint32Array.of"],
|
468
|
+
[Uint8Array, "Uint8Array"],
|
469
|
+
[Uint8Array.from, "Uint8Array.from"],
|
470
|
+
[Uint8Array.of, "Uint8Array.of"],
|
471
|
+
[Uint8ClampedArray, "Uint8ClampedArray"],
|
472
|
+
[Uint8ClampedArray.from, "Uint8ClampedArray.from"],
|
473
|
+
[Uint8ClampedArray.of, "Uint8ClampedArray.of"],
|
474
|
+
[URIError, "URIError"],
|
475
|
+
[WeakMap, "WeakMap"],
|
476
|
+
[WeakSet, "WeakSet"]
|
477
|
+
]);
|
478
|
+
var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
|
479
|
+
[Atomics, "Atomics"],
|
480
|
+
[console, "console"],
|
481
|
+
[globalThis, "globalThis"],
|
482
|
+
[globalThis.crypto, "crypto"],
|
483
|
+
[Intl, "Intl"],
|
484
|
+
[JSON, "JSON"],
|
485
|
+
[Math, "Math"],
|
486
|
+
[Reflect, "Reflect"]
|
487
|
+
]);
|
488
|
+
function toAccess(accessor) {
|
489
|
+
const start = accessor[0];
|
490
|
+
return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
491
|
+
}
|
492
|
+
function patchIteratorNext(proto) {
|
493
|
+
const { next } = proto;
|
494
|
+
proto.next = function(value) {
|
495
|
+
this[kTouchedIterator] = 1;
|
496
|
+
return next.call(this, value);
|
497
|
+
};
|
498
|
+
}
|
499
|
+
|
238
500
|
// src/translator/util/for-each-identifier.ts
|
239
501
|
function forEachIdentifier(node, cb) {
|
240
502
|
switch (node.type) {
|
@@ -588,7 +850,7 @@ var Sorted = class {
|
|
588
850
|
}
|
589
851
|
if (b) {
|
590
852
|
if (Array.isArray(b)) {
|
591
|
-
return addSorted(this.compare,
|
853
|
+
return addSorted(this.compare, b, a);
|
592
854
|
}
|
593
855
|
return joinRepeatable(this.compare, b, a);
|
594
856
|
}
|
@@ -735,6 +997,21 @@ function find(data, cb) {
|
|
735
997
|
function toArray(data, cb) {
|
736
998
|
return data ? Array.isArray(data) ? data.map(cb) : [cb(data, 0)] : [];
|
737
999
|
}
|
1000
|
+
function mapToString(data, sep, cb) {
|
1001
|
+
if (data) {
|
1002
|
+
if (Array.isArray(data)) {
|
1003
|
+
let str = "";
|
1004
|
+
let curSep = "";
|
1005
|
+
for (let i = 0; i < data.length; i++) {
|
1006
|
+
str += curSep + cb(data[i], i);
|
1007
|
+
curSep = sep;
|
1008
|
+
}
|
1009
|
+
return str;
|
1010
|
+
}
|
1011
|
+
return cb(data, 0);
|
1012
|
+
}
|
1013
|
+
return "";
|
1014
|
+
}
|
738
1015
|
function filterMap(data, cb) {
|
739
1016
|
if (data) {
|
740
1017
|
if (Array.isArray(data)) {
|
@@ -910,425 +1187,163 @@ var entry_builder_default = {
|
|
910
1187
|
};
|
911
1188
|
const { analyzedTags } = file.metadata.marko;
|
912
1189
|
state.imports.push(
|
913
|
-
(0, import_babel_utils6.resolveRelativePath)(entryFile, file.opts.filename)
|
914
|
-
);
|
915
|
-
state.init ||= file.path.node.extra.hasInteractiveChild || file.path.node.extra.isInteractive || false;
|
916
|
-
for (const tag of analyzedTags || []) {
|
917
|
-
visitChild(tag);
|
918
|
-
}
|
919
|
-
}
|
920
|
-
};
|
921
|
-
|
922
|
-
// src/translator/util/get-known-attr-values.ts
|
923
|
-
function getKnownAttrValues(tag) {
|
924
|
-
const attrs2 = {};
|
925
|
-
for (const attr2 of tag.attributes) {
|
926
|
-
if (attr2.type === "MarkoAttribute") {
|
927
|
-
attrs2[attr2.name] = attr2.value;
|
928
|
-
}
|
929
|
-
}
|
930
|
-
return attrs2;
|
931
|
-
}
|
932
|
-
|
933
|
-
// src/translator/util/is-core-tag.ts
|
934
|
-
var import_babel_utils7 = require("@marko/compiler/babel-utils");
|
935
|
-
|
936
|
-
// src/translator/util/get-tag-name.ts
|
937
|
-
function getTagName(tag) {
|
938
|
-
return tag.node.name.value;
|
939
|
-
}
|
940
|
-
|
941
|
-
// src/translator/util/is-core-tag.ts
|
942
|
-
var { taglibId } = runtime_info_default;
|
943
|
-
var htmlTaglibId = "marko-html";
|
944
|
-
var interopTaglibId = "@marko/translator-interop-class-tags";
|
945
|
-
function isCoreTag(tag) {
|
946
|
-
if (tag.isMarkoTag()) {
|
947
|
-
const tagDef = (0, import_babel_utils7.getTagDef)(tag);
|
948
|
-
if (tagDef) {
|
949
|
-
switch (tagDef.taglibId) {
|
950
|
-
case taglibId:
|
951
|
-
case interopTaglibId:
|
952
|
-
return true;
|
953
|
-
case htmlTaglibId:
|
954
|
-
switch (tagDef.name) {
|
955
|
-
case "script":
|
956
|
-
case "style":
|
957
|
-
return true;
|
958
|
-
}
|
959
|
-
break;
|
960
|
-
}
|
961
|
-
}
|
962
|
-
}
|
963
|
-
return false;
|
964
|
-
}
|
965
|
-
function isCoreTagName(tag, name2) {
|
966
|
-
return isCoreTag(tag) && getTagName(tag) === name2;
|
967
|
-
}
|
968
|
-
function isConditionTag(tag) {
|
969
|
-
if (isCoreTag(tag)) {
|
970
|
-
switch (getTagName(tag)) {
|
971
|
-
case "if":
|
972
|
-
case "else-if":
|
973
|
-
case "else":
|
974
|
-
return true;
|
975
|
-
}
|
976
|
-
}
|
977
|
-
return false;
|
978
|
-
}
|
979
|
-
function isControlFlowTag(tag) {
|
980
|
-
if (isCoreTag(tag)) {
|
981
|
-
switch (getTagName(tag)) {
|
982
|
-
case "if":
|
983
|
-
case "else-if":
|
984
|
-
case "else":
|
985
|
-
case "for":
|
986
|
-
case "await":
|
987
|
-
case "try":
|
988
|
-
return true;
|
989
|
-
}
|
990
|
-
}
|
991
|
-
return false;
|
992
|
-
}
|
993
|
-
|
994
|
-
// src/translator/util/runtime.ts
|
995
|
-
var import_compiler7 = require("@marko/compiler");
|
996
|
-
var import_babel_utils8 = require("@marko/compiler/babel-utils");
|
997
|
-
|
998
|
-
// src/common/attr-tag.ts
|
999
|
-
var rest = false ? Symbol("Attribute Tag") : Symbol();
|
1000
|
-
|
1001
|
-
// src/common/helpers.ts
|
1002
|
-
function classValue(classValue2) {
|
1003
|
-
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
1004
|
-
}
|
1005
|
-
function stringifyClassObject(name2, value) {
|
1006
|
-
return value ? name2 : "";
|
1007
|
-
}
|
1008
|
-
function styleValue(styleValue2) {
|
1009
|
-
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
1010
|
-
}
|
1011
|
-
function stringifyStyleObject(name2, value) {
|
1012
|
-
return value || value === 0 ? `${name2}:${value && typeof value === "number" && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name2) ? value + "px" : value}` : "";
|
1013
|
-
}
|
1014
|
-
function toDelimitedString(val, delimiter, stringify) {
|
1015
|
-
let str = "";
|
1016
|
-
let sep = "";
|
1017
|
-
let part;
|
1018
|
-
if (val) {
|
1019
|
-
if (typeof val !== "object") {
|
1020
|
-
str += val;
|
1021
|
-
} else if (Array.isArray(val)) {
|
1022
|
-
for (const v of val) {
|
1023
|
-
part = toDelimitedString(v, delimiter, stringify);
|
1024
|
-
if (part) {
|
1025
|
-
str += sep + part;
|
1026
|
-
sep = delimiter;
|
1027
|
-
}
|
1028
|
-
}
|
1029
|
-
} else {
|
1030
|
-
for (const name2 in val) {
|
1031
|
-
part = stringify(name2, val[name2]);
|
1032
|
-
if (part) {
|
1033
|
-
str += sep + part;
|
1034
|
-
sep = delimiter;
|
1035
|
-
}
|
1036
|
-
}
|
1037
|
-
}
|
1038
|
-
}
|
1039
|
-
return str;
|
1040
|
-
}
|
1041
|
-
function isEventHandler(name2) {
|
1042
|
-
return /^on[A-Z-]/.test(name2);
|
1043
|
-
}
|
1044
|
-
function getEventHandlerName(name2) {
|
1045
|
-
return name2[2] === "-" ? name2.slice(3) : name2.slice(2).toLowerCase();
|
1046
|
-
}
|
1047
|
-
function isVoid(value) {
|
1048
|
-
return value == null || value === false;
|
1049
|
-
}
|
1050
|
-
|
1051
|
-
// src/html/content.ts
|
1052
|
-
function toString(val) {
|
1053
|
-
return val ? val + "" : val === 0 ? "0" : "";
|
1054
|
-
}
|
1055
|
-
var unsafeXMLReg = /[<&]/g;
|
1056
|
-
var replaceUnsafeXML = (c) => c === "&" ? "&" : "<";
|
1057
|
-
var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
1058
|
-
function escapeXML(val) {
|
1059
|
-
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "‍";
|
1060
|
-
}
|
1061
|
-
var unsafeScriptReg = /<\/script/g;
|
1062
|
-
var escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
|
1063
|
-
function escapeScript(val) {
|
1064
|
-
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
1065
|
-
}
|
1066
|
-
var unsafeStyleReg = /<\/style/g;
|
1067
|
-
var escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
|
1068
|
-
function escapeStyle(val) {
|
1069
|
-
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
1070
|
-
}
|
1071
|
-
|
1072
|
-
// src/html/serializer.ts
|
1073
|
-
var kTouchedIterator = Symbol();
|
1074
|
-
var { hasOwnProperty } = {};
|
1075
|
-
var Generator = function* () {
|
1076
|
-
}().constructor;
|
1077
|
-
var AsyncGenerator = async function* () {
|
1078
|
-
}().constructor;
|
1079
|
-
patchIteratorNext(Generator.prototype);
|
1080
|
-
patchIteratorNext(AsyncGenerator.prototype);
|
1081
|
-
var KNOWN_SYMBOLS = (() => {
|
1082
|
-
const KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
|
1083
|
-
for (const name2 of Object.getOwnPropertyNames(Symbol)) {
|
1084
|
-
const symbol = Symbol[name2];
|
1085
|
-
if (typeof symbol === "symbol") {
|
1086
|
-
KNOWN_SYMBOLS2.set(symbol, "Symbol." + name2);
|
1190
|
+
(0, import_babel_utils6.resolveRelativePath)(entryFile, file.opts.filename)
|
1191
|
+
);
|
1192
|
+
state.init ||= file.path.node.extra.hasInteractiveChild || file.path.node.extra.isInteractive || false;
|
1193
|
+
for (const tag of analyzedTags || []) {
|
1194
|
+
visitChild(tag);
|
1087
1195
|
}
|
1088
1196
|
}
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
[Atomics.or, "Atomics.or"],
|
1109
|
-
[Atomics.store, "Atomics.store"],
|
1110
|
-
[Atomics.sub, "Atomics.sub"],
|
1111
|
-
[Atomics.wait, "Atomics.wait"],
|
1112
|
-
[BigInt, "BigInt"],
|
1113
|
-
[BigInt.asIntN, "BigInt.asIntN"],
|
1114
|
-
[BigInt.asUintN, "BigInt.asUintN"],
|
1115
|
-
[BigInt64Array, "BigInt64Array"],
|
1116
|
-
[BigInt64Array.from, "BigInt64Array.from"],
|
1117
|
-
[BigInt64Array.of, "BigInt64Array.of"],
|
1118
|
-
[BigUint64Array, "BigUint64Array"],
|
1119
|
-
[BigUint64Array.from, "BigUint64Array.from"],
|
1120
|
-
[BigUint64Array.of, "BigUint64Array.of"],
|
1121
|
-
[Boolean, "Boolean"],
|
1122
|
-
[console.assert, "console.assert"],
|
1123
|
-
[console.clear, "console.clear"],
|
1124
|
-
[console.count, "console.count"],
|
1125
|
-
[console.countReset, "console.countReset"],
|
1126
|
-
[console.debug, "console.debug"],
|
1127
|
-
[console.dir, "console.dir"],
|
1128
|
-
[console.dirxml, "console.dirxml"],
|
1129
|
-
[console.error, "console.error"],
|
1130
|
-
[console.group, "console.group"],
|
1131
|
-
[console.groupCollapsed, "console.groupCollapsed"],
|
1132
|
-
[console.groupEnd, "console.groupEnd"],
|
1133
|
-
[console.info, "console.info"],
|
1134
|
-
[console.log, "console.log"],
|
1135
|
-
[console.table, "console.table"],
|
1136
|
-
[console.time, "console.time"],
|
1137
|
-
[console.timeEnd, "console.timeEnd"],
|
1138
|
-
[console.timeLog, "console.timeLog"],
|
1139
|
-
[console.timeStamp, "console.timeStamp"],
|
1140
|
-
[console.trace, "console.trace"],
|
1141
|
-
[console.warn, "console.warn"],
|
1142
|
-
[DataView, "DataView"],
|
1143
|
-
[Date, "Date"],
|
1144
|
-
[Date.now, "Date.now"],
|
1145
|
-
[Date.parse, "Date.parse"],
|
1146
|
-
[Date.UTC, "Date.UTC"],
|
1147
|
-
[decodeURI, "decodeURI"],
|
1148
|
-
[decodeURIComponent, "decodeURIComponent"],
|
1149
|
-
[encodeURI, "encodeURI"],
|
1150
|
-
[encodeURIComponent, "encodeURIComponent"],
|
1151
|
-
[Error, "Error"],
|
1152
|
-
[EvalError, "EvalError"],
|
1153
|
-
[Float32Array, "Float32Array"],
|
1154
|
-
[Float32Array.from, "Float32Array.from"],
|
1155
|
-
[Float32Array.of, "Float32Array.of"],
|
1156
|
-
[Float64Array, "Float64Array"],
|
1157
|
-
[Float64Array.from, "Float64Array.from"],
|
1158
|
-
[Float64Array.of, "Float64Array.of"],
|
1159
|
-
[Function, "Function"],
|
1160
|
-
[globalThis.atob, "atob"],
|
1161
|
-
[globalThis.btoa, "btoa"],
|
1162
|
-
[globalThis.clearImmediate, "clearImmediate"],
|
1163
|
-
[globalThis.clearInterval, "clearInterval"],
|
1164
|
-
[globalThis.clearTimeout, "clearTimeout"],
|
1165
|
-
[globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
|
1166
|
-
[globalThis.crypto?.randomUUID, "crypto.randomUUID"],
|
1167
|
-
[globalThis.fetch, "fetch"],
|
1168
|
-
[globalThis.performance?.now, "performance.now"],
|
1169
|
-
[globalThis.queueMicrotask, "queueMicrotask"],
|
1170
|
-
[globalThis.setImmediate, "setImmediate"],
|
1171
|
-
[globalThis.setInterval, "setInterval"],
|
1172
|
-
[globalThis.setTimeout, "setTimeout"],
|
1173
|
-
[globalThis.structuredClone, "structuredClone"],
|
1174
|
-
[globalThis.URL, "URL"],
|
1175
|
-
[globalThis.URLSearchParams, "URLSearchParams"],
|
1176
|
-
[globalThis.WritableStream, "WritableStream"],
|
1177
|
-
[Int16Array, "Int16Array"],
|
1178
|
-
[Int16Array.from, "Int16Array.from"],
|
1179
|
-
[Int16Array.of, "Int16Array.of"],
|
1180
|
-
[Int32Array, "Int32Array"],
|
1181
|
-
[Int32Array.from, "Int32Array.from"],
|
1182
|
-
[Int32Array.of, "Int32Array.of"],
|
1183
|
-
[Int8Array, "Int8Array"],
|
1184
|
-
[Int8Array.from, "Int8Array.from"],
|
1185
|
-
[Int8Array.of, "Int8Array.of"],
|
1186
|
-
[Intl.Collator, "Intl.Collator"],
|
1187
|
-
[Intl.DateTimeFormat, "Intl.DateTimeFormat"],
|
1188
|
-
[Intl.DisplayNames, "Intl.DisplayNames"],
|
1189
|
-
[Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
|
1190
|
-
[Intl.ListFormat, "Intl.ListFormat"],
|
1191
|
-
[Intl.Locale, "Intl.Locale"],
|
1192
|
-
[Intl.NumberFormat, "Intl.NumberFormat"],
|
1193
|
-
[Intl.PluralRules, "Intl.PluralRules"],
|
1194
|
-
[Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
|
1195
|
-
[Intl.Segmenter, "Intl.Segmenter"],
|
1196
|
-
[Intl.supportedValuesOf, "Intl.supportedValuesOf"],
|
1197
|
-
[isFinite, "isFinite"],
|
1198
|
-
[isNaN, "isNaN"],
|
1199
|
-
[JSON.parse, "JSON.parse"],
|
1200
|
-
[JSON.stringify, "JSON.stringify"],
|
1201
|
-
[Map, "Map"],
|
1202
|
-
[Map.groupBy, "Map.groupBy"],
|
1203
|
-
[Math.abs, "Math.abs"],
|
1204
|
-
[Math.acos, "Math.acos"],
|
1205
|
-
[Math.acosh, "Math.acosh"],
|
1206
|
-
[Math.asin, "Math.asin"],
|
1207
|
-
[Math.asinh, "Math.asinh"],
|
1208
|
-
[Math.atan, "Math.atan"],
|
1209
|
-
[Math.atan2, "Math.atan2"],
|
1210
|
-
[Math.atanh, "Math.atanh"],
|
1211
|
-
[Math.cbrt, "Math.cbrt"],
|
1212
|
-
[Math.ceil, "Math.ceil"],
|
1213
|
-
[Math.clz32, "Math.clz32"],
|
1214
|
-
[Math.cos, "Math.cos"],
|
1215
|
-
[Math.cosh, "Math.cosh"],
|
1216
|
-
[Math.exp, "Math.exp"],
|
1217
|
-
[Math.expm1, "Math.expm1"],
|
1218
|
-
[Math.floor, "Math.floor"],
|
1219
|
-
[Math.fround, "Math.fround"],
|
1220
|
-
[Math.hypot, "Math.hypot"],
|
1221
|
-
[Math.imul, "Math.imul"],
|
1222
|
-
[Math.log, "Math.log"],
|
1223
|
-
[Math.log10, "Math.log10"],
|
1224
|
-
[Math.log1p, "Math.log1p"],
|
1225
|
-
[Math.log2, "Math.log2"],
|
1226
|
-
[Math.max, "Math.max"],
|
1227
|
-
[Math.min, "Math.min"],
|
1228
|
-
[Math.pow, "Math.pow"],
|
1229
|
-
[Math.random, "Math.random"],
|
1230
|
-
[Math.round, "Math.round"],
|
1231
|
-
[Math.sign, "Math.sign"],
|
1232
|
-
[Math.sin, "Math.sin"],
|
1233
|
-
[Math.sinh, "Math.sinh"],
|
1234
|
-
[Math.sqrt, "Math.sqrt"],
|
1235
|
-
[Math.tan, "Math.tan"],
|
1236
|
-
[Math.tanh, "Math.tanh"],
|
1237
|
-
[Math.trunc, "Math.trunc"],
|
1238
|
-
[Number, "Number"],
|
1239
|
-
[Number.isFinite, "Number.isFinite"],
|
1240
|
-
[Number.isInteger, "Number.isInteger"],
|
1241
|
-
[Number.isNaN, "Number.isNaN"],
|
1242
|
-
[Number.isSafeInteger, "Number.isSafeInteger"],
|
1243
|
-
[Number.parseFloat, "Number.parseFloat"],
|
1244
|
-
[Number.parseInt, "Number.parseInt"],
|
1245
|
-
[Object, "Object"],
|
1246
|
-
[Object.assign, "Object.assign"],
|
1247
|
-
[Object.create, "Object.create"],
|
1248
|
-
[Object.defineProperties, "Object.defineProperties"],
|
1249
|
-
[Object.defineProperty, "Object.defineProperty"],
|
1250
|
-
[Object.entries, "Object.entries"],
|
1251
|
-
[Object.freeze, "Object.freeze"],
|
1252
|
-
[Object.fromEntries, "Object.fromEntries"],
|
1253
|
-
[Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
|
1254
|
-
[Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
|
1255
|
-
[Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
|
1256
|
-
[Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
|
1257
|
-
[Object.getPrototypeOf, "Object.getPrototypeOf"],
|
1258
|
-
[Object.is, "Object.is"],
|
1259
|
-
[Object.isExtensible, "Object.isExtensible"],
|
1260
|
-
[Object.isFrozen, "Object.isFrozen"],
|
1261
|
-
[Object.isSealed, "Object.isSealed"],
|
1262
|
-
[Object.keys, "Object.keys"],
|
1263
|
-
[Object.preventExtensions, "Object.preventExtensions"],
|
1264
|
-
[Object.seal, "Object.seal"],
|
1265
|
-
[Object.setPrototypeOf, "Object.setPrototypeOf"],
|
1266
|
-
[Object.values, "Object.values"],
|
1267
|
-
[parseFloat, "parseFloat"],
|
1268
|
-
[parseInt, "parseInt"],
|
1269
|
-
[Promise, "Promise"],
|
1270
|
-
[Proxy, "Proxy"],
|
1271
|
-
[RangeError, "RangeError"],
|
1272
|
-
[ReferenceError, "ReferenceError"],
|
1273
|
-
[Reflect.apply, "Reflect.apply"],
|
1274
|
-
[Reflect.construct, "Reflect.construct"],
|
1275
|
-
[Reflect.defineProperty, "Reflect.defineProperty"],
|
1276
|
-
[Reflect.deleteProperty, "Reflect.deleteProperty"],
|
1277
|
-
[Reflect.get, "Reflect.get"],
|
1278
|
-
[Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
|
1279
|
-
[Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
|
1280
|
-
[Reflect.has, "Reflect.has"],
|
1281
|
-
[Reflect.isExtensible, "Reflect.isExtensible"],
|
1282
|
-
[Reflect.ownKeys, "Reflect.ownKeys"],
|
1283
|
-
[Reflect.preventExtensions, "Reflect.preventExtensions"],
|
1284
|
-
[Reflect.set, "Reflect.set"],
|
1285
|
-
[Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
|
1286
|
-
[RegExp, "RegExp"],
|
1287
|
-
[Set, "Set"],
|
1288
|
-
[String, "String"],
|
1289
|
-
[String.fromCharCode, "String.fromCharCode"],
|
1290
|
-
[String.fromCodePoint, "String.fromCodePoint"],
|
1291
|
-
[String.raw, "String.raw"],
|
1292
|
-
[Symbol, "Symbol"],
|
1293
|
-
[Symbol.for, "Symbol.for"],
|
1294
|
-
[SyntaxError, "SyntaxError"],
|
1295
|
-
[TypeError, "TypeError"],
|
1296
|
-
[Uint16Array, "Uint16Array"],
|
1297
|
-
[Uint16Array.from, "Uint16Array.from"],
|
1298
|
-
[Uint16Array.of, "Uint16Array.of"],
|
1299
|
-
[Uint32Array, "Uint32Array"],
|
1300
|
-
[Uint32Array.from, "Uint32Array.from"],
|
1301
|
-
[Uint32Array.of, "Uint32Array.of"],
|
1302
|
-
[Uint8Array, "Uint8Array"],
|
1303
|
-
[Uint8Array.from, "Uint8Array.from"],
|
1304
|
-
[Uint8Array.of, "Uint8Array.of"],
|
1305
|
-
[Uint8ClampedArray, "Uint8ClampedArray"],
|
1306
|
-
[Uint8ClampedArray.from, "Uint8ClampedArray.from"],
|
1307
|
-
[Uint8ClampedArray.of, "Uint8ClampedArray.of"],
|
1308
|
-
[URIError, "URIError"],
|
1309
|
-
[WeakMap, "WeakMap"],
|
1310
|
-
[WeakSet, "WeakSet"]
|
1311
|
-
]);
|
1312
|
-
var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
|
1313
|
-
[Atomics, "Atomics"],
|
1314
|
-
[console, "console"],
|
1315
|
-
[globalThis, "globalThis"],
|
1316
|
-
[globalThis.crypto, "crypto"],
|
1317
|
-
[Intl, "Intl"],
|
1318
|
-
[JSON, "JSON"],
|
1319
|
-
[Math, "Math"],
|
1320
|
-
[Reflect, "Reflect"]
|
1321
|
-
]);
|
1322
|
-
function toAccess(accessor) {
|
1323
|
-
const start = accessor[0];
|
1324
|
-
return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
|
1197
|
+
};
|
1198
|
+
|
1199
|
+
// src/translator/util/get-known-attr-values.ts
|
1200
|
+
function getKnownAttrValues(tag) {
|
1201
|
+
const attrs2 = {};
|
1202
|
+
for (const attr2 of tag.attributes) {
|
1203
|
+
if (attr2.type === "MarkoAttribute") {
|
1204
|
+
attrs2[attr2.name] = attr2.value;
|
1205
|
+
}
|
1206
|
+
}
|
1207
|
+
return attrs2;
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
// src/translator/util/is-core-tag.ts
|
1211
|
+
var import_babel_utils7 = require("@marko/compiler/babel-utils");
|
1212
|
+
|
1213
|
+
// src/translator/util/get-tag-name.ts
|
1214
|
+
function getTagName(tag) {
|
1215
|
+
return tag.node.name.value;
|
1325
1216
|
}
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1217
|
+
|
1218
|
+
// src/translator/util/is-core-tag.ts
|
1219
|
+
var { taglibId } = runtime_info_default;
|
1220
|
+
var htmlTaglibId = "marko-html";
|
1221
|
+
var interopTaglibId = "@marko/translator-interop-class-tags";
|
1222
|
+
function isCoreTag(tag) {
|
1223
|
+
if (tag.isMarkoTag()) {
|
1224
|
+
const tagDef = (0, import_babel_utils7.getTagDef)(tag);
|
1225
|
+
if (tagDef) {
|
1226
|
+
switch (tagDef.taglibId) {
|
1227
|
+
case taglibId:
|
1228
|
+
case interopTaglibId:
|
1229
|
+
return true;
|
1230
|
+
case htmlTaglibId:
|
1231
|
+
switch (tagDef.name) {
|
1232
|
+
case "script":
|
1233
|
+
case "style":
|
1234
|
+
return true;
|
1235
|
+
}
|
1236
|
+
break;
|
1237
|
+
}
|
1238
|
+
}
|
1239
|
+
}
|
1240
|
+
return false;
|
1241
|
+
}
|
1242
|
+
function isCoreTagName(tag, name2) {
|
1243
|
+
return isCoreTag(tag) && getTagName(tag) === name2;
|
1244
|
+
}
|
1245
|
+
function isConditionTag(tag) {
|
1246
|
+
if (isCoreTag(tag)) {
|
1247
|
+
switch (getTagName(tag)) {
|
1248
|
+
case "if":
|
1249
|
+
case "else-if":
|
1250
|
+
case "else":
|
1251
|
+
return true;
|
1252
|
+
}
|
1253
|
+
}
|
1254
|
+
return false;
|
1255
|
+
}
|
1256
|
+
function isControlFlowTag(tag) {
|
1257
|
+
if (isCoreTag(tag)) {
|
1258
|
+
switch (getTagName(tag)) {
|
1259
|
+
case "if":
|
1260
|
+
case "else-if":
|
1261
|
+
case "else":
|
1262
|
+
case "for":
|
1263
|
+
case "await":
|
1264
|
+
case "try":
|
1265
|
+
return true;
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
return false;
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
// src/translator/util/runtime.ts
|
1272
|
+
var import_compiler7 = require("@marko/compiler");
|
1273
|
+
var import_babel_utils8 = require("@marko/compiler/babel-utils");
|
1274
|
+
|
1275
|
+
// src/common/attr-tag.ts
|
1276
|
+
var rest = false ? Symbol("Attribute Tag") : Symbol();
|
1277
|
+
|
1278
|
+
// src/common/helpers.ts
|
1279
|
+
function classValue(classValue2) {
|
1280
|
+
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
1281
|
+
}
|
1282
|
+
function stringifyClassObject(name2, value) {
|
1283
|
+
return value ? name2 : "";
|
1284
|
+
}
|
1285
|
+
function styleValue(styleValue2) {
|
1286
|
+
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
1287
|
+
}
|
1288
|
+
function stringifyStyleObject(name2, value) {
|
1289
|
+
return value || value === 0 ? name2 + ":" + value : "";
|
1290
|
+
}
|
1291
|
+
function toDelimitedString(val, delimiter, stringify) {
|
1292
|
+
let str = "";
|
1293
|
+
let sep = "";
|
1294
|
+
let part;
|
1295
|
+
if (val) {
|
1296
|
+
if (typeof val !== "object") {
|
1297
|
+
str += val;
|
1298
|
+
} else if (Array.isArray(val)) {
|
1299
|
+
for (const v of val) {
|
1300
|
+
part = toDelimitedString(v, delimiter, stringify);
|
1301
|
+
if (part) {
|
1302
|
+
str += sep + part;
|
1303
|
+
sep = delimiter;
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
} else {
|
1307
|
+
for (const name2 in val) {
|
1308
|
+
part = stringify(name2, val[name2]);
|
1309
|
+
if (part) {
|
1310
|
+
str += sep + part;
|
1311
|
+
sep = delimiter;
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
}
|
1316
|
+
return str;
|
1317
|
+
}
|
1318
|
+
function isEventHandler(name2) {
|
1319
|
+
return /^on[A-Z-]/.test(name2);
|
1320
|
+
}
|
1321
|
+
function getEventHandlerName(name2) {
|
1322
|
+
return name2[2] === "-" ? name2.slice(3) : name2.slice(2).toLowerCase();
|
1323
|
+
}
|
1324
|
+
function isVoid(value) {
|
1325
|
+
return value == null || value === false;
|
1326
|
+
}
|
1327
|
+
|
1328
|
+
// src/html/content.ts
|
1329
|
+
function toString(val) {
|
1330
|
+
return val ? val + "" : val === 0 ? "0" : "";
|
1331
|
+
}
|
1332
|
+
var unsafeXMLReg = /[<&]/g;
|
1333
|
+
var replaceUnsafeXML = (c) => c === "&" ? "&" : "<";
|
1334
|
+
var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
1335
|
+
function escapeXML(val) {
|
1336
|
+
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "‍";
|
1337
|
+
}
|
1338
|
+
var unsafeScriptReg = /<\/script/g;
|
1339
|
+
var escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
|
1340
|
+
function escapeScript(val) {
|
1341
|
+
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
1342
|
+
}
|
1343
|
+
var unsafeStyleReg = /<\/style/g;
|
1344
|
+
var escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
|
1345
|
+
function escapeStyle(val) {
|
1346
|
+
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
1332
1347
|
}
|
1333
1348
|
|
1334
1349
|
// src/html/writer.ts
|
@@ -1609,9 +1624,7 @@ function addSectionSerializeReasonRef(section, ref, prop) {
|
|
1609
1624
|
forceSectionSerialize(section);
|
1610
1625
|
} else {
|
1611
1626
|
const reason = getSerializeSourcesForRef(ref);
|
1612
|
-
if (reason
|
1613
|
-
forceSectionSerialize(section);
|
1614
|
-
} else {
|
1627
|
+
if (reason) {
|
1615
1628
|
setSectionSerializeReason(
|
1616
1629
|
section,
|
1617
1630
|
mergeSerializeReasons(existingReason, reason)
|
@@ -1629,9 +1642,7 @@ function addKeyedSerializeReasonRef(section, key, ref) {
|
|
1629
1642
|
forceSerializeKey(section, key);
|
1630
1643
|
} else {
|
1631
1644
|
const reason = getSerializeSourcesForRef(ref);
|
1632
|
-
if (reason
|
1633
|
-
forceSerializeKey(section, key);
|
1634
|
-
} else {
|
1645
|
+
if (reason) {
|
1635
1646
|
setSectionKeyedSerializeReason(
|
1636
1647
|
section,
|
1637
1648
|
key,
|
@@ -1757,7 +1768,9 @@ function finalizeSectionSerializeReasons(section) {
|
|
1757
1768
|
}
|
1758
1769
|
reason = mergeSerializeReasons(reason, keyedReason);
|
1759
1770
|
}
|
1760
|
-
|
1771
|
+
if (reason) {
|
1772
|
+
setSectionSerializeReason(section, reason);
|
1773
|
+
}
|
1761
1774
|
}
|
1762
1775
|
}
|
1763
1776
|
function getSerializeSourcesForExpr(expr) {
|
@@ -1768,13 +1781,11 @@ function getSerializeSourcesForExpr(expr) {
|
|
1768
1781
|
function getSerializeSourcesForExprs(exprs) {
|
1769
1782
|
if (exprs) {
|
1770
1783
|
if (Array.isArray(exprs)) {
|
1771
|
-
let
|
1784
|
+
let allSources;
|
1772
1785
|
for (const expr of exprs) {
|
1773
|
-
|
1774
|
-
if (exprSources === true) return true;
|
1775
|
-
serializeSource = bindingUtil.union(serializeSource, exprSources);
|
1786
|
+
allSources = mergeSources(allSources, getSerializeSourcesForExpr(expr));
|
1776
1787
|
}
|
1777
|
-
return
|
1788
|
+
return allSources;
|
1778
1789
|
} else {
|
1779
1790
|
return getSerializeSourcesForExpr(exprs);
|
1780
1791
|
}
|
@@ -1782,24 +1793,20 @@ function getSerializeSourcesForExprs(exprs) {
|
|
1782
1793
|
}
|
1783
1794
|
function getSerializeSourcesForRef(ref) {
|
1784
1795
|
if (ref) {
|
1785
|
-
let
|
1796
|
+
let allSources;
|
1786
1797
|
if (Array.isArray(ref)) {
|
1787
|
-
for (const {
|
1788
|
-
|
1789
|
-
allSerializeSources = bindingUtil.union(
|
1790
|
-
allSerializeSources,
|
1791
|
-
serializeSources
|
1792
|
-
);
|
1798
|
+
for (const { sources } of ref) {
|
1799
|
+
allSources = mergeSources(allSources, sources);
|
1793
1800
|
}
|
1794
|
-
return
|
1801
|
+
return allSources;
|
1795
1802
|
} else {
|
1796
|
-
return ref.
|
1803
|
+
return ref.sources;
|
1797
1804
|
}
|
1798
1805
|
}
|
1799
1806
|
}
|
1800
1807
|
function mergeSerializeReasons(a, b) {
|
1801
1808
|
if (a === true || b === true) return true;
|
1802
|
-
return
|
1809
|
+
return mergeSources(a, b);
|
1803
1810
|
}
|
1804
1811
|
function setSectionSerializeReason(section, reason) {
|
1805
1812
|
section.serializeReason = reason;
|
@@ -2347,35 +2354,77 @@ function simplifyFunction(fn) {
|
|
2347
2354
|
}
|
2348
2355
|
}
|
2349
2356
|
|
2357
|
+
// src/translator/util/with-comment.ts
|
2358
|
+
function withLeadingComment(node, value) {
|
2359
|
+
const comment = {
|
2360
|
+
type: "CommentBlock",
|
2361
|
+
value: ` ${value} `
|
2362
|
+
};
|
2363
|
+
node.leadingComments = node.leadingComments ? [...node.leadingComments, comment] : [comment];
|
2364
|
+
return node;
|
2365
|
+
}
|
2366
|
+
|
2350
2367
|
// src/translator/visitors/program/html.ts
|
2351
2368
|
function getTemplateContentName() {
|
2352
2369
|
return getSharedUid("content");
|
2353
2370
|
}
|
2371
|
+
function getSerializeGuard(reason, optional) {
|
2372
|
+
return !reason ? import_compiler13.types.numericLiteral(0) : reason === true || reason.state ? optional ? void 0 : reason === true ? import_compiler13.types.numericLiteral(1) : withLeadingComment(
|
2373
|
+
import_compiler13.types.numericLiteral(1),
|
2374
|
+
`state: ${mapToString(reason.state, ", ", getDebugName)}`
|
2375
|
+
) : getInputSerializeReasonGuard(reason.input);
|
2376
|
+
}
|
2377
|
+
function getSerializeGuardForAny(reasons, optional) {
|
2378
|
+
if (!reasons || reasons === true) {
|
2379
|
+
return getSerializeGuard(reasons, optional);
|
2380
|
+
}
|
2381
|
+
if (reasons.length === 1) {
|
2382
|
+
return getSerializeGuard(reasons[0], optional);
|
2383
|
+
}
|
2384
|
+
let expr;
|
2385
|
+
for (const reason of reasons) {
|
2386
|
+
if (reason.state) {
|
2387
|
+
return optional ? void 0 : withLeadingComment(
|
2388
|
+
import_compiler13.types.numericLiteral(1),
|
2389
|
+
`state: ${mapToString(reason.state, ", ", getDebugName)}`
|
2390
|
+
);
|
2391
|
+
}
|
2392
|
+
const guard = getSerializeGuard(reason, false);
|
2393
|
+
expr = expr ? import_compiler13.types.logicalExpression("||", expr, guard) : guard;
|
2394
|
+
}
|
2395
|
+
return expr;
|
2396
|
+
}
|
2354
2397
|
function getExprIfSerialized(reason, expr) {
|
2355
|
-
return reason ? reason === true ? expr : import_compiler13.types.logicalExpression(
|
2398
|
+
return reason ? reason === true || reason.state ? expr : import_compiler13.types.logicalExpression(
|
2356
2399
|
"&&",
|
2357
2400
|
callRuntime(
|
2358
2401
|
"serializeIf",
|
2359
2402
|
import_compiler13.types.identifier(getSharedUid("serialize")),
|
2360
|
-
|
2361
|
-
|
2362
|
-
(
|
2363
|
-
|
2364
|
-
|
2403
|
+
withLeadingComment(
|
2404
|
+
import_compiler13.types.numericLiteral(
|
2405
|
+
resolveSerializeReasonId(
|
2406
|
+
(0, import_babel_utils12.getProgram)().node.extra.inputSerializeReasons,
|
2407
|
+
reason.input
|
2408
|
+
)
|
2409
|
+
),
|
2410
|
+
mapToString(reason.input, ", ", getInputDebugName)
|
2365
2411
|
)
|
2366
2412
|
),
|
2367
2413
|
expr
|
2368
2414
|
) : void 0;
|
2369
2415
|
}
|
2370
|
-
function
|
2416
|
+
function getInputSerializeReasonGuard(reason) {
|
2371
2417
|
return callRuntime(
|
2372
2418
|
"serializeGuard",
|
2373
2419
|
import_compiler13.types.identifier(getSharedUid("serialize")),
|
2374
|
-
|
2375
|
-
|
2376
|
-
(
|
2377
|
-
|
2378
|
-
|
2420
|
+
withLeadingComment(
|
2421
|
+
import_compiler13.types.numericLiteral(
|
2422
|
+
resolveSerializeReasonId(
|
2423
|
+
(0, import_babel_utils12.getProgram)().node.extra.inputSerializeReasons,
|
2424
|
+
reason
|
2425
|
+
)
|
2426
|
+
),
|
2427
|
+
mapToString(reason, ",", getDebugName)
|
2379
2428
|
)
|
2380
2429
|
);
|
2381
2430
|
}
|
@@ -2700,12 +2749,7 @@ function getWalkString(section) {
|
|
2700
2749
|
const walks = getWalks(section);
|
2701
2750
|
const walkLiteral = normalizeStringExpression([prefix2, ...walks, postfix]);
|
2702
2751
|
if (walkLiteral && walkLiteral.value !== "") {
|
2703
|
-
walkLiteral.
|
2704
|
-
{
|
2705
|
-
type: "CommentBlock",
|
2706
|
-
value: " " + getWalkComment(section).join(", ") + " "
|
2707
|
-
}
|
2708
|
-
];
|
2752
|
+
withLeadingComment(walkLiteral, getWalkComment(section).join(", "));
|
2709
2753
|
}
|
2710
2754
|
return walkLiteral;
|
2711
2755
|
}
|
@@ -2790,7 +2834,7 @@ function markNode(path5, nodeBinding, reason) {
|
|
2790
2834
|
"markResumeNode",
|
2791
2835
|
getScopeIdIdentifier(section),
|
2792
2836
|
getScopeAccessorLiteral(nodeBinding),
|
2793
|
-
reason
|
2837
|
+
getSerializeGuard(reason, true)
|
2794
2838
|
)}`;
|
2795
2839
|
}
|
2796
2840
|
}
|
@@ -3734,7 +3778,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3734
3778
|
serializedProperties.push(
|
3735
3779
|
toObjectProperty(
|
3736
3780
|
accessor,
|
3737
|
-
sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true &&
|
3781
|
+
sectionSerializeReason && (sectionSerializeReason === reason || sectionSerializeReason !== true && reason !== true && compareSources(sectionSerializeReason, reason) === 0) ? getDeclaredBindingExpression(binding) : getExprIfSerialized(reason, getDeclaredBindingExpression(binding))
|
3738
3782
|
)
|
3739
3783
|
);
|
3740
3784
|
});
|
@@ -3750,7 +3794,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3750
3794
|
serializedProperties.push(
|
3751
3795
|
toObjectProperty(
|
3752
3796
|
ownerAccessor,
|
3753
|
-
sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true &&
|
3797
|
+
sectionSerializeReason && (sectionSerializeReason === ownerReason || sectionSerializeReason !== true && ownerReason !== true && compareSources(sectionSerializeReason, ownerReason) === 0) ? getOwnerExpr : getExprIfSerialized(ownerReason, getOwnerExpr)
|
3754
3798
|
)
|
3755
3799
|
);
|
3756
3800
|
}
|
@@ -3777,14 +3821,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3777
3821
|
if (binding.type === 0 /* dom */) return;
|
3778
3822
|
const serializeReason = getBindingSerializeReason(section, binding);
|
3779
3823
|
if (!serializeReason) return;
|
3780
|
-
|
3781
|
-
let access = "";
|
3782
|
-
while (!(root.loc || root.declared) && root.upstreamAlias) {
|
3783
|
-
if (root.property !== void 0) {
|
3784
|
-
access = toAccess(root.property) + access;
|
3785
|
-
}
|
3786
|
-
root = root.upstreamAlias;
|
3787
|
-
}
|
3824
|
+
const { root, access } = getDebugScopeAccess(binding);
|
3788
3825
|
const locExpr = root.loc && import_compiler20.types.stringLiteral(
|
3789
3826
|
`${root.loc.start.line}:${root.loc.start.column + 1}`
|
3790
3827
|
);
|
@@ -3808,10 +3845,10 @@ function writeHTMLResumeStatements(path5) {
|
|
3808
3845
|
}
|
3809
3846
|
}
|
3810
3847
|
let writeScopeCall = writeScopeBuilder ? writeScopeBuilder(callRuntime("writeScope", ...writeScopeArgs)) : callRuntime("writeScope", ...writeScopeArgs);
|
3811
|
-
if (sectionSerializeReason !== true) {
|
3848
|
+
if (sectionSerializeReason !== true && !sectionSerializeReason.state) {
|
3812
3849
|
writeScopeCall = import_compiler20.types.logicalExpression(
|
3813
3850
|
"&&",
|
3814
|
-
getSerializeGuard(sectionSerializeReason),
|
3851
|
+
getSerializeGuard(sectionSerializeReason, false),
|
3815
3852
|
writeScopeCall
|
3816
3853
|
);
|
3817
3854
|
}
|
@@ -4223,11 +4260,7 @@ var program_default = {
|
|
4223
4260
|
}
|
4224
4261
|
};
|
4225
4262
|
function resolveSerializeReasonId(inputSerializeReasons, reason) {
|
4226
|
-
const id = findIndexSorted(
|
4227
|
-
compareSerializeReasons,
|
4228
|
-
inputSerializeReasons,
|
4229
|
-
reason
|
4230
|
-
);
|
4263
|
+
const id = findIndexSorted(compareReferences, inputSerializeReasons, reason);
|
4231
4264
|
if (id === -1) {
|
4232
4265
|
throw new Error("Unable to resolve serialize reason against input");
|
4233
4266
|
}
|
@@ -4340,7 +4373,6 @@ function createBinding(name2, type, section, upstreamAlias, property, loc = null
|
|
4340
4373
|
closureSections: void 0,
|
4341
4374
|
assignmentSections: void 0,
|
4342
4375
|
excludeProperties: void 0,
|
4343
|
-
serializeSources: void 0,
|
4344
4376
|
sources: void 0,
|
4345
4377
|
aliases: /* @__PURE__ */ new Set(),
|
4346
4378
|
hoists: /* @__PURE__ */ new Map(),
|
@@ -4649,8 +4681,8 @@ function mergeReferences(section, target, nodes) {
|
|
4649
4681
|
getMergedReferences().set(target, nodes);
|
4650
4682
|
return targetExtra;
|
4651
4683
|
}
|
4652
|
-
function
|
4653
|
-
return Array.isArray(a) ? Array.isArray(b) ? compareIntersections(a, b) : -1 : Array.isArray(b) ? 1 : bindingUtil.compare(a, b);
|
4684
|
+
function compareReferences(a, b) {
|
4685
|
+
return a === b ? 0 : Array.isArray(a) ? Array.isArray(b) ? compareIntersections(a, b) : -1 : Array.isArray(b) ? 1 : bindingUtil.compare(a, b);
|
4654
4686
|
}
|
4655
4687
|
function compareIntersections(a, b) {
|
4656
4688
|
const len = a.length;
|
@@ -4753,7 +4785,7 @@ function finalizeReferences() {
|
|
4753
4785
|
addOwnersSerializeReason(
|
4754
4786
|
section2,
|
4755
4787
|
binding.section,
|
4756
|
-
binding.
|
4788
|
+
binding.sources,
|
4757
4789
|
getAccessorProp().Owner
|
4758
4790
|
);
|
4759
4791
|
}
|
@@ -4804,18 +4836,44 @@ function finalizeReferences() {
|
|
4804
4836
|
for (let j = i + 1; j < numReferences; j++) {
|
4805
4837
|
const binding1 = intersection[i];
|
4806
4838
|
const binding2 = intersection[j];
|
4807
|
-
if (!isBindingForceSerialized(section, binding1) && !
|
4839
|
+
if (!isBindingForceSerialized(section, binding1) && !isSupersetSources(binding1, binding2)) {
|
4840
|
+
if (!isSameOrChildSection(section, binding1.section)) {
|
4841
|
+
addOwnersSerializeReason(
|
4842
|
+
section,
|
4843
|
+
binding1.section,
|
4844
|
+
mergeSerializeReasons(
|
4845
|
+
// TODO should check for an actual intersection, not just stateful
|
4846
|
+
binding1.sources,
|
4847
|
+
binding2.sources
|
4848
|
+
),
|
4849
|
+
getAccessorProp().Owner
|
4850
|
+
);
|
4851
|
+
}
|
4808
4852
|
addBindingSerializeReason(
|
4809
|
-
section,
|
4853
|
+
binding1.section,
|
4810
4854
|
binding1,
|
4811
|
-
binding2.
|
4855
|
+
binding2.sources
|
4856
|
+
// TODO should check for an actual intersection, not just binding2.sources stateful
|
4812
4857
|
);
|
4813
4858
|
}
|
4814
|
-
if (!isBindingForceSerialized(section, binding2) && !
|
4859
|
+
if (!isBindingForceSerialized(section, binding2) && !isSupersetSources(binding2, binding1)) {
|
4860
|
+
if (!isSameOrChildSection(section, binding2.section)) {
|
4861
|
+
addOwnersSerializeReason(
|
4862
|
+
section,
|
4863
|
+
binding2.section,
|
4864
|
+
mergeSerializeReasons(
|
4865
|
+
// TODO should check for an actual intersection, not just stateful
|
4866
|
+
binding1.sources,
|
4867
|
+
binding2.sources
|
4868
|
+
),
|
4869
|
+
getAccessorProp().Owner
|
4870
|
+
);
|
4871
|
+
}
|
4815
4872
|
addBindingSerializeReason(
|
4816
|
-
section,
|
4873
|
+
binding2.section,
|
4817
4874
|
binding2,
|
4818
|
-
binding1.
|
4875
|
+
binding1.sources
|
4876
|
+
// TODO should check for an actual intersection, not just binding1.sources stateful
|
4819
4877
|
);
|
4820
4878
|
}
|
4821
4879
|
}
|
@@ -4847,17 +4905,17 @@ function finalizeReferences() {
|
|
4847
4905
|
getBindingSerializeReason(closure.section, closure)
|
4848
4906
|
);
|
4849
4907
|
}
|
4850
|
-
if (closure.
|
4908
|
+
if (closure.sources && isDynamicClosure(section, closure)) {
|
4851
4909
|
addBindingSerializeReason(
|
4852
4910
|
closure.section,
|
4853
4911
|
closure,
|
4854
|
-
closure.
|
4912
|
+
closure.sources,
|
4855
4913
|
getAccessorPrefix().ClosureScopes
|
4856
4914
|
);
|
4857
4915
|
addBindingSerializeReason(
|
4858
4916
|
section,
|
4859
4917
|
closure,
|
4860
|
-
closure.
|
4918
|
+
closure.sources,
|
4861
4919
|
getAccessorPrefix().ClosureSignalIndex
|
4862
4920
|
);
|
4863
4921
|
}
|
@@ -4866,21 +4924,28 @@ function finalizeReferences() {
|
|
4866
4924
|
let inputSerializeReasons;
|
4867
4925
|
forEachSection((section) => {
|
4868
4926
|
finalizeSectionSerializeReasons(section);
|
4869
|
-
if (section.serializeReason && section.serializeReason !== true) {
|
4927
|
+
if (section.serializeReason && section.serializeReason !== true && section.serializeReason.input) {
|
4870
4928
|
inputSerializeReasons = inputSerializeReasons ? addSorted(
|
4871
|
-
|
4929
|
+
compareReferences,
|
4872
4930
|
inputSerializeReasons,
|
4873
|
-
section.serializeReason
|
4874
|
-
) : [section.serializeReason];
|
4931
|
+
section.serializeReason.input
|
4932
|
+
) : [section.serializeReason.input];
|
4875
4933
|
}
|
4876
4934
|
for (const [, reason] of section.serializeReasons) {
|
4877
|
-
if (reason !== true) {
|
4878
|
-
inputSerializeReasons = inputSerializeReasons ? addSorted(
|
4935
|
+
if (reason !== true && reason.input) {
|
4936
|
+
inputSerializeReasons = inputSerializeReasons ? addSorted(compareReferences, inputSerializeReasons, reason.input) : [reason.input];
|
4879
4937
|
}
|
4880
4938
|
}
|
4881
4939
|
});
|
4882
4940
|
const programExtra = (0, import_babel_utils17.getProgram)().node.extra;
|
4883
|
-
|
4941
|
+
if (programExtra.returnValueExpr) {
|
4942
|
+
const returnSources = getSerializeSourcesForExpr(
|
4943
|
+
programExtra.returnValueExpr
|
4944
|
+
);
|
4945
|
+
if (returnSources) {
|
4946
|
+
programExtra.returnSerializeReason = returnSources.state ? true : returnSources.input;
|
4947
|
+
}
|
4948
|
+
}
|
4884
4949
|
programExtra.inputSerializeReasons = inputSerializeReasons;
|
4885
4950
|
forEachSection((section) => {
|
4886
4951
|
let intersectionIndex = 0;
|
@@ -4913,12 +4978,14 @@ function finalizeReferences() {
|
|
4913
4978
|
function getMaxOwnSourceOffset(intersection, section) {
|
4914
4979
|
let scopeOffset;
|
4915
4980
|
for (const binding of intersection) {
|
4916
|
-
if (binding.section === section) {
|
4917
|
-
|
4981
|
+
if (binding.section === section && binding.sources) {
|
4982
|
+
const trackScopeOffset = (source) => {
|
4918
4983
|
if (source.scopeOffset && (!scopeOffset || scopeOffset.id < source.scopeOffset.id)) {
|
4919
4984
|
scopeOffset = source.scopeOffset;
|
4920
4985
|
}
|
4921
|
-
}
|
4986
|
+
};
|
4987
|
+
forEach(binding.sources.state, trackScopeOffset);
|
4988
|
+
forEach(binding.sources.input, trackScopeOffset);
|
4922
4989
|
}
|
4923
4990
|
}
|
4924
4991
|
return scopeOffset;
|
@@ -4934,60 +5001,82 @@ function resolveBindingSources(binding) {
|
|
4934
5001
|
resolvedSources.add(binding);
|
4935
5002
|
switch (binding.type) {
|
4936
5003
|
case 1 /* let */:
|
4937
|
-
binding.sources = binding;
|
4938
|
-
binding.serializeSources = true;
|
5004
|
+
binding.sources = createSources(binding, void 0);
|
4939
5005
|
return;
|
4940
5006
|
case 2 /* input */:
|
4941
|
-
binding.sources = binding;
|
4942
|
-
binding.serializeSources = binding;
|
5007
|
+
binding.sources = createSources(void 0, binding);
|
4943
5008
|
return;
|
4944
5009
|
}
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
|
4949
|
-
|
4950
|
-
|
5010
|
+
if (binding.upstreamAlias) {
|
5011
|
+
let alias;
|
5012
|
+
let source = binding;
|
5013
|
+
while (alias = source.upstreamAlias) {
|
5014
|
+
source = alias;
|
5015
|
+
}
|
5016
|
+
if (!resolvedSources.has(source)) {
|
5017
|
+
resolvedSources.add(source);
|
5018
|
+
resolveDerivedSources(source);
|
5019
|
+
}
|
5020
|
+
binding.sources = source.sources;
|
5021
|
+
} else {
|
4951
5022
|
resolveDerivedSources(binding);
|
4952
|
-
return;
|
4953
|
-
}
|
4954
|
-
if (!resolvedSources.has(source)) {
|
4955
|
-
resolvedSources.add(source);
|
4956
|
-
resolveDerivedSources(source);
|
4957
5023
|
}
|
4958
|
-
binding.sources = source.sources;
|
4959
|
-
binding.serializeSources = source.serializeSources;
|
4960
5024
|
}
|
4961
5025
|
function resolveDerivedSources(binding) {
|
4962
5026
|
const exprs = bindingValueExprs.get(binding);
|
4963
5027
|
bindingValueExprs.delete(binding);
|
4964
5028
|
if (exprs === void 0 || exprs === true) {
|
4965
|
-
binding.
|
4966
|
-
binding.sources = binding;
|
5029
|
+
binding.sources = createSources(binding, void 0);
|
4967
5030
|
} else if (exprs) {
|
4968
5031
|
const seen = /* @__PURE__ */ new Set();
|
4969
|
-
let onlyInputSources = true;
|
4970
|
-
let sources;
|
4971
5032
|
forEach(exprs, (expr) => {
|
4972
5033
|
if (isReferencedExtra(expr)) {
|
4973
5034
|
forEach(expr.referencedBindings, (ref) => {
|
4974
5035
|
if (!seen.has(ref)) {
|
4975
5036
|
seen.add(ref);
|
4976
5037
|
resolveBindingSources(ref);
|
4977
|
-
sources =
|
4978
|
-
onlyInputSources &&= ref.serializeSources !== true;
|
5038
|
+
binding.sources = mergeSources(binding.sources, ref.sources);
|
4979
5039
|
}
|
4980
5040
|
});
|
4981
5041
|
}
|
4982
5042
|
});
|
4983
|
-
if (sources) {
|
4984
|
-
binding.sources = sources;
|
4985
|
-
binding.serializeSources = onlyInputSources ? sources : true;
|
4986
|
-
}
|
4987
5043
|
}
|
4988
5044
|
}
|
5045
|
+
function createSources(state, input) {
|
5046
|
+
if (!(state || input)) {
|
5047
|
+
throw new Error(
|
5048
|
+
"Cannot create a serialize reason that does not reference state or input."
|
5049
|
+
);
|
5050
|
+
}
|
5051
|
+
return { state, input };
|
5052
|
+
}
|
5053
|
+
function compareSources(a, b) {
|
5054
|
+
let delta = 0;
|
5055
|
+
if (a.input) {
|
5056
|
+
if (!b.input) return 1;
|
5057
|
+
if (delta = compareReferences(a.input, b.input)) return delta;
|
5058
|
+
} else if (b.input) {
|
5059
|
+
return -1;
|
5060
|
+
}
|
5061
|
+
if (a.state) {
|
5062
|
+
if (!b.state) return 1;
|
5063
|
+
if (delta = compareReferences(a.state, b.state)) return delta;
|
5064
|
+
} else if (b.state) {
|
5065
|
+
return -1;
|
5066
|
+
}
|
5067
|
+
return 0;
|
5068
|
+
}
|
5069
|
+
function mergeSources(a, b) {
|
5070
|
+
if (!a) return b;
|
5071
|
+
if (!b) return a;
|
5072
|
+
if (a.state === b.state && a.input === b.input) return a;
|
5073
|
+
return createSources(
|
5074
|
+
bindingUtil.union(a.state, b.state),
|
5075
|
+
bindingUtil.union(a.input, b.input)
|
5076
|
+
);
|
5077
|
+
}
|
4989
5078
|
var bindingUtil = new Sorted(function compareBindings(a, b) {
|
4990
|
-
return a.section.id - b.section.id || a.type !== b.type && (a.type === 0 /* dom */ || b.type === 0 /* dom */) ? a.type - b.type || a.id - b.id : a.id - b.id;
|
5079
|
+
return a === b ? 0 : a.section.id - b.section.id || a.type !== b.type && (a.type === 0 /* dom */ || b.type === 0 /* dom */) ? a.type - b.type || a.id - b.id : a.id - b.id;
|
4991
5080
|
});
|
4992
5081
|
var [getReadsByExpression] = createProgramState(
|
4993
5082
|
() => /* @__PURE__ */ new Map()
|
@@ -5054,6 +5143,35 @@ function getScopeAccessor(binding, includeId) {
|
|
5054
5143
|
}
|
5055
5144
|
return binding.name + (includeId || binding.type === 0 /* dom */ ? `/${binding.id}` : "");
|
5056
5145
|
}
|
5146
|
+
function getDebugScopeAccess(binding) {
|
5147
|
+
let root = binding;
|
5148
|
+
let access = "";
|
5149
|
+
while (!(root.loc || root.declared) && root.upstreamAlias) {
|
5150
|
+
if (root.property !== void 0) {
|
5151
|
+
access = toAccess(root.property) + access;
|
5152
|
+
}
|
5153
|
+
root = root.upstreamAlias;
|
5154
|
+
}
|
5155
|
+
return {
|
5156
|
+
root,
|
5157
|
+
access
|
5158
|
+
};
|
5159
|
+
}
|
5160
|
+
function getDebugName(binding) {
|
5161
|
+
const { root, access } = getDebugScopeAccess(binding);
|
5162
|
+
return root.name + access;
|
5163
|
+
}
|
5164
|
+
function getInputDebugName(binding) {
|
5165
|
+
let root = binding;
|
5166
|
+
let access = "";
|
5167
|
+
while (root.upstreamAlias !== root.section.params) {
|
5168
|
+
if (root.property !== void 0) {
|
5169
|
+
access = toAccess(root.property) + access;
|
5170
|
+
}
|
5171
|
+
root = root.upstreamAlias;
|
5172
|
+
}
|
5173
|
+
return root.name + access;
|
5174
|
+
}
|
5057
5175
|
function getSectionInstancesAccessor(section) {
|
5058
5176
|
return section.sectionAccessor ? section.sectionAccessor.prefix + getScopeAccessor(section.sectionAccessor.binding) : getAccessorPrefix().ClosureScopes + section.id;
|
5059
5177
|
}
|
@@ -5177,6 +5295,11 @@ function resolveExpressionReference(reads, readBinding, readProps) {
|
|
5177
5295
|
}
|
5178
5296
|
return createRead(readBinding, readProps);
|
5179
5297
|
}
|
5298
|
+
function isSupersetSources(a, b) {
|
5299
|
+
if (!b.sources) return true;
|
5300
|
+
if (!a.sources) return false;
|
5301
|
+
return bindingUtil.isSuperset(a.sources.state, b.sources.state) && bindingUtil.isSuperset(a.sources.input, b.sources.input);
|
5302
|
+
}
|
5180
5303
|
function getCanonicalProperty(binding) {
|
5181
5304
|
return binding.property ?? binding.upstreamAlias?.property;
|
5182
5305
|
}
|
@@ -5266,7 +5389,6 @@ var await_default = {
|
|
5266
5389
|
const tagBody = tag.get("body");
|
5267
5390
|
const section = getSection(tag);
|
5268
5391
|
const bodySection = getSectionForBody(tagBody);
|
5269
|
-
const serializeReason = bodySection && getSectionSerializeReason(bodySection);
|
5270
5392
|
flushInto(tag);
|
5271
5393
|
writeHTMLResumeStatements(tagBody);
|
5272
5394
|
tag.replaceWith(
|
@@ -5280,7 +5402,10 @@ var await_default = {
|
|
5280
5402
|
node.body.params,
|
5281
5403
|
toFirstExpressionOrBlock(node.body.body)
|
5282
5404
|
),
|
5283
|
-
|
5405
|
+
getSerializeGuard(
|
5406
|
+
bodySection && getSectionSerializeReason(bodySection),
|
5407
|
+
true
|
5408
|
+
)
|
5284
5409
|
)
|
5285
5410
|
)
|
5286
5411
|
)[0].skip();
|
@@ -5626,66 +5751,6 @@ var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
5626
5751
|
// src/translator/visitors/tag/native-tag.ts
|
5627
5752
|
var import_compiler31 = require("@marko/compiler");
|
5628
5753
|
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
5629
|
-
|
5630
|
-
// src/translator/util/css-px-props.ts
|
5631
|
-
var css_px_props_default = /* @__PURE__ */ new Set([
|
5632
|
-
"background-size",
|
5633
|
-
"baseline-shift",
|
5634
|
-
"border-bottom-left-radius",
|
5635
|
-
"border-bottom-right-radius",
|
5636
|
-
"border-bottom-width",
|
5637
|
-
"border-left-width",
|
5638
|
-
"border-right-width",
|
5639
|
-
"border-top-left-radius",
|
5640
|
-
"border-top-right-radius",
|
5641
|
-
"border-top-width",
|
5642
|
-
"bottom",
|
5643
|
-
"column-gap",
|
5644
|
-
"column-rule-width",
|
5645
|
-
"column-width",
|
5646
|
-
"cx",
|
5647
|
-
"cy",
|
5648
|
-
"flex-basis",
|
5649
|
-
"font-size",
|
5650
|
-
"grid-auto-columns",
|
5651
|
-
"grid-auto-rows",
|
5652
|
-
"height",
|
5653
|
-
"left",
|
5654
|
-
"letter-spacing",
|
5655
|
-
"margin-bottom",
|
5656
|
-
"margin-left",
|
5657
|
-
"margin-right",
|
5658
|
-
"margin-top",
|
5659
|
-
"max-height",
|
5660
|
-
"max-width",
|
5661
|
-
"min-height",
|
5662
|
-
"min-width",
|
5663
|
-
"offset-distance",
|
5664
|
-
"outline-offset",
|
5665
|
-
"outline-width",
|
5666
|
-
"padding-bottom",
|
5667
|
-
"padding-left",
|
5668
|
-
"padding-right",
|
5669
|
-
"padding-top",
|
5670
|
-
"perspective",
|
5671
|
-
"r",
|
5672
|
-
"right",
|
5673
|
-
"row-gap",
|
5674
|
-
"rx",
|
5675
|
-
"ry",
|
5676
|
-
"shape-margin",
|
5677
|
-
"stroke-dashoffset",
|
5678
|
-
"stroke-width",
|
5679
|
-
"text-indent",
|
5680
|
-
"top",
|
5681
|
-
"vertical-align",
|
5682
|
-
"width",
|
5683
|
-
"word-spacing",
|
5684
|
-
"x",
|
5685
|
-
"y"
|
5686
|
-
]);
|
5687
|
-
|
5688
|
-
// src/translator/visitors/tag/native-tag.ts
|
5689
5754
|
var kNativeTagBinding = Symbol("native tag binding");
|
5690
5755
|
var kSkipMark = Symbol("skip native tag mark");
|
5691
5756
|
var kGetterId = Symbol("node getter id");
|
@@ -6152,7 +6217,7 @@ var native_tag_default = {
|
|
6152
6217
|
);
|
6153
6218
|
} else {
|
6154
6219
|
if (meta.staticItems) {
|
6155
|
-
write2`${getHTMLRuntime()[helper](
|
6220
|
+
write2`${getHTMLRuntime()[helper](meta.staticItems)}`;
|
6156
6221
|
}
|
6157
6222
|
if (meta.dynamicValues) {
|
6158
6223
|
const keys = Object.keys(meta.dynamicValues);
|
@@ -6164,7 +6229,7 @@ var native_tag_default = {
|
|
6164
6229
|
`${name2}Item`,
|
6165
6230
|
nodeExpr,
|
6166
6231
|
import_compiler31.types.stringLiteral(key),
|
6167
|
-
|
6232
|
+
value2
|
6168
6233
|
)
|
6169
6234
|
);
|
6170
6235
|
} else {
|
@@ -6172,10 +6237,7 @@ var native_tag_default = {
|
|
6172
6237
|
for (const key of keys) {
|
6173
6238
|
const value2 = meta.dynamicValues[key];
|
6174
6239
|
props.push(
|
6175
|
-
import_compiler31.types.objectProperty(
|
6176
|
-
toPropertyName(key),
|
6177
|
-
name2 === "style" && css_px_props_default.has(name2) ? callRuntime("styleItemValue", value2) : value2
|
6178
|
-
)
|
6240
|
+
import_compiler31.types.objectProperty(toPropertyName(key), value2)
|
6179
6241
|
);
|
6180
6242
|
}
|
6181
6243
|
stmt = import_compiler31.types.expressionStatement(
|
@@ -6662,12 +6724,16 @@ var for_default = {
|
|
6662
6724
|
if (markerSerializeReason && onlyChildInParentOptimization) {
|
6663
6725
|
getParentTag(tag).node.extra[kSkipMark] = true;
|
6664
6726
|
}
|
6727
|
+
const markerSerializeArg = getSerializeGuard(
|
6728
|
+
markerSerializeReason,
|
6729
|
+
!onlyChildInParentOptimization
|
6730
|
+
);
|
6665
6731
|
forTagArgs.push(
|
6666
6732
|
forAttrs.by || import_compiler33.types.numericLiteral(0),
|
6667
6733
|
getScopeIdIdentifier(tagSection),
|
6668
6734
|
getScopeAccessorLiteral(nodeBinding),
|
6669
|
-
branchSerializeReason
|
6670
|
-
|
6735
|
+
getSerializeGuard(branchSerializeReason, !markerSerializeArg),
|
6736
|
+
markerSerializeArg
|
6671
6737
|
);
|
6672
6738
|
if (onlyChildInParentOptimization) {
|
6673
6739
|
forTagArgs.push(import_compiler33.types.numericLiteral(1));
|
@@ -7845,7 +7911,6 @@ var html_script_default = {
|
|
7845
7911
|
const tagExtra = tag.node.extra;
|
7846
7912
|
const nodeBinding = tagExtra[kNodeBinding2];
|
7847
7913
|
const write2 = writeTo(tag);
|
7848
|
-
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
7849
7914
|
if (isOutputHTML()) {
|
7850
7915
|
for (const child of tag.node.body.body) {
|
7851
7916
|
if (import_compiler38.types.isMarkoText(child)) {
|
@@ -7880,7 +7945,11 @@ var html_script_default = {
|
|
7880
7945
|
import_compiler38.types.expressionStatement(
|
7881
7946
|
callRuntime(
|
7882
7947
|
"textContent",
|
7883
|
-
import_compiler38.types.memberExpression(
|
7948
|
+
import_compiler38.types.memberExpression(
|
7949
|
+
scopeIdentifier,
|
7950
|
+
getScopeAccessorLiteral(nodeBinding),
|
7951
|
+
true
|
7952
|
+
),
|
7884
7953
|
import_compiler38.types.templateLiteral(templateQuasis, templateExpressions)
|
7885
7954
|
)
|
7886
7955
|
)
|
@@ -8257,7 +8326,6 @@ var html_style_default = {
|
|
8257
8326
|
const tagExtra = tag.node.extra;
|
8258
8327
|
const nodeBinding = tagExtra[kNodeBinding3];
|
8259
8328
|
const write2 = writeTo(tag);
|
8260
|
-
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
8261
8329
|
if (isOutputHTML()) {
|
8262
8330
|
for (const child of tag.node.body.body) {
|
8263
8331
|
if (import_compiler39.types.isMarkoText(child)) {
|
@@ -8292,7 +8360,11 @@ var html_style_default = {
|
|
8292
8360
|
import_compiler39.types.expressionStatement(
|
8293
8361
|
callRuntime(
|
8294
8362
|
"textContent",
|
8295
|
-
import_compiler39.types.memberExpression(
|
8363
|
+
import_compiler39.types.memberExpression(
|
8364
|
+
scopeIdentifier,
|
8365
|
+
getScopeAccessorLiteral(nodeBinding),
|
8366
|
+
true
|
8367
|
+
),
|
8296
8368
|
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
8297
8369
|
)
|
8298
8370
|
)
|
@@ -8520,11 +8592,11 @@ var IfTag = {
|
|
8520
8592
|
);
|
8521
8593
|
if (branchSerializeReason) {
|
8522
8594
|
if (branchSerializeReasons !== true) {
|
8523
|
-
if (branchSerializeReason === true) {
|
8595
|
+
if (branchSerializeReason === true || branchSerializeReason.state) {
|
8524
8596
|
branchSerializeReasons = true;
|
8525
8597
|
} else if (branchSerializeReasons) {
|
8526
8598
|
branchSerializeReasons = addSorted(
|
8527
|
-
|
8599
|
+
compareSources,
|
8528
8600
|
branchSerializeReasons,
|
8529
8601
|
branchSerializeReason
|
8530
8602
|
);
|
@@ -8558,24 +8630,44 @@ var IfTag = {
|
|
8558
8630
|
[],
|
8559
8631
|
import_compiler42.types.blockStatement([statement])
|
8560
8632
|
);
|
8561
|
-
|
8562
|
-
|
8563
|
-
|
8564
|
-
|
8565
|
-
|
8566
|
-
|
8567
|
-
|
8568
|
-
|
8569
|
-
|
8570
|
-
|
8571
|
-
|
8572
|
-
|
8573
|
-
|
8574
|
-
|
8575
|
-
|
8576
|
-
|
8577
|
-
|
8578
|
-
|
8633
|
+
if (singleNodeOptimization) {
|
8634
|
+
const markerSerializeArg = getSerializeGuard(
|
8635
|
+
markerSerializeReason,
|
8636
|
+
!onlyChildInParentOptimization
|
8637
|
+
);
|
8638
|
+
statement = import_compiler42.types.expressionStatement(
|
8639
|
+
callRuntime(
|
8640
|
+
"resumeSingleNodeConditional",
|
8641
|
+
cbNode,
|
8642
|
+
getScopeIdIdentifier(ifTagSection),
|
8643
|
+
getScopeAccessorLiteral(nodeBinding),
|
8644
|
+
getSerializeGuardForAny(
|
8645
|
+
branchSerializeReasons,
|
8646
|
+
!markerSerializeArg
|
8647
|
+
),
|
8648
|
+
markerSerializeArg,
|
8649
|
+
onlyChildInParentOptimization && import_compiler42.types.numericLiteral(1)
|
8650
|
+
)
|
8651
|
+
);
|
8652
|
+
} else {
|
8653
|
+
const markerSerializeArg = getSerializeGuard(
|
8654
|
+
markerSerializeReason,
|
8655
|
+
true
|
8656
|
+
);
|
8657
|
+
statement = import_compiler42.types.expressionStatement(
|
8658
|
+
callRuntime(
|
8659
|
+
"resumeConditional",
|
8660
|
+
cbNode,
|
8661
|
+
getScopeIdIdentifier(ifTagSection),
|
8662
|
+
getScopeAccessorLiteral(nodeBinding),
|
8663
|
+
getSerializeGuardForAny(
|
8664
|
+
branchSerializeReasons,
|
8665
|
+
!markerSerializeArg
|
8666
|
+
),
|
8667
|
+
markerSerializeArg
|
8668
|
+
)
|
8669
|
+
);
|
8670
|
+
}
|
8579
8671
|
}
|
8580
8672
|
nextTag.insertBefore(statement);
|
8581
8673
|
}
|
@@ -8755,13 +8847,6 @@ function getBranches(tag) {
|
|
8755
8847
|
}
|
8756
8848
|
return branches;
|
8757
8849
|
}
|
8758
|
-
function getSerializeGuardForAny(reasons) {
|
8759
|
-
let expr = getSerializeGuard(reasons[0]);
|
8760
|
-
for (let i = 1; i < reasons.length; i++) {
|
8761
|
-
expr = import_compiler42.types.logicalExpression("||", expr, getSerializeGuard(reasons[i]));
|
8762
|
-
}
|
8763
|
-
return expr;
|
8764
|
-
}
|
8765
8850
|
function isLastBranch(tag) {
|
8766
8851
|
const branches = getBranches(tag);
|
8767
8852
|
return branches[branches.length - 1][0] === tag;
|
@@ -9687,10 +9772,10 @@ var placeholder_default = {
|
|
9687
9772
|
} else {
|
9688
9773
|
if (siblingText === 1 /* Before */) {
|
9689
9774
|
if (isHTML && markerSerializeReason) {
|
9690
|
-
if (markerSerializeReason === true) {
|
9775
|
+
if (markerSerializeReason === true || markerSerializeReason.state) {
|
9691
9776
|
write2`<!>`;
|
9692
9777
|
} else {
|
9693
|
-
write2`${callRuntime("commentSeparator", getSerializeGuard(markerSerializeReason))}`;
|
9778
|
+
write2`${callRuntime("commentSeparator", getSerializeGuard(markerSerializeReason, true))}`;
|
9694
9779
|
}
|
9695
9780
|
}
|
9696
9781
|
visit(placeholder, 37 /* Replace */);
|
@@ -10096,7 +10181,7 @@ function translateHTML(tag) {
|
|
10096
10181
|
childScopeBinding,
|
10097
10182
|
childSerializeReasonIds[0]
|
10098
10183
|
);
|
10099
|
-
childSerializeReasonExpr = !reason ? void 0 : reason == true ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason);
|
10184
|
+
childSerializeReasonExpr = !reason ? void 0 : reason == true || reason.state ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason, true);
|
10100
10185
|
} else {
|
10101
10186
|
const props = [];
|
10102
10187
|
let hasDynamicReasons = false;
|
@@ -10108,11 +10193,15 @@ function translateHTML(tag) {
|
|
10108
10193
|
childSerializeReasonIds[i]
|
10109
10194
|
);
|
10110
10195
|
if (reason) {
|
10111
|
-
hasDynamicReasons ||= reason !== true;
|
10196
|
+
hasDynamicReasons ||= reason !== true && !reason.state;
|
10197
|
+
const childReason = childExtra.inputSerializeReasons[i];
|
10112
10198
|
props.push(
|
10113
10199
|
import_compiler56.types.objectProperty(
|
10114
|
-
|
10115
|
-
|
10200
|
+
withLeadingComment(
|
10201
|
+
import_compiler56.types.numericLiteral(i),
|
10202
|
+
mapToString(childReason, ", ", getInputDebugName)
|
10203
|
+
),
|
10204
|
+
reason === true || reason.state ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason, false)
|
10116
10205
|
)
|
10117
10206
|
);
|
10118
10207
|
} else {
|
@@ -10853,11 +10942,10 @@ var dynamic_tag_default = {
|
|
10853
10942
|
if (isOutputHTML()) {
|
10854
10943
|
flushInto(tag);
|
10855
10944
|
writeHTMLResumeStatements(tag.get("body"));
|
10856
|
-
const
|
10857
|
-
tagSection,
|
10858
|
-
|
10945
|
+
const serializeArg = getSerializeGuard(
|
10946
|
+
getBindingSerializeReason(tagSection, nodeBinding),
|
10947
|
+
true
|
10859
10948
|
);
|
10860
|
-
const serializeArg = !serializeReason ? import_compiler57.types.numericLiteral(0) : serializeReason === true ? void 0 : getSerializeGuard(serializeReason);
|
10861
10949
|
const dynamicTagExpr = hasTagArgs ? callRuntime(
|
10862
10950
|
"dynamicTag",
|
10863
10951
|
getScopeIdIdentifier(tagSection),
|