wikiparser-node 1.11.1 → 1.12.1-b

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 (173) hide show
  1. package/bundle/bundle.min.js +37 -0
  2. package/config/enwiki.json +1 -814
  3. package/config/llwiki.json +1 -35
  4. package/config/moegirl.json +1 -44
  5. package/config/zhwiki.json +1 -466
  6. package/extensions/dist/base.js +162 -0
  7. package/extensions/dist/codejar.js +52 -0
  8. package/extensions/dist/editor.js +159 -0
  9. package/extensions/dist/highlight.js +30 -0
  10. package/extensions/dist/lint.js +72 -0
  11. package/extensions/editor.css +59 -0
  12. package/extensions/ui.css +159 -0
  13. package/package.json +29 -21
  14. package/config/.schema.json +0 -186
  15. package/dist/addon/table.js +0 -486
  16. package/dist/addon/token.js +0 -304
  17. package/dist/addon/transclude.js +0 -184
  18. package/dist/base.d.ts +0 -81
  19. package/dist/base.js +0 -39
  20. package/dist/index.d.ts +0 -33
  21. package/dist/index.js +0 -235
  22. package/dist/internal.d.ts +0 -46
  23. package/dist/lib/element.d.ts +0 -125
  24. package/dist/lib/element.js +0 -375
  25. package/dist/lib/node.d.ts +0 -173
  26. package/dist/lib/node.js +0 -477
  27. package/dist/lib/range.d.ts +0 -105
  28. package/dist/lib/range.js +0 -406
  29. package/dist/lib/ranges.d.ts +0 -28
  30. package/dist/lib/ranges.js +0 -126
  31. package/dist/lib/rect.d.ts +0 -18
  32. package/dist/lib/rect.js +0 -34
  33. package/dist/lib/text.d.ts +0 -58
  34. package/dist/lib/text.js +0 -400
  35. package/dist/lib/title.d.ts +0 -42
  36. package/dist/lib/title.js +0 -208
  37. package/dist/mixin/attributesParent.d.ts +0 -49
  38. package/dist/mixin/attributesParent.js +0 -79
  39. package/dist/mixin/fixed.d.ts +0 -5
  40. package/dist/mixin/fixed.js +0 -32
  41. package/dist/mixin/flagsParent.d.ts +0 -43
  42. package/dist/mixin/flagsParent.js +0 -64
  43. package/dist/mixin/hidden.d.ts +0 -7
  44. package/dist/mixin/hidden.js +0 -37
  45. package/dist/mixin/magicLinkParent.d.ts +0 -19
  46. package/dist/mixin/magicLinkParent.js +0 -43
  47. package/dist/mixin/singleLine.d.ts +0 -5
  48. package/dist/mixin/singleLine.js +0 -25
  49. package/dist/mixin/sol.d.ts +0 -6
  50. package/dist/mixin/sol.js +0 -45
  51. package/dist/mixin/syntax.d.ts +0 -8
  52. package/dist/mixin/syntax.js +0 -46
  53. package/dist/parser/braces.js +0 -150
  54. package/dist/parser/commentAndExt.js +0 -79
  55. package/dist/parser/converter.js +0 -39
  56. package/dist/parser/externalLinks.js +0 -37
  57. package/dist/parser/hrAndDoubleUnderscore.js +0 -42
  58. package/dist/parser/html.js +0 -38
  59. package/dist/parser/links.js +0 -101
  60. package/dist/parser/list.js +0 -114
  61. package/dist/parser/magicLinks.js +0 -52
  62. package/dist/parser/quotes.js +0 -67
  63. package/dist/parser/redirect.js +0 -26
  64. package/dist/parser/selector.js +0 -394
  65. package/dist/parser/table.js +0 -123
  66. package/dist/src/arg.d.ts +0 -51
  67. package/dist/src/arg.js +0 -214
  68. package/dist/src/atom.d.ts +0 -14
  69. package/dist/src/atom.js +0 -52
  70. package/dist/src/attribute.d.ts +0 -64
  71. package/dist/src/attribute.js +0 -480
  72. package/dist/src/attributes.d.ts +0 -101
  73. package/dist/src/attributes.js +0 -381
  74. package/dist/src/converter.d.ts +0 -28
  75. package/dist/src/converter.js +0 -148
  76. package/dist/src/converterFlags.d.ts +0 -80
  77. package/dist/src/converterFlags.js +0 -239
  78. package/dist/src/converterRule.d.ts +0 -71
  79. package/dist/src/converterRule.js +0 -216
  80. package/dist/src/extLink.d.ts +0 -36
  81. package/dist/src/extLink.js +0 -218
  82. package/dist/src/gallery.d.ts +0 -47
  83. package/dist/src/gallery.js +0 -143
  84. package/dist/src/heading.d.ts +0 -40
  85. package/dist/src/heading.js +0 -192
  86. package/dist/src/hidden.d.ts +0 -9
  87. package/dist/src/hidden.js +0 -80
  88. package/dist/src/html.d.ts +0 -61
  89. package/dist/src/html.js +0 -343
  90. package/dist/src/imageParameter.d.ts +0 -60
  91. package/dist/src/imageParameter.js +0 -260
  92. package/dist/src/imagemap.d.ts +0 -47
  93. package/dist/src/imagemap.js +0 -146
  94. package/dist/src/imagemapLink.d.ts +0 -31
  95. package/dist/src/imagemapLink.js +0 -97
  96. package/dist/src/index.d.ts +0 -136
  97. package/dist/src/index.js +0 -834
  98. package/dist/src/link/base.d.ts +0 -52
  99. package/dist/src/link/base.js +0 -256
  100. package/dist/src/link/category.d.ts +0 -22
  101. package/dist/src/link/category.js +0 -34
  102. package/dist/src/link/file.d.ts +0 -102
  103. package/dist/src/link/file.js +0 -333
  104. package/dist/src/link/galleryImage.d.ts +0 -29
  105. package/dist/src/link/galleryImage.js +0 -132
  106. package/dist/src/link/index.d.ts +0 -39
  107. package/dist/src/link/index.js +0 -98
  108. package/dist/src/link/redirectTarget.d.ts +0 -27
  109. package/dist/src/link/redirectTarget.js +0 -69
  110. package/dist/src/magicLink.d.ts +0 -58
  111. package/dist/src/magicLink.js +0 -256
  112. package/dist/src/nested.d.ts +0 -40
  113. package/dist/src/nested.js +0 -106
  114. package/dist/src/nowiki/base.d.ts +0 -28
  115. package/dist/src/nowiki/base.js +0 -89
  116. package/dist/src/nowiki/comment.d.ts +0 -14
  117. package/dist/src/nowiki/comment.js +0 -121
  118. package/dist/src/nowiki/dd.d.ts +0 -8
  119. package/dist/src/nowiki/dd.js +0 -72
  120. package/dist/src/nowiki/doubleUnderscore.d.ts +0 -15
  121. package/dist/src/nowiki/doubleUnderscore.js +0 -97
  122. package/dist/src/nowiki/hr.d.ts +0 -5
  123. package/dist/src/nowiki/hr.js +0 -70
  124. package/dist/src/nowiki/index.d.ts +0 -14
  125. package/dist/src/nowiki/index.js +0 -28
  126. package/dist/src/nowiki/list.d.ts +0 -5
  127. package/dist/src/nowiki/list.js +0 -65
  128. package/dist/src/nowiki/listBase.d.ts +0 -23
  129. package/dist/src/nowiki/listBase.js +0 -99
  130. package/dist/src/nowiki/noinclude.d.ts +0 -6
  131. package/dist/src/nowiki/noinclude.js +0 -75
  132. package/dist/src/nowiki/quote.d.ts +0 -14
  133. package/dist/src/nowiki/quote.js +0 -140
  134. package/dist/src/onlyinclude.d.ts +0 -13
  135. package/dist/src/onlyinclude.js +0 -58
  136. package/dist/src/paramTag/index.d.ts +0 -28
  137. package/dist/src/paramTag/index.js +0 -78
  138. package/dist/src/paramTag/inputbox.d.ts +0 -8
  139. package/dist/src/paramTag/inputbox.js +0 -22
  140. package/dist/src/parameter.d.ts +0 -60
  141. package/dist/src/parameter.js +0 -264
  142. package/dist/src/pre.d.ts +0 -28
  143. package/dist/src/pre.js +0 -60
  144. package/dist/src/redirect.d.ts +0 -30
  145. package/dist/src/redirect.js +0 -126
  146. package/dist/src/syntax.d.ts +0 -17
  147. package/dist/src/syntax.js +0 -87
  148. package/dist/src/table/base.d.ts +0 -28
  149. package/dist/src/table/base.js +0 -81
  150. package/dist/src/table/index.d.ts +0 -230
  151. package/dist/src/table/index.js +0 -506
  152. package/dist/src/table/td.d.ts +0 -72
  153. package/dist/src/table/td.js +0 -370
  154. package/dist/src/table/tr.d.ts +0 -30
  155. package/dist/src/table/tr.js +0 -59
  156. package/dist/src/table/trBase.d.ts +0 -49
  157. package/dist/src/table/trBase.js +0 -164
  158. package/dist/src/tagPair/ext.d.ts +0 -29
  159. package/dist/src/tagPair/ext.js +0 -220
  160. package/dist/src/tagPair/include.d.ts +0 -33
  161. package/dist/src/tagPair/include.js +0 -130
  162. package/dist/src/tagPair/index.d.ts +0 -23
  163. package/dist/src/tagPair/index.js +0 -128
  164. package/dist/src/transclude.d.ts +0 -159
  165. package/dist/src/transclude.js +0 -587
  166. package/dist/util/constants.js +0 -25
  167. package/dist/util/debug.js +0 -95
  168. package/dist/util/diff.js +0 -83
  169. package/dist/util/html.js +0 -143
  170. package/dist/util/lint.js +0 -32
  171. package/dist/util/string.js +0 -87
  172. package/errors/README +0 -3
  173. package/printed/README +0 -3
