wikiparser-node 1.35.0 → 1.35.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.
Files changed (71) hide show
  1. package/README.md +29 -28
  2. package/bundle/bundle-es8.min.js +29 -29
  3. package/bundle/bundle-lsp.min.js +34 -34
  4. package/bundle/bundle.min.js +24 -24
  5. package/config/default.json +3 -0
  6. package/config/enwiki.json +3 -0
  7. package/config/jawiki.json +3 -0
  8. package/config/minimum.json +1 -0
  9. package/config/zhwiki.json +3 -0
  10. package/coverage/badge.svg +1 -1
  11. package/data/signatures.json +13 -0
  12. package/dist/addon/attribute.js +13 -12
  13. package/dist/addon/link.js +3 -3
  14. package/dist/addon/token.js +4 -4
  15. package/dist/addon/transclude.js +8 -8
  16. package/dist/base.d.mts +3 -1
  17. package/dist/base.d.ts +3 -1
  18. package/dist/bin/config.js +3 -3
  19. package/dist/index.js +21 -13
  20. package/dist/lib/document.js +14 -12
  21. package/dist/lib/element.d.ts +2 -1
  22. package/dist/lib/element.js +17 -13
  23. package/dist/lib/lintConfig.js +7 -6
  24. package/dist/lib/lsp.js +10 -8
  25. package/dist/lib/node.js +8 -6
  26. package/dist/lib/range.js +17 -13
  27. package/dist/lib/ranges.js +25 -26
  28. package/dist/lib/text.js +14 -13
  29. package/dist/lib/title.js +7 -6
  30. package/dist/parser/braces.js +5 -7
  31. package/dist/parser/hrAndDoubleUnderscore.js +2 -2
  32. package/dist/parser/list.js +1 -1
  33. package/dist/parser/magicLinks.js +2 -1
  34. package/dist/parser/selector.js +15 -15
  35. package/dist/src/arg.js +4 -4
  36. package/dist/src/atom.js +1 -1
  37. package/dist/src/attribute.js +5 -4
  38. package/dist/src/attributes.js +10 -7
  39. package/dist/src/converter.js +4 -4
  40. package/dist/src/converterRule.js +2 -2
  41. package/dist/src/heading.js +2 -2
  42. package/dist/src/imageParameter.js +12 -3
  43. package/dist/src/index.js +15 -10
  44. package/dist/src/link/base.js +10 -7
  45. package/dist/src/link/category.js +3 -3
  46. package/dist/src/link/file.js +6 -5
  47. package/dist/src/link/index.js +5 -3
  48. package/dist/src/multiLine/gallery.js +2 -2
  49. package/dist/src/nowiki/comment.js +4 -3
  50. package/dist/src/nowiki/doubleUnderscore.js +1 -1
  51. package/dist/src/nowiki/listBase.js +2 -2
  52. package/dist/src/nowiki/noinclude.js +1 -1
  53. package/dist/src/nowiki/quote.js +3 -3
  54. package/dist/src/onlyinclude.js +1 -1
  55. package/dist/src/parameter.js +2 -2
  56. package/dist/src/table/index.js +9 -8
  57. package/dist/src/table/td.js +5 -5
  58. package/dist/src/table/trBase.js +4 -4
  59. package/dist/src/tag/html.js +9 -9
  60. package/dist/src/tag/index.js +6 -5
  61. package/dist/src/tag/tvar.js +4 -3
  62. package/dist/src/tagPair/index.js +6 -4
  63. package/dist/src/transclude.js +3 -3
  64. package/dist/util/debug.js +3 -2
  65. package/dist/util/diff.js +11 -6
  66. package/dist/util/selector.js +1 -1
  67. package/dist/util/string.js +2 -2
  68. package/extensions/dist/base.js +12 -4
  69. package/extensions/dist/codejar.js +1 -1
  70. package/package.json +27 -27
  71. package/logo.png +0 -0
@@ -179,9 +179,9 @@ let GalleryToken = (() => {
179
179
  }
180
180
  }
181
181
  /** @private */
