<commit_before>import { Cancellation, Supervisor, Just, Nothing } from 'spica';
import { route as route_, Config } from '../../application/api';
import { documentUrl } from './state/url';
import { env } from '../service/state/env';
import { RouterEventSource } from '../../domain/event/router';
import { progressbar } from './progressbar';
import { bind } from '../../../lib/dom';
import { standardizeUrl } from '../../data/model/domain/url';
import { InterfaceError } from '../data/error';

void bind(window, 'pjax:unload', () =>
  window.history.scrollRestoration = 'auto', true);

export async function route(
  config: Config,
  event: Event,
  process: Supervisor<'', Error, void, void>,
  io: {
    document: Document;
  }
): Promise<void> {
  assert([HTMLAnchorElement, HTMLFormElement, Window].some(Class => event._currentTarget instanceof Class));
  void event.preventDefault();
  const cancellation = new Cancellation<Error>();
  void process.cast('', new InterfaceError(`Abort.`));
  void process.register('', e => {
    throw void cancellation.cancel(e);
  }, void 0);
  const [scripts] = await env;
  window.history.scrollRestoration = 'manual';
  void progressbar(config.progressbar);
  return route_(config, event, { scripts, cancellation }, io)
    .then(m => m
      .bind(cancellation.either)
      .fmap(ss => (
        void ss
          .forEach(s =>
            void scripts.add(standardizeUrl(s.src))),
        void process.terminate(''),
        void documentUrl.sync()))
      .extract())<commit_msg>fix(interface): fix loaded external script registration processing<commit_after>import { Cancellation, Supervisor, Just, Nothing } from 'spica';
import { route as route_, Config } from '../../application/api';
import { documentUrl } from './state/url';
import { env } from '../service/state/env';
import { RouterEventSource } from '../../domain/event/router';
import { progressbar } from './progressbar';
import { bind } from '../../../lib/dom';
import { standardizeUrl } from '../../data/model/domain/url';
import { InterfaceError } from '../data/error';

void bind(window, 'pjax:unload', () =>
  window.history.scrollRestoration = 'auto', true);

export async function route(
  config: Config,
  event: Event,
  process: Supervisor<'', Error, void, void>,
  io: {
    document: Document;
  }
): Promise<void> {
  assert([HTMLAnchorElement, HTMLFormElement, Window].some(Class => event._currentTarget instanceof Class));
  void event.preventDefault();
  const cancellation = new Cancellation<Error>();
  void process.cast('', new InterfaceError(`Abort.`));
  void process.register('', e => {
    throw void cancellation.cancel(e);
  }, void 0);
  const [scripts] = await env;
  window.history.scrollRestoration = 'manual';
  void progressbar(config.progressbar);
  return route_(config, event, { scripts, cancellation }, io)
    .then(m => m
      .bind(cancellation.either)
      .fmap(ss => (
        void ss
          .filter(s => s.hasAttribute('src'))
          .forEach(s =>
            void scripts.add(standardizeUrl(s.src))),
        void process.terminate(''),
        void documentUrl.sync()))
      .extract())
{'fraction_non_alphanumeric': 0.16619002224340643, 'fraction_numerical': 0.0006355258976803305, 'mean_word_length': 3.56231884057971, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6630620', 'n_tokens_mistral': 902, 'n_tokens_neox': 899, 'n_words': 241}