Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
7ba11aa3
Commit
7ba11aa3
authored
Apr 09, 2026
by
Janka Uryga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip stuff idk
parent
a1642c54
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
0 deletions
+111
-0
instant-samples.ts
...c/server/app-render/instant-validation/instant-samples.ts
+13
-0
metadata-image-params.ts
...er/app-render/instant-validation/metadata-image-params.ts
+98
-0
No files found.
packages/next/src/server/app-render/instant-validation/instant-samples.ts
View file @
7ba11aa3
...
...
@@ -264,6 +264,9 @@ export function createExhaustiveParamsProxy<TParams extends Params>(
}
return
new
Proxy
(
underlyingParams
,
{
get
(
target
,
prop
,
receiver
)
{
if
(
prop
===
EXHAUSTIVE_PROXY_MARKER
)
{
return
true
}
if
(
typeof
prop
===
'string'
&&
!
wellKnownProperties
.
has
(
prop
)
&&
...
...
@@ -287,6 +290,16 @@ export function createExhaustiveParamsProxy<TParams extends Params>(
})
}
const
EXHAUSTIVE_PROXY_MARKER
:
unique
symbol
=
Symbol
.
for
(
'next.instant-validation.params-proxy'
)
export
function
isExhaustiveParamsProxy
(
params
:
Params
):
boolean
{
return
(
(
params
as
Record
<
string
|
symbol
,
any
>
)[
EXHAUSTIVE_PROXY_MARKER
]
===
true
)
}
function
isEmptyParams
(
params
:
Params
)
{
for
(
const
_param
in
params
)
{
return
false
...
...
packages/next/src/server/app-render/instant-validation/metadata-image-params.ts
0 → 100644
View file @
7ba11aa3
import
type
{
Params
}
from
'../../request/params'
import
{
workUnitAsyncStorage
}
from
'../work-unit-async-storage.external'
const
PARAM_PLACEHOLDER
=
'-'
export
function
adaptParamsForImageMetadata
(
params
:
Params
)
{
const
workUnitStore
=
workUnitAsyncStorage
.
getStore
()
if
(
workUnitStore
)
{
switch
(
workUnitStore
.
type
)
{
case
'request'
:
{
if
(
workUnitStore
.
validationSamples
)
{
const
{
isExhaustiveParamsProxy
}
=
require
(
'./instant-samples'
)
as
typeof
import
(
'./instant-samples'
)
if
(
isExhaustiveParamsProxy
(
params
))
{
return
createPlaceholderParamsForInstantValidation
(
params
,
PARAM_PLACEHOLDER
)
}
}
// fallthrough
}
case
'cache'
:
case
'private-cache'
:
case
'unstable-cache'
:
case
'prerender-legacy'
:
case
'prerender-ppr'
:
case
'prerender-client'
:
case
'prerender'
:
case
'prerender-runtime'
:
case
'validation-client'
:
case
'generate-static-params'
:
{
break
}
default
:
{
workUnitStore
satisfies
never
}
}
}
// If the params object is not a proxy
return
params
}
function
createPlaceholderParamsForInstantValidation
(
params
:
Params
,
placeholderValue
:
string
):
Params
{
const
placeholderParams
:
Params
=
{}
for
(
const
key
in
params
)
{
placeholderParams
[
key
]
=
placeholderValue
}
return
placeholderParams
}
// const METADATA_ID = '__metadata_id__'
// export function excludeMetadataIdFromServerParams<TParams extends Params>(
// params: TParams
// ): Omit<TParams, '__metadata_id__'> {
// const workUnitStore = workUnitAsyncStorage.getStore()
// if (workUnitStore) {
// switch (workUnitStore.type) {
// case 'request': {
// // In build-time instant validation, params can be wrapped in a proxy
// // that doesn't allow us to destructure the params to extract __metadata_id__.
// // (If all params are provided, we don't use a proxy, so we can skip creating one here as well)
// if (workUnitStore.validationSamples) {
// const { isExhaustiveParamsProxy } =
// require('./instant-samples') as typeof import('./instant-samples')
// if (isExhaustiveParamsProxy(params)) {
// return {} as any
// }
// }
// // fallthrough
// }
// case 'cache':
// case 'private-cache':
// case 'unstable-cache':
// case 'prerender-legacy':
// case 'prerender-ppr':
// case 'prerender-client':
// case 'prerender':
// case 'prerender-runtime':
// case 'validation-client':
// case 'generate-static-params': {
// break
// }
// default: {
// workUnitStore satisfies never
// }
// }
// }
// // If the params object is not a proxy
// const { [METADATA_ID]: _, ...cleanedParams } = params
// return cleanedParams
// }
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment