Skip to content

deps: Migrate to @esfx/canceltoken #639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 47 additions & 179 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"author": "Brian Terlson",
"license": "MIT",
"dependencies": {
"@esfx/canceltoken": "^1.0.0",
"chalk": "^4.1.2",
"command-line-args": "^5.2.0",
"command-line-usage": "^6.1.1",
Expand All @@ -62,7 +63,6 @@
"jsdom": "^25.0.1",
"nwsapi": "2.2.0",
"parse5": "^6.0.1",
"prex": "^0.4.7",
"promise-debounce": "^1.0.1"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
YES_CLAUSE_AUTOLINK,
} from './autolinker';
import { lint } from './lint/lint';
import { CancellationToken } from 'prex';
import { CancelToken } from '@esfx/canceltoken';
import type { JSDOM } from 'jsdom';
import { getProductions, rhsMatches, getLocationInGrammarFile } from './lint/utils';
import type { AugmentedGrammarEle } from './Grammar';
Expand Down Expand Up @@ -314,7 +314,7 @@ export default class Spec {
>; // map from re to its labeled nodes
/** @internal */ labeledStepsToBeRectified: Set<string>;
/** @internal */ replacementAlgorithms: { element: Element; target: string }[];
/** @internal */ cancellationToken: CancellationToken;
/** @internal */ cancellationToken: CancelToken;

readonly log: (msg: string) => void;
readonly warn: (err: Warning) => void | undefined;
Expand All @@ -337,15 +337,15 @@ export default class Spec {
/** @internal */ refsByClause: { [refId: string]: [string] };
/** @internal */ topLevelImportedNodes: Map<Node, EmuImportElement>;

private _fetch: (file: string, token: CancellationToken) => PromiseLike<string>;
private _fetch: (file: string, token: CancelToken) => PromiseLike<string>;

constructor(
rootPath: string,
fetch: (file: string, token: CancellationToken) => PromiseLike<string>,
fetch: (file: string, token: CancelToken) => PromiseLike<string>,
dom: JSDOM,
opts: Options = {},
sourceText: string,
token = CancellationToken.none,
token = CancelToken.none,
) {
this.spec = this;
this.opts = {};
Expand Down Expand Up @@ -1343,7 +1343,7 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod
}

private async loadBiblios() {
this.cancellationToken.throwIfCancellationRequested();
this.cancellationToken.throwIfSignaled();
const biblioPaths = [];
for (const biblioEle of this.doc.querySelectorAll('emu-biblio')) {
const href = biblioEle.getAttribute('href');
Expand Down Expand Up @@ -1444,7 +1444,7 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod
}

private buildBoilerplate() {
this.cancellationToken.throwIfCancellationRequested();
this.cancellationToken.throwIfSignaled();
const status = this.opts.status!;
const version = this.opts.version;
const title = this.opts.title;
Expand Down
6 changes: 3 additions & 3 deletions src/ecmarkup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { BiblioEntry, ExportedBiblio } from './Biblio';

import Spec from './Spec';
import * as utils from './utils';
import { CancellationToken } from 'prex';
import { CancelToken } from '@esfx/canceltoken';

export type { Spec, BiblioEntry };

Expand Down Expand Up @@ -52,9 +52,9 @@ export interface Options {

export async function build(
path: string,
fetch: (path: string, token: CancellationToken) => PromiseLike<string>,
fetch: (path: string, token: CancelToken) => PromiseLike<string>,
opts?: Options,
token = CancellationToken.none,
token = CancelToken.none,
): Promise<Spec> {
const html = await fetch(path, token);
const dom = utils.htmlToDom(html);
Expand Down