Fix bin/publish: copy docs.dist from project root

Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-21 02:08:33 +00:00
commit f6fac6c4bc
79758 changed files with 10547827 additions and 0 deletions

78
node_modules/domhandler/lib/index.d.ts generated vendored Executable file
View File

@@ -0,0 +1,78 @@
import { Node, Element, DataNode } from "./node";
export * from "./node";
export interface DomHandlerOptions {
/**
* Add a `startIndex` property to nodes.
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
* indicating the position of the start of the node in the document.
*
* @default false
*/
withStartIndices?: boolean;
/**
* Add an `endIndex` property to nodes.
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
* indicating the position of the end of the node in the document.
*
* @default false
*/
withEndIndices?: boolean;
/**
* Replace all whitespace with single spaces.
*
* **Note:** Enabling this might break your markup.
*
* @default false
* @deprecated
*/
normalizeWhitespace?: boolean;
}
interface ParserInterface {
startIndex: number | null;
endIndex: number | null;
}
declare type Callback = (error: Error | null, dom: Node[]) => void;
declare type ElementCallback = (element: Element) => void;
export declare class DomHandler {
/** The constructed DOM */
dom: Node[];
/** Called once parsing has completed. */
private readonly _callback;
/** Settings for the handler. */
private readonly _options;
/** Callback whenever a tag is closed. */
private readonly _elementCB;
/** Indicated whether parsing has been completed. */
private _done;
/** Stack of open tags. */
private _tagStack;
/** A data node that is still being written to. */
private _lastNode;
/** Reference to the parser instance. Used for location information. */
private _parser;
/**
* @param callback Called once parsing has completed.
* @param options Settings for the handler.
* @param elementCB Callback whenever a tag is closed.
*/
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
onparserinit(parser: ParserInterface): void;
onreset(): void;
onend(): void;
onerror(error: Error): void;
onclosetag(): void;
onopentag(name: string, attribs: {
[key: string]: string;
}): void;
ontext(data: string): void;
oncomment(data: string): void;
oncommentend(): void;
oncdatastart(): void;
oncdataend(): void;
onprocessinginstruction(name: string, data: string): void;
protected handleCallback(error: Error | null): void;
protected addNode(node: Node): void;
protected addDataNode(node: DataNode): void;
}
export default DomHandler;
//# sourceMappingURL=index.d.ts.map

1
node_modules/domhandler/lib/index.d.ts.map generated vendored Executable file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,EAKX,MAAM,QAAQ,CAAC;AAEhB,cAAc,QAAQ,CAAC;AAIvB,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AASD,UAAU,eAAe;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,aAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;AAC3D,aAAK,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAElD,qBAAa,UAAU;IACnB,0BAA0B;IACnB,GAAG,EAAE,IAAI,EAAE,CAAM;IAExB,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAE5C,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAE7C,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IAEpD,oDAAoD;IACpD,OAAO,CAAC,KAAK,CAAS;IAEtB,0BAA0B;IAC1B,OAAO,CAAC,SAAS,CAAiB;IAElC,kDAAkD;IAClD,OAAO,CAAC,SAAS,CAAyB;IAE1C,uEAAuE;IACvE,OAAO,CAAC,OAAO,CAAgC;IAE/C;;;;OAIG;gBAEC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAClC,SAAS,CAAC,EAAE,eAAe;IAiBxB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAK3C,OAAO,IAAI,IAAI;IASf,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAI3B,UAAU,IAAI,IAAI;IAgBlB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAMjE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAyB1B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAW7B,YAAY,IAAI,IAAI;IAIpB,YAAY,IAAI,IAAI;IAUpB,UAAU,IAAI,IAAI;IAIlB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhE,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAQnD,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAiCnC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;CAI9C;AAED,eAAe,UAAU,CAAC"}

176
node_modules/domhandler/lib/index.js generated vendored Executable file
View File