@@ -1,29 +0,0 @@
1
- import Parser from '../../index';
2
- import { Token } from '../index';
3
- import { TagPairToken } from './index';
4
- import { AttributesToken } from '../attributes';
5
- import type { LintError } from '../../base';
6
- import type { AttributesParentBase } from '../../mixin/attributesParent';
7
- export interface ExtToken extends AttributesParentBase {
8
- }
9
- /**
10
- * 扩展标签
11
- * @classdesc `{childNodes: [AttributesToken, Token]}`
12
- */
13
- export declare abstract class ExtToken extends TagPairToken {
14
- closed: true;
15
- readonly childNodes: readonly [AttributesToken, Token];
16
- abstract get firstChild(): AttributesToken;
17
- abstract get lastChild(): Token;
18
- abstract get children(): [AttributesToken, Token];
19
- abstract get firstElementChild(): AttributesToken;
20
- get type(): 'ext';
21
- /**
22
- * @param name 标签名
23
- * @param attr 标签属性
24
- * @param inner 内部wikitext
25
- * @param closed 是否封闭
26
- */
27
- constructor(name: string, attr?: string, inner?: string, closed?: string, config?: Parser.Config, accum?: Token[]);
28
- cloneNode(): this;
29
- }
@@ -1,220 +0,0 @@
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
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.ExtToken = void 0;
38
- const lint_1 = require("../../util/lint");
39
- const rect_1 = require("../../lib/rect");
40
- const debug_1 = require("../../util/debug");
41
- const constants_1 = require("../../util/constants");
42
- const string_1 = require("../../util/string");
43
- const attributesParent_1 = require("../../mixin/attributesParent");
44
- const index_1 = require("../../index");
45
- const index_2 = require("../index");
46
- const index_3 = require("./index");
47
- const attributes_1 = require("../attributes");
48
- /**
49
- * 从数组中删除指定元素
50
- * @param arr 数组
51
- * @param ele 元素
52
- */
53
- const del = (arr, ele) => {
54
- const set = new Set(arr);
55
- set.delete(ele);
56
- return [...set];
57
- };
58
- /* NOT FOR BROWSER END */
59
- /**
60
- * 扩展标签
61
- * @classdesc `{childNodes: [AttributesToken, Token]}`
62
- */
63
- let ExtToken = (() => {
64
- let _classDecorators = [(0, attributesParent_1.attributesParent)()];
65
- let _classDescriptor;
66
- let _classExtraInitializers = [];
67
- let _classThis;
68
- let _classSuper = index_3.TagPairToken;
69
- var ExtToken = class extends _classSuper {
70
- static { _classThis = this; }
71
- static {
72
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
73
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
74
- ExtToken = _classThis = _classDescriptor.value;
75
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
76
- __runInitializers(_classThis, _classExtraInitializers);
77
- }
78
- /* NOT FOR BROWSER END */
79
- get type() {
80
- return 'ext';
81
- }
82
- /**
83
- * @param name 标签名
84
- * @param attr 标签属性
85
- * @param inner 内部wikitext
86
- * @param closed 是否封闭
87
- */
88
- constructor(name, attr, inner, closed, config = index_1.default.getConfig(), accum = []) {
89
- const lcName = name.toLowerCase(),
90
- // @ts-expect-error abstract class
91
- 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 ?? []] };
92
- let innerToken;
93
- switch (lcName) {
94
- case 'tab':
95
- newConfig.ext = del(newConfig.ext, 'tabs');
96
- // fall through
97
- case 'indicator':
98
- case 'poem':
99
- case 'ref':
100
- case 'option':
101
- case 'combooption':
102
- case 'tabs':
103
- case 'poll':
104
- case 'seo':
105
- if (lcName === 'poem') {
106
- newConfig.excludes.push('heading');
107
- }
108
- innerToken = new index_2.Token(inner, newConfig, accum);
109
- break;
110
- case 'pre': {
111
- const { PreToken } = require('../pre');
112
- // @ts-expect-error abstract class
113
- innerToken = new PreToken(inner, newConfig, accum);
114
- break;
115
- }
116
- case 'dynamicpagelist': {
117
- const { ParamTagToken } = require('../paramTag/index');
118
- // @ts-expect-error abstract class
119
- innerToken = new ParamTagToken(inner, newConfig, accum);
120
- break;
121
- }
122
- case 'inputbox': {
123
- newConfig.excludes.push('heading');
124
- const { InputboxToken } = require('../paramTag/inputbox');
125
- // @ts-expect-error abstract class
126
- innerToken = new InputboxToken(inner, newConfig, accum);
127
- break;
128
- }
129
- case 'references': {
130
- const { NestedToken } = require('../nested');
131
- // @ts-expect-error abstract class
132
- innerToken = new NestedToken(inner, /<!--.*?(?:-->|$)|<(ref)(\s[^>]*?)?(?:\/>|>(.*?)<\/(ref\s*)>)/gisu, ['ref'], newConfig, accum);
133
- break;
134
- }
135
- case 'choose': {
136
- const { NestedToken } = require('../nested');
137
- // @ts-expect-error abstract class
138
- innerToken = new NestedToken(inner, /<(option|choicetemplate)(\s[^>]*?)?(?:\/>|>(.*?)<\/(\1)>)/gsu, ['option', 'choicetemplate'], newConfig, accum);
139
- break;
140
- }
141
- case 'combobox': {
142
- const { NestedToken } = require('../nested');
143
- // @ts-expect-error abstract class
144
- innerToken = new NestedToken(inner, /<(combooption)(\s[^>]*?)?(?:\/>|>(.*?)<\/(combooption\s*)>)/gisu, ['combooption'], newConfig, accum);
145
- break;
146
- }
147
- case 'gallery': {
148
- const { GalleryToken } = require('../gallery');
149
- // @ts-expect-error abstract class
150
- innerToken = new GalleryToken(inner, newConfig, accum);
151
- break;
152
- }
153
- case 'imagemap': {
154
- const { ImagemapToken } = require('../imagemap');
155
- // @ts-expect-error abstract class
156
- innerToken = new ImagemapToken(inner, newConfig, accum);
157
- break;
158
- }
159
- // 更多定制扩展的代码示例:
160
- // ```
161
- // case 'extensionName': {
162
- // const {ExtensionToken}: typeof import('../extension') = require('../extension');
163
- // innerToken = new ExtensionToken(inner, newConfig, accum);
164
- // break;
165
- // }
166
- // ```
167
- default: {
168
- const { NowikiToken } = require('../nowiki/index');
169
- // @ts-expect-error abstract class
170
- innerToken = new NowikiToken(inner, newConfig, accum);
171
- }
172
- }
173
- innerToken.setAttribute('name', lcName);
174
- if (innerToken.type === 'plain') {
175
- innerToken.type = 'ext-inner';
176
- }
177
- super(name, attrToken, innerToken, closed, config, accum);
178
- this.seal('closed', true);
179
- }
180
- /** @private */
181
- lint(start = this.getAbsoluteIndex(), re) {
182
- const errors = super.lint(start, re), rect = new rect_1.BoundingRect(this, start);
183
- if (this.name !== 'nowiki' && this.closest('html-attrs, table-attrs')) {
184
- errors.push((0, lint_1.generateForSelf)(this, rect, 'parsing-order', 'extension tag in HTML tag attributes'));
185
- }
186
- if (this.name === 'ref' && this.closest('heading-title')) {
187
- errors.push((0, lint_1.generateForSelf)(this, rect, 'var-anchor', 'variable anchor in a section header'));
188
- }
189
- return errors;
190
- }
191
- /* NOT FOR BROWSER */
192
- cloneNode() {
193
- const inner = this.lastChild.cloneNode(), tags = this.getAttribute('tags'), config = this.getAttribute('config'), attr = this.firstChild.toString();
194
- return debug_1.Shadow.run(() => {
195
- // @ts-expect-error abstract class
196
- const token = new ExtToken(tags[0], attr, '', this.selfClosing ? undefined : tags[1], config);
197
- token.lastChild.safeReplaceWith(inner);
198
- return token;
199
- });
200
- }
201
- /** @private */
202
- toHtmlInternal() {
203
- const { name, firstChild, lastChild } = this;
204
- switch (name) {
205
- case 'nowiki':
206
- return (0, string_1.newline)(lastChild.toHtmlInternal());
207
- case 'pre':
208
- return `<pre${firstChild.toHtmlInternal()}>${(0, string_1.newline)(lastChild.toHtmlInternal())}</pre>`;
209
- case 'poem':
210
- firstChild.classList.add('poem');
211
- return `<div${firstChild.toHtmlInternal()}>${lastChild.toHtmlInternal().replaceAll('\n', '<br>')}</div>`;
212
- default:
213
- return '';
214
- }
215
- }
216
- };
217
- return ExtToken = _classThis;
218
- })();
219
- exports.ExtToken = ExtToken;
220
- constants_1.classes['ExtToken'] = __filename;
@@ -1,33 +0,0 @@
1
- import { TagPairToken } from './index';
2
- import type { LintError, Config } from '../../base';
3
- import type { AstText, Token } from '../../internal';
4
- /**
5
- * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
6
- * @classdesc `{childNodes: [AstText, AstText]}`
7
- */
8
- export declare abstract class IncludeToken extends TagPairToken {
9
- readonly childNodes: readonly [AstText, AstText];
10
- abstract get firstChild(): AstText;
11
- abstract get lastChild(): AstText;
12
- abstract get children(): [];
13
- abstract get firstElementChild(): undefined;
14
- abstract get lastElementChild(): undefined;
15
- get type(): 'include';
16
- get innerText(): string | undefined;
17
- set innerText(text: string | undefined);
18
- /**
19
- * @param name 标签名
20
- * @param attr 标签属性
21
- * @param inner 内部wikitext
22
- * @param closed 是否封闭
23
- */
24
- constructor(name: string, attr?: string, inner?: string, closed?: string, config?: Config, accum?: Token[]);
25
- cloneNode(): this;
26
- /**
27
- * @override
28
- * @param str 新文本
29
- */
30
- setText(str: string): string;
31
- /** 清除标签属性 */
32
- removeAttr(): void;
33
- }
@@ -1,130 +0,0 @@
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
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.IncludeToken = void 0;
38
- const lint_1 = require("../../util/lint");
39
- const debug_1 = require("../../util/debug");
40
- const constants_1 = require("../../util/constants");
41
- const hidden_1 = require("../../mixin/hidden");
42
- const index_1 = require("../../index");
43
- const index_2 = require("./index");
44
- /**
45
- * `<includeonly>`或`<noinclude>`或`<onlyinclude>`
46
- * @classdesc `{childNodes: [AstText, AstText]}`
47
- */
48
- let IncludeToken = (() => {
49
- let _classDecorators = [(0, hidden_1.hiddenToken)(false)];
50
- let _classDescriptor;
51
- let _classExtraInitializers = [];
52
- let _classThis;
53
- let _classSuper = index_2.TagPairToken;
54
- var IncludeToken = class extends _classSuper {
55
- static { _classThis = this; }
56
- static {
57
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
58
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
59
- IncludeToken = _classThis = _classDescriptor.value;
60
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
61
- __runInitializers(_classThis, _classExtraInitializers);
62
- }
63
- /* NOT FOR BROWSER END */
64
- get type() {
65
- return 'include';
66
- }
67
- /* NOT FOR BROWSER */
68
- get innerText() {
69
- return this.selfClosing ? undefined : this.lastChild.data;
70
- }
71
- set innerText(text) {
72
- if (text === undefined) {
73
- this.selfClosing = true;
74
- }
75
- else {
76
- this.selfClosing = false;
77
- this.setText(text);
78
- }
79
- }
80
- /* NOT FOR BROWSER END */
81
- /**
82
- * @param name 标签名
83
- * @param attr 标签属性
84
- * @param inner 内部wikitext
85
- * @param closed 是否封闭
86
- */
87
- constructor(name, attr = '', inner, closed, config, accum) {
88
- super(name, attr, inner ?? '', inner === undefined ? closed : closed ?? '', config, accum);
89
- }
90
- /** @private */
91
- toString(skip) {
92
- return skip ? '' : super.toString();
93
- }
94
- /** @private */
95
- lint(start = this.getAbsoluteIndex()) {
96
- if (this.closed) {
97
- return [];
98
- }
99
- const e = (0, lint_1.generateForSelf)(this, { start }, 'unclosed-comment', index_1.default.msg('unclosed $1', `<${this.name}>`));
100
- e.suggestions = [
101
- {
102
- desc: 'close',
103
- range: [e.endIndex, e.endIndex],
104
- text: `</${this.name}>`,
105
- },
106
- ];
107
- return [e];
108
- }
109
- /* NOT FOR BROWSER */
110
- cloneNode() {
111
- const tags = this.getAttribute('tags'), config = this.getAttribute('config'), { innerText } = this, closing = this.selfClosing || !this.closed ? undefined : tags[1];
112
- // @ts-expect-error abstract class
113
- return debug_1.Shadow.run(() => new IncludeToken(tags[0], this.firstChild.data, innerText, closing, config));
114
- }
115
- /**
116
- * @override
117
- * @param str 新文本
118
- */
119
- setText(str) {
120
- return super.setText(str, 1);
121
- }
122
- /** 清除标签属性 */
123
- removeAttr() {
124
- super.setText('');
125
- }
126
- };
127
- return IncludeToken = _classThis;
128
- })();
129
- exports.IncludeToken = IncludeToken;
130
- constants_1.classes['IncludeToken'] = __filename;
@@ -1,23 +0,0 @@
1
- import { Token } from '../index';
2
- import type { Config } from '../../base';
3
- import type { AstNodes } from '../../lib/node';
4
- /** 成对标签 */
5
- export declare abstract class TagPairToken extends Token {
6
- #private;
7
- readonly name: string;
8
- closed: boolean;
9
- selfClosing: boolean;
10
- abstract get type(): 'ext' | 'include';
11
- readonly childNodes: readonly [AstNodes, AstNodes];
12
- abstract get firstChild(): AstNodes;
13
- abstract get lastChild(): AstNodes;
14
- /** 内部wikitext */
15
- get innerText(): string | undefined;
16
- /**
17
- * @param name 标签名
18
- * @param attr 标签属性
19
- * @param inner 内部wikitext
20
- * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
21
- */
22
- constructor(name: string, attr: string | Token, inner: string | Token, closed?: string, config?: Config, accum?: Token[]);
23
- }
@@ -1,128 +0,0 @@
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
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.TagPairToken = void 0;
38
- const constants_1 = require("../../util/constants");
39
- const fixed_1 = require("../../mixin/fixed");
40
- const index_1 = require("../../index");
41
- const index_2 = require("../index");
42
- /** 成对标签 */
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);
57
- }
58
- #tags;
59
- closed;
60
- selfClosing;
61
- /* NOT FOR BROWSER END */
62
- /** 内部wikitext */
63
- get innerText() {
64
- return this.selfClosing ? undefined : this.lastChild.text();
65
- }
66
- /**
67
- * @param name 标签名
68
- * @param attr 标签属性
69
- * @param inner 内部wikitext
70
- * @param closed 是否封闭;约定`undefined`表示自封闭,`''`表示未闭合
71
- */
72
- constructor(name, attr, inner, closed, config, 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(skip) {
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(`Auto-closing <${name}>`, lastChild);
90
- this.closed = true;
91
- }
92
- /* NOT FOR BROWSER END */
93
- return selfClosing
94
- ? `<${opening}${firstChild.toString(skip)}/>`
95
- : `<${opening}${firstChild.toString(skip)}>${lastChild.toString(skip)}${this.closed ? `</${closing}>` : ''}`;
96
- }
97
- /** @private */
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
- /** @private */
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
- })();
127
- exports.TagPairToken = TagPairToken;
128
- constants_1.classes['TagPairToken'] = __filename;