wikiparser-node 1.4.2 → 1.4.3

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.
Files changed (103) hide show
  1. package/dist/addon/table.js +5 -1
  2. package/dist/base.d.ts +6 -1
  3. package/dist/index.d.ts +0 -2
  4. package/dist/index.js +3 -3
  5. package/dist/lib/element.d.ts +3 -2
  6. package/dist/lib/element.js +20 -13
  7. package/dist/lib/node.js +13 -10
  8. package/dist/lib/text.js +3 -3
  9. package/dist/lib/title.js +4 -12
  10. package/dist/mixin/attributesParent.d.ts +32 -2
  11. package/dist/mixin/attributesParent.js +14 -25
  12. package/dist/mixin/fixed.d.ts +2 -1
  13. package/dist/mixin/fixed.js +3 -1
  14. package/dist/mixin/flagsParent.d.ts +28 -17
  15. package/dist/mixin/flagsParent.js +12 -25
  16. package/dist/mixin/magicLinkParent.d.ts +14 -8
  17. package/dist/mixin/magicLinkParent.js +7 -8
  18. package/dist/mixin/singleLine.d.ts +2 -1
  19. package/dist/mixin/singleLine.js +3 -2
  20. package/dist/mixin/sol.d.ts +2 -4
  21. package/dist/mixin/sol.js +8 -6
  22. package/dist/mixin/syntax.d.ts +5 -2
  23. package/dist/mixin/syntax.js +14 -18
  24. package/dist/parser/links.js +1 -3
  25. package/dist/src/arg.d.ts +4 -4
  26. package/dist/src/arg.js +4 -4
  27. package/dist/src/attribute.d.ts +9 -7
  28. package/dist/src/attribute.js +271 -218
  29. package/dist/src/attributes.d.ts +3 -3
  30. package/dist/src/attributes.js +0 -1
  31. package/dist/src/converter.d.ts +7 -2
  32. package/dist/src/converter.js +113 -64
  33. package/dist/src/converterFlags.d.ts +5 -5
  34. package/dist/src/converterFlags.js +0 -1
  35. package/dist/src/converterRule.d.ts +5 -5
  36. package/dist/src/converterRule.js +0 -1
  37. package/dist/src/extLink.d.ts +7 -2
  38. package/dist/src/extLink.js +159 -110
  39. package/dist/src/gallery.d.ts +5 -5
  40. package/dist/src/gallery.js +0 -1
  41. package/dist/src/heading.d.ts +8 -8
  42. package/dist/src/heading.js +172 -125
  43. package/dist/src/html.d.ts +8 -5
  44. package/dist/src/html.js +263 -214
  45. package/dist/src/imageParameter.d.ts +2 -2
  46. package/dist/src/imageParameter.js +1 -0
  47. package/dist/src/imagemap.d.ts +5 -5
  48. package/dist/src/imagemap.js +4 -10
  49. package/dist/src/imagemapLink.d.ts +7 -4
  50. package/dist/src/imagemapLink.js +75 -26
  51. package/dist/src/index.js +3 -4
  52. package/dist/src/link/base.d.ts +2 -2
  53. package/dist/src/link/base.js +1 -4
  54. package/dist/src/link/file.d.ts +1 -1
  55. package/dist/src/link/file.js +0 -1
  56. package/dist/src/link/galleryImage.d.ts +2 -1
  57. package/dist/src/link/galleryImage.js +136 -88
  58. package/dist/src/link/index.js +0 -1
  59. package/dist/src/magicLink.d.ts +11 -3
  60. package/dist/src/magicLink.js +170 -120
  61. package/dist/src/nested.d.ts +5 -5
  62. package/dist/src/nested.js +1 -0
  63. package/dist/src/nowiki/base.d.ts +6 -2
  64. package/dist/src/nowiki/base.js +79 -28
  65. package/dist/src/nowiki/comment.d.ts +0 -2
  66. package/dist/src/nowiki/comment.js +0 -9
  67. package/dist/src/nowiki/doubleUnderscore.js +88 -38
  68. package/dist/src/nowiki/hr.d.ts +1 -4
  69. package/dist/src/nowiki/hr.js +53 -4
  70. package/dist/src/nowiki/index.d.ts +2 -2
  71. package/dist/src/nowiki/index.js +1 -0
  72. package/dist/src/nowiki/list.d.ts +1 -4
  73. package/dist/src/nowiki/list.js +88 -39
  74. package/dist/src/nowiki/listBase.d.ts +1 -1
  75. package/dist/src/nowiki/listBase.js +52 -2
  76. package/dist/src/nowiki/quote.d.ts +3 -3
  77. package/dist/src/nowiki/quote.js +102 -54
  78. package/dist/src/paramTag/index.d.ts +5 -5
  79. package/dist/src/paramTag/index.js +2 -1
  80. package/dist/src/parameter.d.ts +11 -8
  81. package/dist/src/parameter.js +225 -176
  82. package/dist/src/pre.d.ts +5 -5
  83. package/dist/src/pre.js +1 -0
  84. package/dist/src/syntax.d.ts +6 -0
  85. package/dist/src/syntax.js +74 -23
  86. package/dist/src/table/base.d.ts +6 -3
  87. package/dist/src/table/base.js +100 -49
  88. package/dist/src/table/index.d.ts +6 -3
  89. package/dist/src/table/index.js +5 -9
  90. package/dist/src/table/td.d.ts +9 -5
  91. package/dist/src/table/td.js +270 -217
  92. package/dist/src/table/tr.d.ts +4 -4
  93. package/dist/src/table/tr.js +1 -0
  94. package/dist/src/tagPair/ext.d.ts +6 -3
  95. package/dist/src/tagPair/ext.js +168 -118
  96. package/dist/src/tagPair/include.d.ts +2 -4
  97. package/dist/src/tagPair/include.js +0 -8
  98. package/dist/src/tagPair/index.d.ts +1 -1
  99. package/dist/src/tagPair/index.js +115 -66
  100. package/dist/src/transclude.d.ts +3 -3
  101. package/dist/src/transclude.js +4 -9
  102. package/dist/util/debug.js +0 -2
  103. package/package.json +3 -3
