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.ExtToken = void 0;
4
38
  const lint_1 = require("../../util/lint");
@@ -24,130 +58,146 @@ const del = (arr, ele) => {
24
58
  * 扩展标签
25
59
  * @classdesc `{childNodes: [AttributesToken, Token]}`
26
60
  */
27
- class ExtToken extends (0, attributesParent_1.attributesParent)(index_3.TagPairToken) {
28
- type = 'ext';
29
- /**
30
- * @param name 标签名
31
- * @param attr 标签属性
32
- * @param inner 内部wikitext
33
- * @param closed 是否封闭
34
- */
35
- constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
36
- const lcName = name.toLowerCase(),
37
- // @ts-expect-error abstract class
38
- attrToken = new attributes_1.AttributesToken(!attr || attr.trimStart() !== attr ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
39
- let innerToken;
40
- switch (lcName) {
41
- case 'tab':
42
- newConfig.ext = del(newConfig.ext, 'tabs');
43
- // fall through
44
- case 'indicator':
45
- case 'poem':
46
- case 'ref':
47
- case 'option':
48
- case 'combooption':
49
- case 'tabs':
50
- case 'poll':
51
- case 'seo':
52
- if (lcName === 'poem') {
61
+ let ExtToken = (() => {
62
+ let _classDecorators = [(0, attributesParent_1.attributesParent)()];
63
+ let _classDescriptor;
64
+ let _classExtraInitializers = [];
65
+ let _classThis;
66
+ let _classSuper = index_3.TagPairToken;
67
+ var ExtToken = class extends _classSuper {
68
+ static { _classThis = this; }
69
+ static {
70
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
71
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
72
+ ExtToken = _classThis = _classDescriptor.value;
73
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
74
+ __runInitializers(_classThis, _classExtraInitializers);
75
+ }
76
+ type = 'ext';
77
+ /* NOT FOR BROWSER END */
78
+ /**
79
+ * @param name 标签名
80
+ * @param attr 标签属性
81
+ * @param inner 内部wikitext
82
+ * @param closed 是否封闭
83
+ */
84
+ constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
85
+ const lcName = name.toLowerCase(),
86
+ // @ts-expect-error abstract class
87
+ attrToken = new attributes_1.AttributesToken(!attr || attr.trimStart() !== attr ? attr : ` ${attr}`, 'ext-attrs', lcName, config, accum), newConfig = { ...config, ext: del(config.ext, lcName), excludes: [...config.excludes ?? []] };
88
+ let innerToken;
89
+ switch (lcName) {
90
+ case 'tab':
91
+ newConfig.ext = del(newConfig.ext, 'tabs');
92
+ // fall through
93
+ case 'indicator':
94
+ case 'poem':
95
+ case 'ref':
96
+ case 'option':
97
+ case 'combooption':
98
+ case 'tabs':
99
+ case 'poll':
100
+ case 'seo':
101
+ if (lcName === 'poem') {
102
+ newConfig.excludes.push('heading');
103
+ }
104
+ innerToken = new index_2.Token(inner, newConfig, accum);
105
+ break;
106
+ case 'pre': {
107
+ const { PreToken } = require('../pre');
108
+ // @ts-expect-error abstract class
109
+ innerToken = new PreToken(inner, newConfig, accum);
110
+ break;
111
+ }
112
+ case 'dynamicpagelist': {
113
+ const { ParamTagToken } = require('../paramTag/index');
114
+ // @ts-expect-error abstract class
115
+ innerToken = new ParamTagToken(inner, newConfig, accum);
116
+ break;
117
+ }
118
+ case 'inputbox': {
53
119
  newConfig.excludes.push('heading');
120
+ const { InputboxToken } = require('../paramTag/inputbox');
121
+ // @ts-expect-error abstract class
122
+ innerToken = new InputboxToken(inner, newConfig, accum);
123
+ break;
124
+ }
125
+ case 'references': {
126
+ const { NestedToken } = require('../nested');
127
+ // @ts-expect-error abstract class
128
+ innerToken = new NestedToken(inner, /<!--.*?(?:-->|$)|<(ref)(\s[^>]*)?>(.*?)<\/(ref\s*)>/gisu, ['ref'], newConfig, accum);
129
+ break;
130
+ }
131
+ case 'choose': {
132
+ const { NestedToken } = require('../nested');
133
+ // @ts-expect-error abstract class
134
+ innerToken = new NestedToken(inner, /<(option|choicetemplate)(\s[^>]*)?>(.*?)<\/(\1)>/gsu, ['option', 'choicetemplate'], newConfig, accum);
135
+ break;
136
+ }
137
+ case 'combobox': {
138
+ const { NestedToken } = require('../nested');
139
+ // @ts-expect-error abstract class
140
+ innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*)?>(.*?)<\/(combooption\s*)>/gisu, ['combooption'], newConfig, accum);
141
+ break;
142
+ }
143
+ case 'gallery': {
144
+ const { GalleryToken } = require('../gallery');
145
+ // @ts-expect-error abstract class
146
+ innerToken = new GalleryToken(inner, newConfig, accum);
147
+ break;
148
+ }
149
+ case 'imagemap': {
150
+ const { ImagemapToken } = require('../imagemap');
151
+ // @ts-expect-error abstract class
152
+ innerToken = new ImagemapToken(inner, newConfig, accum);
153
+ break;
154
+ }
155
+ // 更多定制扩展的代码示例:
156
+ // ```
157
+ // case 'extensionName': {
158
+ // const {ExtensionToken}: typeof import('../extension') = require('../extension');
159
+ // innerToken = new ExtensionToken(inner, newConfig, accum);
160
+ // break;
161
+ // }
162
+ // ```
163
+ default: {
164
+ const { NowikiToken } = require('../nowiki/index');
165
+ // @ts-expect-error abstract class
166
+ innerToken = new NowikiToken(inner, newConfig);
54
167
  }
55
- innerToken = new index_2.Token(inner, newConfig, accum);
56
- break;
57
- case 'pre': {
58
- const { PreToken } = require('../pre');
59
- // @ts-expect-error abstract class
60
- innerToken = new PreToken(inner, newConfig, accum);
61
- break;
62
- }
63
- case 'dynamicpagelist': {
64
- const { ParamTagToken } = require('../paramTag/index');
65
- // @ts-expect-error abstract class
66
- innerToken = new ParamTagToken(inner, newConfig, accum);
67
- break;
68
- }
69
- case 'inputbox': {
70
- newConfig.excludes.push('heading');
71
- const { InputboxToken } = require('../paramTag/inputbox');
72
- // @ts-expect-error abstract class
73
- innerToken = new InputboxToken(inner, newConfig, accum);
74
- break;
75
- }
76
- case 'references': {
77
- const { NestedToken } = require('../nested');
78
- // @ts-expect-error abstract class
79
- innerToken = new NestedToken(inner, /<!--.*?(?:-->|$)|<(ref)(\s[^>]*)?>(.*?)<\/(ref\s*)>/gisu, ['ref'], newConfig, accum);
80
- break;
81
- }
82
- case 'choose': {
83
- const { NestedToken } = require('../nested');
84
- // @ts-expect-error abstract class
85
- innerToken = new NestedToken(inner, /<(option|choicetemplate)(\s[^>]*)?>(.*?)<\/(\1)>/gsu, ['option', 'choicetemplate'], newConfig, accum);
86
- break;
87
- }
88
- case 'combobox': {
89
- const { NestedToken } = require('../nested');
90
- // @ts-expect-error abstract class
91
- innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*)?>(.*?)<\/(combooption\s*)>/gisu, ['combooption'], newConfig, accum);
92
- break;
93
- }
94
- case 'gallery': {
95
- const { GalleryToken } = require('../gallery');
96
- // @ts-expect-error abstract class
97
- innerToken = new GalleryToken(inner, newConfig, accum);
98
- break;
99
168
  }
100
- case 'imagemap': {
101
- const { ImagemapToken } = require('../imagemap');
102
- // @ts-expect-error abstract class
103
- innerToken = new ImagemapToken(inner, newConfig, accum);
104
- break;
169
+ innerToken.setAttribute('name', lcName);
170
+ innerToken.type = 'ext-inner';
171
+ super(name, attrToken, innerToken, closed, config, accum);
172
+ this.seal('closed', true);
173
+ }
174
+ /** @override */
175
+ lint(start = this.getAbsoluteIndex()) {
176
+ const errors = super.lint(start);
177
+ let rect;
178
+ if (this.name !== 'nowiki' && this.closest('html-attrs, table-attrs')) {
179
+ rect = { start, ...this.getRootNode().posFromIndex(start) };
180
+ errors.push((0, lint_1.generateForSelf)(this, rect, 'extension tag in HTML tag attributes'));
105
181
  }
106
- // 更多定制扩展的代码示例:
107
- // ```
108
- // case 'extensionName': {
109
- // const {ExtensionToken}: typeof import('../extension') = require('../extension');
110
- // innerToken = new ExtensionToken(inner, newConfig, accum);
111
- // break;
112
- // }
113
- // ```
114
- default: {
115
- const { NowikiToken } = require('../nowiki/index');
116
- // @ts-expect-error abstract class
117
- innerToken = new NowikiToken(inner, newConfig);
182
+ if (this.name === 'ref' && this.closest('heading-title')) {
183
+ rect ??= { start, ...this.getRootNode().posFromIndex(start) };
184
+ errors.push((0, lint_1.generateForSelf)(this, rect, 'variable anchor in a section header'));
118
185
  }
186
+ return errors;
119
187
  }
120
- innerToken.setAttribute('name', lcName);
121
- innerToken.type = 'ext-inner';
122
- super(name, attrToken, innerToken, closed, config, accum);
123
- /* istanbul ignore next */
124
- this.seal('closed', true);
125
- }
126
- /** @override */
127
- lint(start = this.getAbsoluteIndex()) {
128
- const errors = super.lint(start);
129
- let rect;
130
- if (this.name !== 'nowiki' && this.closest('html-attrs, table-attrs')) {
131
- rect = { start, ...this.getRootNode().posFromIndex(start) };
132
- errors.push((0, lint_1.generateForSelf)(this, rect, 'extension tag in HTML tag attributes'));
133
- }
134
- if (this.name === 'ref' && this.closest('heading-title')) {
135
- rect ??= { start, ...this.getRootNode().posFromIndex(start) };
136
- errors.push((0, lint_1.generateForSelf)(this, rect, 'variable anchor in a section header'));
188
+ /* NOT FOR BROWSER */
189
+ /** @override */
190
+ cloneNode() {
191
+ const inner = this.lastChild.cloneNode(), tags = this.getAttribute('tags'), config = this.getAttribute('config'), attr = String(this.firstChild);
192
+ return debug_1.Shadow.run(() => {
193
+ // @ts-expect-error abstract class
194
+ const token = new ExtToken(tags[0], attr, '', this.selfClosing ? undefined : tags[1], config);
195
+ token.lastChild.safeReplaceWith(inner);
196
+ return token;
197
+ });
137
198
  }
138
- return errors;
139
- }
140
- /* NOT FOR BROWSER */
141
- /** @override */
142
- cloneNode() {
143
- const inner = this.lastChild.cloneNode(), tags = this.getAttribute('tags'), config = this.getAttribute('config'), attr = String(this.firstChild);
144
- return debug_1.Shadow.run(() => {
145
- // @ts-expect-error abstract class
146
- const token = new ExtToken(tags[0], attr, '', this.selfClosing ? undefined : tags[1], config);
147
- token.lastChild.safeReplaceWith(inner);
148
- return token;
149
- });
150
- }
151
- }
199
+ };
200
+ return ExtToken = _classThis;
201
+ })();
152
202
  exports.ExtToken = ExtToken;
153
203
  constants_1.classes['ExtToken'] = __filename;
@@ -5,10 +5,10 @@ import type { AstText, Token } from '../../internal';
5
5
  export declare abstract class IncludeToken extends TagPairToken {
6
6
  readonly type = "include";
7
7
  readonly childNodes: readonly [AstText, AstText];
8
- abstract get children(): [];
9
8
  abstract get firstChild(): AstText;
10
- abstract get firstElementChild(): undefined;
11
9
  abstract get lastChild(): AstText;
10
+ abstract get children(): [];
11
+ abstract get firstElementChild(): undefined;
12
12
  abstract get lastElementChild(): undefined;
13
13
  /** @override */
14
14
  get innerText(): string | undefined;
@@ -23,8 +23,6 @@ export declare abstract class IncludeToken extends TagPairToken {
23
23
  /** @override */
24
24
  lint(start?: number): LintError[];
25
25
  /** @override */
26
- json(): object;
27
- /** @override */
28
26
  cloneNode(): this;
29
27
  /**
30
28
  * @override
@@ -13,7 +13,6 @@ const index_2 = require("./index");
13
13
  */
14
14
  class IncludeToken extends (0, hidden_1.hiddenToken)(index_2.TagPairToken) {
15
15
  type = 'include';
16
- /* NOT FOR BROWSER */
17
16
  /** @override */
18
17
  get innerText() {
19
18
  return this.selfClosing ? undefined : this.lastChild.data;
@@ -41,13 +40,6 @@ class IncludeToken extends (0, hidden_1.hiddenToken)(index_2.TagPairToken) {
41
40
  lint(start = this.getAbsoluteIndex()) {
42
41
  return this.closed ? [] : [(0, lint_1.generateForSelf)(this, { start }, index_1.default.msg('unclosed $1', `<${this.name}>`))];
43
42
  }
44
- /** @override */
45
- json() {
46
- return {
47
- ...super.json(),
48
- closed: this.closed,
49
- };
50
- }
51
43
  /* NOT FOR BROWSER */
52
44
  /** @override */
53
45
  cloneNode() {
@@ -1,6 +1,7 @@
1
1
  import Parser from '../../index';
2
2
  import { Token } from '../index';
3
3
  import type { AstNodes } from '../../lib/node';
4
+ /** 成对标签 */
4
5
  export declare abstract class TagPairToken extends Token {
5
6
  #private;
6
7
  type: 'ext' | 'include';
@@ -24,4 +25,3 @@ export declare abstract class TagPairToken extends Token {
24
25
  /** @override */
25
26
  print(): string;
26
27
  }
27
- export {};
@@ -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.TagPairToken = void 0;
4
38
  const constants_1 = require("../../util/constants");
@@ -6,74 +40,89 @@ const fixed_1 = require("../../mixin/fixed");
6
40
  const index_1 = require("../../index");
7
41
  const index_2 = require("../index");
8
42
  /** 成对标签 */
9
- class TagPairToken extends (0, fixed_1.fixedToken)(index_2.Token) {
10
- #tags;
11
- closed;
12
- selfClosing;
13
- /* NOT FOR BROWSER END */
14
- /** 内部wikitext */
15
- get innerText() {
16
- return this.selfClosing ? undefined : this.lastChild.text();
17
- }
18
- /**
19
- * @param name 标签名
20
- * @param attr 标签属性
21
- * @param inner 内部wikitext
22
- * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
23
- */
24
- constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
25
- super(undefined, config);
26
- this.setAttribute('name', name.toLowerCase());
27
- this.#tags = [name, closed || name];
28
- this.closed = closed !== '';
29
- this.selfClosing = closed === undefined;
30
- this.append(attr, inner);
31
- const index = typeof attr === 'string' ? -1 : accum.indexOf(attr);
32
- accum.splice(index === -1 ? Infinity : index, 0, this);
33
- Object.defineProperty(this, 'closed', { enumerable: false });
34
- }
35
- /** @private */
36
- toString() {
37
- const { selfClosing, firstChild, lastChild,
38
- /* NOT FOR BROWSER */
39
- nextSibling, name, closed, } = this, [opening, closing] = this.#tags;
40
- /* NOT FOR BROWSER */
41
- if (!closed && nextSibling) {
42
- index_1.default.error(`自动闭合 <${name}>`, lastChild);
43
- this.closed = true;
43
+ let TagPairToken = (() => {
44
+ let _classDecorators = [fixed_1.fixedToken];
45
+ let _classDescriptor;
46
+ let _classExtraInitializers = [];
47
+ let _classThis;
48
+ let _classSuper = index_2.Token;
49
+ var TagPairToken = class extends _classSuper {
50
+ static { _classThis = this; }
51
+ static {
52
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
53
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
54
+ TagPairToken = _classThis = _classDescriptor.value;
55
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
56
+ __runInitializers(_classThis, _classExtraInitializers);
44
57
  }
58
+ #tags;
59
+ closed;
60
+ selfClosing;
45
61
  /* NOT FOR BROWSER END */
46
- return selfClosing
47
- ? `<${opening}${String(firstChild)}/>`
48
- : `<${opening}${String(firstChild)}>${String(lastChild)}${this.closed ? `</${closing}>` : ''}`;
49
- }
50
- /** @override */
51
- text() {
52
- const [opening, closing] = this.#tags;
53
- return this.selfClosing
54
- ? `<${opening}${this.firstChild.text()}/>`
55
- : `<${opening}${super.text('>')}${this.closed ? `</${closing}>` : ''}`;
56
- }
57
- /** @private */
58
- getAttribute(key) {
59
- /* NOT FOR BROWSER */
60
- if (key === 'tags') {
61
- return [...this.#tags];
62
+ /** 内部wikitext */
63
+ get innerText() {
64
+ return this.selfClosing ? undefined : this.lastChild.text();
62
65
  }
63
- /* NOT FOR BROWSER END */
64
- return key === 'padding' ? this.#tags[0].length + 1 : super.getAttribute(key);
65
- }
66
- /** @private */
67
- getGaps() {
68
- return 1;
69
- }
70
- /** @override */
71
- print() {
72
- const [opening, closing] = this.#tags;
73
- return super.print(this.selfClosing
74
- ? { pre: `&lt;${opening}`, post: '/&gt;' }
75
- : { pre: `&lt;${opening}`, sep: '&gt;', post: this.closed ? `&lt;/${closing}&gt;` : '' });
76
- }
77
- }
66
+ /**
67
+ * @param name 标签名
68
+ * @param attr 标签属性
69
+ * @param inner 内部wikitext
70
+ * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
71
+ */
72
+ constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
73
+ super(undefined, config);
74
+ this.setAttribute('name', name.toLowerCase());
75
+ this.#tags = [name, closed || name];
76
+ this.closed = closed !== '';
77
+ this.selfClosing = closed === undefined;
78
+ this.append(attr, inner);
79
+ const index = typeof attr === 'string' ? -1 : accum.indexOf(attr);
80
+ accum.splice(index === -1 ? Infinity : index, 0, this);
81
+ }
82
+ /** @private */
83
+ toString() {
84
+ const { selfClosing, firstChild, lastChild,
85
+ /* NOT FOR BROWSER */
86
+ nextSibling, name, closed, } = this, [opening, closing] = this.#tags;
87
+ /* NOT FOR BROWSER */
88
+ if (!closed && nextSibling) {
89
+ index_1.default.error(`自动闭合 <${name}>`, lastChild);
90
+ this.closed = true;
91
+ }
92
+ /* NOT FOR BROWSER END */
93
+ return selfClosing
94
+ ? `<${opening}${String(firstChild)}/>`
95
+ : `<${opening}${String(firstChild)}>${String(lastChild)}${this.closed ? `</${closing}>` : ''}`;
96
+ }
97
+ /** @override */
98
+ text() {
99
+ const [opening, closing] = this.#tags;
100
+ return this.selfClosing
101
+ ? `<${opening}${this.firstChild.text()}/>`
102
+ : `<${opening}${super.text('>')}${this.closed ? `</${closing}>` : ''}`;
103
+ }
104
+ /** @private */
105
+ getAttribute(key) {
106
+ /* NOT FOR BROWSER */
107
+ if (key === 'tags') {
108
+ return [...this.#tags];
109
+ }
110
+ /* NOT FOR BROWSER END */
111
+ return key === 'padding' ? this.#tags[0].length + 1 : super.getAttribute(key);
112
+ }
113
+ /** @private */
114
+ getGaps() {
115
+ return 1;
116
+ }
117
+ /** @override */
118
+ print() {
119
+ const [opening, closing] = this.#tags;
120
+ return super.print(this.selfClosing
121
+ ? { pre: `&lt;${opening}`, post: '/&gt;' }
122
+ : { pre: `&lt;${opening}`, sep: '&gt;', post: this.closed ? `&lt;/${closing}&gt;` : '' });
123
+ }
124
+ };
125
+ return TagPairToken = _classThis;
126
+ })();
78
127
  exports.TagPairToken = TagPairToken;
79
128
  constants_1.classes['TagPairToken'] = __filename;
@@ -11,13 +11,13 @@ import type { LintError } from '../base';
11
11
  export declare abstract class TranscludeToken extends Token {
12
12
  #private;
13
13
  type: 'template' | 'magic-word';
14
- readonly name: string;
15
14
  readonly modifier: string;
15
+ readonly name: string;
16
16
  readonly childNodes: readonly [AtomToken | SyntaxToken, ...ParameterToken[]] | readonly [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
17
- abstract get children(): [AtomToken | SyntaxToken, ...ParameterToken[]] | [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
18
17
  abstract get firstChild(): AtomToken | SyntaxToken;
19
- abstract get firstElementChild(): AtomToken | SyntaxToken;
20
18
  abstract get lastChild(): AtomToken | SyntaxToken | ParameterToken;
19
+ abstract get children(): [AtomToken | SyntaxToken, ...ParameterToken[]] | [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]];
20
+ abstract get firstElementChild(): AtomToken | SyntaxToken;
21
21
  abstract get lastElementChild(): AtomToken | SyntaxToken | ParameterToken;
22
22
  /** 是否存在重复参数 */
23
23
  get duplication(): boolean;
@@ -24,13 +24,11 @@ const insensitiveVars = new Set([
24
24
  */
25
25
  class TranscludeToken extends index_2.Token {
26
26
  type = 'template';
27
- /* NOT FOR BROWSER END */
28
27
  modifier = '';
28
+ #keys = new Set();
29
+ /* NOT FOR BROWSER END */
29
30
  #raw = false;
30
31
  #args = new Map();
31
- /* NOT FOR BROWSER */
32
- #keys = new Set();
33
- /* NOT FOR BROWSER */
34
32
  /** 是否存在重复参数 */
35
33
  get duplication() {
36
34
  return this.isTemplate() && Boolean(this.hasDuplicatedArgs());
@@ -50,9 +48,6 @@ class TranscludeToken extends index_2.Token {
50
48
  super(undefined, config, accum, {
51
49
  AtomToken: 0, SyntaxToken: 0, ParameterToken: '1:',
52
50
  });
53
- /* NOT FOR BROWSER */
54
- this.seal('modifier');
55
- /* NOT FOR BROWSER END */
56
51
  const { parserFunction: [insensitive, sensitive] } = config, argSubst = /^(?:\s|\0\d+c\x7F)*\0\d+s\x7F/u.exec(title)?.[0];
57
52
  if (argSubst) {
58
53
  this.setAttribute('modifier', argSubst);
@@ -80,6 +75,7 @@ class TranscludeToken extends index_2.Token {
80
75
  if (this.name === 'invoke') {
81
76
  /* NOT FOR BROWSER */
82
77
  this.setAttribute('acceptable', { SyntaxToken: 0, AtomToken: '1:3', ParameterToken: '3:' });
78
+ this.protectChildren('1:3');
83
79
  /* NOT FOR BROWSER END */
84
80
  for (let i = 0; i < 2; i++) {
85
81
  const part = parts.shift();
@@ -89,8 +85,6 @@ class TranscludeToken extends index_2.Token {
89
85
  const invoke = new atom_1.AtomToken(part.join('='), `invoke-${i ? 'function' : 'module'}`, config, accum, { 'Stage-1': ':', '!ExtToken': '' });
90
86
  super.insertAt(invoke);
91
87
  }
92
- /* NOT FOR BROWSER */
93
- this.protectChildren('1:3');
94
88
  }
95
89
  }
96
90
  }
@@ -123,6 +117,7 @@ class TranscludeToken extends index_2.Token {
123
117
  // @ts-expect-error abstract class
124
118
  this.insertAt(new parameter_1.ParameterToken(...part, config, accum));
125
119
  }
120
+ this.seal('modifier');
126
121
  /* NOT FOR BROWSER */
127
122
  this.protectChildren(0);
128
123
  }
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.undo = exports.emptyArray = exports.setChildNodes = exports.isToken = exports.Shadow = void 0;
4
4
  exports.Shadow = {
5
- /* NOT FOR BROWSER */
6
5
  running: false,
7
- /* NOT FOR BROWSER END */
8
6
  /** @private */
9
7
  run(callback) {
10
8
  /* NOT FOR BROWSER */