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
@@ -1,4 +1,38 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
37
  exports.ParameterToken = void 0;
4
38
  const string_1 = require("../util/string");
@@ -17,197 +51,212 @@ const getName = (name) => name.text().replace(/^[ \t\n\0\v]+|([^ \t\n\0\v])[ \t\
17
51
  * 模板或魔术字参数
18
52
  * @classdesc `{childNodes: [Token, Token]}`
19
53
  */
20
- class ParameterToken extends (0, fixed_1.fixedToken)(index_2.Token) {
21
- type = 'parameter';
22
- /** 是否是匿名参数 */
23
- get anon() {
24
- return this.firstChild.length === 0;
25
- }
26
- /* NOT FOR BROWSER */
27
- set anon(value) {
28
- if (value) {
29
- throw new Error('无法将命名参数转换为匿名参数!');
54
+ let ParameterToken = (() => {
55
+ let _classDecorators = [fixed_1.fixedToken];
56
+ let _classDescriptor;
57
+ let _classExtraInitializers = [];
58
+ let _classThis;
59
+ let _classSuper = index_2.Token;
60
+ var ParameterToken = class extends _classSuper {
61
+ static { _classThis = this; }
62
+ static {
63
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
64
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
65
+ ParameterToken = _classThis = _classDescriptor.value;
66
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
67
+ __runInitializers(_classThis, _classExtraInitializers);
30
68
  }
31
- this.parentNode?.anonToNamed();
32
- }
33
- /** getValue()的getter */
34
- get value() {
35
- return this.getValue();
36
- }
37
- set value(value) {
38
- this.setValue(value);
39
- }
40
- /** 是否是重复参数 */
41
- get duplicated() {
42
- try {
43
- return Boolean(this.parentNode?.getDuplicatedArgs().some(([key]) => key === this.name));
69
+ type = 'parameter';
70
+ /* NOT FOR BROWSER END */
71
+ /** 是否是匿名参数 */
72
+ get anon() {
73
+ return this.firstChild.length === 0;
44
74
  }
45
- catch {
46
- return false;
75
+ /* NOT FOR BROWSER */
76
+ set anon(value) {
77
+ if (value) {
78
+ throw new Error('无法将命名参数转换为匿名参数!');
79
+ }
80
+ this.parentNode?.anonToNamed();
47
81
  }
48
- }
49
- set duplicated(value) {
50
- if (this.duplicated && !value) {
51
- this.parentNode.fixDuplication();
82
+ /** getValue()的getter */
83
+ get value() {
84
+ return this.getValue();
52
85
  }
53
- }
54
- /* NOT FOR BROWSER END */
55
- /**
56
- * @param key 参数名
57
- * @param value 参数值
58
- */
59
- constructor(key, value, config = index_1.default.getConfig(), accum = []) {
60
- super(undefined, config, accum);
61
- const keyToken = new index_2.Token(typeof key === 'number' ? undefined : key, config, accum, {
62
- 'Stage-11': ':', '!HeadingToken': '',
63
- }), token = new index_2.Token(value, config, accum);
64
- keyToken.type = 'parameter-key';
65
- token.type = 'parameter-value';
66
- token.setAttribute('stage', 2);
67
- this.append(keyToken, token);
68
- }
69
- /** @private */
70
- afterBuild() {
71
- if (!this.anon) {
72
- const { parentNode, firstChild } = this, name = getName(firstChild);
73
- this.setAttribute('name', name);
74
- if (parentNode) {
75
- /* NOT FOR BROWSER */
76
- parentNode.getAttribute('keys').add(name);
77
- /* NOT FOR BROWSER END */
78
- parentNode.getArgs(name, false, false).add(this);
86
+ set value(value) {
87
+ this.setValue(value);
88
+ }
89
+ /** 是否是重复参数 */
90
+ get duplicated() {
91
+ try {
92
+ return Boolean(this.parentNode?.getDuplicatedArgs().some(([key]) => key === this.name));
93
+ }
94
+ catch {
95
+ return false;
79
96
  }
80
97
  }
81
- /* NOT FOR BROWSER */
82
- const /** @implements */ parameterListener = ({ prevTarget }, data) => {
83
- if (!this.anon) { // 匿名参数不管怎么变动还是匿名
84
- const { firstChild, name } = this;
85
- if (prevTarget === firstChild) {
86
- const newKey = getName(firstChild);
87
- data.oldKey = name;
88
- data.newKey = newKey;
89
- this.setAttribute('name', newKey);
98
+ set duplicated(value) {
99
+ if (this.duplicated && !value) {
100
+ this.parentNode.fixDuplication();
101
+ }
102
+ }
103
+ /* NOT FOR BROWSER END */
104
+ /**
105
+ * @param key 参数名
106
+ * @param value 参数值
107
+ */
108
+ constructor(key, value, config = index_1.default.getConfig(), accum = []) {
109
+ super(undefined, config, accum);
110
+ const keyToken = new index_2.Token(typeof key === 'number' ? undefined : key, config, accum, {
111
+ 'Stage-11': ':', '!HeadingToken': '',
112
+ }), token = new index_2.Token(value, config, accum);
113
+ keyToken.type = 'parameter-key';
114
+ token.type = 'parameter-value';
115
+ token.setAttribute('stage', 2);
116
+ this.append(keyToken, token);
117
+ }
118
+ /** @private */
119
+ afterBuild() {
120
+ if (!this.anon) {
121
+ const { parentNode, firstChild } = this, name = getName(firstChild);
122
+ this.setAttribute('name', name);
123
+ if (parentNode) {
124
+ parentNode.getArgs(name, false, false).add(this);
125
+ /* NOT FOR BROWSER */
126
+ parentNode.getAttribute('keys').add(name);
90
127
  }
91
128
  }
92
- };
93
- this.addEventListener(['remove', 'insert', 'replace', 'text'], parameterListener);
94
- }
95
- /** @private */
96
- toString() {
97
- return this.anon ? String(this.lastChild) : super.toString('=');
98
- }
99
- /** @override */
100
- text() {
101
- return this.anon ? this.lastChild.text() : super.text('=');
102
- }
103
- /** @private */
104
- getGaps() {
105
- return this.anon ? 0 : 1;
106
- }
107
- /** @override */
108
- lint(start = this.getAbsoluteIndex()) {
109
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
110
- /https?:\/\/(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])(?:[^[\]<>"\0\t\n\p{Zs}]|\0\d+c\x7F)*$/iu;
111
- const errors = super.lint(start), { firstChild } = this, link = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu').exec(firstChild.text())?.[0];
112
- if (link && new URL(link).search) {
113
- const e = (0, lint_1.generateForChild)(firstChild, { start }, 'unescaped query string in an anonymous parameter');
114
- errors.push({
115
- ...e,
116
- startIndex: e.endIndex,
117
- endIndex: e.endIndex + 1,
118
- startLine: e.endLine,
119
- startCol: e.endCol,
120
- endCol: e.endCol + 1,
129
+ /* NOT FOR BROWSER */
130
+ const /** @implements */ parameterListener = ({ prevTarget }, data) => {
131
+ if (!this.anon) { // 匿名参数不管怎么变动还是匿名
132
+ const { firstChild, name } = this;
133
+ if (prevTarget === firstChild) {
134
+ const newKey = getName(firstChild);
135
+ data.oldKey = name;
136
+ data.newKey = newKey;
137
+ this.setAttribute('name', newKey);
138
+ }
139
+ }
140
+ };
141
+ this.addEventListener(['remove', 'insert', 'replace', 'text'], parameterListener);
142
+ }
143
+ /** @private */
144
+ toString() {
145
+ return this.anon ? String(this.lastChild) : super.toString('=');
146
+ }
147
+ /** @override */
148
+ text() {
149
+ return this.anon ? this.lastChild.text() : super.text('=');
150
+ }
151
+ /** @private */
152
+ getGaps() {
153
+ return this.anon ? 0 : 1;
154
+ }
155
+ /** @override */
156
+ lint(start = this.getAbsoluteIndex()) {
157
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
158
+ /https?:\/\/(?:\[[\da-f:.]+\]|[^[\]<>"\t\n\p{Zs}])(?:[^[\]<>"\0\t\n\p{Zs}]|\0\d+c\x7F)*$/iu;
159
+ const errors = super.lint(start), { firstChild } = this, link = new RegExp(`https?://${string_1.extUrlCharFirst}${string_1.extUrlChar}$`, 'iu').exec(firstChild.text())?.[0];
160
+ if (link && new URL(link).search) {
161
+ const e = (0, lint_1.generateForChild)(firstChild, { start }, 'unescaped query string in an anonymous parameter');
162
+ errors.push({
163
+ ...e,
164
+ startIndex: e.endIndex,
165
+ endIndex: e.endIndex + 1,
166
+ startLine: e.endLine,
167
+ startCol: e.endCol,
168
+ endCol: e.endCol + 1,
169
+ });
170
+ }
171
+ return errors;
172
+ }
173
+ /** @override */
174
+ print() {
175
+ return super.print({ sep: this.anon ? '' : '=' });
176
+ }
177
+ /** @override */
178
+ json() {
179
+ const json = super.json();
180
+ json['anon'] = this.anon;
181
+ return json;
182
+ }
183
+ /* NOT FOR BROWSER */
184
+ /** @override */
185
+ cloneNode() {
186
+ const [key, value] = this.cloneChildNodes(), config = this.getAttribute('config');
187
+ return debug_1.Shadow.run(() => {
188
+ // @ts-expect-error abstract class
189
+ const token = new ParameterToken(this.anon ? Number(this.name) : undefined, undefined, config);
190
+ token.firstChild.safeReplaceWith(key);
191
+ token.lastChild.safeReplaceWith(value);
192
+ token.afterBuild();
193
+ if (this.anon) {
194
+ token.setAttribute('name', this.name);
195
+ }
196
+ return token;
121
197
  });
122
198
  }
123
- return errors;
124
- }
125
- /** @override */
126
- print() {
127
- return super.print({ sep: this.anon ? '' : '=' });
128
- }
129
- /** @override */
130
- json() {
131
- return {
132
- ...super.json(),
133
- anon: this.anon,
134
- };
135
- }
136
- /* NOT FOR BROWSER */
137
- /** @override */
138
- cloneNode() {
139
- const [key, value] = this.cloneChildNodes(), config = this.getAttribute('config');
140
- return debug_1.Shadow.run(() => {
141
- // @ts-expect-error abstract class
142
- const token = new ParameterToken(this.anon ? Number(this.name) : undefined, undefined, config);
143
- token.firstChild.safeReplaceWith(key);
144
- token.lastChild.safeReplaceWith(value);
145
- token.afterBuild();
146
- if (this.anon) {
147
- token.setAttribute('name', this.name);
199
+ /**
200
+ * @override
201
+ * @param token 待替换的节点
202
+ */
203
+ safeReplaceWith(token) {
204
+ index_1.default.warn(`${this.constructor.name}.safeReplaceWith 方法退化到 replaceWith。`);
205
+ this.replaceWith(token);
206
+ }
207
+ /** 获取参数值 */
208
+ getValue() {
209
+ const value = this.lastChild.text();
210
+ return this.anon && this.parentNode?.isTemplate() !== false ? value : value.trim();
211
+ }
212
+ /**
213
+ * 设置参数值
214
+ * @param value 参数值
215
+ */
216
+ setValue(value) {
217
+ const { childNodes } = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config'));
218
+ this.lastChild.replaceChildren(...childNodes);
219
+ }
220
+ /**
221
+ * 修改参数名
222
+ * @param key 新参数名
223
+ * @param force 是否无视冲突命名
224
+ * @throws `Error` 仅用于模板参数
225
+ * @throws `RangeError` 更名造成重复参数
226
+ */
227
+ rename(key, force = false) {
228
+ const { parentNode, anon } = this;
229
+ // 必须检测是否是TranscludeToken
230
+ if (parentNode?.isTemplate() === false) {
231
+ throw new Error('rename 方法仅用于模板参数!');
148
232
  }
149
- return token;
150
- });
151
- }
152
- /**
153
- * @override
154
- * @param token 待替换的节点
155
- */
156
- safeReplaceWith(token) {
157
- index_1.default.warn(`${this.constructor.name}.safeReplaceWith 方法退化到 replaceWith。`);
158
- this.replaceWith(token);
159
- }
160
- /** 获取参数值 */
161
- getValue() {
162
- const value = this.lastChild.text();
163
- return this.anon && this.parentNode?.isTemplate() !== false ? value : value.trim();
164
- }
165
- /**
166
- * 设置参数值
167
- * @param value 参数值
168
- */
169
- setValue(value) {
170
- const { childNodes } = index_1.default.parse(value, this.getAttribute('include'), undefined, this.getAttribute('config'));
171
- this.lastChild.replaceChildren(...childNodes);
172
- }
173
- /**
174
- * 修改参数名
175
- * @param key 新参数名
176
- * @param force 是否无视冲突命名
177
- * @throws `Error` 仅用于模板参数
178
- * @throws `RangeError` 更名造成重复参数
179
- */
180
- rename(key, force = false) {
181
- const { parentNode, anon } = this;
182
- // 必须检测是否是TranscludeToken
183
- if (parentNode?.isTemplate() === false) {
184
- throw new Error('rename 方法仅用于模板参数!');
185
- }
186
- else if (anon) {
187
- parentNode?.anonToNamed();
188
- }
189
- const root = index_1.default.parse(key, this.getAttribute('include'), undefined, this.getAttribute('config')), name = getName(root);
190
- if (this.name === name) {
191
- index_1.default.warn('未改变实际参数名', name);
192
- }
193
- else if (parentNode?.hasArg(name)) {
194
- if (force) {
195
- index_1.default.warn('参数更名造成重复参数', name);
233
+ else if (anon) {
234
+ parentNode?.anonToNamed();
196
235
  }
197
- else {
198
- throw new RangeError(`参数更名造成重复参数:${name}`);
236
+ const root = index_1.default.parse(key, this.getAttribute('include'), undefined, this.getAttribute('config')), name = getName(root);
237
+ if (this.name === name) {
238
+ index_1.default.warn('未改变实际参数名', name);
199
239
  }
240
+ else if (parentNode?.hasArg(name)) {
241
+ if (force) {
242
+ index_1.default.warn('参数更名造成重复参数', name);
243
+ }
244
+ else {
245
+ throw new RangeError(`参数更名造成重复参数:${name}`);
246
+ }
247
+ }
248
+ this.firstChild.replaceChildren(...root.childNodes);
200
249
  }
201
- this.firstChild.replaceChildren(...root.childNodes);
202
- }
203
- /** 转义 `=` */
204
- escape() {
205
- for (const child of this.lastChild.childNodes) {
206
- if (child.type === 'text') {
207
- child.escape();
250
+ /** 转义 `=` */
251
+ escape() {
252
+ for (const child of this.lastChild.childNodes) {
253
+ if (child.type === 'text') {
254
+ child.escape();
255
+ }
208
256
  }
209
257
  }
210
- }
211
- }
258
+ };
259
+ return ParameterToken = _classThis;
260
+ })();
212
261
  exports.ParameterToken = ParameterToken;
213
262
  constants_1.classes['ParameterToken'] = __filename;
package/dist/src/pre.d.ts CHANGED
@@ -10,16 +10,16 @@ export declare abstract class PreToken extends Token {
10
10
  readonly type = "ext-inner";
11
11
  readonly name: 'pre';
12
12
  readonly childNodes: readonly (AstText | NoincludeToken | ConverterToken)[];
13
- abstract get children(): (NoincludeToken | ConverterToken)[];
14
13
  abstract get firstChild(): AstText | NoincludeToken | ConverterToken | undefined;
15
- abstract get firstElementChild(): NoincludeToken | ConverterToken | undefined;
16
14
  abstract get lastChild(): AstText | NoincludeToken | ConverterToken | undefined;
17
- abstract get lastElementChild(): NoincludeToken | ConverterToken | undefined;
18
15
  abstract get nextSibling(): undefined;
19
- abstract get nextElementSibling(): undefined;
20
16
  abstract get previousSibling(): AttributesToken;
21
- abstract get previousElementSibling(): AttributesToken;
22
17
  abstract get parentNode(): ExtToken | undefined;
18
+ abstract get children(): (NoincludeToken | ConverterToken)[];
19
+ abstract get firstElementChild(): NoincludeToken | ConverterToken | undefined;
20
+ abstract get lastElementChild(): NoincludeToken | ConverterToken | undefined;
21
+ abstract get previousElementSibling(): AttributesToken;
22
+ abstract get nextElementSibling(): undefined;
23
23
  abstract get parentElement(): ExtToken | undefined;
24
24
  /** @class */
25
25
  constructor(wikitext?: string, config?: Parser.Config, accum?: Token[]);
package/dist/src/pre.js CHANGED
@@ -12,6 +12,7 @@ const noinclude_1 = require("./nowiki/noinclude");
12
12
  */
13
13
  class PreToken extends index_2.Token {
14
14
  type = 'ext-inner';
15
+ /* NOT FOR BROWSER END */
15
16
  /** @class */
16
17
  constructor(wikitext, config = index_1.default.getConfig(), accum = []) {
17
18
  if (wikitext) {
@@ -1,7 +1,13 @@
1
1
  import Parser from '../index';
2
2
  import { Token } from './index';
3
3
  import type { LintError } from '../base';
4
+ import type { SyntaxBase } from '../mixin/syntax';
4
5
  declare type SyntaxTypes = 'plain' | 'heading-trail' | 'magic-word-name' | 'table-syntax';
6
+ /** NOT FOR BROWSER */
7
+ export interface SyntaxToken extends SyntaxBase {
8
+ }
9
+ /** NOT FOR BROWSER END */
10
+ /** 满足特定语法格式的plain Token */
5
11
  export declare class SyntaxToken extends Token {
6
12
  type: SyntaxTypes;
7
13
  /** @param pattern 语法正则 */
@@ -1,4 +1,38 @@
1
1
  "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
2
36
  Object.defineProperty(exports, "__esModule", { value: true });
3
37
  exports.SyntaxToken = void 0;
4
38
  const debug_1 = require("../util/debug");
@@ -6,30 +40,47 @@ const constants_1 = require("../util/constants");
6
40
  const syntax_1 = require("../mixin/syntax");
7
41
  const index_1 = require("../index");
8
42
  const index_2 = require("./index");
43
+ /** NOT FOR BROWSER END */
9
44
  /** 满足特定语法格式的plain Token */
10
- class SyntaxToken extends (0, syntax_1.syntax)(index_2.Token) {
11
- /** @param pattern 语法正则 */
12
- constructor(wikitext, pattern, type = 'plain', config = index_1.default.getConfig(), accum = [], acceptable) {
13
- super(wikitext, config, accum, acceptable);
14
- this.type = type;
45
+ let SyntaxToken = (() => {
46
+ let _classDecorators = [(0, syntax_1.syntax)()];
47
+ let _classDescriptor;
48
+ let _classExtraInitializers = [];
49
+ let _classThis;
50
+ let _classSuper = index_2.Token;
51
+ var SyntaxToken = class extends _classSuper {
52
+ static { _classThis = this; }
53
+ static {
54
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
55
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
56
+ SyntaxToken = _classThis = _classDescriptor.value;
57
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
58
+ __runInitializers(_classThis, _classExtraInitializers);
59
+ }
60
+ /** @param pattern 语法正则 */
61
+ constructor(wikitext, pattern, type = 'plain', config = index_1.default.getConfig(), accum = [], acceptable) {
62
+ super(wikitext, config, accum, acceptable);
63
+ this.type = type;
64
+ /* NOT FOR BROWSER */
65
+ this.setAttribute('pattern', pattern);
66
+ }
67
+ /** @override */
68
+ lint() {
69
+ return [];
70
+ }
15
71
  /* NOT FOR BROWSER */
16
- this.setAttribute('pattern', pattern);
17
- }
18
- /** @override */
19
- lint() {
20
- return [];
21
- }
22
- /* NOT FOR BROWSER */
23
- /** @override */
24
- cloneNode() {
25
- const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAttribute('acceptable'), pattern = this.getAttribute('pattern');
26
- return debug_1.Shadow.run(() => {
27
- const token = new SyntaxToken(undefined, pattern, this.type, config, [], acceptable);
28
- token.append(...cloned);
29
- token.afterBuild();
30
- return token;
31
- });
32
- }
33
- }
72
+ /** @override */
73
+ cloneNode() {
74
+ const cloned = this.cloneChildNodes(), config = this.getAttribute('config'), acceptable = this.getAttribute('acceptable');
75
+ return debug_1.Shadow.run(() => {
76
+ const token = new SyntaxToken(undefined, this.pattern, this.type, config, [], acceptable);
77
+ token.append(...cloned);
78
+ token.afterBuild();
79
+ return token;
80
+ });
81
+ }
82
+ };
83
+ return SyntaxToken = _classThis;
84
+ })();
34
85
  exports.SyntaxToken = SyntaxToken;
35
86
  constants_1.classes['SyntaxToken'] = __filename;
@@ -5,13 +5,17 @@ import { AttributesToken } from '../attributes';
5
5
  import type { AttributesParentBase } from '../../mixin/attributesParent';
6
6
  export interface TableBaseToken extends AttributesParentBase {
7
7
  }
8
+ /**
9
+ * 表格行,含开头的换行,不含结尾的换行
10
+ * @classdesc `{childNodes: [SyntaxToken, AttributesToken, ...Token]}`
11
+ */
8
12
  export declare abstract class TableBaseToken extends Token {
9
13
  type: 'table' | 'tr' | 'td';
10
14
  readonly childNodes: readonly [SyntaxToken, AttributesToken, ...Token[]];
11
- abstract get children(): [SyntaxToken, AttributesToken, ...Token[]];
12
15
  abstract get firstChild(): SyntaxToken;
13
- abstract get firstElementChild(): SyntaxToken;
14
16
  abstract get lastChild(): Token;
17
+ abstract get children(): [SyntaxToken, AttributesToken, ...Token[]];
18
+ abstract get firstElementChild(): SyntaxToken;
15
19
  abstract get lastElementChild(): Token;
16
20
  /**
17
21
  * @param pattern 表格语法正则
@@ -24,4 +28,3 @@ export declare abstract class TableBaseToken extends Token {
24
28
  /** 转义表格语法 */
25
29
  escape(): void;
26
30
  }
27
- export {};