marko 6.0.8 → 6.0.10
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 +59 -47
- package/dist/debug/dom.mjs +59 -47
- package/dist/debug/html.js +98 -70
- package/dist/debug/html.mjs +98 -70
- package/dist/dom/resume.d.ts +2 -0
- package/dist/dom.js +38 -32
- package/dist/dom.mjs +38 -32
- package/dist/html/writer.d.ts +8 -8
- package/dist/html.js +64 -28
- package/dist/html.mjs +64 -28
- package/dist/translator/index.js +1294 -1170
- package/dist/translator/util/is-only-child-in-parent.d.ts +2 -2
- 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/dist/translator/visitors/tag/native-tag.d.ts +2 -2
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -235,1100 +235,1115 @@ 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/
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
break;
|
254
|
-
}
|
255
|
-
}
|
256
|
-
break;
|
257
|
-
case "ArrayPattern":
|
258
|
-
for (const el of node.elements) {
|
259
|
-
if (el != null) {
|
260
|
-
switch (el.type) {
|
261
|
-
case "RestElement":
|
262
|
-
forEachIdentifier(el.argument, cb);
|
263
|
-
break;
|
264
|
-
case "AssignmentPattern":
|
265
|
-
forEachIdentifier(el.left, cb);
|
266
|
-
break;
|
267
|
-
default:
|
268
|
-
forEachIdentifier(el, cb);
|
269
|
-
break;
|
270
|
-
}
|
271
|
-
}
|
272
|
-
}
|
273
|
-
break;
|
274
|
-
case "Identifier":
|
275
|
-
cb(node);
|
276
|
-
break;
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
// src/translator/util/generate-uid.ts
|
281
|
-
var import_compiler3 = require("@marko/compiler");
|
282
|
-
var import_babel_utils4 = require("@marko/compiler/babel-utils");
|
283
|
-
|
284
|
-
// src/translator/util/get-compile-stage.ts
|
285
|
-
var import_babel_utils3 = require("@marko/compiler/babel-utils");
|
286
|
-
function getCompileStage() {
|
287
|
-
return (0, import_babel_utils3.getFile)().___compileStage;
|
288
|
-
}
|
289
|
-
function isTranslate() {
|
290
|
-
return getCompileStage() === "translate" /* translate */;
|
291
|
-
}
|
292
|
-
|
293
|
-
// src/translator/util/traverse.ts
|
294
|
-
var import_compiler2 = require("@marko/compiler");
|
295
|
-
var skip = Symbol("skip");
|
296
|
-
function traverseReplace(container, key, enter3) {
|
297
|
-
const node = container[key];
|
298
|
-
if (node) {
|
299
|
-
if (Array.isArray(node)) {
|
300
|
-
for (let i = node.length; i--; ) {
|
301
|
-
traverseReplace(node, i, enter3);
|
302
|
-
}
|
303
|
-
} else {
|
304
|
-
const keys = import_compiler2.types.VISITOR_KEYS[node.type];
|
305
|
-
for (let i = keys.length; i--; ) {
|
306
|
-
traverseReplace(node, keys[i], enter3);
|
307
|
-
}
|
308
|
-
const replacement = enter3(node, container, key);
|
309
|
-
if (replacement) container[key] = replacement;
|
310
|
-
}
|
311
|
-
}
|
312
|
-
}
|
313
|
-
function traverseContains(node, check) {
|
314
|
-
if (node) {
|
315
|
-
if (Array.isArray(node)) {
|
316
|
-
for (const item of node) {
|
317
|
-
if (traverseContains(item, check)) {
|
318
|
-
return true;
|
319
|
-
}
|
320
|
-
}
|
321
|
-
} else {
|
322
|
-
switch (check(node)) {
|
323
|
-
case true:
|
324
|
-
return true;
|
325
|
-
case skip:
|
326
|
-
return false;
|
327
|
-
}
|
328
|
-
for (const key of import_compiler2.types.VISITOR_KEYS[node.type]) {
|
329
|
-
if (traverseContains(node[key], check)) {
|
330
|
-
return true;
|
331
|
-
}
|
332
|
-
}
|
333
|
-
}
|
334
|
-
}
|
335
|
-
return false;
|
336
|
-
}
|
337
|
-
function traverse(visit2, node, parent, grandParent) {
|
338
|
-
if (node) {
|
339
|
-
if (Array.isArray(node)) {
|
340
|
-
for (const item of node) {
|
341
|
-
traverse(visit2, item, parent, grandParent);
|
342
|
-
}
|
343
|
-
} else if (visit2(node, parent, grandParent) !== skip) {
|
344
|
-
for (const key of import_compiler2.types.VISITOR_KEYS[node.type]) {
|
345
|
-
traverse(visit2, node[key], node, parent);
|
346
|
-
}
|
347
|
-
}
|
348
|
-
}
|
349
|
-
}
|
350
|
-
|
351
|
-
// src/translator/util/generate-uid.ts
|
352
|
-
var countsForFile = /* @__PURE__ */ new WeakMap();
|
353
|
-
function generateUid(name2 = "") {
|
354
|
-
const file = (0, import_babel_utils4.getFile)();
|
355
|
-
let counts = countsForFile.get(file);
|
356
|
-
if (!counts) {
|
357
|
-
const { cache } = file.markoOpts;
|
358
|
-
const { filename } = file.opts;
|
359
|
-
const cacheKey = `uid-counts:${filename}`;
|
360
|
-
counts = cache.get(cacheKey);
|
361
|
-
if (counts) {
|
362
|
-
if (isTranslate()) {
|
363
|
-
counts = new Map(counts);
|
364
|
-
}
|
365
|
-
} else {
|
366
|
-
counts = getInitialCounts(file);
|
367
|
-
if (!isTranslate()) {
|
368
|
-
cache.set(cacheKey, counts);
|
369
|
-
}
|
370
|
-
}
|
371
|
-
countsForFile.set(file, counts);
|
372
|
-
}
|
373
|
-
name2 = name2.replace(/^[^a-z$_]|[^a-z$_0-9]/gi, "") || "temp";
|
374
|
-
name2 = /^\$?(.*?)\d*$/.exec(name2)?.[1] || name2;
|
375
|
-
const i = (counts.get(name2) || 0) + 1;
|
376
|
-
const uniqueName = `$${i > 1 ? name2 + i : name2}`;
|
377
|
-
counts.set(name2, i);
|
378
|
-
return uniqueName;
|
379
|
-
}
|
380
|
-
function generateUidIdentifier(name2) {
|
381
|
-
return import_compiler3.types.identifier(generateUid(name2));
|
382
|
-
}
|
383
|
-
var sharedUIDsForFile = /* @__PURE__ */ new WeakMap();
|
384
|
-
function getSharedUid(name2) {
|
385
|
-
const file = (0, import_babel_utils4.getFile)();
|
386
|
-
let sharedUIDs = sharedUIDsForFile.get(file);
|
387
|
-
if (!sharedUIDs) {
|
388
|
-
const { cache } = file.markoOpts;
|
389
|
-
const { filename } = file.opts;
|
390
|
-
const cacheKey = `uid-shared:${filename}`;
|
391
|
-
sharedUIDs = cache.get(cacheKey);
|
392
|
-
if (sharedUIDs) {
|
393
|
-
if (isTranslate()) {
|
394
|
-
sharedUIDs = new Map(sharedUIDs);
|
395
|
-
}
|
396
|
-
} else {
|
397
|
-
sharedUIDs = /* @__PURE__ */ new Map();
|
398
|
-
if (!isTranslate()) {
|
399
|
-
cache.set(cacheKey, sharedUIDs);
|
400
|
-
}
|
401
|
-
}
|
402
|
-
sharedUIDsForFile.set(file, sharedUIDs);
|
403
|
-
}
|
404
|
-
let uniqueName = sharedUIDs.get(name2);
|
405
|
-
if (!uniqueName) {
|
406
|
-
uniqueName = generateUid(name2);
|
407
|
-
sharedUIDs.set(name2, uniqueName);
|
408
|
-
}
|
409
|
-
return uniqueName;
|
410
|
-
}
|
411
|
-
function usedSharedUid(name2) {
|
412
|
-
return !!sharedUIDsForFile.get((0, import_babel_utils4.getFile)())?.has(name2);
|
413
|
-
}
|
414
|
-
function getInitialCounts(file) {
|
415
|
-
const counts = /* @__PURE__ */ new Map();
|
416
|
-
const program = file.path;
|
417
|
-
const countName = (name2) => {
|
418
|
-
const match = /^$(.*?)([1-9]\d*)?$/.exec(name2);
|
419
|
-
if (match) {
|
420
|
-
const name3 = match[1];
|
421
|
-
const count = match[2] ? +match[2] + 1 : 1;
|
422
|
-
counts.set(name3, Math.max(counts.get(name3) || 0, count));
|
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);
|
423
253
|
}
|
424
|
-
};
|
425
|
-
for (const name2 in program.scope.globals) {
|
426
|
-
countName(name2);
|
427
254
|
}
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
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;
|
485
491
|
}
|
486
|
-
function
|
487
|
-
|
492
|
+
function patchIteratorNext(proto) {
|
493
|
+
const { next } = proto;
|
494
|
+
proto.next = function(value) {
|
495
|
+
this[kTouchedIterator] = 1;
|
496
|
+
return next.call(this, value);
|
497
|
+
};
|
488
498
|
}
|
489
499
|
|
490
|
-
// src/translator/util/
|
491
|
-
function
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
let fnPath;
|
508
|
-
if (curPath.isProgram()) return;
|
509
|
-
while (!isMarko(curPath)) {
|
510
|
-
if (isFunction(curPath)) {
|
511
|
-
fnPath = curPath;
|
512
|
-
} else {
|
513
|
-
switch (curPath.type) {
|
514
|
-
case "CallExpression":
|
515
|
-
case "NewExpression":
|
516
|
-
fnPath = void 0;
|
517
|
-
break;
|
500
|
+
// src/translator/util/for-each-identifier.ts
|
501
|
+
function forEachIdentifier(node, cb) {
|
502
|
+
switch (node.type) {
|
503
|
+
case "ObjectPattern":
|
504
|
+
for (const prop of node.properties) {
|
505
|
+
switch (prop.type) {
|
506
|
+
case "ObjectProperty":
|
507
|
+
if (prop.value.type === "AssignmentPattern") {
|
508
|
+
forEachIdentifier(prop.value.left, cb);
|
509
|
+
} else {
|
510
|
+
forEachIdentifier(prop.value, cb);
|
511
|
+
}
|
512
|
+
break;
|
513
|
+
case "RestElement":
|
514
|
+
forEachIdentifier(prop.argument, cb);
|
515
|
+
break;
|
516
|
+
}
|
518
517
|
}
|
519
|
-
|
520
|
-
|
518
|
+
break;
|
519
|
+
case "ArrayPattern":
|
520
|
+
for (const el of node.elements) {
|
521
|
+
if (el != null) {
|
522
|
+
switch (el.type) {
|
523
|
+
case "RestElement":
|
524
|
+
forEachIdentifier(el.argument, cb);
|
525
|
+
break;
|
526
|
+
case "AssignmentPattern":
|
527
|
+
forEachIdentifier(el.left, cb);
|
528
|
+
break;
|
529
|
+
default:
|
530
|
+
forEachIdentifier(el, cb);
|
531
|
+
break;
|
532
|
+
}
|
533
|
+
}
|
534
|
+
}
|
535
|
+
break;
|
536
|
+
case "Identifier":
|
537
|
+
cb(node);
|
538
|
+
break;
|
521
539
|
}
|
522
|
-
return fnPath;
|
523
540
|
}
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
default:
|
534
|
-
return false;
|
535
|
-
}
|
541
|
+
|
542
|
+
// src/translator/util/generate-uid.ts
|
543
|
+
var import_compiler3 = require("@marko/compiler");
|
544
|
+
var import_babel_utils4 = require("@marko/compiler/babel-utils");
|
545
|
+
|
546
|
+
// src/translator/util/get-compile-stage.ts
|
547
|
+
var import_babel_utils3 = require("@marko/compiler/babel-utils");
|
548
|
+
function getCompileStage() {
|
549
|
+
return (0, import_babel_utils3.getFile)().___compileStage;
|
536
550
|
}
|
537
|
-
function
|
538
|
-
|
539
|
-
case "FunctionDeclaration":
|
540
|
-
return !path5.node.declare;
|
541
|
-
case "FunctionExpression":
|
542
|
-
case "ArrowFunctionExpression":
|
543
|
-
case "ObjectMethod":
|
544
|
-
return true;
|
545
|
-
default:
|
546
|
-
return false;
|
547
|
-
}
|
551
|
+
function isTranslate() {
|
552
|
+
return getCompileStage() === "translate" /* translate */;
|
548
553
|
}
|
549
554
|
|
550
|
-
// src/translator/util/
|
551
|
-
var
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
555
|
+
// src/translator/util/traverse.ts
|
556
|
+
var import_compiler2 = require("@marko/compiler");
|
557
|
+
var skip = Symbol("skip");
|
558
|
+
function traverseReplace(container, key, enter3) {
|
559
|
+
const node = container[key];
|
560
|
+
if (node) {
|
561
|
+
if (Array.isArray(node)) {
|
562
|
+
for (let i = node.length; i--; ) {
|
563
|
+
traverseReplace(node, i, enter3);
|
564
|
+
}
|
565
|
+
} else {
|
566
|
+
const keys = import_compiler2.types.VISITOR_KEYS[node.type];
|
567
|
+
for (let i = keys.length; i--; ) {
|
568
|
+
traverseReplace(node, keys[i], enter3);
|
569
|
+
}
|
570
|
+
const replacement = enter3(node, container, key);
|
571
|
+
if (replacement) container[key] = replacement;
|
564
572
|
}
|
565
573
|
}
|
566
|
-
return false;
|
567
574
|
}
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
add(data, item) {
|
575
|
-
return data ? Array.isArray(data) ? addSorted(this.compare, data, item) : joinRepeatable(this.compare, data, item) : item;
|
576
|
-
}
|
577
|
-
union(a, b) {
|
578
|
-
if (a) {
|
579
|
-
if (Array.isArray(a)) {
|
580
|
-
if (b) {
|
581
|
-
if (Array.isArray(b)) {
|
582
|
-
return unionSortedRepeatable(this.compare, a, b);
|
583
|
-
} else {
|
584
|
-
return addSorted(this.compare, a, b);
|
585
|
-
}
|
575
|
+
function traverseContains(node, check) {
|
576
|
+
if (node) {
|
577
|
+
if (Array.isArray(node)) {
|
578
|
+
for (const item of node) {
|
579
|
+
if (traverseContains(item, check)) {
|
580
|
+
return true;
|
586
581
|
}
|
587
|
-
return a;
|
588
582
|
}
|
589
|
-
|
590
|
-
|
591
|
-
|
583
|
+
} else {
|
584
|
+
switch (check(node)) {
|
585
|
+
case true:
|
586
|
+
return true;
|
587
|
+
case skip:
|
588
|
+
return false;
|
589
|
+
}
|
590
|
+
for (const key of import_compiler2.types.VISITOR_KEYS[node.type]) {
|
591
|
+
if (traverseContains(node[key], check)) {
|
592
|
+
return true;
|
592
593
|
}
|
593
|
-
return joinRepeatable(this.compare, b, a);
|
594
594
|
}
|
595
|
-
return a;
|
596
595
|
}
|
597
|
-
return b;
|
598
596
|
}
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
597
|
+
return false;
|
598
|
+
}
|
599
|
+
function traverse(visit2, node, parent, grandParent) {
|
600
|
+
if (node) {
|
601
|
+
if (Array.isArray(node)) {
|
602
|
+
for (const item of node) {
|
603
|
+
traverse(visit2, item, parent, grandParent);
|
605
604
|
}
|
606
|
-
}
|
607
|
-
|
608
|
-
|
609
|
-
if (data) {
|
610
|
-
if (Array.isArray(data)) {
|
611
|
-
return findIndexSorted(this.compare, data, item);
|
612
|
-
} else if (this.compare(data, item) === 0) {
|
613
|
-
return 0;
|
605
|
+
} else if (visit2(node, parent, grandParent) !== skip) {
|
606
|
+
for (const key of import_compiler2.types.VISITOR_KEYS[node.type]) {
|
607
|
+
traverse(visit2, node[key], node, parent);
|
614
608
|
}
|
615
609
|
}
|
616
|
-
return -1;
|
617
|
-
}
|
618
|
-
isSuperset(superset, subset) {
|
619
|
-
if (!subset) {
|
620
|
-
return true;
|
621
|
-
}
|
622
|
-
if (!Array.isArray(subset)) {
|
623
|
-
return this.findIndex(superset, subset) !== -1;
|
624
|
-
}
|
625
|
-
if (!Array.isArray(superset)) {
|
626
|
-
return false;
|
627
|
-
}
|
628
|
-
const subLen = subset.length;
|
629
|
-
const supLen = superset.length;
|
630
|
-
if (subLen > supLen) {
|
631
|
-
return false;
|
632
|
-
}
|
633
|
-
for (let i = subLen; i--; ) {
|
634
|
-
const supIndex = this.findIndex(superset, subset[i]);
|
635
|
-
if (supIndex === -1 || supLen - supIndex <= i) return false;
|
636
|
-
}
|
637
|
-
return true;
|
638
|
-
}
|
639
|
-
};
|
640
|
-
function push(data, item) {
|
641
|
-
if (data) {
|
642
|
-
if (Array.isArray(data)) {
|
643
|
-
data.push(item);
|
644
|
-
return data;
|
645
|
-
}
|
646
|
-
return [data, item];
|
647
610
|
}
|
648
|
-
return item;
|
649
611
|
}
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
612
|
+
|
613
|
+
// src/translator/util/generate-uid.ts
|
614
|
+
var countsForFile = /* @__PURE__ */ new WeakMap();
|
615
|
+
function generateUid(name2 = "") {
|
616
|
+
const file = (0, import_babel_utils4.getFile)();
|
617
|
+
let counts = countsForFile.get(file);
|
618
|
+
if (!counts) {
|
619
|
+
const { cache } = file.markoOpts;
|
620
|
+
const { filename } = file.opts;
|
621
|
+
const cacheKey = `uid-counts:${filename}`;
|
622
|
+
counts = cache.get(cacheKey);
|
623
|
+
if (counts) {
|
624
|
+
if (isTranslate()) {
|
625
|
+
counts = new Map(counts);
|
626
|
+
}
|
627
|
+
} else {
|
628
|
+
counts = getInitialCounts(file);
|
629
|
+
if (!isTranslate()) {
|
630
|
+
cache.set(cacheKey, counts);
|
659
631
|
}
|
660
632
|
}
|
661
|
-
|
633
|
+
countsForFile.set(file, counts);
|
662
634
|
}
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
let result;
|
670
|
-
let i = 0;
|
671
|
-
while (i < len) {
|
672
|
-
let item = data[i++];
|
673
|
-
if (cb(item)) {
|
674
|
-
result = item;
|
675
|
-
while (i < len) {
|
676
|
-
item = data[i++];
|
677
|
-
if (cb(item)) {
|
678
|
-
result = [result, item];
|
679
|
-
while (i < len) {
|
680
|
-
item = data[i++];
|
681
|
-
if (cb(item)) {
|
682
|
-
result.push(item);
|
683
|
-
}
|
684
|
-
}
|
685
|
-
return result;
|
686
|
-
}
|
687
|
-
}
|
688
|
-
return result;
|
689
|
-
}
|
690
|
-
}
|
691
|
-
return result;
|
692
|
-
}
|
693
|
-
if (cb(data)) {
|
694
|
-
return data;
|
695
|
-
}
|
696
|
-
}
|
697
|
-
return void 0;
|
635
|
+
name2 = name2.replace(/^[^a-z$_]|[^a-z$_0-9]/gi, "") || "temp";
|
636
|
+
name2 = /^\$?(.*?)\d*$/.exec(name2)?.[1] || name2;
|
637
|
+
const i = (counts.get(name2) || 0) + 1;
|
638
|
+
const uniqueName = `$${i > 1 ? name2 + i : name2}`;
|
639
|
+
counts.set(name2, i);
|
640
|
+
return uniqueName;
|
698
641
|
}
|
699
|
-
function
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
642
|
+
function generateUidIdentifier(name2) {
|
643
|
+
return import_compiler3.types.identifier(generateUid(name2));
|
644
|
+
}
|
645
|
+
var sharedUIDsForFile = /* @__PURE__ */ new WeakMap();
|
646
|
+
function getSharedUid(name2) {
|
647
|
+
const file = (0, import_babel_utils4.getFile)();
|
648
|
+
let sharedUIDs = sharedUIDsForFile.get(file);
|
649
|
+
if (!sharedUIDs) {
|
650
|
+
const { cache } = file.markoOpts;
|
651
|
+
const { filename } = file.opts;
|
652
|
+
const cacheKey = `uid-shared:${filename}`;
|
653
|
+
sharedUIDs = cache.get(cacheKey);
|
654
|
+
if (sharedUIDs) {
|
655
|
+
if (isTranslate()) {
|
656
|
+
sharedUIDs = new Map(sharedUIDs);
|
705
657
|
}
|
706
658
|
} else {
|
707
|
-
|
659
|
+
sharedUIDs = /* @__PURE__ */ new Map();
|
660
|
+
if (!isTranslate()) {
|
661
|
+
cache.set(cacheKey, sharedUIDs);
|
662
|
+
}
|
708
663
|
}
|
664
|
+
sharedUIDsForFile.set(file, sharedUIDs);
|
709
665
|
}
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
for (const item of data) {
|
715
|
-
if (many) {
|
716
|
-
many.push(item);
|
717
|
-
} else if (one) {
|
718
|
-
many = [one, item];
|
719
|
-
} else {
|
720
|
-
one = item;
|
721
|
-
}
|
666
|
+
let uniqueName = sharedUIDs.get(name2);
|
667
|
+
if (!uniqueName) {
|
668
|
+
uniqueName = generateUid(name2);
|
669
|
+
sharedUIDs.set(name2, uniqueName);
|
722
670
|
}
|
723
|
-
return
|
671
|
+
return uniqueName;
|
724
672
|
}
|
725
|
-
function
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
673
|
+
function usedSharedUid(name2) {
|
674
|
+
return !!sharedUIDsForFile.get((0, import_babel_utils4.getFile)())?.has(name2);
|
675
|
+
}
|
676
|
+
function getInitialCounts(file) {
|
677
|
+
const counts = /* @__PURE__ */ new Map();
|
678
|
+
const program = file.path;
|
679
|
+
const countName = (name2) => {
|
680
|
+
const match = /^$(.*?)([1-9]\d*)?$/.exec(name2);
|
681
|
+
if (match) {
|
682
|
+
const name3 = match[1];
|
683
|
+
const count = match[2] ? +match[2] + 1 : 1;
|
684
|
+
counts.set(name3, Math.max(counts.get(name3) || 0, count));
|
732
685
|
}
|
686
|
+
};
|
687
|
+
for (const name2 in program.scope.globals) {
|
688
|
+
countName(name2);
|
733
689
|
}
|
690
|
+
traverse((node, parent, grandParent) => {
|
691
|
+
if (node.type === "Identifier" && import_compiler3.types.isBinding(node, parent, grandParent)) {
|
692
|
+
countName(node.name);
|
693
|
+
}
|
694
|
+
}, program.node);
|
695
|
+
return counts;
|
734
696
|
}
|
735
|
-
|
736
|
-
|
697
|
+
|
698
|
+
// src/common/accessor.ts
|
699
|
+
var AccessorPrefix2 = /* @__PURE__ */ ((AccessorPrefix4) => {
|
700
|
+
AccessorPrefix4["ClosureScopes"] = "a";
|
701
|
+
AccessorPrefix4["ClosureSignalIndex"] = "b";
|
702
|
+
AccessorPrefix4["ConditionalRenderer"] = "c";
|
703
|
+
AccessorPrefix4["ConditionalScope"] = "d";
|
704
|
+
AccessorPrefix4["ControlledHandler"] = "e";
|
705
|
+
AccessorPrefix4["ControlledType"] = "f";
|
706
|
+
AccessorPrefix4["ControlledValue"] = "g";
|
707
|
+
AccessorPrefix4["DynamicPlaceholderLastChild"] = "h";
|
708
|
+
AccessorPrefix4["EventAttributes"] = "i";
|
709
|
+
AccessorPrefix4["Getter"] = "j";
|
710
|
+
AccessorPrefix4["LifecycleAbortController"] = "k";
|
711
|
+
AccessorPrefix4["LoopScopeArray"] = "l";
|
712
|
+
AccessorPrefix4["LoopScopeMap"] = "m";
|
713
|
+
AccessorPrefix4["Promise"] = "n";
|
714
|
+
AccessorPrefix4["TagVariableChange"] = "o";
|
715
|
+
return AccessorPrefix4;
|
716
|
+
})(AccessorPrefix2 || {});
|
717
|
+
var AccessorProp2 = /* @__PURE__ */ ((AccessorProp4) => {
|
718
|
+
AccessorProp4["Owner"] = "_";
|
719
|
+
AccessorProp4["BranchAccessor"] = "a";
|
720
|
+
AccessorProp4["CatchContent"] = "b";
|
721
|
+
AccessorProp4["PlaceholderBranch"] = "c";
|
722
|
+
AccessorProp4["PlaceholderContent"] = "d";
|
723
|
+
AccessorProp4["TagVariable"] = "e";
|
724
|
+
AccessorProp4["TagVariableChange"] = "f";
|
725
|
+
AccessorProp4["ClosestBranchId"] = "g";
|
726
|
+
return AccessorProp4;
|
727
|
+
})(AccessorProp2 || {});
|
728
|
+
|
729
|
+
// src/translator/util/marko-config.ts
|
730
|
+
var import_babel_utils5 = require("@marko/compiler/babel-utils");
|
731
|
+
function isOutputHTML() {
|
732
|
+
return getMarkoOpts().output === "html";
|
737
733
|
}
|
738
|
-
function
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
734
|
+
function isOutputDOM() {
|
735
|
+
return !isOutputHTML();
|
736
|
+
}
|
737
|
+
function getMarkoOpts() {
|
738
|
+
return (0, import_babel_utils5.getFile)().markoOpts;
|
739
|
+
}
|
740
|
+
function isOptimize() {
|
741
|
+
return getMarkoOpts().optimize;
|
742
|
+
}
|
743
|
+
|
744
|
+
// src/translator/util/get-accessor-char.ts
|
745
|
+
function getAccessorPrefix() {
|
746
|
+
return isOptimize() ? AccessorPrefix2 : AccessorPrefix;
|
747
|
+
}
|
748
|
+
function getAccessorProp() {
|
749
|
+
return isOptimize() ? AccessorProp2 : AccessorProp;
|
750
|
+
}
|
751
|
+
|
752
|
+
// src/translator/util/get-root.ts
|
753
|
+
function getMarkoRoot(path5) {
|
754
|
+
let curPath = path5;
|
755
|
+
do
|
756
|
+
curPath = curPath.parentPath;
|
757
|
+
while (curPath && !isMarko(curPath));
|
758
|
+
return curPath;
|
759
|
+
}
|
760
|
+
function getExprRoot(path5) {
|
761
|
+
let curPath = path5;
|
762
|
+
while (!isMarko(curPath.parentPath)) {
|
763
|
+
curPath = curPath.parentPath;
|
764
|
+
}
|
765
|
+
return curPath;
|
766
|
+
}
|
767
|
+
function getFnRoot(path5) {
|
768
|
+
let curPath = path5;
|
769
|
+
let fnPath;
|
770
|
+
if (curPath.isProgram()) return;
|
771
|
+
while (!isMarko(curPath)) {
|
772
|
+
if (isFunction(curPath)) {
|
773
|
+
fnPath = curPath;
|
765
774
|
} else {
|
766
|
-
|
775
|
+
switch (curPath.type) {
|
776
|
+
case "CallExpression":
|
777
|
+
case "NewExpression":
|
778
|
+
fnPath = void 0;
|
779
|
+
break;
|
780
|
+
}
|
767
781
|
}
|
782
|
+
curPath = curPath.parentPath;
|
768
783
|
}
|
784
|
+
return fnPath;
|
769
785
|
}
|
770
|
-
function
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
786
|
+
function isMarko(path5) {
|
787
|
+
switch (path5.type) {
|
788
|
+
case "MarkoTag":
|
789
|
+
case "MarkoTagBody":
|
790
|
+
case "MarkoAttribute":
|
791
|
+
case "MarkoSpreadAttribute":
|
792
|
+
case "MarkoPlaceholder":
|
793
|
+
case "MarkoScriptlet":
|
794
|
+
return true;
|
795
|
+
default:
|
796
|
+
return false;
|
780
797
|
}
|
781
798
|
}
|
782
|
-
function
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
return -1;
|
793
|
-
}
|
794
|
-
function addSorted(compare, data, item) {
|
795
|
-
const len = data.length;
|
796
|
-
let max = len;
|
797
|
-
let pos = 0;
|
798
|
-
while (pos < max) {
|
799
|
-
const mid = pos + max >>> 1;
|
800
|
-
const compareResult = compare(data[mid], item);
|
801
|
-
if (compareResult === 0) return data;
|
802
|
-
if (compareResult > 0) max = mid;
|
803
|
-
else pos = mid + 1;
|
804
|
-
}
|
805
|
-
const result = new Array(len + 1);
|
806
|
-
for (let i = 0; i < pos; i++) {
|
807
|
-
result[i] = data[i];
|
808
|
-
}
|
809
|
-
let cur = item;
|
810
|
-
while (pos < len) {
|
811
|
-
const next = cur;
|
812
|
-
cur = data[pos];
|
813
|
-
result[pos++] = next;
|
799
|
+
function isFunction(path5) {
|
800
|
+
switch (path5.type) {
|
801
|
+
case "FunctionDeclaration":
|
802
|
+
return !path5.node.declare;
|
803
|
+
case "FunctionExpression":
|
804
|
+
case "ArrowFunctionExpression":
|
805
|
+
case "ObjectMethod":
|
806
|
+
return true;
|
807
|
+
default:
|
808
|
+
return false;
|
814
809
|
}
|
815
|
-
result[len] = cur;
|
816
|
-
return result;
|
817
810
|
}
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
let
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
aIndex++;
|
834
|
-
result.push(aValue);
|
835
|
-
} else {
|
836
|
-
bIndex++;
|
837
|
-
result.push(bValue);
|
811
|
+
|
812
|
+
// src/translator/util/is-invoked-function.ts
|
813
|
+
var import_compiler4 = require("@marko/compiler");
|
814
|
+
function isInvokedFunction(expr) {
|
815
|
+
let curPath = expr;
|
816
|
+
while (curPath) {
|
817
|
+
const { parent, node } = curPath;
|
818
|
+
switch (parent.type) {
|
819
|
+
case "CallExpression":
|
820
|
+
return parent.callee === node;
|
821
|
+
case "TSNonNullExpression":
|
822
|
+
curPath = curPath.parentPath;
|
823
|
+
break;
|
824
|
+
default:
|
825
|
+
return false;
|
838
826
|
}
|
839
827
|
}
|
840
|
-
|
841
|
-
|
828
|
+
return false;
|
829
|
+
}
|
830
|
+
|
831
|
+
// src/translator/util/optional.ts
|
832
|
+
var Sorted = class {
|
833
|
+
constructor(compare) {
|
834
|
+
this.compare = compare;
|
842
835
|
}
|
843
|
-
|
844
|
-
|
836
|
+
add(data, item) {
|
837
|
+
return data ? Array.isArray(data) ? addSorted(this.compare, data, item) : joinRepeatable(this.compare, data, item) : item;
|
845
838
|
}
|
846
|
-
|
847
|
-
|
839
|
+
union(a, b) {
|
840
|
+
if (a) {
|
841
|
+
if (Array.isArray(a)) {
|
842
|
+
if (b) {
|
843
|
+
if (Array.isArray(b)) {
|
844
|
+
return unionSortedRepeatable(this.compare, a, b);
|
845
|
+
} else {
|
846
|
+
return addSorted(this.compare, a, b);
|
847
|
+
}
|
848
|
+
}
|
849
|
+
return a;
|
850
|
+
}
|
851
|
+
if (b) {
|
852
|
+
if (Array.isArray(b)) {
|
853
|
+
return addSorted(this.compare, b, a);
|
854
|
+
}
|
855
|
+
return joinRepeatable(this.compare, b, a);
|
856
|
+
}
|
857
|
+
return a;
|
858
|
+
}
|
859
|
+
return b;
|
848
860
|
}
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
var import_compiler23 = require("@marko/compiler");
|
858
|
-
|
859
|
-
// src/translator/visitors/program/index.ts
|
860
|
-
var import_compiler22 = require("@marko/compiler");
|
861
|
-
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
862
|
-
var import_path2 = __toESM(require("path"));
|
863
|
-
|
864
|
-
// src/translator/util/binding-has-downstream-expressions.ts
|
865
|
-
function bindingHasDownstreamExpressions(binding) {
|
866
|
-
if (binding.downstreamExpressions.size) return true;
|
867
|
-
for (const alias of binding.aliases) {
|
868
|
-
if (bindingHasDownstreamExpressions(alias)) return true;
|
861
|
+
find(data, item) {
|
862
|
+
if (data) {
|
863
|
+
if (Array.isArray(data)) {
|
864
|
+
return findSorted(this.compare, data, item);
|
865
|
+
} else if (this.compare(data, item) === 0) {
|
866
|
+
return data;
|
867
|
+
}
|
868
|
+
}
|
869
869
|
}
|
870
|
-
|
871
|
-
if (
|
870
|
+
findIndex(data, item) {
|
871
|
+
if (data) {
|
872
|
+
if (Array.isArray(data)) {
|
873
|
+
return findIndexSorted(this.compare, data, item);
|
874
|
+
} else if (this.compare(data, item) === 0) {
|
875
|
+
return 0;
|
876
|
+
}
|
877
|
+
}
|
878
|
+
return -1;
|
872
879
|
}
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
// src/translator/util/entry-builder.ts
|
877
|
-
var import_compiler5 = require("@marko/compiler");
|
878
|
-
var import_babel_utils6 = require("@marko/compiler/babel-utils");
|
879
|
-
var kState = Symbol();
|
880
|
-
var entry_builder_default = {
|
881
|
-
build(entryFile) {
|
882
|
-
const state = entryFile[kState];
|
883
|
-
if (!state) {
|
884
|
-
throw entryFile.path.buildCodeFrameError(
|
885
|
-
"Unable to build hydrate code, no files were visited before finalizing the build"
|
886
|
-
);
|
880
|
+
isSuperset(superset, subset) {
|
881
|
+
if (!subset) {
|
882
|
+
return true;
|
887
883
|
}
|
888
|
-
|
889
|
-
|
890
|
-
);
|
891
|
-
if (state.init) {
|
892
|
-
body.unshift(
|
893
|
-
import_compiler5.types.importDeclaration(
|
894
|
-
[import_compiler5.types.importSpecifier(import_compiler5.types.identifier("init"), import_compiler5.types.identifier("init"))],
|
895
|
-
import_compiler5.types.stringLiteral(
|
896
|
-
`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`
|
897
|
-
)
|
898
|
-
)
|
899
|
-
);
|
900
|
-
body.push(
|
901
|
-
import_compiler5.types.expressionStatement(import_compiler5.types.callExpression(import_compiler5.types.identifier("init"), []))
|
902
|
-
);
|
884
|
+
if (!Array.isArray(subset)) {
|
885
|
+
return this.findIndex(superset, subset) !== -1;
|
903
886
|
}
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
const
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
state.init ||= file.path.node.extra.hasInteractiveChild || file.path.node.extra.isInteractive || false;
|
916
|
-
for (const tag of analyzedTags || []) {
|
917
|
-
visitChild(tag);
|
887
|
+
if (!Array.isArray(superset)) {
|
888
|
+
return false;
|
889
|
+
}
|
890
|
+
const subLen = subset.length;
|
891
|
+
const supLen = superset.length;
|
892
|
+
if (subLen > supLen) {
|
893
|
+
return false;
|
894
|
+
}
|
895
|
+
for (let i = subLen; i--; ) {
|
896
|
+
const supIndex = this.findIndex(superset, subset[i]);
|
897
|
+
if (supIndex === -1 || supLen - supIndex <= i) return false;
|
918
898
|
}
|
899
|
+
return true;
|
919
900
|
}
|
920
901
|
};
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
if (attr2.type === "MarkoAttribute") {
|
927
|
-
attrs2[attr2.name] = attr2.value;
|
902
|
+
function push(data, item) {
|
903
|
+
if (data) {
|
904
|
+
if (Array.isArray(data)) {
|
905
|
+
data.push(item);
|
906
|
+
return data;
|
928
907
|
}
|
908
|
+
return [data, item];
|
929
909
|
}
|
930
|
-
return
|
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;
|
910
|
+
return item;
|
939
911
|
}
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
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;
|
912
|
+
function concat(a, b) {
|
913
|
+
if (a) {
|
914
|
+
if (b) {
|
915
|
+
if (Array.isArray(a)) {
|
916
|
+
return a.concat(b);
|
917
|
+
} else if (Array.isArray(b)) {
|
918
|
+
return [a, ...b];
|
919
|
+
} else {
|
920
|
+
return [a, b];
|
960
921
|
}
|
961
922
|
}
|
923
|
+
return a;
|
962
924
|
}
|
963
|
-
return
|
964
|
-
}
|
965
|
-
function isCoreTagName(tag, name2) {
|
966
|
-
return isCoreTag(tag) && getTagName(tag) === name2;
|
925
|
+
return b;
|
967
926
|
}
|
968
|
-
function
|
969
|
-
if (
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
927
|
+
function filter(data, cb) {
|
928
|
+
if (data) {
|
929
|
+
if (Array.isArray(data)) {
|
930
|
+
const len = data.length;
|
931
|
+
let result;
|
932
|
+
let i = 0;
|
933
|
+
while (i < len) {
|
934
|
+
let item = data[i++];
|
935
|
+
if (cb(item)) {
|
936
|
+
result = item;
|
937
|
+
while (i < len) {
|
938
|
+
item = data[i++];
|
939
|
+
if (cb(item)) {
|
940
|
+
result = [result, item];
|
941
|
+
while (i < len) {
|
942
|
+
item = data[i++];
|
943
|
+
if (cb(item)) {
|
944
|
+
result.push(item);
|
945
|
+
}
|
946
|
+
}
|
947
|
+
return result;
|
948
|
+
}
|
949
|
+
}
|
950
|
+
return result;
|
951
|
+
}
|
952
|
+
}
|
953
|
+
return result;
|
954
|
+
}
|
955
|
+
if (cb(data)) {
|
956
|
+
return data;
|
975
957
|
}
|
976
958
|
}
|
977
|
-
return
|
959
|
+
return void 0;
|
978
960
|
}
|
979
|
-
function
|
980
|
-
if (
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
return true;
|
961
|
+
function forEach(data, cb) {
|
962
|
+
if (data) {
|
963
|
+
if (Array.isArray(data)) {
|
964
|
+
let i = 0;
|
965
|
+
for (const item of data) {
|
966
|
+
cb(item, i++);
|
967
|
+
}
|
968
|
+
} else {
|
969
|
+
cb(data, 0);
|
989
970
|
}
|
990
971
|
}
|
991
|
-
return false;
|
992
972
|
}
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
973
|
+
function fromIter(data) {
|
974
|
+
let one;
|
975
|
+
let many;
|
976
|
+
for (const item of data) {
|
977
|
+
if (many) {
|
978
|
+
many.push(item);
|
979
|
+
} else if (one) {
|
980
|
+
many = [one, item];
|
981
|
+
} else {
|
982
|
+
one = item;
|
983
|
+
}
|
984
|
+
}
|
985
|
+
return many || one;
|
1004
986
|
}
|
1005
|
-
function
|
1006
|
-
|
987
|
+
function find(data, cb) {
|
988
|
+
if (data) {
|
989
|
+
if (Array.isArray(data)) {
|
990
|
+
return data.find(cb);
|
991
|
+
}
|
992
|
+
if (cb(data, 0)) {
|
993
|
+
return data;
|
994
|
+
}
|
995
|
+
}
|
1007
996
|
}
|
1008
|
-
function
|
1009
|
-
return
|
997
|
+
function toArray(data, cb) {
|
998
|
+
return data ? Array.isArray(data) ? data.map(cb) : [cb(data, 0)] : [];
|
1010
999
|
}
|
1011
|
-
function
|
1012
|
-
|
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 "";
|
1013
1014
|
}
|
1014
|
-
function
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1015
|
+
function filterMap(data, cb) {
|
1016
|
+
if (data) {
|
1017
|
+
if (Array.isArray(data)) {
|
1018
|
+
const len = data.length;
|
1019
|
+
let result;
|
1020
|
+
let i = 0;
|
1021
|
+
while (i < len) {
|
1022
|
+
let item = cb(data[i++]);
|
1023
|
+
if (item) {
|
1024
|
+
result = item;
|
1025
|
+
while (i < len) {
|
1026
|
+
item = cb(data[i++]);
|
1027
|
+
if (item) {
|
1028
|
+
result = [result, item];
|
1029
|
+
while (i < len) {
|
1030
|
+
item = cb(data[i++]);
|
1031
|
+
if (item) {
|
1032
|
+
result.push(item);
|
1033
|
+
}
|
1034
|
+
}
|
1035
|
+
return result;
|
1036
|
+
}
|
1037
|
+
}
|
1038
|
+
return result;
|
1027
1039
|
}
|
1028
1040
|
}
|
1041
|
+
return result;
|
1029
1042
|
} else {
|
1030
|
-
|
1031
|
-
part = stringify(name2, val[name2]);
|
1032
|
-
if (part) {
|
1033
|
-
str += sep + part;
|
1034
|
-
sep = delimiter;
|
1035
|
-
}
|
1036
|
-
}
|
1043
|
+
return cb(data);
|
1037
1044
|
}
|
1038
1045
|
}
|
1039
|
-
return str;
|
1040
1046
|
}
|
1041
|
-
function
|
1042
|
-
|
1047
|
+
function findSorted(compare, data, item) {
|
1048
|
+
let max = data.length;
|
1049
|
+
let pos = 0;
|
1050
|
+
while (pos < max) {
|
1051
|
+
const mid = pos + max >>> 1;
|
1052
|
+
const cur = data[mid];
|
1053
|
+
const compareResult = compare(cur, item);
|
1054
|
+
if (compareResult === 0) return cur;
|
1055
|
+
if (compareResult > 0) max = mid;
|
1056
|
+
else pos = mid + 1;
|
1057
|
+
}
|
1043
1058
|
}
|
1044
|
-
function
|
1045
|
-
|
1059
|
+
function findIndexSorted(compare, data, item) {
|
1060
|
+
let max = data.length;
|
1061
|
+
let pos = 0;
|
1062
|
+
while (pos < max) {
|
1063
|
+
const mid = pos + max >>> 1;
|
1064
|
+
const compareResult = compare(data[mid], item);
|
1065
|
+
if (compareResult === 0) return mid;
|
1066
|
+
if (compareResult > 0) max = mid;
|
1067
|
+
else pos = mid + 1;
|
1068
|
+
}
|
1069
|
+
return -1;
|
1046
1070
|
}
|
1047
|
-
function
|
1048
|
-
|
1071
|
+
function addSorted(compare, data, item) {
|
1072
|
+
const len = data.length;
|
1073
|
+
let max = len;
|
1074
|
+
let pos = 0;
|
1075
|
+
while (pos < max) {
|
1076
|
+
const mid = pos + max >>> 1;
|
1077
|
+
const compareResult = compare(data[mid], item);
|
1078
|
+
if (compareResult === 0) return data;
|
1079
|
+
if (compareResult > 0) max = mid;
|
1080
|
+
else pos = mid + 1;
|
1081
|
+
}
|
1082
|
+
const result = new Array(len + 1);
|
1083
|
+
for (let i = 0; i < pos; i++) {
|
1084
|
+
result[i] = data[i];
|
1085
|
+
}
|
1086
|
+
let cur = item;
|
1087
|
+
while (pos < len) {
|
1088
|
+
const next = cur;
|
1089
|
+
cur = data[pos];
|
1090
|
+
result[pos++] = next;
|
1091
|
+
}
|
1092
|
+
result[len] = cur;
|
1093
|
+
return result;
|
1049
1094
|
}
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1095
|
+
function unionSortedRepeatable(compare, a, b) {
|
1096
|
+
const aLen = a.length;
|
1097
|
+
const bLen = b.length;
|
1098
|
+
let aIndex = 0;
|
1099
|
+
let bIndex = 0;
|
1100
|
+
const result = [];
|
1101
|
+
while (aIndex < aLen && bIndex < bLen) {
|
1102
|
+
const aValue = a[aIndex];
|
1103
|
+
const bValue = b[bIndex];
|
1104
|
+
const delta = compare(aValue, bValue);
|
1105
|
+
if (delta === 0) {
|
1106
|
+
aIndex++;
|
1107
|
+
bIndex++;
|
1108
|
+
result.push(aValue);
|
1109
|
+
} else if (delta < 0) {
|
1110
|
+
aIndex++;
|
1111
|
+
result.push(aValue);
|
1112
|
+
} else {
|
1113
|
+
bIndex++;
|
1114
|
+
result.push(bValue);
|
1115
|
+
}
|
1116
|
+
}
|
1117
|
+
if (aLen === bLen && aIndex === aLen) {
|
1118
|
+
return a;
|
1119
|
+
}
|
1120
|
+
while (aIndex < aLen) {
|
1121
|
+
result.push(a[aIndex++]);
|
1122
|
+
}
|
1123
|
+
while (bIndex < bLen) {
|
1124
|
+
result.push(b[bIndex++]);
|
1125
|
+
}
|
1126
|
+
return result;
|
1054
1127
|
}
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
function escapeXML(val) {
|
1059
|
-
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "‍";
|
1128
|
+
function joinRepeatable(compare, a, b) {
|
1129
|
+
const compareResult = compare(a, b);
|
1130
|
+
return compareResult === 0 ? a : compareResult < 0 ? [a, b] : [b, a];
|
1060
1131
|
}
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
var
|
1067
|
-
var
|
1068
|
-
|
1069
|
-
|
1132
|
+
|
1133
|
+
// src/translator/util/scope-read.ts
|
1134
|
+
var import_compiler23 = require("@marko/compiler");
|
1135
|
+
|
1136
|
+
// src/translator/visitors/program/index.ts
|
1137
|
+
var import_compiler22 = require("@marko/compiler");
|
1138
|
+
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
1139
|
+
var import_path2 = __toESM(require("path"));
|
1140
|
+
|
1141
|
+
// src/translator/util/binding-has-downstream-expressions.ts
|
1142
|
+
function bindingHasDownstreamExpressions(binding) {
|
1143
|
+
if (binding.downstreamExpressions.size) return true;
|
1144
|
+
for (const alias of binding.aliases) {
|
1145
|
+
if (bindingHasDownstreamExpressions(alias)) return true;
|
1146
|
+
}
|
1147
|
+
for (const alias of binding.propertyAliases.values()) {
|
1148
|
+
if (bindingHasDownstreamExpressions(alias)) return true;
|
1149
|
+
}
|
1150
|
+
return false;
|
1070
1151
|
}
|
1071
1152
|
|
1072
|
-
// src/
|
1073
|
-
var
|
1074
|
-
var
|
1075
|
-
var
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
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);
|
1153
|
+
// src/translator/util/entry-builder.ts
|
1154
|
+
var import_compiler5 = require("@marko/compiler");
|
1155
|
+
var import_babel_utils6 = require("@marko/compiler/babel-utils");
|
1156
|
+
var kState = Symbol();
|
1157
|
+
var entry_builder_default = {
|
1158
|
+
build(entryFile) {
|
1159
|
+
const state = entryFile[kState];
|
1160
|
+
if (!state) {
|
1161
|
+
throw entryFile.path.buildCodeFrameError(
|
1162
|
+
"Unable to build hydrate code, no files were visited before finalizing the build"
|
1163
|
+
);
|
1087
1164
|
}
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
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;
|
1165
|
+
const body = state.imports.map(
|
1166
|
+
(it) => import_compiler5.types.importDeclaration([], import_compiler5.types.stringLiteral(it))
|
1167
|
+
);
|
1168
|
+
if (state.init) {
|
1169
|
+
body.unshift(
|
1170
|
+
import_compiler5.types.importDeclaration(
|
1171
|
+
[import_compiler5.types.importSpecifier(import_compiler5.types.identifier("init"), import_compiler5.types.identifier("init"))],
|
1172
|
+
import_compiler5.types.stringLiteral(
|
1173
|
+
`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`
|
1174
|
+
)
|
1175
|
+
)
|
1176
|
+
);
|
1177
|
+
body.push(
|
1178
|
+
import_compiler5.types.expressionStatement(import_compiler5.types.callExpression(import_compiler5.types.identifier("init"), []))
|
1179
|
+
);
|
1180
|
+
}
|
1181
|
+
return body;
|
1182
|
+
},
|
1183
|
+
visit(file, entryFile, visitChild) {
|
1184
|
+
const state = entryFile[kState] ||= {
|
1185
|
+
imports: [],
|
1186
|
+
init: false
|
1187
|
+
};
|
1188
|
+
const { analyzedTags } = file.metadata.marko;
|
1189
|
+
state.imports.push(
|
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);
|
1195
|
+
}
|
1196
|
+
}
|
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;
|
1325
1208
|
}
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
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;
|
1216
|
+
}
|
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
5023
|
}
|
4954
|
-
if (!resolvedSources.has(source)) {
|
4955
|
-
resolvedSources.add(source);
|
4956
|
-
resolveDerivedSources(source);
|
4957
|
-
}
|
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();
|
@@ -5627,7 +5752,7 @@ var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
5627
5752
|
var import_compiler31 = require("@marko/compiler");
|
5628
5753
|
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
5629
5754
|
var kNativeTagBinding = Symbol("native tag binding");
|
5630
|
-
var
|
5755
|
+
var kSkipEndTag = Symbol("skip native tag mark");
|
5631
5756
|
var kGetterId = Symbol("node getter id");
|
5632
5757
|
var htmlSelectArgs = /* @__PURE__ */ new WeakMap();
|
5633
5758
|
var native_tag_default = {
|
@@ -5934,7 +6059,9 @@ var native_tag_default = {
|
|
5934
6059
|
flushInto(tag);
|
5935
6060
|
}
|
5936
6061
|
if (selectArgs) {
|
5937
|
-
|
6062
|
+
if (!tagExtra[kSkipEndTag]) {
|
6063
|
+
writeTo(tag)`</${tag.node.name}>`;
|
6064
|
+
}
|
5938
6065
|
flushInto(tag);
|
5939
6066
|
tag.insertBefore(
|
5940
6067
|
import_compiler31.types.expressionStatement(
|
@@ -5954,8 +6081,8 @@ var native_tag_default = {
|
|
5954
6081
|
} else {
|
5955
6082
|
tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
5956
6083
|
}
|
5957
|
-
const markerSerializeReason =
|
5958
|
-
if (!openTagOnly && !selectArgs) {
|
6084
|
+
const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getBindingSerializeReason(tagSection, nodeBinding);
|
6085
|
+
if (!tagExtra[kSkipEndTag] && !openTagOnly && !selectArgs) {
|
5959
6086
|
writeTo(
|
5960
6087
|
tag,
|
5961
6088
|
!markerSerializeReason && (tagName === "html" || tagName === "body")
|
@@ -6468,19 +6595,16 @@ function buildUndefined() {
|
|
6468
6595
|
// src/translator/util/is-only-child-in-parent.ts
|
6469
6596
|
var kOnlyChildInParent = Symbol("only child in parent");
|
6470
6597
|
var kNodeRef = Symbol("potential only child node ref");
|
6471
|
-
function
|
6598
|
+
function getOnlyChildParentTagName(tag, branchSize = 1) {
|
6472
6599
|
const extra = tag.node.extra;
|
6473
6600
|
if (extra[kOnlyChildInParent] !== void 0) {
|
6474
6601
|
return extra[kOnlyChildInParent];
|
6475
6602
|
}
|
6476
6603
|
const parentTag = getParentTag(tag);
|
6477
|
-
|
6478
|
-
return extra[kOnlyChildInParent] = tag.parent.body.length === branchSize;
|
6479
|
-
}
|
6480
|
-
return extra[kOnlyChildInParent] = false;
|
6604
|
+
return extra[kOnlyChildInParent] = parentTag && (0, import_babel_utils24.getTagDef)(parentTag)?.html && parentTag.node.name.type === "StringLiteral" && tag.parent.body.length === branchSize ? parentTag.node.name.value : false;
|
6481
6605
|
}
|
6482
6606
|
function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
|
6483
|
-
if (
|
6607
|
+
if (getOnlyChildParentTagName(tag, branchSize)) {
|
6484
6608
|
const parentTag = getParentTag(tag).node;
|
6485
6609
|
const parentTagName = parentTag.name?.value;
|
6486
6610
|
return (parentTag.extra ??= {})[kNativeTagBinding] ??= createBinding(
|
@@ -6560,7 +6684,7 @@ var for_default = {
|
|
6560
6684
|
return;
|
6561
6685
|
}
|
6562
6686
|
setSectionParentIsOwner(bodySection, true);
|
6563
|
-
if (!
|
6687
|
+
if (!getOnlyChildParentTagName(tag)) {
|
6564
6688
|
visit(tag, 37 /* Replace */);
|
6565
6689
|
enterShallow(tag);
|
6566
6690
|
}
|
@@ -6572,7 +6696,7 @@ var for_default = {
|
|
6572
6696
|
const tagSection = getSection(tag);
|
6573
6697
|
const bodySection = getSectionForBody(tagBody);
|
6574
6698
|
const { node } = tag;
|
6575
|
-
const
|
6699
|
+
const onlyChildParentTagName = getOnlyChildParentTagName(tag);
|
6576
6700
|
const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
|
6577
6701
|
const forAttrs = getKnownAttrValues(node);
|
6578
6702
|
const forType = getForType(node);
|
@@ -6596,18 +6720,21 @@ var for_default = {
|
|
6596
6720
|
import_compiler33.types.arrowFunctionExpression(params, import_compiler33.types.blockStatement(bodyStatements))
|
6597
6721
|
);
|
6598
6722
|
if (branchSerializeReason) {
|
6599
|
-
|
6600
|
-
|
6601
|
-
|
6723
|
+
const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
|
6724
|
+
const markerSerializeArg = getSerializeGuard(
|
6725
|
+
markerSerializeReason,
|
6726
|
+
!skipParentEnd
|
6727
|
+
);
|
6602
6728
|
forTagArgs.push(
|
6603
6729
|
forAttrs.by || import_compiler33.types.numericLiteral(0),
|
6604
6730
|
getScopeIdIdentifier(tagSection),
|
6605
6731
|
getScopeAccessorLiteral(nodeBinding),
|
6606
|
-
branchSerializeReason
|
6607
|
-
|
6732
|
+
getSerializeGuard(branchSerializeReason, !markerSerializeArg),
|
6733
|
+
markerSerializeArg
|
6608
6734
|
);
|
6609
|
-
if (
|
6610
|
-
|
6735
|
+
if (skipParentEnd) {
|
6736
|
+
getParentTag(tag).node.extra[kSkipEndTag] = true;
|
6737
|
+
forTagArgs.push(import_compiler33.types.stringLiteral(`</${onlyChildParentTagName}>`));
|
6611
6738
|
}
|
6612
6739
|
}
|
6613
6740
|
statements.push(
|
@@ -6628,7 +6755,7 @@ var for_default = {
|
|
6628
6755
|
return;
|
6629
6756
|
}
|
6630
6757
|
setSectionParentIsOwner(bodySection, true);
|
6631
|
-
if (!
|
6758
|
+
if (!getOnlyChildParentTagName(tag)) {
|
6632
6759
|
visit(tag, 37 /* Replace */);
|
6633
6760
|
enterShallow(tag);
|
6634
6761
|
}
|
@@ -8418,7 +8545,7 @@ var IfTag = {
|
|
8418
8545
|
if (tag.node.body.attributeTags) return;
|
8419
8546
|
const tagBody = tag.get("body");
|
8420
8547
|
const bodySection = getSectionForBody(tagBody);
|
8421
|
-
if (isRoot(tag) && !
|
8548
|
+
if (isRoot(tag) && !getOnlyChildParentTagName(tag)) {
|
8422
8549
|
visit(tag, 37 /* Replace */);
|
8423
8550
|
enterShallow(tag);
|
8424
8551
|
}
|
@@ -8445,7 +8572,7 @@ var IfTag = {
|
|
8445
8572
|
ifTag,
|
8446
8573
|
ifTagSection
|
8447
8574
|
);
|
8448
|
-
const
|
8575
|
+
const onlyChildParentTagName = getOnlyChildParentTagName(ifTag);
|
8449
8576
|
const markerSerializeReason = getBindingSerializeReason(
|
8450
8577
|
ifTagSection,
|
8451
8578
|
nodeBinding
|
@@ -8463,11 +8590,11 @@ var IfTag = {
|
|
8463
8590
|
);
|
8464
8591
|
if (branchSerializeReason) {
|
8465
8592
|
if (branchSerializeReasons !== true) {
|
8466
|
-
if (branchSerializeReason === true) {
|
8593
|
+
if (branchSerializeReason === true || branchSerializeReason.state) {
|
8467
8594
|
branchSerializeReasons = true;
|
8468
8595
|
} else if (branchSerializeReasons) {
|
8469
8596
|
branchSerializeReasons = addSorted(
|
8470
|
-
|
8597
|
+
compareSources,
|
8471
8598
|
branchSerializeReasons,
|
8472
8599
|
branchSerializeReason
|
8473
8600
|
);
|
@@ -8494,29 +8621,30 @@ var IfTag = {
|
|
8494
8621
|
branchTag.remove();
|
8495
8622
|
}
|
8496
8623
|
if (branchSerializeReasons) {
|
8497
|
-
|
8498
|
-
|
8624
|
+
const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
|
8625
|
+
if (skipParentEnd) {
|
8626
|
+
getParentTag(ifTag).node.extra[kSkipEndTag] = true;
|
8499
8627
|
}
|
8628
|
+
const markerSerializeArg = getSerializeGuard(
|
8629
|
+
markerSerializeReason,
|
8630
|
+
!skipParentEnd
|
8631
|
+
);
|
8500
8632
|
const cbNode = import_compiler42.types.arrowFunctionExpression(
|
8501
8633
|
[],
|
8502
8634
|
import_compiler42.types.blockStatement([statement])
|
8503
8635
|
);
|
8504
8636
|
statement = import_compiler42.types.expressionStatement(
|
8505
|
-
|
8506
|
-
"resumeSingleNodeConditional",
|
8507
|
-
cbNode,
|
8508
|
-
getScopeIdIdentifier(ifTagSection),
|
8509
|
-
getScopeAccessorLiteral(nodeBinding),
|
8510
|
-
branchSerializeReasons === true ? markerSerializeReason === true && !onlyChildInParentOptimization ? void 0 : import_compiler42.types.numericLiteral(1) : getSerializeGuardForAny(branchSerializeReasons),
|
8511
|
-
!markerSerializeReason ? import_compiler42.types.numericLiteral(0) : markerSerializeReason === true ? onlyChildInParentOptimization ? import_compiler42.types.numericLiteral(1) : void 0 : getSerializeGuard(markerSerializeReason),
|
8512
|
-
onlyChildInParentOptimization && import_compiler42.types.numericLiteral(1)
|
8513
|
-
) : callRuntime(
|
8514
|
-
"resumeConditional",
|
8637
|
+
callRuntime(
|
8638
|
+
singleNodeOptimization ? "resumeSingleNodeConditional" : "resumeConditional",
|
8515
8639
|
cbNode,
|
8516
8640
|
getScopeIdIdentifier(ifTagSection),
|
8517
8641
|
getScopeAccessorLiteral(nodeBinding),
|
8518
|
-
|
8519
|
-
|
8642
|
+
getSerializeGuardForAny(
|
8643
|
+
branchSerializeReasons,
|
8644
|
+
!markerSerializeArg
|
8645
|
+
),
|
8646
|
+
markerSerializeArg,
|
8647
|
+
skipParentEnd && import_compiler42.types.stringLiteral(`</${onlyChildParentTagName}>`)
|
8520
8648
|
)
|
8521
8649
|
);
|
8522
8650
|
}
|
@@ -8532,7 +8660,7 @@ var IfTag = {
|
|
8532
8660
|
if (bodySection) {
|
8533
8661
|
setSectionParentIsOwner(bodySection, true);
|
8534
8662
|
}
|
8535
|
-
if (isRoot(tag) && !
|
8663
|
+
if (isRoot(tag) && !getOnlyChildParentTagName(tag)) {
|
8536
8664
|
visit(tag, 37 /* Replace */);
|
8537
8665
|
enterShallow(tag);
|
8538
8666
|
}
|
@@ -8698,13 +8826,6 @@ function getBranches(tag) {
|
|
8698
8826
|
}
|
8699
8827
|
return branches;
|
8700
8828
|
}
|
8701
|
-
function getSerializeGuardForAny(reasons) {
|
8702
|
-
let expr = getSerializeGuard(reasons[0]);
|
8703
|
-
for (let i = 1; i < reasons.length; i++) {
|
8704
|
-
expr = import_compiler42.types.logicalExpression("||", expr, getSerializeGuard(reasons[i]));
|
8705
|
-
}
|
8706
|
-
return expr;
|
8707
|
-
}
|
8708
8829
|
function isLastBranch(tag) {
|
8709
8830
|
const branches = getBranches(tag);
|
8710
8831
|
return branches[branches.length - 1][0] === tag;
|
@@ -9630,10 +9751,10 @@ var placeholder_default = {
|
|
9630
9751
|
} else {
|
9631
9752
|
if (siblingText === 1 /* Before */) {
|
9632
9753
|
if (isHTML && markerSerializeReason) {
|
9633
|
-
if (markerSerializeReason === true) {
|
9754
|
+
if (markerSerializeReason === true || markerSerializeReason.state) {
|
9634
9755
|
write2`<!>`;
|
9635
9756
|
} else {
|
9636
|
-
write2`${callRuntime("commentSeparator", getSerializeGuard(markerSerializeReason))}`;
|
9757
|
+
write2`${callRuntime("commentSeparator", getSerializeGuard(markerSerializeReason, true))}`;
|
9637
9758
|
}
|
9638
9759
|
}
|
9639
9760
|
visit(placeholder, 37 /* Replace */);
|
@@ -10039,7 +10160,7 @@ function translateHTML(tag) {
|
|
10039
10160
|
childScopeBinding,
|
10040
10161
|
childSerializeReasonIds[0]
|
10041
10162
|
);
|
10042
|
-
childSerializeReasonExpr = !reason ? void 0 : reason == true ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason);
|
10163
|
+
childSerializeReasonExpr = !reason ? void 0 : reason == true || reason.state ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason, true);
|
10043
10164
|
} else {
|
10044
10165
|
const props = [];
|
10045
10166
|
let hasDynamicReasons = false;
|
@@ -10051,11 +10172,15 @@ function translateHTML(tag) {
|
|
10051
10172
|
childSerializeReasonIds[i]
|
10052
10173
|
);
|
10053
10174
|
if (reason) {
|
10054
|
-
hasDynamicReasons ||= reason !== true;
|
10175
|
+
hasDynamicReasons ||= reason !== true && !reason.state;
|
10176
|
+
const childReason = childExtra.inputSerializeReasons[i];
|
10055
10177
|
props.push(
|
10056
10178
|
import_compiler56.types.objectProperty(
|
10057
|
-
|
10058
|
-
|
10179
|
+
withLeadingComment(
|
10180
|
+
import_compiler56.types.numericLiteral(i),
|
10181
|
+
mapToString(childReason, ", ", getInputDebugName)
|
10182
|
+
),
|
10183
|
+
reason === true || reason.state ? import_compiler56.types.numericLiteral(1) : getSerializeGuard(reason, false)
|
10059
10184
|
)
|
10060
10185
|
);
|
10061
10186
|
} else {
|
@@ -10796,11 +10921,10 @@ var dynamic_tag_default = {
|
|
10796
10921
|
if (isOutputHTML()) {
|
10797
10922
|
flushInto(tag);
|
10798
10923
|
writeHTMLResumeStatements(tag.get("body"));
|
10799
|
-
const
|
10800
|
-
tagSection,
|
10801
|
-
|
10924
|
+
const serializeArg = getSerializeGuard(
|
10925
|
+
getBindingSerializeReason(tagSection, nodeBinding),
|
10926
|
+
true
|
10802
10927
|
);
|
10803
|
-
const serializeArg = !serializeReason ? import_compiler57.types.numericLiteral(0) : serializeReason === true ? void 0 : getSerializeGuard(serializeReason);
|
10804
10928
|
const dynamicTagExpr = hasTagArgs ? callRuntime(
|
10805
10929
|
"dynamicTag",
|
10806
10930
|
getScopeIdIdentifier(tagSection),
|