gyosjs 0.3.2 → 0.4.1
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/README.md +128 -126
- package/dist/core/router/diff-nodes.d.ts +2 -1
- package/dist/core/router/diff-nodes.d.ts.map +1 -1
- package/dist/core/router/router.d.ts +30 -2
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +415 -191
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +415 -191
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +591 -287
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +591 -287
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +592 -288
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +593 -287
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +416 -192
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +417 -191
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/public-api.d.ts +5 -2
- package/dist/public-api.d.ts.map +1 -1
- package/dist/reactivity/signal.d.ts.map +1 -1
- package/dist/utils/progress-bar.d.ts +1 -0
- package/dist/utils/progress-bar.d.ts.map +1 -1
- package/package.json +91 -90
package/dist/gyos.csp.auto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.
|
|
2
|
+
* GyosJS v0.4.1
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -189,10 +189,35 @@
|
|
|
189
189
|
* count.value++; // Triggers effect
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
/**
|
|
193
|
-
* Current effect being tracked
|
|
194
|
-
*/
|
|
195
192
|
let currentEffect = null;
|
|
193
|
+
function track(source) {
|
|
194
|
+
if (!currentEffect)
|
|
195
|
+
return;
|
|
196
|
+
source.subscribers.add(currentEffect);
|
|
197
|
+
currentEffect.__dependencies?.add(source.subscribers);
|
|
198
|
+
currentEffect.__versions?.set(source, source.version);
|
|
199
|
+
}
|
|
200
|
+
function dependenciesChanged(versions) {
|
|
201
|
+
return untrack(() => {
|
|
202
|
+
for (const [source, version] of versions) {
|
|
203
|
+
source.refresh?.();
|
|
204
|
+
if (source.version !== version)
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return false;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// Invalidate derived caches synchronously; only user effects are deferred.
|
|
211
|
+
function notifySubscribers(subscribers) {
|
|
212
|
+
for (const sub of Array.from(subscribers)) {
|
|
213
|
+
if (sub.__invalidate)
|
|
214
|
+
sub();
|
|
215
|
+
else if (isBatching)
|
|
216
|
+
batchedEffects.add(sub);
|
|
217
|
+
else
|
|
218
|
+
queueEffect(sub);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
196
221
|
// Simple counter for debug-friendly IDs
|
|
197
222
|
let signalIdCounter = 0;
|
|
198
223
|
const WARN_SUBSCRIBERS = () => typeof window !== 'undefined' && window.GYOS_DEBUG_WARN_SUBSCRIBERS;
|
|
@@ -230,6 +255,9 @@
|
|
|
230
255
|
}
|
|
231
256
|
});
|
|
232
257
|
isFlushingQueue = false;
|
|
258
|
+
// A plain subscribe callback can enqueue more work without entering effect().
|
|
259
|
+
if (effectQueue.size > 0)
|
|
260
|
+
queueMicrotask(flushEffectQueue);
|
|
233
261
|
}
|
|
234
262
|
/**
|
|
235
263
|
* Queue an effect for execution in next microtask
|
|
@@ -288,17 +316,14 @@
|
|
|
288
316
|
const debugId = ++signalIdCounter;
|
|
289
317
|
let value = initialValue;
|
|
290
318
|
const subscribers = new Set();
|
|
319
|
+
const source = { subscribers, version: 0 };
|
|
291
320
|
let warnedSubscribers = false;
|
|
292
321
|
const read = () => {
|
|
293
322
|
// Track dependency
|
|
294
323
|
if (currentEffect) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
// Store the subscribers Set in the effect's dependencies for cleanup
|
|
299
|
-
if (currentEffect.__dependencies) {
|
|
300
|
-
currentEffect.__dependencies.add(subscribers);
|
|
301
|
-
}
|
|
324
|
+
const wasSubscribed = subscribers.has(currentEffect);
|
|
325
|
+
track(source);
|
|
326
|
+
if (!wasSubscribed) {
|
|
302
327
|
if (DEBUG_VERBOSE()) {
|
|
303
328
|
console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Added subscriber, total:', subscribers.size);
|
|
304
329
|
}
|
|
@@ -317,18 +342,13 @@
|
|
|
317
342
|
// For objects/arrays, check if it's actually the same reference
|
|
318
343
|
// Deep equality is expensive, let user handle it
|
|
319
344
|
value = newValue;
|
|
345
|
+
source.version++;
|
|
320
346
|
DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Value changed to:', newValue);
|
|
321
347
|
notify();
|
|
322
348
|
};
|
|
323
349
|
const notify = () => {
|
|
324
350
|
DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Notifying', subscribers.size, 'subscribers');
|
|
325
|
-
|
|
326
|
-
subscribers.forEach(sub => batchedEffects.add(sub));
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
// Always queue effects to prevent cascading updates
|
|
330
|
-
subscribers.forEach(sub => queueEffect(sub));
|
|
331
|
-
}
|
|
351
|
+
notifySubscribers(subscribers);
|
|
332
352
|
};
|
|
333
353
|
// Create callable signal (like Angular/SolidJS)
|
|
334
354
|
// Call without args = read, call with arg = write
|
|
@@ -363,8 +383,16 @@
|
|
|
363
383
|
},
|
|
364
384
|
subscribe: {
|
|
365
385
|
value: function (fn) {
|
|
366
|
-
|
|
367
|
-
|
|
386
|
+
let active = true;
|
|
387
|
+
const callback = () => { if (active)
|
|
388
|
+
untrack(fn); };
|
|
389
|
+
subscribers.add(callback);
|
|
390
|
+
return () => {
|
|
391
|
+
active = false;
|
|
392
|
+
subscribers.delete(callback);
|
|
393
|
+
effectQueue.delete(callback);
|
|
394
|
+
batchedEffects.delete(callback);
|
|
395
|
+
};
|
|
368
396
|
},
|
|
369
397
|
enumerable: true,
|
|
370
398
|
configurable: true
|
|
@@ -424,49 +452,60 @@
|
|
|
424
452
|
let value;
|
|
425
453
|
let isDirty = true;
|
|
426
454
|
let isFirstRun = true;
|
|
455
|
+
let computing = false;
|
|
427
456
|
const subscribers = new Set();
|
|
428
|
-
|
|
457
|
+
const dependencies = new Set();
|
|
458
|
+
const versions = new Map();
|
|
459
|
+
const source = { subscribers, version: 0, refresh: () => compute() };
|
|
460
|
+
const invalidate = () => {
|
|
461
|
+
// A later batched write must also move already queued consumers into
|
|
462
|
+
// the batch, even when an earlier ordinary write dirtied this cache.
|
|
463
|
+
if (isDirty && !isBatching)
|
|
464
|
+
return;
|
|
465
|
+
isDirty = true;
|
|
466
|
+
notifySubscribers(subscribers);
|
|
467
|
+
};
|
|
468
|
+
invalidate.__invalidate = true;
|
|
469
|
+
invalidate.__dependencies = dependencies;
|
|
470
|
+
invalidate.__versions = versions;
|
|
429
471
|
const compute = () => {
|
|
430
472
|
if (!isDirty && !isFirstRun)
|
|
431
473
|
return;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
value = newValue;
|
|
442
|
-
isFirstRun = false;
|
|
443
|
-
isDirty = false;
|
|
444
|
-
// Notify subscribers
|
|
445
|
-
if (!isBatching) {
|
|
446
|
-
subscribers.forEach(sub => queueEffect(sub));
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
subscribers.forEach(sub => batchedEffects.add(sub));
|
|
450
|
-
}
|
|
451
|
-
}
|
|
474
|
+
if (computing)
|
|
475
|
+
throw new Error('[Computed] Circular dependency');
|
|
476
|
+
computing = true;
|
|
477
|
+
const previousEffect = currentEffect;
|
|
478
|
+
try {
|
|
479
|
+
// A dirty upstream computed may still resolve to its previous value.
|
|
480
|
+
if (!isFirstRun && !dependenciesChanged(versions)) {
|
|
481
|
+
isDirty = false;
|
|
482
|
+
return;
|
|
452
483
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
484
|
+
dependencies.forEach(dependency => dependency.delete(invalidate));
|
|
485
|
+
dependencies.clear();
|
|
486
|
+
versions.clear();
|
|
487
|
+
currentEffect = invalidate;
|
|
488
|
+
const nextValue = fn();
|
|
489
|
+
if (isFirstRun || !Object.is(value, nextValue)) {
|
|
490
|
+
value = nextValue;
|
|
491
|
+
source.version++;
|
|
456
492
|
}
|
|
457
|
-
|
|
458
|
-
|
|
493
|
+
isFirstRun = false;
|
|
494
|
+
isDirty = false;
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
// Preserve error isolation and the last successful value.
|
|
498
|
+
console.error('[Computed] Error in computation:', error);
|
|
499
|
+
isDirty = false;
|
|
500
|
+
}
|
|
501
|
+
finally {
|
|
502
|
+
currentEffect = previousEffect;
|
|
503
|
+
computing = false;
|
|
504
|
+
}
|
|
459
505
|
};
|
|
460
506
|
const read = () => {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
// Track dependency
|
|
464
|
-
if (currentEffect && !subscribers.has(currentEffect)) {
|
|
465
|
-
subscribers.add(currentEffect);
|
|
466
|
-
if (currentEffect.__dependencies) {
|
|
467
|
-
currentEffect.__dependencies.add(subscribers);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
507
|
+
compute();
|
|
508
|
+
track(source);
|
|
470
509
|
return value;
|
|
471
510
|
};
|
|
472
511
|
// Create callable computed (read-only)
|
|
@@ -491,8 +530,14 @@
|
|
|
491
530
|
},
|
|
492
531
|
subscribe: {
|
|
493
532
|
value: function (fn) {
|
|
494
|
-
|
|
495
|
-
|
|
533
|
+
// Establish dependencies even if subscribe() is the first access.
|
|
534
|
+
let first = true;
|
|
535
|
+
return effect(() => {
|
|
536
|
+
read();
|
|
537
|
+
if (!first)
|
|
538
|
+
untrack(fn);
|
|
539
|
+
first = false;
|
|
540
|
+
});
|
|
496
541
|
},
|
|
497
542
|
enumerable: true,
|
|
498
543
|
configurable: true
|
|
@@ -543,11 +588,15 @@
|
|
|
543
588
|
*/
|
|
544
589
|
function effect(fn) {
|
|
545
590
|
let cleanup;
|
|
546
|
-
|
|
591
|
+
const dependencies = new Set();
|
|
592
|
+
const versions = new Map();
|
|
547
593
|
let active = true;
|
|
594
|
+
let initialized = false;
|
|
548
595
|
const execute = () => {
|
|
549
596
|
if (!active)
|
|
550
597
|
return;
|
|
598
|
+
if (initialized && !dependenciesChanged(versions))
|
|
599
|
+
return;
|
|
551
600
|
// Prevent recursive execution - if already running, skip
|
|
552
601
|
if (runningEffects.has(execute)) {
|
|
553
602
|
DEBUG() && console.warn('[Effect] Skipped recursive execution');
|
|
@@ -562,10 +611,13 @@
|
|
|
562
611
|
});
|
|
563
612
|
DEBUG() && console.log('[Effect] Cleaned up dependencies, count:', dependencies.size);
|
|
564
613
|
dependencies.clear();
|
|
614
|
+
versions.clear();
|
|
565
615
|
// Clean up previous run
|
|
566
616
|
if (cleanup) {
|
|
617
|
+
const previousCleanup = cleanup;
|
|
618
|
+
cleanup = undefined;
|
|
567
619
|
try {
|
|
568
|
-
|
|
620
|
+
untrack(previousCleanup);
|
|
569
621
|
}
|
|
570
622
|
catch (error) {
|
|
571
623
|
console.error('[Effect] Error in cleanup:', error);
|
|
@@ -576,6 +628,7 @@
|
|
|
576
628
|
currentEffect = execute;
|
|
577
629
|
// Store dependencies for cleanup
|
|
578
630
|
execute.__dependencies = dependencies;
|
|
631
|
+
execute.__versions = versions;
|
|
579
632
|
try {
|
|
580
633
|
const nextCleanup = fn();
|
|
581
634
|
cleanup = typeof nextCleanup === 'function' ? nextCleanup : undefined;
|
|
@@ -585,6 +638,7 @@
|
|
|
585
638
|
// Don't throw - allow other effects to continue
|
|
586
639
|
}
|
|
587
640
|
finally {
|
|
641
|
+
initialized = true;
|
|
588
642
|
currentEffect = prevEffect;
|
|
589
643
|
effectDepth--;
|
|
590
644
|
runningEffects.delete(execute);
|
|
@@ -601,14 +655,17 @@
|
|
|
601
655
|
if (!active)
|
|
602
656
|
return;
|
|
603
657
|
active = false;
|
|
658
|
+
effectQueue.delete(execute);
|
|
659
|
+
batchedEffects.delete(execute);
|
|
604
660
|
// Remove from all dependencies
|
|
605
661
|
dependencies.forEach(depSet => {
|
|
606
662
|
depSet.delete(execute);
|
|
607
663
|
});
|
|
608
664
|
dependencies.clear();
|
|
665
|
+
versions.clear();
|
|
609
666
|
if (cleanup) {
|
|
610
667
|
try {
|
|
611
|
-
cleanup
|
|
668
|
+
untrack(cleanup);
|
|
612
669
|
}
|
|
613
670
|
catch (error) {
|
|
614
671
|
console.error('[Effect] Error in final cleanup:', error);
|
|
@@ -668,6 +725,8 @@
|
|
|
668
725
|
const effects = Array.from(batchedEffects);
|
|
669
726
|
batchedEffects.clear();
|
|
670
727
|
effects.forEach(effect => {
|
|
728
|
+
// This batch also settles any earlier queued write to this observer.
|
|
729
|
+
effectQueue.delete(effect);
|
|
671
730
|
try {
|
|
672
731
|
effect();
|
|
673
732
|
}
|
|
@@ -2202,59 +2261,59 @@
|
|
|
2202
2261
|
return;
|
|
2203
2262
|
const style = document.createElement('style');
|
|
2204
2263
|
style.id = styleId;
|
|
2205
|
-
style.textContent = `
|
|
2206
|
-
/* Opacity utilities */
|
|
2264
|
+
style.textContent = `
|
|
2265
|
+
/* Opacity utilities */
|
|
2207
2266
|
.gyos-t-opacity-0 { opacity: 0; }
|
|
2208
2267
|
.gyos-t-opacity-100 { opacity: 1; }
|
|
2209
|
-
|
|
2210
|
-
/* Transform - Translate Y */
|
|
2268
|
+
|
|
2269
|
+
/* Transform - Translate Y */
|
|
2211
2270
|
.gyos-t-translate-y-0 { transform: translateY(0); }
|
|
2212
2271
|
.gyos-t-translate-y--100 { transform: translateY(-100%); }
|
|
2213
2272
|
.gyos-t-translate-y-100 { transform: translateY(100%); }
|
|
2214
|
-
|
|
2215
|
-
/* Transform - Translate X */
|
|
2273
|
+
|
|
2274
|
+
/* Transform - Translate X */
|
|
2216
2275
|
.gyos-t-translate-x-0 { transform: translateX(0); }
|
|
2217
2276
|
.gyos-t-translate-x--100 { transform: translateX(-100%); }
|
|
2218
2277
|
.gyos-t-translate-x-100 { transform: translateX(100%); }
|
|
2219
|
-
|
|
2220
|
-
/* Transform - Scale */
|
|
2278
|
+
|
|
2279
|
+
/* Transform - Scale */
|
|
2221
2280
|
.gyos-t-scale-0 { transform: scale(0); }
|
|
2222
2281
|
.gyos-t-scale-50 { transform: scale(0.5); }
|
|
2223
2282
|
.gyos-t-scale-100 { transform: scale(1); }
|
|
2224
|
-
|
|
2225
|
-
/* Animation Keyframes */
|
|
2226
|
-
@keyframes gyos-fade-in {
|
|
2227
|
-
from { opacity: 0; }
|
|
2228
|
-
to { opacity: 1; }
|
|
2229
|
-
}
|
|
2230
|
-
|
|
2231
|
-
@keyframes gyos-fade-out {
|
|
2232
|
-
from { opacity: 1; }
|
|
2233
|
-
to { opacity: 0; }
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
@keyframes gyos-slide-down {
|
|
2237
|
-
from { transform: translateY(-100%); opacity: 0; }
|
|
2238
|
-
to { transform: translateY(0); opacity: 1; }
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
@keyframes gyos-slide-up {
|
|
2242
|
-
from { transform: translateY(100%); opacity: 0; }
|
|
2243
|
-
to { transform: translateY(0); opacity: 1; }
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
@keyframes gyos-scale-in {
|
|
2247
|
-
from { transform: scale(0); opacity: 0; }
|
|
2248
|
-
to { transform: scale(1); opacity: 1; }
|
|
2249
|
-
}
|
|
2250
|
-
|
|
2251
|
-
@keyframes gyos-scale-out {
|
|
2252
|
-
from { transform: scale(1); opacity: 1; }
|
|
2253
|
-
to { transform: scale(0); opacity: 0; }
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
[g-cloak] {
|
|
2257
|
-
display: none !important;
|
|
2283
|
+
|
|
2284
|
+
/* Animation Keyframes */
|
|
2285
|
+
@keyframes gyos-fade-in {
|
|
2286
|
+
from { opacity: 0; }
|
|
2287
|
+
to { opacity: 1; }
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
@keyframes gyos-fade-out {
|
|
2291
|
+
from { opacity: 1; }
|
|
2292
|
+
to { opacity: 0; }
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
@keyframes gyos-slide-down {
|
|
2296
|
+
from { transform: translateY(-100%); opacity: 0; }
|
|
2297
|
+
to { transform: translateY(0); opacity: 1; }
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
@keyframes gyos-slide-up {
|
|
2301
|
+
from { transform: translateY(100%); opacity: 0; }
|
|
2302
|
+
to { transform: translateY(0); opacity: 1; }
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
@keyframes gyos-scale-in {
|
|
2306
|
+
from { transform: scale(0); opacity: 0; }
|
|
2307
|
+
to { transform: scale(1); opacity: 1; }
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
@keyframes gyos-scale-out {
|
|
2311
|
+
from { transform: scale(1); opacity: 1; }
|
|
2312
|
+
to { transform: scale(0); opacity: 0; }
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
[g-cloak] {
|
|
2316
|
+
display: none !important;
|
|
2258
2317
|
}`;
|
|
2259
2318
|
document.head.appendChild(style);
|
|
2260
2319
|
}
|
|
@@ -6611,33 +6670,44 @@
|
|
|
6611
6670
|
getCurrentProgress() {
|
|
6612
6671
|
return this.currentProgress;
|
|
6613
6672
|
}
|
|
6673
|
+
reconnect() {
|
|
6674
|
+
if (!this.element || !this.progressBarEnabled || !document.body)
|
|
6675
|
+
return;
|
|
6676
|
+
// Snapshots may contain a clone of the runtime bar. Keep this instance.
|
|
6677
|
+
document.querySelectorAll('#gyos-progress-bar').forEach(node => {
|
|
6678
|
+
if (node !== this.element)
|
|
6679
|
+
node.remove();
|
|
6680
|
+
});
|
|
6681
|
+
if (!this.element.isConnected)
|
|
6682
|
+
document.body.appendChild(this.element);
|
|
6683
|
+
}
|
|
6614
6684
|
createBar() {
|
|
6615
6685
|
if (typeof document === 'undefined')
|
|
6616
6686
|
return;
|
|
6617
6687
|
// Create progress bar element
|
|
6618
6688
|
this.element = document.createElement('div');
|
|
6619
6689
|
this.element.id = 'gyos-progress-bar';
|
|
6620
|
-
this.element.style.cssText = `
|
|
6621
|
-
position: fixed;
|
|
6622
|
-
top: 0;
|
|
6623
|
-
left: 0;
|
|
6624
|
-
width: 0%;
|
|
6625
|
-
height: 6px;
|
|
6626
|
-
background: var(--gyos-progress-color, linear-gradient(90deg, #aab9ff, #77889f));
|
|
6627
|
-
z-index: 999999;
|
|
6628
|
-
transition: width 0.3s linear, opacity 0.3s linear;
|
|
6629
|
-
opacity: 0;
|
|
6630
|
-
pointer-events: none;
|
|
6631
|
-
box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
|
|
6690
|
+
this.element.style.cssText = `
|
|
6691
|
+
position: fixed;
|
|
6692
|
+
top: 0;
|
|
6693
|
+
left: 0;
|
|
6694
|
+
width: 0%;
|
|
6695
|
+
height: 6px;
|
|
6696
|
+
background: var(--gyos-progress-color, linear-gradient(90deg, #aab9ff, #77889f));
|
|
6697
|
+
z-index: 999999;
|
|
6698
|
+
transition: width 0.3s linear, opacity 0.3s linear;
|
|
6699
|
+
opacity: 0;
|
|
6700
|
+
pointer-events: none;
|
|
6701
|
+
box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
|
|
6632
6702
|
`;
|
|
6633
6703
|
// Insert into DOM when ready
|
|
6634
6704
|
if (document.readyState === 'loading') {
|
|
6635
6705
|
document.addEventListener('DOMContentLoaded', () => {
|
|
6636
|
-
|
|
6637
|
-
});
|
|
6706
|
+
this.reconnect();
|
|
6707
|
+
}, { once: true });
|
|
6638
6708
|
}
|
|
6639
6709
|
else {
|
|
6640
|
-
|
|
6710
|
+
this.reconnect();
|
|
6641
6711
|
}
|
|
6642
6712
|
}
|
|
6643
6713
|
start() {
|
|
@@ -6661,6 +6731,7 @@
|
|
|
6661
6731
|
setProgress(percent) {
|
|
6662
6732
|
if (!this.element || !this.progressBarEnabled)
|
|
6663
6733
|
return;
|
|
6734
|
+
this.reconnect();
|
|
6664
6735
|
// Clamp between 0-100
|
|
6665
6736
|
percent = Math.min(100, Math.max(0, percent));
|
|
6666
6737
|
this.currentProgress = percent;
|
|
@@ -6709,41 +6780,41 @@
|
|
|
6709
6780
|
function createTargetSpinner() {
|
|
6710
6781
|
const spinner = document.createElement('div');
|
|
6711
6782
|
spinner.className = 'gyos-target-spinner';
|
|
6712
|
-
spinner.innerHTML = `
|
|
6713
|
-
<div class="gyos-spinner-content">
|
|
6714
|
-
<svg class="gyos-spinner-icon" viewBox="0 0 50 50">
|
|
6715
|
-
<circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="31.4 31.4" />
|
|
6716
|
-
</svg>
|
|
6717
|
-
</div>
|
|
6783
|
+
spinner.innerHTML = `
|
|
6784
|
+
<div class="gyos-spinner-content">
|
|
6785
|
+
<svg class="gyos-spinner-icon" viewBox="0 0 50 50">
|
|
6786
|
+
<circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="31.4 31.4" />
|
|
6787
|
+
</svg>
|
|
6788
|
+
</div>
|
|
6718
6789
|
`;
|
|
6719
6790
|
// Inject styles if not already present
|
|
6720
6791
|
if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
|
|
6721
6792
|
const style = document.createElement('style');
|
|
6722
6793
|
style.id = 'gyos-target-spinner-styles';
|
|
6723
|
-
style.textContent = `
|
|
6724
|
-
.gyos-target-spinner {
|
|
6725
|
-
display: flex;
|
|
6726
|
-
align-items: center;
|
|
6727
|
-
justify-content: center;
|
|
6728
|
-
padding: 20px;
|
|
6729
|
-
min-height: 60px;
|
|
6730
|
-
}
|
|
6731
|
-
.gyos-spinner-content {
|
|
6732
|
-
display: flex;
|
|
6733
|
-
align-items: center;
|
|
6734
|
-
gap: 10px;
|
|
6735
|
-
color: var(--gyos-spinner-color, #667eea);
|
|
6736
|
-
font-size: 14px;
|
|
6737
|
-
}
|
|
6738
|
-
.gyos-spinner-icon {
|
|
6739
|
-
width: 24px;
|
|
6740
|
-
height: 24px;
|
|
6741
|
-
animation: gyos-spin 1s linear infinite;
|
|
6742
|
-
}
|
|
6743
|
-
@keyframes gyos-spin {
|
|
6744
|
-
0% { transform: rotate(0deg); }
|
|
6745
|
-
100% { transform: rotate(360deg); }
|
|
6746
|
-
}
|
|
6794
|
+
style.textContent = `
|
|
6795
|
+
.gyos-target-spinner {
|
|
6796
|
+
display: flex;
|
|
6797
|
+
align-items: center;
|
|
6798
|
+
justify-content: center;
|
|
6799
|
+
padding: 20px;
|
|
6800
|
+
min-height: 60px;
|
|
6801
|
+
}
|
|
6802
|
+
.gyos-spinner-content {
|
|
6803
|
+
display: flex;
|
|
6804
|
+
align-items: center;
|
|
6805
|
+
gap: 10px;
|
|
6806
|
+
color: var(--gyos-spinner-color, #667eea);
|
|
6807
|
+
font-size: 14px;
|
|
6808
|
+
}
|
|
6809
|
+
.gyos-spinner-icon {
|
|
6810
|
+
width: 24px;
|
|
6811
|
+
height: 24px;
|
|
6812
|
+
animation: gyos-spin 1s linear infinite;
|
|
6813
|
+
}
|
|
6814
|
+
@keyframes gyos-spin {
|
|
6815
|
+
0% { transform: rotate(0deg); }
|
|
6816
|
+
100% { transform: rotate(360deg); }
|
|
6817
|
+
}
|
|
6747
6818
|
`;
|
|
6748
6819
|
document.head.appendChild(style);
|
|
6749
6820
|
}
|
|
@@ -7117,8 +7188,8 @@
|
|
|
7117
7188
|
}
|
|
7118
7189
|
result = target;
|
|
7119
7190
|
}
|
|
7120
|
-
await options.beforeScripts?.();
|
|
7121
7191
|
options.onCommitted?.(result, normalized === 'append' || normalized === 'prepend' ? incomingChildren : [result]);
|
|
7192
|
+
await options.beforeScripts?.();
|
|
7122
7193
|
// Additive swaps must not re-run scripts that already existed in the target.
|
|
7123
7194
|
if (normalized === 'append' || normalized === 'prepend') {
|
|
7124
7195
|
await executeScriptsInNodes(incomingChildren, options.signal);
|
|
@@ -7358,6 +7429,21 @@
|
|
|
7358
7429
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
7359
7430
|
}
|
|
7360
7431
|
|
|
7432
|
+
// A retained relative URL still identifies the resource loaded on its original
|
|
7433
|
+
// page, even after pushState changes document.baseURI.
|
|
7434
|
+
const resourceUrls = new WeakMap();
|
|
7435
|
+
function rememberResourceUrls(root, baseUrl) {
|
|
7436
|
+
root.querySelectorAll('script[src], link[href]').forEach(node => {
|
|
7437
|
+
const attribute = node.tagName === 'SCRIPT' ? 'src' : 'href';
|
|
7438
|
+
const source = node.getAttribute(attribute);
|
|
7439
|
+
if (resourceUrls.get(node)?.source === source)
|
|
7440
|
+
return;
|
|
7441
|
+
try {
|
|
7442
|
+
resourceUrls.set(node, { source, url: new URL(source, baseUrl).href });
|
|
7443
|
+
}
|
|
7444
|
+
catch { /* Invalid resource URLs retain their literal identity. */ }
|
|
7445
|
+
});
|
|
7446
|
+
}
|
|
7361
7447
|
function isNonceMeta(el) {
|
|
7362
7448
|
return el.tagName === 'META' && el.getAttribute('name')?.toLowerCase() === 'csp-nonce';
|
|
7363
7449
|
}
|
|
@@ -7375,7 +7461,20 @@
|
|
|
7375
7461
|
return;
|
|
7376
7462
|
if (context.csp && isNonceMeta(el) && attr.name.toLowerCase() === 'content')
|
|
7377
7463
|
return;
|
|
7378
|
-
|
|
7464
|
+
let value = attr.value;
|
|
7465
|
+
if ((el.tagName === 'SCRIPT' && attr.name === 'src') || (el.tagName === 'LINK' && attr.name === 'href')) {
|
|
7466
|
+
const cached = resourceUrls.get(el);
|
|
7467
|
+
if (cached?.source === value)
|
|
7468
|
+
value = cached.url;
|
|
7469
|
+
else {
|
|
7470
|
+
try {
|
|
7471
|
+
value = new URL(value, context.baseUrl || el.baseURI).href;
|
|
7472
|
+
resourceUrls.set(el, { source: attr.value, url: value });
|
|
7473
|
+
}
|
|
7474
|
+
catch { /* Keep invalid URLs distinct. */ }
|
|
7475
|
+
}
|
|
7476
|
+
}
|
|
7477
|
+
attributes.set(attr.name, value);
|
|
7379
7478
|
});
|
|
7380
7479
|
if (context.csp && usesCspNonce(el) && context.activeNonce) {
|
|
7381
7480
|
attributes.set('nonce', context.activeNonce);
|
|
@@ -7442,19 +7541,21 @@
|
|
|
7442
7541
|
console.warn('[GyosJS CSP] Skipped an inline MPA script because no active document nonce is configured.');
|
|
7443
7542
|
}
|
|
7444
7543
|
}
|
|
7445
|
-
async function diffNodes(currentNodes, nextNodes, container = document.head, signal) {
|
|
7544
|
+
async function diffNodes(currentNodes, nextNodes, container = document.head, signal, currentBaseUrl = document.baseURI) {
|
|
7446
7545
|
const csp = expressionRuntimeMode() === 'csp';
|
|
7447
7546
|
const context = {
|
|
7448
7547
|
csp,
|
|
7449
7548
|
activeNonce: csp ? resolveCspNonce() : undefined
|
|
7450
7549
|
};
|
|
7451
|
-
const current = keyedNodes(currentNodes, context);
|
|
7550
|
+
const current = keyedNodes(currentNodes, { ...context, baseUrl: currentBaseUrl });
|
|
7452
7551
|
const next = keyedNodes(nextNodes, context);
|
|
7552
|
+
const persistentKey = (node) => container === document.head ? node.getAttribute('g-head-persist') : null;
|
|
7553
|
+
const persistent = new Set(currentNodes.map(persistentKey).filter(Boolean));
|
|
7453
7554
|
const currentKeys = new Set(current.map(item => item.key));
|
|
7454
7555
|
const nextKeys = new Set(next.map(item => item.key));
|
|
7455
7556
|
// Remove nodes that are not in the new head
|
|
7456
7557
|
current.forEach(({ key, node }) => {
|
|
7457
|
-
if (!nextKeys.has(key)) {
|
|
7558
|
+
if (!nextKeys.has(key) && !persistentKey(node)) {
|
|
7458
7559
|
node.remove();
|
|
7459
7560
|
}
|
|
7460
7561
|
});
|
|
@@ -7462,6 +7563,8 @@
|
|
|
7462
7563
|
for (const { key, node } of next) {
|
|
7463
7564
|
if (signal?.aborted)
|
|
7464
7565
|
return;
|
|
7566
|
+
if (persistent.has(persistentKey(node)))
|
|
7567
|
+
continue;
|
|
7465
7568
|
if (!currentKeys.has(key)) {
|
|
7466
7569
|
if (!canInsertNode(node, context)) {
|
|
7467
7570
|
warnSkippedNode(node);
|
|
@@ -7664,6 +7767,7 @@
|
|
|
7664
7767
|
* MPA boost navigation inspired by Turbo Drive.
|
|
7665
7768
|
* Implements attribute-driven routing, snapshot caching, and persistent islands.
|
|
7666
7769
|
*/
|
|
7770
|
+
const submittingForms = new WeakSet();
|
|
7667
7771
|
const snapshots = new Map();
|
|
7668
7772
|
const preloadCache = new Map();
|
|
7669
7773
|
const preloadControllers = new Map();
|
|
@@ -7680,12 +7784,30 @@
|
|
|
7680
7784
|
let progressBar = null;
|
|
7681
7785
|
const beforeNavigate = [];
|
|
7682
7786
|
const afterNavigate = [];
|
|
7787
|
+
const beforeSwap = [];
|
|
7788
|
+
const navigationEnd = [];
|
|
7789
|
+
function registerNavigationHook(hooks, callback) {
|
|
7790
|
+
// A wrapper gives each registration its own unsubscribe identity.
|
|
7791
|
+
const entry = (url, context) => callback(url, context);
|
|
7792
|
+
hooks.push(entry);
|
|
7793
|
+
return () => {
|
|
7794
|
+
const index = hooks.indexOf(entry);
|
|
7795
|
+
if (index !== -1)
|
|
7796
|
+
hooks.splice(index, 1);
|
|
7797
|
+
};
|
|
7798
|
+
}
|
|
7683
7799
|
// Expose hooks to register before/after navigation callbacks
|
|
7684
7800
|
function onBeforeNavigate(callback) {
|
|
7685
|
-
beforeNavigate
|
|
7801
|
+
return registerNavigationHook(beforeNavigate, callback);
|
|
7686
7802
|
}
|
|
7687
7803
|
function onAfterNavigate(callback) {
|
|
7688
|
-
afterNavigate
|
|
7804
|
+
return registerNavigationHook(afterNavigate, callback);
|
|
7805
|
+
}
|
|
7806
|
+
function onBeforeSwap(callback) {
|
|
7807
|
+
return registerNavigationHook(beforeSwap, callback);
|
|
7808
|
+
}
|
|
7809
|
+
function onNavigationEnd(callback) {
|
|
7810
|
+
return registerNavigationHook(navigationEnd, (_url, context) => callback(context));
|
|
7689
7811
|
}
|
|
7690
7812
|
function startRouter(options) {
|
|
7691
7813
|
// If not has g-boost attribute, do not start router
|
|
@@ -7709,6 +7831,7 @@
|
|
|
7709
7831
|
}
|
|
7710
7832
|
// Cache scripts from initial page to prevent re-execution on first navigation back
|
|
7711
7833
|
cacheInitialPageScripts();
|
|
7834
|
+
rememberResourceUrls(document, document.baseURI);
|
|
7712
7835
|
routerStarted = true;
|
|
7713
7836
|
log('[GyosRouter] started');
|
|
7714
7837
|
}
|
|
@@ -7765,9 +7888,13 @@
|
|
|
7765
7888
|
const outlet = findGlobalOutlet();
|
|
7766
7889
|
return outlet instanceof HTMLElement ? outlet : null;
|
|
7767
7890
|
}
|
|
7891
|
+
function isFullDocument(html) {
|
|
7892
|
+
return /^\s*(?:<!--[^]*?-->\s*)*(?:<!doctype\s+html\b|<html(?:\s|>))/i.test(html);
|
|
7893
|
+
}
|
|
7768
7894
|
function saveSnapshot(url, html) {
|
|
7769
7895
|
// create HTMLElement by html string to remove scripts and get clean snapshot
|
|
7770
7896
|
const doc = parseNavigationDocument(html);
|
|
7897
|
+
doc.querySelectorAll('#gyos-progress-bar').forEach(node => node.remove());
|
|
7771
7898
|
// Ignore hash for snapshot keys
|
|
7772
7899
|
if (url.includes('#'))
|
|
7773
7900
|
url = url.split('#')[0];
|
|
@@ -7776,7 +7903,7 @@
|
|
|
7776
7903
|
if (s.hasAttribute('g-script-once'))
|
|
7777
7904
|
s.textContent = '';
|
|
7778
7905
|
});
|
|
7779
|
-
snapshots.set(url, { html: doc.documentElement.outerHTML });
|
|
7906
|
+
snapshots.set(url, { html: doc.documentElement.outerHTML, fullDocument: isFullDocument(html) });
|
|
7780
7907
|
log('[GyosRouter] snapshot saved for', url);
|
|
7781
7908
|
}
|
|
7782
7909
|
function getOutletIndex(root, target) {
|
|
@@ -7888,10 +8015,10 @@
|
|
|
7888
8015
|
// update callback remains the navigation source of truth and is awaited below.
|
|
7889
8016
|
void promise?.catch(() => undefined);
|
|
7890
8017
|
}
|
|
7891
|
-
function runNavigationHooks(callbacks, url) {
|
|
7892
|
-
callbacks.forEach(callback => {
|
|
8018
|
+
function runNavigationHooks(callbacks, url, context) {
|
|
8019
|
+
[...callbacks].forEach(callback => {
|
|
7893
8020
|
try {
|
|
7894
|
-
callback(url);
|
|
8021
|
+
callback(url, { ...context });
|
|
7895
8022
|
}
|
|
7896
8023
|
catch (error) {
|
|
7897
8024
|
console.error('[GyosRouter] navigation hook error', error);
|
|
@@ -7929,7 +8056,13 @@
|
|
|
7929
8056
|
url = mergeFormDataIntoUrl(url, opts.formData);
|
|
7930
8057
|
}
|
|
7931
8058
|
else {
|
|
7932
|
-
|
|
8059
|
+
if (opts.formEncoding === 'application/x-www-form-urlencoded') {
|
|
8060
|
+
const encoded = new URLSearchParams();
|
|
8061
|
+
opts.formData.forEach((value, name) => encoded.append(name, typeof value === 'string' ? value : value.name));
|
|
8062
|
+
init.body = encoded;
|
|
8063
|
+
}
|
|
8064
|
+
else
|
|
8065
|
+
init.body = opts.formData;
|
|
7933
8066
|
}
|
|
7934
8067
|
}
|
|
7935
8068
|
else if (opts.jsonData) {
|
|
@@ -7972,25 +8105,26 @@
|
|
|
7972
8105
|
preloadControllers.delete(cacheKey);
|
|
7973
8106
|
});
|
|
7974
8107
|
}
|
|
7975
|
-
async function updateHead(fromDoc, signal) {
|
|
8108
|
+
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
7976
8109
|
const allowedSelector = 'meta, link, style:not(#gyos-transitions), script';
|
|
7977
8110
|
const currentNodes = Array.from(document.head.querySelectorAll(allowedSelector));
|
|
7978
8111
|
const nextNodes = Array.from(fromDoc.head.querySelectorAll(allowedSelector));
|
|
7979
|
-
await diffNodes(currentNodes, nextNodes, document.head, signal);
|
|
8112
|
+
await diffNodes(currentNodes, nextNodes, document.head, signal, currentBaseUrl);
|
|
7980
8113
|
}
|
|
7981
|
-
async function scriptNotInOutletTarget(fromDoc, target, source, signal) {
|
|
8114
|
+
async function scriptNotInOutletTarget(fromDoc, target, source, signal, currentBaseUrl) {
|
|
7982
8115
|
// scripts in current document and it not in target outlet
|
|
7983
8116
|
const currentScripts = Array.from(document.scripts).filter(s => !target.contains(s) && !document.head.contains(s));
|
|
7984
8117
|
// scripts in fromDoc and it not in source outlet
|
|
7985
8118
|
const incomingScripts = Array.from(fromDoc.scripts).filter(s => !source.contains(s) && !fromDoc.head.contains(s));
|
|
7986
8119
|
// Diff and update scripts not in outlet/target
|
|
7987
|
-
await diffNodes(currentScripts, incomingScripts, document.body, signal);
|
|
8120
|
+
await diffNodes(currentScripts, incomingScripts, document.body, signal, currentBaseUrl);
|
|
7988
8121
|
}
|
|
7989
8122
|
function resolveIncomingScriptUrls(root, baseUrl) {
|
|
7990
|
-
root.querySelectorAll('script[src]').forEach(
|
|
7991
|
-
const
|
|
8123
|
+
root.querySelectorAll('script[src], link[href]').forEach(node => {
|
|
8124
|
+
const attribute = node.tagName === 'SCRIPT' ? 'src' : 'href';
|
|
8125
|
+
const source = node.getAttribute(attribute);
|
|
7992
8126
|
if (source)
|
|
7993
|
-
|
|
8127
|
+
node.setAttribute(attribute, new URL(source, baseUrl).href);
|
|
7994
8128
|
});
|
|
7995
8129
|
}
|
|
7996
8130
|
function isNavigableHtmlResponse(response) {
|
|
@@ -8044,6 +8178,22 @@
|
|
|
8044
8178
|
resolveDone
|
|
8045
8179
|
};
|
|
8046
8180
|
activeNavigation = transaction;
|
|
8181
|
+
const currentBaseUrl = document.baseURI;
|
|
8182
|
+
rememberResourceUrls(document, currentBaseUrl);
|
|
8183
|
+
const context = {
|
|
8184
|
+
from: currentUrl, url: opts.url, method: opts.method.toUpperCase(),
|
|
8185
|
+
trigger: opts.trigger || null, target: null, form: opts.form || null,
|
|
8186
|
+
popstate: opts.popstate === true, signal: transaction.controller.signal,
|
|
8187
|
+
status: null, committed: false, fallback: false, outcome: null
|
|
8188
|
+
};
|
|
8189
|
+
const formEvent = opts.form
|
|
8190
|
+
? { form: opts.form, url: opts.url, status: null, outcome: null, committed: false, fallback: false }
|
|
8191
|
+
: null;
|
|
8192
|
+
const fallback = (url, requestSent) => {
|
|
8193
|
+
context.fallback = context.method === 'GET' || (!requestSent && !!opts.form);
|
|
8194
|
+
context.outcome ?? (context.outcome = context.fallback ? 'fallback' : 'invalid-response');
|
|
8195
|
+
fallbackFromBoost(opts, url, requestSent);
|
|
8196
|
+
};
|
|
8047
8197
|
const hasTargetSpinner = opts.trigger?.hasAttribute('g-router-spin');
|
|
8048
8198
|
const setRand = () => {
|
|
8049
8199
|
if (isActiveNavigation(transaction) && progressBar?.getCurrentProgress() < 70) {
|
|
@@ -8051,7 +8201,10 @@
|
|
|
8051
8201
|
}
|
|
8052
8202
|
};
|
|
8053
8203
|
try {
|
|
8054
|
-
|
|
8204
|
+
if (formEvent)
|
|
8205
|
+
document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
|
|
8206
|
+
runNavigationHooks(beforeNavigate, opts.url, context);
|
|
8207
|
+
assertActiveNavigation(transaction);
|
|
8055
8208
|
progressBar?.start();
|
|
8056
8209
|
// popstate already points history at the destination entry. Keep the visible
|
|
8057
8210
|
// page's position under currentUrl without overwriting that destination state.
|
|
@@ -8060,9 +8213,10 @@
|
|
|
8060
8213
|
saveScrollPosition();
|
|
8061
8214
|
// Pick target element to swap
|
|
8062
8215
|
let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
|
|
8216
|
+
context.target = target;
|
|
8063
8217
|
if (!target) {
|
|
8064
8218
|
if (isActiveNavigation(transaction))
|
|
8065
|
-
|
|
8219
|
+
fallback(opts.url, false);
|
|
8066
8220
|
return;
|
|
8067
8221
|
}
|
|
8068
8222
|
const swapMode = (opts.swapMode || opts.trigger?.getAttribute('g-swap') || 'inner').toLowerCase();
|
|
@@ -8087,6 +8241,7 @@
|
|
|
8087
8241
|
if (hasTargetSpinner)
|
|
8088
8242
|
transaction.spinner = showTargetSpinner(target, swapMode);
|
|
8089
8243
|
const { finalUrl, init } = buildRequest(opts);
|
|
8244
|
+
context.url = finalUrl;
|
|
8090
8245
|
// Add abort signal to request
|
|
8091
8246
|
init.signal = transaction.controller.signal;
|
|
8092
8247
|
let html;
|
|
@@ -8114,7 +8269,8 @@
|
|
|
8114
8269
|
if (error.name === 'AbortError')
|
|
8115
8270
|
throw error;
|
|
8116
8271
|
assertActiveNavigation(transaction);
|
|
8117
|
-
|
|
8272
|
+
context.outcome = 'network-error';
|
|
8273
|
+
fallback(finalUrl, true);
|
|
8118
8274
|
return;
|
|
8119
8275
|
}
|
|
8120
8276
|
preloadCache.delete(preloadKey); // consume cache
|
|
@@ -8139,28 +8295,46 @@
|
|
|
8139
8295
|
log('[GyosRouter] Navigation cancelled');
|
|
8140
8296
|
return;
|
|
8141
8297
|
}
|
|
8298
|
+
context.outcome = 'network-error';
|
|
8142
8299
|
if (isActiveNavigation(transaction))
|
|
8143
|
-
|
|
8300
|
+
fallback(finalUrl, true);
|
|
8144
8301
|
return;
|
|
8145
8302
|
}
|
|
8146
8303
|
}
|
|
8147
8304
|
assertActiveNavigation(transaction);
|
|
8148
|
-
|
|
8149
|
-
|
|
8305
|
+
context.status = response?.status ?? null;
|
|
8306
|
+
context.url = response?.url || finalUrl;
|
|
8307
|
+
const acceptedErrors = (opts.trigger?.getAttribute('g-boost-errors') || '').split(/[\s,]+/);
|
|
8308
|
+
const renderHttpError = !!response && response.status >= 400 && response.status <= 599
|
|
8309
|
+
&& acceptedErrors.includes(String(response.status));
|
|
8310
|
+
if (response && !response.ok)
|
|
8311
|
+
context.outcome = 'http-error';
|
|
8312
|
+
if (!response || (!response.ok && !renderHttpError) || !isNavigableHtmlResponse(response)) {
|
|
8313
|
+
context.outcome ?? (context.outcome = 'invalid-response');
|
|
8150
8314
|
if (isActiveNavigation(transaction))
|
|
8151
|
-
|
|
8315
|
+
fallback(finalUrl, true);
|
|
8152
8316
|
return;
|
|
8153
8317
|
}
|
|
8154
8318
|
html = await response.text();
|
|
8155
8319
|
assertActiveNavigation(transaction);
|
|
8156
|
-
if (!opts.popstate && target.hasAttribute('g-snapshot')) {
|
|
8157
|
-
saveSnapshot(canonicalUrl(response.url || finalUrl), html);
|
|
8158
|
-
}
|
|
8159
8320
|
}
|
|
8160
8321
|
// Parse HTML
|
|
8161
8322
|
const doc = html
|
|
8162
8323
|
? parseNavigationDocument(html)
|
|
8163
8324
|
: document.implementation.createHTMLDocument();
|
|
8325
|
+
// Detached parsing cannot tell whether the live CSP permits an incoming base.
|
|
8326
|
+
// Let native navigation enforce base-uri instead of authorizing its URLs ourselves.
|
|
8327
|
+
if (doc.querySelector('base[href]') || opts.historyFragment?.querySelector('base[href]')) {
|
|
8328
|
+
context.outcome = 'invalid-response';
|
|
8329
|
+
fallback(response?.url || finalUrl, true);
|
|
8330
|
+
return;
|
|
8331
|
+
}
|
|
8332
|
+
if (response?.ok && !opts.popstate && target.hasAttribute('g-snapshot')) {
|
|
8333
|
+
saveSnapshot(canonicalUrl(response.url || finalUrl), html);
|
|
8334
|
+
}
|
|
8335
|
+
const syncDocumentAttributes = isFullOutletNavigation && destructiveSwap && !currentHead
|
|
8336
|
+
&& !opts.historyFragment && (opts.popstate && snapshots.has(urlWithoutHash)
|
|
8337
|
+
? snapshots.get(urlWithoutHash).fullDocument : isFullDocument(html || ''));
|
|
8164
8338
|
// Pick source fragment
|
|
8165
8339
|
const src = opts.historyFragment || pickSourceFragment(doc, target, targetOutletIndex);
|
|
8166
8340
|
stripInertFallbackContent(src);
|
|
@@ -8172,15 +8346,18 @@
|
|
|
8172
8346
|
targetUrl += finalUrl.substring(finalUrl.indexOf('#'));
|
|
8173
8347
|
}
|
|
8174
8348
|
resolveIncomingScriptUrls(doc, targetUrl);
|
|
8349
|
+
context.url = targetUrl;
|
|
8175
8350
|
if (opts.historyFragment)
|
|
8176
8351
|
resolveIncomingScriptUrls(src, targetUrl);
|
|
8177
8352
|
const triggerChangesState = opts.trigger?.hasAttribute('g-change-state') || false;
|
|
8178
8353
|
const keepsCurrentState = opts.trigger?.hasAttribute('g-current-state') || false;
|
|
8179
8354
|
const redirectedSubmission = opts.method.toUpperCase() !== 'GET' && response?.redirected === true;
|
|
8180
|
-
const changesState = !keepsCurrentState && (opts.changeState === true || triggerChangesState || redirectedSubmission);
|
|
8355
|
+
const changesState = context.outcome !== 'http-error' && !keepsCurrentState && (opts.changeState === true || triggerChangesState || redirectedSubmission);
|
|
8181
8356
|
const performUpdate = async () => {
|
|
8182
8357
|
assertActiveNavigation(transaction);
|
|
8183
8358
|
transaction.committing = true;
|
|
8359
|
+
runNavigationHooks(beforeSwap, targetUrl, context);
|
|
8360
|
+
assertActiveNavigation(transaction);
|
|
8184
8361
|
// Update progress to rand 80 - 90% before swap
|
|
8185
8362
|
progressBar?.setProgress(Math.random() * 10 + 80);
|
|
8186
8363
|
const outgoingHistoryFragment = changesState && !opts.replace && !isFullOutletNavigation
|
|
@@ -8251,21 +8428,34 @@
|
|
|
8251
8428
|
beforeScripts: async () => {
|
|
8252
8429
|
if (!isFullOutletNavigation || currentHead)
|
|
8253
8430
|
return;
|
|
8431
|
+
if (syncDocumentAttributes) {
|
|
8432
|
+
for (const name of ['lang', 'dir']) {
|
|
8433
|
+
const value = doc.documentElement.getAttribute(name);
|
|
8434
|
+
if (value === null)
|
|
8435
|
+
document.documentElement.removeAttribute(name);
|
|
8436
|
+
else
|
|
8437
|
+
document.documentElement.setAttribute(name, value);
|
|
8438
|
+
}
|
|
8439
|
+
}
|
|
8254
8440
|
const incomingTitle = doc.querySelector('title');
|
|
8255
8441
|
if (incomingTitle) {
|
|
8256
8442
|
document.title = incomingTitle.textContent || document.title;
|
|
8257
8443
|
}
|
|
8258
|
-
await updateHead(doc, transaction.controller.signal);
|
|
8444
|
+
await updateHead(doc, transaction.controller.signal, currentBaseUrl);
|
|
8259
8445
|
assertActiveNavigation(transaction);
|
|
8260
8446
|
},
|
|
8261
8447
|
onCommitted: (committedTarget, roots) => {
|
|
8262
8448
|
target = committedTarget;
|
|
8449
|
+
context.target = committedTarget;
|
|
8450
|
+
context.committed = true;
|
|
8451
|
+
progressBar?.reconnect();
|
|
8263
8452
|
committedRoots = roots;
|
|
8264
8453
|
}
|
|
8265
8454
|
});
|
|
8455
|
+
context.committed = true;
|
|
8266
8456
|
assertActiveNavigation(transaction);
|
|
8267
8457
|
if (isFullOutletNavigation) {
|
|
8268
|
-
await scriptNotInOutletTarget(doc, target, src, transaction.controller.signal);
|
|
8458
|
+
await scriptNotInOutletTarget(doc, target, src, transaction.controller.signal, currentBaseUrl);
|
|
8269
8459
|
assertActiveNavigation(transaction);
|
|
8270
8460
|
}
|
|
8271
8461
|
}
|
|
@@ -8299,14 +8489,15 @@
|
|
|
8299
8489
|
await performUpdate();
|
|
8300
8490
|
}
|
|
8301
8491
|
assertActiveNavigation(transaction);
|
|
8302
|
-
if (removeTriggerAfterCommit && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
|
|
8492
|
+
if (removeTriggerAfterCommit && context.outcome !== 'http-error' && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
|
|
8303
8493
|
disposeEffects(opts.trigger);
|
|
8304
8494
|
opts.trigger.remove();
|
|
8305
8495
|
}
|
|
8306
8496
|
if (hasTargetSpinner)
|
|
8307
8497
|
hideTargetSpinner(transaction.spinner);
|
|
8308
8498
|
transaction.spinner = null;
|
|
8309
|
-
|
|
8499
|
+
context.outcome ?? (context.outcome = 'success');
|
|
8500
|
+
runNavigationHooks(afterNavigate, targetUrl, context);
|
|
8310
8501
|
log('[GyosRouter] navigated to', targetUrl);
|
|
8311
8502
|
currentUrl = changesState
|
|
8312
8503
|
? canonicalUrl(targetUrl, true)
|
|
@@ -8322,11 +8513,15 @@
|
|
|
8322
8513
|
return;
|
|
8323
8514
|
}
|
|
8324
8515
|
if (isActiveNavigation(transaction)) {
|
|
8516
|
+
context.outcome ?? (context.outcome = 'error');
|
|
8325
8517
|
console.error('[GyosRouter] navigation error', error);
|
|
8326
|
-
|
|
8518
|
+
fallback(opts.url, true);
|
|
8327
8519
|
}
|
|
8328
8520
|
}
|
|
8329
8521
|
finally {
|
|
8522
|
+
if (transaction.controller.signal.aborted)
|
|
8523
|
+
context.outcome = 'aborted';
|
|
8524
|
+
context.outcome ?? (context.outcome = 'aborted');
|
|
8330
8525
|
if (transaction.interval)
|
|
8331
8526
|
clearInterval(transaction.interval);
|
|
8332
8527
|
if (transaction.spinner)
|
|
@@ -8336,6 +8531,15 @@
|
|
|
8336
8531
|
progressBar?.complete();
|
|
8337
8532
|
}
|
|
8338
8533
|
transaction.resolveDone();
|
|
8534
|
+
if (formEvent)
|
|
8535
|
+
submittingForms.delete(formEvent.form);
|
|
8536
|
+
runNavigationHooks(navigationEnd, context.url, context);
|
|
8537
|
+
if (formEvent) {
|
|
8538
|
+
const { url, status, outcome, committed, fallback } = context;
|
|
8539
|
+
document.dispatchEvent(new CustomEvent('gyos:form-end', {
|
|
8540
|
+
detail: { ...formEvent, url, status, outcome, committed, fallback }
|
|
8541
|
+
}));
|
|
8542
|
+
}
|
|
8339
8543
|
}
|
|
8340
8544
|
}
|
|
8341
8545
|
function shouldBoost(el) {
|
|
@@ -8444,16 +8648,34 @@
|
|
|
8444
8648
|
return;
|
|
8445
8649
|
if (shouldDeferToFormValidation(form))
|
|
8446
8650
|
return;
|
|
8447
|
-
event.
|
|
8448
|
-
const
|
|
8449
|
-
const
|
|
8450
|
-
const
|
|
8451
|
-
|
|
8452
|
-
|
|
8651
|
+
const submitter = event.submitter;
|
|
8652
|
+
const override = (name) => submitter?.getAttribute(`form${name}`) ?? form.getAttribute(name);
|
|
8653
|
+
const target = override('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
8654
|
+
const declaredMethod = (override('method') || 'GET').toUpperCase();
|
|
8655
|
+
const method = ['GET', 'POST', 'DIALOG'].includes(declaredMethod) ? declaredMethod : 'GET';
|
|
8656
|
+
const formEncoding = override('enctype')?.toLowerCase();
|
|
8657
|
+
if ((target && target.toLowerCase() !== '_self') || method === 'DIALOG' || formEncoding === 'text/plain')
|
|
8658
|
+
return;
|
|
8659
|
+
if (!resolveTarget(form))
|
|
8453
8660
|
return;
|
|
8661
|
+
// Image submitters carry click coordinates which SubmitEvent does not expose.
|
|
8662
|
+
if (submitter instanceof HTMLInputElement && submitter.type === 'image')
|
|
8663
|
+
return;
|
|
8664
|
+
let url;
|
|
8665
|
+
try {
|
|
8666
|
+
url = new URL(override('action') || window.location.href, document.baseURI);
|
|
8454
8667
|
}
|
|
8455
|
-
|
|
8456
|
-
|
|
8668
|
+
catch {
|
|
8669
|
+
return;
|
|
8670
|
+
}
|
|
8671
|
+
if (url.origin !== window.location.origin)
|
|
8672
|
+
return;
|
|
8673
|
+
event.preventDefault();
|
|
8674
|
+
if (submittingForms.has(form))
|
|
8675
|
+
return;
|
|
8676
|
+
const formData = new FormData(form, submitter);
|
|
8677
|
+
submittingForms.add(form);
|
|
8678
|
+
void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
|
|
8457
8679
|
}
|
|
8458
8680
|
function onPopState(event) {
|
|
8459
8681
|
const url = window.location.href;
|
|
@@ -8558,23 +8780,25 @@
|
|
|
8558
8780
|
startRouter,
|
|
8559
8781
|
onBeforeNavigate,
|
|
8560
8782
|
onAfterNavigate,
|
|
8783
|
+
onBeforeSwap,
|
|
8784
|
+
onNavigationEnd,
|
|
8561
8785
|
portalCreate,
|
|
8562
8786
|
portalDestroy,
|
|
8563
8787
|
setCspNonce,
|
|
8564
|
-
version: '0.
|
|
8788
|
+
version: '0.4.1'
|
|
8565
8789
|
};
|
|
8566
8790
|
|
|
8567
8791
|
// This file was generated. Do not modify manually!
|
|
8568
|
-
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1,
|
|
8792
|
+
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 78, 5, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 266, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
8569
8793
|
|
|
8570
8794
|
// This file was generated. Do not modify manually!
|
|
8571
|
-
var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25,
|
|
8795
|
+
var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 7, 25, 39, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 5, 57, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 24, 43, 261, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 33, 24, 3, 24, 45, 74, 6, 0, 67, 12, 65, 1, 2, 0, 15, 4, 10, 7381, 42, 31, 98, 114, 8702, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 208, 30, 2, 2, 2, 1, 2, 6, 3, 4, 10, 1, 225, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4381, 3, 5773, 3, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 8489];
|
|
8572
8796
|
|
|
8573
8797
|
// This file was generated. Do not modify manually!
|
|
8574
|
-
var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\
|
|
8798
|
+
var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1add\u1ae0-\u1aeb\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
|
|
8575
8799
|
|
|
8576
8800
|
// This file was generated. Do not modify manually!
|
|
8577
|
-
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\
|
|
8801
|
+
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088f\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5c\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdc-\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7dc\ua7f1-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
|
|
8578
8802
|
|
|
8579
8803
|
// These are a run-length and offset encoded representation of the
|
|
8580
8804
|
// >0xffff code points that are a valid part of identifiers. The
|
|
@@ -8899,9 +9123,12 @@
|
|
|
8899
9123
|
// for new syntax features.
|
|
8900
9124
|
ecmaVersion: null,
|
|
8901
9125
|
// `sourceType` indicates the mode the code should be parsed in.
|
|
8902
|
-
// Can be either `"script"` or `"
|
|
9126
|
+
// Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
|
|
8903
9127
|
// strict mode and parsing of `import` and `export` declarations.
|
|
8904
9128
|
sourceType: "script",
|
|
9129
|
+
// When set to true, enable strict parsing mode even if `sourceType`
|
|
9130
|
+
// is `"script"`.
|
|
9131
|
+
strict: false,
|
|
8905
9132
|
// `onInsertedSemicolon` can be a callback that will be called when
|
|
8906
9133
|
// a semicolon is automatically inserted. It will be passed the
|
|
8907
9134
|
// position of the inserted semicolon as an offset, and if
|
|
@@ -8943,6 +9170,11 @@
|
|
|
8943
9170
|
// line being 1-based and column 0-based) will be attached to the
|
|
8944
9171
|
// nodes.
|
|
8945
9172
|
locations: false,
|
|
9173
|
+
// Pass an optional `{line, column}` object to use for the start of
|
|
9174
|
+
// the parse. This is mostly useful when using `parseExpressionAt`
|
|
9175
|
+
// with `locations: true`, to prevent the parser from having to
|
|
9176
|
+
// determine the line position at the start position.
|
|
9177
|
+
startLocation: null,
|
|
8946
9178
|
// A function can be passed as `onToken` option, which will
|
|
8947
9179
|
// cause Acorn to call that function with object in the same
|
|
8948
9180
|
// format as tokens returned from `tokenizer().getToken()`. Note
|
|
@@ -9023,6 +9255,9 @@
|
|
|
9023
9255
|
if (isArray(options.onComment))
|
|
9024
9256
|
{ options.onComment = pushComment(options, options.onComment); }
|
|
9025
9257
|
|
|
9258
|
+
if (options.sourceType === "commonjs" && options.allowAwaitOutsideFunction)
|
|
9259
|
+
{ throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs") }
|
|
9260
|
+
|
|
9026
9261
|
return options
|
|
9027
9262
|
}
|
|
9028
9263
|
|
|
@@ -9054,6 +9289,7 @@
|
|
|
9054
9289
|
SCOPE_DIRECT_SUPER = 128,
|
|
9055
9290
|
SCOPE_CLASS_STATIC_BLOCK = 256,
|
|
9056
9291
|
SCOPE_CLASS_FIELD_INIT = 512,
|
|
9292
|
+
SCOPE_SWITCH = 1024,
|
|
9057
9293
|
SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
|
|
9058
9294
|
|
|
9059
9295
|
function functionFlags(async, generator) {
|
|
@@ -9092,13 +9328,17 @@
|
|
|
9092
9328
|
// Set up token state
|
|
9093
9329
|
|
|
9094
9330
|
// The current position of the tokenizer in the input.
|
|
9095
|
-
|
|
9096
|
-
|
|
9331
|
+
this.pos = startPos || 0;
|
|
9332
|
+
this.curLine = 1;
|
|
9333
|
+
if (options.startLocation) {
|
|
9334
|
+
this.lineStart = this.pos - options.startLocation.column;
|
|
9335
|
+
this.curLine = options.startLocation.line;
|
|
9336
|
+
} else if (startPos) {
|
|
9097
9337
|
this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
|
|
9098
|
-
|
|
9338
|
+
if (this.options.locations)
|
|
9339
|
+
{ this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; }
|
|
9099
9340
|
} else {
|
|
9100
|
-
this.
|
|
9101
|
-
this.curLine = 1;
|
|
9341
|
+
this.lineStart = 0;
|
|
9102
9342
|
}
|
|
9103
9343
|
|
|
9104
9344
|
// Properties of the current token:
|
|
@@ -9124,7 +9364,7 @@
|
|
|
9124
9364
|
|
|
9125
9365
|
// Figure out if it's a module code.
|
|
9126
9366
|
this.inModule = options.sourceType === "module";
|
|
9127
|
-
this.strict = this.inModule || this.strictDirective(this.pos);
|
|
9367
|
+
this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
|
|
9128
9368
|
|
|
9129
9369
|
// Used to signify the start of a potential arrow function
|
|
9130
9370
|
this.potentialArrowAt = -1;
|
|
@@ -9143,7 +9383,12 @@
|
|
|
9143
9383
|
|
|
9144
9384
|
// Scope tracking for duplicate variable names (see scope.js)
|
|
9145
9385
|
this.scopeStack = [];
|
|
9146
|
-
this.enterScope(
|
|
9386
|
+
this.enterScope(
|
|
9387
|
+
this.options.sourceType === "commonjs"
|
|
9388
|
+
// In commonjs, the top-level scope behaves like a function scope
|
|
9389
|
+
? SCOPE_FUNCTION
|
|
9390
|
+
: SCOPE_TOP
|
|
9391
|
+
);
|
|
9147
9392
|
|
|
9148
9393
|
// For RegExp validation
|
|
9149
9394
|
this.regexpState = null;
|
|
@@ -9154,12 +9399,14 @@
|
|
|
9154
9399
|
this.privateNameStack = [];
|
|
9155
9400
|
};
|
|
9156
9401
|
|
|
9157
|
-
var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } };
|
|
9402
|
+
var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowReturn: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },allowUsing: { configurable: true },inClassStaticBlock: { configurable: true } };
|
|
9158
9403
|
|
|
9159
9404
|
Parser.prototype.parse = function parse () {
|
|
9405
|
+
var this$1$1 = this;
|
|
9406
|
+
|
|
9160
9407
|
var node = this.options.program || this.startNode();
|
|
9161
9408
|
this.nextToken();
|
|
9162
|
-
return this.parseTopLevel(node)
|
|
9409
|
+
return this.catchStackOverflow(function () { return this$1$1.parseTopLevel(node); })
|
|
9163
9410
|
};
|
|
9164
9411
|
|
|
9165
9412
|
prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
|
|
@@ -9178,6 +9425,12 @@
|
|
|
9178
9425
|
return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
|
|
9179
9426
|
};
|
|
9180
9427
|
|
|
9428
|
+
prototypeAccessors.allowReturn.get = function () {
|
|
9429
|
+
if (this.inFunction) { return true }
|
|
9430
|
+
if (this.options.allowReturnOutsideFunction && this.currentVarScope().flags & SCOPE_TOP) { return true }
|
|
9431
|
+
return false
|
|
9432
|
+
};
|
|
9433
|
+
|
|
9181
9434
|
prototypeAccessors.allowSuper.get = function () {
|
|
9182
9435
|
var ref = this.currentThisScope();
|
|
9183
9436
|
var flags = ref.flags;
|
|
@@ -9198,6 +9451,14 @@
|
|
|
9198
9451
|
return false
|
|
9199
9452
|
};
|
|
9200
9453
|
|
|
9454
|
+
prototypeAccessors.allowUsing.get = function () {
|
|
9455
|
+
var ref = this.currentScope();
|
|
9456
|
+
var flags = ref.flags;
|
|
9457
|
+
if (flags & SCOPE_SWITCH) { return false }
|
|
9458
|
+
if (!this.inModule && flags & SCOPE_TOP) { return false }
|
|
9459
|
+
return true
|
|
9460
|
+
};
|
|
9461
|
+
|
|
9201
9462
|
prototypeAccessors.inClassStaticBlock.get = function () {
|
|
9202
9463
|
return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
|
|
9203
9464
|
};
|
|
@@ -9284,6 +9545,17 @@
|
|
|
9284
9545
|
return true
|
|
9285
9546
|
};
|
|
9286
9547
|
|
|
9548
|
+
pp$9.catchStackOverflow = function(f) {
|
|
9549
|
+
try {
|
|
9550
|
+
return f()
|
|
9551
|
+
} catch (e) {
|
|
9552
|
+
if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message)))
|
|
9553
|
+
{ this.raise(this.start, "Not enough stack space to parse input"); }
|
|
9554
|
+
else
|
|
9555
|
+
{ throw e }
|
|
9556
|
+
}
|
|
9557
|
+
};
|
|
9558
|
+
|
|
9287
9559
|
// Asserts that following token is given contextual keyword.
|
|
9288
9560
|
|
|
9289
9561
|
pp$9.expectContextual = function(name) {
|
|
@@ -9387,10 +9659,10 @@
|
|
|
9387
9659
|
// to its body instead of creating a new node.
|
|
9388
9660
|
|
|
9389
9661
|
pp$8.parseTopLevel = function(node) {
|
|
9390
|
-
var exports = Object.create(null);
|
|
9662
|
+
var exports$1 = Object.create(null);
|
|
9391
9663
|
if (!node.body) { node.body = []; }
|
|
9392
9664
|
while (this.type !== types$1.eof) {
|
|
9393
|
-
var stmt = this.parseStatement(null, true, exports);
|
|
9665
|
+
var stmt = this.parseStatement(null, true, exports$1);
|
|
9394
9666
|
node.body.push(stmt);
|
|
9395
9667
|
}
|
|
9396
9668
|
if (this.inModule)
|
|
@@ -9402,7 +9674,7 @@
|
|
|
9402
9674
|
} }
|
|
9403
9675
|
this.adaptDirectivePrologue(node.body);
|
|
9404
9676
|
this.next();
|
|
9405
|
-
node.sourceType = this.options.sourceType;
|
|
9677
|
+
node.sourceType = this.options.sourceType === "commonjs" ? "script" : this.options.sourceType;
|
|
9406
9678
|
return this.finishNode(node, "Program")
|
|
9407
9679
|
};
|
|
9408
9680
|
|
|
@@ -9412,7 +9684,7 @@
|
|
|
9412
9684
|
if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
|
|
9413
9685
|
skipWhiteSpace.lastIndex = this.pos;
|
|
9414
9686
|
var skip = skipWhiteSpace.exec(this.input);
|
|
9415
|
-
var next = this.pos + skip[0].length, nextCh = this.
|
|
9687
|
+
var next = this.pos + skip[0].length, nextCh = this.fullCharCodeAt(next);
|
|
9416
9688
|
// For ambiguous cases, determine if a LexicalDeclaration (or only a
|
|
9417
9689
|
// Statement) is allowed here. If context is not empty then only a Statement
|
|
9418
9690
|
// is allowed. However, `let [` is an explicit negative lookahead for
|
|
@@ -9420,12 +9692,13 @@
|
|
|
9420
9692
|
if (nextCh === 91 || nextCh === 92) { return true } // '[', '\'
|
|
9421
9693
|
if (context) { return false }
|
|
9422
9694
|
|
|
9423
|
-
if (nextCh === 123
|
|
9424
|
-
if (isIdentifierStart(nextCh
|
|
9425
|
-
var
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9695
|
+
if (nextCh === 123) { return true } // '{'
|
|
9696
|
+
if (isIdentifierStart(nextCh)) {
|
|
9697
|
+
var start = next;
|
|
9698
|
+
do { next += nextCh <= 0xffff ? 1 : 2; }
|
|
9699
|
+
while (isIdentifierChar(nextCh = this.fullCharCodeAt(next)))
|
|
9700
|
+
if (nextCh === 92) { return true }
|
|
9701
|
+
var ident = this.input.slice(start, next);
|
|
9429
9702
|
if (!keywordRelationalOperator.test(ident)) { return true }
|
|
9430
9703
|
}
|
|
9431
9704
|
return false
|
|
@@ -9444,7 +9717,7 @@
|
|
|
9444
9717
|
return !lineBreak.test(this.input.slice(this.pos, next)) &&
|
|
9445
9718
|
this.input.slice(next, next + 8) === "function" &&
|
|
9446
9719
|
(next + 8 === this.input.length ||
|
|
9447
|
-
!(isIdentifierChar(after = this.
|
|
9720
|
+
!(isIdentifierChar(after = this.fullCharCodeAt(next + 8)) || after === 92 /* '\' */))
|
|
9448
9721
|
};
|
|
9449
9722
|
|
|
9450
9723
|
pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
|
|
@@ -9458,28 +9731,39 @@
|
|
|
9458
9731
|
if (lineBreak.test(this.input.slice(this.pos, next))) { return false }
|
|
9459
9732
|
|
|
9460
9733
|
if (isAwaitUsing) {
|
|
9461
|
-
var
|
|
9462
|
-
if (this.input.slice(next,
|
|
9463
|
-
|
|
9464
|
-
isIdentifierChar(after = this.
|
|
9465
|
-
|
|
9734
|
+
var usingEndPos = next + 5 /* using */, after;
|
|
9735
|
+
if (this.input.slice(next, usingEndPos) !== "using" ||
|
|
9736
|
+
usingEndPos === this.input.length ||
|
|
9737
|
+
isIdentifierChar(after = this.fullCharCodeAt(usingEndPos)) ||
|
|
9738
|
+
after === 92 /* '\' */
|
|
9466
9739
|
) { return false }
|
|
9467
9740
|
|
|
9468
|
-
skipWhiteSpace.lastIndex =
|
|
9741
|
+
skipWhiteSpace.lastIndex = usingEndPos;
|
|
9469
9742
|
var skipAfterUsing = skipWhiteSpace.exec(this.input);
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9743
|
+
next = usingEndPos + skipAfterUsing[0].length;
|
|
9744
|
+
if (skipAfterUsing && lineBreak.test(this.input.slice(usingEndPos, next))) { return false }
|
|
9745
|
+
}
|
|
9746
|
+
|
|
9747
|
+
var ch = this.fullCharCodeAt(next);
|
|
9748
|
+
if (!isIdentifierStart(ch) && ch !== 92 /* '\' */) { return false }
|
|
9749
|
+
var idStart = next;
|
|
9750
|
+
do { next += ch <= 0xffff ? 1 : 2; }
|
|
9751
|
+
while (isIdentifierChar(ch = this.fullCharCodeAt(next)))
|
|
9752
|
+
if (ch === 92) { return true }
|
|
9753
|
+
var id = this.input.slice(idStart, next);
|
|
9754
|
+
if (keywordRelationalOperator.test(id)) { return false }
|
|
9755
|
+
if (isFor && !isAwaitUsing && id === "of") {
|
|
9756
|
+
// Look ahead for using declaration with initializer, i.e., `for (using of = ...)`
|
|
9757
|
+
skipWhiteSpace.lastIndex = next;
|
|
9758
|
+
var skipAfterOf = skipWhiteSpace.exec(this.input);
|
|
9759
|
+
next = next + skipAfterOf[0].length;
|
|
9760
|
+
if (this.input.charCodeAt(next) !== 61 /* '=' */ ||
|
|
9761
|
+
// Check for ==, === and => operators
|
|
9762
|
+
(ch = this.input.charCodeAt(next + 1)) === 61 /* '=' */ || ch === 62 /* '>' */) {
|
|
9763
|
+
return false
|
|
9478
9764
|
}
|
|
9479
9765
|
}
|
|
9480
|
-
|
|
9481
|
-
var ch = this.input.charCodeAt(next);
|
|
9482
|
-
return isIdentifierStart(ch, true) || ch === 92 // '\'
|
|
9766
|
+
return true
|
|
9483
9767
|
};
|
|
9484
9768
|
|
|
9485
9769
|
pp$8.isAwaitUsing = function(isFor) {
|
|
@@ -9497,7 +9781,7 @@
|
|
|
9497
9781
|
// `if (foo) /blah/.exec(foo)`, where looking at the previous token
|
|
9498
9782
|
// does not help.
|
|
9499
9783
|
|
|
9500
|
-
pp$8.parseStatement = function(context, topLevel, exports) {
|
|
9784
|
+
pp$8.parseStatement = function(context, topLevel, exports$1) {
|
|
9501
9785
|
var starttype = this.type, node = this.startNode(), kind;
|
|
9502
9786
|
|
|
9503
9787
|
if (this.isLet(context)) {
|
|
@@ -9552,7 +9836,7 @@
|
|
|
9552
9836
|
if (!this.inModule)
|
|
9553
9837
|
{ this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
|
|
9554
9838
|
}
|
|
9555
|
-
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
|
|
9839
|
+
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1)
|
|
9556
9840
|
|
|
9557
9841
|
// If the statement does not start with a statement keyword or a
|
|
9558
9842
|
// brace, it's an ExpressionStatement or LabeledStatement. We
|
|
@@ -9568,8 +9852,12 @@
|
|
|
9568
9852
|
|
|
9569
9853
|
var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null;
|
|
9570
9854
|
if (usingKind) {
|
|
9571
|
-
if (
|
|
9572
|
-
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`");
|
|
9855
|
+
if (!this.allowUsing) {
|
|
9856
|
+
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
|
|
9857
|
+
}
|
|
9858
|
+
if (context) {
|
|
9859
|
+
// Cases like `for (;;) using x = ...;`, `if (true) await using x = ...;`, etc. are not allowed.
|
|
9860
|
+
this.raise(this.start, "Using declaration is not allowed in single-statement positions");
|
|
9573
9861
|
}
|
|
9574
9862
|
if (usingKind === "await using") {
|
|
9575
9863
|
if (!this.canAwait) {
|
|
@@ -9666,7 +9954,12 @@
|
|
|
9666
9954
|
if (usingKind) {
|
|
9667
9955
|
var init$2 = this.startNode();
|
|
9668
9956
|
this.next();
|
|
9669
|
-
if (usingKind === "await using") {
|
|
9957
|
+
if (usingKind === "await using") {
|
|
9958
|
+
if (!this.canAwait) {
|
|
9959
|
+
this.raise(this.start, "Await using cannot appear outside of async function");
|
|
9960
|
+
}
|
|
9961
|
+
this.next();
|
|
9962
|
+
}
|
|
9670
9963
|
this.parseVar(init$2, true, usingKind);
|
|
9671
9964
|
this.finishNode(init$2, "VariableDeclaration");
|
|
9672
9965
|
return this.parseForAfterInit(node, init$2, awaitAt)
|
|
@@ -9699,11 +9992,12 @@
|
|
|
9699
9992
|
// Helper method to parse for loop after variable initialization
|
|
9700
9993
|
pp$8.parseForAfterInit = function(node, init, awaitAt) {
|
|
9701
9994
|
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
|
|
9702
|
-
if (this.
|
|
9703
|
-
if (
|
|
9704
|
-
|
|
9705
|
-
}
|
|
9706
|
-
|
|
9995
|
+
if (this.type === types$1._in) {
|
|
9996
|
+
if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
|
|
9997
|
+
this.raise(this.start, "Using declaration is not allowed in for-in loops");
|
|
9998
|
+
}
|
|
9999
|
+
if (this.options.ecmaVersion >= 9 && awaitAt > -1) { this.unexpected(awaitAt); }
|
|
10000
|
+
} else if (this.options.ecmaVersion >= 9) { node.await = awaitAt > -1; }
|
|
9707
10001
|
return this.parseForIn(node, init)
|
|
9708
10002
|
}
|
|
9709
10003
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
@@ -9725,7 +10019,7 @@
|
|
|
9725
10019
|
};
|
|
9726
10020
|
|
|
9727
10021
|
pp$8.parseReturnStatement = function(node) {
|
|
9728
|
-
if (!this.
|
|
10022
|
+
if (!this.allowReturn)
|
|
9729
10023
|
{ this.raise(this.start, "'return' outside of function"); }
|
|
9730
10024
|
this.next();
|
|
9731
10025
|
|
|
@@ -9744,7 +10038,7 @@
|
|
|
9744
10038
|
node.cases = [];
|
|
9745
10039
|
this.expect(types$1.braceL);
|
|
9746
10040
|
this.labels.push(switchLabel);
|
|
9747
|
-
this.enterScope(
|
|
10041
|
+
this.enterScope(SCOPE_SWITCH);
|
|
9748
10042
|
|
|
9749
10043
|
// Statements under must be grouped (by label) in SwitchCase
|
|
9750
10044
|
// nodes. `cur` is used to keep the node that we are currently
|
|
@@ -10308,11 +10602,11 @@
|
|
|
10308
10602
|
|
|
10309
10603
|
// Parses module export declaration.
|
|
10310
10604
|
|
|
10311
|
-
pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
10605
|
+
pp$8.parseExportAllDeclaration = function(node, exports$1) {
|
|
10312
10606
|
if (this.options.ecmaVersion >= 11) {
|
|
10313
10607
|
if (this.eatContextual("as")) {
|
|
10314
10608
|
node.exported = this.parseModuleExportName();
|
|
10315
|
-
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
10609
|
+
this.checkExport(exports$1, node.exported, this.lastTokStart);
|
|
10316
10610
|
} else {
|
|
10317
10611
|
node.exported = null;
|
|
10318
10612
|
}
|
|
@@ -10326,14 +10620,14 @@
|
|
|
10326
10620
|
return this.finishNode(node, "ExportAllDeclaration")
|
|
10327
10621
|
};
|
|
10328
10622
|
|
|
10329
|
-
pp$8.parseExport = function(node, exports) {
|
|
10623
|
+
pp$8.parseExport = function(node, exports$1) {
|
|
10330
10624
|
this.next();
|
|
10331
10625
|
// export * from '...'
|
|
10332
10626
|
if (this.eat(types$1.star)) {
|
|
10333
|
-
return this.parseExportAllDeclaration(node, exports)
|
|
10627
|
+
return this.parseExportAllDeclaration(node, exports$1)
|
|
10334
10628
|
}
|
|
10335
10629
|
if (this.eat(types$1._default)) { // export default ...
|
|
10336
|
-
this.checkExport(exports, "default", this.lastTokStart);
|
|
10630
|
+
this.checkExport(exports$1, "default", this.lastTokStart);
|
|
10337
10631
|
node.declaration = this.parseExportDefaultDeclaration();
|
|
10338
10632
|
return this.finishNode(node, "ExportDefaultDeclaration")
|
|
10339
10633
|
}
|
|
@@ -10341,16 +10635,16 @@
|
|
|
10341
10635
|
if (this.shouldParseExportStatement()) {
|
|
10342
10636
|
node.declaration = this.parseExportDeclaration(node);
|
|
10343
10637
|
if (node.declaration.type === "VariableDeclaration")
|
|
10344
|
-
{ this.checkVariableExport(exports, node.declaration.declarations); }
|
|
10638
|
+
{ this.checkVariableExport(exports$1, node.declaration.declarations); }
|
|
10345
10639
|
else
|
|
10346
|
-
{ this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
|
|
10640
|
+
{ this.checkExport(exports$1, node.declaration.id, node.declaration.id.start); }
|
|
10347
10641
|
node.specifiers = [];
|
|
10348
10642
|
node.source = null;
|
|
10349
10643
|
if (this.options.ecmaVersion >= 16)
|
|
10350
10644
|
{ node.attributes = []; }
|
|
10351
10645
|
} else { // export { x, y as z } [from '...']
|
|
10352
10646
|
node.declaration = null;
|
|
10353
|
-
node.specifiers = this.parseExportSpecifiers(exports);
|
|
10647
|
+
node.specifiers = this.parseExportSpecifiers(exports$1);
|
|
10354
10648
|
if (this.eatContextual("from")) {
|
|
10355
10649
|
if (this.type !== types$1.string) { this.unexpected(); }
|
|
10356
10650
|
node.source = this.parseExprAtom();
|
|
@@ -10400,47 +10694,47 @@
|
|
|
10400
10694
|
}
|
|
10401
10695
|
};
|
|
10402
10696
|
|
|
10403
|
-
pp$8.checkExport = function(exports, name, pos) {
|
|
10404
|
-
if (!exports) { return }
|
|
10697
|
+
pp$8.checkExport = function(exports$1, name, pos) {
|
|
10698
|
+
if (!exports$1) { return }
|
|
10405
10699
|
if (typeof name !== "string")
|
|
10406
10700
|
{ name = name.type === "Identifier" ? name.name : name.value; }
|
|
10407
|
-
if (hasOwn(exports, name))
|
|
10701
|
+
if (hasOwn(exports$1, name))
|
|
10408
10702
|
{ this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
|
|
10409
|
-
exports[name] = true;
|
|
10703
|
+
exports$1[name] = true;
|
|
10410
10704
|
};
|
|
10411
10705
|
|
|
10412
|
-
pp$8.checkPatternExport = function(exports, pat) {
|
|
10706
|
+
pp$8.checkPatternExport = function(exports$1, pat) {
|
|
10413
10707
|
var type = pat.type;
|
|
10414
10708
|
if (type === "Identifier")
|
|
10415
|
-
{ this.checkExport(exports, pat, pat.start); }
|
|
10709
|
+
{ this.checkExport(exports$1, pat, pat.start); }
|
|
10416
10710
|
else if (type === "ObjectPattern")
|
|
10417
10711
|
{ for (var i = 0, list = pat.properties; i < list.length; i += 1)
|
|
10418
10712
|
{
|
|
10419
10713
|
var prop = list[i];
|
|
10420
10714
|
|
|
10421
|
-
this.checkPatternExport(exports, prop);
|
|
10715
|
+
this.checkPatternExport(exports$1, prop);
|
|
10422
10716
|
} }
|
|
10423
10717
|
else if (type === "ArrayPattern")
|
|
10424
10718
|
{ for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
10425
10719
|
var elt = list$1[i$1];
|
|
10426
10720
|
|
|
10427
|
-
if (elt) { this.checkPatternExport(exports, elt); }
|
|
10721
|
+
if (elt) { this.checkPatternExport(exports$1, elt); }
|
|
10428
10722
|
} }
|
|
10429
10723
|
else if (type === "Property")
|
|
10430
|
-
{ this.checkPatternExport(exports, pat.value); }
|
|
10724
|
+
{ this.checkPatternExport(exports$1, pat.value); }
|
|
10431
10725
|
else if (type === "AssignmentPattern")
|
|
10432
|
-
{ this.checkPatternExport(exports, pat.left); }
|
|
10726
|
+
{ this.checkPatternExport(exports$1, pat.left); }
|
|
10433
10727
|
else if (type === "RestElement")
|
|
10434
|
-
{ this.checkPatternExport(exports, pat.argument); }
|
|
10728
|
+
{ this.checkPatternExport(exports$1, pat.argument); }
|
|
10435
10729
|
};
|
|
10436
10730
|
|
|
10437
|
-
pp$8.checkVariableExport = function(exports, decls) {
|
|
10438
|
-
if (!exports) { return }
|
|
10731
|
+
pp$8.checkVariableExport = function(exports$1, decls) {
|
|
10732
|
+
if (!exports$1) { return }
|
|
10439
10733
|
for (var i = 0, list = decls; i < list.length; i += 1)
|
|
10440
10734
|
{
|
|
10441
10735
|
var decl = list[i];
|
|
10442
10736
|
|
|
10443
|
-
this.checkPatternExport(exports, decl.id);
|
|
10737
|
+
this.checkPatternExport(exports$1, decl.id);
|
|
10444
10738
|
}
|
|
10445
10739
|
};
|
|
10446
10740
|
|
|
@@ -10455,13 +10749,13 @@
|
|
|
10455
10749
|
|
|
10456
10750
|
// Parses a comma-separated list of module exports.
|
|
10457
10751
|
|
|
10458
|
-
pp$8.parseExportSpecifier = function(exports) {
|
|
10752
|
+
pp$8.parseExportSpecifier = function(exports$1) {
|
|
10459
10753
|
var node = this.startNode();
|
|
10460
10754
|
node.local = this.parseModuleExportName();
|
|
10461
10755
|
|
|
10462
10756
|
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
10463
10757
|
this.checkExport(
|
|
10464
|
-
exports,
|
|
10758
|
+
exports$1,
|
|
10465
10759
|
node.exported,
|
|
10466
10760
|
node.exported.start
|
|
10467
10761
|
);
|
|
@@ -10469,7 +10763,7 @@
|
|
|
10469
10763
|
return this.finishNode(node, "ExportSpecifier")
|
|
10470
10764
|
};
|
|
10471
10765
|
|
|
10472
|
-
pp$8.parseExportSpecifiers = function(exports) {
|
|
10766
|
+
pp$8.parseExportSpecifiers = function(exports$1) {
|
|
10473
10767
|
var nodes = [], first = true;
|
|
10474
10768
|
// export { x, y as z } [from '...']
|
|
10475
10769
|
this.expect(types$1.braceL);
|
|
@@ -10479,7 +10773,7 @@
|
|
|
10479
10773
|
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
10480
10774
|
} else { first = false; }
|
|
10481
10775
|
|
|
10482
|
-
nodes.push(this.parseExportSpecifier(exports));
|
|
10776
|
+
nodes.push(this.parseExportSpecifier(exports$1));
|
|
10483
10777
|
}
|
|
10484
10778
|
return nodes
|
|
10485
10779
|
};
|
|
@@ -11210,15 +11504,19 @@
|
|
|
11210
11504
|
// delayed syntax error at correct position).
|
|
11211
11505
|
|
|
11212
11506
|
pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
11213
|
-
var
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
var
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11507
|
+
var this$1$1 = this;
|
|
11508
|
+
|
|
11509
|
+
return this.catchStackOverflow(function () {
|
|
11510
|
+
var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
|
|
11511
|
+
var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
11512
|
+
if (this$1$1.type === types$1.comma) {
|
|
11513
|
+
var node = this$1$1.startNodeAt(startPos, startLoc);
|
|
11514
|
+
node.expressions = [expr];
|
|
11515
|
+
while (this$1$1.eat(types$1.comma)) { node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors)); }
|
|
11516
|
+
return this$1$1.finishNode(node, "SequenceExpression")
|
|
11517
|
+
}
|
|
11518
|
+
return expr
|
|
11519
|
+
})
|
|
11222
11520
|
};
|
|
11223
11521
|
|
|
11224
11522
|
// Parse an assignment expression. This includes applications of
|
|
@@ -11283,7 +11581,7 @@
|
|
|
11283
11581
|
var startPos = this.start, startLoc = this.startLoc;
|
|
11284
11582
|
var expr = this.parseExprOps(forInit, refDestructuringErrors);
|
|
11285
11583
|
if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
|
|
11286
|
-
if (this.eat(types$1.question)) {
|
|
11584
|
+
if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
|
|
11287
11585
|
var node = this.startNodeAt(startPos, startLoc);
|
|
11288
11586
|
node.test = expr;
|
|
11289
11587
|
node.consequent = this.parseMaybeAssign();
|
|
@@ -11383,7 +11681,7 @@
|
|
|
11383
11681
|
}
|
|
11384
11682
|
}
|
|
11385
11683
|
|
|
11386
|
-
if (!incDec && this.eat(types$1.starstar)) {
|
|
11684
|
+
if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
|
|
11387
11685
|
if (sawUnary)
|
|
11388
11686
|
{ this.unexpected(this.lastTokStart); }
|
|
11389
11687
|
else
|
|
@@ -11835,6 +12133,8 @@
|
|
|
11835
12133
|
}
|
|
11836
12134
|
var startPos = this.start, startLoc = this.startLoc;
|
|
11837
12135
|
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
12136
|
+
if (node.callee.type === "Super")
|
|
12137
|
+
{ this.raiseRecoverable(startPos, "Invalid use of 'super'"); }
|
|
11838
12138
|
if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
|
|
11839
12139
|
else { node.arguments = empty; }
|
|
11840
12140
|
return this.finishNode(node, "NewExpression")
|
|
@@ -12452,7 +12752,7 @@
|
|
|
12452
12752
|
};
|
|
12453
12753
|
|
|
12454
12754
|
// This file was generated by "bin/generate-unicode-script-values.js". Do not modify manually!
|
|
12455
|
-
var scriptValuesAddedInUnicode = "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz";
|
|
12755
|
+
var scriptValuesAddedInUnicode = "Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz";
|
|
12456
12756
|
|
|
12457
12757
|
// This file contains Unicode properties extracted from the ECMAScript specification.
|
|
12458
12758
|
// The lists are extracted like so:
|
|
@@ -14013,13 +14313,17 @@
|
|
|
14013
14313
|
return this.getTokenFromCode(code)
|
|
14014
14314
|
};
|
|
14015
14315
|
|
|
14016
|
-
pp.
|
|
14017
|
-
var code = this.input.charCodeAt(
|
|
14316
|
+
pp.fullCharCodeAt = function(pos) {
|
|
14317
|
+
var code = this.input.charCodeAt(pos);
|
|
14018
14318
|
if (code <= 0xd7ff || code >= 0xdc00) { return code }
|
|
14019
|
-
var next = this.input.charCodeAt(
|
|
14319
|
+
var next = this.input.charCodeAt(pos + 1);
|
|
14020
14320
|
return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
|
|
14021
14321
|
};
|
|
14022
14322
|
|
|
14323
|
+
pp.fullCharCodeAtPos = function() {
|
|
14324
|
+
return this.fullCharCodeAt(this.pos)
|
|
14325
|
+
};
|
|
14326
|
+
|
|
14023
14327
|
pp.skipBlockComment = function() {
|
|
14024
14328
|
var startLoc = this.options.onComment && this.curPosition();
|
|
14025
14329
|
var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
|
|
@@ -14747,7 +15051,7 @@
|
|
|
14747
15051
|
// [ghbt]: https://github.com/acornjs/acorn/issues
|
|
14748
15052
|
|
|
14749
15053
|
|
|
14750
|
-
var version = "8.
|
|
15054
|
+
var version = "8.18.0";
|
|
14751
15055
|
|
|
14752
15056
|
Parser.acorn = {
|
|
14753
15057
|
Parser: Parser,
|