Adding login and registration base pages
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\acorn\bin\acorn" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../acorn/bin/acorn" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../acorn/bin/acorn" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../acorn/bin/acorn" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\browserslist\cli.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../browserslist/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../browserslist/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../browserslist/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../browserslist/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\esbuild\bin\esbuild" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../esbuild/bin/esbuild" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../esbuild/bin/esbuild" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../esbuild/bin/esbuild" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../esbuild/bin/esbuild" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\eslint\bin\eslint.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../eslint/bin/eslint.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../eslint/bin/eslint.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../eslint/bin/eslint.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../eslint/bin/eslint.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\js-yaml\bin\js-yaml.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../js-yaml/bin/js-yaml.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\jsesc\bin\jsesc" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../jsesc/bin/jsesc" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../jsesc/bin/jsesc" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../jsesc/bin/jsesc" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../jsesc/bin/jsesc" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\json5\lib\cli.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../json5/lib/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nanoid\bin\nanoid.cjs" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../nanoid/bin/nanoid.cjs" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\which\bin\node-which" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../which/bin/node-which" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../which/bin/node-which" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\@babel\parser\bin\babel-parser.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../@babel/parser/bin/babel-parser.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../@babel/parser/bin/babel-parser.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../@babel/parser/bin/babel-parser.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../@babel/parser/bin/babel-parser.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\rollup\dist\bin\rollup" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../rollup/dist/bin/rollup" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../rollup/dist/bin/rollup" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../rollup/dist/bin/rollup" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../rollup/dist/bin/rollup" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../semver/bin/semver.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\update-browserslist-db\cli.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../update-browserslist-db/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../update-browserslist-db/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../update-browserslist-db/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../update-browserslist-db/cli.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\vite\bin\vite.js" %*
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../vite/bin/vite.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../vite/bin/vite.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../vite/bin/vite.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../vite/bin/vite.js" $args
|
||||
}
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
+278
@@ -0,0 +1,278 @@
|
||||
import {
|
||||
__commonJS,
|
||||
require_react
|
||||
} from "./chunk-V62QEVPD.js";
|
||||
|
||||
// node_modules/react-dom/cjs/react-dom.development.js
|
||||
var require_react_dom_development = __commonJS({
|
||||
"node_modules/react-dom/cjs/react-dom.development.js"(exports) {
|
||||
"use strict";
|
||||
(function() {
|
||||
function noop() {
|
||||
}
|
||||
function testStringCoercion(value) {
|
||||
return "" + value;
|
||||
}
|
||||
function createPortal$1(children, containerInfo, implementation) {
|
||||
var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
|
||||
try {
|
||||
testStringCoercion(key);
|
||||
var JSCompiler_inline_result = false;
|
||||
} catch (e) {
|
||||
JSCompiler_inline_result = true;
|
||||
}
|
||||
JSCompiler_inline_result && (console.error(
|
||||
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
||||
"function" === typeof Symbol && Symbol.toStringTag && key[Symbol.toStringTag] || key.constructor.name || "Object"
|
||||
), testStringCoercion(key));
|
||||
return {
|
||||
$$typeof: REACT_PORTAL_TYPE,
|
||||
key: null == key ? null : "" + key,
|
||||
children,
|
||||
containerInfo,
|
||||
implementation
|
||||
};
|
||||
}
|
||||
function getCrossOriginStringAs(as, input) {
|
||||
if ("font" === as) return "";
|
||||
if ("string" === typeof input)
|
||||
return "use-credentials" === input ? input : "";
|
||||
}
|
||||
function getValueDescriptorExpectingObjectForWarning(thing) {
|
||||
return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : 'something with type "' + typeof thing + '"';
|
||||
}
|
||||
function getValueDescriptorExpectingEnumForWarning(thing) {
|
||||
return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : "string" === typeof thing ? JSON.stringify(thing) : "number" === typeof thing ? "`" + thing + "`" : 'something with type "' + typeof thing + '"';
|
||||
}
|
||||
function resolveDispatcher() {
|
||||
var dispatcher = ReactSharedInternals.H;
|
||||
null === dispatcher && console.error(
|
||||
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
||||
);
|
||||
return dispatcher;
|
||||
}
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
||||
var React = require_react(), Internals = {
|
||||
d: {
|
||||
f: noop,
|
||||
r: function() {
|
||||
throw Error(
|
||||
"Invalid form element. requestFormReset must be passed a form that was rendered by React."
|
||||
);
|
||||
},
|
||||
D: noop,
|
||||
C: noop,
|
||||
L: noop,
|
||||
m: noop,
|
||||
X: noop,
|
||||
S: noop,
|
||||
M: noop
|
||||
},
|
||||
p: 0,
|
||||
findDOMNode: null
|
||||
}, REACT_PORTAL_TYPE = Symbol.for("react.portal"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
||||
"function" === typeof Map && null != Map.prototype && "function" === typeof Map.prototype.forEach && "function" === typeof Set && null != Set.prototype && "function" === typeof Set.prototype.clear && "function" === typeof Set.prototype.forEach || console.error(
|
||||
"React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"
|
||||
);
|
||||
exports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = Internals;
|
||||
exports.createPortal = function(children, container) {
|
||||
var key = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null;
|
||||
if (!container || 1 !== container.nodeType && 9 !== container.nodeType && 11 !== container.nodeType)
|
||||
throw Error("Target container is not a DOM element.");
|
||||
return createPortal$1(children, container, null, key);
|
||||
};
|
||||
exports.flushSync = function(fn) {
|
||||
var previousTransition = ReactSharedInternals.T, previousUpdatePriority = Internals.p;
|
||||
try {
|
||||
if (ReactSharedInternals.T = null, Internals.p = 2, fn)
|
||||
return fn();
|
||||
} finally {
|
||||
ReactSharedInternals.T = previousTransition, Internals.p = previousUpdatePriority, Internals.d.f() && console.error(
|
||||
"flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."
|
||||
);
|
||||
}
|
||||
};
|
||||
exports.preconnect = function(href, options) {
|
||||
"string" === typeof href && href ? null != options && "object" !== typeof options ? console.error(
|
||||
"ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",
|
||||
getValueDescriptorExpectingEnumForWarning(options)
|
||||
) : null != options && "string" !== typeof options.crossOrigin && console.error(
|
||||
"ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",
|
||||
getValueDescriptorExpectingObjectForWarning(options.crossOrigin)
|
||||
) : console.error(
|
||||
"ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
|
||||
getValueDescriptorExpectingObjectForWarning(href)
|
||||
);
|
||||
"string" === typeof href && (options ? (options = options.crossOrigin, options = "string" === typeof options ? "use-credentials" === options ? options : "" : void 0) : options = null, Internals.d.C(href, options));
|
||||
};
|
||||
exports.prefetchDNS = function(href) {
|
||||
if ("string" !== typeof href || !href)
|
||||
console.error(
|
||||
"ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
|
||||
getValueDescriptorExpectingObjectForWarning(href)
|
||||
);
|
||||
else if (1 < arguments.length) {
|
||||
var options = arguments[1];
|
||||
"object" === typeof options && options.hasOwnProperty("crossOrigin") ? console.error(
|
||||
"ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
|
||||
getValueDescriptorExpectingEnumForWarning(options)
|
||||
) : console.error(
|
||||
"ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
|
||||
getValueDescriptorExpectingEnumForWarning(options)
|
||||
);
|
||||
}
|
||||
"string" === typeof href && Internals.d.D(href);
|
||||
};
|
||||
exports.preinit = function(href, options) {
|
||||
"string" === typeof href && href ? null == options || "object" !== typeof options ? console.error(
|
||||
"ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",
|
||||
getValueDescriptorExpectingEnumForWarning(options)
|
||||
) : "style" !== options.as && "script" !== options.as && console.error(
|
||||
'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',
|
||||
getValueDescriptorExpectingEnumForWarning(options.as)
|
||||
) : console.error(
|
||||
"ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
|
||||
getValueDescriptorExpectingObjectForWarning(href)
|
||||
);
|
||||
if ("string" === typeof href && options && "string" === typeof options.as) {
|
||||
var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin), integrity = "string" === typeof options.integrity ? options.integrity : void 0, fetchPriority = "string" === typeof options.fetchPriority ? options.fetchPriority : void 0;
|
||||
"style" === as ? Internals.d.S(
|
||||
href,
|
||||
"string" === typeof options.precedence ? options.precedence : void 0,
|
||||
{
|
||||
crossOrigin,
|
||||
integrity,
|
||||
fetchPriority
|
||||
}
|
||||
) : "script" === as && Internals.d.X(href, {
|
||||
crossOrigin,
|
||||
integrity,
|
||||
fetchPriority,
|
||||
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.preinitModule = function(href, options) {
|
||||
var encountered = "";
|
||||
"string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
|
||||
void 0 !== options && "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : options && "as" in options && "script" !== options.as && (encountered += " The `as` option encountered was " + getValueDescriptorExpectingEnumForWarning(options.as) + ".");
|
||||
if (encountered)
|
||||
console.error(
|
||||
"ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",
|
||||
encountered
|
||||
);
|
||||
else
|
||||
switch (encountered = options && "string" === typeof options.as ? options.as : "script", encountered) {
|
||||
case "script":
|
||||
break;
|
||||
default:
|
||||
encountered = getValueDescriptorExpectingEnumForWarning(encountered), console.error(
|
||||
'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',
|
||||
encountered,
|
||||
href
|
||||
);
|
||||
}
|
||||
if ("string" === typeof href)
|
||||
if ("object" === typeof options && null !== options) {
|
||||
if (null == options.as || "script" === options.as)
|
||||
encountered = getCrossOriginStringAs(
|
||||
options.as,
|
||||
options.crossOrigin
|
||||
), Internals.d.M(href, {
|
||||
crossOrigin: encountered,
|
||||
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
||||
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
||||
});
|
||||
} else null == options && Internals.d.M(href);
|
||||
};
|
||||
exports.preload = function(href, options) {
|
||||
var encountered = "";
|
||||
"string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
|
||||
null == options || "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : "string" === typeof options.as && options.as || (encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".");
|
||||
encountered && console.error(
|
||||
'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',
|
||||
encountered
|
||||
);
|
||||
if ("string" === typeof href && "object" === typeof options && null !== options && "string" === typeof options.as) {
|
||||
encountered = options.as;
|
||||
var crossOrigin = getCrossOriginStringAs(
|
||||
encountered,
|
||||
options.crossOrigin
|
||||
);
|
||||
Internals.d.L(href, encountered, {
|
||||
crossOrigin,
|
||||
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
||||
nonce: "string" === typeof options.nonce ? options.nonce : void 0,
|
||||
type: "string" === typeof options.type ? options.type : void 0,
|
||||
fetchPriority: "string" === typeof options.fetchPriority ? options.fetchPriority : void 0,
|
||||
referrerPolicy: "string" === typeof options.referrerPolicy ? options.referrerPolicy : void 0,
|
||||
imageSrcSet: "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0,
|
||||
imageSizes: "string" === typeof options.imageSizes ? options.imageSizes : void 0,
|
||||
media: "string" === typeof options.media ? options.media : void 0
|
||||
});
|
||||
}
|
||||
};
|
||||
exports.preloadModule = function(href, options) {
|
||||
var encountered = "";
|
||||
"string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
|
||||
void 0 !== options && "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : options && "as" in options && "string" !== typeof options.as && (encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".");
|
||||
encountered && console.error(
|
||||
'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',
|
||||
encountered
|
||||
);
|
||||
"string" === typeof href && (options ? (encountered = getCrossOriginStringAs(
|
||||
options.as,
|
||||
options.crossOrigin
|
||||
), Internals.d.m(href, {
|
||||
as: "string" === typeof options.as && "script" !== options.as ? options.as : void 0,
|
||||
crossOrigin: encountered,
|
||||
integrity: "string" === typeof options.integrity ? options.integrity : void 0
|
||||
})) : Internals.d.m(href));
|
||||
};
|
||||
exports.requestFormReset = function(form) {
|
||||
Internals.d.r(form);
|
||||
};
|
||||
exports.unstable_batchedUpdates = function(fn, a) {
|
||||
return fn(a);
|
||||
};
|
||||
exports.useFormState = function(action, initialState, permalink) {
|
||||
return resolveDispatcher().useFormState(action, initialState, permalink);
|
||||
};
|
||||
exports.useFormStatus = function() {
|
||||
return resolveDispatcher().useHostTransitionStatus();
|
||||
};
|
||||
exports.version = "19.1.0";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
||||
})();
|
||||
}
|
||||
});
|
||||
|
||||
// node_modules/react-dom/index.js
|
||||
var require_react_dom = __commonJS({
|
||||
"node_modules/react-dom/index.js"(exports, module) {
|
||||
if (false) {
|
||||
checkDCE();
|
||||
module.exports = null;
|
||||
} else {
|
||||
module.exports = require_react_dom_development();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export {
|
||||
require_react_dom
|
||||
};
|
||||
/*! Bundled license information:
|
||||
|
||||
react-dom/cjs/react-dom.development.js:
|
||||
(**
|
||||
* @license React
|
||||
* react-dom.development.js
|
||||
*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
*/
|
||||
//# sourceMappingURL=chunk-G4HUE2DP.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+996
@@ -0,0 +1,996 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
|
||||
// node_modules/react/cjs/react.development.js
|
||||
var require_react_development = __commonJS({
|
||||
"node_modules/react/cjs/react.development.js"(exports, module) {
|
||||
"use strict";
|
||||
(function() {
|
||||
function defineDeprecationWarning(methodName, info) {
|
||||
Object.defineProperty(Component.prototype, methodName, {
|
||||
get: function() {
|
||||
console.warn(
|
||||
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
||||
info[0],
|
||||
info[1]
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
function getIteratorFn(maybeIterable) {
|
||||
if (null === maybeIterable || "object" !== typeof maybeIterable)
|
||||
return null;
|
||||
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
||||
return "function" === typeof maybeIterable ? maybeIterable : null;
|
||||
}
|
||||
function warnNoop(publicInstance, callerName) {
|
||||
publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
|
||||
var warningKey = publicInstance + "." + callerName;
|
||||
didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
|
||||
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
||||
callerName,
|
||||
publicInstance
|
||||
), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
|
||||
}
|
||||
function Component(props, context, updater) {
|
||||
this.props = props;
|
||||
this.context = context;
|
||||
this.refs = emptyObject;
|
||||
this.updater = updater || ReactNoopUpdateQueue;
|
||||
}
|
||||
function ComponentDummy() {
|
||||
}
|
||||
function PureComponent(props, context, updater) {
|
||||
this.props = props;
|
||||
this.context = context;
|
||||
this.refs = emptyObject;
|
||||
this.updater = updater || ReactNoopUpdateQueue;
|
||||
}
|
||||
function testStringCoercion(value) {
|
||||
return "" + value;
|
||||
}
|
||||
function checkKeyStringCoercion(value) {
|
||||
try {
|
||||
testStringCoercion(value);
|
||||
var JSCompiler_inline_result = false;
|
||||
} catch (e) {
|
||||
JSCompiler_inline_result = true;
|
||||
}
|
||||
if (JSCompiler_inline_result) {
|
||||
JSCompiler_inline_result = console;
|
||||
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
||||
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
||||
JSCompiler_temp_const.call(
|
||||
JSCompiler_inline_result,
|
||||
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
||||
JSCompiler_inline_result$jscomp$0
|
||||
);
|
||||
return testStringCoercion(value);
|
||||
}
|
||||
}
|
||||
function getComponentNameFromType(type) {
|
||||
if (null == type) return null;
|
||||
if ("function" === typeof type)
|
||||
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
||||
if ("string" === typeof type) return type;
|
||||
switch (type) {
|
||||
case REACT_FRAGMENT_TYPE:
|
||||
return "Fragment";
|
||||
case REACT_PROFILER_TYPE:
|
||||
return "Profiler";
|
||||
case REACT_STRICT_MODE_TYPE:
|
||||
return "StrictMode";
|
||||
case REACT_SUSPENSE_TYPE:
|
||||
return "Suspense";
|
||||
case REACT_SUSPENSE_LIST_TYPE:
|
||||
return "SuspenseList";
|
||||
case REACT_ACTIVITY_TYPE:
|
||||
return "Activity";
|
||||
}
|
||||
if ("object" === typeof type)
|
||||
switch ("number" === typeof type.tag && console.error(
|
||||
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
||||
), type.$$typeof) {
|
||||
case REACT_PORTAL_TYPE:
|
||||
return "Portal";
|
||||
case REACT_CONTEXT_TYPE:
|
||||
return (type.displayName || "Context") + ".Provider";
|
||||
case REACT_CONSUMER_TYPE:
|
||||
return (type._context.displayName || "Context") + ".Consumer";
|
||||
case REACT_FORWARD_REF_TYPE:
|
||||
var innerType = type.render;
|
||||
type = type.displayName;
|
||||
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
||||
return type;
|
||||
case REACT_MEMO_TYPE:
|
||||
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
||||
case REACT_LAZY_TYPE:
|
||||
innerType = type._payload;
|
||||
type = type._init;
|
||||
try {
|
||||
return getComponentNameFromType(type(innerType));
|
||||
} catch (x) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getTaskName(type) {
|
||||
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
||||
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
||||
return "<...>";
|
||||
try {
|
||||
var name = getComponentNameFromType(type);
|
||||
return name ? "<" + name + ">" : "<...>";
|
||||
} catch (x) {
|
||||
return "<...>";
|
||||
}
|
||||
}
|
||||
function getOwner() {
|
||||
var dispatcher = ReactSharedInternals.A;
|
||||
return null === dispatcher ? null : dispatcher.getOwner();
|
||||
}
|
||||
function UnknownOwner() {
|
||||
return Error("react-stack-top-frame");
|
||||
}
|
||||
function hasValidKey(config) {
|
||||
if (hasOwnProperty.call(config, "key")) {
|
||||
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
||||
if (getter && getter.isReactWarning) return false;
|
||||
}
|
||||
return void 0 !== config.key;
|
||||
}
|
||||
function defineKeyPropWarningGetter(props, displayName) {
|
||||
function warnAboutAccessingKey() {
|
||||
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
||||
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
||||
displayName
|
||||
));
|
||||
}
|
||||
warnAboutAccessingKey.isReactWarning = true;
|
||||
Object.defineProperty(props, "key", {
|
||||
get: warnAboutAccessingKey,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
function elementRefGetterWithDeprecationWarning() {
|
||||
var componentName = getComponentNameFromType(this.type);
|
||||
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
||||
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
||||
));
|
||||
componentName = this.props.ref;
|
||||
return void 0 !== componentName ? componentName : null;
|
||||
}
|
||||
function ReactElement(type, key, self, source, owner, props, debugStack, debugTask) {
|
||||
self = props.ref;
|
||||
type = {
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
type,
|
||||
key,
|
||||
props,
|
||||
_owner: owner
|
||||
};
|
||||
null !== (void 0 !== self ? self : null) ? Object.defineProperty(type, "ref", {
|
||||
enumerable: false,
|
||||
get: elementRefGetterWithDeprecationWarning
|
||||
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
||||
type._store = {};
|
||||
Object.defineProperty(type._store, "validated", {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: 0
|
||||
});
|
||||
Object.defineProperty(type, "_debugInfo", {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: null
|
||||
});
|
||||
Object.defineProperty(type, "_debugStack", {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: debugStack
|
||||
});
|
||||
Object.defineProperty(type, "_debugTask", {
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: debugTask
|
||||
});
|
||||
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
||||
return type;
|
||||
}
|
||||
function cloneAndReplaceKey(oldElement, newKey) {
|
||||
newKey = ReactElement(
|
||||
oldElement.type,
|
||||
newKey,
|
||||
void 0,
|
||||
void 0,
|
||||
oldElement._owner,
|
||||
oldElement.props,
|
||||
oldElement._debugStack,
|
||||
oldElement._debugTask
|
||||
);
|
||||
oldElement._store && (newKey._store.validated = oldElement._store.validated);
|
||||
return newKey;
|
||||
}
|
||||
function isValidElement(object) {
|
||||
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
function escape(key) {
|
||||
var escaperLookup = { "=": "=0", ":": "=2" };
|
||||
return "$" + key.replace(/[=:]/g, function(match) {
|
||||
return escaperLookup[match];
|
||||
});
|
||||
}
|
||||
function getElementKey(element, index) {
|
||||
return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
|
||||
}
|
||||
function noop$1() {
|
||||
}
|
||||
function resolveThenable(thenable) {
|
||||
switch (thenable.status) {
|
||||
case "fulfilled":
|
||||
return thenable.value;
|
||||
case "rejected":
|
||||
throw thenable.reason;
|
||||
default:
|
||||
switch ("string" === typeof thenable.status ? thenable.then(noop$1, noop$1) : (thenable.status = "pending", thenable.then(
|
||||
function(fulfilledValue) {
|
||||
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
||||
},
|
||||
function(error) {
|
||||
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
||||
}
|
||||
)), thenable.status) {
|
||||
case "fulfilled":
|
||||
return thenable.value;
|
||||
case "rejected":
|
||||
throw thenable.reason;
|
||||
}
|
||||
}
|
||||
throw thenable;
|
||||
}
|
||||
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
||||
var type = typeof children;
|
||||
if ("undefined" === type || "boolean" === type) children = null;
|
||||
var invokeCallback = false;
|
||||
if (null === children) invokeCallback = true;
|
||||
else
|
||||
switch (type) {
|
||||
case "bigint":
|
||||
case "string":
|
||||
case "number":
|
||||
invokeCallback = true;
|
||||
break;
|
||||
case "object":
|
||||
switch (children.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
case REACT_PORTAL_TYPE:
|
||||
invokeCallback = true;
|
||||
break;
|
||||
case REACT_LAZY_TYPE:
|
||||
return invokeCallback = children._init, mapIntoArray(
|
||||
invokeCallback(children._payload),
|
||||
array,
|
||||
escapedPrefix,
|
||||
nameSoFar,
|
||||
callback
|
||||
);
|
||||
}
|
||||
}
|
||||
if (invokeCallback) {
|
||||
invokeCallback = children;
|
||||
callback = callback(invokeCallback);
|
||||
var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
|
||||
isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
||||
return c;
|
||||
})) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
|
||||
callback,
|
||||
escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
|
||||
userProvidedKeyEscapeRegex,
|
||||
"$&/"
|
||||
) + "/") + childKey
|
||||
), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
|
||||
return 1;
|
||||
}
|
||||
invokeCallback = 0;
|
||||
childKey = "" === nameSoFar ? "." : nameSoFar + ":";
|
||||
if (isArrayImpl(children))
|
||||
for (var i = 0; i < children.length; i++)
|
||||
nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
||||
nameSoFar,
|
||||
array,
|
||||
escapedPrefix,
|
||||
type,
|
||||
callback
|
||||
);
|
||||
else if (i = getIteratorFn(children), "function" === typeof i)
|
||||
for (i === children.entries && (didWarnAboutMaps || console.warn(
|
||||
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
||||
), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
||||
nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
||||
nameSoFar,
|
||||
array,
|
||||
escapedPrefix,
|
||||
type,
|
||||
callback
|
||||
);
|
||||
else if ("object" === type) {
|
||||
if ("function" === typeof children.then)
|
||||
return mapIntoArray(
|
||||
resolveThenable(children),
|
||||
array,
|
||||
escapedPrefix,
|
||||
nameSoFar,
|
||||
callback
|
||||
);
|
||||
array = String(children);
|
||||
throw Error(
|
||||
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
||||
);
|
||||
}
|
||||
return invokeCallback;
|
||||
}
|
||||
function mapChildren(children, func, context) {
|
||||
if (null == children) return children;
|
||||
var result = [], count = 0;
|
||||
mapIntoArray(children, result, "", "", function(child) {
|
||||
return func.call(context, child, count++);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function lazyInitializer(payload) {
|
||||
if (-1 === payload._status) {
|
||||
var ctor = payload._result;
|
||||
ctor = ctor();
|
||||
ctor.then(
|
||||
function(moduleObject) {
|
||||
if (0 === payload._status || -1 === payload._status)
|
||||
payload._status = 1, payload._result = moduleObject;
|
||||
},
|
||||
function(error) {
|
||||
if (0 === payload._status || -1 === payload._status)
|
||||
payload._status = 2, payload._result = error;
|
||||
}
|
||||
);
|
||||
-1 === payload._status && (payload._status = 0, payload._result = ctor);
|
||||
}
|
||||
if (1 === payload._status)
|
||||
return ctor = payload._result, void 0 === ctor && console.error(
|
||||
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
|
||||
ctor
|
||||
), "default" in ctor || console.error(
|
||||
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
|
||||
ctor
|
||||
), ctor.default;
|
||||
throw payload._result;
|
||||
}
|
||||
function resolveDispatcher() {
|
||||
var dispatcher = ReactSharedInternals.H;
|
||||
null === dispatcher && console.error(
|
||||
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
||||
);
|
||||
return dispatcher;
|
||||
}
|
||||
function noop() {
|
||||
}
|
||||
function enqueueTask(task) {
|
||||
if (null === enqueueTaskImpl)
|
||||
try {
|
||||
var requireString = ("require" + Math.random()).slice(0, 7);
|
||||
enqueueTaskImpl = (module && module[requireString]).call(
|
||||
module,
|
||||
"timers"
|
||||
).setImmediate;
|
||||
} catch (_err) {
|
||||
enqueueTaskImpl = function(callback) {
|
||||
false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
|
||||
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
||||
));
|
||||
var channel = new MessageChannel();
|
||||
channel.port1.onmessage = callback;
|
||||
channel.port2.postMessage(void 0);
|
||||
};
|
||||
}
|
||||
return enqueueTaskImpl(task);
|
||||
}
|
||||
function aggregateErrors(errors) {
|
||||
return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
|
||||
}
|
||||
function popActScope(prevActQueue, prevActScopeDepth) {
|
||||
prevActScopeDepth !== actScopeDepth - 1 && console.error(
|
||||
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
||||
);
|
||||
actScopeDepth = prevActScopeDepth;
|
||||
}
|
||||
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
||||
var queue = ReactSharedInternals.actQueue;
|
||||
if (null !== queue)
|
||||
if (0 !== queue.length)
|
||||
try {
|
||||
flushActQueue(queue);
|
||||
enqueueTask(function() {
|
||||
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
||||
});
|
||||
return;
|
||||
} catch (error) {
|
||||
ReactSharedInternals.thrownErrors.push(error);
|
||||
}
|
||||
else ReactSharedInternals.actQueue = null;
|
||||
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
|
||||
}
|
||||
function flushActQueue(queue) {
|
||||
if (!isFlushing) {
|
||||
isFlushing = true;
|
||||
var i = 0;
|
||||
try {
|
||||
for (; i < queue.length; i++) {
|
||||
var callback = queue[i];
|
||||
do {
|
||||
ReactSharedInternals.didUsePromise = false;
|
||||
var continuation = callback(false);
|
||||
if (null !== continuation) {
|
||||
if (ReactSharedInternals.didUsePromise) {
|
||||
queue[i] = callback;
|
||||
queue.splice(0, i);
|
||||
return;
|
||||
}
|
||||
callback = continuation;
|
||||
} else break;
|
||||
} while (1);
|
||||
}
|
||||
queue.length = 0;
|
||||
} catch (error) {
|
||||
queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
|
||||
} finally {
|
||||
isFlushing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
||||
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
||||
Symbol.for("react.provider");
|
||||
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
|
||||
isMounted: function() {
|
||||
return false;
|
||||
},
|
||||
enqueueForceUpdate: function(publicInstance) {
|
||||
warnNoop(publicInstance, "forceUpdate");
|
||||
},
|
||||
enqueueReplaceState: function(publicInstance) {
|
||||
warnNoop(publicInstance, "replaceState");
|
||||
},
|
||||
enqueueSetState: function(publicInstance) {
|
||||
warnNoop(publicInstance, "setState");
|
||||
}
|
||||
}, assign = Object.assign, emptyObject = {};
|
||||
Object.freeze(emptyObject);
|
||||
Component.prototype.isReactComponent = {};
|
||||
Component.prototype.setState = function(partialState, callback) {
|
||||
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
||||
throw Error(
|
||||
"takes an object of state variables to update or a function which returns an object of state variables."
|
||||
);
|
||||
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
||||
};
|
||||
Component.prototype.forceUpdate = function(callback) {
|
||||
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
||||
};
|
||||
var deprecatedAPIs = {
|
||||
isMounted: [
|
||||
"isMounted",
|
||||
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
||||
],
|
||||
replaceState: [
|
||||
"replaceState",
|
||||
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
||||
]
|
||||
}, fnName;
|
||||
for (fnName in deprecatedAPIs)
|
||||
deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
||||
ComponentDummy.prototype = Component.prototype;
|
||||
deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
|
||||
deprecatedAPIs.constructor = PureComponent;
|
||||
assign(deprecatedAPIs, Component.prototype);
|
||||
deprecatedAPIs.isPureReactComponent = true;
|
||||
var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
|
||||
H: null,
|
||||
A: null,
|
||||
T: null,
|
||||
S: null,
|
||||
V: null,
|
||||
actQueue: null,
|
||||
isBatchingLegacy: false,
|
||||
didScheduleLegacyUpdate: false,
|
||||
didUsePromise: false,
|
||||
thrownErrors: [],
|
||||
getCurrentStack: null,
|
||||
recentlyCreatedOwnerStacks: 0
|
||||
}, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
|
||||
return null;
|
||||
};
|
||||
deprecatedAPIs = {
|
||||
"react-stack-bottom-frame": function(callStackForError) {
|
||||
return callStackForError();
|
||||
}
|
||||
};
|
||||
var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
|
||||
var didWarnAboutElementRef = {};
|
||||
var unknownOwnerDebugStack = deprecatedAPIs["react-stack-bottom-frame"].bind(deprecatedAPIs, UnknownOwner)();
|
||||
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
||||
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
||||
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
||||
var event = new window.ErrorEvent("error", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
||||
error
|
||||
});
|
||||
if (!window.dispatchEvent(event)) return;
|
||||
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
||||
process.emit("uncaughtException", error);
|
||||
return;
|
||||
}
|
||||
console.error(error);
|
||||
}, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
|
||||
queueMicrotask(function() {
|
||||
return queueMicrotask(callback);
|
||||
});
|
||||
} : enqueueTask;
|
||||
deprecatedAPIs = Object.freeze({
|
||||
__proto__: null,
|
||||
c: function(size) {
|
||||
return resolveDispatcher().useMemoCache(size);
|
||||
}
|
||||
});
|
||||
exports.Children = {
|
||||
map: mapChildren,
|
||||
forEach: function(children, forEachFunc, forEachContext) {
|
||||
mapChildren(
|
||||
children,
|
||||
function() {
|
||||
forEachFunc.apply(this, arguments);
|
||||
},
|
||||
forEachContext
|
||||
);
|
||||
},
|
||||
count: function(children) {
|
||||
var n = 0;
|
||||
mapChildren(children, function() {
|
||||
n++;
|
||||
});
|
||||
return n;
|
||||
},
|
||||
toArray: function(children) {
|
||||
return mapChildren(children, function(child) {
|
||||
return child;
|
||||
}) || [];
|
||||
},
|
||||
only: function(children) {
|
||||
if (!isValidElement(children))
|
||||
throw Error(
|
||||
"React.Children.only expected to receive a single React element child."
|
||||
);
|
||||
return children;
|
||||
}
|
||||
};
|
||||
exports.Component = Component;
|
||||
exports.Fragment = REACT_FRAGMENT_TYPE;
|
||||
exports.Profiler = REACT_PROFILER_TYPE;
|
||||
exports.PureComponent = PureComponent;
|
||||
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
||||
exports.Suspense = REACT_SUSPENSE_TYPE;
|
||||
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
||||
exports.__COMPILER_RUNTIME = deprecatedAPIs;
|
||||
exports.act = function(callback) {
|
||||
var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
|
||||
actScopeDepth++;
|
||||
var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
|
||||
try {
|
||||
var result = callback();
|
||||
} catch (error) {
|
||||
ReactSharedInternals.thrownErrors.push(error);
|
||||
}
|
||||
if (0 < ReactSharedInternals.thrownErrors.length)
|
||||
throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
||||
if (null !== result && "object" === typeof result && "function" === typeof result.then) {
|
||||
var thenable = result;
|
||||
queueSeveralMicrotasks(function() {
|
||||
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
||||
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
||||
));
|
||||
});
|
||||
return {
|
||||
then: function(resolve, reject) {
|
||||
didAwaitActCall = true;
|
||||
thenable.then(
|
||||
function(returnValue) {
|
||||
popActScope(prevActQueue, prevActScopeDepth);
|
||||
if (0 === prevActScopeDepth) {
|
||||
try {
|
||||
flushActQueue(queue), enqueueTask(function() {
|
||||
return recursivelyFlushAsyncActWork(
|
||||
returnValue,
|
||||
resolve,
|
||||
reject
|
||||
);
|
||||
});
|
||||
} catch (error$0) {
|
||||
ReactSharedInternals.thrownErrors.push(error$0);
|
||||
}
|
||||
if (0 < ReactSharedInternals.thrownErrors.length) {
|
||||
var _thrownError = aggregateErrors(
|
||||
ReactSharedInternals.thrownErrors
|
||||
);
|
||||
ReactSharedInternals.thrownErrors.length = 0;
|
||||
reject(_thrownError);
|
||||
}
|
||||
} else resolve(returnValue);
|
||||
},
|
||||
function(error) {
|
||||
popActScope(prevActQueue, prevActScopeDepth);
|
||||
0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
|
||||
ReactSharedInternals.thrownErrors
|
||||
), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
var returnValue$jscomp$0 = result;
|
||||
popActScope(prevActQueue, prevActScopeDepth);
|
||||
0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
|
||||
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
||||
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
||||
));
|
||||
}), ReactSharedInternals.actQueue = null);
|
||||
if (0 < ReactSharedInternals.thrownErrors.length)
|
||||
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
||||
return {
|
||||
then: function(resolve, reject) {
|
||||
didAwaitActCall = true;
|
||||
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
||||
return recursivelyFlushAsyncActWork(
|
||||
returnValue$jscomp$0,
|
||||
resolve,
|
||||
reject
|
||||
);
|
||||
})) : resolve(returnValue$jscomp$0);
|
||||
}
|
||||
};
|
||||
};
|
||||
exports.cache = function(fn) {
|
||||
return function() {
|
||||
return fn.apply(null, arguments);
|
||||
};
|
||||
};
|
||||
exports.captureOwnerStack = function() {
|
||||
var getCurrentStack = ReactSharedInternals.getCurrentStack;
|
||||
return null === getCurrentStack ? null : getCurrentStack();
|
||||
};
|
||||
exports.cloneElement = function(element, config, children) {
|
||||
if (null === element || void 0 === element)
|
||||
throw Error(
|
||||
"The argument must be a React element, but you passed " + element + "."
|
||||
);
|
||||
var props = assign({}, element.props), key = element.key, owner = element._owner;
|
||||
if (null != config) {
|
||||
var JSCompiler_inline_result;
|
||||
a: {
|
||||
if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
|
||||
config,
|
||||
"ref"
|
||||
).get) && JSCompiler_inline_result.isReactWarning) {
|
||||
JSCompiler_inline_result = false;
|
||||
break a;
|
||||
}
|
||||
JSCompiler_inline_result = void 0 !== config.ref;
|
||||
}
|
||||
JSCompiler_inline_result && (owner = getOwner());
|
||||
hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
|
||||
for (propName in config)
|
||||
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
||||
}
|
||||
var propName = arguments.length - 2;
|
||||
if (1 === propName) props.children = children;
|
||||
else if (1 < propName) {
|
||||
JSCompiler_inline_result = Array(propName);
|
||||
for (var i = 0; i < propName; i++)
|
||||
JSCompiler_inline_result[i] = arguments[i + 2];
|
||||
props.children = JSCompiler_inline_result;
|
||||
}
|
||||
props = ReactElement(
|
||||
element.type,
|
||||
key,
|
||||
void 0,
|
||||
void 0,
|
||||
owner,
|
||||
props,
|
||||
element._debugStack,
|
||||
element._debugTask
|
||||
);
|
||||
for (key = 2; key < arguments.length; key++)
|
||||
owner = arguments[key], isValidElement(owner) && owner._store && (owner._store.validated = 1);
|
||||
return props;
|
||||
};
|
||||
exports.createContext = function(defaultValue) {
|
||||
defaultValue = {
|
||||
$$typeof: REACT_CONTEXT_TYPE,
|
||||
_currentValue: defaultValue,
|
||||
_currentValue2: defaultValue,
|
||||
_threadCount: 0,
|
||||
Provider: null,
|
||||
Consumer: null
|
||||
};
|
||||
defaultValue.Provider = defaultValue;
|
||||
defaultValue.Consumer = {
|
||||
$$typeof: REACT_CONSUMER_TYPE,
|
||||
_context: defaultValue
|
||||
};
|
||||
defaultValue._currentRenderer = null;
|
||||
defaultValue._currentRenderer2 = null;
|
||||
return defaultValue;
|
||||
};
|
||||
exports.createElement = function(type, config, children) {
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var node = arguments[i];
|
||||
isValidElement(node) && node._store && (node._store.validated = 1);
|
||||
}
|
||||
i = {};
|
||||
node = null;
|
||||
if (null != config)
|
||||
for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
|
||||
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
||||
)), hasValidKey(config) && (checkKeyStringCoercion(config.key), node = "" + config.key), config)
|
||||
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
|
||||
var childrenLength = arguments.length - 2;
|
||||
if (1 === childrenLength) i.children = children;
|
||||
else if (1 < childrenLength) {
|
||||
for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
|
||||
childArray[_i] = arguments[_i + 2];
|
||||
Object.freeze && Object.freeze(childArray);
|
||||
i.children = childArray;
|
||||
}
|
||||
if (type && type.defaultProps)
|
||||
for (propName in childrenLength = type.defaultProps, childrenLength)
|
||||
void 0 === i[propName] && (i[propName] = childrenLength[propName]);
|
||||
node && defineKeyPropWarningGetter(
|
||||
i,
|
||||
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
||||
);
|
||||
var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
||||
return ReactElement(
|
||||
type,
|
||||
node,
|
||||
void 0,
|
||||
void 0,
|
||||
getOwner(),
|
||||
i,
|
||||
propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
||||
propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
||||
);
|
||||
};
|
||||
exports.createRef = function() {
|
||||
var refObject = { current: null };
|
||||
Object.seal(refObject);
|
||||
return refObject;
|
||||
};
|
||||
exports.forwardRef = function(render) {
|
||||
null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
|
||||
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
||||
) : "function" !== typeof render ? console.error(
|
||||
"forwardRef requires a render function but was given %s.",
|
||||
null === render ? "null" : typeof render
|
||||
) : 0 !== render.length && 2 !== render.length && console.error(
|
||||
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
||||
1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
||||
);
|
||||
null != render && null != render.defaultProps && console.error(
|
||||
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
||||
);
|
||||
var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
|
||||
Object.defineProperty(elementType, "displayName", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
get: function() {
|
||||
return ownName;
|
||||
},
|
||||
set: function(name) {
|
||||
ownName = name;
|
||||
render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
|
||||
}
|
||||
});
|
||||
return elementType;
|
||||
};
|
||||
exports.isValidElement = isValidElement;
|
||||
exports.lazy = function(ctor) {
|
||||
return {
|
||||
$$typeof: REACT_LAZY_TYPE,
|
||||
_payload: { _status: -1, _result: ctor },
|
||||
_init: lazyInitializer
|
||||
};
|
||||
};
|
||||
exports.memo = function(type, compare) {
|
||||
null == type && console.error(
|
||||
"memo: The first argument must be a component. Instead received: %s",
|
||||
null === type ? "null" : typeof type
|
||||
);
|
||||
compare = {
|
||||
$$typeof: REACT_MEMO_TYPE,
|
||||
type,
|
||||
compare: void 0 === compare ? null : compare
|
||||
};
|
||||
var ownName;
|
||||
Object.defineProperty(compare, "displayName", {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
get: function() {
|
||||
return ownName;
|
||||
},
|
||||
set: function(name) {
|
||||
ownName = name;
|
||||
type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
|
||||
}
|
||||
});
|
||||
return compare;
|
||||
};
|
||||
exports.startTransition = function(scope) {
|
||||
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
||||
ReactSharedInternals.T = currentTransition;
|
||||
currentTransition._updatedFibers = /* @__PURE__ */ new Set();
|
||||
try {
|
||||
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
||||
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
||||
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
|
||||
} catch (error) {
|
||||
reportGlobalError(error);
|
||||
} finally {
|
||||
null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
|
||||
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
||||
)), ReactSharedInternals.T = prevTransition;
|
||||
}
|
||||
};
|
||||
exports.unstable_useCacheRefresh = function() {
|
||||
return resolveDispatcher().useCacheRefresh();
|
||||
};
|
||||
exports.use = function(usable) {
|
||||
return resolveDispatcher().use(usable);
|
||||
};
|
||||
exports.useActionState = function(action, initialState, permalink) {
|
||||
return resolveDispatcher().useActionState(
|
||||
action,
|
||||
initialState,
|
||||
permalink
|
||||
);
|
||||
};
|
||||
exports.useCallback = function(callback, deps) {
|
||||
return resolveDispatcher().useCallback(callback, deps);
|
||||
};
|
||||
exports.useContext = function(Context) {
|
||||
var dispatcher = resolveDispatcher();
|
||||
Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
|
||||
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
||||
);
|
||||
return dispatcher.useContext(Context);
|
||||
};
|
||||
exports.useDebugValue = function(value, formatterFn) {
|
||||
return resolveDispatcher().useDebugValue(value, formatterFn);
|
||||
};
|
||||
exports.useDeferredValue = function(value, initialValue) {
|
||||
return resolveDispatcher().useDeferredValue(value, initialValue);
|
||||
};
|
||||
exports.useEffect = function(create, createDeps, update) {
|
||||
null == create && console.warn(
|
||||
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
||||
);
|
||||
var dispatcher = resolveDispatcher();
|
||||
if ("function" === typeof update)
|
||||
throw Error(
|
||||
"useEffect CRUD overload is not enabled in this build of React."
|
||||
);
|
||||
return dispatcher.useEffect(create, createDeps);
|
||||
};
|
||||
exports.useId = function() {
|
||||
return resolveDispatcher().useId();
|
||||
};
|
||||
exports.useImperativeHandle = function(ref, create, deps) {
|
||||
return resolveDispatcher().useImperativeHandle(ref, create, deps);
|
||||
};
|
||||
exports.useInsertionEffect = function(create, deps) {
|
||||
null == create && console.warn(
|
||||
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
||||
);
|
||||
return resolveDispatcher().useInsertionEffect(create, deps);
|
||||
};
|
||||
exports.useLayoutEffect = function(create, deps) {
|
||||
null == create && console.warn(
|
||||
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
||||
);
|
||||
return resolveDispatcher().useLayoutEffect(create, deps);
|
||||
};
|
||||
exports.useMemo = function(create, deps) {
|
||||
return resolveDispatcher().useMemo(create, deps);
|
||||
};
|
||||
exports.useOptimistic = function(passthrough, reducer) {
|
||||
return resolveDispatcher().useOptimistic(passthrough, reducer);
|
||||
};
|
||||
exports.useReducer = function(reducer, initialArg, init) {
|
||||
return resolveDispatcher().useReducer(reducer, initialArg, init);
|
||||
};
|
||||
exports.useRef = function(initialValue) {
|
||||
return resolveDispatcher().useRef(initialValue);
|
||||
};
|
||||
exports.useState = function(initialState) {
|
||||
return resolveDispatcher().useState(initialState);
|
||||
};
|
||||
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
||||
return resolveDispatcher().useSyncExternalStore(
|
||||
subscribe,
|
||||
getSnapshot,
|
||||
getServerSnapshot
|
||||
);
|
||||
};
|
||||
exports.useTransition = function() {
|
||||
return resolveDispatcher().useTransition();
|
||||
};
|
||||
exports.version = "19.1.0";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
||||
})();
|
||||
}
|
||||
});
|
||||
|
||||
// node_modules/react/index.js
|
||||
var require_react = __commonJS({
|
||||
"node_modules/react/index.js"(exports, module) {
|
||||
if (false) {
|
||||
module.exports = null;
|
||||
} else {
|
||||
module.exports = require_react_development();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export {
|
||||
__commonJS,
|
||||
__toESM,
|
||||
require_react
|
||||
};
|
||||
/*! Bundled license information:
|
||||
|
||||
react/cjs/react.development.js:
|
||||
(**
|
||||
* @license React
|
||||
* react.development.js
|
||||
*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
*/
|
||||
//# sourceMappingURL=chunk-V62QEVPD.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+12093
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+3
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the Windows 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
Binary file not shown.
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@esbuild/win32-x64",
|
||||
"version": "0.25.4",
|
||||
"description": "The Windows 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
# `@rollup/rollup-win32-x64-msvc`
|
||||
|
||||
This is the **x86_64-pc-windows-msvc** binary for `rollup`
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@rollup/rollup-win32-x64-msvc",
|
||||
"version": "4.40.2",
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"files": [
|
||||
"rollup.win32-x64-msvc.node"
|
||||
],
|
||||
"description": "Native bindings for Rollup",
|
||||
"author": "Lukas Taegert-Atkinson",
|
||||
"homepage": "https://rollupjs.org/",
|
||||
"license": "MIT",
|
||||
"repository": "rollup/rollup",
|
||||
"main": "./rollup.win32-x64-msvc.node"
|
||||
}
|
||||
BIN
Binary file not shown.
+23
@@ -0,0 +1,23 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) React Training LLC 2015-2019
|
||||
Copyright (c) Remix Software Inc. 2020-2021
|
||||
Copyright (c) Shopify Inc. 2022-2023
|
||||
|
||||
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.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
This package simply re-exports everything from `react-router` to smooth the upgrade path for v6 applications. Once upgraded you can change all of your imports and remove it from your dependencies:
|
||||
|
||||
```diff
|
||||
-import { Routes } from "react-router-dom"
|
||||
+import { Routes } from "react-router"
|
||||
```
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { HydratedRouter, RouterProvider, RouterProviderProps } from 'react-router/dom';
|
||||
export * from 'react-router';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { HydratedRouter, RouterProvider, RouterProviderProps } from 'react-router/dom';
|
||||
export * from 'react-router';
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* react-router-dom v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// index.ts
|
||||
var react_router_dom_exports = {};
|
||||
__export(react_router_dom_exports, {
|
||||
HydratedRouter: () => import_dom.HydratedRouter,
|
||||
RouterProvider: () => import_dom.RouterProvider
|
||||
});
|
||||
module.exports = __toCommonJS(react_router_dom_exports);
|
||||
var import_dom = require("react-router/dom");
|
||||
__reExport(react_router_dom_exports, require("react-router"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
HydratedRouter,
|
||||
RouterProvider,
|
||||
...require("react-router")
|
||||
});
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* react-router-dom v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
// index.ts
|
||||
import { HydratedRouter, RouterProvider } from "react-router/dom";
|
||||
export * from "react-router";
|
||||
export {
|
||||
HydratedRouter,
|
||||
RouterProvider
|
||||
};
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "react-router-dom",
|
||||
"version": "7.6.0",
|
||||
"description": "Declarative routing for React web applications",
|
||||
"keywords": [
|
||||
"react",
|
||||
"router",
|
||||
"route",
|
||||
"routing",
|
||||
"history",
|
||||
"link"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remix-run/react-router",
|
||||
"directory": "packages/react-router-dom"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Remix Software <[email protected]>",
|
||||
"sideEffects": false,
|
||||
"main": "./dist/main.js",
|
||||
"unpkg": "./dist/umd/react-router-dom.production.min.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"module-sync": "./dist/index.mjs",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"wireit": {
|
||||
"build": {
|
||||
"command": "tsup",
|
||||
"files": [
|
||||
"*.ts",
|
||||
"tsconfig.json",
|
||||
"package.json"
|
||||
],
|
||||
"output": [
|
||||
"dist/**"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"react-router": "7.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"tsup": "^8.3.0",
|
||||
"typescript": "^5.1.6",
|
||||
"wireit": "0.14.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"LICENSE.md",
|
||||
"README.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "wireit",
|
||||
"typecheck": "tsc"
|
||||
}
|
||||
}
|
||||
+1657
File diff suppressed because it is too large
Load Diff
+23
@@ -0,0 +1,23 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) React Training LLC 2015-2019
|
||||
Copyright (c) Remix Software Inc. 2020-2021
|
||||
Copyright (c) Shopify Inc. 2022-2023
|
||||
|
||||
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.
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
`react-router` is the primary package in the React Router project.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm i react-router
|
||||
```
|
||||
+11556
File diff suppressed because it is too large
Load Diff
+23
@@ -0,0 +1,23 @@
|
||||
import * as React from 'react';
|
||||
import { R as RouterProviderProps$1 } from './lib-CCSAGgcP.mjs';
|
||||
import { R as RouterInit } from './route-data-C6QaL0wu.mjs';
|
||||
|
||||
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
||||
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
||||
|
||||
interface HydratedRouterProps {
|
||||
/**
|
||||
* Context object to passed through to `createBrowserRouter` and made available
|
||||
* to `clientLoader`/`clientActon` functions
|
||||
*/
|
||||
unstable_getContext?: RouterInit["unstable_getContext"];
|
||||
}
|
||||
/**
|
||||
* Framework-mode router component to be used in `entry.client.tsx` to hydrate a
|
||||
* router from a `ServerRouter`
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
||||
|
||||
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import * as React from 'react';
|
||||
import { RouterProviderProps as RouterProviderProps$1, RouterInit } from 'react-router';
|
||||
|
||||
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
||||
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
||||
|
||||
interface HydratedRouterProps {
|
||||
/**
|
||||
* Context object to passed through to `createBrowserRouter` and made available
|
||||
* to `clientLoader`/`clientActon` functions
|
||||
*/
|
||||
unstable_getContext?: RouterInit["unstable_getContext"];
|
||||
}
|
||||
/**
|
||||
* Framework-mode router component to be used in `entry.client.tsx` to hydrate a
|
||||
* router from a `ServerRouter`
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
||||
|
||||
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// dom-export.ts
|
||||
var dom_export_exports = {};
|
||||
__export(dom_export_exports, {
|
||||
HydratedRouter: () => HydratedRouter,
|
||||
RouterProvider: () => RouterProvider
|
||||
});
|
||||
module.exports = __toCommonJS(dom_export_exports);
|
||||
|
||||
// lib/dom-export/dom-router-provider.tsx
|
||||
var React = __toESM(require("react"));
|
||||
var ReactDOM = __toESM(require("react-dom"));
|
||||
var import_react_router = require("react-router");
|
||||
function RouterProvider(props) {
|
||||
return /* @__PURE__ */ React.createElement(import_react_router.RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
||||
}
|
||||
|
||||
// lib/dom-export/hydrated-router.tsx
|
||||
var React2 = __toESM(require("react"));
|
||||
var import_react_router2 = require("react-router");
|
||||
var ssrInfo = null;
|
||||
var router = null;
|
||||
function initSsrInfo() {
|
||||
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
||||
if (window.__reactRouterManifest.sri === true) {
|
||||
const importMap = document.querySelector("script[rr-importmap]");
|
||||
if (importMap?.textContent) {
|
||||
try {
|
||||
window.__reactRouterManifest.sri = JSON.parse(
|
||||
importMap.textContent
|
||||
).integrity;
|
||||
} catch (err) {
|
||||
console.error("Failed to parse import map", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
ssrInfo = {
|
||||
context: window.__reactRouterContext,
|
||||
manifest: window.__reactRouterManifest,
|
||||
routeModules: window.__reactRouterRouteModules,
|
||||
stateDecodingPromise: void 0,
|
||||
router: void 0,
|
||||
routerInitialized: false
|
||||
};
|
||||
}
|
||||
}
|
||||
function createHydratedRouter({
|
||||
unstable_getContext
|
||||
}) {
|
||||
initSsrInfo();
|
||||
if (!ssrInfo) {
|
||||
throw new Error(
|
||||
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
||||
);
|
||||
}
|
||||
let localSsrInfo = ssrInfo;
|
||||
if (!ssrInfo.stateDecodingPromise) {
|
||||
let stream = ssrInfo.context.stream;
|
||||
(0, import_react_router2.UNSAFE_invariant)(stream, "No stream found for single fetch decoding");
|
||||
ssrInfo.context.stream = void 0;
|
||||
ssrInfo.stateDecodingPromise = (0, import_react_router2.UNSAFE_decodeViaTurboStream)(stream, window).then((value) => {
|
||||
ssrInfo.context.state = value.value;
|
||||
localSsrInfo.stateDecodingPromise.value = true;
|
||||
}).catch((e) => {
|
||||
localSsrInfo.stateDecodingPromise.error = e;
|
||||
});
|
||||
}
|
||||
if (ssrInfo.stateDecodingPromise.error) {
|
||||
throw ssrInfo.stateDecodingPromise.error;
|
||||
}
|
||||
if (!ssrInfo.stateDecodingPromise.value) {
|
||||
throw ssrInfo.stateDecodingPromise;
|
||||
}
|
||||
let routes = (0, import_react_router2.UNSAFE_createClientRoutes)(
|
||||
ssrInfo.manifest.routes,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.state,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
let hydrationData = void 0;
|
||||
if (ssrInfo.context.isSpaMode) {
|
||||
let { loaderData } = ssrInfo.context.state;
|
||||
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
||||
hydrationData = {
|
||||
loaderData: {
|
||||
root: loaderData.root
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
hydrationData = (0, import_react_router2.UNSAFE_getHydrationData)(
|
||||
ssrInfo.context.state,
|
||||
routes,
|
||||
(routeId) => ({
|
||||
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
||||
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
||||
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
||||
}),
|
||||
window.location,
|
||||
window.__reactRouterContext?.basename,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
if (hydrationData && hydrationData.errors) {
|
||||
hydrationData.errors = (0, import_react_router2.UNSAFE_deserializeErrors)(hydrationData.errors);
|
||||
}
|
||||
}
|
||||
let router2 = (0, import_react_router2.UNSAFE_createRouter)({
|
||||
routes,
|
||||
history: (0, import_react_router2.UNSAFE_createBrowserHistory)(),
|
||||
basename: ssrInfo.context.basename,
|
||||
unstable_getContext,
|
||||
hydrationData,
|
||||
hydrationRouteProperties: import_react_router2.UNSAFE_hydrationRouteProperties,
|
||||
mapRouteProperties: import_react_router2.UNSAFE_mapRouteProperties,
|
||||
future: {
|
||||
unstable_middleware: ssrInfo.context.future.unstable_middleware
|
||||
},
|
||||
dataStrategy: (0, import_react_router2.UNSAFE_getTurboStreamSingleFetchDataStrategy)(
|
||||
() => router2,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.basename
|
||||
),
|
||||
patchRoutesOnNavigation: (0, import_react_router2.UNSAFE_getPatchRoutesOnNavigationFunction)(
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode,
|
||||
ssrInfo.context.basename
|
||||
)
|
||||
});
|
||||
ssrInfo.router = router2;
|
||||
if (router2.state.initialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
router2.initialize();
|
||||
}
|
||||
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
||||
import_react_router2.UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
|
||||
window.__reactRouterDataRouter = router2;
|
||||
return router2;
|
||||
}
|
||||
function HydratedRouter(props) {
|
||||
if (!router) {
|
||||
router = createHydratedRouter({
|
||||
unstable_getContext: props.unstable_getContext
|
||||
});
|
||||
}
|
||||
let [criticalCss, setCriticalCss] = React2.useState(
|
||||
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
||||
);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (ssrInfo) {
|
||||
window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
|
||||
}
|
||||
}
|
||||
let [location, setLocation] = React2.useState(router.state.location);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
ssrInfo.router.initialize();
|
||||
}
|
||||
}, []);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router) {
|
||||
return ssrInfo.router.subscribe((newState) => {
|
||||
if (newState.location !== location) {
|
||||
setLocation(newState.location);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [location]);
|
||||
(0, import_react_router2.UNSAFE_invariant)(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
||||
(0, import_react_router2.UNSAFE_useFogOFWarDiscovery)(
|
||||
router,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
return (
|
||||
// This fragment is important to ensure we match the <ServerRouter> JSX
|
||||
// structure so that useId values hydrate correctly
|
||||
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
||||
import_react_router2.UNSAFE_FrameworkContext.Provider,
|
||||
{
|
||||
value: {
|
||||
manifest: ssrInfo.manifest,
|
||||
routeModules: ssrInfo.routeModules,
|
||||
future: ssrInfo.context.future,
|
||||
criticalCss,
|
||||
ssr: ssrInfo.context.ssr,
|
||||
isSpaMode: ssrInfo.context.isSpaMode,
|
||||
routeDiscovery: ssrInfo.context.routeDiscovery
|
||||
}
|
||||
},
|
||||
/* @__PURE__ */ React2.createElement(import_react_router2.UNSAFE_RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider, { router }))
|
||||
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
||||
);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
HydratedRouter,
|
||||
RouterProvider
|
||||
});
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
import {
|
||||
FrameworkContext,
|
||||
RemixErrorBoundary,
|
||||
RouterProvider,
|
||||
createBrowserHistory,
|
||||
createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut,
|
||||
createRouter,
|
||||
decodeViaTurboStream,
|
||||
deserializeErrors,
|
||||
getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy,
|
||||
hydrationRouteProperties,
|
||||
invariant,
|
||||
mapRouteProperties,
|
||||
useFogOFWarDiscovery
|
||||
} from "./chunk-D4RADZKF.mjs";
|
||||
|
||||
// lib/dom-export/dom-router-provider.tsx
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
function RouterProvider2(props) {
|
||||
return /* @__PURE__ */ React.createElement(RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
||||
}
|
||||
|
||||
// lib/dom-export/hydrated-router.tsx
|
||||
import * as React2 from "react";
|
||||
var ssrInfo = null;
|
||||
var router = null;
|
||||
function initSsrInfo() {
|
||||
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
||||
if (window.__reactRouterManifest.sri === true) {
|
||||
const importMap = document.querySelector("script[rr-importmap]");
|
||||
if (importMap?.textContent) {
|
||||
try {
|
||||
window.__reactRouterManifest.sri = JSON.parse(
|
||||
importMap.textContent
|
||||
).integrity;
|
||||
} catch (err) {
|
||||
console.error("Failed to parse import map", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
ssrInfo = {
|
||||
context: window.__reactRouterContext,
|
||||
manifest: window.__reactRouterManifest,
|
||||
routeModules: window.__reactRouterRouteModules,
|
||||
stateDecodingPromise: void 0,
|
||||
router: void 0,
|
||||
routerInitialized: false
|
||||
};
|
||||
}
|
||||
}
|
||||
function createHydratedRouter({
|
||||
unstable_getContext
|
||||
}) {
|
||||
initSsrInfo();
|
||||
if (!ssrInfo) {
|
||||
throw new Error(
|
||||
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
||||
);
|
||||
}
|
||||
let localSsrInfo = ssrInfo;
|
||||
if (!ssrInfo.stateDecodingPromise) {
|
||||
let stream = ssrInfo.context.stream;
|
||||
invariant(stream, "No stream found for single fetch decoding");
|
||||
ssrInfo.context.stream = void 0;
|
||||
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then((value) => {
|
||||
ssrInfo.context.state = value.value;
|
||||
localSsrInfo.stateDecodingPromise.value = true;
|
||||
}).catch((e) => {
|
||||
localSsrInfo.stateDecodingPromise.error = e;
|
||||
});
|
||||
}
|
||||
if (ssrInfo.stateDecodingPromise.error) {
|
||||
throw ssrInfo.stateDecodingPromise.error;
|
||||
}
|
||||
if (!ssrInfo.stateDecodingPromise.value) {
|
||||
throw ssrInfo.stateDecodingPromise;
|
||||
}
|
||||
let routes = createClientRoutes(
|
||||
ssrInfo.manifest.routes,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.state,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
let hydrationData = void 0;
|
||||
if (ssrInfo.context.isSpaMode) {
|
||||
let { loaderData } = ssrInfo.context.state;
|
||||
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
||||
hydrationData = {
|
||||
loaderData: {
|
||||
root: loaderData.root
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
hydrationData = getHydrationData(
|
||||
ssrInfo.context.state,
|
||||
routes,
|
||||
(routeId) => ({
|
||||
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
||||
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
||||
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
||||
}),
|
||||
window.location,
|
||||
window.__reactRouterContext?.basename,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
if (hydrationData && hydrationData.errors) {
|
||||
hydrationData.errors = deserializeErrors(hydrationData.errors);
|
||||
}
|
||||
}
|
||||
let router2 = createRouter({
|
||||
routes,
|
||||
history: createBrowserHistory(),
|
||||
basename: ssrInfo.context.basename,
|
||||
unstable_getContext,
|
||||
hydrationData,
|
||||
hydrationRouteProperties,
|
||||
mapRouteProperties,
|
||||
future: {
|
||||
unstable_middleware: ssrInfo.context.future.unstable_middleware
|
||||
},
|
||||
dataStrategy: getTurboStreamSingleFetchDataStrategy(
|
||||
() => router2,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.basename
|
||||
),
|
||||
patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode,
|
||||
ssrInfo.context.basename
|
||||
)
|
||||
});
|
||||
ssrInfo.router = router2;
|
||||
if (router2.state.initialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
router2.initialize();
|
||||
}
|
||||
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
||||
createClientRoutesWithHMRRevalidationOptOut;
|
||||
window.__reactRouterDataRouter = router2;
|
||||
return router2;
|
||||
}
|
||||
function HydratedRouter(props) {
|
||||
if (!router) {
|
||||
router = createHydratedRouter({
|
||||
unstable_getContext: props.unstable_getContext
|
||||
});
|
||||
}
|
||||
let [criticalCss, setCriticalCss] = React2.useState(
|
||||
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
||||
);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (ssrInfo) {
|
||||
window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
|
||||
}
|
||||
}
|
||||
let [location, setLocation] = React2.useState(router.state.location);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
ssrInfo.router.initialize();
|
||||
}
|
||||
}, []);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router) {
|
||||
return ssrInfo.router.subscribe((newState) => {
|
||||
if (newState.location !== location) {
|
||||
setLocation(newState.location);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [location]);
|
||||
invariant(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
||||
useFogOFWarDiscovery(
|
||||
router,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
return (
|
||||
// This fragment is important to ensure we match the <ServerRouter> JSX
|
||||
// structure so that useId values hydrate correctly
|
||||
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
||||
FrameworkContext.Provider,
|
||||
{
|
||||
value: {
|
||||
manifest: ssrInfo.manifest,
|
||||
routeModules: ssrInfo.routeModules,
|
||||
future: ssrInfo.context.future,
|
||||
criticalCss,
|
||||
ssr: ssrInfo.context.ssr,
|
||||
isSpaMode: ssrInfo.context.isSpaMode,
|
||||
routeDiscovery: ssrInfo.context.routeDiscovery
|
||||
}
|
||||
},
|
||||
/* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider2, { router }))
|
||||
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
||||
);
|
||||
}
|
||||
export {
|
||||
HydratedRouter,
|
||||
RouterProvider2 as RouterProvider
|
||||
};
|
||||
+814
@@ -0,0 +1,814 @@
|
||||
import { a as Router, b as RouteModules, D as DataStrategyFunction, T as To, c as RelativeRoutingType, L as Location, A as Action, P as ParamParseKey, d as Path, e as PathPattern, f as PathMatch, N as NavigateOptions, g as Params$1, h as RouteObject, i as Navigation, U as UIMatch, S as SerializeFrom, B as BlockerFunction, j as Blocker, k as StaticHandlerContext, l as StaticHandler, F as FutureConfig, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as unstable_InitialContext, m as IndexRouteObject, n as NonIndexRouteObject, o as LoaderFunction, p as ActionFunction, M as MetaFunction, q as LinksFunction, r as MiddlewareEnabled, s as AppLoadContext, E as Equal, t as RouterState, v as PatchRoutesOnNavigationFunction, w as DataRouteObject, x as ClientLoaderFunction } from './route-data-C6QaL0wu.mjs';
|
||||
export { W as ActionFunctionArgs, av as ClientActionFunction, aw as ClientActionFunctionArgs, ax as ClientLoaderFunctionArgs, ar as DataRouteMatch, X as DataStrategyFunctionArgs, Y as DataStrategyMatch, Z as DataStrategyResult, $ as ErrorResponse, z as Fetcher, a0 as FormEncType, a1 as FormMethod, aF as Future, G as GetScrollPositionFunction, y as GetScrollRestorationKeyFunction, a2 as HTMLFormMethod, ay as HeadersArgs, az as HeadersFunction, aD as HtmlLinkDescriptor, ah as IDLE_BLOCKER, ag as IDLE_FETCHER, af as IDLE_NAVIGATION, a3 as LazyRouteFunction, aE as LinkDescriptor, a4 as LoaderFunctionArgs, aA as MetaArgs, aB as MetaDescriptor, J as NavigationStates, as as Navigator, aC as PageLinkDescriptor, at as PatchRoutesOnNavigationFunctionArgs, a6 as PathParam, a7 as RedirectFunction, V as RevalidationState, au as RouteMatch, Q as RouterFetchOptions, R as RouterInit, O as RouterNavigateOptions, K as RouterSubscriber, a9 as ShouldRevalidateFunction, aa as ShouldRevalidateFunctionArgs, aL as UNSAFE_DataRouterContext, aM as UNSAFE_DataRouterStateContext, _ as UNSAFE_DataWithResponseInit, aK as UNSAFE_ErrorResponseImpl, aN as UNSAFE_FetchersContext, aO as UNSAFE_LocationContext, aP as UNSAFE_NavigationContext, aQ as UNSAFE_RouteContext, aR as UNSAFE_ViewTransitionContext, aH as UNSAFE_createBrowserHistory, aJ as UNSAFE_createRouter, aI as UNSAFE_invariant, ad as createPath, ai as data, aj as generatePath, ak as isRouteErrorResponse, al as matchPath, am as matchRoutes, ae as parsePath, an as redirect, ao as redirectDocument, ap as replace, aq as resolvePath, a5 as unstable_MiddlewareFunction, a8 as unstable_RouterContext, ac as unstable_RouterContextProvider, aG as unstable_SerializesTo, ab as unstable_createContext } from './route-data-C6QaL0wu.mjs';
|
||||
import { A as AssetsManifest, E as EntryContext, F as FutureConfig$1, S as ServerBuild } from './lib-CCSAGgcP.mjs';
|
||||
export { f as Await, a as AwaitProps, Q as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, v as FetcherFormProps, C as FetcherSubmitFunction, a6 as FetcherSubmitOptions, G as FetcherWithComponents, X as Form, w as FormProps, ah as HandleDataRequestFunction, ai as HandleDocumentRequestFunction, aj as HandleErrorFunction, T as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, U as Link, s as LinkProps, ad as Links, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, ac as Meta, W as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a7 as ParamKeyValuePair, P as PathRouteProps, af as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ae as Scripts, ag as ScriptsProps, Y as ScrollRestoration, x as ScrollRestorationProps, ak as ServerEntryModule, y as SetURLSearchParams, z as SubmitFunction, a8 as SubmitOptions, aa as SubmitTarget, an as UNSAFE_FrameworkContext, ao as UNSAFE_createClientRoutes, ap as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, al as UNSAFE_hydrationRouteProperties, am as UNSAFE_mapRouteProperties, aq as UNSAFE_shouldHydrateRouteLoader, ar as UNSAFE_useScrollRestoration, a9 as URLSearchParamsInit, J as createBrowserRouter, K as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, ab as createSearchParams, r as renderMatches, V as unstable_HistoryRouter, a4 as unstable_usePrompt, a3 as useBeforeUnload, a1 as useFetcher, a2 as useFetchers, a0 as useFormAction, Z as useLinkClickHandler, _ as useSearchParams, $ as useSubmit, a5 as useViewTransitionState } from './lib-CCSAGgcP.mjs';
|
||||
import * as React from 'react';
|
||||
import { ReactElement } from 'react';
|
||||
import { ParseOptions, SerializeOptions } from 'cookie';
|
||||
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
||||
|
||||
declare const SingleFetchRedirectSymbol: unique symbol;
|
||||
declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
|
||||
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
|
||||
done: Promise<undefined>;
|
||||
value: unknown;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The mode to use when running the server.
|
||||
*/
|
||||
declare enum ServerMode {
|
||||
Development = "development",
|
||||
Production = "production",
|
||||
Test = "test"
|
||||
}
|
||||
|
||||
/**
|
||||
Resolves a URL against the current location.
|
||||
|
||||
```tsx
|
||||
import { useHref } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
let href = useHref("some/where");
|
||||
// "/resolved/some/where"
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useHref(to: To, { relative }?: {
|
||||
relative?: RelativeRoutingType;
|
||||
}): string;
|
||||
/**
|
||||
* Returns true if this component is a descendant of a Router, useful to ensure
|
||||
* a component is used within a Router.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useInRouterContext(): boolean;
|
||||
/**
|
||||
Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
|
||||
|
||||
```tsx
|
||||
import * as React from 'react'
|
||||
import { useLocation } from 'react-router'
|
||||
|
||||
function SomeComponent() {
|
||||
let location = useLocation()
|
||||
|
||||
React.useEffect(() => {
|
||||
// Google Analytics
|
||||
ga('send', 'pageview')
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
// ...
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useLocation(): Location;
|
||||
/**
|
||||
* Returns the current navigation action which describes how the router came to
|
||||
* the current location, either by a pop, push, or replace on the history stack.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useNavigationType(): Action;
|
||||
/**
|
||||
* Returns a PathMatch object if the given pattern matches the current URL.
|
||||
* This is useful for components that need to know "active" state, e.g.
|
||||
* `<NavLink>`.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
|
||||
/**
|
||||
* The interface for the navigate() function returned from useNavigate().
|
||||
*/
|
||||
interface NavigateFunction {
|
||||
(to: To, options?: NavigateOptions): void | Promise<void>;
|
||||
(delta: number): void | Promise<void>;
|
||||
}
|
||||
/**
|
||||
Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
|
||||
|
||||
```tsx
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
function SomeComponent() {
|
||||
let navigate = useNavigate();
|
||||
return (
|
||||
<button
|
||||
onClick={() => {
|
||||
navigate(-1);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useNavigate(): NavigateFunction;
|
||||
/**
|
||||
* Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useOutletContext<Context = unknown>(): Context;
|
||||
/**
|
||||
* Returns the element for the child route at this level of the route
|
||||
* hierarchy. Used internally by `<Outlet>` to render child routes.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useOutlet(context?: unknown): React.ReactElement | null;
|
||||
/**
|
||||
Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
|
||||
|
||||
```tsx
|
||||
import { useParams } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
let params = useParams()
|
||||
params.postId
|
||||
}
|
||||
```
|
||||
|
||||
Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
||||
ParamsOrKey
|
||||
] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
|
||||
/**
|
||||
Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
|
||||
|
||||
```tsx
|
||||
import { useResolvedPath } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
// if the user is at /dashboard/profile
|
||||
let path = useResolvedPath("../accounts")
|
||||
path.pathname // "/dashboard/accounts"
|
||||
path.search // ""
|
||||
path.hash // ""
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useResolvedPath(to: To, { relative }?: {
|
||||
relative?: RelativeRoutingType;
|
||||
}): Path;
|
||||
/**
|
||||
Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
|
||||
|
||||
The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
|
||||
|
||||
```tsx
|
||||
import * as React from "react";
|
||||
import { useRoutes } from "react-router";
|
||||
|
||||
function App() {
|
||||
let element = useRoutes([
|
||||
{
|
||||
path: "/",
|
||||
element: <Dashboard />,
|
||||
children: [
|
||||
{
|
||||
path: "messages",
|
||||
element: <DashboardMessages />,
|
||||
},
|
||||
{ path: "tasks", element: <DashboardTasks /> },
|
||||
],
|
||||
},
|
||||
{ path: "team", element: <AboutPage /> },
|
||||
]);
|
||||
|
||||
return element;
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
||||
/**
|
||||
Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
|
||||
|
||||
```tsx
|
||||
import { useNavigation } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
let navigation = useNavigation();
|
||||
navigation.state
|
||||
navigation.formData
|
||||
// etc.
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useNavigation(): Navigation;
|
||||
/**
|
||||
Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
|
||||
|
||||
```tsx
|
||||
import { useRevalidator } from "react-router";
|
||||
|
||||
function WindowFocusRevalidator() {
|
||||
const revalidator = useRevalidator();
|
||||
|
||||
useFakeWindowFocus(() => {
|
||||
revalidator.revalidate();
|
||||
});
|
||||
|
||||
return (
|
||||
<div hidden={revalidator.state === "idle"}>
|
||||
Revalidating...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRevalidator(): {
|
||||
revalidate: () => Promise<void>;
|
||||
state: Router["state"]["revalidation"];
|
||||
};
|
||||
/**
|
||||
* Returns the active route matches, useful for accessing loaderData for
|
||||
* parent/child routes or the route "handle" property
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useMatches(): UIMatch[];
|
||||
/**
|
||||
Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
|
||||
|
||||
```tsx
|
||||
import { useLoaderData } from "react-router"
|
||||
|
||||
export async function loader() {
|
||||
return await fakeDb.invoices.findAll();
|
||||
}
|
||||
|
||||
export default function Invoices() {
|
||||
let invoices = useLoaderData<typeof loader>();
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useLoaderData<T = any>(): SerializeFrom<T>;
|
||||
/**
|
||||
Returns the loader data for a given route by route ID.
|
||||
|
||||
```tsx
|
||||
import { useRouteLoaderData } from "react-router";
|
||||
|
||||
function SomeComponent() {
|
||||
const { user } = useRouteLoaderData("root");
|
||||
}
|
||||
```
|
||||
|
||||
Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
|
||||
|
||||
| Route Filename | Route ID |
|
||||
| -------------------------- | -------------------- |
|
||||
| `app/root.tsx` | `"root"` |
|
||||
| `app/routes/teams.tsx` | `"routes/teams"` |
|
||||
| `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
|
||||
|
||||
If you created an ID manually, you can use that instead:
|
||||
|
||||
```tsx
|
||||
route("/", "containers/app.tsx", { id: "app" }})
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
|
||||
/**
|
||||
Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
|
||||
|
||||
```tsx
|
||||
import { Form, useActionData } from "react-router"
|
||||
|
||||
export async function action({ request }) {
|
||||
const body = await request.formData()
|
||||
const name = body.get("visitorsName")
|
||||
return { message: `Hello, ${name}` }
|
||||
}
|
||||
|
||||
export default function Invoices() {
|
||||
const data = useActionData()
|
||||
return (
|
||||
<Form method="post">
|
||||
<input type="text" name="visitorsName" />
|
||||
{data ? data.message : "Waiting..."}
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
|
||||
/**
|
||||
Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
|
||||
|
||||
```tsx
|
||||
export function ErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
return <div>{error.message}</div>;
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRouteError(): unknown;
|
||||
/**
|
||||
Returns the resolved promise value from the closest {@link Await | `<Await>`}.
|
||||
|
||||
```tsx
|
||||
function SomeDescendant() {
|
||||
const value = useAsyncValue();
|
||||
// ...
|
||||
}
|
||||
|
||||
// somewhere in your app
|
||||
<Await resolve={somePromise}>
|
||||
<SomeDescendant />
|
||||
</Await>
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useAsyncValue(): unknown;
|
||||
/**
|
||||
Returns the rejection value from the closest {@link Await | `<Await>`}.
|
||||
|
||||
```tsx
|
||||
import { Await, useAsyncError } from "react-router"
|
||||
|
||||
function ErrorElement() {
|
||||
const error = useAsyncError();
|
||||
return (
|
||||
<p>Uh Oh, something went wrong! {error.message}</p>
|
||||
);
|
||||
}
|
||||
|
||||
// somewhere in your app
|
||||
<Await
|
||||
resolve={promiseThatRejects}
|
||||
errorElement={<ErrorElement />}
|
||||
/>
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useAsyncError(): unknown;
|
||||
/**
|
||||
* Allow the application to block navigations within the SPA and present the
|
||||
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
|
||||
* using half-filled form data. This does not handle hard-reloads or
|
||||
* cross-origin navigations.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
|
||||
|
||||
interface StaticRouterProps {
|
||||
basename?: string;
|
||||
children?: React.ReactNode;
|
||||
location: Partial<Location> | string;
|
||||
}
|
||||
/**
|
||||
* A `<Router>` that may not navigate to any other location. This is useful
|
||||
* on the server where there is no stateful UI.
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
|
||||
interface StaticRouterProviderProps {
|
||||
context: StaticHandlerContext;
|
||||
router: Router;
|
||||
hydrate?: boolean;
|
||||
nonce?: string;
|
||||
}
|
||||
/**
|
||||
* A Data Router that may not navigate to any other location. This is useful
|
||||
* on the server where there is no stateful UI.
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
|
||||
type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
|
||||
/**
|
||||
* @category Utils
|
||||
*/
|
||||
declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
||||
/**
|
||||
* @category Data Routers
|
||||
*/
|
||||
declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
||||
future?: Partial<FutureConfig>;
|
||||
}): Router;
|
||||
|
||||
interface ServerRouterProps {
|
||||
context: EntryContext;
|
||||
url: string | URL;
|
||||
nonce?: string;
|
||||
}
|
||||
/**
|
||||
* The entry point for a Remix app when it is rendered on the server (in
|
||||
* `app/entry.server.js`). This component is used to generate the HTML in the
|
||||
* response from the server.
|
||||
*
|
||||
* @category Components
|
||||
*/
|
||||
declare function ServerRouter({ context, url, nonce, }: ServerRouterProps): ReactElement;
|
||||
|
||||
interface StubRouteExtensions {
|
||||
Component?: React.ComponentType<{
|
||||
params: ReturnType<typeof useParams>;
|
||||
loaderData: ReturnType<typeof useLoaderData>;
|
||||
actionData: ReturnType<typeof useActionData>;
|
||||
matches: ReturnType<typeof useMatches>;
|
||||
}>;
|
||||
HydrateFallback?: React.ComponentType<{
|
||||
params: ReturnType<typeof useParams>;
|
||||
loaderData: ReturnType<typeof useLoaderData>;
|
||||
actionData: ReturnType<typeof useActionData>;
|
||||
}>;
|
||||
ErrorBoundary?: React.ComponentType<{
|
||||
params: ReturnType<typeof useParams>;
|
||||
loaderData: ReturnType<typeof useLoaderData>;
|
||||
actionData: ReturnType<typeof useActionData>;
|
||||
error: ReturnType<typeof useRouteError>;
|
||||
}>;
|
||||
loader?: LoaderFunction;
|
||||
action?: ActionFunction;
|
||||
children?: StubRouteObject[];
|
||||
meta?: MetaFunction;
|
||||
links?: LinksFunction;
|
||||
}
|
||||
interface StubIndexRouteObject extends Omit<IndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {
|
||||
}
|
||||
interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {
|
||||
}
|
||||
type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
|
||||
interface RoutesTestStubProps {
|
||||
/**
|
||||
* The initial entries in the history stack. This allows you to start a test with
|
||||
* multiple locations already in the history stack (for testing a back navigation, etc.)
|
||||
* The test will default to the last entry in initialEntries if no initialIndex is provided.
|
||||
* e.g. initialEntries={["/home", "/about", "/contact"]}
|
||||
*/
|
||||
initialEntries?: InitialEntry[];
|
||||
/**
|
||||
* The initial index in the history stack to render. This allows you to start a test at a specific entry.
|
||||
* It defaults to the last entry in initialEntries.
|
||||
* e.g.
|
||||
* initialEntries: ["/", "/events/123"]
|
||||
* initialIndex: 1 // start at "/events/123"
|
||||
*/
|
||||
initialIndex?: number;
|
||||
/**
|
||||
* Used to set the route's initial loader and action data.
|
||||
* e.g. hydrationData={{
|
||||
* loaderData: { "/contact": { locale: "en-US" } },
|
||||
* actionData: { "/login": { errors: { email: "invalid email" } }}
|
||||
* }}
|
||||
*/
|
||||
hydrationData?: HydrationState;
|
||||
/**
|
||||
* Future flags mimicking the settings in react-router.config.ts
|
||||
*/
|
||||
future?: Partial<FutureConfig$1>;
|
||||
}
|
||||
/**
|
||||
* @category Utils
|
||||
*/
|
||||
declare function createRoutesStub(routes: StubRouteObject[], unstable_getContext?: () => unstable_InitialContext): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
|
||||
|
||||
interface CookieSignatureOptions {
|
||||
/**
|
||||
* An array of secrets that may be used to sign/unsign the value of a cookie.
|
||||
*
|
||||
* The array makes it easy to rotate secrets. New secrets should be added to
|
||||
* the beginning of the array. `cookie.serialize()` will always use the first
|
||||
* value in the array, but `cookie.parse()` may use any of them so that
|
||||
* cookies that were signed with older secrets still work.
|
||||
*/
|
||||
secrets?: string[];
|
||||
}
|
||||
type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
|
||||
/**
|
||||
* A HTTP cookie.
|
||||
*
|
||||
* A Cookie is a logical container for metadata about a HTTP cookie; its name
|
||||
* and options. But it doesn't contain a value. Instead, it has `parse()` and
|
||||
* `serialize()` methods that allow a single instance to be reused for
|
||||
* parsing/encoding multiple different values.
|
||||
*
|
||||
* @see https://remix.run/utils/cookies#cookie-api
|
||||
*/
|
||||
interface Cookie {
|
||||
/**
|
||||
* The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* True if this cookie uses one or more secrets for verification.
|
||||
*/
|
||||
readonly isSigned: boolean;
|
||||
/**
|
||||
* The Date this cookie expires.
|
||||
*
|
||||
* Note: This is calculated at access time using `maxAge` when no `expires`
|
||||
* option is provided to `createCookie()`.
|
||||
*/
|
||||
readonly expires?: Date;
|
||||
/**
|
||||
* Parses a raw `Cookie` header and returns the value of this cookie or
|
||||
* `null` if it's not present.
|
||||
*/
|
||||
parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
|
||||
/**
|
||||
* Serializes the given value to a string and returns the `Set-Cookie`
|
||||
* header.
|
||||
*/
|
||||
serialize(value: any, options?: SerializeOptions): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* Creates a logical container for managing a browser cookie from the server.
|
||||
*/
|
||||
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
||||
type IsCookieFunction = (object: any) => object is Cookie;
|
||||
/**
|
||||
* Returns true if an object is a Remix cookie container.
|
||||
*
|
||||
* @see https://remix.run/utils/cookies#iscookie
|
||||
*/
|
||||
declare const isCookie: IsCookieFunction;
|
||||
|
||||
type RequestHandler = (request: Request, loadContext?: MiddlewareEnabled extends true ? unstable_InitialContext : AppLoadContext) => Promise<Response>;
|
||||
type CreateRequestHandlerFunction = (build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>), mode?: string) => RequestHandler;
|
||||
declare const createRequestHandler: CreateRequestHandlerFunction;
|
||||
|
||||
/**
|
||||
* An object of name/value pairs to be used in the session.
|
||||
*/
|
||||
interface SessionData {
|
||||
[name: string]: any;
|
||||
}
|
||||
/**
|
||||
* Session persists data across HTTP requests.
|
||||
*
|
||||
* @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
|
||||
*/
|
||||
interface Session<Data = SessionData, FlashData = Data> {
|
||||
/**
|
||||
* A unique identifier for this session.
|
||||
*
|
||||
* Note: This will be the empty string for newly created sessions and
|
||||
* sessions that are not backed by a database (i.e. cookie-based sessions).
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* The raw data contained in this session.
|
||||
*
|
||||
* This is useful mostly for SessionStorage internally to access the raw
|
||||
* session data to persist.
|
||||
*/
|
||||
readonly data: FlashSessionData<Data, FlashData>;
|
||||
/**
|
||||
* Returns `true` if the session has a value for the given `name`, `false`
|
||||
* otherwise.
|
||||
*/
|
||||
has(name: (keyof Data | keyof FlashData) & string): boolean;
|
||||
/**
|
||||
* Returns the value for the given `name` in this session.
|
||||
*/
|
||||
get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
|
||||
/**
|
||||
* Sets a value in the session for the given `name`.
|
||||
*/
|
||||
set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
|
||||
/**
|
||||
* Sets a value in the session that is only valid until the next `get()`.
|
||||
* This can be useful for temporary values, like error messages.
|
||||
*/
|
||||
flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
|
||||
/**
|
||||
* Removes a value from the session.
|
||||
*/
|
||||
unset(name: keyof Data & string): void;
|
||||
}
|
||||
type FlashSessionData<Data, FlashData> = Partial<Data & {
|
||||
[Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
|
||||
}>;
|
||||
type FlashDataKey<Key extends string> = `__flash_${Key}__`;
|
||||
type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
|
||||
/**
|
||||
* Creates a new Session object.
|
||||
*
|
||||
* Note: This function is typically not invoked directly by application code.
|
||||
* Instead, use a `SessionStorage` object's `getSession` method.
|
||||
*/
|
||||
declare const createSession: CreateSessionFunction;
|
||||
type IsSessionFunction = (object: any) => object is Session;
|
||||
/**
|
||||
* Returns true if an object is a React Router session.
|
||||
*
|
||||
* @see https://reactrouter.com/api/utils/isSession
|
||||
*/
|
||||
declare const isSession: IsSessionFunction;
|
||||
/**
|
||||
* SessionStorage stores session data between HTTP requests and knows how to
|
||||
* parse and create cookies.
|
||||
*
|
||||
* A SessionStorage creates Session objects using a `Cookie` header as input.
|
||||
* Then, later it generates the `Set-Cookie` header to be used in the response.
|
||||
*/
|
||||
interface SessionStorage<Data = SessionData, FlashData = Data> {
|
||||
/**
|
||||
* Parses a Cookie header from a HTTP request and returns the associated
|
||||
* Session. If there is no session associated with the cookie, this will
|
||||
* return a new Session with no data.
|
||||
*/
|
||||
getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
|
||||
/**
|
||||
* Stores all data in the Session and returns the Set-Cookie header to be
|
||||
* used in the HTTP response.
|
||||
*/
|
||||
commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
|
||||
/**
|
||||
* Deletes all data associated with the Session and returns the Set-Cookie
|
||||
* header to be used in the HTTP response.
|
||||
*/
|
||||
destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
|
||||
}
|
||||
/**
|
||||
* SessionIdStorageStrategy is designed to allow anyone to easily build their
|
||||
* own SessionStorage using `createSessionStorage(strategy)`.
|
||||
*
|
||||
* This strategy describes a common scenario where the session id is stored in
|
||||
* a cookie but the actual session data is stored elsewhere, usually in a
|
||||
* database or on disk. A set of create, read, update, and delete operations
|
||||
* are provided for managing the session data.
|
||||
*/
|
||||
interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
||||
/**
|
||||
* The Cookie used to store the session id, or options used to automatically
|
||||
* create one.
|
||||
*/
|
||||
cookie?: Cookie | (CookieOptions & {
|
||||
name?: string;
|
||||
});
|
||||
/**
|
||||
* Creates a new record with the given data and returns the session id.
|
||||
*/
|
||||
createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
|
||||
/**
|
||||
* Returns data for a given session id, or `null` if there isn't any.
|
||||
*/
|
||||
readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
|
||||
/**
|
||||
* Updates data for the given session id.
|
||||
*/
|
||||
updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
|
||||
/**
|
||||
* Deletes data for a given session id from the data store.
|
||||
*/
|
||||
deleteData: (id: string) => Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Creates a SessionStorage object using a SessionIdStorageStrategy.
|
||||
*
|
||||
* Note: This is a low-level API that should only be used if none of the
|
||||
* existing session storage options meet your requirements.
|
||||
*/
|
||||
declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
|
||||
|
||||
interface CookieSessionStorageOptions {
|
||||
/**
|
||||
* The Cookie used to store the session data on the client, or options used
|
||||
* to automatically create one.
|
||||
*/
|
||||
cookie?: SessionIdStorageStrategy["cookie"];
|
||||
}
|
||||
/**
|
||||
* Creates and returns a SessionStorage object that stores all session data
|
||||
* directly in the session cookie itself.
|
||||
*
|
||||
* This has the advantage that no database or other backend services are
|
||||
* needed, and can help to simplify some load-balanced scenarios. However, it
|
||||
* also has the limitation that serialized session data may not exceed the
|
||||
* browser's maximum cookie size. Trade-offs!
|
||||
*/
|
||||
declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
|
||||
|
||||
interface MemorySessionStorageOptions {
|
||||
/**
|
||||
* The Cookie used to store the session id on the client, or options used
|
||||
* to automatically create one.
|
||||
*/
|
||||
cookie?: SessionIdStorageStrategy["cookie"];
|
||||
}
|
||||
/**
|
||||
* Creates and returns a simple in-memory SessionStorage object, mostly useful
|
||||
* for testing and as a reference implementation.
|
||||
*
|
||||
* Note: This storage does not scale beyond a single process, so it is not
|
||||
* suitable for most production scenarios.
|
||||
*/
|
||||
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
|
||||
|
||||
type DevServerHooks = {
|
||||
getCriticalCss?: (pathname: string) => Promise<string | undefined>;
|
||||
processRequestError?: (error: unknown) => void;
|
||||
};
|
||||
declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
|
||||
|
||||
/**
|
||||
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
||||
* React Router should handle this for you via type generation.
|
||||
*
|
||||
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
|
||||
*/
|
||||
interface Register {
|
||||
}
|
||||
|
||||
type AnyParams = Record<string, Record<string, string | undefined>>;
|
||||
type Params = Register extends {
|
||||
params: infer RegisteredParams extends AnyParams;
|
||||
} ? RegisteredParams : AnyParams;
|
||||
type Args = {
|
||||
[K in keyof Params]: ToArgs<Params[K]>;
|
||||
};
|
||||
type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [
|
||||
T
|
||||
];
|
||||
/**
|
||||
Returns a resolved URL path for the specified route.
|
||||
|
||||
```tsx
|
||||
const h = href("/:lang?/about", { lang: "en" })
|
||||
// -> `/en/about`
|
||||
|
||||
<Link to={href("/products/:id", { id: "abc123" })} />
|
||||
```
|
||||
*/
|
||||
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
||||
|
||||
declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
|
||||
|
||||
type RemixErrorBoundaryProps = React.PropsWithChildren<{
|
||||
location: Location;
|
||||
isOutsideRemixApp?: boolean;
|
||||
error?: Error;
|
||||
}>;
|
||||
type RemixErrorBoundaryState = {
|
||||
error: null | Error;
|
||||
location: Location;
|
||||
};
|
||||
declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
|
||||
constructor(props: RemixErrorBoundaryProps);
|
||||
static getDerivedStateFromError(error: Error): {
|
||||
error: Error;
|
||||
};
|
||||
static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
|
||||
error: Error | null;
|
||||
location: Location<any>;
|
||||
};
|
||||
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
||||
}
|
||||
|
||||
declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
|
||||
declare function useFogOFWarDiscovery(router: Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
|
||||
|
||||
declare function getHydrationData(state: {
|
||||
loaderData?: Router["state"]["loaderData"];
|
||||
actionData?: Router["state"]["actionData"];
|
||||
errors?: Router["state"]["errors"];
|
||||
}, routes: DataRouteObject[], getRouteInfo: (routeId: string) => {
|
||||
clientLoader: ClientLoaderFunction | undefined;
|
||||
hasLoader: boolean;
|
||||
hasHydrateFallback: boolean;
|
||||
}, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
|
||||
|
||||
export { ActionFunction, AppLoadContext, Blocker, BlockerFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, DataRouteObject, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params$1 as Params, PatchRoutesOnNavigationFunction, Path, PathMatch, PathPattern, type Register, RelativeRoutingType, type RequestHandler, RouteObject, RouterState, type RoutesTestStubProps, ServerBuild, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, MiddlewareEnabled as UNSAFE_MiddlewareEnabled, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, unstable_InitialContext, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
|
||||
+2544
File diff suppressed because it is too large
Load Diff
+11706
File diff suppressed because it is too large
Load Diff
+246
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
import {
|
||||
Action,
|
||||
Await,
|
||||
BrowserRouter,
|
||||
DataRouterContext,
|
||||
DataRouterStateContext,
|
||||
ErrorResponseImpl,
|
||||
FetchersContext,
|
||||
Form,
|
||||
FrameworkContext,
|
||||
HashRouter,
|
||||
HistoryRouter,
|
||||
IDLE_BLOCKER,
|
||||
IDLE_FETCHER,
|
||||
IDLE_NAVIGATION,
|
||||
Link,
|
||||
Links,
|
||||
LocationContext,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
NavigationContext,
|
||||
Outlet,
|
||||
PrefetchPageLinks,
|
||||
RemixErrorBoundary,
|
||||
Route,
|
||||
RouteContext,
|
||||
Router,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
ServerMode,
|
||||
ServerRouter,
|
||||
SingleFetchRedirectSymbol,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
ViewTransitionContext,
|
||||
createBrowserHistory,
|
||||
createBrowserRouter,
|
||||
createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut,
|
||||
createCookie,
|
||||
createCookieSessionStorage,
|
||||
createHashRouter,
|
||||
createMemoryRouter,
|
||||
createMemorySessionStorage,
|
||||
createPath,
|
||||
createRequestHandler,
|
||||
createRouter,
|
||||
createRoutesFromChildren,
|
||||
createRoutesFromElements,
|
||||
createRoutesStub,
|
||||
createSearchParams,
|
||||
createSession,
|
||||
createSessionStorage,
|
||||
createStaticHandler,
|
||||
createStaticRouter,
|
||||
data,
|
||||
decodeViaTurboStream,
|
||||
deserializeErrors,
|
||||
generatePath,
|
||||
getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy,
|
||||
href,
|
||||
hydrationRouteProperties,
|
||||
invariant,
|
||||
isCookie,
|
||||
isRouteErrorResponse,
|
||||
isSession,
|
||||
mapRouteProperties,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
parsePath,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
renderMatches,
|
||||
replace,
|
||||
resolvePath,
|
||||
setDevServerHooks,
|
||||
shouldHydrateRouteLoader,
|
||||
unstable_RouterContextProvider,
|
||||
unstable_createContext,
|
||||
useActionData,
|
||||
useAsyncError,
|
||||
useAsyncValue,
|
||||
useBeforeUnload,
|
||||
useBlocker,
|
||||
useFetcher,
|
||||
useFetchers,
|
||||
useFogOFWarDiscovery,
|
||||
useFormAction,
|
||||
useHref,
|
||||
useInRouterContext,
|
||||
useLinkClickHandler,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useMatch,
|
||||
useMatches,
|
||||
useNavigate,
|
||||
useNavigation,
|
||||
useNavigationType,
|
||||
useOutlet,
|
||||
useOutletContext,
|
||||
useParams,
|
||||
usePrompt,
|
||||
useResolvedPath,
|
||||
useRevalidator,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
useRoutes,
|
||||
useScrollRestoration,
|
||||
useSearchParams,
|
||||
useSubmit,
|
||||
useViewTransitionState
|
||||
} from "./chunk-D4RADZKF.mjs";
|
||||
export {
|
||||
Await,
|
||||
BrowserRouter,
|
||||
Form,
|
||||
HashRouter,
|
||||
IDLE_BLOCKER,
|
||||
IDLE_FETCHER,
|
||||
IDLE_NAVIGATION,
|
||||
Link,
|
||||
Links,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
Action as NavigationType,
|
||||
Outlet,
|
||||
PrefetchPageLinks,
|
||||
Route,
|
||||
Router,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
ServerRouter,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
DataRouterContext as UNSAFE_DataRouterContext,
|
||||
DataRouterStateContext as UNSAFE_DataRouterStateContext,
|
||||
ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
|
||||
FetchersContext as UNSAFE_FetchersContext,
|
||||
FrameworkContext as UNSAFE_FrameworkContext,
|
||||
LocationContext as UNSAFE_LocationContext,
|
||||
NavigationContext as UNSAFE_NavigationContext,
|
||||
RemixErrorBoundary as UNSAFE_RemixErrorBoundary,
|
||||
RouteContext as UNSAFE_RouteContext,
|
||||
ServerMode as UNSAFE_ServerMode,
|
||||
SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol,
|
||||
ViewTransitionContext as UNSAFE_ViewTransitionContext,
|
||||
createBrowserHistory as UNSAFE_createBrowserHistory,
|
||||
createClientRoutes as UNSAFE_createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
|
||||
createRouter as UNSAFE_createRouter,
|
||||
decodeViaTurboStream as UNSAFE_decodeViaTurboStream,
|
||||
deserializeErrors as UNSAFE_deserializeErrors,
|
||||
getHydrationData as UNSAFE_getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy,
|
||||
hydrationRouteProperties as UNSAFE_hydrationRouteProperties,
|
||||
invariant as UNSAFE_invariant,
|
||||
mapRouteProperties as UNSAFE_mapRouteProperties,
|
||||
shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader,
|
||||
useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery,
|
||||
useScrollRestoration as UNSAFE_useScrollRestoration,
|
||||
createBrowserRouter,
|
||||
createCookie,
|
||||
createCookieSessionStorage,
|
||||
createHashRouter,
|
||||
createMemoryRouter,
|
||||
createMemorySessionStorage,
|
||||
createPath,
|
||||
createRequestHandler,
|
||||
createRoutesFromChildren,
|
||||
createRoutesFromElements,
|
||||
createRoutesStub,
|
||||
createSearchParams,
|
||||
createSession,
|
||||
createSessionStorage,
|
||||
createStaticHandler,
|
||||
createStaticRouter,
|
||||
data,
|
||||
generatePath,
|
||||
href,
|
||||
isCookie,
|
||||
isRouteErrorResponse,
|
||||
isSession,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
parsePath,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
renderMatches,
|
||||
replace,
|
||||
resolvePath,
|
||||
HistoryRouter as unstable_HistoryRouter,
|
||||
unstable_RouterContextProvider,
|
||||
unstable_createContext,
|
||||
setDevServerHooks as unstable_setDevServerHooks,
|
||||
usePrompt as unstable_usePrompt,
|
||||
useActionData,
|
||||
useAsyncError,
|
||||
useAsyncValue,
|
||||
useBeforeUnload,
|
||||
useBlocker,
|
||||
useFetcher,
|
||||
useFetchers,
|
||||
useFormAction,
|
||||
useHref,
|
||||
useInRouterContext,
|
||||
useLinkClickHandler,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useMatch,
|
||||
useMatches,
|
||||
useNavigate,
|
||||
useNavigation,
|
||||
useNavigationType,
|
||||
useOutlet,
|
||||
useOutletContext,
|
||||
useParams,
|
||||
useResolvedPath,
|
||||
useRevalidator,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
useRoutes,
|
||||
useSearchParams,
|
||||
useSubmit,
|
||||
useViewTransitionState
|
||||
};
|
||||
+1736
File diff suppressed because it is too large
Load Diff
+208
@@ -0,0 +1,208 @@
|
||||
import { aE as LinkDescriptor, L as Location, aB as MetaDescriptor, aV as ServerDataFrom, aW as ClientDataFrom, aX as Func, aY as unstable_MiddlewareNextFunction, E as Equal, ac as unstable_RouterContextProvider, r as MiddlewareEnabled, s as AppLoadContext, aZ as Pretty } from '../../route-data-C6QaL0wu.mjs';
|
||||
import 'react';
|
||||
|
||||
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RouteModule = {
|
||||
meta?: Func;
|
||||
links?: Func;
|
||||
headers?: Func;
|
||||
loader?: Func;
|
||||
clientLoader?: Func;
|
||||
action?: Func;
|
||||
clientAction?: Func;
|
||||
HydrateFallback?: unknown;
|
||||
default?: unknown;
|
||||
ErrorBoundary?: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type LinkDescriptors = LinkDescriptor[];
|
||||
type RouteInfo = {
|
||||
parents: RouteInfo[];
|
||||
module: RouteModule;
|
||||
id: unknown;
|
||||
file: string;
|
||||
path: string;
|
||||
params: unknown;
|
||||
loaderData: unknown;
|
||||
actionData: unknown;
|
||||
};
|
||||
type MetaMatch<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
meta: MetaDescriptor[];
|
||||
data: T["loaderData"];
|
||||
handle?: unknown;
|
||||
error?: unknown;
|
||||
}>;
|
||||
type MetaMatches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<RouteInfo> | undefined>;
|
||||
type CreateMetaArgs<T extends RouteInfo> = {
|
||||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
||||
location: Location;
|
||||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
||||
params: T["params"];
|
||||
/** The return value for this route's server loader function */
|
||||
data: T["loaderData"];
|
||||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
||||
error?: unknown;
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: MetaMatches<[...T["parents"], T]>;
|
||||
};
|
||||
type MetaDescriptors = MetaDescriptor[];
|
||||
type HeadersArgs = {
|
||||
loaderHeaders: Headers;
|
||||
parentHeaders: Headers;
|
||||
actionHeaders: Headers;
|
||||
errorHeaders: Headers | undefined;
|
||||
};
|
||||
type IsHydrate<ClientLoader> = ClientLoader extends {
|
||||
hydrate: true;
|
||||
} ? true : ClientLoader extends {
|
||||
hydrate: false;
|
||||
} ? false : false;
|
||||
type CreateLoaderData<T extends RouteModule> = _CreateLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
||||
HydrateFallback: Func;
|
||||
} ? true : false>;
|
||||
type _CreateLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
||||
HasHydrateFallback,
|
||||
ClientLoaderHydrate
|
||||
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
||||
IsDefined<ClientLoaderData>,
|
||||
IsDefined<ServerLoaderData>
|
||||
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
||||
type CreateActionData<T extends RouteModule> = _CreateActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
||||
type _CreateActionData<ServerActionData, ClientActionData> = Awaited<[
|
||||
IsDefined<ServerActionData>,
|
||||
IsDefined<ClientActionData>
|
||||
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
||||
type ClientDataFunctionArgs<T extends RouteInfo> = {
|
||||
/**
|
||||
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
||||
*
|
||||
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
||||
**/
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function clientLoader({
|
||||
* params,
|
||||
* }: Route.ClientLoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* When `future.unstable_middleware` is not enabled, this is undefined.
|
||||
*
|
||||
* When `future.unstable_middleware` is enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used to access context values
|
||||
* from your route middlewares. You may pass in initial context values in your
|
||||
* `<HydratedRouter unstable_getContext>` prop
|
||||
*/
|
||||
context: unstable_RouterContextProvider;
|
||||
};
|
||||
type ServerDataFunctionArgs<T extends RouteInfo> = {
|
||||
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function loader({
|
||||
* params,
|
||||
* }: Route.LoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* Without `future.unstable_middleware` enabled, this is the context passed in
|
||||
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
||||
* gap between the adapter's request/response API with your React Router app.
|
||||
* It is only applicable if you are using a custom server adapter.
|
||||
*
|
||||
* With `future.unstable_middleware` enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used for type-safe access to
|
||||
* context value set in your route middlewares. If you are using a custom
|
||||
* server adapter, you may provide an initial set of context values from your
|
||||
* `getLoadContext` function.
|
||||
*/
|
||||
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
||||
};
|
||||
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
||||
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
||||
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
||||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
||||
};
|
||||
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */
|
||||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
||||
};
|
||||
type CreateHydrateFallbackProps<T extends RouteInfo> = {
|
||||
params: T["params"];
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
type Match<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
data: T["loaderData"];
|
||||
handle: unknown;
|
||||
}>;
|
||||
type Matches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [Match<F>, ...Matches<R>] : Array<Match<RouteInfo> | undefined>;
|
||||
type CreateComponentProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export default function Component({
|
||||
* params,
|
||||
* }: Route.ComponentProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: Matches<[...T["parents"], T]>;
|
||||
};
|
||||
type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function ErrorBoundary({
|
||||
* params,
|
||||
* }: Route.ErrorBoundaryProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
error: unknown;
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
|
||||
export type { CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateClientMiddlewareFunction, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, CreateServerMiddlewareFunction, HeadersArgs, LinkDescriptors, MetaDescriptors };
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
import { aH as LinkDescriptor, e as Location, aF as MetaDescriptor, aV as ServerDataFrom, aW as ClientDataFrom, aX as Func, aY as unstable_MiddlewareNextFunction, _ as Equal, u as unstable_RouterContextProvider, M as MiddlewareEnabled, i as AppLoadContext, aZ as Pretty } from '../../route-data-B9_30zbP.js';
|
||||
import 'react';
|
||||
|
||||
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RouteModule = {
|
||||
meta?: Func;
|
||||
links?: Func;
|
||||
headers?: Func;
|
||||
loader?: Func;
|
||||
clientLoader?: Func;
|
||||
action?: Func;
|
||||
clientAction?: Func;
|
||||
HydrateFallback?: unknown;
|
||||
default?: unknown;
|
||||
ErrorBoundary?: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type LinkDescriptors = LinkDescriptor[];
|
||||
type RouteInfo = {
|
||||
parents: RouteInfo[];
|
||||
module: RouteModule;
|
||||
id: unknown;
|
||||
file: string;
|
||||
path: string;
|
||||
params: unknown;
|
||||
loaderData: unknown;
|
||||
actionData: unknown;
|
||||
};
|
||||
type MetaMatch<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
meta: MetaDescriptor[];
|
||||
data: T["loaderData"];
|
||||
handle?: unknown;
|
||||
error?: unknown;
|
||||
}>;
|
||||
type MetaMatches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<RouteInfo> | undefined>;
|
||||
type CreateMetaArgs<T extends RouteInfo> = {
|
||||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
||||
location: Location;
|
||||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
||||
params: T["params"];
|
||||
/** The return value for this route's server loader function */
|
||||
data: T["loaderData"];
|
||||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
||||
error?: unknown;
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: MetaMatches<[...T["parents"], T]>;
|
||||
};
|
||||
type MetaDescriptors = MetaDescriptor[];
|
||||
type HeadersArgs = {
|
||||
loaderHeaders: Headers;
|
||||
parentHeaders: Headers;
|
||||
actionHeaders: Headers;
|
||||
errorHeaders: Headers | undefined;
|
||||
};
|
||||
type IsHydrate<ClientLoader> = ClientLoader extends {
|
||||
hydrate: true;
|
||||
} ? true : ClientLoader extends {
|
||||
hydrate: false;
|
||||
} ? false : false;
|
||||
type CreateLoaderData<T extends RouteModule> = _CreateLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
||||
HydrateFallback: Func;
|
||||
} ? true : false>;
|
||||
type _CreateLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
||||
HasHydrateFallback,
|
||||
ClientLoaderHydrate
|
||||
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
||||
IsDefined<ClientLoaderData>,
|
||||
IsDefined<ServerLoaderData>
|
||||
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
||||
type CreateActionData<T extends RouteModule> = _CreateActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
||||
type _CreateActionData<ServerActionData, ClientActionData> = Awaited<[
|
||||
IsDefined<ServerActionData>,
|
||||
IsDefined<ClientActionData>
|
||||
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
||||
type ClientDataFunctionArgs<T extends RouteInfo> = {
|
||||
/**
|
||||
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
||||
*
|
||||
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
||||
**/
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function clientLoader({
|
||||
* params,
|
||||
* }: Route.ClientLoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* When `future.unstable_middleware` is not enabled, this is undefined.
|
||||
*
|
||||
* When `future.unstable_middleware` is enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used to access context values
|
||||
* from your route middlewares. You may pass in initial context values in your
|
||||
* `<HydratedRouter unstable_getContext>` prop
|
||||
*/
|
||||
context: unstable_RouterContextProvider;
|
||||
};
|
||||
type ServerDataFunctionArgs<T extends RouteInfo> = {
|
||||
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function loader({
|
||||
* params,
|
||||
* }: Route.LoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* Without `future.unstable_middleware` enabled, this is the context passed in
|
||||
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
||||
* gap between the adapter's request/response API with your React Router app.
|
||||
* It is only applicable if you are using a custom server adapter.
|
||||
*
|
||||
* With `future.unstable_middleware` enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used for type-safe access to
|
||||
* context value set in your route middlewares. If you are using a custom
|
||||
* server adapter, you may provide an initial set of context values from your
|
||||
* `getLoadContext` function.
|
||||
*/
|
||||
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
||||
};
|
||||
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
||||
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
||||
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
||||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
||||
};
|
||||
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */
|
||||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
||||
};
|
||||
type CreateHydrateFallbackProps<T extends RouteInfo> = {
|
||||
params: T["params"];
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
type Match<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
data: T["loaderData"];
|
||||
handle: unknown;
|
||||
}>;
|
||||
type Matches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [Match<F>, ...Matches<R>] : Array<Match<RouteInfo> | undefined>;
|
||||
type CreateComponentProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export default function Component({
|
||||
* params,
|
||||
* }: Route.ComponentProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: Matches<[...T["parents"], T]>;
|
||||
};
|
||||
type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function ErrorBoundary({
|
||||
* params,
|
||||
* }: Route.ErrorBoundaryProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
error: unknown;
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
|
||||
export type { CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateClientMiddlewareFunction, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, CreateServerMiddlewareFunction, HeadersArgs, LinkDescriptors, MetaDescriptors };
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// lib/types/route-module.ts
|
||||
var route_module_exports = {};
|
||||
module.exports = __toCommonJS(route_module_exports);
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
+1749
File diff suppressed because it is too large
Load Diff
+1749
File diff suppressed because it is too large
Load Diff
+11556
File diff suppressed because it is too large
Load Diff
+23
@@ -0,0 +1,23 @@
|
||||
import * as React from 'react';
|
||||
import { R as RouterProviderProps$1 } from './lib-CCSAGgcP.mjs';
|
||||
import { R as RouterInit } from './route-data-C6QaL0wu.mjs';
|
||||
|
||||
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
||||
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
||||
|
||||
interface HydratedRouterProps {
|
||||
/**
|
||||
* Context object to passed through to `createBrowserRouter` and made available
|
||||
* to `clientLoader`/`clientActon` functions
|
||||
*/
|
||||
unstable_getContext?: RouterInit["unstable_getContext"];
|
||||
}
|
||||
/**
|
||||
* Framework-mode router component to be used in `entry.client.tsx` to hydrate a
|
||||
* router from a `ServerRouter`
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
||||
|
||||
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import * as React from 'react';
|
||||
import { RouterProviderProps as RouterProviderProps$1, RouterInit } from 'react-router';
|
||||
|
||||
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
||||
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
||||
|
||||
interface HydratedRouterProps {
|
||||
/**
|
||||
* Context object to passed through to `createBrowserRouter` and made available
|
||||
* to `clientLoader`/`clientActon` functions
|
||||
*/
|
||||
unstable_getContext?: RouterInit["unstable_getContext"];
|
||||
}
|
||||
/**
|
||||
* Framework-mode router component to be used in `entry.client.tsx` to hydrate a
|
||||
* router from a `ServerRouter`
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
||||
|
||||
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// dom-export.ts
|
||||
var dom_export_exports = {};
|
||||
__export(dom_export_exports, {
|
||||
HydratedRouter: () => HydratedRouter,
|
||||
RouterProvider: () => RouterProvider
|
||||
});
|
||||
module.exports = __toCommonJS(dom_export_exports);
|
||||
|
||||
// lib/dom-export/dom-router-provider.tsx
|
||||
var React = __toESM(require("react"));
|
||||
var ReactDOM = __toESM(require("react-dom"));
|
||||
var import_react_router = require("react-router");
|
||||
function RouterProvider(props) {
|
||||
return /* @__PURE__ */ React.createElement(import_react_router.RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
||||
}
|
||||
|
||||
// lib/dom-export/hydrated-router.tsx
|
||||
var React2 = __toESM(require("react"));
|
||||
var import_react_router2 = require("react-router");
|
||||
var ssrInfo = null;
|
||||
var router = null;
|
||||
function initSsrInfo() {
|
||||
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
||||
if (window.__reactRouterManifest.sri === true) {
|
||||
const importMap = document.querySelector("script[rr-importmap]");
|
||||
if (importMap?.textContent) {
|
||||
try {
|
||||
window.__reactRouterManifest.sri = JSON.parse(
|
||||
importMap.textContent
|
||||
).integrity;
|
||||
} catch (err) {
|
||||
console.error("Failed to parse import map", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
ssrInfo = {
|
||||
context: window.__reactRouterContext,
|
||||
manifest: window.__reactRouterManifest,
|
||||
routeModules: window.__reactRouterRouteModules,
|
||||
stateDecodingPromise: void 0,
|
||||
router: void 0,
|
||||
routerInitialized: false
|
||||
};
|
||||
}
|
||||
}
|
||||
function createHydratedRouter({
|
||||
unstable_getContext
|
||||
}) {
|
||||
initSsrInfo();
|
||||
if (!ssrInfo) {
|
||||
throw new Error(
|
||||
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
||||
);
|
||||
}
|
||||
let localSsrInfo = ssrInfo;
|
||||
if (!ssrInfo.stateDecodingPromise) {
|
||||
let stream = ssrInfo.context.stream;
|
||||
(0, import_react_router2.UNSAFE_invariant)(stream, "No stream found for single fetch decoding");
|
||||
ssrInfo.context.stream = void 0;
|
||||
ssrInfo.stateDecodingPromise = (0, import_react_router2.UNSAFE_decodeViaTurboStream)(stream, window).then((value) => {
|
||||
ssrInfo.context.state = value.value;
|
||||
localSsrInfo.stateDecodingPromise.value = true;
|
||||
}).catch((e) => {
|
||||
localSsrInfo.stateDecodingPromise.error = e;
|
||||
});
|
||||
}
|
||||
if (ssrInfo.stateDecodingPromise.error) {
|
||||
throw ssrInfo.stateDecodingPromise.error;
|
||||
}
|
||||
if (!ssrInfo.stateDecodingPromise.value) {
|
||||
throw ssrInfo.stateDecodingPromise;
|
||||
}
|
||||
let routes = (0, import_react_router2.UNSAFE_createClientRoutes)(
|
||||
ssrInfo.manifest.routes,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.state,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
let hydrationData = void 0;
|
||||
if (ssrInfo.context.isSpaMode) {
|
||||
let { loaderData } = ssrInfo.context.state;
|
||||
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
||||
hydrationData = {
|
||||
loaderData: {
|
||||
root: loaderData.root
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
hydrationData = (0, import_react_router2.UNSAFE_getHydrationData)(
|
||||
ssrInfo.context.state,
|
||||
routes,
|
||||
(routeId) => ({
|
||||
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
||||
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
||||
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
||||
}),
|
||||
window.location,
|
||||
window.__reactRouterContext?.basename,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
if (hydrationData && hydrationData.errors) {
|
||||
hydrationData.errors = (0, import_react_router2.UNSAFE_deserializeErrors)(hydrationData.errors);
|
||||
}
|
||||
}
|
||||
let router2 = (0, import_react_router2.UNSAFE_createRouter)({
|
||||
routes,
|
||||
history: (0, import_react_router2.UNSAFE_createBrowserHistory)(),
|
||||
basename: ssrInfo.context.basename,
|
||||
unstable_getContext,
|
||||
hydrationData,
|
||||
hydrationRouteProperties: import_react_router2.UNSAFE_hydrationRouteProperties,
|
||||
mapRouteProperties: import_react_router2.UNSAFE_mapRouteProperties,
|
||||
future: {
|
||||
unstable_middleware: ssrInfo.context.future.unstable_middleware
|
||||
},
|
||||
dataStrategy: (0, import_react_router2.UNSAFE_getTurboStreamSingleFetchDataStrategy)(
|
||||
() => router2,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.basename
|
||||
),
|
||||
patchRoutesOnNavigation: (0, import_react_router2.UNSAFE_getPatchRoutesOnNavigationFunction)(
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode,
|
||||
ssrInfo.context.basename
|
||||
)
|
||||
});
|
||||
ssrInfo.router = router2;
|
||||
if (router2.state.initialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
router2.initialize();
|
||||
}
|
||||
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
||||
import_react_router2.UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
|
||||
window.__reactRouterDataRouter = router2;
|
||||
return router2;
|
||||
}
|
||||
function HydratedRouter(props) {
|
||||
if (!router) {
|
||||
router = createHydratedRouter({
|
||||
unstable_getContext: props.unstable_getContext
|
||||
});
|
||||
}
|
||||
let [criticalCss, setCriticalCss] = React2.useState(
|
||||
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
||||
);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (ssrInfo) {
|
||||
window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
|
||||
}
|
||||
}
|
||||
let [location, setLocation] = React2.useState(router.state.location);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
ssrInfo.router.initialize();
|
||||
}
|
||||
}, []);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router) {
|
||||
return ssrInfo.router.subscribe((newState) => {
|
||||
if (newState.location !== location) {
|
||||
setLocation(newState.location);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [location]);
|
||||
(0, import_react_router2.UNSAFE_invariant)(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
||||
(0, import_react_router2.UNSAFE_useFogOFWarDiscovery)(
|
||||
router,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
return (
|
||||
// This fragment is important to ensure we match the <ServerRouter> JSX
|
||||
// structure so that useId values hydrate correctly
|
||||
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
||||
import_react_router2.UNSAFE_FrameworkContext.Provider,
|
||||
{
|
||||
value: {
|
||||
manifest: ssrInfo.manifest,
|
||||
routeModules: ssrInfo.routeModules,
|
||||
future: ssrInfo.context.future,
|
||||
criticalCss,
|
||||
ssr: ssrInfo.context.ssr,
|
||||
isSpaMode: ssrInfo.context.isSpaMode,
|
||||
routeDiscovery: ssrInfo.context.routeDiscovery
|
||||
}
|
||||
},
|
||||
/* @__PURE__ */ React2.createElement(import_react_router2.UNSAFE_RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider, { router }))
|
||||
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
||||
);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
HydratedRouter,
|
||||
RouterProvider
|
||||
});
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
import {
|
||||
FrameworkContext,
|
||||
RemixErrorBoundary,
|
||||
RouterProvider,
|
||||
createBrowserHistory,
|
||||
createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut,
|
||||
createRouter,
|
||||
decodeViaTurboStream,
|
||||
deserializeErrors,
|
||||
getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy,
|
||||
hydrationRouteProperties,
|
||||
invariant,
|
||||
mapRouteProperties,
|
||||
useFogOFWarDiscovery
|
||||
} from "./chunk-CVXGOGHQ.mjs";
|
||||
|
||||
// lib/dom-export/dom-router-provider.tsx
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
function RouterProvider2(props) {
|
||||
return /* @__PURE__ */ React.createElement(RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
||||
}
|
||||
|
||||
// lib/dom-export/hydrated-router.tsx
|
||||
import * as React2 from "react";
|
||||
var ssrInfo = null;
|
||||
var router = null;
|
||||
function initSsrInfo() {
|
||||
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
||||
if (window.__reactRouterManifest.sri === true) {
|
||||
const importMap = document.querySelector("script[rr-importmap]");
|
||||
if (importMap?.textContent) {
|
||||
try {
|
||||
window.__reactRouterManifest.sri = JSON.parse(
|
||||
importMap.textContent
|
||||
).integrity;
|
||||
} catch (err) {
|
||||
console.error("Failed to parse import map", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
ssrInfo = {
|
||||
context: window.__reactRouterContext,
|
||||
manifest: window.__reactRouterManifest,
|
||||
routeModules: window.__reactRouterRouteModules,
|
||||
stateDecodingPromise: void 0,
|
||||
router: void 0,
|
||||
routerInitialized: false
|
||||
};
|
||||
}
|
||||
}
|
||||
function createHydratedRouter({
|
||||
unstable_getContext
|
||||
}) {
|
||||
initSsrInfo();
|
||||
if (!ssrInfo) {
|
||||
throw new Error(
|
||||
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
||||
);
|
||||
}
|
||||
let localSsrInfo = ssrInfo;
|
||||
if (!ssrInfo.stateDecodingPromise) {
|
||||
let stream = ssrInfo.context.stream;
|
||||
invariant(stream, "No stream found for single fetch decoding");
|
||||
ssrInfo.context.stream = void 0;
|
||||
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then((value) => {
|
||||
ssrInfo.context.state = value.value;
|
||||
localSsrInfo.stateDecodingPromise.value = true;
|
||||
}).catch((e) => {
|
||||
localSsrInfo.stateDecodingPromise.error = e;
|
||||
});
|
||||
}
|
||||
if (ssrInfo.stateDecodingPromise.error) {
|
||||
throw ssrInfo.stateDecodingPromise.error;
|
||||
}
|
||||
if (!ssrInfo.stateDecodingPromise.value) {
|
||||
throw ssrInfo.stateDecodingPromise;
|
||||
}
|
||||
let routes = createClientRoutes(
|
||||
ssrInfo.manifest.routes,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.state,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
let hydrationData = void 0;
|
||||
if (ssrInfo.context.isSpaMode) {
|
||||
let { loaderData } = ssrInfo.context.state;
|
||||
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
||||
hydrationData = {
|
||||
loaderData: {
|
||||
root: loaderData.root
|
||||
}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
hydrationData = getHydrationData(
|
||||
ssrInfo.context.state,
|
||||
routes,
|
||||
(routeId) => ({
|
||||
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
||||
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
||||
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
||||
}),
|
||||
window.location,
|
||||
window.__reactRouterContext?.basename,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
if (hydrationData && hydrationData.errors) {
|
||||
hydrationData.errors = deserializeErrors(hydrationData.errors);
|
||||
}
|
||||
}
|
||||
let router2 = createRouter({
|
||||
routes,
|
||||
history: createBrowserHistory(),
|
||||
basename: ssrInfo.context.basename,
|
||||
unstable_getContext,
|
||||
hydrationData,
|
||||
hydrationRouteProperties,
|
||||
mapRouteProperties,
|
||||
future: {
|
||||
unstable_middleware: ssrInfo.context.future.unstable_middleware
|
||||
},
|
||||
dataStrategy: getTurboStreamSingleFetchDataStrategy(
|
||||
() => router2,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.basename
|
||||
),
|
||||
patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode,
|
||||
ssrInfo.context.basename
|
||||
)
|
||||
});
|
||||
ssrInfo.router = router2;
|
||||
if (router2.state.initialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
router2.initialize();
|
||||
}
|
||||
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
||||
createClientRoutesWithHMRRevalidationOptOut;
|
||||
window.__reactRouterDataRouter = router2;
|
||||
return router2;
|
||||
}
|
||||
function HydratedRouter(props) {
|
||||
if (!router) {
|
||||
router = createHydratedRouter({
|
||||
unstable_getContext: props.unstable_getContext
|
||||
});
|
||||
}
|
||||
let [criticalCss, setCriticalCss] = React2.useState(
|
||||
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
||||
);
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (ssrInfo) {
|
||||
window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
|
||||
}
|
||||
}
|
||||
let [location, setLocation] = React2.useState(router.state.location);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
||||
ssrInfo.routerInitialized = true;
|
||||
ssrInfo.router.initialize();
|
||||
}
|
||||
}, []);
|
||||
React2.useLayoutEffect(() => {
|
||||
if (ssrInfo && ssrInfo.router) {
|
||||
return ssrInfo.router.subscribe((newState) => {
|
||||
if (newState.location !== location) {
|
||||
setLocation(newState.location);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [location]);
|
||||
invariant(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
||||
useFogOFWarDiscovery(
|
||||
router,
|
||||
ssrInfo.manifest,
|
||||
ssrInfo.routeModules,
|
||||
ssrInfo.context.ssr,
|
||||
ssrInfo.context.routeDiscovery,
|
||||
ssrInfo.context.isSpaMode
|
||||
);
|
||||
return (
|
||||
// This fragment is important to ensure we match the <ServerRouter> JSX
|
||||
// structure so that useId values hydrate correctly
|
||||
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
||||
FrameworkContext.Provider,
|
||||
{
|
||||
value: {
|
||||
manifest: ssrInfo.manifest,
|
||||
routeModules: ssrInfo.routeModules,
|
||||
future: ssrInfo.context.future,
|
||||
criticalCss,
|
||||
ssr: ssrInfo.context.ssr,
|
||||
isSpaMode: ssrInfo.context.isSpaMode,
|
||||
routeDiscovery: ssrInfo.context.routeDiscovery
|
||||
}
|
||||
},
|
||||
/* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider2, { router }))
|
||||
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
||||
);
|
||||
}
|
||||
export {
|
||||
HydratedRouter,
|
||||
RouterProvider2 as RouterProvider
|
||||
};
|
||||
+814
@@ -0,0 +1,814 @@
|
||||
import { a as Router, b as RouteModules, D as DataStrategyFunction, T as To, c as RelativeRoutingType, L as Location, A as Action, P as ParamParseKey, d as Path, e as PathPattern, f as PathMatch, N as NavigateOptions, g as Params$1, h as RouteObject, i as Navigation, U as UIMatch, S as SerializeFrom, B as BlockerFunction, j as Blocker, k as StaticHandlerContext, l as StaticHandler, F as FutureConfig, C as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as unstable_InitialContext, m as IndexRouteObject, n as NonIndexRouteObject, o as LoaderFunction, p as ActionFunction, M as MetaFunction, q as LinksFunction, r as MiddlewareEnabled, s as AppLoadContext, E as Equal, t as RouterState, v as PatchRoutesOnNavigationFunction, w as DataRouteObject, x as ClientLoaderFunction } from './route-data-C6QaL0wu.mjs';
|
||||
export { W as ActionFunctionArgs, av as ClientActionFunction, aw as ClientActionFunctionArgs, ax as ClientLoaderFunctionArgs, ar as DataRouteMatch, X as DataStrategyFunctionArgs, Y as DataStrategyMatch, Z as DataStrategyResult, $ as ErrorResponse, z as Fetcher, a0 as FormEncType, a1 as FormMethod, aF as Future, G as GetScrollPositionFunction, y as GetScrollRestorationKeyFunction, a2 as HTMLFormMethod, ay as HeadersArgs, az as HeadersFunction, aD as HtmlLinkDescriptor, ah as IDLE_BLOCKER, ag as IDLE_FETCHER, af as IDLE_NAVIGATION, a3 as LazyRouteFunction, aE as LinkDescriptor, a4 as LoaderFunctionArgs, aA as MetaArgs, aB as MetaDescriptor, J as NavigationStates, as as Navigator, aC as PageLinkDescriptor, at as PatchRoutesOnNavigationFunctionArgs, a6 as PathParam, a7 as RedirectFunction, V as RevalidationState, au as RouteMatch, Q as RouterFetchOptions, R as RouterInit, O as RouterNavigateOptions, K as RouterSubscriber, a9 as ShouldRevalidateFunction, aa as ShouldRevalidateFunctionArgs, aL as UNSAFE_DataRouterContext, aM as UNSAFE_DataRouterStateContext, _ as UNSAFE_DataWithResponseInit, aK as UNSAFE_ErrorResponseImpl, aN as UNSAFE_FetchersContext, aO as UNSAFE_LocationContext, aP as UNSAFE_NavigationContext, aQ as UNSAFE_RouteContext, aR as UNSAFE_ViewTransitionContext, aH as UNSAFE_createBrowserHistory, aJ as UNSAFE_createRouter, aI as UNSAFE_invariant, ad as createPath, ai as data, aj as generatePath, ak as isRouteErrorResponse, al as matchPath, am as matchRoutes, ae as parsePath, an as redirect, ao as redirectDocument, ap as replace, aq as resolvePath, a5 as unstable_MiddlewareFunction, a8 as unstable_RouterContext, ac as unstable_RouterContextProvider, aG as unstable_SerializesTo, ab as unstable_createContext } from './route-data-C6QaL0wu.mjs';
|
||||
import { A as AssetsManifest, E as EntryContext, F as FutureConfig$1, S as ServerBuild } from './lib-CCSAGgcP.mjs';
|
||||
export { f as Await, a as AwaitProps, Q as BrowserRouter, B as BrowserRouterProps, D as DOMRouterOpts, v as FetcherFormProps, C as FetcherSubmitFunction, a6 as FetcherSubmitOptions, G as FetcherWithComponents, X as Form, w as FormProps, ah as HandleDataRequestFunction, ai as HandleDocumentRequestFunction, aj as HandleErrorFunction, T as HashRouter, H as HashRouterProps, q as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, U as Link, s as LinkProps, ad as Links, g as MemoryRouter, M as MemoryRouterOpts, b as MemoryRouterProps, ac as Meta, W as NavLink, t as NavLinkProps, u as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a7 as ParamKeyValuePair, P as PathRouteProps, af as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ae as Scripts, ag as ScriptsProps, Y as ScrollRestoration, x as ScrollRestorationProps, ak as ServerEntryModule, y as SetURLSearchParams, z as SubmitFunction, a8 as SubmitOptions, aa as SubmitTarget, an as UNSAFE_FrameworkContext, ao as UNSAFE_createClientRoutes, ap as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, al as UNSAFE_hydrationRouteProperties, am as UNSAFE_mapRouteProperties, aq as UNSAFE_shouldHydrateRouteLoader, ar as UNSAFE_useScrollRestoration, a9 as URLSearchParamsInit, J as createBrowserRouter, K as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, p as createRoutesFromElements, ab as createSearchParams, r as renderMatches, V as unstable_HistoryRouter, a4 as unstable_usePrompt, a3 as useBeforeUnload, a1 as useFetcher, a2 as useFetchers, a0 as useFormAction, Z as useLinkClickHandler, _ as useSearchParams, $ as useSubmit, a5 as useViewTransitionState } from './lib-CCSAGgcP.mjs';
|
||||
import * as React from 'react';
|
||||
import { ReactElement } from 'react';
|
||||
import { ParseOptions, SerializeOptions } from 'cookie';
|
||||
export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
|
||||
|
||||
declare const SingleFetchRedirectSymbol: unique symbol;
|
||||
declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, basename: string | undefined): DataStrategyFunction;
|
||||
declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
|
||||
done: Promise<undefined>;
|
||||
value: unknown;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* The mode to use when running the server.
|
||||
*/
|
||||
declare enum ServerMode {
|
||||
Development = "development",
|
||||
Production = "production",
|
||||
Test = "test"
|
||||
}
|
||||
|
||||
/**
|
||||
Resolves a URL against the current location.
|
||||
|
||||
```tsx
|
||||
import { useHref } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
let href = useHref("some/where");
|
||||
// "/resolved/some/where"
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useHref(to: To, { relative }?: {
|
||||
relative?: RelativeRoutingType;
|
||||
}): string;
|
||||
/**
|
||||
* Returns true if this component is a descendant of a Router, useful to ensure
|
||||
* a component is used within a Router.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useInRouterContext(): boolean;
|
||||
/**
|
||||
Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
|
||||
|
||||
```tsx
|
||||
import * as React from 'react'
|
||||
import { useLocation } from 'react-router'
|
||||
|
||||
function SomeComponent() {
|
||||
let location = useLocation()
|
||||
|
||||
React.useEffect(() => {
|
||||
// Google Analytics
|
||||
ga('send', 'pageview')
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
// ...
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useLocation(): Location;
|
||||
/**
|
||||
* Returns the current navigation action which describes how the router came to
|
||||
* the current location, either by a pop, push, or replace on the history stack.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useNavigationType(): Action;
|
||||
/**
|
||||
* Returns a PathMatch object if the given pattern matches the current URL.
|
||||
* This is useful for components that need to know "active" state, e.g.
|
||||
* `<NavLink>`.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
|
||||
/**
|
||||
* The interface for the navigate() function returned from useNavigate().
|
||||
*/
|
||||
interface NavigateFunction {
|
||||
(to: To, options?: NavigateOptions): void | Promise<void>;
|
||||
(delta: number): void | Promise<void>;
|
||||
}
|
||||
/**
|
||||
Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
|
||||
|
||||
```tsx
|
||||
import { useNavigate } from "react-router";
|
||||
|
||||
function SomeComponent() {
|
||||
let navigate = useNavigate();
|
||||
return (
|
||||
<button
|
||||
onClick={() => {
|
||||
navigate(-1);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useNavigate(): NavigateFunction;
|
||||
/**
|
||||
* Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useOutletContext<Context = unknown>(): Context;
|
||||
/**
|
||||
* Returns the element for the child route at this level of the route
|
||||
* hierarchy. Used internally by `<Outlet>` to render child routes.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useOutlet(context?: unknown): React.ReactElement | null;
|
||||
/**
|
||||
Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
|
||||
|
||||
```tsx
|
||||
import { useParams } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
let params = useParams()
|
||||
params.postId
|
||||
}
|
||||
```
|
||||
|
||||
Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
||||
ParamsOrKey
|
||||
] extends [string] ? Params$1<ParamsOrKey> : Partial<ParamsOrKey>>;
|
||||
/**
|
||||
Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
|
||||
|
||||
```tsx
|
||||
import { useResolvedPath } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
// if the user is at /dashboard/profile
|
||||
let path = useResolvedPath("../accounts")
|
||||
path.pathname // "/dashboard/accounts"
|
||||
path.search // ""
|
||||
path.hash // ""
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useResolvedPath(to: To, { relative }?: {
|
||||
relative?: RelativeRoutingType;
|
||||
}): Path;
|
||||
/**
|
||||
Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
|
||||
|
||||
The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
|
||||
|
||||
```tsx
|
||||
import * as React from "react";
|
||||
import { useRoutes } from "react-router";
|
||||
|
||||
function App() {
|
||||
let element = useRoutes([
|
||||
{
|
||||
path: "/",
|
||||
element: <Dashboard />,
|
||||
children: [
|
||||
{
|
||||
path: "messages",
|
||||
element: <DashboardMessages />,
|
||||
},
|
||||
{ path: "tasks", element: <DashboardTasks /> },
|
||||
],
|
||||
},
|
||||
{ path: "team", element: <AboutPage /> },
|
||||
]);
|
||||
|
||||
return element;
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
||||
/**
|
||||
Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
|
||||
|
||||
```tsx
|
||||
import { useNavigation } from "react-router"
|
||||
|
||||
function SomeComponent() {
|
||||
let navigation = useNavigation();
|
||||
navigation.state
|
||||
navigation.formData
|
||||
// etc.
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useNavigation(): Navigation;
|
||||
/**
|
||||
Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
|
||||
|
||||
```tsx
|
||||
import { useRevalidator } from "react-router";
|
||||
|
||||
function WindowFocusRevalidator() {
|
||||
const revalidator = useRevalidator();
|
||||
|
||||
useFakeWindowFocus(() => {
|
||||
revalidator.revalidate();
|
||||
});
|
||||
|
||||
return (
|
||||
<div hidden={revalidator.state === "idle"}>
|
||||
Revalidating...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRevalidator(): {
|
||||
revalidate: () => Promise<void>;
|
||||
state: Router["state"]["revalidation"];
|
||||
};
|
||||
/**
|
||||
* Returns the active route matches, useful for accessing loaderData for
|
||||
* parent/child routes or the route "handle" property
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useMatches(): UIMatch[];
|
||||
/**
|
||||
Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
|
||||
|
||||
```tsx
|
||||
import { useLoaderData } from "react-router"
|
||||
|
||||
export async function loader() {
|
||||
return await fakeDb.invoices.findAll();
|
||||
}
|
||||
|
||||
export default function Invoices() {
|
||||
let invoices = useLoaderData<typeof loader>();
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useLoaderData<T = any>(): SerializeFrom<T>;
|
||||
/**
|
||||
Returns the loader data for a given route by route ID.
|
||||
|
||||
```tsx
|
||||
import { useRouteLoaderData } from "react-router";
|
||||
|
||||
function SomeComponent() {
|
||||
const { user } = useRouteLoaderData("root");
|
||||
}
|
||||
```
|
||||
|
||||
Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
|
||||
|
||||
| Route Filename | Route ID |
|
||||
| -------------------------- | -------------------- |
|
||||
| `app/root.tsx` | `"root"` |
|
||||
| `app/routes/teams.tsx` | `"routes/teams"` |
|
||||
| `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
|
||||
|
||||
If you created an ID manually, you can use that instead:
|
||||
|
||||
```tsx
|
||||
route("/", "containers/app.tsx", { id: "app" }})
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
|
||||
/**
|
||||
Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
|
||||
|
||||
```tsx
|
||||
import { Form, useActionData } from "react-router"
|
||||
|
||||
export async function action({ request }) {
|
||||
const body = await request.formData()
|
||||
const name = body.get("visitorsName")
|
||||
return { message: `Hello, ${name}` }
|
||||
}
|
||||
|
||||
export default function Invoices() {
|
||||
const data = useActionData()
|
||||
return (
|
||||
<Form method="post">
|
||||
<input type="text" name="visitorsName" />
|
||||
{data ? data.message : "Waiting..."}
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
|
||||
/**
|
||||
Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
|
||||
|
||||
```tsx
|
||||
export function ErrorBoundary() {
|
||||
const error = useRouteError();
|
||||
return <div>{error.message}</div>;
|
||||
}
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useRouteError(): unknown;
|
||||
/**
|
||||
Returns the resolved promise value from the closest {@link Await | `<Await>`}.
|
||||
|
||||
```tsx
|
||||
function SomeDescendant() {
|
||||
const value = useAsyncValue();
|
||||
// ...
|
||||
}
|
||||
|
||||
// somewhere in your app
|
||||
<Await resolve={somePromise}>
|
||||
<SomeDescendant />
|
||||
</Await>
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useAsyncValue(): unknown;
|
||||
/**
|
||||
Returns the rejection value from the closest {@link Await | `<Await>`}.
|
||||
|
||||
```tsx
|
||||
import { Await, useAsyncError } from "react-router"
|
||||
|
||||
function ErrorElement() {
|
||||
const error = useAsyncError();
|
||||
return (
|
||||
<p>Uh Oh, something went wrong! {error.message}</p>
|
||||
);
|
||||
}
|
||||
|
||||
// somewhere in your app
|
||||
<Await
|
||||
resolve={promiseThatRejects}
|
||||
errorElement={<ErrorElement />}
|
||||
/>
|
||||
```
|
||||
|
||||
@category Hooks
|
||||
*/
|
||||
declare function useAsyncError(): unknown;
|
||||
/**
|
||||
* Allow the application to block navigations within the SPA and present the
|
||||
* user a confirmation dialog to confirm the navigation. Mostly used to avoid
|
||||
* using half-filled form data. This does not handle hard-reloads or
|
||||
* cross-origin navigations.
|
||||
*
|
||||
* @category Hooks
|
||||
*/
|
||||
declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
|
||||
|
||||
interface StaticRouterProps {
|
||||
basename?: string;
|
||||
children?: React.ReactNode;
|
||||
location: Partial<Location> | string;
|
||||
}
|
||||
/**
|
||||
* A `<Router>` that may not navigate to any other location. This is useful
|
||||
* on the server where there is no stateful UI.
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
|
||||
interface StaticRouterProviderProps {
|
||||
context: StaticHandlerContext;
|
||||
router: Router;
|
||||
hydrate?: boolean;
|
||||
nonce?: string;
|
||||
}
|
||||
/**
|
||||
* A Data Router that may not navigate to any other location. This is useful
|
||||
* on the server where there is no stateful UI.
|
||||
*
|
||||
* @category Component Routers
|
||||
*/
|
||||
declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
|
||||
type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
|
||||
/**
|
||||
* @category Utils
|
||||
*/
|
||||
declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
||||
/**
|
||||
* @category Data Routers
|
||||
*/
|
||||
declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
|
||||
future?: Partial<FutureConfig>;
|
||||
}): Router;
|
||||
|
||||
interface ServerRouterProps {
|
||||
context: EntryContext;
|
||||
url: string | URL;
|
||||
nonce?: string;
|
||||
}
|
||||
/**
|
||||
* The entry point for a Remix app when it is rendered on the server (in
|
||||
* `app/entry.server.js`). This component is used to generate the HTML in the
|
||||
* response from the server.
|
||||
*
|
||||
* @category Components
|
||||
*/
|
||||
declare function ServerRouter({ context, url, nonce, }: ServerRouterProps): ReactElement;
|
||||
|
||||
interface StubRouteExtensions {
|
||||
Component?: React.ComponentType<{
|
||||
params: ReturnType<typeof useParams>;
|
||||
loaderData: ReturnType<typeof useLoaderData>;
|
||||
actionData: ReturnType<typeof useActionData>;
|
||||
matches: ReturnType<typeof useMatches>;
|
||||
}>;
|
||||
HydrateFallback?: React.ComponentType<{
|
||||
params: ReturnType<typeof useParams>;
|
||||
loaderData: ReturnType<typeof useLoaderData>;
|
||||
actionData: ReturnType<typeof useActionData>;
|
||||
}>;
|
||||
ErrorBoundary?: React.ComponentType<{
|
||||
params: ReturnType<typeof useParams>;
|
||||
loaderData: ReturnType<typeof useLoaderData>;
|
||||
actionData: ReturnType<typeof useActionData>;
|
||||
error: ReturnType<typeof useRouteError>;
|
||||
}>;
|
||||
loader?: LoaderFunction;
|
||||
action?: ActionFunction;
|
||||
children?: StubRouteObject[];
|
||||
meta?: MetaFunction;
|
||||
links?: LinksFunction;
|
||||
}
|
||||
interface StubIndexRouteObject extends Omit<IndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {
|
||||
}
|
||||
interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {
|
||||
}
|
||||
type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
|
||||
interface RoutesTestStubProps {
|
||||
/**
|
||||
* The initial entries in the history stack. This allows you to start a test with
|
||||
* multiple locations already in the history stack (for testing a back navigation, etc.)
|
||||
* The test will default to the last entry in initialEntries if no initialIndex is provided.
|
||||
* e.g. initialEntries={["/home", "/about", "/contact"]}
|
||||
*/
|
||||
initialEntries?: InitialEntry[];
|
||||
/**
|
||||
* The initial index in the history stack to render. This allows you to start a test at a specific entry.
|
||||
* It defaults to the last entry in initialEntries.
|
||||
* e.g.
|
||||
* initialEntries: ["/", "/events/123"]
|
||||
* initialIndex: 1 // start at "/events/123"
|
||||
*/
|
||||
initialIndex?: number;
|
||||
/**
|
||||
* Used to set the route's initial loader and action data.
|
||||
* e.g. hydrationData={{
|
||||
* loaderData: { "/contact": { locale: "en-US" } },
|
||||
* actionData: { "/login": { errors: { email: "invalid email" } }}
|
||||
* }}
|
||||
*/
|
||||
hydrationData?: HydrationState;
|
||||
/**
|
||||
* Future flags mimicking the settings in react-router.config.ts
|
||||
*/
|
||||
future?: Partial<FutureConfig$1>;
|
||||
}
|
||||
/**
|
||||
* @category Utils
|
||||
*/
|
||||
declare function createRoutesStub(routes: StubRouteObject[], unstable_getContext?: () => unstable_InitialContext): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
|
||||
|
||||
interface CookieSignatureOptions {
|
||||
/**
|
||||
* An array of secrets that may be used to sign/unsign the value of a cookie.
|
||||
*
|
||||
* The array makes it easy to rotate secrets. New secrets should be added to
|
||||
* the beginning of the array. `cookie.serialize()` will always use the first
|
||||
* value in the array, but `cookie.parse()` may use any of them so that
|
||||
* cookies that were signed with older secrets still work.
|
||||
*/
|
||||
secrets?: string[];
|
||||
}
|
||||
type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
|
||||
/**
|
||||
* A HTTP cookie.
|
||||
*
|
||||
* A Cookie is a logical container for metadata about a HTTP cookie; its name
|
||||
* and options. But it doesn't contain a value. Instead, it has `parse()` and
|
||||
* `serialize()` methods that allow a single instance to be reused for
|
||||
* parsing/encoding multiple different values.
|
||||
*
|
||||
* @see https://remix.run/utils/cookies#cookie-api
|
||||
*/
|
||||
interface Cookie {
|
||||
/**
|
||||
* The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* True if this cookie uses one or more secrets for verification.
|
||||
*/
|
||||
readonly isSigned: boolean;
|
||||
/**
|
||||
* The Date this cookie expires.
|
||||
*
|
||||
* Note: This is calculated at access time using `maxAge` when no `expires`
|
||||
* option is provided to `createCookie()`.
|
||||
*/
|
||||
readonly expires?: Date;
|
||||
/**
|
||||
* Parses a raw `Cookie` header and returns the value of this cookie or
|
||||
* `null` if it's not present.
|
||||
*/
|
||||
parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
|
||||
/**
|
||||
* Serializes the given value to a string and returns the `Set-Cookie`
|
||||
* header.
|
||||
*/
|
||||
serialize(value: any, options?: SerializeOptions): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* Creates a logical container for managing a browser cookie from the server.
|
||||
*/
|
||||
declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
|
||||
type IsCookieFunction = (object: any) => object is Cookie;
|
||||
/**
|
||||
* Returns true if an object is a Remix cookie container.
|
||||
*
|
||||
* @see https://remix.run/utils/cookies#iscookie
|
||||
*/
|
||||
declare const isCookie: IsCookieFunction;
|
||||
|
||||
type RequestHandler = (request: Request, loadContext?: MiddlewareEnabled extends true ? unstable_InitialContext : AppLoadContext) => Promise<Response>;
|
||||
type CreateRequestHandlerFunction = (build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>), mode?: string) => RequestHandler;
|
||||
declare const createRequestHandler: CreateRequestHandlerFunction;
|
||||
|
||||
/**
|
||||
* An object of name/value pairs to be used in the session.
|
||||
*/
|
||||
interface SessionData {
|
||||
[name: string]: any;
|
||||
}
|
||||
/**
|
||||
* Session persists data across HTTP requests.
|
||||
*
|
||||
* @see https://reactrouter.com/explanation/sessions-and-cookies#sessions
|
||||
*/
|
||||
interface Session<Data = SessionData, FlashData = Data> {
|
||||
/**
|
||||
* A unique identifier for this session.
|
||||
*
|
||||
* Note: This will be the empty string for newly created sessions and
|
||||
* sessions that are not backed by a database (i.e. cookie-based sessions).
|
||||
*/
|
||||
readonly id: string;
|
||||
/**
|
||||
* The raw data contained in this session.
|
||||
*
|
||||
* This is useful mostly for SessionStorage internally to access the raw
|
||||
* session data to persist.
|
||||
*/
|
||||
readonly data: FlashSessionData<Data, FlashData>;
|
||||
/**
|
||||
* Returns `true` if the session has a value for the given `name`, `false`
|
||||
* otherwise.
|
||||
*/
|
||||
has(name: (keyof Data | keyof FlashData) & string): boolean;
|
||||
/**
|
||||
* Returns the value for the given `name` in this session.
|
||||
*/
|
||||
get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
|
||||
/**
|
||||
* Sets a value in the session for the given `name`.
|
||||
*/
|
||||
set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
|
||||
/**
|
||||
* Sets a value in the session that is only valid until the next `get()`.
|
||||
* This can be useful for temporary values, like error messages.
|
||||
*/
|
||||
flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
|
||||
/**
|
||||
* Removes a value from the session.
|
||||
*/
|
||||
unset(name: keyof Data & string): void;
|
||||
}
|
||||
type FlashSessionData<Data, FlashData> = Partial<Data & {
|
||||
[Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
|
||||
}>;
|
||||
type FlashDataKey<Key extends string> = `__flash_${Key}__`;
|
||||
type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
|
||||
/**
|
||||
* Creates a new Session object.
|
||||
*
|
||||
* Note: This function is typically not invoked directly by application code.
|
||||
* Instead, use a `SessionStorage` object's `getSession` method.
|
||||
*/
|
||||
declare const createSession: CreateSessionFunction;
|
||||
type IsSessionFunction = (object: any) => object is Session;
|
||||
/**
|
||||
* Returns true if an object is a React Router session.
|
||||
*
|
||||
* @see https://reactrouter.com/api/utils/isSession
|
||||
*/
|
||||
declare const isSession: IsSessionFunction;
|
||||
/**
|
||||
* SessionStorage stores session data between HTTP requests and knows how to
|
||||
* parse and create cookies.
|
||||
*
|
||||
* A SessionStorage creates Session objects using a `Cookie` header as input.
|
||||
* Then, later it generates the `Set-Cookie` header to be used in the response.
|
||||
*/
|
||||
interface SessionStorage<Data = SessionData, FlashData = Data> {
|
||||
/**
|
||||
* Parses a Cookie header from a HTTP request and returns the associated
|
||||
* Session. If there is no session associated with the cookie, this will
|
||||
* return a new Session with no data.
|
||||
*/
|
||||
getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
|
||||
/**
|
||||
* Stores all data in the Session and returns the Set-Cookie header to be
|
||||
* used in the HTTP response.
|
||||
*/
|
||||
commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
|
||||
/**
|
||||
* Deletes all data associated with the Session and returns the Set-Cookie
|
||||
* header to be used in the HTTP response.
|
||||
*/
|
||||
destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
|
||||
}
|
||||
/**
|
||||
* SessionIdStorageStrategy is designed to allow anyone to easily build their
|
||||
* own SessionStorage using `createSessionStorage(strategy)`.
|
||||
*
|
||||
* This strategy describes a common scenario where the session id is stored in
|
||||
* a cookie but the actual session data is stored elsewhere, usually in a
|
||||
* database or on disk. A set of create, read, update, and delete operations
|
||||
* are provided for managing the session data.
|
||||
*/
|
||||
interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
|
||||
/**
|
||||
* The Cookie used to store the session id, or options used to automatically
|
||||
* create one.
|
||||
*/
|
||||
cookie?: Cookie | (CookieOptions & {
|
||||
name?: string;
|
||||
});
|
||||
/**
|
||||
* Creates a new record with the given data and returns the session id.
|
||||
*/
|
||||
createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
|
||||
/**
|
||||
* Returns data for a given session id, or `null` if there isn't any.
|
||||
*/
|
||||
readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
|
||||
/**
|
||||
* Updates data for the given session id.
|
||||
*/
|
||||
updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
|
||||
/**
|
||||
* Deletes data for a given session id from the data store.
|
||||
*/
|
||||
deleteData: (id: string) => Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Creates a SessionStorage object using a SessionIdStorageStrategy.
|
||||
*
|
||||
* Note: This is a low-level API that should only be used if none of the
|
||||
* existing session storage options meet your requirements.
|
||||
*/
|
||||
declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
|
||||
|
||||
interface CookieSessionStorageOptions {
|
||||
/**
|
||||
* The Cookie used to store the session data on the client, or options used
|
||||
* to automatically create one.
|
||||
*/
|
||||
cookie?: SessionIdStorageStrategy["cookie"];
|
||||
}
|
||||
/**
|
||||
* Creates and returns a SessionStorage object that stores all session data
|
||||
* directly in the session cookie itself.
|
||||
*
|
||||
* This has the advantage that no database or other backend services are
|
||||
* needed, and can help to simplify some load-balanced scenarios. However, it
|
||||
* also has the limitation that serialized session data may not exceed the
|
||||
* browser's maximum cookie size. Trade-offs!
|
||||
*/
|
||||
declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
|
||||
|
||||
interface MemorySessionStorageOptions {
|
||||
/**
|
||||
* The Cookie used to store the session id on the client, or options used
|
||||
* to automatically create one.
|
||||
*/
|
||||
cookie?: SessionIdStorageStrategy["cookie"];
|
||||
}
|
||||
/**
|
||||
* Creates and returns a simple in-memory SessionStorage object, mostly useful
|
||||
* for testing and as a reference implementation.
|
||||
*
|
||||
* Note: This storage does not scale beyond a single process, so it is not
|
||||
* suitable for most production scenarios.
|
||||
*/
|
||||
declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
|
||||
|
||||
type DevServerHooks = {
|
||||
getCriticalCss?: (pathname: string) => Promise<string | undefined>;
|
||||
processRequestError?: (error: unknown) => void;
|
||||
};
|
||||
declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
|
||||
|
||||
/**
|
||||
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
||||
* React Router should handle this for you via type generation.
|
||||
*
|
||||
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
|
||||
*/
|
||||
interface Register {
|
||||
}
|
||||
|
||||
type AnyParams = Record<string, Record<string, string | undefined>>;
|
||||
type Params = Register extends {
|
||||
params: infer RegisteredParams extends AnyParams;
|
||||
} ? RegisteredParams : AnyParams;
|
||||
type Args = {
|
||||
[K in keyof Params]: ToArgs<Params[K]>;
|
||||
};
|
||||
type ToArgs<T> = Equal<T, {}> extends true ? [] : Partial<T> extends T ? [T] | [] : [
|
||||
T
|
||||
];
|
||||
/**
|
||||
Returns a resolved URL path for the specified route.
|
||||
|
||||
```tsx
|
||||
const h = href("/:lang?/about", { lang: "en" })
|
||||
// -> `/en/about`
|
||||
|
||||
<Link to={href("/products/:id", { id: "abc123" })} />
|
||||
```
|
||||
*/
|
||||
declare function href<Path extends keyof Args>(path: Path, ...args: Args[Path]): string;
|
||||
|
||||
declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
|
||||
|
||||
type RemixErrorBoundaryProps = React.PropsWithChildren<{
|
||||
location: Location;
|
||||
isOutsideRemixApp?: boolean;
|
||||
error?: Error;
|
||||
}>;
|
||||
type RemixErrorBoundaryState = {
|
||||
error: null | Error;
|
||||
location: Location;
|
||||
};
|
||||
declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
|
||||
constructor(props: RemixErrorBoundaryProps);
|
||||
static getDerivedStateFromError(error: Error): {
|
||||
error: Error;
|
||||
};
|
||||
static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
|
||||
error: Error | null;
|
||||
location: Location<any>;
|
||||
};
|
||||
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
||||
}
|
||||
|
||||
declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
|
||||
declare function useFogOFWarDiscovery(router: Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
|
||||
|
||||
declare function getHydrationData(state: {
|
||||
loaderData?: Router["state"]["loaderData"];
|
||||
actionData?: Router["state"]["actionData"];
|
||||
errors?: Router["state"]["errors"];
|
||||
}, routes: DataRouteObject[], getRouteInfo: (routeId: string) => {
|
||||
clientLoader: ClientLoaderFunction | undefined;
|
||||
hasLoader: boolean;
|
||||
hasHydrateFallback: boolean;
|
||||
}, location: Path, basename: string | undefined, isSpaMode: boolean): HydrationState;
|
||||
|
||||
export { ActionFunction, AppLoadContext, Blocker, BlockerFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, DataRouteObject, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params$1 as Params, PatchRoutesOnNavigationFunction, Path, PathMatch, PathPattern, type Register, RelativeRoutingType, type RequestHandler, RouteObject, RouterState, type RoutesTestStubProps, ServerBuild, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, MiddlewareEnabled as UNSAFE_MiddlewareEnabled, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, href, isCookie, isSession, unstable_InitialContext, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
|
||||
+2544
File diff suppressed because it is too large
Load Diff
+11706
File diff suppressed because it is too large
Load Diff
+246
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
import {
|
||||
Action,
|
||||
Await,
|
||||
BrowserRouter,
|
||||
DataRouterContext,
|
||||
DataRouterStateContext,
|
||||
ErrorResponseImpl,
|
||||
FetchersContext,
|
||||
Form,
|
||||
FrameworkContext,
|
||||
HashRouter,
|
||||
HistoryRouter,
|
||||
IDLE_BLOCKER,
|
||||
IDLE_FETCHER,
|
||||
IDLE_NAVIGATION,
|
||||
Link,
|
||||
Links,
|
||||
LocationContext,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
NavigationContext,
|
||||
Outlet,
|
||||
PrefetchPageLinks,
|
||||
RemixErrorBoundary,
|
||||
Route,
|
||||
RouteContext,
|
||||
Router,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
ServerMode,
|
||||
ServerRouter,
|
||||
SingleFetchRedirectSymbol,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
ViewTransitionContext,
|
||||
createBrowserHistory,
|
||||
createBrowserRouter,
|
||||
createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut,
|
||||
createCookie,
|
||||
createCookieSessionStorage,
|
||||
createHashRouter,
|
||||
createMemoryRouter,
|
||||
createMemorySessionStorage,
|
||||
createPath,
|
||||
createRequestHandler,
|
||||
createRouter,
|
||||
createRoutesFromChildren,
|
||||
createRoutesFromElements,
|
||||
createRoutesStub,
|
||||
createSearchParams,
|
||||
createSession,
|
||||
createSessionStorage,
|
||||
createStaticHandler,
|
||||
createStaticRouter,
|
||||
data,
|
||||
decodeViaTurboStream,
|
||||
deserializeErrors,
|
||||
generatePath,
|
||||
getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy,
|
||||
href,
|
||||
hydrationRouteProperties,
|
||||
invariant,
|
||||
isCookie,
|
||||
isRouteErrorResponse,
|
||||
isSession,
|
||||
mapRouteProperties,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
parsePath,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
renderMatches,
|
||||
replace,
|
||||
resolvePath,
|
||||
setDevServerHooks,
|
||||
shouldHydrateRouteLoader,
|
||||
unstable_RouterContextProvider,
|
||||
unstable_createContext,
|
||||
useActionData,
|
||||
useAsyncError,
|
||||
useAsyncValue,
|
||||
useBeforeUnload,
|
||||
useBlocker,
|
||||
useFetcher,
|
||||
useFetchers,
|
||||
useFogOFWarDiscovery,
|
||||
useFormAction,
|
||||
useHref,
|
||||
useInRouterContext,
|
||||
useLinkClickHandler,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useMatch,
|
||||
useMatches,
|
||||
useNavigate,
|
||||
useNavigation,
|
||||
useNavigationType,
|
||||
useOutlet,
|
||||
useOutletContext,
|
||||
useParams,
|
||||
usePrompt,
|
||||
useResolvedPath,
|
||||
useRevalidator,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
useRoutes,
|
||||
useScrollRestoration,
|
||||
useSearchParams,
|
||||
useSubmit,
|
||||
useViewTransitionState
|
||||
} from "./chunk-CVXGOGHQ.mjs";
|
||||
export {
|
||||
Await,
|
||||
BrowserRouter,
|
||||
Form,
|
||||
HashRouter,
|
||||
IDLE_BLOCKER,
|
||||
IDLE_FETCHER,
|
||||
IDLE_NAVIGATION,
|
||||
Link,
|
||||
Links,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
Action as NavigationType,
|
||||
Outlet,
|
||||
PrefetchPageLinks,
|
||||
Route,
|
||||
Router,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
ServerRouter,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
DataRouterContext as UNSAFE_DataRouterContext,
|
||||
DataRouterStateContext as UNSAFE_DataRouterStateContext,
|
||||
ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
|
||||
FetchersContext as UNSAFE_FetchersContext,
|
||||
FrameworkContext as UNSAFE_FrameworkContext,
|
||||
LocationContext as UNSAFE_LocationContext,
|
||||
NavigationContext as UNSAFE_NavigationContext,
|
||||
RemixErrorBoundary as UNSAFE_RemixErrorBoundary,
|
||||
RouteContext as UNSAFE_RouteContext,
|
||||
ServerMode as UNSAFE_ServerMode,
|
||||
SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol,
|
||||
ViewTransitionContext as UNSAFE_ViewTransitionContext,
|
||||
createBrowserHistory as UNSAFE_createBrowserHistory,
|
||||
createClientRoutes as UNSAFE_createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
|
||||
createRouter as UNSAFE_createRouter,
|
||||
decodeViaTurboStream as UNSAFE_decodeViaTurboStream,
|
||||
deserializeErrors as UNSAFE_deserializeErrors,
|
||||
getHydrationData as UNSAFE_getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy,
|
||||
hydrationRouteProperties as UNSAFE_hydrationRouteProperties,
|
||||
invariant as UNSAFE_invariant,
|
||||
mapRouteProperties as UNSAFE_mapRouteProperties,
|
||||
shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader,
|
||||
useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery,
|
||||
useScrollRestoration as UNSAFE_useScrollRestoration,
|
||||
createBrowserRouter,
|
||||
createCookie,
|
||||
createCookieSessionStorage,
|
||||
createHashRouter,
|
||||
createMemoryRouter,
|
||||
createMemorySessionStorage,
|
||||
createPath,
|
||||
createRequestHandler,
|
||||
createRoutesFromChildren,
|
||||
createRoutesFromElements,
|
||||
createRoutesStub,
|
||||
createSearchParams,
|
||||
createSession,
|
||||
createSessionStorage,
|
||||
createStaticHandler,
|
||||
createStaticRouter,
|
||||
data,
|
||||
generatePath,
|
||||
href,
|
||||
isCookie,
|
||||
isRouteErrorResponse,
|
||||
isSession,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
parsePath,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
renderMatches,
|
||||
replace,
|
||||
resolvePath,
|
||||
HistoryRouter as unstable_HistoryRouter,
|
||||
unstable_RouterContextProvider,
|
||||
unstable_createContext,
|
||||
setDevServerHooks as unstable_setDevServerHooks,
|
||||
usePrompt as unstable_usePrompt,
|
||||
useActionData,
|
||||
useAsyncError,
|
||||
useAsyncValue,
|
||||
useBeforeUnload,
|
||||
useBlocker,
|
||||
useFetcher,
|
||||
useFetchers,
|
||||
useFormAction,
|
||||
useHref,
|
||||
useInRouterContext,
|
||||
useLinkClickHandler,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useMatch,
|
||||
useMatches,
|
||||
useNavigate,
|
||||
useNavigation,
|
||||
useNavigationType,
|
||||
useOutlet,
|
||||
useOutletContext,
|
||||
useParams,
|
||||
useResolvedPath,
|
||||
useRevalidator,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
useRoutes,
|
||||
useSearchParams,
|
||||
useSubmit,
|
||||
useViewTransitionState
|
||||
};
|
||||
+1736
File diff suppressed because it is too large
Load Diff
+208
@@ -0,0 +1,208 @@
|
||||
import { aE as LinkDescriptor, L as Location, aB as MetaDescriptor, aV as ServerDataFrom, aW as ClientDataFrom, aX as Func, aY as unstable_MiddlewareNextFunction, E as Equal, ac as unstable_RouterContextProvider, r as MiddlewareEnabled, s as AppLoadContext, aZ as Pretty } from '../../route-data-C6QaL0wu.mjs';
|
||||
import 'react';
|
||||
|
||||
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RouteModule = {
|
||||
meta?: Func;
|
||||
links?: Func;
|
||||
headers?: Func;
|
||||
loader?: Func;
|
||||
clientLoader?: Func;
|
||||
action?: Func;
|
||||
clientAction?: Func;
|
||||
HydrateFallback?: unknown;
|
||||
default?: unknown;
|
||||
ErrorBoundary?: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type LinkDescriptors = LinkDescriptor[];
|
||||
type RouteInfo = {
|
||||
parents: RouteInfo[];
|
||||
module: RouteModule;
|
||||
id: unknown;
|
||||
file: string;
|
||||
path: string;
|
||||
params: unknown;
|
||||
loaderData: unknown;
|
||||
actionData: unknown;
|
||||
};
|
||||
type MetaMatch<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
meta: MetaDescriptor[];
|
||||
data: T["loaderData"];
|
||||
handle?: unknown;
|
||||
error?: unknown;
|
||||
}>;
|
||||
type MetaMatches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<RouteInfo> | undefined>;
|
||||
type CreateMetaArgs<T extends RouteInfo> = {
|
||||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
||||
location: Location;
|
||||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
||||
params: T["params"];
|
||||
/** The return value for this route's server loader function */
|
||||
data: T["loaderData"];
|
||||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
||||
error?: unknown;
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: MetaMatches<[...T["parents"], T]>;
|
||||
};
|
||||
type MetaDescriptors = MetaDescriptor[];
|
||||
type HeadersArgs = {
|
||||
loaderHeaders: Headers;
|
||||
parentHeaders: Headers;
|
||||
actionHeaders: Headers;
|
||||
errorHeaders: Headers | undefined;
|
||||
};
|
||||
type IsHydrate<ClientLoader> = ClientLoader extends {
|
||||
hydrate: true;
|
||||
} ? true : ClientLoader extends {
|
||||
hydrate: false;
|
||||
} ? false : false;
|
||||
type CreateLoaderData<T extends RouteModule> = _CreateLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
||||
HydrateFallback: Func;
|
||||
} ? true : false>;
|
||||
type _CreateLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
||||
HasHydrateFallback,
|
||||
ClientLoaderHydrate
|
||||
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
||||
IsDefined<ClientLoaderData>,
|
||||
IsDefined<ServerLoaderData>
|
||||
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
||||
type CreateActionData<T extends RouteModule> = _CreateActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
||||
type _CreateActionData<ServerActionData, ClientActionData> = Awaited<[
|
||||
IsDefined<ServerActionData>,
|
||||
IsDefined<ClientActionData>
|
||||
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
||||
type ClientDataFunctionArgs<T extends RouteInfo> = {
|
||||
/**
|
||||
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
||||
*
|
||||
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
||||
**/
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function clientLoader({
|
||||
* params,
|
||||
* }: Route.ClientLoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* When `future.unstable_middleware` is not enabled, this is undefined.
|
||||
*
|
||||
* When `future.unstable_middleware` is enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used to access context values
|
||||
* from your route middlewares. You may pass in initial context values in your
|
||||
* `<HydratedRouter unstable_getContext>` prop
|
||||
*/
|
||||
context: unstable_RouterContextProvider;
|
||||
};
|
||||
type ServerDataFunctionArgs<T extends RouteInfo> = {
|
||||
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function loader({
|
||||
* params,
|
||||
* }: Route.LoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* Without `future.unstable_middleware` enabled, this is the context passed in
|
||||
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
||||
* gap between the adapter's request/response API with your React Router app.
|
||||
* It is only applicable if you are using a custom server adapter.
|
||||
*
|
||||
* With `future.unstable_middleware` enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used for type-safe access to
|
||||
* context value set in your route middlewares. If you are using a custom
|
||||
* server adapter, you may provide an initial set of context values from your
|
||||
* `getLoadContext` function.
|
||||
*/
|
||||
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
||||
};
|
||||
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
||||
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
||||
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
||||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
||||
};
|
||||
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */
|
||||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
||||
};
|
||||
type CreateHydrateFallbackProps<T extends RouteInfo> = {
|
||||
params: T["params"];
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
type Match<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
data: T["loaderData"];
|
||||
handle: unknown;
|
||||
}>;
|
||||
type Matches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [Match<F>, ...Matches<R>] : Array<Match<RouteInfo> | undefined>;
|
||||
type CreateComponentProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export default function Component({
|
||||
* params,
|
||||
* }: Route.ComponentProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: Matches<[...T["parents"], T]>;
|
||||
};
|
||||
type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function ErrorBoundary({
|
||||
* params,
|
||||
* }: Route.ErrorBoundaryProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
error: unknown;
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
|
||||
export type { CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateClientMiddlewareFunction, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, CreateServerMiddlewareFunction, HeadersArgs, LinkDescriptors, MetaDescriptors };
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
import { aH as LinkDescriptor, e as Location, aF as MetaDescriptor, aV as ServerDataFrom, aW as ClientDataFrom, aX as Func, aY as unstable_MiddlewareNextFunction, _ as Equal, u as unstable_RouterContextProvider, M as MiddlewareEnabled, i as AppLoadContext, aZ as Pretty } from '../../route-data-B9_30zbP.js';
|
||||
import 'react';
|
||||
|
||||
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type RouteModule = {
|
||||
meta?: Func;
|
||||
links?: Func;
|
||||
headers?: Func;
|
||||
loader?: Func;
|
||||
clientLoader?: Func;
|
||||
action?: Func;
|
||||
clientAction?: Func;
|
||||
HydrateFallback?: unknown;
|
||||
default?: unknown;
|
||||
ErrorBoundary?: unknown;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
type LinkDescriptors = LinkDescriptor[];
|
||||
type RouteInfo = {
|
||||
parents: RouteInfo[];
|
||||
module: RouteModule;
|
||||
id: unknown;
|
||||
file: string;
|
||||
path: string;
|
||||
params: unknown;
|
||||
loaderData: unknown;
|
||||
actionData: unknown;
|
||||
};
|
||||
type MetaMatch<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
meta: MetaDescriptor[];
|
||||
data: T["loaderData"];
|
||||
handle?: unknown;
|
||||
error?: unknown;
|
||||
}>;
|
||||
type MetaMatches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<RouteInfo> | undefined>;
|
||||
type CreateMetaArgs<T extends RouteInfo> = {
|
||||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
||||
location: Location;
|
||||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
||||
params: T["params"];
|
||||
/** The return value for this route's server loader function */
|
||||
data: T["loaderData"];
|
||||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
||||
error?: unknown;
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: MetaMatches<[...T["parents"], T]>;
|
||||
};
|
||||
type MetaDescriptors = MetaDescriptor[];
|
||||
type HeadersArgs = {
|
||||
loaderHeaders: Headers;
|
||||
parentHeaders: Headers;
|
||||
actionHeaders: Headers;
|
||||
errorHeaders: Headers | undefined;
|
||||
};
|
||||
type IsHydrate<ClientLoader> = ClientLoader extends {
|
||||
hydrate: true;
|
||||
} ? true : ClientLoader extends {
|
||||
hydrate: false;
|
||||
} ? false : false;
|
||||
type CreateLoaderData<T extends RouteModule> = _CreateLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
||||
HydrateFallback: Func;
|
||||
} ? true : false>;
|
||||
type _CreateLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
||||
HasHydrateFallback,
|
||||
ClientLoaderHydrate
|
||||
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
||||
IsDefined<ClientLoaderData>,
|
||||
IsDefined<ServerLoaderData>
|
||||
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
||||
type CreateActionData<T extends RouteModule> = _CreateActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
||||
type _CreateActionData<ServerActionData, ClientActionData> = Awaited<[
|
||||
IsDefined<ServerActionData>,
|
||||
IsDefined<ClientActionData>
|
||||
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
||||
type ClientDataFunctionArgs<T extends RouteInfo> = {
|
||||
/**
|
||||
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
|
||||
*
|
||||
* @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
|
||||
**/
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function clientLoader({
|
||||
* params,
|
||||
* }: Route.ClientLoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* When `future.unstable_middleware` is not enabled, this is undefined.
|
||||
*
|
||||
* When `future.unstable_middleware` is enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used to access context values
|
||||
* from your route middlewares. You may pass in initial context values in your
|
||||
* `<HydratedRouter unstable_getContext>` prop
|
||||
*/
|
||||
context: unstable_RouterContextProvider;
|
||||
};
|
||||
type ServerDataFunctionArgs<T extends RouteInfo> = {
|
||||
/** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
|
||||
request: Request;
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function loader({
|
||||
* params,
|
||||
* }: Route.LoaderArgs) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/**
|
||||
* Without `future.unstable_middleware` enabled, this is the context passed in
|
||||
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
||||
* gap between the adapter's request/response API with your React Router app.
|
||||
* It is only applicable if you are using a custom server adapter.
|
||||
*
|
||||
* With `future.unstable_middleware` enabled, this is an instance of
|
||||
* `unstable_RouterContextProvider` and can be used for type-safe access to
|
||||
* context value set in your route middlewares. If you are using a custom
|
||||
* server adapter, you may provide an initial set of context values from your
|
||||
* `getLoadContext` function.
|
||||
*/
|
||||
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
||||
};
|
||||
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
||||
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
||||
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
||||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
||||
};
|
||||
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
||||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
||||
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */
|
||||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
||||
};
|
||||
type CreateHydrateFallbackProps<T extends RouteInfo> = {
|
||||
params: T["params"];
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
type Match<T extends RouteInfo> = Pretty<Pick<T, "id" | "params"> & {
|
||||
pathname: string;
|
||||
data: T["loaderData"];
|
||||
handle: unknown;
|
||||
}>;
|
||||
type Matches<T extends RouteInfo[]> = T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]] ? [Match<F>, ...Matches<R>] : Array<Match<RouteInfo> | undefined>;
|
||||
type CreateComponentProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export default function Component({
|
||||
* params,
|
||||
* }: Route.ComponentProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: Matches<[...T["parents"], T]>;
|
||||
};
|
||||
type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function ErrorBoundary({
|
||||
* params,
|
||||
* }: Route.ErrorBoundaryProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
error: unknown;
|
||||
loaderData?: T["loaderData"];
|
||||
actionData?: T["actionData"];
|
||||
};
|
||||
|
||||
export type { CreateActionData, CreateClientActionArgs, CreateClientLoaderArgs, CreateClientMiddlewareFunction, CreateComponentProps, CreateErrorBoundaryProps, CreateHydrateFallbackProps, CreateLoaderData, CreateMetaArgs, CreateServerActionArgs, CreateServerLoaderArgs, CreateServerMiddlewareFunction, HeadersArgs, LinkDescriptors, MetaDescriptors };
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// lib/types/route-module.ts
|
||||
var route_module_exports = {};
|
||||
module.exports = __toCommonJS(route_module_exports);
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* react-router v7.6.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
+1749
File diff suppressed because it is too large
Load Diff
+1749
File diff suppressed because it is too large
Load Diff
+24
@@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2014 Roman Shtylman <[email protected]>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <[email protected]>
|
||||
|
||||
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.
|
||||
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
# cookie
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Coverage Status][coverage-image]][coverage-url]
|
||||
|
||||
Basic HTTP cookie parser and serializer for HTTP servers.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install cookie
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
const cookie = require("cookie");
|
||||
// import * as cookie from 'cookie';
|
||||
```
|
||||
|
||||
### cookie.parse(str, options)
|
||||
|
||||
Parse a HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
|
||||
The `str` argument is the string representing a `Cookie` header value and `options` is an
|
||||
optional object containing additional parsing options.
|
||||
|
||||
```js
|
||||
const cookies = cookie.parse("foo=bar; equation=E%3Dmc%5E2");
|
||||
// { foo: 'bar', equation: 'E=mc^2' }
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`cookie.parse` accepts these properties in the options object.
|
||||
|
||||
##### decode
|
||||
|
||||
Specifies a function that will be used to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode
|
||||
a previously-encoded cookie value into a JavaScript string.
|
||||
|
||||
The default function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error
|
||||
is thrown it will return the cookie's original value. If you provide your own encode/decode
|
||||
scheme you must ensure errors are appropriately handled.
|
||||
|
||||
### cookie.serialize(name, value, options)
|
||||
|
||||
Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
|
||||
name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
|
||||
argument is an optional object containing additional serialization options.
|
||||
|
||||
```js
|
||||
const setCookie = cookie.serialize("foo", "bar");
|
||||
// foo=bar
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`cookie.serialize` accepts these properties in the options object.
|
||||
|
||||
##### encode
|
||||
|
||||
Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode
|
||||
a value into a string suited for a cookie's value, and should mirror `decode` when parsing.
|
||||
|
||||
The default function is the global `encodeURIComponent`.
|
||||
|
||||
##### maxAge
|
||||
|
||||
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
|
||||
|
||||
The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
##### expires
|
||||
|
||||
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
|
||||
When no expiration is set clients consider this a "non-persistent cookie" and delete it the current session is over.
|
||||
|
||||
The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
##### domain
|
||||
|
||||
Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
|
||||
When no domain is set clients consider the cookie to apply to the current domain only.
|
||||
|
||||
##### path
|
||||
|
||||
Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
||||
When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
|
||||
|
||||
##### httpOnly
|
||||
|
||||
Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
|
||||
When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
|
||||
|
||||
##### secure
|
||||
|
||||
Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
|
||||
When enabled, clients will only send the cookie back if the browser has a HTTPS connection.
|
||||
|
||||
##### partitioned
|
||||
|
||||
Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
|
||||
When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
|
||||
|
||||
This is an attribute that has not yet been fully standardized, and may change in the future.
|
||||
This also means clients may ignore this attribute until they understand it. More information
|
||||
about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
||||
|
||||
##### priority
|
||||
|
||||
Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
|
||||
- `'low'` will set the `Priority` attribute to `Low`.
|
||||
- `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
||||
- `'high'` will set the `Priority` attribute to `High`.
|
||||
|
||||
More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
|
||||
##### sameSite
|
||||
|
||||
Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
|
||||
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
||||
- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
||||
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
|
||||
More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
|
||||
## Example
|
||||
|
||||
The following example uses this module in conjunction with the Node.js core HTTP server
|
||||
to prompt a user for their name and display it back on future visits.
|
||||
|
||||
```js
|
||||
var cookie = require("cookie");
|
||||
var escapeHtml = require("escape-html");
|
||||
var http = require("http");
|
||||
var url = require("url");
|
||||
|
||||
function onRequest(req, res) {
|
||||
// Parse the query string
|
||||
var query = url.parse(req.url, true, true).query;
|
||||
|
||||
if (query && query.name) {
|
||||
// Set a new cookie with the name
|
||||
res.setHeader(
|
||||
"Set-Cookie",
|
||||
cookie.serialize("name", String(query.name), {
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7, // 1 week
|
||||
}),
|
||||
);
|
||||
|
||||
// Redirect back after setting cookie
|
||||
res.statusCode = 302;
|
||||
res.setHeader("Location", req.headers.referer || "/");
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse the cookies on the request
|
||||
var cookies = cookie.parse(req.headers.cookie || "");
|
||||
|
||||
// Get the visitor name set in the cookie
|
||||
var name = cookies.name;
|
||||
|
||||
res.setHeader("Content-Type", "text/html; charset=UTF-8");
|
||||
|
||||
if (name) {
|
||||
res.write("<p>Welcome back, <b>" + escapeHtml(name) + "</b>!</p>");
|
||||
} else {
|
||||
res.write("<p>Hello, new visitor!</p>");
|
||||
}
|
||||
|
||||
res.write('<form method="GET">');
|
||||
res.write(
|
||||
'<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">',
|
||||
);
|
||||
res.end("</form>");
|
||||
}
|
||||
|
||||
http.createServer(onRequest).listen(3000);
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
npm test
|
||||
```
|
||||
|
||||
## Benchmark
|
||||
|
||||
```sh
|
||||
npm run bench
|
||||
```
|
||||
|
||||
```
|
||||
name hz min max mean p75 p99 p995 p999 rme samples
|
||||
· simple 8,566,313.09 0.0000 0.3694 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.64% 4283157 fastest
|
||||
· decode 3,834,348.85 0.0001 0.2465 0.0003 0.0003 0.0003 0.0004 0.0006 ±0.38% 1917175
|
||||
· unquote 8,315,355.96 0.0000 0.3824 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.72% 4157880
|
||||
· duplicates 1,944,765.97 0.0004 0.2959 0.0005 0.0005 0.0006 0.0006 0.0008 ±0.24% 972384
|
||||
· 10 cookies 675,345.67 0.0012 0.4328 0.0015 0.0015 0.0019 0.0020 0.0058 ±0.75% 337673
|
||||
· 100 cookies 61,040.71 0.0152 0.4092 0.0164 0.0160 0.0196 0.0228 0.2260 ±0.71% 30521 slowest
|
||||
✓ parse top-sites (15) 22945ms
|
||||
name hz min max mean p75 p99 p995 p999 rme samples
|
||||
· parse accounts.google.com 7,164,349.17 0.0000 0.0929 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.09% 3582184
|
||||
· parse apple.com 7,817,686.84 0.0000 0.6048 0.0001 0.0001 0.0002 0.0002 0.0003 ±1.05% 3908844
|
||||
· parse cloudflare.com 7,189,841.70 0.0000 0.0390 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3594921
|
||||
· parse docs.google.com 7,051,765.61 0.0000 0.0296 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3525883
|
||||
· parse drive.google.com 7,349,104.77 0.0000 0.0368 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.05% 3674553
|
||||
· parse en.wikipedia.org 1,929,909.49 0.0004 0.3598 0.0005 0.0005 0.0007 0.0007 0.0012 ±0.16% 964955
|
||||
· parse linkedin.com 2,225,658.01 0.0003 0.0595 0.0004 0.0005 0.0005 0.0005 0.0006 ±0.06% 1112830
|
||||
· parse maps.google.com 4,423,511.68 0.0001 0.0942 0.0002 0.0003 0.0003 0.0003 0.0005 ±0.08% 2211756
|
||||
· parse microsoft.com 3,387,601.88 0.0002 0.0725 0.0003 0.0003 0.0004 0.0004 0.0005 ±0.09% 1693801
|
||||
· parse play.google.com 7,375,980.86 0.0000 0.1994 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.12% 3687991
|
||||
· parse support.google.com 4,912,267.94 0.0001 2.8958 0.0002 0.0002 0.0003 0.0003 0.0005 ±1.28% 2456134
|
||||
· parse www.google.com 3,443,035.87 0.0002 0.2783 0.0003 0.0003 0.0004 0.0004 0.0007 ±0.51% 1721518
|
||||
· parse youtu.be 1,910,492.87 0.0004 0.3490 0.0005 0.0005 0.0007 0.0007 0.0011 ±0.46% 955247
|
||||
· parse youtube.com 1,895,082.62 0.0004 0.7454 0.0005 0.0005 0.0006 0.0007 0.0013 ±0.64% 947542 slowest
|
||||
· parse example.com 21,582,835.27 0.0000 0.1095 0.0000 0.0000 0.0001 0.0001 0.0001 ±0.13% 10791418
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [RFC 6265: HTTP State Management Mechanism](https://tools.ietf.org/html/rfc6265)
|
||||
- [Same-site Cookies](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://img.shields.io/github/actions/workflow/status/jshttp/cookie/ci.yml
|
||||
[ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml?query=branch%3Amaster
|
||||
[coverage-image]: https://img.shields.io/codecov/c/github/jshttp/cookie/master
|
||||
[coverage-url]: https://app.codecov.io/gh/jshttp/cookie
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/cookie
|
||||
[npm-url]: https://npmjs.org/package/cookie
|
||||
[npm-version-image]: https://img.shields.io/npm/v/cookie
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* Parse options.
|
||||
*/
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
* Specifies a function that will be used to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
* Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode
|
||||
* a previously-encoded cookie value into a JavaScript string.
|
||||
*
|
||||
* The default function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error
|
||||
* is thrown it will return the cookie's original value. If you provide your own encode/decode
|
||||
* scheme you must ensure errors are appropriately handled.
|
||||
*
|
||||
* @default decode
|
||||
*/
|
||||
decode?: (str: string) => string | undefined;
|
||||
}
|
||||
/**
|
||||
* Parse a cookie header.
|
||||
*
|
||||
* Parse the given cookie header string into an object
|
||||
* The object has the various cookies as keys(names) => values
|
||||
*/
|
||||
export declare function parse(str: string, options?: ParseOptions): Record<string, string | undefined>;
|
||||
/**
|
||||
* Serialize options.
|
||||
*/
|
||||
export interface SerializeOptions {
|
||||
/**
|
||||
* Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
* Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode
|
||||
* a value into a string suited for a cookie's value, and should mirror `decode` when parsing.
|
||||
*
|
||||
* @default encodeURIComponent
|
||||
*/
|
||||
encode?: (str: string) => string;
|
||||
/**
|
||||
* Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
|
||||
*
|
||||
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
* so if both are set, they should point to the same date and time.
|
||||
*/
|
||||
maxAge?: number;
|
||||
/**
|
||||
* Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
|
||||
* When no expiration is set clients consider this a "non-persistent cookie" and delete it the current session is over.
|
||||
*
|
||||
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
* so if both are set, they should point to the same date and time.
|
||||
*/
|
||||
expires?: Date;
|
||||
/**
|
||||
* Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
|
||||
* When no domain is set clients consider the cookie to apply to the current domain only.
|
||||
*/
|
||||
domain?: string;
|
||||
/**
|
||||
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
||||
* When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
|
||||
* When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
|
||||
*/
|
||||
httpOnly?: boolean;
|
||||
/**
|
||||
* Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
|
||||
* When enabled, clients will only send the cookie back if the browser has a HTTPS connection.
|
||||
*/
|
||||
secure?: boolean;
|
||||
/**
|
||||
* Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
|
||||
* When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
|
||||
*
|
||||
* This is an attribute that has not yet been fully standardized, and may change in the future.
|
||||
* This also means clients may ignore this attribute until they understand it. More information
|
||||
* about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
||||
*/
|
||||
partitioned?: boolean;
|
||||
/**
|
||||
* Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
*
|
||||
* - `'low'` will set the `Priority` attribute to `Low`.
|
||||
* - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
||||
* - `'high'` will set the `Priority` attribute to `High`.
|
||||
*
|
||||
* More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
*/
|
||||
priority?: "low" | "medium" | "high";
|
||||
/**
|
||||
* Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
*
|
||||
* - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
* - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
||||
* - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
||||
* - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
*
|
||||
* More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
*/
|
||||
sameSite?: boolean | "lax" | "strict" | "none";
|
||||
}
|
||||
/**
|
||||
* Serialize data into a cookie header.
|
||||
*
|
||||
* Serialize a name value pair into a cookie string suitable for
|
||||
* http headers. An optional options object specifies cookie parameters.
|
||||
*
|
||||
* serialize('foo', 'bar', { httpOnly: true })
|
||||
* => "foo=bar; httpOnly"
|
||||
*/
|
||||
export declare function serialize(name: string, val: string, options?: SerializeOptions): string;
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parse = parse;
|
||||
exports.serialize = serialize;
|
||||
/**
|
||||
* RegExp to match cookie-name in RFC 6265 sec 4.1.1
|
||||
* This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
|
||||
* which has been replaced by the token definition in RFC 7230 appendix B.
|
||||
*
|
||||
* cookie-name = token
|
||||
* token = 1*tchar
|
||||
* tchar = "!" / "#" / "$" / "%" / "&" / "'" /
|
||||
* "*" / "+" / "-" / "." / "^" / "_" /
|
||||
* "`" / "|" / "~" / DIGIT / ALPHA
|
||||
*
|
||||
* Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191
|
||||
* Allow same range as cookie value, except `=`, which delimits end of name.
|
||||
*/
|
||||
const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
|
||||
/**
|
||||
* RegExp to match cookie-value in RFC 6265 sec 4.1.1
|
||||
*
|
||||
* cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
|
||||
* cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
|
||||
* ; US-ASCII characters excluding CTLs,
|
||||
* ; whitespace DQUOTE, comma, semicolon,
|
||||
* ; and backslash
|
||||
*
|
||||
* Allowing more characters: https://github.com/jshttp/cookie/issues/191
|
||||
* Comma, backslash, and DQUOTE are not part of the parsing algorithm.
|
||||
*/
|
||||
const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
|
||||
/**
|
||||
* RegExp to match domain-value in RFC 6265 sec 4.1.1
|
||||
*
|
||||
* domain-value = <subdomain>
|
||||
* ; defined in [RFC1034], Section 3.5, as
|
||||
* ; enhanced by [RFC1123], Section 2.1
|
||||
* <subdomain> = <label> | <subdomain> "." <label>
|
||||
* <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
|
||||
* Labels must be 63 characters or less.
|
||||
* 'let-dig' not 'letter' in the first char, per RFC1123
|
||||
* <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
|
||||
* <let-dig-hyp> = <let-dig> | "-"
|
||||
* <let-dig> = <letter> | <digit>
|
||||
* <letter> = any one of the 52 alphabetic characters A through Z in
|
||||
* upper case and a through z in lower case
|
||||
* <digit> = any one of the ten digits 0 through 9
|
||||
*
|
||||
* Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
|
||||
*
|
||||
* > (Note that a leading %x2E ("."), if present, is ignored even though that
|
||||
* character is not permitted, but a trailing %x2E ("."), if present, will
|
||||
* cause the user agent to ignore the attribute.)
|
||||
*/
|
||||
const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
||||
/**
|
||||
* RegExp to match path-value in RFC 6265 sec 4.1.1
|
||||
*
|
||||
* path-value = <any CHAR except CTLs or ";">
|
||||
* CHAR = %x01-7F
|
||||
* ; defined in RFC 5234 appendix B.1
|
||||
*/
|
||||
const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
||||
const __toString = Object.prototype.toString;
|
||||
const NullObject = /* @__PURE__ */ (() => {
|
||||
const C = function () { };
|
||||
C.prototype = Object.create(null);
|
||||
return C;
|
||||
})();
|
||||
/**
|
||||
* Parse a cookie header.
|
||||
*
|
||||
* Parse the given cookie header string into an object
|
||||
* The object has the various cookies as keys(names) => values
|
||||
*/
|
||||
function parse(str, options) {
|
||||
const obj = new NullObject();
|
||||
const len = str.length;
|
||||
// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
|
||||
if (len < 2)
|
||||
return obj;
|
||||
const dec = options?.decode || decode;
|
||||
let index = 0;
|
||||
do {
|
||||
const eqIdx = str.indexOf("=", index);
|
||||
if (eqIdx === -1)
|
||||
break; // No more cookie pairs.
|
||||
const colonIdx = str.indexOf(";", index);
|
||||
const endIdx = colonIdx === -1 ? len : colonIdx;
|
||||
if (eqIdx > endIdx) {
|
||||
// backtrack on prior semicolon
|
||||
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
||||
continue;
|
||||
}
|
||||
const keyStartIdx = startIndex(str, index, eqIdx);
|
||||
const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
||||
const key = str.slice(keyStartIdx, keyEndIdx);
|
||||
// only assign once
|
||||
if (obj[key] === undefined) {
|
||||
let valStartIdx = startIndex(str, eqIdx + 1, endIdx);
|
||||
let valEndIdx = endIndex(str, endIdx, valStartIdx);
|
||||
const value = dec(str.slice(valStartIdx, valEndIdx));
|
||||
obj[key] = value;
|
||||
}
|
||||
index = endIdx + 1;
|
||||
} while (index < len);
|
||||
return obj;
|
||||
}
|
||||
function startIndex(str, index, max) {
|
||||
do {
|
||||
const code = str.charCodeAt(index);
|
||||
if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
|
||||
return index;
|
||||
} while (++index < max);
|
||||
return max;
|
||||
}
|
||||
function endIndex(str, index, min) {
|
||||
while (index > min) {
|
||||
const code = str.charCodeAt(--index);
|
||||
if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
|
||||
return index + 1;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
/**
|
||||
* Serialize data into a cookie header.
|
||||
*
|
||||
* Serialize a name value pair into a cookie string suitable for
|
||||
* http headers. An optional options object specifies cookie parameters.
|
||||
*
|
||||
* serialize('foo', 'bar', { httpOnly: true })
|
||||
* => "foo=bar; httpOnly"
|
||||
*/
|
||||
function serialize(name, val, options) {
|
||||
const enc = options?.encode || encodeURIComponent;
|
||||
if (!cookieNameRegExp.test(name)) {
|
||||
throw new TypeError(`argument name is invalid: ${name}`);
|
||||
}
|
||||
const value = enc(val);
|
||||
if (!cookieValueRegExp.test(value)) {
|
||||
throw new TypeError(`argument val is invalid: ${val}`);
|
||||
}
|
||||
let str = name + "=" + value;
|
||||
if (!options)
|
||||
return str;
|
||||
if (options.maxAge !== undefined) {
|
||||
if (!Number.isInteger(options.maxAge)) {
|
||||
throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);
|
||||
}
|
||||
str += "; Max-Age=" + options.maxAge;
|
||||
}
|
||||
if (options.domain) {
|
||||
if (!domainValueRegExp.test(options.domain)) {
|
||||
throw new TypeError(`option domain is invalid: ${options.domain}`);
|
||||
}
|
||||
str += "; Domain=" + options.domain;
|
||||
}
|
||||
if (options.path) {
|
||||
if (!pathValueRegExp.test(options.path)) {
|
||||
throw new TypeError(`option path is invalid: ${options.path}`);
|
||||
}
|
||||
str += "; Path=" + options.path;
|
||||
}
|
||||
if (options.expires) {
|
||||
if (!isDate(options.expires) ||
|
||||
!Number.isFinite(options.expires.valueOf())) {
|
||||
throw new TypeError(`option expires is invalid: ${options.expires}`);
|
||||
}
|
||||
str += "; Expires=" + options.expires.toUTCString();
|
||||
}
|
||||
if (options.httpOnly) {
|
||||
str += "; HttpOnly";
|
||||
}
|
||||
if (options.secure) {
|
||||
str += "; Secure";
|
||||
}
|
||||
if (options.partitioned) {
|
||||
str += "; Partitioned";
|
||||
}
|
||||
if (options.priority) {
|
||||
const priority = typeof options.priority === "string"
|
||||
? options.priority.toLowerCase()
|
||||
: undefined;
|
||||
switch (priority) {
|
||||
case "low":
|
||||
str += "; Priority=Low";
|
||||
break;
|
||||
case "medium":
|
||||
str += "; Priority=Medium";
|
||||
break;
|
||||
case "high":
|
||||
str += "; Priority=High";
|
||||
break;
|
||||
default:
|
||||
throw new TypeError(`option priority is invalid: ${options.priority}`);
|
||||
}
|
||||
}
|
||||
if (options.sameSite) {
|
||||
const sameSite = typeof options.sameSite === "string"
|
||||
? options.sameSite.toLowerCase()
|
||||
: options.sameSite;
|
||||
switch (sameSite) {
|
||||
case true:
|
||||
case "strict":
|
||||
str += "; SameSite=Strict";
|
||||
break;
|
||||
case "lax":
|
||||
str += "; SameSite=Lax";
|
||||
break;
|
||||
case "none":
|
||||
str += "; SameSite=None";
|
||||
break;
|
||||
default:
|
||||
throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* URL-decode string value. Optimized to skip native call when no %.
|
||||
*/
|
||||
function decode(str) {
|
||||
if (str.indexOf("%") === -1)
|
||||
return str;
|
||||
try {
|
||||
return decodeURIComponent(str);
|
||||
}
|
||||
catch (e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine if value is a Date.
|
||||
*/
|
||||
function isDate(val) {
|
||||
return __toString.call(val) === "[object Date]";
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "cookie",
|
||||
"version": "1.0.2",
|
||||
"description": "HTTP server cookie parsing and serialization",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"repository": "jshttp/cookie",
|
||||
"license": "MIT",
|
||||
"author": "Roman Shtylman <[email protected]>",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <[email protected]>"
|
||||
],
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"scripts": {
|
||||
"bench": "vitest bench",
|
||||
"build": "ts-scripts build",
|
||||
"format": "ts-scripts format",
|
||||
"prepare": "ts-scripts install",
|
||||
"prepublishOnly": "npm run build",
|
||||
"specs": "ts-scripts specs",
|
||||
"test": "ts-scripts test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@borderless/ts-scripts": "^0.15.0",
|
||||
"@vitest/coverage-v8": "^2.1.2",
|
||||
"top-sites": "1.1.194",
|
||||
"typescript": "^5.6.2",
|
||||
"vitest": "^2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"ts-scripts": {
|
||||
"project": "tsconfig.build.json"
|
||||
}
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
{
|
||||
"name": "react-router",
|
||||
"version": "7.6.0",
|
||||
"description": "Declarative routing for React",
|
||||
"keywords": [
|
||||
"react",
|
||||
"router",
|
||||
"route",
|
||||
"routing",
|
||||
"history",
|
||||
"link"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remix-run/react-router",
|
||||
"directory": "packages/react-router"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Remix Software <[email protected]>",
|
||||
"sideEffects": false,
|
||||
"types": "./dist/development/index.d.ts",
|
||||
"main": "./dist/development/index.js",
|
||||
"module": "./dist/development/index.mjs",
|
||||
"exports": {
|
||||
".": {
|
||||
"node": {
|
||||
"types": "./dist/development/index.d.ts",
|
||||
"module-sync": "./dist/development/index.mjs",
|
||||
"default": "./dist/development/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/development/index.d.mts",
|
||||
"default": "./dist/development/index.mjs"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/development/index.d.ts",
|
||||
"default": "./dist/development/index.js"
|
||||
}
|
||||
},
|
||||
"./route-module": {
|
||||
"node": {
|
||||
"types": "./dist/development/lib/types/route-module.d.ts"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/development/lib/types/route-module.d.mts"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/development/lib/types/route-module.d.ts"
|
||||
}
|
||||
},
|
||||
"./dom": {
|
||||
"node": {
|
||||
"types": "./dist/development/dom-export.d.ts",
|
||||
"module-sync": "./dist/development/dom-export.mjs",
|
||||
"default": "./dist/development/dom-export.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/development/dom-export.d.mts",
|
||||
"default": "./dist/development/dom-export.mjs"
|
||||
},
|
||||
"default": {
|
||||
"types": "./dist/development/dom-export.d.ts",
|
||||
"default": "./dist/development/dom-export.js"
|
||||
}
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"wireit": {
|
||||
"build": {
|
||||
"command": "rimraf dist && tsup",
|
||||
"files": [
|
||||
"lib/**",
|
||||
"*.ts",
|
||||
"tsconfig.json",
|
||||
"package.json"
|
||||
],
|
||||
"output": [
|
||||
"dist/**"
|
||||
]
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
"set-cookie-parser": "^2.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/set-cookie-parser": "^2.4.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"rimraf": "^6.0.1",
|
||||
"tsup": "^8.3.0",
|
||||
"typescript": "^5.1.6",
|
||||
"wireit": "0.14.9"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE.md",
|
||||
"README.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "wireit",
|
||||
"typecheck": "tsc"
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Nathan Friedly <[email protected]> (http://nfriedly.com/)
|
||||
|
||||
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.
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
# set-cookie-parser
|
||||
|
||||
[](https://github.com/nfriedly/set-cookie-parser/actions/workflows/node.js.yml)
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[][npm-url]
|
||||
|
||||
---
|
||||
|
||||
ℹ️ **Note for current users:** I'm considering some changes for the next major version and would appreciate your feedback: https://github.com/nfriedly/set-cookie-parser/discussions/68
|
||||
|
||||
---
|
||||
|
||||
Parses set-cookie headers into JavaScript objects
|
||||
|
||||
Accepts a single `set-cookie` header value, an array of `set-cookie` header values, a Node.js response object, or a `fetch()` `Response` object that may have 0 or more `set-cookie` headers.
|
||||
|
||||
Also accepts an optional options object. Defaults:
|
||||
|
||||
```js
|
||||
{
|
||||
decodeValues: true, // Calls decodeURIComponent on each value - default: true
|
||||
map: false, // Return an object instead of an array - default: false
|
||||
silent: false, // Suppress the warning that is logged when called on a request instead of a response - default: false
|
||||
}
|
||||
```
|
||||
|
||||
Returns either an array of cookie objects or a map of name => cookie object with `{map: true}`. Each cookie object will have, at a minimum `name` and `value` properties, and may have additional properties depending on the set-cookie header:
|
||||
|
||||
* `name` - cookie name (string)
|
||||
* `value` - cookie value (string)
|
||||
* `path` - URL path to limit the scope to (string or undefined)
|
||||
* `domain` - domain to expand the scope to (string or undefined, may begin with "." to indicate the named domain or any subdomain of it)
|
||||
* `expires` - absolute expiration date for the cookie (Date object or undefined)
|
||||
* `maxAge` - relative expiration time of the cookie in seconds from when the client receives it (integer or undefined)
|
||||
* Note: when using with [express's res.cookie() method](http://expressjs.com/en/4x/api.html#res.cookie), multiply `maxAge` by 1000 to convert to milliseconds.
|
||||
* `secure` - indicates cookie should only be sent over HTTPs (true or undefined)
|
||||
* `httpOnly` - indicates cookie should *not* be accessible to client-side JavaScript (true or undefined)
|
||||
* `sameSite` - indicates if cookie should be included in cross-site requests ([more info](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value)) (string or undefined)
|
||||
* Note: valid values are `"Strict"`, `"Lax"`, and `"None"`, but set-cookie-parser coppies the value verbatim and does *not* perform any validation.
|
||||
* `partitioned` - indicates cookie should be scoped to the combination of 3rd party domain + top page domain ([more info](https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies)) (true or undefined)
|
||||
|
||||
(The output format is loosely based on the input format of https://www.npmjs.com/package/cookie)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save set-cookie-parser
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### Get array of cookie objects
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var setCookie = require('set-cookie-parser');
|
||||
|
||||
http.get('http://example.com', function(res) {
|
||||
var cookies = setCookie.parse(res, {
|
||||
decodeValues: true // default: true
|
||||
});
|
||||
|
||||
cookies.forEach(console.log);
|
||||
}
|
||||
```
|
||||
|
||||
Example output:
|
||||
|
||||
```js
|
||||
[
|
||||
{
|
||||
name: 'bam',
|
||||
value: 'baz'
|
||||
},
|
||||
{
|
||||
name: 'foo',
|
||||
value: 'bar',
|
||||
path: '/',
|
||||
expires: new Date('Tue Jul 01 2025 06:01:11 GMT-0400 (EDT)'),
|
||||
maxAge: 1000,
|
||||
domain: '.example.com',
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
sameSite: 'lax'
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Get map of cookie objects
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var setCookie = require('set-cookie-parser');
|
||||
|
||||
http.get('http://example.com', function(res) {
|
||||
var cookies = setCookie.parse(res, {
|
||||
decodeValues: true, // default: true
|
||||
map: true // default: false
|
||||
});
|
||||
|
||||
var desiredCookie = cookies['session'];
|
||||
console.log(desiredCookie);
|
||||
});
|
||||
```
|
||||
Example output:
|
||||
```js
|
||||
{
|
||||
bam: {
|
||||
name: 'bam',
|
||||
value: 'baz'
|
||||
},
|
||||
foo: {
|
||||
name: 'foo',
|
||||
value: 'bar',
|
||||
path: '/',
|
||||
expires: new Date('Tue Jul 01 2025 06:01:11 GMT-0400 (EDT)'),
|
||||
maxAge: 1000,
|
||||
domain: '.example.com',
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
sameSite: 'lax'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Creating a new, modified set-cookie header
|
||||
|
||||
This library can be used in conjunction with the [cookie](https://www.npmjs.com/package/cookie) library to modify and replace set-cookie headers:
|
||||
|
||||
```js
|
||||
const libCookie = require('cookie');
|
||||
const setCookie = require('set-cookie-parser');
|
||||
|
||||
function modifySetCookie(res){
|
||||
// parse the set-cookie headers with this library
|
||||
let cookies = setCookie.parse(res);
|
||||
|
||||
// modify the cookies here
|
||||
// ...
|
||||
|
||||
// create new set-cookie headers using the cookie library
|
||||
res.headers['set-cookie'] = cookies.map(function(cookie) {
|
||||
return libCookie.serialize(cookie.name, cookie.value, cookie);
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
See a real-world example of this in [unblocker](https://github.com/nfriedly/node-unblocker/blob/08a89ec27274b46dcd80d0a324a59406f2bdad3d/lib/cookies.js#L67-L85)
|
||||
|
||||
## Usage in React Native (and with some other fetch implementations)
|
||||
|
||||
React Native follows the Fetch spec more closely and combines all of the Set-Cookie header values into a single string.
|
||||
The `splitCookiesString` method reverses this.
|
||||
|
||||
```js
|
||||
var setCookie = require('set-cookie-parser');
|
||||
|
||||
var response = fetch(/*...*/);
|
||||
|
||||
// This is mainly for React Native; Node.js does not combine set-cookie headers.
|
||||
var combinedCookieHeader = response.headers.get('Set-Cookie');
|
||||
var splitCookieHeaders = setCookie.splitCookiesString(combinedCookieHeader)
|
||||
var cookies = setCookie.parse(splitCookieHeaders);
|
||||
|
||||
console.log(cookies); // should be an array of cookies
|
||||
```
|
||||
|
||||
This behavior may become a default part of parse in the next major release, but requires the extra step for now.
|
||||
|
||||
Note that the `fetch()` spec now includes a `getSetCookie()` method that provides un-combined `Set-Cookie` headers. This library will automatically use that method if it is present.
|
||||
|
||||
## API
|
||||
|
||||
### parse(input, [options])
|
||||
|
||||
Parses cookies from a string, array of strings, or a http response object.
|
||||
Always returns an array, regardless of input format. (Unless the `map` option is set, in which case it always returns an object.)
|
||||
|
||||
### parseString(individualSetCookieHeader, [options])
|
||||
|
||||
Parses a single set-cookie header value string. Options default is `{decodeValues: true}`. Used under-the-hood by `parse()`.
|
||||
Returns an object.
|
||||
|
||||
### splitCookiesString(combinedSetCookieHeader)
|
||||
|
||||
It's uncommon, but the HTTP spec does allow for multiple of the same header to have their values combined (comma-separated) into a single header.
|
||||
This method splits apart a combined header without choking on commas that appear within a cookie's value (or expiration date).
|
||||
Returns an array of strings that may be passed to `parse()`.
|
||||
|
||||
## References
|
||||
|
||||
* [RFC 6265: HTTP State Management Mechanism](https://tools.ietf.org/html/rfc6265)
|
||||
* [draft-ietf-httpbis-rfc6265bis-10](https://httpwg.org/http-extensions/draft-ietf-httpbis-rfc6265bis.html)
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Nathan Friedly](http://www.nfriedly.com/)
|
||||
|
||||
|
||||
[npm-image]: https://badge.fury.io/js/set-cookie-parser.svg
|
||||
[npm-url]: https://npmjs.org/package/set-cookie-parser
|
||||
+224
@@ -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;
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "set-cookie-parser",
|
||||
"version": "2.7.1",
|
||||
"description": "Parses set-cookie headers into objects",
|
||||
"homepage": "https://github.com/nfriedly/set-cookie-parser",
|
||||
"repository": "nfriedly/set-cookie-parser",
|
||||
"author": {
|
||||
"name": "Nathan Friedly",
|
||||
"url": "http://nfriedly.com/"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"main": "./lib/set-cookie.js",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"set-cookie",
|
||||
"set",
|
||||
"cookie",
|
||||
"cookies",
|
||||
"header",
|
||||
"parse",
|
||||
"parser"
|
||||
],
|
||||
"devDependencies": {
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"husky": "^9.0.11",
|
||||
"mocha": "^10.3.0",
|
||||
"prettier": "^3.2.5",
|
||||
"pretty-quick": "^4.0.0",
|
||||
"sinon": "^17.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint . --ignore-pattern '!.eslintrc.js'",
|
||||
"test": "npm run lint && mocha",
|
||||
"autofix": "npm run lint -- --fix",
|
||||
"precommit": "npm test"
|
||||
},
|
||||
"license": "MIT",
|
||||
"prettier": {
|
||||
"trailingComma": "es5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
const config = {
|
||||
apiBaseUrl: "https://gameauthapi.ranaze.com"
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,66 @@
|
||||
import React, { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import config from "../config";
|
||||
|
||||
const Login = () => {
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleLogin = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const response = await fetch(`${config.API_BASE_URL}/api/Auth/login`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
// Save token etc.
|
||||
console.log("Login successful:", data);
|
||||
// Redirect or update state
|
||||
} else {
|
||||
alert("Login failed.");
|
||||
}
|
||||
};
|
||||
|
||||
const goToRegister = () => {
|
||||
navigate("/register");
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Login</h2>
|
||||
<form onSubmit={handleLogin}>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<br />
|
||||
<input
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
required
|
||||
/>
|
||||
<br />
|
||||
<button type="submit">Login</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={goToRegister}
|
||||
style={{ marginLeft: "10px" }}
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Login;
|
||||
@@ -0,0 +1,85 @@
|
||||
import React, { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import config from "../config";
|
||||
|
||||
const Register = () => {
|
||||
const navigate = useNavigate();
|
||||
const [form, setForm] = useState({
|
||||
username: "",
|
||||
email: "",
|
||||
password: "",
|
||||
});
|
||||
const [error, setError] = useState("");
|
||||
|
||||
const handleChange = (e) => {
|
||||
setForm({ ...form, [e.target.name]: e.target.value });
|
||||
};
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const payload = {
|
||||
username: form.username,
|
||||
password: form.password,
|
||||
email: form.email,
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await fetch(`${config.apiBaseUrl}/api/Auth/register`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: form.username,
|
||||
email: form.email,
|
||||
password: form.password,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const data = await res.json();
|
||||
throw new Error(data.message || "Registration failed");
|
||||
}
|
||||
|
||||
alert("Success!");
|
||||
navigate("/login");
|
||||
} catch (err) {
|
||||
console.error("Register error:", err);
|
||||
alert("Network or server error occurred.");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Register</h2>
|
||||
{error && <p style={{ color: "red" }}>{error}</p>}
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
name="username"
|
||||
placeholder="Username"
|
||||
value={form.username}
|
||||
onChange={handleChange}
|
||||
required
|
||||
/>
|
||||
<input
|
||||
name="email"
|
||||
placeholder="Email"
|
||||
value={form.email}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<input
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
value={form.password}
|
||||
onChange={handleChange}
|
||||
required
|
||||
/>
|
||||
<button type="submit">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Register;
|
||||
Reference in New Issue
Block a user