@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,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const index = require("../../unist-util-visit-parents/lib/index.cjs");
|
|
4
|
-
const visit = (
|
|
5
|
-
/**
|
|
6
|
-
* @type {(
|
|
7
|
-
* (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
|
|
8
|
-
* (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
|
|
9
|
-
* )}
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @param {Node} tree
|
|
13
|
-
* @param {Test} test
|
|
14
|
-
* @param {Visitor} visitor
|
|
15
|
-
* @param {boolean | null | undefined} [reverse]
|
|
16
|
-
* @returns {void}
|
|
17
|
-
*/
|
|
18
|
-
function(tree, test, visitor, reverse) {
|
|
19
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
20
|
-
reverse = visitor;
|
|
21
|
-
visitor = test;
|
|
22
|
-
test = null;
|
|
23
|
-
}
|
|
24
|
-
index.visitParents(tree, test, overload, reverse);
|
|
25
|
-
function overload(node, parents) {
|
|
26
|
-
const parent = parents[parents.length - 1];
|
|
27
|
-
return visitor(
|
|
28
|
-
node,
|
|
29
|
-
parent ? parent.children.indexOf(node) : null,
|
|
30
|
-
parent
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
exports.CONTINUE = index.CONTINUE;
|
|
36
|
-
exports.EXIT = index.EXIT;
|
|
37
|
-
exports.SKIP = index.SKIP;
|
|
38
|
-
exports.visit = visit;
|
|
39
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../../node_modules/unist-util-visit/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * Check if `Child` can be a child of `Ancestor`.\n *\n * Returns the ancestor when `Child` can be a child of `Ancestor`, or returns\n * `never`.\n *\n * @template {Node} Ancestor\n * Node type.\n * @template {Node} Child\n * Node type.\n * @typedef {(\n * Ancestor extends Parent\n * ? Child extends Ancestor['children'][number]\n * ? Ancestor\n * : never\n * : never\n * )} ParentsOf\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends Node ? number | null : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends Node ? Ancestor | null : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Visited\n * Node type.\n * @template {Parent} Ancestor\n * Parent type.\n * @typedef {Visitor<Visited, ParentsOf<Ancestor, Visited>>} BuildVisitorFromMatch\n */\n\n/**\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n * @typedef {(\n * BuildVisitorFromMatch<\n * import('unist-util-visit-parents/complex-types.js').Matches<Descendant, Check>,\n * Extract<Descendant, Parent>\n * >\n * )} BuildVisitorFromDescendants\n */\n\n/**\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} [Tree=Node]\n * Node type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {(\n * BuildVisitorFromDescendants<\n * import('unist-util-visit-parents/complex-types.js').InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visit =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n visitor = test\n test = null\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {Node} node\n * @param {Array<Parent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n return visitor(\n node,\n parent ? parent.children.indexOf(node) : null,\n parent\n )\n }\n }\n )\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n"],"names":["visitParents"],"mappings":";;;AA8IY,MAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeT,SAAU,MAAM,MAAM,SAAS,SAAS;AACtC,QAAI,OAAO,SAAS,cAAc,OAAO,YAAY,YAAY;AAC/D,gBAAU;AACV,gBAAU;AACV,aAAO;AAAA,IACR;AAEDA,UAAAA,aAAa,MAAM,MAAM,UAAU,OAAO;AAM1C,aAAS,SAAS,MAAM,SAAS;AAC/B,YAAM,SAAS,QAAQ,QAAQ,SAAS,CAAC;AACzC,aAAO;AAAA,QACL;AAAA,QACA,SAAS,OAAO,SAAS,QAAQ,IAAI,IAAI;AAAA,QACzC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AAAA;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { visitParents } from "../../unist-util-visit-parents/lib/index.js";
|
|
2
|
-
import { CONTINUE, EXIT, SKIP } from "../../unist-util-visit-parents/lib/index.js";
|
|
3
|
-
const visit = (
|
|
4
|
-
/**
|
|
5
|
-
* @type {(
|
|
6
|
-
* (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
|
|
7
|
-
* (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
|
|
8
|
-
* )}
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @param {Node} tree
|
|
12
|
-
* @param {Test} test
|
|
13
|
-
* @param {Visitor} visitor
|
|
14
|
-
* @param {boolean | null | undefined} [reverse]
|
|
15
|
-
* @returns {void}
|
|
16
|
-
*/
|
|
17
|
-
function(tree, test, visitor, reverse) {
|
|
18
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
19
|
-
reverse = visitor;
|
|
20
|
-
visitor = test;
|
|
21
|
-
test = null;
|
|
22
|
-
}
|
|
23
|
-
visitParents(tree, test, overload, reverse);
|
|
24
|
-
function overload(node, parents) {
|
|
25
|
-
const parent = parents[parents.length - 1];
|
|
26
|
-
return visitor(
|
|
27
|
-
node,
|
|
28
|
-
parent ? parent.children.indexOf(node) : null,
|
|
29
|
-
parent
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
export {
|
|
35
|
-
CONTINUE,
|
|
36
|
-
EXIT,
|
|
37
|
-
SKIP,
|
|
38
|
-
visit
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/unist-util-visit/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * Check if `Child` can be a child of `Ancestor`.\n *\n * Returns the ancestor when `Child` can be a child of `Ancestor`, or returns\n * `never`.\n *\n * @template {Node} Ancestor\n * Node type.\n * @template {Node} Child\n * Node type.\n * @typedef {(\n * Ancestor extends Parent\n * ? Child extends Ancestor['children'][number]\n * ? Ancestor\n * : never\n * : never\n * )} ParentsOf\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends Node ? number | null : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends Node ? Ancestor | null : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Visited\n * Node type.\n * @template {Parent} Ancestor\n * Parent type.\n * @typedef {Visitor<Visited, ParentsOf<Ancestor, Visited>>} BuildVisitorFromMatch\n */\n\n/**\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n * @typedef {(\n * BuildVisitorFromMatch<\n * import('unist-util-visit-parents/complex-types.js').Matches<Descendant, Check>,\n * Extract<Descendant, Parent>\n * >\n * )} BuildVisitorFromDescendants\n */\n\n/**\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} [Tree=Node]\n * Node type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {(\n * BuildVisitorFromDescendants<\n * import('unist-util-visit-parents/complex-types.js').InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visit =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n visitor = test\n test = null\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {Node} node\n * @param {Array<Parent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n return visitor(\n node,\n parent ? parent.children.indexOf(node) : null,\n parent\n )\n }\n }\n )\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n"],"names":[],"mappings":";;AA8IY,MAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeT,SAAU,MAAM,MAAM,SAAS,SAAS;AACtC,QAAI,OAAO,SAAS,cAAc,OAAO,YAAY,YAAY;AAC/D,gBAAU;AACV,gBAAU;AACV,aAAO;AAAA,IACR;AAED,iBAAa,MAAM,MAAM,UAAU,OAAO;AAM1C,aAAS,SAAS,MAAM,SAAS;AAC/B,YAAM,SAAS,QAAQ,QAAQ,SAAS,CAAC;AACzC,aAAO;AAAA,QACL;AAAA,QACA,SAAS,OAAO,SAAS,QAAQ,IAAI,IAAI;AAAA,QACzC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AAAA;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color.browser.cjs","sources":["../../../../../../node_modules/unist-util-visit-parents/lib/color.browser.js"],"sourcesContent":["/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return d\n}\n"],"names":[],"mappings":";;AAIO,SAAS,MAAM,GAAG;AACvB,SAAO;AACT;;","x_google_ignoreList":[0]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color.browser.js","sources":["../../../../../../node_modules/unist-util-visit-parents/lib/color.browser.js"],"sourcesContent":["/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return d\n}\n"],"names":[],"mappings":"AAIO,SAAS,MAAM,GAAG;AACvB,SAAO;AACT;","x_google_ignoreList":[0]}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const color_browser = require("./color.browser.cjs");
|
|
4
|
-
const index = require("../../unist-util-is/lib/index.cjs");
|
|
5
|
-
const CONTINUE = true;
|
|
6
|
-
const EXIT = false;
|
|
7
|
-
const SKIP = "skip";
|
|
8
|
-
const visitParents = (
|
|
9
|
-
/**
|
|
10
|
-
* @type {(
|
|
11
|
-
* (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
|
|
12
|
-
* (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
|
|
13
|
-
* )}
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @param {Node} tree
|
|
17
|
-
* @param {Test} test
|
|
18
|
-
* @param {Visitor<Node>} visitor
|
|
19
|
-
* @param {boolean | null | undefined} [reverse]
|
|
20
|
-
* @returns {void}
|
|
21
|
-
*/
|
|
22
|
-
function(tree, test, visitor, reverse) {
|
|
23
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
24
|
-
reverse = visitor;
|
|
25
|
-
visitor = test;
|
|
26
|
-
test = null;
|
|
27
|
-
}
|
|
28
|
-
const is = index.convert(test);
|
|
29
|
-
const step = reverse ? -1 : 1;
|
|
30
|
-
factory(tree, void 0, [])();
|
|
31
|
-
function factory(node, index2, parents) {
|
|
32
|
-
const value = node && typeof node === "object" ? node : {};
|
|
33
|
-
if (typeof value.type === "string") {
|
|
34
|
-
const name = (
|
|
35
|
-
// `hast`
|
|
36
|
-
typeof value.tagName === "string" ? value.tagName : (
|
|
37
|
-
// `xast`
|
|
38
|
-
typeof value.name === "string" ? value.name : void 0
|
|
39
|
-
)
|
|
40
|
-
);
|
|
41
|
-
Object.defineProperty(visit, "name", {
|
|
42
|
-
value: "node (" + color_browser.color(node.type + (name ? "<" + name + ">" : "")) + ")"
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return visit;
|
|
46
|
-
function visit() {
|
|
47
|
-
let result = [];
|
|
48
|
-
let subresult;
|
|
49
|
-
let offset;
|
|
50
|
-
let grandparents;
|
|
51
|
-
if (!test || is(node, index2, parents[parents.length - 1] || null)) {
|
|
52
|
-
result = toResult(visitor(node, parents));
|
|
53
|
-
if (result[0] === EXIT) {
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (node.children && result[0] !== SKIP) {
|
|
58
|
-
offset = (reverse ? node.children.length : -1) + step;
|
|
59
|
-
grandparents = parents.concat(node);
|
|
60
|
-
while (offset > -1 && offset < node.children.length) {
|
|
61
|
-
subresult = factory(node.children[offset], offset, grandparents)();
|
|
62
|
-
if (subresult[0] === EXIT) {
|
|
63
|
-
return subresult;
|
|
64
|
-
}
|
|
65
|
-
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
function toResult(value) {
|
|
74
|
-
if (Array.isArray(value)) {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
if (typeof value === "number") {
|
|
78
|
-
return [CONTINUE, value];
|
|
79
|
-
}
|
|
80
|
-
return [value];
|
|
81
|
-
}
|
|
82
|
-
exports.CONTINUE = CONTINUE;
|
|
83
|
-
exports.EXIT = EXIT;
|
|
84
|
-
exports.SKIP = SKIP;
|
|
85
|
-
exports.visitParents = visitParents;
|
|
86
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../../node_modules/unist-util-visit-parents/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * @typedef {boolean | 'skip'} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<Ancestor>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * Tree type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from './color.js'\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visitParents =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor<Node>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n test = null\n }\n\n const is = convert(test)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {Node} node\n * @param {number | undefined} index\n * @param {Array<Parent>} parents\n */\n function factory(node, index, parents) {\n /** @type {Record<string, unknown>} */\n // @ts-expect-error: hush\n const value = node && typeof node === 'object' ? node : {}\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {ActionTuple} */\n let result = []\n /** @type {ActionTuple} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<Parent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || null)) {\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n // @ts-expect-error looks like a parent.\n if (node.children && result[0] !== SKIP) {\n // @ts-expect-error looks like a parent.\n offset = (reverse ? node.children.length : -1) + step\n // @ts-expect-error looks like a parent.\n grandparents = parents.concat(node)\n\n // @ts-expect-error looks like a parent.\n while (offset > -1 && offset < node.children.length) {\n // @ts-expect-error looks like a parent.\n subresult = factory(node.children[offset], offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n\n return result\n }\n }\n }\n )\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {ActionTuple}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return [value]\n}\n"],"names":["convert","index","color"],"mappings":";;;;AAgFY,MAAC,WAAW;AAKZ,MAAC,OAAO;AAKR,MAAC,OAAO;AA+BR,MAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeT,SAAU,MAAM,MAAM,SAAS,SAAS;AACtC,QAAI,OAAO,SAAS,cAAc,OAAO,YAAY,YAAY;AAC/D,gBAAU;AAEV,gBAAU;AACV,aAAO;AAAA,IACR;AAED,UAAM,KAAKA,MAAO,QAAC,IAAI;AACvB,UAAM,OAAO,UAAU,KAAK;AAE5B,YAAQ,MAAM,QAAW,CAAA,CAAE,EAAG;AAO9B,aAAS,QAAQ,MAAMC,QAAO,SAAS;AAGrC,YAAM,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO,CAAE;AAE1D,UAAI,OAAO,MAAM,SAAS,UAAU;AAClC,cAAM;AAAA;AAAA,UAEJ,OAAO,MAAM,YAAY,WACrB,MAAM;AAAA;AAAA,YAER,OAAO,MAAM,SAAS,WACpB,MAAM,OACN;AAAA;AAAA;AAEN,eAAO,eAAe,OAAO,QAAQ;AAAA,UACnC,OACE,WAAWC,cAAK,MAAC,KAAK,QAAQ,OAAO,MAAM,OAAO,MAAM,GAAG,IAAI;AAAA,QAC7E,CAAW;AAAA,MACF;AAED,aAAO;AAEP,eAAS,QAAQ;AAEf,YAAI,SAAS,CAAE;AAEf,YAAI;AAEJ,YAAI;AAEJ,YAAI;AAEJ,YAAI,CAAC,QAAQ,GAAG,MAAMD,QAAO,QAAQ,QAAQ,SAAS,CAAC,KAAK,IAAI,GAAG;AACjE,mBAAS,SAAS,QAAQ,MAAM,OAAO,CAAC;AAExC,cAAI,OAAO,CAAC,MAAM,MAAM;AACtB,mBAAO;AAAA,UACR;AAAA,QACF;AAGD,YAAI,KAAK,YAAY,OAAO,CAAC,MAAM,MAAM;AAEvC,oBAAU,UAAU,KAAK,SAAS,SAAS,MAAM;AAEjD,yBAAe,QAAQ,OAAO,IAAI;AAGlC,iBAAO,SAAS,MAAM,SAAS,KAAK,SAAS,QAAQ;AAEnD,wBAAY,QAAQ,KAAK,SAAS,MAAM,GAAG,QAAQ,YAAY,EAAG;AAElE,gBAAI,UAAU,CAAC,MAAM,MAAM;AACzB,qBAAO;AAAA,YACR;AAED,qBACE,OAAO,UAAU,CAAC,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS;AAAA,UAC9D;AAAA,QACF;AAED,eAAO;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA;AAWL,SAAS,SAAS,OAAO;AACvB,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO;AAAA,EACR;AAED,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,CAAC,UAAU,KAAK;AAAA,EACxB;AAED,SAAO,CAAC,KAAK;AACf;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { color } from "./color.browser.js";
|
|
2
|
-
import { convert } from "../../unist-util-is/lib/index.js";
|
|
3
|
-
const CONTINUE = true;
|
|
4
|
-
const EXIT = false;
|
|
5
|
-
const SKIP = "skip";
|
|
6
|
-
const visitParents = (
|
|
7
|
-
/**
|
|
8
|
-
* @type {(
|
|
9
|
-
* (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
|
|
10
|
-
* (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
|
|
11
|
-
* )}
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @param {Node} tree
|
|
15
|
-
* @param {Test} test
|
|
16
|
-
* @param {Visitor<Node>} visitor
|
|
17
|
-
* @param {boolean | null | undefined} [reverse]
|
|
18
|
-
* @returns {void}
|
|
19
|
-
*/
|
|
20
|
-
function(tree, test, visitor, reverse) {
|
|
21
|
-
if (typeof test === "function" && typeof visitor !== "function") {
|
|
22
|
-
reverse = visitor;
|
|
23
|
-
visitor = test;
|
|
24
|
-
test = null;
|
|
25
|
-
}
|
|
26
|
-
const is = convert(test);
|
|
27
|
-
const step = reverse ? -1 : 1;
|
|
28
|
-
factory(tree, void 0, [])();
|
|
29
|
-
function factory(node, index, parents) {
|
|
30
|
-
const value = node && typeof node === "object" ? node : {};
|
|
31
|
-
if (typeof value.type === "string") {
|
|
32
|
-
const name = (
|
|
33
|
-
// `hast`
|
|
34
|
-
typeof value.tagName === "string" ? value.tagName : (
|
|
35
|
-
// `xast`
|
|
36
|
-
typeof value.name === "string" ? value.name : void 0
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
Object.defineProperty(visit, "name", {
|
|
40
|
-
value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return visit;
|
|
44
|
-
function visit() {
|
|
45
|
-
let result = [];
|
|
46
|
-
let subresult;
|
|
47
|
-
let offset;
|
|
48
|
-
let grandparents;
|
|
49
|
-
if (!test || is(node, index, parents[parents.length - 1] || null)) {
|
|
50
|
-
result = toResult(visitor(node, parents));
|
|
51
|
-
if (result[0] === EXIT) {
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (node.children && result[0] !== SKIP) {
|
|
56
|
-
offset = (reverse ? node.children.length : -1) + step;
|
|
57
|
-
grandparents = parents.concat(node);
|
|
58
|
-
while (offset > -1 && offset < node.children.length) {
|
|
59
|
-
subresult = factory(node.children[offset], offset, grandparents)();
|
|
60
|
-
if (subresult[0] === EXIT) {
|
|
61
|
-
return subresult;
|
|
62
|
-
}
|
|
63
|
-
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
function toResult(value) {
|
|
72
|
-
if (Array.isArray(value)) {
|
|
73
|
-
return value;
|
|
74
|
-
}
|
|
75
|
-
if (typeof value === "number") {
|
|
76
|
-
return [CONTINUE, value];
|
|
77
|
-
}
|
|
78
|
-
return [value];
|
|
79
|
-
}
|
|
80
|
-
export {
|
|
81
|
-
CONTINUE,
|
|
82
|
-
EXIT,
|
|
83
|
-
SKIP,
|
|
84
|
-
visitParents
|
|
85
|
-
};
|
|
86
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../node_modules/unist-util-visit-parents/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * @typedef {boolean | 'skip'} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<Ancestor>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * Tree type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from './color.js'\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visitParents =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor<Node>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n test = null\n }\n\n const is = convert(test)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {Node} node\n * @param {number | undefined} index\n * @param {Array<Parent>} parents\n */\n function factory(node, index, parents) {\n /** @type {Record<string, unknown>} */\n // @ts-expect-error: hush\n const value = node && typeof node === 'object' ? node : {}\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {ActionTuple} */\n let result = []\n /** @type {ActionTuple} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<Parent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || null)) {\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n // @ts-expect-error looks like a parent.\n if (node.children && result[0] !== SKIP) {\n // @ts-expect-error looks like a parent.\n offset = (reverse ? node.children.length : -1) + step\n // @ts-expect-error looks like a parent.\n grandparents = parents.concat(node)\n\n // @ts-expect-error looks like a parent.\n while (offset > -1 && offset < node.children.length) {\n // @ts-expect-error looks like a parent.\n subresult = factory(node.children[offset], offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n\n return result\n }\n }\n }\n )\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {ActionTuple}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return [value]\n}\n"],"names":[],"mappings":";;AAgFY,MAAC,WAAW;AAKZ,MAAC,OAAO;AAKR,MAAC,OAAO;AA+BR,MAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeT,SAAU,MAAM,MAAM,SAAS,SAAS;AACtC,QAAI,OAAO,SAAS,cAAc,OAAO,YAAY,YAAY;AAC/D,gBAAU;AAEV,gBAAU;AACV,aAAO;AAAA,IACR;AAED,UAAM,KAAK,QAAQ,IAAI;AACvB,UAAM,OAAO,UAAU,KAAK;AAE5B,YAAQ,MAAM,QAAW,CAAA,CAAE,EAAG;AAO9B,aAAS,QAAQ,MAAM,OAAO,SAAS;AAGrC,YAAM,QAAQ,QAAQ,OAAO,SAAS,WAAW,OAAO,CAAE;AAE1D,UAAI,OAAO,MAAM,SAAS,UAAU;AAClC,cAAM;AAAA;AAAA,UAEJ,OAAO,MAAM,YAAY,WACrB,MAAM;AAAA;AAAA,YAER,OAAO,MAAM,SAAS,WACpB,MAAM,OACN;AAAA;AAAA;AAEN,eAAO,eAAe,OAAO,QAAQ;AAAA,UACnC,OACE,WAAW,MAAM,KAAK,QAAQ,OAAO,MAAM,OAAO,MAAM,GAAG,IAAI;AAAA,QAC7E,CAAW;AAAA,MACF;AAED,aAAO;AAEP,eAAS,QAAQ;AAEf,YAAI,SAAS,CAAE;AAEf,YAAI;AAEJ,YAAI;AAEJ,YAAI;AAEJ,YAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,QAAQ,QAAQ,SAAS,CAAC,KAAK,IAAI,GAAG;AACjE,mBAAS,SAAS,QAAQ,MAAM,OAAO,CAAC;AAExC,cAAI,OAAO,CAAC,MAAM,MAAM;AACtB,mBAAO;AAAA,UACR;AAAA,QACF;AAGD,YAAI,KAAK,YAAY,OAAO,CAAC,MAAM,MAAM;AAEvC,oBAAU,UAAU,KAAK,SAAS,SAAS,MAAM;AAEjD,yBAAe,QAAQ,OAAO,IAAI;AAGlC,iBAAO,SAAS,MAAM,SAAS,KAAK,SAAS,QAAQ;AAEnD,wBAAY,QAAQ,KAAK,SAAS,MAAM,GAAG,QAAQ,YAAY,EAAG;AAElE,gBAAI,UAAU,CAAC,MAAM,MAAM;AACzB,qBAAO;AAAA,YACR;AAED,qBACE,OAAO,UAAU,CAAC,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS;AAAA,UAC9D;AAAA,QACF;AAED,eAAO;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA;AAWL,SAAS,SAAS,OAAO;AACvB,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO;AAAA,EACR;AAED,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,CAAC,UAAU,KAAK;AAAA,EACxB;AAED,SAAO,CAAC,KAAK;AACf;","x_google_ignoreList":[0]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const t = require("io-ts");
|
|
4
|
-
function _interopNamespaceDefault(e) {
|
|
5
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
-
if (e) {
|
|
7
|
-
for (const k in e) {
|
|
8
|
-
if (k !== "default") {
|
|
9
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: () => e[k]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
n.default = e;
|
|
18
|
-
return Object.freeze(n);
|
|
19
|
-
}
|
|
20
|
-
const t__namespace = /* @__PURE__ */ _interopNamespaceDefault(t);
|
|
21
|
-
const functionCodec = new t__namespace.Type(
|
|
22
|
-
"function",
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
24
|
-
(input) => typeof input === "function",
|
|
25
|
-
(input, context) => typeof input === "function" ? t__namespace.success(input) : t__namespace.failure(input, context),
|
|
26
|
-
t__namespace.identity
|
|
27
|
-
);
|
|
28
|
-
exports.functionCodec = functionCodec;
|
|
29
|
-
//# sourceMappingURL=functionCodec.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functionCodec.cjs","sources":["../../../src/lib/functionCodec.ts"],"sourcesContent":["import * as t from \"io-ts\";\n\nexport const functionCodec = new t.Type<\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\tFunction,\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\tFunction,\n\tunknown\n>(\n\t\"function\",\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t(input: unknown): input is Function => typeof input === \"function\",\n\t(input, context) =>\n\t\ttypeof input === \"function\" ? t.success(input) : t.failure(input, context),\n\tt.identity,\n);\n"],"names":["t"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEa,MAAA,gBAAgB,IAAIA,aAAE;AAAA,EAOlC;AAAA;AAAA,EAEA,CAAC,UAAsC,OAAO,UAAU;AAAA,EACxD,CAAC,OAAO,YACP,OAAO,UAAU,aAAaA,aAAE,QAAQ,KAAK,IAAIA,aAAE,QAAQ,OAAO,OAAO;AAAA,EAC1EA,aAAE;AAAQ;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
const functionCodec = new t.Type(
|
|
3
|
-
"function",
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
|
-
(input) => typeof input === "function",
|
|
6
|
-
(input, context) => typeof input === "function" ? t.success(input) : t.failure(input, context),
|
|
7
|
-
t.identity
|
|
8
|
-
);
|
|
9
|
-
export {
|
|
10
|
-
functionCodec
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=functionCodec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functionCodec.js","sources":["../../../src/lib/functionCodec.ts"],"sourcesContent":["import * as t from \"io-ts\";\n\nexport const functionCodec = new t.Type<\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\tFunction,\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\tFunction,\n\tunknown\n>(\n\t\"function\",\n\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t(input: unknown): input is Function => typeof input === \"function\",\n\t(input, context) =>\n\t\ttypeof input === \"function\" ? t.success(input) : t.failure(input, context),\n\tt.identity,\n);\n"],"names":[],"mappings":";AAEa,MAAA,gBAAgB,IAAI,EAAE;AAAA,EAOlC;AAAA;AAAA,EAEA,CAAC,UAAsC,OAAO,UAAU;AAAA,EACxD,CAAC,OAAO,YACP,OAAO,UAAU,aAAa,EAAE,QAAQ,KAAK,IAAI,EAAE,QAAQ,OAAO,OAAO;AAAA,EAC1E,EAAE;AAAQ;"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
-
const index = require('./../_node_modules/unist-util-visit/lib/index.cjs');
|
|
26
|
-
const createRehypeStarryNight = async () => {
|
|
27
|
-
const { createStarryNight, common } = await import("@wooorm/starry-night");
|
|
28
|
-
const { default: tsxGrammar } = await import("@wooorm/starry-night/lang/source.tsx.js");
|
|
29
|
-
const { default: vueGrammar } = await import("@wooorm/starry-night/lang/text.html.vue.js");
|
|
30
|
-
const { toString } = await import("hast-util-to-string");
|
|
31
|
-
return (options = {}) => {
|
|
32
|
-
const grammars = options.grammars || [...common, tsxGrammar, vueGrammar];
|
|
33
|
-
const starryNightPromise = createStarryNight(grammars);
|
|
34
|
-
const prefix = "language-";
|
|
35
|
-
return async (tree) => {
|
|
36
|
-
const starryNight = await starryNightPromise;
|
|
37
|
-
index.visit(tree, "element", function(node, index2, parent) {
|
|
38
|
-
if (!parent || index2 === null || node.tagName !== "pre") {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const head = node.children[0];
|
|
42
|
-
if (!head || head.type !== "element" || head.tagName !== "code" || !head.properties) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const classes = head.properties.className;
|
|
46
|
-
if (!Array.isArray(classes)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const language = classes.find((d) => typeof d === "string" && d.startsWith(prefix));
|
|
50
|
-
if (typeof language !== "string") {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const scope = starryNight.flagToScope(language.slice(prefix.length));
|
|
54
|
-
if (!scope) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const fragment = starryNight.highlight(toString(head), scope);
|
|
58
|
-
const children = fragment.children;
|
|
59
|
-
parent.children.splice(index2, 1, {
|
|
60
|
-
type: "element",
|
|
61
|
-
tagName: "div",
|
|
62
|
-
properties: {
|
|
63
|
-
className: [
|
|
64
|
-
"highlight",
|
|
65
|
-
"highlight-" + scope.replace(/^source\./, "").replace(/\./g, "-")
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
children: [
|
|
69
|
-
{ type: "element", tagName: "pre", properties: {}, children }
|
|
70
|
-
]
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
let processor;
|
|
77
|
-
const markdownToHTML = async (markdown) => {
|
|
78
|
-
if (!processor) {
|
|
79
|
-
const { unified } = await import("unified");
|
|
80
|
-
const remarkParse = await import("remark-parse");
|
|
81
|
-
const remarkGfm = await import("remark-gfm");
|
|
82
|
-
const remarkRehype = await import("remark-rehype");
|
|
83
|
-
const rehypeStringify = await import("rehype-stringify");
|
|
84
|
-
const rehypeStarryNight = await createRehypeStarryNight();
|
|
85
|
-
processor = unified().use(remarkParse.default).use(remarkGfm.default).use(remarkRehype.default).use(rehypeStarryNight).use(rehypeStringify.default);
|
|
86
|
-
}
|
|
87
|
-
const virtualFile = await processor.process(markdown);
|
|
88
|
-
return virtualFile.toString();
|
|
89
|
-
};
|
|
90
|
-
exports.markdownToHTML = markdownToHTML;
|
|
91
|
-
//# sourceMappingURL=markdownToHTML.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdownToHTML.cjs","sources":["../../../src/lib/markdownToHTML.ts"],"sourcesContent":["import type { Plugin, Processor } from \"unified\";\nimport type { Root, ElementContent } from \"hast\";\nimport type { Grammar } from \"@wooorm/starry-night\";\nimport { visit } from \"unist-util-visit\";\n\ntype RehypeStarryNightOptions = {\n\tgrammars?: Grammar[];\n};\n\n/**\n * Rehype plugin to highlight code with `starry-night`.\n *\n * Adapted from:\n * https://github.com/wooorm/starry-night/tree/c73aac7b8bff41ada86747f668dd932a791b851b#example-integrate-with-unified-remark-and-rehype\n */\nconst createRehypeStarryNight = async (): Promise<\n\tPlugin<[options?: RehypeStarryNightOptions], Root>\n> => {\n\tconst { createStarryNight, common } = await import(\"@wooorm/starry-night\");\n\tconst { default: tsxGrammar } = await import(\n\t\t\"@wooorm/starry-night/lang/source.tsx.js\"\n\t);\n\tconst { default: vueGrammar } = await import(\n\t\t\"@wooorm/starry-night/lang/text.html.vue.js\"\n\t);\n\tconst { toString } = await import(\"hast-util-to-string\");\n\n\treturn (options = {}) => {\n\t\tconst grammars = options.grammars || [...common, tsxGrammar, vueGrammar];\n\t\tconst starryNightPromise = createStarryNight(grammars);\n\t\tconst prefix = \"language-\";\n\n\t\treturn async (tree) => {\n\t\t\tconst starryNight = await starryNightPromise;\n\n\t\t\tvisit(tree, \"element\", function (node, index, parent) {\n\t\t\t\tif (!parent || index === null || node.tagName !== \"pre\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst head = node.children[0];\n\n\t\t\t\tif (\n\t\t\t\t\t!head ||\n\t\t\t\t\thead.type !== \"element\" ||\n\t\t\t\t\thead.tagName !== \"code\" ||\n\t\t\t\t\t!head.properties\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst classes = head.properties.className;\n\n\t\t\t\tif (!Array.isArray(classes)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst language = classes.find(\n\t\t\t\t\t(d) => typeof d === \"string\" && d.startsWith(prefix),\n\t\t\t\t);\n\n\t\t\t\tif (typeof language !== \"string\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scope = starryNight.flagToScope(language.slice(prefix.length));\n\n\t\t\t\t// Maybe warn?\n\t\t\t\tif (!scope) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst fragment = starryNight.highlight(toString(head), scope);\n\t\t\t\tconst children = fragment.children as ElementContent[];\n\n\t\t\t\tparent.children.splice(index, 1, {\n\t\t\t\t\ttype: \"element\",\n\t\t\t\t\ttagName: \"div\",\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tclassName: [\n\t\t\t\t\t\t\t\"highlight\",\n\t\t\t\t\t\t\t\"highlight-\" + scope.replace(/^source\\./, \"\").replace(/\\./g, \"-\"),\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{ type: \"element\", tagName: \"pre\", properties: {}, children },\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t};\n};\n\nlet processor: Processor;\n\nexport const markdownToHTML = async (markdown: string): Promise<string> => {\n\tif (!processor) {\n\t\tconst { unified } = await import(\"unified\");\n\t\tconst remarkParse = await import(\"remark-parse\");\n\t\tconst remarkGfm = await import(\"remark-gfm\");\n\t\tconst remarkRehype = await import(\"remark-rehype\");\n\t\tconst rehypeStringify = await import(\"rehype-stringify\");\n\t\tconst rehypeStarryNight = await createRehypeStarryNight();\n\n\t\tprocessor = unified()\n\t\t\t.use(remarkParse.default)\n\t\t\t.use(remarkGfm.default)\n\t\t\t.use(remarkRehype.default)\n\t\t\t.use(rehypeStarryNight)\n\t\t\t.use(rehypeStringify.default);\n\t}\n\n\tconst virtualFile = await processor.process(markdown);\n\n\treturn virtualFile.toString();\n};\n"],"names":["visit","index"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,0BAA0B,YAE5B;AACH,QAAM,EAAE,mBAAmB,OAAW,IAAA,MAAM,OAAO,sBAAsB;AACzE,QAAM,EAAE,SAAS,WAAe,IAAA,MAAM,OACrC,yCAAyC;AAE1C,QAAM,EAAE,SAAS,WAAe,IAAA,MAAM,OACrC,4CAA4C;AAE7C,QAAM,EAAE,SAAA,IAAa,MAAM,OAAO,qBAAqB;AAEhD,SAAA,CAAC,UAAU,OAAM;AACvB,UAAM,WAAW,QAAQ,YAAY,CAAC,GAAG,QAAQ,YAAY,UAAU;AACjE,UAAA,qBAAqB,kBAAkB,QAAQ;AACrD,UAAM,SAAS;AAEf,WAAO,OAAO,SAAQ;AACrB,YAAM,cAAc,MAAM;AAE1BA,YAAA,MAAM,MAAM,WAAW,SAAU,MAAMC,QAAO,QAAM;AACnD,YAAI,CAAC,UAAUA,WAAU,QAAQ,KAAK,YAAY,OAAO;AACxD;AAAA,QACA;AAEK,cAAA,OAAO,KAAK,SAAS,CAAC;AAG3B,YAAA,CAAC,QACD,KAAK,SAAS,aACd,KAAK,YAAY,UACjB,CAAC,KAAK,YACL;AACD;AAAA,QACA;AAEK,cAAA,UAAU,KAAK,WAAW;AAEhC,YAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AAC5B;AAAA,QACA;AAEK,cAAA,WAAW,QAAQ,KACxB,CAAC,MAAM,OAAO,MAAM,YAAY,EAAE,WAAW,MAAM,CAAC;AAGjD,YAAA,OAAO,aAAa,UAAU;AACjC;AAAA,QACA;AAED,cAAM,QAAQ,YAAY,YAAY,SAAS,MAAM,OAAO,MAAM,CAAC;AAGnE,YAAI,CAAC,OAAO;AACX;AAAA,QACA;AAED,cAAM,WAAW,YAAY,UAAU,SAAS,IAAI,GAAG,KAAK;AAC5D,cAAM,WAAW,SAAS;AAEnB,eAAA,SAAS,OAAOA,QAAO,GAAG;AAAA,UAChC,MAAM;AAAA,UACN,SAAS;AAAA,UACT,YAAY;AAAA,YACX,WAAW;AAAA,cACV;AAAA,cACA,eAAe,MAAM,QAAQ,aAAa,EAAE,EAAE,QAAQ,OAAO,GAAG;AAAA,YAChE;AAAA,UACD;AAAA,UACD,UAAU;AAAA,YACT,EAAE,MAAM,WAAW,SAAS,OAAO,YAAY,IAAI,SAAU;AAAA,UAC7D;AAAA,QAAA,CACD;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,IAAI;AAES,MAAA,iBAAiB,OAAO,aAAqC;AACzE,MAAI,CAAC,WAAW;AACf,UAAM,EAAE,QAAA,IAAY,MAAM,OAAO,SAAS;AACpC,UAAA,cAAc,MAAM,OAAO,cAAc;AACzC,UAAA,YAAY,MAAM,OAAO,YAAY;AACrC,UAAA,eAAe,MAAM,OAAO,eAAe;AAC3C,UAAA,kBAAkB,MAAM,OAAO,kBAAkB;AACjD,UAAA,oBAAoB,MAAM;AAEhC,gBAAY,QACV,EAAA,IAAI,YAAY,OAAO,EACvB,IAAI,UAAU,OAAO,EACrB,IAAI,aAAa,OAAO,EACxB,IAAI,iBAAiB,EACrB,IAAI,gBAAgB,OAAO;AAAA,EAC7B;AAED,QAAM,cAAc,MAAM,UAAU,QAAQ,QAAQ;AAEpD,SAAO,YAAY;AACpB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const markdownToHTML: (markdown: string) => Promise<string>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { visit } from './../_node_modules/unist-util-visit/lib/index.js';
|
|
2
|
-
const createRehypeStarryNight = async () => {
|
|
3
|
-
const { createStarryNight, common } = await import("@wooorm/starry-night");
|
|
4
|
-
const { default: tsxGrammar } = await import("@wooorm/starry-night/lang/source.tsx.js");
|
|
5
|
-
const { default: vueGrammar } = await import("@wooorm/starry-night/lang/text.html.vue.js");
|
|
6
|
-
const { toString } = await import("hast-util-to-string");
|
|
7
|
-
return (options = {}) => {
|
|
8
|
-
const grammars = options.grammars || [...common, tsxGrammar, vueGrammar];
|
|
9
|
-
const starryNightPromise = createStarryNight(grammars);
|
|
10
|
-
const prefix = "language-";
|
|
11
|
-
return async (tree) => {
|
|
12
|
-
const starryNight = await starryNightPromise;
|
|
13
|
-
visit(tree, "element", function(node, index, parent) {
|
|
14
|
-
if (!parent || index === null || node.tagName !== "pre") {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const head = node.children[0];
|
|
18
|
-
if (!head || head.type !== "element" || head.tagName !== "code" || !head.properties) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const classes = head.properties.className;
|
|
22
|
-
if (!Array.isArray(classes)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const language = classes.find((d) => typeof d === "string" && d.startsWith(prefix));
|
|
26
|
-
if (typeof language !== "string") {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const scope = starryNight.flagToScope(language.slice(prefix.length));
|
|
30
|
-
if (!scope) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
const fragment = starryNight.highlight(toString(head), scope);
|
|
34
|
-
const children = fragment.children;
|
|
35
|
-
parent.children.splice(index, 1, {
|
|
36
|
-
type: "element",
|
|
37
|
-
tagName: "div",
|
|
38
|
-
properties: {
|
|
39
|
-
className: [
|
|
40
|
-
"highlight",
|
|
41
|
-
"highlight-" + scope.replace(/^source\./, "").replace(/\./g, "-")
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
children: [
|
|
45
|
-
{ type: "element", tagName: "pre", properties: {}, children }
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
let processor;
|
|
53
|
-
const markdownToHTML = async (markdown) => {
|
|
54
|
-
if (!processor) {
|
|
55
|
-
const { unified } = await import("unified");
|
|
56
|
-
const remarkParse = await import("remark-parse");
|
|
57
|
-
const remarkGfm = await import("remark-gfm");
|
|
58
|
-
const remarkRehype = await import("remark-rehype");
|
|
59
|
-
const rehypeStringify = await import("rehype-stringify");
|
|
60
|
-
const rehypeStarryNight = await createRehypeStarryNight();
|
|
61
|
-
processor = unified().use(remarkParse.default).use(remarkGfm.default).use(remarkRehype.default).use(rehypeStarryNight).use(rehypeStringify.default);
|
|
62
|
-
}
|
|
63
|
-
const virtualFile = await processor.process(markdown);
|
|
64
|
-
return virtualFile.toString();
|
|
65
|
-
};
|
|
66
|
-
export {
|
|
67
|
-
markdownToHTML
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=markdownToHTML.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdownToHTML.js","sources":["../../../src/lib/markdownToHTML.ts"],"sourcesContent":["import type { Plugin, Processor } from \"unified\";\nimport type { Root, ElementContent } from \"hast\";\nimport type { Grammar } from \"@wooorm/starry-night\";\nimport { visit } from \"unist-util-visit\";\n\ntype RehypeStarryNightOptions = {\n\tgrammars?: Grammar[];\n};\n\n/**\n * Rehype plugin to highlight code with `starry-night`.\n *\n * Adapted from:\n * https://github.com/wooorm/starry-night/tree/c73aac7b8bff41ada86747f668dd932a791b851b#example-integrate-with-unified-remark-and-rehype\n */\nconst createRehypeStarryNight = async (): Promise<\n\tPlugin<[options?: RehypeStarryNightOptions], Root>\n> => {\n\tconst { createStarryNight, common } = await import(\"@wooorm/starry-night\");\n\tconst { default: tsxGrammar } = await import(\n\t\t\"@wooorm/starry-night/lang/source.tsx.js\"\n\t);\n\tconst { default: vueGrammar } = await import(\n\t\t\"@wooorm/starry-night/lang/text.html.vue.js\"\n\t);\n\tconst { toString } = await import(\"hast-util-to-string\");\n\n\treturn (options = {}) => {\n\t\tconst grammars = options.grammars || [...common, tsxGrammar, vueGrammar];\n\t\tconst starryNightPromise = createStarryNight(grammars);\n\t\tconst prefix = \"language-\";\n\n\t\treturn async (tree) => {\n\t\t\tconst starryNight = await starryNightPromise;\n\n\t\t\tvisit(tree, \"element\", function (node, index, parent) {\n\t\t\t\tif (!parent || index === null || node.tagName !== \"pre\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst head = node.children[0];\n\n\t\t\t\tif (\n\t\t\t\t\t!head ||\n\t\t\t\t\thead.type !== \"element\" ||\n\t\t\t\t\thead.tagName !== \"code\" ||\n\t\t\t\t\t!head.properties\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst classes = head.properties.className;\n\n\t\t\t\tif (!Array.isArray(classes)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst language = classes.find(\n\t\t\t\t\t(d) => typeof d === \"string\" && d.startsWith(prefix),\n\t\t\t\t);\n\n\t\t\t\tif (typeof language !== \"string\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scope = starryNight.flagToScope(language.slice(prefix.length));\n\n\t\t\t\t// Maybe warn?\n\t\t\t\tif (!scope) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst fragment = starryNight.highlight(toString(head), scope);\n\t\t\t\tconst children = fragment.children as ElementContent[];\n\n\t\t\t\tparent.children.splice(index, 1, {\n\t\t\t\t\ttype: \"element\",\n\t\t\t\t\ttagName: \"div\",\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tclassName: [\n\t\t\t\t\t\t\t\"highlight\",\n\t\t\t\t\t\t\t\"highlight-\" + scope.replace(/^source\\./, \"\").replace(/\\./g, \"-\"),\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\tchildren: [\n\t\t\t\t\t\t{ type: \"element\", tagName: \"pre\", properties: {}, children },\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t});\n\t\t};\n\t};\n};\n\nlet processor: Processor;\n\nexport const markdownToHTML = async (markdown: string): Promise<string> => {\n\tif (!processor) {\n\t\tconst { unified } = await import(\"unified\");\n\t\tconst remarkParse = await import(\"remark-parse\");\n\t\tconst remarkGfm = await import(\"remark-gfm\");\n\t\tconst remarkRehype = await import(\"remark-rehype\");\n\t\tconst rehypeStringify = await import(\"rehype-stringify\");\n\t\tconst rehypeStarryNight = await createRehypeStarryNight();\n\n\t\tprocessor = unified()\n\t\t\t.use(remarkParse.default)\n\t\t\t.use(remarkGfm.default)\n\t\t\t.use(remarkRehype.default)\n\t\t\t.use(rehypeStarryNight)\n\t\t\t.use(rehypeStringify.default);\n\t}\n\n\tconst virtualFile = await processor.process(markdown);\n\n\treturn virtualFile.toString();\n};\n"],"names":[],"mappings":";AAeA,MAAM,0BAA0B,YAE5B;AACH,QAAM,EAAE,mBAAmB,OAAW,IAAA,MAAM,OAAO,sBAAsB;AACzE,QAAM,EAAE,SAAS,WAAe,IAAA,MAAM,OACrC,yCAAyC;AAE1C,QAAM,EAAE,SAAS,WAAe,IAAA,MAAM,OACrC,4CAA4C;AAE7C,QAAM,EAAE,SAAA,IAAa,MAAM,OAAO,qBAAqB;AAEhD,SAAA,CAAC,UAAU,OAAM;AACvB,UAAM,WAAW,QAAQ,YAAY,CAAC,GAAG,QAAQ,YAAY,UAAU;AACjE,UAAA,qBAAqB,kBAAkB,QAAQ;AACrD,UAAM,SAAS;AAEf,WAAO,OAAO,SAAQ;AACrB,YAAM,cAAc,MAAM;AAE1B,YAAM,MAAM,WAAW,SAAU,MAAM,OAAO,QAAM;AACnD,YAAI,CAAC,UAAU,UAAU,QAAQ,KAAK,YAAY,OAAO;AACxD;AAAA,QACA;AAEK,cAAA,OAAO,KAAK,SAAS,CAAC;AAG3B,YAAA,CAAC,QACD,KAAK,SAAS,aACd,KAAK,YAAY,UACjB,CAAC,KAAK,YACL;AACD;AAAA,QACA;AAEK,cAAA,UAAU,KAAK,WAAW;AAEhC,YAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AAC5B;AAAA,QACA;AAEK,cAAA,WAAW,QAAQ,KACxB,CAAC,MAAM,OAAO,MAAM,YAAY,EAAE,WAAW,MAAM,CAAC;AAGjD,YAAA,OAAO,aAAa,UAAU;AACjC;AAAA,QACA;AAED,cAAM,QAAQ,YAAY,YAAY,SAAS,MAAM,OAAO,MAAM,CAAC;AAGnE,YAAI,CAAC,OAAO;AACX;AAAA,QACA;AAED,cAAM,WAAW,YAAY,UAAU,SAAS,IAAI,GAAG,KAAK;AAC5D,cAAM,WAAW,SAAS;AAEnB,eAAA,SAAS,OAAO,OAAO,GAAG;AAAA,UAChC,MAAM;AAAA,UACN,SAAS;AAAA,UACT,YAAY;AAAA,YACX,WAAW;AAAA,cACV;AAAA,cACA,eAAe,MAAM,QAAQ,aAAa,EAAE,EAAE,QAAQ,OAAO,GAAG;AAAA,YAChE;AAAA,UACD;AAAA,UACD,UAAU;AAAA,YACT,EAAE,MAAM,WAAW,SAAS,OAAO,YAAY,IAAI,SAAU;AAAA,UAC7D;AAAA,QAAA,CACD;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,IAAI;AAES,MAAA,iBAAiB,OAAO,aAAqC;AACzE,MAAI,CAAC,WAAW;AACf,UAAM,EAAE,QAAA,IAAY,MAAM,OAAO,SAAS;AACpC,UAAA,cAAc,MAAM,OAAO,cAAc;AACzC,UAAA,YAAY,MAAM,OAAO,YAAY;AACrC,UAAA,eAAe,MAAM,OAAO,eAAe;AAC3C,UAAA,kBAAkB,MAAM,OAAO,kBAAkB;AACjD,UAAA,oBAAoB,MAAM;AAEhC,gBAAY,QACV,EAAA,IAAI,YAAY,OAAO,EACvB,IAAI,UAAU,OAAO,EACrB,IAAI,aAAa,OAAO,EACxB,IAAI,iBAAiB,EACrB,IAAI,gBAAgB,OAAO;AAAA,EAC7B;AAED,QAAM,cAAc,MAAM,UAAU,QAAQ,QAAQ;AAEpD,SAAO,YAAY;AACpB;"}
|
package/src/lib/functionCodec.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as t from "io-ts";
|
|
2
|
-
|
|
3
|
-
export const functionCodec = new t.Type<
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
|
-
Function,
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
7
|
-
Function,
|
|
8
|
-
unknown
|
|
9
|
-
>(
|
|
10
|
-
"function",
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
12
|
-
(input: unknown): input is Function => typeof input === "function",
|
|
13
|
-
(input, context) =>
|
|
14
|
-
typeof input === "function" ? t.success(input) : t.failure(input, context),
|
|
15
|
-
t.identity,
|
|
16
|
-
);
|