wikiparser-node 1.13.1-b → 1.13.1
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.
- package/config/.schema.json +203 -0
- package/config/default.json +32 -31
- package/config/enwiki.json +829 -15
- package/config/llwiki.json +56 -21
- package/config/moegirl.json +65 -21
- package/config/zhwiki.json +498 -32
- package/dist/addon/table.js +494 -0
- package/dist/addon/token.js +392 -0
- package/dist/addon/transclude.js +184 -0
- package/dist/base.d.ts +110 -0
- package/dist/base.js +67 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +279 -0
- package/dist/internal.d.ts +47 -0
- package/dist/lib/element.d.ts +125 -0
- package/dist/lib/element.js +364 -0
- package/dist/lib/node.d.ts +173 -0
- package/dist/lib/node.js +478 -0
- package/dist/lib/range.d.ts +105 -0
- package/dist/lib/range.js +406 -0
- package/dist/lib/ranges.d.ts +28 -0
- package/dist/lib/ranges.js +126 -0
- package/dist/lib/rect.d.ts +18 -0
- package/dist/lib/rect.js +36 -0
- package/dist/lib/text.d.ts +58 -0
- package/dist/lib/text.js +414 -0
- package/dist/lib/title.d.ts +49 -0
- package/dist/lib/title.js +251 -0
- package/dist/mixin/attributesParent.d.ts +49 -0
- package/dist/mixin/attributesParent.js +80 -0
- package/dist/mixin/fixed.d.ts +5 -0
- package/dist/mixin/fixed.js +32 -0
- package/dist/mixin/flagsParent.d.ts +43 -0
- package/dist/mixin/flagsParent.js +64 -0
- package/dist/mixin/hidden.d.ts +7 -0
- package/dist/mixin/hidden.js +39 -0
- package/dist/mixin/magicLinkParent.d.ts +19 -0
- package/dist/mixin/magicLinkParent.js +43 -0
- package/dist/mixin/singleLine.d.ts +5 -0
- package/dist/mixin/singleLine.js +25 -0
- package/dist/mixin/sol.d.ts +6 -0
- package/dist/mixin/sol.js +45 -0
- package/dist/mixin/syntax.d.ts +8 -0
- package/dist/mixin/syntax.js +46 -0
- package/dist/parser/braces.js +152 -0
- package/dist/parser/commentAndExt.js +84 -0
- package/dist/parser/converter.js +41 -0
- package/dist/parser/externalLinks.js +39 -0
- package/dist/parser/hrAndDoubleUnderscore.js +44 -0
- package/dist/parser/html.js +40 -0
- package/dist/parser/links.js +103 -0
- package/dist/parser/list.js +116 -0
- package/dist/parser/magicLinks.js +55 -0
- package/dist/parser/quotes.js +69 -0
- package/dist/parser/redirect.js +28 -0
- package/dist/parser/selector.js +443 -0
- package/dist/parser/table.js +125 -0
- package/dist/src/arg.d.ts +49 -0
- package/dist/src/arg.js +220 -0
- package/dist/src/atom.d.ts +14 -0
- package/dist/src/atom.js +54 -0
- package/dist/src/attribute.d.ts +64 -0
- package/dist/src/attribute.js +482 -0
- package/dist/src/attributes.d.ts +103 -0
- package/dist/src/attributes.js +383 -0
- package/dist/src/converter.d.ts +28 -0
- package/dist/src/converter.js +153 -0
- package/dist/src/converterFlags.d.ts +80 -0
- package/dist/src/converterFlags.js +241 -0
- package/dist/src/converterRule.d.ts +71 -0
- package/dist/src/converterRule.js +218 -0
- package/dist/src/extLink.d.ts +36 -0
- package/dist/src/extLink.js +223 -0
- package/dist/src/gallery.d.ts +51 -0
- package/dist/src/gallery.js +166 -0
- package/dist/src/heading.d.ts +44 -0
- package/dist/src/heading.js +222 -0
- package/dist/src/hidden.d.ts +9 -0
- package/dist/src/hidden.js +82 -0
- package/dist/src/html.d.ts +61 -0
- package/dist/src/html.js +344 -0
- package/dist/src/imageParameter.d.ts +60 -0
- package/dist/src/imageParameter.js +262 -0
- package/dist/src/imagemap.d.ts +47 -0
- package/dist/src/imagemap.js +148 -0
- package/dist/src/imagemapLink.d.ts +35 -0
- package/dist/src/imagemapLink.js +99 -0
- package/dist/src/index.d.ts +136 -0
- package/dist/src/index.js +790 -0
- package/dist/src/link/base.d.ts +52 -0
- package/dist/src/link/base.js +258 -0
- package/dist/src/link/category.d.ts +22 -0
- package/dist/src/link/category.js +36 -0
- package/dist/src/link/file.d.ts +102 -0
- package/dist/src/link/file.js +345 -0
- package/dist/src/link/galleryImage.d.ts +29 -0
- package/dist/src/link/galleryImage.js +133 -0
- package/dist/src/link/index.d.ts +39 -0
- package/dist/src/link/index.js +100 -0
- package/dist/src/link/redirectTarget.d.ts +27 -0
- package/dist/src/link/redirectTarget.js +71 -0
- package/dist/src/magicLink.d.ts +57 -0
- package/dist/src/magicLink.js +261 -0
- package/dist/src/nested.d.ts +40 -0
- package/dist/src/nested.js +108 -0
- package/dist/src/nowiki/base.d.ts +28 -0
- package/dist/src/nowiki/base.js +90 -0
- package/dist/src/nowiki/comment.d.ts +14 -0
- package/dist/src/nowiki/comment.js +123 -0
- package/dist/src/nowiki/dd.d.ts +8 -0
- package/dist/src/nowiki/dd.js +74 -0
- package/dist/src/nowiki/doubleUnderscore.d.ts +15 -0
- package/dist/src/nowiki/doubleUnderscore.js +101 -0
- package/dist/src/nowiki/hr.d.ts +5 -0
- package/dist/src/nowiki/hr.js +72 -0
- package/dist/src/nowiki/index.d.ts +14 -0
- package/dist/src/nowiki/index.js +30 -0
- package/dist/src/nowiki/list.d.ts +5 -0
- package/dist/src/nowiki/list.js +67 -0
- package/dist/src/nowiki/listBase.d.ts +23 -0
- package/dist/src/nowiki/listBase.js +100 -0
- package/dist/src/nowiki/noinclude.d.ts +6 -0
- package/dist/src/nowiki/noinclude.js +77 -0
- package/dist/src/nowiki/quote.d.ts +14 -0
- package/dist/src/nowiki/quote.js +149 -0
- package/dist/src/onlyinclude.d.ts +13 -0
- package/dist/src/onlyinclude.js +60 -0
- package/dist/src/paramTag/index.d.ts +28 -0
- package/dist/src/paramTag/index.js +80 -0
- package/dist/src/paramTag/inputbox.d.ts +8 -0
- package/dist/src/paramTag/inputbox.js +38 -0
- package/dist/src/parameter.d.ts +60 -0
- package/dist/src/parameter.js +267 -0
- package/dist/src/pre.d.ts +28 -0
- package/dist/src/pre.js +70 -0
- package/dist/src/redirect.d.ts +30 -0
- package/dist/src/redirect.js +128 -0
- package/dist/src/syntax.d.ts +15 -0
- package/dist/src/syntax.js +87 -0
- package/dist/src/table/base.d.ts +28 -0
- package/dist/src/table/base.js +81 -0
- package/dist/src/table/index.d.ts +230 -0
- package/dist/src/table/index.js +506 -0
- package/dist/src/table/td.d.ts +72 -0
- package/dist/src/table/td.js +375 -0
- package/dist/src/table/tr.d.ts +30 -0
- package/dist/src/table/tr.js +61 -0
- package/dist/src/table/trBase.d.ts +49 -0
- package/dist/src/table/trBase.js +165 -0
- package/dist/src/tagPair/ext.d.ts +29 -0
- package/dist/src/tagPair/ext.js +229 -0
- package/dist/src/tagPair/include.d.ts +33 -0
- package/dist/src/tagPair/include.js +145 -0
- package/dist/src/tagPair/index.d.ts +23 -0
- package/dist/src/tagPair/index.js +130 -0
- package/dist/src/transclude.d.ts +159 -0
- package/dist/src/transclude.js +598 -0
- package/dist/util/constants.js +26 -0
- package/dist/util/debug.js +95 -0
- package/dist/util/diff.js +83 -0
- package/dist/util/html.js +146 -0
- package/dist/util/lint.js +32 -0
- package/dist/util/string.js +107 -0
- package/errors/README +3 -0
- package/package.json +21 -28
- package/printed/README +3 -0
- package/bundle/bundle.min.js +0 -37
- package/extensions/dist/base.js +0 -163
- package/extensions/dist/codejar.js +0 -53
- package/extensions/dist/editor.js +0 -159
- package/extensions/dist/highlight.js +0 -30
- package/extensions/dist/lint.js +0 -72
- package/extensions/editor.css +0 -59
- package/extensions/ui.css +0 -162
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Title = void 0;
|
|
4
|
+
const string_1 = require("../util/string");
|
|
5
|
+
/* NOT FOR BROWSER */
|
|
6
|
+
const constants_1 = require("../util/constants");
|
|
7
|
+
const index_1 = require("../index");
|
|
8
|
+
/* NOT FOR BROWSER END */
|
|
9
|
+
/** MediaWiki页面标题对象 */
|
|
10
|
+
class Title {
|
|
11
|
+
#main;
|
|
12
|
+
#namespaces;
|
|
13
|
+
#ns;
|
|
14
|
+
#fragment;
|
|
15
|
+
interwiki = '';
|
|
16
|
+
valid;
|
|
17
|
+
/** @private */
|
|
18
|
+
encoded = false;
|
|
19
|
+
/* NOT FOR BROWSER */
|
|
20
|
+
#redirectFragment;
|
|
21
|
+
#path;
|
|
22
|
+
/** @private */
|
|
23
|
+
conversionTable = new Map();
|
|
24
|
+
/** @private */
|
|
25
|
+
redirects = new Map();
|
|
26
|
+
/* NOT FOR BROWSER END */
|
|
27
|
+
/** 命名空间 */
|
|
28
|
+
get ns() {
|
|
29
|
+
return this.#ns;
|
|
30
|
+
}
|
|
31
|
+
/** 片段标识符 */
|
|
32
|
+
get fragment() {
|
|
33
|
+
return this.#fragment;
|
|
34
|
+
}
|
|
35
|
+
/** 不含命名空间的标题主体部分 */
|
|
36
|
+
get main() {
|
|
37
|
+
return this.#main;
|
|
38
|
+
}
|
|
39
|
+
set main(title) {
|
|
40
|
+
title = title.replace(/_/gu, ' ').trim();
|
|
41
|
+
this.#main = title && title[0].toUpperCase() + title.slice(1);
|
|
42
|
+
}
|
|
43
|
+
/** 命名空间前缀 */
|
|
44
|
+
get prefix() {
|
|
45
|
+
const namespace = this.#namespaces[this.ns];
|
|
46
|
+
return namespace + (namespace && ':');
|
|
47
|
+
}
|
|
48
|
+
/** 完整标题 */
|
|
49
|
+
get title() {
|
|
50
|
+
return this.getRedirection()[1];
|
|
51
|
+
}
|
|
52
|
+
/** 扩展名 */
|
|
53
|
+
get extension() {
|
|
54
|
+
const { main } = this, i = main.lastIndexOf('.');
|
|
55
|
+
return i === -1 ? undefined : main.slice(i + 1).toLowerCase();
|
|
56
|
+
}
|
|
57
|
+
/* NOT FOR BROWSER */
|
|
58
|
+
set extension(extension) {
|
|
59
|
+
extension ??= '';
|
|
60
|
+
const { main } = this, i = main.lastIndexOf('.');
|
|
61
|
+
this.main = (i === -1 ? main : main.slice(0, i)) + (extension && '.') + extension;
|
|
62
|
+
}
|
|
63
|
+
/** @throws `RangeError` undefined namespace */
|
|
64
|
+
set ns(ns) {
|
|
65
|
+
if (!(this.ns in this.#namespaces)) {
|
|
66
|
+
throw new RangeError('Undefined namespace!');
|
|
67
|
+
}
|
|
68
|
+
this.#ns = Number(ns);
|
|
69
|
+
}
|
|
70
|
+
set fragment(fragment) {
|
|
71
|
+
if (fragment === undefined) {
|
|
72
|
+
this.#fragment = undefined;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (fragment.includes('%')) {
|
|
76
|
+
try {
|
|
77
|
+
fragment = (0, string_1.rawurldecode)(fragment);
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
80
|
+
}
|
|
81
|
+
this.#fragment = (0, string_1.decodeHtml)(fragment).replace(/[_ ]+/gu, ' ').trimEnd().replaceAll(' ', '_');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/* NOT FOR BROWSER END */
|
|
85
|
+
/**
|
|
86
|
+
* @see MediaWikiTitleCodec::splitTitleString
|
|
87
|
+
*
|
|
88
|
+
* @param title 标题(含或不含命名空间前缀)
|
|
89
|
+
* @param defaultNs 命名空间
|
|
90
|
+
* @param decode 是否需要解码
|
|
91
|
+
* @param selfLink 是否允许selfLink
|
|
92
|
+
*/
|
|
93
|
+
constructor(title, defaultNs, config, decode, selfLink) {
|
|
94
|
+
const subpage = title.trim().startsWith('../');
|
|
95
|
+
if (decode && title.includes('%')) {
|
|
96
|
+
try {
|
|
97
|
+
const encoded = /%(?!21|3[ce]|5[bd]|7[b-d])[\da-f]{2}/iu.test(title);
|
|
98
|
+
title = (0, string_1.rawurldecode)(title);
|
|
99
|
+
this.encoded = encoded;
|
|
100
|
+
}
|
|
101
|
+
catch { }
|
|
102
|
+
}
|
|
103
|
+
title = (0, string_1.decodeHtml)(title).replace(/[_ ]+/gu, ' ').trim();
|
|
104
|
+
if (subpage) {
|
|
105
|
+
this.#ns = 0;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
let ns = defaultNs;
|
|
109
|
+
if (title.startsWith(':')) {
|
|
110
|
+
ns = 0;
|
|
111
|
+
title = title.slice(1).trim();
|
|
112
|
+
}
|
|
113
|
+
/* NOT FOR BROWSER */
|
|
114
|
+
const iw = defaultNs ? null : index_1.default.isInterwiki(title, config);
|
|
115
|
+
if (iw) {
|
|
116
|
+
this.interwiki = iw[1].toLowerCase();
|
|
117
|
+
title = title.slice(iw.indices[0][1]);
|
|
118
|
+
}
|
|
119
|
+
/* NOT FOR BROWSER END */
|
|
120
|
+
const m = title.split(':');
|
|
121
|
+
if (m.length > 1) {
|
|
122
|
+
const k = m[0].trim().toLowerCase(), id = Object.prototype.hasOwnProperty.call(config.nsid, k) && config.nsid[k];
|
|
123
|
+
if (id) {
|
|
124
|
+
ns = id;
|
|
125
|
+
title = m.slice(1).join(':').trim();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
this.#ns = ns;
|
|
129
|
+
}
|
|
130
|
+
const i = title.indexOf('#');
|
|
131
|
+
if (i !== -1) {
|
|
132
|
+
let fragment = title.slice(i + 1).trimEnd();
|
|
133
|
+
if (fragment.includes('%')) {
|
|
134
|
+
try {
|
|
135
|
+
fragment = (0, string_1.rawurldecode)(fragment);
|
|
136
|
+
}
|
|
137
|
+
catch { }
|
|
138
|
+
}
|
|
139
|
+
this.#fragment = fragment.replace(/ /gu, '_');
|
|
140
|
+
title = title.slice(0, i).trim();
|
|
141
|
+
}
|
|
142
|
+
this.valid = Boolean(title || this.interwiki || selfLink && this.ns === 0 && this.#fragment !== undefined)
|
|
143
|
+
&& (0, string_1.decodeHtml)(title) === title
|
|
144
|
+
&& !/^:|\0\d+[eh!+-]\x7F|[<>[\]{}|\n]|%[\da-f]{2}|(?:^|\/)\.{1,2}(?:$|\/)/iu.test(subpage ? /^(?:\.\.\/)+(.*)/u.exec(title)[1] : title);
|
|
145
|
+
this.main = title;
|
|
146
|
+
Object.defineProperties(this, {
|
|
147
|
+
encoded: { enumerable: false, writable: false },
|
|
148
|
+
/* NOT FOR BROWSER */
|
|
149
|
+
valid: { writable: false },
|
|
150
|
+
conversionTable: { enumerable: false },
|
|
151
|
+
redirects: { enumerable: false },
|
|
152
|
+
});
|
|
153
|
+
this.#namespaces = config.namespaces;
|
|
154
|
+
this.#path = config.articlePath || '/wiki/$1';
|
|
155
|
+
}
|
|
156
|
+
/** @private */
|
|
157
|
+
toString(display) {
|
|
158
|
+
return `${display ? this.title.replace(/_/gu, ' ') : this.title}${this.#fragment === undefined
|
|
159
|
+
&& this.#redirectFragment === undefined
|
|
160
|
+
? ''
|
|
161
|
+
: `#${this.#fragment
|
|
162
|
+
?? this.#redirectFragment}`}`;
|
|
163
|
+
}
|
|
164
|
+
/** 检测是否是重定向 */
|
|
165
|
+
getRedirection() {
|
|
166
|
+
const prefix = this.interwiki + (this.interwiki && ':') + this.prefix;
|
|
167
|
+
let title = (prefix + this.main).replace(/ /gu, '_');
|
|
168
|
+
/* NOT FOR BROWSER */
|
|
169
|
+
let redirected = this.#redirect(title);
|
|
170
|
+
if (redirected) {
|
|
171
|
+
return [true, redirected];
|
|
172
|
+
}
|
|
173
|
+
this.autoConvert();
|
|
174
|
+
title = (prefix + this.main).replaceAll(' ', '_');
|
|
175
|
+
redirected = this.#redirect(title);
|
|
176
|
+
if (redirected) {
|
|
177
|
+
return [true, redirected];
|
|
178
|
+
}
|
|
179
|
+
/* NOT FOR BROWSER END */
|
|
180
|
+
return [false, title];
|
|
181
|
+
}
|
|
182
|
+
/** @private */
|
|
183
|
+
setFragment(fragment) {
|
|
184
|
+
this.#fragment = fragment;
|
|
185
|
+
}
|
|
186
|
+
/* NOT FOR BROWSER */
|
|
187
|
+
/**
|
|
188
|
+
* 处理重定向
|
|
189
|
+
* @param title 原标题
|
|
190
|
+
*/
|
|
191
|
+
#redirect(title) {
|
|
192
|
+
const media = title.startsWith('Media:');
|
|
193
|
+
if (media) {
|
|
194
|
+
title = `File:${title.slice(6)}`;
|
|
195
|
+
}
|
|
196
|
+
const redirected = this.redirects.get(title);
|
|
197
|
+
if (redirected) {
|
|
198
|
+
[title, this.#redirectFragment] = redirected.split('#', 2);
|
|
199
|
+
return media ? title.replace(/^File:/u, 'Media:') : title;
|
|
200
|
+
}
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
/** 执行单向转换 */
|
|
204
|
+
autoConvert() {
|
|
205
|
+
const { conversionTable } = this;
|
|
206
|
+
if (conversionTable.size > 0) {
|
|
207
|
+
const regex = new RegExp([...conversionTable.keys()].sort().reverse().map(string_1.escapeRegExp).join('|'), 'gu');
|
|
208
|
+
this.main = this.main.replace(regex, p => conversionTable.get(p));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** 转换为主页面 */
|
|
212
|
+
toSubjectPage() {
|
|
213
|
+
if (this.isTalkPage()) {
|
|
214
|
+
this.#ns--;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/** 转换为讨论页面 */
|
|
218
|
+
toTalkPage() {
|
|
219
|
+
if (!this.isTalkPage()) {
|
|
220
|
+
this.#ns++;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** 是否是讨论页 */
|
|
224
|
+
isTalkPage() {
|
|
225
|
+
return this.ns % 2 === 1;
|
|
226
|
+
}
|
|
227
|
+
/** 转换为上一级页面 */
|
|
228
|
+
toBasePage() {
|
|
229
|
+
this.main = this.main.replace(/\/[^/]*$/u, '');
|
|
230
|
+
}
|
|
231
|
+
/** 转换为根页面 */
|
|
232
|
+
toRootPage() {
|
|
233
|
+
this.main = this.main.replace(/\/.*/u, '');
|
|
234
|
+
}
|
|
235
|
+
/** 生成URL */
|
|
236
|
+
getUrl() {
|
|
237
|
+
const { title, fragment } = this;
|
|
238
|
+
if (title) {
|
|
239
|
+
return this.#path.replace('$1', `${encodeURIComponent(title)}${fragment === undefined && this.#redirectFragment === undefined
|
|
240
|
+
? ''
|
|
241
|
+
: `#${encodeURIComponent(fragment ?? this.#redirectFragment)}`}`);
|
|
242
|
+
}
|
|
243
|
+
return fragment === undefined ? '' : `#${encodeURIComponent(fragment)}`;
|
|
244
|
+
}
|
|
245
|
+
/** @private */
|
|
246
|
+
getTitleAttr() {
|
|
247
|
+
return this.title.replace(/^Media:/u, '').replace(/["_]/gu, p => p === '"' ? '"' : ' ');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.Title = Title;
|
|
251
|
+
constants_1.classes['Title'] = __filename;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface AttributesParentBase {
|
|
2
|
+
/** getAttrs()方法的getter写法 */
|
|
3
|
+
attributes: Record<string, string | true>;
|
|
4
|
+
/** 以字符串表示的class属性 */
|
|
5
|
+
className: string;
|
|
6
|
+
/** 以Set表示的class属性 */
|
|
7
|
+
classList: Set<string>;
|
|
8
|
+
/** id属性 */
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* 获取AttributesToken子节点的属性
|
|
12
|
+
* @param key 属性键
|
|
13
|
+
*/
|
|
14
|
+
getAttr(key: string): string | true | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* AttributesToken子节点是否具有某属性
|
|
17
|
+
* @param key 属性键
|
|
18
|
+
*/
|
|
19
|
+
hasAttr(key: string): boolean;
|
|
20
|
+
/** 列举AttributesToken子节点的属性键 */
|
|
21
|
+
getAttrNames(): Set<string>;
|
|
22
|
+
/** 获取AttributesToken子节点的全部标签属性 */
|
|
23
|
+
getAttrs(): Record<string, string | true>;
|
|
24
|
+
/**
|
|
25
|
+
* 对AttributesToken子节点设置属性
|
|
26
|
+
* @param key 属性键
|
|
27
|
+
* @param value 属性值
|
|
28
|
+
* @param prop 属性对象
|
|
29
|
+
*/
|
|
30
|
+
setAttr(key: string, value: string | boolean): void;
|
|
31
|
+
setAttr(prop: Record<string, string | boolean>): void;
|
|
32
|
+
/**
|
|
33
|
+
* 移除AttributesToken子节点的某属性
|
|
34
|
+
* @param key 属性键
|
|
35
|
+
*/
|
|
36
|
+
removeAttr(key: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* 开关AttributesToken子节点的某属性
|
|
39
|
+
* @param key 属性键
|
|
40
|
+
* @param force 强制开启或关闭
|
|
41
|
+
*/
|
|
42
|
+
toggleAttr(key: string, force?: boolean): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 子节点含有AttributesToken的类
|
|
46
|
+
* @param i AttributesToken子节点的位置
|
|
47
|
+
* @param constructor 基类
|
|
48
|
+
* @param _ context
|
|
49
|
+
*/
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.attributesParent = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
5
|
+
/* NOT FOR BROWSER */
|
|
6
|
+
const constants_1 = require("../util/constants");
|
|
7
|
+
/**
|
|
8
|
+
* 子节点含有AttributesToken的类
|
|
9
|
+
* @param i AttributesToken子节点的位置
|
|
10
|
+
* @param constructor 基类
|
|
11
|
+
* @param _ context
|
|
12
|
+
*/
|
|
13
|
+
const attributesParent = (i = 0) => (constructor, _) => {
|
|
14
|
+
/** 子节点含有AttributesToken的类 */
|
|
15
|
+
class AttributesParent extends constructor {
|
|
16
|
+
/** AttributesToken子节点 */
|
|
17
|
+
get #attributesChild() {
|
|
18
|
+
return this.childNodes[i];
|
|
19
|
+
}
|
|
20
|
+
/* NOT FOR BROWSER */
|
|
21
|
+
/** @implements */
|
|
22
|
+
get attributes() {
|
|
23
|
+
return this.#attributesChild.attributes;
|
|
24
|
+
}
|
|
25
|
+
set attributes(attributes) {
|
|
26
|
+
this.#attributesChild.attributes = attributes;
|
|
27
|
+
}
|
|
28
|
+
/** @implements */
|
|
29
|
+
get className() {
|
|
30
|
+
return this.#attributesChild.className;
|
|
31
|
+
}
|
|
32
|
+
set className(className) {
|
|
33
|
+
this.#attributesChild.className = className;
|
|
34
|
+
}
|
|
35
|
+
/** @implements */
|
|
36
|
+
get classList() {
|
|
37
|
+
return this.#attributesChild.classList;
|
|
38
|
+
}
|
|
39
|
+
/** @implements */
|
|
40
|
+
get id() {
|
|
41
|
+
return this.#attributesChild.id;
|
|
42
|
+
}
|
|
43
|
+
set id(id) {
|
|
44
|
+
this.#attributesChild.id = id;
|
|
45
|
+
}
|
|
46
|
+
/* NOT FOR BROWSER END */
|
|
47
|
+
/** @implements */
|
|
48
|
+
getAttr(key) {
|
|
49
|
+
return this.#attributesChild.getAttr(key);
|
|
50
|
+
}
|
|
51
|
+
/* NOT FOR BROWSER */
|
|
52
|
+
/** @implements */
|
|
53
|
+
hasAttr(key) {
|
|
54
|
+
return this.#attributesChild.hasAttr(key);
|
|
55
|
+
}
|
|
56
|
+
/** @implements */
|
|
57
|
+
getAttrNames() {
|
|
58
|
+
return this.#attributesChild.getAttrNames();
|
|
59
|
+
}
|
|
60
|
+
/** @implements */
|
|
61
|
+
getAttrs() {
|
|
62
|
+
return this.#attributesChild.getAttrs();
|
|
63
|
+
}
|
|
64
|
+
setAttr(keyOrProp, value) {
|
|
65
|
+
this.#attributesChild.setAttr(keyOrProp, value);
|
|
66
|
+
}
|
|
67
|
+
/** @implements */
|
|
68
|
+
removeAttr(key) {
|
|
69
|
+
this.#attributesChild.removeAttr(key);
|
|
70
|
+
}
|
|
71
|
+
/** @implements */
|
|
72
|
+
toggleAttr(key, force) {
|
|
73
|
+
this.#attributesChild.toggleAttr(key, force);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
(0, debug_1.mixin)(AttributesParent, constructor);
|
|
77
|
+
return AttributesParent;
|
|
78
|
+
};
|
|
79
|
+
exports.attributesParent = attributesParent;
|
|
80
|
+
constants_1.mixins['attributesParent'] = __filename;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fixedToken = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
5
|
+
const constants_1 = require("../util/constants");
|
|
6
|
+
/**
|
|
7
|
+
* 不可增删子节点的类
|
|
8
|
+
* @param constructor 基类
|
|
9
|
+
* @param _ context
|
|
10
|
+
*/
|
|
11
|
+
const fixedToken = (constructor, _) => {
|
|
12
|
+
/** 不可增删子节点的类 */
|
|
13
|
+
class FixedToken extends constructor {
|
|
14
|
+
/** @private */
|
|
15
|
+
get fixed() {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
/** @override */
|
|
19
|
+
removeAt() {
|
|
20
|
+
this.constructorError('cannot remove child nodes');
|
|
21
|
+
}
|
|
22
|
+
insertAt(token, i) {
|
|
23
|
+
return debug_1.Shadow.running
|
|
24
|
+
? super.insertAt(token, i)
|
|
25
|
+
: this.constructorError('cannot insert child nodes');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
(0, debug_1.mixin)(FixedToken, constructor);
|
|
29
|
+
return FixedToken;
|
|
30
|
+
};
|
|
31
|
+
exports.fixedToken = fixedToken;
|
|
32
|
+
constants_1.mixins['fixedToken'] = __filename;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ConverterFlagsToken } from '../src/converterFlags';
|
|
2
|
+
export interface FlagsParentBase {
|
|
3
|
+
/** 所有转换类型标记 */
|
|
4
|
+
flags: Set<string>;
|
|
5
|
+
/** 获取所有转换类型标记 */
|
|
6
|
+
getAllFlags(): Set<string>;
|
|
7
|
+
/** 获取有效的转换类型标记 */
|
|
8
|
+
getEffectiveFlags(): Set<string>;
|
|
9
|
+
/** 获取未知的转换类型标记 */
|
|
10
|
+
getUnknownFlags(): Set<string>;
|
|
11
|
+
/** 获取指定语言变体的转换标记 */
|
|
12
|
+
getVariantFlags(): Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* 是否具有某转换类型标记
|
|
15
|
+
* @param flag 转换类型标记
|
|
16
|
+
*/
|
|
17
|
+
hasFlag(flag: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 是否具有某有效的转换类型标记
|
|
20
|
+
* @param flag 转换类型标记
|
|
21
|
+
*/
|
|
22
|
+
hasEffectiveFlag(flag: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 移除转换类型标记
|
|
25
|
+
* @param flag 转换类型标记
|
|
26
|
+
*/
|
|
27
|
+
removeFlag(flag: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* 设置转换类型标记
|
|
30
|
+
* @param flag 转换类型标记
|
|
31
|
+
*/
|
|
32
|
+
setFlag(flag: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* 开关某转换类型标记
|
|
35
|
+
* @param flag 转换类型标记
|
|
36
|
+
*/
|
|
37
|
+
toggleFlag(flag: string): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* ConverterToken
|
|
41
|
+
* @param constructor 基类
|
|
42
|
+
* @param _ context
|
|
43
|
+
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flagsParent = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
5
|
+
const constants_1 = require("../util/constants");
|
|
6
|
+
/* NOT FOR BROWSER END */
|
|
7
|
+
/**
|
|
8
|
+
* ConverterToken
|
|
9
|
+
* @param constructor 基类
|
|
10
|
+
* @param _ context
|
|
11
|
+
*/
|
|
12
|
+
const flagsParent = (constructor, _) => {
|
|
13
|
+
/** 子节点含有ConverterFlagsToken的类 */
|
|
14
|
+
class FlagsParent extends constructor {
|
|
15
|
+
/* NOT FOR BROWSER */
|
|
16
|
+
/** @implements */
|
|
17
|
+
get flags() {
|
|
18
|
+
return this.firstChild.flags;
|
|
19
|
+
}
|
|
20
|
+
set flags(value) {
|
|
21
|
+
this.firstChild.flags = value;
|
|
22
|
+
}
|
|
23
|
+
/** @implements */
|
|
24
|
+
getAllFlags() {
|
|
25
|
+
return this.firstChild.getAllFlags();
|
|
26
|
+
}
|
|
27
|
+
/** @implements */
|
|
28
|
+
getEffectiveFlags() {
|
|
29
|
+
return this.firstChild.getEffectiveFlags();
|
|
30
|
+
}
|
|
31
|
+
/** @implements */
|
|
32
|
+
getUnknownFlags() {
|
|
33
|
+
return this.firstChild.getUnknownFlags();
|
|
34
|
+
}
|
|
35
|
+
/** @implements */
|
|
36
|
+
getVariantFlags() {
|
|
37
|
+
return this.firstChild.getVariantFlags();
|
|
38
|
+
}
|
|
39
|
+
/** @implements */
|
|
40
|
+
hasFlag(flag) {
|
|
41
|
+
return this.firstChild.hasFlag(flag);
|
|
42
|
+
}
|
|
43
|
+
/** @implements */
|
|
44
|
+
hasEffectiveFlag(flag) {
|
|
45
|
+
return this.firstChild.hasEffectiveFlag(flag);
|
|
46
|
+
}
|
|
47
|
+
/** @implements */
|
|
48
|
+
removeFlag(flag) {
|
|
49
|
+
this.firstChild.removeFlag(flag);
|
|
50
|
+
}
|
|
51
|
+
/** @implements */
|
|
52
|
+
setFlag(flag) {
|
|
53
|
+
this.firstChild.setFlag(flag);
|
|
54
|
+
}
|
|
55
|
+
/** @implements */
|
|
56
|
+
toggleFlag(flag) {
|
|
57
|
+
this.firstChild.toggleFlag(flag);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
(0, debug_1.mixin)(FlagsParent, constructor);
|
|
61
|
+
return FlagsParent;
|
|
62
|
+
};
|
|
63
|
+
exports.flagsParent = flagsParent;
|
|
64
|
+
constants_1.mixins['flagsParent'] = __filename;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hiddenToken = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
5
|
+
/* NOT FOR BROWSER */
|
|
6
|
+
const constants_1 = require("../util/constants");
|
|
7
|
+
/* NOT FOR BROWSER END */
|
|
8
|
+
/**
|
|
9
|
+
* 解析后不可见的类
|
|
10
|
+
* @param linter 是否覆写 lint 方法
|
|
11
|
+
* @param html 是否覆写 toHtml 方法
|
|
12
|
+
* @param constructor 基类
|
|
13
|
+
* @param _ context
|
|
14
|
+
*/
|
|
15
|
+
const hiddenToken = (linter = true, html = true) => (constructor, _) => {
|
|
16
|
+
/** 解析后不可见的类 */
|
|
17
|
+
class AnyHiddenToken extends constructor {
|
|
18
|
+
/** 没有可见部分 */
|
|
19
|
+
text() {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
lint(start) {
|
|
23
|
+
// @ts-expect-error private argument
|
|
24
|
+
return linter ? [] : super.lint(start);
|
|
25
|
+
}
|
|
26
|
+
/* NOT FOR BROWSER */
|
|
27
|
+
/** @private */
|
|
28
|
+
dispatchEvent() {
|
|
29
|
+
//
|
|
30
|
+
}
|
|
31
|
+
toHtmlInternal() {
|
|
32
|
+
return html ? '' : super.toHtmlInternal();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
(0, debug_1.mixin)(AnyHiddenToken, constructor);
|
|
36
|
+
return AnyHiddenToken;
|
|
37
|
+
};
|
|
38
|
+
exports.hiddenToken = hiddenToken;
|
|
39
|
+
constants_1.mixins['hiddenToken'] = __filename;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MagicLinkToken } from '../src/magicLink';
|
|
2
|
+
export interface MagicLinkParentBase {
|
|
3
|
+
/** 协议 */
|
|
4
|
+
protocol: string | undefined;
|
|
5
|
+
/** 和内链保持一致 */
|
|
6
|
+
link: string;
|
|
7
|
+
/** 获取网址 */
|
|
8
|
+
getUrl(): URL;
|
|
9
|
+
/**
|
|
10
|
+
* 设置链接目标
|
|
11
|
+
* @param url 网址
|
|
12
|
+
*/
|
|
13
|
+
setTarget(url: string): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ExtLinkToken
|
|
17
|
+
* @param constructor 基类
|
|
18
|
+
* @param _ context
|
|
19
|
+
*/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.magicLinkParent = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
5
|
+
const constants_1 = require("../util/constants");
|
|
6
|
+
/* NOT FOR BROWSER END */
|
|
7
|
+
/**
|
|
8
|
+
* ExtLinkToken
|
|
9
|
+
* @param constructor 基类
|
|
10
|
+
* @param _ context
|
|
11
|
+
*/
|
|
12
|
+
const magicLinkParent = (constructor, _) => {
|
|
13
|
+
/** 子节点含有MagicLinkParent的类 */
|
|
14
|
+
class MagicLinkParent extends constructor {
|
|
15
|
+
/* NOT FOR BROWSER */
|
|
16
|
+
/** @implements */
|
|
17
|
+
get protocol() {
|
|
18
|
+
return this.firstChild.protocol;
|
|
19
|
+
}
|
|
20
|
+
set protocol(value) {
|
|
21
|
+
this.firstChild.protocol = value;
|
|
22
|
+
}
|
|
23
|
+
/** @implements */
|
|
24
|
+
get link() {
|
|
25
|
+
return this.firstChild.link;
|
|
26
|
+
}
|
|
27
|
+
set link(url) {
|
|
28
|
+
this.firstChild.link = url;
|
|
29
|
+
}
|
|
30
|
+
/** @implements */
|
|
31
|
+
getUrl() {
|
|
32
|
+
return this.firstChild.getUrl();
|
|
33
|
+
}
|
|
34
|
+
/** @implements */
|
|
35
|
+
setTarget(url) {
|
|
36
|
+
this.firstChild.setTarget(url);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
(0, debug_1.mixin)(MagicLinkParent, constructor);
|
|
40
|
+
return MagicLinkParent;
|
|
41
|
+
};
|
|
42
|
+
exports.magicLinkParent = magicLinkParent;
|
|
43
|
+
constants_1.mixins['magicLinkParent'] = __filename;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.singleLine = void 0;
|
|
4
|
+
const debug_1 = require("../util/debug");
|
|
5
|
+
const constants_1 = require("../util/constants");
|
|
6
|
+
/**
|
|
7
|
+
* 不可包含换行符的类
|
|
8
|
+
* @param constructor 基类
|
|
9
|
+
* @param _ context
|
|
10
|
+
*/
|
|
11
|
+
const singleLine = (constructor, _) => {
|
|
12
|
+
/** 不可包含换行符的类 */
|
|
13
|
+
class SingleLineToken extends constructor {
|
|
14
|
+
toString(skip) {
|
|
15
|
+
return super.toString(skip).replaceAll('\n', ' ');
|
|
16
|
+
}
|
|
17
|
+
text() {
|
|
18
|
+
return super.text().replaceAll('\n', ' ');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
(0, debug_1.mixin)(SingleLineToken, constructor);
|
|
22
|
+
return SingleLineToken;
|
|
23
|
+
};
|
|
24
|
+
exports.singleLine = singleLine;
|
|
25
|
+
constants_1.mixins['singleLine'] = __filename;
|