Add capacitorjs runtime

This commit is contained in:
olcxja 2026-05-03 17:09:55 +02:00
commit f90c0e6c40
8362 changed files with 1502407 additions and 1 deletions

21
node_modules/@xml-tools/parser/lib/api.js generated vendored Normal file
View file

@ -0,0 +1,21 @@
const { xmlLexer } = require("./lexer");
const { xmlParser } = require("./parser");
module.exports = {
parse: function parse(text) {
const lexResult = xmlLexer.tokenize(text);
// setting a new input will RESET the parser instance's state.
xmlParser.input = lexResult.tokens;
// any top level rule may be used as an entry point
const cst = xmlParser.document();
return {
cst: cst,
tokenVector: lexResult.tokens,
lexErrors: lexResult.errors,
parseErrors: xmlParser.errors,
};
},
BaseXmlCstVisitor: xmlParser.getBaseCstVisitorConstructor(),
};

206
node_modules/@xml-tools/parser/lib/lexer.js generated vendored Normal file
View file

@ -0,0 +1,206 @@
const { createToken: createTokenOrg, Lexer } = require("chevrotain");
// A little mini DSL for easier lexer definition.
const fragments = {};
const f = fragments;
function FRAGMENT(name, def) {
fragments[name] = typeof def === "string" ? def : def.source;
}
function makePattern(strings, ...args) {
let combined = "";
for (let i = 0; i < strings.length; i++) {
combined += strings[i];
if (i < args.length) {
let pattern = args[i];
// By wrapping in a RegExp (none) capturing group
// We enabled the safe usage of qualifiers and assertions.
combined += `(?:${pattern})`;
}
}
return new RegExp(combined);
}
const tokensArray = [];
const tokensDictionary = {};
function createToken(options) {
const newTokenType = createTokenOrg(options);
tokensArray.push(newTokenType);
tokensDictionary[options.name] = newTokenType;
return newTokenType;
}
FRAGMENT(
"NameStartChar",
"(:|[a-zA-Z]|_|\\u2070-\\u218F|\\u2C00-\\u2FEF|\\u3001-\\uD7FF|\\uF900-\\uFDCF|\\uFDF0-\\uFFFD)"
);
FRAGMENT(
"NameChar",
makePattern`${f.NameStartChar}|-|\\.|\\d|\\u00B7||[\\u0300-\\u036F]|[\\u203F-\\u2040]`
);
FRAGMENT("Name", makePattern`${f.NameStartChar}(${f.NameChar})*`);
const Comment = createToken({
name: "Comment",
pattern: /<!--(.|\r?\n)*?-->/,
// A Comment may span multiple lines.
line_breaks: true,
});
const CData = createToken({
name: "CData",
pattern: /<!\[CDATA\[(.|\r?\n)*?]]>/,
line_breaks: true,
});
const DocType = createToken({
name: "DocType",
pattern: /<!DOCTYPE/,
push_mode: "INSIDE",
});
const IgnoredDTD = createToken({
name: "DTD",
pattern: /<!.*?>/,
group: Lexer.SKIPPED,
});
const EntityRef = createToken({
name: "EntityRef",
pattern: makePattern`&${f.Name};`,
});
const CharRef = createToken({
name: "CharRef",
pattern: /&#\d+;|&#x[a-fA-F0-9]/,
});
const SEA_WS = createToken({
name: "SEA_WS",
pattern: /( |\t|\n|\r\n)+/,
});
const XMLDeclOpen = createToken({
name: "XMLDeclOpen",
pattern: /<\?xml[ \t\r\n]/,
push_mode: "INSIDE",
});
const SLASH_OPEN = createToken({
name: "SLASH_OPEN",
pattern: /<\//,
push_mode: "INSIDE",
});
const INVALID_SLASH_OPEN = createToken({
name: "INVALID_SLASH_OPEN",
pattern: /<\//,
categories: [SLASH_OPEN],
});
const PROCESSING_INSTRUCTION = createToken({
name: "PROCESSING_INSTRUCTION",
pattern: makePattern`<\\?${f.Name}.*\\?>`,
});
const OPEN = createToken({ name: "OPEN", pattern: /</, push_mode: "INSIDE" });
// Meant to avoid skipping '<' token in a partial sequence of elements.
// Example of the problem this solves:
// <
// <from>john</from>
// - The second '<' will be skipped because in the mode "INSIDE" '<' is not recognized.
// - This means the AST will include only a single element instead of two
const INVALID_OPEN_INSIDE = createToken({
name: "INVALID_OPEN_INSIDE",
pattern: /</,
categories: [OPEN],
});
const TEXT = createToken({ name: "TEXT", pattern: /[^<&]+/ });
const CLOSE = createToken({ name: "CLOSE", pattern: />/, pop_mode: true });
const SPECIAL_CLOSE = createToken({
name: "SPECIAL_CLOSE",
pattern: /\?>/,
pop_mode: true,
});
const SLASH_CLOSE = createToken({
name: "SLASH_CLOSE",
pattern: /\/>/,
pop_mode: true,
});
const SLASH = createToken({ name: "SLASH", pattern: /\// });
const STRING = createToken({
name: "STRING",
pattern: /"[^<"]*"|'[^<']*'/,
});
const EQUALS = createToken({ name: "EQUALS", pattern: /=/ });
const Name = createToken({ name: "Name", pattern: makePattern`${f.Name}` });
const S = createToken({
name: "S",
pattern: /[ \t\r\n]/,
group: Lexer.SKIPPED,
});
const xmlLexerDefinition = {
defaultMode: "OUTSIDE",
modes: {
OUTSIDE: [
Comment,
CData,
DocType,
IgnoredDTD,
EntityRef,
CharRef,
SEA_WS,
XMLDeclOpen,
SLASH_OPEN,
PROCESSING_INSTRUCTION,
OPEN,
TEXT,
],
INSIDE: [
// Tokens from `OUTSIDE` to improve error recovery behavior
Comment,
INVALID_SLASH_OPEN,
INVALID_OPEN_INSIDE,
// "Real" `INSIDE` tokens
CLOSE,
SPECIAL_CLOSE,
SLASH_CLOSE,
SLASH,
EQUALS,
STRING,
Name,
S,
],
},
};
const xmlLexer = new Lexer(xmlLexerDefinition, {
// Reducing the amount of position tracking can provide a small performance boost (<10%)
// Likely best to keep the full info for better error position reporting and
// to expose "fuller" ITokens from the Lexer.
positionTracking: "full",
ensureOptimizations: false,
// TODO: inspect definitions for XML line terminators
lineTerminatorCharacters: ["\n"],
lineTerminatorsPattern: /\n|\r\n/g,
});
module.exports = {
xmlLexer,
tokensDictionary,
};

211
node_modules/@xml-tools/parser/lib/parser.js generated vendored Normal file
View file

@ -0,0 +1,211 @@
const { CstParser, tokenMatcher } = require("chevrotain");
const { tokensDictionary: t } = require("./lexer");
class Parser extends CstParser {
constructor() {
super(t, {
maxLookahead: 1,
recoveryEnabled: true,
nodeLocationTracking: "full",
});
this.deletionRecoveryEnabled = true;
const $ = this;
$.RULE("document", () => {
$.OPTION(() => {
$.SUBRULE($.prolog);
});
$.MANY(() => {
$.SUBRULE($.misc);
});
$.OPTION2(() => {
$.SUBRULE($.docTypeDecl);
});
$.MANY2(() => {
$.SUBRULE2($.misc);
});
$.SUBRULE($.element);
$.MANY3(() => {
$.SUBRULE3($.misc);
});
});
$.RULE("prolog", () => {
$.CONSUME(t.XMLDeclOpen);
$.MANY(() => {
$.SUBRULE($.attribute);
});
$.CONSUME(t.SPECIAL_CLOSE);
});
// https://www.w3.org/TR/xml/#NT-doctypedecl
$.RULE("docTypeDecl", () => {
$.CONSUME(t.DocType);
$.CONSUME(t.Name);
$.OPTION(() => {
$.SUBRULE($.externalID);
});
// The internal subSet part is intentionally not implemented because we do not at this
// time wish to implement a full DTD Parser as part of this project...
// https://www.w3.org/TR/xml/#NT-intSubset
$.CONSUME(t.CLOSE);
});
$.RULE("externalID", () => {
// Using gates to assert the value of the "Name" Identifiers.
// We could use Categories to model un-reserved keywords, however I am not sure
// The added complexity is needed at this time...
$.OR([
{
GATE: () => $.LA(1).image === "SYSTEM",
ALT: () => {
$.CONSUME2(t.Name, { LABEL: "System" });
$.CONSUME(t.STRING, { LABEL: "SystemLiteral" });
},
},
{
GATE: () => $.LA(1).image === "PUBLIC",
ALT: () => {
$.CONSUME3(t.Name, { LABEL: "Public" });
$.CONSUME2(t.STRING, { LABEL: "PubIDLiteral" });
$.CONSUME3(t.STRING, { LABEL: "SystemLiteral" });
},
},
]);
});
$.RULE("content", () => {
$.MANY(() => {
$.OR([
{ ALT: () => $.SUBRULE($.element) },
{ ALT: () => $.SUBRULE($.chardata) },
{ ALT: () => $.SUBRULE($.reference) },
{ ALT: () => $.CONSUME(t.CData) },
{ ALT: () => $.CONSUME(t.PROCESSING_INSTRUCTION) },
{ ALT: () => $.CONSUME(t.Comment) },
]);
});
});
$.RULE("element", () => {
$.CONSUME(t.OPEN);
try {
this.deletionRecoveryEnabled = false;
// disabling single token deletion here
// because `<
// </note>`
// will be parsed as: `<note>`
// and the next element will be lost
$.CONSUME(t.Name);
} finally {
this.deletionRecoveryEnabled = true;
}
$.MANY(() => {
$.SUBRULE($.attribute);
});
$.OR([
{
ALT: () => {
$.CONSUME(t.CLOSE, { LABEL: "START_CLOSE" });
$.SUBRULE($.content);
$.CONSUME(t.SLASH_OPEN);
$.CONSUME2(t.Name, { LABEL: "END_NAME" });
$.CONSUME2(t.CLOSE, { LABEL: "END" });
},
},
{
ALT: () => {
$.CONSUME(t.SLASH_CLOSE);
},
},
]);
});
$.RULE("reference", () => {
$.OR([
{ ALT: () => $.CONSUME(t.EntityRef) },
{ ALT: () => $.CONSUME(t.CharRef) },
]);
});
$.RULE("attribute", () => {
$.CONSUME(t.Name);
try {
this.deletionRecoveryEnabled = false;
// disabling single token deletion here
// because `attrib1 attrib2="666`
// will be parsed as: `attrib1="666`
$.CONSUME(t.EQUALS);
// disabling single token deletion here
// to avoid new elementName being
$.CONSUME(t.STRING);
} finally {
this.deletionRecoveryEnabled = true;
}
});
$.RULE("chardata", () => {
$.OR([
{ ALT: () => $.CONSUME(t.TEXT) },
{ ALT: () => $.CONSUME(t.SEA_WS) },
]);
});
$.RULE("misc", () => {
$.OR([
{ ALT: () => $.CONSUME(t.Comment) },
{ ALT: () => $.CONSUME(t.PROCESSING_INSTRUCTION) },
{ ALT: () => $.CONSUME(t.SEA_WS) },
]);
});
this.performSelfAnalysis();
}
canRecoverWithSingleTokenDeletion(expectedTokType) {
if (this.deletionRecoveryEnabled === false) {
return false;
}
return super.canRecoverWithSingleTokenDeletion(expectedTokType);
}
// TODO: provide this fix upstream to chevrotain
// https://github.com/SAP/chevrotain/issues/1055
/* istanbul ignore next - should be tested as part of Chevrotain */
findReSyncTokenType() {
const allPossibleReSyncTokTypes = this.flattenFollowSet();
// this loop will always terminate as EOF is always in the follow stack and also always (virtually) in the input
let nextToken = this.LA(1);
let k = 2;
/* eslint-disable-next-line no-constant-condition -- see above comment */
while (true) {
const foundMatch = allPossibleReSyncTokTypes.find((resyncTokType) => {
const canMatch = tokenMatcher(nextToken, resyncTokType);
return canMatch;
});
if (foundMatch !== undefined) {
return foundMatch;
}
nextToken = this.LA(k);
k++;
}
}
}
// Re-use the same parser instance
const xmlParser = new Parser();
module.exports = {
xmlParser,
};