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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.
|
|
2
|
+
* GyosJS v0.4.1
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -183,10 +183,35 @@ function hasStructuralParent(el) {
|
|
|
183
183
|
* count.value++; // Triggers effect
|
|
184
184
|
* ```
|
|
185
185
|
*/
|
|
186
|
-
/**
|
|
187
|
-
* Current effect being tracked
|
|
188
|
-
*/
|
|
189
186
|
let currentEffect = null;
|
|
187
|
+
function track(source) {
|
|
188
|
+
if (!currentEffect)
|
|
189
|
+
return;
|
|
190
|
+
source.subscribers.add(currentEffect);
|
|
191
|
+
currentEffect.__dependencies?.add(source.subscribers);
|
|
192
|
+
currentEffect.__versions?.set(source, source.version);
|
|
193
|
+
}
|
|
194
|
+
function dependenciesChanged(versions) {
|
|
195
|
+
return untrack(() => {
|
|
196
|
+
for (const [source, version] of versions) {
|
|
197
|
+
source.refresh?.();
|
|
198
|
+
if (source.version !== version)
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
// Invalidate derived caches synchronously; only user effects are deferred.
|
|
205
|
+
function notifySubscribers(subscribers) {
|
|
206
|
+
for (const sub of Array.from(subscribers)) {
|
|
207
|
+
if (sub.__invalidate)
|
|
208
|
+
sub();
|
|
209
|
+
else if (isBatching)
|
|
210
|
+
batchedEffects.add(sub);
|
|
211
|
+
else
|
|
212
|
+
queueEffect(sub);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
190
215
|
// Simple counter for debug-friendly IDs
|
|
191
216
|
let signalIdCounter = 0;
|
|
192
217
|
const WARN_SUBSCRIBERS = () => typeof window !== 'undefined' && window.GYOS_DEBUG_WARN_SUBSCRIBERS;
|
|
@@ -224,6 +249,9 @@ function flushEffectQueue() {
|
|
|
224
249
|
}
|
|
225
250
|
});
|
|
226
251
|
isFlushingQueue = false;
|
|
252
|
+
// A plain subscribe callback can enqueue more work without entering effect().
|
|
253
|
+
if (effectQueue.size > 0)
|
|
254
|
+
queueMicrotask(flushEffectQueue);
|
|
227
255
|
}
|
|
228
256
|
/**
|
|
229
257
|
* Queue an effect for execution in next microtask
|
|
@@ -282,17 +310,14 @@ function signal(initialValue, debugOrOptions) {
|
|
|
282
310
|
const debugId = ++signalIdCounter;
|
|
283
311
|
let value = initialValue;
|
|
284
312
|
const subscribers = new Set();
|
|
313
|
+
const source = { subscribers, version: 0 };
|
|
285
314
|
let warnedSubscribers = false;
|
|
286
315
|
const read = () => {
|
|
287
316
|
// Track dependency
|
|
288
317
|
if (currentEffect) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// Store the subscribers Set in the effect's dependencies for cleanup
|
|
293
|
-
if (currentEffect.__dependencies) {
|
|
294
|
-
currentEffect.__dependencies.add(subscribers);
|
|
295
|
-
}
|
|
318
|
+
const wasSubscribed = subscribers.has(currentEffect);
|
|
319
|
+
track(source);
|
|
320
|
+
if (!wasSubscribed) {
|
|
296
321
|
if (DEBUG_VERBOSE()) {
|
|
297
322
|
console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Added subscriber, total:', subscribers.size);
|
|
298
323
|
}
|
|
@@ -311,18 +336,13 @@ function signal(initialValue, debugOrOptions) {
|
|
|
311
336
|
// For objects/arrays, check if it's actually the same reference
|
|
312
337
|
// Deep equality is expensive, let user handle it
|
|
313
338
|
value = newValue;
|
|
339
|
+
source.version++;
|
|
314
340
|
DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Value changed to:', newValue);
|
|
315
341
|
notify();
|
|
316
342
|
};
|
|
317
343
|
const notify = () => {
|
|
318
344
|
DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Notifying', subscribers.size, 'subscribers');
|
|
319
|
-
|
|
320
|
-
subscribers.forEach(sub => batchedEffects.add(sub));
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
// Always queue effects to prevent cascading updates
|
|
324
|
-
subscribers.forEach(sub => queueEffect(sub));
|
|
325
|
-
}
|
|
345
|
+
notifySubscribers(subscribers);
|
|
326
346
|
};
|
|
327
347
|
// Create callable signal (like Angular/SolidJS)
|
|
328
348
|
// Call without args = read, call with arg = write
|
|
@@ -357,8 +377,16 @@ function signal(initialValue, debugOrOptions) {
|
|
|
357
377
|
},
|
|
358
378
|
subscribe: {
|
|
359
379
|
value: function (fn) {
|
|
360
|
-
|
|
361
|
-
|
|
380
|
+
let active = true;
|
|
381
|
+
const callback = () => { if (active)
|
|
382
|
+
untrack(fn); };
|
|
383
|
+
subscribers.add(callback);
|
|
384
|
+
return () => {
|
|
385
|
+
active = false;
|
|
386
|
+
subscribers.delete(callback);
|
|
387
|
+
effectQueue.delete(callback);
|
|
388
|
+
batchedEffects.delete(callback);
|
|
389
|
+
};
|
|
362
390
|
},
|
|
363
391
|
enumerable: true,
|
|
364
392
|
configurable: true
|
|
@@ -418,49 +446,60 @@ function computed(fn) {
|
|
|
418
446
|
let value;
|
|
419
447
|
let isDirty = true;
|
|
420
448
|
let isFirstRun = true;
|
|
449
|
+
let computing = false;
|
|
421
450
|
const subscribers = new Set();
|
|
422
|
-
|
|
451
|
+
const dependencies = new Set();
|
|
452
|
+
const versions = new Map();
|
|
453
|
+
const source = { subscribers, version: 0, refresh: () => compute() };
|
|
454
|
+
const invalidate = () => {
|
|
455
|
+
// A later batched write must also move already queued consumers into
|
|
456
|
+
// the batch, even when an earlier ordinary write dirtied this cache.
|
|
457
|
+
if (isDirty && !isBatching)
|
|
458
|
+
return;
|
|
459
|
+
isDirty = true;
|
|
460
|
+
notifySubscribers(subscribers);
|
|
461
|
+
};
|
|
462
|
+
invalidate.__invalidate = true;
|
|
463
|
+
invalidate.__dependencies = dependencies;
|
|
464
|
+
invalidate.__versions = versions;
|
|
423
465
|
const compute = () => {
|
|
424
466
|
if (!isDirty && !isFirstRun)
|
|
425
467
|
return;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
value = newValue;
|
|
436
|
-
isFirstRun = false;
|
|
437
|
-
isDirty = false;
|
|
438
|
-
// Notify subscribers
|
|
439
|
-
if (!isBatching) {
|
|
440
|
-
subscribers.forEach(sub => queueEffect(sub));
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
subscribers.forEach(sub => batchedEffects.add(sub));
|
|
444
|
-
}
|
|
445
|
-
}
|
|
468
|
+
if (computing)
|
|
469
|
+
throw new Error('[Computed] Circular dependency');
|
|
470
|
+
computing = true;
|
|
471
|
+
const previousEffect = currentEffect;
|
|
472
|
+
try {
|
|
473
|
+
// A dirty upstream computed may still resolve to its previous value.
|
|
474
|
+
if (!isFirstRun && !dependenciesChanged(versions)) {
|
|
475
|
+
isDirty = false;
|
|
476
|
+
return;
|
|
446
477
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
478
|
+
dependencies.forEach(dependency => dependency.delete(invalidate));
|
|
479
|
+
dependencies.clear();
|
|
480
|
+
versions.clear();
|
|
481
|
+
currentEffect = invalidate;
|
|
482
|
+
const nextValue = fn();
|
|
483
|
+
if (isFirstRun || !Object.is(value, nextValue)) {
|
|
484
|
+
value = nextValue;
|
|
485
|
+
source.version++;
|
|
450
486
|
}
|
|
451
|
-
|
|
452
|
-
|
|
487
|
+
isFirstRun = false;
|
|
488
|
+
isDirty = false;
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
// Preserve error isolation and the last successful value.
|
|
492
|
+
console.error('[Computed] Error in computation:', error);
|
|
493
|
+
isDirty = false;
|
|
494
|
+
}
|
|
495
|
+
finally {
|
|
496
|
+
currentEffect = previousEffect;
|
|
497
|
+
computing = false;
|
|
498
|
+
}
|
|
453
499
|
};
|
|
454
500
|
const read = () => {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
// Track dependency
|
|
458
|
-
if (currentEffect && !subscribers.has(currentEffect)) {
|
|
459
|
-
subscribers.add(currentEffect);
|
|
460
|
-
if (currentEffect.__dependencies) {
|
|
461
|
-
currentEffect.__dependencies.add(subscribers);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
501
|
+
compute();
|
|
502
|
+
track(source);
|
|
464
503
|
return value;
|
|
465
504
|
};
|
|
466
505
|
// Create callable computed (read-only)
|
|
@@ -485,8 +524,14 @@ function computed(fn) {
|
|
|
485
524
|
},
|
|
486
525
|
subscribe: {
|
|
487
526
|
value: function (fn) {
|
|
488
|
-
|
|
489
|
-
|
|
527
|
+
// Establish dependencies even if subscribe() is the first access.
|
|
528
|
+
let first = true;
|
|
529
|
+
return effect(() => {
|
|
530
|
+
read();
|
|
531
|
+
if (!first)
|
|
532
|
+
untrack(fn);
|
|
533
|
+
first = false;
|
|
534
|
+
});
|
|
490
535
|
},
|
|
491
536
|
enumerable: true,
|
|
492
537
|
configurable: true
|
|
@@ -537,11 +582,15 @@ function computed(fn) {
|
|
|
537
582
|
*/
|
|
538
583
|
function effect(fn) {
|
|
539
584
|
let cleanup;
|
|
540
|
-
|
|
585
|
+
const dependencies = new Set();
|
|
586
|
+
const versions = new Map();
|
|
541
587
|
let active = true;
|
|
588
|
+
let initialized = false;
|
|
542
589
|
const execute = () => {
|
|
543
590
|
if (!active)
|
|
544
591
|
return;
|
|
592
|
+
if (initialized && !dependenciesChanged(versions))
|
|
593
|
+
return;
|
|
545
594
|
// Prevent recursive execution - if already running, skip
|
|
546
595
|
if (runningEffects.has(execute)) {
|
|
547
596
|
DEBUG() && console.warn('[Effect] Skipped recursive execution');
|
|
@@ -556,10 +605,13 @@ function effect(fn) {
|
|
|
556
605
|
});
|
|
557
606
|
DEBUG() && console.log('[Effect] Cleaned up dependencies, count:', dependencies.size);
|
|
558
607
|
dependencies.clear();
|
|
608
|
+
versions.clear();
|
|
559
609
|
// Clean up previous run
|
|
560
610
|
if (cleanup) {
|
|
611
|
+
const previousCleanup = cleanup;
|
|
612
|
+
cleanup = undefined;
|
|
561
613
|
try {
|
|
562
|
-
|
|
614
|
+
untrack(previousCleanup);
|
|
563
615
|
}
|
|
564
616
|
catch (error) {
|
|
565
617
|
console.error('[Effect] Error in cleanup:', error);
|
|
@@ -570,6 +622,7 @@ function effect(fn) {
|
|
|
570
622
|
currentEffect = execute;
|
|
571
623
|
// Store dependencies for cleanup
|
|
572
624
|
execute.__dependencies = dependencies;
|
|
625
|
+
execute.__versions = versions;
|
|
573
626
|
try {
|
|
574
627
|
const nextCleanup = fn();
|
|
575
628
|
cleanup = typeof nextCleanup === 'function' ? nextCleanup : undefined;
|
|
@@ -579,6 +632,7 @@ function effect(fn) {
|
|
|
579
632
|
// Don't throw - allow other effects to continue
|
|
580
633
|
}
|
|
581
634
|
finally {
|
|
635
|
+
initialized = true;
|
|
582
636
|
currentEffect = prevEffect;
|
|
583
637
|
effectDepth--;
|
|
584
638
|
runningEffects.delete(execute);
|
|
@@ -595,14 +649,17 @@ function effect(fn) {
|
|
|
595
649
|
if (!active)
|
|
596
650
|
return;
|
|
597
651
|
active = false;
|
|
652
|
+
effectQueue.delete(execute);
|
|
653
|
+
batchedEffects.delete(execute);
|
|
598
654
|
// Remove from all dependencies
|
|
599
655
|
dependencies.forEach(depSet => {
|
|
600
656
|
depSet.delete(execute);
|
|
601
657
|
});
|
|
602
658
|
dependencies.clear();
|
|
659
|
+
versions.clear();
|
|
603
660
|
if (cleanup) {
|
|
604
661
|
try {
|
|
605
|
-
cleanup
|
|
662
|
+
untrack(cleanup);
|
|
606
663
|
}
|
|
607
664
|
catch (error) {
|
|
608
665
|
console.error('[Effect] Error in final cleanup:', error);
|
|
@@ -662,6 +719,8 @@ function batch(fn) {
|
|
|
662
719
|
const effects = Array.from(batchedEffects);
|
|
663
720
|
batchedEffects.clear();
|
|
664
721
|
effects.forEach(effect => {
|
|
722
|
+
// This batch also settles any earlier queued write to this observer.
|
|
723
|
+
effectQueue.delete(effect);
|
|
665
724
|
try {
|
|
666
725
|
effect();
|
|
667
726
|
}
|
|
@@ -2196,59 +2255,59 @@ function applyTransitionStyles() {
|
|
|
2196
2255
|
return;
|
|
2197
2256
|
const style = document.createElement('style');
|
|
2198
2257
|
style.id = styleId;
|
|
2199
|
-
style.textContent = `
|
|
2200
|
-
/* Opacity utilities */
|
|
2258
|
+
style.textContent = `
|
|
2259
|
+
/* Opacity utilities */
|
|
2201
2260
|
.gyos-t-opacity-0 { opacity: 0; }
|
|
2202
2261
|
.gyos-t-opacity-100 { opacity: 1; }
|
|
2203
|
-
|
|
2204
|
-
/* Transform - Translate Y */
|
|
2262
|
+
|
|
2263
|
+
/* Transform - Translate Y */
|
|
2205
2264
|
.gyos-t-translate-y-0 { transform: translateY(0); }
|
|
2206
2265
|
.gyos-t-translate-y--100 { transform: translateY(-100%); }
|
|
2207
2266
|
.gyos-t-translate-y-100 { transform: translateY(100%); }
|
|
2208
|
-
|
|
2209
|
-
/* Transform - Translate X */
|
|
2267
|
+
|
|
2268
|
+
/* Transform - Translate X */
|
|
2210
2269
|
.gyos-t-translate-x-0 { transform: translateX(0); }
|
|
2211
2270
|
.gyos-t-translate-x--100 { transform: translateX(-100%); }
|
|
2212
2271
|
.gyos-t-translate-x-100 { transform: translateX(100%); }
|
|
2213
|
-
|
|
2214
|
-
/* Transform - Scale */
|
|
2272
|
+
|
|
2273
|
+
/* Transform - Scale */
|
|
2215
2274
|
.gyos-t-scale-0 { transform: scale(0); }
|
|
2216
2275
|
.gyos-t-scale-50 { transform: scale(0.5); }
|
|
2217
2276
|
.gyos-t-scale-100 { transform: scale(1); }
|
|
2218
|
-
|
|
2219
|
-
/* Animation Keyframes */
|
|
2220
|
-
@keyframes gyos-fade-in {
|
|
2221
|
-
from { opacity: 0; }
|
|
2222
|
-
to { opacity: 1; }
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
@keyframes gyos-fade-out {
|
|
2226
|
-
from { opacity: 1; }
|
|
2227
|
-
to { opacity: 0; }
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
@keyframes gyos-slide-down {
|
|
2231
|
-
from { transform: translateY(-100%); opacity: 0; }
|
|
2232
|
-
to { transform: translateY(0); opacity: 1; }
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
@keyframes gyos-slide-up {
|
|
2236
|
-
from { transform: translateY(100%); opacity: 0; }
|
|
2237
|
-
to { transform: translateY(0); opacity: 1; }
|
|
2238
|
-
}
|
|
2239
|
-
|
|
2240
|
-
@keyframes gyos-scale-in {
|
|
2241
|
-
from { transform: scale(0); opacity: 0; }
|
|
2242
|
-
to { transform: scale(1); opacity: 1; }
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
@keyframes gyos-scale-out {
|
|
2246
|
-
from { transform: scale(1); opacity: 1; }
|
|
2247
|
-
to { transform: scale(0); opacity: 0; }
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
[g-cloak] {
|
|
2251
|
-
display: none !important;
|
|
2277
|
+
|
|
2278
|
+
/* Animation Keyframes */
|
|
2279
|
+
@keyframes gyos-fade-in {
|
|
2280
|
+
from { opacity: 0; }
|
|
2281
|
+
to { opacity: 1; }
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
@keyframes gyos-fade-out {
|
|
2285
|
+
from { opacity: 1; }
|
|
2286
|
+
to { opacity: 0; }
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
@keyframes gyos-slide-down {
|
|
2290
|
+
from { transform: translateY(-100%); opacity: 0; }
|
|
2291
|
+
to { transform: translateY(0); opacity: 1; }
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
@keyframes gyos-slide-up {
|
|
2295
|
+
from { transform: translateY(100%); opacity: 0; }
|
|
2296
|
+
to { transform: translateY(0); opacity: 1; }
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
@keyframes gyos-scale-in {
|
|
2300
|
+
from { transform: scale(0); opacity: 0; }
|
|
2301
|
+
to { transform: scale(1); opacity: 1; }
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
@keyframes gyos-scale-out {
|
|
2305
|
+
from { transform: scale(1); opacity: 1; }
|
|
2306
|
+
to { transform: scale(0); opacity: 0; }
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
[g-cloak] {
|
|
2310
|
+
display: none !important;
|
|
2252
2311
|
}`;
|
|
2253
2312
|
document.head.appendChild(style);
|
|
2254
2313
|
}
|
|
@@ -6605,33 +6664,44 @@ class ProgressBar {
|
|
|
6605
6664
|
getCurrentProgress() {
|
|
6606
6665
|
return this.currentProgress;
|
|
6607
6666
|
}
|
|
6667
|
+
reconnect() {
|
|
6668
|
+
if (!this.element || !this.progressBarEnabled || !document.body)
|
|
6669
|
+
return;
|
|
6670
|
+
// Snapshots may contain a clone of the runtime bar. Keep this instance.
|
|
6671
|
+
document.querySelectorAll('#gyos-progress-bar').forEach(node => {
|
|
6672
|
+
if (node !== this.element)
|
|
6673
|
+
node.remove();
|
|
6674
|
+
});
|
|
6675
|
+
if (!this.element.isConnected)
|
|
6676
|
+
document.body.appendChild(this.element);
|
|
6677
|
+
}
|
|
6608
6678
|
createBar() {
|
|
6609
6679
|
if (typeof document === 'undefined')
|
|
6610
6680
|
return;
|
|
6611
6681
|
// Create progress bar element
|
|
6612
6682
|
this.element = document.createElement('div');
|
|
6613
6683
|
this.element.id = 'gyos-progress-bar';
|
|
6614
|
-
this.element.style.cssText = `
|
|
6615
|
-
position: fixed;
|
|
6616
|
-
top: 0;
|
|
6617
|
-
left: 0;
|
|
6618
|
-
width: 0%;
|
|
6619
|
-
height: 6px;
|
|
6620
|
-
background: var(--gyos-progress-color, linear-gradient(90deg, #aab9ff, #77889f));
|
|
6621
|
-
z-index: 999999;
|
|
6622
|
-
transition: width 0.3s linear, opacity 0.3s linear;
|
|
6623
|
-
opacity: 0;
|
|
6624
|
-
pointer-events: none;
|
|
6625
|
-
box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
|
|
6684
|
+
this.element.style.cssText = `
|
|
6685
|
+
position: fixed;
|
|
6686
|
+
top: 0;
|
|
6687
|
+
left: 0;
|
|
6688
|
+
width: 0%;
|
|
6689
|
+
height: 6px;
|
|
6690
|
+
background: var(--gyos-progress-color, linear-gradient(90deg, #aab9ff, #77889f));
|
|
6691
|
+
z-index: 999999;
|
|
6692
|
+
transition: width 0.3s linear, opacity 0.3s linear;
|
|
6693
|
+
opacity: 0;
|
|
6694
|
+
pointer-events: none;
|
|
6695
|
+
box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
|
|
6626
6696
|
`;
|
|
6627
6697
|
// Insert into DOM when ready
|
|
6628
6698
|
if (document.readyState === 'loading') {
|
|
6629
6699
|
document.addEventListener('DOMContentLoaded', () => {
|
|
6630
|
-
|
|
6631
|
-
});
|
|
6700
|
+
this.reconnect();
|
|
6701
|
+
}, { once: true });
|
|
6632
6702
|
}
|
|
6633
6703
|
else {
|
|
6634
|
-
|
|
6704
|
+
this.reconnect();
|
|
6635
6705
|
}
|
|
6636
6706
|
}
|
|
6637
6707
|
start() {
|
|
@@ -6655,6 +6725,7 @@ class ProgressBar {
|
|
|
6655
6725
|
setProgress(percent) {
|
|
6656
6726
|
if (!this.element || !this.progressBarEnabled)
|
|
6657
6727
|
return;
|
|
6728
|
+
this.reconnect();
|
|
6658
6729
|
// Clamp between 0-100
|
|
6659
6730
|
percent = Math.min(100, Math.max(0, percent));
|
|
6660
6731
|
this.currentProgress = percent;
|
|
@@ -6703,41 +6774,41 @@ class ProgressBar {
|
|
|
6703
6774
|
function createTargetSpinner() {
|
|
6704
6775
|
const spinner = document.createElement('div');
|
|
6705
6776
|
spinner.className = 'gyos-target-spinner';
|
|
6706
|
-
spinner.innerHTML = `
|
|
6707
|
-
<div class="gyos-spinner-content">
|
|
6708
|
-
<svg class="gyos-spinner-icon" viewBox="0 0 50 50">
|
|
6709
|
-
<circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="31.4 31.4" />
|
|
6710
|
-
</svg>
|
|
6711
|
-
</div>
|
|
6777
|
+
spinner.innerHTML = `
|
|
6778
|
+
<div class="gyos-spinner-content">
|
|
6779
|
+
<svg class="gyos-spinner-icon" viewBox="0 0 50 50">
|
|
6780
|
+
<circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="31.4 31.4" />
|
|
6781
|
+
</svg>
|
|
6782
|
+
</div>
|
|
6712
6783
|
`;
|
|
6713
6784
|
// Inject styles if not already present
|
|
6714
6785
|
if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
|
|
6715
6786
|
const style = document.createElement('style');
|
|
6716
6787
|
style.id = 'gyos-target-spinner-styles';
|
|
6717
|
-
style.textContent = `
|
|
6718
|
-
.gyos-target-spinner {
|
|
6719
|
-
display: flex;
|
|
6720
|
-
align-items: center;
|
|
6721
|
-
justify-content: center;
|
|
6722
|
-
padding: 20px;
|
|
6723
|
-
min-height: 60px;
|
|
6724
|
-
}
|
|
6725
|
-
.gyos-spinner-content {
|
|
6726
|
-
display: flex;
|
|
6727
|
-
align-items: center;
|
|
6728
|
-
gap: 10px;
|
|
6729
|
-
color: var(--gyos-spinner-color, #667eea);
|
|
6730
|
-
font-size: 14px;
|
|
6731
|
-
}
|
|
6732
|
-
.gyos-spinner-icon {
|
|
6733
|
-
width: 24px;
|
|
6734
|
-
height: 24px;
|
|
6735
|
-
animation: gyos-spin 1s linear infinite;
|
|
6736
|
-
}
|
|
6737
|
-
@keyframes gyos-spin {
|
|
6738
|
-
0% { transform: rotate(0deg); }
|
|
6739
|
-
100% { transform: rotate(360deg); }
|
|
6740
|
-
}
|
|
6788
|
+
style.textContent = `
|
|
6789
|
+
.gyos-target-spinner {
|
|
6790
|
+
display: flex;
|
|
6791
|
+
align-items: center;
|
|
6792
|
+
justify-content: center;
|
|
6793
|
+
padding: 20px;
|
|
6794
|
+
min-height: 60px;
|
|
6795
|
+
}
|
|
6796
|
+
.gyos-spinner-content {
|
|
6797
|
+
display: flex;
|
|
6798
|
+
align-items: center;
|
|
6799
|
+
gap: 10px;
|
|
6800
|
+
color: var(--gyos-spinner-color, #667eea);
|
|
6801
|
+
font-size: 14px;
|
|
6802
|
+
}
|
|
6803
|
+
.gyos-spinner-icon {
|
|
6804
|
+
width: 24px;
|
|
6805
|
+
height: 24px;
|
|
6806
|
+
animation: gyos-spin 1s linear infinite;
|
|
6807
|
+
}
|
|
6808
|
+
@keyframes gyos-spin {
|
|
6809
|
+
0% { transform: rotate(0deg); }
|
|
6810
|
+
100% { transform: rotate(360deg); }
|
|
6811
|
+
}
|
|
6741
6812
|
`;
|
|
6742
6813
|
document.head.appendChild(style);
|
|
6743
6814
|
}
|
|
@@ -7111,8 +7182,8 @@ async function performSwap(target, src, mode, options = {}) {
|
|
|
7111
7182
|
}
|
|
7112
7183
|
result = target;
|
|
7113
7184
|
}
|
|
7114
|
-
await options.beforeScripts?.();
|
|
7115
7185
|
options.onCommitted?.(result, normalized === 'append' || normalized === 'prepend' ? incomingChildren : [result]);
|
|
7186
|
+
await options.beforeScripts?.();
|
|
7116
7187
|
// Additive swaps must not re-run scripts that already existed in the target.
|
|
7117
7188
|
if (normalized === 'append' || normalized === 'prepend') {
|
|
7118
7189
|
await executeScriptsInNodes(incomingChildren, options.signal);
|
|
@@ -7352,6 +7423,21 @@ function handleScroll(url, trigger, savedScroll) {
|
|
|
7352
7423
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
7353
7424
|
}
|
|
7354
7425
|
|
|
7426
|
+
// A retained relative URL still identifies the resource loaded on its original
|
|
7427
|
+
// page, even after pushState changes document.baseURI.
|
|
7428
|
+
const resourceUrls = new WeakMap();
|
|
7429
|
+
function rememberResourceUrls(root, baseUrl) {
|
|
7430
|
+
root.querySelectorAll('script[src], link[href]').forEach(node => {
|
|
7431
|
+
const attribute = node.tagName === 'SCRIPT' ? 'src' : 'href';
|
|
7432
|
+
const source = node.getAttribute(attribute);
|
|
7433
|
+
if (resourceUrls.get(node)?.source === source)
|
|
7434
|
+
return;
|
|
7435
|
+
try {
|
|
7436
|
+
resourceUrls.set(node, { source, url: new URL(source, baseUrl).href });
|
|
7437
|
+
}
|
|
7438
|
+
catch { /* Invalid resource URLs retain their literal identity. */ }
|
|
7439
|
+
});
|
|
7440
|
+
}
|
|
7355
7441
|
function isNonceMeta(el) {
|
|
7356
7442
|
return el.tagName === 'META' && el.getAttribute('name')?.toLowerCase() === 'csp-nonce';
|
|
7357
7443
|
}
|
|
@@ -7369,7 +7455,20 @@ function serializeAttributes(el, context) {
|
|
|
7369
7455
|
return;
|
|
7370
7456
|
if (context.csp && isNonceMeta(el) && attr.name.toLowerCase() === 'content')
|
|
7371
7457
|
return;
|
|
7372
|
-
|
|
7458
|
+
let value = attr.value;
|
|
7459
|
+
if ((el.tagName === 'SCRIPT' && attr.name === 'src') || (el.tagName === 'LINK' && attr.name === 'href')) {
|
|
7460
|
+
const cached = resourceUrls.get(el);
|
|
7461
|
+
if (cached?.source === value)
|
|
7462
|
+
value = cached.url;
|
|
7463
|
+
else {
|
|
7464
|
+
try {
|
|
7465
|
+
value = new URL(value, context.baseUrl || el.baseURI).href;
|
|
7466
|
+
resourceUrls.set(el, { source: attr.value, url: value });
|
|
7467
|
+
}
|
|
7468
|
+
catch { /* Keep invalid URLs distinct. */ }
|
|
7469
|
+
}
|
|
7470
|
+
}
|
|
7471
|
+
attributes.set(attr.name, value);
|
|
7373
7472
|
});
|
|
7374
7473
|
if (context.csp && usesCspNonce(el) && context.activeNonce) {
|
|
7375
7474
|
attributes.set('nonce', context.activeNonce);
|
|
@@ -7436,19 +7535,21 @@ function warnSkippedNode(node) {
|
|
|
7436
7535
|
console.warn('[GyosJS CSP] Skipped an inline MPA script because no active document nonce is configured.');
|
|
7437
7536
|
}
|
|
7438
7537
|
}
|
|
7439
|
-
async function diffNodes(currentNodes, nextNodes, container = document.head, signal) {
|
|
7538
|
+
async function diffNodes(currentNodes, nextNodes, container = document.head, signal, currentBaseUrl = document.baseURI) {
|
|
7440
7539
|
const csp = expressionRuntimeMode() === 'csp';
|
|
7441
7540
|
const context = {
|
|
7442
7541
|
csp,
|
|
7443
7542
|
activeNonce: csp ? resolveCspNonce() : undefined
|
|
7444
7543
|
};
|
|
7445
|
-
const current = keyedNodes(currentNodes, context);
|
|
7544
|
+
const current = keyedNodes(currentNodes, { ...context, baseUrl: currentBaseUrl });
|
|
7446
7545
|
const next = keyedNodes(nextNodes, context);
|
|
7546
|
+
const persistentKey = (node) => container === document.head ? node.getAttribute('g-head-persist') : null;
|
|
7547
|
+
const persistent = new Set(currentNodes.map(persistentKey).filter(Boolean));
|
|
7447
7548
|
const currentKeys = new Set(current.map(item => item.key));
|
|
7448
7549
|
const nextKeys = new Set(next.map(item => item.key));
|
|
7449
7550
|
// Remove nodes that are not in the new head
|
|
7450
7551
|
current.forEach(({ key, node }) => {
|
|
7451
|
-
if (!nextKeys.has(key)) {
|
|
7552
|
+
if (!nextKeys.has(key) && !persistentKey(node)) {
|
|
7452
7553
|
node.remove();
|
|
7453
7554
|
}
|
|
7454
7555
|
});
|
|
@@ -7456,6 +7557,8 @@ async function diffNodes(currentNodes, nextNodes, container = document.head, sig
|
|
|
7456
7557
|
for (const { key, node } of next) {
|
|
7457
7558
|
if (signal?.aborted)
|
|
7458
7559
|
return;
|
|
7560
|
+
if (persistent.has(persistentKey(node)))
|
|
7561
|
+
continue;
|
|
7459
7562
|
if (!currentKeys.has(key)) {
|
|
7460
7563
|
if (!canInsertNode(node, context)) {
|
|
7461
7564
|
warnSkippedNode(node);
|
|
@@ -7658,6 +7761,7 @@ function prepareNavigationHtml(html) {
|
|
|
7658
7761
|
* MPA boost navigation inspired by Turbo Drive.
|
|
7659
7762
|
* Implements attribute-driven routing, snapshot caching, and persistent islands.
|
|
7660
7763
|
*/
|
|
7764
|
+
const submittingForms = new WeakSet();
|
|
7661
7765
|
const snapshots = new Map();
|
|
7662
7766
|
const preloadCache = new Map();
|
|
7663
7767
|
const preloadControllers = new Map();
|
|
@@ -7674,12 +7778,30 @@ let activeNavigation = null;
|
|
|
7674
7778
|
let progressBar = null;
|
|
7675
7779
|
const beforeNavigate = [];
|
|
7676
7780
|
const afterNavigate = [];
|
|
7781
|
+
const beforeSwap = [];
|
|
7782
|
+
const navigationEnd = [];
|
|
7783
|
+
function registerNavigationHook(hooks, callback) {
|
|
7784
|
+
// A wrapper gives each registration its own unsubscribe identity.
|
|
7785
|
+
const entry = (url, context) => callback(url, context);
|
|
7786
|
+
hooks.push(entry);
|
|
7787
|
+
return () => {
|
|
7788
|
+
const index = hooks.indexOf(entry);
|
|
7789
|
+
if (index !== -1)
|
|
7790
|
+
hooks.splice(index, 1);
|
|
7791
|
+
};
|
|
7792
|
+
}
|
|
7677
7793
|
// Expose hooks to register before/after navigation callbacks
|
|
7678
7794
|
function onBeforeNavigate(callback) {
|
|
7679
|
-
beforeNavigate
|
|
7795
|
+
return registerNavigationHook(beforeNavigate, callback);
|
|
7680
7796
|
}
|
|
7681
7797
|
function onAfterNavigate(callback) {
|
|
7682
|
-
afterNavigate
|
|
7798
|
+
return registerNavigationHook(afterNavigate, callback);
|
|
7799
|
+
}
|
|
7800
|
+
function onBeforeSwap(callback) {
|
|
7801
|
+
return registerNavigationHook(beforeSwap, callback);
|
|
7802
|
+
}
|
|
7803
|
+
function onNavigationEnd(callback) {
|
|
7804
|
+
return registerNavigationHook(navigationEnd, (_url, context) => callback(context));
|
|
7683
7805
|
}
|
|
7684
7806
|
function startRouter(options) {
|
|
7685
7807
|
// If not has g-boost attribute, do not start router
|
|
@@ -7703,6 +7825,7 @@ function startRouter(options) {
|
|
|
7703
7825
|
}
|
|
7704
7826
|
// Cache scripts from initial page to prevent re-execution on first navigation back
|
|
7705
7827
|
cacheInitialPageScripts();
|
|
7828
|
+
rememberResourceUrls(document, document.baseURI);
|
|
7706
7829
|
routerStarted = true;
|
|
7707
7830
|
log('[GyosRouter] started');
|
|
7708
7831
|
}
|
|
@@ -7759,9 +7882,13 @@ function resolveTarget(trigger, targetSelector, targetOutletIndex) {
|
|
|
7759
7882
|
const outlet = findGlobalOutlet();
|
|
7760
7883
|
return outlet instanceof HTMLElement ? outlet : null;
|
|
7761
7884
|
}
|
|
7885
|
+
function isFullDocument(html) {
|
|
7886
|
+
return /^\s*(?:<!--[^]*?-->\s*)*(?:<!doctype\s+html\b|<html(?:\s|>))/i.test(html);
|
|
7887
|
+
}
|
|
7762
7888
|
function saveSnapshot(url, html) {
|
|
7763
7889
|
// create HTMLElement by html string to remove scripts and get clean snapshot
|
|
7764
7890
|
const doc = parseNavigationDocument(html);
|
|
7891
|
+
doc.querySelectorAll('#gyos-progress-bar').forEach(node => node.remove());
|
|
7765
7892
|
// Ignore hash for snapshot keys
|
|
7766
7893
|
if (url.includes('#'))
|
|
7767
7894
|
url = url.split('#')[0];
|
|
@@ -7770,7 +7897,7 @@ function saveSnapshot(url, html) {
|
|
|
7770
7897
|
if (s.hasAttribute('g-script-once'))
|
|
7771
7898
|
s.textContent = '';
|
|
7772
7899
|
});
|
|
7773
|
-
snapshots.set(url, { html: doc.documentElement.outerHTML });
|
|
7900
|
+
snapshots.set(url, { html: doc.documentElement.outerHTML, fullDocument: isFullDocument(html) });
|
|
7774
7901
|
log('[GyosRouter] snapshot saved for', url);
|
|
7775
7902
|
}
|
|
7776
7903
|
function getOutletIndex(root, target) {
|
|
@@ -7882,10 +8009,10 @@ function consumeViewTransitionRejection(promise) {
|
|
|
7882
8009
|
// update callback remains the navigation source of truth and is awaited below.
|
|
7883
8010
|
void promise?.catch(() => undefined);
|
|
7884
8011
|
}
|
|
7885
|
-
function runNavigationHooks(callbacks, url) {
|
|
7886
|
-
callbacks.forEach(callback => {
|
|
8012
|
+
function runNavigationHooks(callbacks, url, context) {
|
|
8013
|
+
[...callbacks].forEach(callback => {
|
|
7887
8014
|
try {
|
|
7888
|
-
callback(url);
|
|
8015
|
+
callback(url, { ...context });
|
|
7889
8016
|
}
|
|
7890
8017
|
catch (error) {
|
|
7891
8018
|
console.error('[GyosRouter] navigation hook error', error);
|
|
@@ -7923,7 +8050,13 @@ function buildRequest(opts) {
|
|
|
7923
8050
|
url = mergeFormDataIntoUrl(url, opts.formData);
|
|
7924
8051
|
}
|
|
7925
8052
|
else {
|
|
7926
|
-
|
|
8053
|
+
if (opts.formEncoding === 'application/x-www-form-urlencoded') {
|
|
8054
|
+
const encoded = new URLSearchParams();
|
|
8055
|
+
opts.formData.forEach((value, name) => encoded.append(name, typeof value === 'string' ? value : value.name));
|
|
8056
|
+
init.body = encoded;
|
|
8057
|
+
}
|
|
8058
|
+
else
|
|
8059
|
+
init.body = opts.formData;
|
|
7927
8060
|
}
|
|
7928
8061
|
}
|
|
7929
8062
|
else if (opts.jsonData) {
|
|
@@ -7966,25 +8099,26 @@ function preload(url) {
|
|
|
7966
8099
|
preloadControllers.delete(cacheKey);
|
|
7967
8100
|
});
|
|
7968
8101
|
}
|
|
7969
|
-
async function updateHead(fromDoc, signal) {
|
|
8102
|
+
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
7970
8103
|
const allowedSelector = 'meta, link, style:not(#gyos-transitions), script';
|
|
7971
8104
|
const currentNodes = Array.from(document.head.querySelectorAll(allowedSelector));
|
|
7972
8105
|
const nextNodes = Array.from(fromDoc.head.querySelectorAll(allowedSelector));
|
|
7973
|
-
await diffNodes(currentNodes, nextNodes, document.head, signal);
|
|
8106
|
+
await diffNodes(currentNodes, nextNodes, document.head, signal, currentBaseUrl);
|
|
7974
8107
|
}
|
|
7975
|
-
async function scriptNotInOutletTarget(fromDoc, target, source, signal) {
|
|
8108
|
+
async function scriptNotInOutletTarget(fromDoc, target, source, signal, currentBaseUrl) {
|
|
7976
8109
|
// scripts in current document and it not in target outlet
|
|
7977
8110
|
const currentScripts = Array.from(document.scripts).filter(s => !target.contains(s) && !document.head.contains(s));
|
|
7978
8111
|
// scripts in fromDoc and it not in source outlet
|
|
7979
8112
|
const incomingScripts = Array.from(fromDoc.scripts).filter(s => !source.contains(s) && !fromDoc.head.contains(s));
|
|
7980
8113
|
// Diff and update scripts not in outlet/target
|
|
7981
|
-
await diffNodes(currentScripts, incomingScripts, document.body, signal);
|
|
8114
|
+
await diffNodes(currentScripts, incomingScripts, document.body, signal, currentBaseUrl);
|
|
7982
8115
|
}
|
|
7983
8116
|
function resolveIncomingScriptUrls(root, baseUrl) {
|
|
7984
|
-
root.querySelectorAll('script[src]').forEach(
|
|
7985
|
-
const
|
|
8117
|
+
root.querySelectorAll('script[src], link[href]').forEach(node => {
|
|
8118
|
+
const attribute = node.tagName === 'SCRIPT' ? 'src' : 'href';
|
|
8119
|
+
const source = node.getAttribute(attribute);
|
|
7986
8120
|
if (source)
|
|
7987
|
-
|
|
8121
|
+
node.setAttribute(attribute, new URL(source, baseUrl).href);
|
|
7988
8122
|
});
|
|
7989
8123
|
}
|
|
7990
8124
|
function isNavigableHtmlResponse(response) {
|
|
@@ -8038,6 +8172,22 @@ async function navigate(opts) {
|
|
|
8038
8172
|
resolveDone
|
|
8039
8173
|
};
|
|
8040
8174
|
activeNavigation = transaction;
|
|
8175
|
+
const currentBaseUrl = document.baseURI;
|
|
8176
|
+
rememberResourceUrls(document, currentBaseUrl);
|
|
8177
|
+
const context = {
|
|
8178
|
+
from: currentUrl, url: opts.url, method: opts.method.toUpperCase(),
|
|
8179
|
+
trigger: opts.trigger || null, target: null, form: opts.form || null,
|
|
8180
|
+
popstate: opts.popstate === true, signal: transaction.controller.signal,
|
|
8181
|
+
status: null, committed: false, fallback: false, outcome: null
|
|
8182
|
+
};
|
|
8183
|
+
const formEvent = opts.form
|
|
8184
|
+
? { form: opts.form, url: opts.url, status: null, outcome: null, committed: false, fallback: false }
|
|
8185
|
+
: null;
|
|
8186
|
+
const fallback = (url, requestSent) => {
|
|
8187
|
+
context.fallback = context.method === 'GET' || (!requestSent && !!opts.form);
|
|
8188
|
+
context.outcome ?? (context.outcome = context.fallback ? 'fallback' : 'invalid-response');
|
|
8189
|
+
fallbackFromBoost(opts, url, requestSent);
|
|
8190
|
+
};
|
|
8041
8191
|
const hasTargetSpinner = opts.trigger?.hasAttribute('g-router-spin');
|
|
8042
8192
|
const setRand = () => {
|
|
8043
8193
|
if (isActiveNavigation(transaction) && progressBar?.getCurrentProgress() < 70) {
|
|
@@ -8045,7 +8195,10 @@ async function navigate(opts) {
|
|
|
8045
8195
|
}
|
|
8046
8196
|
};
|
|
8047
8197
|
try {
|
|
8048
|
-
|
|
8198
|
+
if (formEvent)
|
|
8199
|
+
document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
|
|
8200
|
+
runNavigationHooks(beforeNavigate, opts.url, context);
|
|
8201
|
+
assertActiveNavigation(transaction);
|
|
8049
8202
|
progressBar?.start();
|
|
8050
8203
|
// popstate already points history at the destination entry. Keep the visible
|
|
8051
8204
|
// page's position under currentUrl without overwriting that destination state.
|
|
@@ -8054,9 +8207,10 @@ async function navigate(opts) {
|
|
|
8054
8207
|
saveScrollPosition();
|
|
8055
8208
|
// Pick target element to swap
|
|
8056
8209
|
let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
|
|
8210
|
+
context.target = target;
|
|
8057
8211
|
if (!target) {
|
|
8058
8212
|
if (isActiveNavigation(transaction))
|
|
8059
|
-
|
|
8213
|
+
fallback(opts.url, false);
|
|
8060
8214
|
return;
|
|
8061
8215
|
}
|
|
8062
8216
|
const swapMode = (opts.swapMode || opts.trigger?.getAttribute('g-swap') || 'inner').toLowerCase();
|
|
@@ -8081,6 +8235,7 @@ async function navigate(opts) {
|
|
|
8081
8235
|
if (hasTargetSpinner)
|
|
8082
8236
|
transaction.spinner = showTargetSpinner(target, swapMode);
|
|
8083
8237
|
const { finalUrl, init } = buildRequest(opts);
|
|
8238
|
+
context.url = finalUrl;
|
|
8084
8239
|
// Add abort signal to request
|
|
8085
8240
|
init.signal = transaction.controller.signal;
|
|
8086
8241
|
let html;
|
|
@@ -8108,7 +8263,8 @@ async function navigate(opts) {
|
|
|
8108
8263
|
if (error.name === 'AbortError')
|
|
8109
8264
|
throw error;
|
|
8110
8265
|
assertActiveNavigation(transaction);
|
|
8111
|
-
|
|
8266
|
+
context.outcome = 'network-error';
|
|
8267
|
+
fallback(finalUrl, true);
|
|
8112
8268
|
return;
|
|
8113
8269
|
}
|
|
8114
8270
|
preloadCache.delete(preloadKey); // consume cache
|
|
@@ -8133,28 +8289,46 @@ async function navigate(opts) {
|
|
|
8133
8289
|
log('[GyosRouter] Navigation cancelled');
|
|
8134
8290
|
return;
|
|
8135
8291
|
}
|
|
8292
|
+
context.outcome = 'network-error';
|
|
8136
8293
|
if (isActiveNavigation(transaction))
|
|
8137
|
-
|
|
8294
|
+
fallback(finalUrl, true);
|
|
8138
8295
|
return;
|
|
8139
8296
|
}
|
|
8140
8297
|
}
|
|
8141
8298
|
assertActiveNavigation(transaction);
|
|
8142
|
-
|
|
8143
|
-
|
|
8299
|
+
context.status = response?.status ?? null;
|
|
8300
|
+
context.url = response?.url || finalUrl;
|
|
8301
|
+
const acceptedErrors = (opts.trigger?.getAttribute('g-boost-errors') || '').split(/[\s,]+/);
|
|
8302
|
+
const renderHttpError = !!response && response.status >= 400 && response.status <= 599
|
|
8303
|
+
&& acceptedErrors.includes(String(response.status));
|
|
8304
|
+
if (response && !response.ok)
|
|
8305
|
+
context.outcome = 'http-error';
|
|
8306
|
+
if (!response || (!response.ok && !renderHttpError) || !isNavigableHtmlResponse(response)) {
|
|
8307
|
+
context.outcome ?? (context.outcome = 'invalid-response');
|
|
8144
8308
|
if (isActiveNavigation(transaction))
|
|
8145
|
-
|
|
8309
|
+
fallback(finalUrl, true);
|
|
8146
8310
|
return;
|
|
8147
8311
|
}
|
|
8148
8312
|
html = await response.text();
|
|
8149
8313
|
assertActiveNavigation(transaction);
|
|
8150
|
-
if (!opts.popstate && target.hasAttribute('g-snapshot')) {
|
|
8151
|
-
saveSnapshot(canonicalUrl(response.url || finalUrl), html);
|
|
8152
|
-
}
|
|
8153
8314
|
}
|
|
8154
8315
|
// Parse HTML
|
|
8155
8316
|
const doc = html
|
|
8156
8317
|
? parseNavigationDocument(html)
|
|
8157
8318
|
: document.implementation.createHTMLDocument();
|
|
8319
|
+
// Detached parsing cannot tell whether the live CSP permits an incoming base.
|
|
8320
|
+
// Let native navigation enforce base-uri instead of authorizing its URLs ourselves.
|
|
8321
|
+
if (doc.querySelector('base[href]') || opts.historyFragment?.querySelector('base[href]')) {
|
|
8322
|
+
context.outcome = 'invalid-response';
|
|
8323
|
+
fallback(response?.url || finalUrl, true);
|
|
8324
|
+
return;
|
|
8325
|
+
}
|
|
8326
|
+
if (response?.ok && !opts.popstate && target.hasAttribute('g-snapshot')) {
|
|
8327
|
+
saveSnapshot(canonicalUrl(response.url || finalUrl), html);
|
|
8328
|
+
}
|
|
8329
|
+
const syncDocumentAttributes = isFullOutletNavigation && destructiveSwap && !currentHead
|
|
8330
|
+
&& !opts.historyFragment && (opts.popstate && snapshots.has(urlWithoutHash)
|
|
8331
|
+
? snapshots.get(urlWithoutHash).fullDocument : isFullDocument(html || ''));
|
|
8158
8332
|
// Pick source fragment
|
|
8159
8333
|
const src = opts.historyFragment || pickSourceFragment(doc, target, targetOutletIndex);
|
|
8160
8334
|
stripInertFallbackContent(src);
|
|
@@ -8166,15 +8340,18 @@ async function navigate(opts) {
|
|
|
8166
8340
|
targetUrl += finalUrl.substring(finalUrl.indexOf('#'));
|
|
8167
8341
|
}
|
|
8168
8342
|
resolveIncomingScriptUrls(doc, targetUrl);
|
|
8343
|
+
context.url = targetUrl;
|
|
8169
8344
|
if (opts.historyFragment)
|
|
8170
8345
|
resolveIncomingScriptUrls(src, targetUrl);
|
|
8171
8346
|
const triggerChangesState = opts.trigger?.hasAttribute('g-change-state') || false;
|
|
8172
8347
|
const keepsCurrentState = opts.trigger?.hasAttribute('g-current-state') || false;
|
|
8173
8348
|
const redirectedSubmission = opts.method.toUpperCase() !== 'GET' && response?.redirected === true;
|
|
8174
|
-
const changesState = !keepsCurrentState && (opts.changeState === true || triggerChangesState || redirectedSubmission);
|
|
8349
|
+
const changesState = context.outcome !== 'http-error' && !keepsCurrentState && (opts.changeState === true || triggerChangesState || redirectedSubmission);
|
|
8175
8350
|
const performUpdate = async () => {
|
|
8176
8351
|
assertActiveNavigation(transaction);
|
|
8177
8352
|
transaction.committing = true;
|
|
8353
|
+
runNavigationHooks(beforeSwap, targetUrl, context);
|
|
8354
|
+
assertActiveNavigation(transaction);
|
|
8178
8355
|
// Update progress to rand 80 - 90% before swap
|
|
8179
8356
|
progressBar?.setProgress(Math.random() * 10 + 80);
|
|
8180
8357
|
const outgoingHistoryFragment = changesState && !opts.replace && !isFullOutletNavigation
|
|
@@ -8245,21 +8422,34 @@ async function navigate(opts) {
|
|
|
8245
8422
|
beforeScripts: async () => {
|
|
8246
8423
|
if (!isFullOutletNavigation || currentHead)
|
|
8247
8424
|
return;
|
|
8425
|
+
if (syncDocumentAttributes) {
|
|
8426
|
+
for (const name of ['lang', 'dir']) {
|
|
8427
|
+
const value = doc.documentElement.getAttribute(name);
|
|
8428
|
+
if (value === null)
|
|
8429
|
+
document.documentElement.removeAttribute(name);
|
|
8430
|
+
else
|
|
8431
|
+
document.documentElement.setAttribute(name, value);
|
|
8432
|
+
}
|
|
8433
|
+
}
|
|
8248
8434
|
const incomingTitle = doc.querySelector('title');
|
|
8249
8435
|
if (incomingTitle) {
|
|
8250
8436
|
document.title = incomingTitle.textContent || document.title;
|
|
8251
8437
|
}
|
|
8252
|
-
await updateHead(doc, transaction.controller.signal);
|
|
8438
|
+
await updateHead(doc, transaction.controller.signal, currentBaseUrl);
|
|
8253
8439
|
assertActiveNavigation(transaction);
|
|
8254
8440
|
},
|
|
8255
8441
|
onCommitted: (committedTarget, roots) => {
|
|
8256
8442
|
target = committedTarget;
|
|
8443
|
+
context.target = committedTarget;
|
|
8444
|
+
context.committed = true;
|
|
8445
|
+
progressBar?.reconnect();
|
|
8257
8446
|
committedRoots = roots;
|
|
8258
8447
|
}
|
|
8259
8448
|
});
|
|
8449
|
+
context.committed = true;
|
|
8260
8450
|
assertActiveNavigation(transaction);
|
|
8261
8451
|
if (isFullOutletNavigation) {
|
|
8262
|
-
await scriptNotInOutletTarget(doc, target, src, transaction.controller.signal);
|
|
8452
|
+
await scriptNotInOutletTarget(doc, target, src, transaction.controller.signal, currentBaseUrl);
|
|
8263
8453
|
assertActiveNavigation(transaction);
|
|
8264
8454
|
}
|
|
8265
8455
|
}
|
|
@@ -8293,14 +8483,15 @@ async function navigate(opts) {
|
|
|
8293
8483
|
await performUpdate();
|
|
8294
8484
|
}
|
|
8295
8485
|
assertActiveNavigation(transaction);
|
|
8296
|
-
if (removeTriggerAfterCommit && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
|
|
8486
|
+
if (removeTriggerAfterCommit && context.outcome !== 'http-error' && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
|
|
8297
8487
|
disposeEffects(opts.trigger);
|
|
8298
8488
|
opts.trigger.remove();
|
|
8299
8489
|
}
|
|
8300
8490
|
if (hasTargetSpinner)
|
|
8301
8491
|
hideTargetSpinner(transaction.spinner);
|
|
8302
8492
|
transaction.spinner = null;
|
|
8303
|
-
|
|
8493
|
+
context.outcome ?? (context.outcome = 'success');
|
|
8494
|
+
runNavigationHooks(afterNavigate, targetUrl, context);
|
|
8304
8495
|
log('[GyosRouter] navigated to', targetUrl);
|
|
8305
8496
|
currentUrl = changesState
|
|
8306
8497
|
? canonicalUrl(targetUrl, true)
|
|
@@ -8316,11 +8507,15 @@ async function navigate(opts) {
|
|
|
8316
8507
|
return;
|
|
8317
8508
|
}
|
|
8318
8509
|
if (isActiveNavigation(transaction)) {
|
|
8510
|
+
context.outcome ?? (context.outcome = 'error');
|
|
8319
8511
|
console.error('[GyosRouter] navigation error', error);
|
|
8320
|
-
|
|
8512
|
+
fallback(opts.url, true);
|
|
8321
8513
|
}
|
|
8322
8514
|
}
|
|
8323
8515
|
finally {
|
|
8516
|
+
if (transaction.controller.signal.aborted)
|
|
8517
|
+
context.outcome = 'aborted';
|
|
8518
|
+
context.outcome ?? (context.outcome = 'aborted');
|
|
8324
8519
|
if (transaction.interval)
|
|
8325
8520
|
clearInterval(transaction.interval);
|
|
8326
8521
|
if (transaction.spinner)
|
|
@@ -8330,6 +8525,15 @@ async function navigate(opts) {
|
|
|
8330
8525
|
progressBar?.complete();
|
|
8331
8526
|
}
|
|
8332
8527
|
transaction.resolveDone();
|
|
8528
|
+
if (formEvent)
|
|
8529
|
+
submittingForms.delete(formEvent.form);
|
|
8530
|
+
runNavigationHooks(navigationEnd, context.url, context);
|
|
8531
|
+
if (formEvent) {
|
|
8532
|
+
const { url, status, outcome, committed, fallback } = context;
|
|
8533
|
+
document.dispatchEvent(new CustomEvent('gyos:form-end', {
|
|
8534
|
+
detail: { ...formEvent, url, status, outcome, committed, fallback }
|
|
8535
|
+
}));
|
|
8536
|
+
}
|
|
8333
8537
|
}
|
|
8334
8538
|
}
|
|
8335
8539
|
function shouldBoost(el) {
|
|
@@ -8438,16 +8642,34 @@ function onSubmit(event) {
|
|
|
8438
8642
|
return;
|
|
8439
8643
|
if (shouldDeferToFormValidation(form))
|
|
8440
8644
|
return;
|
|
8441
|
-
event.
|
|
8442
|
-
const
|
|
8443
|
-
const
|
|
8444
|
-
const
|
|
8445
|
-
|
|
8446
|
-
|
|
8645
|
+
const submitter = event.submitter;
|
|
8646
|
+
const override = (name) => submitter?.getAttribute(`form${name}`) ?? form.getAttribute(name);
|
|
8647
|
+
const target = override('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
8648
|
+
const declaredMethod = (override('method') || 'GET').toUpperCase();
|
|
8649
|
+
const method = ['GET', 'POST', 'DIALOG'].includes(declaredMethod) ? declaredMethod : 'GET';
|
|
8650
|
+
const formEncoding = override('enctype')?.toLowerCase();
|
|
8651
|
+
if ((target && target.toLowerCase() !== '_self') || method === 'DIALOG' || formEncoding === 'text/plain')
|
|
8652
|
+
return;
|
|
8653
|
+
if (!resolveTarget(form))
|
|
8447
8654
|
return;
|
|
8655
|
+
// Image submitters carry click coordinates which SubmitEvent does not expose.
|
|
8656
|
+
if (submitter instanceof HTMLInputElement && submitter.type === 'image')
|
|
8657
|
+
return;
|
|
8658
|
+
let url;
|
|
8659
|
+
try {
|
|
8660
|
+
url = new URL(override('action') || window.location.href, document.baseURI);
|
|
8448
8661
|
}
|
|
8449
|
-
|
|
8450
|
-
|
|
8662
|
+
catch {
|
|
8663
|
+
return;
|
|
8664
|
+
}
|
|
8665
|
+
if (url.origin !== window.location.origin)
|
|
8666
|
+
return;
|
|
8667
|
+
event.preventDefault();
|
|
8668
|
+
if (submittingForms.has(form))
|
|
8669
|
+
return;
|
|
8670
|
+
const formData = new FormData(form, submitter);
|
|
8671
|
+
submittingForms.add(form);
|
|
8672
|
+
void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
|
|
8451
8673
|
}
|
|
8452
8674
|
function onPopState(event) {
|
|
8453
8675
|
const url = window.location.href;
|
|
@@ -8552,23 +8774,25 @@ const Gyos = {
|
|
|
8552
8774
|
startRouter,
|
|
8553
8775
|
onBeforeNavigate,
|
|
8554
8776
|
onAfterNavigate,
|
|
8777
|
+
onBeforeSwap,
|
|
8778
|
+
onNavigationEnd,
|
|
8555
8779
|
portalCreate,
|
|
8556
8780
|
portalDestroy,
|
|
8557
8781
|
setCspNonce,
|
|
8558
|
-
version: '0.
|
|
8782
|
+
version: '0.4.1'
|
|
8559
8783
|
};
|
|
8560
8784
|
|
|
8561
8785
|
// This file was generated. Do not modify manually!
|
|
8562
|
-
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,
|
|
8786
|
+
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];
|
|
8563
8787
|
|
|
8564
8788
|
// This file was generated. Do not modify manually!
|
|
8565
|
-
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,
|
|
8789
|
+
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];
|
|
8566
8790
|
|
|
8567
8791
|
// This file was generated. Do not modify manually!
|
|
8568
|
-
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-\
|
|
8792
|
+
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";
|
|
8569
8793
|
|
|
8570
8794
|
// This file was generated. Do not modify manually!
|
|
8571
|
-
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-\
|
|
8795
|
+
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";
|
|
8572
8796
|
|
|
8573
8797
|
// These are a run-length and offset encoded representation of the
|
|
8574
8798
|
// >0xffff code points that are a valid part of identifiers. The
|
|
@@ -8893,9 +9117,12 @@ var defaultOptions = {
|
|
|
8893
9117
|
// for new syntax features.
|
|
8894
9118
|
ecmaVersion: null,
|
|
8895
9119
|
// `sourceType` indicates the mode the code should be parsed in.
|
|
8896
|
-
// Can be either `"script"` or `"
|
|
9120
|
+
// Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
|
|
8897
9121
|
// strict mode and parsing of `import` and `export` declarations.
|
|
8898
9122
|
sourceType: "script",
|
|
9123
|
+
// When set to true, enable strict parsing mode even if `sourceType`
|
|
9124
|
+
// is `"script"`.
|
|
9125
|
+
strict: false,
|
|
8899
9126
|
// `onInsertedSemicolon` can be a callback that will be called when
|
|
8900
9127
|
// a semicolon is automatically inserted. It will be passed the
|
|
8901
9128
|
// position of the inserted semicolon as an offset, and if
|
|
@@ -8937,6 +9164,11 @@ var defaultOptions = {
|
|
|
8937
9164
|
// line being 1-based and column 0-based) will be attached to the
|
|
8938
9165
|
// nodes.
|
|
8939
9166
|
locations: false,
|
|
9167
|
+
// Pass an optional `{line, column}` object to use for the start of
|
|
9168
|
+
// the parse. This is mostly useful when using `parseExpressionAt`
|
|
9169
|
+
// with `locations: true`, to prevent the parser from having to
|
|
9170
|
+
// determine the line position at the start position.
|
|
9171
|
+
startLocation: null,
|
|
8940
9172
|
// A function can be passed as `onToken` option, which will
|
|
8941
9173
|
// cause Acorn to call that function with object in the same
|
|
8942
9174
|
// format as tokens returned from `tokenizer().getToken()`. Note
|
|
@@ -9017,6 +9249,9 @@ function getOptions(opts) {
|
|
|
9017
9249
|
if (isArray(options.onComment))
|
|
9018
9250
|
{ options.onComment = pushComment(options, options.onComment); }
|
|
9019
9251
|
|
|
9252
|
+
if (options.sourceType === "commonjs" && options.allowAwaitOutsideFunction)
|
|
9253
|
+
{ throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs") }
|
|
9254
|
+
|
|
9020
9255
|
return options
|
|
9021
9256
|
}
|
|
9022
9257
|
|
|
@@ -9048,6 +9283,7 @@ var
|
|
|
9048
9283
|
SCOPE_DIRECT_SUPER = 128,
|
|
9049
9284
|
SCOPE_CLASS_STATIC_BLOCK = 256,
|
|
9050
9285
|
SCOPE_CLASS_FIELD_INIT = 512,
|
|
9286
|
+
SCOPE_SWITCH = 1024,
|
|
9051
9287
|
SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
|
|
9052
9288
|
|
|
9053
9289
|
function functionFlags(async, generator) {
|
|
@@ -9086,13 +9322,17 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
9086
9322
|
// Set up token state
|
|
9087
9323
|
|
|
9088
9324
|
// The current position of the tokenizer in the input.
|
|
9089
|
-
|
|
9090
|
-
|
|
9325
|
+
this.pos = startPos || 0;
|
|
9326
|
+
this.curLine = 1;
|
|
9327
|
+
if (options.startLocation) {
|
|
9328
|
+
this.lineStart = this.pos - options.startLocation.column;
|
|
9329
|
+
this.curLine = options.startLocation.line;
|
|
9330
|
+
} else if (startPos) {
|
|
9091
9331
|
this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
|
|
9092
|
-
|
|
9332
|
+
if (this.options.locations)
|
|
9333
|
+
{ this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; }
|
|
9093
9334
|
} else {
|
|
9094
|
-
this.
|
|
9095
|
-
this.curLine = 1;
|
|
9335
|
+
this.lineStart = 0;
|
|
9096
9336
|
}
|
|
9097
9337
|
|
|
9098
9338
|
// Properties of the current token:
|
|
@@ -9118,7 +9358,7 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
9118
9358
|
|
|
9119
9359
|
// Figure out if it's a module code.
|
|
9120
9360
|
this.inModule = options.sourceType === "module";
|
|
9121
|
-
this.strict = this.inModule || this.strictDirective(this.pos);
|
|
9361
|
+
this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
|
|
9122
9362
|
|
|
9123
9363
|
// Used to signify the start of a potential arrow function
|
|
9124
9364
|
this.potentialArrowAt = -1;
|
|
@@ -9137,7 +9377,12 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
9137
9377
|
|
|
9138
9378
|
// Scope tracking for duplicate variable names (see scope.js)
|
|
9139
9379
|
this.scopeStack = [];
|
|
9140
|
-
this.enterScope(
|
|
9380
|
+
this.enterScope(
|
|
9381
|
+
this.options.sourceType === "commonjs"
|
|
9382
|
+
// In commonjs, the top-level scope behaves like a function scope
|
|
9383
|
+
? SCOPE_FUNCTION
|
|
9384
|
+
: SCOPE_TOP
|
|
9385
|
+
);
|
|
9141
9386
|
|
|
9142
9387
|
// For RegExp validation
|
|
9143
9388
|
this.regexpState = null;
|
|
@@ -9148,12 +9393,14 @@ var Parser = function Parser(options, input, startPos) {
|
|
|
9148
9393
|
this.privateNameStack = [];
|
|
9149
9394
|
};
|
|
9150
9395
|
|
|
9151
|
-
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 } };
|
|
9396
|
+
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 } };
|
|
9152
9397
|
|
|
9153
9398
|
Parser.prototype.parse = function parse () {
|
|
9399
|
+
var this$1$1 = this;
|
|
9400
|
+
|
|
9154
9401
|
var node = this.options.program || this.startNode();
|
|
9155
9402
|
this.nextToken();
|
|
9156
|
-
return this.parseTopLevel(node)
|
|
9403
|
+
return this.catchStackOverflow(function () { return this$1$1.parseTopLevel(node); })
|
|
9157
9404
|
};
|
|
9158
9405
|
|
|
9159
9406
|
prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
|
|
@@ -9172,6 +9419,12 @@ prototypeAccessors.canAwait.get = function () {
|
|
|
9172
9419
|
return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
|
|
9173
9420
|
};
|
|
9174
9421
|
|
|
9422
|
+
prototypeAccessors.allowReturn.get = function () {
|
|
9423
|
+
if (this.inFunction) { return true }
|
|
9424
|
+
if (this.options.allowReturnOutsideFunction && this.currentVarScope().flags & SCOPE_TOP) { return true }
|
|
9425
|
+
return false
|
|
9426
|
+
};
|
|
9427
|
+
|
|
9175
9428
|
prototypeAccessors.allowSuper.get = function () {
|
|
9176
9429
|
var ref = this.currentThisScope();
|
|
9177
9430
|
var flags = ref.flags;
|
|
@@ -9192,6 +9445,14 @@ prototypeAccessors.allowNewDotTarget.get = function () {
|
|
|
9192
9445
|
return false
|
|
9193
9446
|
};
|
|
9194
9447
|
|
|
9448
|
+
prototypeAccessors.allowUsing.get = function () {
|
|
9449
|
+
var ref = this.currentScope();
|
|
9450
|
+
var flags = ref.flags;
|
|
9451
|
+
if (flags & SCOPE_SWITCH) { return false }
|
|
9452
|
+
if (!this.inModule && flags & SCOPE_TOP) { return false }
|
|
9453
|
+
return true
|
|
9454
|
+
};
|
|
9455
|
+
|
|
9195
9456
|
prototypeAccessors.inClassStaticBlock.get = function () {
|
|
9196
9457
|
return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
|
|
9197
9458
|
};
|
|
@@ -9278,6 +9539,17 @@ pp$9.eatContextual = function(name) {
|
|
|
9278
9539
|
return true
|
|
9279
9540
|
};
|
|
9280
9541
|
|
|
9542
|
+
pp$9.catchStackOverflow = function(f) {
|
|
9543
|
+
try {
|
|
9544
|
+
return f()
|
|
9545
|
+
} catch (e) {
|
|
9546
|
+
if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message)))
|
|
9547
|
+
{ this.raise(this.start, "Not enough stack space to parse input"); }
|
|
9548
|
+
else
|
|
9549
|
+
{ throw e }
|
|
9550
|
+
}
|
|
9551
|
+
};
|
|
9552
|
+
|
|
9281
9553
|
// Asserts that following token is given contextual keyword.
|
|
9282
9554
|
|
|
9283
9555
|
pp$9.expectContextual = function(name) {
|
|
@@ -9381,10 +9653,10 @@ var pp$8 = Parser.prototype;
|
|
|
9381
9653
|
// to its body instead of creating a new node.
|
|
9382
9654
|
|
|
9383
9655
|
pp$8.parseTopLevel = function(node) {
|
|
9384
|
-
var exports = Object.create(null);
|
|
9656
|
+
var exports$1 = Object.create(null);
|
|
9385
9657
|
if (!node.body) { node.body = []; }
|
|
9386
9658
|
while (this.type !== types$1.eof) {
|
|
9387
|
-
var stmt = this.parseStatement(null, true, exports);
|
|
9659
|
+
var stmt = this.parseStatement(null, true, exports$1);
|
|
9388
9660
|
node.body.push(stmt);
|
|
9389
9661
|
}
|
|
9390
9662
|
if (this.inModule)
|
|
@@ -9396,7 +9668,7 @@ pp$8.parseTopLevel = function(node) {
|
|
|
9396
9668
|
} }
|
|
9397
9669
|
this.adaptDirectivePrologue(node.body);
|
|
9398
9670
|
this.next();
|
|
9399
|
-
node.sourceType = this.options.sourceType;
|
|
9671
|
+
node.sourceType = this.options.sourceType === "commonjs" ? "script" : this.options.sourceType;
|
|
9400
9672
|
return this.finishNode(node, "Program")
|
|
9401
9673
|
};
|
|
9402
9674
|
|
|
@@ -9406,7 +9678,7 @@ pp$8.isLet = function(context) {
|
|
|
9406
9678
|
if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
|
|
9407
9679
|
skipWhiteSpace.lastIndex = this.pos;
|
|
9408
9680
|
var skip = skipWhiteSpace.exec(this.input);
|
|
9409
|
-
var next = this.pos + skip[0].length, nextCh = this.
|
|
9681
|
+
var next = this.pos + skip[0].length, nextCh = this.fullCharCodeAt(next);
|
|
9410
9682
|
// For ambiguous cases, determine if a LexicalDeclaration (or only a
|
|
9411
9683
|
// Statement) is allowed here. If context is not empty then only a Statement
|
|
9412
9684
|
// is allowed. However, `let [` is an explicit negative lookahead for
|
|
@@ -9414,12 +9686,13 @@ pp$8.isLet = function(context) {
|
|
|
9414
9686
|
if (nextCh === 91 || nextCh === 92) { return true } // '[', '\'
|
|
9415
9687
|
if (context) { return false }
|
|
9416
9688
|
|
|
9417
|
-
if (nextCh === 123
|
|
9418
|
-
if (isIdentifierStart(nextCh
|
|
9419
|
-
var
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9689
|
+
if (nextCh === 123) { return true } // '{'
|
|
9690
|
+
if (isIdentifierStart(nextCh)) {
|
|
9691
|
+
var start = next;
|
|
9692
|
+
do { next += nextCh <= 0xffff ? 1 : 2; }
|
|
9693
|
+
while (isIdentifierChar(nextCh = this.fullCharCodeAt(next)))
|
|
9694
|
+
if (nextCh === 92) { return true }
|
|
9695
|
+
var ident = this.input.slice(start, next);
|
|
9423
9696
|
if (!keywordRelationalOperator.test(ident)) { return true }
|
|
9424
9697
|
}
|
|
9425
9698
|
return false
|
|
@@ -9438,7 +9711,7 @@ pp$8.isAsyncFunction = function() {
|
|
|
9438
9711
|
return !lineBreak.test(this.input.slice(this.pos, next)) &&
|
|
9439
9712
|
this.input.slice(next, next + 8) === "function" &&
|
|
9440
9713
|
(next + 8 === this.input.length ||
|
|
9441
|
-
!(isIdentifierChar(after = this.
|
|
9714
|
+
!(isIdentifierChar(after = this.fullCharCodeAt(next + 8)) || after === 92 /* '\' */))
|
|
9442
9715
|
};
|
|
9443
9716
|
|
|
9444
9717
|
pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
|
|
@@ -9452,28 +9725,39 @@ pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
|
|
|
9452
9725
|
if (lineBreak.test(this.input.slice(this.pos, next))) { return false }
|
|
9453
9726
|
|
|
9454
9727
|
if (isAwaitUsing) {
|
|
9455
|
-
var
|
|
9456
|
-
if (this.input.slice(next,
|
|
9457
|
-
|
|
9458
|
-
isIdentifierChar(after = this.
|
|
9459
|
-
|
|
9728
|
+
var usingEndPos = next + 5 /* using */, after;
|
|
9729
|
+
if (this.input.slice(next, usingEndPos) !== "using" ||
|
|
9730
|
+
usingEndPos === this.input.length ||
|
|
9731
|
+
isIdentifierChar(after = this.fullCharCodeAt(usingEndPos)) ||
|
|
9732
|
+
after === 92 /* '\' */
|
|
9460
9733
|
) { return false }
|
|
9461
9734
|
|
|
9462
|
-
skipWhiteSpace.lastIndex =
|
|
9735
|
+
skipWhiteSpace.lastIndex = usingEndPos;
|
|
9463
9736
|
var skipAfterUsing = skipWhiteSpace.exec(this.input);
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9737
|
+
next = usingEndPos + skipAfterUsing[0].length;
|
|
9738
|
+
if (skipAfterUsing && lineBreak.test(this.input.slice(usingEndPos, next))) { return false }
|
|
9739
|
+
}
|
|
9740
|
+
|
|
9741
|
+
var ch = this.fullCharCodeAt(next);
|
|
9742
|
+
if (!isIdentifierStart(ch) && ch !== 92 /* '\' */) { return false }
|
|
9743
|
+
var idStart = next;
|
|
9744
|
+
do { next += ch <= 0xffff ? 1 : 2; }
|
|
9745
|
+
while (isIdentifierChar(ch = this.fullCharCodeAt(next)))
|
|
9746
|
+
if (ch === 92) { return true }
|
|
9747
|
+
var id = this.input.slice(idStart, next);
|
|
9748
|
+
if (keywordRelationalOperator.test(id)) { return false }
|
|
9749
|
+
if (isFor && !isAwaitUsing && id === "of") {
|
|
9750
|
+
// Look ahead for using declaration with initializer, i.e., `for (using of = ...)`
|
|
9751
|
+
skipWhiteSpace.lastIndex = next;
|
|
9752
|
+
var skipAfterOf = skipWhiteSpace.exec(this.input);
|
|
9753
|
+
next = next + skipAfterOf[0].length;
|
|
9754
|
+
if (this.input.charCodeAt(next) !== 61 /* '=' */ ||
|
|
9755
|
+
// Check for ==, === and => operators
|
|
9756
|
+
(ch = this.input.charCodeAt(next + 1)) === 61 /* '=' */ || ch === 62 /* '>' */) {
|
|
9757
|
+
return false
|
|
9472
9758
|
}
|
|
9473
9759
|
}
|
|
9474
|
-
|
|
9475
|
-
var ch = this.input.charCodeAt(next);
|
|
9476
|
-
return isIdentifierStart(ch, true) || ch === 92 // '\'
|
|
9760
|
+
return true
|
|
9477
9761
|
};
|
|
9478
9762
|
|
|
9479
9763
|
pp$8.isAwaitUsing = function(isFor) {
|
|
@@ -9491,7 +9775,7 @@ pp$8.isUsing = function(isFor) {
|
|
|
9491
9775
|
// `if (foo) /blah/.exec(foo)`, where looking at the previous token
|
|
9492
9776
|
// does not help.
|
|
9493
9777
|
|
|
9494
|
-
pp$8.parseStatement = function(context, topLevel, exports) {
|
|
9778
|
+
pp$8.parseStatement = function(context, topLevel, exports$1) {
|
|
9495
9779
|
var starttype = this.type, node = this.startNode(), kind;
|
|
9496
9780
|
|
|
9497
9781
|
if (this.isLet(context)) {
|
|
@@ -9546,7 +9830,7 @@ pp$8.parseStatement = function(context, topLevel, exports) {
|
|
|
9546
9830
|
if (!this.inModule)
|
|
9547
9831
|
{ this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
|
|
9548
9832
|
}
|
|
9549
|
-
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
|
|
9833
|
+
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1)
|
|
9550
9834
|
|
|
9551
9835
|
// If the statement does not start with a statement keyword or a
|
|
9552
9836
|
// brace, it's an ExpressionStatement or LabeledStatement. We
|
|
@@ -9562,8 +9846,12 @@ pp$8.parseStatement = function(context, topLevel, exports) {
|
|
|
9562
9846
|
|
|
9563
9847
|
var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null;
|
|
9564
9848
|
if (usingKind) {
|
|
9565
|
-
if (
|
|
9566
|
-
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`");
|
|
9849
|
+
if (!this.allowUsing) {
|
|
9850
|
+
this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
|
|
9851
|
+
}
|
|
9852
|
+
if (context) {
|
|
9853
|
+
// Cases like `for (;;) using x = ...;`, `if (true) await using x = ...;`, etc. are not allowed.
|
|
9854
|
+
this.raise(this.start, "Using declaration is not allowed in single-statement positions");
|
|
9567
9855
|
}
|
|
9568
9856
|
if (usingKind === "await using") {
|
|
9569
9857
|
if (!this.canAwait) {
|
|
@@ -9660,7 +9948,12 @@ pp$8.parseForStatement = function(node) {
|
|
|
9660
9948
|
if (usingKind) {
|
|
9661
9949
|
var init$2 = this.startNode();
|
|
9662
9950
|
this.next();
|
|
9663
|
-
if (usingKind === "await using") {
|
|
9951
|
+
if (usingKind === "await using") {
|
|
9952
|
+
if (!this.canAwait) {
|
|
9953
|
+
this.raise(this.start, "Await using cannot appear outside of async function");
|
|
9954
|
+
}
|
|
9955
|
+
this.next();
|
|
9956
|
+
}
|
|
9664
9957
|
this.parseVar(init$2, true, usingKind);
|
|
9665
9958
|
this.finishNode(init$2, "VariableDeclaration");
|
|
9666
9959
|
return this.parseForAfterInit(node, init$2, awaitAt)
|
|
@@ -9693,11 +9986,12 @@ pp$8.parseForStatement = function(node) {
|
|
|
9693
9986
|
// Helper method to parse for loop after variable initialization
|
|
9694
9987
|
pp$8.parseForAfterInit = function(node, init, awaitAt) {
|
|
9695
9988
|
if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
|
|
9696
|
-
if (this.
|
|
9697
|
-
if (
|
|
9698
|
-
|
|
9699
|
-
}
|
|
9700
|
-
|
|
9989
|
+
if (this.type === types$1._in) {
|
|
9990
|
+
if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
|
|
9991
|
+
this.raise(this.start, "Using declaration is not allowed in for-in loops");
|
|
9992
|
+
}
|
|
9993
|
+
if (this.options.ecmaVersion >= 9 && awaitAt > -1) { this.unexpected(awaitAt); }
|
|
9994
|
+
} else if (this.options.ecmaVersion >= 9) { node.await = awaitAt > -1; }
|
|
9701
9995
|
return this.parseForIn(node, init)
|
|
9702
9996
|
}
|
|
9703
9997
|
if (awaitAt > -1) { this.unexpected(awaitAt); }
|
|
@@ -9719,7 +10013,7 @@ pp$8.parseIfStatement = function(node) {
|
|
|
9719
10013
|
};
|
|
9720
10014
|
|
|
9721
10015
|
pp$8.parseReturnStatement = function(node) {
|
|
9722
|
-
if (!this.
|
|
10016
|
+
if (!this.allowReturn)
|
|
9723
10017
|
{ this.raise(this.start, "'return' outside of function"); }
|
|
9724
10018
|
this.next();
|
|
9725
10019
|
|
|
@@ -9738,7 +10032,7 @@ pp$8.parseSwitchStatement = function(node) {
|
|
|
9738
10032
|
node.cases = [];
|
|
9739
10033
|
this.expect(types$1.braceL);
|
|
9740
10034
|
this.labels.push(switchLabel);
|
|
9741
|
-
this.enterScope(
|
|
10035
|
+
this.enterScope(SCOPE_SWITCH);
|
|
9742
10036
|
|
|
9743
10037
|
// Statements under must be grouped (by label) in SwitchCase
|
|
9744
10038
|
// nodes. `cur` is used to keep the node that we are currently
|
|
@@ -10302,11 +10596,11 @@ function checkKeyName(node, name) {
|
|
|
10302
10596
|
|
|
10303
10597
|
// Parses module export declaration.
|
|
10304
10598
|
|
|
10305
|
-
pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
10599
|
+
pp$8.parseExportAllDeclaration = function(node, exports$1) {
|
|
10306
10600
|
if (this.options.ecmaVersion >= 11) {
|
|
10307
10601
|
if (this.eatContextual("as")) {
|
|
10308
10602
|
node.exported = this.parseModuleExportName();
|
|
10309
|
-
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
10603
|
+
this.checkExport(exports$1, node.exported, this.lastTokStart);
|
|
10310
10604
|
} else {
|
|
10311
10605
|
node.exported = null;
|
|
10312
10606
|
}
|
|
@@ -10320,14 +10614,14 @@ pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
|
10320
10614
|
return this.finishNode(node, "ExportAllDeclaration")
|
|
10321
10615
|
};
|
|
10322
10616
|
|
|
10323
|
-
pp$8.parseExport = function(node, exports) {
|
|
10617
|
+
pp$8.parseExport = function(node, exports$1) {
|
|
10324
10618
|
this.next();
|
|
10325
10619
|
// export * from '...'
|
|
10326
10620
|
if (this.eat(types$1.star)) {
|
|
10327
|
-
return this.parseExportAllDeclaration(node, exports)
|
|
10621
|
+
return this.parseExportAllDeclaration(node, exports$1)
|
|
10328
10622
|
}
|
|
10329
10623
|
if (this.eat(types$1._default)) { // export default ...
|
|
10330
|
-
this.checkExport(exports, "default", this.lastTokStart);
|
|
10624
|
+
this.checkExport(exports$1, "default", this.lastTokStart);
|
|
10331
10625
|
node.declaration = this.parseExportDefaultDeclaration();
|
|
10332
10626
|
return this.finishNode(node, "ExportDefaultDeclaration")
|
|
10333
10627
|
}
|
|
@@ -10335,16 +10629,16 @@ pp$8.parseExport = function(node, exports) {
|
|
|
10335
10629
|
if (this.shouldParseExportStatement()) {
|
|
10336
10630
|
node.declaration = this.parseExportDeclaration(node);
|
|
10337
10631
|
if (node.declaration.type === "VariableDeclaration")
|
|
10338
|
-
{ this.checkVariableExport(exports, node.declaration.declarations); }
|
|
10632
|
+
{ this.checkVariableExport(exports$1, node.declaration.declarations); }
|
|
10339
10633
|
else
|
|
10340
|
-
{ this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
|
|
10634
|
+
{ this.checkExport(exports$1, node.declaration.id, node.declaration.id.start); }
|
|
10341
10635
|
node.specifiers = [];
|
|
10342
10636
|
node.source = null;
|
|
10343
10637
|
if (this.options.ecmaVersion >= 16)
|
|
10344
10638
|
{ node.attributes = []; }
|
|
10345
10639
|
} else { // export { x, y as z } [from '...']
|
|
10346
10640
|
node.declaration = null;
|
|
10347
|
-
node.specifiers = this.parseExportSpecifiers(exports);
|
|
10641
|
+
node.specifiers = this.parseExportSpecifiers(exports$1);
|
|
10348
10642
|
if (this.eatContextual("from")) {
|
|
10349
10643
|
if (this.type !== types$1.string) { this.unexpected(); }
|
|
10350
10644
|
node.source = this.parseExprAtom();
|
|
@@ -10394,47 +10688,47 @@ pp$8.parseExportDefaultDeclaration = function() {
|
|
|
10394
10688
|
}
|
|
10395
10689
|
};
|
|
10396
10690
|
|
|
10397
|
-
pp$8.checkExport = function(exports, name, pos) {
|
|
10398
|
-
if (!exports) { return }
|
|
10691
|
+
pp$8.checkExport = function(exports$1, name, pos) {
|
|
10692
|
+
if (!exports$1) { return }
|
|
10399
10693
|
if (typeof name !== "string")
|
|
10400
10694
|
{ name = name.type === "Identifier" ? name.name : name.value; }
|
|
10401
|
-
if (hasOwn(exports, name))
|
|
10695
|
+
if (hasOwn(exports$1, name))
|
|
10402
10696
|
{ this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
|
|
10403
|
-
exports[name] = true;
|
|
10697
|
+
exports$1[name] = true;
|
|
10404
10698
|
};
|
|
10405
10699
|
|
|
10406
|
-
pp$8.checkPatternExport = function(exports, pat) {
|
|
10700
|
+
pp$8.checkPatternExport = function(exports$1, pat) {
|
|
10407
10701
|
var type = pat.type;
|
|
10408
10702
|
if (type === "Identifier")
|
|
10409
|
-
{ this.checkExport(exports, pat, pat.start); }
|
|
10703
|
+
{ this.checkExport(exports$1, pat, pat.start); }
|
|
10410
10704
|
else if (type === "ObjectPattern")
|
|
10411
10705
|
{ for (var i = 0, list = pat.properties; i < list.length; i += 1)
|
|
10412
10706
|
{
|
|
10413
10707
|
var prop = list[i];
|
|
10414
10708
|
|
|
10415
|
-
this.checkPatternExport(exports, prop);
|
|
10709
|
+
this.checkPatternExport(exports$1, prop);
|
|
10416
10710
|
} }
|
|
10417
10711
|
else if (type === "ArrayPattern")
|
|
10418
10712
|
{ for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
10419
10713
|
var elt = list$1[i$1];
|
|
10420
10714
|
|
|
10421
|
-
if (elt) { this.checkPatternExport(exports, elt); }
|
|
10715
|
+
if (elt) { this.checkPatternExport(exports$1, elt); }
|
|
10422
10716
|
} }
|
|
10423
10717
|
else if (type === "Property")
|
|
10424
|
-
{ this.checkPatternExport(exports, pat.value); }
|
|
10718
|
+
{ this.checkPatternExport(exports$1, pat.value); }
|
|
10425
10719
|
else if (type === "AssignmentPattern")
|
|
10426
|
-
{ this.checkPatternExport(exports, pat.left); }
|
|
10720
|
+
{ this.checkPatternExport(exports$1, pat.left); }
|
|
10427
10721
|
else if (type === "RestElement")
|
|
10428
|
-
{ this.checkPatternExport(exports, pat.argument); }
|
|
10722
|
+
{ this.checkPatternExport(exports$1, pat.argument); }
|
|
10429
10723
|
};
|
|
10430
10724
|
|
|
10431
|
-
pp$8.checkVariableExport = function(exports, decls) {
|
|
10432
|
-
if (!exports) { return }
|
|
10725
|
+
pp$8.checkVariableExport = function(exports$1, decls) {
|
|
10726
|
+
if (!exports$1) { return }
|
|
10433
10727
|
for (var i = 0, list = decls; i < list.length; i += 1)
|
|
10434
10728
|
{
|
|
10435
10729
|
var decl = list[i];
|
|
10436
10730
|
|
|
10437
|
-
this.checkPatternExport(exports, decl.id);
|
|
10731
|
+
this.checkPatternExport(exports$1, decl.id);
|
|
10438
10732
|
}
|
|
10439
10733
|
};
|
|
10440
10734
|
|
|
@@ -10449,13 +10743,13 @@ pp$8.shouldParseExportStatement = function() {
|
|
|
10449
10743
|
|
|
10450
10744
|
// Parses a comma-separated list of module exports.
|
|
10451
10745
|
|
|
10452
|
-
pp$8.parseExportSpecifier = function(exports) {
|
|
10746
|
+
pp$8.parseExportSpecifier = function(exports$1) {
|
|
10453
10747
|
var node = this.startNode();
|
|
10454
10748
|
node.local = this.parseModuleExportName();
|
|
10455
10749
|
|
|
10456
10750
|
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
10457
10751
|
this.checkExport(
|
|
10458
|
-
exports,
|
|
10752
|
+
exports$1,
|
|
10459
10753
|
node.exported,
|
|
10460
10754
|
node.exported.start
|
|
10461
10755
|
);
|
|
@@ -10463,7 +10757,7 @@ pp$8.parseExportSpecifier = function(exports) {
|
|
|
10463
10757
|
return this.finishNode(node, "ExportSpecifier")
|
|
10464
10758
|
};
|
|
10465
10759
|
|
|
10466
|
-
pp$8.parseExportSpecifiers = function(exports) {
|
|
10760
|
+
pp$8.parseExportSpecifiers = function(exports$1) {
|
|
10467
10761
|
var nodes = [], first = true;
|
|
10468
10762
|
// export { x, y as z } [from '...']
|
|
10469
10763
|
this.expect(types$1.braceL);
|
|
@@ -10473,7 +10767,7 @@ pp$8.parseExportSpecifiers = function(exports) {
|
|
|
10473
10767
|
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
10474
10768
|
} else { first = false; }
|
|
10475
10769
|
|
|
10476
|
-
nodes.push(this.parseExportSpecifier(exports));
|
|
10770
|
+
nodes.push(this.parseExportSpecifier(exports$1));
|
|
10477
10771
|
}
|
|
10478
10772
|
return nodes
|
|
10479
10773
|
};
|
|
@@ -11204,15 +11498,19 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
|
|
|
11204
11498
|
// delayed syntax error at correct position).
|
|
11205
11499
|
|
|
11206
11500
|
pp$5.parseExpression = function(forInit, refDestructuringErrors) {
|
|
11207
|
-
var
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
var
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11501
|
+
var this$1$1 = this;
|
|
11502
|
+
|
|
11503
|
+
return this.catchStackOverflow(function () {
|
|
11504
|
+
var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
|
|
11505
|
+
var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
|
|
11506
|
+
if (this$1$1.type === types$1.comma) {
|
|
11507
|
+
var node = this$1$1.startNodeAt(startPos, startLoc);
|
|
11508
|
+
node.expressions = [expr];
|
|
11509
|
+
while (this$1$1.eat(types$1.comma)) { node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors)); }
|
|
11510
|
+
return this$1$1.finishNode(node, "SequenceExpression")
|
|
11511
|
+
}
|
|
11512
|
+
return expr
|
|
11513
|
+
})
|
|
11216
11514
|
};
|
|
11217
11515
|
|
|
11218
11516
|
// Parse an assignment expression. This includes applications of
|
|
@@ -11277,7 +11575,7 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
|
|
|
11277
11575
|
var startPos = this.start, startLoc = this.startLoc;
|
|
11278
11576
|
var expr = this.parseExprOps(forInit, refDestructuringErrors);
|
|
11279
11577
|
if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
|
|
11280
|
-
if (this.eat(types$1.question)) {
|
|
11578
|
+
if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
|
|
11281
11579
|
var node = this.startNodeAt(startPos, startLoc);
|
|
11282
11580
|
node.test = expr;
|
|
11283
11581
|
node.consequent = this.parseMaybeAssign();
|
|
@@ -11377,7 +11675,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
|
|
|
11377
11675
|
}
|
|
11378
11676
|
}
|
|
11379
11677
|
|
|
11380
|
-
if (!incDec && this.eat(types$1.starstar)) {
|
|
11678
|
+
if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
|
|
11381
11679
|
if (sawUnary)
|
|
11382
11680
|
{ this.unexpected(this.lastTokStart); }
|
|
11383
11681
|
else
|
|
@@ -11829,6 +12127,8 @@ pp$5.parseNew = function() {
|
|
|
11829
12127
|
}
|
|
11830
12128
|
var startPos = this.start, startLoc = this.startLoc;
|
|
11831
12129
|
node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
|
|
12130
|
+
if (node.callee.type === "Super")
|
|
12131
|
+
{ this.raiseRecoverable(startPos, "Invalid use of 'super'"); }
|
|
11832
12132
|
if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
|
|
11833
12133
|
else { node.arguments = empty; }
|
|
11834
12134
|
return this.finishNode(node, "NewExpression")
|
|
@@ -12446,7 +12746,7 @@ pp$2.copyNode = function(node) {
|
|
|
12446
12746
|
};
|
|
12447
12747
|
|
|
12448
12748
|
// This file was generated by "bin/generate-unicode-script-values.js". Do not modify manually!
|
|
12449
|
-
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";
|
|
12749
|
+
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";
|
|
12450
12750
|
|
|
12451
12751
|
// This file contains Unicode properties extracted from the ECMAScript specification.
|
|
12452
12752
|
// The lists are extracted like so:
|
|
@@ -14007,13 +14307,17 @@ pp.readToken = function(code) {
|
|
|
14007
14307
|
return this.getTokenFromCode(code)
|
|
14008
14308
|
};
|
|
14009
14309
|
|
|
14010
|
-
pp.
|
|
14011
|
-
var code = this.input.charCodeAt(
|
|
14310
|
+
pp.fullCharCodeAt = function(pos) {
|
|
14311
|
+
var code = this.input.charCodeAt(pos);
|
|
14012
14312
|
if (code <= 0xd7ff || code >= 0xdc00) { return code }
|
|
14013
|
-
var next = this.input.charCodeAt(
|
|
14313
|
+
var next = this.input.charCodeAt(pos + 1);
|
|
14014
14314
|
return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
|
|
14015
14315
|
};
|
|
14016
14316
|
|
|
14317
|
+
pp.fullCharCodeAtPos = function() {
|
|
14318
|
+
return this.fullCharCodeAt(this.pos)
|
|
14319
|
+
};
|
|
14320
|
+
|
|
14017
14321
|
pp.skipBlockComment = function() {
|
|
14018
14322
|
var startLoc = this.options.onComment && this.curPosition();
|
|
14019
14323
|
var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
|
|
@@ -14741,7 +15045,7 @@ pp.readWord = function() {
|
|
|
14741
15045
|
// [ghbt]: https://github.com/acornjs/acorn/issues
|
|
14742
15046
|
|
|
14743
15047
|
|
|
14744
|
-
var version = "8.
|
|
15048
|
+
var version = "8.18.0";
|
|
14745
15049
|
|
|
14746
15050
|
Parser.acorn = {
|
|
14747
15051
|
Parser: Parser,
|