update
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
export function dequal(foo, bar) {
|
||||
var ctor, len;
|
||||
if (foo === bar) return true;
|
||||
|
||||
if (foo && bar && (ctor=foo.constructor) === bar.constructor) {
|
||||
if (ctor === Date) return foo.getTime() === bar.getTime();
|
||||
if (ctor === RegExp) return foo.toString() === bar.toString();
|
||||
|
||||
if (ctor === Array) {
|
||||
if ((len=foo.length) === bar.length) {
|
||||
while (len-- && dequal(foo[len], bar[len]));
|
||||
}
|
||||
return len === -1;
|
||||
}
|
||||
|
||||
if (!ctor || typeof foo === 'object') {
|
||||
len = 0;
|
||||
for (ctor in foo) {
|
||||
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
||||
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
||||
}
|
||||
return Object.keys(bar).length === len;
|
||||
}
|
||||
}
|
||||
|
||||
return foo !== foo && bar !== bar;
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
// Generated by LiveScript 1.6.0
|
||||
(function(){
|
||||
var identifierRegex, tokenRegex;
|
||||
identifierRegex = /[\$\w]+/;
|
||||
function peek(tokens){
|
||||
var token;
|
||||
token = tokens[0];
|
||||
if (token == null) {
|
||||
throw new Error('Unexpected end of input.');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
function consumeIdent(tokens){
|
||||
var token;
|
||||
token = peek(tokens);
|
||||
if (!identifierRegex.test(token)) {
|
||||
throw new Error("Expected text, got '" + token + "' instead.");
|
||||
}
|
||||
return tokens.shift();
|
||||
}
|
||||
function consumeOp(tokens, op){
|
||||
var token;
|
||||
token = peek(tokens);
|
||||
if (token !== op) {
|
||||
throw new Error("Expected '" + op + "', got '" + token + "' instead.");
|
||||
}
|
||||
return tokens.shift();
|
||||
}
|
||||
function maybeConsumeOp(tokens, op){
|
||||
var token;
|
||||
token = tokens[0];
|
||||
if (token === op) {
|
||||
return tokens.shift();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function consumeArray(tokens){
|
||||
var types;
|
||||
consumeOp(tokens, '[');
|
||||
if (peek(tokens) === ']') {
|
||||
throw new Error("Must specify type of Array - eg. [Type], got [] instead.");
|
||||
}
|
||||
types = consumeTypes(tokens);
|
||||
consumeOp(tokens, ']');
|
||||
return {
|
||||
structure: 'array',
|
||||
of: types
|
||||
};
|
||||
}
|
||||
function consumeTuple(tokens){
|
||||
var components;
|
||||
components = [];
|
||||
consumeOp(tokens, '(');
|
||||
if (peek(tokens) === ')') {
|
||||
throw new Error("Tuple must be of at least length 1 - eg. (Type), got () instead.");
|
||||
}
|
||||
for (;;) {
|
||||
components.push(consumeTypes(tokens));
|
||||
maybeConsumeOp(tokens, ',');
|
||||
if (')' === peek(tokens)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
consumeOp(tokens, ')');
|
||||
return {
|
||||
structure: 'tuple',
|
||||
of: components
|
||||
};
|
||||
}
|
||||
function consumeFields(tokens){
|
||||
var fields, subset, ref$, key, types;
|
||||
fields = {};
|
||||
consumeOp(tokens, '{');
|
||||
subset = false;
|
||||
for (;;) {
|
||||
if (maybeConsumeOp(tokens, '...')) {
|
||||
subset = true;
|
||||
break;
|
||||
}
|
||||
ref$ = consumeField(tokens), key = ref$[0], types = ref$[1];
|
||||
fields[key] = types;
|
||||
maybeConsumeOp(tokens, ',');
|
||||
if ('}' === peek(tokens)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
consumeOp(tokens, '}');
|
||||
return {
|
||||
structure: 'fields',
|
||||
of: fields,
|
||||
subset: subset
|
||||
};
|
||||
}
|
||||
function consumeField(tokens){
|
||||
var key, types;
|
||||
key = consumeIdent(tokens);
|
||||
consumeOp(tokens, ':');
|
||||
types = consumeTypes(tokens);
|
||||
return [key, types];
|
||||
}
|
||||
function maybeConsumeStructure(tokens){
|
||||
switch (tokens[0]) {
|
||||
case '[':
|
||||
return consumeArray(tokens);
|
||||
case '(':
|
||||
return consumeTuple(tokens);
|
||||
case '{':
|
||||
return consumeFields(tokens);
|
||||
}
|
||||
}
|
||||
function consumeType(tokens){
|
||||
var token, wildcard, type, structure;
|
||||
token = peek(tokens);
|
||||
wildcard = token === '*';
|
||||
if (wildcard || identifierRegex.test(token)) {
|
||||
type = wildcard
|
||||
? consumeOp(tokens, '*')
|
||||
: consumeIdent(tokens);
|
||||
structure = maybeConsumeStructure(tokens);
|
||||
if (structure) {
|
||||
return structure.type = type, structure;
|
||||
} else {
|
||||
return {
|
||||
type: type
|
||||
};
|
||||
}
|
||||
} else {
|
||||
structure = maybeConsumeStructure(tokens);
|
||||
if (!structure) {
|
||||
throw new Error("Unexpected character: " + token);
|
||||
}
|
||||
return structure;
|
||||
}
|
||||
}
|
||||
function consumeTypes(tokens){
|
||||
var lookahead, types, typesSoFar, typeObj, type, structure;
|
||||
if ('::' === peek(tokens)) {
|
||||
throw new Error("No comment before comment separator '::' found.");
|
||||
}
|
||||
lookahead = tokens[1];
|
||||
if (lookahead != null && lookahead === '::') {
|
||||
tokens.shift();
|
||||
tokens.shift();
|
||||
}
|
||||
types = [];
|
||||
typesSoFar = {};
|
||||
if ('Maybe' === peek(tokens)) {
|
||||
tokens.shift();
|
||||
types = [
|
||||
{
|
||||
type: 'Undefined'
|
||||
}, {
|
||||
type: 'Null'
|
||||
}
|
||||
];
|
||||
typesSoFar = {
|
||||
Undefined: true,
|
||||
Null: true
|
||||
};
|
||||
}
|
||||
for (;;) {
|
||||
typeObj = consumeType(tokens), type = typeObj.type, structure = typeObj.structure;
|
||||
if (!typesSoFar[type]) {
|
||||
types.push(typeObj);
|
||||
}
|
||||
if (structure == null) {
|
||||
typesSoFar[type] = true;
|
||||
}
|
||||
if (!maybeConsumeOp(tokens, '|')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
tokenRegex = RegExp('\\.\\.\\.|::|->|' + identifierRegex.source + '|\\S', 'g');
|
||||
module.exports = function(input){
|
||||
var tokens, e;
|
||||
if (!input.length) {
|
||||
throw new Error('No type specified.');
|
||||
}
|
||||
tokens = input.match(tokenRegex) || [];
|
||||
if (in$('->', tokens)) {
|
||||
throw new Error("Function types are not supported.\ To validate that something is a function, you may use 'Function'.");
|
||||
}
|
||||
try {
|
||||
return consumeTypes(tokens);
|
||||
} catch (e$) {
|
||||
e = e$;
|
||||
throw new Error(e.message + " - Remaining tokens: " + JSON.stringify(tokens) + " - Initial input: '" + input + "'");
|
||||
}
|
||||
};
|
||||
function in$(x, xs){
|
||||
var i = -1, l = xs.length >>> 0;
|
||||
while (++i < l) if (x === xs[i]) return true;
|
||||
return false;
|
||||
}
|
||||
}).call(this);
|
||||
@@ -0,0 +1 @@
|
||||
self.Flatted=function(n){"use strict";function t(n){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t(n)}var r=JSON.parse,e=JSON.stringify,o=Object.keys,u=String,f="string",i={},c="object",a=function(n,t){return t},l=function(n){return n instanceof u?u(n):n},s=function(n,r){return t(r)===f?new u(r):r},y=function(n,r,e,f){for(var a=[],l=o(e),s=l.length,p=0;p<s;p++){var v=l[p],S=e[v];if(S instanceof u){var b=n[S];t(b)!==c||r.has(b)?e[v]=f.call(e,v,b):(r.add(b),e[v]=i,a.push({k:v,a:[n,r,b,f]}))}else e[v]!==i&&(e[v]=f.call(e,v,S))}for(var m=a.length,g=0;g<m;g++){var h=a[g],O=h.k,d=h.a;e[O]=f.call(e,O,y.apply(null,d))}return e},p=function(n,t,r){var e=u(t.push(r)-1);return n.set(r,e),e},v=function(n,e){var o=r(n,s).map(l),u=o[0],f=e||a,i=t(u)===c&&u?y(o,new Set,u,f):u;return f.call({"":i},"",i)},S=function(n,r,o){for(var u=r&&t(r)===c?function(n,t){return""===n||-1<r.indexOf(n)?t:void 0}:r||a,i=new Map,l=[],s=[],y=+p(i,l,u.call({"":n},"",n)),v=!y;y<l.length;)v=!0,s[y]=e(l[y++],S,o);return"["+s.join(",")+"]";function S(n,r){if(v)return v=!v,r;var e=u.call(this,n,r);switch(t(e)){case c:if(null===e)return e;case f:return i.get(e)||p(i,l,e)}return e}};return n.fromJSON=function(n){return v(e(n))},n.parse=v,n.stringify=S,n.toJSON=function(n){return r(S(n))},n}({});
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = StructTreeItem;
|
||||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const react_1 = require("react");
|
||||
const structTreeUtils_js_1 = require("./shared/structTreeUtils.js");
|
||||
function StructTreeItem({ className, node, }) {
|
||||
const attributes = (0, react_1.useMemo)(() => (0, structTreeUtils_js_1.getAttributes)(node), [node]);
|
||||
const children = (0, react_1.useMemo)(() => {
|
||||
if (!(0, structTreeUtils_js_1.isStructTreeNode)(node)) {
|
||||
return null;
|
||||
}
|
||||
if ((0, structTreeUtils_js_1.isStructTreeNodeWithOnlyContentChild)(node)) {
|
||||
return null;
|
||||
}
|
||||
return node.children.map((child, index) => {
|
||||
return (
|
||||
// biome-ignore lint/suspicious/noArrayIndexKey: index is stable here
|
||||
(0, jsx_runtime_1.jsx)(StructTreeItem, { node: child }, index));
|
||||
});
|
||||
}, [node]);
|
||||
return ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: className }, attributes, { children: children })));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var parse = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('whitespace should be whitespace', function (t) {
|
||||
t.plan(1);
|
||||
var x = parse(['-x', '\t']).x;
|
||||
t.equal(x, '\t');
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},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","2":"C L M G N O P"},C:{"1":"0 1 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 LC J PB K D E F A B C L M G N O P qC rC","132":"QB"},D:{"1":"0 9 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 4 5 6 7 8 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"},E:{"1":"B C L M G 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 K D E F A sC SC tC uC vC wC"},F:{"1":"0 6 7 8 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":"1 2 3 4 5 F B C G N O P QB 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"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":"E SC 9C lC AD BD CD DD ED FD GD"},H:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C 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:"TextEncoder & TextDecoder",D:true};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getHighestUnreleased = getHighestUnreleased;
|
||||
exports.getLowestImplementedVersion = getLowestImplementedVersion;
|
||||
exports.getLowestUnreleased = getLowestUnreleased;
|
||||
exports.isUnreleasedVersion = isUnreleasedVersion;
|
||||
exports.semverMin = semverMin;
|
||||
exports.semverify = semverify;
|
||||
var _semver = require("semver");
|
||||
var _helperValidatorOption = require("@babel/helper-validator-option");
|
||||
var _targets = require("./targets.js");
|
||||
const versionRegExp = /^(?:\d+|\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?))$/;
|
||||
const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
|
||||
function semverMin(first, second) {
|
||||
return first && _semver.lt(first, second) ? first : second;
|
||||
}
|
||||
function semverify(version) {
|
||||
if (typeof version === "string" && _semver.valid(version)) {
|
||||
return version;
|
||||
}
|
||||
v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
|
||||
version = version.toString();
|
||||
let pos = 0;
|
||||
let num = 0;
|
||||
while ((pos = version.indexOf(".", pos + 1)) > 0) {
|
||||
num++;
|
||||
}
|
||||
return version + ".0".repeat(2 - num);
|
||||
}
|
||||
function isUnreleasedVersion(version, env) {
|
||||
const unreleasedLabel = _targets.unreleasedLabels[env];
|
||||
return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
|
||||
}
|
||||
function getLowestUnreleased(a, b, env) {
|
||||
const unreleasedLabel = _targets.unreleasedLabels[env];
|
||||
if (a === unreleasedLabel) {
|
||||
return b;
|
||||
}
|
||||
if (b === unreleasedLabel) {
|
||||
return a;
|
||||
}
|
||||
return semverMin(a, b);
|
||||
}
|
||||
function getHighestUnreleased(a, b, env) {
|
||||
return getLowestUnreleased(a, b, env) === a ? b : a;
|
||||
}
|
||||
function getLowestImplementedVersion(plugin, environment) {
|
||||
const result = plugin[environment];
|
||||
if (!result && environment === "android") {
|
||||
return plugin.chrome;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=utils.js.map
|
||||
@@ -0,0 +1,119 @@
|
||||
import * as React from 'react'
|
||||
|
||||
export function useStableCallback<T extends (...args: Array<any>) => any>(
|
||||
fn: T,
|
||||
): T {
|
||||
const fnRef = React.useRef(fn)
|
||||
fnRef.current = fn
|
||||
|
||||
const ref = React.useRef((...args: Array<any>) => fnRef.current(...args))
|
||||
return ref.current as T
|
||||
}
|
||||
|
||||
export const useLayoutEffect =
|
||||
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
|
||||
|
||||
/**
|
||||
* Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3
|
||||
*/
|
||||
export function usePrevious<T>(value: T): T | null {
|
||||
// initialise the ref with previous and current values
|
||||
const ref = React.useRef<{ value: T; prev: T | null }>({
|
||||
value: value,
|
||||
prev: null,
|
||||
})
|
||||
|
||||
const current = ref.current.value
|
||||
|
||||
// if the value passed into hook doesn't match what we store as "current"
|
||||
// move the "current" to the "previous"
|
||||
// and store the passed value as "current"
|
||||
if (value !== current) {
|
||||
ref.current = {
|
||||
value: value,
|
||||
prev: current,
|
||||
}
|
||||
}
|
||||
|
||||
// return the previous value only
|
||||
return ref.current.prev
|
||||
}
|
||||
|
||||
/**
|
||||
* React hook to wrap `IntersectionObserver`.
|
||||
*
|
||||
* This hook will create an `IntersectionObserver` and observe the ref passed to it.
|
||||
*
|
||||
* When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.
|
||||
*
|
||||
* @param ref - The ref to observe
|
||||
* @param intersectionObserverOptions - The options to pass to the IntersectionObserver
|
||||
* @param options - The options to pass to the hook
|
||||
* @param callback - The callback to call when the intersection changes
|
||||
* @returns The IntersectionObserver instance
|
||||
* @example
|
||||
* ```tsx
|
||||
* const MyComponent = () => {
|
||||
* const ref = React.useRef<HTMLDivElement>(null)
|
||||
* useIntersectionObserver(
|
||||
* ref,
|
||||
* (entry) => { doSomething(entry) },
|
||||
* { rootMargin: '10px' },
|
||||
* { disabled: false }
|
||||
* )
|
||||
* return <div ref={ref} />
|
||||
* ```
|
||||
*/
|
||||
export function useIntersectionObserver<T extends Element>(
|
||||
ref: React.RefObject<T | null>,
|
||||
callback: (entry: IntersectionObserverEntry | undefined) => void,
|
||||
intersectionObserverOptions: IntersectionObserverInit = {},
|
||||
options: { disabled?: boolean } = {},
|
||||
): IntersectionObserver | null {
|
||||
const isIntersectionObserverAvailable = React.useRef(
|
||||
typeof IntersectionObserver === 'function',
|
||||
)
|
||||
|
||||
const observerRef = React.useRef<IntersectionObserver | null>(null)
|
||||
|
||||
React.useEffect(() => {
|
||||
if (
|
||||
!ref.current ||
|
||||
!isIntersectionObserverAvailable.current ||
|
||||
options.disabled
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
observerRef.current = new IntersectionObserver(([entry]) => {
|
||||
callback(entry)
|
||||
}, intersectionObserverOptions)
|
||||
|
||||
observerRef.current.observe(ref.current)
|
||||
|
||||
return () => {
|
||||
observerRef.current?.disconnect()
|
||||
}
|
||||
}, [callback, intersectionObserverOptions, options.disabled, ref])
|
||||
|
||||
return observerRef.current
|
||||
}
|
||||
|
||||
/**
|
||||
* React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.
|
||||
*
|
||||
* @param ref - The forwarded ref
|
||||
* @returns The inner ref returned by `useRef`
|
||||
* @example
|
||||
* ```tsx
|
||||
* const MyComponent = React.forwardRef((props, ref) => {
|
||||
* const innerRef = useForwardedRef(ref)
|
||||
* return <div ref={innerRef} />
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
export function useForwardedRef<T>(ref?: React.ForwardedRef<T>) {
|
||||
const innerRef = React.useRef<T>(null)
|
||||
React.useImperativeHandle(ref, () => innerRef.current!, [])
|
||||
return innerRef
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "pump",
|
||||
"version": "3.0.2",
|
||||
"repository": "git://github.com/mafintosh/pump.git",
|
||||
"license": "MIT",
|
||||
"description": "pipe streams together and close all of them if one of them closes",
|
||||
"browser": {
|
||||
"fs": false
|
||||
},
|
||||
"keywords": [
|
||||
"streams",
|
||||
"pipe",
|
||||
"destroy",
|
||||
"callback"
|
||||
],
|
||||
"author": "Mathias Buus Madsen <mathiasbuus@gmail.com>",
|
||||
"dependencies": {
|
||||
"end-of-stream": "^1.1.0",
|
||||
"once": "^1.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test-browser.js && node test-node.js"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
Copyright (c) George Zahariev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,72 @@
|
||||
import { RouterCore, AnyRoute, CreateRouterFn, RouterConstructorOptions, TrailingSlashOption } from '@tanstack/router-core';
|
||||
import { RouterHistory } from '@tanstack/history';
|
||||
import { ErrorRouteComponent, NotFoundRouteComponent, RouteComponent } from './route.cjs';
|
||||
declare module '@tanstack/router-core' {
|
||||
interface RouterOptionsExtensions {
|
||||
/**
|
||||
* The default `component` a route should use if no component is provided.
|
||||
*
|
||||
* @default Outlet
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultcomponent-property)
|
||||
*/
|
||||
defaultComponent?: RouteComponent;
|
||||
/**
|
||||
* The default `errorComponent` a route should use if no error component is provided.
|
||||
*
|
||||
* @default ErrorComponent
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulterrorcomponent-property)
|
||||
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
|
||||
*/
|
||||
defaultErrorComponent?: ErrorRouteComponent;
|
||||
/**
|
||||
* The default `pendingComponent` a route should use if no pending component is provided.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingcomponent-property)
|
||||
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#showing-a-pending-component)
|
||||
*/
|
||||
defaultPendingComponent?: RouteComponent;
|
||||
/**
|
||||
* The default `notFoundComponent` a route should use if no notFound component is provided.
|
||||
*
|
||||
* @default NotFound
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
|
||||
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#default-router-wide-not-found-handling)
|
||||
*/
|
||||
defaultNotFoundComponent?: NotFoundRouteComponent;
|
||||
/**
|
||||
* A component that will be used to wrap the entire router.
|
||||
*
|
||||
* This is useful for providing a context to the entire router.
|
||||
*
|
||||
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#wrap-property)
|
||||
*/
|
||||
Wrap?: (props: {
|
||||
children: any;
|
||||
}) => React.JSX.Element;
|
||||
/**
|
||||
* A component that will be used to wrap the inner contents of the router.
|
||||
*
|
||||
* This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
|
||||
*
|
||||
* Only non-DOM-rendering components like providers should be used, anything else will cause a hydration error.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#innerwrap-property)
|
||||
*/
|
||||
InnerWrap?: (props: {
|
||||
children: any;
|
||||
}) => React.JSX.Element;
|
||||
/**
|
||||
* The default `onCatch` handler for errors caught by the Router ErrorBoundary
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
|
||||
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
|
||||
*/
|
||||
defaultOnCatch?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
||||
}
|
||||
}
|
||||
export declare const createRouter: CreateRouterFn;
|
||||
export declare class Router<in out TRouteTree extends AnyRoute, in out TTrailingSlashOption extends TrailingSlashOption = 'never', in out TDefaultStructuralSharingOption extends boolean = false, in out TRouterHistory extends RouterHistory = RouterHistory, in out TDehydrated extends Record<string, any> = Record<string, any>> extends RouterCore<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated> {
|
||||
constructor(options: RouterConstructorOptions<TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated>);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_helperCompilationTargets","data","require","resolveBrowserslistConfigFile","browserslistConfigFile","configFilePath","undefined","resolveTargets","options","root","optTargets","targets","Array","isArray","browsers","Object","assign","esmodules","getTargets","ignoreBrowserslistConfig","browserslistEnv"],"sources":["../../src/config/resolve-targets-browser.ts"],"sourcesContent":["import type { ValidatedOptions } from \"./validation/options.ts\";\nimport getTargets, {\n type InputTargets,\n} from \"@babel/helper-compilation-targets\";\n\nimport type { Targets } from \"@babel/helper-compilation-targets\";\n\nexport function resolveBrowserslistConfigFile(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n browserslistConfigFile: string,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n configFilePath: string,\n): string | void {\n return undefined;\n}\n\nexport function resolveTargets(\n options: ValidatedOptions,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n root: string,\n): Targets {\n const optTargets = options.targets;\n let targets: InputTargets;\n\n if (typeof optTargets === \"string\" || Array.isArray(optTargets)) {\n targets = { browsers: optTargets };\n } else if (optTargets) {\n if (\"esmodules\" in optTargets) {\n targets = { ...optTargets, esmodules: \"intersect\" };\n } else {\n // https://github.com/microsoft/TypeScript/issues/17002\n targets = optTargets as InputTargets;\n }\n }\n\n return getTargets(targets, {\n ignoreBrowserslistConfig: true,\n browserslistEnv: options.browserslistEnv,\n });\n}\n"],"mappings":";;;;;;;AACA,SAAAA,0BAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,yBAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAMO,SAASE,6BAA6BA,CAE3CC,sBAA8B,EAE9BC,cAAsB,EACP;EACf,OAAOC,SAAS;AAClB;AAEO,SAASC,cAAcA,CAC5BC,OAAyB,EAEzBC,IAAY,EACH;EACT,MAAMC,UAAU,GAAGF,OAAO,CAACG,OAAO;EAClC,IAAIA,OAAqB;EAEzB,IAAI,OAAOD,UAAU,KAAK,QAAQ,IAAIE,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,EAAE;IAC/DC,OAAO,GAAG;MAAEG,QAAQ,EAAEJ;IAAW,CAAC;EACpC,CAAC,MAAM,IAAIA,UAAU,EAAE;IACrB,IAAI,WAAW,IAAIA,UAAU,EAAE;MAC7BC,OAAO,GAAAI,MAAA,CAAAC,MAAA,KAAQN,UAAU;QAAEO,SAAS,EAAE;MAAW,EAAE;IACrD,CAAC,MAAM;MAELN,OAAO,GAAGD,UAA0B;IACtC;EACF;EAEA,OAAO,IAAAQ,mCAAU,EAACP,OAAO,EAAE;IACzBQ,wBAAwB,EAAE,IAAI;IAC9BC,eAAe,EAAEZ,OAAO,CAACY;EAC3B,CAAC,CAAC;AACJ;AAAC","ignoreList":[]}
|
||||
@@ -0,0 +1,125 @@
|
||||
'use strict';
|
||||
|
||||
var schema = {
|
||||
additionalItems: subschema('additionalItems'),
|
||||
items: subschema('items'),
|
||||
contains: subschema('contains'),
|
||||
additionalProperties: subschema('additionalProperties'),
|
||||
propertyNames: subschema('propertyNames'),
|
||||
not: subschema('not'),
|
||||
allOf: [
|
||||
subschema('allOf_0'),
|
||||
subschema('allOf_1'),
|
||||
{
|
||||
items: [
|
||||
subschema('items_0'),
|
||||
subschema('items_1'),
|
||||
]
|
||||
}
|
||||
],
|
||||
anyOf: [
|
||||
subschema('anyOf_0'),
|
||||
subschema('anyOf_1'),
|
||||
],
|
||||
oneOf: [
|
||||
subschema('oneOf_0'),
|
||||
subschema('oneOf_1'),
|
||||
],
|
||||
definitions: {
|
||||
foo: subschema('definitions_foo'),
|
||||
bar: subschema('definitions_bar'),
|
||||
},
|
||||
properties: {
|
||||
foo: subschema('properties_foo'),
|
||||
bar: subschema('properties_bar'),
|
||||
},
|
||||
patternProperties: {
|
||||
foo: subschema('patternProperties_foo'),
|
||||
bar: subschema('patternProperties_bar'),
|
||||
},
|
||||
dependencies: {
|
||||
foo: subschema('dependencies_foo'),
|
||||
bar: subschema('dependencies_bar'),
|
||||
},
|
||||
required: ['foo', 'bar']
|
||||
};
|
||||
|
||||
|
||||
function subschema(keyword) {
|
||||
var sch = {
|
||||
properties: {},
|
||||
additionalProperties: false,
|
||||
additionalItems: false,
|
||||
anyOf: [
|
||||
{format: 'email'},
|
||||
{format: 'hostname'}
|
||||
]
|
||||
};
|
||||
sch.properties['foo_' + keyword] = {title: 'foo'};
|
||||
sch.properties['bar_' + keyword] = {title: 'bar'};
|
||||
return sch;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
schema: schema,
|
||||
|
||||
// schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex
|
||||
expectedCalls: [[schema, '', schema, undefined, undefined, undefined, undefined]]
|
||||
.concat(expectedCalls('additionalItems'))
|
||||
.concat(expectedCalls('items'))
|
||||
.concat(expectedCalls('contains'))
|
||||
.concat(expectedCalls('additionalProperties'))
|
||||
.concat(expectedCalls('propertyNames'))
|
||||
.concat(expectedCalls('not'))
|
||||
.concat(expectedCallsChild('allOf', 0))
|
||||
.concat(expectedCallsChild('allOf', 1))
|
||||
.concat([
|
||||
[schema.allOf[2], '/allOf/2', schema, '', 'allOf', schema, 2],
|
||||
[schema.allOf[2].items[0], '/allOf/2/items/0', schema, '/allOf/2', 'items', schema.allOf[2], 0],
|
||||
[schema.allOf[2].items[0].properties.foo_items_0, '/allOf/2/items/0/properties/foo_items_0', schema, '/allOf/2/items/0', 'properties', schema.allOf[2].items[0], 'foo_items_0'],
|
||||
[schema.allOf[2].items[0].properties.bar_items_0, '/allOf/2/items/0/properties/bar_items_0', schema, '/allOf/2/items/0', 'properties', schema.allOf[2].items[0], 'bar_items_0'],
|
||||
[schema.allOf[2].items[0].anyOf[0], '/allOf/2/items/0/anyOf/0', schema, '/allOf/2/items/0', 'anyOf', schema.allOf[2].items[0], 0],
|
||||
[schema.allOf[2].items[0].anyOf[1], '/allOf/2/items/0/anyOf/1', schema, '/allOf/2/items/0', 'anyOf', schema.allOf[2].items[0], 1],
|
||||
|
||||
[schema.allOf[2].items[1], '/allOf/2/items/1', schema, '/allOf/2', 'items', schema.allOf[2], 1],
|
||||
[schema.allOf[2].items[1].properties.foo_items_1, '/allOf/2/items/1/properties/foo_items_1', schema, '/allOf/2/items/1', 'properties', schema.allOf[2].items[1], 'foo_items_1'],
|
||||
[schema.allOf[2].items[1].properties.bar_items_1, '/allOf/2/items/1/properties/bar_items_1', schema, '/allOf/2/items/1', 'properties', schema.allOf[2].items[1], 'bar_items_1'],
|
||||
[schema.allOf[2].items[1].anyOf[0], '/allOf/2/items/1/anyOf/0', schema, '/allOf/2/items/1', 'anyOf', schema.allOf[2].items[1], 0],
|
||||
[schema.allOf[2].items[1].anyOf[1], '/allOf/2/items/1/anyOf/1', schema, '/allOf/2/items/1', 'anyOf', schema.allOf[2].items[1], 1]
|
||||
])
|
||||
.concat(expectedCallsChild('anyOf', 0))
|
||||
.concat(expectedCallsChild('anyOf', 1))
|
||||
.concat(expectedCallsChild('oneOf', 0))
|
||||
.concat(expectedCallsChild('oneOf', 1))
|
||||
.concat(expectedCallsChild('definitions', 'foo'))
|
||||
.concat(expectedCallsChild('definitions', 'bar'))
|
||||
.concat(expectedCallsChild('properties', 'foo'))
|
||||
.concat(expectedCallsChild('properties', 'bar'))
|
||||
.concat(expectedCallsChild('patternProperties', 'foo'))
|
||||
.concat(expectedCallsChild('patternProperties', 'bar'))
|
||||
.concat(expectedCallsChild('dependencies', 'foo'))
|
||||
.concat(expectedCallsChild('dependencies', 'bar'))
|
||||
};
|
||||
|
||||
|
||||
function expectedCalls(keyword) {
|
||||
return [
|
||||
[schema[keyword], `/${keyword}`, schema, '', keyword, schema, undefined],
|
||||
[schema[keyword].properties[`foo_${keyword}`], `/${keyword}/properties/foo_${keyword}`, schema, `/${keyword}`, 'properties', schema[keyword], `foo_${keyword}`],
|
||||
[schema[keyword].properties[`bar_${keyword}`], `/${keyword}/properties/bar_${keyword}`, schema, `/${keyword}`, 'properties', schema[keyword], `bar_${keyword}`],
|
||||
[schema[keyword].anyOf[0], `/${keyword}/anyOf/0`, schema, `/${keyword}`, 'anyOf', schema[keyword], 0],
|
||||
[schema[keyword].anyOf[1], `/${keyword}/anyOf/1`, schema, `/${keyword}`, 'anyOf', schema[keyword], 1]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
function expectedCallsChild(keyword, i) {
|
||||
return [
|
||||
[schema[keyword][i], `/${keyword}/${i}`, schema, '', keyword, schema, i],
|
||||
[schema[keyword][i].properties[`foo_${keyword}_${i}`], `/${keyword}/${i}/properties/foo_${keyword}_${i}`, schema, `/${keyword}/${i}`, 'properties', schema[keyword][i], `foo_${keyword}_${i}`],
|
||||
[schema[keyword][i].properties[`bar_${keyword}_${i}`], `/${keyword}/${i}/properties/bar_${keyword}_${i}`, schema, `/${keyword}/${i}`, 'properties', schema[keyword][i], `bar_${keyword}_${i}`],
|
||||
[schema[keyword][i].anyOf[0], `/${keyword}/${i}/anyOf/0`, schema, `/${keyword}/${i}`, 'anyOf', schema[keyword][i], 0],
|
||||
[schema[keyword][i].anyOf[1], `/${keyword}/${i}/anyOf/1`, schema, `/${keyword}/${i}`, 'anyOf', schema[keyword][i], 1]
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"es6.module": {
|
||||
"chrome": "61",
|
||||
"and_chr": "61",
|
||||
"edge": "16",
|
||||
"firefox": "60",
|
||||
"and_ff": "60",
|
||||
"node": "13.2.0",
|
||||
"opera": "48",
|
||||
"op_mob": "45",
|
||||
"safari": "10.1",
|
||||
"ios": "10.3",
|
||||
"samsung": "8.2",
|
||||
"android": "61",
|
||||
"electron": "2.0",
|
||||
"ios_saf": "10.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const jsxRuntime = require("react/jsx-runtime");
|
||||
const jsesc = require("jsesc");
|
||||
function ScriptOnce({
|
||||
children,
|
||||
log
|
||||
}) {
|
||||
if (typeof document !== "undefined") {
|
||||
return null;
|
||||
}
|
||||
return /* @__PURE__ */ jsxRuntime.jsx(
|
||||
"script",
|
||||
{
|
||||
className: "tsr-once",
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: [
|
||||
children,
|
||||
(log ?? true) && process.env.NODE_ENV === "development" ? `console.info(\`Injected From Server:
|
||||
${jsesc(children.toString(), { quotes: "backtick" })}\`)` : "",
|
||||
'if (typeof __TSR_SSR__ !== "undefined") __TSR_SSR__.cleanScripts()'
|
||||
].filter(Boolean).join("\n")
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
exports.ScriptOnce = ScriptOnce;
|
||||
//# sourceMappingURL=ScriptOnce.cjs.map
|
||||
@@ -0,0 +1,76 @@
|
||||
import { TSR_DEFERRED_PROMISE, defer } from "./defer.js";
|
||||
import { preloadWarning } from "./link.js";
|
||||
import { isMatch } from "./Matches.js";
|
||||
import { cleanPath, exactPathTest, interpolatePath, joinPaths, matchByPath, matchPathname, parsePathname, removeBasepath, removeTrailingSlash, resolvePath, trimPath, trimPathLeft, trimPathRight } from "./path.js";
|
||||
import { decode, encode } from "./qss.js";
|
||||
import { rootRouteId } from "./root.js";
|
||||
import { BaseRootRoute, BaseRoute, BaseRouteApi } from "./route.js";
|
||||
import { PathParamError, RouterCore, SearchParamError, componentTypes, defaultSerializeError, getInitialRouterState, getLocationChangeInfo, lazyFn } from "./router.js";
|
||||
import { retainSearchParams, stripSearchParams } from "./searchMiddleware.js";
|
||||
import { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith } from "./searchParams.js";
|
||||
import { createControlledPromise, deepEqual, escapeJSON, functionalUpdate, isPlainArray, isPlainObject, last, pick, replaceEqualDeep, shallow } from "./utils.js";
|
||||
import { isRedirect, isResolvedRedirect, redirect } from "./redirect.js";
|
||||
import { isNotFound, notFound } from "./not-found.js";
|
||||
import { defaultGetScrollRestorationKey, getCssSelector, handleHashScroll, restoreScroll, scrollRestorationCache, setupScrollRestoration, storageKey } from "./scroll-restoration.js";
|
||||
export {
|
||||
BaseRootRoute,
|
||||
BaseRoute,
|
||||
BaseRouteApi,
|
||||
PathParamError,
|
||||
RouterCore,
|
||||
SearchParamError,
|
||||
TSR_DEFERRED_PROMISE,
|
||||
cleanPath,
|
||||
componentTypes,
|
||||
createControlledPromise,
|
||||
decode,
|
||||
deepEqual,
|
||||
defaultGetScrollRestorationKey,
|
||||
defaultParseSearch,
|
||||
defaultSerializeError,
|
||||
defaultStringifySearch,
|
||||
defer,
|
||||
encode,
|
||||
escapeJSON,
|
||||
exactPathTest,
|
||||
functionalUpdate,
|
||||
getCssSelector,
|
||||
getInitialRouterState,
|
||||
getLocationChangeInfo,
|
||||
handleHashScroll,
|
||||
interpolatePath,
|
||||
isMatch,
|
||||
isNotFound,
|
||||
isPlainArray,
|
||||
isPlainObject,
|
||||
isRedirect,
|
||||
isResolvedRedirect,
|
||||
joinPaths,
|
||||
last,
|
||||
lazyFn,
|
||||
matchByPath,
|
||||
matchPathname,
|
||||
notFound,
|
||||
parsePathname,
|
||||
parseSearchWith,
|
||||
pick,
|
||||
preloadWarning,
|
||||
redirect,
|
||||
removeBasepath,
|
||||
removeTrailingSlash,
|
||||
replaceEqualDeep,
|
||||
resolvePath,
|
||||
restoreScroll,
|
||||
retainSearchParams,
|
||||
rootRouteId,
|
||||
scrollRestorationCache,
|
||||
setupScrollRestoration,
|
||||
shallow,
|
||||
storageKey,
|
||||
stringifySearchWith,
|
||||
stripSearchParams,
|
||||
trimPath,
|
||||
trimPathLeft,
|
||||
trimPathRight
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* @fileoverview Disallow reassigning function parameters.
|
||||
* @author Nat Burns
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const stopNodePattern =
|
||||
/(?:Statement|Declaration|Function(?:Expression)?|Program)$/u;
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow reassigning function parameters",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-param-reassign",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
oneOf: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
props: {
|
||||
enum: [false],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
props: {
|
||||
enum: [true],
|
||||
},
|
||||
ignorePropertyModificationsFor: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
},
|
||||
uniqueItems: true,
|
||||
},
|
||||
ignorePropertyModificationsForRegex: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
},
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
assignmentToFunctionParam:
|
||||
"Assignment to function parameter '{{name}}'.",
|
||||
assignmentToFunctionParamProp:
|
||||
"Assignment to property of function parameter '{{name}}'.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const props = context.options[0] && context.options[0].props;
|
||||
const ignoredPropertyAssignmentsFor =
|
||||
(context.options[0] &&
|
||||
context.options[0].ignorePropertyModificationsFor) ||
|
||||
[];
|
||||
const ignoredPropertyAssignmentsForRegex =
|
||||
(context.options[0] &&
|
||||
context.options[0].ignorePropertyModificationsForRegex) ||
|
||||
[];
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Checks whether or not the reference modifies properties of its variable.
|
||||
* @param {Reference} reference A reference to check.
|
||||
* @returns {boolean} Whether or not the reference modifies properties of its variable.
|
||||
*/
|
||||
function isModifyingProp(reference) {
|
||||
let node = reference.identifier;
|
||||
let parent = node.parent;
|
||||
|
||||
while (
|
||||
parent &&
|
||||
(!stopNodePattern.test(parent.type) ||
|
||||
parent.type === "ForInStatement" ||
|
||||
parent.type === "ForOfStatement")
|
||||
) {
|
||||
switch (parent.type) {
|
||||
// e.g. foo.a = 0;
|
||||
case "AssignmentExpression":
|
||||
return parent.left === node;
|
||||
|
||||
// e.g. ++foo.a;
|
||||
case "UpdateExpression":
|
||||
return true;
|
||||
|
||||
// e.g. delete foo.a;
|
||||
case "UnaryExpression":
|
||||
if (parent.operator === "delete") {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
// e.g. for (foo.a in b) {}
|
||||
case "ForInStatement":
|
||||
case "ForOfStatement":
|
||||
if (parent.left === node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// this is a stop node for parent.right and parent.body
|
||||
return false;
|
||||
|
||||
// EXCLUDES: e.g. cache.get(foo.a).b = 0;
|
||||
case "CallExpression":
|
||||
if (parent.callee !== node) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
// EXCLUDES: e.g. cache[foo.a] = 0;
|
||||
case "MemberExpression":
|
||||
if (parent.property === node) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
// EXCLUDES: e.g. ({ [foo]: a }) = bar;
|
||||
case "Property":
|
||||
if (parent.key === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// EXCLUDES: e.g. (foo ? a : b).c = bar;
|
||||
case "ConditionalExpression":
|
||||
if (parent.test === node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// no default
|
||||
}
|
||||
|
||||
node = parent;
|
||||
parent = node.parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that an identifier name matches any of the ignored property assignments.
|
||||
* First we test strings in ignoredPropertyAssignmentsFor.
|
||||
* Then we instantiate and test RegExp objects from ignoredPropertyAssignmentsForRegex strings.
|
||||
* @param {string} identifierName A string that describes the name of an identifier to
|
||||
* ignore property assignments for.
|
||||
* @returns {boolean} Whether the string matches an ignored property assignment regular expression or not.
|
||||
*/
|
||||
function isIgnoredPropertyAssignment(identifierName) {
|
||||
return (
|
||||
ignoredPropertyAssignmentsFor.includes(identifierName) ||
|
||||
ignoredPropertyAssignmentsForRegex.some(ignored =>
|
||||
new RegExp(ignored, "u").test(identifierName),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports a reference if is non initializer and writable.
|
||||
* @param {Reference} reference A reference to check.
|
||||
* @param {int} index The index of the reference in the references.
|
||||
* @param {Reference[]} references The array that the reference belongs to.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkReference(reference, index, references) {
|
||||
const identifier = reference.identifier;
|
||||
|
||||
if (
|
||||
identifier &&
|
||||
!reference.init &&
|
||||
/*
|
||||
* Destructuring assignments can have multiple default value,
|
||||
* so possibly there are multiple writeable references for the same identifier.
|
||||
*/
|
||||
(index === 0 || references[index - 1].identifier !== identifier)
|
||||
) {
|
||||
if (reference.isWrite()) {
|
||||
context.report({
|
||||
node: identifier,
|
||||
messageId: "assignmentToFunctionParam",
|
||||
data: { name: identifier.name },
|
||||
});
|
||||
} else if (
|
||||
props &&
|
||||
isModifyingProp(reference) &&
|
||||
!isIgnoredPropertyAssignment(identifier.name)
|
||||
) {
|
||||
context.report({
|
||||
node: identifier,
|
||||
messageId: "assignmentToFunctionParamProp",
|
||||
data: { name: identifier.name },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and reports references that are non initializer and writable.
|
||||
* @param {Variable} variable A variable to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkVariable(variable) {
|
||||
if (variable.defs[0].type === "Parameter") {
|
||||
variable.references.forEach(checkReference);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks parameters of a given function node.
|
||||
* @param {ASTNode} node A function node to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkForFunction(node) {
|
||||
sourceCode.getDeclaredVariables(node).forEach(checkVariable);
|
||||
}
|
||||
|
||||
return {
|
||||
// `:exit` is needed for the `node.parent` property of identifier nodes.
|
||||
"FunctionDeclaration:exit": checkForFunction,
|
||||
"FunctionExpression:exit": checkForFunction,
|
||||
"ArrowFunctionExpression:exit": checkForFunction,
|
||||
};
|
||||
},
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["_t","require","addComment","_addComment","addComments","_addComments","shareCommentsWithSiblings","key","node","trailing","trailingComments","leading","leadingComments","prev","getSibling","next","hasPrev","Boolean","hasNext","removeIfExisting","list","toRemove","length","set","Set","filter","el","has","type","content","line","comments"],"sources":["../../src/path/comments.ts"],"sourcesContent":["// This file contains methods responsible for dealing with comments.\nimport type * as t from \"@babel/types\";\nimport type NodePath from \"./index.ts\";\nimport {\n addComment as _addComment,\n addComments as _addComments,\n} from \"@babel/types\";\n\n/**\n * Share comments amongst siblings.\n */\n\nexport function shareCommentsWithSiblings(this: NodePath) {\n // NOTE: this assumes numbered keys\n if (typeof this.key === \"string\") return;\n\n const node = this.node;\n if (!node) return;\n\n const trailing = node.trailingComments;\n const leading = node.leadingComments;\n if (!trailing && !leading) return;\n\n const prev = this.getSibling(this.key - 1);\n const next = this.getSibling(this.key + 1);\n const hasPrev = Boolean(prev.node);\n const hasNext = Boolean(next.node);\n\n if (hasPrev) {\n if (leading) {\n prev.addComments(\n \"trailing\",\n removeIfExisting(leading, prev.node.trailingComments),\n );\n }\n if (trailing && !hasNext) prev.addComments(\"trailing\", trailing);\n }\n if (hasNext) {\n if (trailing) {\n next.addComments(\n \"leading\",\n removeIfExisting(trailing, next.node.leadingComments),\n );\n }\n if (leading && !hasPrev) next.addComments(\"leading\", leading);\n }\n}\n\nfunction removeIfExisting<T>(list: T[], toRemove?: T[]): T[] {\n if (!toRemove?.length) return list;\n const set = new Set(toRemove);\n return list.filter(el => {\n return !set.has(el);\n });\n}\n\nexport function addComment(\n this: NodePath,\n type: t.CommentTypeShorthand,\n content: string,\n line?: boolean,\n) {\n _addComment(this.node, type, content, line);\n}\n\n/**\n * Give node `comments` of the specified `type`.\n */\n\nexport function addComments(\n this: NodePath,\n type: t.CommentTypeShorthand,\n comments: t.Comment[],\n) {\n _addComments(this.node, type, comments);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,EAAA,GAAAC,OAAA;AAGsB;EAFpBC,UAAU,EAAIC,WAAW;EACzBC,WAAW,EAAIC;AAAY,IAAAL,EAAA;AAOtB,SAASM,yBAAyBA,CAAA,EAAiB;EAExD,IAAI,OAAO,IAAI,CAACC,GAAG,KAAK,QAAQ,EAAE;EAElC,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;EACtB,IAAI,CAACA,IAAI,EAAE;EAEX,MAAMC,QAAQ,GAAGD,IAAI,CAACE,gBAAgB;EACtC,MAAMC,OAAO,GAAGH,IAAI,CAACI,eAAe;EACpC,IAAI,CAACH,QAAQ,IAAI,CAACE,OAAO,EAAE;EAE3B,MAAME,IAAI,GAAG,IAAI,CAACC,UAAU,CAAC,IAAI,CAACP,GAAG,GAAG,CAAC,CAAC;EAC1C,MAAMQ,IAAI,GAAG,IAAI,CAACD,UAAU,CAAC,IAAI,CAACP,GAAG,GAAG,CAAC,CAAC;EAC1C,MAAMS,OAAO,GAAGC,OAAO,CAACJ,IAAI,CAACL,IAAI,CAAC;EAClC,MAAMU,OAAO,GAAGD,OAAO,CAACF,IAAI,CAACP,IAAI,CAAC;EAElC,IAAIQ,OAAO,EAAE;IACX,IAAIL,OAAO,EAAE;MACXE,IAAI,CAACT,WAAW,CACd,UAAU,EACVe,gBAAgB,CAACR,OAAO,EAAEE,IAAI,CAACL,IAAI,CAACE,gBAAgB,CACtD,CAAC;IACH;IACA,IAAID,QAAQ,IAAI,CAACS,OAAO,EAAEL,IAAI,CAACT,WAAW,CAAC,UAAU,EAAEK,QAAQ,CAAC;EAClE;EACA,IAAIS,OAAO,EAAE;IACX,IAAIT,QAAQ,EAAE;MACZM,IAAI,CAACX,WAAW,CACd,SAAS,EACTe,gBAAgB,CAACV,QAAQ,EAAEM,IAAI,CAACP,IAAI,CAACI,eAAe,CACtD,CAAC;IACH;IACA,IAAID,OAAO,IAAI,CAACK,OAAO,EAAED,IAAI,CAACX,WAAW,CAAC,SAAS,EAAEO,OAAO,CAAC;EAC/D;AACF;AAEA,SAASQ,gBAAgBA,CAAIC,IAAS,EAAEC,QAAc,EAAO;EAC3D,IAAI,EAACA,QAAQ,YAARA,QAAQ,CAAEC,MAAM,GAAE,OAAOF,IAAI;EAClC,MAAMG,GAAG,GAAG,IAAIC,GAAG,CAACH,QAAQ,CAAC;EAC7B,OAAOD,IAAI,CAACK,MAAM,CAACC,EAAE,IAAI;IACvB,OAAO,CAACH,GAAG,CAACI,GAAG,CAACD,EAAE,CAAC;EACrB,CAAC,CAAC;AACJ;AAEO,SAASxB,UAAUA,CAExB0B,IAA4B,EAC5BC,OAAe,EACfC,IAAc,EACd;EACA3B,WAAW,CAAC,IAAI,CAACK,IAAI,EAAEoB,IAAI,EAAEC,OAAO,EAAEC,IAAI,CAAC;AAC7C;AAMO,SAAS1B,WAAWA,CAEzBwB,IAA4B,EAC5BG,QAAqB,EACrB;EACA1B,YAAY,CAAC,IAAI,CAACG,IAAI,EAAEoB,IAAI,EAAEG,QAAQ,CAAC;AACzC","ignoreList":[]}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},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","2":"C L M G N O P"},C:{"2":"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 9 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 4 5 6 7 8 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"},E:{"2":"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 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":"1 2 3 4 5 6 7 8 F B C G N O P QB RB SB TB UB VB 4C 5C 6C 7C FC kC 8C GC"},G:{"2":"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:{"2":"WD"},I:{"1":"I","2":"LC J XD YD ZD aD lC bD cD"},J:{"2":"D A"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"2":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD","2":"J"},Q:{"1":"oD"},R:{"1":"pD"},S:{"2":"qD rD"}},B:6,C:"Client Hints: DPR, Width, Viewport-Width",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F mC","129":"A B"},B:{"1":"0 9 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","129":"C L M"},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 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":"J PB K D","33":"1 2 3 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","2":"J PB sC SC tC","33":"K"},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","33":"BD"},H:{"2":"WD"},I:{"1":"I bD cD","2":"LC XD YD ZD","33":"J 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:{"1":"qD rD"}},B:5,C:"Blob URLs",D:true};
|
||||
Reference in New Issue
Block a user