From e9df0a8cd173c13f4926da5453a3b196514cf2b9 Mon Sep 17 00:00:00 2001 From: bhsd <2545473905@qq.com> Date: Thu, 23 Nov 2023 22:25:37 +0800 Subject: [PATCH] style: new way to mark use for browser --- lib/node.ts | 4 ++++ src/attributes.ts | 4 ++++ src/link/base.ts | 5 ----- src/nested.ts | 2 +- src/table/base.ts | 4 ++++ src/table/index.ts | 4 ++++ src/table/td.ts | 4 ++++ 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/node.ts b/lib/node.ts index f52964886..27fb91ac0 100644 --- a/lib/node.ts +++ b/lib/node.ts @@ -86,6 +86,8 @@ export interface CaretPosition { offset: number; } +/* NOT FOR BROWSER */ + /** * 定制TypeError消息 * @param {Function} Constructor 类 @@ -97,6 +99,8 @@ const typeError = ({name}: Function, method: string, ...args: string[]): never = throw new TypeError(`${name}.${method} 方法仅接受 ${args.join('、')} 作为输入参数!`); }; +/* NOT FOR BROWSER END */ + /** 类似Node */ export abstract class AstNode { type: TokenTypes | 'text'; diff --git a/src/attributes.ts b/src/attributes.ts index 3b31660ca..fb5d19277 100644 --- a/src/attributes.ts +++ b/src/attributes.ts @@ -8,8 +8,12 @@ import type {LintError} from '../index'; import type {ExtToken, HtmlToken, TdToken, TrToken, TableToken} from '../internal'; import type {AttributeTypes} from './attribute'; +/* NOT FOR BROWSER */ + const stages = {'ext-attrs': 0, 'html-attrs': 2, 'table-attrs': 3}; +/* NOT FOR BROWSER END */ + declare type AttributesTypes = 'ext-attrs' | 'html-attrs' | 'table-attrs'; /** diff --git a/src/link/base.ts b/src/link/base.ts index cd107dbb0..5a4770b7c 100644 --- a/src/link/base.ts +++ b/src/link/base.ts @@ -14,16 +14,11 @@ import type {Title} from '../../lib/title'; export abstract class LinkBaseToken extends Token { declare type: 'link' | 'category' | 'file' | 'gallery-image' | 'imagemap-image'; declare name: string; - - /* NOT FOR BROWSER */ - #bracket = true; #delimiter; #fragment: string | undefined; #encoded = false; - /* NOT FOR BROWSER END */ - declare childNodes: [AtomToken, ...Token[]]; abstract override get children(): [AtomToken, ...Token[]]; abstract override get firstChild(): AtomToken; diff --git a/src/nested.ts b/src/nested.ts index 58cdc7536..ce36ce6bf 100644 --- a/src/nested.ts +++ b/src/nested.ts @@ -13,10 +13,10 @@ import type {AttributesToken} from './attributes'; */ export class NestedToken extends Token { override readonly type = 'ext-inner'; + declare name: string; /* NOT FOR BROWSER */ - declare name: string; #tags: string[]; #regex; diff --git a/src/table/base.ts b/src/table/base.ts index a83b59e02..11319ae7a 100644 --- a/src/table/base.ts +++ b/src/table/base.ts @@ -4,6 +4,8 @@ import {Token} from '../index'; import {SyntaxToken} from '../syntax'; import {AttributesToken} from '../attributes'; +/* NOT FOR BROWSER */ + /** * 转义表格语法 * @param syntax 表格语法节点 @@ -19,6 +21,8 @@ const escapeTable = (syntax: SyntaxToken): void => { syntax.replaceChildren(...token.childNodes); }; +/* NOT FOR BROWSER END */ + /** * 表格行,含开头的换行,不含结尾的换行 * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...Token]}` diff --git a/src/table/index.ts b/src/table/index.ts index 9d8034409..c82879c5a 100644 --- a/src/table/index.ts +++ b/src/table/index.ts @@ -21,6 +21,8 @@ declare interface TableRenderedCoords { const closingPattern = /^\n[^\S\n]*(?:\|\}|\{\{\s*!\s*\}\}\}|\{\{\s*!\)\s*\}\})$/u; +/* NOT FOR BROWSER */ + /** * 比较两个表格坐标 * @param coords1 坐标1 @@ -118,6 +120,8 @@ class Layout extends Array { } } +/* NOT FOR BROWSER END */ + /** * 表格 * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ?Token, ...TdToken, ...TrToken, ?SyntaxToken]}` diff --git a/src/table/td.ts b/src/table/td.ts index 837bb5a66..c6daaa90d 100644 --- a/src/table/td.ts +++ b/src/table/td.ts @@ -296,6 +296,8 @@ export class TdToken extends fixed(TableBaseToken) { } } +/* NOT FOR BROWSER */ + /** * 创建新的单元格 * @param inner 内部wikitext @@ -321,4 +323,6 @@ export const createTd = ( return token; }; +/* NOT FOR BROWSER END */ + Parser.classes['TdToken'] = __filename;