Skip to content

Commit

Permalink
style: adjust module resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
bhsd-harry committed Nov 21, 2023
1 parent 2d3580c commit ea083cb
Show file tree
Hide file tree
Showing 39 changed files with 54 additions and 47 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
target-branch: "browser"
assignees:
- "bhsd-harry"
commit-message:
Expand Down
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ const Parser: Parser = {
if (halfParsed) {
return new Title(title, defaultNs, config, decode, selfLink);
}
const {Token}: typeof import('./src') = require('./src');
const {Token}: typeof import('./src/index') = require('./src/index');
const token = this.run(() => new Token(title, config).parseOnce(0, include).parseOnce()),
titleObj = new Title(String(token), defaultNs, config, decode, selfLink);
this.run(() => {
Expand All @@ -313,7 +313,7 @@ const Parser: Parser = {

/** @implements */
parse(wikitext, include, maxStage = Parser.MAX_STAGE, config = Parser.getConfig()) {
const {Token}: typeof import('./src') = require('./src');
const {Token}: typeof import('./src/index') = require('./src/index');
let token: Token;
this.run(() => {
token = new Token(wikitext.replace(/[\0\x7F]/gu, ''), config);
Expand Down
10 changes: 5 additions & 5 deletions internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type {
} from './lib/node';
export type * from './lib/text';
// export type * from './lib/element';
export type * from './src';
export type * from './src/index';
export type * from './src/onlyinclude';
// export type * from './src/nowiki/base';
export type * from './src/nowiki/noinclude';
Expand All @@ -26,11 +26,11 @@ export type * from './src/html';
export type {TdToken} from './src/table/td';
// export type {TrBaseToken} from './src/table/trBase';
export type * from './src/table/tr';
export type * from './src/table';
export type * from './src/table/index';
export type * from './src/nowiki/hr';
export type * from './src/nowiki/doubleUnderscore';
// export type * from './src/link/base';
export type * from './src/link';
export type * from './src/link/index';
export type * from './src/link/category';
export type * from './src/imageParameter';
export type * from './src/link/file';
Expand All @@ -43,9 +43,9 @@ export type * from './src/nowiki/list';
export type * from './src/converterFlags';
export type * from './src/converterRule';
export type * from './src/converter';
export type * from './src/nowiki';
export type * from './src/nowiki/index';
export type * from './src/pre';
export type * from './src/paramTag';
export type * from './src/paramTag/index';
export type * from './src/paramTag/inputbox';
export type * from './src/nested';
export type * from './src/gallery';
Expand Down
2 changes: 1 addition & 1 deletion parser/braces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Parser from '../index';
import {HeadingToken} from '../src/heading';
import {TranscludeToken} from '../src/transclude';
import {ArgToken} from '../src/arg';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析花括号
Expand Down
2 changes: 1 addition & 1 deletion parser/commentAndExt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {NoincludeToken} from '../src/nowiki/noinclude';
import {IncludeToken} from '../src/tagPair/include';
import {ExtToken} from '../src/tagPair/ext';
import {CommentToken} from '../src/nowiki/comment';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析HTML注释和扩展标签
Expand Down
2 changes: 1 addition & 1 deletion parser/converter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Parser from '../index';
import {ConverterToken} from '../src/converter';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析语言变体转换
Expand Down
2 changes: 1 addition & 1 deletion parser/externalLinks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {extUrlChar, extUrlCharFirst} from '../util/string';
import * as Parser from '../index';
import {ExtLinkToken} from '../src/extLink';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析外部链接
Expand Down
2 changes: 1 addition & 1 deletion parser/html.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Parser from '../index';
import {AttributesToken} from '../src/attributes';
import {HtmlToken} from '../src/html';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析HTML标签
Expand Down
2 changes: 1 addition & 1 deletion parser/links.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Parser from '../index';
import {LinkToken} from '../src/link';
import {LinkToken} from '../src/link/index';
import {FileToken} from '../src/link/file';
import {CategoryToken} from '../src/link/category';
import type {Token} from '../internal';
Expand Down
2 changes: 1 addition & 1 deletion parser/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Parser from '../index';
import {ListToken} from '../src/nowiki/list';
import {DdToken} from '../src/nowiki/dd';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析列表
Expand Down
2 changes: 1 addition & 1 deletion parser/magicLinks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {extUrlChar, extUrlCharFirst} from '../util/string';
import * as Parser from '../index';
import {MagicLinkToken} from '../src/magicLink';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析自由外链
Expand Down
2 changes: 1 addition & 1 deletion parser/quotes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Parser from '../index';
import {QuoteToken} from '../src/nowiki/quote';
import type {Token} from '../src';
import type {Token} from '../src/index';

/**
* 解析单引号
Expand Down
4 changes: 2 additions & 2 deletions parser/table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as Parser from '../index';
import {Token} from '../src';
import {TableToken} from '../src/table';
import {Token} from '../src/index';
import {TableToken} from '../src/table/index';
import {TrToken} from '../src/table/tr';
import {TdToken} from '../src/table/td';
import {DdToken} from '../src/nowiki/dd';
Expand Down
2 changes: 1 addition & 1 deletion src/arg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {text, noWrap} from '../util/string';
import {generateForSelf, generateForChild} from '../util/lint';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {AtomToken} from './atom';
import {HiddenToken} from './hidden';
import type {LintError} from '../index';
Expand Down
2 changes: 1 addition & 1 deletion src/atom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';

declare type AtomTypes = 'arg-name'
| 'attr-key'
Expand Down
2 changes: 1 addition & 1 deletion src/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {generateForChild} from '../util/lint';
import {noWrap, removeComment} from '../util/string';
import {fixed} from '../mixin/fixed';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {AtomToken} from './atom';
import type {LintError, Config} from '../index';
import type {AttributesToken} from '../internal';
Expand Down
2 changes: 1 addition & 1 deletion src/attributes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {generateForSelf, generateForChild} from '../util/lint';
import {toCase, normalizeSpace, text, removeComment} from '../util/string';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {AtomToken} from './atom';
import {AttributeToken} from './attribute';
import type {LintError} from '../index';
Expand Down
2 changes: 1 addition & 1 deletion src/converter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {text, print} from '../util/string';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {ConverterFlagsToken} from './converterFlags';
import {ConverterRuleToken} from './converterRule';

Expand Down
2 changes: 1 addition & 1 deletion src/converterFlags.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {generateForChild} from '../util/lint';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {AtomToken} from './atom';
import type {LintError} from '../index';
import type {ConverterToken, ConverterRuleToken} from '../internal';
Expand Down
2 changes: 1 addition & 1 deletion src/converterRule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {undo} from '../util/debug';
import {noWrap} from '../util/string';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {AtomToken} from './atom';
import type {ConverterToken, ConverterFlagsToken} from '../internal';

Expand Down
2 changes: 1 addition & 1 deletion src/extLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {noWrap, normalizeSpace} from '../util/string';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {MagicLinkToken} from './magicLink';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/gallery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {GalleryImageToken} from './link/galleryImage';
import {HiddenToken} from './hidden';
import type {LintError} from '../index';
Expand Down
2 changes: 1 addition & 1 deletion src/heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {generateForSelf} from '../util/lint';
import {fixed} from '../mixin/fixed';
import {sol} from '../mixin/sol';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {SyntaxToken} from './syntax';
import type {LintError} from '../index';

Expand Down
2 changes: 1 addition & 1 deletion src/hidden.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {hidden} from '../mixin/hidden';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';

/** 不可见的节点 */
export class HiddenToken extends hidden(Token) {
Expand Down
2 changes: 1 addition & 1 deletion src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {noWrap} from '../util/string';
import {fixed} from '../mixin/fixed';
import {attributesParent} from '../mixin/attributesParent';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import type {LintError} from '../index';
import type {AttributesToken, TranscludeToken} from '../internal';

Expand Down
2 changes: 1 addition & 1 deletion src/imageParameter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {text, noWrap, print, extUrlChar, extUrlCharFirst} from '../util/string';
import {generateForSelf} from '../util/lint';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import type {LintError, Config} from '../index';
import type {Title} from '../lib/title';
import type {AstNodes, AstText, AtomToken, FileToken} from '../internal';
Expand Down
2 changes: 1 addition & 1 deletion src/imagemap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {generateForSelf, generateForChild} from '../util/lint';
import {singleLine} from '../mixin/singleLine';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {NoincludeToken} from './nowiki/noinclude';
import {GalleryImageToken} from './link/galleryImage';
import {ImagemapLinkToken} from './imagemapLink';
Expand Down
4 changes: 2 additions & 2 deletions src/imagemapLink.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {fixed} from '../mixin/fixed';
import {singleLine} from '../mixin/singleLine';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {NoincludeToken} from './nowiki/noinclude';
import {LinkToken} from './link';
import {LinkToken} from './link/index';
import {ExtLinkToken} from './extLink';
import type {Title} from '../lib/title';
import type {AstText, ImagemapToken} from '../internal';
Expand Down
2 changes: 1 addition & 1 deletion src/link/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {generateForChild} from '../../util/lint';
import {noWrap} from '../../util/string';
import {undo} from '../../util/debug';
import * as Parser from '../../index';
import {Token} from '..';
import {Token} from '../index';
import {AtomToken} from '../atom';
import type {LintError} from '../../index';
import type {Title} from '../../lib/title';
Expand Down
2 changes: 1 addition & 1 deletion src/link/category.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {decodeHtml} from '../../util/string';
import * as Parser from '../../index';
import {LinkToken} from '.';
import {LinkToken} from './index';

/** 分类 */
// @ts-expect-error not implementing all abstract methods
Expand Down
2 changes: 1 addition & 1 deletion src/link/galleryImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {generateForSelf} from '../../util/lint';
import {undo} from '../../util/debug';
import {singleLine} from '../../mixin/singleLine';
import * as Parser from '../../index';
import {Token} from '..';
import {Token} from '../index';
import {FileToken} from './file';
import type {Title} from '../../lib/title';
import type {LintError} from '../../index';
Expand Down
2 changes: 1 addition & 1 deletion src/magicLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {generateForChild} from '../util/lint';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import type {LintError} from '../index';
import type {ParameterToken} from './parameter';

Expand Down
2 changes: 1 addition & 1 deletion src/nested.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {generateForChild} from '../util/lint';
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';
import {ExtToken} from './tagPair/ext';
import {NoincludeToken} from './nowiki/noinclude';
import {CommentToken} from './nowiki/comment';
Expand Down
10 changes: 9 additions & 1 deletion src/nowiki/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {fixed} from '../../mixin/fixed';
import * as Parser from '../../index';
import {Token} from '..';
import {Token} from '../index';
import type {AstText} from '../../lib/text';

declare type NowikiTypes = 'ext-inner'
Expand All @@ -25,6 +25,14 @@ export abstract class NowikiBaseToken extends fixed(Token) {
abstract override get lastChild(): AstText;
abstract override get lastElementChild(): undefined;

/**
* @param wikitext default: `''`
* @browser
*/
constructor(wikitext = '', config = Parser.getConfig(), accum: Token[] = []) {
super(wikitext, config, accum);
}

/** @override */
override cloneNode(this: this & {constructor: new (...args: any[]) => unknown}): this {
const {constructor, firstChild: {data}, type} = this,
Expand Down
2 changes: 1 addition & 1 deletion src/nowiki/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {hidden} from '../../mixin/hidden';
import * as Parser from '../../index';
import {NowikiBaseToken} from './base';
import type {LintError} from '../../index';
import type {Token} from '..';
import type {Token} from '../index';

/** HTML注释,不可见 */
// @ts-expect-error not implementing all abstract methods
Expand Down
2 changes: 1 addition & 1 deletion src/onlyinclude.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Parser from '../index';
import {Token} from '.';
import {Token} from './index';

/**
* 嵌入时的`<onlyinclude>`
Expand Down
2 changes: 1 addition & 1 deletion src/paramTag/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {generateForChild} from '../../util/lint';
import {singleLine} from '../../mixin/singleLine';
import * as Parser from '../../index';
import {Token} from '..';
import {Token} from '../index';
import {AtomToken} from '../atom';
import type {LintError} from '../../index';
import type {AttributesToken, ExtToken} from '../../internal';
Expand Down
4 changes: 2 additions & 2 deletions src/paramTag/inputbox.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {parseBraces} from '../../parser/braces';
import * as Parser from '../../index';
import {ParamTagToken} from '.';
import type {Token} from '..';
import {ParamTagToken} from './index';
import type {Token} from '../index';

/** `<inputbox>` */
// @ts-expect-error not implementing all abstract methods
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"index.ts"
],
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"target": "esnext",
"module": "CommonJS",
"declaration": true,
Expand Down

0 comments on commit ea083cb

Please sign in to comment.