mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-04 14:29:47 +00:00
chore: Update deps
This commit is contained in:
@@ -0,0 +1,711 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.dump = void 0;
|
||||
const error_js_1 = require("../error.js");
|
||||
const common = __importStar(require("../utils.js"));
|
||||
const dumper_state_js_1 = require("./dumper_state.js");
|
||||
const _toString = Object.prototype.toString;
|
||||
const { hasOwn } = Object;
|
||||
const CHAR_TAB = 0x09; /* Tab */
|
||||
const CHAR_LINE_FEED = 0x0a; /* LF */
|
||||
const CHAR_SPACE = 0x20; /* Space */
|
||||
const CHAR_EXCLAMATION = 0x21; /* ! */
|
||||
const CHAR_DOUBLE_QUOTE = 0x22; /* " */
|
||||
const CHAR_SHARP = 0x23; /* # */
|
||||
const CHAR_PERCENT = 0x25; /* % */
|
||||
const CHAR_AMPERSAND = 0x26; /* & */
|
||||
const CHAR_SINGLE_QUOTE = 0x27; /* ' */
|
||||
const CHAR_ASTERISK = 0x2a; /* * */
|
||||
const CHAR_COMMA = 0x2c; /* , */
|
||||
const CHAR_MINUS = 0x2d; /* - */
|
||||
const CHAR_COLON = 0x3a; /* : */
|
||||
const CHAR_GREATER_THAN = 0x3e; /* > */
|
||||
const CHAR_QUESTION = 0x3f; /* ? */
|
||||
const CHAR_COMMERCIAL_AT = 0x40; /* @ */
|
||||
const CHAR_LEFT_SQUARE_BRACKET = 0x5b; /* [ */
|
||||
const CHAR_RIGHT_SQUARE_BRACKET = 0x5d; /* ] */
|
||||
const CHAR_GRAVE_ACCENT = 0x60; /* ` */
|
||||
const CHAR_LEFT_CURLY_BRACKET = 0x7b; /* { */
|
||||
const CHAR_VERTICAL_LINE = 0x7c; /* | */
|
||||
const CHAR_RIGHT_CURLY_BRACKET = 0x7d; /* } */
|
||||
const ESCAPE_SEQUENCES = {};
|
||||
ESCAPE_SEQUENCES[0x00] = "\\0";
|
||||
ESCAPE_SEQUENCES[0x07] = "\\a";
|
||||
ESCAPE_SEQUENCES[0x08] = "\\b";
|
||||
ESCAPE_SEQUENCES[0x09] = "\\t";
|
||||
ESCAPE_SEQUENCES[0x0a] = "\\n";
|
||||
ESCAPE_SEQUENCES[0x0b] = "\\v";
|
||||
ESCAPE_SEQUENCES[0x0c] = "\\f";
|
||||
ESCAPE_SEQUENCES[0x0d] = "\\r";
|
||||
ESCAPE_SEQUENCES[0x1b] = "\\e";
|
||||
ESCAPE_SEQUENCES[0x22] = '\\"';
|
||||
ESCAPE_SEQUENCES[0x5c] = "\\\\";
|
||||
ESCAPE_SEQUENCES[0x85] = "\\N";
|
||||
ESCAPE_SEQUENCES[0xa0] = "\\_";
|
||||
ESCAPE_SEQUENCES[0x2028] = "\\L";
|
||||
ESCAPE_SEQUENCES[0x2029] = "\\P";
|
||||
const DEPRECATED_BOOLEANS_SYNTAX = [
|
||||
"y",
|
||||
"Y",
|
||||
"yes",
|
||||
"Yes",
|
||||
"YES",
|
||||
"on",
|
||||
"On",
|
||||
"ON",
|
||||
"n",
|
||||
"N",
|
||||
"no",
|
||||
"No",
|
||||
"NO",
|
||||
"off",
|
||||
"Off",
|
||||
"OFF",
|
||||
];
|
||||
function encodeHex(character) {
|
||||
const string = character.toString(16).toUpperCase();
|
||||
let handle;
|
||||
let length;
|
||||
if (character <= 0xff) {
|
||||
handle = "x";
|
||||
length = 2;
|
||||
}
|
||||
else if (character <= 0xffff) {
|
||||
handle = "u";
|
||||
length = 4;
|
||||
}
|
||||
else if (character <= 0xffffffff) {
|
||||
handle = "U";
|
||||
length = 8;
|
||||
}
|
||||
else {
|
||||
throw new error_js_1.YAMLError("code point within a string may not be greater than 0xFFFFFFFF");
|
||||
}
|
||||
return `\\${handle}${common.repeat("0", length - string.length)}${string}`;
|
||||
}
|
||||
// Indents every line in a string. Empty lines (\n only) are not indented.
|
||||
function indentString(string, spaces) {
|
||||
const ind = common.repeat(" ", spaces), length = string.length;
|
||||
let position = 0, next = -1, result = "", line;
|
||||
while (position < length) {
|
||||
next = string.indexOf("\n", position);
|
||||
if (next === -1) {
|
||||
line = string.slice(position);
|
||||
position = length;
|
||||
}
|
||||
else {
|
||||
line = string.slice(position, next + 1);
|
||||
position = next + 1;
|
||||
}
|
||||
if (line.length && line !== "\n")
|
||||
result += ind;
|
||||
result += line;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function generateNextLine(state, level) {
|
||||
return `\n${common.repeat(" ", state.indent * level)}`;
|
||||
}
|
||||
function testImplicitResolving(state, str) {
|
||||
let type;
|
||||
for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
||||
type = state.implicitTypes[index];
|
||||
if (type.resolve(str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// [33] s-white ::= s-space | s-tab
|
||||
function isWhitespace(c) {
|
||||
return c === CHAR_SPACE || c === CHAR_TAB;
|
||||
}
|
||||
// Returns true if the character can be printed without escaping.
|
||||
// From YAML 1.2: "any allowed characters known to be non-printable
|
||||
// should also be escaped. [However,] This isn’t mandatory"
|
||||
// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
|
||||
function isPrintable(c) {
|
||||
return ((0x00020 <= c && c <= 0x00007e) ||
|
||||
(0x000a1 <= c && c <= 0x00d7ff && c !== 0x2028 && c !== 0x2029) ||
|
||||
(0x0e000 <= c && c <= 0x00fffd && c !== 0xfeff) /* BOM */ ||
|
||||
(0x10000 <= c && c <= 0x10ffff));
|
||||
}
|
||||
// Simplified test for values allowed after the first character in plain style.
|
||||
function isPlainSafe(c) {
|
||||
// Uses a subset of nb-char - c-flow-indicator - ":" - "#"
|
||||
// where nb-char ::= c-printable - b-char - c-byte-order-mark.
|
||||
return (isPrintable(c) &&
|
||||
c !== 0xfeff &&
|
||||
// - c-flow-indicator
|
||||
c !== CHAR_COMMA &&
|
||||
c !== CHAR_LEFT_SQUARE_BRACKET &&
|
||||
c !== CHAR_RIGHT_SQUARE_BRACKET &&
|
||||
c !== CHAR_LEFT_CURLY_BRACKET &&
|
||||
c !== CHAR_RIGHT_CURLY_BRACKET &&
|
||||
// - ":" - "#"
|
||||
c !== CHAR_COLON &&
|
||||
c !== CHAR_SHARP);
|
||||
}
|
||||
// Simplified test for values allowed as the first character in plain style.
|
||||
function isPlainSafeFirst(c) {
|
||||
// Uses a subset of ns-char - c-indicator
|
||||
// where ns-char = nb-char - s-white.
|
||||
return (isPrintable(c) &&
|
||||
c !== 0xfeff &&
|
||||
!isWhitespace(c) && // - s-white
|
||||
// - (c-indicator ::=
|
||||
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
|
||||
c !== CHAR_MINUS &&
|
||||
c !== CHAR_QUESTION &&
|
||||
c !== CHAR_COLON &&
|
||||
c !== CHAR_COMMA &&
|
||||
c !== CHAR_LEFT_SQUARE_BRACKET &&
|
||||
c !== CHAR_RIGHT_SQUARE_BRACKET &&
|
||||
c !== CHAR_LEFT_CURLY_BRACKET &&
|
||||
c !== CHAR_RIGHT_CURLY_BRACKET &&
|
||||
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
|
||||
c !== CHAR_SHARP &&
|
||||
c !== CHAR_AMPERSAND &&
|
||||
c !== CHAR_ASTERISK &&
|
||||
c !== CHAR_EXCLAMATION &&
|
||||
c !== CHAR_VERTICAL_LINE &&
|
||||
c !== CHAR_GREATER_THAN &&
|
||||
c !== CHAR_SINGLE_QUOTE &&
|
||||
c !== CHAR_DOUBLE_QUOTE &&
|
||||
// | “%” | “@” | “`”)
|
||||
c !== CHAR_PERCENT &&
|
||||
c !== CHAR_COMMERCIAL_AT &&
|
||||
c !== CHAR_GRAVE_ACCENT);
|
||||
}
|
||||
// Determines whether block indentation indicator is required.
|
||||
function needIndentIndicator(string) {
|
||||
const leadingSpaceRe = /^\n* /;
|
||||
return leadingSpaceRe.test(string);
|
||||
}
|
||||
const STYLE_PLAIN = 1, STYLE_SINGLE = 2, STYLE_LITERAL = 3, STYLE_FOLDED = 4, STYLE_DOUBLE = 5;
|
||||
// Determines which scalar styles are possible and returns the preferred style.
|
||||
// lineWidth = -1 => no limit.
|
||||
// Pre-conditions: str.length > 0.
|
||||
// Post-conditions:
|
||||
// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
|
||||
// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
|
||||
// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
|
||||
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
||||
const shouldTrackWidth = lineWidth !== -1;
|
||||
let hasLineBreak = false, hasFoldableLine = false, // only checked if shouldTrackWidth
|
||||
previousLineBreak = -1, // count the first line correctly
|
||||
plain = isPlainSafeFirst(string.charCodeAt(0)) &&
|
||||
!isWhitespace(string.charCodeAt(string.length - 1));
|
||||
let char, i;
|
||||
if (singleLineOnly) {
|
||||
// Case: no block styles.
|
||||
// Check for disallowed characters to rule out plain and single.
|
||||
for (i = 0; i < string.length; i++) {
|
||||
char = string.charCodeAt(i);
|
||||
if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Case: block styles permitted.
|
||||
for (i = 0; i < string.length; i++) {
|
||||
char = string.charCodeAt(i);
|
||||
if (char === CHAR_LINE_FEED) {
|
||||
hasLineBreak = true;
|
||||
// Check if any line can be folded.
|
||||
if (shouldTrackWidth) {
|
||||
hasFoldableLine = hasFoldableLine ||
|
||||
// Foldable line = too long, and not more-indented.
|
||||
(i - previousLineBreak - 1 > lineWidth &&
|
||||
string[previousLineBreak + 1] !== " ");
|
||||
previousLineBreak = i;
|
||||
}
|
||||
}
|
||||
else if (!isPrintable(char)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
plain = plain && isPlainSafe(char);
|
||||
}
|
||||
// in case the end is missing a \n
|
||||
hasFoldableLine = hasFoldableLine ||
|
||||
(shouldTrackWidth &&
|
||||
i - previousLineBreak - 1 > lineWidth &&
|
||||
string[previousLineBreak + 1] !== " ");
|
||||
}
|
||||
// Although every style can represent \n without escaping, prefer block styles
|
||||
// for multiline, since they're more readable and they don't add empty lines.
|
||||
// Also prefer folding a super-long line.
|
||||
if (!hasLineBreak && !hasFoldableLine) {
|
||||
// Strings interpretable as another type have to be quoted;
|
||||
// e.g. the string 'true' vs. the boolean true.
|
||||
return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
|
||||
}
|
||||
// Edge case: block indentation indicator can only have one digit.
|
||||
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
||||
return STYLE_DOUBLE;
|
||||
}
|
||||
// At this point we know block styles are valid.
|
||||
// Prefer literal style unless we want to fold.
|
||||
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
||||
}
|
||||
// Greedy line breaking.
|
||||
// Picks the longest line under the limit each time,
|
||||
// otherwise settles for the shortest line over the limit.
|
||||
// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
|
||||
function foldLine(line, width) {
|
||||
if (line === "" || line[0] === " ")
|
||||
return line;
|
||||
// Since a more-indented line adds a \n, breaks can't be followed by a space.
|
||||
const breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
|
||||
let match;
|
||||
// start is an inclusive index. end, curr, and next are exclusive.
|
||||
let start = 0, end, curr = 0, next = 0;
|
||||
let result = "";
|
||||
// Invariants: 0 <= start <= length-1.
|
||||
// 0 <= curr <= next <= max(0, length-2). curr - start <= width.
|
||||
// Inside the loop:
|
||||
// A match implies length >= 2, so curr and next are <= length-2.
|
||||
// tslint:disable-next-line:no-conditional-assignment
|
||||
while ((match = breakRe.exec(line))) {
|
||||
next = match.index;
|
||||
// maintain invariant: curr - start <= width
|
||||
if (next - start > width) {
|
||||
end = curr > start ? curr : next; // derive end <= length-2
|
||||
result += `\n${line.slice(start, end)}`;
|
||||
// skip the space that was output as \n
|
||||
start = end + 1; // derive start <= length-1
|
||||
}
|
||||
curr = next;
|
||||
}
|
||||
// By the invariants, start <= length-1, so there is something left over.
|
||||
// It is either the whole string or a part starting from non-whitespace.
|
||||
result += "\n";
|
||||
// Insert a break if the remainder is too long and there is a break available.
|
||||
if (line.length - start > width && curr > start) {
|
||||
result += `${line.slice(start, curr)}\n${line.slice(curr + 1)}`;
|
||||
}
|
||||
else {
|
||||
result += line.slice(start);
|
||||
}
|
||||
return result.slice(1); // drop extra \n joiner
|
||||
}
|
||||
// (See the note for writeScalar.)
|
||||
function dropEndingNewline(string) {
|
||||
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
||||
}
|
||||
// Note: a long line without a suitable break point will exceed the width limit.
|
||||
// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
|
||||
function foldString(string, width) {
|
||||
// In folded style, $k$ consecutive newlines output as $k+1$ newlines—
|
||||
// unless they're before or after a more-indented line, or at the very
|
||||
// beginning or end, in which case $k$ maps to $k$.
|
||||
// Therefore, parse each chunk as newline(s) followed by a content line.
|
||||
const lineRe = /(\n+)([^\n]*)/g;
|
||||
// first line (possibly an empty line)
|
||||
let result = (() => {
|
||||
let nextLF = string.indexOf("\n");
|
||||
nextLF = nextLF !== -1 ? nextLF : string.length;
|
||||
lineRe.lastIndex = nextLF;
|
||||
return foldLine(string.slice(0, nextLF), width);
|
||||
})();
|
||||
// If we haven't reached the first content line yet, don't add an extra \n.
|
||||
let prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
||||
let moreIndented;
|
||||
// rest of the lines
|
||||
let match;
|
||||
// tslint:disable-next-line:no-conditional-assignment
|
||||
while ((match = lineRe.exec(string))) {
|
||||
const prefix = match[1], line = match[2];
|
||||
moreIndented = line[0] === " ";
|
||||
result += prefix +
|
||||
(!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") +
|
||||
foldLine(line, width);
|
||||
prevMoreIndented = moreIndented;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Escapes a double-quoted string.
|
||||
function escapeString(string) {
|
||||
let result = "";
|
||||
let char, nextChar;
|
||||
let escapeSeq;
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
char = string.charCodeAt(i);
|
||||
// Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
|
||||
if (char >= 0xd800 && char <= 0xdbff /* high surrogate */) {
|
||||
nextChar = string.charCodeAt(i + 1);
|
||||
if (nextChar >= 0xdc00 && nextChar <= 0xdfff /* low surrogate */) {
|
||||
// Combine the surrogate pair and store it escaped.
|
||||
result += encodeHex((char - 0xd800) * 0x400 + nextChar - 0xdc00 + 0x10000);
|
||||
// Advance index one extra since we already used that char here.
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
escapeSeq = ESCAPE_SEQUENCES[char];
|
||||
result += !escapeSeq && isPrintable(char)
|
||||
? string[i]
|
||||
: escapeSeq || encodeHex(char);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
|
||||
function blockHeader(string, indentPerLevel) {
|
||||
const indentIndicator = needIndentIndicator(string)
|
||||
? String(indentPerLevel)
|
||||
: "";
|
||||
// note the special case: the string '\n' counts as a "trailing" empty line.
|
||||
const clip = string[string.length - 1] === "\n";
|
||||
const keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
||||
const chomp = keep ? "+" : clip ? "" : "-";
|
||||
return `${indentIndicator}${chomp}\n`;
|
||||
}
|
||||
// Note: line breaking/folding is implemented for only the folded style.
|
||||
// NB. We drop the last trailing newline (if any) of a returned block scalar
|
||||
// since the dumper adds its own newline. This always works:
|
||||
// • No ending newline => unaffected; already using strip "-" chomping.
|
||||
// • Ending newline => removed then restored.
|
||||
// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
|
||||
function writeScalar(state, string, level, iskey) {
|
||||
state.dump = (() => {
|
||||
if (string.length === 0) {
|
||||
return "''";
|
||||
}
|
||||
if (!state.noCompatMode &&
|
||||
DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
|
||||
return `'${string}'`;
|
||||
}
|
||||
const indent = state.indent * Math.max(1, level); // no 0-indent scalars
|
||||
// As indentation gets deeper, let the width decrease monotonically
|
||||
// to the lower bound min(state.lineWidth, 40).
|
||||
// Note that this implies
|
||||
// state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
|
||||
// state.lineWidth > 40 + state.indent: width decreases until the lower
|
||||
// bound.
|
||||
// This behaves better than a constant minimum width which disallows
|
||||
// narrower options, or an indent threshold which causes the width
|
||||
// to suddenly increase.
|
||||
const lineWidth = state.lineWidth === -1
|
||||
? -1
|
||||
: Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
||||
// Without knowing if keys are implicit/explicit,
|
||||
// assume implicit for safety.
|
||||
const singleLineOnly = iskey ||
|
||||
// No block styles in flow mode.
|
||||
(state.flowLevel > -1 && level >= state.flowLevel);
|
||||
function testAmbiguity(str) {
|
||||
return testImplicitResolving(state, str);
|
||||
}
|
||||
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
|
||||
case STYLE_PLAIN:
|
||||
return string;
|
||||
case STYLE_SINGLE:
|
||||
return `'${string.replace(/'/g, "''")}'`;
|
||||
case STYLE_LITERAL:
|
||||
return `|${blockHeader(string, state.indent)}${dropEndingNewline(indentString(string, indent))}`;
|
||||
case STYLE_FOLDED:
|
||||
return `>${blockHeader(string, state.indent)}${dropEndingNewline(indentString(foldString(string, lineWidth), indent))}`;
|
||||
case STYLE_DOUBLE:
|
||||
return `"${escapeString(string)}"`;
|
||||
default:
|
||||
throw new error_js_1.YAMLError("impossible error: invalid scalar style");
|
||||
}
|
||||
})();
|
||||
}
|
||||
function writeFlowSequence(state, level, object) {
|
||||
let _result = "";
|
||||
const _tag = state.tag;
|
||||
for (let index = 0, length = object.length; index < length; index += 1) {
|
||||
// Write only valid elements.
|
||||
if (writeNode(state, level, object[index], false, false)) {
|
||||
if (index !== 0)
|
||||
_result += `,${!state.condenseFlow ? " " : ""}`;
|
||||
_result += state.dump;
|
||||
}
|
||||
}
|
||||
state.tag = _tag;
|
||||
state.dump = `[${_result}]`;
|
||||
}
|
||||
function writeBlockSequence(state, level, object, compact = false) {
|
||||
let _result = "";
|
||||
const _tag = state.tag;
|
||||
for (let index = 0, length = object.length; index < length; index += 1) {
|
||||
// Write only valid elements.
|
||||
if (writeNode(state, level + 1, object[index], true, true)) {
|
||||
if (!compact || index !== 0) {
|
||||
_result += generateNextLine(state, level);
|
||||
}
|
||||
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||
_result += "-";
|
||||
}
|
||||
else {
|
||||
_result += "- ";
|
||||
}
|
||||
_result += state.dump;
|
||||
}
|
||||
}
|
||||
state.tag = _tag;
|
||||
state.dump = _result || "[]"; // Empty sequence if no valid values.
|
||||
}
|
||||
function writeFlowMapping(state, level, object) {
|
||||
let _result = "";
|
||||
const _tag = state.tag, objectKeyList = Object.keys(object);
|
||||
let pairBuffer, objectKey, objectValue;
|
||||
for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = state.condenseFlow ? '"' : "";
|
||||
if (index !== 0)
|
||||
pairBuffer += ", ";
|
||||
objectKey = objectKeyList[index];
|
||||
objectValue = object[objectKey];
|
||||
if (!writeNode(state, level, objectKey, false, false)) {
|
||||
continue; // Skip this pair because of invalid key;
|
||||
}
|
||||
if (state.dump.length > 1024)
|
||||
pairBuffer += "? ";
|
||||
pairBuffer += `${state.dump}${state.condenseFlow ? '"' : ""}:${state.condenseFlow ? "" : " "}`;
|
||||
if (!writeNode(state, level, objectValue, false, false)) {
|
||||
continue; // Skip this pair because of invalid value.
|
||||
}
|
||||
pairBuffer += state.dump;
|
||||
// Both key and value are valid.
|
||||
_result += pairBuffer;
|
||||
}
|
||||
state.tag = _tag;
|
||||
state.dump = `{${_result}}`;
|
||||
}
|
||||
function writeBlockMapping(state, level, object, compact = false) {
|
||||
const _tag = state.tag, objectKeyList = Object.keys(object);
|
||||
let _result = "";
|
||||
// Allow sorting keys so that the output file is deterministic
|
||||
if (state.sortKeys === true) {
|
||||
// Default sorting
|
||||
objectKeyList.sort();
|
||||
}
|
||||
else if (typeof state.sortKeys === "function") {
|
||||
// Custom sort function
|
||||
objectKeyList.sort(state.sortKeys);
|
||||
}
|
||||
else if (state.sortKeys) {
|
||||
// Something is wrong
|
||||
throw new error_js_1.YAMLError("sortKeys must be a boolean or a function");
|
||||
}
|
||||
let pairBuffer = "", objectKey, objectValue, explicitPair;
|
||||
for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = "";
|
||||
if (!compact || index !== 0) {
|
||||
pairBuffer += generateNextLine(state, level);
|
||||
}
|
||||
objectKey = objectKeyList[index];
|
||||
objectValue = object[objectKey];
|
||||
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
||||
continue; // Skip this pair because of invalid key.
|
||||
}
|
||||
explicitPair = (state.tag !== null && state.tag !== "?") ||
|
||||
(state.dump && state.dump.length > 1024);
|
||||
if (explicitPair) {
|
||||
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||
pairBuffer += "?";
|
||||
}
|
||||
else {
|
||||
pairBuffer += "? ";
|
||||
}
|
||||
}
|
||||
pairBuffer += state.dump;
|
||||
if (explicitPair) {
|
||||
pairBuffer += generateNextLine(state, level);
|
||||
}
|
||||
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
||||
continue; // Skip this pair because of invalid value.
|
||||
}
|
||||
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
||||
pairBuffer += ":";
|
||||
}
|
||||
else {
|
||||
pairBuffer += ": ";
|
||||
}
|
||||
pairBuffer += state.dump;
|
||||
// Both key and value are valid.
|
||||
_result += pairBuffer;
|
||||
}
|
||||
state.tag = _tag;
|
||||
state.dump = _result || "{}"; // Empty mapping if no valid pairs.
|
||||
}
|
||||
function detectType(state, object, explicit = false) {
|
||||
const typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
||||
let type;
|
||||
let style;
|
||||
let _result;
|
||||
for (let index = 0, length = typeList.length; index < length; index += 1) {
|
||||
type = typeList[index];
|
||||
if ((type.instanceOf || type.predicate) &&
|
||||
(!type.instanceOf ||
|
||||
(typeof object === "object" && object instanceof type.instanceOf)) &&
|
||||
(!type.predicate || type.predicate(object))) {
|
||||
state.tag = explicit ? type.tag : "?";
|
||||
if (type.represent) {
|
||||
style = state.styleMap[type.tag] || type.defaultStyle;
|
||||
if (_toString.call(type.represent) === "[object Function]") {
|
||||
_result = type.represent(object, style);
|
||||
}
|
||||
else if (hasOwn(type.represent, style)) {
|
||||
_result = type.represent[style](object, style);
|
||||
}
|
||||
else {
|
||||
throw new error_js_1.YAMLError(`!<${type.tag}> tag resolver accepts not "${style}" style`);
|
||||
}
|
||||
state.dump = _result;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Serializes `object` and writes it to global `result`.
|
||||
// Returns true on success, or false on invalid object.
|
||||
//
|
||||
function writeNode(state, level, object, block, compact, iskey = false) {
|
||||
state.tag = null;
|
||||
state.dump = object;
|
||||
if (!detectType(state, object, false)) {
|
||||
detectType(state, object, true);
|
||||
}
|
||||
const type = _toString.call(state.dump);
|
||||
if (block) {
|
||||
block = state.flowLevel < 0 || state.flowLevel > level;
|
||||
}
|
||||
const objectOrArray = type === "[object Object]" || type === "[object Array]";
|
||||
let duplicateIndex = -1;
|
||||
let duplicate = false;
|
||||
if (objectOrArray) {
|
||||
duplicateIndex = state.duplicates.indexOf(object);
|
||||
duplicate = duplicateIndex !== -1;
|
||||
}
|
||||
if ((state.tag !== null && state.tag !== "?") ||
|
||||
duplicate ||
|
||||
(state.indent !== 2 && level > 0)) {
|
||||
compact = false;
|
||||
}
|
||||
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
||||
state.dump = `*ref_${duplicateIndex}`;
|
||||
}
|
||||
else {
|
||||
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
||||
state.usedDuplicates[duplicateIndex] = true;
|
||||
}
|
||||
if (type === "[object Object]") {
|
||||
if (block && Object.keys(state.dump).length !== 0) {
|
||||
writeBlockMapping(state, level, state.dump, compact);
|
||||
if (duplicate) {
|
||||
state.dump = `&ref_${duplicateIndex}${state.dump}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
writeFlowMapping(state, level, state.dump);
|
||||
if (duplicate) {
|
||||
state.dump = `&ref_${duplicateIndex} ${state.dump}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type === "[object Array]") {
|
||||
const arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
|
||||
if (block && state.dump.length !== 0) {
|
||||
writeBlockSequence(state, arrayLevel, state.dump, compact);
|
||||
if (duplicate) {
|
||||
state.dump = `&ref_${duplicateIndex}${state.dump}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
writeFlowSequence(state, arrayLevel, state.dump);
|
||||
if (duplicate) {
|
||||
state.dump = `&ref_${duplicateIndex} ${state.dump}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type === "[object String]") {
|
||||
if (state.tag !== "?") {
|
||||
writeScalar(state, state.dump, level, iskey);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (state.skipInvalid)
|
||||
return false;
|
||||
throw new error_js_1.YAMLError(`unacceptable kind of an object to dump ${type}`);
|
||||
}
|
||||
if (state.tag !== null && state.tag !== "?") {
|
||||
state.dump = `!<${state.tag}> ${state.dump}`;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function inspectNode(object, objects, duplicatesIndexes) {
|
||||
if (object !== null && typeof object === "object") {
|
||||
const index = objects.indexOf(object);
|
||||
if (index !== -1) {
|
||||
if (duplicatesIndexes.indexOf(index) === -1) {
|
||||
duplicatesIndexes.push(index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
objects.push(object);
|
||||
if (Array.isArray(object)) {
|
||||
for (let idx = 0, length = object.length; idx < length; idx += 1) {
|
||||
inspectNode(object[idx], objects, duplicatesIndexes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const objectKeyList = Object.keys(object);
|
||||
for (let idx = 0, length = objectKeyList.length; idx < length; idx += 1) {
|
||||
inspectNode(object[objectKeyList[idx]], objects, duplicatesIndexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function getDuplicateReferences(object, state) {
|
||||
const objects = [], duplicatesIndexes = [];
|
||||
inspectNode(object, objects, duplicatesIndexes);
|
||||
const length = duplicatesIndexes.length;
|
||||
for (let index = 0; index < length; index += 1) {
|
||||
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
||||
}
|
||||
state.usedDuplicates = Array.from({ length });
|
||||
}
|
||||
function dump(input, options) {
|
||||
options = options || {};
|
||||
const state = new dumper_state_js_1.DumperState(options);
|
||||
if (!state.noRefs)
|
||||
getDuplicateReferences(input, state);
|
||||
if (writeNode(state, 0, input, true, true))
|
||||
return `${state.dump}\n`;
|
||||
return "";
|
||||
}
|
||||
exports.dump = dump;
|
||||
@@ -0,0 +1,152 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DumperState = void 0;
|
||||
const state_js_1 = require("../state.js");
|
||||
const { hasOwn } = Object;
|
||||
function compileStyleMap(schema, map) {
|
||||
if (typeof map === "undefined" || map === null)
|
||||
return {};
|
||||
let type;
|
||||
const result = {};
|
||||
const keys = Object.keys(map);
|
||||
let tag, style;
|
||||
for (let index = 0, length = keys.length; index < length; index += 1) {
|
||||
tag = keys[index];
|
||||
style = String(map[tag]);
|
||||
if (tag.slice(0, 2) === "!!") {
|
||||
tag = `tag:yaml.org,2002:${tag.slice(2)}`;
|
||||
}
|
||||
type = schema.compiledTypeMap.fallback[tag];
|
||||
if (type &&
|
||||
typeof type.styleAliases !== "undefined" &&
|
||||
hasOwn(type.styleAliases, style)) {
|
||||
style = type.styleAliases[style];
|
||||
}
|
||||
result[tag] = style;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
class DumperState extends state_js_1.State {
|
||||
constructor({ schema, indent = 2, noArrayIndent = false, skipInvalid = false, flowLevel = -1, styles = null, sortKeys = false, lineWidth = 80, noRefs = false, noCompatMode = false, condenseFlow = false, }) {
|
||||
super(schema);
|
||||
Object.defineProperty(this, "indent", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "noArrayIndent", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "skipInvalid", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "flowLevel", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "sortKeys", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lineWidth", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "noRefs", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "noCompatMode", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "condenseFlow", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "implicitTypes", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "explicitTypes", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "tag", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: null
|
||||
});
|
||||
Object.defineProperty(this, "result", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: ""
|
||||
});
|
||||
Object.defineProperty(this, "duplicates", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: []
|
||||
});
|
||||
Object.defineProperty(this, "usedDuplicates", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: []
|
||||
}); // changed from null to []
|
||||
Object.defineProperty(this, "styleMap", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "dump", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.indent = Math.max(1, indent);
|
||||
this.noArrayIndent = noArrayIndent;
|
||||
this.skipInvalid = skipInvalid;
|
||||
this.flowLevel = flowLevel;
|
||||
this.styleMap = compileStyleMap(this.schema, styles);
|
||||
this.sortKeys = sortKeys;
|
||||
this.lineWidth = lineWidth;
|
||||
this.noRefs = noRefs;
|
||||
this.noCompatMode = noCompatMode;
|
||||
this.condenseFlow = condenseFlow;
|
||||
this.implicitTypes = this.schema.compiledImplicit;
|
||||
this.explicitTypes = this.schema.compiledExplicit;
|
||||
}
|
||||
}
|
||||
exports.DumperState = DumperState;
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLError = void 0;
|
||||
class YAMLError extends Error {
|
||||
constructor(message = "(unknown reason)", mark = "") {
|
||||
super(`${message} ${mark}`);
|
||||
Object.defineProperty(this, "mark", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: mark
|
||||
});
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
toString(_compact) {
|
||||
return `${this.name}: ${this.message} ${this.mark}`;
|
||||
}
|
||||
}
|
||||
exports.YAMLError = YAMLError;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LoaderState = void 0;
|
||||
const state_js_1 = require("../state.js");
|
||||
class LoaderState extends state_js_1.State {
|
||||
constructor(input, { filename, schema, onWarning, legacy = false, json = false, listener = null, }) {
|
||||
super(schema);
|
||||
Object.defineProperty(this, "input", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: input
|
||||
});
|
||||
Object.defineProperty(this, "documents", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: []
|
||||
});
|
||||
Object.defineProperty(this, "length", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lineIndent", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 0
|
||||
});
|
||||
Object.defineProperty(this, "lineStart", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 0
|
||||
});
|
||||
Object.defineProperty(this, "position", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 0
|
||||
});
|
||||
Object.defineProperty(this, "line", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: 0
|
||||
});
|
||||
Object.defineProperty(this, "filename", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "onWarning", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "legacy", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "json", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "listener", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "implicitTypes", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "typeMap", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "version", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "checkLineBreaks", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "tagMap", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "anchorMap", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "tag", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "anchor", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "kind", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "result", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: ""
|
||||
});
|
||||
this.filename = filename;
|
||||
this.onWarning = onWarning;
|
||||
this.legacy = legacy;
|
||||
this.json = json;
|
||||
this.listener = listener;
|
||||
this.implicitTypes = this.schema.compiledImplicit;
|
||||
this.typeMap = this.schema.compiledTypeMap;
|
||||
this.length = input.length;
|
||||
}
|
||||
}
|
||||
exports.LoaderState = LoaderState;
|
||||
85
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/mark.js
Normal file
85
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/mark.js
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Mark = void 0;
|
||||
const utils_js_1 = require("./utils.js");
|
||||
class Mark {
|
||||
constructor(name, buffer, position, line, column) {
|
||||
Object.defineProperty(this, "name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: name
|
||||
});
|
||||
Object.defineProperty(this, "buffer", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: buffer
|
||||
});
|
||||
Object.defineProperty(this, "position", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: position
|
||||
});
|
||||
Object.defineProperty(this, "line", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: line
|
||||
});
|
||||
Object.defineProperty(this, "column", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: column
|
||||
});
|
||||
}
|
||||
getSnippet(indent = 4, maxLength = 75) {
|
||||
if (!this.buffer)
|
||||
return null;
|
||||
let head = "";
|
||||
let start = this.position;
|
||||
while (start > 0 &&
|
||||
"\x00\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(start - 1)) === -1) {
|
||||
start -= 1;
|
||||
if (this.position - start > maxLength / 2 - 1) {
|
||||
head = " ... ";
|
||||
start += 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let tail = "";
|
||||
let end = this.position;
|
||||
while (end < this.buffer.length &&
|
||||
"\x00\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(end)) === -1) {
|
||||
end += 1;
|
||||
if (end - this.position > maxLength / 2 - 1) {
|
||||
tail = " ... ";
|
||||
end -= 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const snippet = this.buffer.slice(start, end);
|
||||
return `${(0, utils_js_1.repeat)(" ", indent)}${head}${snippet}${tail}\n${(0, utils_js_1.repeat)(" ", indent + this.position - start + head.length)}^`;
|
||||
}
|
||||
toString(compact) {
|
||||
let snippet, where = "";
|
||||
if (this.name) {
|
||||
where += `in "${this.name}" `;
|
||||
}
|
||||
where += `at line ${this.line + 1}, column ${this.column + 1}`;
|
||||
if (!compact) {
|
||||
snippet = this.getSnippet();
|
||||
if (snippet) {
|
||||
where += `:\n${snippet}`;
|
||||
}
|
||||
}
|
||||
return where;
|
||||
}
|
||||
}
|
||||
exports.Mark = Mark;
|
||||
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseAll = exports.parse = void 0;
|
||||
const loader_js_1 = require("./loader/loader.js");
|
||||
/**
|
||||
* Parses `content` as single YAML document.
|
||||
*
|
||||
* Returns a JavaScript object or throws `YAMLException` on error.
|
||||
* By default, does not support regexps, functions and undefined. This method is safe for untrusted data.
|
||||
*/
|
||||
function parse(content, options) {
|
||||
return (0, loader_js_1.load)(content, options);
|
||||
}
|
||||
exports.parse = parse;
|
||||
function parseAll(content, iterator, options) {
|
||||
return (0, loader_js_1.loadAll)(content, iterator, options);
|
||||
}
|
||||
exports.parseAll = parseAll;
|
||||
106
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/schema.js
Normal file
106
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/schema.js
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Schema = void 0;
|
||||
const error_js_1 = require("./error.js");
|
||||
function compileList(schema, name, result) {
|
||||
const exclude = [];
|
||||
for (const includedSchema of schema.include) {
|
||||
result = compileList(includedSchema, name, result);
|
||||
}
|
||||
for (const currentType of schema[name]) {
|
||||
for (let previousIndex = 0; previousIndex < result.length; previousIndex++) {
|
||||
const previousType = result[previousIndex];
|
||||
if (previousType.tag === currentType.tag &&
|
||||
previousType.kind === currentType.kind) {
|
||||
exclude.push(previousIndex);
|
||||
}
|
||||
}
|
||||
result.push(currentType);
|
||||
}
|
||||
return result.filter((_type, index) => !exclude.includes(index));
|
||||
}
|
||||
function compileMap(...typesList) {
|
||||
const result = {
|
||||
fallback: {},
|
||||
mapping: {},
|
||||
scalar: {},
|
||||
sequence: {},
|
||||
};
|
||||
for (const types of typesList) {
|
||||
for (const type of types) {
|
||||
if (type.kind !== null) {
|
||||
result[type.kind][type.tag] = result["fallback"][type.tag] = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
class Schema {
|
||||
constructor(definition) {
|
||||
Object.defineProperty(this, "implicit", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "explicit", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "include", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "compiledImplicit", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "compiledExplicit", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "compiledTypeMap", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.explicit = definition.explicit || [];
|
||||
this.implicit = definition.implicit || [];
|
||||
this.include = definition.include || [];
|
||||
for (const type of this.implicit) {
|
||||
if (type.loadKind && type.loadKind !== "scalar") {
|
||||
throw new error_js_1.YAMLError("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
||||
}
|
||||
}
|
||||
this.compiledImplicit = compileList(this, "implicit", []);
|
||||
this.compiledExplicit = compileList(this, "explicit", []);
|
||||
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
||||
}
|
||||
/* Returns a new extended schema from current schema */
|
||||
extend(definition) {
|
||||
return new Schema({
|
||||
implicit: [
|
||||
...new Set([...this.implicit, ...(definition?.implicit ?? [])]),
|
||||
],
|
||||
explicit: [
|
||||
...new Set([...this.explicit, ...(definition?.explicit ?? [])]),
|
||||
],
|
||||
include: [...new Set([...this.include, ...(definition?.include ?? [])])],
|
||||
});
|
||||
}
|
||||
static create() { }
|
||||
}
|
||||
exports.Schema = Schema;
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.core = void 0;
|
||||
const schema_js_1 = require("../schema.js");
|
||||
const json_js_1 = require("./json.js");
|
||||
// Standard YAML's Core schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2804923
|
||||
exports.core = new schema_js_1.Schema({
|
||||
include: [json_js_1.json],
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.def = void 0;
|
||||
const schema_js_1 = require("../schema.js");
|
||||
const mod_js_1 = require("../type/mod.js");
|
||||
const core_js_1 = require("./core.js");
|
||||
// JS-YAML's default schema for `safeLoad` function.
|
||||
// It is not described in the YAML specification.
|
||||
exports.def = new schema_js_1.Schema({
|
||||
explicit: [mod_js_1.binary, mod_js_1.omap, mod_js_1.pairs, mod_js_1.set],
|
||||
implicit: [mod_js_1.timestamp, mod_js_1.merge],
|
||||
include: [core_js_1.core],
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extended = void 0;
|
||||
const schema_js_1 = require("../schema.js");
|
||||
const mod_js_1 = require("../type/mod.js");
|
||||
const default_js_1 = require("./default.js");
|
||||
// Extends JS-YAML default schema with additional JavaScript types
|
||||
// It is not described in the YAML specification.
|
||||
exports.extended = new schema_js_1.Schema({
|
||||
explicit: [mod_js_1.regexp, mod_js_1.undefinedType],
|
||||
include: [default_js_1.def],
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.failsafe = void 0;
|
||||
const schema_js_1 = require("../schema.js");
|
||||
const mod_js_1 = require("../type/mod.js");
|
||||
// Standard YAML's Failsafe schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2802346
|
||||
exports.failsafe = new schema_js_1.Schema({
|
||||
explicit: [mod_js_1.str, mod_js_1.seq, mod_js_1.map],
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.json = void 0;
|
||||
const schema_js_1 = require("../schema.js");
|
||||
const mod_js_1 = require("../type/mod.js");
|
||||
const failsafe_js_1 = require("./failsafe.js");
|
||||
// Standard YAML's JSON schema.
|
||||
// http://www.yaml.org/spec/1.2/spec.html#id2803231
|
||||
exports.json = new schema_js_1.Schema({
|
||||
implicit: [mod_js_1.nil, mod_js_1.bool, mod_js_1.int, mod_js_1.float],
|
||||
include: [failsafe_js_1.failsafe],
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JSON_SCHEMA = exports.FAILSAFE_SCHEMA = exports.EXTENDED_SCHEMA = exports.DEFAULT_SCHEMA = exports.CORE_SCHEMA = void 0;
|
||||
var core_js_1 = require("./core.js");
|
||||
Object.defineProperty(exports, "CORE_SCHEMA", { enumerable: true, get: function () { return core_js_1.core; } });
|
||||
var default_js_1 = require("./default.js");
|
||||
Object.defineProperty(exports, "DEFAULT_SCHEMA", { enumerable: true, get: function () { return default_js_1.def; } });
|
||||
var extended_js_1 = require("./extended.js");
|
||||
Object.defineProperty(exports, "EXTENDED_SCHEMA", { enumerable: true, get: function () { return extended_js_1.extended; } });
|
||||
var failsafe_js_1 = require("./failsafe.js");
|
||||
Object.defineProperty(exports, "FAILSAFE_SCHEMA", { enumerable: true, get: function () { return failsafe_js_1.failsafe; } });
|
||||
var json_js_1 = require("./json.js");
|
||||
Object.defineProperty(exports, "JSON_SCHEMA", { enumerable: true, get: function () { return json_js_1.json; } });
|
||||
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.State = void 0;
|
||||
const mod_js_1 = require("./schema/mod.js");
|
||||
class State {
|
||||
constructor(schema = mod_js_1.DEFAULT_SCHEMA) {
|
||||
Object.defineProperty(this, "schema", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: schema
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.State = State;
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stringify = void 0;
|
||||
const dumper_js_1 = require("./dumper/dumper.js");
|
||||
/**
|
||||
* Serializes `object` as a YAML document.
|
||||
*
|
||||
* You can disable exceptions by setting the skipInvalid option to true.
|
||||
*/
|
||||
function stringify(obj, options) {
|
||||
return (0, dumper_js_1.dump)(obj, options);
|
||||
}
|
||||
exports.stringify = stringify;
|
||||
88
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/type.js
Normal file
88
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/type.js
Normal file
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Type = void 0;
|
||||
const DEFAULT_RESOLVE = () => true;
|
||||
const DEFAULT_CONSTRUCT = (data) => data;
|
||||
function checkTagFormat(tag) {
|
||||
return tag;
|
||||
}
|
||||
class Type {
|
||||
constructor(tag, options) {
|
||||
Object.defineProperty(this, "tag", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "kind", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: null
|
||||
});
|
||||
Object.defineProperty(this, "instanceOf", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "predicate", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "represent", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "defaultStyle", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "styleAliases", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "loadKind", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "resolve", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: () => true
|
||||
});
|
||||
Object.defineProperty(this, "construct", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: (data) => data
|
||||
});
|
||||
this.tag = checkTagFormat(tag);
|
||||
if (options) {
|
||||
this.kind = options.kind;
|
||||
this.resolve = options.resolve || DEFAULT_RESOLVE;
|
||||
this.construct = options.construct || DEFAULT_CONSTRUCT;
|
||||
this.instanceOf = options.instanceOf;
|
||||
this.predicate = options.predicate;
|
||||
this.represent = options.represent;
|
||||
this.defaultStyle = options.defaultStyle;
|
||||
this.styleAliases = options.styleAliases;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Type = Type;
|
||||
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.binary = void 0;
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
const type_js_1 = require("../type.js");
|
||||
const buffer_js_1 = require("../../../io/buffer.js");
|
||||
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
|
||||
const BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
||||
function resolveYamlBinary(data) {
|
||||
if (data === null)
|
||||
return false;
|
||||
let code;
|
||||
let bitlen = 0;
|
||||
const max = data.length;
|
||||
const map = BASE64_MAP;
|
||||
// Convert one by one.
|
||||
for (let idx = 0; idx < max; idx++) {
|
||||
code = map.indexOf(data.charAt(idx));
|
||||
// Skip CR/LF
|
||||
if (code > 64)
|
||||
continue;
|
||||
// Fail on illegal characters
|
||||
if (code < 0)
|
||||
return false;
|
||||
bitlen += 6;
|
||||
}
|
||||
// If there are any bits left, source was corrupted
|
||||
return bitlen % 8 === 0;
|
||||
}
|
||||
function constructYamlBinary(data) {
|
||||
// remove CR/LF & padding to simplify scan
|
||||
const input = data.replace(/[\r\n=]/g, "");
|
||||
const max = input.length;
|
||||
const map = BASE64_MAP;
|
||||
// Collect by 6*4 bits (3 bytes)
|
||||
const result = [];
|
||||
let bits = 0;
|
||||
for (let idx = 0; idx < max; idx++) {
|
||||
if (idx % 4 === 0 && idx) {
|
||||
result.push((bits >> 16) & 0xff);
|
||||
result.push((bits >> 8) & 0xff);
|
||||
result.push(bits & 0xff);
|
||||
}
|
||||
bits = (bits << 6) | map.indexOf(input.charAt(idx));
|
||||
}
|
||||
// Dump tail
|
||||
const tailbits = (max % 4) * 6;
|
||||
if (tailbits === 0) {
|
||||
result.push((bits >> 16) & 0xff);
|
||||
result.push((bits >> 8) & 0xff);
|
||||
result.push(bits & 0xff);
|
||||
}
|
||||
else if (tailbits === 18) {
|
||||
result.push((bits >> 10) & 0xff);
|
||||
result.push((bits >> 2) & 0xff);
|
||||
}
|
||||
else if (tailbits === 12) {
|
||||
result.push((bits >> 4) & 0xff);
|
||||
}
|
||||
return new buffer_js_1.Buffer(new Uint8Array(result));
|
||||
}
|
||||
function representYamlBinary(object) {
|
||||
const max = object.length;
|
||||
const map = BASE64_MAP;
|
||||
// Convert every three bytes to 4 ASCII characters.
|
||||
let result = "";
|
||||
let bits = 0;
|
||||
for (let idx = 0; idx < max; idx++) {
|
||||
if (idx % 3 === 0 && idx) {
|
||||
result += map[(bits >> 18) & 0x3f];
|
||||
result += map[(bits >> 12) & 0x3f];
|
||||
result += map[(bits >> 6) & 0x3f];
|
||||
result += map[bits & 0x3f];
|
||||
}
|
||||
bits = (bits << 8) + object[idx];
|
||||
}
|
||||
// Dump tail
|
||||
const tail = max % 3;
|
||||
if (tail === 0) {
|
||||
result += map[(bits >> 18) & 0x3f];
|
||||
result += map[(bits >> 12) & 0x3f];
|
||||
result += map[(bits >> 6) & 0x3f];
|
||||
result += map[bits & 0x3f];
|
||||
}
|
||||
else if (tail === 2) {
|
||||
result += map[(bits >> 10) & 0x3f];
|
||||
result += map[(bits >> 4) & 0x3f];
|
||||
result += map[(bits << 2) & 0x3f];
|
||||
result += map[64];
|
||||
}
|
||||
else if (tail === 1) {
|
||||
result += map[(bits >> 2) & 0x3f];
|
||||
result += map[(bits << 4) & 0x3f];
|
||||
result += map[64];
|
||||
result += map[64];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function isBinary(obj) {
|
||||
const buf = new buffer_js_1.Buffer();
|
||||
try {
|
||||
if (0 > buf.readFromSync(obj))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
buf.reset();
|
||||
}
|
||||
}
|
||||
exports.binary = new type_js_1.Type("tag:yaml.org,2002:binary", {
|
||||
construct: constructYamlBinary,
|
||||
kind: "scalar",
|
||||
predicate: isBinary,
|
||||
represent: representYamlBinary,
|
||||
resolve: resolveYamlBinary,
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.bool = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const utils_js_1 = require("../utils.js");
|
||||
function resolveYamlBoolean(data) {
|
||||
const max = data.length;
|
||||
return ((max === 4 && (data === "true" || data === "True" || data === "TRUE")) ||
|
||||
(max === 5 && (data === "false" || data === "False" || data === "FALSE")));
|
||||
}
|
||||
function constructYamlBoolean(data) {
|
||||
return data === "true" || data === "True" || data === "TRUE";
|
||||
}
|
||||
exports.bool = new type_js_1.Type("tag:yaml.org,2002:bool", {
|
||||
construct: constructYamlBoolean,
|
||||
defaultStyle: "lowercase",
|
||||
kind: "scalar",
|
||||
predicate: utils_js_1.isBoolean,
|
||||
represent: {
|
||||
lowercase(object) {
|
||||
return object ? "true" : "false";
|
||||
},
|
||||
uppercase(object) {
|
||||
return object ? "TRUE" : "FALSE";
|
||||
},
|
||||
camelcase(object) {
|
||||
return object ? "True" : "False";
|
||||
},
|
||||
},
|
||||
resolve: resolveYamlBoolean,
|
||||
});
|
||||
@@ -0,0 +1,109 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.float = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const utils_js_1 = require("../utils.js");
|
||||
const YAML_FLOAT_PATTERN = new RegExp(
|
||||
// 2.5e4, 2.5 and integers
|
||||
"^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?" +
|
||||
// .2e4, .2
|
||||
// special case, seems not from spec
|
||||
"|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?" +
|
||||
// 20:59
|
||||
"|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*" +
|
||||
// .inf
|
||||
"|[-+]?\\.(?:inf|Inf|INF)" +
|
||||
// .nan
|
||||
"|\\.(?:nan|NaN|NAN))$");
|
||||
function resolveYamlFloat(data) {
|
||||
if (!YAML_FLOAT_PATTERN.test(data) ||
|
||||
// Quick hack to not allow integers end with `_`
|
||||
// Probably should update regexp & check speed
|
||||
data[data.length - 1] === "_") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function constructYamlFloat(data) {
|
||||
let value = data.replace(/_/g, "").toLowerCase();
|
||||
const sign = value[0] === "-" ? -1 : 1;
|
||||
const digits = [];
|
||||
if ("+-".indexOf(value[0]) >= 0) {
|
||||
value = value.slice(1);
|
||||
}
|
||||
if (value === ".inf") {
|
||||
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
||||
}
|
||||
if (value === ".nan") {
|
||||
return NaN;
|
||||
}
|
||||
if (value.indexOf(":") >= 0) {
|
||||
value.split(":").forEach((v) => {
|
||||
digits.unshift(parseFloat(v));
|
||||
});
|
||||
let valueNb = 0.0;
|
||||
let base = 1;
|
||||
digits.forEach((d) => {
|
||||
valueNb += d * base;
|
||||
base *= 60;
|
||||
});
|
||||
return sign * valueNb;
|
||||
}
|
||||
return sign * parseFloat(value);
|
||||
}
|
||||
const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
||||
function representYamlFloat(object, style) {
|
||||
if (isNaN(object)) {
|
||||
switch (style) {
|
||||
case "lowercase":
|
||||
return ".nan";
|
||||
case "uppercase":
|
||||
return ".NAN";
|
||||
case "camelcase":
|
||||
return ".NaN";
|
||||
}
|
||||
}
|
||||
else if (Number.POSITIVE_INFINITY === object) {
|
||||
switch (style) {
|
||||
case "lowercase":
|
||||
return ".inf";
|
||||
case "uppercase":
|
||||
return ".INF";
|
||||
case "camelcase":
|
||||
return ".Inf";
|
||||
}
|
||||
}
|
||||
else if (Number.NEGATIVE_INFINITY === object) {
|
||||
switch (style) {
|
||||
case "lowercase":
|
||||
return "-.inf";
|
||||
case "uppercase":
|
||||
return "-.INF";
|
||||
case "camelcase":
|
||||
return "-.Inf";
|
||||
}
|
||||
}
|
||||
else if ((0, utils_js_1.isNegativeZero)(object)) {
|
||||
return "-0.0";
|
||||
}
|
||||
const res = object.toString(10);
|
||||
// JS stringifier can build scientific format without dots: 5e-100,
|
||||
// while YAML requires dot: 5.e-100. Fix it with simple hack
|
||||
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
||||
}
|
||||
function isFloat(object) {
|
||||
return (Object.prototype.toString.call(object) === "[object Number]" &&
|
||||
(object % 1 !== 0 || (0, utils_js_1.isNegativeZero)(object)));
|
||||
}
|
||||
exports.float = new type_js_1.Type("tag:yaml.org,2002:float", {
|
||||
construct: constructYamlFloat,
|
||||
defaultStyle: "lowercase",
|
||||
kind: "scalar",
|
||||
predicate: isFloat,
|
||||
represent: representYamlFloat,
|
||||
resolve: resolveYamlFloat,
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
// Ported and adapted from js-yaml-js-types v1.0.0:
|
||||
// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.func = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
// Note: original implementation used Esprima to handle functions
|
||||
// To avoid dependencies, we'll just try to check if we can construct a function from given string
|
||||
function reconstructFunction(code) {
|
||||
const func = new Function(`return ${code}`)();
|
||||
if (!(func instanceof Function)) {
|
||||
throw new TypeError(`Expected function but got ${typeof func}: ${code}`);
|
||||
}
|
||||
return func;
|
||||
}
|
||||
exports.func = new type_js_1.Type("tag:yaml.org,2002:js/function", {
|
||||
kind: "scalar",
|
||||
resolve(data) {
|
||||
if (data === null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
reconstructFunction(`${data}`);
|
||||
return true;
|
||||
}
|
||||
catch (_err) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
construct(data) {
|
||||
return reconstructFunction(data);
|
||||
},
|
||||
predicate(object) {
|
||||
return object instanceof Function;
|
||||
},
|
||||
represent(object) {
|
||||
return object.toString();
|
||||
},
|
||||
});
|
||||
171
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/type/int.js
Normal file
171
lib/script/deps/deno.land/std@0.140.0/encoding/_yaml/type/int.js
Normal file
@@ -0,0 +1,171 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.int = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const utils_js_1 = require("../utils.js");
|
||||
function isHexCode(c) {
|
||||
return ((0x30 <= /* 0 */ c && c <= 0x39) /* 9 */ ||
|
||||
(0x41 <= /* A */ c && c <= 0x46) /* F */ ||
|
||||
(0x61 <= /* a */ c && c <= 0x66) /* f */);
|
||||
}
|
||||
function isOctCode(c) {
|
||||
return 0x30 <= /* 0 */ c && c <= 0x37 /* 7 */;
|
||||
}
|
||||
function isDecCode(c) {
|
||||
return 0x30 <= /* 0 */ c && c <= 0x39 /* 9 */;
|
||||
}
|
||||
function resolveYamlInteger(data) {
|
||||
const max = data.length;
|
||||
let index = 0;
|
||||
let hasDigits = false;
|
||||
if (!max)
|
||||
return false;
|
||||
let ch = data[index];
|
||||
// sign
|
||||
if (ch === "-" || ch === "+") {
|
||||
ch = data[++index];
|
||||
}
|
||||
if (ch === "0") {
|
||||
// 0
|
||||
if (index + 1 === max)
|
||||
return true;
|
||||
ch = data[++index];
|
||||
// base 2, base 8, base 16
|
||||
if (ch === "b") {
|
||||
// base 2
|
||||
index++;
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === "_")
|
||||
continue;
|
||||
if (ch !== "0" && ch !== "1")
|
||||
return false;
|
||||
hasDigits = true;
|
||||
}
|
||||
return hasDigits && ch !== "_";
|
||||
}
|
||||
if (ch === "x") {
|
||||
// base 16
|
||||
index++;
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === "_")
|
||||
continue;
|
||||
if (!isHexCode(data.charCodeAt(index)))
|
||||
return false;
|
||||
hasDigits = true;
|
||||
}
|
||||
return hasDigits && ch !== "_";
|
||||
}
|
||||
// base 8
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === "_")
|
||||
continue;
|
||||
if (!isOctCode(data.charCodeAt(index)))
|
||||
return false;
|
||||
hasDigits = true;
|
||||
}
|
||||
return hasDigits && ch !== "_";
|
||||
}
|
||||
// base 10 (except 0) or base 60
|
||||
// value should not start with `_`;
|
||||
if (ch === "_")
|
||||
return false;
|
||||
for (; index < max; index++) {
|
||||
ch = data[index];
|
||||
if (ch === "_")
|
||||
continue;
|
||||
if (ch === ":")
|
||||
break;
|
||||
if (!isDecCode(data.charCodeAt(index))) {
|
||||
return false;
|
||||
}
|
||||
hasDigits = true;
|
||||
}
|
||||
// Should have digits and should not end with `_`
|
||||
if (!hasDigits || ch === "_")
|
||||
return false;
|
||||
// if !base60 - done;
|
||||
if (ch !== ":")
|
||||
return true;
|
||||
// base60 almost not used, no needs to optimize
|
||||
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
||||
}
|
||||
function constructYamlInteger(data) {
|
||||
let value = data;
|
||||
const digits = [];
|
||||
if (value.indexOf("_") !== -1) {
|
||||
value = value.replace(/_/g, "");
|
||||
}
|
||||
let sign = 1;
|
||||
let ch = value[0];
|
||||
if (ch === "-" || ch === "+") {
|
||||
if (ch === "-")
|
||||
sign = -1;
|
||||
value = value.slice(1);
|
||||
ch = value[0];
|
||||
}
|
||||
if (value === "0")
|
||||
return 0;
|
||||
if (ch === "0") {
|
||||
if (value[1] === "b")
|
||||
return sign * parseInt(value.slice(2), 2);
|
||||
if (value[1] === "x")
|
||||
return sign * parseInt(value, 16);
|
||||
return sign * parseInt(value, 8);
|
||||
}
|
||||
if (value.indexOf(":") !== -1) {
|
||||
value.split(":").forEach((v) => {
|
||||
digits.unshift(parseInt(v, 10));
|
||||
});
|
||||
let valueInt = 0;
|
||||
let base = 1;
|
||||
digits.forEach((d) => {
|
||||
valueInt += d * base;
|
||||
base *= 60;
|
||||
});
|
||||
return sign * valueInt;
|
||||
}
|
||||
return sign * parseInt(value, 10);
|
||||
}
|
||||
function isInteger(object) {
|
||||
return (Object.prototype.toString.call(object) === "[object Number]" &&
|
||||
object % 1 === 0 &&
|
||||
!(0, utils_js_1.isNegativeZero)(object));
|
||||
}
|
||||
exports.int = new type_js_1.Type("tag:yaml.org,2002:int", {
|
||||
construct: constructYamlInteger,
|
||||
defaultStyle: "decimal",
|
||||
kind: "scalar",
|
||||
predicate: isInteger,
|
||||
represent: {
|
||||
binary(obj) {
|
||||
return obj >= 0
|
||||
? `0b${obj.toString(2)}`
|
||||
: `-0b${obj.toString(2).slice(1)}`;
|
||||
},
|
||||
octal(obj) {
|
||||
return obj >= 0 ? `0${obj.toString(8)}` : `-0${obj.toString(8).slice(1)}`;
|
||||
},
|
||||
decimal(obj) {
|
||||
return obj.toString(10);
|
||||
},
|
||||
hexadecimal(obj) {
|
||||
return obj >= 0
|
||||
? `0x${obj.toString(16).toUpperCase()}`
|
||||
: `-0x${obj.toString(16).toUpperCase().slice(1)}`;
|
||||
},
|
||||
},
|
||||
resolve: resolveYamlInteger,
|
||||
styleAliases: {
|
||||
binary: [2, "bin"],
|
||||
decimal: [10, "dec"],
|
||||
hexadecimal: [16, "hex"],
|
||||
octal: [8, "oct"],
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.map = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
exports.map = new type_js_1.Type("tag:yaml.org,2002:map", {
|
||||
construct(data) {
|
||||
return data !== null ? data : {};
|
||||
},
|
||||
kind: "mapping",
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.merge = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
function resolveYamlMerge(data) {
|
||||
return data === "<<" || data === null;
|
||||
}
|
||||
exports.merge = new type_js_1.Type("tag:yaml.org,2002:merge", {
|
||||
kind: "scalar",
|
||||
resolve: resolveYamlMerge,
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.undefinedType = exports.timestamp = exports.str = exports.set = exports.seq = exports.regexp = exports.pairs = exports.omap = exports.nil = exports.merge = exports.map = exports.int = exports.func = exports.float = exports.bool = exports.binary = void 0;
|
||||
var binary_js_1 = require("./binary.js");
|
||||
Object.defineProperty(exports, "binary", { enumerable: true, get: function () { return binary_js_1.binary; } });
|
||||
var bool_js_1 = require("./bool.js");
|
||||
Object.defineProperty(exports, "bool", { enumerable: true, get: function () { return bool_js_1.bool; } });
|
||||
var float_js_1 = require("./float.js");
|
||||
Object.defineProperty(exports, "float", { enumerable: true, get: function () { return float_js_1.float; } });
|
||||
var function_js_1 = require("./function.js");
|
||||
Object.defineProperty(exports, "func", { enumerable: true, get: function () { return function_js_1.func; } });
|
||||
var int_js_1 = require("./int.js");
|
||||
Object.defineProperty(exports, "int", { enumerable: true, get: function () { return int_js_1.int; } });
|
||||
var map_js_1 = require("./map.js");
|
||||
Object.defineProperty(exports, "map", { enumerable: true, get: function () { return map_js_1.map; } });
|
||||
var merge_js_1 = require("./merge.js");
|
||||
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return merge_js_1.merge; } });
|
||||
var nil_js_1 = require("./nil.js");
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return nil_js_1.nil; } });
|
||||
var omap_js_1 = require("./omap.js");
|
||||
Object.defineProperty(exports, "omap", { enumerable: true, get: function () { return omap_js_1.omap; } });
|
||||
var pairs_js_1 = require("./pairs.js");
|
||||
Object.defineProperty(exports, "pairs", { enumerable: true, get: function () { return pairs_js_1.pairs; } });
|
||||
var regexp_js_1 = require("./regexp.js");
|
||||
Object.defineProperty(exports, "regexp", { enumerable: true, get: function () { return regexp_js_1.regexp; } });
|
||||
var seq_js_1 = require("./seq.js");
|
||||
Object.defineProperty(exports, "seq", { enumerable: true, get: function () { return seq_js_1.seq; } });
|
||||
var set_js_1 = require("./set.js");
|
||||
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return set_js_1.set; } });
|
||||
var str_js_1 = require("./str.js");
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return str_js_1.str; } });
|
||||
var timestamp_js_1 = require("./timestamp.js");
|
||||
Object.defineProperty(exports, "timestamp", { enumerable: true, get: function () { return timestamp_js_1.timestamp; } });
|
||||
var undefined_js_1 = require("./undefined.js");
|
||||
Object.defineProperty(exports, "undefinedType", { enumerable: true, get: function () { return undefined_js_1.undefinedType; } });
|
||||
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.nil = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
function resolveYamlNull(data) {
|
||||
const max = data.length;
|
||||
return ((max === 1 && data === "~") ||
|
||||
(max === 4 && (data === "null" || data === "Null" || data === "NULL")));
|
||||
}
|
||||
function constructYamlNull() {
|
||||
return null;
|
||||
}
|
||||
function isNull(object) {
|
||||
return object === null;
|
||||
}
|
||||
exports.nil = new type_js_1.Type("tag:yaml.org,2002:null", {
|
||||
construct: constructYamlNull,
|
||||
defaultStyle: "lowercase",
|
||||
kind: "scalar",
|
||||
predicate: isNull,
|
||||
represent: {
|
||||
canonical() {
|
||||
return "~";
|
||||
},
|
||||
lowercase() {
|
||||
return "null";
|
||||
},
|
||||
uppercase() {
|
||||
return "NULL";
|
||||
},
|
||||
camelcase() {
|
||||
return "Null";
|
||||
},
|
||||
},
|
||||
resolve: resolveYamlNull,
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.omap = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const { hasOwn } = Object;
|
||||
const _toString = Object.prototype.toString;
|
||||
function resolveYamlOmap(data) {
|
||||
const objectKeys = [];
|
||||
let pairKey = "";
|
||||
let pairHasKey = false;
|
||||
for (const pair of data) {
|
||||
pairHasKey = false;
|
||||
if (_toString.call(pair) !== "[object Object]")
|
||||
return false;
|
||||
for (pairKey in pair) {
|
||||
if (hasOwn(pair, pairKey)) {
|
||||
if (!pairHasKey)
|
||||
pairHasKey = true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!pairHasKey)
|
||||
return false;
|
||||
if (objectKeys.indexOf(pairKey) === -1)
|
||||
objectKeys.push(pairKey);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function constructYamlOmap(data) {
|
||||
return data !== null ? data : [];
|
||||
}
|
||||
exports.omap = new type_js_1.Type("tag:yaml.org,2002:omap", {
|
||||
construct: constructYamlOmap,
|
||||
kind: "sequence",
|
||||
resolve: resolveYamlOmap,
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pairs = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const _toString = Object.prototype.toString;
|
||||
function resolveYamlPairs(data) {
|
||||
const result = Array.from({ length: data.length });
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
const pair = data[index];
|
||||
if (_toString.call(pair) !== "[object Object]")
|
||||
return false;
|
||||
const keys = Object.keys(pair);
|
||||
if (keys.length !== 1)
|
||||
return false;
|
||||
result[index] = [keys[0], pair[keys[0]]];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function constructYamlPairs(data) {
|
||||
if (data === null)
|
||||
return [];
|
||||
const result = Array.from({ length: data.length });
|
||||
for (let index = 0; index < data.length; index += 1) {
|
||||
const pair = data[index];
|
||||
const keys = Object.keys(pair);
|
||||
result[index] = [keys[0], pair[keys[0]]];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.pairs = new type_js_1.Type("tag:yaml.org,2002:pairs", {
|
||||
construct: constructYamlPairs,
|
||||
kind: "sequence",
|
||||
resolve: resolveYamlPairs,
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
// Ported and adapted from js-yaml-js-types v1.0.0:
|
||||
// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.regexp = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const REGEXP = /^\/(?<regexp>[\s\S]+)\/(?<modifiers>[gismuy]*)$/;
|
||||
exports.regexp = new type_js_1.Type("tag:yaml.org,2002:js/regexp", {
|
||||
kind: "scalar",
|
||||
resolve(data) {
|
||||
if ((data === null) || (!data.length)) {
|
||||
return false;
|
||||
}
|
||||
const regexp = `${data}`;
|
||||
if (regexp.charAt(0) === "/") {
|
||||
// Ensure regex is properly terminated
|
||||
if (!REGEXP.test(data)) {
|
||||
return false;
|
||||
}
|
||||
// Check no duplicate modifiers
|
||||
const modifiers = [...(regexp.match(REGEXP)?.groups?.modifiers ?? "")];
|
||||
if (new Set(modifiers).size < modifiers.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
construct(data) {
|
||||
const { regexp = `${data}`, modifiers = "" } = `${data}`.match(REGEXP)?.groups ?? {};
|
||||
return new RegExp(regexp, modifiers);
|
||||
},
|
||||
predicate(object) {
|
||||
return object instanceof RegExp;
|
||||
},
|
||||
represent(object) {
|
||||
return object.toString();
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.seq = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
exports.seq = new type_js_1.Type("tag:yaml.org,2002:seq", {
|
||||
construct(data) {
|
||||
return data !== null ? data : [];
|
||||
},
|
||||
kind: "sequence",
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.set = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const { hasOwn } = Object;
|
||||
function resolveYamlSet(data) {
|
||||
if (data === null)
|
||||
return true;
|
||||
for (const key in data) {
|
||||
if (hasOwn(data, key)) {
|
||||
if (data[key] !== null)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function constructYamlSet(data) {
|
||||
return data !== null ? data : {};
|
||||
}
|
||||
exports.set = new type_js_1.Type("tag:yaml.org,2002:set", {
|
||||
construct: constructYamlSet,
|
||||
kind: "mapping",
|
||||
resolve: resolveYamlSet,
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.str = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
exports.str = new type_js_1.Type("tag:yaml.org,2002:str", {
|
||||
construct(data) {
|
||||
return data !== null ? data : "";
|
||||
},
|
||||
kind: "scalar",
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.timestamp = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
const YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + // [1] year
|
||||
"-([0-9][0-9])" + // [2] month
|
||||
"-([0-9][0-9])$");
|
||||
const YAML_TIMESTAMP_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + // [1] year
|
||||
"-([0-9][0-9]?)" + // [2] month
|
||||
"-([0-9][0-9]?)" + // [3] day
|
||||
"(?:[Tt]|[ \\t]+)" + // ...
|
||||
"([0-9][0-9]?)" + // [4] hour
|
||||
":([0-9][0-9])" + // [5] minute
|
||||
":([0-9][0-9])" + // [6] second
|
||||
"(?:\\.([0-9]*))?" + // [7] fraction
|
||||
"(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + // [8] tz [9] tz_sign [10] tz_hour
|
||||
"(?::([0-9][0-9]))?))?$");
|
||||
function resolveYamlTimestamp(data) {
|
||||
if (data === null)
|
||||
return false;
|
||||
if (YAML_DATE_REGEXP.exec(data) !== null)
|
||||
return true;
|
||||
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function constructYamlTimestamp(data) {
|
||||
let match = YAML_DATE_REGEXP.exec(data);
|
||||
if (match === null)
|
||||
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
||||
if (match === null)
|
||||
throw new Error("Date resolve error");
|
||||
// match: [1] year [2] month [3] day
|
||||
const year = +match[1];
|
||||
const month = +match[2] - 1; // JS month starts with 0
|
||||
const day = +match[3];
|
||||
if (!match[4]) {
|
||||
// no hour
|
||||
return new Date(Date.UTC(year, month, day));
|
||||
}
|
||||
// match: [4] hour [5] minute [6] second [7] fraction
|
||||
const hour = +match[4];
|
||||
const minute = +match[5];
|
||||
const second = +match[6];
|
||||
let fraction = 0;
|
||||
if (match[7]) {
|
||||
let partFraction = match[7].slice(0, 3);
|
||||
while (partFraction.length < 3) {
|
||||
// milli-seconds
|
||||
partFraction += "0";
|
||||
}
|
||||
fraction = +partFraction;
|
||||
}
|
||||
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
||||
let delta = null;
|
||||
if (match[9]) {
|
||||
const tzHour = +match[10];
|
||||
const tzMinute = +(match[11] || 0);
|
||||
delta = (tzHour * 60 + tzMinute) * 60000; // delta in milli-seconds
|
||||
if (match[9] === "-")
|
||||
delta = -delta;
|
||||
}
|
||||
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
||||
if (delta)
|
||||
date.setTime(date.getTime() - delta);
|
||||
return date;
|
||||
}
|
||||
function representYamlTimestamp(date) {
|
||||
return date.toISOString();
|
||||
}
|
||||
exports.timestamp = new type_js_1.Type("tag:yaml.org,2002:timestamp", {
|
||||
construct: constructYamlTimestamp,
|
||||
instanceOf: Date,
|
||||
kind: "scalar",
|
||||
represent: representYamlTimestamp,
|
||||
resolve: resolveYamlTimestamp,
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
// Ported and adapted from js-yaml-js-types v1.0.0:
|
||||
// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.undefinedType = void 0;
|
||||
const type_js_1 = require("../type.js");
|
||||
exports.undefinedType = new type_js_1.Type("tag:yaml.org,2002:js/undefined", {
|
||||
kind: "scalar",
|
||||
resolve() {
|
||||
return true;
|
||||
},
|
||||
construct() {
|
||||
return undefined;
|
||||
},
|
||||
predicate(object) {
|
||||
return typeof object === "undefined";
|
||||
},
|
||||
represent() {
|
||||
return "";
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
// Ported from js-yaml v3.13.1:
|
||||
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
||||
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isNegativeZero = exports.repeat = exports.toArray = exports.isRegExp = exports.isFunction = exports.isError = exports.isObject = exports.isUndefined = exports.isSymbol = exports.isString = exports.isNumber = exports.isNull = exports.isBoolean = exports.isArray = exports.isNothing = void 0;
|
||||
function isNothing(subject) {
|
||||
return typeof subject === "undefined" || subject === null;
|
||||
}
|
||||
exports.isNothing = isNothing;
|
||||
function isArray(value) {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
exports.isArray = isArray;
|
||||
function isBoolean(value) {
|
||||
return typeof value === "boolean" || value instanceof Boolean;
|
||||
}
|
||||
exports.isBoolean = isBoolean;
|
||||
function isNull(value) {
|
||||
return value === null;
|
||||
}
|
||||
exports.isNull = isNull;
|
||||
function isNumber(value) {
|
||||
return typeof value === "number" || value instanceof Number;
|
||||
}
|
||||
exports.isNumber = isNumber;
|
||||
function isString(value) {
|
||||
return typeof value === "string" || value instanceof String;
|
||||
}
|
||||
exports.isString = isString;
|
||||
function isSymbol(value) {
|
||||
return typeof value === "symbol";
|
||||
}
|
||||
exports.isSymbol = isSymbol;
|
||||
function isUndefined(value) {
|
||||
return value === undefined;
|
||||
}
|
||||
exports.isUndefined = isUndefined;
|
||||
function isObject(value) {
|
||||
return value !== null && typeof value === "object";
|
||||
}
|
||||
exports.isObject = isObject;
|
||||
function isError(e) {
|
||||
return e instanceof Error;
|
||||
}
|
||||
exports.isError = isError;
|
||||
function isFunction(value) {
|
||||
return typeof value === "function";
|
||||
}
|
||||
exports.isFunction = isFunction;
|
||||
function isRegExp(value) {
|
||||
return value instanceof RegExp;
|
||||
}
|
||||
exports.isRegExp = isRegExp;
|
||||
function toArray(sequence) {
|
||||
if (isArray(sequence))
|
||||
return sequence;
|
||||
if (isNothing(sequence))
|
||||
return [];
|
||||
return [sequence];
|
||||
}
|
||||
exports.toArray = toArray;
|
||||
function repeat(str, count) {
|
||||
let result = "";
|
||||
for (let cycle = 0; cycle < count; cycle++) {
|
||||
result += str;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.repeat = repeat;
|
||||
function isNegativeZero(i) {
|
||||
return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;
|
||||
}
|
||||
exports.isNegativeZero = isNegativeZero;
|
||||
Reference in New Issue
Block a user