update
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const Hook = require("./Hook");
|
||||
const HookCodeFactory = require("./HookCodeFactory");
|
||||
|
||||
class SyncLoopHookCodeFactory extends HookCodeFactory {
|
||||
content({ onError, onDone, rethrowIfPossible }) {
|
||||
return this.callTapsLooping({
|
||||
onError: (i, err) => onError(err),
|
||||
onDone,
|
||||
rethrowIfPossible
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const factory = new SyncLoopHookCodeFactory();
|
||||
|
||||
const TAP_ASYNC = () => {
|
||||
throw new Error("tapAsync is not supported on a SyncLoopHook");
|
||||
};
|
||||
|
||||
const TAP_PROMISE = () => {
|
||||
throw new Error("tapPromise is not supported on a SyncLoopHook");
|
||||
};
|
||||
|
||||
const COMPILE = function(options) {
|
||||
factory.setup(this, options);
|
||||
return factory.create(options);
|
||||
};
|
||||
|
||||
function SyncLoopHook(args = [], name = undefined) {
|
||||
const hook = new Hook(args, name);
|
||||
hook.constructor = SyncLoopHook;
|
||||
hook.tapAsync = TAP_ASYNC;
|
||||
hook.tapPromise = TAP_PROMISE;
|
||||
hook.compile = COMPILE;
|
||||
return hook;
|
||||
}
|
||||
|
||||
SyncLoopHook.prototype = null;
|
||||
|
||||
module.exports = SyncLoopHook;
|
||||
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
// From pdfjs-dist/lib/web/struct_tree_layer_builder.js
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HEADING_PATTERN = exports.PDF_ROLE_TO_HTML_ROLE = void 0;
|
||||
exports.PDF_ROLE_TO_HTML_ROLE = {
|
||||
// Document level structure types
|
||||
Document: null, // There's a "document" role, but it doesn't make sense here.
|
||||
DocumentFragment: null,
|
||||
// Grouping level structure types
|
||||
Part: 'group',
|
||||
Sect: 'group', // XXX: There's a "section" role, but it's abstract.
|
||||
Div: 'group',
|
||||
Aside: 'note',
|
||||
NonStruct: 'none',
|
||||
// Block level structure types
|
||||
P: null,
|
||||
// H<n>,
|
||||
H: 'heading',
|
||||
Title: null,
|
||||
FENote: 'note',
|
||||
// Sub-block level structure type
|
||||
Sub: 'group',
|
||||
// General inline level structure types
|
||||
Lbl: null,
|
||||
Span: null,
|
||||
Em: null,
|
||||
Strong: null,
|
||||
Link: 'link',
|
||||
Annot: 'note',
|
||||
Form: 'form',
|
||||
// Ruby and Warichu structure types
|
||||
Ruby: null,
|
||||
RB: null,
|
||||
RT: null,
|
||||
RP: null,
|
||||
Warichu: null,
|
||||
WT: null,
|
||||
WP: null,
|
||||
// List standard structure types
|
||||
L: 'list',
|
||||
LI: 'listitem',
|
||||
LBody: null,
|
||||
// Table standard structure types
|
||||
Table: 'table',
|
||||
TR: 'row',
|
||||
TH: 'columnheader',
|
||||
TD: 'cell',
|
||||
THead: 'columnheader',
|
||||
TBody: null,
|
||||
TFoot: null,
|
||||
// Standard structure type Caption
|
||||
Caption: null,
|
||||
// Standard structure type Figure
|
||||
Figure: 'figure',
|
||||
// Standard structure type Formula
|
||||
Formula: null,
|
||||
// standard structure type Artifact
|
||||
Artifact: null,
|
||||
};
|
||||
exports.HEADING_PATTERN = /^H(\d+)$/;
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "esbuild",
|
||||
"version": "0.25.2",
|
||||
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "node install.js"
|
||||
},
|
||||
"main": "lib/main.js",
|
||||
"types": "lib/main.d.ts",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.25.2",
|
||||
"@esbuild/android-arm": "0.25.2",
|
||||
"@esbuild/android-arm64": "0.25.2",
|
||||
"@esbuild/android-x64": "0.25.2",
|
||||
"@esbuild/darwin-arm64": "0.25.2",
|
||||
"@esbuild/darwin-x64": "0.25.2",
|
||||
"@esbuild/freebsd-arm64": "0.25.2",
|
||||
"@esbuild/freebsd-x64": "0.25.2",
|
||||
"@esbuild/linux-arm": "0.25.2",
|
||||
"@esbuild/linux-arm64": "0.25.2",
|
||||
"@esbuild/linux-ia32": "0.25.2",
|
||||
"@esbuild/linux-loong64": "0.25.2",
|
||||
"@esbuild/linux-mips64el": "0.25.2",
|
||||
"@esbuild/linux-ppc64": "0.25.2",
|
||||
"@esbuild/linux-riscv64": "0.25.2",
|
||||
"@esbuild/linux-s390x": "0.25.2",
|
||||
"@esbuild/linux-x64": "0.25.2",
|
||||
"@esbuild/netbsd-arm64": "0.25.2",
|
||||
"@esbuild/netbsd-x64": "0.25.2",
|
||||
"@esbuild/openbsd-arm64": "0.25.2",
|
||||
"@esbuild/openbsd-x64": "0.25.2",
|
||||
"@esbuild/sunos-x64": "0.25.2",
|
||||
"@esbuild/win32-arm64": "0.25.2",
|
||||
"@esbuild/win32-ia32": "0.25.2",
|
||||
"@esbuild/win32-x64": "0.25.2"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"115":0.0112,"132":0.02614,"135":0.43314,"136":0.49662,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 133 134 137 138 139 140 3.5 3.6"},D:{"39":0.00373,"40":0.0112,"41":0.01494,"42":0.0112,"43":0.00747,"44":0.00747,"45":0.00373,"46":0.00373,"47":0.00747,"48":0.0112,"50":0.01494,"51":0.00373,"52":0.01494,"53":0.0112,"54":0.00747,"56":0.00373,"57":0.00747,"59":0.0224,"79":0.04854,"89":0.0112,"90":0.00373,"93":0.00373,"101":0.00747,"103":0.04481,"109":0.08962,"116":0.07841,"119":0.00747,"122":0.02614,"123":0.04107,"124":0.00747,"125":0.04107,"126":0.01494,"127":0.07468,"128":0.00747,"129":0.15683,"130":0.11575,"131":1.1202,"132":0.49289,"133":6.44862,"134":10.12287,"135":0.00373,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 49 55 58 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 83 84 85 86 87 88 91 92 94 95 96 97 98 99 100 102 104 105 106 107 108 110 111 112 113 114 115 117 118 120 121 136 137 138"},F:{"87":0.0112,"116":0.31739,"117":0.35473,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"89":0.02987,"92":0.1867,"100":0.00747,"109":0.09708,"113":0.0112,"120":0.02614,"122":0.00747,"123":0.00747,"127":0.01867,"128":0.00373,"129":0.15683,"130":0.07841,"131":0.02987,"132":0.25018,"133":2.58393,"134":4.91394,_:"12 13 14 15 16 17 18 79 80 81 83 84 85 86 87 88 90 91 93 94 95 96 97 98 99 101 102 103 104 105 106 107 108 110 111 112 114 115 116 117 118 119 121 124 125 126"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 12.1 13.1 15.1 15.2-15.3 15.4 16.5","11.1":0.00373,"14.1":0.04107,"15.5":0.11949,"15.6":0.19417,"16.0":0.00373,"16.1":0.01494,"16.2":0.00747,"16.3":0.05601,"16.4":0.0224,"16.6":1.00071,"17.0":0.00747,"17.1":0.10455,"17.2":0.02987,"17.3":0.03361,"17.4":0.07841,"17.5":0.11949,"17.6":0.36593,"18.0":0.27632,"18.1":0.24271,"18.2":0.13816,"18.3":3.45022,"18.4":0.07095},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00672,"5.0-5.1":0,"6.0-6.1":0.02016,"7.0-7.1":0.01344,"8.1-8.4":0,"9.0-9.2":0.01008,"9.3":0.04704,"10.0-10.2":0.00336,"10.3":0.07728,"11.0-11.2":0.35614,"11.3-11.4":0.02352,"12.0-12.1":0.01344,"12.2-12.5":0.33262,"13.0-13.1":0.00672,"13.2":0.01008,"13.3":0.01344,"13.4-13.7":0.04704,"14.0-14.4":0.11759,"14.5-14.8":0.14111,"15.0-15.1":0.07728,"15.2-15.3":0.07728,"15.4":0.09408,"15.5":0.10751,"15.6-15.8":1.32377,"16.0":0.18815,"16.1":0.38638,"16.2":0.20159,"16.3":0.34942,"16.4":0.07728,"16.5":0.14447,"16.6-16.7":1.56904,"17.0":0.09408,"17.1":0.16799,"17.2":0.12767,"17.3":0.17807,"17.4":0.35614,"17.5":0.79292,"17.6-17.7":2.30148,"18.0":0.64509,"18.1":2.10997,"18.2":0.94411,"18.3":19.73228,"18.4":0.29231},P:{"21":0.01067,"22":0.0427,"23":0.01067,"24":0.09607,"25":0.01067,"26":0.01067,"27":3.63983,_:"4 20 5.0-5.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0","6.2-6.4":0.01067,"7.2-7.4":1.38762},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":0},K:{"0":0.05639,_:"10 11 12 11.1 11.5 12.1"},A:{_:"6 7 8 9 10 11 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.06893},Q:{_:"14.9"},O:{"0":0.01253},H:{"0":0},L:{"0":24.51985}};
|
||||
@@ -0,0 +1,61 @@
|
||||
import { HEADING_PATTERN, PDF_ROLE_TO_HTML_ROLE } from './constants.js';
|
||||
export function isPdfRole(role) {
|
||||
return role in PDF_ROLE_TO_HTML_ROLE;
|
||||
}
|
||||
export function isStructTreeNode(node) {
|
||||
return 'children' in node;
|
||||
}
|
||||
export function isStructTreeNodeWithOnlyContentChild(node) {
|
||||
if (!isStructTreeNode(node)) {
|
||||
return false;
|
||||
}
|
||||
return node.children.length === 1 && 0 in node.children && 'id' in node.children[0];
|
||||
}
|
||||
export function getRoleAttributes(node) {
|
||||
const attributes = {};
|
||||
if (isStructTreeNode(node)) {
|
||||
const { role } = node;
|
||||
const matches = role.match(HEADING_PATTERN);
|
||||
if (matches) {
|
||||
attributes.role = 'heading';
|
||||
attributes['aria-level'] = Number(matches[1]);
|
||||
}
|
||||
else if (isPdfRole(role)) {
|
||||
const htmlRole = PDF_ROLE_TO_HTML_ROLE[role];
|
||||
if (htmlRole) {
|
||||
attributes.role = htmlRole;
|
||||
}
|
||||
}
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
export function getBaseAttributes(node) {
|
||||
const attributes = {};
|
||||
if (isStructTreeNode(node)) {
|
||||
if (node.alt !== undefined) {
|
||||
attributes['aria-label'] = node.alt;
|
||||
}
|
||||
if (node.lang !== undefined) {
|
||||
attributes.lang = node.lang;
|
||||
}
|
||||
if (isStructTreeNodeWithOnlyContentChild(node)) {
|
||||
const [child] = node.children;
|
||||
if (child) {
|
||||
const childAttributes = getBaseAttributes(child);
|
||||
return Object.assign(Object.assign({}, attributes), childAttributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ('id' in node) {
|
||||
attributes['aria-owns'] = node.id;
|
||||
}
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
export function getAttributes(node) {
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
return Object.assign(Object.assign({}, getRoleAttributes(node)), getBaseAttributes(node));
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
viewBox="0 0 40 40">
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 158 B |
@@ -0,0 +1,313 @@
|
||||
/**
|
||||
* @fileoverview Rule to control usage of strict mode directives.
|
||||
* @author Brandon Mills
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets all of the Use Strict Directives in the Directive Prologue of a group of
|
||||
* statements.
|
||||
* @param {ASTNode[]} statements Statements in the program or function body.
|
||||
* @returns {ASTNode[]} All of the Use Strict Directives.
|
||||
*/
|
||||
function getUseStrictDirectives(statements) {
|
||||
const directives = [];
|
||||
|
||||
for (let i = 0; i < statements.length; i++) {
|
||||
const statement = statements[i];
|
||||
|
||||
if (
|
||||
statement.type === "ExpressionStatement" &&
|
||||
statement.expression.type === "Literal" &&
|
||||
statement.expression.value === "use strict"
|
||||
) {
|
||||
directives[i] = statement;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return directives;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given parameter is a simple parameter.
|
||||
* @param {ASTNode} node A pattern node to check.
|
||||
* @returns {boolean} `true` if the node is an Identifier node.
|
||||
*/
|
||||
function isSimpleParameter(node) {
|
||||
return node.type === "Identifier";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given parameter list is a simple parameter list.
|
||||
* @param {ASTNode[]} params A parameter list to check.
|
||||
* @returns {boolean} `true` if the every parameter is an Identifier node.
|
||||
*/
|
||||
function isSimpleParameterList(params) {
|
||||
return params.every(isSimpleParameter);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: ["safe"],
|
||||
|
||||
docs: {
|
||||
description: "Require or disallow strict mode directives",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/strict",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["never", "global", "function", "safe"],
|
||||
},
|
||||
],
|
||||
|
||||
fixable: "code",
|
||||
messages: {
|
||||
function: "Use the function form of 'use strict'.",
|
||||
global: "Use the global form of 'use strict'.",
|
||||
multiple: "Multiple 'use strict' directives.",
|
||||
never: "Strict mode is not permitted.",
|
||||
unnecessary: "Unnecessary 'use strict' directive.",
|
||||
module: "'use strict' is unnecessary inside of modules.",
|
||||
implied:
|
||||
"'use strict' is unnecessary when implied strict mode is enabled.",
|
||||
unnecessaryInClasses:
|
||||
"'use strict' is unnecessary inside of classes.",
|
||||
nonSimpleParameterList:
|
||||
"'use strict' directive inside a function with non-simple parameter list throws a syntax error since ES2016.",
|
||||
wrap: "Wrap {{name}} in a function with 'use strict' directive.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const ecmaFeatures = context.parserOptions.ecmaFeatures || {},
|
||||
scopes = [],
|
||||
classScopes = [];
|
||||
let [mode] = context.options;
|
||||
|
||||
if (ecmaFeatures.impliedStrict) {
|
||||
mode = "implied";
|
||||
} else if (mode === "safe") {
|
||||
mode =
|
||||
ecmaFeatures.globalReturn ||
|
||||
context.languageOptions.sourceType === "commonjs"
|
||||
? "global"
|
||||
: "function";
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a reported error should be fixed, depending on the error type.
|
||||
* @param {string} errorType The type of error
|
||||
* @returns {boolean} `true` if the reported error should be fixed
|
||||
*/
|
||||
function shouldFix(errorType) {
|
||||
return (
|
||||
errorType === "multiple" ||
|
||||
errorType === "unnecessary" ||
|
||||
errorType === "module" ||
|
||||
errorType === "implied" ||
|
||||
errorType === "unnecessaryInClasses"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a fixer function to remove a given 'use strict' directive.
|
||||
* @param {ASTNode} node The directive that should be removed
|
||||
* @returns {Function} A fixer function
|
||||
*/
|
||||
function getFixFunction(node) {
|
||||
return fixer => fixer.remove(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a slice of an array of nodes with a given message.
|
||||
* @param {ASTNode[]} nodes Nodes.
|
||||
* @param {string} start Index to start from.
|
||||
* @param {string} end Index to end before.
|
||||
* @param {string} messageId Message to display.
|
||||
* @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
|
||||
* @returns {void}
|
||||
*/
|
||||
function reportSlice(nodes, start, end, messageId, fix) {
|
||||
nodes.slice(start, end).forEach(node => {
|
||||
context.report({
|
||||
node,
|
||||
messageId,
|
||||
fix: fix ? getFixFunction(node) : null,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Report all nodes in an array with a given message.
|
||||
* @param {ASTNode[]} nodes Nodes.
|
||||
* @param {string} messageId Message id to display.
|
||||
* @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
|
||||
* @returns {void}
|
||||
*/
|
||||
function reportAll(nodes, messageId, fix) {
|
||||
reportSlice(nodes, 0, nodes.length, messageId, fix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report all nodes in an array, except the first, with a given message.
|
||||
* @param {ASTNode[]} nodes Nodes.
|
||||
* @param {string} messageId Message id to display.
|
||||
* @param {boolean} fix `true` if the directive should be fixed (i.e. removed)
|
||||
* @returns {void}
|
||||
*/
|
||||
function reportAllExceptFirst(nodes, messageId, fix) {
|
||||
reportSlice(nodes, 1, nodes.length, messageId, fix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Entering a function in 'function' mode pushes a new nested scope onto the
|
||||
* stack. The new scope is true if the nested function is strict mode code.
|
||||
* @param {ASTNode} node The function declaration or expression.
|
||||
* @param {ASTNode[]} useStrictDirectives The Use Strict Directives of the node.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterFunctionInFunctionMode(node, useStrictDirectives) {
|
||||
const isInClass = classScopes.length > 0,
|
||||
isParentGlobal =
|
||||
scopes.length === 0 && classScopes.length === 0,
|
||||
isParentStrict = scopes.length > 0 && scopes.at(-1),
|
||||
isStrict = useStrictDirectives.length > 0;
|
||||
|
||||
if (isStrict) {
|
||||
if (!isSimpleParameterList(node.params)) {
|
||||
context.report({
|
||||
node: useStrictDirectives[0],
|
||||
messageId: "nonSimpleParameterList",
|
||||
});
|
||||
} else if (isParentStrict) {
|
||||
context.report({
|
||||
node: useStrictDirectives[0],
|
||||
messageId: "unnecessary",
|
||||
fix: getFixFunction(useStrictDirectives[0]),
|
||||
});
|
||||
} else if (isInClass) {
|
||||
context.report({
|
||||
node: useStrictDirectives[0],
|
||||
messageId: "unnecessaryInClasses",
|
||||
fix: getFixFunction(useStrictDirectives[0]),
|
||||
});
|
||||
}
|
||||
|
||||
reportAllExceptFirst(useStrictDirectives, "multiple", true);
|
||||
} else if (isParentGlobal) {
|
||||
if (isSimpleParameterList(node.params)) {
|
||||
context.report({ node, messageId: "function" });
|
||||
} else {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrap",
|
||||
data: { name: astUtils.getFunctionNameWithKind(node) },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
scopes.push(isParentStrict || isStrict);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exiting a function in 'function' mode pops its scope off the stack.
|
||||
* @returns {void}
|
||||
*/
|
||||
function exitFunctionInFunctionMode() {
|
||||
scopes.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter a function and either:
|
||||
* - Push a new nested scope onto the stack (in 'function' mode).
|
||||
* - Report all the Use Strict Directives (in the other modes).
|
||||
* @param {ASTNode} node The function declaration or expression.
|
||||
* @returns {void}
|
||||
*/
|
||||
function enterFunction(node) {
|
||||
const isBlock = node.body.type === "BlockStatement",
|
||||
useStrictDirectives = isBlock
|
||||
? getUseStrictDirectives(node.body.body)
|
||||
: [];
|
||||
|
||||
if (mode === "function") {
|
||||
enterFunctionInFunctionMode(node, useStrictDirectives);
|
||||
} else if (useStrictDirectives.length > 0) {
|
||||
if (isSimpleParameterList(node.params)) {
|
||||
reportAll(useStrictDirectives, mode, shouldFix(mode));
|
||||
} else {
|
||||
context.report({
|
||||
node: useStrictDirectives[0],
|
||||
messageId: "nonSimpleParameterList",
|
||||
});
|
||||
reportAllExceptFirst(useStrictDirectives, "multiple", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rule = {
|
||||
Program(node) {
|
||||
const useStrictDirectives = getUseStrictDirectives(node.body);
|
||||
|
||||
if (node.sourceType === "module") {
|
||||
mode = "module";
|
||||
}
|
||||
|
||||
if (mode === "global") {
|
||||
if (
|
||||
node.body.length > 0 &&
|
||||
useStrictDirectives.length === 0
|
||||
) {
|
||||
context.report({ node, messageId: "global" });
|
||||
}
|
||||
reportAllExceptFirst(useStrictDirectives, "multiple", true);
|
||||
} else {
|
||||
reportAll(useStrictDirectives, mode, shouldFix(mode));
|
||||
}
|
||||
},
|
||||
FunctionDeclaration: enterFunction,
|
||||
FunctionExpression: enterFunction,
|
||||
ArrowFunctionExpression: enterFunction,
|
||||
};
|
||||
|
||||
if (mode === "function") {
|
||||
Object.assign(rule, {
|
||||
// Inside of class bodies are always strict mode.
|
||||
ClassBody() {
|
||||
classScopes.push(true);
|
||||
},
|
||||
"ClassBody:exit"() {
|
||||
classScopes.pop();
|
||||
},
|
||||
|
||||
"FunctionDeclaration:exit": exitFunctionInFunctionMode,
|
||||
"FunctionExpression:exit": exitFunctionInFunctionMode,
|
||||
"ArrowFunctionExpression:exit": exitFunctionInFunctionMode,
|
||||
});
|
||||
}
|
||||
|
||||
return rule;
|
||||
},
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const Hook = require("./Hook");
|
||||
const HookCodeFactory = require("./HookCodeFactory");
|
||||
|
||||
class SyncHookCodeFactory extends HookCodeFactory {
|
||||
content({ onError, onDone, rethrowIfPossible }) {
|
||||
return this.callTapsSeries({
|
||||
onError: (i, err) => onError(err),
|
||||
onDone,
|
||||
rethrowIfPossible
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const factory = new SyncHookCodeFactory();
|
||||
|
||||
const TAP_ASYNC = () => {
|
||||
throw new Error("tapAsync is not supported on a SyncHook");
|
||||
};
|
||||
|
||||
const TAP_PROMISE = () => {
|
||||
throw new Error("tapPromise is not supported on a SyncHook");
|
||||
};
|
||||
|
||||
const COMPILE = function(options) {
|
||||
factory.setup(this, options);
|
||||
return factory.create(options);
|
||||
};
|
||||
|
||||
function SyncHook(args = [], name = undefined) {
|
||||
const hook = new Hook(args, name);
|
||||
hook.constructor = SyncHook;
|
||||
hook.tapAsync = TAP_ASYNC;
|
||||
hook.tapPromise = TAP_PROMISE;
|
||||
hook.compile = COMPILE;
|
||||
return hook;
|
||||
}
|
||||
|
||||
SyncHook.prototype = null;
|
||||
|
||||
module.exports = SyncHook;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,80 @@
|
||||
# ModuleImporter
|
||||
|
||||
by [Nicholas C. Zakas](https://humanwhocodes.com)
|
||||
|
||||
If you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate).
|
||||
|
||||
## Description
|
||||
|
||||
A utility for seamlessly importing modules in Node.js regardless if they are CommonJS or ESM format. Under the hood, this uses `import()` and relies on Node.js's CommonJS compatibility to work correctly. This ensures that the correct locations and formats are used for CommonJS so you can call one method and not worry about any compatibility issues.
|
||||
|
||||
The problem with the default `import()` is that it always resolves relative to the file location in which it is called. If you want to resolve from a different location, you need to jump through a few hoops to achieve that. This package makes it easy to both resolve and import modules from any directory.
|
||||
|
||||
## Usage
|
||||
|
||||
### Node.js
|
||||
|
||||
Install using [npm][npm] or [yarn][yarn]:
|
||||
|
||||
```
|
||||
npm install @humanwhocodes/module-importer
|
||||
|
||||
# or
|
||||
|
||||
yarn add @humanwhocodes/module-importer
|
||||
```
|
||||
|
||||
Import into your Node.js project:
|
||||
|
||||
```js
|
||||
// CommonJS
|
||||
const { ModuleImporter } = require("@humanwhocodes/module-importer");
|
||||
|
||||
// ESM
|
||||
import { ModuleImporter } from "@humanwhocodes/module-importer";
|
||||
```
|
||||
|
||||
### Bun
|
||||
|
||||
Install using this command:
|
||||
|
||||
```
|
||||
bun add @humanwhocodes/module-importer
|
||||
```
|
||||
|
||||
Import into your Bun project:
|
||||
|
||||
```js
|
||||
import { ModuleImporter } from "@humanwhocodes/module-importer";
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
After importing, create a new instance of `ModuleImporter` to start emitting events:
|
||||
|
||||
```js
|
||||
// cwd can be omitted to use process.cwd()
|
||||
const importer = new ModuleImporter(cwd);
|
||||
|
||||
// you can resolve the location of any package
|
||||
const location = importer.resolve("./some-file.cjs");
|
||||
|
||||
// you can also import directly
|
||||
const module = importer.import("./some-file.cjs");
|
||||
```
|
||||
|
||||
For both `resolve()` and `import()`, you can pass in package names and filenames.
|
||||
|
||||
## Developer Setup
|
||||
|
||||
1. Fork the repository
|
||||
2. Clone your fork
|
||||
3. Run `npm install` to setup dependencies
|
||||
4. Run `npm test` to run tests
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
[npm]: https://npmjs.com/
|
||||
[yarn]: https://yarnpkg.com/
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"useLoaderData.js","sources":["../../src/useLoaderData.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseLoaderData,\n StrictOrFrom,\n UseLoaderDataResult,\n} from '@tanstack/router-core'\n\nexport interface UseLoaderDataBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n match: ResolveUseLoaderData<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n}\n\nexport type UseLoaderDataOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseLoaderDataBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseLoaderDataRoute<out TId> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseLoaderDataBaseOptions<\n TRouter,\n TId,\n true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseLoaderDataResult<TRouter, TId, true, TSelected>\n\nexport function useLoaderData<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts: UseLoaderDataOptions<\n TRouter,\n TFrom,\n TStrict,\n TSelected,\n TStructuralSharing\n >,\n): UseLoaderDataResult<TRouter, TFrom, TStrict, TSelected> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n structuralSharing: opts.structuralSharing,\n select: (s: any) => {\n return opts.select ? opts.select(s.loaderData) : s.loaderData\n },\n } as any) as UseLoaderDataResult<TRouter, TFrom, TStrict, TSelected>\n}\n"],"names":[],"mappings":";AAwDO,SAAS,cAOd,MAOyD;AACzD,SAAO,SAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,MAAW;AAClB,aAAO,KAAK,SAAS,KAAK,OAAO,EAAE,UAAU,IAAI,EAAE;AAAA,IAAA;AAAA,EACrD,CACM;AACV;"}
|
||||
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* @fileoverview Comma spacing - validates spacing before and after comma
|
||||
* @author Vignesh Anand aka vegetableman.
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
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: "comma-spacing",
|
||||
url: "https://eslint.style/rules/js/comma-spacing",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after commas",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/comma-spacing",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
before: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
after: {
|
||||
type: "boolean",
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
missing: "A space is required {{loc}} ','.",
|
||||
unexpected: "There should be no space {{loc}} ','.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const tokensAndComments = sourceCode.tokensAndComments;
|
||||
|
||||
const options = {
|
||||
before: context.options[0] ? context.options[0].before : false,
|
||||
after: context.options[0] ? context.options[0].after : true,
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// list of comma tokens to ignore for the check of leading whitespace
|
||||
const commaTokensToIgnore = [];
|
||||
|
||||
/**
|
||||
* Reports a spacing error with an appropriate message.
|
||||
* @param {ASTNode} node The binary expression node to report.
|
||||
* @param {string} loc Is the error "before" or "after" the comma?
|
||||
* @param {ASTNode} otherNode The node at the left or right of `node`
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function report(node, loc, otherNode) {
|
||||
context.report({
|
||||
node,
|
||||
fix(fixer) {
|
||||
if (options[loc]) {
|
||||
if (loc === "before") {
|
||||
return fixer.insertTextBefore(node, " ");
|
||||
}
|
||||
return fixer.insertTextAfter(node, " ");
|
||||
}
|
||||
let start, end;
|
||||
const newText = "";
|
||||
|
||||
if (loc === "before") {
|
||||
start = otherNode.range[1];
|
||||
end = node.range[0];
|
||||
} else {
|
||||
start = node.range[1];
|
||||
end = otherNode.range[0];
|
||||
}
|
||||
|
||||
return fixer.replaceTextRange([start, end], newText);
|
||||
},
|
||||
messageId: options[loc] ? "missing" : "unexpected",
|
||||
data: {
|
||||
loc,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds null elements of the given ArrayExpression or ArrayPattern node to the ignore list.
|
||||
* @param {ASTNode} node An ArrayExpression or ArrayPattern node.
|
||||
* @returns {void}
|
||||
*/
|
||||
function addNullElementsToIgnoreList(node) {
|
||||
let previousToken = sourceCode.getFirstToken(node);
|
||||
|
||||
node.elements.forEach(element => {
|
||||
let token;
|
||||
|
||||
if (element === null) {
|
||||
token = sourceCode.getTokenAfter(previousToken);
|
||||
|
||||
if (astUtils.isCommaToken(token)) {
|
||||
commaTokensToIgnore.push(token);
|
||||
}
|
||||
} else {
|
||||
token = sourceCode.getTokenAfter(element);
|
||||
}
|
||||
|
||||
previousToken = token;
|
||||
});
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
"Program:exit"() {
|
||||
tokensAndComments.forEach((token, i) => {
|
||||
if (!astUtils.isCommaToken(token)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const previousToken = tokensAndComments[i - 1];
|
||||
const nextToken = tokensAndComments[i + 1];
|
||||
|
||||
if (
|
||||
previousToken &&
|
||||
!astUtils.isCommaToken(previousToken) && // ignore spacing between two commas
|
||||
/*
|
||||
* `commaTokensToIgnore` are ending commas of `null` elements (array holes/elisions).
|
||||
* In addition to spacing between two commas, this can also ignore:
|
||||
*
|
||||
* - Spacing after `[` (controlled by array-bracket-spacing)
|
||||
* Example: [ , ]
|
||||
* ^
|
||||
* - Spacing after a comment (for backwards compatibility, this was possibly unintentional)
|
||||
* Example: [a, /* * / ,]
|
||||
* ^
|
||||
*/
|
||||
!commaTokensToIgnore.includes(token) &&
|
||||
astUtils.isTokenOnSameLine(previousToken, token) &&
|
||||
options.before !==
|
||||
sourceCode.isSpaceBetweenTokens(
|
||||
previousToken,
|
||||
token,
|
||||
)
|
||||
) {
|
||||
report(token, "before", previousToken);
|
||||
}
|
||||
|
||||
if (
|
||||
nextToken &&
|
||||
!astUtils.isCommaToken(nextToken) && // ignore spacing between two commas
|
||||
!astUtils.isClosingParenToken(nextToken) && // controlled by space-in-parens
|
||||
!astUtils.isClosingBracketToken(nextToken) && // controlled by array-bracket-spacing
|
||||
!astUtils.isClosingBraceToken(nextToken) && // controlled by object-curly-spacing
|
||||
!(!options.after && nextToken.type === "Line") && // special case, allow space before line comment
|
||||
astUtils.isTokenOnSameLine(token, nextToken) &&
|
||||
options.after !==
|
||||
sourceCode.isSpaceBetweenTokens(token, nextToken)
|
||||
) {
|
||||
report(token, "after", nextToken);
|
||||
}
|
||||
});
|
||||
},
|
||||
ArrayExpression: addNullElementsToIgnoreList,
|
||||
ArrayPattern: addNullElementsToIgnoreList,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"48":0.00859,"115":0.05581,"128":0.06869,"132":0.00429,"133":0.01288,"134":0.02147,"135":0.33485,"136":1.76442,"137":0.00859,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 116 117 118 119 120 121 122 123 124 125 126 127 129 130 131 138 139 140 3.5 3.6"},D:{"5":0.02147,"41":0.00429,"47":0.00429,"49":0.00429,"51":0.00429,"53":0.00429,"54":0.00429,"55":0.00429,"60":0.00429,"65":0.00429,"67":0.00429,"70":0.00429,"79":0.00859,"80":0.00429,"85":0.00429,"87":0.03005,"90":0.00859,"91":0.00859,"98":0.02576,"99":0.00859,"103":0.17601,"105":0.00429,"106":0.00429,"108":0.00429,"109":0.23182,"110":0.00859,"112":0.00429,"113":0.02576,"114":0.00429,"115":0.00429,"116":0.04293,"119":0.00859,"122":0.04722,"123":0.02576,"124":0.32627,"125":0.01288,"126":0.02147,"127":0.03434,"128":0.0644,"129":0.00429,"130":0.01717,"131":0.39066,"132":0.3048,"133":5.83419,"134":10.01128,"135":0.00429,"136":0.00429,_:"4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 42 43 44 45 46 48 50 52 56 57 58 59 61 62 63 64 66 68 69 71 72 73 74 75 76 77 78 81 83 84 86 88 89 92 93 94 95 96 97 100 101 102 104 107 111 117 118 120 121 137 138"},F:{"79":0.00429,"86":0.00429,"87":0.00859,"95":0.00429,"114":0.01288,"115":0.0601,"116":0.16743,"117":0.674,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84 85 88 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"85":0.00429,"87":0.00859,"98":0.00429,"109":0.00429,"122":0.00429,"127":0.00429,"128":0.00429,"131":0.02576,"132":0.02576,"133":0.6139,"134":2.00483,_:"12 13 14 15 16 17 18 79 80 81 83 84 86 88 89 90 91 92 93 94 95 96 97 99 100 101 102 103 104 105 106 107 108 110 111 112 113 114 115 116 117 118 119 120 121 123 124 125 126 129 130"},E:{"12":0.00429,"14":0.00859,_:"0 4 5 6 7 8 9 10 11 13 15 3.1 3.2 5.1 6.1 7.1 9.1 10.1 11.1 12.1","13.1":0.03005,"14.1":0.03005,"15.1":0.03864,"15.2-15.3":0.01288,"15.4":0.08157,"15.5":0.04722,"15.6":0.56668,"16.0":0.03434,"16.1":0.20606,"16.2":0.07727,"16.3":0.25758,"16.4":0.0644,"16.5":0.21894,"16.6":1.42957,"17.0":0.10733,"17.1":0.99168,"17.2":0.37778,"17.3":0.21894,"17.4":0.24041,"17.5":1.06037,"17.6":2.83338,"18.0":0.18889,"18.1":0.55809,"18.2":0.52375,"18.3":7.18219,"18.4":0.10733},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00704,"5.0-5.1":0,"6.0-6.1":0.02111,"7.0-7.1":0.01408,"8.1-8.4":0,"9.0-9.2":0.01056,"9.3":0.04927,"10.0-10.2":0.00352,"10.3":0.08094,"11.0-11.2":0.37301,"11.3-11.4":0.02463,"12.0-12.1":0.01408,"12.2-12.5":0.34837,"13.0-13.1":0.00704,"13.2":0.01056,"13.3":0.01408,"13.4-13.7":0.04927,"14.0-14.4":0.12316,"14.5-14.8":0.1478,"15.0-15.1":0.08094,"15.2-15.3":0.08094,"15.4":0.09853,"15.5":0.11261,"15.6-15.8":1.38646,"16.0":0.19706,"16.1":0.40468,"16.2":0.21114,"16.3":0.36597,"16.4":0.08094,"16.5":0.15131,"16.6-16.7":1.64334,"17.0":0.09853,"17.1":0.17595,"17.2":0.13372,"17.3":0.1865,"17.4":0.37301,"17.5":0.83047,"17.6-17.7":2.41047,"18.0":0.67564,"18.1":2.20989,"18.2":0.98882,"18.3":20.66671,"18.4":0.30615},P:{"4":0.01057,"22":0.09513,"26":0.05285,"27":1.9131,_:"20 21 23 24 25 5.0-5.4 6.2-6.4 7.2-7.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0"},I:{"0":0.01139,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0,"4.4":0,"4.4.3-4.4.4":0.00001},K:{"0":0.0799,_:"10 11 12 11.1 11.5 12.1"},A:{"11":0.00429,_:"6 7 8 9 10 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.37666},Q:{_:"14.9"},O:{"0":0.02283},H:{"0":0},L:{"0":19.36497}};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"mC","8":"K D E","260":"F A B"},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:{"1":"0 2 3 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 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","132":"LC qC rC","260":"1 J PB K D E F A B C L M G N O P QB"},D:{"1":"0 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","132":"J PB","260":"1 2 3 4 5 6 K D E F A B C L M G N O P QB"},E:{"1":"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","132":"J sC SC","260":"PB K 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","132":"F B 4C 5C 6C 7C","260":"C 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","132":"SC","260":"9C lC AD BD"},H:{"132":"WD"},I:{"1":"I bD cD","132":"XD","260":"LC J YD ZD aD lC"},J:{"260":"D A"},K:{"1":"H","132":"A","260":"B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"260":"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:"HTML5 semantic elements",D:true};
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "util-deprecate",
|
||||
"version": "1.0.2",
|
||||
"description": "The Node.js `util.deprecate()` function with browser support",
|
||||
"main": "node.js",
|
||||
"browser": "browser.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/util-deprecate.git"
|
||||
},
|
||||
"keywords": [
|
||||
"util",
|
||||
"deprecate",
|
||||
"browserify",
|
||||
"browser",
|
||||
"node"
|
||||
],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/util-deprecate/issues"
|
||||
},
|
||||
"homepage": "https://github.com/TooTallNate/util-deprecate"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_assertThisInitialized","require","_possibleConstructorReturn","self","value","TypeError","assertThisInitialized"],"sources":["../../src/helpers/possibleConstructorReturn.ts"],"sourcesContent":["/* @minVersion 7.0.0-beta.0 */\n\nimport assertThisInitialized from \"./assertThisInitialized.ts\";\n\nexport default function _possibleConstructorReturn(\n self: object | undefined,\n value: unknown,\n) {\n if (value && (typeof value === \"object\" || typeof value === \"function\")) {\n return value;\n } else if (value !== void 0) {\n throw new TypeError(\n \"Derived constructors may only return object or undefined\",\n );\n }\n\n return assertThisInitialized(self);\n}\n"],"mappings":";;;;;;AAEA,IAAAA,sBAAA,GAAAC,OAAA;AAEe,SAASC,0BAA0BA,CAChDC,IAAwB,EACxBC,KAAc,EACd;EACA,IAAIA,KAAK,KAAK,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,CAAC,EAAE;IACvE,OAAOA,KAAK;EACd,CAAC,MAAM,IAAIA,KAAK,KAAK,KAAK,CAAC,EAAE;IAC3B,MAAM,IAAIC,SAAS,CACjB,0DACF,CAAC;EACH;EAEA,OAAO,IAAAC,8BAAqB,EAACH,IAAI,CAAC;AACpC","ignoreList":[]}
|
||||
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
* @fileoverview Enforce newlines between operands of ternary expressions
|
||||
* @author Kai Cataldo
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
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: "multiline-ternary",
|
||||
url: "https://eslint.style/rules/js/multiline-ternary",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce newlines between operands of ternary expressions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/multiline-ternary",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["always", "always-multiline", "never"],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
expectedTestCons:
|
||||
"Expected newline between test and consequent of ternary expression.",
|
||||
expectedConsAlt:
|
||||
"Expected newline between consequent and alternate of ternary expression.",
|
||||
unexpectedTestCons:
|
||||
"Unexpected newline between test and consequent of ternary expression.",
|
||||
unexpectedConsAlt:
|
||||
"Unexpected newline between consequent and alternate of ternary expression.",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0];
|
||||
const multiline = option !== "never";
|
||||
const allowSingleLine = option === "always-multiline";
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
return {
|
||||
ConditionalExpression(node) {
|
||||
const questionToken = sourceCode.getTokenAfter(
|
||||
node.test,
|
||||
astUtils.isNotClosingParenToken,
|
||||
);
|
||||
const colonToken = sourceCode.getTokenAfter(
|
||||
node.consequent,
|
||||
astUtils.isNotClosingParenToken,
|
||||
);
|
||||
|
||||
const firstTokenOfTest = sourceCode.getFirstToken(node);
|
||||
const lastTokenOfTest =
|
||||
sourceCode.getTokenBefore(questionToken);
|
||||
const firstTokenOfConsequent =
|
||||
sourceCode.getTokenAfter(questionToken);
|
||||
const lastTokenOfConsequent =
|
||||
sourceCode.getTokenBefore(colonToken);
|
||||
const firstTokenOfAlternate =
|
||||
sourceCode.getTokenAfter(colonToken);
|
||||
|
||||
const areTestAndConsequentOnSameLine =
|
||||
astUtils.isTokenOnSameLine(
|
||||
lastTokenOfTest,
|
||||
firstTokenOfConsequent,
|
||||
);
|
||||
const areConsequentAndAlternateOnSameLine =
|
||||
astUtils.isTokenOnSameLine(
|
||||
lastTokenOfConsequent,
|
||||
firstTokenOfAlternate,
|
||||
);
|
||||
|
||||
const hasComments = !!sourceCode.getCommentsInside(node).length;
|
||||
|
||||
if (!multiline) {
|
||||
if (!areTestAndConsequentOnSameLine) {
|
||||
context.report({
|
||||
node: node.test,
|
||||
loc: {
|
||||
start: firstTokenOfTest.loc.start,
|
||||
end: lastTokenOfTest.loc.end,
|
||||
},
|
||||
messageId: "unexpectedTestCons",
|
||||
fix(fixer) {
|
||||
if (hasComments) {
|
||||
return null;
|
||||
}
|
||||
const fixers = [];
|
||||
const areTestAndQuestionOnSameLine =
|
||||
astUtils.isTokenOnSameLine(
|
||||
lastTokenOfTest,
|
||||
questionToken,
|
||||
);
|
||||
const areQuestionAndConsOnSameLine =
|
||||
astUtils.isTokenOnSameLine(
|
||||
questionToken,
|
||||
firstTokenOfConsequent,
|
||||
);
|
||||
|
||||
if (!areTestAndQuestionOnSameLine) {
|
||||
fixers.push(
|
||||
fixer.removeRange([
|
||||
lastTokenOfTest.range[1],
|
||||
questionToken.range[0],
|
||||
]),
|
||||
);
|
||||
}
|
||||
if (!areQuestionAndConsOnSameLine) {
|
||||
fixers.push(
|
||||
fixer.removeRange([
|
||||
questionToken.range[1],
|
||||
firstTokenOfConsequent.range[0],
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
return fixers;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (!areConsequentAndAlternateOnSameLine) {
|
||||
context.report({
|
||||
node: node.consequent,
|
||||
loc: {
|
||||
start: firstTokenOfConsequent.loc.start,
|
||||
end: lastTokenOfConsequent.loc.end,
|
||||
},
|
||||
messageId: "unexpectedConsAlt",
|
||||
fix(fixer) {
|
||||
if (hasComments) {
|
||||
return null;
|
||||
}
|
||||
const fixers = [];
|
||||
const areConsAndColonOnSameLine =
|
||||
astUtils.isTokenOnSameLine(
|
||||
lastTokenOfConsequent,
|
||||
colonToken,
|
||||
);
|
||||
const areColonAndAltOnSameLine =
|
||||
astUtils.isTokenOnSameLine(
|
||||
colonToken,
|
||||
firstTokenOfAlternate,
|
||||
);
|
||||
|
||||
if (!areConsAndColonOnSameLine) {
|
||||
fixers.push(
|
||||
fixer.removeRange([
|
||||
lastTokenOfConsequent.range[1],
|
||||
colonToken.range[0],
|
||||
]),
|
||||
);
|
||||
}
|
||||
if (!areColonAndAltOnSameLine) {
|
||||
fixers.push(
|
||||
fixer.removeRange([
|
||||
colonToken.range[1],
|
||||
firstTokenOfAlternate.range[0],
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
return fixers;
|
||||
},
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
allowSingleLine &&
|
||||
node.loc.start.line === node.loc.end.line
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (areTestAndConsequentOnSameLine) {
|
||||
context.report({
|
||||
node: node.test,
|
||||
loc: {
|
||||
start: firstTokenOfTest.loc.start,
|
||||
end: lastTokenOfTest.loc.end,
|
||||
},
|
||||
messageId: "expectedTestCons",
|
||||
fix: fixer =>
|
||||
hasComments
|
||||
? null
|
||||
: fixer.replaceTextRange(
|
||||
[
|
||||
lastTokenOfTest.range[1],
|
||||
questionToken.range[0],
|
||||
],
|
||||
"\n",
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
if (areConsequentAndAlternateOnSameLine) {
|
||||
context.report({
|
||||
node: node.consequent,
|
||||
loc: {
|
||||
start: firstTokenOfConsequent.loc.start,
|
||||
end: lastTokenOfConsequent.loc.end,
|
||||
},
|
||||
messageId: "expectedConsAlt",
|
||||
fix: fixer =>
|
||||
hasComments
|
||||
? null
|
||||
: fixer.replaceTextRange(
|
||||
[
|
||||
lastTokenOfConsequent.range[1],
|
||||
colonToken.range[0],
|
||||
],
|
||||
"\n",
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D mC","132":"E","260":"F A B"},B:{"1":"0 9 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","260":"C L G N O P","772":"M"},C:{"1":"0 1 2 3 4 5 6 7 8 9 nC LC 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 qC rC"},D:{"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 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"},E:{"1":"J PB K D E F A B C L M G sC SC 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"},F:{"1":"0 1 2 3 4 5 6 7 8 F 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"},G:{"1":"E SC 9C lC 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"},H:{"1":"WD"},I:{"1":"LC J I XD YD ZD aD lC bD cD"},J:{"1":"D A"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"260":"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:6,C:"Data URIs",D:true};
|
||||
@@ -0,0 +1,3 @@
|
||||
let urlAlphabet =
|
||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
||||
export { urlAlphabet }
|
||||
@@ -0,0 +1 @@
|
||||
// eslint-disable-next-line unicorn/no-empty-file
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,412 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const stateIndexKey = "__TSR_index";
|
||||
const popStateEvent = "popstate";
|
||||
const beforeUnloadEvent = "beforeunload";
|
||||
function createHistory(opts) {
|
||||
let location = opts.getLocation();
|
||||
const subscribers = /* @__PURE__ */ new Set();
|
||||
const notify = (action) => {
|
||||
location = opts.getLocation();
|
||||
subscribers.forEach((subscriber) => subscriber({ location, action }));
|
||||
};
|
||||
const handleIndexChange = (action) => {
|
||||
if (opts.notifyOnIndexChange ?? true) notify(action);
|
||||
else location = opts.getLocation();
|
||||
};
|
||||
const tryNavigation = async ({
|
||||
task,
|
||||
navigateOpts,
|
||||
...actionInfo
|
||||
}) => {
|
||||
var _a, _b;
|
||||
const ignoreBlocker = (navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false;
|
||||
if (ignoreBlocker) {
|
||||
task();
|
||||
return;
|
||||
}
|
||||
const blockers = ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
|
||||
const isPushOrReplace = actionInfo.type === "PUSH" || actionInfo.type === "REPLACE";
|
||||
if (typeof document !== "undefined" && blockers.length && isPushOrReplace) {
|
||||
for (const blocker of blockers) {
|
||||
const nextLocation = parseHref(actionInfo.path, actionInfo.state);
|
||||
const isBlocked = await blocker.blockerFn({
|
||||
currentLocation: location,
|
||||
nextLocation,
|
||||
action: actionInfo.type
|
||||
});
|
||||
if (isBlocked) {
|
||||
(_b = opts.onBlocked) == null ? void 0 : _b.call(opts);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
task();
|
||||
};
|
||||
return {
|
||||
get location() {
|
||||
return location;
|
||||
},
|
||||
get length() {
|
||||
return opts.getLength();
|
||||
},
|
||||
subscribers,
|
||||
subscribe: (cb) => {
|
||||
subscribers.add(cb);
|
||||
return () => {
|
||||
subscribers.delete(cb);
|
||||
};
|
||||
},
|
||||
push: (path, state, navigateOpts) => {
|
||||
const currentIndex = location.state[stateIndexKey];
|
||||
state = assignKeyAndIndex(currentIndex + 1, state);
|
||||
tryNavigation({
|
||||
task: () => {
|
||||
opts.pushState(path, state);
|
||||
notify({ type: "PUSH" });
|
||||
},
|
||||
navigateOpts,
|
||||
type: "PUSH",
|
||||
path,
|
||||
state
|
||||
});
|
||||
},
|
||||
replace: (path, state, navigateOpts) => {
|
||||
const currentIndex = location.state[stateIndexKey];
|
||||
state = assignKeyAndIndex(currentIndex, state);
|
||||
tryNavigation({
|
||||
task: () => {
|
||||
opts.replaceState(path, state);
|
||||
notify({ type: "REPLACE" });
|
||||
},
|
||||
navigateOpts,
|
||||
type: "REPLACE",
|
||||
path,
|
||||
state
|
||||
});
|
||||
},
|
||||
go: (index, navigateOpts) => {
|
||||
tryNavigation({
|
||||
task: () => {
|
||||
opts.go(index);
|
||||
handleIndexChange({ type: "GO", index });
|
||||
},
|
||||
navigateOpts,
|
||||
type: "GO"
|
||||
});
|
||||
},
|
||||
back: (navigateOpts) => {
|
||||
tryNavigation({
|
||||
task: () => {
|
||||
opts.back((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
|
||||
handleIndexChange({ type: "BACK" });
|
||||
},
|
||||
navigateOpts,
|
||||
type: "BACK"
|
||||
});
|
||||
},
|
||||
forward: (navigateOpts) => {
|
||||
tryNavigation({
|
||||
task: () => {
|
||||
opts.forward((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
|
||||
handleIndexChange({ type: "FORWARD" });
|
||||
},
|
||||
navigateOpts,
|
||||
type: "FORWARD"
|
||||
});
|
||||
},
|
||||
canGoBack: () => location.state[stateIndexKey] !== 0,
|
||||
createHref: (str) => opts.createHref(str),
|
||||
block: (blocker) => {
|
||||
var _a;
|
||||
if (!opts.setBlockers) return () => {
|
||||
};
|
||||
const blockers = ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
|
||||
opts.setBlockers([...blockers, blocker]);
|
||||
return () => {
|
||||
var _a2, _b;
|
||||
const blockers2 = ((_a2 = opts.getBlockers) == null ? void 0 : _a2.call(opts)) ?? [];
|
||||
(_b = opts.setBlockers) == null ? void 0 : _b.call(opts, blockers2.filter((b) => b !== blocker));
|
||||
};
|
||||
},
|
||||
flush: () => {
|
||||
var _a;
|
||||
return (_a = opts.flush) == null ? void 0 : _a.call(opts);
|
||||
},
|
||||
destroy: () => {
|
||||
var _a;
|
||||
return (_a = opts.destroy) == null ? void 0 : _a.call(opts);
|
||||
},
|
||||
notify
|
||||
};
|
||||
}
|
||||
function assignKeyAndIndex(index, state) {
|
||||
if (!state) {
|
||||
state = {};
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
key: createRandomKey(),
|
||||
[stateIndexKey]: index
|
||||
};
|
||||
}
|
||||
function createBrowserHistory(opts) {
|
||||
var _a;
|
||||
const win = (opts == null ? void 0 : opts.window) ?? (typeof document !== "undefined" ? window : void 0);
|
||||
const originalPushState = win.history.pushState;
|
||||
const originalReplaceState = win.history.replaceState;
|
||||
let blockers = [];
|
||||
const _getBlockers = () => blockers;
|
||||
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
||||
const createHref = (opts == null ? void 0 : opts.createHref) ?? ((path) => path);
|
||||
const parseLocation = (opts == null ? void 0 : opts.parseLocation) ?? (() => parseHref(
|
||||
`${win.location.pathname}${win.location.search}${win.location.hash}`,
|
||||
win.history.state
|
||||
));
|
||||
if (!((_a = win.history.state) == null ? void 0 : _a.key)) {
|
||||
win.history.replaceState(
|
||||
{
|
||||
[stateIndexKey]: 0,
|
||||
key: createRandomKey()
|
||||
},
|
||||
""
|
||||
);
|
||||
}
|
||||
let currentLocation = parseLocation();
|
||||
let rollbackLocation;
|
||||
let nextPopIsGo = false;
|
||||
let ignoreNextPop = false;
|
||||
let skipBlockerNextPop = false;
|
||||
let ignoreNextBeforeUnload = false;
|
||||
const getLocation = () => currentLocation;
|
||||
let next;
|
||||
let scheduled;
|
||||
const flush = () => {
|
||||
if (!next) {
|
||||
return;
|
||||
}
|
||||
history._ignoreSubscribers = true;
|
||||
(next.isPush ? win.history.pushState : win.history.replaceState)(
|
||||
next.state,
|
||||
"",
|
||||
next.href
|
||||
);
|
||||
history._ignoreSubscribers = false;
|
||||
next = void 0;
|
||||
scheduled = void 0;
|
||||
rollbackLocation = void 0;
|
||||
};
|
||||
const queueHistoryAction = (type, destHref, state) => {
|
||||
const href = createHref(destHref);
|
||||
if (!scheduled) {
|
||||
rollbackLocation = currentLocation;
|
||||
}
|
||||
currentLocation = parseHref(destHref, state);
|
||||
next = {
|
||||
href,
|
||||
state,
|
||||
isPush: (next == null ? void 0 : next.isPush) || type === "push"
|
||||
};
|
||||
if (!scheduled) {
|
||||
scheduled = Promise.resolve().then(() => flush());
|
||||
}
|
||||
};
|
||||
const onPushPop = (type) => {
|
||||
currentLocation = parseLocation();
|
||||
history.notify({ type });
|
||||
};
|
||||
const onPushPopEvent = async () => {
|
||||
if (ignoreNextPop) {
|
||||
ignoreNextPop = false;
|
||||
return;
|
||||
}
|
||||
const nextLocation = parseLocation();
|
||||
const delta = nextLocation.state[stateIndexKey] - currentLocation.state[stateIndexKey];
|
||||
const isForward = delta === 1;
|
||||
const isBack = delta === -1;
|
||||
const isGo = !isForward && !isBack || nextPopIsGo;
|
||||
nextPopIsGo = false;
|
||||
const action = isGo ? "GO" : isBack ? "BACK" : "FORWARD";
|
||||
const notify = isGo ? {
|
||||
type: "GO",
|
||||
index: delta
|
||||
} : {
|
||||
type: isBack ? "BACK" : "FORWARD"
|
||||
};
|
||||
if (skipBlockerNextPop) {
|
||||
skipBlockerNextPop = false;
|
||||
} else {
|
||||
const blockers2 = _getBlockers();
|
||||
if (typeof document !== "undefined" && blockers2.length) {
|
||||
for (const blocker of blockers2) {
|
||||
const isBlocked = await blocker.blockerFn({
|
||||
currentLocation,
|
||||
nextLocation,
|
||||
action
|
||||
});
|
||||
if (isBlocked) {
|
||||
ignoreNextPop = true;
|
||||
win.history.go(1);
|
||||
history.notify(notify);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
currentLocation = parseLocation();
|
||||
history.notify(notify);
|
||||
};
|
||||
const onBeforeUnload = (e) => {
|
||||
if (ignoreNextBeforeUnload) {
|
||||
ignoreNextBeforeUnload = false;
|
||||
return;
|
||||
}
|
||||
let shouldBlock = false;
|
||||
const blockers2 = _getBlockers();
|
||||
if (typeof document !== "undefined" && blockers2.length) {
|
||||
for (const blocker of blockers2) {
|
||||
const shouldHaveBeforeUnload = blocker.enableBeforeUnload ?? true;
|
||||
if (shouldHaveBeforeUnload === true) {
|
||||
shouldBlock = true;
|
||||
break;
|
||||
}
|
||||
if (typeof shouldHaveBeforeUnload === "function" && shouldHaveBeforeUnload() === true) {
|
||||
shouldBlock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldBlock) {
|
||||
e.preventDefault();
|
||||
return e.returnValue = "";
|
||||
}
|
||||
return;
|
||||
};
|
||||
const history = createHistory({
|
||||
getLocation,
|
||||
getLength: () => win.history.length,
|
||||
pushState: (href, state) => queueHistoryAction("push", href, state),
|
||||
replaceState: (href, state) => queueHistoryAction("replace", href, state),
|
||||
back: (ignoreBlocker) => {
|
||||
if (ignoreBlocker) skipBlockerNextPop = true;
|
||||
ignoreNextBeforeUnload = true;
|
||||
return win.history.back();
|
||||
},
|
||||
forward: (ignoreBlocker) => {
|
||||
if (ignoreBlocker) skipBlockerNextPop = true;
|
||||
ignoreNextBeforeUnload = true;
|
||||
win.history.forward();
|
||||
},
|
||||
go: (n) => {
|
||||
nextPopIsGo = true;
|
||||
win.history.go(n);
|
||||
},
|
||||
createHref: (href) => createHref(href),
|
||||
flush,
|
||||
destroy: () => {
|
||||
win.history.pushState = originalPushState;
|
||||
win.history.replaceState = originalReplaceState;
|
||||
win.removeEventListener(beforeUnloadEvent, onBeforeUnload, {
|
||||
capture: true
|
||||
});
|
||||
win.removeEventListener(popStateEvent, onPushPopEvent);
|
||||
},
|
||||
onBlocked: () => {
|
||||
if (rollbackLocation && currentLocation !== rollbackLocation) {
|
||||
currentLocation = rollbackLocation;
|
||||
}
|
||||
},
|
||||
getBlockers: _getBlockers,
|
||||
setBlockers: _setBlockers,
|
||||
notifyOnIndexChange: false
|
||||
});
|
||||
win.addEventListener(beforeUnloadEvent, onBeforeUnload, { capture: true });
|
||||
win.addEventListener(popStateEvent, onPushPopEvent);
|
||||
win.history.pushState = function(...args) {
|
||||
const res = originalPushState.apply(win.history, args);
|
||||
if (!history._ignoreSubscribers) onPushPop("PUSH");
|
||||
return res;
|
||||
};
|
||||
win.history.replaceState = function(...args) {
|
||||
const res = originalReplaceState.apply(win.history, args);
|
||||
if (!history._ignoreSubscribers) onPushPop("REPLACE");
|
||||
return res;
|
||||
};
|
||||
return history;
|
||||
}
|
||||
function createHashHistory(opts) {
|
||||
const win = (opts == null ? void 0 : opts.window) ?? (typeof document !== "undefined" ? window : void 0);
|
||||
return createBrowserHistory({
|
||||
window: win,
|
||||
parseLocation: () => {
|
||||
const hashSplit = win.location.hash.split("#").slice(1);
|
||||
const pathPart = hashSplit[0] ?? "/";
|
||||
const searchPart = win.location.search;
|
||||
const hashEntries = hashSplit.slice(1);
|
||||
const hashPart = hashEntries.length === 0 ? "" : `#${hashEntries.join("#")}`;
|
||||
const hashHref = `${pathPart}${searchPart}${hashPart}`;
|
||||
return parseHref(hashHref, win.history.state);
|
||||
},
|
||||
createHref: (href) => `${win.location.pathname}${win.location.search}#${href}`
|
||||
});
|
||||
}
|
||||
function createMemoryHistory(opts = {
|
||||
initialEntries: ["/"]
|
||||
}) {
|
||||
const entries = opts.initialEntries;
|
||||
let index = opts.initialIndex ? Math.min(Math.max(opts.initialIndex, 0), entries.length - 1) : entries.length - 1;
|
||||
const states = entries.map(
|
||||
(_entry, index2) => assignKeyAndIndex(index2, void 0)
|
||||
);
|
||||
const getLocation = () => parseHref(entries[index], states[index]);
|
||||
return createHistory({
|
||||
getLocation,
|
||||
getLength: () => entries.length,
|
||||
pushState: (path, state) => {
|
||||
if (index < entries.length - 1) {
|
||||
entries.splice(index + 1);
|
||||
states.splice(index + 1);
|
||||
}
|
||||
states.push(state);
|
||||
entries.push(path);
|
||||
index = Math.max(entries.length - 1, 0);
|
||||
},
|
||||
replaceState: (path, state) => {
|
||||
states[index] = state;
|
||||
entries[index] = path;
|
||||
},
|
||||
back: () => {
|
||||
index = Math.max(index - 1, 0);
|
||||
},
|
||||
forward: () => {
|
||||
index = Math.min(index + 1, entries.length - 1);
|
||||
},
|
||||
go: (n) => {
|
||||
index = Math.min(Math.max(index + n, 0), entries.length - 1);
|
||||
},
|
||||
createHref: (path) => path
|
||||
});
|
||||
}
|
||||
function parseHref(href, state) {
|
||||
const hashIndex = href.indexOf("#");
|
||||
const searchIndex = href.indexOf("?");
|
||||
return {
|
||||
href,
|
||||
pathname: href.substring(
|
||||
0,
|
||||
hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : href.length
|
||||
),
|
||||
hash: hashIndex > -1 ? href.substring(hashIndex) : "",
|
||||
search: searchIndex > -1 ? href.slice(searchIndex, hashIndex === -1 ? void 0 : hashIndex) : "",
|
||||
state: state || { [stateIndexKey]: 0, key: createRandomKey() }
|
||||
};
|
||||
}
|
||||
function createRandomKey() {
|
||||
return (Math.random() + 1).toString(36).substring(7);
|
||||
}
|
||||
exports.createBrowserHistory = createBrowserHistory;
|
||||
exports.createHashHistory = createHashHistory;
|
||||
exports.createHistory = createHistory;
|
||||
exports.createMemoryHistory = createMemoryHistory;
|
||||
exports.parseHref = parseHref;
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
Reference in New Issue
Block a user