182
- json(_, start = this.getAbsoluteIndex()) {
182
+ json(_, depth, start = this.getAbsoluteIndex()) {
183
183
  LSP: {
184
- const json = super.json(undefined, start);
184
+ const json = super.json(undefined, depth, start);
185
185
  Object.assign(json, { widths: this.widths, heights: this.heights });
186
186
  return json;
187
187
  }
@@ -92,7 +92,7 @@ let CommentToken = (() => {
92
92
  return [];
93
93
  }
94
94
  const rule = 'unclosed-comment', { lintConfig } = index_1.default, s = lintConfig.getSeverity(rule);
95
- /* istanbul ignore if */
95
+ /* c8 ignore next 3 */
96
96
  if (!s) {
97
97
  return [];
98
98
  }
@@ -106,11 +106,12 @@ let CommentToken = (() => {
106
106
  /** @private */
107
107
  toString(skip) {
108
108
  /* NOT FOR BROWSER */
109
- /* istanbul ignore if */
109
+ /* c8 ignore start */
110
110
  if (!this.closed && this.nextSibling) {
111
111
  index_1.default.error('Auto-closing HTML comment', this);
112
112
  this.closed = true;
113
113
  }
114
+ /* c8 ignore stop */
114
115
  /* NOT FOR BROWSER END */
115
116
  return skip ? '' : `<!--${this.innerText}${this.closed ? '-->' : ''}`;
116
117
  }
@@ -126,7 +127,7 @@ let CommentToken = (() => {
126
127
  }
127
128
  /** @private */
128
129
  setText(text) {
129
- /* istanbul ignore if */
130
+ /* c8 ignore next 3 */
130
131
  if (text.includes('-->')) {
131
132
  throw new RangeError('Do not contain "-->" in the comment!');
132
133
  }
@@ -77,7 +77,7 @@ let DoubleUnderscoreToken = (() => {
77
77
  */
78
78
  constructor(word, sensitive, fullWidth, config, accum) {
79
79
  super(word, config, accum);
80
- const lc = word.toLowerCase(), { doubleUnderscore: [, , iAlias, sAlias] } = config;
80
+ const lc = word.toLowerCase(), [, , iAlias, sAlias] = config.doubleUnderscore;
81
81
  this.setAttribute('name', (sensitive ? sAlias?.[word]?.toLowerCase() : iAlias?.[lc]) ?? lc);
82
82
  this.#fullWidth = fullWidth;
83
83
  /* NOT FOR BROWSER */
@@ -47,9 +47,9 @@ class ListBaseToken extends base_1.NowikiBaseToken {
47
47
  }
48
48
  /* NOT FOR BROWSER END */
49
49
  /** @private */
50
- json(_, start = this.getAbsoluteIndex()) {
50
+ json(_, depth, start = this.getAbsoluteIndex()) {
51
51
  LSP: {
52
- const json = super.json(undefined, start), { indent } = this;
52
+ const json = super.json(undefined, depth, start), { indent } = this;
53
53
  if (indent) {
54
54
  json['indent'] = indent;
55
55
  }
@@ -111,7 +111,7 @@ let NoincludeToken = (() => {
111
111
  return new C(this.innerText, this.getAttribute('config'), [], this.#fixed);
112
112
  });
113
113
  }
114
- /* istanbul ignore next */
114
+ /* c8 ignore start */
115
115
  setText(str) {
116
116
  return this.#fixed ? this.constructorError('cannot change the text content') : super.setText(str);
117
117
  }
@@ -132,7 +132,7 @@ let QuoteToken = (() => {
132
132
  startCol: endCol - length,
133
133
  endCol,
134
134
  };
135
- if (computeEditInfo) {
135
+ if (computeEditInfo && bold) {
136
136
  eNew.suggestions = [
137
137
  (0, lint_1.fixByEscape)(startIndex, '&apos;', length),
138
138
  (0, lint_1.fixByRemove)(eNew),
@@ -152,9 +152,9 @@ let QuoteToken = (() => {
152
152
  }
153
153
  }
154
154
  /** @private */
155
- json(_, start = this.getAbsoluteIndex()) {
155
+ json(_, depth, start = this.getAbsoluteIndex()) {
156
156
  LSP: {
157
- const json = super.json(undefined, start);
157
+ const json = super.json(undefined, depth, start);
158
158
  Object.assign(json, { bold: this.bold, italic: this.italic });
159
159
  return json;
160
160
  }
@@ -81,7 +81,7 @@ let OnlyincludeToken = (() => {
81
81
  }
82
82
  /** @throws `RangeError` 不允许包含`</onlyinclude>` */
83
83
  set innerText(text) {
84
- /* istanbul ignore if */
84
+ /* c8 ignore next 3 */
85
85
  if (text.includes('</onlyinclude>')) {
86
86
  throw new RangeError('"</onlyinclude>" is not allowed in the text!');
87
87
  }
@@ -204,9 +204,9 @@ let ParameterToken = (() => {
204
204
  PRINT: return super.print({ sep: this.anon ? '' : '=' });
205
205
  }
206
206
  /** @private */
207
- json(_, start = this.getAbsoluteIndex()) {
207
+ json(_, depth, start = this.getAbsoluteIndex()) {
208
208
  LSP: {
209
- const json = super.json(undefined, start);
209
+ const json = super.json(undefined, depth, start);
210
210
  Object.assign(json, { anon: this.anon }, this.duplicated && { duplicated: true });
211
211
  return json;
212
212
  }
@@ -253,13 +253,14 @@ let TableToken = (() => {
253
253
  && (isRow
254
254
  || force && nRows === 0)) {
255
255
  return this;
256
- /* NOT FOR BROWSER */
257
256
  }
258
- else /* istanbul ignore if */ if (n < 0 || n > nRows || n === nRows && !insert) {
257
+ /* NOT FOR BROWSER */
258
+ /* c8 ignore next 3 */
259
+ if (n < 0 || n > nRows || n === nRows && !insert) {
259
260
  throw new RangeError(`The table does not have row ${n}!`);
260
- /* NOT FOR BROWSER END */
261
261
  }
262
- else if (isRow) {
262
+ /* NOT FOR BROWSER END */
263
+ if (isRow) {
263
264
  n--;
264
265
  }
265
266
  for (const child of this.childNodes.slice(2)) {
@@ -280,9 +281,9 @@ let TableToken = (() => {
280
281
  }
281
282
  }
282
283
  /** @private */
283
- json(_, start = this.getAbsoluteIndex()) {
284
+ json(_, depth, start = this.getAbsoluteIndex()) {
284
285
  LSP: {
285
- const json = super.json(undefined, start);
286
+ const json = super.json(undefined, depth, start);
286
287
  json['closed'] = this.closed;
287
288
  return json;
288
289
  }
@@ -297,12 +298,12 @@ let TableToken = (() => {
297
298
  insertAt(token, i = this.length) {
298
299
  i += i < 0 ? this.length : 0;
299
300
  const previous = this.childNodes[i - 1];
300
- /* istanbul ignore else */
301
301
  if (typeof token !== 'string' && token.is('td') && previous?.is('tr')) {
302
302
  index_1.default.warn('The table cell is inserted into the current row instead.');
303
303
  return previous.insertAt(token);
304
304
  }
305
- else if (i > 0 && token instanceof syntax_1.SyntaxToken && token.pattern !== closingPattern) {
305
+ /* c8 ignore next 3 */
306
+ if (i > 0 && token instanceof syntax_1.SyntaxToken && token.pattern !== closingPattern) {
306
307
  throw new SyntaxError(`The closing part of the table is invalid: ${(0, string_1.noWrap)(token.toString())}`);
307
308
  }
308
309
  return super.insertAt(token, i);
@@ -195,7 +195,7 @@ let TdToken = (() => {
195
195
  /* NOT FOR BROWSER */
196
196
  this.#correct();
197
197
  /* NOT FOR BROWSER END */
198
- const { childNodes: [syntax, attr, inner] } = this;
198
+ const [syntax, attr, inner] = this.childNodes;
199
199
  return syntax.toString(skip) + attr.toString(skip) + this.#innerSyntax + inner.toString(skip);
200
200
  }
201
201
  /** @private */
@@ -203,7 +203,7 @@ let TdToken = (() => {
203
203
  /* NOT FOR BROWSER */
204
204
  this.#correct();
205
205
  /* NOT FOR BROWSER END */
206
- const { childNodes: [syntax, attr, inner] } = this;
206
+ const [syntax, attr, inner] = this.childNodes;
207
207
  return syntax.text() + attr.text() + this.#innerSyntax + inner.text();
208
208
  }
209
209
  /** @private */
@@ -276,14 +276,14 @@ let TdToken = (() => {
276
276
  /** @private */
277
277
  print() {
278
278
  PRINT: {
279
- const { childNodes: [syntax, attr, inner] } = this;
279
+ const [syntax, attr, inner] = this.childNodes;
280
280
  return `<span class="wpb-td">${syntax.print()}${attr.print()}${this.#innerSyntax}${inner.print()}</span>`;
281
281
  }
282
282
  }
283
283
  /** @private */
284
- json(_, start = this.getAbsoluteIndex()) {
284
+ json(_, depth, start = this.getAbsoluteIndex()) {
285
285
  LSP: {
286
- const json = super.json(undefined, start), { rowspan, colspan } = this;
286
+ const json = super.json(undefined, depth, start), { rowspan, colspan } = this;
287
287
  Object.assign(json, { subtype: this.subtype }, rowspan !== 1 && { rowspan }, colspan !== 1 && { colspan });
288
288
  return json;
289
289
  }
@@ -95,7 +95,7 @@ let TrBaseToken = (() => {
95
95
  getNthCol(n, insert) {
96
96
  const nCols = this.getColCount();
97
97
  n += n < 0 ? nCols : 0;
98
- /* istanbul ignore if */
98
+ /* c8 ignore next 3 */
99
99
  if (n < 0 || n > nCols || n === nCols && !insert) {
100
100
  throw new RangeError(`There is no cell at position ${n}!`);
101
101
  }
@@ -118,7 +118,7 @@ let TrBaseToken = (() => {
118
118
  }
119
119
  /** 修复简单的表格语法错误 */
120
120
  #correct() {
121
- const { childNodes: [, , child] } = this;
121
+ const [, , child] = this.childNodes;
122
122
  if (child?.constructor === index_2.Token) {
123
123
  const { firstChild } = child;
124
124
  if (firstChild?.type !== 'text') {
@@ -158,11 +158,11 @@ let TrBaseToken = (() => {
158
158
  */
159
159
  insertAt(token, i = this.length) {
160
160
  if (!debug_1.Shadow.running && !token.is('td')) {
161
- /* istanbul ignore next */
161
+ /* c8 ignore next 6 */
162
162
  if (this.is('tr')) {
163
163
  this.typeError('insertAt', 'TdToken');
164
164
  }
165
- else if (!token.is('tr')) {
165
+ if (!token.is('tr')) {
166
166
  this.typeError('insertAt', 'TrToken', 'TdToken');
167
167
  }
168
168
  }
@@ -119,7 +119,7 @@ let HtmlToken = (() => {
119
119
  else if (this.closing) {
120
120
  throw new Error('This is a closing tag!');
121
121
  }
122
- const { html: [tags] } = this.getAttribute('config');
122
+ const [tags] = this.getAttribute('config').html;
123
123
  if (tags.includes(this.name)) {
124
124
  throw new Error(`<${this.name}> tag cannot be self-closing!`);
125
125
  }
@@ -135,7 +135,7 @@ let HtmlToken = (() => {
135
135
  if (this.#selfClosing) {
136
136
  throw new Error('This is a self-closing tag!');
137
137
  }
138
- const { html: [, , tags] } = this.getAttribute('config');
138
+ const [, , tags] = this.getAttribute('config').html;
139
139
  if (tags.includes(this.name)) {
140
140
  throw new Error('This is a void tag!');
141
141
  }
@@ -156,7 +156,7 @@ let HtmlToken = (() => {
156
156
  }
157
157
  /** @private */
158
158
  text() {
159
- const { closing, selfClosing, name } = this, { html: [, , voidTags] } = this.getAttribute('config');
159
+ const { closing, selfClosing, name } = this, [, , voidTags] = this.getAttribute('config').html;
160
160
  if (voidTags.includes(name)) {
161
161
  return closing && name !== 'br' ? '' : super.text('/');
162
162
  }
@@ -197,7 +197,7 @@ let HtmlToken = (() => {
197
197
  }
198
198
  errors.push(e);
199
199
  }
200
- const { html: [, flexibleTags, voidTags] } = this.getAttribute('config'), isVoid = voidTags.includes(name), isFlexible = flexibleTags.includes(name), isNormal = !isVoid && !isFlexible;
200
+ const [, flexibleTags, voidTags] = this.getAttribute('config').html, isVoid = voidTags.includes(name), isFlexible = flexibleTags.includes(name), isNormal = !isVoid && !isFlexible;
201
201
  rule = 'unmatched-tag';
202
202
  if (closing && (selfClosing || isVoid) || selfClosing && isNormal) {
203
203
  s = lintConfig.getSeverity(rule, closing ? 'both' : 'selfClosing');
@@ -263,9 +263,9 @@ let HtmlToken = (() => {
263
263
  return key === 'invalid' ? (this.inTableAttrs() === 2) : super.getAttribute(key);
264
264
  }
265
265
  /** @private */
266
- json(_, start = this.getAbsoluteIndex()) {
266
+ json(_, depth, start = this.getAbsoluteIndex()) {
267
267
  LSP: {
268
- const json = super.json(undefined, start);
268
+ const json = super.json(undefined, depth, start);
269
269
  json['selfClosing'] = this.#selfClosing;
270
270
  return json;
271
271
  }
@@ -299,7 +299,7 @@ let HtmlToken = (() => {
299
299
  * @throws `Error` 无法修复无效自封闭标签
300
300
  */
301
301
  fix() {
302
- const { html: [normalTags] } = this.getAttribute('config'), { parentNode, name: tagName, firstChild, selfClosing } = this;
302
+ const [normalTags] = this.getAttribute('config').html, { parentNode, name: tagName, firstChild, selfClosing } = this;
303
303
  if (!parentNode || !selfClosing || !normalTags.includes(tagName)) {
304
304
  return;
305
305
  }
@@ -320,7 +320,7 @@ let HtmlToken = (() => {
320
320
  }
321
321
  /** @private */
322
322
  toHtmlInternal() {
323
- const { closing, name } = this, { html: [, selfClosingTags, voidTags] } = this.getAttribute('config'), tag = name + (closing ? '' : super.toHtmlInternal());
323
+ const { closing, name } = this, [, selfClosingTags, voidTags] = this.getAttribute('config').html, tag = name + (closing ? '' : super.toHtmlInternal());
324
324
  if (voidTags.includes(name)) {
325
325
  return closing && name !== 'br' ? '' : `<${tag}>`;
326
326
  }
@@ -341,7 +341,7 @@ let HtmlToken = (() => {
341
341
  }
342
342
  /** @private */
343
343
  getRange() {
344
- const { selfClosing, name } = this, { html: [, selfClosingTags, voidTags] } = this.getAttribute('config');
344
+ const { selfClosing, name } = this, [, selfClosingTags, voidTags] = this.getAttribute('config').html;
345
345
  if (voidTags.includes(name) || selfClosing && selfClosingTags.includes(name)) {
346
346
  return undefined;
347
347
  }
@@ -128,14 +128,15 @@ let TagToken = (() => {
128
128
  legacy, } = this;
129
129
  let isVoid = false, isFlexible = false;
130
130
  if (type === 'html') {
131
- const { html: [, flexibleTags, voidTags] } = this.getAttribute('config');
131
+ const [, flexibleTags, voidTags] = this.getAttribute('config').html;
132
132
  isVoid = voidTags.includes(name);
133
133
  isFlexible = flexibleTags.includes(name);
134
134
  }
135
135
  if (isVoid || isFlexible && selfClosing) { // 自封闭标签
136
136
  return this;
137
137
  }
138
- else /* istanbul ignore if */ if (!parentNode) {
138
+ /* c8 ignore next 3 */
139
+ if (!parentNode) {
139
140
  return undefined;
140
141
  }
141
142
  const { childNodes } = parentNode, i = childNodes.indexOf(this), siblings = closing ? childNodes.slice(0, i).reverse() : childNodes.slice(i + 1), stack = [this], { rev } = debug_1.Shadow;
@@ -146,7 +147,7 @@ let TagToken = (() => {
146
147
  continue;
147
148
  }
148
149
  else if (token.#closing === closing) {
149
- /* istanbul ignore if */
150
+ /* c8 ignore next 3 */
150
151
  if (type === 'tvar') {
151
152
  return undefined;
152
153
  }
@@ -184,9 +185,9 @@ let TagToken = (() => {
184
185
  });
185
186
  }
186
187
  /** @private */
187
- json(_, start = this.getAbsoluteIndex()) {
188
+ json(_, depth, start = this.getAbsoluteIndex()) {
188
189
  LSP: {
189
- const json = super.json(undefined, start);
190
+ const json = super.json(undefined, depth, start);
190
191
  json['closing'] = this.#closing;
191
192
  return json;
192
193
  }
@@ -148,14 +148,15 @@ let TvarToken = (() => {
148
148
  */
149
149
  setName(name) {
150
150
  const { closing, firstChild } = this;
151
- /* istanbul ignore if */
151
+ /* c8 ignore next 3 */
152
152
  if (closing) {
153
153
  throw new Error('Cannot set name of a closing tvar tag');
154
154
  }
155
- else if (firstChild.pattern === legacyPattern) {
155
+ if (firstChild.pattern === legacyPattern) {
156
156
  firstChild.replaceChildren(`|${name}`);
157
157
  }
158
- else /* istanbul ignore if */ if (name.includes('"') && name.includes("'")) {
158
+ else if (name.includes('"') && name.includes("'")) {
159
+ /* c8 ignore next */
159
160
  throw new SyntaxError('Tvar name cannot contain both single and double quotes');
160
161
  }
161
162
  else {
@@ -114,11 +114,12 @@ let TagPairToken = (() => {
114
114
  /* NOT FOR BROWSER */
115
115
  nextSibling, name, closed, type, } = this, [opening, closing] = this.#tags;
116
116
  /* NOT FOR BROWSER */
117
- /* istanbul ignore next */
117
+ /* c8 ignore start */
118
118
  if (!closed && nextSibling && type === 'include') {
119
119
  index_2.default.error(`Auto-closing <${name}>`, lastChild);
120
120
  this.closed = true;
121
121
  }
122
+ /* c8 ignore stop */
122
123
  /* NOT FOR BROWSER END */
123
124
  return this.#selfClosing
124
125
  ? `<${opening}${firstChild.toString(skip)}/>`
@@ -150,9 +151,9 @@ let TagPairToken = (() => {
150
151
  }
151
152
  }
152
153
  /** @private */
153
- json(_, start = this.getAbsoluteIndex()) {
154
+ json(_, depth, start = this.getAbsoluteIndex()) {
154
155
  LSP: {
155
- const json = super.json(undefined, start);
156
+ const json = super.json(undefined, depth, start);
156
157
  json['selfClosing'] = this.#selfClosing;
157
158
  return json;
158
159
  }
@@ -162,11 +163,12 @@ let TagPairToken = (() => {
162
163
  afterBuild() {
163
164
  super.afterBuild();
164
165
  const /** @implements */ tagPairListener = (e, data) => {
165
- /* istanbul ignore if */
166
+ /* c8 ignore start */
166
167
  if (this.#selfClosing && e.prevTarget === this.lastChild && this.lastChild.toString()) {
167
168
  (0, debug_1.undo)(e, data);
168
169
  throw new Error('A self-closing tag does not have inner content.');
169
170
  }
171
+ /* c8 ignore stop */
170
172
  };
171
173
  this.addEventListener(['insert', 'replace', 'text'], tagPairListener);
172
174
  }
@@ -227,7 +227,7 @@ let TranscludeToken = (() => {
227
227
  * @param modifier transclusion modifier / 引用修饰符
228
228
  */
229
229
  setModifier(modifier) {
230
- const { parserFunction: [, , raw, subst] } = this.getAttribute('config'), lcModifier = (0, string_1.removeComment)(modifier).trim();
230
+ const [, , raw, subst] = this.getAttribute('config').parserFunction, lcModifier = (0, string_1.removeComment)(modifier).trim();
231
231
  if (modifier && !lcModifier.endsWith(':')) {
232
232
  return false;
233
233
  }
@@ -793,7 +793,7 @@ let TranscludeToken = (() => {
793
793
  * @throws `Error` 仅用于模块
794
794
  */
795
795
  getModule() {
796
- /* istanbul ignore if */
796
+ /* c8 ignore next 3 */
797
797
  if (this.type !== 'magic-word' || this.name !== 'invoke') {
798
798
  throw new Error('TranscludeToken.getModule method is only for modules!');
799
799
  }
@@ -808,7 +808,7 @@ let TranscludeToken = (() => {
808
808
  * @throws `Error` 仅用于模块
809
809
  */
810
810
  getFrame(context) {
811
- /* istanbul ignore if */
811
+ /* c8 ignore next 3 */
812
812
  if (this.type === 'template' ? context : this.name !== 'invoke') {
813
813
  throw new Error('TranscludeToken.getFrame method is only for modules!');
814
814
  }
@@ -30,10 +30,11 @@ exports.Shadow = {
30
30
  finish();
31
31
  return result;
32
32
  }
33
- catch (e) /* istanbul ignore next */ {
33
+ catch (e) /* c8 ignore start */ {
34
34
  finish();
35
35
  throw e;
36
36
  }
37
+ /* c8 ignore stop */
37
38
  },
38
39
  /** @private */
39
40
  internal(callback, Parser) {
@@ -159,7 +160,7 @@ const undo = (e, data) => {
159
160
  case 'text':
160
161
  target.setAttribute('data', data.oldText);
161
162
  break;
162
- /* istanbul ignore next */
163
+ /* c8 ignore next 2 */
163
164
  default:
164
165
  throw new RangeError(`Unable to undo events with an unknown type: ${type}`);
165
166
  }
package/dist/util/diff.js CHANGED
@@ -7,11 +7,11 @@ exports.info = exports.error = exports.diff = exports.cmd = void 0;
7
7
  const promises_1 = __importDefault(require("fs/promises"));
8
8
  const util_1 = __importDefault(require("util"));
9
9
  const child_process_1 = require("child_process");
10
- /* istanbul ignore next */
10
+ /* c8 ignore start */
11
11
  process.on('unhandledRejection', e => {
12
12
  console.error(e);
13
13
  });
14
- /* istanbul ignore next */
14
+ /* c8 ignore stop */
15
15
  /**
16
16
  * 将shell命令转化为Promise对象
17
17
  * @param command shell指令
@@ -31,6 +31,7 @@ const cmd = (command, args) => new Promise(resolve => {
31
31
  try {
32
32
  shell = (0, child_process_1.spawn)(command, args);
33
33
  timer = setTimeout(() => {
34
+ /* c8 ignore next */
34
35
  shell.kill('SIGINT');
35
36
  }, 60 * 1e3);
36
37
  let buf = '';
@@ -47,12 +48,13 @@ const cmd = (command, args) => new Promise(resolve => {
47
48
  r(undefined);
48
49
  });
49
50
  }
50
- catch {
51
+ catch /* c8 ignore start */ {
51
52
  r(undefined);
52
53
  }
54
+ /* c8 ignore stop */
53
55
  });
54
56
  exports.cmd = cmd;
55
- /* istanbul ignore next */
57
+ /* c8 ignore start */
56
58
  /**
57
59
  * 比较两个文件
58
60
  * @param oldStr 旧文本
@@ -77,17 +79,20 @@ const diff = async (oldStr, newStr, uid) => {
77
79
  await Promise.allSettled([promises_1.default.unlink(oldFile), promises_1.default.unlink(newFile)]);
78
80
  };
79
81
  exports.diff = diff;
80
- /* istanbul ignore next */
82
+ /* c8 ignore stop */
83
+ /* c8 ignore start */
81
84
  /** @implements */
82
85
  const error = (msg, ...args) => {
83
86
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
84
87
  console.error(util_1.default.styleText?.('red', msg) ?? msg, ...args);
85
88
  };
86
89
  exports.error = error;
87
- /* istanbul ignore next */
90
+ /* c8 ignore stop */
91
+ /* c8 ignore start */
88
92
  /** @implements */
89
93
  const info = (msg, ...args) => {
90
94
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
91
95
  console.info(util_1.default.styleText?.('green', msg) ?? msg, ...args);
92
96
  };
93
97
  exports.info = info;
98
+ /* c8 ignore stop */
@@ -27,7 +27,7 @@ const getCondition = (selector, scope, has) => {
27
27
  return checkToken(selector, scope, has);
28
28
  }
29
29
  /* NOT FOR BROWSER END */
30
- /* istanbul ignore if */
30
+ /* c8 ignore next 3 */
31
31
  if (!selector) {
32
32
  return (() => true);
33
33
  }
@@ -60,10 +60,10 @@ const decodeHtml = (str) => {
60
60
  const { decodeHTMLStrict } = require('entities');
61
61
  return (s) => decodeHTMLStrict(s).replace(/\xA0/gu, ' ');
62
62
  }
63
- catch { }
63
+ catch /* c8 ignore next */ { }
64
64
  }
65
65
  /* NOT FOR BROWSER ONLY END */
66
- /* istanbul ignore next */
66
+ /* c8 ignore next */
67
67
  return exports.decodeHtmlBasic;
68
68
  })();
69
69
  return decodeHtmlResolved(str);
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var _a;
3
- const version = '1.35.0', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
3
+ const version = '1.35.1', src = (_a = document.currentScript) === null || _a === void 0 ? void 0 : _a.src, file = /\/extensions\/dist\/base\.(?:min\.)?js$/u, CDN = src && file.test(src)
4
4
  ? src.replace(file, '')
5
- : `https://testingcf.jsdelivr.net/npm/wikiparser-node@${version}`;
5
+ : `https://fastly.jsdelivr.net/npm/wikiparser-node@${version}`;
6
6
  const workerJS = () => {
7
7
  importScripts('$CDN/bundle/bundle-lsp.min.js');
8
8
  const entities = { '&': 'amp', '<': 'lt', '>': 'gt' }, lsps = new Map(), last = { include: true };
@@ -220,10 +220,18 @@ const workerJS = () => {
220
220
  ]);
221
221
  break;
222
222
  case 'findStyleTokens':
223
- postMessage([command, qid, getLSP(qid).findStyleTokens().map(token => token.json())]);
223
+ postMessage([
224
+ command,
225
+ qid,
226
+ getLSP(qid).findStyleTokens().map(token => token.json(undefined, 2)),
227
+ ]);
224
228
  break;
225
229
  case 'findTemplateTokens':
226
- postMessage([command, qid, getLSP(qid).findTemplateTokens().map(token => token.json())]);
230
+ postMessage([
231
+ command,
232
+ qid,
233
+ getLSP(qid).findTemplateTokens().map(token => token.json(undefined, 1)),
234
+ ]);
227
235
  }
228
236
  };
229
237
  };
@@ -2,7 +2,7 @@
2
2
  const codejar = (async () => {
3
3
  const { CodeJar } = 'CodeJar' in globalThis
4
4
  ? globalThis
5
- : await import('https://testingcf.jsdelivr.net/npm/codejar-async');
5
+ : await import('https://fastly.jsdelivr.net/npm/codejar-async');
6
6
  return (textbox, include, linenums) => {
7
7
  var _a;
8
8
  if (!(textbox instanceof HTMLTextAreaElement)) {