@lotics/ui 12.1.0 → 12.1.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/package.json +1 -1
- package/src/remark_gfm_safe.ts +23 -0
package/package.json
CHANGED
package/src/remark_gfm_safe.ts
CHANGED
|
@@ -6,6 +6,29 @@ import { gfmTaskListItemFromMarkdown } from "mdast-util-gfm-task-list-item";
|
|
|
6
6
|
import { gfm } from "micromark-extension-gfm";
|
|
7
7
|
import type { Plugin } from "unified";
|
|
8
8
|
|
|
9
|
+
// A micromark syntax extension is exactly what `gfm()` produces; deriving the type
|
|
10
|
+
// from the imported value keeps this dependency-free (`micromark-util-types` is
|
|
11
|
+
// only a transitive dep) while staying the true type the registry holds.
|
|
12
|
+
type MicromarkExtension = ReturnType<typeof gfm>;
|
|
13
|
+
|
|
14
|
+
// `unified`'s `Data` interface ships bare (`{ settings? }`). `remark-parse` is what
|
|
15
|
+
// normally augments it with the two extension registries a `fromMarkdown` plugin
|
|
16
|
+
// writes into via `this.data()` — but this module composes GFM from its parts
|
|
17
|
+
// precisely so it never imports the `remark-gfm`/autolink-literal graph, and it
|
|
18
|
+
// doesn't import `remark-parse` either, so nothing else in a consumer's compile
|
|
19
|
+
// graph declares them. We restate the ecosystem's canonical augmentation here so
|
|
20
|
+
// the writes below type-check for every app that pulls this file in through
|
|
21
|
+
// `<Markdown>` (without it, `tsc` throws TS2339 on the whole app). Types mirror
|
|
22
|
+
// the consumers: `micromarkExtensions` holds micromark `Extension`s;
|
|
23
|
+
// `fromMarkdownExtensions` mirrors `mdast-util-from-markdown`'s `mdastExtensions`
|
|
24
|
+
// shape (`Extension | Extension[]`), which is what we push a nested list into below.
|
|
25
|
+
declare module "unified" {
|
|
26
|
+
interface Data {
|
|
27
|
+
micromarkExtensions?: MicromarkExtension[];
|
|
28
|
+
fromMarkdownExtensions?: Array<Extension | Extension[]>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
/**
|
|
10
33
|
* `remark-gfm`, rebuilt so no regex lookbehind reaches the bundle.
|
|
11
34
|
*
|