@slicemachine/manager 0.18.3-beta.1 → 0.18.3-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.
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
- package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_virtual/index2.cjs +3 -4
- package/dist/_virtual/index2.cjs.map +1 -1
- package/dist/_virtual/index2.js +2 -4
- package/dist/_virtual/index2.js.map +1 -1
- package/dist/_virtual/index3.cjs +4 -3
- package/dist/_virtual/index3.cjs.map +1 -1
- package/dist/_virtual/index3.js +4 -2
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/client/index.d.ts +0 -1
- package/dist/managers/SliceMachineManager.cjs +0 -1
- package/dist/managers/SliceMachineManager.cjs.map +1 -1
- package/dist/managers/SliceMachineManager.d.ts +0 -1
- package/dist/managers/SliceMachineManager.js +0 -1
- package/dist/managers/SliceMachineManager.js.map +1 -1
- package/dist/managers/simulator/SimulatorManager.cjs +0 -80
- package/dist/managers/simulator/SimulatorManager.cjs.map +1 -1
- package/dist/managers/simulator/SimulatorManager.d.ts +0 -29
- package/dist/managers/simulator/SimulatorManager.js +0 -63
- package/dist/managers/simulator/SimulatorManager.js.map +1 -1
- package/dist/managers/telemetry/types.cjs +0 -2
- package/dist/managers/telemetry/types.cjs.map +1 -1
- package/dist/managers/telemetry/types.d.ts +1 -4
- package/dist/managers/telemetry/types.js +0 -2
- package/dist/managers/telemetry/types.js.map +1 -1
- package/package.json +3 -10
- package/src/client/index.ts +0 -5
- package/src/managers/SliceMachineManager.ts +0 -2
- package/src/managers/simulator/SimulatorManager.ts +0 -130
- package/src/managers/telemetry/types.ts +0 -7
- package/dist/_node_modules/unist-util-is/lib/index.cjs +0 -76
- package/dist/_node_modules/unist-util-is/lib/index.cjs.map +0 -1
- package/dist/_node_modules/unist-util-is/lib/index.js +0 -76
- package/dist/_node_modules/unist-util-is/lib/index.js.map +0 -1
- package/dist/_node_modules/unist-util-visit/lib/index.cjs +0 -39
- package/dist/_node_modules/unist-util-visit/lib/index.cjs.map +0 -1
- package/dist/_node_modules/unist-util-visit/lib/index.js +0 -40
- package/dist/_node_modules/unist-util-visit/lib/index.js.map +0 -1
- package/dist/_node_modules/unist-util-visit-parents/lib/color.browser.cjs +0 -7
- package/dist/_node_modules/unist-util-visit-parents/lib/color.browser.cjs.map +0 -1
- package/dist/_node_modules/unist-util-visit-parents/lib/color.browser.js +0 -7
- package/dist/_node_modules/unist-util-visit-parents/lib/color.browser.js.map +0 -1
- package/dist/_node_modules/unist-util-visit-parents/lib/index.cjs +0 -86
- package/dist/_node_modules/unist-util-visit-parents/lib/index.cjs.map +0 -1
- package/dist/_node_modules/unist-util-visit-parents/lib/index.js +0 -86
- package/dist/_node_modules/unist-util-visit-parents/lib/index.js.map +0 -1
- package/dist/lib/functionCodec.cjs +0 -29
- package/dist/lib/functionCodec.cjs.map +0 -1
- package/dist/lib/functionCodec.d.ts +0 -2
- package/dist/lib/functionCodec.js +0 -12
- package/dist/lib/functionCodec.js.map +0 -1
- package/dist/lib/markdownToHTML.cjs +0 -91
- package/dist/lib/markdownToHTML.cjs.map +0 -1
- package/dist/lib/markdownToHTML.d.ts +0 -1
- package/dist/lib/markdownToHTML.js +0 -69
- package/dist/lib/markdownToHTML.js.map +0 -1
- package/src/lib/functionCodec.ts +0 -16
- package/src/lib/markdownToHTML.ts +0 -116
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { Plugin, Processor } from "unified";
|
|
2
|
-
import type { Root, ElementContent } from "hast";
|
|
3
|
-
import type { Grammar } from "@wooorm/starry-night";
|
|
4
|
-
import { visit } from "unist-util-visit";
|
|
5
|
-
|
|
6
|
-
type RehypeStarryNightOptions = {
|
|
7
|
-
grammars?: Grammar[];
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Rehype plugin to highlight code with `starry-night`.
|
|
12
|
-
*
|
|
13
|
-
* Adapted from:
|
|
14
|
-
* https://github.com/wooorm/starry-night/tree/c73aac7b8bff41ada86747f668dd932a791b851b#example-integrate-with-unified-remark-and-rehype
|
|
15
|
-
*/
|
|
16
|
-
const createRehypeStarryNight = async (): Promise<
|
|
17
|
-
Plugin<[options?: RehypeStarryNightOptions], Root>
|
|
18
|
-
> => {
|
|
19
|
-
const { createStarryNight, common } = await import("@wooorm/starry-night");
|
|
20
|
-
const { default: tsxGrammar } = await import(
|
|
21
|
-
"@wooorm/starry-night/lang/source.tsx.js"
|
|
22
|
-
);
|
|
23
|
-
const { default: vueGrammar } = await import(
|
|
24
|
-
"@wooorm/starry-night/lang/text.html.vue.js"
|
|
25
|
-
);
|
|
26
|
-
const { toString } = await import("hast-util-to-string");
|
|
27
|
-
|
|
28
|
-
return (options = {}) => {
|
|
29
|
-
const grammars = options.grammars || [...common, tsxGrammar, vueGrammar];
|
|
30
|
-
const starryNightPromise = createStarryNight(grammars);
|
|
31
|
-
const prefix = "language-";
|
|
32
|
-
|
|
33
|
-
return async (tree) => {
|
|
34
|
-
const starryNight = await starryNightPromise;
|
|
35
|
-
|
|
36
|
-
visit(tree, "element", function (node, index, parent) {
|
|
37
|
-
if (!parent || index === null || node.tagName !== "pre") {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const head = node.children[0];
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
!head ||
|
|
45
|
-
head.type !== "element" ||
|
|
46
|
-
head.tagName !== "code" ||
|
|
47
|
-
!head.properties
|
|
48
|
-
) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const classes = head.properties.className;
|
|
53
|
-
|
|
54
|
-
if (!Array.isArray(classes)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const language = classes.find(
|
|
59
|
-
(d) => typeof d === "string" && d.startsWith(prefix),
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
if (typeof language !== "string") {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const scope = starryNight.flagToScope(language.slice(prefix.length));
|
|
67
|
-
|
|
68
|
-
// Maybe warn?
|
|
69
|
-
if (!scope) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const fragment = starryNight.highlight(toString(head), scope);
|
|
74
|
-
const children = fragment.children as ElementContent[];
|
|
75
|
-
|
|
76
|
-
parent.children.splice(index, 1, {
|
|
77
|
-
type: "element",
|
|
78
|
-
tagName: "div",
|
|
79
|
-
properties: {
|
|
80
|
-
className: [
|
|
81
|
-
"highlight",
|
|
82
|
-
"highlight-" + scope.replace(/^source\./, "").replace(/\./g, "-"),
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
children: [
|
|
86
|
-
{ type: "element", tagName: "pre", properties: {}, children },
|
|
87
|
-
],
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
let processor: Processor;
|
|
95
|
-
|
|
96
|
-
export const markdownToHTML = async (markdown: string): Promise<string> => {
|
|
97
|
-
if (!processor) {
|
|
98
|
-
const { unified } = await import("unified");
|
|
99
|
-
const remarkParse = await import("remark-parse");
|
|
100
|
-
const remarkGfm = await import("remark-gfm");
|
|
101
|
-
const remarkRehype = await import("remark-rehype");
|
|
102
|
-
const rehypeStringify = await import("rehype-stringify");
|
|
103
|
-
const rehypeStarryNight = await createRehypeStarryNight();
|
|
104
|
-
|
|
105
|
-
processor = unified()
|
|
106
|
-
.use(remarkParse.default)
|
|
107
|
-
.use(remarkGfm.default)
|
|
108
|
-
.use(remarkRehype.default)
|
|
109
|
-
.use(rehypeStarryNight)
|
|
110
|
-
.use(rehypeStringify.default);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const virtualFile = await processor.process(markdown);
|
|
114
|
-
|
|
115
|
-
return virtualFile.toString();
|
|
116
|
-
};
|