This commit is contained in:
2025-05-09 05:30:08 +02:00
parent 7bb10e7df4
commit 73367bad9e
5322 changed files with 1266973 additions and 313 deletions

View File

@@ -0,0 +1,822 @@
/**
* @fileoverview Rule to specify spacing of object literal keys and values
* @author Brandon Mills
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils");
const { getGraphemeCount } = require("../shared/string-utils");
/**
* Checks whether a string contains a line terminator as defined in
* http://www.ecma-international.org/ecma-262/5.1/#sec-7.3
* @param {string} str String to test.
* @returns {boolean} True if str contains a line terminator.
*/
function containsLineTerminator(str) {
return astUtils.LINEBREAK_MATCHER.test(str);
}
/**
* Gets the last element of an array.
* @param {Array} arr An array.
* @returns {any} Last element of arr.
*/
function last(arr) {
return arr.at(-1);
}
/**
* Checks whether a node is contained on a single line.
* @param {ASTNode} node AST Node being evaluated.
* @returns {boolean} True if the node is a single line.
*/
function isSingleLine(node) {
return node.loc.end.line === node.loc.start.line;
}
/**
* Checks whether the properties on a single line.
* @param {ASTNode[]} properties List of Property AST nodes.
* @returns {boolean} True if all properties is on a single line.
*/
function isSingleLineProperties(properties) {
const [firstProp] = properties,
lastProp = last(properties);
return firstProp.loc.start.line === lastProp.loc.end.line;
}
/**
* Initializes a single option property from the configuration with defaults for undefined values
* @param {Object} toOptions Object to be initialized
* @param {Object} fromOptions Object to be initialized from
* @returns {Object} The object with correctly initialized options and values
*/
function initOptionProperty(toOptions, fromOptions) {
toOptions.mode = fromOptions.mode || "strict";
// Set value of beforeColon
if (typeof fromOptions.beforeColon !== "undefined") {
toOptions.beforeColon = +fromOptions.beforeColon;
} else {
toOptions.beforeColon = 0;
}
// Set value of afterColon
if (typeof fromOptions.afterColon !== "undefined") {
toOptions.afterColon = +fromOptions.afterColon;
} else {
toOptions.afterColon = 1;
}
// Set align if exists
if (typeof fromOptions.align !== "undefined") {
if (typeof fromOptions.align === "object") {
toOptions.align = fromOptions.align;
} else {
// "string"
toOptions.align = {
on: fromOptions.align,
mode: toOptions.mode,
beforeColon: toOptions.beforeColon,
afterColon: toOptions.afterColon,
};
}
}
return toOptions;
}
/**
* Initializes all the option values (singleLine, multiLine and align) from the configuration with defaults for undefined values
* @param {Object} toOptions Object to be initialized
* @param {Object} fromOptions Object to be initialized from
* @returns {Object} The object with correctly initialized options and values
*/
function initOptions(toOptions, fromOptions) {
if (typeof fromOptions.align === "object") {
// Initialize the alignment configuration
toOptions.align = initOptionProperty({}, fromOptions.align);
toOptions.align.on = fromOptions.align.on || "colon";
toOptions.align.mode = fromOptions.align.mode || "strict";
toOptions.multiLine = initOptionProperty(
{},
fromOptions.multiLine || fromOptions,
);
toOptions.singleLine = initOptionProperty(
{},
fromOptions.singleLine || fromOptions,
);
} else {
// string or undefined
toOptions.multiLine = initOptionProperty(
{},
fromOptions.multiLine || fromOptions,
);
toOptions.singleLine = initOptionProperty(
{},
fromOptions.singleLine || fromOptions,
);
// If alignment options are defined in multiLine, pull them out into the general align configuration
if (toOptions.multiLine.align) {
toOptions.align = {
on: toOptions.multiLine.align.on,
mode:
toOptions.multiLine.align.mode || toOptions.multiLine.mode,
beforeColon: toOptions.multiLine.align.beforeColon,
afterColon: toOptions.multiLine.align.afterColon,
};
}
}
return toOptions;
}
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
deprecated: {
message: "Formatting rules are being moved out of ESLint core.",
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
deprecatedSince: "8.53.0",
availableUntil: "10.0.0",
replacedBy: [
{
message:
"ESLint Stylistic now maintains deprecated stylistic core rules.",
url: "https://eslint.style/guide/migration",
plugin: {
name: "@stylistic/eslint-plugin-js",
url: "https://eslint.style/packages/js",
},
rule: {
name: "key-spacing",
url: "https://eslint.style/rules/js/key-spacing",
},
},
],
},
type: "layout",
docs: {
description:
"Enforce consistent spacing between keys and values in object literal properties",
recommended: false,
url: "https://eslint.org/docs/latest/rules/key-spacing",
},
fixable: "whitespace",
schema: [
{
anyOf: [
{
type: "object",
properties: {
align: {
anyOf: [
{
enum: ["colon", "value"],
},
{
type: "object",
properties: {
mode: {
enum: ["strict", "minimum"],
},
on: {
enum: ["colon", "value"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
],
},
mode: {
enum: ["strict", "minimum"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
{
type: "object",
properties: {
singleLine: {
type: "object",
properties: {
mode: {
enum: ["strict", "minimum"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
multiLine: {
type: "object",
properties: {
align: {
anyOf: [
{
enum: ["colon", "value"],
},
{
type: "object",
properties: {
mode: {
enum: [
"strict",
"minimum",
],
},
on: {
enum: [
"colon",
"value",
],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
],
},
mode: {
enum: ["strict", "minimum"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
},
additionalProperties: false,
},
{
type: "object",
properties: {
singleLine: {
type: "object",
properties: {
mode: {
enum: ["strict", "minimum"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
multiLine: {
type: "object",
properties: {
mode: {
enum: ["strict", "minimum"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
align: {
type: "object",
properties: {
mode: {
enum: ["strict", "minimum"],
},
on: {
enum: ["colon", "value"],
},
beforeColon: {
type: "boolean",
},
afterColon: {
type: "boolean",
},
},
additionalProperties: false,
},
},
additionalProperties: false,
},
],
},
],
messages: {
extraKey: "Extra space after {{computed}}key '{{key}}'.",
extraValue:
"Extra space before value for {{computed}}key '{{key}}'.",
missingKey: "Missing space after {{computed}}key '{{key}}'.",
missingValue:
"Missing space before value for {{computed}}key '{{key}}'.",
},
},
create(context) {
/**
* OPTIONS
* "key-spacing": [2, {
* beforeColon: false,
* afterColon: true,
* align: "colon" // Optional, or "value"
* }
*/
const options = context.options[0] || {},
ruleOptions = initOptions({}, options),
multiLineOptions = ruleOptions.multiLine,
singleLineOptions = ruleOptions.singleLine,
alignmentOptions = ruleOptions.align || null;
const sourceCode = context.sourceCode;
/**
* Determines if the given property is key-value property.
* @param {ASTNode} property Property node to check.
* @returns {boolean} Whether the property is a key-value property.
*/
function isKeyValueProperty(property) {
return !(
(
property.method ||
property.shorthand ||
property.kind !== "init" ||
property.type !== "Property"
) // Could be "ExperimentalSpreadProperty" or "SpreadElement"
);
}
/**
* Starting from the given node (a property.key node here) looks forward
* until it finds the colon punctuator and returns it.
* @param {ASTNode} node The node to start looking from.
* @returns {ASTNode} The colon punctuator.
*/
function getNextColon(node) {
return sourceCode.getTokenAfter(node, astUtils.isColonToken);
}
/**
* Starting from the given node (a property.key node here) looks forward
* until it finds the last token before a colon punctuator and returns it.
* @param {ASTNode} node The node to start looking from.
* @returns {ASTNode} The last token before a colon punctuator.
*/
function getLastTokenBeforeColon(node) {
const colonToken = getNextColon(node);
return sourceCode.getTokenBefore(colonToken);
}
/**
* Starting from the given node (a property.key node here) looks forward
* until it finds the first token after a colon punctuator and returns it.
* @param {ASTNode} node The node to start looking from.
* @returns {ASTNode} The first token after a colon punctuator.
*/
function getFirstTokenAfterColon(node) {
const colonToken = getNextColon(node);
return sourceCode.getTokenAfter(colonToken);
}
/**
* Checks whether a property is a member of the property group it follows.
* @param {ASTNode} lastMember The last Property known to be in the group.
* @param {ASTNode} candidate The next Property that might be in the group.
* @returns {boolean} True if the candidate property is part of the group.
*/
function continuesPropertyGroup(lastMember, candidate) {
const groupEndLine = lastMember.loc.start.line,
candidateValueStartLine = (
isKeyValueProperty(candidate)
? getFirstTokenAfterColon(candidate.key)
: candidate
).loc.start.line;
if (candidateValueStartLine - groupEndLine <= 1) {
return true;
}
/*
* Check that the first comment is adjacent to the end of the group, the
* last comment is adjacent to the candidate property, and that successive
* comments are adjacent to each other.
*/
const leadingComments = sourceCode.getCommentsBefore(candidate);
if (
leadingComments.length &&
leadingComments[0].loc.start.line - groupEndLine <= 1 &&
candidateValueStartLine - last(leadingComments).loc.end.line <=
1
) {
for (let i = 1; i < leadingComments.length; i++) {
if (
leadingComments[i].loc.start.line -
leadingComments[i - 1].loc.end.line >
1
) {
return false;
}
}
return true;
}
return false;
}
/**
* Gets an object literal property's key as the identifier name or string value.
* @param {ASTNode} property Property node whose key to retrieve.
* @returns {string} The property's key.
*/
function getKey(property) {
const key = property.key;
if (property.computed) {
return sourceCode.getText().slice(key.range[0], key.range[1]);
}
return astUtils.getStaticPropertyName(property);
}
/**
* Reports an appropriately-formatted error if spacing is incorrect on one
* side of the colon.
* @param {ASTNode} property Key-value pair in an object literal.
* @param {string} side Side being verified - either "key" or "value".
* @param {string} whitespace Actual whitespace string.
* @param {int} expected Expected whitespace length.
* @param {string} mode Value of the mode as "strict" or "minimum"
* @returns {void}
*/
function report(property, side, whitespace, expected, mode) {
const diff = whitespace.length - expected;
if (
((diff && mode === "strict") ||
(diff < 0 && mode === "minimum") ||
(diff > 0 && !expected && mode === "minimum")) &&
!(expected && containsLineTerminator(whitespace))
) {
const nextColon = getNextColon(property.key),
tokenBeforeColon = sourceCode.getTokenBefore(nextColon, {
includeComments: true,
}),
tokenAfterColon = sourceCode.getTokenAfter(nextColon, {
includeComments: true,
}),
isKeySide = side === "key",
isExtra = diff > 0,
diffAbs = Math.abs(diff),
spaces = Array(diffAbs + 1).join(" ");
const locStart = isKeySide
? tokenBeforeColon.loc.end
: nextColon.loc.start;
const locEnd = isKeySide
? nextColon.loc.start
: tokenAfterColon.loc.start;
const missingLoc = isKeySide
? tokenBeforeColon.loc
: tokenAfterColon.loc;
const loc = isExtra
? { start: locStart, end: locEnd }
: missingLoc;
let fix;
if (isExtra) {
let range;
// Remove whitespace
if (isKeySide) {
range = [
tokenBeforeColon.range[1],
tokenBeforeColon.range[1] + diffAbs,
];
} else {
range = [
tokenAfterColon.range[0] - diffAbs,
tokenAfterColon.range[0],
];
}
fix = function (fixer) {
return fixer.removeRange(range);
};
} else {
// Add whitespace
if (isKeySide) {
fix = function (fixer) {
return fixer.insertTextAfter(
tokenBeforeColon,
spaces,
);
};
} else {
fix = function (fixer) {
return fixer.insertTextBefore(
tokenAfterColon,
spaces,
);
};
}
}
let messageId;
if (isExtra) {
messageId = side === "key" ? "extraKey" : "extraValue";
} else {
messageId = side === "key" ? "missingKey" : "missingValue";
}
context.report({
node: property[side],
loc,
messageId,
data: {
computed: property.computed ? "computed " : "",
key: getKey(property),
},
fix,
});
}
}
/**
* Gets the number of characters in a key, including quotes around string
* keys and braces around computed property keys.
* @param {ASTNode} property Property of on object literal.
* @returns {int} Width of the key.
*/
function getKeyWidth(property) {
const startToken = sourceCode.getFirstToken(property);
const endToken = getLastTokenBeforeColon(property.key);
return getGraphemeCount(
sourceCode
.getText()
.slice(startToken.range[0], endToken.range[1]),
);
}
/**
* Gets the whitespace around the colon in an object literal property.
* @param {ASTNode} property Property node from an object literal.
* @returns {Object} Whitespace before and after the property's colon.
*/
function getPropertyWhitespace(property) {
const whitespace = /(\s*):(\s*)/u.exec(
sourceCode
.getText()
.slice(property.key.range[1], property.value.range[0]),
);
if (whitespace) {
return {
beforeColon: whitespace[1],
afterColon: whitespace[2],
};
}
return null;
}
/**
* Creates groups of properties.
* @param {ASTNode} node ObjectExpression node being evaluated.
* @returns {Array<ASTNode[]>} Groups of property AST node lists.
*/
function createGroups(node) {
if (node.properties.length === 1) {
return [node.properties];
}
return node.properties.reduce(
(groups, property) => {
const currentGroup = last(groups),
prev = last(currentGroup);
if (!prev || continuesPropertyGroup(prev, property)) {
currentGroup.push(property);
} else {
groups.push([property]);
}
return groups;
},
[[]],
);
}
/**
* Verifies correct vertical alignment of a group of properties.
* @param {ASTNode[]} properties List of Property AST nodes.
* @returns {void}
*/
function verifyGroupAlignment(properties) {
const length = properties.length,
widths = properties.map(getKeyWidth), // Width of keys, including quotes
align = alignmentOptions.on; // "value" or "colon"
let targetWidth = Math.max(...widths),
beforeColon,
afterColon,
mode;
if (alignmentOptions && length > 1) {
// When aligning values within a group, use the alignment configuration.
beforeColon = alignmentOptions.beforeColon;
afterColon = alignmentOptions.afterColon;
mode = alignmentOptions.mode;
} else {
beforeColon = multiLineOptions.beforeColon;
afterColon = multiLineOptions.afterColon;
mode = alignmentOptions.mode;
}
// Conditionally include one space before or after colon
targetWidth += align === "colon" ? beforeColon : afterColon;
for (let i = 0; i < length; i++) {
const property = properties[i];
const whitespace = getPropertyWhitespace(property);
if (whitespace) {
// Object literal getters/setters lack a colon
const width = widths[i];
if (align === "value") {
report(
property,
"key",
whitespace.beforeColon,
beforeColon,
mode,
);
report(
property,
"value",
whitespace.afterColon,
targetWidth - width,
mode,
);
} else {
// align = "colon"
report(
property,
"key",
whitespace.beforeColon,
targetWidth - width,
mode,
);
report(
property,
"value",
whitespace.afterColon,
afterColon,
mode,
);
}
}
}
}
/**
* Verifies spacing of property conforms to specified options.
* @param {ASTNode} node Property node being evaluated.
* @param {Object} lineOptions Configured singleLine or multiLine options
* @returns {void}
*/
function verifySpacing(node, lineOptions) {
const actual = getPropertyWhitespace(node);
if (actual) {
// Object literal getters/setters lack colons
report(
node,
"key",
actual.beforeColon,
lineOptions.beforeColon,
lineOptions.mode,
);
report(
node,
"value",
actual.afterColon,
lineOptions.afterColon,
lineOptions.mode,
);
}
}
/**
* Verifies spacing of each property in a list.
* @param {ASTNode[]} properties List of Property AST nodes.
* @param {Object} lineOptions Configured singleLine or multiLine options
* @returns {void}
*/
function verifyListSpacing(properties, lineOptions) {
const length = properties.length;
for (let i = 0; i < length; i++) {
verifySpacing(properties[i], lineOptions);
}
}
/**
* Verifies vertical alignment, taking into account groups of properties.
* @param {ASTNode} node ObjectExpression node being evaluated.
* @returns {void}
*/
function verifyAlignment(node) {
createGroups(node).forEach(group => {
const properties = group.filter(isKeyValueProperty);
if (
properties.length > 0 &&
isSingleLineProperties(properties)
) {
verifyListSpacing(properties, multiLineOptions);
} else {
verifyGroupAlignment(properties);
}
});
}
//--------------------------------------------------------------------------
// Public API
//--------------------------------------------------------------------------
if (alignmentOptions) {
// Verify vertical alignment
return {
ObjectExpression(node) {
if (isSingleLine(node)) {
verifyListSpacing(
node.properties.filter(isKeyValueProperty),
singleLineOptions,
);
} else {
verifyAlignment(node);
}
},
};
}
// Obey beforeColon and afterColon in each property as configured
return {
Property(node) {
verifySpacing(
node,
isSingleLine(node.parent)
? singleLineOptions
: multiLineOptions,
);
},
};
},
};

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"C L M G"},C:{"1":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC LC qC rC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"J PB K D E F"},E:{"1":"K D E F A B C L M G tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J sC SC","16":"PB"},F:{"1":"0 1 2 3 4 5 6 7 8 B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC","2":"F"},G:{"1":"E AD BD CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC"},H:{"1":"WD"},I:{"1":"LC J I aD lC bD cD","2":"XD YD ZD"},J:{"1":"D A"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:1,C:"Form attribute",D:true};

View File

@@ -0,0 +1 @@
{"version":3,"file":"not-found.cjs","sources":["../../src/not-found.ts"],"sourcesContent":["import type { RouteIds } from './routeInfo'\nimport type { RegisteredRouter } from './router'\n\nexport type NotFoundError = {\n /**\n @deprecated\n Use `routeId: rootRouteId` instead\n */\n global?: boolean\n /**\n @private\n Do not use this. It's used internally to indicate a path matching error\n */\n _global?: boolean\n data?: any\n throw?: boolean\n routeId?: RouteIds<RegisteredRouter['routeTree']>\n headers?: HeadersInit\n}\n\nexport function notFound(options: NotFoundError = {}) {\n ;(options as any).isNotFound = true\n if (options.throw) throw options\n return options\n}\n\nexport function isNotFound(obj: any): obj is NotFoundError {\n return !!obj?.isNotFound\n}\n"],"names":[],"mappings":";;AAoBgB,SAAA,SAAS,UAAyB,IAAI;AAClD,UAAgB,aAAa;AAC3B,MAAA,QAAQ,MAAa,OAAA;AAClB,SAAA;AACT;AAEO,SAAS,WAAW,KAAgC;AAClD,SAAA,CAAC,EAAC,2BAAK;AAChB;;;"}

View File

@@ -0,0 +1,340 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports._getKey = _getKey;
exports._getPattern = _getPattern;
exports.get = get;
exports.getAllNextSiblings = getAllNextSiblings;
exports.getAllPrevSiblings = getAllPrevSiblings;
exports.getAssignmentIdentifiers = getAssignmentIdentifiers;
exports.getBindingIdentifierPaths = getBindingIdentifierPaths;
exports.getBindingIdentifiers = getBindingIdentifiers;
exports.getCompletionRecords = getCompletionRecords;
exports.getNextSibling = getNextSibling;
exports.getOpposite = getOpposite;
exports.getOuterBindingIdentifierPaths = getOuterBindingIdentifierPaths;
exports.getOuterBindingIdentifiers = getOuterBindingIdentifiers;
exports.getPrevSibling = getPrevSibling;
exports.getSibling = getSibling;
var _index = require("./index.js");
var _t = require("@babel/types");
const {
getAssignmentIdentifiers: _getAssignmentIdentifiers,
getBindingIdentifiers: _getBindingIdentifiers,
getOuterBindingIdentifiers: _getOuterBindingIdentifiers,
numericLiteral,
unaryExpression
} = _t;
const NORMAL_COMPLETION = 0;
const BREAK_COMPLETION = 1;
function NormalCompletion(path) {
return {
type: NORMAL_COMPLETION,
path
};
}
function BreakCompletion(path) {
return {
type: BREAK_COMPLETION,
path
};
}
function getOpposite() {
if (this.key === "left") {
return this.getSibling("right");
} else if (this.key === "right") {
return this.getSibling("left");
}
return null;
}
function addCompletionRecords(path, records, context) {
if (path) {
records.push(..._getCompletionRecords(path, context));
}
return records;
}
function completionRecordForSwitch(cases, records, context) {
let lastNormalCompletions = [];
for (let i = 0; i < cases.length; i++) {
const casePath = cases[i];
const caseCompletions = _getCompletionRecords(casePath, context);
const normalCompletions = [];
const breakCompletions = [];
for (const c of caseCompletions) {
if (c.type === NORMAL_COMPLETION) {
normalCompletions.push(c);
}
if (c.type === BREAK_COMPLETION) {
breakCompletions.push(c);
}
}
if (normalCompletions.length) {
lastNormalCompletions = normalCompletions;
}
records.push(...breakCompletions);
}
records.push(...lastNormalCompletions);
return records;
}
function normalCompletionToBreak(completions) {
completions.forEach(c => {
c.type = BREAK_COMPLETION;
});
}
function replaceBreakStatementInBreakCompletion(completions, reachable) {
completions.forEach(c => {
if (c.path.isBreakStatement({
label: null
})) {
if (reachable) {
c.path.replaceWith(unaryExpression("void", numericLiteral(0)));
} else {
c.path.remove();
}
}
});
}
function getStatementListCompletion(paths, context) {
const completions = [];
if (context.canHaveBreak) {
let lastNormalCompletions = [];
for (let i = 0; i < paths.length; i++) {
const path = paths[i];
const newContext = Object.assign({}, context, {
inCaseClause: false
});
if (path.isBlockStatement() && (context.inCaseClause || context.shouldPopulateBreak)) {
newContext.shouldPopulateBreak = true;
} else {
newContext.shouldPopulateBreak = false;
}
const statementCompletions = _getCompletionRecords(path, newContext);
if (statementCompletions.length > 0 && statementCompletions.every(c => c.type === BREAK_COMPLETION)) {
if (lastNormalCompletions.length > 0 && statementCompletions.every(c => c.path.isBreakStatement({
label: null
}))) {
normalCompletionToBreak(lastNormalCompletions);
completions.push(...lastNormalCompletions);
if (lastNormalCompletions.some(c => c.path.isDeclaration())) {
completions.push(...statementCompletions);
replaceBreakStatementInBreakCompletion(statementCompletions, true);
}
replaceBreakStatementInBreakCompletion(statementCompletions, false);
} else {
completions.push(...statementCompletions);
if (!context.shouldPopulateBreak) {
replaceBreakStatementInBreakCompletion(statementCompletions, true);
}
}
break;
}
if (i === paths.length - 1) {
completions.push(...statementCompletions);
} else {
lastNormalCompletions = [];
for (let i = 0; i < statementCompletions.length; i++) {
const c = statementCompletions[i];
if (c.type === BREAK_COMPLETION) {
completions.push(c);
}
if (c.type === NORMAL_COMPLETION) {
lastNormalCompletions.push(c);
}
}
}
}
} else if (paths.length) {
for (let i = paths.length - 1; i >= 0; i--) {
const pathCompletions = _getCompletionRecords(paths[i], context);
if (pathCompletions.length > 1 || pathCompletions.length === 1 && !pathCompletions[0].path.isVariableDeclaration()) {
completions.push(...pathCompletions);
break;
}
}
}
return completions;
}
function _getCompletionRecords(path, context) {
let records = [];
if (path.isIfStatement()) {
records = addCompletionRecords(path.get("consequent"), records, context);
records = addCompletionRecords(path.get("alternate"), records, context);
} else if (path.isDoExpression() || path.isFor() || path.isWhile() || path.isLabeledStatement()) {
return addCompletionRecords(path.get("body"), records, context);
} else if (path.isProgram() || path.isBlockStatement()) {
return getStatementListCompletion(path.get("body"), context);
} else if (path.isFunction()) {
return _getCompletionRecords(path.get("body"), context);
} else if (path.isTryStatement()) {
records = addCompletionRecords(path.get("block"), records, context);
records = addCompletionRecords(path.get("handler"), records, context);
} else if (path.isCatchClause()) {
return addCompletionRecords(path.get("body"), records, context);
} else if (path.isSwitchStatement()) {
return completionRecordForSwitch(path.get("cases"), records, context);
} else if (path.isSwitchCase()) {
return getStatementListCompletion(path.get("consequent"), {
canHaveBreak: true,
shouldPopulateBreak: false,
inCaseClause: true
});
} else if (path.isBreakStatement()) {
records.push(BreakCompletion(path));
} else {
records.push(NormalCompletion(path));
}
return records;
}
function getCompletionRecords() {
const records = _getCompletionRecords(this, {
canHaveBreak: false,
shouldPopulateBreak: false,
inCaseClause: false
});
return records.map(r => r.path);
}
function getSibling(key) {
return _index.default.get({
parentPath: this.parentPath,
parent: this.parent,
container: this.container,
listKey: this.listKey,
key: key
}).setContext(this.context);
}
function getPrevSibling() {
return this.getSibling(this.key - 1);
}
function getNextSibling() {
return this.getSibling(this.key + 1);
}
function getAllNextSiblings() {
let _key = this.key;
let sibling = this.getSibling(++_key);
const siblings = [];
while (sibling.node) {
siblings.push(sibling);
sibling = this.getSibling(++_key);
}
return siblings;
}
function getAllPrevSiblings() {
let _key = this.key;
let sibling = this.getSibling(--_key);
const siblings = [];
while (sibling.node) {
siblings.push(sibling);
sibling = this.getSibling(--_key);
}
return siblings;
}
function get(key, context = true) {
if (context === true) context = this.context;
const parts = key.split(".");
if (parts.length === 1) {
return _getKey.call(this, key, context);
} else {
return _getPattern.call(this, parts, context);
}
}
function _getKey(key, context) {
const node = this.node;
const container = node[key];
if (Array.isArray(container)) {
return container.map((_, i) => {
return _index.default.get({
listKey: key,
parentPath: this,
parent: node,
container: container,
key: i
}).setContext(context);
});
} else {
return _index.default.get({
parentPath: this,
parent: node,
container: node,
key: key
}).setContext(context);
}
}
function _getPattern(parts, context) {
let path = this;
for (const part of parts) {
if (part === ".") {
path = path.parentPath;
} else {
if (Array.isArray(path)) {
path = path[part];
} else {
path = path.get(part, context);
}
}
}
return path;
}
function getAssignmentIdentifiers() {
return _getAssignmentIdentifiers(this.node);
}
function getBindingIdentifiers(duplicates) {
return _getBindingIdentifiers(this.node, duplicates);
}
function getOuterBindingIdentifiers(duplicates) {
return _getOuterBindingIdentifiers(this.node, duplicates);
}
function getBindingIdentifierPaths(duplicates = false, outerOnly = false) {
const path = this;
const search = [path];
const ids = Object.create(null);
while (search.length) {
const id = search.shift();
if (!id) continue;
if (!id.node) continue;
const keys = _getBindingIdentifiers.keys[id.node.type];
if (id.isIdentifier()) {
if (duplicates) {
const _ids = ids[id.node.name] = ids[id.node.name] || [];
_ids.push(id);
} else {
ids[id.node.name] = id;
}
continue;
}
if (id.isExportDeclaration()) {
const declaration = id.get("declaration");
if (declaration.isDeclaration()) {
search.push(declaration);
}
continue;
}
if (outerOnly) {
if (id.isFunctionDeclaration()) {
search.push(id.get("id"));
continue;
}
if (id.isFunctionExpression()) {
continue;
}
}
if (keys) {
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const child = id.get(key);
if (Array.isArray(child)) {
search.push(...child);
} else if (child.node) {
search.push(child);
}
}
}
}
return ids;
}
function getOuterBindingIdentifierPaths(duplicates = false) {
return this.getBindingIdentifierPaths(duplicates, true);
}
//# sourceMappingURL=family.js.map

View File

@@ -0,0 +1,11 @@
A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/)
```js
var colors = require('color-name');
colors.red //[255,0,0]
```
<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>

View File

@@ -0,0 +1 @@
module.exports={A:{A:{"1":"A B","2":"K D E F mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"2":"1 2 3 4 nC LC J PB K D E F A B C L M G N O P QB qC rC","66":"5 6 7 8 RB SB TB","129":"UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB","257":"0 9 sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC"},D:{"1":"0 4 5 6 7 8 9 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 J PB K D E F A B C L M G N O P QB"},E:{"1":"K D E F A B C L M G uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB sC SC tC"},F:{"1":"0 1 2 3 4 5 6 7 8 G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z","2":"F B C 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"E CD DD ED FD GD HD ID JD KD LD MD ND OD PD QD RD SD UC VC HC TD IC WC XC YC ZC aC UD JC bC cC dC eC fC VD KC gC hC iC jC","2":"SC 9C lC AD BD"},H:{"2":"WD"},I:{"1":"I bD cD","2":"LC J XD YD ZD aD lC"},J:{"1":"A","2":"D"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"B","2":"A"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 J dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"129":"qD rD"}},B:4,C:"WebVTT - Web Video Text Tracks",D:true};

View File

@@ -0,0 +1,18 @@
'use strict';
var l, s;
if (process.env.NODE_ENV === 'production') {
l = require('./cjs/react-dom-server-legacy.browser.production.js');
s = require('./cjs/react-dom-server.browser.production.js');
} else {
l = require('./cjs/react-dom-server-legacy.browser.development.js');
s = require('./cjs/react-dom-server.browser.development.js');
}
exports.version = l.version;
exports.renderToString = l.renderToString;
exports.renderToStaticMarkup = l.renderToStaticMarkup;
exports.renderToReadableStream = s.renderToReadableStream;
if (s.resume) {
exports.resume = s.resume;
}

View File

@@ -0,0 +1,29 @@
import type { RouteIds } from './routeInfo'
import type { RegisteredRouter } from './router'
export type NotFoundError = {
/**
@deprecated
Use `routeId: rootRouteId` instead
*/
global?: boolean
/**
@private
Do not use this. It's used internally to indicate a path matching error
*/
_global?: boolean
data?: any
throw?: boolean
routeId?: RouteIds<RegisteredRouter['routeTree']>
headers?: HeadersInit
}
export function notFound(options: NotFoundError = {}) {
;(options as any).isNotFound = true
if (options.throw) throw options
return options
}
export function isNotFound(obj: any): obj is NotFoundError {
return !!obj?.isNotFound
}

View File

@@ -0,0 +1,3 @@
declare function clearRequireCache(files: string[]): void;
export { clearRequireCache };

View File

@@ -0,0 +1,43 @@
{
"name": "json-schema-traverse",
"version": "0.4.1",
"description": "Traverse JSON Schema passing each schema object to callback",
"main": "index.js",
"scripts": {
"eslint": "eslint index.js spec",
"test-spec": "mocha spec -R spec",
"test": "npm run eslint && nyc npm run test-spec"
},
"repository": {
"type": "git",
"url": "git+https://github.com/epoberezkin/json-schema-traverse.git"
},
"keywords": [
"JSON-Schema",
"traverse",
"iterate"
],
"author": "Evgeny Poberezkin",
"license": "MIT",
"bugs": {
"url": "https://github.com/epoberezkin/json-schema-traverse/issues"
},
"homepage": "https://github.com/epoberezkin/json-schema-traverse#readme",
"devDependencies": {
"coveralls": "^2.13.1",
"eslint": "^3.19.0",
"mocha": "^3.4.2",
"nyc": "^11.0.2",
"pre-commit": "^1.2.2"
},
"nyc": {
"exclude": [
"**/spec/**",
"node_modules"
],
"reporter": [
"lcov",
"text-summary"
]
}
}

View File

@@ -0,0 +1,167 @@
/**
* @fileoverview Rule to flag use of unnecessary semicolons
* @author Nicholas C. Zakas
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const FixTracker = require("./utils/fix-tracker");
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
deprecated: {
message: "Formatting rules are being moved out of ESLint core.",
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
deprecatedSince: "8.53.0",
availableUntil: "10.0.0",
replacedBy: [
{
message:
"ESLint Stylistic now maintains deprecated stylistic core rules.",
url: "https://eslint.style/guide/migration",
plugin: {
name: "@stylistic/eslint-plugin-js",
url: "https://eslint.style/packages/js",
},
rule: {
name: "no-extra-semi",
url: "https://eslint.style/rules/js/no-extra-semi",
},
},
],
},
type: "suggestion",
docs: {
description: "Disallow unnecessary semicolons",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-extra-semi",
},
fixable: "code",
schema: [],
messages: {
unexpected: "Unnecessary semicolon.",
},
},
create(context) {
const sourceCode = context.sourceCode;
/**
* Checks if a node or token is fixable.
* A node is fixable if it can be removed without turning a subsequent statement into a directive after fixing other nodes.
* @param {Token} nodeOrToken The node or token to check.
* @returns {boolean} Whether or not the node is fixable.
*/
function isFixable(nodeOrToken) {
const nextToken = sourceCode.getTokenAfter(nodeOrToken);
if (!nextToken || nextToken.type !== "String") {
return true;
}
const stringNode = sourceCode.getNodeByRangeIndex(
nextToken.range[0],
);
return !astUtils.isTopLevelExpressionStatement(stringNode.parent);
}
/**
* Reports an unnecessary semicolon error.
* @param {Node|Token} nodeOrToken A node or a token to be reported.
* @returns {void}
*/
function report(nodeOrToken) {
context.report({
node: nodeOrToken,
messageId: "unexpected",
fix: isFixable(nodeOrToken)
? fixer =>
/*
* Expand the replacement range to include the surrounding
* tokens to avoid conflicting with semi.
* https://github.com/eslint/eslint/issues/7928
*/
new FixTracker(fixer, context.sourceCode)
.retainSurroundingTokens(nodeOrToken)
.remove(nodeOrToken)
: null,
});
}
/**
* Checks for a part of a class body.
* This checks tokens from a specified token to a next MethodDefinition or the end of class body.
* @param {Token} firstToken The first token to check.
* @returns {void}
*/
function checkForPartOfClassBody(firstToken) {
for (
let token = firstToken;
token.type === "Punctuator" &&
!astUtils.isClosingBraceToken(token);
token = sourceCode.getTokenAfter(token)
) {
if (astUtils.isSemicolonToken(token)) {
report(token);
}
}
}
return {
/**
* Reports this empty statement, except if the parent node is a loop.
* @param {Node} node A EmptyStatement node to be reported.
* @returns {void}
*/
EmptyStatement(node) {
const parent = node.parent,
allowedParentTypes = [
"ForStatement",
"ForInStatement",
"ForOfStatement",
"WhileStatement",
"DoWhileStatement",
"IfStatement",
"LabeledStatement",
"WithStatement",
];
if (!allowedParentTypes.includes(parent.type)) {
report(node);
}
},
/**
* Checks tokens from the head of this class body to the first MethodDefinition or the end of this class body.
* @param {Node} node A ClassBody node to check.
* @returns {void}
*/
ClassBody(node) {
checkForPartOfClassBody(sourceCode.getFirstToken(node, 1)); // 0 is `{`.
},
/**
* Checks tokens from this MethodDefinition to the next MethodDefinition or the end of this class body.
* @param {Node} node A MethodDefinition node of the start point.
* @returns {void}
*/
"MethodDefinition, PropertyDefinition, StaticBlock"(node) {
checkForPartOfClassBody(sourceCode.getTokenAfter(node));
},
};
},
};

View File

@@ -0,0 +1 @@
{"version":3,"names":["_cloneNode","require","cloneDeepWithoutLoc","node","cloneNode"],"sources":["../../src/clone/cloneDeepWithoutLoc.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * excluding `_private` and location properties.\n */\nexport default function cloneDeepWithoutLoc<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ true, /* withoutLoc */ true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAOe,SAASC,mBAAmBA,CAAmBC,IAAO,EAAK;EACxE,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,IAAI,EAAmB,IAAI,CAAC;AAChE","ignoreList":[]}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hooks = void 0;
const hooks = exports.hooks = [function (self, parent) {
const removeParent = self.key === "test" && (parent.isWhile() || parent.isSwitchCase()) || self.key === "declaration" && parent.isExportDeclaration() || self.key === "body" && parent.isLabeledStatement() || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 1 || self.key === "expression" && parent.isExpressionStatement();
if (removeParent) {
parent.remove();
return true;
}
}, function (self, parent) {
if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
parent.replaceWith(parent.node.expressions[0]);
return true;
}
}, function (self, parent) {
if (parent.isBinary()) {
if (self.key === "left") {
parent.replaceWith(parent.node.right);
} else {
parent.replaceWith(parent.node.left);
}
return true;
}
}, function (self, parent) {
if (parent.isIfStatement() && self.key === "consequent" || self.key === "body" && (parent.isLoop() || parent.isArrowFunctionExpression())) {
self.replaceWith({
type: "BlockStatement",
body: []
});
return true;
}
}];
//# sourceMappingURL=removal-hooks.js.map

View File

@@ -0,0 +1,116 @@
export type PDFHistoryOptions = {
/**
* - The navigation/linking service.
*/
linkService: IPDFLinkService;
/**
* - The application event bus.
*/
eventBus: EventBus;
};
export type InitializeParameters = {
/**
* - The PDF document's unique fingerprint.
*/
fingerprint: string;
/**
* - Reset the browsing history.
*/
resetHistory?: boolean | undefined;
/**
* - Attempt to update the document URL, with
* the current hash, when pushing/replacing browser history entries.
*/
updateUrl?: boolean | undefined;
};
export type PushParameters = {
/**
* - The named destination. If absent, a
* stringified version of `explicitDest` is used.
*/
namedDest?: string | undefined;
/**
* - The explicit destination array.
*/
explicitDest: any[];
/**
* - The page to which the destination points.
*/
pageNumber: number;
};
export type EventBus = import("./event_utils").EventBus;
export type IPDFLinkService = import("./interfaces").IPDFLinkService;
export function isDestArraysEqual(firstDest: any, secondDest: any): boolean;
export function isDestHashesEqual(destHash: any, pushHash: any): boolean;
export class PDFHistory {
/**
* @param {PDFHistoryOptions} options
*/
constructor({ linkService, eventBus }: PDFHistoryOptions);
linkService: import("./interfaces").IPDFLinkService;
eventBus: import("./event_utils.js").EventBus;
_initialized: boolean;
_fingerprint: string;
_isPagesLoaded: boolean;
/**
* Initialize the history for the PDF document, using either the current
* browser history entry or the document hash, whichever is present.
* @param {InitializeParameters} params
*/
initialize({ fingerprint, resetHistory, updateUrl }: InitializeParameters): void;
_updateUrl: boolean | undefined;
_popStateInProgress: boolean | undefined;
_blockHashChange: number | undefined;
_currentHash: string | undefined;
_numPositionUpdates: number | undefined;
_uid: any;
_maxUid: any;
_destination: any;
_position: {
hash: any;
page: number;
first: any;
rotation: any;
} | null | undefined;
_initialRotation: any;
_initialBookmark: any;
/**
* Reset the current `PDFHistory` instance, and consequently prevent any
* further updates and/or navigation of the browser history.
*/
reset(): void;
_updateViewareaTimeout: any;
/**
* Push an internal destination to the browser history.
* @param {PushParameters}
*/
push({ namedDest, explicitDest, pageNumber }: PushParameters): void;
/**
* Push a page to the browser history; generally the `push` method should be
* used instead.
* @param {number} pageNumber
*/
pushPage(pageNumber: number): void;
/**
* Push the current position to the browser history.
*/
pushCurrentPosition(): void;
/**
* Go back one step in the browser history.
* NOTE: Avoids navigating away from the document, useful for "named actions".
*/
back(): void;
/**
* Go forward one step in the browser history.
* NOTE: Avoids navigating away from the document, useful for "named actions".
*/
forward(): void;
/**
* @type {boolean} Indicating if the user is currently moving through the
* browser history, useful e.g. for skipping the next 'hashchange' event.
*/
get popStateInProgress(): boolean;
get initialBookmark(): any;
get initialRotation(): any;
#private;
}

View File

@@ -0,0 +1,160 @@
function last(arr) {
return arr[arr.length - 1];
}
function isFunction(d) {
return typeof d === "function";
}
function functionalUpdate(updater, previous) {
if (isFunction(updater)) {
return updater(previous);
}
return updater;
}
function pick(parent, keys) {
return keys.reduce((obj, key) => {
obj[key] = parent[key];
return obj;
}, {});
}
function replaceEqualDeep(prev, _next) {
if (prev === _next) {
return prev;
}
const next = _next;
const array = isPlainArray(prev) && isPlainArray(next);
if (array || isPlainObject(prev) && isPlainObject(next)) {
const prevItems = array ? prev : Object.keys(prev);
const prevSize = prevItems.length;
const nextItems = array ? next : Object.keys(next);
const nextSize = nextItems.length;
const copy = array ? [] : {};
let equalItems = 0;
for (let i = 0; i < nextSize; i++) {
const key = array ? i : nextItems[i];
if ((!array && prevItems.includes(key) || array) && prev[key] === void 0 && next[key] === void 0) {
copy[key] = void 0;
equalItems++;
} else {
copy[key] = replaceEqualDeep(prev[key], next[key]);
if (copy[key] === prev[key] && prev[key] !== void 0) {
equalItems++;
}
}
}
return prevSize === nextSize && equalItems === prevSize ? prev : copy;
}
return next;
}
function isPlainObject(o) {
if (!hasObjectPrototype(o)) {
return false;
}
const ctor = o.constructor;
if (typeof ctor === "undefined") {
return true;
}
const prot = ctor.prototype;
if (!hasObjectPrototype(prot)) {
return false;
}
if (!prot.hasOwnProperty("isPrototypeOf")) {
return false;
}
return true;
}
function hasObjectPrototype(o) {
return Object.prototype.toString.call(o) === "[object Object]";
}
function isPlainArray(value) {
return Array.isArray(value) && value.length === Object.keys(value).length;
}
function getObjectKeys(obj, ignoreUndefined) {
let keys = Object.keys(obj);
if (ignoreUndefined) {
keys = keys.filter((key) => obj[key] !== void 0);
}
return keys;
}
function deepEqual(a, b, opts) {
if (a === b) {
return true;
}
if (typeof a !== typeof b) {
return false;
}
if (isPlainObject(a) && isPlainObject(b)) {
const ignoreUndefined = (opts == null ? void 0 : opts.ignoreUndefined) ?? true;
const aKeys = getObjectKeys(a, ignoreUndefined);
const bKeys = getObjectKeys(b, ignoreUndefined);
if (!(opts == null ? void 0 : opts.partial) && aKeys.length !== bKeys.length) {
return false;
}
return bKeys.every((key) => deepEqual(a[key], b[key], opts));
}
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) {
return false;
}
return !a.some((item, index) => !deepEqual(item, b[index], opts));
}
return false;
}
function createControlledPromise(onResolve) {
let resolveLoadPromise;
let rejectLoadPromise;
const controlledPromise = new Promise((resolve, reject) => {
resolveLoadPromise = resolve;
rejectLoadPromise = reject;
});
controlledPromise.status = "pending";
controlledPromise.resolve = (value) => {
controlledPromise.status = "resolved";
controlledPromise.value = value;
resolveLoadPromise(value);
onResolve == null ? void 0 : onResolve(value);
};
controlledPromise.reject = (e) => {
controlledPromise.status = "rejected";
rejectLoadPromise(e);
};
return controlledPromise;
}
function escapeJSON(jsonString) {
return jsonString.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"');
}
function shallow(objA, objB) {
if (Object.is(objA, objB)) {
return true;
}
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
return false;
}
const keysA = Object.keys(objA);
if (keysA.length !== Object.keys(objB).length) {
return false;
}
for (const item of keysA) {
if (!Object.prototype.hasOwnProperty.call(objB, item) || !Object.is(objA[item], objB[item])) {
return false;
}
}
return true;
}
function hasUriEncodedChars(inputString) {
const pattern = /%[0-9A-Fa-f]{2}/;
return pattern.test(inputString);
}
export {
createControlledPromise,
deepEqual,
escapeJSON,
functionalUpdate,
hasUriEncodedChars,
isPlainArray,
isPlainObject,
last,
pick,
replaceEqualDeep,
shallow
};
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1,122 @@
import * as React from "react";
import { createElement } from "react";
import { Asset } from "./Asset.js";
import { useRouter } from "./useRouter.js";
import { useRouterState } from "./useRouterState.js";
const useTags = () => {
const router = useRouter();
const routeMeta = useRouterState({
select: (state) => {
return state.matches.map((match) => match.meta).filter(Boolean);
}
});
const meta = React.useMemo(() => {
const resultMeta = [];
const metaByAttribute = {};
let title;
[...routeMeta].reverse().forEach((metas) => {
[...metas].reverse().forEach((m) => {
if (!m) return;
if (m.title) {
if (!title) {
title = {
tag: "title",
children: m.title
};
}
} else {
const attribute = m.name ?? m.property;
if (attribute) {
if (metaByAttribute[attribute]) {
return;
} else {
metaByAttribute[attribute] = true;
}
}
resultMeta.push({
tag: "meta",
attrs: {
...m
}
});
}
});
});
if (title) {
resultMeta.push(title);
}
resultMeta.reverse();
return resultMeta;
}, [routeMeta]);
const links = useRouterState({
select: (state) => state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
tag: "link",
attrs: {
...link
}
})),
structuralSharing: true
});
const preloadMeta = useRouterState({
select: (state) => {
const preloadMeta2 = [];
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
(route) => {
var _a, _b, _c, _d;
return (_d = (_c = (_b = (_a = router.ssr) == null ? void 0 : _a.manifest) == null ? void 0 : _b.routes[route.id]) == null ? void 0 : _c.preloads) == null ? void 0 : _d.filter(Boolean).forEach((preload) => {
preloadMeta2.push({
tag: "link",
attrs: {
rel: "modulepreload",
href: preload
}
});
});
}
);
return preloadMeta2;
},
structuralSharing: true
});
const headScripts = useRouterState({
select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
tag: "script",
attrs: {
...script
},
children
})),
structuralSharing: true
});
return uniqBy(
[
...meta,
...preloadMeta,
...links,
...headScripts
],
(d) => {
return JSON.stringify(d);
}
);
};
function HeadContent() {
const tags = useTags();
return tags.map((tag) => /* @__PURE__ */ createElement(Asset, { ...tag, key: `tsr-meta-${JSON.stringify(tag)}` }));
}
function uniqBy(arr, fn) {
const seen = /* @__PURE__ */ new Set();
return arr.filter((item) => {
const key = fn(item);
if (seen.has(key)) {
return false;
}
seen.add(key);
return true;
});
}
export {
HeadContent,
useTags
};
//# sourceMappingURL=HeadContent.js.map

View File

@@ -0,0 +1,5 @@
# use-sync-external-store
Backwards-compatible shim for [`React.useSyncExternalStore`](https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore). Works with any React that supports Hooks.
See also https://github.com/reactwg/react-18/discussions/86.

View File

@@ -0,0 +1,158 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = loadPrivatePartialConfig;
exports.loadPartialConfig = loadPartialConfig;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
var _plugin = require("./plugin.js");
var _util = require("./util.js");
var _item = require("./item.js");
var _configChain = require("./config-chain.js");
var _environment = require("./helpers/environment.js");
var _options = require("./validation/options.js");
var _index = require("./files/index.js");
var _resolveTargets = require("./resolve-targets.js");
const _excluded = ["showIgnoredFiles"];
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
function resolveRootMode(rootDir, rootMode) {
switch (rootMode) {
case "root":
return rootDir;
case "upward-optional":
{
const upwardRootDir = (0, _index.findConfigUpwards)(rootDir);
return upwardRootDir === null ? rootDir : upwardRootDir;
}
case "upward":
{
const upwardRootDir = (0, _index.findConfigUpwards)(rootDir);
if (upwardRootDir !== null) return upwardRootDir;
throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}".\n` + `One of the following config files must be in the directory tree: ` + `"${_index.ROOT_CONFIG_FILENAMES.join(", ")}".`), {
code: "BABEL_ROOT_NOT_FOUND",
dirname: rootDir
});
}
default:
throw new Error(`Assertion failure - unknown rootMode value.`);
}
}
function* loadPrivatePartialConfig(inputOpts) {
if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) {
throw new Error("Babel options must be an object, null, or undefined");
}
const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};
const {
envName = (0, _environment.getEnv)(),
cwd = ".",
root: rootDir = ".",
rootMode = "root",
caller,
cloneInputAst = true
} = args;
const absoluteCwd = _path().resolve(cwd);
const absoluteRootDir = resolveRootMode(_path().resolve(absoluteCwd, rootDir), rootMode);
const filename = typeof args.filename === "string" ? _path().resolve(cwd, args.filename) : undefined;
const showConfigPath = yield* (0, _index.resolveShowConfigPath)(absoluteCwd);
const context = {
filename,
cwd: absoluteCwd,
root: absoluteRootDir,
envName,
caller,
showConfig: showConfigPath === filename
};
const configChain = yield* (0, _configChain.buildRootChain)(args, context);
if (!configChain) return null;
const merged = {
assumptions: {}
};
configChain.options.forEach(opts => {
(0, _util.mergeOptions)(merged, opts);
});
const options = Object.assign({}, merged, {
targets: (0, _resolveTargets.resolveTargets)(merged, absoluteRootDir),
cloneInputAst,
babelrc: false,
configFile: false,
browserslistConfigFile: false,
passPerPreset: false,
envName: context.envName,
cwd: context.cwd,
root: context.root,
rootMode: "root",
filename: typeof context.filename === "string" ? context.filename : undefined,
plugins: configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)),
presets: configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor))
});
return {
options,
context,
fileHandling: configChain.fileHandling,
ignore: configChain.ignore,
babelrc: configChain.babelrc,
config: configChain.config,
files: configChain.files
};
}
function* loadPartialConfig(opts) {
let showIgnoredFiles = false;
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
var _opts = opts;
({
showIgnoredFiles
} = _opts);
opts = _objectWithoutPropertiesLoose(_opts, _excluded);
_opts;
}
const result = yield* loadPrivatePartialConfig(opts);
if (!result) return null;
const {
options,
babelrc,
ignore,
config,
fileHandling,
files
} = result;
if (fileHandling === "ignored" && !showIgnoredFiles) {
return null;
}
(options.plugins || []).forEach(item => {
if (item.value instanceof _plugin.default) {
throw new Error("Passing cached plugin instances is not supported in " + "babel.loadPartialConfig()");
}
});
return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined, fileHandling, files);
}
class PartialConfig {
constructor(options, babelrc, ignore, config, fileHandling, files) {
this.options = void 0;
this.babelrc = void 0;
this.babelignore = void 0;
this.config = void 0;
this.fileHandling = void 0;
this.files = void 0;
this.options = options;
this.babelignore = ignore;
this.babelrc = babelrc;
this.config = config;
this.fileHandling = fileHandling;
this.files = files;
Object.freeze(this);
}
hasFilesystemConfig() {
return this.babelrc !== undefined || this.config !== undefined;
}
}
Object.freeze(PartialConfig.prototype);
0 && 0;
//# sourceMappingURL=partial.js.map