@@ -0,0 +1,176 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DomHandler = void 0;
var node_1 = require("./node");
__exportStar(require("./node"), exports);
var reWhitespace = /\s+/g;
// Default options
var defaultOpts = {
normalizeWhitespace: false,
withStartIndices: false,
withEndIndices: false,
};
var DomHandler = /** @class */ (function () {
/**
* @param callback Called once parsing has completed.
* @param options Settings for the handler.
* @param elementCB Callback whenever a tag is closed.
*/
function DomHandler(callback, options, elementCB) {
/** The constructed DOM */
this.dom = [];
/** Indicated whether parsing has been completed. */
this._done = false;
/** Stack of open tags. */
this._tagStack = [];
/** A data node that is still being written to. */
this._lastNode = null;
/** Reference to the parser instance. Used for location information. */
this._parser = null;
// Make it possible to skip arguments, for backwards-compatibility
if (typeof options === "function") {
elementCB = options;
options = defaultOpts;
}
if (typeof callback === "object") {
options = callback;
callback = undefined;
}
this._callback = callback !== null && callback !== void 0 ? callback : null;
this._options = options !== null && options !== void 0 ? options : defaultOpts;
this._elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
}
DomHandler.prototype.onparserinit = function (parser) {
this._parser = parser;
};
// Resets the handler back to starting state
DomHandler.prototype.onreset = function () {
var _a;
this.dom = [];
this._done = false;
this._tagStack = [];
this._lastNode = null;
this._parser = (_a = this._parser) !== null && _a !== void 0 ? _a : null;
};
// Signals the handler that parsing is done
DomHandler.prototype.onend = function () {
if (this._done)
return;
this._done = true;
this._parser = null;
this.handleCallback(null);
};
DomHandler.prototype.onerror = function (error) {
this.handleCallback(error);
};
DomHandler.prototype.onclosetag = function () {
this._lastNode = null;
var elem = this._tagStack.pop();
if (!elem || !this._parser) {
return;
}
if (this._options.withEndIndices) {
elem.endIndex = this._parser.endIndex;
}
if (this._elementCB)
this._elementCB(elem);
};
DomHandler.prototype.onopentag = function (name, attribs) {
var element = new node_1.Element(name, attribs);
this.addNode(element);
this._tagStack.push(element);
};
DomHandler.prototype.ontext = function (data) {
var normalize = this._options.normalizeWhitespace;
var _lastNode = this._lastNode;
if (_lastNode && _lastNode.type === "text" /* Text */) {
if (normalize) {
_lastNode.data = (_lastNode.data + data).replace(reWhitespace, " ");
}
else {
_lastNode.data += data;
}
}
else {
if (normalize) {
data = data.replace(reWhitespace, " ");
}
var node = new node_1.Text(data);
this.addNode(node);
this._lastNode = node;
}
};
DomHandler.prototype.oncomment = function (data) {
if (this._lastNode && this._lastNode.type === "comment" /* Comment */) {
this._lastNode.data += data;
return;
}
var node = new node_1.Comment(data);
this.addNode(node);
this._lastNode = node;
};
DomHandler.prototype.oncommentend = function () {
this._lastNode = null;
};
DomHandler.prototype.oncdatastart = function () {
var text = new node_1.Text("");
var node = new node_1.NodeWithChildren("cdata" /* CDATA */, [text]);
this.addNode(node);
text.parent = node;
this._lastNode = text;
};
DomHandler.prototype.oncdataend = function () {
this._lastNode = null;
};
DomHandler.prototype.onprocessinginstruction = function (name, data) {
var node = new node_1.ProcessingInstruction(name, data);
this.addNode(node);
};
DomHandler.prototype.handleCallback = function (error) {
if (typeof this._callback === "function") {
this._callback(error, this.dom);
}
else if (error) {
throw error;
}
};
DomHandler.prototype.addNode = function (node) {
var parent = this._tagStack[this._tagStack.length - 1];
var siblings = parent ? parent.children : this.dom;
var previousSibling = siblings[siblings.length - 1];
if (this._parser) {
if (this._options.withStartIndices) {
node.startIndex = this._parser.startIndex;
}
if (this._options.withEndIndices) {
node.endIndex = this._parser.endIndex;
}
}
siblings.push(node);
if (previousSibling) {
node.prev = previousSibling;
previousSibling.next = node;
}
if (parent) {
node.parent = parent;
}
this._lastNode = null;
};
DomHandler.prototype.addDataNode = function (node) {
this.addNode(node);
this._lastNode = node;
};
return DomHandler;
}());
exports.DomHandler = DomHandler;
exports.default = DomHandler;

98
node_modules/domhandler/lib/node.d.ts generated vendored Executable file
View File