@@ -40,7 +40,11 @@ const isStartCol = (rowLayout, i, oneCol = false) => {
40
40
  return rowLayout[i - 1] !== coords && (!oneCol || rowLayout[i + 1] !== coords);
41
41
  };
42
42
  function occupied(layout, i, oneRow = false, cells) {
43
- return layout[i].map(({ row, column }, j) => row === i && (!oneRow || cells[column].rowspan === 1) ? j : undefined).filter((j) => j !== undefined);
43
+ const rowLayout = layout[i];
44
+ if (rowLayout) {
45
+ return rowLayout.map(({ row, column }, j) => row === i && (!oneRow || cells[column]?.rowspan === 1) ? j : undefined).filter((j) => j !== undefined);
46
+ }
47
+ throw new RangeError(`表格没有第 ${i} 行!`);
44
48
  }
45
49
  /**
46
50
  * 设置表格格式
package/dist/base.d.ts CHANGED
@@ -24,6 +24,11 @@ export interface LintError {
24
24
  readonly endLine: number;
25
25
  readonly endCol: number;
26
26
  }
27
+ export type AST = Record<string, string | number | boolean> & {
28
+ range: [number, number];
29
+ type?: string;
30
+ childNodes?: AST[];
31
+ };
27
32
  /** 类似Node */
