update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Scripts.js","sources":["../../src/Scripts.tsx"],"sourcesContent":["import { Asset } from './Asset'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = () => {\n const router = useRouter()\n\n const assetScripts = useRouterState({\n select: (state) => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n state.matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n manifest.routes[route.id]?.assets\n ?.filter((d) => d.tag === 'script')\n .forEach((asset) => {\n assetScripts.push({\n tag: 'script',\n attrs: asset.attrs,\n children: asset.children,\n } as any)\n }),\n )\n\n return assetScripts\n },\n structuralSharing: true as any,\n })\n\n const { scripts } = useRouterState({\n select: (state) => ({\n scripts: (\n state.matches\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n suppressHydrationWarning: true,\n },\n children,\n })),\n }),\n })\n\n const allScripts = [...scripts, ...assetScripts] as Array<RouterManagedTag>\n\n return (\n <>\n {allScripts.map((asset, i) => (\n <Asset {...asset} key={`tsr-scripts-${asset.tag}-${i}`} />\n ))}\n </>\n )\n}\n"],"names":["assetScripts","_a"],"mappings":";;;;;AAKO,MAAM,UAAU,MAAM;AAC3B,QAAM,SAAS,UAAU;AAEzB,QAAM,eAAe,eAAe;AAAA,IAClC,QAAQ,CAAC,UAAU;;AACjB,YAAMA,gBAAwC,CAAC;AACzC,YAAA,YAAW,YAAO,QAAP,mBAAY;AAE7B,UAAI,CAAC,UAAU;AACb,eAAO,CAAC;AAAA,MAAA;AAGJ,YAAA,QACH,IAAI,CAAC,UAAU,OAAO,gBAAgB,MAAM,OAAO,CAAE,EACrD;AAAA,QAAQ,CAAC,UACR;;AAAA,wBAAAC,MAAA,SAAS,OAAO,MAAM,EAAE,MAAxB,gBAAAA,IAA2B,WAA3B,mBACI,OAAO,CAAC,MAAM,EAAE,QAAQ,UACzB,QAAQ,CAAC,UAAU;AAClBD,0BAAa,KAAK;AAAA,cAChB,KAAK;AAAA,cACL,OAAO,MAAM;AAAA,cACb,UAAU,MAAM;AAAA,YAAA,CACV;AAAA,UACT;AAAA;AAAA,MACL;AAEKA,aAAAA;AAAAA,IACT;AAAA,IACA,mBAAmB;AAAA,EAAA,CACpB;AAEK,QAAA,EAAE,QAAQ,IAAI,eAAe;AAAA,IACjC,QAAQ,CAAC,WAAW;AAAA,MAClB,SACE,MAAM,QACH,IAAI,CAAC,UAAU,MAAM,OAAQ,EAC7B,KAAK,CAAC,EACN,OAAO,OAAO,EACjB,IAAI,CAAC,EAAE,UAAU,GAAG,cAAc;AAAA,QAClC,KAAK;AAAA,QACL,OAAO;AAAA,UACL,GAAG;AAAA,UACH,0BAA0B;AAAA,QAC5B;AAAA,QACA;AAAA,MAAA,EACA;AAAA,IACJ;AAAA,EAAA,CACD;AAED,QAAM,aAAa,CAAC,GAAG,SAAS,GAAG,YAAY;AAE/C,yCAEK,UAAW,WAAA,IAAI,CAAC,OAAO,oCACrB,OAAO,EAAA,GAAG,OAAO,KAAK,eAAe,MAAM,GAAG,IAAI,CAAC,IAAI,CACzD,GACH;AAEJ;"}
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _superPropGet;
|
||||
var _get = require("./get.js");
|
||||
var _getPrototypeOf = require("./getPrototypeOf.js");
|
||||
function _superPropGet(classArg, property, receiver, flags) {
|
||||
var result = (0, _get.default)((0, _getPrototypeOf.default)(flags & 1 ? classArg.prototype : classArg), property, receiver);
|
||||
return flags & 2 && typeof result === "function" ? function (args) {
|
||||
return result.apply(receiver, args);
|
||||
} : result;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=superPropGet.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"0 9 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","2":"C"},C:{"1":"0 9 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":"1 2 3 4 5 6 7 8 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 qC rC"},D:{"1":"0 9 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","132":"fB gB hB iB jB kB lB"},E:{"1":"F A B C L M G 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 K D E sC SC tC uC vC"},F:{"1":"0 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 4C 5C 6C 7C FC kC 8C GC","132":"SB TB UB VB WB XB YB"},G:{"1":"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":"E SC 9C lC AD BD CD DD"},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 dD eD fD gD hD TC iD jD kD lD mD IC JC KC nD","2":"J"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"qD rD"}},B:6,C:"ES6 classes",D:true};
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = createFlowUnionType;
|
||||
var _index = require("../generated/index.js");
|
||||
var _removeTypeDuplicates = require("../../modifications/flow/removeTypeDuplicates.js");
|
||||
function createFlowUnionType(types) {
|
||||
const flattened = (0, _removeTypeDuplicates.default)(types);
|
||||
if (flattened.length === 1) {
|
||||
return flattened[0];
|
||||
} else {
|
||||
return (0, _index.unionTypeAnnotation)(flattened);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=createFlowUnionType.js.map
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag when deleting variables
|
||||
* @author Ilya Volodin
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow deleting variables",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-delete-var",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
unexpected: "Variables should not be deleted.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
UnaryExpression(node) {
|
||||
if (
|
||||
node.operator === "delete" &&
|
||||
node.argument.type === "Identifier"
|
||||
) {
|
||||
context.report({ node, messageId: "unexpected" });
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
const { createRequire } = require("node:module");
|
||||
const _createJiti = require("../dist/jiti.cjs");
|
||||
const transform = require("../dist/babel.cjs");
|
||||
|
||||
function onError(err) {
|
||||
throw err; /* ↓ Check stack trace ↓ */
|
||||
}
|
||||
|
||||
const nativeImport = (id) => import(id);
|
||||
|
||||
function createJiti(id, opts = {}) {
|
||||
if (!opts.transform) {
|
||||
opts = { ...opts, transform };
|
||||
}
|
||||
return _createJiti(id, opts, {
|
||||
onError,
|
||||
nativeImport,
|
||||
createRequire,
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createJiti;
|
||||
module.exports.createJiti = createJiti;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"A B","2":"K D E F mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 1 2 3 4 5 6 7 8 9 J PB K D E F A B C L M G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC oC pC","2":"nC LC qC rC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 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","2":"J"},E:{"1":"PB K D E F A B C L M G tC uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J sC SC"},F:{"1":"0 1 2 3 4 5 6 7 8 B C G N O P QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB wB xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R OC S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 4C 5C 6C 7C FC kC 8C GC","2":"F"},G:{"1":"E 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":"LC J I aD lC bD cD","132":"XD YD ZD"},J:{"1":"A","132":"D"},K:{"1":"A B C H FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"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:"Email, telephone & URL input types",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"A B","260":"K D E F mC"},B:{"1":"0 9 C L M G N O P Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I"},C:{"1":"0 1 2 3 4 5 6 7 8 9 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","132":"B","260":"nC LC J PB K D qC rC","516":"E F A"},D:{"1":"0 9 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":"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"},E:{"1":"E F A B C L M G 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 PB K D sC SC tC uC"},F:{"1":"0 1 2 3 4 5 6 7 8 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","16":"F 4C","132":"B C G N O 5C 6C 7C FC kC 8C GC"},G:{"1":"E 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 9C lC AD BD CD"},H:{"132":"WD"},I:{"1":"I bD cD","132":"LC J XD YD ZD aD lC"},J:{"132":"D A"},K:{"1":"H","16":"A","132":"B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"1":"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:4,C:"DOM Parsing and Serialization",D:true};
|
||||
@@ -0,0 +1,6 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="40" width="40">
|
||||
<path d="M9 3.5a1.5 1.5 0 0 0-3-.001v7.95C6 12.83 7.12 14 8.5 14s2.5-1.17 2.5-2.55V5.5a.5.5 0 0 1 1 0v6.03C11.955 13.427 10.405 15 8.5 15S5.044 13.426 5 11.53V3.5a2.5 2.5 0 0 1 5 0v7.003a1.5 1.5 0 0 1-3-.003v-5a.5.5 0 0 1 1 0v5a.5.5 0 0 0 1 0Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 552 B |
@@ -0,0 +1,76 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __rest = (this && this.__rest) || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
||||
t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
||||
t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import invariant from 'tiny-invariant';
|
||||
import Ref from './Ref.js';
|
||||
import useCachedValue from './shared/hooks/useCachedValue.js';
|
||||
import useDocumentContext from './shared/hooks/useDocumentContext.js';
|
||||
import useOutlineContext from './shared/hooks/useOutlineContext.js';
|
||||
export default function OutlineItem(props) {
|
||||
const documentContext = useDocumentContext();
|
||||
const outlineContext = useOutlineContext();
|
||||
invariant(outlineContext, 'Unable to find Outline context.');
|
||||
const mergedProps = Object.assign(Object.assign(Object.assign({}, documentContext), outlineContext), props);
|
||||
const { item, linkService, onItemClick, pdf } = mergedProps, otherProps = __rest(mergedProps, ["item", "linkService", "onItemClick", "pdf"]);
|
||||
invariant(pdf, 'Attempted to load an outline, but no document was specified. Wrap <Outline /> in a <Document /> or pass explicit `pdf` prop.');
|
||||
const getDestination = useCachedValue(() => {
|
||||
if (typeof item.dest === 'string') {
|
||||
return pdf.getDestination(item.dest);
|
||||
}
|
||||
return item.dest;
|
||||
});
|
||||
const getPageIndex = useCachedValue(() => __awaiter(this, void 0, void 0, function* () {
|
||||
const destination = yield getDestination();
|
||||
if (!destination) {
|
||||
throw new Error('Destination not found.');
|
||||
}
|
||||
const [ref] = destination;
|
||||
return pdf.getPageIndex(new Ref(ref));
|
||||
}));
|
||||
const getPageNumber = useCachedValue(() => __awaiter(this, void 0, void 0, function* () {
|
||||
const pageIndex = yield getPageIndex();
|
||||
return pageIndex + 1;
|
||||
}));
|
||||
function onClick(event) {
|
||||
event.preventDefault();
|
||||
invariant(onItemClick || linkService, 'Either onItemClick callback or linkService must be defined in order to navigate to an outline item.');
|
||||
if (onItemClick) {
|
||||
Promise.all([getDestination(), getPageIndex(), getPageNumber()]).then(([dest, pageIndex, pageNumber]) => {
|
||||
onItemClick({
|
||||
dest,
|
||||
pageIndex,
|
||||
pageNumber,
|
||||
});
|
||||
});
|
||||
}
|
||||
else if (linkService) {
|
||||
linkService.goToDestination(item.dest);
|
||||
}
|
||||
}
|
||||
function renderSubitems() {
|
||||
if (!item.items || !item.items.length) {
|
||||
return null;
|
||||
}
|
||||
const { items: subitems } = item;
|
||||
return (_jsx("ul", { children: subitems.map((subitem, subitemIndex) => (_jsx(OutlineItem, Object.assign({ item: subitem, pdf: pdf }, otherProps), typeof subitem.dest === 'string' ? subitem.dest : subitemIndex))) }));
|
||||
}
|
||||
return (_jsxs("li", { children: [_jsx("a", { href: "#", onClick: onClick, children: item.title }), renderSubitems()] }));
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
var stringify = require('../');
|
||||
|
||||
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
|
||||
var s = stringify(obj, function (a, b) {
|
||||
return a.key < b.key ? 1 : -1;
|
||||
});
|
||||
console.log(s);
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Copyright (c) 2017 Evgeny Poberezkin
|
||||
Copyright (c) 2013 James Halliday
|
||||
|
||||
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,384 @@
|
||||
/**
|
||||
* @fileoverview Look for useless escapes in strings and regexes
|
||||
* @author Onur Temizkan
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
const { RegExpParser, visitRegExpAST } = require("@eslint-community/regexpp");
|
||||
|
||||
/**
|
||||
* @typedef {import('@eslint-community/regexpp').AST.CharacterClass} CharacterClass
|
||||
* @typedef {import('@eslint-community/regexpp').AST.ExpressionCharacterClass} ExpressionCharacterClass
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the union of two sets.
|
||||
* @param {Set} setA The first set
|
||||
* @param {Set} setB The second set
|
||||
* @returns {Set} The union of the two sets
|
||||
*/
|
||||
function union(setA, setB) {
|
||||
return new Set(
|
||||
(function* () {
|
||||
yield* setA;
|
||||
yield* setB;
|
||||
})(),
|
||||
);
|
||||
}
|
||||
|
||||
const VALID_STRING_ESCAPES = union(new Set("\\nrvtbfux"), astUtils.LINEBREAKS);
|
||||
const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnpPrsStvwWxu0123456789]");
|
||||
const REGEX_NON_CHARCLASS_ESCAPES = union(
|
||||
REGEX_GENERAL_ESCAPES,
|
||||
new Set("^/.$*+?[{}|()Bk"),
|
||||
);
|
||||
|
||||
/*
|
||||
* Set of characters that require escaping in character classes in `unicodeSets` mode.
|
||||
* ( ) [ ] { } / - \ | are ClassSetSyntaxCharacter
|
||||
*/
|
||||
const REGEX_CLASSSET_CHARACTER_ESCAPES = union(
|
||||
REGEX_GENERAL_ESCAPES,
|
||||
new Set("q/[{}|()-"),
|
||||
);
|
||||
|
||||
/*
|
||||
* A single character set of ClassSetReservedDoublePunctuator.
|
||||
* && !! ## $$ %% ** ++ ,, .. :: ;; << == >> ?? @@ ^^ `` ~~ are ClassSetReservedDoublePunctuator
|
||||
*/
|
||||
const REGEX_CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR = new Set(
|
||||
"!#$%&*+,.:;<=>?@^`~",
|
||||
);
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow unnecessary escape characters",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-useless-escape",
|
||||
},
|
||||
|
||||
hasSuggestions: true,
|
||||
|
||||
messages: {
|
||||
unnecessaryEscape: "Unnecessary escape character: \\{{character}}.",
|
||||
removeEscape:
|
||||
"Remove the `\\`. This maintains the current functionality.",
|
||||
removeEscapeDoNotKeepSemantics:
|
||||
"Remove the `\\` if it was inserted by mistake.",
|
||||
escapeBackslash:
|
||||
"Replace the `\\` with `\\\\` to include the actual backslash character.",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
const parser = new RegExpParser();
|
||||
|
||||
/**
|
||||
* Reports a node
|
||||
* @param {ASTNode} node The node to report
|
||||
* @param {number} startOffset The backslash's offset from the start of the node
|
||||
* @param {string} character The uselessly escaped character (not including the backslash)
|
||||
* @param {boolean} [disableEscapeBackslashSuggest] `true` if escapeBackslash suggestion should be turned off.
|
||||
* @returns {void}
|
||||
*/
|
||||
function report(
|
||||
node,
|
||||
startOffset,
|
||||
character,
|
||||
disableEscapeBackslashSuggest,
|
||||
) {
|
||||
const rangeStart = node.range[0] + startOffset;
|
||||
const range = [rangeStart, rangeStart + 1];
|
||||
const start = sourceCode.getLocFromIndex(rangeStart);
|
||||
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start,
|
||||
end: { line: start.line, column: start.column + 1 },
|
||||
},
|
||||
messageId: "unnecessaryEscape",
|
||||
data: { character },
|
||||
suggest: [
|
||||
{
|
||||
// Removing unnecessary `\` characters in a directive is not guaranteed to maintain functionality.
|
||||
messageId: astUtils.isDirective(node.parent)
|
||||
? "removeEscapeDoNotKeepSemantics"
|
||||
: "removeEscape",
|
||||
fix(fixer) {
|
||||
return fixer.removeRange(range);
|
||||
},
|
||||
},
|
||||
...(disableEscapeBackslashSuggest
|
||||
? []
|
||||
: [
|
||||
{
|
||||
messageId: "escapeBackslash",
|
||||
fix(fixer) {
|
||||
return fixer.insertTextBeforeRange(
|
||||
range,
|
||||
"\\",
|
||||
);
|
||||
},
|
||||
},
|
||||
]),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the escape character in given string slice is unnecessary.
|
||||
* @private
|
||||
* @param {ASTNode} node node to validate.
|
||||
* @param {string} match string slice to validate.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateString(node, match) {
|
||||
const isTemplateElement = node.type === "TemplateElement";
|
||||
const escapedChar = match[0][1];
|
||||
let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar);
|
||||
let isQuoteEscape;
|
||||
|
||||
if (isTemplateElement) {
|
||||
isQuoteEscape = escapedChar === "`";
|
||||
|
||||
if (escapedChar === "$") {
|
||||
// Warn if `\$` is not followed by `{`
|
||||
isUnnecessaryEscape = match.input[match.index + 2] !== "{";
|
||||
} else if (escapedChar === "{") {
|
||||
/*
|
||||
* Warn if `\{` is not preceded by `$`. If preceded by `$`, escaping
|
||||
* is necessary and the rule should not warn. If preceded by `/$`, the rule
|
||||
* will warn for the `/$` instead, as it is the first unnecessarily escaped character.
|
||||
*/
|
||||
isUnnecessaryEscape = match.input[match.index - 1] !== "$";
|
||||
}
|
||||
} else {
|
||||
isQuoteEscape = escapedChar === node.raw[0];
|
||||
}
|
||||
|
||||
if (isUnnecessaryEscape && !isQuoteEscape) {
|
||||
report(node, match.index, match[0].slice(1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the escape character in given regexp is unnecessary.
|
||||
* @private
|
||||
* @param {ASTNode} node node to validate.
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateRegExp(node) {
|
||||
const { pattern, flags } = node.regex;
|
||||
let patternNode;
|
||||
const unicode = flags.includes("u");
|
||||
const unicodeSets = flags.includes("v");
|
||||
|
||||
try {
|
||||
patternNode = parser.parsePattern(pattern, 0, pattern.length, {
|
||||
unicode,
|
||||
unicodeSets,
|
||||
});
|
||||
} catch {
|
||||
// Ignore regular expressions with syntax errors
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {(CharacterClass | ExpressionCharacterClass)[]} */
|
||||
const characterClassStack = [];
|
||||
|
||||
visitRegExpAST(patternNode, {
|
||||
onCharacterClassEnter: characterClassNode =>
|
||||
characterClassStack.unshift(characterClassNode),
|
||||
onCharacterClassLeave: () => characterClassStack.shift(),
|
||||
onExpressionCharacterClassEnter: characterClassNode =>
|
||||
characterClassStack.unshift(characterClassNode),
|
||||
onExpressionCharacterClassLeave: () =>
|
||||
characterClassStack.shift(),
|
||||
onCharacterEnter(characterNode) {
|
||||
if (!characterNode.raw.startsWith("\\")) {
|
||||
// It's not an escaped character.
|
||||
return;
|
||||
}
|
||||
|
||||
const escapedChar = characterNode.raw.slice(1);
|
||||
|
||||
if (
|
||||
escapedChar !==
|
||||
String.fromCodePoint(characterNode.value)
|
||||
) {
|
||||
// It's a valid escape.
|
||||
return;
|
||||
}
|
||||
let allowedEscapes;
|
||||
|
||||
if (characterClassStack.length) {
|
||||
allowedEscapes = unicodeSets
|
||||
? REGEX_CLASSSET_CHARACTER_ESCAPES
|
||||
: REGEX_GENERAL_ESCAPES;
|
||||
} else {
|
||||
allowedEscapes = REGEX_NON_CHARCLASS_ESCAPES;
|
||||
}
|
||||
if (allowedEscapes.has(escapedChar)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const reportedIndex = characterNode.start + 1;
|
||||
let disableEscapeBackslashSuggest = false;
|
||||
|
||||
if (characterClassStack.length) {
|
||||
const characterClassNode = characterClassStack[0];
|
||||
|
||||
if (escapedChar === "^") {
|
||||
/*
|
||||
* The '^' character is also a special case; it must always be escaped outside of character classes, but
|
||||
* it only needs to be escaped in character classes if it's at the beginning of the character class. To
|
||||
* account for this, consider it to be a valid escape character outside of character classes, and filter
|
||||
* out '^' characters that appear at the start of a character class.
|
||||
*/
|
||||
if (
|
||||
characterClassNode.start + 1 ===
|
||||
characterNode.start
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!unicodeSets) {
|
||||
if (escapedChar === "-") {
|
||||
/*
|
||||
* The '-' character is a special case, because it's only valid to escape it if it's in a character
|
||||
* class, and is not at either edge of the character class. To account for this, don't consider '-'
|
||||
* characters to be valid in general, and filter out '-' characters that appear in the middle of a
|
||||
* character class.
|
||||
*/
|
||||
if (
|
||||
characterClassNode.start + 1 !==
|
||||
characterNode.start &&
|
||||
characterNode.end !==
|
||||
characterClassNode.end - 1
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// unicodeSets mode
|
||||
if (
|
||||
REGEX_CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR.has(
|
||||
escapedChar,
|
||||
)
|
||||
) {
|
||||
// Escaping is valid if it is a ClassSetReservedDoublePunctuator.
|
||||
if (
|
||||
pattern[characterNode.end] === escapedChar
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
pattern[characterNode.start - 1] ===
|
||||
escapedChar
|
||||
) {
|
||||
if (escapedChar !== "^") {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the previous character is a `negate` caret(`^`), escape to caret is unnecessary.
|
||||
|
||||
if (!characterClassNode.negate) {
|
||||
return;
|
||||
}
|
||||
const negateCaretIndex =
|
||||
characterClassNode.start + 1;
|
||||
|
||||
if (
|
||||
negateCaretIndex <
|
||||
characterNode.start - 1
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
characterNode.parent.type ===
|
||||
"ClassIntersection" ||
|
||||
characterNode.parent.type === "ClassSubtraction"
|
||||
) {
|
||||
disableEscapeBackslashSuggest = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
report(
|
||||
node,
|
||||
reportedIndex,
|
||||
escapedChar,
|
||||
disableEscapeBackslashSuggest,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a node has an escape.
|
||||
* @param {ASTNode} node node to check.
|
||||
* @returns {void}
|
||||
*/
|
||||
function check(node) {
|
||||
const isTemplateElement = node.type === "TemplateElement";
|
||||
|
||||
if (
|
||||
isTemplateElement &&
|
||||
node.parent &&
|
||||
node.parent.parent &&
|
||||
node.parent.parent.type === "TaggedTemplateExpression" &&
|
||||
node.parent === node.parent.parent.quasi
|
||||
) {
|
||||
// Don't report tagged template literals, because the backslash character is accessible to the tag function.
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof node.value === "string" || isTemplateElement) {
|
||||
/*
|
||||
* JSXAttribute doesn't have any escape sequence: https://facebook.github.io/jsx/.
|
||||
* In addition, backticks are not supported by JSX yet: https://github.com/facebook/jsx/issues/25.
|
||||
*/
|
||||
if (
|
||||
node.parent.type === "JSXAttribute" ||
|
||||
node.parent.type === "JSXElement" ||
|
||||
node.parent.type === "JSXFragment"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const value = isTemplateElement
|
||||
? sourceCode.getText(node)
|
||||
: node.raw;
|
||||
const pattern = /\\[^\d]/gu;
|
||||
let match;
|
||||
|
||||
while ((match = pattern.exec(value))) {
|
||||
validateString(node, match);
|
||||
}
|
||||
} else if (node.regex) {
|
||||
validateRegExp(node);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
Literal: check,
|
||||
TemplateElement: check,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={"0":"117","1":"20","2":"21","3":"22","4":"23","5":"24","6":"25","7":"26","8":"27","9":"118",A:"10",B:"11",C:"12",D:"7",E:"8",F:"9",G:"15",H:"80",I:"134",J:"4",K:"6",L:"13",M:"14",N:"16",O:"17",P:"18",Q:"79",R:"81",S:"83",T:"84",U:"85",V:"86",W:"87",X:"88",Y:"89",Z:"90",a:"91",b:"92",c:"93",d:"94",e:"95",f:"96",g:"97",h:"98",i:"99",j:"100",k:"101",l:"102",m:"103",n:"104",o:"105",p:"106",q:"107",r:"108",s:"109",t:"110",u:"111",v:"112",w:"113",x:"114",y:"115",z:"116",AB:"119",BB:"120",CB:"121",DB:"122",EB:"123",FB:"124",GB:"125",HB:"126",IB:"127",JB:"128",KB:"129",LB:"130",MB:"131",NB:"132",OB:"133",PB:"5",QB:"19",RB:"28",SB:"29",TB:"30",UB:"31",VB:"32",WB:"33",XB:"34",YB:"35",ZB:"36",aB:"37",bB:"38",cB:"39",dB:"40",eB:"41",fB:"42",gB:"43",hB:"44",iB:"45",jB:"46",kB:"47",lB:"48",mB:"49",nB:"50",oB:"51",pB:"52",qB:"53",rB:"54",sB:"55",tB:"56",uB:"57",vB:"58",wB:"60",xB:"62",yB:"63",zB:"64","0B":"65","1B":"66","2B":"67","3B":"68","4B":"69","5B":"70","6B":"71","7B":"72","8B":"73","9B":"74",AC:"75",BC:"76",CC:"77",DC:"78",EC:"136",FC:"11.1",GC:"12.1",HC:"15.5",IC:"16.0",JC:"17.0",KC:"18.0",LC:"3",MC:"59",NC:"61",OC:"82",PC:"135",QC:"137",RC:"138",SC:"3.2",TC:"10.1",UC:"15.2-15.3",VC:"15.4",WC:"16.1",XC:"16.2",YC:"16.3",ZC:"16.4",aC:"16.5",bC:"17.1",cC:"17.2",dC:"17.3",eC:"17.4",fC:"17.5",gC:"18.1",hC:"18.2",iC:"18.3",jC:"18.4",kC:"11.5",lC:"4.2-4.3",mC:"5.5",nC:"2",oC:"139",pC:"140",qC:"3.5",rC:"3.6",sC:"3.1",tC:"5.1",uC:"6.1",vC:"7.1",wC:"9.1",xC:"13.1",yC:"14.1",zC:"15.1","0C":"15.6","1C":"16.6","2C":"17.6","3C":"TP","4C":"9.5-9.6","5C":"10.0-10.1","6C":"10.5","7C":"10.6","8C":"11.6","9C":"4.0-4.1",AD:"5.0-5.1",BD:"6.0-6.1",CD:"7.0-7.1",DD:"8.1-8.4",ED:"9.0-9.2",FD:"9.3",GD:"10.0-10.2",HD:"10.3",ID:"11.0-11.2",JD:"11.3-11.4",KD:"12.0-12.1",LD:"12.2-12.5",MD:"13.0-13.1",ND:"13.2",OD:"13.3",PD:"13.4-13.7",QD:"14.0-14.4",RD:"14.5-14.8",SD:"15.0-15.1",TD:"15.6-15.8",UD:"16.6-16.7",VD:"17.6-17.7",WD:"all",XD:"2.1",YD:"2.2",ZD:"2.3",aD:"4.1",bD:"4.4",cD:"4.4.3-4.4.4",dD:"5.0-5.4",eD:"6.2-6.4",fD:"7.2-7.4",gD:"8.2",hD:"9.2",iD:"11.1-11.2",jD:"12.0",kD:"13.0",lD:"14.0",mD:"15.0",nD:"19.0",oD:"14.9",pD:"13.52",qD:"2.5",rD:"3.0-3.1"};
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
const shebangRegex = require('shebang-regex');
|
||||
|
||||
module.exports = (string = '') => {
|
||||
const match = string.match(shebangRegex);
|
||||
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const [path, argument] = match[0].replace(/#! ?/, '').split(' ');
|
||||
const binary = path.split('/').pop();
|
||||
|
||||
if (binary === 'env') {
|
||||
return argument;
|
||||
}
|
||||
|
||||
return argument ? `${binary} ${argument}` : binary;
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
const React = require("react");
|
||||
function _interopNamespaceDefault(e) {
|
||||
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
||||
if (e) {
|
||||
for (const k in e) {
|
||||
if (k !== "default") {
|
||||
const d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: () => e[k]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
n.default = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
||||
const routerContext = React__namespace.createContext(null);
|
||||
function getRouterContext() {
|
||||
if (typeof document === "undefined") {
|
||||
return routerContext;
|
||||
}
|
||||
if (window.__TSR_ROUTER_CONTEXT__) {
|
||||
return window.__TSR_ROUTER_CONTEXT__;
|
||||
}
|
||||
window.__TSR_ROUTER_CONTEXT__ = routerContext;
|
||||
return routerContext;
|
||||
}
|
||||
exports.getRouterContext = getRouterContext;
|
||||
//# sourceMappingURL=routerContext.cjs.map
|
||||
@@ -0,0 +1,44 @@
|
||||
import * as React from "./";
|
||||
export { Fragment } from "./";
|
||||
|
||||
export namespace JSX {
|
||||
interface Element extends React.JSX.Element {}
|
||||
interface ElementClass extends React.JSX.ElementClass {}
|
||||
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {}
|
||||
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {}
|
||||
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>;
|
||||
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {}
|
||||
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
||||
interface IntrinsicElements extends React.JSX.IntrinsicElements {}
|
||||
}
|
||||
|
||||
export interface JSXSource {
|
||||
/**
|
||||
* The source file where the element originates from.
|
||||
*/
|
||||
fileName?: string | undefined;
|
||||
|
||||
/**
|
||||
* The line number where the element was created.
|
||||
*/
|
||||
lineNumber?: number | undefined;
|
||||
|
||||
/**
|
||||
* The column number where the element was created.
|
||||
*/
|
||||
columnNumber?: number | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a React element.
|
||||
*
|
||||
* You should not use this function directly. Use JSX and a transpiler instead.
|
||||
*/
|
||||
export function jsxDEV(
|
||||
type: React.ElementType,
|
||||
props: unknown,
|
||||
key: React.Key | undefined,
|
||||
isStatic: boolean,
|
||||
source?: JSXSource,
|
||||
self?: unknown,
|
||||
): React.ReactElement;
|
||||
Reference in New Issue
Block a user