@@ -0,0 +1,98 @@
import { ElementType } from "domelementtype";
/**
* This object will be used as the prototype for Nodes when creating a
* DOM-Level-1-compliant structure.
*/
export declare class Node {
type: ElementType;
/** Parent of the node */
parent: NodeWithChildren | null;
/** Previous sibling */
prev: Node | null;
/** Next sibling */
next: Node | null;
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
startIndex: number | null;
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
endIndex: number | null;
/**
*
* @param type The type of the node.
*/
constructor(type: ElementType);
get nodeType(): number;
get parentNode(): NodeWithChildren | null;
set parentNode(parent: NodeWithChildren | null);
get previousSibling(): Node | null;
set previousSibling(prev: Node | null);
get nextSibling(): Node | null;
set nextSibling(next: Node | null);
/**
* Clone this node, and optionally its children.
*
* @param recursive Clone child nodes as well.
* @returns A clone of the node.
*/
cloneNode(recursive?: boolean): Node;
}
export declare class DataNode extends Node {
data: string;
/**
* @param type The type of the node
* @param data The content of the data node
*/
constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
get nodeValue(): string;
set nodeValue(data: string);
}
export declare class Text extends DataNode {
constructor(data: string);
}
export declare class Comment extends DataNode {
constructor(data: string);
}
export declare class ProcessingInstruction extends DataNode {
name: string;
constructor(name: string, data: string);
}
export declare class NodeWithChildren extends Node {
children: Node[];
/**
*
* @param type Type of the node.
* @param children Children of the node. Only certain node types can have children.
*/
constructor(type: ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
get firstChild(): Node | null;
get lastChild(): Node | null;
get childNodes(): Node[];
set childNodes(children: Node[]);
}
export declare class Element extends NodeWithChildren {
name: string;
attribs: {
[name: string]: string;
};
/**
* @param name Name of the tag, eg. `div`, `span`.
* @param attribs Object mapping attribute names to attribute values.
* @param children Children of the node.
*/
constructor(name: string, attribs: {
[name: string]: string;
}, children?: Node[]);
get tagName(): string;
set tagName(name: string);
get attributes(): {
name: string;
value: string;
}[];
}
/**
* Clone a node, and optionally its children.
*
* @param recursive Clone child nodes as well.
* @returns A clone of the node.
*/
export declare function cloneNode(node: Node, recursive?: boolean): Node;
//# sourceMappingURL=node.d.ts.map

1
node_modules/domhandler/lib/node.d.ts.map generated vendored Executable file
View File

@@ -0,0 +1 @@
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"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"}

296
node_modules/domhandler/lib/node.js generated vendored Executable file
View File

