| Server IP : 159.203.156.69 / Your IP : 216.73.217.172 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/vinext/dist/shims/ |
Upload File : |
{"version":3,"file":"slot.js","names":["React"],"sources":["../../src/shims/slot.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n AppElementsWire,\n UNMATCHED_SLOT,\n type AppElementValue,\n type AppElements,\n} from \"../server/app-elements.js\";\nimport { notFound } from \"./navigation.js\";\n\nconst EMPTY_ELEMENTS: AppElements = Object.freeze({});\nconst warnedMissingEntryIds = new Set<string>();\n\nexport { UNMATCHED_SLOT };\n\n/**\n * Holds resolved AppElements (not a Promise). React 19's use(Promise) during\n * hydration triggers \"async Client Component\" for native Promises that lack\n * React's internal .status property. Storing resolved values sidesteps this.\n */\nexport const ElementsContext = React.createContext<AppElements>(EMPTY_ELEMENTS);\n\nexport const ChildrenContext = React.createContext<React.ReactNode>(null);\n\nexport const ParallelSlotsContext = React.createContext<Readonly<\n Record<string, React.ReactNode>\n> | null>(null);\n\ntype MergeElementsOptions = {\n clearAbsentSlots?: boolean;\n preserveAbsentSlots?: boolean;\n preserveElementIds?: readonly string[];\n};\n\nexport function mergeElements(\n prev: AppElements,\n next: AppElements,\n options: MergeElementsOptions | boolean = {},\n): AppElements {\n const clearAbsentSlots =\n typeof options === \"boolean\" ? options : (options.clearAbsentSlots ?? false);\n const preserveAbsentSlots =\n typeof options === \"boolean\" ? !options : (options.preserveAbsentSlots ?? true);\n const preserveElementIds = typeof options === \"boolean\" ? [] : (options.preserveElementIds ?? []);\n const merged: Record<string, AppElementValue> = { ...next };\n\n for (const id of preserveElementIds) {\n if (Object.hasOwn(merged, id)) continue;\n if (Object.hasOwn(prev, id)) {\n const value = prev[id];\n if (value !== undefined) merged[id] = value;\n }\n }\n\n // On soft navigation, unmatched parallel slots preserve their previous subtree\n // instead of firing notFound(). Only hard navigation (full page load) should 404.\n // This matches Next.js behavior for parallel route persistence.\n const slotKeys = new Set(\n [...Object.keys(prev), ...Object.keys(next)].filter((key) => AppElementsWire.isSlotId(key)),\n );\n for (const key of slotKeys) {\n if (next[key] === UNMATCHED_SLOT && Object.hasOwn(prev, key)) {\n merged[key] = prev[key];\n }\n }\n // On traversal (browser back/forward), the server renders the full destination\n // route tree. A slot absent from next means the destination route tree does not\n // include it, so clear it rather than keeping the stale prev value. The legacy\n // absent-slot path stays opt-in for unpromoted fallbacks; promoted navigation\n // commits preserve mounted slots through planner-approved preserveElementIds.\n if (clearAbsentSlots) {\n for (const key of slotKeys) {\n if (!Object.hasOwn(next, key)) {\n delete merged[key];\n }\n }\n } else if (preserveAbsentSlots) {\n for (const key of slotKeys) {\n if (!Object.hasOwn(merged, key) && Object.hasOwn(prev, key)) {\n const value = prev[key];\n if (value !== undefined) merged[key] = value;\n }\n }\n }\n return merged;\n}\n\nexport function Slot({\n id,\n children,\n parallelSlots,\n}: {\n id: string;\n children?: React.ReactNode;\n parallelSlots?: Readonly<Record<string, React.ReactNode>>;\n}) {\n const elements = React.useContext(ElementsContext);\n\n if (!Object.hasOwn(elements, id)) {\n if (process.env.NODE_ENV !== \"production\" && !AppElementsWire.isSlotId(id)) {\n if (!warnedMissingEntryIds.has(id)) {\n warnedMissingEntryIds.add(id);\n console.warn(\"[vinext] Missing App Router element entry during render: \" + id);\n }\n }\n return null;\n }\n\n const element = elements[id];\n if (element === UNMATCHED_SLOT) {\n notFound();\n }\n\n return (\n <ParallelSlotsContext.Provider value={parallelSlots ?? null}>\n <ChildrenContext.Provider value={children ?? null}>{element}</ChildrenContext.Provider>\n </ParallelSlotsContext.Provider>\n );\n}\n\nexport function Children() {\n return React.useContext(ChildrenContext);\n}\n\nexport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