@openclaw/discord 2026.10.5-beta.1 → 2026.10.5-beta.2

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 (83) hide show
  1. package/node_modules/@types/node/README.md +1 -1
  2. package/node_modules/@types/node/crypto.d.ts +2 -2
  3. package/node_modules/@types/node/dgram.d.ts +1 -1
  4. package/node_modules/@types/node/package.json +2 -2
  5. package/node_modules/@types/node/zlib.d.ts +6 -0
  6. package/node_modules/@types/ws/README.md +1 -1
  7. package/node_modules/@types/ws/index.d.mts +4 -0
  8. package/node_modules/@types/ws/index.d.ts +4 -0
  9. package/node_modules/@types/ws/package.json +3 -3
  10. package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
  11. package/node_modules/micromark/dev/lib/compile.js +14 -4
  12. package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
  13. package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
  14. package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
  15. package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
  16. package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
  17. package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
  18. package/node_modules/micromark/dev/lib/preprocess.js +19 -21
  19. package/node_modules/micromark/lib/compile.d.ts.map +1 -1
  20. package/node_modules/micromark/lib/compile.js +37 -29
  21. package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
  22. package/node_modules/micromark/lib/create-tokenizer.js +37 -35
  23. package/node_modules/micromark/lib/initialize/document.js +21 -13
  24. package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
  25. package/node_modules/micromark/lib/initialize/text.js +7 -3
  26. package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
  27. package/node_modules/micromark/lib/preprocess.js +16 -19
  28. package/node_modules/micromark/package.json +2 -15
  29. package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
  30. package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
  31. package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
  32. package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
  33. package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
  34. package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
  35. package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
  36. package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
  37. package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
  38. package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
  39. package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
  40. package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
  41. package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
  42. package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
  43. package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
  44. package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
  45. package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
  46. package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
  47. package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
  48. package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
  49. package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
  50. package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
  51. package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
  52. package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
  53. package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
  54. package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
  55. package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
  56. package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
  57. package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
  58. package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
  59. package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
  60. package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
  61. package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
  62. package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
  63. package/node_modules/micromark-core-commonmark/package.json +4 -16
  64. package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
  65. package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
  66. package/node_modules/micromark-factory-space/dev/index.js +58 -3
  67. package/node_modules/micromark-factory-space/index.d.ts +24 -1
  68. package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
  69. package/node_modules/micromark-factory-space/index.js +55 -3
  70. package/node_modules/micromark-factory-space/package.json +1 -10
  71. package/node_modules/micromark-factory-space/readme.md +25 -25
  72. package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
  73. package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
  74. package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
  75. package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
  76. package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
  77. package/node_modules/micromark-util-edit-map/index.js +225 -0
  78. package/node_modules/micromark-util-edit-map/license +22 -0
  79. package/node_modules/micromark-util-edit-map/package.json +48 -0
  80. package/node_modules/micromark-util-edit-map/readme.md +234 -0
  81. package/node_modules/micromark-util-types/index.d.ts +6 -3
  82. package/node_modules/micromark-util-types/package.json +2 -36
  83. package/package.json +4 -4
@@ -12,6 +12,7 @@
12
12
  import { asciiAlphanumeric, asciiAlpha, markdownLineEndingOrSpace, markdownLineEnding, markdownSpace } from 'micromark-util-character';