@@ -0,0 +1,296 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneNode = exports.Element = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
var nodeTypes = new Map([
["tag" /* Tag */, 1],
["script" /* Script */, 1],
["style" /* Style */, 1],
["directive" /* Directive */, 1],
["text" /* Text */, 3],
["cdata" /* CDATA */, 4],
["comment" /* Comment */, 8],
]);
/**
* This object will be used as the prototype for Nodes when creating a
* DOM-Level-1-compliant structure.
*/
var Node = /** @class */ (function () {
/**
*
* @param type The type of the node.
*/
function Node(type) {
this.type = type;
/** Parent of the node */
this.parent = null;
/** Previous sibling */
this.prev = null;
/** Next sibling */
this.next = null;
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
this.startIndex = null;
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
this.endIndex = null;
}
Object.defineProperty(Node.prototype, "nodeType", {
// Read-only aliases
get: function () {
var _a;
return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Node.prototype, "parentNode", {
// Read-write aliases for properties
get: function () {
return this.parent;
},
set: function (parent) {
this.parent = parent;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Node.prototype, "previousSibling", {
get: function () {
return this.prev;
},
set: function (prev) {
this.prev = prev;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Node.prototype, "nextSibling", {
get: function () {
return this.next;
},
set: function (next) {
this.next = next;
},
enumerable: false,
configurable: true
});
/**
* Clone this node, and optionally its children.
*
* @param recursive Clone child nodes as well.
* @returns A clone of the node.
*/
Node.prototype.cloneNode = function (recursive) {
if (recursive === void 0) { recursive = false; }
return cloneNode(this, recursive);
};
return Node;
}());
exports.Node = Node;
var DataNode = /** @class */ (function (_super) {
__extends(DataNode, _super);
/**
* @param type The type of the node
* @param data The content of the data node
*/
function DataNode(type, data) {
var _this = _super.call(this, type) || this;
_this.data = data;
return _this;
}
Object.defineProperty(DataNode.prototype, "nodeValue", {
get: function () {
return this.data;
},
set: function (data) {
this.data = data;
},
enumerable: false,
configurable: true
});
return DataNode;
}(Node));
exports.DataNode = DataNode;
var Text = /** @class */ (function (_super) {
__extends(Text, _super);
function Text(data) {
return _super.call(this, "text" /* Text */, data) || this;
}
return Text;
}(DataNode));
exports.Text = Text;
var Comment = /** @class */ (function (_super) {
__extends(Comment, _super);
function Comment(data) {
return _super.call(this, "comment" /* Comment */, data) || this;
}
return Comment;
}(DataNode));
exports.Comment = Comment;
var ProcessingInstruction = /** @class */ (function (_super) {
__extends(ProcessingInstruction, _super);
function ProcessingInstruction(name, data) {
var _this = _super.call(this, "directive" /* Directive */, data) || this;
_this.name = name;
return _this;
}
return ProcessingInstruction;
}(DataNode));
exports.ProcessingInstruction = ProcessingInstruction;
var NodeWithChildren = /** @class */ (function (_super) {
__extends(NodeWithChildren, _super);
/**
*
* @param type Type of the node.
* @param children Children of the node. Only certain node types can have children.
*/
function NodeWithChildren(type, children) {
var _this = _super.call(this, type) || this;
_this.children = children;
return _this;
}
Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
// Aliases
get: function () {
var _a;
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
},
enumerable: false,
configurable: true
});
Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
get: function () {
return this.children.length > 0
? this.children[this.children.length - 1]
: null;
},
enumerable: false,
configurable: true
});
Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
get: function () {
return this.children;
},
set: function (children) {
this.children = children;
},
enumerable: false,
configurable: true
});
return NodeWithChildren;
}(Node));
exports.NodeWithChildren = NodeWithChildren;
var Element = /** @class */ (function (_super) {
__extends(Element, _super);
/**
* @param name Name of the tag, eg. `div`, `span`.
* @param attribs Object mapping attribute names to attribute values.
* @param children Children of the node.
*/
function Element(name, attribs, children) {
if (children === void 0) { children = []; }
var _this = _super.call(this, name === "script"
? "script" /* Script */
: name === "style"
? "style" /* Style */
: "tag" /* Tag */, children) || this;
_this.name = name;
_this.attribs = attribs;
_this.attribs = attribs;
return _this;
}
Object.defineProperty(Element.prototype, "tagName", {
// DOM Level 1 aliases
get: function () {
return this.name;
},
set: function (name) {
this.name = name;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Element.prototype, "attributes", {
get: function () {
var _this = this;
return Object.keys(this.attribs).map(function (name) { return ({
name: name,
value: _this.attribs[name],
}); });
},
enumerable: false,
configurable: true
});
return Element;
}(NodeWithChildren));
exports.Element = Element;
/**
* Clone a node, and optionally its children.
*
* @param recursive Clone child nodes as well.
* @returns A clone of the node.
*/
function cloneNode(node, recursive) {
if (recursive === void 0) { recursive = false; }
switch (node.type) {
case "text" /* Text */:
return new Text(node.data);
case "directive" /* Directive */: {
var instr = node;
return new ProcessingInstruction(instr.name, instr.data);
}
case "comment" /* Comment */:
return new Comment(node.data);
case "tag" /* Tag */:
case "script" /* Script */:
case "style" /* Style */: {
var elem = node;
var children = recursive ? cloneChildren(elem.children) : [];
var clone_1 = new Element(elem.name, __assign({}, elem.attribs), children);
children.forEach(function (child) { return (child.parent = clone_1); });
return clone_1;
}
case "cdata" /* CDATA */: {
var cdata = node;
var children = recursive ? cloneChildren(cdata.children) : [];
var clone_2 = new NodeWithChildren("cdata" /* CDATA */, children);
children.forEach(function (child) { return (child.parent = clone_2); });
return clone_2;
}
case "doctype" /* Doctype */: {
// This type isn't used yet.
throw new Error("Not implemented yet: ElementType.Doctype case");
}
}
}
exports.cloneNode = cloneNode;
function cloneChildren(childs) {
var children = childs.map(function (child) { return cloneNode(child, true); });
for (var i = 1; i < children.length; i++) {
children[i].prev = children[i - 1];
children[i - 1].next = children[i];
}
return children;
}