gyosjs 0.3.2 → 0.4.0

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.3.2
2
+ * GyosJS v0.4.0
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -2196,59 +2196,59 @@ function applyTransitionStyles() {
2196
2196
  return;
2197
2197
  const style = document.createElement('style');
2198
2198
  style.id = styleId;
2199
- style.textContent = `
2200
- /* Opacity utilities */
2199
+ style.textContent = `
2200
+ /* Opacity utilities */
2201
2201
  .gyos-t-opacity-0 { opacity: 0; }
2202
2202
  .gyos-t-opacity-100 { opacity: 1; }
2203
-
2204
- /* Transform - Translate Y */
2203
+
2204
+ /* Transform - Translate Y */
2205
2205
  .gyos-t-translate-y-0 { transform: translateY(0); }
2206
2206
  .gyos-t-translate-y--100 { transform: translateY(-100%); }
2207
2207
  .gyos-t-translate-y-100 { transform: translateY(100%); }
2208
-
2209
- /* Transform - Translate X */
2208
+
2209
+ /* Transform - Translate X */
2210
2210
  .gyos-t-translate-x-0 { transform: translateX(0); }
2211
2211
  .gyos-t-translate-x--100 { transform: translateX(-100%); }
2212
2212
  .gyos-t-translate-x-100 { transform: translateX(100%); }
2213
-
2214
- /* Transform - Scale */
2213
+
2214
+ /* Transform - Scale */
2215
2215
  .gyos-t-scale-0 { transform: scale(0); }
2216
2216
  .gyos-t-scale-50 { transform: scale(0.5); }
2217
2217
  .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;
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;
2252
2252
  }`;
2253
2253
  document.head.appendChild(style);
2254
2254
  }
@@ -6605,33 +6605,44 @@ class ProgressBar {
6605
6605
  getCurrentProgress() {
6606
6606
  return this.currentProgress;
6607
6607
  }
6608
+ reconnect() {
6609
+ if (!this.element || !this.progressBarEnabled || !document.body)
6610
+ return;
6611
+ // Snapshots may contain a clone of the runtime bar. Keep this instance.
6612
+ document.querySelectorAll('#gyos-progress-bar').forEach(node => {
6613
+ if (node !== this.element)
6614
+ node.remove();
6615
+ });
6616
+ if (!this.element.isConnected)
6617
+ document.body.appendChild(this.element);
6618
+ }
6608
6619
  createBar() {
6609
6620
  if (typeof document === 'undefined')
6610
6621
  return;
6611
6622
  // Create progress bar element
6612
6623
  this.element = document.createElement('div');
6613
6624
  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);
6625
+ this.element.style.cssText = `
6626
+ position: fixed;
6627
+ top: 0;
6628
+ left: 0;
6629
+ width: 0%;
6630
+ height: 6px;
6631
+ background: var(--gyos-progress-color, linear-gradient(90deg, #aab9ff, #77889f));
6632
+ z-index: 999999;
6633
+ transition: width 0.3s linear, opacity 0.3s linear;
6634
+ opacity: 0;
6635
+ pointer-events: none;
6636
+ box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
6626
6637
  `;
6627
6638
  // Insert into DOM when ready
6628
6639
  if (document.readyState === 'loading') {
6629
6640
  document.addEventListener('DOMContentLoaded', () => {
6630
- document.body.insertAdjacentElement('beforeend', this.element);
6631
- });
6641
+ this.reconnect();
6642
+ }, { once: true });
6632
6643
  }
6633
6644
  else {
6634
- document.body.insertAdjacentElement('beforeend', this.element);
6645
+ this.reconnect();
6635
6646
  }
6636
6647
  }
6637
6648
  start() {
@@ -6655,6 +6666,7 @@ class ProgressBar {
6655
6666
  setProgress(percent) {
6656
6667
  if (!this.element || !this.progressBarEnabled)
6657
6668
  return;
6669
+ this.reconnect();
6658
6670
  // Clamp between 0-100
6659
6671
  percent = Math.min(100, Math.max(0, percent));
6660
6672
  this.currentProgress = percent;
@@ -6703,41 +6715,41 @@ class ProgressBar {
6703
6715
  function createTargetSpinner() {
6704
6716
  const spinner = document.createElement('div');
6705
6717
  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>
6718
+ spinner.innerHTML = `
6719
+ <div class="gyos-spinner-content">
6720
+ <svg class="gyos-spinner-icon" viewBox="0 0 50 50">
6721
+ <circle cx="25" cy="25" r="20" fill="none" stroke="currentColor" stroke-width="4" stroke-dasharray="31.4 31.4" />
6722
+ </svg>
6723
+ </div>
6712
6724
  `;
6713
6725
  // Inject styles if not already present
6714
6726
  if (expressionRuntimeMode() === 'standard' && !document.getElementById('gyos-target-spinner-styles')) {
6715
6727
  const style = document.createElement('style');
6716
6728
  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
- }
6729
+ style.textContent = `
6730
+ .gyos-target-spinner {
6731
+ display: flex;
6732
+ align-items: center;
6733
+ justify-content: center;
6734
+ padding: 20px;
6735
+ min-height: 60px;
6736
+ }
6737
+ .gyos-spinner-content {
6738
+ display: flex;
6739
+ align-items: center;
6740
+ gap: 10px;
6741
+ color: var(--gyos-spinner-color, #667eea);
6742
+ font-size: 14px;
6743
+ }
6744
+ .gyos-spinner-icon {
6745
+ width: 24px;
6746
+ height: 24px;
6747
+ animation: gyos-spin 1s linear infinite;
6748
+ }
6749
+ @keyframes gyos-spin {
6750
+ 0% { transform: rotate(0deg); }
6751
+ 100% { transform: rotate(360deg); }
6752
+ }
6741
6753
  `;
6742
6754
  document.head.appendChild(style);
6743
6755
  }
@@ -7111,8 +7123,8 @@ async function performSwap(target, src, mode, options = {}) {
7111
7123
  }
7112
7124
  result = target;
7113
7125
  }
7114
- await options.beforeScripts?.();
7115
7126
  options.onCommitted?.(result, normalized === 'append' || normalized === 'prepend' ? incomingChildren : [result]);
7127
+ await options.beforeScripts?.();
7116
7128
  // Additive swaps must not re-run scripts that already existed in the target.
7117
7129
  if (normalized === 'append' || normalized === 'prepend') {
7118
7130
  await executeScriptsInNodes(incomingChildren, options.signal);
@@ -7352,6 +7364,21 @@ function handleScroll(url, trigger, savedScroll) {
7352
7364
  window.scrollTo({ top: 0, behavior: 'smooth' });
7353
7365
  }
7354
7366
 
7367
+ // A retained relative URL still identifies the resource loaded on its original
7368
+ // page, even after pushState changes document.baseURI.
7369
+ const resourceUrls = new WeakMap();
7370
+ function rememberResourceUrls(root, baseUrl) {
7371
+ root.querySelectorAll('script[src], link[href]').forEach(node => {
7372
+ const attribute = node.tagName === 'SCRIPT' ? 'src' : 'href';
7373
+ const source = node.getAttribute(attribute);
7374
+ if (resourceUrls.get(node)?.source === source)
7375
+ return;
7376
+ try {
7377
+ resourceUrls.set(node, { source, url: new URL(source, baseUrl).href });
7378
+ }
7379
+ catch { /* Invalid resource URLs retain their literal identity. */ }
7380
+ });
7381
+ }
7355
7382
  function isNonceMeta(el) {
7356
7383
  return el.tagName === 'META' && el.getAttribute('name')?.toLowerCase() === 'csp-nonce';
7357
7384
  }
@@ -7369,7 +7396,20 @@ function serializeAttributes(el, context) {
7369
7396
  return;
7370
7397
  if (context.csp && isNonceMeta(el) && attr.name.toLowerCase() === 'content')
7371
7398
  return;
7372
- attributes.set(attr.name, attr.value);
7399
+ let value = attr.value;
7400
+ if ((el.tagName === 'SCRIPT' && attr.name === 'src') || (el.tagName === 'LINK' && attr.name === 'href')) {
7401
+ const cached = resourceUrls.get(el);
7402
+ if (cached?.source === value)
7403
+ value = cached.url;
7404
+ else {
7405
+ try {
7406
+ value = new URL(value, context.baseUrl || el.baseURI).href;
7407
+ resourceUrls.set(el, { source: attr.value, url: value });
7408
+ }
7409
+ catch { /* Keep invalid URLs distinct. */ }
7410
+ }
7411
+ }
7412
+ attributes.set(attr.name, value);
7373
7413
  });
7374
7414
  if (context.csp && usesCspNonce(el) && context.activeNonce) {
7375
7415
  attributes.set('nonce', context.activeNonce);
@@ -7436,19 +7476,21 @@ function warnSkippedNode(node) {
7436
7476
  console.warn('[GyosJS CSP] Skipped an inline MPA script because no active document nonce is configured.');
7437
7477
  }
7438
7478
  }
7439
- async function diffNodes(currentNodes, nextNodes, container = document.head, signal) {
7479
+ async function diffNodes(currentNodes, nextNodes, container = document.head, signal, currentBaseUrl = document.baseURI) {
7440
7480
  const csp = expressionRuntimeMode() === 'csp';
7441
7481
  const context = {
7442
7482
  csp,
7443
7483
  activeNonce: csp ? resolveCspNonce() : undefined
7444
7484
  };
7445
- const current = keyedNodes(currentNodes, context);
7485
+ const current = keyedNodes(currentNodes, { ...context, baseUrl: currentBaseUrl });
7446
7486
  const next = keyedNodes(nextNodes, context);
7487
+ const persistentKey = (node) => container === document.head ? node.getAttribute('g-head-persist') : null;
7488
+ const persistent = new Set(currentNodes.map(persistentKey).filter(Boolean));
7447
7489
  const currentKeys = new Set(current.map(item => item.key));
7448
7490
  const nextKeys = new Set(next.map(item => item.key));
7449
7491
  // Remove nodes that are not in the new head
7450
7492
  current.forEach(({ key, node }) => {
7451
- if (!nextKeys.has(key)) {
7493
+ if (!nextKeys.has(key) && !persistentKey(node)) {
7452
7494
  node.remove();
7453
7495
  }
7454
7496
  });
@@ -7456,6 +7498,8 @@ async function diffNodes(currentNodes, nextNodes, container = document.head, sig
7456
7498
  for (const { key, node } of next) {
7457
7499
  if (signal?.aborted)
7458
7500
  return;
7501
+ if (persistent.has(persistentKey(node)))
7502
+ continue;
7459
7503
  if (!currentKeys.has(key)) {
7460
7504
  if (!canInsertNode(node, context)) {
7461
7505
  warnSkippedNode(node);
@@ -7658,6 +7702,7 @@ function prepareNavigationHtml(html) {
7658
7702
  * MPA boost navigation inspired by Turbo Drive.
7659
7703
  * Implements attribute-driven routing, snapshot caching, and persistent islands.
7660
7704
  */
7705
+ const submittingForms = new WeakSet();
7661
7706
  const snapshots = new Map();
7662
7707
  const preloadCache = new Map();
7663
7708
  const preloadControllers = new Map();
@@ -7674,12 +7719,30 @@ let activeNavigation = null;
7674
7719
  let progressBar = null;
7675
7720
  const beforeNavigate = [];
7676
7721
  const afterNavigate = [];
7722
+ const beforeSwap = [];
7723
+ const navigationEnd = [];
7724
+ function registerNavigationHook(hooks, callback) {
7725
+ // A wrapper gives each registration its own unsubscribe identity.
7726
+ const entry = (url, context) => callback(url, context);
7727
+ hooks.push(entry);
7728
+ return () => {
7729
+ const index = hooks.indexOf(entry);
7730
+ if (index !== -1)
7731
+ hooks.splice(index, 1);
7732
+ };
7733
+ }
7677
7734
  // Expose hooks to register before/after navigation callbacks
7678
7735
  function onBeforeNavigate(callback) {
7679
- beforeNavigate.push(callback);
7736
+ return registerNavigationHook(beforeNavigate, callback);
7680
7737
  }
7681
7738
  function onAfterNavigate(callback) {
7682
- afterNavigate.push(callback);
7739
+ return registerNavigationHook(afterNavigate, callback);
7740
+ }
7741
+ function onBeforeSwap(callback) {
7742
+ return registerNavigationHook(beforeSwap, callback);
7743
+ }
7744
+ function onNavigationEnd(callback) {
7745
+ return registerNavigationHook(navigationEnd, (_url, context) => callback(context));
7683
7746
  }
7684
7747
  function startRouter(options) {
7685
7748
  // If not has g-boost attribute, do not start router
@@ -7703,6 +7766,7 @@ function startRouter(options) {
7703
7766
  }
7704
7767
  // Cache scripts from initial page to prevent re-execution on first navigation back
7705
7768
  cacheInitialPageScripts();
7769
+ rememberResourceUrls(document, document.baseURI);
7706
7770
  routerStarted = true;
7707
7771
  log('[GyosRouter] started');
7708
7772
  }
@@ -7759,9 +7823,13 @@ function resolveTarget(trigger, targetSelector, targetOutletIndex) {
7759
7823
  const outlet = findGlobalOutlet();
7760
7824
  return outlet instanceof HTMLElement ? outlet : null;
7761
7825
  }
7826
+ function isFullDocument(html) {
7827
+ return /^\s*(?:<!--[^]*?-->\s*)*(?:<!doctype\s+html\b|<html(?:\s|>))/i.test(html);
7828
+ }
7762
7829
  function saveSnapshot(url, html) {
7763
7830
  // create HTMLElement by html string to remove scripts and get clean snapshot
7764
7831
  const doc = parseNavigationDocument(html);
7832
+ doc.querySelectorAll('#gyos-progress-bar').forEach(node => node.remove());
7765
7833
  // Ignore hash for snapshot keys
7766
7834
  if (url.includes('#'))
7767
7835
  url = url.split('#')[0];
@@ -7770,7 +7838,7 @@ function saveSnapshot(url, html) {
7770
7838
  if (s.hasAttribute('g-script-once'))
7771
7839
  s.textContent = '';
7772
7840
  });
7773
- snapshots.set(url, { html: doc.documentElement.outerHTML });
7841
+ snapshots.set(url, { html: doc.documentElement.outerHTML, fullDocument: isFullDocument(html) });
7774
7842
  log('[GyosRouter] snapshot saved for', url);
7775
7843
  }
7776
7844
  function getOutletIndex(root, target) {
@@ -7882,10 +7950,10 @@ function consumeViewTransitionRejection(promise) {
7882
7950
  // update callback remains the navigation source of truth and is awaited below.
7883
7951
  void promise?.catch(() => undefined);
7884
7952
  }
7885
- function runNavigationHooks(callbacks, url) {
7886
- callbacks.forEach(callback => {
7953
+ function runNavigationHooks(callbacks, url, context) {
7954
+ [...callbacks].forEach(callback => {
7887
7955
  try {
7888
- callback(url);
7956
+ callback(url, { ...context });
7889
7957
  }
7890
7958
  catch (error) {
7891
7959
  console.error('[GyosRouter] navigation hook error', error);
@@ -7923,7 +7991,13 @@ function buildRequest(opts) {
7923
7991
  url = mergeFormDataIntoUrl(url, opts.formData);
7924
7992
  }
7925
7993
  else {
7926
- init.body = opts.formData;
7994
+ if (opts.formEncoding === 'application/x-www-form-urlencoded') {
7995
+ const encoded = new URLSearchParams();
7996
+ opts.formData.forEach((value, name) => encoded.append(name, typeof value === 'string' ? value : value.name));
7997
+ init.body = encoded;
7998
+ }
7999
+ else
8000
+ init.body = opts.formData;
7927
8001
  }
7928
8002
  }
7929
8003
  else if (opts.jsonData) {
@@ -7966,25 +8040,26 @@ function preload(url) {
7966
8040
  preloadControllers.delete(cacheKey);
7967
8041
  });
7968
8042
  }
7969
- async function updateHead(fromDoc, signal) {
8043
+ async function updateHead(fromDoc, signal, currentBaseUrl) {
7970
8044
  const allowedSelector = 'meta, link, style:not(#gyos-transitions), script';
7971
8045
  const currentNodes = Array.from(document.head.querySelectorAll(allowedSelector));
7972
8046
  const nextNodes = Array.from(fromDoc.head.querySelectorAll(allowedSelector));
7973
- await diffNodes(currentNodes, nextNodes, document.head, signal);
8047
+ await diffNodes(currentNodes, nextNodes, document.head, signal, currentBaseUrl);
7974
8048
  }
7975
- async function scriptNotInOutletTarget(fromDoc, target, source, signal) {
8049
+ async function scriptNotInOutletTarget(fromDoc, target, source, signal, currentBaseUrl) {
7976
8050
  // scripts in current document and it not in target outlet
7977
8051
  const currentScripts = Array.from(document.scripts).filter(s => !target.contains(s) && !document.head.contains(s));
7978
8052
  // scripts in fromDoc and it not in source outlet
7979
8053
  const incomingScripts = Array.from(fromDoc.scripts).filter(s => !source.contains(s) && !fromDoc.head.contains(s));
7980
8054
  // Diff and update scripts not in outlet/target
7981
- await diffNodes(currentScripts, incomingScripts, document.body, signal);
8055
+ await diffNodes(currentScripts, incomingScripts, document.body, signal, currentBaseUrl);
7982
8056
  }
7983
8057
  function resolveIncomingScriptUrls(root, baseUrl) {
7984
- root.querySelectorAll('script[src]').forEach(script => {
7985
- const source = script.getAttribute('src');
8058
+ root.querySelectorAll('script[src], link[href]').forEach(node => {
8059
+ const attribute = node.tagName === 'SCRIPT' ? 'src' : 'href';
8060
+ const source = node.getAttribute(attribute);
7986
8061
  if (source)
7987
- script.src = new URL(source, baseUrl).href;
8062
+ node.setAttribute(attribute, new URL(source, baseUrl).href);
7988
8063
  });
7989
8064
  }
7990
8065
  function isNavigableHtmlResponse(response) {
@@ -8038,6 +8113,22 @@ async function navigate(opts) {
8038
8113
  resolveDone
8039
8114
  };
8040
8115
  activeNavigation = transaction;
8116
+ const currentBaseUrl = document.baseURI;
8117
+ rememberResourceUrls(document, currentBaseUrl);
8118
+ const context = {
8119
+ from: currentUrl, url: opts.url, method: opts.method.toUpperCase(),
8120
+ trigger: opts.trigger || null, target: null, form: opts.form || null,
8121
+ popstate: opts.popstate === true, signal: transaction.controller.signal,
8122
+ status: null, committed: false, fallback: false, outcome: null
8123
+ };
8124
+ const formEvent = opts.form
8125
+ ? { form: opts.form, url: opts.url, status: null, outcome: null, committed: false, fallback: false }
8126
+ : null;
8127
+ const fallback = (url, requestSent) => {
8128
+ context.fallback = context.method === 'GET' || (!requestSent && !!opts.form);
8129
+ context.outcome ?? (context.outcome = context.fallback ? 'fallback' : 'invalid-response');
8130
+ fallbackFromBoost(opts, url, requestSent);
8131
+ };
8041
8132
  const hasTargetSpinner = opts.trigger?.hasAttribute('g-router-spin');
8042
8133
  const setRand = () => {
8043
8134
  if (isActiveNavigation(transaction) && progressBar?.getCurrentProgress() < 70) {
@@ -8045,7 +8136,10 @@ async function navigate(opts) {
8045
8136
  }
8046
8137
  };
8047
8138
  try {
8048
- runNavigationHooks(beforeNavigate, opts.url);
8139
+ if (formEvent)
8140
+ document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
8141
+ runNavigationHooks(beforeNavigate, opts.url, context);
8142
+ assertActiveNavigation(transaction);
8049
8143
  progressBar?.start();
8050
8144
  // popstate already points history at the destination entry. Keep the visible
8051
8145
  // page's position under currentUrl without overwriting that destination state.
@@ -8054,9 +8148,10 @@ async function navigate(opts) {
8054
8148
  saveScrollPosition();
8055
8149
  // Pick target element to swap
8056
8150
  let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
8151
+ context.target = target;
8057
8152
  if (!target) {
8058
8153
  if (isActiveNavigation(transaction))
8059
- fallbackFromBoost(opts, opts.url, false);
8154
+ fallback(opts.url, false);
8060
8155
  return;
8061
8156
  }
8062
8157
  const swapMode = (opts.swapMode || opts.trigger?.getAttribute('g-swap') || 'inner').toLowerCase();
@@ -8081,6 +8176,7 @@ async function navigate(opts) {
8081
8176
  if (hasTargetSpinner)
8082
8177
  transaction.spinner = showTargetSpinner(target, swapMode);
8083
8178
  const { finalUrl, init } = buildRequest(opts);
8179
+ context.url = finalUrl;
8084
8180
  // Add abort signal to request
8085
8181
  init.signal = transaction.controller.signal;
8086
8182
  let html;
@@ -8108,7 +8204,8 @@ async function navigate(opts) {
8108
8204
  if (error.name === 'AbortError')
8109
8205
  throw error;
8110
8206
  assertActiveNavigation(transaction);
8111
- window.location.href = finalUrl;
8207
+ context.outcome = 'network-error';
8208
+ fallback(finalUrl, true);
8112
8209
  return;
8113
8210
  }
8114
8211
  preloadCache.delete(preloadKey); // consume cache
@@ -8133,28 +8230,46 @@ async function navigate(opts) {
8133
8230
  log('[GyosRouter] Navigation cancelled');
8134
8231
  return;
8135
8232
  }
8233
+ context.outcome = 'network-error';
8136
8234
  if (isActiveNavigation(transaction))
8137
- fallbackFromBoost(opts, finalUrl, true);
8235
+ fallback(finalUrl, true);
8138
8236
  return;
8139
8237
  }
8140
8238
  }
8141
8239
  assertActiveNavigation(transaction);
8142
- // If response not ok, fallback to full navigation
8143
- if (!response || !response.ok || !isNavigableHtmlResponse(response)) {
8240
+ context.status = response?.status ?? null;
8241
+ context.url = response?.url || finalUrl;
8242
+ const acceptedErrors = (opts.trigger?.getAttribute('g-boost-errors') || '').split(/[\s,]+/);
8243
+ const renderHttpError = !!response && response.status >= 400 && response.status <= 599
8244
+ && acceptedErrors.includes(String(response.status));
8245
+ if (response && !response.ok)
8246
+ context.outcome = 'http-error';
8247
+ if (!response || (!response.ok && !renderHttpError) || !isNavigableHtmlResponse(response)) {
8248
+ context.outcome ?? (context.outcome = 'invalid-response');
8144
8249
  if (isActiveNavigation(transaction))
8145
- fallbackFromBoost(opts, finalUrl, true);
8250
+ fallback(finalUrl, true);
8146
8251
  return;
8147
8252
  }
8148
8253
  html = await response.text();
8149
8254
  assertActiveNavigation(transaction);
8150
- if (!opts.popstate && target.hasAttribute('g-snapshot')) {
8151
- saveSnapshot(canonicalUrl(response.url || finalUrl), html);
8152
- }
8153
8255
  }
8154
8256
  // Parse HTML
8155
8257
  const doc = html
8156
8258
  ? parseNavigationDocument(html)
8157
8259
  : document.implementation.createHTMLDocument();
8260
+ // Detached parsing cannot tell whether the live CSP permits an incoming base.
8261
+ // Let native navigation enforce base-uri instead of authorizing its URLs ourselves.
8262
+ if (doc.querySelector('base[href]') || opts.historyFragment?.querySelector('base[href]')) {
8263
+ context.outcome = 'invalid-response';
8264
+ fallback(response?.url || finalUrl, true);
8265
+ return;
8266
+ }
8267
+ if (response?.ok && !opts.popstate && target.hasAttribute('g-snapshot')) {
8268
+ saveSnapshot(canonicalUrl(response.url || finalUrl), html);
8269
+ }
8270
+ const syncDocumentAttributes = isFullOutletNavigation && destructiveSwap && !currentHead
8271
+ && !opts.historyFragment && (opts.popstate && snapshots.has(urlWithoutHash)
8272
+ ? snapshots.get(urlWithoutHash).fullDocument : isFullDocument(html || ''));
8158
8273
  // Pick source fragment
8159
8274
  const src = opts.historyFragment || pickSourceFragment(doc, target, targetOutletIndex);
8160
8275
  stripInertFallbackContent(src);
@@ -8166,15 +8281,18 @@ async function navigate(opts) {
8166
8281
  targetUrl += finalUrl.substring(finalUrl.indexOf('#'));
8167
8282
  }
8168
8283
  resolveIncomingScriptUrls(doc, targetUrl);
8284
+ context.url = targetUrl;
8169
8285
  if (opts.historyFragment)
8170
8286
  resolveIncomingScriptUrls(src, targetUrl);
8171
8287
  const triggerChangesState = opts.trigger?.hasAttribute('g-change-state') || false;
8172
8288
  const keepsCurrentState = opts.trigger?.hasAttribute('g-current-state') || false;
8173
8289
  const redirectedSubmission = opts.method.toUpperCase() !== 'GET' && response?.redirected === true;
8174
- const changesState = !keepsCurrentState && (opts.changeState === true || triggerChangesState || redirectedSubmission);
8290
+ const changesState = context.outcome !== 'http-error' && !keepsCurrentState && (opts.changeState === true || triggerChangesState || redirectedSubmission);
8175
8291
  const performUpdate = async () => {
8176
8292
  assertActiveNavigation(transaction);
8177
8293
  transaction.committing = true;
8294
+ runNavigationHooks(beforeSwap, targetUrl, context);
8295
+ assertActiveNavigation(transaction);
8178
8296
  // Update progress to rand 80 - 90% before swap
8179
8297
  progressBar?.setProgress(Math.random() * 10 + 80);
8180
8298
  const outgoingHistoryFragment = changesState && !opts.replace && !isFullOutletNavigation
@@ -8245,21 +8363,34 @@ async function navigate(opts) {
8245
8363
  beforeScripts: async () => {
8246
8364
  if (!isFullOutletNavigation || currentHead)
8247
8365
  return;
8366
+ if (syncDocumentAttributes) {
8367
+ for (const name of ['lang', 'dir']) {
8368
+ const value = doc.documentElement.getAttribute(name);
8369
+ if (value === null)
8370
+ document.documentElement.removeAttribute(name);
8371
+ else
8372
+ document.documentElement.setAttribute(name, value);
8373
+ }
8374
+ }
8248
8375
  const incomingTitle = doc.querySelector('title');
8249
8376
  if (incomingTitle) {
8250
8377
  document.title = incomingTitle.textContent || document.title;
8251
8378
  }
8252
- await updateHead(doc, transaction.controller.signal);
8379
+ await updateHead(doc, transaction.controller.signal, currentBaseUrl);
8253
8380
  assertActiveNavigation(transaction);
8254
8381
  },
8255
8382
  onCommitted: (committedTarget, roots) => {
8256
8383
  target = committedTarget;
8384
+ context.target = committedTarget;
8385
+ context.committed = true;
8386
+ progressBar?.reconnect();
8257
8387
  committedRoots = roots;
8258
8388
  }
8259
8389
  });
8390
+ context.committed = true;
8260
8391
  assertActiveNavigation(transaction);
8261
8392
  if (isFullOutletNavigation) {
8262
- await scriptNotInOutletTarget(doc, target, src, transaction.controller.signal);
8393
+ await scriptNotInOutletTarget(doc, target, src, transaction.controller.signal, currentBaseUrl);
8263
8394
  assertActiveNavigation(transaction);
8264
8395
  }
8265
8396
  }
@@ -8293,14 +8424,15 @@ async function navigate(opts) {
8293
8424
  await performUpdate();
8294
8425
  }
8295
8426
  assertActiveNavigation(transaction);
8296
- if (removeTriggerAfterCommit && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
8427
+ if (removeTriggerAfterCommit && context.outcome !== 'http-error' && opts.trigger instanceof HTMLElement && opts.trigger.isConnected) {
8297
8428
  disposeEffects(opts.trigger);
8298
8429
  opts.trigger.remove();
8299
8430
  }
8300
8431
  if (hasTargetSpinner)
8301
8432
  hideTargetSpinner(transaction.spinner);
8302
8433
  transaction.spinner = null;
8303
- runNavigationHooks(afterNavigate, targetUrl);
8434
+ context.outcome ?? (context.outcome = 'success');
8435
+ runNavigationHooks(afterNavigate, targetUrl, context);
8304
8436
  log('[GyosRouter] navigated to', targetUrl);
8305
8437
  currentUrl = changesState
8306
8438
  ? canonicalUrl(targetUrl, true)
@@ -8316,11 +8448,15 @@ async function navigate(opts) {
8316
8448
  return;
8317
8449
  }
8318
8450
  if (isActiveNavigation(transaction)) {
8451
+ context.outcome ?? (context.outcome = 'error');
8319
8452
  console.error('[GyosRouter] navigation error', error);
8320
- fallbackFromBoost(opts, opts.url, true);
8453
+ fallback(opts.url, true);
8321
8454
  }
8322
8455
  }
8323
8456
  finally {
8457
+ if (transaction.controller.signal.aborted)
8458
+ context.outcome = 'aborted';
8459
+ context.outcome ?? (context.outcome = 'aborted');
8324
8460
  if (transaction.interval)
8325
8461
  clearInterval(transaction.interval);
8326
8462
  if (transaction.spinner)
@@ -8330,6 +8466,15 @@ async function navigate(opts) {
8330
8466
  progressBar?.complete();
8331
8467
  }
8332
8468
  transaction.resolveDone();
8469
+ if (formEvent)
8470
+ submittingForms.delete(formEvent.form);
8471
+ runNavigationHooks(navigationEnd, context.url, context);
8472
+ if (formEvent) {
8473
+ const { url, status, outcome, committed, fallback } = context;
8474
+ document.dispatchEvent(new CustomEvent('gyos:form-end', {
8475
+ detail: { ...formEvent, url, status, outcome, committed, fallback }
8476
+ }));
8477
+ }
8333
8478
  }
8334
8479
  }
8335
8480
  function shouldBoost(el) {
@@ -8438,16 +8583,34 @@ function onSubmit(event) {
8438
8583
  return;
8439
8584
  if (shouldDeferToFormValidation(form))
8440
8585
  return;
8441
- event.preventDefault();
8442
- const action = form.action || window.location.href;
8443
- const method = (form.method || 'GET').toUpperCase();
8444
- const url = new URL(action, window.location.href);
8445
- if (url.origin !== window.location.origin) {
8446
- window.location.href = url.toString();
8586
+ const submitter = event.submitter;
8587
+ const override = (name) => submitter?.getAttribute(`form${name}`) ?? form.getAttribute(name);
8588
+ const target = override('target') ?? document.querySelector('base[target]')?.getAttribute('target');
8589
+ const declaredMethod = (override('method') || 'GET').toUpperCase();
8590
+ const method = ['GET', 'POST', 'DIALOG'].includes(declaredMethod) ? declaredMethod : 'GET';
8591
+ const formEncoding = override('enctype')?.toLowerCase();
8592
+ if ((target && target.toLowerCase() !== '_self') || method === 'DIALOG' || formEncoding === 'text/plain')
8593
+ return;
8594
+ if (!resolveTarget(form))
8595
+ return;
8596
+ // Image submitters carry click coordinates which SubmitEvent does not expose.
8597
+ if (submitter instanceof HTMLInputElement && submitter.type === 'image')
8447
8598
  return;
8599
+ let url;
8600
+ try {
8601
+ url = new URL(override('action') || window.location.href, document.baseURI);
8448
8602
  }
8449
- const formData = new FormData(form);
8450
- navigate({ url: url.toString(), method, trigger: form, form, formData, changeState: method === 'GET' });
8603
+ catch {
8604
+ return;
8605
+ }
8606
+ if (url.origin !== window.location.origin)
8607
+ return;
8608
+ event.preventDefault();
8609
+ if (submittingForms.has(form))
8610
+ return;
8611
+ const formData = new FormData(form, submitter);
8612
+ submittingForms.add(form);
8613
+ void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8451
8614
  }
8452
8615
  function onPopState(event) {
8453
8616
  const url = window.location.href;
@@ -8552,23 +8715,25 @@ const Gyos = {
8552
8715
  startRouter,
8553
8716
  onBeforeNavigate,
8554
8717
  onAfterNavigate,
8718
+ onBeforeSwap,
8719
+ onNavigationEnd,
8555
8720
  portalCreate,
8556
8721
  portalDestroy,
8557
8722
  setCspNonce,
8558
- version: '0.3.2'
8723
+ version: '0.4.0'
8559
8724
  };
8560
8725
 
8561
8726
  // 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, 80, 3, 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, 343, 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, 330, 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, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
8727
+ 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
8728
 
8564
8729
  // 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, 71, 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, 2, 60, 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, 328, 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, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 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, 496, 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, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
8730
+ 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
8731
 
8567
8732
  // 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-\u1ace\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";
8733
+ 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
8734
 
8570
8735
  // 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-\u088e\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\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\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-\ua7cd\ua7d0\ua7d1\ua7d3\ua7d5-\ua7dc\ua7f2-\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";
8736
+ 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
8737
 
8573
8738
  // These are a run-length and offset encoded representation of the
8574
8739
  // >0xffff code points that are a valid part of identifiers. The
@@ -8893,9 +9058,12 @@ var defaultOptions = {
8893
9058
  // for new syntax features.
8894
9059
  ecmaVersion: null,
8895
9060
  // `sourceType` indicates the mode the code should be parsed in.
8896
- // Can be either `"script"` or `"module"`. This influences global
9061
+ // Can be either `"script"`, `"module"` or `"commonjs"`. This influences global
8897
9062
  // strict mode and parsing of `import` and `export` declarations.
8898
9063
  sourceType: "script",
9064
+ // When set to true, enable strict parsing mode even if `sourceType`
9065
+ // is `"script"`.
9066
+ strict: false,
8899
9067
  // `onInsertedSemicolon` can be a callback that will be called when
8900
9068
  // a semicolon is automatically inserted. It will be passed the
8901
9069
  // position of the inserted semicolon as an offset, and if
@@ -8937,6 +9105,11 @@ var defaultOptions = {
8937
9105
  // line being 1-based and column 0-based) will be attached to the
8938
9106
  // nodes.
8939
9107
  locations: false,
9108
+ // Pass an optional `{line, column}` object to use for the start of
9109
+ // the parse. This is mostly useful when using `parseExpressionAt`
9110
+ // with `locations: true`, to prevent the parser from having to
9111
+ // determine the line position at the start position.
9112
+ startLocation: null,
8940
9113
  // A function can be passed as `onToken` option, which will
8941
9114
  // cause Acorn to call that function with object in the same
8942
9115
  // format as tokens returned from `tokenizer().getToken()`. Note
@@ -9017,6 +9190,9 @@ function getOptions(opts) {
9017
9190
  if (isArray(options.onComment))
9018
9191
  { options.onComment = pushComment(options, options.onComment); }
9019
9192
 
9193
+ if (options.sourceType === "commonjs" && options.allowAwaitOutsideFunction)
9194
+ { throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs") }
9195
+
9020
9196
  return options
9021
9197
  }
9022
9198
 
@@ -9048,6 +9224,7 @@ var
9048
9224
  SCOPE_DIRECT_SUPER = 128,
9049
9225
  SCOPE_CLASS_STATIC_BLOCK = 256,
9050
9226
  SCOPE_CLASS_FIELD_INIT = 512,
9227
+ SCOPE_SWITCH = 1024,
9051
9228
  SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK;
9052
9229
 
9053
9230
  function functionFlags(async, generator) {
@@ -9086,13 +9263,17 @@ var Parser = function Parser(options, input, startPos) {
9086
9263
  // Set up token state
9087
9264
 
9088
9265
  // The current position of the tokenizer in the input.
9089
- if (startPos) {
9090
- this.pos = startPos;
9266
+ this.pos = startPos || 0;
9267
+ this.curLine = 1;
9268
+ if (options.startLocation) {
9269
+ this.lineStart = this.pos - options.startLocation.column;
9270
+ this.curLine = options.startLocation.line;
9271
+ } else if (startPos) {
9091
9272
  this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
9092
- this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
9273
+ if (this.options.locations)
9274
+ { this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; }
9093
9275
  } else {
9094
- this.pos = this.lineStart = 0;
9095
- this.curLine = 1;
9276
+ this.lineStart = 0;
9096
9277
  }
9097
9278
 
9098
9279
  // Properties of the current token:
@@ -9118,7 +9299,7 @@ var Parser = function Parser(options, input, startPos) {
9118
9299
 
9119
9300
  // Figure out if it's a module code.
9120
9301
  this.inModule = options.sourceType === "module";
9121
- this.strict = this.inModule || this.strictDirective(this.pos);
9302
+ this.strict = this.inModule || options.strict === true || this.strictDirective(this.pos);
9122
9303
 
9123
9304
  // Used to signify the start of a potential arrow function
9124
9305
  this.potentialArrowAt = -1;
@@ -9137,7 +9318,12 @@ var Parser = function Parser(options, input, startPos) {
9137
9318
 
9138
9319
  // Scope tracking for duplicate variable names (see scope.js)
9139
9320
  this.scopeStack = [];
9140
- this.enterScope(SCOPE_TOP);
9321
+ this.enterScope(
9322
+ this.options.sourceType === "commonjs"
9323
+ // In commonjs, the top-level scope behaves like a function scope
9324
+ ? SCOPE_FUNCTION
9325
+ : SCOPE_TOP
9326
+ );
9141
9327
 
9142
9328
  // For RegExp validation
9143
9329
  this.regexpState = null;
@@ -9148,12 +9334,14 @@ var Parser = function Parser(options, input, startPos) {
9148
9334
  this.privateNameStack = [];
9149
9335
  };
9150
9336
 
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 } };
9337
+ 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
9338
 
9153
9339
  Parser.prototype.parse = function parse () {
9340
+ var this$1$1 = this;
9341
+
9154
9342
  var node = this.options.program || this.startNode();
9155
9343
  this.nextToken();
9156
- return this.parseTopLevel(node)
9344
+ return this.catchStackOverflow(function () { return this$1$1.parseTopLevel(node); })
9157
9345
  };
9158
9346
 
9159
9347
  prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
@@ -9172,6 +9360,12 @@ prototypeAccessors.canAwait.get = function () {
9172
9360
  return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction
9173
9361
  };
9174
9362
 
9363
+ prototypeAccessors.allowReturn.get = function () {
9364
+ if (this.inFunction) { return true }
9365
+ if (this.options.allowReturnOutsideFunction && this.currentVarScope().flags & SCOPE_TOP) { return true }
9366
+ return false
9367
+ };
9368
+
9175
9369
  prototypeAccessors.allowSuper.get = function () {
9176
9370
  var ref = this.currentThisScope();
9177
9371
  var flags = ref.flags;
@@ -9192,6 +9386,14 @@ prototypeAccessors.allowNewDotTarget.get = function () {
9192
9386
  return false
9193
9387
  };
9194
9388
 
9389
+ prototypeAccessors.allowUsing.get = function () {
9390
+ var ref = this.currentScope();
9391
+ var flags = ref.flags;
9392
+ if (flags & SCOPE_SWITCH) { return false }
9393
+ if (!this.inModule && flags & SCOPE_TOP) { return false }
9394
+ return true
9395
+ };
9396
+
9195
9397
  prototypeAccessors.inClassStaticBlock.get = function () {
9196
9398
  return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0
9197
9399
  };
@@ -9278,6 +9480,17 @@ pp$9.eatContextual = function(name) {
9278
9480
  return true
9279
9481
  };
9280
9482
 
9483
+ pp$9.catchStackOverflow = function(f) {
9484
+ try {
9485
+ return f()
9486
+ } catch (e) {
9487
+ if (e instanceof Error && (/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message) || /\btoo much recursion\b/i.test(e.message)))
9488
+ { this.raise(this.start, "Not enough stack space to parse input"); }
9489
+ else
9490
+ { throw e }
9491
+ }
9492
+ };
9493
+
9281
9494
  // Asserts that following token is given contextual keyword.
9282
9495
 
9283
9496
  pp$9.expectContextual = function(name) {
@@ -9381,10 +9594,10 @@ var pp$8 = Parser.prototype;
9381
9594
  // to its body instead of creating a new node.
9382
9595
 
9383
9596
  pp$8.parseTopLevel = function(node) {
9384
- var exports = Object.create(null);
9597
+ var exports$1 = Object.create(null);
9385
9598
  if (!node.body) { node.body = []; }
9386
9599
  while (this.type !== types$1.eof) {
9387
- var stmt = this.parseStatement(null, true, exports);
9600
+ var stmt = this.parseStatement(null, true, exports$1);
9388
9601
  node.body.push(stmt);
9389
9602
  }
9390
9603
  if (this.inModule)
@@ -9396,7 +9609,7 @@ pp$8.parseTopLevel = function(node) {
9396
9609
  } }
9397
9610
  this.adaptDirectivePrologue(node.body);
9398
9611
  this.next();
9399
- node.sourceType = this.options.sourceType;
9612
+ node.sourceType = this.options.sourceType === "commonjs" ? "script" : this.options.sourceType;
9400
9613
  return this.finishNode(node, "Program")
9401
9614
  };
9402
9615
 
@@ -9406,7 +9619,7 @@ pp$8.isLet = function(context) {
9406
9619
  if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
9407
9620
  skipWhiteSpace.lastIndex = this.pos;
9408
9621
  var skip = skipWhiteSpace.exec(this.input);
9409
- var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
9622
+ var next = this.pos + skip[0].length, nextCh = this.fullCharCodeAt(next);
9410
9623
  // For ambiguous cases, determine if a LexicalDeclaration (or only a
9411
9624
  // Statement) is allowed here. If context is not empty then only a Statement
9412
9625
  // is allowed. However, `let [` is an explicit negative lookahead for
@@ -9414,12 +9627,13 @@ pp$8.isLet = function(context) {
9414
9627
  if (nextCh === 91 || nextCh === 92) { return true } // '[', '\'
9415
9628
  if (context) { return false }
9416
9629
 
9417
- if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral
9418
- if (isIdentifierStart(nextCh, true)) {
9419
- var pos = next + 1;
9420
- while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; }
9421
- if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true }
9422
- var ident = this.input.slice(next, pos);
9630
+ if (nextCh === 123) { return true } // '{'
9631
+ if (isIdentifierStart(nextCh)) {
9632
+ var start = next;
9633
+ do { next += nextCh <= 0xffff ? 1 : 2; }
9634
+ while (isIdentifierChar(nextCh = this.fullCharCodeAt(next)))
9635
+ if (nextCh === 92) { return true }
9636
+ var ident = this.input.slice(start, next);
9423
9637
  if (!keywordRelationalOperator.test(ident)) { return true }
9424
9638
  }
9425
9639
  return false
@@ -9438,7 +9652,7 @@ pp$8.isAsyncFunction = function() {
9438
9652
  return !lineBreak.test(this.input.slice(this.pos, next)) &&
9439
9653
  this.input.slice(next, next + 8) === "function" &&
9440
9654
  (next + 8 === this.input.length ||
9441
- !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
9655
+ !(isIdentifierChar(after = this.fullCharCodeAt(next + 8)) || after === 92 /* '\' */))
9442
9656
  };
9443
9657
 
9444
9658
  pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
@@ -9452,28 +9666,39 @@ pp$8.isUsingKeyword = function(isAwaitUsing, isFor) {
9452
9666
  if (lineBreak.test(this.input.slice(this.pos, next))) { return false }
9453
9667
 
9454
9668
  if (isAwaitUsing) {
9455
- var awaitEndPos = next + 5 /* await */, after;
9456
- if (this.input.slice(next, awaitEndPos) !== "using" ||
9457
- awaitEndPos === this.input.length ||
9458
- isIdentifierChar(after = this.input.charCodeAt(awaitEndPos)) ||
9459
- (after > 0xd7ff && after < 0xdc00)
9669
+ var usingEndPos = next + 5 /* using */, after;
9670
+ if (this.input.slice(next, usingEndPos) !== "using" ||
9671
+ usingEndPos === this.input.length ||
9672
+ isIdentifierChar(after = this.fullCharCodeAt(usingEndPos)) ||
9673
+ after === 92 /* '\' */
9460
9674
  ) { return false }
9461
9675
 
9462
- skipWhiteSpace.lastIndex = awaitEndPos;
9676
+ skipWhiteSpace.lastIndex = usingEndPos;
9463
9677
  var skipAfterUsing = skipWhiteSpace.exec(this.input);
9464
- if (skipAfterUsing && lineBreak.test(this.input.slice(awaitEndPos, awaitEndPos + skipAfterUsing[0].length))) { return false }
9465
- }
9466
-
9467
- if (isFor) {
9468
- var ofEndPos = next + 2 /* of */, after$1;
9469
- if (this.input.slice(next, ofEndPos) === "of") {
9470
- if (ofEndPos === this.input.length ||
9471
- (!isIdentifierChar(after$1 = this.input.charCodeAt(ofEndPos)) && !(after$1 > 0xd7ff && after$1 < 0xdc00))) { return false }
9678
+ next = usingEndPos + skipAfterUsing[0].length;
9679
+ if (skipAfterUsing && lineBreak.test(this.input.slice(usingEndPos, next))) { return false }
9680
+ }
9681
+
9682
+ var ch = this.fullCharCodeAt(next);
9683
+ if (!isIdentifierStart(ch) && ch !== 92 /* '\' */) { return false }
9684
+ var idStart = next;
9685
+ do { next += ch <= 0xffff ? 1 : 2; }
9686
+ while (isIdentifierChar(ch = this.fullCharCodeAt(next)))
9687
+ if (ch === 92) { return true }
9688
+ var id = this.input.slice(idStart, next);
9689
+ if (keywordRelationalOperator.test(id)) { return false }
9690
+ if (isFor && !isAwaitUsing && id === "of") {
9691
+ // Look ahead for using declaration with initializer, i.e., `for (using of = ...)`
9692
+ skipWhiteSpace.lastIndex = next;
9693
+ var skipAfterOf = skipWhiteSpace.exec(this.input);
9694
+ next = next + skipAfterOf[0].length;
9695
+ if (this.input.charCodeAt(next) !== 61 /* '=' */ ||
9696
+ // Check for ==, === and => operators
9697
+ (ch = this.input.charCodeAt(next + 1)) === 61 /* '=' */ || ch === 62 /* '>' */) {
9698
+ return false
9472
9699
  }
9473
9700
  }
9474
-
9475
- var ch = this.input.charCodeAt(next);
9476
- return isIdentifierStart(ch, true) || ch === 92 // '\'
9701
+ return true
9477
9702
  };
9478
9703
 
9479
9704
  pp$8.isAwaitUsing = function(isFor) {
@@ -9491,7 +9716,7 @@ pp$8.isUsing = function(isFor) {
9491
9716
  // `if (foo) /blah/.exec(foo)`, where looking at the previous token
9492
9717
  // does not help.
9493
9718
 
9494
- pp$8.parseStatement = function(context, topLevel, exports) {
9719
+ pp$8.parseStatement = function(context, topLevel, exports$1) {
9495
9720
  var starttype = this.type, node = this.startNode(), kind;
9496
9721
 
9497
9722
  if (this.isLet(context)) {
@@ -9546,7 +9771,7 @@ pp$8.parseStatement = function(context, topLevel, exports) {
9546
9771
  if (!this.inModule)
9547
9772
  { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
9548
9773
  }
9549
- return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
9774
+ return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1)
9550
9775
 
9551
9776
  // If the statement does not start with a statement keyword or a
9552
9777
  // brace, it's an ExpressionStatement or LabeledStatement. We
@@ -9562,8 +9787,12 @@ pp$8.parseStatement = function(context, topLevel, exports) {
9562
9787
 
9563
9788
  var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null;
9564
9789
  if (usingKind) {
9565
- if (topLevel && this.options.sourceType === "script") {
9566
- this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`");
9790
+ if (!this.allowUsing) {
9791
+ this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");
9792
+ }
9793
+ if (context) {
9794
+ // Cases like `for (;;) using x = ...;`, `if (true) await using x = ...;`, etc. are not allowed.
9795
+ this.raise(this.start, "Using declaration is not allowed in single-statement positions");
9567
9796
  }
9568
9797
  if (usingKind === "await using") {
9569
9798
  if (!this.canAwait) {
@@ -9660,7 +9889,12 @@ pp$8.parseForStatement = function(node) {
9660
9889
  if (usingKind) {
9661
9890
  var init$2 = this.startNode();
9662
9891
  this.next();
9663
- if (usingKind === "await using") { this.next(); }
9892
+ if (usingKind === "await using") {
9893
+ if (!this.canAwait) {
9894
+ this.raise(this.start, "Await using cannot appear outside of async function");
9895
+ }
9896
+ this.next();
9897
+ }
9664
9898
  this.parseVar(init$2, true, usingKind);
9665
9899
  this.finishNode(init$2, "VariableDeclaration");
9666
9900
  return this.parseForAfterInit(node, init$2, awaitAt)
@@ -9693,11 +9927,12 @@ pp$8.parseForStatement = function(node) {
9693
9927
  // Helper method to parse for loop after variable initialization
9694
9928
  pp$8.parseForAfterInit = function(node, init, awaitAt) {
9695
9929
  if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) {
9696
- if (this.options.ecmaVersion >= 9) {
9697
- if (this.type === types$1._in) {
9698
- if (awaitAt > -1) { this.unexpected(awaitAt); }
9699
- } else { node.await = awaitAt > -1; }
9700
- }
9930
+ if (this.type === types$1._in) {
9931
+ if ((init.kind === "using" || init.kind === "await using") && !init.declarations[0].init) {
9932
+ this.raise(this.start, "Using declaration is not allowed in for-in loops");
9933
+ }
9934
+ if (this.options.ecmaVersion >= 9 && awaitAt > -1) { this.unexpected(awaitAt); }
9935
+ } else if (this.options.ecmaVersion >= 9) { node.await = awaitAt > -1; }
9701
9936
  return this.parseForIn(node, init)
9702
9937
  }
9703
9938
  if (awaitAt > -1) { this.unexpected(awaitAt); }
@@ -9719,7 +9954,7 @@ pp$8.parseIfStatement = function(node) {
9719
9954
  };
9720
9955
 
9721
9956
  pp$8.parseReturnStatement = function(node) {
9722
- if (!this.inFunction && !this.options.allowReturnOutsideFunction)
9957
+ if (!this.allowReturn)
9723
9958
  { this.raise(this.start, "'return' outside of function"); }
9724
9959
  this.next();
9725
9960
 
@@ -9738,7 +9973,7 @@ pp$8.parseSwitchStatement = function(node) {
9738
9973
  node.cases = [];
9739
9974
  this.expect(types$1.braceL);
9740
9975
  this.labels.push(switchLabel);
9741
- this.enterScope(0);
9976
+ this.enterScope(SCOPE_SWITCH);
9742
9977
 
9743
9978
  // Statements under must be grouped (by label) in SwitchCase
9744
9979
  // nodes. `cur` is used to keep the node that we are currently
@@ -10302,11 +10537,11 @@ function checkKeyName(node, name) {
10302
10537
 
10303
10538
  // Parses module export declaration.
10304
10539
 
10305
- pp$8.parseExportAllDeclaration = function(node, exports) {
10540
+ pp$8.parseExportAllDeclaration = function(node, exports$1) {
10306
10541
  if (this.options.ecmaVersion >= 11) {
10307
10542
  if (this.eatContextual("as")) {
10308
10543
  node.exported = this.parseModuleExportName();
10309
- this.checkExport(exports, node.exported, this.lastTokStart);
10544
+ this.checkExport(exports$1, node.exported, this.lastTokStart);
10310
10545
  } else {
10311
10546
  node.exported = null;
10312
10547
  }
@@ -10320,14 +10555,14 @@ pp$8.parseExportAllDeclaration = function(node, exports) {
10320
10555
  return this.finishNode(node, "ExportAllDeclaration")
10321
10556
  };
10322
10557
 
10323
- pp$8.parseExport = function(node, exports) {
10558
+ pp$8.parseExport = function(node, exports$1) {
10324
10559
  this.next();
10325
10560
  // export * from '...'
10326
10561
  if (this.eat(types$1.star)) {
10327
- return this.parseExportAllDeclaration(node, exports)
10562
+ return this.parseExportAllDeclaration(node, exports$1)
10328
10563
  }
10329
10564
  if (this.eat(types$1._default)) { // export default ...
10330
- this.checkExport(exports, "default", this.lastTokStart);
10565
+ this.checkExport(exports$1, "default", this.lastTokStart);
10331
10566
  node.declaration = this.parseExportDefaultDeclaration();
10332
10567
  return this.finishNode(node, "ExportDefaultDeclaration")
10333
10568
  }
@@ -10335,16 +10570,16 @@ pp$8.parseExport = function(node, exports) {
10335
10570
  if (this.shouldParseExportStatement()) {
10336
10571
  node.declaration = this.parseExportDeclaration(node);
10337
10572
  if (node.declaration.type === "VariableDeclaration")
10338
- { this.checkVariableExport(exports, node.declaration.declarations); }
10573
+ { this.checkVariableExport(exports$1, node.declaration.declarations); }
10339
10574
  else
10340
- { this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
10575
+ { this.checkExport(exports$1, node.declaration.id, node.declaration.id.start); }
10341
10576
  node.specifiers = [];
10342
10577
  node.source = null;
10343
10578
  if (this.options.ecmaVersion >= 16)
10344
10579
  { node.attributes = []; }
10345
10580
  } else { // export { x, y as z } [from '...']
10346
10581
  node.declaration = null;
10347
- node.specifiers = this.parseExportSpecifiers(exports);
10582
+ node.specifiers = this.parseExportSpecifiers(exports$1);
10348
10583
  if (this.eatContextual("from")) {
10349
10584
  if (this.type !== types$1.string) { this.unexpected(); }
10350
10585
  node.source = this.parseExprAtom();
@@ -10394,47 +10629,47 @@ pp$8.parseExportDefaultDeclaration = function() {
10394
10629
  }
10395
10630
  };
10396
10631
 
10397
- pp$8.checkExport = function(exports, name, pos) {
10398
- if (!exports) { return }
10632
+ pp$8.checkExport = function(exports$1, name, pos) {
10633
+ if (!exports$1) { return }
10399
10634
  if (typeof name !== "string")
10400
10635
  { name = name.type === "Identifier" ? name.name : name.value; }
10401
- if (hasOwn(exports, name))
10636
+ if (hasOwn(exports$1, name))
10402
10637
  { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
10403
- exports[name] = true;
10638
+ exports$1[name] = true;
10404
10639
  };
10405
10640
 
10406
- pp$8.checkPatternExport = function(exports, pat) {
10641
+ pp$8.checkPatternExport = function(exports$1, pat) {
10407
10642
  var type = pat.type;
10408
10643
  if (type === "Identifier")
10409
- { this.checkExport(exports, pat, pat.start); }
10644
+ { this.checkExport(exports$1, pat, pat.start); }
10410
10645
  else if (type === "ObjectPattern")
10411
10646
  { for (var i = 0, list = pat.properties; i < list.length; i += 1)
10412
10647
  {
10413
10648
  var prop = list[i];
10414
10649
 
10415
- this.checkPatternExport(exports, prop);
10650
+ this.checkPatternExport(exports$1, prop);
10416
10651
  } }
10417
10652
  else if (type === "ArrayPattern")
10418
10653
  { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
10419
10654
  var elt = list$1[i$1];
10420
10655
 
10421
- if (elt) { this.checkPatternExport(exports, elt); }
10656
+ if (elt) { this.checkPatternExport(exports$1, elt); }
10422
10657
  } }
10423
10658
  else if (type === "Property")
10424
- { this.checkPatternExport(exports, pat.value); }
10659
+ { this.checkPatternExport(exports$1, pat.value); }
10425
10660
  else if (type === "AssignmentPattern")
10426
- { this.checkPatternExport(exports, pat.left); }
10661
+ { this.checkPatternExport(exports$1, pat.left); }
10427
10662
  else if (type === "RestElement")
10428
- { this.checkPatternExport(exports, pat.argument); }
10663
+ { this.checkPatternExport(exports$1, pat.argument); }
10429
10664
  };
10430
10665
 
10431
- pp$8.checkVariableExport = function(exports, decls) {
10432
- if (!exports) { return }
10666
+ pp$8.checkVariableExport = function(exports$1, decls) {
10667
+ if (!exports$1) { return }
10433
10668
  for (var i = 0, list = decls; i < list.length; i += 1)
10434
10669
  {
10435
10670
  var decl = list[i];
10436
10671
 
10437
- this.checkPatternExport(exports, decl.id);
10672
+ this.checkPatternExport(exports$1, decl.id);
10438
10673
  }
10439
10674
  };
10440
10675
 
@@ -10449,13 +10684,13 @@ pp$8.shouldParseExportStatement = function() {
10449
10684
 
10450
10685
  // Parses a comma-separated list of module exports.
10451
10686
 
10452
- pp$8.parseExportSpecifier = function(exports) {
10687
+ pp$8.parseExportSpecifier = function(exports$1) {
10453
10688
  var node = this.startNode();
10454
10689
  node.local = this.parseModuleExportName();
10455
10690
 
10456
10691
  node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
10457
10692
  this.checkExport(
10458
- exports,
10693
+ exports$1,
10459
10694
  node.exported,
10460
10695
  node.exported.start
10461
10696
  );
@@ -10463,7 +10698,7 @@ pp$8.parseExportSpecifier = function(exports) {
10463
10698
  return this.finishNode(node, "ExportSpecifier")
10464
10699
  };
10465
10700
 
10466
- pp$8.parseExportSpecifiers = function(exports) {
10701
+ pp$8.parseExportSpecifiers = function(exports$1) {
10467
10702
  var nodes = [], first = true;
10468
10703
  // export { x, y as z } [from '...']
10469
10704
  this.expect(types$1.braceL);
@@ -10473,7 +10708,7 @@ pp$8.parseExportSpecifiers = function(exports) {
10473
10708
  if (this.afterTrailingComma(types$1.braceR)) { break }
10474
10709
  } else { first = false; }
10475
10710
 
10476
- nodes.push(this.parseExportSpecifier(exports));
10711
+ nodes.push(this.parseExportSpecifier(exports$1));
10477
10712
  }
10478
10713
  return nodes
10479
10714
  };
@@ -11204,15 +11439,19 @@ pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) {
11204
11439
  // delayed syntax error at correct position).
11205
11440
 
11206
11441
  pp$5.parseExpression = function(forInit, refDestructuringErrors) {
11207
- var startPos = this.start, startLoc = this.startLoc;
11208
- var expr = this.parseMaybeAssign(forInit, refDestructuringErrors);
11209
- if (this.type === types$1.comma) {
11210
- var node = this.startNodeAt(startPos, startLoc);
11211
- node.expressions = [expr];
11212
- while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); }
11213
- return this.finishNode(node, "SequenceExpression")
11214
- }
11215
- return expr
11442
+ var this$1$1 = this;
11443
+
11444
+ return this.catchStackOverflow(function () {
11445
+ var startPos = this$1$1.start, startLoc = this$1$1.startLoc;
11446
+ var expr = this$1$1.parseMaybeAssign(forInit, refDestructuringErrors);
11447
+ if (this$1$1.type === types$1.comma) {
11448
+ var node = this$1$1.startNodeAt(startPos, startLoc);
11449
+ node.expressions = [expr];
11450
+ while (this$1$1.eat(types$1.comma)) { node.expressions.push(this$1$1.parseMaybeAssign(forInit, refDestructuringErrors)); }
11451
+ return this$1$1.finishNode(node, "SequenceExpression")
11452
+ }
11453
+ return expr
11454
+ })
11216
11455
  };
11217
11456
 
11218
11457
  // Parse an assignment expression. This includes applications of
@@ -11277,7 +11516,7 @@ pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) {
11277
11516
  var startPos = this.start, startLoc = this.startLoc;
11278
11517
  var expr = this.parseExprOps(forInit, refDestructuringErrors);
11279
11518
  if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
11280
- if (this.eat(types$1.question)) {
11519
+ if (!(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.question)) {
11281
11520
  var node = this.startNodeAt(startPos, startLoc);
11282
11521
  node.test = expr;
11283
11522
  node.consequent = this.parseMaybeAssign();
@@ -11377,7 +11616,7 @@ pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forIni
11377
11616
  }
11378
11617
  }
11379
11618
 
11380
- if (!incDec && this.eat(types$1.starstar)) {
11619
+ if (!incDec && !(expr.type === "ArrowFunctionExpression" && expr.start === startPos) && this.eat(types$1.starstar)) {
11381
11620
  if (sawUnary)
11382
11621
  { this.unexpected(this.lastTokStart); }
11383
11622
  else
@@ -11829,6 +12068,8 @@ pp$5.parseNew = function() {
11829
12068
  }
11830
12069
  var startPos = this.start, startLoc = this.startLoc;
11831
12070
  node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false);
12071
+ if (node.callee.type === "Super")
12072
+ { this.raiseRecoverable(startPos, "Invalid use of 'super'"); }
11832
12073
  if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); }
11833
12074
  else { node.arguments = empty; }
11834
12075
  return this.finishNode(node, "NewExpression")
@@ -12446,7 +12687,7 @@ pp$2.copyNode = function(node) {
12446
12687
  };
12447
12688
 
12448
12689
  // 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";
12690
+ 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
12691
 
12451
12692
  // This file contains Unicode properties extracted from the ECMAScript specification.
12452
12693
  // The lists are extracted like so:
@@ -14007,13 +14248,17 @@ pp.readToken = function(code) {
14007
14248
  return this.getTokenFromCode(code)
14008
14249
  };
14009
14250
 
14010
- pp.fullCharCodeAtPos = function() {
14011
- var code = this.input.charCodeAt(this.pos);
14251
+ pp.fullCharCodeAt = function(pos) {
14252
+ var code = this.input.charCodeAt(pos);
14012
14253
  if (code <= 0xd7ff || code >= 0xdc00) { return code }
14013
- var next = this.input.charCodeAt(this.pos + 1);
14254
+ var next = this.input.charCodeAt(pos + 1);
14014
14255
  return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00
14015
14256
  };
14016
14257
 
14258
+ pp.fullCharCodeAtPos = function() {
14259
+ return this.fullCharCodeAt(this.pos)
14260
+ };
14261
+
14017
14262
  pp.skipBlockComment = function() {
14018
14263
  var startLoc = this.options.onComment && this.curPosition();
14019
14264
  var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
@@ -14741,7 +14986,7 @@ pp.readWord = function() {
14741
14986
  // [ghbt]: https://github.com/acornjs/acorn/issues
14742
14987
 
14743
14988
 
14744
- var version = "8.15.0";
14989
+ var version = "8.18.0";
14745
14990
 
14746
14991
  Parser.acorn = {
14747
14992
  Parser: Parser,