update
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"renderRouteNotFound.js","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as React from 'react'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n"],"names":[],"mappings":";;;AAKgB,SAAA,oBACd,QACA,OACA,MACA;AACI,MAAA,CAAC,MAAM,QAAQ,mBAAmB;AAChC,QAAA,OAAO,QAAQ,0BAA0B;AAC3C,aAAQ,oBAAA,OAAO,QAAQ,0BAAf,EAAwC,KAAY,CAAA;AAAA,IAAA;AAG1D,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C;AAAA,QACE,MAAM,QAAQ;AAAA,QACd,yDAAyD,MAAM,EAAE;AAAA,MACnE;AAAA,IAAA;AAGF,+BAAQ,uBAAsB,EAAA;AAAA,EAAA;AAGhC,SAAQ,oBAAA,MAAM,QAAQ,mBAAd,EAAgC,KAAY,CAAA;AACtD;"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getBindingIdentifiers;
|
||||
var _index = require("../validators/generated/index.js");
|
||||
function getBindingIdentifiers(node, duplicates, outerOnly, newBindingsOnly) {
|
||||
const search = [].concat(node);
|
||||
const ids = Object.create(null);
|
||||
while (search.length) {
|
||||
const id = search.shift();
|
||||
if (!id) continue;
|
||||
if (newBindingsOnly && ((0, _index.isAssignmentExpression)(id) || (0, _index.isUnaryExpression)(id) || (0, _index.isUpdateExpression)(id))) {
|
||||
continue;
|
||||
}
|
||||
if ((0, _index.isIdentifier)(id)) {
|
||||
if (duplicates) {
|
||||
const _ids = ids[id.name] = ids[id.name] || [];
|
||||
_ids.push(id);
|
||||
} else {
|
||||
ids[id.name] = id;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ((0, _index.isExportDeclaration)(id) && !(0, _index.isExportAllDeclaration)(id)) {
|
||||
if ((0, _index.isDeclaration)(id.declaration)) {
|
||||
search.push(id.declaration);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (outerOnly) {
|
||||
if ((0, _index.isFunctionDeclaration)(id)) {
|
||||
search.push(id.id);
|
||||
continue;
|
||||
}
|
||||
if ((0, _index.isFunctionExpression)(id)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const keys = getBindingIdentifiers.keys[id.type];
|
||||
if (keys) {
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const nodes = id[key];
|
||||
if (nodes) {
|
||||
if (Array.isArray(nodes)) {
|
||||
search.push(...nodes);
|
||||
} else {
|
||||
search.push(nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
const keys = {
|
||||
DeclareClass: ["id"],
|
||||
DeclareFunction: ["id"],
|
||||
DeclareModule: ["id"],
|
||||
DeclareVariable: ["id"],
|
||||
DeclareInterface: ["id"],
|
||||
DeclareTypeAlias: ["id"],
|
||||
DeclareOpaqueType: ["id"],
|
||||
InterfaceDeclaration: ["id"],
|
||||
TypeAlias: ["id"],
|
||||
OpaqueType: ["id"],
|
||||
CatchClause: ["param"],
|
||||
LabeledStatement: ["label"],
|
||||
UnaryExpression: ["argument"],
|
||||
AssignmentExpression: ["left"],
|
||||
ImportSpecifier: ["local"],
|
||||
ImportNamespaceSpecifier: ["local"],
|
||||
ImportDefaultSpecifier: ["local"],
|
||||
ImportDeclaration: ["specifiers"],
|
||||
TSImportEqualsDeclaration: ["id"],
|
||||
ExportSpecifier: ["exported"],
|
||||
ExportNamespaceSpecifier: ["exported"],
|
||||
ExportDefaultSpecifier: ["exported"],
|
||||
FunctionDeclaration: ["id", "params"],
|
||||
FunctionExpression: ["id", "params"],
|
||||
ArrowFunctionExpression: ["params"],
|
||||
ObjectMethod: ["params"],
|
||||
ClassMethod: ["params"],
|
||||
ClassPrivateMethod: ["params"],
|
||||
ForInStatement: ["left"],
|
||||
ForOfStatement: ["left"],
|
||||
ClassDeclaration: ["id"],
|
||||
ClassExpression: ["id"],
|
||||
RestElement: ["argument"],
|
||||
UpdateExpression: ["argument"],
|
||||
ObjectProperty: ["value"],
|
||||
AssignmentPattern: ["left"],
|
||||
ArrayPattern: ["elements"],
|
||||
ObjectPattern: ["properties"],
|
||||
VariableDeclaration: ["declarations"],
|
||||
VariableDeclarator: ["id"]
|
||||
};
|
||||
getBindingIdentifiers.keys = keys;
|
||||
|
||||
//# sourceMappingURL=getBindingIdentifiers.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"E F A B","2":"K D mC"},B:{"2":"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 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:{"2":"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:{"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":"F B C 4C 5C 6C 7C FC kC 8C GC","16":"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"},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:{"16":"WD"},I:{"2":"LC J I XD YD ZD aD lC bD cD"},J:{"16":"D A"},K:{"2":"H","16":"A B C FC kC GC"},L:{"16":"I"},M:{"16":"EC"},N:{"16":"A B"},O:{"16":"HC"},P:{"16":"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:{"2":"oD"},R:{"16":"pD"},S:{"1":"qD rD"}},B:1,C:"Alternate stylesheet",D:false};
|
||||
@@ -0,0 +1 @@
|
||||
export { SourceMapGenerator } from '..';
|
||||
@@ -0,0 +1,52 @@
|
||||
const eq = require('./eq')
|
||||
const neq = require('./neq')
|
||||
const gt = require('./gt')
|
||||
const gte = require('./gte')
|
||||
const lt = require('./lt')
|
||||
const lte = require('./lte')
|
||||
|
||||
const cmp = (a, op, b, loose) => {
|
||||
switch (op) {
|
||||
case '===':
|
||||
if (typeof a === 'object') {
|
||||
a = a.version
|
||||
}
|
||||
if (typeof b === 'object') {
|
||||
b = b.version
|
||||
}
|
||||
return a === b
|
||||
|
||||
case '!==':
|
||||
if (typeof a === 'object') {
|
||||
a = a.version
|
||||
}
|
||||
if (typeof b === 'object') {
|
||||
b = b.version
|
||||
}
|
||||
return a !== b
|
||||
|
||||
case '':
|
||||
case '=':
|
||||
case '==':
|
||||
return eq(a, b, loose)
|
||||
|
||||
case '!=':
|
||||
return neq(a, b, loose)
|
||||
|
||||
case '>':
|
||||
return gt(a, b, loose)
|
||||
|
||||
case '>=':
|
||||
return gte(a, b, loose)
|
||||
|
||||
case '<':
|
||||
return lt(a, b, loose)
|
||||
|
||||
case '<=':
|
||||
return lte(a, b, loose)
|
||||
|
||||
default:
|
||||
throw new TypeError(`Invalid operator: ${op}`)
|
||||
}
|
||||
}
|
||||
module.exports = cmp
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.0189877 13.6645L0.612989 10.4635C0.687989 10.0545 0.884989 9.6805 1.18099 9.3825L9.98199 0.5805C10.756 -0.1925 12.015 -0.1945 12.792 0.5805L14.42 2.2085C15.194 2.9835 15.194 4.2435 14.42 5.0185L5.61599 13.8215C5.31999 14.1165 4.94599 14.3125 4.53799 14.3875L1.33599 14.9815C1.26599 14.9935 1.19799 15.0005 1.12999 15.0005C0.832989 15.0005 0.544988 14.8835 0.330988 14.6695C0.0679874 14.4055 -0.0490122 14.0305 0.0189877 13.6645Z" fill="white"/>
|
||||
<path d="M0.0189877 13.6645L0.612989 10.4635C0.687989 10.0545 0.884989 9.6805 1.18099 9.3825L9.98199 0.5805C10.756 -0.1925 12.015 -0.1945 12.792 0.5805L14.42 2.2085C15.194 2.9835 15.194 4.2435 14.42 5.0185L5.61599 13.8215C5.31999 14.1165 4.94599 14.3125 4.53799 14.3875L1.33599 14.9815C1.26599 14.9935 1.19799 15.0005 1.12999 15.0005C0.832989 15.0005 0.544988 14.8835 0.330988 14.6695C0.0679874 14.4055 -0.0490122 14.0305 0.0189877 13.6645ZM12.472 5.1965L13.632 4.0365L13.631 3.1885L11.811 1.3675L10.963 1.3685L9.80299 2.5285L12.472 5.1965ZM4.31099 13.1585C4.47099 13.1285 4.61799 13.0515 4.73399 12.9345L11.587 6.0815L8.91899 3.4135L2.06599 10.2655C1.94899 10.3835 1.87199 10.5305 1.84099 10.6915L1.36699 13.2485L1.75199 13.6335L4.31099 13.1585Z" fill="black"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "flat-cache",
|
||||
"version": "4.0.1",
|
||||
"description": "A stupidly simple key/value storage using files to persist some data",
|
||||
"repository": "jaredwray/flat-cache",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Jared Wray",
|
||||
"url": "https://jaredwray.com"
|
||||
},
|
||||
"main": "src/cache.js",
|
||||
"files": [
|
||||
"src/cache.js",
|
||||
"src/del.js",
|
||||
"src/utils.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"precommit": [
|
||||
"npm run verify --silent"
|
||||
],
|
||||
"prepush": [
|
||||
"npm run verify --silent"
|
||||
],
|
||||
"scripts": {
|
||||
"eslint": "eslint --cache --cache-location=node_modules/.cache/ ./src/**/*.js ./test/**/*.js",
|
||||
"clean": "rimraf ./node_modules ./package-lock.json ./yarn.lock ./coverage",
|
||||
"eslint-fix": "npm run eslint -- --fix",
|
||||
"autofix": "npm run eslint-fix",
|
||||
"check": "npm run eslint",
|
||||
"verify": "npm run eslint && npm run test:cache",
|
||||
"test:cache": "c8 mocha -R spec test/specs",
|
||||
"test:ci:cache": "c8 --reporter=lcov mocha -R spec test/specs",
|
||||
"test": "npm run verify --silent",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"keywords": [
|
||||
"json cache",
|
||||
"simple cache",
|
||||
"file cache",
|
||||
"key par",
|
||||
"key value",
|
||||
"cache"
|
||||
],
|
||||
"devDependencies": {
|
||||
"c8": "^9.1.0",
|
||||
"chai": "^4.3.10",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-mocha": "^10.2.0",
|
||||
"glob-expand": "^0.2.1",
|
||||
"mocha": "^10.3.0",
|
||||
"prettier": "^3.2.4",
|
||||
"rimraf": "^5.0.5",
|
||||
"sinon": "^17.0.1",
|
||||
"write": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"flatted": "^3.2.9",
|
||||
"keyv": "^4.5.4"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
import { functionalUpdate } from './utils'
|
||||
import type { AnyRouter } from './router'
|
||||
import type { ParsedLocation } from './location'
|
||||
import type { NonNullableUpdater } from './utils'
|
||||
|
||||
export type ScrollRestorationEntry = { scrollX: number; scrollY: number }
|
||||
|
||||
export type ScrollRestorationByElement = Record<string, ScrollRestorationEntry>
|
||||
|
||||
export type ScrollRestorationByKey = Record<string, ScrollRestorationByElement>
|
||||
|
||||
export type ScrollRestorationCache = {
|
||||
state: ScrollRestorationByKey
|
||||
set: (updater: NonNullableUpdater<ScrollRestorationByKey>) => void
|
||||
}
|
||||
export type ScrollRestorationOptions = {
|
||||
getKey?: (location: ParsedLocation) => string
|
||||
scrollBehavior?: ScrollToOptions['behavior']
|
||||
}
|
||||
|
||||
export const storageKey = 'tsr-scroll-restoration-v1_3'
|
||||
let sessionsStorage = false
|
||||
try {
|
||||
sessionsStorage =
|
||||
typeof window !== 'undefined' && typeof window.sessionStorage === 'object'
|
||||
} catch {}
|
||||
const throttle = (fn: (...args: Array<any>) => void, wait: number) => {
|
||||
let timeout: any
|
||||
return (...args: Array<any>) => {
|
||||
if (!timeout) {
|
||||
timeout = setTimeout(() => {
|
||||
fn(...args)
|
||||
timeout = null
|
||||
}, wait)
|
||||
}
|
||||
}
|
||||
}
|
||||
export const scrollRestorationCache: ScrollRestorationCache = sessionsStorage
|
||||
? (() => {
|
||||
const state: ScrollRestorationByKey =
|
||||
JSON.parse(window.sessionStorage.getItem(storageKey) || 'null') || {}
|
||||
|
||||
return {
|
||||
state,
|
||||
// This setter is simply to make sure that we set the sessionStorage right
|
||||
// after the state is updated. It doesn't necessarily need to be a functional
|
||||
// update.
|
||||
set: (updater) => (
|
||||
(scrollRestorationCache.state =
|
||||
functionalUpdate(updater, scrollRestorationCache.state) ||
|
||||
scrollRestorationCache.state),
|
||||
window.sessionStorage.setItem(
|
||||
storageKey,
|
||||
JSON.stringify(scrollRestorationCache.state),
|
||||
)
|
||||
),
|
||||
}
|
||||
})()
|
||||
: (undefined as any)
|
||||
/**
|
||||
* The default `getKey` function for `useScrollRestoration`.
|
||||
* It returns the `key` from the location state or the `href` of the location.
|
||||
*
|
||||
* The `location.href` is used as a fallback to support the use case where the location state is not available like the initial render.
|
||||
*/
|
||||
|
||||
export const defaultGetScrollRestorationKey = (location: ParsedLocation) => {
|
||||
return location.state.key! || location.href
|
||||
}
|
||||
|
||||
export function getCssSelector(el: any): string {
|
||||
const path = []
|
||||
let parent
|
||||
while ((parent = el.parentNode)) {
|
||||
path.unshift(
|
||||
`${el.tagName}:nth-child(${([].indexOf as any).call(parent.children, el) + 1})`,
|
||||
)
|
||||
el = parent
|
||||
}
|
||||
return `${path.join(' > ')}`.toLowerCase()
|
||||
}
|
||||
|
||||
let ignoreScroll = false
|
||||
|
||||
// NOTE: This function must remain pure and not use any outside variables
|
||||
// unless they are passed in as arguments. Why? Because we need to be able to
|
||||
// toString() it into a script tag to execute as early as possible in the browser
|
||||
// during SSR. Additionally, we also call it from within the router lifecycle
|
||||
export function restoreScroll(
|
||||
storageKey: string,
|
||||
key: string | undefined,
|
||||
behavior: ScrollToOptions['behavior'] | undefined,
|
||||
shouldScrollRestoration: boolean | undefined,
|
||||
scrollToTopSelectors: Array<string> | undefined,
|
||||
) {
|
||||
let byKey: ScrollRestorationByKey
|
||||
|
||||
try {
|
||||
byKey = JSON.parse(sessionStorage.getItem(storageKey) || '{}')
|
||||
} catch (error: any) {
|
||||
console.error(error)
|
||||
return
|
||||
}
|
||||
|
||||
const resolvedKey = key || window.history.state?.key
|
||||
const elementEntries = byKey[resolvedKey]
|
||||
|
||||
//
|
||||
ignoreScroll = true
|
||||
|
||||
//
|
||||
;(() => {
|
||||
// If we have a cached entry for this location state,
|
||||
// we always need to prefer that over the hash scroll.
|
||||
if (shouldScrollRestoration && elementEntries) {
|
||||
for (const elementSelector in elementEntries) {
|
||||
const entry = elementEntries[elementSelector]!
|
||||
if (elementSelector === 'window') {
|
||||
window.scrollTo({
|
||||
top: entry.scrollY,
|
||||
left: entry.scrollX,
|
||||
behavior,
|
||||
})
|
||||
} else if (elementSelector) {
|
||||
const element = document.querySelector(elementSelector)
|
||||
if (element) {
|
||||
element.scrollLeft = entry.scrollX
|
||||
element.scrollTop = entry.scrollY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// If we don't have a cached entry for the hash,
|
||||
// Which means we've never seen this location before,
|
||||
// we need to check if there is a hash in the URL.
|
||||
// If there is, we need to scroll it's ID into view.
|
||||
const hash = window.location.hash.split('#')[1]
|
||||
|
||||
if (hash) {
|
||||
const hashScrollIntoViewOptions =
|
||||
(window.history.state || {}).__hashScrollIntoViewOptions ?? true
|
||||
|
||||
if (hashScrollIntoViewOptions) {
|
||||
const el = document.getElementById(hash)
|
||||
if (el) {
|
||||
el.scrollIntoView(hashScrollIntoViewOptions)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// If there is no cached entry for the hash and there is no hash in the URL,
|
||||
// we need to scroll to the top of the page for every scrollToTop element
|
||||
;[
|
||||
'window',
|
||||
...(scrollToTopSelectors?.filter((d) => d !== 'window') ?? []),
|
||||
].forEach((selector) => {
|
||||
const element =
|
||||
selector === 'window' ? window : document.querySelector(selector)
|
||||
if (element) {
|
||||
element.scrollTo({
|
||||
top: 0,
|
||||
left: 0,
|
||||
behavior,
|
||||
})
|
||||
}
|
||||
})
|
||||
})()
|
||||
|
||||
//
|
||||
ignoreScroll = false
|
||||
}
|
||||
|
||||
export function setupScrollRestoration(router: AnyRouter, force?: boolean) {
|
||||
const shouldScrollRestoration =
|
||||
force ?? router.options.scrollRestoration ?? false
|
||||
|
||||
if (shouldScrollRestoration) {
|
||||
router.isScrollRestoring = true
|
||||
}
|
||||
|
||||
if (typeof document === 'undefined' || router.isScrollRestorationSetup) {
|
||||
return
|
||||
}
|
||||
|
||||
router.isScrollRestorationSetup = true
|
||||
|
||||
//
|
||||
ignoreScroll = false
|
||||
|
||||
const getKey =
|
||||
router.options.getScrollRestorationKey || defaultGetScrollRestorationKey
|
||||
|
||||
window.history.scrollRestoration = 'manual'
|
||||
|
||||
// // Create a MutationObserver to monitor DOM changes
|
||||
// const mutationObserver = new MutationObserver(() => {
|
||||
// ;ignoreScroll = true
|
||||
// requestAnimationFrame(() => {
|
||||
// ;ignoreScroll = false
|
||||
|
||||
// // Attempt to restore scroll position on each dom
|
||||
// // mutation until the user scrolls. We do this
|
||||
// // because dynamic content may come in at different
|
||||
// // ticks after the initial render and we want to
|
||||
// // keep up with that content as much as possible.
|
||||
// // As soon as the user scrolls, we no longer need
|
||||
// // to attempt router.
|
||||
// // console.log('mutation observer restoreScroll')
|
||||
// restoreScroll(
|
||||
// storageKey,
|
||||
// getKey(router.state.location),
|
||||
// router.options.scrollRestorationBehavior,
|
||||
// )
|
||||
// })
|
||||
// })
|
||||
|
||||
// const observeDom = () => {
|
||||
// // Observe changes to the entire document
|
||||
// mutationObserver.observe(document, {
|
||||
// childList: true, // Detect added or removed child nodes
|
||||
// subtree: true, // Monitor all descendants
|
||||
// characterData: true, // Detect text content changes
|
||||
// })
|
||||
// }
|
||||
|
||||
// const unobserveDom = () => {
|
||||
// mutationObserver.disconnect()
|
||||
// }
|
||||
|
||||
// observeDom()
|
||||
|
||||
const onScroll = (event: Event) => {
|
||||
// unobserveDom()
|
||||
|
||||
if (ignoreScroll || !router.isScrollRestoring) {
|
||||
return
|
||||
}
|
||||
|
||||
let elementSelector = ''
|
||||
|
||||
if (event.target === document || event.target === window) {
|
||||
elementSelector = 'window'
|
||||
} else {
|
||||
const attrId = (event.target as Element).getAttribute(
|
||||
'data-scroll-restoration-id',
|
||||
)
|
||||
|
||||
if (attrId) {
|
||||
elementSelector = `[data-scroll-restoration-id="${attrId}"]`
|
||||
} else {
|
||||
elementSelector = getCssSelector(event.target)
|
||||
}
|
||||
}
|
||||
|
||||
const restoreKey = getKey(router.state.location)
|
||||
|
||||
scrollRestorationCache.set((state) => {
|
||||
const keyEntry = (state[restoreKey] =
|
||||
state[restoreKey] || ({} as ScrollRestorationByElement))
|
||||
|
||||
const elementEntry = (keyEntry[elementSelector] =
|
||||
keyEntry[elementSelector] || ({} as ScrollRestorationEntry))
|
||||
|
||||
if (elementSelector === 'window') {
|
||||
elementEntry.scrollX = window.scrollX || 0
|
||||
elementEntry.scrollY = window.scrollY || 0
|
||||
} else if (elementSelector) {
|
||||
const element = document.querySelector(elementSelector)
|
||||
if (element) {
|
||||
elementEntry.scrollX = element.scrollLeft || 0
|
||||
elementEntry.scrollY = element.scrollTop || 0
|
||||
}
|
||||
}
|
||||
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
// Throttle the scroll event to avoid excessive updates
|
||||
if (typeof document !== 'undefined') {
|
||||
document.addEventListener('scroll', throttle(onScroll, 100), true)
|
||||
}
|
||||
|
||||
router.subscribe('onRendered', (event) => {
|
||||
// unobserveDom()
|
||||
|
||||
const cacheKey = getKey(event.toLocation)
|
||||
|
||||
// If the user doesn't want to restore the scroll position,
|
||||
// we don't need to do anything.
|
||||
if (!router.resetNextScroll) {
|
||||
router.resetNextScroll = true
|
||||
return
|
||||
}
|
||||
|
||||
restoreScroll(
|
||||
storageKey,
|
||||
cacheKey,
|
||||
router.options.scrollRestorationBehavior || undefined,
|
||||
router.isScrollRestoring || undefined,
|
||||
router.options.scrollToTopSelectors || undefined,
|
||||
)
|
||||
|
||||
if (router.isScrollRestoring) {
|
||||
// Mark the location as having been seen
|
||||
scrollRestorationCache.set((state) => {
|
||||
state[cacheKey] = state[cacheKey] || ({} as ScrollRestorationByElement)
|
||||
|
||||
return state
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Handles hash-based scrolling after navigation completes.
|
||||
* To be used in framework-specific <Transitioner> components during the onResolved event.
|
||||
*
|
||||
* Provides hash scrolling for programmatic navigation when default browser handling is prevented.
|
||||
* @param router The router instance containing current location and state
|
||||
*/
|
||||
export function handleHashScroll(router: AnyRouter) {
|
||||
if (typeof document !== 'undefined' && (document as any).querySelector) {
|
||||
const hashScrollIntoViewOptions =
|
||||
router.state.location.state.__hashScrollIntoViewOptions ?? true
|
||||
|
||||
if (hashScrollIntoViewOptions && router.state.location.hash !== '') {
|
||||
const el = document.getElementById(router.state.location.hash)
|
||||
if (el) {
|
||||
el.scrollIntoView(hashScrollIntoViewOptions)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* @fileoverview Rule to enforce that all class methods use 'this'.
|
||||
* @author Patrick Williams
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
dialects: ["javascript", "typescript"],
|
||||
language: "javascript",
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: [
|
||||
{
|
||||
enforceForClassFields: true,
|
||||
exceptMethods: [],
|
||||
},
|
||||
],
|
||||
|
||||
docs: {
|
||||
description: "Enforce that class methods utilize `this`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/class-methods-use-this",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
exceptMethods: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
enforceForClassFields: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
missingThis: "Expected 'this' to be used by class {{name}}.",
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const [options] = context.options;
|
||||
const { enforceForClassFields } = options;
|
||||
const exceptMethods = new Set(options.exceptMethods);
|
||||
|
||||
const stack = [];
|
||||
|
||||
/**
|
||||
* Push `this` used flag initialized with `false` onto the stack.
|
||||
* @returns {void}
|
||||
*/
|
||||
function pushContext() {
|
||||
stack.push(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop `this` used flag from the stack.
|
||||
* @returns {boolean | undefined} `this` used flag
|
||||
*/
|
||||
function popContext() {
|
||||
return stack.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the current context to false and pushes it onto the stack.
|
||||
* These booleans represent whether 'this' has been used in the context.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function enterFunction() {
|
||||
pushContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the node is an instance method
|
||||
* @param {ASTNode} node node to check
|
||||
* @returns {boolean} True if its an instance method
|
||||
* @private
|
||||
*/
|
||||
function isInstanceMethod(node) {
|
||||
switch (node.type) {
|
||||
case "MethodDefinition":
|
||||
return !node.static && node.kind !== "constructor";
|
||||
case "PropertyDefinition":
|
||||
return !node.static && enforceForClassFields;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the node is an instance method not excluded by config
|
||||
* @param {ASTNode} node node to check
|
||||
* @returns {boolean} True if it is an instance method, and not excluded by config
|
||||
* @private
|
||||
*/
|
||||
function isIncludedInstanceMethod(node) {
|
||||
if (isInstanceMethod(node)) {
|
||||
if (node.computed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const hashIfNeeded =
|
||||
node.key.type === "PrivateIdentifier" ? "#" : "";
|
||||
const name =
|
||||
node.key.type === "Literal"
|
||||
? astUtils.getStaticStringValue(node.key)
|
||||
: node.key.name || "";
|
||||
|
||||
return !exceptMethods.has(hashIfNeeded + name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if we are leaving a function that is a method, and reports if 'this' has not been used.
|
||||
* Static methods and the constructor are exempt.
|
||||
* Then pops the context off the stack.
|
||||
* @param {ASTNode} node A function node that was entered.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function exitFunction(node) {
|
||||
const methodUsesThis = popContext();
|
||||
|
||||
if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
|
||||
context.report({
|
||||
node,
|
||||
loc: astUtils.getFunctionHeadLoc(node, context.sourceCode),
|
||||
messageId: "missingThis",
|
||||
data: {
|
||||
name: astUtils.getFunctionNameWithKind(node),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the current context as having used 'this'.
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function markThisUsed() {
|
||||
if (stack.length) {
|
||||
stack[stack.length - 1] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
FunctionDeclaration: enterFunction,
|
||||
"FunctionDeclaration:exit": exitFunction,
|
||||
FunctionExpression: enterFunction,
|
||||
"FunctionExpression:exit": exitFunction,
|
||||
|
||||
/*
|
||||
* Class field value are implicit functions.
|
||||
*/
|
||||
"PropertyDefinition > *.key:exit": pushContext,
|
||||
"PropertyDefinition:exit": popContext,
|
||||
|
||||
/*
|
||||
* Class static blocks are implicit functions. They aren't required to use `this`,
|
||||
* but we have to push context so that it captures any use of `this` in the static block
|
||||
* separately from enclosing contexts, because static blocks have their own `this` and it
|
||||
* shouldn't count as used `this` in enclosing contexts.
|
||||
*/
|
||||
StaticBlock: pushContext,
|
||||
"StaticBlock:exit": popContext,
|
||||
|
||||
ThisExpression: markThisUsed,
|
||||
Super: markThisUsed,
|
||||
...(enforceForClassFields && {
|
||||
"PropertyDefinition > ArrowFunctionExpression.value":
|
||||
enterFunction,
|
||||
"PropertyDefinition > ArrowFunctionExpression.value:exit":
|
||||
exitFunction,
|
||||
}),
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,291 @@
|
||||
var path = require('path');
|
||||
var crypto = require('crypto');
|
||||
|
||||
module.exports = {
|
||||
createFromFile: function (filePath, useChecksum) {
|
||||
var fname = path.basename(filePath);
|
||||
var dir = path.dirname(filePath);
|
||||
return this.create(fname, dir, useChecksum);
|
||||
},
|
||||
|
||||
create: function (cacheId, _path, useChecksum) {
|
||||
var fs = require('fs');
|
||||
var flatCache = require('flat-cache');
|
||||
var cache = flatCache.load(cacheId, _path);
|
||||
var normalizedEntries = {};
|
||||
|
||||
var removeNotFoundFiles = function removeNotFoundFiles() {
|
||||
const cachedEntries = cache.keys();
|
||||
// remove not found entries
|
||||
cachedEntries.forEach(function remover(fPath) {
|
||||
try {
|
||||
fs.statSync(fPath);
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
cache.removeKey(fPath);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
removeNotFoundFiles();
|
||||
|
||||
return {
|
||||
/**
|
||||
* the flat cache storage used to persist the metadata of the `files
|
||||
* @type {Object}
|
||||
*/
|
||||
cache: cache,
|
||||
|
||||
/**
|
||||
* Given a buffer, calculate md5 hash of its content.
|
||||
* @method getHash
|
||||
* @param {Buffer} buffer buffer to calculate hash on
|
||||
* @return {String} content hash digest
|
||||
*/
|
||||
getHash: function (buffer) {
|
||||
return crypto.createHash('md5').update(buffer).digest('hex');
|
||||
},
|
||||
|
||||
/**
|
||||
* Return whether or not a file has changed since last time reconcile was called.
|
||||
* @method hasFileChanged
|
||||
* @param {String} file the filepath to check
|
||||
* @return {Boolean} wheter or not the file has changed
|
||||
*/
|
||||
hasFileChanged: function (file) {
|
||||
return this.getFileDescriptor(file).changed;
|
||||
},
|
||||
|
||||
/**
|
||||
* given an array of file paths it return and object with three arrays:
|
||||
* - changedFiles: Files that changed since previous run
|
||||
* - notChangedFiles: Files that haven't change
|
||||
* - notFoundFiles: Files that were not found, probably deleted
|
||||
*
|
||||
* @param {Array} files the files to analyze and compare to the previous seen files
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
analyzeFiles: function (files) {
|
||||
var me = this;
|
||||
files = files || [];
|
||||
|
||||
var res = {
|
||||
changedFiles: [],
|
||||
notFoundFiles: [],
|
||||
notChangedFiles: [],
|
||||
};
|
||||
|
||||
me.normalizeEntries(files).forEach(function (entry) {
|
||||
if (entry.changed) {
|
||||
res.changedFiles.push(entry.key);
|
||||
return;
|
||||
}
|
||||
if (entry.notFound) {
|
||||
res.notFoundFiles.push(entry.key);
|
||||
return;
|
||||
}
|
||||
res.notChangedFiles.push(entry.key);
|
||||
});
|
||||
return res;
|
||||
},
|
||||
|
||||
getFileDescriptor: function (file) {
|
||||
var fstat;
|
||||
|
||||
try {
|
||||
fstat = fs.statSync(file);
|
||||
} catch (ex) {
|
||||
this.removeEntry(file);
|
||||
return { key: file, notFound: true, err: ex };
|
||||
}
|
||||
|
||||
if (useChecksum) {
|
||||
return this._getFileDescriptorUsingChecksum(file);
|
||||
}
|
||||
|
||||
return this._getFileDescriptorUsingMtimeAndSize(file, fstat);
|
||||
},
|
||||
|
||||
_getFileDescriptorUsingMtimeAndSize: function (file, fstat) {
|
||||
var meta = cache.getKey(file);
|
||||
var cacheExists = !!meta;
|
||||
|
||||
var cSize = fstat.size;
|
||||
var cTime = fstat.mtime.getTime();
|
||||
|
||||
var isDifferentDate;
|
||||
var isDifferentSize;
|
||||
|
||||
if (!meta) {
|
||||
meta = { size: cSize, mtime: cTime };
|
||||
} else {
|
||||
isDifferentDate = cTime !== meta.mtime;
|
||||
isDifferentSize = cSize !== meta.size;
|
||||
}
|
||||
|
||||
var nEntry = (normalizedEntries[file] = {
|
||||
key: file,
|
||||
changed: !cacheExists || isDifferentDate || isDifferentSize,
|
||||
meta: meta,
|
||||
});
|
||||
|
||||
return nEntry;
|
||||
},
|
||||
|
||||
_getFileDescriptorUsingChecksum: function (file) {
|
||||
var meta = cache.getKey(file);
|
||||
var cacheExists = !!meta;
|
||||
|
||||
var contentBuffer;
|
||||
try {
|
||||
contentBuffer = fs.readFileSync(file);
|
||||
} catch (ex) {
|
||||
contentBuffer = '';
|
||||
}
|
||||
|
||||
var isDifferent = true;
|
||||
var hash = this.getHash(contentBuffer);
|
||||
|
||||
if (!meta) {
|
||||
meta = { hash: hash };
|
||||
} else {
|
||||
isDifferent = hash !== meta.hash;
|
||||
}
|
||||
|
||||
var nEntry = (normalizedEntries[file] = {
|
||||
key: file,
|
||||
changed: !cacheExists || isDifferent,
|
||||
meta: meta,
|
||||
});
|
||||
|
||||
return nEntry;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the list o the files that changed compared
|
||||
* against the ones stored in the cache
|
||||
*
|
||||
* @method getUpdated
|
||||
* @param files {Array} the array of files to compare against the ones in the cache
|
||||
* @returns {Array}
|
||||
*/
|
||||
getUpdatedFiles: function (files) {
|
||||
var me = this;
|
||||
files = files || [];
|
||||
|
||||
return me
|
||||
.normalizeEntries(files)
|
||||
.filter(function (entry) {
|
||||
return entry.changed;
|
||||
})
|
||||
.map(function (entry) {
|
||||
return entry.key;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* return the list of files
|
||||
* @method normalizeEntries
|
||||
* @param files
|
||||
* @returns {*}
|
||||
*/
|
||||
normalizeEntries: function (files) {
|
||||
files = files || [];
|
||||
|
||||
var me = this;
|
||||
var nEntries = files.map(function (file) {
|
||||
return me.getFileDescriptor(file);
|
||||
});
|
||||
|
||||
//normalizeEntries = nEntries;
|
||||
return nEntries;
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove an entry from the file-entry-cache. Useful to force the file to still be considered
|
||||
* modified the next time the process is run
|
||||
*
|
||||
* @method removeEntry
|
||||
* @param entryName
|
||||
*/
|
||||
removeEntry: function (entryName) {
|
||||
delete normalizedEntries[entryName];
|
||||
cache.removeKey(entryName);
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete the cache file from the disk
|
||||
* @method deleteCacheFile
|
||||
*/
|
||||
deleteCacheFile: function () {
|
||||
cache.removeCacheFile();
|
||||
},
|
||||
|
||||
/**
|
||||
* remove the cache from the file and clear the memory cache
|
||||
*/
|
||||
destroy: function () {
|
||||
normalizedEntries = {};
|
||||
cache.destroy();
|
||||
},
|
||||
|
||||
_getMetaForFileUsingCheckSum: function (cacheEntry) {
|
||||
var contentBuffer = fs.readFileSync(cacheEntry.key);
|
||||
var hash = this.getHash(contentBuffer);
|
||||
var meta = Object.assign(cacheEntry.meta, { hash: hash });
|
||||
delete meta.size;
|
||||
delete meta.mtime;
|
||||
return meta;
|
||||
},
|
||||
|
||||
_getMetaForFileUsingMtimeAndSize: function (cacheEntry) {
|
||||
var stat = fs.statSync(cacheEntry.key);
|
||||
var meta = Object.assign(cacheEntry.meta, {
|
||||
size: stat.size,
|
||||
mtime: stat.mtime.getTime(),
|
||||
});
|
||||
delete meta.hash;
|
||||
return meta;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sync the files and persist them to the cache
|
||||
* @method reconcile
|
||||
*/
|
||||
reconcile: function (noPrune) {
|
||||
removeNotFoundFiles();
|
||||
|
||||
noPrune = typeof noPrune === 'undefined' ? true : noPrune;
|
||||
|
||||
var entries = normalizedEntries;
|
||||
var keys = Object.keys(entries);
|
||||
|
||||
if (keys.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var me = this;
|
||||
|
||||
keys.forEach(function (entryName) {
|
||||
var cacheEntry = entries[entryName];
|
||||
|
||||
try {
|
||||
var meta = useChecksum
|
||||
? me._getMetaForFileUsingCheckSum(cacheEntry)
|
||||
: me._getMetaForFileUsingMtimeAndSize(cacheEntry);
|
||||
cache.setKey(entryName, meta);
|
||||
} catch (err) {
|
||||
// if the file does not exists we don't save it
|
||||
// other errors are just thrown
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cache.save(noPrune);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,224 @@
|
||||
"use strict";
|
||||
|
||||
var defaultParseOptions = {
|
||||
decodeValues: true,
|
||||
map: false,
|
||||
silent: false,
|
||||
};
|
||||
|
||||
function isNonEmptyString(str) {
|
||||
return typeof str === "string" && !!str.trim();
|
||||
}
|
||||
|
||||
function parseString(setCookieValue, options) {
|
||||
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
||||
|
||||
var nameValuePairStr = parts.shift();
|
||||
var parsed = parseNameValuePair(nameValuePairStr);
|
||||
var name = parsed.name;
|
||||
var value = parsed.value;
|
||||
|
||||
options = options
|
||||
? Object.assign({}, defaultParseOptions, options)
|
||||
: defaultParseOptions;
|
||||
|
||||
try {
|
||||
value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
|
||||
} catch (e) {
|
||||
console.error(
|
||||
"set-cookie-parser encountered an error while decoding a cookie with value '" +
|
||||
value +
|
||||
"'. Set options.decodeValues to false to disable this feature.",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
var cookie = {
|
||||
name: name,
|
||||
value: value,
|
||||
};
|
||||
|
||||
parts.forEach(function (part) {
|
||||
var sides = part.split("=");
|
||||
var key = sides.shift().trimLeft().toLowerCase();
|
||||
var value = sides.join("=");
|
||||
if (key === "expires") {
|
||||
cookie.expires = new Date(value);
|
||||
} else if (key === "max-age") {
|
||||
cookie.maxAge = parseInt(value, 10);
|
||||
} else if (key === "secure") {
|
||||
cookie.secure = true;
|
||||
} else if (key === "httponly") {
|
||||
cookie.httpOnly = true;
|
||||
} else if (key === "samesite") {
|
||||
cookie.sameSite = value;
|
||||
} else if (key === "partitioned") {
|
||||
cookie.partitioned = true;
|
||||
} else {
|
||||
cookie[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
function parseNameValuePair(nameValuePairStr) {
|
||||
// Parses name-value-pair according to rfc6265bis draft
|
||||
|
||||
var name = "";
|
||||
var value = "";
|
||||
var nameValueArr = nameValuePairStr.split("=");
|
||||
if (nameValueArr.length > 1) {
|
||||
name = nameValueArr.shift();
|
||||
value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
|
||||
} else {
|
||||
value = nameValuePairStr;
|
||||
}
|
||||
|
||||
return { name: name, value: value };
|
||||
}
|
||||
|
||||
function parse(input, options) {
|
||||
options = options
|
||||
? Object.assign({}, defaultParseOptions, options)
|
||||
: defaultParseOptions;
|
||||
|
||||
if (!input) {
|
||||
if (!options.map) {
|
||||
return [];
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (input.headers) {
|
||||
if (typeof input.headers.getSetCookie === "function") {
|
||||
// for fetch responses - they combine headers of the same type in the headers array,
|
||||
// but getSetCookie returns an uncombined array
|
||||
input = input.headers.getSetCookie();
|
||||
} else if (input.headers["set-cookie"]) {
|
||||
// fast-path for node.js (which automatically normalizes header names to lower-case
|
||||
input = input.headers["set-cookie"];
|
||||
} else {
|
||||
// slow-path for other environments - see #25
|
||||
var sch =
|
||||
input.headers[
|
||||
Object.keys(input.headers).find(function (key) {
|
||||
return key.toLowerCase() === "set-cookie";
|
||||
})
|
||||
];
|
||||
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
||||
if (!sch && input.headers.cookie && !options.silent) {
|
||||
console.warn(
|
||||
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
||||
);
|
||||
}
|
||||
input = sch;
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(input)) {
|
||||
input = [input];
|
||||
}
|
||||
|
||||
if (!options.map) {
|
||||
return input.filter(isNonEmptyString).map(function (str) {
|
||||
return parseString(str, options);
|
||||
});
|
||||
} else {
|
||||
var cookies = {};
|
||||
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
|
||||
var cookie = parseString(str, options);
|
||||
cookies[cookie.name] = cookie;
|
||||
return cookies;
|
||||
}, cookies);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
||||
that are within a single set-cookie field-value, such as in the Expires portion.
|
||||
|
||||
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
||||
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
||||
React Native's fetch does this for *every* header, including set-cookie.
|
||||
|
||||
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
||||
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
||||
*/
|
||||
function splitCookiesString(cookiesString) {
|
||||
if (Array.isArray(cookiesString)) {
|
||||
return cookiesString;
|
||||
}
|
||||
if (typeof cookiesString !== "string") {
|
||||
return [];
|
||||
}
|
||||
|
||||
var cookiesStrings = [];
|
||||
var pos = 0;
|
||||
var start;
|
||||
var ch;
|
||||
var lastComma;
|
||||
var nextStart;
|
||||
var cookiesSeparatorFound;
|
||||
|
||||
function skipWhitespace() {
|
||||
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
||||
pos += 1;
|
||||
}
|
||||
return pos < cookiesString.length;
|
||||
}
|
||||
|
||||
function notSpecialChar() {
|
||||
ch = cookiesString.charAt(pos);
|
||||
|
||||
return ch !== "=" && ch !== ";" && ch !== ",";
|
||||
}
|
||||
|
||||
while (pos < cookiesString.length) {
|
||||
start = pos;
|
||||
cookiesSeparatorFound = false;
|
||||
|
||||
while (skipWhitespace()) {
|
||||
ch = cookiesString.charAt(pos);
|
||||
if (ch === ",") {
|
||||
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
||||
lastComma = pos;
|
||||
pos += 1;
|
||||
|
||||
skipWhitespace();
|
||||
nextStart = pos;
|
||||
|
||||
while (pos < cookiesString.length && notSpecialChar()) {
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
// currently special character
|
||||
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
||||
// we found cookies separator
|
||||
cookiesSeparatorFound = true;
|
||||
// pos is inside the next cookie, so back up and return it.
|
||||
pos = nextStart;
|
||||
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
||||
start = pos;
|
||||
} else {
|
||||
// in param ',' or param separator ';',
|
||||
// we continue from that comma
|
||||
pos = lastComma + 1;
|
||||
}
|
||||
} else {
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
||||
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
||||
}
|
||||
}
|
||||
|
||||
return cookiesStrings;
|
||||
}
|
||||
|
||||
module.exports = parse;
|
||||
module.exports.parse = parse;
|
||||
module.exports.parseString = parseString;
|
||||
module.exports.splitCookiesString = splitCookiesString;
|
||||
@@ -0,0 +1,16 @@
|
||||
type GeneratedColumn = number;
|
||||
type SourcesIndex = number;
|
||||
type SourceLine = number;
|
||||
type SourceColumn = number;
|
||||
type NamesIndex = number;
|
||||
type GeneratedLine = number;
|
||||
export type SourceMapSegment = [GeneratedColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn] | [GeneratedColumn, SourcesIndex, SourceLine, SourceColumn, NamesIndex];
|
||||
export type ReverseSegment = [SourceColumn, GeneratedLine, GeneratedColumn];
|
||||
export declare const COLUMN = 0;
|
||||
export declare const SOURCES_INDEX = 1;
|
||||
export declare const SOURCE_LINE = 2;
|
||||
export declare const SOURCE_COLUMN = 3;
|
||||
export declare const NAMES_INDEX = 4;
|
||||
export declare const REV_GENERATED_LINE = 1;
|
||||
export declare const REV_GENERATED_COLUMN = 2;
|
||||
export {};
|
||||
@@ -0,0 +1,109 @@
|
||||
import { AnyRoute, StaticDataRouteOption } from './route.js';
|
||||
import { AllContext, AllLoaderData, AllParams, FullSearchSchema, ParseRoute, RouteById, RouteIds } from './routeInfo.js';
|
||||
import { AnyRouter, RegisteredRouter } from './router.js';
|
||||
import { Constrain, ControlledPromise } from './utils.js';
|
||||
export type AnyMatchAndValue = {
|
||||
match: any;
|
||||
value: any;
|
||||
};
|
||||
export type FindValueByIndex<TKey, TValue extends ReadonlyArray<any>> = TKey extends `${infer TIndex extends number}` ? TValue[TIndex] : never;
|
||||
export type FindValueByKey<TKey, TValue> = TValue extends ReadonlyArray<any> ? FindValueByIndex<TKey, TValue> : TValue[TKey & keyof TValue];
|
||||
export type CreateMatchAndValue<TMatch, TValue> = TValue extends any ? {
|
||||
match: TMatch;
|
||||
value: TValue;
|
||||
} : never;
|
||||
export type NextMatchAndValue<TKey, TMatchAndValue extends AnyMatchAndValue> = TMatchAndValue extends any ? CreateMatchAndValue<TMatchAndValue['match'], FindValueByKey<TKey, TMatchAndValue['value']>> : never;
|
||||
export type IsMatchKeyOf<TValue> = TValue extends ReadonlyArray<any> ? number extends TValue['length'] ? `${number}` : keyof TValue & `${number}` : TValue extends object ? keyof TValue & string : never;
|
||||
export type IsMatchPath<TParentPath extends string, TMatchAndValue extends AnyMatchAndValue> = `${TParentPath}${IsMatchKeyOf<TMatchAndValue['value']>}`;
|
||||
export type IsMatchResult<TKey, TMatchAndValue extends AnyMatchAndValue> = TMatchAndValue extends any ? TKey extends keyof TMatchAndValue['value'] ? TMatchAndValue['match'] : never : never;
|
||||
export type IsMatchParse<TPath, TMatchAndValue extends AnyMatchAndValue, TParentPath extends string = ''> = TPath extends `${string}.${string}` ? TPath extends `${infer TFirst}.${infer TRest}` ? IsMatchParse<TRest, NextMatchAndValue<TFirst, TMatchAndValue>, `${TParentPath}${TFirst}.`> : never : {
|
||||
path: IsMatchPath<TParentPath, TMatchAndValue>;
|
||||
result: IsMatchResult<TPath, TMatchAndValue>;
|
||||
};
|
||||
export type IsMatch<TMatch, TPath> = IsMatchParse<TPath, TMatch extends any ? {
|
||||
match: TMatch;
|
||||
value: TMatch;
|
||||
} : never>;
|
||||
/**
|
||||
* Narrows matches based on a path
|
||||
* @experimental
|
||||
*/
|
||||
export declare const isMatch: <TMatch, TPath extends string>(match: TMatch, path: Constrain<TPath, IsMatch<TMatch, TPath>["path"]>) => match is IsMatch<TMatch, TPath>["result"];
|
||||
export interface DefaultRouteMatchExtensions {
|
||||
scripts?: unknown;
|
||||
links?: unknown;
|
||||
headScripts?: unknown;
|
||||
meta?: unknown;
|
||||
}
|
||||
export interface RouteMatchExtensions extends DefaultRouteMatchExtensions {
|
||||
}
|
||||
export interface RouteMatch<out TRouteId, out TFullPath, out TAllParams, out TFullSearchSchema, out TLoaderData, out TAllContext, out TLoaderDeps> extends RouteMatchExtensions {
|
||||
id: string;
|
||||
routeId: TRouteId;
|
||||
fullPath: TFullPath;
|
||||
index: number;
|
||||
pathname: string;
|
||||
params: TAllParams;
|
||||
_strictParams: TAllParams;
|
||||
status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound';
|
||||
isFetching: false | 'beforeLoad' | 'loader';
|
||||
error: unknown;
|
||||
paramsError: unknown;
|
||||
searchError: unknown;
|
||||
updatedAt: number;
|
||||
loadPromise?: ControlledPromise<void>;
|
||||
beforeLoadPromise?: ControlledPromise<void>;
|
||||
loaderPromise?: ControlledPromise<void>;
|
||||
loaderData?: TLoaderData;
|
||||
__routeContext: Record<string, unknown>;
|
||||
__beforeLoadContext: Record<string, unknown>;
|
||||
context: TAllContext;
|
||||
search: TFullSearchSchema;
|
||||
_strictSearch: TFullSearchSchema;
|
||||
fetchCount: number;
|
||||
abortController: AbortController;
|
||||
cause: 'preload' | 'enter' | 'stay';
|
||||
loaderDeps: TLoaderDeps;
|
||||
preload: boolean;
|
||||
invalid: boolean;
|
||||
headers?: Record<string, string>;
|
||||
globalNotFound?: boolean;
|
||||
staticData: StaticDataRouteOption;
|
||||
minPendingPromise?: ControlledPromise<void>;
|
||||
pendingTimeout?: ReturnType<typeof setTimeout>;
|
||||
}
|
||||
export type MakeRouteMatchFromRoute<TRoute extends AnyRoute> = RouteMatch<TRoute['types']['id'], TRoute['types']['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']>;
|
||||
export type MakeRouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRouteId = RouteIds<TRouteTree>, TStrict extends boolean = true> = RouteMatch<TRouteId, RouteById<TRouteTree, TRouteId>['types']['fullPath'], TStrict extends false ? AllParams<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['allParams'], TStrict extends false ? FullSearchSchema<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'], TStrict extends false ? AllLoaderData<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['loaderData'], TStrict extends false ? AllContext<TRouteTree> : RouteById<TRouteTree, TRouteId>['types']['allContext'], RouteById<TRouteTree, TRouteId>['types']['loaderDeps']>;
|
||||
export type AnyRouteMatch = RouteMatch<any, any, any, any, any, any, any>;
|
||||
export type MakeRouteMatchUnion<TRouter extends AnyRouter = RegisteredRouter, TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>> = TRoute extends any ? RouteMatch<TRoute['id'], TRoute['fullPath'], TRoute['types']['allParams'], TRoute['types']['fullSearchSchema'], TRoute['types']['loaderData'], TRoute['types']['allContext'], TRoute['types']['loaderDeps']> : never;
|
||||
/**
|
||||
* The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)
|
||||
*/
|
||||
export interface MatchRouteOptions {
|
||||
/**
|
||||
* If `true`, will match against pending location instead of the current location.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)
|
||||
*/
|
||||
pending?: boolean;
|
||||
/**
|
||||
* If `true`, will match against the current location with case sensitivity.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
* If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)
|
||||
*/
|
||||
includeSearch?: boolean;
|
||||
/**
|
||||
* If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.
|
||||
*
|
||||
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)
|
||||
*/
|
||||
fuzzy?: boolean;
|
||||
}
|
||||
@@ -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 9 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 iB jB kB lB mB nB oB pB qC rC"},D:{"1":"0 9 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 jB kB lB mB nB oB pB qB rB sB tB uB"},E:{"1":"L M G 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 B C sC SC tC uC vC wC TC FC GC"},F:{"1":"0 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 WB XB YB ZB aB bB cB dB eB fB gB hB 4C 5C 6C 7C FC kC 8C GC"},G:{"1":"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 HD ID JD KD LD"},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 fD gD hD TC iD jD kD lD mD IC JC KC nD","2":"J dD eD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"1":"rD","2":"qD"}},B:4,C:"display: flow-root",D:true};
|
||||
Reference in New Issue
Block a user