28
33
  export interface AstNode {
29
34
  type: string;
@@ -36,7 +41,7 @@ export interface AstNode {
36
41
  /** 类似HTMLElement */
37
42
  interface AstElement extends AstNode {
38
43
  /** 保存为JSON */
39
- json(): object;
44
+ json(): AST;
40
45
  }
41
46
  export interface Parser {
42
47
  config: string | Config;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- import { Shadow } from './util/debug';
2
1
  import type { log } from './util/diff';
3
2
  import type { Config, LintError, Parser as ParserBase } from './base';
4
3
  import type { Title } from './lib/title';
5
4
  import type { Token } from './internal';
6
5
  declare interface Parser extends ParserBase {
7
- readonly Shadow: typeof Shadow;
8
6
  conversionTable: Map<string, string>;
9
7
  redirects: Map<string, string>;
10
8
  warning: boolean;
package/dist/index.js CHANGED
@@ -17,7 +17,6 @@ const Parser = {
17
17
  config: 'default',
18
18
  i18n: undefined,
19
19
  /* NOT FOR BROWSER */
20
- Shadow: debug_1.Shadow,
21
20
  conversionTable: new Map(),
22
21
  redirects: new Map(),
23
22
  warning: true,
@@ -62,8 +61,9 @@ const Parser = {
62
61
  /* NOT FOR BROWSER */
63
62
  debug_1.Shadow.run(() => {
64
63
  for (const key of ['main', 'fragment']) {
65
- if (titleObj[key]?.includes('\0')) {
66
- titleObj[key] = token.buildFromStr(titleObj[key], constants_1.BuildMethod.Text);
64
+ const str = titleObj[key];
65
+ if (str?.includes('\0')) {
66
+ titleObj[key] = token.buildFromStr(str, constants_1.BuildMethod.Text);
67
67
  }
68
68
  }
69
69
  });
@@ -1,5 +1,5 @@
1
1
  import { AstNode } from './node';
2
- import type { LintError } from '../base';
2
+ import type { LintError, AST } from '../base';
3
3
  import type { AstNodes, AstText, Token } from '../internal';
4
4
  /** 类似HTMLElement */
5
5
  export declare abstract class AstElement extends AstNode {
@@ -85,8 +85,9 @@ export declare abstract class AstElement extends AstNode {
85
85
  /**
86
86
  * 保存为JSON
87
87
  * @param file 文件名
88
+ * @param start
88
89
  */
89
- json(file?: string): object;
90
+ json(file?: string, start?: number): AST;
90
91
  /** 销毁 */
91
92
  destroy(): void;
92
93
  /**
@@ -11,6 +11,7 @@ const ranges_1 = require("./ranges");
11
11
  const title_1 = require("./title");
12
12
  const index_1 = require("../index");
13
13
  const node_1 = require("./node");
14
+ /* NOT FOR BROWSER */
14
15
  /**
15
16
  * optionally convert to lower cases
16
17
  * @param val 属性值
@@ -164,18 +165,14 @@ class AstElement extends node_1.AstNode {
164
165
  * @param selector 选择器
165
166
  */
166
167
  #getCondition(selector) {
167
- let condition;
168
168
  /* NOT FOR BROWSER */
169
169
  if (/[^a-z\-,\s]/u.test(selector)) {
170
170
  const stack = (0, selector_1.parseSelector)(selector);
171
- condition = (token => stack.some(copy => token.#matchesArray(copy)));
171
+ return (token => stack.some(copy => token.#matchesArray(copy)));
172
172
  }
173
- else {
174
- /* NOT FOR BROWSER END */
175
- const types = new Set(selector.split(',').map(str => str.trim()));
176
- condition = (token => types.has(token.type));
177
- }
178
- return condition;
173
+ /* NOT FOR BROWSER END */
174
+ const types = new Set(selector.split(',').map(str => str.trim()));
175
+ return (({ type }) => types.has(type));
179
176
  }
180
177
  /**
181
178
  * 最近的祖先节点
@@ -223,9 +220,7 @@ class AstElement extends node_1.AstNode {
223
220
  this.verifyChild(i);
224
221
  /* NOT FOR BROWSER END */
225
222
  const oldText = this.childNodes[i];
226
- /* NOT FOR BROWSER */
227
- if (oldText.type === 'text') {
228
- /* NOT FOR BROWSER END */
223
+ if (oldText.type === 'text') { // eslint-disable-line @typescript-eslint/no-unnecessary-condition
229
224
  const { data } = oldText;
230
225
  oldText.replaceData(str);
231
226
  return data;
@@ -260,12 +255,24 @@ class AstElement extends node_1.AstNode {
260
255
  /**
261
256
  * 保存为JSON
262
257
  * @param file 文件名
258
+ * @param start
263
259
  */
264
- json(file) {
260
+ json(file, start = this.getAbsoluteIndex()) {
265
261
  const json = {
266
262
  ...this,
267
- childNodes: this.childNodes.map(child => child.type === 'text' ? { data: child.data } : child.json()),
263
+ range: [start, start + String(this).length],
264
+ childNodes: [],
268
265
  };
266
+ for (let i = 0, cur = start + this.getAttribute('padding'); i < this.length; i++) {
267
+ const child = this.childNodes[i], { length } = String(child);
268
+ if (child.type === 'text') {
269
+ json.childNodes.push({ data: child.data, range: [cur, cur + length] });
270
+ }
271
+ else {
272
+ json.childNodes.push(child.json(undefined, cur));
273
+ }
274
+ cur += length + this.getGaps(i);
275
+ }
269
276
  /* NOT FOR BROWSER */
270
277
  if (typeof file === 'string') {
271
278
  fs.writeFileSync(path.join(__dirname.slice(0, -4), '..', 'printed', `${file}${file.endsWith('.json') ? '' : '.json'}`), JSON.stringify(json, null, 2));
package/dist/lib/node.js CHANGED
@@ -199,26 +199,29 @@ class AstNode {
199
199
  const { parentNode } = this;
200
200
  return parentNode ? parentNode.getAbsoluteIndex() + this.getRelativeIndex() : 0;
201
201
  }
202
- /* NOT FOR BROWSER */
203
- /** @private */
204
- typeError(method, ...types) {
205
- return typeError(this.constructor, method, ...types);
206
- }
207
- /** @private */
208
- constructorError(msg) {
209
- throw new Error(`${this.constructor.name} ${msg}!`);
210
- }
211
202
  /** @private */
212
203
  seal(key, permanent) {
204
+ /* NOT FOR BROWSER */
213
205
  if (!permanent) {
214
206
  this.#optional.add(key);
215
207
  }
208
+ /* NOT FOR BROWSER END */
216
209
  Object.defineProperty(this, key, {
217
- writable: false,
218
210
  enumerable: !permanent && Boolean(this[key]),
219
211
  configurable: true,
212
+ /* NOT FOR BROWSER */
213
+ writable: false,
220
214
  });
221
215
  }
216
+ /* NOT FOR BROWSER */
217
+ /** @private */
218
+ typeError(method, ...types) {
219
+ return typeError(this.constructor, method, ...types);
220
+ }
221
+ /** @private */
222
+ constructorError(msg) {
223
+ throw new Error(`${this.constructor.name} ${msg}!`);
224
+ }
222
225
  /**
223
226
  * 是否是全同节点
224
227
  * @param node 待比较的节点
package/dist/lib/text.js CHANGED
@@ -85,14 +85,13 @@ class AstText extends node_1.AstNode {
85
85
  constructor(text) {
86
86
  super();
87
87
  Object.defineProperties(this, {
88
+ childNodes: { enumerable: false, configurable: false },
89
+ type: { enumerable: false, writable: false },
88
90
  data: {
89
91
  value: text,
90
92
  /* NOT FOR BROWSER */
91
93
  writable: false,
92
94
  },
93
- /* NOT FOR BROWSER */
94
- childNodes: { enumerable: false, configurable: false },
95
- type: { enumerable: false, writable: false },
96
95
  });
97
96
  }
98
97
  /** @private */
@@ -116,6 +115,7 @@ class AstText extends node_1.AstNode {
116
115
  }
117
116
  /* NOT FOR BROWSER END */
118
117
  const { NowikiToken } = require('../src/nowiki');
118
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
119
119
  const { type, name } = parentNode, nowiki = name === 'nowiki' || name === 'pre';
120
120
  let errorRegex;
121
121
  if (type === 'ext-inner' && (name === 'pre' || parentNode instanceof NowikiToken)) {
package/dist/lib/title.js CHANGED
@@ -61,12 +61,6 @@ class Title {
61
61
  * @param selfLink 是否允许selfLink
62
62
  */
63
63
  constructor(title, defaultNs = 0, config = index_1.default.getConfig(), decode = false, selfLink = false) {
64
- const { nsid,
65
- /* NOT FOR BROWSER */
66
- namespaces, } = config;
67
- /* NOT FOR BROWSER */
68
- this.#namespaces = namespaces;
69
- /* NOT FOR BROWSER END */
70
64
  title = (0, string_1.decodeHtml)(title);
71
65
  if (decode && title.includes('%')) {
72
66
  try {
@@ -91,7 +85,7 @@ class Title {
91
85
  /* NOT FOR BROWSER END */
92
86
  const m = title.split(':');
93
87
  if (m.length > 1) {
94
- const id = nsid[m[0].trim().toLowerCase()];
88
+ const id = config.nsid[m[0].trim().toLowerCase()];
95
89
  if (id) {
96
90
  ns = id;
97
91
  title = m.slice(1).join(':').trim();
@@ -116,12 +110,10 @@ class Title {
116
110
  this.fragment = fragment;
117
111
  title = title.slice(0, i).trim();
118
112
  }
119
- this.valid = Boolean(title
120
- /* NOT FOR BROWSER */
121
- || this.interwiki
122
- /* NOT FOR BROWSER END */
123
- || selfLink && this.fragment !== undefined) && !/^:|\0\d+[eh!+-]\x7F|[<>[\]{}|]|%[\da-f]{2}/iu.test(title);
113
+ this.valid = Boolean(title || this.interwiki || selfLink && this.fragment !== undefined)
114
+ && !/^:|\0\d+[eh!+-]\x7F|[<>[\]{}|]|%[\da-f]{2}/iu.test(title);
124
115
  /* NOT FOR BROWSER */
116
+ this.#namespaces = config.namespaces;
125
117
  this.main = title;
126
118
  Object.defineProperties(this, {
127
119
  valid: { writable: false },
@@ -1,20 +1,50 @@
1
1
  export interface AttributesParentBase {
2
+ /** getAttrs()方法的getter写法 */
2
3
  attributes: Record<string, string | true>;
4
+ /** 以字符串表示的class属性 */
3
5
  className: string;
6
+ /** 以Set表示的class属性 */
4
7
  classList: Set<string>;
8
+ /** id属性 */
5
9
  id: string;
10
+ /**
11
+ * AttributesToken子节点是否具有某属性
12
+ * @param key 属性键
13
+ */
6
14
  hasAttr(key: string): boolean;
15
+ /**
16
+ * 获取AttributesToken子节点的属性
17
+ * @param key 属性键
18
+ */
7
19
  getAttr(key: string): string | true | undefined;
20
+ /** 列举AttributesToken子节点的属性键 */
8
21
  getAttrNames(): Set<string>;
22
+ /** 获取AttributesToken子节点的全部标签属性 */
9
23
  getAttrs(): Record<string, string | true>;
24
+ /**
25
+ * 对AttributesToken子节点设置属性
26
+ * @param key 属性键
27
+ * @param value 属性值
28
+ * @param prop 属性对象
29
+ */
10
30
  setAttr(key: string, value: string | boolean): void;
11
31
  setAttr(prop: Record<string, string | boolean>): void;
32
+ /**
33
+ * 移除AttributesToken子节点的某属性
34
+ * @param key 属性键
35
+ */
12
36
  removeAttr(key: string): void;
37
+ /**
38
+ * 开关AttributesToken子节点的某属性
39
+ * @param key 属性键
40
+ * @param force 强制开启或关闭
41
+ */
13
42
  toggleAttr(key: string, force?: boolean): void;
14
43
  }
15
44
  /**
16
45
  * 子节点含有AttributesToken的类
17
- * @param constructor 基类
18
46
  * @param i AttributesToken子节点的位置
47
+ * @param constructor 基类
48
+ * @param _ context
19
49
  */
20
- export declare const attributesParent: <T extends AstConstructor>(constructor: T, i?: number) => T;
50
+ export declare const attributesParent: (i?: number) => <T extends AstConstructor>(constructor: T, _?: unknown) => T;
@@ -4,85 +4,74 @@ exports.attributesParent = void 0;
4
4
  const constants_1 = require("../util/constants");
5
5
  /**
6
6
  * 子节点含有AttributesToken的类
7
- * @param constructor 基类
8
7
  * @param i AttributesToken子节点的位置
8
+ * @param constructor 基类
9
+ * @param _ context
9
10
  */
10
- const attributesParent = (constructor, i = 0) => {
11
+ const attributesParent = (i = 0) => (constructor, _) => {
11
12
  /** 子节点含有AttributesToken的类 */
12
13
  class AttributesParent extends constructor {
13
14
  /** AttributesToken子节点 */
14
15
  get #attributesChild() {
15
16
  return this.childNodes[i];
16
17
  }
17
- /** getAttrs()方法的getter写法 */
18
+ /** @implements */
18
19
  get attributes() {
19
20
  return this.#attributesChild.attributes;
20
21
  }
21
22
  set attributes(attributes) {
22
23
  this.#attributesChild.attributes = attributes;
23
24
  }
24
- /** 以字符串表示的class属性 */
25
+ /** @implements */
25
26
  get className() {
26
27
  return this.#attributesChild.className;
27
28
  }
28
29
  set className(className) {
29
30
  this.#attributesChild.className = className;
30
31
  }
31
- /** 以Set表示的class属性 */
32
+ /** @implements */
32
33
  get classList() {
33
34
  return this.#attributesChild.classList;
34
35
  }
35
36
  set classList(classList) {
36
37
  this.#attributesChild.classList = classList;
37
38
  }
38
- /** id属性 */
39
+ /** @implements */
39
40
  get id() {
40
41
  return this.#attributesChild.id;
41
42
  }
42
43
  set id(id) {
43
44
  this.#attributesChild.id = id;
44
45
  }
45
- /**
46
- * AttributesToken子节点是否具有某属性
47
- * @param key 属性键
48
- */
46
+ /** @implements */
49
47
  hasAttr(key) {
50
48
  return this.#attributesChild.hasAttr(key);
51
49
  }
52
- /**
53
- * 获取AttributesToken子节点的属性
54
- * @param key 属性键
55
- */
50
+ /** @implements */
56
51
  getAttr(key) {
57
52
  return this.#attributesChild.getAttr(key);
58
53
  }
59
- /** 列举AttributesToken子节点的属性键 */
54
+ /** @implements */
60
55
  getAttrNames() {
61
56
  return this.#attributesChild.getAttrNames();
62
57
  }
63
- /** 获取AttributesToken子节点的全部标签属性 */
58
+ /** @implements */
64
59
  getAttrs() {
65
60
  return this.#attributesChild.getAttrs();
66
61
  }
67
62
  setAttr(keyOrProp, value) {
68
63
  this.#attributesChild.setAttr(keyOrProp, value);
69
64
  }
70
- /**
71
- * 移除AttributesToken子节点的某属性
72
- * @param key 属性键
73
- */
65
+ /** @implements */
74
66
  removeAttr(key) {
75
67
  this.#attributesChild.removeAttr(key);
76
68
  }
77
- /**
78
- * 开关AttributesToken子节点的某属性
79
- * @param key 属性键
80
- * @param force 强制开启或关闭
81
- */
69
+ /** @implements */
82
70
  toggleAttr(key, force) {
83
71
  this.#attributesChild.toggleAttr(key, force);
84
72
  }
85
73
  }
74
+ Object.defineProperty(AttributesParent, 'name', { value: constructor.name });
86
75
  return AttributesParent;
87
76
  };
88
77
  exports.attributesParent = attributesParent;
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * 不可增删子节点的类
3
3
  * @param constructor 基类
4
+ * @param _ context
4
5
  */
5
- export declare const fixedToken: <S extends AstConstructor>(constructor: S) => S;
6
+ export declare const fixedToken: <S extends AstConstructor>(constructor: S, _?: unknown) => S;
@@ -6,8 +6,9 @@ const constants_1 = require("../util/constants");
6
6
  /**
7
7
  * 不可增删子节点的类
8
8
  * @param constructor 基类
9
+ * @param _ context
9
10
  */
10
- const fixedToken = (constructor) => {
11
+ const fixedToken = (constructor, _) => {
11
12
  /** 不可增删子节点的类 */
12
13
  class FixedToken extends constructor {
13
14
  /** @private */
@@ -22,6 +23,7 @@ const fixedToken = (constructor) => {
22
23
  return debug_1.Shadow.running ? super.insertAt(token, i) : this.constructorError('不可插入元素');
23
24
  }
24
25
  }
26
+ Object.defineProperty(FixedToken, 'name', { value: constructor.name });
25
27
  return FixedToken;
26
28
  };
27
29
  exports.fixedToken = fixedToken;
@@ -1,22 +1,5 @@
1
1
  import type { ConverterFlagsToken } from '../src/converterFlags';
2
2
  export interface FlagsParentBase {
3
- flags: Set<string>;
4
- getAllFlags(): Set<string>;
5
- getEffectiveFlags(): Set<string>;
6
- getUnknownFlags(): Set<string>;
7
- hasFlag(flag: string): boolean;
8
- hasEffectiveFlag(flag: string): boolean;
9
- removeFlag(flag: string): void;
10
- setFlag(flag: string): void;
11
- toggleFlag(flag: string): void;
12
- }
13
- /**
14
- * ConverterToken
15
- * @param constructor 基类
16
- */
17
- export declare const flagsParent: <T extends AstConstructor>(constructor: T) => (abstract new (...args: any[]) => {
18
- readonly firstChild: ConverterFlagsToken;
19
- readonly firstElementChild: ConverterFlagsToken;
20
3
  /** 所有转换类型标记 */
21
4
  flags: Set<string>;
22
5
  /** 获取所有转换类型标记 */
@@ -50,6 +33,33 @@ export declare const flagsParent: <T extends AstConstructor>(constructor: T) =>
50
33
  * @param flag 转换类型标记
51
34
  */
52
35
  toggleFlag(flag: string): void;
36
+ }
37
+ /**
38
+ * ConverterToken
39
+ * @param constructor 基类
40
+ * @param _ context
41
+ */
42
+ export declare const flagsParent: <T extends AstConstructor>(constructor: T, _?: unknown) => (abstract new (...args: any[]) => {
43
+ readonly firstChild: ConverterFlagsToken;
44
+ readonly firstElementChild: ConverterFlagsToken;
45
+ /** @implements */
46
+ flags: Set<string>;
47
+ /** @implements */
48
+ getAllFlags(): Set<string>;
49
+ /** @implements */
50
+ getEffectiveFlags(): Set<string>;
51
+ /** @implements */
52
+ getUnknownFlags(): Set<string>;
53
+ /** @implements */
54
+ hasFlag(flag: string): boolean;
55
+ /** @implements */
56
+ hasEffectiveFlag(flag: string): boolean;
57
+ /** @implements */
58
+ removeFlag(flag: string): void;
59
+ /** @implements */
60
+ setFlag(flag: string): void;
61
+ /** @implements */
62
+ toggleFlag(flag: string): void;
53
63
  toString(separator?: string | undefined): string;
54
64
  text(separator?: string | undefined): string;
55
65
  insertAt(token: unknown, i?: number | undefined): unknown;
@@ -58,4 +68,5 @@ export declare const flagsParent: <T extends AstConstructor>(constructor: T) =>
58
68
  addEventListener(events: string | string[], listener: AstListener): void;
59
69
  replaceChildren(...elements: (string | import("..").AstNodes)[]): void;
60
70
  constructorError(msg: string): never;
71
+ seal(key: string, permanent?: boolean | undefined): void;
61
72
  }) & T;
@@ -6,66 +6,53 @@ const constants_1 = require("../util/constants");
6
6
  /**
7
7
  * ConverterToken
8
8
  * @param constructor 基类
9
+ * @param _ context
9
10
  */
10
- const flagsParent = (constructor) => {
11
+ const flagsParent = (constructor, _) => {
11
12
  /** 子节点含有ConverterFlagsToken的类 */
12
13
  class FlagsParent extends constructor {
13
14
  /* NOT FOR BROWSER */
14
- /** 所有转换类型标记 */
15
+ /** @implements */
15
16
  get flags() {
16
17
  return this.firstChild.flags;
17
18
  }
18
19
  set flags(value) {
19
20
  this.firstChild.flags = value;
20
21
  }
21
- /** 获取所有转换类型标记 */
22
+ /** @implements */
22
23
  getAllFlags() {
23
24
  return this.firstChild.getAllFlags();
24
25
  }
25
- /** 获取有效的转换类型标记 */
26
+ /** @implements */
26
27
  getEffectiveFlags() {
27
28
  return this.firstChild.getEffectiveFlags();
28
29
  }
29
- /** 获取未知的转换类型标记 */
30
+ /** @implements */
30
31
  getUnknownFlags() {
31
32
  return this.firstChild.getUnknownFlags();
32
33
  }
33
- /**
34
- * 是否具有某转换类型标记
35
- * @param flag 转换类型标记
36
- */
34
+ /** @implements */
37
35
  hasFlag(flag) {
38
36
  return this.firstChild.hasFlag(flag);
39
37
  }
40
- /**
41
- * 是否具有某有效的转换类型标记
42
- * @param flag 转换类型标记
43
- */
38
+ /** @implements */
44
39
  hasEffectiveFlag(flag) {
45
40
  return this.firstChild.hasEffectiveFlag(flag);
46
41
  }
47
- /**
48
- * 移除转换类型标记
49
- * @param flag 转换类型标记
50
- */
42
+ /** @implements */
51
43
  removeFlag(flag) {
52
44
  this.firstChild.removeFlag(flag);
53
45
  }
54
- /**
55
- * 设置转换类型标记
56
- * @param flag 转换类型标记
57
- */
46
+ /** @implements */
58
47
  setFlag(flag) {
59
48
  this.firstChild.setFlag(flag);
60
49
  }
61
- /**
62
- * 开关某转换类型标记
63
- * @param flag 转换类型标记
64
- */
50
+ /** @implements */
65
51
  toggleFlag(flag) {
66
52
  this.firstChild.toggleFlag(flag);
67
53
  }
68
54
  }
55
+ Object.defineProperty(FlagsParent, 'name', { value: constructor.name });
69
56
  return FlagsParent;
70
57
  };
71
58
  exports.flagsParent = flagsParent;
@@ -1,27 +1,32 @@
1
1
  import type { MagicLinkToken } from '../src/magicLink';
2
2
  export interface MagicLinkParentBase {
3
+ /** 协议 */
3
4
  protocol: string | undefined;
5
+ /** 和内链保持一致 */
4
6
  link: string;
7
+ /** 获取网址 */
5
8
  getUrl(): URL;
9
+ /**
10
+ * 设置链接目标
11
+ * @param url 网址
12
+ */
6
13
  setTarget(url: string): void;
7
14
  }
8
15
  /**
9
16
  * ExtLinkToken
10
17
  * @param constructor 基类
18
+ * @param _ context
11
19
  */
12
- export declare const magicLinkParent: <T extends AstConstructor>(constructor: T) => (abstract new (...args: any[]) => {
20
+ export declare const magicLinkParent: <T extends AstConstructor>(constructor: T, _?: unknown) => (abstract new (...args: any[]) => {
13
21
  readonly firstChild: MagicLinkToken;
14
22
  readonly firstElementChild: MagicLinkToken;
15
- /** 协议 */
23
+ /** @implements */
16
24
  protocol: string | undefined;
17
- /** 和内链保持一致 */
25
+ /** @implements */
18
26
  link: string;
19
- /** 获取网址 */
27
+ /** @implements */
20
28
  getUrl(): URL;
21
- /**
22
- * 设置链接目标
23
- * @param url 网址
24
- */
29
+ /** @implements */
25
30
  setTarget(url: string): void;
26
31
  toString(separator?: string | undefined): string;
27
32
  text(separator?: string | undefined): string;
@@ -31,4 +36,5 @@ export declare const magicLinkParent: <T extends AstConstructor>(constructor: T)
31
36
  addEventListener(events: string | string[], listener: AstListener): void;
32
37
  replaceChildren(...elements: (string | import("..").AstNodes)[]): void;
33
38
  constructorError(msg: string): never;
39
+ seal(key: string, permanent?: boolean | undefined): void;
34
40
  }) & T;
@@ -6,37 +6,36 @@ const constants_1 = require("../util/constants");
6
6
  /**
7
7
  * ExtLinkToken
8
8
  * @param constructor 基类
9
+ * @param _ context
9
10
  */
10
- const magicLinkParent = (constructor) => {
11
+ const magicLinkParent = (constructor, _) => {
11
12
  /** 子节点含有MagicLinkParent的类 */
12
13
  class MagicLinkParent extends constructor {
13
14
  /* NOT FOR BROWSER */
14
- /** 协议 */
15
+ /** @implements */
15
16
  get protocol() {
16
17
  return this.firstChild.protocol;
17
18
  }
18
19
  set protocol(value) {
19
20
  this.firstChild.protocol = value;
20
21
  }
21
- /** 和内链保持一致 */
22
+ /** @implements */
22
23
  get link() {
23
24
  return this.firstChild.link;
24
25
  }
25
26
  set link(url) {
26
27
  this.firstChild.link = url;
27
28
  }
28
- /** 获取网址 */
29
+ /** @implements */
29
30
  getUrl() {
30
31
  return this.firstChild.getUrl();
31
32
  }
32
- /**
33
- * 设置链接目标
34
- * @param url 网址
35
- */
33
+ /** @implements */
36
34
  setTarget(url) {
37
35
  this.firstChild.setTarget(url);
38
36
  }
39
37
  }
38
+ Object.defineProperty(MagicLinkParent, 'name', { value: constructor.name });
40
39
  return MagicLinkParent;
41
40
  };
42
41
  exports.magicLinkParent = magicLinkParent;