update
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"awaited.cjs","sources":["../../src/awaited.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { TSR_DEFERRED_PROMISE, defer } from '@tanstack/router-core'\nimport type { DeferredPromise } from '@tanstack/router-core'\n\nexport type AwaitOptions<T> = {\n promise: Promise<T>\n}\n\nexport function useAwaited<T>({\n promise: _promise,\n}: AwaitOptions<T>): [T, DeferredPromise<T>] {\n const promise = defer(_promise)\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'pending') {\n throw promise\n }\n\n if (promise[TSR_DEFERRED_PROMISE].status === 'error') {\n throw promise[TSR_DEFERRED_PROMISE].error\n }\n\n return [promise[TSR_DEFERRED_PROMISE].data, promise]\n}\n\nexport function Await<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n) {\n const inner = <AwaitInner {...props} />\n if (props.fallback) {\n return <React.Suspense fallback={props.fallback}>{inner}</React.Suspense>\n }\n return inner\n}\n\nfunction AwaitInner<T>(\n props: AwaitOptions<T> & {\n fallback?: React.ReactNode\n children: (result: T) => React.ReactNode\n },\n): React.JSX.Element {\n const [data] = useAwaited(props)\n\n return props.children(data) as React.JSX.Element\n}\n"],"names":["defer","TSR_DEFERRED_PROMISE","jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASO,SAAS,WAAc;AAAA,EAC5B,SAAS;AACX,GAA6C;AACrC,QAAA,UAAUA,iBAAM,QAAQ;AAE9B,MAAI,QAAQC,WAAAA,oBAAoB,EAAE,WAAW,WAAW;AAChD,UAAA;AAAA,EAAA;AAGR,MAAI,QAAQA,WAAAA,oBAAoB,EAAE,WAAW,SAAS;AAC9C,UAAA,QAAQA,WAAoB,oBAAA,EAAE;AAAA,EAAA;AAGtC,SAAO,CAAC,QAAQA,WAAAA,oBAAoB,EAAE,MAAM,OAAO;AACrD;AAEO,SAAS,MACd,OAIA;AACA,QAAM,QAAQC,2BAAA,IAAC,YAAY,EAAA,GAAG,MAAO,CAAA;AACrC,MAAI,MAAM,UAAU;AAClB,0CAAQC,iBAAM,UAAN,EAAe,UAAU,MAAM,UAAW,UAAM,OAAA;AAAA,EAAA;AAEnD,SAAA;AACT;AAEA,SAAS,WACP,OAImB;AACnB,QAAM,CAAC,IAAI,IAAI,WAAW,KAAK;AAExB,SAAA,MAAM,SAAS,IAAI;AAC5B;;;"}
|
||||
@@ -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","16":"C"},C:{"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 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 nC LC J PB K D E F A B C L M G N O P QB qC rC"},D:{"1":"0 5 6 7 8 9 RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB lB mB nB oB pB qB rB sB tB uB vB MC wB NC xB yB zB 0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AC BC CC DC Q H R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB I PC EC QC RC","2":"1 2 3 4 J PB K D E F A B C L M G N O P QB"},E:{"1":"D E F A B C L M G uC vC wC TC FC GC xC yC zC UC VC HC 0C IC WC XC YC ZC aC 1C JC bC cC dC eC fC 2C KC gC hC iC jC 3C","2":"J PB sC SC tC","16":"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 BD"},H:{"2":"WD"},I:{"1":"I bD cD","2":"LC J XD YD ZD aD lC"},J:{"1":"A","2":"D"},K:{"1":"H","2":"A B C FC kC GC"},L:{"1":"I"},M:{"1":"EC"},N:{"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:"ChildNode.remove()",D:true};
|
||||
@@ -0,0 +1,7 @@
|
||||
declare class BrowserslistError extends Error {
|
||||
constructor(message: any)
|
||||
name: 'BrowserslistError'
|
||||
browserslist: true
|
||||
}
|
||||
|
||||
export = BrowserslistError
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Mathias Buus
|
||||
|
||||
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,6 @@
|
||||
<svg width="18" height="19" viewBox="0 0 18 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.2 3.09C12.28 3.01 12.43 3 12.43 3C12.48 3 12.58 3.02 12.66 3.1L14.45 4.89C14.58 5.02 14.58 5.22 14.45 5.35L11.7713 8.02872L9.51628 5.77372L12.2 3.09ZM13.2658 5.12L11.7713 6.6145L10.9305 5.77372L12.425 4.27921L13.2658 5.12Z" fill="#FBFBFE"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.98 9.32L8.23 11.57L10.7106 9.08938L8.45562 6.83438L5.98 9.31V9.32ZM8.23 10.1558L9.29641 9.08938L8.45562 8.24859L7.38921 9.315L8.23 10.1558Z" fill="#FBFBFE"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1526 13.1816L16.2125 7.1217C16.7576 6.58919 17.05 5.8707 17.05 5.12C17.05 4.36931 16.7576 3.65084 16.2126 3.11834L14.4317 1.33747C13.8992 0.79242 13.1807 0.5 12.43 0.5C11.6643 0.5 10.9529 0.812929 10.4329 1.33289L3.68289 8.08289C3.04127 8.72452 3.00459 9.75075 3.57288 10.4363L1.29187 12.7239C1.09186 12.9245 0.990263 13.1957 1.0007 13.4685L1 14.5C0.447715 14.5 0 14.9477 0 15.5V17.5C0 18.0523 0.447715 18.5 1 18.5H16C16.5523 18.5 17 18.0523 17 17.5V15.5C17 14.9477 16.5523 14.5 16 14.5H10.2325C9.83594 14.5 9.39953 13.9347 10.1526 13.1816ZM4.39 9.85L4.9807 10.4407L2.39762 13.0312H6.63877L7.10501 12.565L7.57125 13.0312H8.88875L15.51 6.41C15.86 6.07 16.05 5.61 16.05 5.12C16.05 4.63 15.86 4.17 15.51 3.83L13.72 2.04C13.38 1.69 12.92 1.5 12.43 1.5C11.94 1.5 11.48 1.7 11.14 2.04L4.39 8.79C4.1 9.08 4.1 9.56 4.39 9.85ZM16 17.5V15.5H1V17.5H16Z" fill="#FBFBFE"/>
|
||||
<path d="M15.1616 6.05136L15.1616 6.05132L15.1564 6.05645L8.40645 12.8064C8.35915 12.8537 8.29589 12.88 8.23 12.88C8.16411 12.88 8.10085 12.8537 8.05355 12.8064L7.45857 12.2115L7.10501 11.8579L6.75146 12.2115L6.03289 12.93H3.20465L5.33477 10.7937L5.6873 10.4402L5.33426 10.0871L4.74355 9.49645C4.64882 9.40171 4.64882 9.23829 4.74355 9.14355L11.4936 2.39355C11.7436 2.14354 12.0779 2 12.43 2C12.7883 2 13.1179 2.13776 13.3614 2.38839L13.3613 2.38843L13.3664 2.39355L15.1564 4.18355L15.1564 4.18359L15.1616 4.18864C15.4122 4.43211 15.55 4.76166 15.55 5.12C15.55 5.47834 15.4122 5.80789 15.1616 6.05136ZM7.87645 11.9236L8.23 12.2771L8.58355 11.9236L11.0642 9.44293L11.4177 9.08938L11.0642 8.73582L8.80918 6.48082L8.45562 6.12727L8.10207 6.48082L5.62645 8.95645L5.48 9.10289V9.31V9.32V9.52711L5.62645 9.67355L7.87645 11.9236ZM11.4177 8.38227L11.7713 8.73582L12.1248 8.38227L14.8036 5.70355C15.1288 5.37829 15.1288 4.86171 14.8036 4.53645L13.0136 2.74645C12.8186 2.55146 12.5792 2.5 12.43 2.5H12.4134L12.3967 2.50111L12.43 3C12.3967 2.50111 12.3966 2.50112 12.3965 2.50112L12.3963 2.50114L12.3957 2.50117L12.3947 2.50125L12.3924 2.50142L12.387 2.50184L12.3732 2.50311C12.3628 2.50416 12.3498 2.50567 12.3346 2.50784C12.3049 2.51208 12.2642 2.51925 12.2178 2.53146C12.1396 2.55202 11.9797 2.60317 11.8464 2.73645L9.16273 5.42016L8.80918 5.77372L9.16273 6.12727L11.4177 8.38227ZM1.5 16H15.5V17H1.5V16Z" stroke="#15141A"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow use of new operator with the `require` function
|
||||
* @author Wil Moore III
|
||||
* @deprecated in ESLint v7.0.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Node.js rules were moved out of ESLint core.",
|
||||
url: "https://eslint.org/docs/latest/use/migrating-to-7.0.0#deprecate-node-rules",
|
||||
deprecatedSince: "7.0.0",
|
||||
availableUntil: null,
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"eslint-plugin-n now maintains deprecated Node.js-related rules.",
|
||||
plugin: {
|
||||
name: "eslint-plugin-n",
|
||||
url: "https://github.com/eslint-community/eslint-plugin-n",
|
||||
},
|
||||
rule: {
|
||||
name: "no-new-require",
|
||||
url: "https://github.com/eslint-community/eslint-plugin-n/tree/master/docs/rules/no-new-require.md",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "Disallow `new` operators with calls to `require`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-new-require",
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
noNewRequire: "Unexpected use of new with require.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
NewExpression(node) {
|
||||
if (
|
||||
node.callee.type === "Identifier" &&
|
||||
node.callee.name === "require"
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "noNewRequire",
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,528 @@
|
||||
import * as React from 'react'
|
||||
import { flushSync } from 'react-dom'
|
||||
import {
|
||||
deepEqual,
|
||||
exactPathTest,
|
||||
functionalUpdate,
|
||||
preloadWarning,
|
||||
removeTrailingSlash,
|
||||
} from '@tanstack/router-core'
|
||||
import { useRouterState } from './useRouterState'
|
||||
import { useRouter } from './useRouter'
|
||||
|
||||
import {
|
||||
useForwardedRef,
|
||||
useIntersectionObserver,
|
||||
useLayoutEffect,
|
||||
} from './utils'
|
||||
|
||||
import { useMatches } from './Matches'
|
||||
import type {
|
||||
AnyRouter,
|
||||
Constrain,
|
||||
LinkCurrentTargetElement,
|
||||
LinkOptions,
|
||||
RegisteredRouter,
|
||||
RoutePaths,
|
||||
} from '@tanstack/router-core'
|
||||
import type { ReactNode } from 'react'
|
||||
import type {
|
||||
ValidateLinkOptions,
|
||||
ValidateLinkOptionsArray,
|
||||
} from './typePrimitives'
|
||||
|
||||
export function useLinkProps<
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
const TFrom extends string = string,
|
||||
const TTo extends string | undefined = undefined,
|
||||
const TMaskFrom extends string = TFrom,
|
||||
const TMaskTo extends string = '',
|
||||
>(
|
||||
options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
|
||||
forwardedRef?: React.ForwardedRef<Element>,
|
||||
): React.ComponentPropsWithRef<'a'> {
|
||||
const router = useRouter()
|
||||
const [isTransitioning, setIsTransitioning] = React.useState(false)
|
||||
const hasRenderFetched = React.useRef(false)
|
||||
const innerRef = useForwardedRef(forwardedRef)
|
||||
|
||||
const {
|
||||
// custom props
|
||||
activeProps = () => ({ className: 'active' }),
|
||||
inactiveProps = () => ({}),
|
||||
activeOptions,
|
||||
to,
|
||||
preload: userPreload,
|
||||
preloadDelay: userPreloadDelay,
|
||||
hashScrollIntoView,
|
||||
replace,
|
||||
startTransition,
|
||||
resetScroll,
|
||||
viewTransition,
|
||||
// element props
|
||||
children,
|
||||
target,
|
||||
disabled,
|
||||
style,
|
||||
className,
|
||||
onClick,
|
||||
onFocus,
|
||||
onMouseEnter,
|
||||
onMouseLeave,
|
||||
onTouchStart,
|
||||
ignoreBlocker,
|
||||
...rest
|
||||
} = options
|
||||
|
||||
const {
|
||||
// prevent these from being returned
|
||||
params: _params,
|
||||
search: _search,
|
||||
hash: _hash,
|
||||
state: _state,
|
||||
mask: _mask,
|
||||
reloadDocument: _reloadDocument,
|
||||
...propsSafeToSpread
|
||||
} = rest
|
||||
|
||||
// If this link simply reloads the current route,
|
||||
// make sure it has a new key so it will trigger a data refresh
|
||||
|
||||
// If this `to` is a valid external URL, return
|
||||
// null for LinkUtils
|
||||
|
||||
const type: 'internal' | 'external' = React.useMemo(() => {
|
||||
try {
|
||||
new URL(`${to}`)
|
||||
return 'external'
|
||||
} catch {}
|
||||
return 'internal'
|
||||
}, [to])
|
||||
|
||||
// subscribe to search params to re-build location if it changes
|
||||
const currentSearch = useRouterState({
|
||||
select: (s) => s.location.search,
|
||||
structuralSharing: true as any,
|
||||
})
|
||||
|
||||
// when `from` is not supplied, use the leaf route of the current matches as the `from` location
|
||||
// so relative routing works as expected
|
||||
const from = useMatches({
|
||||
select: (matches) => options.from ?? matches[matches.length - 1]?.fullPath,
|
||||
})
|
||||
// Use it as the default `from` location
|
||||
const _options = React.useMemo(() => ({ ...options, from }), [options, from])
|
||||
|
||||
const next = React.useMemo(
|
||||
() => router.buildLocation(_options as any),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[router, _options, currentSearch],
|
||||
)
|
||||
|
||||
const preload = React.useMemo(() => {
|
||||
if (_options.reloadDocument) {
|
||||
return false
|
||||
}
|
||||
return userPreload ?? router.options.defaultPreload
|
||||
}, [router.options.defaultPreload, userPreload, _options.reloadDocument])
|
||||
const preloadDelay =
|
||||
userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0
|
||||
|
||||
const isActive = useRouterState({
|
||||
select: (s) => {
|
||||
if (activeOptions?.exact) {
|
||||
const testExact = exactPathTest(
|
||||
s.location.pathname,
|
||||
next.pathname,
|
||||
router.basepath,
|
||||
)
|
||||
if (!testExact) {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
const currentPathSplit = removeTrailingSlash(
|
||||
s.location.pathname,
|
||||
router.basepath,
|
||||
).split('/')
|
||||
const nextPathSplit = removeTrailingSlash(
|
||||
next.pathname,
|
||||
router.basepath,
|
||||
).split('/')
|
||||
|
||||
const pathIsFuzzyEqual = nextPathSplit.every(
|
||||
(d, i) => d === currentPathSplit[i],
|
||||
)
|
||||
if (!pathIsFuzzyEqual) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (activeOptions?.includeSearch ?? true) {
|
||||
const searchTest = deepEqual(s.location.search, next.search, {
|
||||
partial: !activeOptions?.exact,
|
||||
ignoreUndefined: !activeOptions?.explicitUndefined,
|
||||
})
|
||||
if (!searchTest) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (activeOptions?.includeHash) {
|
||||
return s.location.hash === next.hash
|
||||
}
|
||||
return true
|
||||
},
|
||||
})
|
||||
|
||||
const doPreload = React.useCallback(() => {
|
||||
router.preloadRoute(_options as any).catch((err) => {
|
||||
console.warn(err)
|
||||
console.warn(preloadWarning)
|
||||
})
|
||||
}, [_options, router])
|
||||
|
||||
const preloadViewportIoCallback = React.useCallback(
|
||||
(entry: IntersectionObserverEntry | undefined) => {
|
||||
if (entry?.isIntersecting) {
|
||||
doPreload()
|
||||
}
|
||||
},
|
||||
[doPreload],
|
||||
)
|
||||
|
||||
useIntersectionObserver(
|
||||
innerRef,
|
||||
preloadViewportIoCallback,
|
||||
{ rootMargin: '100px' },
|
||||
{ disabled: !!disabled || !(preload === 'viewport') },
|
||||
)
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (hasRenderFetched.current) {
|
||||
return
|
||||
}
|
||||
if (!disabled && preload === 'render') {
|
||||
doPreload()
|
||||
hasRenderFetched.current = true
|
||||
}
|
||||
}, [disabled, doPreload, preload])
|
||||
|
||||
if (type === 'external') {
|
||||
return {
|
||||
...propsSafeToSpread,
|
||||
ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],
|
||||
type,
|
||||
href: to,
|
||||
...(children && { children }),
|
||||
...(target && { target }),
|
||||
...(disabled && { disabled }),
|
||||
...(style && { style }),
|
||||
...(className && { className }),
|
||||
...(onClick && { onClick }),
|
||||
...(onFocus && { onFocus }),
|
||||
...(onMouseEnter && { onMouseEnter }),
|
||||
...(onMouseLeave && { onMouseLeave }),
|
||||
...(onTouchStart && { onTouchStart }),
|
||||
}
|
||||
}
|
||||
|
||||
// The click handler
|
||||
const handleClick = (e: MouseEvent) => {
|
||||
if (
|
||||
!disabled &&
|
||||
!isCtrlEvent(e) &&
|
||||
!e.defaultPrevented &&
|
||||
(!target || target === '_self') &&
|
||||
e.button === 0
|
||||
) {
|
||||
e.preventDefault()
|
||||
|
||||
flushSync(() => {
|
||||
setIsTransitioning(true)
|
||||
})
|
||||
|
||||
const unsub = router.subscribe('onResolved', () => {
|
||||
unsub()
|
||||
setIsTransitioning(false)
|
||||
})
|
||||
|
||||
// All is well? Navigate!
|
||||
// N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing
|
||||
return router.navigate({
|
||||
..._options,
|
||||
replace,
|
||||
resetScroll,
|
||||
hashScrollIntoView,
|
||||
startTransition,
|
||||
viewTransition,
|
||||
ignoreBlocker,
|
||||
} as any)
|
||||
}
|
||||
}
|
||||
|
||||
// The click handler
|
||||
const handleFocus = (_: MouseEvent) => {
|
||||
if (disabled) return
|
||||
if (preload) {
|
||||
doPreload()
|
||||
}
|
||||
}
|
||||
|
||||
const handleTouchStart = handleFocus
|
||||
|
||||
const handleEnter = (e: MouseEvent) => {
|
||||
if (disabled) return
|
||||
const eventTarget = (e.target || {}) as LinkCurrentTargetElement
|
||||
|
||||
if (preload) {
|
||||
if (eventTarget.preloadTimeout) {
|
||||
return
|
||||
}
|
||||
|
||||
eventTarget.preloadTimeout = setTimeout(() => {
|
||||
eventTarget.preloadTimeout = null
|
||||
doPreload()
|
||||
}, preloadDelay)
|
||||
}
|
||||
}
|
||||
|
||||
const handleLeave = (e: MouseEvent) => {
|
||||
if (disabled) return
|
||||
const eventTarget = (e.target || {}) as LinkCurrentTargetElement
|
||||
|
||||
if (eventTarget.preloadTimeout) {
|
||||
clearTimeout(eventTarget.preloadTimeout)
|
||||
eventTarget.preloadTimeout = null
|
||||
}
|
||||
}
|
||||
|
||||
const composeHandlers =
|
||||
(handlers: Array<undefined | ((e: any) => void)>) =>
|
||||
(e: { persist?: () => void; defaultPrevented: boolean }) => {
|
||||
e.persist?.()
|
||||
handlers.filter(Boolean).forEach((handler) => {
|
||||
if (e.defaultPrevented) return
|
||||
handler!(e)
|
||||
})
|
||||
}
|
||||
|
||||
// Get the active props
|
||||
const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> = isActive
|
||||
? (functionalUpdate(activeProps as any, {}) ?? {})
|
||||
: {}
|
||||
|
||||
// Get the inactive props
|
||||
const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =
|
||||
isActive ? {} : functionalUpdate(inactiveProps, {})
|
||||
|
||||
const resolvedClassName = [
|
||||
className,
|
||||
resolvedActiveProps.className,
|
||||
resolvedInactiveProps.className,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
|
||||
const resolvedStyle = {
|
||||
...style,
|
||||
...resolvedActiveProps.style,
|
||||
...resolvedInactiveProps.style,
|
||||
}
|
||||
|
||||
return {
|
||||
...propsSafeToSpread,
|
||||
...resolvedActiveProps,
|
||||
...resolvedInactiveProps,
|
||||
href: disabled
|
||||
? undefined
|
||||
: next.maskedLocation
|
||||
? router.history.createHref(next.maskedLocation.href)
|
||||
: router.history.createHref(next.href),
|
||||
ref: innerRef as React.ComponentPropsWithRef<'a'>['ref'],
|
||||
onClick: composeHandlers([onClick, handleClick]),
|
||||
onFocus: composeHandlers([onFocus, handleFocus]),
|
||||
onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
|
||||
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
||||
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
||||
disabled: !!disabled,
|
||||
target,
|
||||
...(Object.keys(resolvedStyle).length && { style: resolvedStyle }),
|
||||
...(resolvedClassName && { className: resolvedClassName }),
|
||||
...(disabled && {
|
||||
role: 'link',
|
||||
'aria-disabled': true,
|
||||
}),
|
||||
...(isActive && { 'data-status': 'active', 'aria-current': 'page' }),
|
||||
...(isTransitioning && { 'data-transitioning': 'transitioning' }),
|
||||
}
|
||||
}
|
||||
|
||||
type UseLinkReactProps<TComp> = TComp extends keyof React.JSX.IntrinsicElements
|
||||
? React.JSX.IntrinsicElements[TComp]
|
||||
: React.PropsWithoutRef<
|
||||
TComp extends React.ComponentType<infer TProps> ? TProps : never
|
||||
> &
|
||||
React.RefAttributes<
|
||||
TComp extends
|
||||
| React.FC<{ ref: infer TRef }>
|
||||
| React.Component<{ ref: infer TRef }>
|
||||
? TRef
|
||||
: never
|
||||
>
|
||||
|
||||
export type UseLinkPropsOptions<
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
TFrom extends RoutePaths<TRouter['routeTree']> | string = string,
|
||||
TTo extends string | undefined = '.',
|
||||
TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,
|
||||
TMaskTo extends string = '.',
|
||||
> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
|
||||
UseLinkReactProps<'a'>
|
||||
|
||||
export type ActiveLinkOptions<
|
||||
TComp = 'a',
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
TFrom extends string = string,
|
||||
TTo extends string | undefined = '.',
|
||||
TMaskFrom extends string = TFrom,
|
||||
TMaskTo extends string = '.',
|
||||
> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
|
||||
ActiveLinkOptionProps<TComp>
|
||||
|
||||
type ActiveLinkProps<TComp> = Partial<
|
||||
LinkComponentReactProps<TComp> & {
|
||||
[key: `data-${string}`]: unknown
|
||||
}
|
||||
>
|
||||
|
||||
export interface ActiveLinkOptionProps<TComp = 'a'> {
|
||||
/**
|
||||
* A function that returns additional props for the `active` state of this link.
|
||||
* These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
|
||||
*/
|
||||
activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)
|
||||
/**
|
||||
* A function that returns additional props for the `inactive` state of this link.
|
||||
* These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)
|
||||
*/
|
||||
inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)
|
||||
}
|
||||
|
||||
export type LinkProps<
|
||||
TComp = 'a',
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
TFrom extends string = string,
|
||||
TTo extends string | undefined = '.',
|
||||
TMaskFrom extends string = TFrom,
|
||||
TMaskTo extends string = '.',
|
||||
> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &
|
||||
LinkPropsChildren
|
||||
|
||||
export interface LinkPropsChildren {
|
||||
// If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns
|
||||
children?:
|
||||
| React.ReactNode
|
||||
| ((state: {
|
||||
isActive: boolean
|
||||
isTransitioning: boolean
|
||||
}) => React.ReactNode)
|
||||
}
|
||||
|
||||
type LinkComponentReactProps<TComp> = Omit<
|
||||
UseLinkReactProps<TComp>,
|
||||
keyof CreateLinkProps
|
||||
>
|
||||
|
||||
export type LinkComponentProps<
|
||||
TComp = 'a',
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
TFrom extends string = string,
|
||||
TTo extends string | undefined = '.',
|
||||
TMaskFrom extends string = TFrom,
|
||||
TMaskTo extends string = '.',
|
||||
> = LinkComponentReactProps<TComp> &
|
||||
LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
|
||||
|
||||
export type CreateLinkProps = LinkProps<
|
||||
any,
|
||||
any,
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
string
|
||||
>
|
||||
|
||||
export type LinkComponent<TComp> = <
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
const TFrom extends string = string,
|
||||
const TTo extends string | undefined = undefined,
|
||||
const TMaskFrom extends string = TFrom,
|
||||
const TMaskTo extends string = '',
|
||||
>(
|
||||
props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,
|
||||
) => React.ReactElement
|
||||
|
||||
export function createLink<const TComp>(
|
||||
Comp: Constrain<TComp, any, (props: CreateLinkProps) => ReactNode>,
|
||||
): LinkComponent<TComp> {
|
||||
return React.forwardRef(function CreatedLink(props, ref) {
|
||||
return <Link {...(props as any)} _asChild={Comp} ref={ref} />
|
||||
}) as any
|
||||
}
|
||||
|
||||
export const Link: LinkComponent<'a'> = React.forwardRef<Element, any>(
|
||||
(props, ref) => {
|
||||
const { _asChild, ...rest } = props
|
||||
const {
|
||||
type: _type,
|
||||
ref: innerRef,
|
||||
...linkProps
|
||||
} = useLinkProps(rest as any, ref)
|
||||
|
||||
const children =
|
||||
typeof rest.children === 'function'
|
||||
? rest.children({
|
||||
isActive: (linkProps as any)['data-status'] === 'active',
|
||||
})
|
||||
: rest.children
|
||||
|
||||
if (typeof _asChild === 'undefined') {
|
||||
// the ReturnType of useLinkProps returns the correct type for a <a> element, not a general component that has a disabled prop
|
||||
// @ts-expect-error
|
||||
delete linkProps.disabled
|
||||
}
|
||||
|
||||
return React.createElement(
|
||||
_asChild ? _asChild : 'a',
|
||||
{
|
||||
...linkProps,
|
||||
ref: innerRef,
|
||||
},
|
||||
children,
|
||||
)
|
||||
},
|
||||
) as any
|
||||
|
||||
function isCtrlEvent(e: MouseEvent) {
|
||||
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
|
||||
}
|
||||
|
||||
export type LinkOptionsFnOptions<
|
||||
TOptions,
|
||||
TComp,
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
> =
|
||||
TOptions extends ReadonlyArray<any>
|
||||
? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>
|
||||
: ValidateLinkOptions<TRouter, TOptions, string, TComp>
|
||||
|
||||
export type LinkOptionsFn<TComp> = <
|
||||
const TOptions,
|
||||
TRouter extends AnyRouter = RegisteredRouter,
|
||||
>(
|
||||
options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,
|
||||
) => TOptions
|
||||
|
||||
export const linkOptions: LinkOptionsFn<'a'> = (options) => {
|
||||
return options as any
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: React.ReactNode\n}) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router as AnyRouter}>\n {children}\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n <Matches />\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n NonNullable<TRouter['options']['defaultStructuralSharing']>,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":[],"mappings":";;;AASO,SAAS,sBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAEG;AAED,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,KAAK;AAAA,IAAA;AAAA,EACV,CACM;AAER,QAAM,gBAAgB,iBAAiB;AAEvC,QAAM,WACH,oBAAA,cAAc,UAAd,EAAuB,OAAO,QAC5B,UACH;AAGE,MAAA,OAAO,QAAQ,MAAM;AACvB,WAAQ,oBAAA,OAAO,QAAQ,MAAf,EAAqB,UAAS,UAAA;AAAA,EAAA;AAGjC,SAAA;AACT;AAEO,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA2C;AACxD,6BACG,uBAAsB,EAAA,QAAiB,GAAG,MACzC,UAAA,oBAAC,UAAQ,CAAA,GACX;AAEJ;"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"78":0.00383,"88":0.00383,"91":0.00383,"102":0.00383,"113":0.00383,"115":0.09578,"123":0.00383,"125":0.00383,"126":0.00383,"127":0.00383,"128":0.07279,"129":0.00383,"130":0.00383,"131":0.00383,"132":0.00383,"133":0.01532,"134":0.01532,"135":0.20687,"136":0.90412,"137":0.00383,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 79 80 81 82 83 84 85 86 87 89 90 92 93 94 95 96 97 98 99 100 101 103 104 105 106 107 108 109 110 111 112 114 116 117 118 119 120 121 122 124 138 139 140 3.5 3.6"},D:{"39":0.01149,"40":0.01149,"41":0.01149,"42":0.01149,"43":0.01532,"44":0.01149,"45":0.01149,"46":0.01149,"47":0.01532,"48":0.01532,"49":0.01532,"50":0.01149,"51":0.01916,"52":0.01532,"53":0.01149,"54":0.01149,"55":0.01916,"56":0.01532,"57":0.01149,"58":0.01532,"59":0.01532,"60":0.01149,"66":0.00383,"72":0.00383,"74":0.00383,"75":0.01149,"78":0.01149,"79":0.02299,"80":0.00383,"81":0.00766,"83":0.00383,"84":0.00383,"85":0.00383,"86":0.00766,"87":0.01916,"88":0.00766,"89":0.00383,"90":0.00383,"91":0.00766,"92":0.00383,"94":0.03831,"96":0.00766,"99":0.00383,"100":0.00383,"101":0.00383,"102":0.00766,"103":0.02682,"104":0.05747,"105":0.01149,"106":0.01149,"107":0.01916,"108":0.03065,"109":0.98457,"110":0.01532,"111":0.01916,"112":0.01532,"113":0.00383,"114":0.01916,"115":0.00383,"116":0.04597,"117":0.08045,"118":0.00383,"119":0.02682,"120":0.02299,"121":0.01916,"122":0.07279,"123":0.03065,"124":0.07662,"125":0.07662,"126":0.07279,"127":0.05747,"128":0.17623,"129":0.08811,"130":0.1111,"131":0.37544,"132":0.42524,"133":6.89963,"134":17.13223,"135":0.02299,"136":0.01149,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 61 62 63 64 65 67 68 69 70 71 73 76 77 93 95 97 98 137 138"},F:{"87":0.00766,"88":0.00383,"95":0.01916,"113":0.00383,"114":0.00766,"115":0.00383,"116":0.96924,"117":2.12237,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 89 90 91 92 93 94 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"18":0.00383,"80":0.00383,"81":0.00383,"83":0.00383,"84":0.00383,"89":0.00383,"91":0.00766,"92":0.01149,"94":0.00766,"105":0.00766,"107":0.00383,"109":0.02682,"110":0.00383,"114":0.00766,"118":0.00383,"120":0.00383,"122":0.00383,"125":0.00383,"126":0.00766,"127":0.00383,"128":0.00383,"129":0.00383,"130":0.01149,"131":0.03065,"132":0.07662,"133":1.088,"134":3.14142,_:"12 13 14 15 16 17 79 85 86 87 88 90 93 95 96 97 98 99 100 101 102 103 104 106 108 111 112 113 115 116 117 119 121 123 124"},E:{_:"0 4 5 6 7 8 9 10 11 12 13 14 15 3.1 3.2 6.1 7.1 10.1 11.1 12.1 15.1 15.2-15.3 15.5 17.0","5.1":0.00383,"9.1":0.00383,"13.1":0.00383,"14.1":0.00383,"15.4":0.00383,"15.6":0.03065,"16.0":0.00383,"16.1":0.00766,"16.2":0.00383,"16.3":0.00383,"16.4":0.00383,"16.5":0.00383,"16.6":0.03065,"17.1":0.01149,"17.2":0.00383,"17.3":0.00383,"17.4":0.01532,"17.5":0.02299,"17.6":0.0613,"18.0":0.01532,"18.1":0.02682,"18.2":0.01532,"18.3":0.36778,"18.4":0.01149},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00101,"5.0-5.1":0,"6.0-6.1":0.00303,"7.0-7.1":0.00202,"8.1-8.4":0,"9.0-9.2":0.00151,"9.3":0.00706,"10.0-10.2":0.0005,"10.3":0.01161,"11.0-11.2":0.05349,"11.3-11.4":0.00353,"12.0-12.1":0.00202,"12.2-12.5":0.04996,"13.0-13.1":0.00101,"13.2":0.00151,"13.3":0.00202,"13.4-13.7":0.00706,"14.0-14.4":0.01766,"14.5-14.8":0.02119,"15.0-15.1":0.01161,"15.2-15.3":0.01161,"15.4":0.01413,"15.5":0.01615,"15.6-15.8":0.19882,"16.0":0.02826,"16.1":0.05803,"16.2":0.03028,"16.3":0.05248,"16.4":0.01161,"16.5":0.0217,"16.6-16.7":0.23566,"17.0":0.01413,"17.1":0.02523,"17.2":0.01918,"17.3":0.02675,"17.4":0.05349,"17.5":0.11909,"17.6-17.7":0.34567,"18.0":0.09689,"18.1":0.3169,"18.2":0.1418,"18.3":2.96366,"18.4":0.0439},P:{"4":0.01054,"21":0.01054,"22":0.01054,"23":0.01054,"24":0.01054,"25":0.01054,"26":0.05272,"27":0.99108,_:"20 5.0-5.4 6.2-6.4 8.2 9.2 10.1 11.1-11.2 12.0 13.0 14.0 15.0 16.0 18.0 19.0","7.2-7.4":0.04217,"17.0":0.01054},I:{"0":0.30165,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00009,"4.4":0,"4.4.3-4.4.4":0.00033},K:{"0":0.22825,_:"10 11 12 11.1 11.5 12.1"},A:{"8":0.00406,"9":0.00406,"10":0.00406,"11":0.1219,_:"6 7 5.5"},S:{_:"2.5 3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.09254},Q:{_:"14.9"},O:{"0":0.02468},H:{"0":0},L:{"0":55.16543}};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"K D E F A B mC"},B:{"1":"CB DB EB FB GB HB IB JB KB LB MB NB OB I","2":"0 9 C L M G N O z AB BB","194":"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"},C:{"1":"0 9 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 qB rB qC rC","66":"sB tB uB vB MC wB NC xB yB zB","260":"0B","516":"1B"},D:{"1":"0 9 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 vB MC wB NC xB yB zB 0B 1B","66":"2B 3B 4B"},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","1028":"JC bC cC dC eC fC 2C KC gC hC iC jC 3C"},F:{"1":"0 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 iB jB kB lB mB nB oB pB qB rB sB tB 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","1028":"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:{"1":"EC"},N:{"2":"A B"},O:{"1":"HC"},P:{"1":"1 2 3 4 5 6 7 8 jD kD lD mD IC JC KC nD","2":"J dD eD fD gD hD TC iD"},Q:{"1":"oD"},R:{"1":"pD"},S:{"2":"qD rD"}},B:6,C:"AV1 video format",D:true};
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["module","exports","import_","filepath"],"sources":["../../../src/config/files/import.cjs"],"sourcesContent":["// We keep this in a separate file so that in older node versions, where\n// import() isn't supported, we can try/catch around the require() call\n// when loading this file.\n\nmodule.exports = function import_(filepath) {\n return import(filepath);\n};\n"],"mappings":"AAIAA,MAAM,CAACC,OAAO,GAAG,SAASC,OAAOA,CAACC,QAAQ,EAAE;EAC1C,OAAO,OAAOA,QAAQ,CAAC;AACzB,CAAC;AAAC","ignoreList":[]}
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* @fileoverview Rule to require sorting of variables within a single Variable Declaration block
|
||||
* @author Ilya Volodin
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: [
|
||||
{
|
||||
ignoreCase: false,
|
||||
},
|
||||
],
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Require variables within the same declaration block to be sorted",
|
||||
recommended: false,
|
||||
frozen: true,
|
||||
url: "https://eslint.org/docs/latest/rules/sort-vars",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
ignoreCase: {
|
||||
type: "boolean",
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
fixable: "code",
|
||||
|
||||
messages: {
|
||||
sortVars:
|
||||
"Variables within the same declaration block should be sorted alphabetically.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [{ ignoreCase }] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
VariableDeclaration(node) {
|
||||
const idDeclarations = node.declarations.filter(
|
||||
decl => decl.id.type === "Identifier",
|
||||
);
|
||||
const getSortableName = ignoreCase
|
||||
? decl => decl.id.name.toLowerCase()
|
||||
: decl => decl.id.name;
|
||||
const unfixable = idDeclarations.some(
|
||||
decl => decl.init !== null && decl.init.type !== "Literal",
|
||||
);
|
||||
let fixed = false;
|
||||
|
||||
idDeclarations.slice(1).reduce((memo, decl) => {
|
||||
const lastVariableName = getSortableName(memo),
|
||||
currentVariableName = getSortableName(decl);
|
||||
|
||||
if (currentVariableName < lastVariableName) {
|
||||
context.report({
|
||||
node: decl,
|
||||
messageId: "sortVars",
|
||||
fix(fixer) {
|
||||
if (unfixable || fixed) {
|
||||
return null;
|
||||
}
|
||||
return fixer.replaceTextRange(
|
||||
[
|
||||
idDeclarations[0].range[0],
|
||||
idDeclarations.at(-1).range[1],
|
||||
],
|
||||
idDeclarations
|
||||
|
||||
// Clone the idDeclarations array to avoid mutating it
|
||||
.slice()
|
||||
|
||||
// Sort the array into the desired order
|
||||
.sort((declA, declB) => {
|
||||
const aName =
|
||||
getSortableName(declA);
|
||||
const bName =
|
||||
getSortableName(declB);
|
||||
|
||||
return aName > bName ? 1 : -1;
|
||||
})
|
||||
|
||||
// Build a string out of the sorted list of identifier declarations and the text between the originals
|
||||
.reduce(
|
||||
(sourceText, identifier, index) => {
|
||||
const textAfterIdentifier =
|
||||
index ===
|
||||
idDeclarations.length - 1
|
||||
? ""
|
||||
: sourceCode
|
||||
.getText()
|
||||
.slice(
|
||||
idDeclarations[
|
||||
index
|
||||
].range[1],
|
||||
idDeclarations[
|
||||
index +
|
||||
1
|
||||
].range[0],
|
||||
);
|
||||
|
||||
return (
|
||||
sourceText +
|
||||
sourceCode.getText(
|
||||
identifier,
|
||||
) +
|
||||
textAfterIdentifier
|
||||
);
|
||||
},
|
||||
"",
|
||||
),
|
||||
);
|
||||
},
|
||||
});
|
||||
fixed = true;
|
||||
return memo;
|
||||
}
|
||||
return decl;
|
||||
}, idDeclarations[0]);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@tailwindcss/oxide",
|
||||
"version": "4.1.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tailwindlabs/tailwindcss.git",
|
||||
"directory": "crates/node"
|
||||
},
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"napi": {
|
||||
"name": "tailwindcss-oxide",
|
||||
"triples": {
|
||||
"additional": [
|
||||
"armv7-linux-androideabi",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-freebsd",
|
||||
"i686-pc-windows-msvc",
|
||||
"aarch64-pc-windows-msvc"
|
||||
]
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^2.18.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"publishConfig": {
|
||||
"provenance": true,
|
||||
"access": "public"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tailwindcss/oxide-android-arm64": "4.1.2",
|
||||
"@tailwindcss/oxide-darwin-x64": "4.1.2",
|
||||
"@tailwindcss/oxide-freebsd-x64": "4.1.2",
|
||||
"@tailwindcss/oxide-linux-arm64-musl": "4.1.2",
|
||||
"@tailwindcss/oxide-linux-arm64-gnu": "4.1.2",
|
||||
"@tailwindcss/oxide-linux-x64-gnu": "4.1.2",
|
||||
"@tailwindcss/oxide-linux-x64-musl": "4.1.2",
|
||||
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.2",
|
||||
"@tailwindcss/oxide-win32-x64-msvc": "4.1.2",
|
||||
"@tailwindcss/oxide-win32-arm64-msvc": "4.1.2",
|
||||
"@tailwindcss/oxide-darwin-arm64": "4.1.2"
|
||||
},
|
||||
"scripts": {
|
||||
"artifacts": "napi artifacts",
|
||||
"build": "napi build --platform --release --no-const-enum",
|
||||
"dev": "cargo watch --quiet --shell 'npm run build'",
|
||||
"build:debug": "napi build --platform --no-const-enum",
|
||||
"version": "napi version"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { jsx } from "react/jsx-runtime";
|
||||
function Asset({ tag, attrs, children }) {
|
||||
switch (tag) {
|
||||
case "title":
|
||||
return /* @__PURE__ */ jsx("title", { ...attrs, suppressHydrationWarning: true, children });
|
||||
case "meta":
|
||||
return /* @__PURE__ */ jsx("meta", { ...attrs, suppressHydrationWarning: true });
|
||||
case "link":
|
||||
return /* @__PURE__ */ jsx("link", { ...attrs, suppressHydrationWarning: true });
|
||||
case "style":
|
||||
return /* @__PURE__ */ jsx(
|
||||
"style",
|
||||
{
|
||||
...attrs,
|
||||
dangerouslySetInnerHTML: { __html: children }
|
||||
}
|
||||
);
|
||||
case "script":
|
||||
if (attrs && attrs.src) {
|
||||
return /* @__PURE__ */ jsx("script", { ...attrs, suppressHydrationWarning: true });
|
||||
}
|
||||
if (typeof children === "string")
|
||||
return /* @__PURE__ */ jsx(
|
||||
"script",
|
||||
{
|
||||
...attrs,
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: children
|
||||
},
|
||||
suppressHydrationWarning: true
|
||||
}
|
||||
);
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export {
|
||||
Asset
|
||||
};
|
||||
//# sourceMappingURL=Asset.js.map
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"60":0.00326,"88":0.00326,"115":0.09131,"120":0.01304,"128":0.00652,"129":0.00652,"130":0.00652,"131":0.00652,"132":0.00326,"133":0.00326,"134":0.00652,"135":0.1924,"136":0.88047,"137":0.00978,"138":0.00326,_:"2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 116 117 118 119 121 122 123 124 125 126 127 139 140 3.5 3.6"},D:{"49":0.00326,"60":0.00326,"65":0.00326,"74":0.00326,"75":0.00978,"76":0.00978,"78":0.02609,"79":0.02283,"84":0.00326,"86":0.00326,"87":0.01631,"88":0.00326,"91":0.00326,"93":0.00326,"94":0.00326,"95":0.00326,"99":0.00326,"102":0.00326,"103":0.03261,"104":0.00326,"106":0.00652,"108":0.01304,"109":0.5935,"110":0.00326,"111":0.00326,"114":0.00978,"115":0.00326,"116":0.05544,"117":0.00326,"118":0.00978,"119":0.00978,"120":0.01304,"121":0.01304,"122":0.06522,"123":0.02609,"124":0.10435,"125":0.03913,"126":0.0587,"127":0.01957,"128":0.07826,"129":0.02609,"130":0.05218,"131":0.17609,"132":0.27392,"133":6.27416,"134":12.84508,"135":0.00326,"136":0.00652,_:"4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 50 51 52 53 54 55 56 57 58 59 61 62 63 64 66 67 68 69 70 71 72 73 77 80 81 83 85 89 90 92 96 97 98 100 101 105 107 112 113 137 138"},F:{"42":0.01957,"79":0.00652,"87":0.00652,"88":0.00326,"94":0.00326,"95":0.01304,"102":0.00326,"114":0.00652,"116":0.40436,"117":1.15766,_:"9 11 12 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84 85 86 89 90 91 92 93 96 97 98 99 100 101 103 104 105 106 107 108 109 110 111 112 113 115 9.5-9.6 10.0-10.1 10.5 10.6 11.1 11.5 11.6 12.1"},B:{"92":0.00978,"100":0.00326,"109":0.01304,"110":0.00326,"114":0.00326,"120":0.00326,"122":0.00326,"124":0.00652,"125":0.00326,"126":0.00652,"127":0.00978,"128":0.00652,"129":0.00978,"130":0.00652,"131":0.02935,"132":0.03913,"133":1.02722,"134":2.37727,_:"12 13 14 15 16 17 18 79 80 81 83 84 85 86 87 88 89 90 91 93 94 95 96 97 98 99 101 102 103 104 105 106 107 108 111 112 113 115 116 117 118 119 121 123"},E:{"14":0.00652,_:"0 4 5 6 7 8 9 10 11 12 13 15 3.1 3.2 6.1 7.1 9.1 10.1 11.1 12.1","5.1":0.00326,"13.1":0.00652,"14.1":0.00978,"15.1":0.00326,"15.2-15.3":0.00326,"15.4":0.00326,"15.5":0.00652,"15.6":0.06848,"16.0":0.00978,"16.1":0.00652,"16.2":0.00326,"16.3":0.00978,"16.4":0.00326,"16.5":0.01304,"16.6":0.07174,"17.0":0.00978,"17.1":0.03261,"17.2":0.01304,"17.3":0.00652,"17.4":0.02283,"17.5":0.09131,"17.6":0.14022,"18.0":0.03261,"18.1":0.07826,"18.2":0.03913,"18.3":0.96852,"18.4":0.02609},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0.00265,"5.0-5.1":0,"6.0-6.1":0.00794,"7.0-7.1":0.00529,"8.1-8.4":0,"9.0-9.2":0.00397,"9.3":0.01853,"10.0-10.2":0.00132,"10.3":0.03044,"11.0-11.2":0.1403,"11.3-11.4":0.00926,"12.0-12.1":0.00529,"12.2-12.5":0.13103,"13.0-13.1":0.00265,"13.2":0.00397,"13.3":0.00529,"13.4-13.7":0.01853,"14.0-14.4":0.04632,"14.5-14.8":0.05559,"15.0-15.1":0.03044,"15.2-15.3":0.03044,"15.4":0.03706,"15.5":0.04235,"15.6-15.8":0.52147,"16.0":0.07412,"16.1":0.15221,"16.2":0.07941,"16.3":0.13765,"16.4":0.03044,"16.5":0.05691,"16.6-16.7":0.61809,"17.0":0.03706,"17.1":0.06618,"17.2":0.05029,"17.3":0.07015,"17.4":0.1403,"17.5":0.31236,"17.6-17.7":0.90662,"18.0":0.25412,"18.1":0.83118,"18.2":0.37191,"18.3":7.77315,"18.4":0.11515},P:{"4":0.01023,"20":0.01023,"21":0.02046,"22":0.06137,"23":0.04092,"24":0.09206,"25":0.06137,"26":0.10229,"27":2.92545,_:"5.0-5.4 6.2-6.4 8.2 9.2 10.1 12.0 14.0 15.0 17.0 18.0","7.2-7.4":0.06137,"11.1-11.2":0.01023,"13.0":0.02046,"16.0":0.01023,"19.0":0.01023},I:{"0":0.02017,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0,"4.2-4.3":0.00001,"4.4":0,"4.4.3-4.4.4":0.00002},K:{"0":0.26282,_:"10 11 12 11.1 11.5 12.1"},A:{_:"6 7 8 9 10 11 5.5"},S:{"2.5":0.00674,_:"3.0-3.1"},J:{_:"7 10"},N:{_:"10 11"},R:{_:"0"},M:{"0":0.22239},Q:{_:"14.9"},O:{"0":0.0337},H:{"0":0},L:{"0":52.4972}};
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "mimic-response",
|
||||
"version": "3.1.0",
|
||||
"description": "Mimic a Node.js HTTP response stream",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/mimic-response",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"mimic",
|
||||
"response",
|
||||
"stream",
|
||||
"http",
|
||||
"https",
|
||||
"request",
|
||||
"get",
|
||||
"core"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.1",
|
||||
"ava": "^2.4.0",
|
||||
"create-test-server": "^2.4.0",
|
||||
"p-event": "^4.1.0",
|
||||
"pify": "^5.0.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.30.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const napi = require('napi-build-utils')
|
||||
|
||||
const pkg = require(path.resolve('package.json'))
|
||||
const rc = require('./rc')(pkg)
|
||||
const log = require('./log')(rc, process.env)
|
||||
const download = require('./download')
|
||||
const asset = require('./asset')
|
||||
const util = require('./util')
|
||||
|
||||
const prebuildClientVersion = require('./package.json').version
|
||||
if (rc.version) {
|
||||
console.log(prebuildClientVersion)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
if (rc.path) process.chdir(rc.path)
|
||||
|
||||
if (rc.runtime === 'electron' && rc.target[0] === '4' && rc.abi === '64') {
|
||||
log.error(`Electron version ${rc.target} found - skipping prebuild-install work due to known ABI issue`)
|
||||
log.error('More information about this issue can be found at https://github.com/lgeiger/node-abi/issues/54')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!fs.existsSync('package.json')) {
|
||||
log.error('setup', 'No package.json found. Aborting...')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (rc.help) {
|
||||
console.error(fs.readFileSync(path.join(__dirname, 'help.txt'), 'utf-8'))
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
log.info('begin', 'Prebuild-install version', prebuildClientVersion)
|
||||
|
||||
const opts = Object.assign({}, rc, { pkg: pkg, log: log })
|
||||
|
||||
if (napi.isNapiRuntime(rc.runtime)) napi.logUnsupportedVersion(rc.target, log)
|
||||
|
||||
const origin = util.packageOrigin(process.env, pkg)
|
||||
|
||||
if (opts.force) {
|
||||
log.warn('install', 'prebuilt binaries enforced with --force!')
|
||||
log.warn('install', 'prebuilt binaries may be out of date!')
|
||||
} else if (origin && origin.length > 4 && origin.substr(0, 4) === 'git+') {
|
||||
log.info('install', 'installing from git repository, skipping download.')
|
||||
process.exit(1)
|
||||
} else if (opts.buildFromSource) {
|
||||
log.info('install', '--build-from-source specified, not attempting download.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const startDownload = function (downloadUrl) {
|
||||
download(downloadUrl, opts, function (err) {
|
||||
if (err) {
|
||||
log.warn('install', err.message)
|
||||
return process.exit(1)
|
||||
}
|
||||
log.info('install', 'Successfully installed prebuilt binary!')
|
||||
})
|
||||
}
|
||||
|
||||
if (opts.token) {
|
||||
asset(opts, function (err, assetId) {
|
||||
if (err) {
|
||||
log.warn('install', err.message)
|
||||
return process.exit(1)
|
||||
}
|
||||
|
||||
startDownload(util.getAssetUrl(opts, assetId))
|
||||
})
|
||||
} else {
|
||||
startDownload(util.getDownloadUrl(opts))
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
export type IRenderableView = import("./interfaces").IRenderableView;
|
||||
export type PDFViewer = import("./pdf_viewer").PDFViewer;
|
||||
export type PDFThumbnailViewer = import("./pdf_thumbnail_viewer").PDFThumbnailViewer;
|
||||
/**
|
||||
* Controls rendering of the views for pages and thumbnails.
|
||||
*/
|
||||
export class PDFRenderingQueue {
|
||||
pdfViewer: import("./pdf_viewer").PDFViewer | null;
|
||||
pdfThumbnailViewer: import("./pdf_thumbnail_viewer").PDFThumbnailViewer | null;
|
||||
onIdle: any;
|
||||
highestPriorityPage: string | null;
|
||||
/** @type {number} */
|
||||
idleTimeout: number;
|
||||
printing: boolean;
|
||||
isThumbnailViewEnabled: boolean;
|
||||
/**
|
||||
* @param {PDFViewer} pdfViewer
|
||||
*/
|
||||
setViewer(pdfViewer: PDFViewer): void;
|
||||
/**
|
||||
* @param {PDFThumbnailViewer} pdfThumbnailViewer
|
||||
*/
|
||||
setThumbnailViewer(pdfThumbnailViewer: PDFThumbnailViewer): void;
|
||||
/**
|
||||
* @param {IRenderableView} view
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isHighestPriority(view: IRenderableView): boolean;
|
||||
/**
|
||||
* @param {Object} currentlyVisiblePages
|
||||
*/
|
||||
renderHighestPriority(currentlyVisiblePages: Object): void;
|
||||
/**
|
||||
* @param {Object} visible
|
||||
* @param {Array} views
|
||||
* @param {boolean} scrolledDown
|
||||
* @param {boolean} [preRenderExtra]
|
||||
*/
|
||||
getHighestPriority(visible: Object, views: any[], scrolledDown: boolean, preRenderExtra?: boolean | undefined): any;
|
||||
/**
|
||||
* @param {IRenderableView} view
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isViewFinished(view: IRenderableView): boolean;
|
||||
/**
|
||||
* Render a page or thumbnail view. This calls the appropriate function
|
||||
* based on the views state. If the view is already rendered it will return
|
||||
* `false`.
|
||||
*
|
||||
* @param {IRenderableView} view
|
||||
*/
|
||||
renderView(view: IRenderableView): boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user