13
13
  import { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name';
14
14
  import { blankLine } from './blank-line.js';
15
+ import { nonLazyContinuation } from './partial-non-lazy-continuation.js';
15
16
 
16
17
  /** @type {Construct} */
17
18
  export const htmlFlow = {
@@ -26,10 +27,6 @@ const blankLineBefore = {
26
27
  partial: true,
27
28
  tokenize: tokenizeBlankLineBefore
28
29
  };
29
- const nonLazyContinuationStart = {
30
- partial: true,
31
- tokenize: tokenizeNonLazyContinuationStart
32
- };
33
30
 
34
31
  /** @type {Resolver} */
35
32
  function resolveToHtmlFlow(events) {
@@ -608,7 +605,7 @@ function tokenizeHtmlFlow(effects, ok, nok) {
608
605
  * @type {State}
609
606
  */
610
607
  function continuationStart(code) {
611
- return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
608
+ return effects.check(nonLazyContinuation, continuationStartNonLazy, continuationAfter)(code);
612
609
  }
613
610
 
614
611
  /**
@@ -802,52 +799,6 @@ function tokenizeHtmlFlow(effects, ok, nok) {
802
799
  }
803
800
  }
804
801
 
805
- /**
806
- * @this {TokenizeContext}
807
- * Context.
808
- * @type {Tokenizer}
809
- */
810
- function tokenizeNonLazyContinuationStart(effects, ok, nok) {
811
- const self = this;
812
- return start;
813
-
814
- /**
815
- * At eol, before continuation.
816
- *
817
- * ```markdown
818
- * > | * ```js
819
- * ^
820
- * | b
821
- * ```
822
- *
823
- * @type {State}
824
- */
825
- function start(code) {
826
- if (markdownLineEnding(code)) {
827
- effects.enter("lineEnding");
828
- effects.consume(code);
829
- effects.exit("lineEnding");
830
- return after;
831
- }
832
- return nok(code);
833
- }
834
-
835
- /**
836
- * A continuation.
837
- *
838
- * ```markdown
839
- * | * ```js
840
- * > | b
841
- * ^
842
- * ```
843
- *
844
- * @type {State}
845
- */
846
- function after(code) {
847
- return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
848
- }
849
- }
850
-
851
802
  /**
852
803
  * @this {TokenizeContext}
853
804
  * Context.
@@ -66,8 +66,6 @@ function resolveAllLabelEnd(events) {
66
66
  function resolveToLabelEnd(events, context) {
67
67
  let index = events.length;
68
68
  let offset = 0;
69
- /** @type {Token} */
70
- let token;
71
69
  /** @type {number | undefined} */
72
70
  let open;
73
71
  /** @type {number | undefined} */
@@ -77,7 +75,7 @@ function resolveToLabelEnd(events, context) {
77
75
 
78
76
  // Find an opening.
79
77
  while (index--) {
80
- token = events[index][1];
78
+ const token = events[index][1];
81
79
  if (open) {
82
80
  // If we see another link, or inactive link label, we’ve been here before.
83
81
  if (token.type === "link" || token.type === "labelLink" && token._inactive) {
@@ -160,18 +158,18 @@ function resolveToLabelEnd(events, context) {
160
158
  */
161
159
  function tokenizeLabelEnd(effects, ok, nok) {
162
160
  const self = this;
163
- let index = self.events.length;
161
+ const labelStarts = self._labelStarts;
164
162
  /** @type {Token} */
165
163
  let labelStart;
166
164
  /** @type {boolean} */
167
165
  let defined;
168
-
169
- // Find an opening.
170
- while (index--) {
171
- if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) {
172
- labelStart = self.events[index][1];
173
- break;
166
+ if (labelStarts) {
167
+ // Discard ones that failed to close,
168
+ // they’re not needed anymore.
169
+ while (labelStarts.length > 0 && labelStarts[labelStarts.length - 1]._balanced) {
170
+ labelStarts.pop();
174
171
  }
172
+ labelStart = labelStarts[labelStarts.length - 1];
175
173
  }
176
174
  return start;
177
175
 
@@ -290,6 +288,9 @@ function tokenizeLabelEnd(effects, ok, nok) {
290
288
  */
291
289
  function labelEndOk(code) {
292
290
  // Note: `markdown-rs` does a bunch of stuff here.
291
+ // This label start is now used up: discard it so it’s never found again.
292
+
293
+ labelStarts.pop();
293
294
  return ok(code);
294
295
  }
295
296
 
@@ -1 +1 @@
1
- {"version":3,"file":"label-start-image.d.ts","sourceRoot":"","sources":["label-start-image.js"],"names":[],"mappings":"AAaA,wBAAwB;AACxB,8BADW,SAAS,CAKnB;+BAZS,sBAAsB"}
1
+ {"version":3,"file":"label-start-image.d.ts","sourceRoot":"","sources":["label-start-image.js"],"names":[],"mappings":"AAcA,wBAAwB;AACxB,8BADW,SAAS,CAKnB;+BAZS,sBAAsB"}
@@ -2,6 +2,7 @@
2
2
  * @import {
3
3
  * Construct,
4
4
  * State,
5
+ * Token,
5
6
  * TokenizeContext,
6
7
  * Tokenizer
7
8
  * } from 'micromark-util-types'
@@ -23,6 +24,8 @@ export const labelStartImage = {
23
24
  */
24
25
  function tokenizeLabelStartImage(effects, ok, nok) {
25
26
  const self = this;
27
+ /** @type {Token} */
28
+ let labelImage;
26
29
  return start;
27
30
 
28
31
  /**
@@ -58,7 +61,7 @@ function tokenizeLabelStartImage(effects, ok, nok) {
58
61
  effects.enter("labelMarker");
59
62
  effects.consume(code);
60
63
  effects.exit("labelMarker");
61
- effects.exit("labelImage");
64
+ labelImage = effects.exit("labelImage");
62
65
  return after;
63
66
  }
64
67
  return nok(code);
@@ -96,7 +99,12 @@ function tokenizeLabelStartImage(effects, ok, nok) {
96
99
  // `micromark-extension-gfm-footnote`, but the `label-start-link`
97
100
  // behavior isn’t.
98
101
  // Hidden footnotes hook.
99
- /* c8 ignore next 3 */
100
- return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);
102
+ /* c8 ignore next 6 */
103
+ if (code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs) {
104
+ return nok(code);
105
+ }
106
+ self._labelStarts = self._labelStarts || [];
107
+ self._labelStarts.push(labelImage);
108
+ return ok(code);
101
109
  }
102
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"label-start-link.d.ts","sourceRoot":"","sources":["label-start-link.js"],"names":[],"mappings":"AAaA,wBAAwB;AACxB,6BADW,SAAS,CAKnB;+BAZS,sBAAsB"}
1
+ {"version":3,"file":"label-start-link.d.ts","sourceRoot":"","sources":["label-start-link.js"],"names":[],"mappings":"AAcA,wBAAwB;AACxB,6BADW,SAAS,CAKnB;+BAZS,sBAAsB"}
@@ -2,6 +2,7 @@
2
2
  * @import {
3
3
  * Construct,
4
4
  * State,
5
+ * Token,
5
6
  * TokenizeContext,
6
7
  * Tokenizer
7
8
  * } from 'micromark-util-types'
@@ -23,6 +24,8 @@ export const labelStartLink = {
23
24
  */
24
25
  function tokenizeLabelStartLink(effects, ok, nok) {
25
26
  const self = this;
27
+ /** @type {Token} */
28
+ let labelLink;
26
29
  return start;
27
30
 
28
31
  /**
@@ -40,7 +43,7 @@ function tokenizeLabelStartLink(effects, ok, nok) {
40
43
  effects.enter("labelMarker");
41
44
  effects.consume(code);
42
45
  effects.exit("labelMarker");
43
- effects.exit("labelLink");
46
+ labelLink = effects.exit("labelLink");
44
47
  return after;
45
48
  }
46
49
 
@@ -49,7 +52,12 @@ function tokenizeLabelStartLink(effects, ok, nok) {
49
52
  // To do: this isn’t needed in `micromark-extension-gfm-footnote`,
50
53
  // remove.
51
54
  // Hidden footnotes hook.
52
- /* c8 ignore next 3 */
53
- return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs ? nok(code) : ok(code);
55
+ /* c8 ignore next 6 */
56
+ if (code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs) {
57
+ return nok(code);
58
+ }
59
+ self._labelStarts = self._labelStarts || [];
60
+ self._labelStarts.push(labelLink);
61
+ return ok(code);
54
62
  }
55
63
  }
@@ -0,0 +1,4 @@
1
+ /** @type {Construct} */
2
+ export const nonLazyContinuation: Construct;
3
+ import type { Construct } from 'micromark-util-types';
4
+ //# sourceMappingURL=partial-non-lazy-continuation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partial-non-lazy-continuation.d.ts","sourceRoot":"","sources":["partial-non-lazy-continuation.js"],"names":[],"mappings":"AAaA,wBAAwB;AACxB,kCADW,SAAS,CAInB;+BAXS,sBAAsB"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @import {
3
+ * Construct,
4
+ * State,
5
+ * TokenizeContext,
6
+ * Tokenizer
7
+ * } from 'micromark-util-types'
8
+ */
9
+
10
+ import { markdownLineEnding } from 'micromark-util-character';
11
+ /** @type {Construct} */
12
+ export const nonLazyContinuation = {
13
+ partial: true,
14
+ tokenize: tokenizeNonLazyContinuation
15
+ };
16
+
17
+ /**
18
+ * @this {TokenizeContext}
19
+ * Context.
20
+ * @type {Tokenizer}
21
+ */
22
+ function tokenizeNonLazyContinuation(effects, ok, nok) {
23
+ const self = this;
24
+ return start;
25
+
26
+ /**
27
+ * At eol, before continuation.
28
+ *
29
+ * ```markdown
30
+ * > | * ```js
31
+ * ^
32
+ * | b
33
+ * ```
34
+ *
35
+ * @type {State}
36
+ */
37
+ function start(code) {
38
+ if (code === null) {
39
+ return nok(code);
40
+ }
41
+ effects.enter("lineEnding");
42
+ effects.consume(code);
43
+ effects.exit("lineEnding");
44
+ return after;
45
+ }
46
+
47
+ /**
48
+ * A continuation.
49
+ *
50
+ * ```markdown
51
+ * | * ```js
52
+ * > | b
53
+ * ^
54
+ * ```
55
+ *
56
+ * @type {State}
57
+ */
58
+ function after(code) {
59
+ return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
60
+ }
61
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"setext-underline.d.ts","sourceRoot":"","sources":["setext-underline.js"],"names":[],"mappings":"AAgBA,wBAAwB;AACxB,8BADW,SAAS,CAKnB;+BAbS,sBAAsB"}
1
+ {"version":3,"file":"setext-underline.d.ts","sourceRoot":"","sources":["setext-underline.js"],"names":[],"mappings":"AAiBA,wBAAwB;AACxB,8BADW,SAAS,CAKnB;+BAdS,sBAAsB"}
@@ -11,6 +11,7 @@
11
11
 
12
12
  import { factorySpace } from 'micromark-factory-space';
13
13
  import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
14
+ import { EditMap } from 'micromark-util-edit-map';
14
15
  /** @type {Construct} */
15
16
  export const setextUnderline = {
16
17
  name: 'setextUnderline',
@@ -20,7 +21,7 @@ export const setextUnderline = {
20
21
 
21
22
  /** @type {Resolver} */
22
23
  function resolveToSetextUnderline(events, context) {
23
- // To do: resolve like `markdown-rs`.
24
+ const editMap = new EditMap();
24
25
  let index = events.length;
25
26
  /** @type {number | undefined} */
26
27
  let content;
@@ -45,7 +46,7 @@ function resolveToSetextUnderline(events, context) {
45
46
  else {
46
47
  if (events[index][1].type === "content") {
47
48
  // Remove the content end (if needed we’ll add it later)
48
- events.splice(index, 1);
49
+ editMap.add(index, 1, []);
49
50
  }
50
51
  if (!definition && events[index][1].type === "definition") {
51
52
  definition = index;
@@ -68,8 +69,8 @@ function resolveToSetextUnderline(events, context) {
68
69
  // If we have definitions in the content, we’ll keep on having content,
69
70
  // but we need move it.
70
71
  if (definition) {
71
- events.splice(text, 0, ['enter', heading, context]);
72
- events.splice(definition + 1, 0, ['exit', events[content][1], context]);
72
+ editMap.add(text, 0, [['enter', heading, context]]);
73
+ editMap.add(definition + 1, 0, [['exit', events[content][1], context]]);
73
74
  events[content][1].end = {
74
75
  ...events[definition][1].end
75
76
  };
@@ -78,7 +79,8 @@ function resolveToSetextUnderline(events, context) {
78
79
  }
79
80
 
80
81
  // Add the heading exit at the end.
81
- events.push(['exit', heading, context]);
82
+ editMap.add(events.length, 0, [['exit', heading, context]]);
83
+ editMap.consume(events);
82
84
  return events;
83
85
  }
84
86
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micromark-core-commonmark",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "The CommonMark markdown constructs",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -42,33 +42,21 @@
42
42
  "devlop": "^1.0.0",
43
43
  "micromark-factory-destination": "^2.0.0",
44
44
  "micromark-factory-label": "^2.0.0",
45
- "micromark-factory-space": "^2.0.0",
45
+ "micromark-factory-space": "^2.1.0",
46
46
  "micromark-factory-title": "^2.0.0",
47
47
  "micromark-factory-whitespace": "^2.0.0",
48
48
  "micromark-util-character": "^2.0.0",
49
49
  "micromark-util-chunked": "^2.0.0",
50
50
  "micromark-util-classify-character": "^2.0.0",
51
+ "micromark-util-edit-map": "^1.0.0",
51
52
  "micromark-util-html-tag-name": "^2.0.0",
52
53
  "micromark-util-normalize-identifier": "^2.0.0",
53
54
  "micromark-util-resolve-all": "^2.0.0",
54
55
  "micromark-util-subtokenize": "^2.0.0",
55
56
  "micromark-util-symbol": "^2.0.0",
56
- "micromark-util-types": "^2.0.0"
57
+ "micromark-util-types": "^2.0.3"
57
58
  },
58
59
  "scripts": {
59
60
  "build": "micromark-build"
60
- },
61
- "xo": {
62
- "envs": [
63
- "shared-node-browser"
64
- ],
65
- "prettier": true,
66
- "rules": {
67
- "logical-assignment-operators": "off",
68
- "max-depth": "off",
69
- "unicorn/no-this-assignment": "off",
70
- "unicorn/prefer-at": "off",
71
- "unicorn/prefer-code-point": "off"
72
- }
73
61
  }
74
62
  }
@@ -24,13 +24,36 @@
24
24
  * @param {State} ok
25
25
  * State switched to when successful.
26
26
  * @param {TokenType} type
27
- * Type (`' \t'`).
27
+ * Type of the whole whitespace.
28
28
  * @param {number | undefined} [max=Infinity]
29
29
  * Max (exclusive).
30
30
  * @returns {State}
31
31
  * Start state.
32
32
  */
33
33
  export function factorySpace(effects: Effects, ok: State, type: TokenType, max?: number | undefined): State;
34
+ /**
35
+ * Parse spaces and tabs, with a required minimum and maximum, matching
36
+ * `markdown-rs`’s `space_or_tab_min_max`.
37
+ *
38
+ * Unlike `factorySpace`, this can fail: `nok` is used when fewer than
39
+ * `min` spaces or tabs are found.
40
+ *
41
+ * @param {Effects} effects
42
+ * Context.
43
+ * @param {State} ok
44
+ * State switched to when successful.
45
+ * @param {State} nok
46
+ * State switched to when unsuccessful.
47
+ * @param {TokenType} type
48
+ * Type of the whole whitespace.
49
+ * @param {number} min
50
+ * Minimum allowed characters (inclusive).
51
+ * @param {number} max
52
+ * Maximum allowed characters (inclusive).
53
+ * @returns {State}
54
+ * Start state.
55
+ */
56
+ export function factorySpaceMinMax(effects: Effects, ok: State, nok: State, type: TokenType, min: number, max: number): State;
34
57
  import type { Effects } from 'micromark-util-types';
35
58
  import type { State } from 'micromark-util-types';
36
59
  import type { TokenType } from 'micromark-util-types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,sCAXW,OAAO,MAEP,KAAK,QAEL,SAAS,QAET,MAAM,GAAG,SAAS,GAEhB,KAAK,CA6BjB;6BAjE2C,sBAAsB;2BAAtB,sBAAsB;+BAAtB,sBAAsB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,sCAXW,OAAO,MAEP,KAAK,QAEL,SAAS,QAET,MAAM,GAAG,SAAS,GAEhB,KAAK,CA6BjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,4CAfW,OAAO,MAEP,KAAK,OAEL,KAAK,QAEL,SAAS,OAET,MAAM,OAEN,MAAM,GAEJ,KAAK,CAkCjB;6BAxH2C,sBAAsB;2BAAtB,sBAAsB;+BAAtB,sBAAsB"}
@@ -4,7 +4,7 @@
4
4
 
5
5
  import {markdownSpace} from 'micromark-util-character'
6
6
 
7
- // To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`.
7
+ // To do: implement `spaceOrTabWithOptions` (`connect`, `content`).
8
8
 
9
9
  /**
10
10
  * Parse spaces and tabs.
@@ -32,14 +32,14 @@ import {markdownSpace} from 'micromark-util-character'
32
32
  * @param {State} ok
33
33
  * State switched to when successful.
34
34
  * @param {TokenType} type
35
- * Type (`' \t'`).
35
+ * Type of the whole whitespace.
36
36
  * @param {number | undefined} [max=Infinity]
37
37
  * Max (exclusive).
38
38
  * @returns {State}
39
39
  * Start state.
40
40
  */
41
41
  export function factorySpace(effects, ok, type, max) {
42
- const limit = max ? max - 1 : Number.POSITIVE_INFINITY
42
+ const limit = max ? max - 1 : Infinity
43
43
  let size = 0
44
44
 
45
45
  return start
@@ -65,3 +65,58 @@ export function factorySpace(effects, ok, type, max) {
65
65
  return ok(code)
66
66
  }
67
67
  }
68
+
69
+ /**
70
+ * Parse spaces and tabs, with a required minimum and maximum, matching
71
+ * `markdown-rs`’s `space_or_tab_min_max`.
72
+ *
73
+ * Unlike `factorySpace`, this can fail: `nok` is used when fewer than
74
+ * `min` spaces or tabs are found.
75
+ *
76
+ * @param {Effects} effects
77
+ * Context.
78
+ * @param {State} ok
79
+ * State switched to when successful.
80
+ * @param {State} nok
81
+ * State switched to when unsuccessful.
82
+ * @param {TokenType} type
83
+ * Type of the whole whitespace.
84
+ * @param {number} min
85
+ * Minimum allowed characters (inclusive).
86
+ * @param {number} max
87
+ * Maximum allowed characters (inclusive).
88
+ * @returns {State}
89
+ * Start state.
90
+ */
91
+ export function factorySpaceMinMax(effects, ok, nok, type, min, max) {
92
+ let size = 0
93
+
94
+ return start
95
+
96
+ /** @type {State} */
97
+ function start(code) {
98
+ if (max > 0 && markdownSpace(code)) {
99
+ effects.enter(type)
100
+ return prefix(code)
101
+ }
102
+
103
+ return after(code)
104
+ }
105
+
106
+ /** @type {State} */
107
+ function prefix(code) {
108
+ if (markdownSpace(code) && size < max) {
109
+ effects.consume(code)
110
+ size++
111
+ return prefix
112
+ }
113
+
114
+ effects.exit(type)
115
+ return after(code)
116
+ }
117
+
118
+ /** @type {State} */
119
+ function after(code) {
120
+ return size >= min ? ok(code) : nok(code)
121
+ }
122
+ }
@@ -24,13 +24,36 @@
24
24
  * @param {State} ok
25
25
  * State switched to when successful.
26
26
  * @param {TokenType} type
27
- * Type (`' \t'`).
27
+ * Type of the whole whitespace.
28
28
  * @param {number | undefined} [max=Infinity]
29
29
  * Max (exclusive).
30
30
  * @returns {State}
31
31
  * Start state.
32
32
  */
33
33
  export function factorySpace(effects: Effects, ok: State, type: TokenType, max?: number | undefined): State;
34
+ /**
35
+ * Parse spaces and tabs, with a required minimum and maximum, matching
36
+ * `markdown-rs`’s `space_or_tab_min_max`.
37
+ *
38
+ * Unlike `factorySpace`, this can fail: `nok` is used when fewer than
39
+ * `min` spaces or tabs are found.
40
+ *
41
+ * @param {Effects} effects
42
+ * Context.
43
+ * @param {State} ok
44
+ * State switched to when successful.
45
+ * @param {State} nok
46
+ * State switched to when unsuccessful.
47
+ * @param {TokenType} type
48
+ * Type of the whole whitespace.
49
+ * @param {number} min
50
+ * Minimum allowed characters (inclusive).
51
+ * @param {number} max
52
+ * Maximum allowed characters (inclusive).
53
+ * @returns {State}
54
+ * Start state.
55
+ */
56
+ export function factorySpaceMinMax(effects: Effects, ok: State, nok: State, type: TokenType, min: number, max: number): State;
34
57
  import type { Effects } from 'micromark-util-types';
35
58
  import type { State } from 'micromark-util-types';
36
59
  import type { TokenType } from 'micromark-util-types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,sCAXW,OAAO,MAEP,KAAK,QAEL,SAAS,QAET,MAAM,GAAG,SAAS,GAEhB,KAAK,CA6BjB;6BAjE2C,sBAAsB;2BAAtB,sBAAsB;+BAAtB,sBAAsB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,sCAXW,OAAO,MAEP,KAAK,QAEL,SAAS,QAET,MAAM,GAAG,SAAS,GAEhB,KAAK,CA6BjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,4CAfW,OAAO,MAEP,KAAK,OAEL,KAAK,QAEL,SAAS,OAET,MAAM,OAEN,MAAM,GAEJ,KAAK,CAkCjB;6BAxH2C,sBAAsB;2BAAtB,sBAAsB;+BAAtB,sBAAsB"}
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { markdownSpace } from 'micromark-util-character';
6
6
 
7
- // To do: implement `spaceOrTab`, `spaceOrTabMinMax`, `spaceOrTabWithOptions`.
7
+ // To do: implement `spaceOrTabWithOptions` (`connect`, `content`).
8
8
 
9
9
  /**
10
10
  * Parse spaces and tabs.
@@ -32,14 +32,14 @@ import { markdownSpace } from 'micromark-util-character';
32
32
  * @param {State} ok
33
33
  * State switched to when successful.
34
34
  * @param {TokenType} type
35
- * Type (`' \t'`).
35
+ * Type of the whole whitespace.
36
36
  * @param {number | undefined} [max=Infinity]
37
37
  * Max (exclusive).
38
38
  * @returns {State}
39
39
  * Start state.
40
40
  */
41
41
  export function factorySpace(effects, ok, type, max) {
42
- const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
42
+ const limit = max ? max - 1 : Infinity;
43
43
  let size = 0;
44
44
  return start;
45
45
 
@@ -61,4 +61,56 @@ export function factorySpace(effects, ok, type, max) {
61
61
  effects.exit(type);
62
62
  return ok(code);
63
63
  }
64
+ }
65
+
66
+ /**
67
+ * Parse spaces and tabs, with a required minimum and maximum, matching
68
+ * `markdown-rs`’s `space_or_tab_min_max`.
69
+ *
70
+ * Unlike `factorySpace`, this can fail: `nok` is used when fewer than
71
+ * `min` spaces or tabs are found.
72
+ *
73
+ * @param {Effects} effects
74
+ * Context.
75
+ * @param {State} ok
76
+ * State switched to when successful.
77
+ * @param {State} nok
78
+ * State switched to when unsuccessful.
79
+ * @param {TokenType} type
80
+ * Type of the whole whitespace.
81
+ * @param {number} min
82
+ * Minimum allowed characters (inclusive).
83
+ * @param {number} max
84
+ * Maximum allowed characters (inclusive).
85
+ * @returns {State}
86
+ * Start state.
87
+ */
88
+ export function factorySpaceMinMax(effects, ok, nok, type, min, max) {
89
+ let size = 0;
90
+ return start;
91
+
92
+ /** @type {State} */
93
+ function start(code) {
94
+ if (max > 0 && markdownSpace(code)) {
95
+ effects.enter(type);
96
+ return prefix(code);
97
+ }
98
+ return after(code);
99
+ }
100
+
101
+ /** @type {State} */
102
+ function prefix(code) {
103
+ if (markdownSpace(code) && size < max) {
104
+ effects.consume(code);
105
+ size++;
106
+ return prefix;
107
+ }
108
+ effects.exit(type);
109
+ return after(code);
110
+ }
111
+
112
+ /** @type {State} */
113
+ function after(code) {
114
+ return size >= min ? ok(code) : nok(code);
115
+ }
64
116
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micromark-factory-space",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "micromark factory to parse markdown space (found in lots of places)",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -42,14 +42,5 @@
42
42
  },
43
43
  "scripts": {
44
44
  "build": "micromark-build"
45
- },
46
- "xo": {
47
- "envs": [
48
- "shared-node-browser"
49
- ],
50
- "prettier": true,
51
- "rules": {
52
- "unicorn/prefer-code-point": "off"
53
- }
54
45
  }
55
46
  }