fix: bundle non-shared deps into dist to prevent runtime resolution failures

Move non-allowlisted packages from dependencies/peerDependencies to
devDependencies so tsup bundles them into dist/ instead of leaving
them as external imports that may not resolve at runtime.
This commit is contained in:
saberzero1 2026-03-17 19:31:51 +01:00
parent e63332c22e
commit 21a2acf044
No known key found for this signature in database
3 changed files with 315 additions and 18 deletions

313
dist/index.js vendored
View file

@ -1,5 +1,314 @@
import { visit } from 'unist-util-visit';
import { findAndReplace } from 'mdast-util-find-and-replace';
// node_modules/unist-util-is/lib/index.js
var convert = (
// Note: overloads in JSDoc cant yet use different `@template`s.
/**
* @type {(
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
* ((test?: Test) => Check)
* )}
*/
/**
* @param {Test} [test]
* @returns {Check}
*/
(function(test) {
if (test === null || test === void 0) {
return ok;
}
if (typeof test === "function") {
return castFactory(test);
}
if (typeof test === "object") {
return Array.isArray(test) ? anyFactory(test) : (
// Cast because `ReadonlyArray` goes into the above but `isArray`
// narrows to `Array`.
propertiesFactory(
/** @type {Props} */
test
)
);
}
if (typeof test === "string") {
return typeFactory(test);
}
throw new Error("Expected function, string, or object as test");
})
);
function anyFactory(tests) {
const checks = [];
let index = -1;
while (++index < tests.length) {
checks[index] = convert(tests[index]);
}
return castFactory(any);
function any(...parameters) {
let index2 = -1;
while (++index2 < checks.length) {
if (checks[index2].apply(this, parameters)) return true;
}
return false;
}
}
function propertiesFactory(check) {
const checkAsRecord = (
/** @type {Record<string, unknown>} */
check
);
return castFactory(all);
function all(node) {
const nodeAsRecord = (
/** @type {Record<string, unknown>} */
/** @type {unknown} */
node
);
let key;
for (key in check) {
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
}
return true;
}
}
function typeFactory(check) {
return castFactory(type);
function type(node) {
return node && node.type === check;
}
}
function castFactory(testFunction) {
return check;
function check(value, index, parent) {
return Boolean(
looksLikeANode(value) && testFunction.call(
this,
value,
typeof index === "number" ? index : void 0,
parent || void 0
)
);
}
}
function ok() {
return true;
}
function looksLikeANode(value) {
return value !== null && typeof value === "object" && "type" in value;
}
// node_modules/unist-util-visit-parents/lib/color.node.js
function color(d) {
return "\x1B[33m" + d + "\x1B[39m";
}
// node_modules/unist-util-visit-parents/lib/index.js
var empty = [];
var CONTINUE = true;
var EXIT = false;
var SKIP = "skip";
function visitParents(tree, test, visitor, reverse) {
let check;
if (typeof test === "function" && typeof visitor !== "function") {
reverse = visitor;
visitor = test;
} else {
check = test;
}
const is2 = convert(check);
const step = reverse ? -1 : 1;
factory(tree, void 0, [])();
function factory(node, index, parents) {
const value = (
/** @type {Record<string, unknown>} */
node && typeof node === "object" ? node : {}
);
if (typeof value.type === "string") {
const name = (
// `hast`
typeof value.tagName === "string" ? value.tagName : (
// `xast`
typeof value.name === "string" ? value.name : void 0
)
);
Object.defineProperty(visit2, "name", {
value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
});
}
return visit2;
function visit2() {
let result = empty;
let subresult;
let offset;
let grandparents;
if (!test || is2(node, index, parents[parents.length - 1] || void 0)) {
result = toResult(visitor(node, parents));
if (result[0] === EXIT) {
return result;
}
}
if ("children" in node && node.children) {
const nodeAsParent = (
/** @type {UnistParent} */
node
);
if (nodeAsParent.children && result[0] !== SKIP) {
offset = (reverse ? nodeAsParent.children.length : -1) + step;
grandparents = parents.concat(nodeAsParent);
while (offset > -1 && offset < nodeAsParent.children.length) {
const child = nodeAsParent.children[offset];
subresult = factory(child, offset, grandparents)();
if (subresult[0] === EXIT) {
return subresult;
}
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
}
}
}
return result;
}
}
}
function toResult(value) {
if (Array.isArray(value)) {
return value;
}
if (typeof value === "number") {
return [CONTINUE, value];
}
return value === null || value === void 0 ? empty : [value];
}
// node_modules/unist-util-visit/lib/index.js
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
let reverse;
let test;
let visitor;
{
test = testOrVisitor;
visitor = visitorOrReverse;
reverse = maybeReverse;
}
visitParents(tree, test, overload, reverse);
function overload(node, parents) {
const parent = parents[parents.length - 1];
const index = parent ? parent.children.indexOf(node) : void 0;
return visitor(node, index, parent);
}
}
// node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp/index.js
function escapeStringRegexp(string) {
if (typeof string !== "string") {
throw new TypeError("Expected a string");
}
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
}
// node_modules/mdast-util-find-and-replace/lib/index.js
function findAndReplace(tree, list, options) {
const settings = {};
const ignored = convert(settings.ignore || []);
const pairs = toPairs(list);
let pairIndex = -1;
while (++pairIndex < pairs.length) {
visitParents(tree, "text", visitor);
}
function visitor(node, parents) {
let index = -1;
let grandparent;
while (++index < parents.length) {
const parent = parents[index];
const siblings = grandparent ? grandparent.children : void 0;
if (ignored(
parent,
siblings ? siblings.indexOf(parent) : void 0,
grandparent
)) {
return;
}
grandparent = parent;
}
if (grandparent) {
return handler(node, parents);
}
}
function handler(node, parents) {
const parent = parents[parents.length - 1];
const find = pairs[pairIndex][0];
const replace = pairs[pairIndex][1];
let start = 0;
const siblings = parent.children;
const index = siblings.indexOf(node);
let change = false;
let nodes = [];
find.lastIndex = 0;
let match = find.exec(node.value);
while (match) {
const position = match.index;
const matchObject = {
index: match.index,
input: match.input,
stack: [...parents, node]
};
let value = replace(...match, matchObject);
if (typeof value === "string") {
value = value.length > 0 ? { type: "text", value } : void 0;
}
if (value === false) {
find.lastIndex = position + 1;
} else {
if (start !== position) {
nodes.push({
type: "text",
value: node.value.slice(start, position)
});
}
if (Array.isArray(value)) {
nodes.push(...value);
} else if (value) {
nodes.push(value);
}
start = position + match[0].length;
change = true;
}
if (!find.global) {
break;
}
match = find.exec(node.value);
}
if (change) {
if (start < node.value.length) {
nodes.push({ type: "text", value: node.value.slice(start) });
}
parent.children.splice(index, 1, ...nodes);
} else {
nodes = [node];
}
return index + nodes.length;
}
}
function toPairs(tupleOrList) {
const result = [];
if (!Array.isArray(tupleOrList)) {
throw new TypeError("Expected find and replace tuple or list of tuples");
}
const list = !tupleOrList[0] || Array.isArray(tupleOrList[0]) ? tupleOrList : [tupleOrList];
let index = -1;
while (++index < list.length) {
const tuple = list[index];
result.push([toExpression(tuple[0]), toFunction(tuple[1])]);
}
return result;
}
function toExpression(find) {
return typeof find === "string" ? new RegExp(escapeStringRegexp(find), "g") : find;
}
function toFunction(replace) {
return typeof replace === "function" ? replace : function() {
return replace;
};
}
// src/transformer.ts
var defaultOptions = {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -44,10 +44,7 @@
},
"peerDependencies": {
"@jackyzha0/quartz": "^4.5.2",
"mdast-util-find-and-replace": "^3.0.1",
"preact": "^10.0.0",
"unified": "^11.0.5",
"unist-util-visit": "^5.0.0"
"preact": "^10.0.0"
},
"peerDependenciesMeta": {
"@jackyzha0/quartz": {
@ -55,20 +52,10 @@
},
"preact": {
"optional": false
},
"mdast-util-find-and-replace": {
"optional": true
},
"unified": {
"optional": true
},
"unist-util-visit": {
"optional": true
}
},
"dependencies": {
"@quartz-community/types": "github:quartz-community/types",
"mdast": "^3.0.0"
"@quartz-community/types": "github:quartz-community/types"
},
"devDependencies": {
"@types/hast": "^3.0.4",
@ -78,6 +65,7 @@
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"mdast": "^3.0.0",
"mdast-util-find-and-replace": "^3.0.2",
"preact": "^10.28.2",
"prettier": "^3.6.2",