@wular/pnext 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wular/pnext",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "A fast little framework for server-first React apps, fully compatible with Next.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -7,6 +7,7 @@ import { existsSync, readFileSync } from 'node:fs'
7
7
  import path from 'node:path'
8
8
  import { pathToFileURL } from 'node:url'
9
9
  import type { Plugin as EsbuildPlugin } from 'esbuild'
10
+ import { frameworkFingerprint } from '../../runtime/fingerprint'
10
11
 
11
12
  const frameworkRoot = path.resolve(import.meta.dirname, '..', '..', '..')
12
13
 
@@ -20,8 +21,17 @@ function frameworkVersion(): string {
20
21
  }
21
22
  }
22
23
 
23
- function serverEntryDir(outPath: string): string {
24
- return path.join(outPath, 'server', `bundle-${frameworkVersion()}`)
24
+ /**
25
+ * Version AND framework fingerprint: the version alone let an edited `src` keep serving the bundle
26
+ * built from the previous source, so a fix appeared to have no effect until the app was rebuilt.
27
+ * The fingerprint is the same one every other compiled artifact is keyed on, taken through the
28
+ * cache-root record so a restart pays one stat per file rather than re-reading the tree.
29
+ */
30
+ export function serverEntryDir(outPath: string): string {
31
+ // Cache root spelled inline, not imported: this module is parsed before anything else on the
32
+ // start path, and pulling in the module cache for one path.join would drag its whole graph along.
33
+ const generation = frameworkFingerprint(path.join(outPath, 'cache', 'server'))
34
+ return path.join(outPath, 'server', `bundle-${frameworkVersion()}-${generation}`)
25
35
  }
26
36
 
27
37
  function serverEntryFile(outPath: string): string {
@@ -30,7 +40,7 @@ function serverEntryFile(outPath: string): string {
30
40
 
31
41
  /**
32
42
  * The prebuilt entry for a project root, or undefined when there is none to
33
- * use (no build, a custom `outDir`, a version mismatch, or the opt-out). The
43
+ * use (no build, a custom `outDir`, a version or source-generation mismatch, or the opt-out). The
34
44
  * caller then falls back to importing src/cli/start.ts directly, so a miss only
35
45
  * costs speed. Deliberately cheap: one existsSync and one package.json read,
36
46
  * because it runs before anything else on the start path.
@@ -43,7 +53,7 @@ export function prebuiltServerEntry(root = process.cwd()): string | undefined {
43
53
  }
44
54
 
45
55
  /**
46
- * Bundle src/cli/start.ts under `<outPath>/server/bundle-<version>/`. Bare
56
+ * Bundle src/cli/start.ts under `<outPath>/server/bundle-<version>-<fingerprint>/`. Bare
47
57
  * specifiers stay external (the framework's deps are already plain JS), so only
48
58
  * the framework's own source is inlined. Splitting is on so the graph behind a
49
59
  * dynamic import (compat, dev, build) stays in its own chunk — folding it into
@@ -15,6 +15,7 @@ import type { ResolvedConfig } from '../../config'
15
15
  import { bootstrapCompat } from '../../compat-bootstrap'
16
16
  import { registerServerRuntime, serverBundleTargetForRuntime } from '../../runtime/loader'
17
17
  import { importModuleOnce } from '../../runtime/modules'
18
+ import { abortUpstreamFetchOnDisconnect } from '../../runtime/fetch-host'
18
19
  import { applyProxyResponse, createProxyRunner } from '../../routing/proxy'
19
20
  import {
20
21
  isPprShellUpgradeEligible,
@@ -287,6 +288,9 @@ export async function createRequestHandler(
287
288
  },
288
289
  )
289
290
  const response = maybeCloseNodeFetchConnection(finalized, request)
291
+ // Wired before the close-observer wraps the body: the stream a handler
292
+ // passed through from fetch is still the one the abort map knows.
293
+ abortUpstreamFetchOnDisconnect(response.body, request.signal)
290
294
  return flushWorkUnitOnClose(response, unit, request.signal)
291
295
  } catch (error) {
292
296
  // A dropped promise here would close the socket without a response
package/src/cli/start.ts CHANGED
@@ -130,6 +130,15 @@ async function guardUnservableOutputMode(root?: string): Promise<ResolvedConfig>
130
130
  )
131
131
  process.exit(1)
132
132
  }
133
+ // Next warns on `next start` with standalone output; its standalone launcher re-execs this path
134
+ // with __NEXT_PRIVATE_STANDALONE_CONFIG set to suppress the warning. Mirror both.
135
+ // eslint-disable-next-line turbo/no-undeclared-env-vars
136
+ if (mode === 'standalone' && !process.env.__NEXT_PRIVATE_STANDALONE_CONFIG) {
137
+ console.warn(
138
+ '"next start" does not work with "output: standalone" configuration. ' +
139
+ 'Use "node .next/standalone/server.js" instead.',
140
+ )
141
+ }
133
142
  return config
134
143
  }
135
144
 
@@ -57,7 +57,10 @@ function routeEntry(route: RouteManifestEntry) {
57
57
  }
58
58
 
59
59
  async function writeChecks(config: ResolvedConfig, routes: RouteManifestEntry[]) {
60
- const checksDir = path.join(config.typesPath, 'checks')
60
+ const checksDir = config.checksPath
61
+ // Checks used to live under typesPath, which the app's own tsconfig includes; a stale
62
+ // copy there fails the app's compiler on pnext internals, so heal that on every generate.
63
+ await rm(path.join(config.typesPath, 'checks'), { recursive: true, force: true })
61
64
  await rm(checksDir, { recursive: true, force: true })
62
65
  await ensureDir(checksDir)
63
66
 
@@ -4810,9 +4810,11 @@ export async function softNavigate(href: string, options: SoftNavigateOptions =
4810
4810
  // Same-entry-identity navigation (a search-param nav on the same pathname, a refresh):
4811
4811
  // `key={bfcacheId}` subtrees do NOT remount, so typed values must survive. The commit can
4812
4812
  // still rebuild the page DOM under them (a PPR route streams its page slot in AFTER the
4813
- // swap), so re-apply the departure snapshot as the controls appear.
4813
+ // swap), so re-apply the departure snapshot as the controls appear - but only to the DOM
4814
+ // this swap replaced, never to a control a live island's own render owns (see
4815
+ // islandOwnedControl).
4814
4816
  else if (departingBfcacheId && departingBfcacheId === historyBfcacheId()) {
4815
- restoreFormStateWhenMounted(departingBfcacheId, sequence)
4817
+ restoreFormStateWhenMounted(departingBfcacheId, sequence, true)
4816
4818
  }
4817
4819
 
4818
4820
  // A navigation that only changed parallel slots (same children path AND unchanged search
@@ -4907,13 +4909,25 @@ function restoreControl(
4907
4909
  if (control.value !== saved.value) control.value = saved.value
4908
4910
  }
4909
4911
 
4910
- function restoreFormState(bfcacheId: string | undefined, onlyEmpty = false) {
4912
+ /**
4913
+ * A control inside a mounted island is owned by that island's preact diff, which reproduces
4914
+ * React's reconciliation - including an app key (`key={searchParams.get('q')}`) that
4915
+ * deliberately remounts the subtree with an EMPTY control. Re-applying the departure snapshot
4916
+ * there fights the app; only DOM the raw swap replaced is pnext's own loss to compensate.
4917
+ */
4918
+ function islandOwnedControl(control: Element): boolean {
4919
+ const root: LiveIslandRoot | null = control.closest('pnext-client[data-pnext-client]')
4920
+ return Boolean(root?.__pnextLive)
4921
+ }
4922
+
4923
+ function restoreFormState(bfcacheId: string | undefined, onlyEmpty = false, skipIslands = false) {
4911
4924
  if (!bfcacheId) return
4912
4925
  const state = entryFormStateCache.get(bfcacheId)
4913
4926
  if (!state) return
4914
4927
  const controls = formControls()
4915
4928
  if (controls.length !== state.length) return
4916
4929
  for (const [index, control] of controls.entries()) {
4930
+ if (skipIslands && islandOwnedControl(control)) continue
4917
4931
  // `onlyEmpty`: a freshly mounted control is empty, so filling it restores
4918
4932
  // what the remount lost — while anything already carrying a value (the app
4919
4933
  // set it, or the user typed after the commit) is left alone.
@@ -4951,10 +4965,10 @@ function restoreSharedLayoutFormState(
4951
4965
  * describes can appear after the swap. Keep trying while the DOM changes until the control
4952
4966
  * set matches the snapshot.
4953
4967
  */
4954
- function restoreFormStateWhenMounted(bfcacheId: string, sequence: number): void {
4968
+ function restoreFormStateWhenMounted(bfcacheId: string, sequence: number, skipIslands = false) {
4955
4969
  const state = entryFormStateCache.get(bfcacheId)
4956
4970
  if (!state) return
4957
- restoreFormState(bfcacheId, true)
4971
+ restoreFormState(bfcacheId, true, skipIslands)
4958
4972
  // The controls can be rebuilt more than once while the commit settles, so the restore stays
4959
4973
  // armed for a short window instead of firing once. It only ever fills EMPTY controls, so a
4960
4974
  // value the app or the user set after the commit is never clobbered.
@@ -4963,7 +4977,7 @@ function restoreFormStateWhenMounted(bfcacheId: string, sequence: number): void
4963
4977
  observer.disconnect()
4964
4978
  return
4965
4979
  }
4966
- restoreFormState(bfcacheId, true)
4980
+ restoreFormState(bfcacheId, true, skipIslands)
4967
4981
  })
4968
4982
  observer.observe(document.body, { childList: true, subtree: true })
4969
4983
  window.setTimeout(() => observer.disconnect(), FORM_STATE_RESTORE_WINDOW_MS)
@@ -1,6 +1,7 @@
1
1
  import type { Metadata, MetadataOpenGraph, PageProps, RouteManifestEntry, Viewport } from '../types'
2
2
  import { staticMetadataForPathFromFiles, type StaticMetadataFile } from '../routing/metadata-files'
3
3
  import { coerceString } from '../render/metadata'
4
+ import { legacyRequestAPIs } from '../request/context'
4
5
  import { readSourceText } from '../resolve/source-text'
5
6
  import { SPAN_TYPE, withChildSpan } from './otel/tracer'
6
7
  import { settledPromise } from '../render/renderer'
@@ -146,7 +147,9 @@ function resolvedParentMetadata(parent: Metadata): Metadata {
146
147
  }
147
148
  }
148
149
 
149
- function resolvedParentOpenGraph(openGraph: MetadataOpenGraph | undefined): MetadataOpenGraph {
150
+ function resolvedParentOpenGraph(
151
+ openGraph: MetadataOpenGraph | null | undefined,
152
+ ): MetadataOpenGraph {
150
153
  if (!openGraph) return {}
151
154
  return {
152
155
  ...openGraph,
@@ -165,7 +168,7 @@ function resolvedParentOpenGraph(openGraph: MetadataOpenGraph | undefined): Meta
165
168
  }
166
169
 
167
170
  function normalizeKeywordList(value: Metadata['keywords']): (string | number)[] | undefined {
168
- if (value === undefined) return undefined
171
+ if (value === undefined || value === null) return undefined
169
172
  return Array.isArray(value) ? value : [value]
170
173
  }
171
174
 
@@ -192,6 +195,14 @@ export async function warnNextMetadataBuildIssues(
192
195
  if (route.kind !== 'page') continue
193
196
  const routeFacts = await Promise.all(routeSourceFiles(appPath, route).map(factsFor))
194
197
  const some = (pick: (fact: MetadataSourceFacts) => boolean) => routeFacts.some(pick)
198
+ // themeColor-in-metadata deprecation is Next 15+; legacy (Next-14 era) apps never saw it.
199
+ if (!legacyRequestAPIs() && some(fact => fact.themeColor)) {
200
+ warnOnce(
201
+ warned,
202
+ `themeColor:${route.route}`,
203
+ `Unsupported metadata themeColor is configured in metadata export in ${route.route || '/'}. Please move it to viewport\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-viewport`,
204
+ )
205
+ }
195
206
  if (some(fact => fact.appleTouchFullscreen)) {
196
207
  warnOnce(
197
208
  warned,
@@ -239,6 +250,7 @@ async function readSourceTextOrEmpty(file: string) {
239
250
  * nearly every file has none of these keys.
240
251
  */
241
252
  interface MetadataSourceFacts {
253
+ themeColor: boolean
242
254
  appleTouchFullscreen: boolean
243
255
  appleTouchIconPrecomposed: boolean
244
256
  metadataBase: boolean
@@ -247,6 +259,7 @@ interface MetadataSourceFacts {
247
259
 
248
260
  function metadataSourceFacts(source: string): MetadataSourceFacts {
249
261
  return {
262
+ themeColor: themeColorInMetadataExport(source),
250
263
  appleTouchFullscreen:
251
264
  source.includes('apple-touch-fullscreen') && /['"]apple-touch-fullscreen['"]/.test(source),
252
265
  appleTouchIconPrecomposed:
@@ -257,6 +270,35 @@ function metadataSourceFacts(source: string): MetadataSourceFacts {
257
270
  }
258
271
  }
259
272
 
273
+ // A themeColor inside a viewport export is where the notice says to put it, so
274
+ // only occurrences outside viewport/generateViewport blocks count.
275
+ function themeColorInMetadataExport(source: string): boolean {
276
+ if (!source.includes('themeColor') || !/\bthemeColor\s*:/.test(source)) return false
277
+ return /\bthemeColor\s*:/.test(stripViewportExports(source))
278
+ }
279
+
280
+ function stripViewportExports(source: string): string {
281
+ const starts =
282
+ /export\s+(?:const|let|var)\s+viewport\b|export\s+(?:async\s+)?function\s+generateViewport\b/g
283
+ let out = ''
284
+ let last = 0
285
+ for (let match = starts.exec(source); match; match = starts.exec(source)) {
286
+ const open = source.indexOf('{', match.index)
287
+ if (open === -1) break
288
+ let depth = 0
289
+ let end = open
290
+ for (; end < source.length; end++) {
291
+ const char = source[end]
292
+ if (char === '{') depth++
293
+ else if (char === '}' && --depth === 0) break
294
+ }
295
+ out += source.slice(last, match.index)
296
+ last = end + 1
297
+ starts.lastIndex = last
298
+ }
299
+ return out + source.slice(last)
300
+ }
301
+
260
302
  function routeUsesRelativeSocialImage(
261
303
  route: RouteManifestEntry,
262
304
  facts: MetadataSourceFacts[],
@@ -112,10 +112,16 @@ function findConfigPath(root: string): string | undefined {
112
112
  return undefined
113
113
  }
114
114
 
115
+ // `Bun` through globalThis: pnext ships TypeScript source, so app compilers without
116
+ // bun-types typecheck this file and a bare `Bun` identifier would fail them.
117
+ const { Bun: bun } = globalThis as unknown as {
118
+ Bun: { hash(input: string | ArrayBufferView): { toString(radix?: number): string } }
119
+ }
120
+
115
121
  /** Stable per config content, so the emitted bundle keeps one name per boot. */
116
122
  function configSourceKey(configPath: string): string {
117
123
  try {
118
- return Bun.hash(readFileSync(configPath)).toString(36)
124
+ return bun.hash(readFileSync(configPath)).toString(36)
119
125
  } catch {
120
126
  return 'config'
121
127
  }
@@ -9,8 +9,10 @@ import {
9
9
  registerBuildSteps,
10
10
  type BuildStepContext,
11
11
  } from '../../extensions'
12
+ import { legacyRequestAPIs } from '../../request/context'
12
13
  import type { RouteManifestEntry } from '../../types'
13
14
  import { nextCompatEnabled } from '../aliases'
15
+ import { writeTsconfigDefaults } from '../tsconfig-defaults'
14
16
  import { typecheckDisabled, validateTypesOffThread } from '../typecheck/check'
15
17
  import { generateTypedRoutes } from '../typed-routes/generate'
16
18
 
@@ -20,6 +22,8 @@ export function registerTypedRoutesExtensions(_config: ResolvedConfig): void {
20
22
 
21
23
  async function runTypedRoutesBuildStep(ctx: BuildStepContext): Promise<void> {
22
24
  if (!nextCompatEnabled(ctx.config)) return
25
+ // Legacy (Next-14 era) apps keep their tsconfig untouched; current apps get Next's defaults.
26
+ if (!legacyRequestAPIs()) await writeTsconfigDefaults(ctx.config)
23
27
  await generateTypedRoutes(ctx.config, ctx.routes as RouteManifestEntry[])
24
28
  // The typecheck reads only files that already exist on disk, so it runs on a worker thread
25
29
  // alongside client bundling and prerendering rather than ahead of them; the CLI awaits it before
@@ -372,6 +372,10 @@ async function writeTypecheckProject(
372
372
  },
373
373
  include: [
374
374
  path.join(dir, 'next-shims.d.ts'),
375
+ // Generated per-route assignability checks (typegen writes them next to this
376
+ // project, not under the app-included `types/` dir, so only pnext's own compiler
377
+ // reads them). Included by hand to keep that coverage.
378
+ path.join(dir, 'checks', '**/*.ts'),
375
379
  ...(nodeTypes ? [path.join(nodeTypes, 'index.d.ts')] : []),
376
380
  path.join(config.root, 'next-env.d.ts'),
377
381
  // The build emits `.next/types/validator.ts` (page/layout/route-handler export validation) just
@@ -661,7 +665,7 @@ declare module 'react/jsx-runtime' {
661
665
  `
662
666
  const requestType = (type: string) =>
663
667
  legacyRequestTypes ? `Promise<${type}> & ${type}` : `Promise<${type}>`
664
- const requestShims = `declare module 'next/headers'{interface CookieSetOptions{name?:string;value?:string;path?:string;maxAge?:number;expires?:Date|number;httpOnly?:boolean;secure?:boolean;sameSite?:'strict'|'lax'|'none'|boolean;domain?:string}interface CookieStore{get(name:string):{name:string;value:string}|undefined;get(options:{name:string;value?:string}):{name:string;value:string}|undefined;getAll(name?:string):{name:string;value:string}[];getAll(options:{name:string;value?:string}):{name:string;value:string}[];has(name:string):boolean;readonly size:number;set(name:string,value:string,options?:CookieSetOptions):CookieStore;set(options:CookieSetOptions):CookieStore;delete(name:string):boolean;clear():CookieStore;[Symbol.iterator]():IterableIterator<readonly[string,{name?:string;value:string}]>}export function cookies():${requestType('CookieStore')};export function headers():${requestType('Headers')};export function draftMode():${requestType(`{isEnabled:boolean;enable():void;disable():void}`)}}
668
+ const requestShims = `declare module 'next/headers'{interface CookieSetOptions{name?:string;value?:string;path?:string;maxAge?:number;expires?:Date|number;httpOnly?:boolean;secure?:boolean;sameSite?:'strict'|'lax'|'none'|boolean;domain?:string}interface CookieStore{get(name:string):{name:string;value:string}|undefined;get(options:{name:string;value?:string}):{name:string;value:string}|undefined;getAll(name?:string):{name:string;value:string}[];getAll(options:{name:string;value?:string}):{name:string;value:string}[];has(name:string):boolean;readonly size:number;set(options:CookieSetOptions):CookieStore;set(name:string,value:string,options?:CookieSetOptions):CookieStore;delete(name:string):boolean;clear():CookieStore;[Symbol.iterator]():IterableIterator<readonly[string,{name?:string;value:string}]>}export function cookies():${requestType('CookieStore')};export function headers():${requestType('Headers')};export function draftMode():${requestType(`{isEnabled:boolean;enable():void;disable():void}`)}}
665
669
  `
666
670
  const fontShims = hasRealNext
667
671
  ? ''
package/src/config.ts CHANGED
@@ -21,6 +21,12 @@ export type ResolvedConfig = Required<Pick<PNextConfig, 'outDir' | 'basePath'>>
21
21
  outRootPath: string
22
22
  /** Generated types — always under the out root, because tsconfig points at it. */
23
23
  typesPath: string
24
+ /**
25
+ * Generated per-route assignability checks. Deliberately OUTSIDE typesPath: an app's
26
+ * tsconfig includes `<outRoot>/types/**` and a foreign compiler must never see pnext's
27
+ * own internals. pnext's private typecheck project includes this directory instead.
28
+ */
29
+ checksPath: string
24
30
  }
25
31
 
26
32
  /**
@@ -146,6 +152,7 @@ export async function loadConfig(
146
152
  outPath: options.dev ? path.join(outRootPath, devOutSegment) : outRootPath,
147
153
  outRootPath,
148
154
  typesPath: path.join(outRootPath, 'types'),
155
+ checksPath: path.join(outRootPath, 'typecheck', 'checks'),
149
156
  }
150
157
  }
151
158
 
package/src/dev/server.ts CHANGED
@@ -100,6 +100,7 @@ import {
100
100
  } from '../runtime/modules'
101
101
  import { ssrClientReference } from '../client/reference'
102
102
  import { cacheRoot, setDevWatcherFreshness } from '../runtime/module-cache'
103
+ import { abortUpstreamFetchOnDisconnect } from '../runtime/fetch-host'
103
104
  import { markBoot } from '../cli/boot/trace'
104
105
  import { formatDuration } from '../utils/verbose'
105
106
 
@@ -454,6 +455,7 @@ export async function startDevServer(options: DevServerOptions) {
454
455
  syncWatchRoots()
455
456
  }, 0)
456
457
  if (profile) flushDevProfileLines()
458
+ abortUpstreamFetchOnDisconnect(logged.body, request.signal)
457
459
  return flushWorkUnitOnClose(logged, unit, request.signal)
458
460
  }
459
461
 
package/src/extensions.ts CHANGED
@@ -15,6 +15,12 @@ import type { BuildManifest, ClientEntryReason, RouteManifestEntry, RouteParamVa
15
15
  import type { VerboseLogger } from './utils/verbose'
16
16
  import { escapeRegex } from './utils/code'
17
17
 
18
+ // `Bun` through globalThis: pnext ships TypeScript source, so app compilers without
19
+ // bun-types typecheck this file and a bare `Bun` identifier would fail them.
20
+ const { Bun: bun } = globalThis as unknown as {
21
+ Bun: { hash(input: string | ArrayBufferView): { toString(radix?: number): string } }
22
+ }
23
+
18
24
  /** Per-build wiring for the server plugin chain. */
19
25
  export interface ServerEsbuildPluginOptions {
20
26
  /**
@@ -1416,7 +1422,7 @@ export function classifyRouteDependencies(
1416
1422
 
1417
1423
  /** Every reason a registered detector requires a client entry for this source. */
1418
1424
  export function sourceClientEntryReasons(source: string): ClientEntryReason[] {
1419
- const key = `${source.length}\0${Bun.hash(source).toString(36)}`
1425
+ const key = `${source.length}\0${bun.hash(source).toString(36)}`
1420
1426
  const cached = clientEntryReasonCache.get(key)
1421
1427
  if (cached) return cached
1422
1428
  const reasons: ClientEntryReason[] = []
@@ -7,6 +7,7 @@ import type {
7
7
  MetadataLink,
8
8
  MetadataOpenGraph,
9
9
  MetadataRobots,
10
+ MetadataValue,
10
11
  ResourceHint,
11
12
  MetadataTwitter,
12
13
  Viewport,
@@ -19,6 +20,13 @@ import {
19
20
  import { escapeHtml, stringifyHtmlValue } from '../utils/html'
20
21
  import { getTrailingSlashUrls, withBasePath } from '../routing/href'
21
22
 
23
+ /** Every metadata field is nullable: null means "not set", exactly like undefined. */
24
+ type MetaContent = MetadataValue | null | undefined
25
+
26
+ function absent(value: unknown): value is null | undefined {
27
+ return value === undefined || value === null
28
+ }
29
+
22
30
  export type MetadataExport = Metadata | (() => Metadata | Promise<Metadata>)
23
31
 
24
32
  export type ViewportExport = Viewport | (() => Viewport | Promise<Viewport>)
@@ -224,12 +232,15 @@ function prefixImageBasePath(image: MetadataImage): MetadataImage {
224
232
  export function metadataTags(metadata: Metadata, context: MetadataContext): string {
225
233
  const meta = metadata
226
234
  const tags: string[] = []
227
- const push = (name: string, content: string | undefined) => {
228
- if (content) tags.push(`<meta name="${escapeHtml(name)}" content="${escapeHtml(content)}"/>`)
235
+ const push = (name: string, content: MetaContent) => {
236
+ if (content)
237
+ tags.push(`<meta name="${escapeHtml(name)}" content="${escapeHtml(coerceString(content))}"/>`)
229
238
  }
230
- const pushProperty = (property: string, content: string | undefined) => {
239
+ const pushProperty = (property: string, content: MetaContent) => {
231
240
  if (content)
232
- tags.push(`<meta property="${escapeHtml(property)}" content="${escapeHtml(content)}"/>`)
241
+ tags.push(
242
+ `<meta property="${escapeHtml(property)}" content="${escapeHtml(coerceString(content))}"/>`,
243
+ )
233
244
  }
234
245
 
235
246
  push('description', meta.description)
@@ -263,8 +274,8 @@ export function metadataTags(metadata: Metadata, context: MetadataContext): stri
263
274
  }
264
275
  if (meta.facebook?.appId) pushProperty('fb:app_id', meta.facebook.appId)
265
276
  for (const admin of list(meta.facebook?.admins)) pushProperty('fb:admins', admin)
266
- if (meta.pinterest?.richPin !== undefined) {
267
- pushProperty('pinterest-rich-pin', meta.pinterest.richPin ? 'true' : 'false')
277
+ if (!absent(meta.pinterest?.richPin)) {
278
+ pushProperty('pinterest-rich-pin', String(meta.pinterest.richPin))
268
279
  }
269
280
  for (const [property, value] of appLinkTags(meta.appLinks)) pushProperty(property, value)
270
281
 
@@ -278,13 +289,15 @@ export function metadataTags(metadata: Metadata, context: MetadataContext): stri
278
289
  function openGraphTags(og: MetadataOpenGraph | undefined, context: MetadataContext): string[] {
279
290
  if (!og) return []
280
291
  const tags: string[] = []
281
- const push = (property: string, content: string | undefined) => {
292
+ const push = (property: string, content: MetaContent) => {
282
293
  if (content)
283
- tags.push(`<meta property="${escapeHtml(property)}" content="${escapeHtml(content)}"/>`)
294
+ tags.push(
295
+ `<meta property="${escapeHtml(property)}" content="${escapeHtml(coerceString(content))}"/>`,
296
+ )
284
297
  }
285
298
  push('og:title', og.title === undefined ? undefined : resolveTitleChain([{ title: og.title }]))
286
299
  push('og:description', og.description)
287
- push('og:url', og.url === undefined ? undefined : resolveMetadataUrl(og.url, context))
300
+ push('og:url', resolveMetadataUrl(og.url, context))
288
301
  push('og:site_name', og.siteName)
289
302
  push('og:locale', og.locale)
290
303
  push('og:type', og.type)
@@ -313,8 +326,9 @@ function openGraphTags(og: MetadataOpenGraph | undefined, context: MetadataConte
313
326
  function twitterTags(twitter: MetadataTwitter | undefined, context: MetadataContext): string[] {
314
327
  if (!twitter) return []
315
328
  const tags: string[] = []
316
- const push = (name: string, content: string | undefined) => {
317
- if (content) tags.push(`<meta name="${escapeHtml(name)}" content="${escapeHtml(content)}"/>`)
329
+ const push = (name: string, content: MetaContent) => {
330
+ if (content)
331
+ tags.push(`<meta name="${escapeHtml(name)}" content="${escapeHtml(coerceString(content))}"/>`)
318
332
  }
319
333
  push('twitter:card', twitterCard(twitter))
320
334
  push('twitter:site', twitter.site)
@@ -334,10 +348,13 @@ function twitterTags(twitter: MetadataTwitter | undefined, context: MetadataCont
334
348
  push('twitter:image:alt', image.alt)
335
349
  push('twitter:image:type', image.type)
336
350
  }
337
- push('twitter:player', resolveMetadataUrl(twitter.players?.playerUrl, context))
338
- push('twitter:player:stream', resolveMetadataUrl(twitter.players?.streamUrl, context))
339
- push('twitter:player:width', coerceString(twitter.players?.width) || undefined)
340
- push('twitter:player:height', coerceString(twitter.players?.height) || undefined)
351
+ const players = twitter.players === undefined ? [] : [twitter.players].flat()
352
+ for (const player of players) {
353
+ push('twitter:player', resolveMetadataUrl(player.playerUrl, context))
354
+ push('twitter:player:stream', resolveMetadataUrl(player.streamUrl, context))
355
+ push('twitter:player:width', coerceString(player.width) || undefined)
356
+ push('twitter:player:height', coerceString(player.height) || undefined)
357
+ }
341
358
  for (const [device, id] of Object.entries(twitter.app?.id ?? {})) {
342
359
  push(`twitter:app:id:${device}`, id)
343
360
  }
@@ -349,7 +366,7 @@ function twitterTags(twitter: MetadataTwitter | undefined, context: MetadataCont
349
366
 
350
367
  // theme-color: string | { color, media } | array of those.
351
368
  export function themeColorTags(value: Viewport['themeColor']): string {
352
- if (value === undefined) return ''
369
+ if (absent(value)) return ''
353
370
  const list = Array.isArray(value) ? value : [value]
354
371
  return list
355
372
  .map(entry => {
@@ -514,13 +531,13 @@ function coerceKeywords(value: Metadata['keywords']): string | undefined {
514
531
  }
515
532
 
516
533
  function normalizeKeywordList(value: Metadata['keywords']): (string | number)[] | undefined {
517
- if (value === undefined) return undefined
534
+ if (absent(value)) return undefined
518
535
  return Array.isArray(value) ? value : [value]
519
536
  }
520
537
 
521
538
  // authors -> list of display names for meta[name=author].
522
539
  function coerceAuthors(value: Metadata['authors']): string[] {
523
- if (value === undefined) return []
540
+ if (absent(value)) return []
524
541
  const list = Array.isArray(value) ? value : [value]
525
542
  return list
526
543
  .map(author => (typeof author === 'string' ? author : author.name))
@@ -530,7 +547,7 @@ function coerceAuthors(value: Metadata['authors']): string[] {
530
547
 
531
548
  // robots: string passthrough, or object -> "index, follow, noarchive" style.
532
549
  function coerceRobots(value: Metadata['robots']): string | undefined {
533
- if (value === undefined) return undefined
550
+ if (absent(value)) return undefined
534
551
  if (typeof value === 'string') return value
535
552
  const flags: string[] = []
536
553
  const r = value
@@ -601,7 +618,7 @@ function coerceCanonical(
601
618
  context: MetadataContext,
602
619
  ): string | undefined {
603
620
  const canonical = value?.canonical
604
- if (canonical === undefined) return undefined
621
+ if (absent(canonical)) return undefined
605
622
  if (typeof canonical === 'string') return resolveMetadataUrl(canonical, context)
606
623
  if (canonical instanceof URL) return canonical.href
607
624
  if (typeof canonical === 'object' && 'url' in canonical)
@@ -687,7 +704,7 @@ function joinUrlPath(...parts: string[]) {
687
704
 
688
705
  // Normalizes every icon form (string | URL | object | group) into <link> descriptors.
689
706
  function coerceIcons(value: Metadata['icons'], context: MetadataContext): MetadataLink[] {
690
- if (value === undefined) return []
707
+ if (absent(value)) return []
691
708
  if (isIconGroups(value)) {
692
709
  return [
693
710
  ...iconList(value.icon, 'icon', context),
@@ -706,11 +723,11 @@ function isIconGroups(value: NonNullable<Metadata['icons']>): value is MetadataI
706
723
  }
707
724
 
708
725
  function iconList(
709
- value: MetadataIcon | MetadataIcon[] | undefined,
726
+ value: MetadataIcon | MetadataIcon[] | null | undefined,
710
727
  rel: string,
711
728
  context: MetadataContext,
712
729
  ): MetadataLink[] {
713
- if (value === undefined) return []
730
+ if (absent(value)) return []
714
731
  const list = Array.isArray(value) ? value : [value]
715
732
  return list.map((icon): MetadataLink => {
716
733
  if (typeof icon === 'string') return { rel, url: resolveMetadataUrl(icon, context) ?? icon }
@@ -725,7 +742,7 @@ function iconList(
725
742
  }
726
743
 
727
744
  function authorLinks(value: Metadata['authors'], context: MetadataContext): MetadataLink[] {
728
- if (value === undefined) return []
745
+ if (absent(value)) return []
729
746
  return (Array.isArray(value) ? value : [value])
730
747
  .filter((author): author is MetadataAuthor => typeof author === 'object' && author !== null)
731
748
  .flatMap(author => {
@@ -775,7 +792,7 @@ function alternateLinks(value: Metadata['alternates'], context: MetadataContext)
775
792
  for (const [type, entries] of Object.entries(value.types ?? {})) {
776
793
  const listEntries = Array.isArray(entries) ? entries : [entries]
777
794
  for (const entry of listEntries) {
778
- const record =
795
+ const record: { url: unknown; title?: string } =
779
796
  typeof entry === 'object' && !(entry instanceof URL) && entry !== null && 'url' in entry
780
797
  ? entry
781
798
  : { url: entry }
@@ -794,8 +811,8 @@ function appleStartupLinks(
794
811
  value: Metadata['appleWebApp'],
795
812
  context: MetadataContext,
796
813
  ): MetadataLink[] {
797
- if (!value || typeof value !== 'object' || value.startupImage === undefined) return []
798
- const images = Array.isArray(value.startupImage) ? value.startupImage : [value.startupImage]
814
+ if (!value || typeof value !== 'object' || absent(value.startupImage)) return []
815
+ const images = [value.startupImage].flat()
799
816
  return images.map(image => {
800
817
  if (typeof image === 'string' || image instanceof URL) {
801
818
  return {
@@ -853,8 +870,10 @@ function appLinkTags(value: Metadata['appLinks']): [string, string][] {
853
870
  if (!value) return []
854
871
  const tags: [string, string][] = []
855
872
  for (const [platform, entries] of Object.entries(value)) {
856
- for (const [name, item] of Object.entries(entries)) {
857
- if (item !== undefined) tags.push([`al:${platform}:${name}`, String(item)])
873
+ for (const target of entries === undefined ? [] : [entries].flat()) {
874
+ for (const [name, item] of Object.entries(target)) {
875
+ if (item !== undefined) tags.push([`al:${platform}:${name}`, coerceString(item)])
876
+ }
858
877
  }
859
878
  }
860
879
  return tags
@@ -890,11 +909,14 @@ function resolveSocialMetadata(meta: Metadata): {
890
909
  images: ownImages ? twitter?.images : og.images,
891
910
  }
892
911
  }
893
- return { openGraph: og && inherited(og, meta), twitter: twitter && inherited(twitter, meta) }
912
+ return {
913
+ openGraph: og ? inherited(og, meta) : undefined,
914
+ twitter: twitter ? inherited(twitter, meta) : undefined,
915
+ }
894
916
  }
895
917
 
896
918
  // A block that renders no title/description of its own falls back to the page's.
897
- function inherited<T extends { title?: Metadata['title']; description?: string }>(
919
+ function inherited<T extends { title?: Metadata['title']; description?: string | null }>(
898
920
  block: T,
899
921
  meta: Metadata,
900
922
  ): T {
@@ -11,6 +11,12 @@ import {
11
11
  } from './engine'
12
12
  import { onExtensionHostReset } from '../extensions'
13
13
 
14
+ // `Bun` through globalThis: pnext ships TypeScript source, so app compilers without
15
+ // bun-types typecheck this file and a bare `Bun` identifier would fail them.
16
+ const { Bun: bun } = globalThis as unknown as {
17
+ Bun: { resolveSync(specifier: string, parent: string): string }
18
+ }
19
+
14
20
  // Conditions for "is this a local source file" lookups. Ordered to mirror the
15
21
  // preference a bundler applies, though `exports` key order ultimately decides.
16
22
  const localConditions = ['source', 'import', 'browser', 'node', 'default', 'require']
@@ -668,7 +674,7 @@ export function resolveRuntimeSpecifier(dir: string, specifier: string): string
668
674
  const cached = runtimeResolveCache.get(key)
669
675
  if (cached !== undefined) return cached
670
676
  try {
671
- const resolved = Bun.resolveSync(specifier, dir)
677
+ const resolved = bun.resolveSync(specifier, dir)
672
678
  runtimeResolveCache.set(key, resolved)
673
679
  return resolved
674
680
  } catch {
@@ -17,6 +17,12 @@ const parseSync: typeof import('oxc-parser').parseSync = (...args) =>
17
17
  import { loadNative } from '../utils/native-require'
18
18
  import { spliceSource } from '../runtime/module-transform'
19
19
 
20
+ // `Bun` through globalThis: pnext ships TypeScript source, so app compilers without
21
+ // bun-types typecheck this file and a bare `Bun` identifier would fail them.
22
+ const { Bun: bun } = globalThis as unknown as {
23
+ Bun: { hash(input: string | ArrayBufferView): { toString(radix?: number): string } }
24
+ }
25
+
20
26
  export interface ScanEdge {
21
27
  specifier: string
22
28
  /** Bound names: `default`, `*` (namespace object), or the imported names. */
@@ -187,7 +193,7 @@ export function rewriteFacts(file: string, source: string): RewriteFacts {
187
193
  }
188
194
 
189
195
  function parsed(file: string, source: string, lang = langForFile(file)) {
190
- const key = `${lang}\0${source.length}\0${Bun.hash(source).toString()}`
196
+ const key = `${lang}\0${source.length}\0${bun.hash(source).toString()}`
191
197
  const cached = memo.get(key)
192
198
  if (cached) {
193
199
  hits += 1
@@ -3,10 +3,18 @@
3
3
  * always derives Host from the request URL and drops any supplied one. An app that forwards its
4
4
  * inbound request headers to an upstream - every proxy/BFF route handler - would otherwise send
5
5
  * the local Host upstream, an RFC 9110 7.2 violation that real upstreams reject. Match undici.
6
+ *
7
+ * Bun also ignores response-body cancellation: cancelling a fetch Response's stream leaves the
8
+ * upstream request in flight and its keep-alive socket checked out for good, so a passthrough proxy
9
+ * route whose client disconnects mid-stream leaks a connection per abort until later fetches to that
10
+ * host queue behind them forever. Only the fetch's own AbortSignal tears the request down, so each
11
+ * response body is tracked against its controller here and the serving layer fires it on disconnect.
6
12
  */
7
13
 
8
14
  let installed = false
9
15
 
16
+ const upstreamAborts = new WeakMap<ReadableStream<Uint8Array>, AbortController>()
17
+
10
18
  function isHostKey(key: unknown): boolean {
11
19
  return typeof key === 'string' && key.length === 4 && key.toLowerCase() === 'host'
12
20
  }
@@ -36,7 +44,43 @@ export function installFetchHostNormalization(): void {
36
44
  const original = globalThis.fetch.bind(globalThis)
37
45
  globalThis.fetch = function fetch(input: RequestInfo | URL, init?: RequestInit) {
38
46
  const source = init?.headers ?? (input instanceof Request ? input.headers : undefined)
39
- if (source === undefined || !hasHost(source)) return original(input, init)
40
- return original(input, { ...init, headers: withoutHost(source) })
47
+ const normalized =
48
+ source !== undefined && hasHost(source) ? { ...init, headers: withoutHost(source) } : init
49
+ return trackUpstream(original, input, normalized)
41
50
  } as typeof globalThis.fetch
42
51
  }
52
+
53
+ /** Give every fetch an abort handle of its own, keyed on the body it streams back. */
54
+ function trackUpstream(
55
+ original: typeof globalThis.fetch,
56
+ input: RequestInfo | URL,
57
+ init: RequestInit | undefined,
58
+ ): Promise<Response> {
59
+ const controller = new AbortController()
60
+ const caller = init?.signal ?? (input instanceof Request ? input.signal : undefined)
61
+ const signal = caller ? AbortSignal.any([caller, controller.signal]) : controller.signal
62
+ return original(input, { ...init, signal }).then(response => {
63
+ if (response.body) upstreamAborts.set(response.body, controller)
64
+ return response
65
+ })
66
+ }
67
+
68
+ /**
69
+ * Tear down the upstream fetch `body` is streaming from once the client goes away. Bun.serve never
70
+ * cancels the body it is writing, so this disconnect is the only chance to release that socket.
71
+ * Zero-cost for any response that is not a fetch passthrough.
72
+ */
73
+ export function abortUpstreamFetchOnDisconnect(
74
+ body: ReadableStream<Uint8Array> | null,
75
+ signal: AbortSignal | undefined,
76
+ ): void {
77
+ if (!body || !signal || !upstreamAborts.has(body)) return
78
+ const abort = () => {
79
+ const controller = upstreamAborts.get(body)
80
+ if (!controller) return
81
+ upstreamAborts.delete(body)
82
+ controller.abort()
83
+ }
84
+ if (signal.aborted) abort()
85
+ else signal.addEventListener('abort', abort, { once: true })
86
+ }
package/src/types.ts CHANGED
@@ -95,7 +95,8 @@ export interface ResourceHint extends Omit<MetadataLink, 'url'> {
95
95
  export type MetadataTitle =
96
96
  string | number | { absolute?: string; default?: string; template?: string | null }
97
97
 
98
- export type MetadataIcon = string | URL | (Partial<MetadataLink> & { url: string | URL })
98
+ export type MetadataIcon =
99
+ string | URL | (Omit<Partial<MetadataLink>, 'url'> & { url: string | URL })
99
100
 
100
101
  export interface MetadataIconGroups {
101
102
  icon?: MetadataIcon | MetadataIcon[]
@@ -116,7 +117,7 @@ export interface MetadataRobots {
116
117
  nosnippet?: boolean
117
118
  noimageindex?: boolean
118
119
  nocache?: boolean
119
- googleBot?: MetadataRobots & Record<string, string | number | boolean | undefined>
120
+ googleBot?: string | (MetadataRobots & Record<string, string | number | boolean | undefined>)
120
121
  }
121
122
 
122
123
  export type MetadataImage =
@@ -134,7 +135,7 @@ export type MetadataImage =
134
135
  export interface MetadataOpenGraph {
135
136
  title?: MetadataTitle
136
137
  description?: string
137
- url?: string | URL
138
+ url?: string | URL | null
138
139
  siteName?: string
139
140
  locale?: string
140
141
  type?: string
@@ -142,109 +143,125 @@ export interface MetadataOpenGraph {
142
143
  videos?: MetadataImage | MetadataImage[]
143
144
  audio?: MetadataImage | MetadataImage[]
144
145
  publishedTime?: string
145
- authors?: string | string[]
146
+ authors?: string | URL | (string | URL)[] | null
146
147
  emails?: string | string[]
147
148
  phoneNumbers?: string | string[]
148
149
  faxNumbers?: string | string[]
149
150
  }
150
151
 
152
+ export interface MetadataTwitterPlayer {
153
+ playerUrl?: string | URL
154
+ streamUrl?: string | URL
155
+ width?: string | number
156
+ height?: string | number
157
+ }
158
+
151
159
  export interface MetadataTwitter {
152
160
  card?: string
153
- site?: string
154
- siteId?: string
155
- creator?: string
156
- creatorId?: string
161
+ site?: string | null
162
+ siteId?: string | null
163
+ creator?: string | null
164
+ creatorId?: string | null
157
165
  title?: MetadataTitle
158
- description?: string
166
+ description?: string | null
159
167
  images?: MetadataImage | MetadataImage[]
160
- players?: {
161
- playerUrl?: string | URL
162
- streamUrl?: string | URL
163
- width?: string | number
164
- height?: string | number
165
- }
168
+ players?: MetadataTwitterPlayer | MetadataTwitterPlayer[]
166
169
  app?: {
167
170
  name?: string
168
- id?: Record<string, string | undefined>
171
+ id?: Record<string, MetadataValue | undefined>
169
172
  url?: Record<string, string | URL | undefined>
170
173
  }
171
174
  }
172
175
 
176
+ export type MetadataAlternate =
177
+ | string
178
+ | URL
179
+ | { url: string | URL; title?: string }
180
+ | (string | URL | { url: string | URL; title?: string })[]
181
+
173
182
  export interface MetadataAlternates {
174
- canonical?: string | URL | { url: string | URL }
175
- languages?: Record<string, string | URL>
176
- media?: Record<string, string | URL>
177
- types?: Record<
178
- string,
179
- | string
180
- | URL
181
- | { url: string | URL; title?: string }
182
- | (string | URL | { url: string | URL; title?: string })[]
183
- >
183
+ canonical?: string | URL | { url: string | URL; title?: string } | null
184
+ languages?: Record<string, MetadataAlternate | null | undefined>
185
+ media?: Record<string, MetadataAlternate | null | undefined>
186
+ types?: Record<string, MetadataAlternate | null | undefined>
184
187
  }
185
188
 
189
+ // Every field is nullable: a metadata object may explicitly null a field out to
190
+ // suppress an inherited value, and null reads the same as absent here.
186
191
  export interface Metadata {
187
- metadataBase?: string | URL
188
- title?: MetadataTitle
189
- description?: string
190
- lang?: string
191
- keywords?: string | number | (string | number)[]
192
- authors?: string | MetadataAuthor | (string | MetadataAuthor)[]
193
- generator?: string
194
- applicationName?: string
195
- referrer?: string
196
- robots?: string | MetadataRobots
197
- openGraph?: MetadataOpenGraph
198
- twitter?: MetadataTwitter
199
- alternates?: MetadataAlternates
192
+ metadataBase?: string | URL | null
193
+ title?: MetadataTitle | null
194
+ description?: string | null
195
+ lang?: string | null
196
+ keywords?: string | number | (string | number)[] | null
197
+ authors?: string | MetadataAuthor | (string | MetadataAuthor)[] | null
198
+ generator?: string | null
199
+ applicationName?: string | null
200
+ referrer?: string | null
201
+ robots?: string | MetadataRobots | null
202
+ openGraph?: MetadataOpenGraph | null
203
+ twitter?: MetadataTwitter | null
204
+ alternates?: MetadataAlternates | null
200
205
  pagination?: {
201
- previous?: string | URL
202
- next?: string | URL
203
- }
204
- icons?: MetadataIcon | MetadataIcon[] | MetadataIconGroups
205
- manifest?: string | URL
206
- creator?: string
207
- publisher?: string
206
+ previous?: string | URL | null
207
+ next?: string | URL | null
208
+ } | null
209
+ icons?: MetadataIcon | MetadataIcon[] | MetadataIconGroups | null
210
+ manifest?: string | URL | null
211
+ creator?: string | null
212
+ publisher?: string | null
208
213
  formatDetection?: {
209
- email?: boolean
210
- address?: boolean
211
- telephone?: boolean
212
- url?: boolean
213
- }
214
+ email?: boolean | null
215
+ address?: boolean | null
216
+ telephone?: boolean | null
217
+ url?: boolean | null
218
+ } | null
214
219
  verification?: {
215
- google?: string | string[]
216
- yahoo?: string | string[]
217
- yandex?: string | string[]
218
- other?: Record<string, string | string[]>
219
- }
220
+ google?: MetadataValue | MetadataValue[] | null
221
+ yahoo?: MetadataValue | MetadataValue[] | null
222
+ yandex?: MetadataValue | MetadataValue[] | null
223
+ other?: Record<string, MetadataValue | MetadataValue[]>
224
+ } | null
220
225
  itunes?: {
221
226
  appId?: string
222
- appArgument?: string
223
- }
227
+ appArgument?: string | null
228
+ } | null
224
229
  appleWebApp?:
225
230
  | boolean
226
231
  | {
227
232
  capable?: boolean
228
- title?: string
233
+ title?: string | null
229
234
  statusBarStyle?: string
230
235
  startupImage?:
231
236
  | string
232
237
  | URL
233
238
  | { url: string | URL; media?: string }
234
239
  | (string | URL | { url: string | URL; media?: string })[]
240
+ | null
235
241
  }
242
+ | null
236
243
  facebook?: {
237
244
  appId?: string
238
- admins?: string | string[]
239
- }
245
+ admins?: MetadataValue | MetadataValue[]
246
+ } | null
240
247
  pinterest?: {
241
- richPin?: boolean
242
- }
243
- appLinks?: Record<string, Record<string, string | boolean | undefined>>
244
- other?: Record<string, string | string[]>
248
+ richPin?: boolean | string | null
249
+ } | null
250
+ appLinks?: MetadataAppLinks | null
251
+ other?: Record<string, MetadataValue | MetadataValue[] | null>
245
252
  links?: MetadataLink[]
246
253
  }
247
254
 
255
+ /** A metadata value that renders to text; numbers are stringified. */
256
+ export type MetadataValue = string | number
257
+
258
+ export type MetadataAppLinkTarget = Record<string, MetadataValue | boolean | URL | undefined>
259
+
260
+ export type MetadataAppLinks = Record<
261
+ string,
262
+ MetadataAppLinkTarget | MetadataAppLinkTarget[] | undefined
263
+ >
264
+
248
265
  export type ThemeColor = string | { color: string; media?: string }
249
266
 
250
267
  export interface Viewport {
@@ -255,8 +272,8 @@ export interface Viewport {
255
272
  userScalable?: boolean
256
273
  viewportFit?: 'auto' | 'contain' | 'cover'
257
274
  interactiveWidget?: 'resizes-visual' | 'resizes-content' | 'overlays-content'
258
- themeColor?: ThemeColor | ThemeColor[]
259
- colorScheme?: string
275
+ themeColor?: ThemeColor | ThemeColor[] | null
276
+ colorScheme?: string | null
260
277
  }
261
278
 
262
279
  export interface NextRequestCookie {