convex-cms 0.0.6 → 0.0.7
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/README.md +68 -101
- package/admin/src/components/BreakingChangesWarningDialog.tsx +5 -5
- package/admin/src/components/BulkOperationModal.tsx +14 -14
- package/admin/src/components/ContentEntryEditor.tsx +8 -8
- package/admin/src/components/ContentTypeFormModal.tsx +122 -82
- package/admin/src/components/Header.tsx +5 -2
- package/admin/src/components/SchemaDriftWarning.tsx +126 -0
- package/admin/src/components/TaxonomyEditor.tsx +2 -2
- package/admin/src/components/TermTree.tsx +3 -3
- package/admin/src/components/UploadDropzone.tsx +7 -7
- package/admin/src/components/VersionCompare.tsx +13 -13
- package/admin/src/components/VersionHistory.tsx +2 -2
- package/admin/src/components/VersionRollbackModal.tsx +5 -5
- package/admin/src/components/cmsds/CmsButton.tsx +2 -2
- package/admin/src/components/cmsds/CmsDialog.tsx +4 -1
- package/admin/src/components/cmsds/CmsStatusBadge.tsx +5 -5
- package/admin/src/components/fields/JsonField.tsx +1 -1
- package/admin/src/components/fields/ReferenceField.tsx +9 -9
- package/admin/src/components/fields/TagField.tsx +1 -1
- package/admin/src/contexts/SettingsConfigContext.tsx +10 -3
- package/admin/src/embed/index.tsx +29 -9
- package/admin/src/embed/pages/ContentTypeEntries.tsx +25 -0
- package/admin/src/embed/pages/Entry.tsx +114 -0
- package/admin/src/embed/pages/Media.tsx +3 -1
- package/admin/src/embed/pages/NewEntry.tsx +83 -0
- package/admin/src/embed/pages/index.ts +3 -0
- package/admin/src/pages/ContentPage.tsx +27 -20
- package/admin/src/pages/ContentTypeEntriesPage.tsx +466 -0
- package/admin/src/pages/ContentTypesPage.tsx +65 -19
- package/admin/src/pages/DashboardPage.tsx +3 -0
- package/admin/src/pages/SettingsPage.tsx +4 -4
- package/admin/src/pages/index.ts +1 -0
- package/admin/src/routes/__root.tsx +10 -10
- package/admin/src/routes/entries/$entryId.tsx +1 -1
- package/admin/src/routes/entries/type/$contentTypeId.tsx +1 -1
- package/admin/src/styles/globals.css +31 -5
- package/admin/src/styles/tailwind-config.css +25 -0
- package/admin/src/styles/theme.css +50 -0
- package/admin-dist/nitro.json +1 -1
- package/admin-dist/public/assets/CmsEmptyState-6-PLaXtD.js +1 -0
- package/admin-dist/public/assets/CmsPageHeader-SoF4Epu9.js +1 -0
- package/admin-dist/public/assets/CmsStatusBadge-D7kYaohx.js +1 -0
- package/admin-dist/public/assets/{CmsSurface-DBy5Lumx.js → CmsSurface-BvksBm6W.js} +1 -1
- package/admin-dist/public/assets/CmsToolbar-DlZPMe2B.js +1 -0
- package/admin-dist/public/assets/ContentEntryEditor-C6n9xLS9.js +4 -0
- package/admin-dist/public/assets/TaxonomyFilter-CFX1_g8s.js +1 -0
- package/admin-dist/public/assets/_contentTypeId-DTv8UoTp.js +1 -0
- package/admin-dist/public/assets/_entryId-D3lr5Dvy.js +1 -0
- package/admin-dist/public/assets/alert-BAHTL6ao.js +1 -0
- package/admin-dist/public/assets/badge-oJv4Eai8.js +1 -0
- package/admin-dist/public/assets/{circle-check-big-CpLxAvEj.js → circle-check-big-3OHxNDhO.js} +1 -1
- package/admin-dist/public/assets/command-DwgQs69u.js +1 -0
- package/admin-dist/public/assets/content-CKQ4QwW2.js +1 -0
- package/admin-dist/public/assets/content-types-BrttaLpc.js +1 -0
- package/admin-dist/public/assets/globals-CoCRjt0K.css +1 -0
- package/admin-dist/public/assets/index-DOkgTSx0.js +1 -0
- package/admin-dist/public/assets/main-DV6oxWnU.js +102 -0
- package/admin-dist/public/assets/media-B2i-mCbx.js +1 -0
- package/admin-dist/public/assets/new._contentTypeId-VF63rpic.js +1 -0
- package/admin-dist/public/assets/pencil-CX1CiTDD.js +1 -0
- package/admin-dist/public/assets/refresh-cw-Cm-YOeFI.js +1 -0
- package/admin-dist/public/assets/{rotate-ccw-BZpZtw0N.js → rotate-ccw-B45JsL5f.js} +1 -1
- package/admin-dist/public/assets/scroll-area-b3A1HHR7.js +1 -0
- package/admin-dist/public/assets/{search-BvgYr-c9.js → search-DKKh_DdH.js} +1 -1
- package/admin-dist/public/assets/settings-CGVDEV1r.js +1 -0
- package/admin-dist/public/assets/switch-BTMY8Qnk.js +1 -0
- package/admin-dist/public/assets/tabs-DUQwUoIb.js +1 -0
- package/admin-dist/public/assets/tanstack-adapter-f7AHmQ5L.js +1 -0
- package/admin-dist/public/assets/taxonomies-DvMppdiD.js +1 -0
- package/admin-dist/public/assets/trash-D7e0uKd9.js +1 -0
- package/admin-dist/public/assets/{useBreadcrumbLabel-D00rvqjw.js → useBreadcrumbLabel-CF2KYwsw.js} +1 -1
- package/admin-dist/public/assets/usePermissions-DWBImEOW.js +1 -0
- package/admin-dist/server/_chunks/_libs/@date-fns/tz.mjs +2 -2
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-avatar.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-collection.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-context.mjs +2 -2
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-dialog.mjs +2 -2
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-label.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-menu.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-popover.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-primitive.mjs +6 -72
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-select.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-separator.mjs +1 -1
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-slot.mjs +20 -435
- package/admin-dist/server/_chunks/_libs/@radix-ui/react-visually-hidden.mjs +30 -3
- package/admin-dist/server/_chunks/_libs/@tanstack/history.mjs +0 -376
- package/admin-dist/server/_chunks/_libs/@tanstack/react-router.mjs +168 -383
- package/admin-dist/server/_chunks/_libs/@tanstack/router-core.mjs +451 -1195
- package/admin-dist/server/_chunks/_libs/react-dom.mjs +5 -5
- package/admin-dist/server/_chunks/_libs/react.mjs +2 -2
- package/admin-dist/server/_libs/cmdk.mjs +1 -1
- package/admin-dist/server/_libs/convex.mjs +3 -3
- package/admin-dist/server/_libs/cookie-es.mjs +1 -58
- package/admin-dist/server/_libs/date-fns.mjs +1 -1
- package/admin-dist/server/_libs/lucide-react.mjs +117 -103
- package/admin-dist/server/_libs/seroval-plugins.mjs +1 -58
- package/admin-dist/server/_libs/seroval.mjs +1 -1765
- package/admin-dist/server/_libs/zod.mjs +1 -1
- package/admin-dist/server/_ssr/CmsEmptyState-BM8DghTl.mjs +38 -0
- package/admin-dist/server/_ssr/{CmsPageHeader-ClNPU7Up.mjs → CmsPageHeader-BHUmrIWD.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsStatusBadge-CojMbrY7.mjs → CmsStatusBadge-D0Zb0oRl.mjs} +7 -7
- package/admin-dist/server/_ssr/{CmsSurface-Dcv440rp.mjs → CmsSurface-B2eBr-47.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsToolbar-BKv1nL6u.mjs → CmsToolbar-BCrwg7OL.mjs} +2 -3
- package/admin-dist/server/_ssr/{ContentEntryEditor-weiXSBdZ.mjs → ContentEntryEditor-Cjfm0uhr.mjs} +46 -49
- package/admin-dist/server/_ssr/{TaxonomyFilter-BPQ57Mwk.mjs → TaxonomyFilter-C4pD0kfM.mjs} +4 -5
- package/admin-dist/server/_ssr/{_contentTypeId-DyyauLOs.mjs → _contentTypeId-CiDiX-p7.mjs} +34 -43
- package/admin-dist/server/_ssr/{_entryId-9Cafwxmw.mjs → _entryId-9GxatOkL.mjs} +35 -47
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-CC7UrHKE.mjs +4 -0
- package/admin-dist/server/_ssr/badge-EI998zba.mjs +39 -0
- package/admin-dist/server/_ssr/{command-CEf8YBxY.mjs → command-BLAWQhUw.mjs} +2 -2
- package/admin-dist/server/_ssr/{config.server-D7JHDcDv.mjs → config.server-BOr7Jxr4.mjs} +5 -14
- package/admin-dist/server/_ssr/{content-ZFWVzO25.mjs → content-BHX39L4D.mjs} +63 -63
- package/admin-dist/server/_ssr/content-types-DCzrBhTH.mjs +459 -0
- package/admin-dist/server/_ssr/{index-BlSIlH4Z.mjs → index-DwM_5VNP.mjs} +114 -30
- package/admin-dist/server/_ssr/index.mjs +3459 -62
- package/admin-dist/server/_ssr/{media-CD2_NUMw.mjs → media-CbzgTRRQ.mjs} +31 -43
- package/admin-dist/server/_ssr/{new._contentTypeId-dmZy6PBX.mjs → new._contentTypeId-6Ph-Gtlw.mjs} +33 -45
- package/admin-dist/server/_ssr/router-vd1nySeP.mjs +3041 -0
- package/admin-dist/server/_ssr/{scroll-area-BH_1K-WT.mjs → scroll-area--B9snFTJ.mjs} +1 -1
- package/admin-dist/server/_ssr/{settings-DVdsoWoh.mjs → settings-DlTO2JSj.mjs} +34 -43
- package/admin-dist/server/_ssr/{switch-DX_X8vZl.mjs → switch-C05NgNW0.mjs} +1 -1
- package/admin-dist/server/_ssr/{tabs-4FWM0sn8.mjs → tabs-DAk2J5xy.mjs} +9 -10
- package/admin-dist/server/_ssr/{tanstack-adapter-D3ZcKtbY.mjs → tanstack-adapter-DWbaPByn.mjs} +15 -1
- package/admin-dist/server/_ssr/{taxonomies-BHFfO9Yr.mjs → taxonomies-B8nqce6u.mjs} +35 -44
- package/admin-dist/server/_ssr/{trash-9tUB2KwI.mjs → trash-zdlZgpTo.mjs} +30 -39
- package/admin-dist/server/_ssr/{useBreadcrumbLabel-DVme3DSb.mjs → useBreadcrumbLabel-DpEKyG1h.mjs} +1 -1
- package/admin-dist/server/_ssr/{usePermissions-zAQj-ruE.mjs → usePermissions-olYRd9S9.mjs} +1 -1
- package/admin-dist/server/index.mjs +168 -203
- package/dist/cli/templates/cmsClient.d.ts +1 -1
- package/dist/cli/templates/cmsClient.d.ts.map +1 -1
- package/dist/cli/templates/cmsClient.js +30 -11
- package/dist/cli/templates/cmsClient.js.map +1 -1
- package/dist/cli/templates/cmsConfig.d.ts +1 -1
- package/dist/cli/templates/cmsConfig.d.ts.map +1 -1
- package/dist/cli/templates/cmsConfig.js +3 -3
- package/dist/client/admin/contentLock.d.ts +4 -4
- package/dist/client/admin/contentLock.d.ts.map +1 -1
- package/dist/client/admin/contentLock.js +1 -1
- package/dist/client/admin/contentLock.js.map +1 -1
- package/dist/client/admin/contentTypes.d.ts +328 -290
- package/dist/client/admin/contentTypes.d.ts.map +1 -1
- package/dist/client/admin/contentTypes.js +307 -9
- package/dist/client/admin/contentTypes.js.map +1 -1
- package/dist/client/admin/entries.d.ts +18 -19
- package/dist/client/admin/entries.d.ts.map +1 -1
- package/dist/client/admin/entries.js +33 -8
- package/dist/client/admin/entries.js.map +1 -1
- package/dist/client/admin/index.d.ts +694 -642
- package/dist/client/admin/index.d.ts.map +1 -1
- package/dist/client/admin/index.js +45 -5
- package/dist/client/admin/index.js.map +1 -1
- package/dist/client/admin/media.d.ts.map +1 -1
- package/dist/client/admin/taxonomies.d.ts.map +1 -1
- package/dist/client/admin/trash.d.ts +3 -4
- package/dist/client/admin/trash.d.ts.map +1 -1
- package/dist/client/admin/types.d.ts +185 -4
- package/dist/client/admin/types.d.ts.map +1 -1
- package/dist/client/admin/validators.d.ts +2009 -25
- package/dist/client/admin/validators.d.ts.map +1 -1
- package/dist/client/admin/validators.js +15 -4
- package/dist/client/admin/validators.js.map +1 -1
- package/dist/client/admin/versions.d.ts +1 -1
- package/dist/client/admin/versions.d.ts.map +1 -1
- package/dist/client/agentTools.d.ts +1 -4
- package/dist/client/agentTools.d.ts.map +1 -1
- package/dist/client/agentTools.js +9 -21
- package/dist/client/agentTools.js.map +1 -1
- package/dist/client/config.d.ts +10 -0
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js +1 -0
- package/dist/client/config.js.map +1 -1
- package/dist/client/defineContent.d.ts +338 -0
- package/dist/client/defineContent.d.ts.map +1 -0
- package/dist/client/defineContent.js +368 -0
- package/dist/client/defineContent.js.map +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/queryBuilder.d.ts +0 -15
- package/dist/client/queryBuilder.d.ts.map +1 -1
- package/dist/client/queryBuilder.js +0 -23
- package/dist/client/queryBuilder.js.map +1 -1
- package/dist/client/registry.d.ts +77 -0
- package/dist/client/registry.d.ts.map +1 -0
- package/dist/client/registry.js +95 -0
- package/dist/client/registry.js.map +1 -0
- package/dist/client/schema/defineContentType.d.ts +36 -24
- package/dist/client/schema/defineContentType.d.ts.map +1 -1
- package/dist/client/schema/defineContentType.js +176 -128
- package/dist/client/schema/defineContentType.js.map +1 -1
- package/dist/client/schema/typedClient.d.ts.map +1 -1
- package/dist/client/schema/typedClient.js +2 -10
- package/dist/client/schema/typedClient.js.map +1 -1
- package/dist/client/schema/types.d.ts +16 -9
- package/dist/client/schema/types.d.ts.map +1 -1
- package/dist/client/schema/types.js.map +1 -1
- package/dist/client/utils/toSlug.d.ts +60 -0
- package/dist/client/utils/toSlug.d.ts.map +1 -0
- package/dist/client/utils/toSlug.js +31 -0
- package/dist/client/utils/toSlug.js.map +1 -0
- package/dist/client/wrapper.d.ts +2 -2
- package/dist/client/wrapper.d.ts.map +1 -1
- package/dist/client/wrapper.js +22 -30
- package/dist/client/wrapper.js.map +1 -1
- package/dist/component/_generated/component.d.ts +24 -28
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/authorizationHooks.d.ts +1 -1
- package/dist/component/authorizationHooks.d.ts.map +1 -1
- package/dist/component/authorizationHooks.js +2 -2
- package/dist/component/authorizationHooks.js.map +1 -1
- package/dist/component/bulkOperations.d.ts.map +1 -1
- package/dist/component/bulkOperations.js +7 -4
- package/dist/component/bulkOperations.js.map +1 -1
- package/dist/component/contentEntries.d.ts +18 -56
- package/dist/component/contentEntries.d.ts.map +1 -1
- package/dist/component/contentEntries.js +45 -137
- package/dist/component/contentEntries.js.map +1 -1
- package/dist/component/contentEntryMutations.d.ts +14 -14
- package/dist/component/contentEntryMutations.d.ts.map +1 -1
- package/dist/component/contentEntryMutations.js +40 -43
- package/dist/component/contentEntryMutations.js.map +1 -1
- package/dist/component/contentEntryValidation.d.ts +3 -3
- package/dist/component/contentEntryValidation.js +6 -9
- package/dist/component/contentEntryValidation.js.map +1 -1
- package/dist/component/contentLock.d.ts +7 -7
- package/dist/component/contentLock.js +3 -3
- package/dist/component/contentLock.js.map +1 -1
- package/dist/component/contentTypeMigration.d.ts +1 -1
- package/dist/component/contentTypeMigration.js +2 -2
- package/dist/component/contentTypeMigration.js.map +1 -1
- package/dist/component/contentTypeMutations.d.ts.map +1 -1
- package/dist/component/contentTypeMutations.js +7 -6
- package/dist/component/contentTypeMutations.js.map +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +1 -1
- package/dist/component/convex.config.js.map +1 -1
- package/dist/component/eventEmitter.d.ts +0 -1
- package/dist/component/eventEmitter.d.ts.map +1 -1
- package/dist/component/eventEmitter.js.map +1 -1
- package/dist/component/exportImport.d.ts +37 -37
- package/dist/component/exportImport.d.ts.map +1 -1
- package/dist/component/exportImport.js +34 -34
- package/dist/component/exportImport.js.map +1 -1
- package/dist/component/lib/deepReferenceResolver.d.ts +2 -2
- package/dist/component/lib/deepReferenceResolver.d.ts.map +1 -1
- package/dist/component/lib/deepReferenceResolver.js +13 -8
- package/dist/component/lib/deepReferenceResolver.js.map +1 -1
- package/dist/component/lib/ragContentChunker.d.ts +3 -3
- package/dist/component/lib/ragContentChunker.d.ts.map +1 -1
- package/dist/component/lib/ragContentChunker.js +4 -4
- package/dist/component/lib/ragContentChunker.js.map +1 -1
- package/dist/component/lib/referenceResolver.d.ts.map +1 -1
- package/dist/component/lib/referenceResolver.js +10 -17
- package/dist/component/lib/referenceResolver.js.map +1 -1
- package/dist/component/mediaAssetMutations.js +4 -4
- package/dist/component/mediaAssetMutations.js.map +1 -1
- package/dist/component/ragContentIndexer.d.ts +2 -2
- package/dist/component/ragContentIndexer.d.ts.map +1 -1
- package/dist/component/ragContentIndexer.js +44 -48
- package/dist/component/ragContentIndexer.js.map +1 -1
- package/dist/component/roles.d.ts +3 -3
- package/dist/component/scheduledPublish.d.ts +4 -4
- package/dist/component/scheduledPublish.js +3 -3
- package/dist/component/scheduledPublish.js.map +1 -1
- package/dist/component/schema.d.ts +18 -18
- package/dist/component/schema.js +5 -5
- package/dist/component/schema.js.map +1 -1
- package/dist/component/trash.d.ts +6 -9
- package/dist/component/trash.d.ts.map +1 -1
- package/dist/component/trash.js +12 -36
- package/dist/component/trash.js.map +1 -1
- package/dist/component/userContext.d.ts +1 -2
- package/dist/component/userContext.d.ts.map +1 -1
- package/dist/component/userContext.js +1 -2
- package/dist/component/userContext.js.map +1 -1
- package/dist/component/validators.d.ts +27 -33
- package/dist/component/validators.d.ts.map +1 -1
- package/dist/component/validators.js +3 -5
- package/dist/component/validators.js.map +1 -1
- package/dist/component/versionMutations.d.ts +1 -1
- package/dist/component/webhookTrigger.d.ts +14 -14
- package/dist/test.d.ts +30 -30
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +24 -24
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/admin-dist/public/assets/CmsEmptyState-Do_erIgn.js +0 -5
- package/admin-dist/public/assets/CmsPageHeader-qDwPGi48.js +0 -1
- package/admin-dist/public/assets/CmsStatusBadge-Dd9uToHE.js +0 -1
- package/admin-dist/public/assets/CmsToolbar-D1-Y-7SK.js +0 -1
- package/admin-dist/public/assets/ContentEntryEditor-CWBiIx52.js +0 -4
- package/admin-dist/public/assets/TaxonomyFilter-CdYQawxb.js +0 -1
- package/admin-dist/public/assets/_contentTypeId-D9VMP6Gs.js +0 -1
- package/admin-dist/public/assets/_entryId-2FlCfqE7.js +0 -1
- package/admin-dist/public/assets/alert-GxZx0y5c.js +0 -1
- package/admin-dist/public/assets/badge-BAlGIjop.js +0 -1
- package/admin-dist/public/assets/command-di7XCqcv.js +0 -1
- package/admin-dist/public/assets/content-D8zELsDG.js +0 -1
- package/admin-dist/public/assets/content-types-BmzD0krT.js +0 -2
- package/admin-dist/public/assets/globals-BvFfH-v9.css +0 -1
- package/admin-dist/public/assets/index-zqfj4T_v.js +0 -1
- package/admin-dist/public/assets/label-B6PPtKR5.js +0 -1
- package/admin-dist/public/assets/link-2-W2fVnVOf.js +0 -1
- package/admin-dist/public/assets/list-F8O0lZXC.js +0 -1
- package/admin-dist/public/assets/main-dZT72bAG.js +0 -97
- package/admin-dist/public/assets/media-CETueFbV.js +0 -1
- package/admin-dist/public/assets/new._contentTypeId-BV2-TyyR.js +0 -1
- package/admin-dist/public/assets/plus-AABQIF0N.js +0 -1
- package/admin-dist/public/assets/scroll-area-CDfk-zrz.js +0 -1
- package/admin-dist/public/assets/select-BuiHcMzS.js +0 -1
- package/admin-dist/public/assets/settings-DBxbYDvn.js +0 -1
- package/admin-dist/public/assets/switch-DiJvolcs.js +0 -1
- package/admin-dist/public/assets/tabs-Cgz6G_Xy.js +0 -1
- package/admin-dist/public/assets/tanstack-adapter-BknsSgra.js +0 -1
- package/admin-dist/public/assets/taxonomies-DOErsLl5.js +0 -1
- package/admin-dist/public/assets/textarea-CgggMxUX.js +0 -1
- package/admin-dist/public/assets/trash-BU4ANuaW.js +0 -1
- package/admin-dist/public/assets/triangle-alert-lvCbwp0s.js +0 -1
- package/admin-dist/public/assets/usePermissions-D7tQowaF.js +0 -1
- package/admin-dist/server/_libs/h3-v2.mjs +0 -277
- package/admin-dist/server/_ssr/CmsButton-DbzfJru_.mjs +0 -125
- package/admin-dist/server/_ssr/CmsEmptyState-CuvcXr3Z.mjs +0 -290
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-Dk-FIYPN.mjs +0 -4
- package/admin-dist/server/_ssr/content-types-D25lUE-j.mjs +0 -1312
- package/admin-dist/server/_ssr/label-PblVvdRv.mjs +0 -22
- package/admin-dist/server/_ssr/router-x6Ab8T4s.mjs +0 -1622
- package/admin-dist/server/_ssr/select-CrfEkFJw.mjs +0 -142
- package/admin-dist/server/_ssr/textarea-CZVaroMc.mjs +0 -18
|
@@ -1,39 +1,9 @@
|
|
|
1
|
-
import { s as splitSetCookieString } from "../../../_libs/cookie-es.mjs";
|
|
2
1
|
import { b as batch, S as Store } from "./store.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { p as parseHref } from "./history.mjs";
|
|
4
3
|
import { i as invariant } from "../../../_libs/tiny-invariant.mjs";
|
|
5
|
-
import { n as ni, t as te, c as cn, m as mn } from "../../../_libs/seroval.mjs";
|
|
6
|
-
import { p } from "../../../_libs/seroval-plugins.mjs";
|
|
7
4
|
import { ReadableStream as ReadableStream$1 } from "node:stream/web";
|
|
8
5
|
import { Readable } from "node:stream";
|
|
9
|
-
|
|
10
|
-
if (init instanceof Headers) {
|
|
11
|
-
return new Headers(init);
|
|
12
|
-
} else if (Array.isArray(init)) {
|
|
13
|
-
return new Headers(init);
|
|
14
|
-
} else if (typeof init === "object") {
|
|
15
|
-
return new Headers(init);
|
|
16
|
-
} else {
|
|
17
|
-
return new Headers();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
function mergeHeaders(...headers) {
|
|
21
|
-
return headers.reduce((acc, header) => {
|
|
22
|
-
const headersInstance = toHeadersInstance(header);
|
|
23
|
-
for (const [key, value] of headersInstance.entries()) {
|
|
24
|
-
if (key === "set-cookie") {
|
|
25
|
-
const splitCookies = splitSetCookieString(value);
|
|
26
|
-
splitCookies.forEach((cookie) => acc.append("set-cookie", cookie));
|
|
27
|
-
} else {
|
|
28
|
-
acc.set(key, value);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return acc;
|
|
32
|
-
}, new Headers());
|
|
33
|
-
}
|
|
34
|
-
function isNotFound(obj) {
|
|
35
|
-
return !!obj?.isNotFound;
|
|
36
|
-
}
|
|
6
|
+
const isServer = true;
|
|
37
7
|
function last(arr) {
|
|
38
8
|
return arr[arr.length - 1];
|
|
39
9
|
}
|
|
@@ -66,20 +36,20 @@ function replaceEqualDeep(prev, _next, _depth = 0) {
|
|
|
66
36
|
let equalItems = 0;
|
|
67
37
|
for (let i = 0; i < nextSize; i++) {
|
|
68
38
|
const key = array ? i : nextItems[i];
|
|
69
|
-
const
|
|
39
|
+
const p = prev[key];
|
|
70
40
|
const n = next[key];
|
|
71
|
-
if (
|
|
72
|
-
copy[key] =
|
|
41
|
+
if (p === n) {
|
|
42
|
+
copy[key] = p;
|
|
73
43
|
if (array ? i < prevSize : hasOwn.call(prev, key)) equalItems++;
|
|
74
44
|
continue;
|
|
75
45
|
}
|
|
76
|
-
if (
|
|
46
|
+
if (p === null || n === null || typeof p !== "object" || typeof n !== "object") {
|
|
77
47
|
copy[key] = n;
|
|
78
48
|
continue;
|
|
79
49
|
}
|
|
80
|
-
const v = replaceEqualDeep(
|
|
50
|
+
const v = replaceEqualDeep(p, n, _depth + 1);
|
|
81
51
|
copy[key] = v;
|
|
82
|
-
if (v ===
|
|
52
|
+
if (v === p) equalItems++;
|
|
83
53
|
}
|
|
84
54
|
return prevSize === nextSize && equalItems === prevSize ? prev : copy;
|
|
85
55
|
}
|
|
@@ -247,6 +217,10 @@ function decodePath(path, decodeIgnore) {
|
|
|
247
217
|
}
|
|
248
218
|
return result;
|
|
249
219
|
}
|
|
220
|
+
function encodeNonAscii(path) {
|
|
221
|
+
if (!/[^\u0000-\u007F]/.test(path)) return path;
|
|
222
|
+
return path.replace(/[^\u0000-\u007F]/gu, encodeURIComponent);
|
|
223
|
+
}
|
|
250
224
|
function createLRUCache(max) {
|
|
251
225
|
const cache = /* @__PURE__ */ new Map();
|
|
252
226
|
let oldest;
|
|
@@ -316,9 +290,15 @@ const SEGMENT_TYPE_WILDCARD = 2;
|
|
|
316
290
|
const SEGMENT_TYPE_OPTIONAL_PARAM = 3;
|
|
317
291
|
const SEGMENT_TYPE_INDEX = 4;
|
|
318
292
|
const SEGMENT_TYPE_PATHLESS = 5;
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
293
|
+
function getOpenAndCloseBraces(part) {
|
|
294
|
+
const openBrace = part.indexOf("{");
|
|
295
|
+
if (openBrace === -1) return null;
|
|
296
|
+
const closeBrace = part.indexOf("}", openBrace);
|
|
297
|
+
if (closeBrace === -1) return null;
|
|
298
|
+
const afterOpen = openBrace + 1;
|
|
299
|
+
if (afterOpen >= part.length) return null;
|
|
300
|
+
return [openBrace, closeBrace];
|
|
301
|
+
}
|
|
322
302
|
function parseSegment(path, start, output = new Uint16Array(6)) {
|
|
323
303
|
const next = path.indexOf("/", start);
|
|
324
304
|
const end = next === -1 ? path.length : next;
|
|
@@ -351,45 +331,44 @@ function parseSegment(path, start, output = new Uint16Array(6)) {
|
|
|
351
331
|
output[5] = end;
|
|
352
332
|
return output;
|
|
353
333
|
}
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return output;
|
|
334
|
+
const braces = getOpenAndCloseBraces(part);
|
|
335
|
+
if (braces) {
|
|
336
|
+
const [openBrace, closeBrace] = braces;
|
|
337
|
+
const firstChar = part.charCodeAt(openBrace + 1);
|
|
338
|
+
if (firstChar === 45) {
|
|
339
|
+
if (openBrace + 2 < part.length && part.charCodeAt(openBrace + 2) === 36) {
|
|
340
|
+
const paramStart = openBrace + 3;
|
|
341
|
+
const paramEnd = closeBrace;
|
|
342
|
+
if (paramStart < paramEnd) {
|
|
343
|
+
output[0] = SEGMENT_TYPE_OPTIONAL_PARAM;
|
|
344
|
+
output[1] = start + openBrace;
|
|
345
|
+
output[2] = start + paramStart;
|
|
346
|
+
output[3] = start + paramEnd;
|
|
347
|
+
output[4] = start + closeBrace + 1;
|
|
348
|
+
output[5] = end;
|
|
349
|
+
return output;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} else if (firstChar === 36) {
|
|
353
|
+
const dollarPos = openBrace + 1;
|
|
354
|
+
const afterDollar = openBrace + 2;
|
|
355
|
+
if (afterDollar === closeBrace) {
|
|
356
|
+
output[0] = SEGMENT_TYPE_WILDCARD;
|
|
357
|
+
output[1] = start + openBrace;
|
|
358
|
+
output[2] = start + dollarPos;
|
|
359
|
+
output[3] = start + afterDollar;
|
|
360
|
+
output[4] = start + closeBrace + 1;
|
|
361
|
+
output[5] = path.length;
|
|
362
|
+
return output;
|
|
363
|
+
}
|
|
364
|
+
output[0] = SEGMENT_TYPE_PARAM;
|
|
365
|
+
output[1] = start + openBrace;
|
|
366
|
+
output[2] = start + afterDollar;
|
|
367
|
+
output[3] = start + closeBrace;
|
|
368
|
+
output[4] = start + closeBrace + 1;
|
|
369
|
+
output[5] = end;
|
|
370
|
+
return output;
|
|
371
|
+
}
|
|
393
372
|
}
|
|
394
373
|
output[0] = SEGMENT_TYPE_PATHNAME;
|
|
395
374
|
output[1] = start;
|
|
@@ -1230,19 +1209,27 @@ function resolvePath({
|
|
|
1230
1209
|
if (key && cache) cache.set(key, result);
|
|
1231
1210
|
return result;
|
|
1232
1211
|
}
|
|
1233
|
-
function
|
|
1212
|
+
function compileDecodeCharMap(pathParamsAllowedCharacters) {
|
|
1213
|
+
const charMap = new Map(
|
|
1214
|
+
pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char])
|
|
1215
|
+
);
|
|
1216
|
+
const pattern = Array.from(charMap.keys()).map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
1217
|
+
const regex = new RegExp(pattern, "g");
|
|
1218
|
+
return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
|
|
1219
|
+
}
|
|
1220
|
+
function encodeParam(key, params, decoder) {
|
|
1234
1221
|
const value = params[key];
|
|
1235
1222
|
if (typeof value !== "string") return value;
|
|
1236
1223
|
if (key === "_splat") {
|
|
1237
1224
|
return encodeURI(value);
|
|
1238
1225
|
} else {
|
|
1239
|
-
return encodePathParam(value,
|
|
1226
|
+
return encodePathParam(value, decoder);
|
|
1240
1227
|
}
|
|
1241
1228
|
}
|
|
1242
1229
|
function interpolatePath({
|
|
1243
1230
|
path,
|
|
1244
1231
|
params,
|
|
1245
|
-
|
|
1232
|
+
decoder
|
|
1246
1233
|
}) {
|
|
1247
1234
|
let isMissingParams = false;
|
|
1248
1235
|
const usedParams = {};
|
|
@@ -1278,7 +1265,7 @@ function interpolatePath({
|
|
|
1278
1265
|
}
|
|
1279
1266
|
continue;
|
|
1280
1267
|
}
|
|
1281
|
-
const value = encodeParam("_splat", params,
|
|
1268
|
+
const value = encodeParam("_splat", params, decoder);
|
|
1282
1269
|
joined += "/" + prefix + value + suffix;
|
|
1283
1270
|
continue;
|
|
1284
1271
|
}
|
|
@@ -1290,7 +1277,7 @@ function interpolatePath({
|
|
|
1290
1277
|
usedParams[key] = params[key];
|
|
1291
1278
|
const prefix = path.substring(start, segment[1]);
|
|
1292
1279
|
const suffix = path.substring(segment[4], end);
|
|
1293
|
-
const value = encodeParam(key, params,
|
|
1280
|
+
const value = encodeParam(key, params, decoder) ?? "undefined";
|
|
1294
1281
|
joined += "/" + prefix + value + suffix;
|
|
1295
1282
|
continue;
|
|
1296
1283
|
}
|
|
@@ -1301,7 +1288,7 @@ function interpolatePath({
|
|
|
1301
1288
|
usedParams[key] = valueRaw;
|
|
1302
1289
|
const prefix = path.substring(start, segment[1]);
|
|
1303
1290
|
const suffix = path.substring(segment[4], end);
|
|
1304
|
-
const value = encodeParam(key, params,
|
|
1291
|
+
const value = encodeParam(key, params, decoder) ?? "";
|
|
1305
1292
|
joined += "/" + prefix + value + suffix;
|
|
1306
1293
|
continue;
|
|
1307
1294
|
}
|
|
@@ -1310,14 +1297,12 @@ function interpolatePath({
|
|
|
1310
1297
|
const interpolatedPath = joined || "/";
|
|
1311
1298
|
return { usedParams, interpolatedPath, isMissingParams };
|
|
1312
1299
|
}
|
|
1313
|
-
function encodePathParam(value,
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
}
|
|
1320
|
-
return encoded;
|
|
1300
|
+
function encodePathParam(value, decoder) {
|
|
1301
|
+
const encoded = encodeURIComponent(value);
|
|
1302
|
+
return decoder?.(encoded) ?? encoded;
|
|
1303
|
+
}
|
|
1304
|
+
function isNotFound(obj) {
|
|
1305
|
+
return !!obj?.isNotFound;
|
|
1321
1306
|
}
|
|
1322
1307
|
function getSafeSessionStorage() {
|
|
1323
1308
|
try {
|
|
@@ -1329,17 +1314,6 @@ function getSafeSessionStorage() {
|
|
|
1329
1314
|
return void 0;
|
|
1330
1315
|
}
|
|
1331
1316
|
const storageKey = "tsr-scroll-restoration-v1_3";
|
|
1332
|
-
const throttle = (fn, wait) => {
|
|
1333
|
-
let timeout;
|
|
1334
|
-
return (...args) => {
|
|
1335
|
-
if (!timeout) {
|
|
1336
|
-
timeout = setTimeout(() => {
|
|
1337
|
-
fn(...args);
|
|
1338
|
-
timeout = null;
|
|
1339
|
-
}, wait);
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
};
|
|
1343
1317
|
function createScrollRestorationCache() {
|
|
1344
1318
|
const safeSessionStorage = getSafeSessionStorage();
|
|
1345
1319
|
if (!safeSessionStorage) {
|
|
@@ -1364,22 +1338,10 @@ function createScrollRestorationCache() {
|
|
|
1364
1338
|
}
|
|
1365
1339
|
};
|
|
1366
1340
|
}
|
|
1367
|
-
|
|
1341
|
+
createScrollRestorationCache();
|
|
1368
1342
|
const defaultGetScrollRestorationKey = (location) => {
|
|
1369
1343
|
return location.state.__TSR_key || location.href;
|
|
1370
1344
|
};
|
|
1371
|
-
function getCssSelector(el) {
|
|
1372
|
-
const path = [];
|
|
1373
|
-
let parent;
|
|
1374
|
-
while (parent = el.parentNode) {
|
|
1375
|
-
path.push(
|
|
1376
|
-
`${el.tagName}:nth-child(${Array.prototype.indexOf.call(parent.children, el) + 1})`
|
|
1377
|
-
);
|
|
1378
|
-
el = parent;
|
|
1379
|
-
}
|
|
1380
|
-
return `${path.reverse().join(" > ")}`.toLowerCase();
|
|
1381
|
-
}
|
|
1382
|
-
let ignoreScroll = false;
|
|
1383
1345
|
function restoreScroll({
|
|
1384
1346
|
storageKey: storageKey2,
|
|
1385
1347
|
key,
|
|
@@ -1397,7 +1359,6 @@ function restoreScroll({
|
|
|
1397
1359
|
}
|
|
1398
1360
|
const resolvedKey = key || window.history.state?.__TSR_key;
|
|
1399
1361
|
const elementEntries = byKey[resolvedKey];
|
|
1400
|
-
ignoreScroll = true;
|
|
1401
1362
|
scroll: {
|
|
1402
1363
|
if (shouldScrollRestoration && elementEntries && Object.keys(elementEntries).length > 0) {
|
|
1403
1364
|
for (const elementSelector in elementEntries) {
|
|
@@ -1439,100 +1400,15 @@ function restoreScroll({
|
|
|
1439
1400
|
}
|
|
1440
1401
|
}
|
|
1441
1402
|
}
|
|
1442
|
-
ignoreScroll = false;
|
|
1443
1403
|
}
|
|
1444
1404
|
function setupScrollRestoration(router, force) {
|
|
1445
|
-
if (!scrollRestorationCache && !router.isServer) {
|
|
1446
|
-
return;
|
|
1447
|
-
}
|
|
1448
1405
|
const shouldScrollRestoration = router.options.scrollRestoration ?? false;
|
|
1449
1406
|
if (shouldScrollRestoration) {
|
|
1450
1407
|
router.isScrollRestoring = true;
|
|
1451
1408
|
}
|
|
1452
|
-
|
|
1409
|
+
{
|
|
1453
1410
|
return;
|
|
1454
1411
|
}
|
|
1455
|
-
router.isScrollRestorationSetup = true;
|
|
1456
|
-
ignoreScroll = false;
|
|
1457
|
-
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
1458
|
-
window.history.scrollRestoration = "manual";
|
|
1459
|
-
const onScroll = (event) => {
|
|
1460
|
-
if (ignoreScroll || !router.isScrollRestoring) {
|
|
1461
|
-
return;
|
|
1462
|
-
}
|
|
1463
|
-
let elementSelector = "";
|
|
1464
|
-
if (event.target === document || event.target === window) {
|
|
1465
|
-
elementSelector = "window";
|
|
1466
|
-
} else {
|
|
1467
|
-
const attrId = event.target.getAttribute(
|
|
1468
|
-
"data-scroll-restoration-id"
|
|
1469
|
-
);
|
|
1470
|
-
if (attrId) {
|
|
1471
|
-
elementSelector = `[data-scroll-restoration-id="${attrId}"]`;
|
|
1472
|
-
} else {
|
|
1473
|
-
elementSelector = getCssSelector(event.target);
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
const restoreKey = getKey(router.state.location);
|
|
1477
|
-
scrollRestorationCache.set((state) => {
|
|
1478
|
-
const keyEntry = state[restoreKey] ||= {};
|
|
1479
|
-
const elementEntry = keyEntry[elementSelector] ||= {};
|
|
1480
|
-
if (elementSelector === "window") {
|
|
1481
|
-
elementEntry.scrollX = window.scrollX || 0;
|
|
1482
|
-
elementEntry.scrollY = window.scrollY || 0;
|
|
1483
|
-
} else if (elementSelector) {
|
|
1484
|
-
const element = document.querySelector(elementSelector);
|
|
1485
|
-
if (element) {
|
|
1486
|
-
elementEntry.scrollX = element.scrollLeft || 0;
|
|
1487
|
-
elementEntry.scrollY = element.scrollTop || 0;
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
return state;
|
|
1491
|
-
});
|
|
1492
|
-
};
|
|
1493
|
-
if (typeof document !== "undefined") {
|
|
1494
|
-
document.addEventListener("scroll", throttle(onScroll, 100), true);
|
|
1495
|
-
}
|
|
1496
|
-
router.subscribe("onRendered", (event) => {
|
|
1497
|
-
const cacheKey = getKey(event.toLocation);
|
|
1498
|
-
const resetScroll = event.toLocation.state.__TSR_resetScroll ?? true;
|
|
1499
|
-
if (!resetScroll) {
|
|
1500
|
-
return;
|
|
1501
|
-
}
|
|
1502
|
-
if (typeof router.options.scrollRestoration === "function") {
|
|
1503
|
-
const shouldRestore = router.options.scrollRestoration({
|
|
1504
|
-
location: router.latestLocation
|
|
1505
|
-
});
|
|
1506
|
-
if (!shouldRestore) {
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
restoreScroll({
|
|
1511
|
-
storageKey,
|
|
1512
|
-
key: cacheKey,
|
|
1513
|
-
behavior: router.options.scrollRestorationBehavior,
|
|
1514
|
-
shouldScrollRestoration: router.isScrollRestoring,
|
|
1515
|
-
scrollToTopSelectors: router.options.scrollToTopSelectors,
|
|
1516
|
-
location: router.history.location
|
|
1517
|
-
});
|
|
1518
|
-
if (router.isScrollRestoring) {
|
|
1519
|
-
scrollRestorationCache.set((state) => {
|
|
1520
|
-
state[cacheKey] ||= {};
|
|
1521
|
-
return state;
|
|
1522
|
-
});
|
|
1523
|
-
}
|
|
1524
|
-
});
|
|
1525
|
-
}
|
|
1526
|
-
function handleHashScroll(router) {
|
|
1527
|
-
if (typeof document !== "undefined" && document.querySelector) {
|
|
1528
|
-
const hashScrollIntoViewOptions = router.state.location.state.__hashScrollIntoViewOptions ?? true;
|
|
1529
|
-
if (hashScrollIntoViewOptions && router.state.location.hash !== "") {
|
|
1530
|
-
const el = document.getElementById(router.state.location.hash);
|
|
1531
|
-
if (el) {
|
|
1532
|
-
el.scrollIntoView(hashScrollIntoViewOptions);
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
1412
|
}
|
|
1537
1413
|
function encode(obj, stringify = String) {
|
|
1538
1414
|
const result = new URLSearchParams();
|
|
@@ -1642,15 +1518,6 @@ function redirect(opts) {
|
|
|
1642
1518
|
function isRedirect(obj) {
|
|
1643
1519
|
return obj instanceof Response && !!obj.options;
|
|
1644
1520
|
}
|
|
1645
|
-
function isResolvedRedirect(obj) {
|
|
1646
|
-
return isRedirect(obj) && !!obj.options.href;
|
|
1647
|
-
}
|
|
1648
|
-
function parseRedirect(obj) {
|
|
1649
|
-
if (obj !== null && typeof obj === "object" && obj.isSerializedRedirect) {
|
|
1650
|
-
return redirect(obj);
|
|
1651
|
-
}
|
|
1652
|
-
return void 0;
|
|
1653
|
-
}
|
|
1654
1521
|
const triggerOnReady = (inner) => {
|
|
1655
1522
|
if (!inner.rendered) {
|
|
1656
1523
|
inner.rendered = true;
|
|
@@ -1732,10 +1599,7 @@ const handleRedirectAndNotFound = (inner, match, err) => {
|
|
|
1732
1599
|
};
|
|
1733
1600
|
const shouldSkipLoader = (inner, matchId) => {
|
|
1734
1601
|
const match = inner.router.getMatch(matchId);
|
|
1735
|
-
if (
|
|
1736
|
-
return true;
|
|
1737
|
-
}
|
|
1738
|
-
if (inner.router.isServer && match.ssr === false) {
|
|
1602
|
+
if (match.ssr === false) {
|
|
1739
1603
|
return true;
|
|
1740
1604
|
}
|
|
1741
1605
|
return false;
|
|
@@ -1825,7 +1689,7 @@ const isBeforeLoadSsr = (inner, matchId, index, route) => {
|
|
|
1825
1689
|
const setupPendingTimeout = (inner, matchId, route, match) => {
|
|
1826
1690
|
if (match._nonReactive.pendingTimeout !== void 0) return;
|
|
1827
1691
|
const pendingMs = route.options.pendingMs ?? inner.router.options.defaultPendingMs;
|
|
1828
|
-
const shouldPending = !!(inner.onReady &&
|
|
1692
|
+
const shouldPending = !!(inner.onReady && false);
|
|
1829
1693
|
if (shouldPending) {
|
|
1830
1694
|
const pendingTimeout = setTimeout(() => {
|
|
1831
1695
|
triggerOnReady(inner);
|
|
@@ -1957,7 +1821,7 @@ const handleBeforeLoad = (inner, index) => {
|
|
|
1957
1821
|
const { id: matchId, routeId } = inner.matches[index];
|
|
1958
1822
|
const route = inner.router.looseRoutesById[routeId];
|
|
1959
1823
|
const serverSsr = () => {
|
|
1960
|
-
|
|
1824
|
+
{
|
|
1961
1825
|
const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
|
|
1962
1826
|
if (isPromise(maybePromise)) return maybePromise.then(queueExecution);
|
|
1963
1827
|
}
|
|
@@ -2031,7 +1895,7 @@ const runLoader = async (inner, matchId, index, route) => {
|
|
|
2031
1895
|
try {
|
|
2032
1896
|
const match = inner.router.getMatch(matchId);
|
|
2033
1897
|
try {
|
|
2034
|
-
if (!inner.router.isServer || match.ssr === true) {
|
|
1898
|
+
if (!(isServer ?? inner.router.isServer) || match.ssr === true) {
|
|
2035
1899
|
loadRouteChunk(route);
|
|
2036
1900
|
}
|
|
2037
1901
|
const loaderResult = route.options.loader?.(
|
|
@@ -2120,7 +1984,7 @@ const loadRouteMatch = async (inner, index) => {
|
|
|
2120
1984
|
let loaderIsRunningAsync = false;
|
|
2121
1985
|
const route = inner.router.looseRoutesById[routeId];
|
|
2122
1986
|
if (shouldSkipLoader(inner, matchId)) {
|
|
2123
|
-
|
|
1987
|
+
{
|
|
2124
1988
|
return inner.router.getMatch(matchId);
|
|
2125
1989
|
}
|
|
2126
1990
|
} else {
|
|
@@ -2198,9 +2062,6 @@ async function loadMatches(arg) {
|
|
|
2198
2062
|
const inner = Object.assign(arg, {
|
|
2199
2063
|
matchPromises: []
|
|
2200
2064
|
});
|
|
2201
|
-
if (!inner.router.isServer && inner.router.state.matches.some((d) => d._forcePending)) {
|
|
2202
|
-
triggerOnReady(inner);
|
|
2203
|
-
}
|
|
2204
2065
|
try {
|
|
2205
2066
|
for (let i = 0; i < inner.matches.length; i++) {
|
|
2206
2067
|
const beforeLoad = handleBeforeLoad(inner, i);
|
|
@@ -2385,6 +2246,7 @@ class RouterCore {
|
|
|
2385
2246
|
this.tempLocationKey = `${Math.round(
|
|
2386
2247
|
Math.random() * 1e7
|
|
2387
2248
|
)}`;
|
|
2249
|
+
this.resetNextScroll = true;
|
|
2388
2250
|
this.shouldViewTransition = void 0;
|
|
2389
2251
|
this.isViewTransitionTypesSupported = void 0;
|
|
2390
2252
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
@@ -2406,26 +2268,19 @@ class RouterCore {
|
|
|
2406
2268
|
...newOptions
|
|
2407
2269
|
};
|
|
2408
2270
|
this.isServer = this.options.isServer ?? typeof document === "undefined";
|
|
2409
|
-
|
|
2410
|
-
this.
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
])
|
|
2414
|
-
) : void 0;
|
|
2271
|
+
if (this.options.pathParamsAllowedCharacters)
|
|
2272
|
+
this.pathParamsDecoder = compileDecodeCharMap(
|
|
2273
|
+
this.options.pathParamsAllowedCharacters
|
|
2274
|
+
);
|
|
2415
2275
|
if (!this.history || this.options.history && this.options.history !== this.history) {
|
|
2416
|
-
if (!this.options.history)
|
|
2417
|
-
|
|
2418
|
-
this.history = createBrowserHistory();
|
|
2419
|
-
}
|
|
2420
|
-
} else {
|
|
2276
|
+
if (!this.options.history) ;
|
|
2277
|
+
else {
|
|
2421
2278
|
this.history = this.options.history;
|
|
2422
2279
|
}
|
|
2423
2280
|
}
|
|
2424
2281
|
this.origin = this.options.origin;
|
|
2425
2282
|
if (!this.origin) {
|
|
2426
|
-
|
|
2427
|
-
this.origin = window.origin;
|
|
2428
|
-
} else {
|
|
2283
|
+
{
|
|
2429
2284
|
this.origin = "http://localhost";
|
|
2430
2285
|
}
|
|
2431
2286
|
}
|
|
@@ -2434,7 +2289,23 @@ class RouterCore {
|
|
|
2434
2289
|
}
|
|
2435
2290
|
if (this.options.routeTree !== this.routeTree) {
|
|
2436
2291
|
this.routeTree = this.options.routeTree;
|
|
2437
|
-
|
|
2292
|
+
let processRouteTreeResult;
|
|
2293
|
+
if (globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree) {
|
|
2294
|
+
const cached = globalThis.__TSR_CACHE__;
|
|
2295
|
+
this.resolvePathCache = cached.resolvePathCache;
|
|
2296
|
+
processRouteTreeResult = cached.processRouteTreeResult;
|
|
2297
|
+
} else {
|
|
2298
|
+
this.resolvePathCache = createLRUCache(1e3);
|
|
2299
|
+
processRouteTreeResult = this.buildRouteTree();
|
|
2300
|
+
if (globalThis.__TSR_CACHE__ === void 0) {
|
|
2301
|
+
globalThis.__TSR_CACHE__ = {
|
|
2302
|
+
routeTree: this.routeTree,
|
|
2303
|
+
processRouteTreeResult,
|
|
2304
|
+
resolvePathCache: this.resolvePathCache
|
|
2305
|
+
};
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
this.setRoutes(processRouteTreeResult);
|
|
2438
2309
|
}
|
|
2439
2310
|
if (!this.__store && this.latestLocation) {
|
|
2440
2311
|
this.__store = new Store(getInitialRouterState(this.latestLocation), {
|
|
@@ -2457,7 +2328,8 @@ class RouterCore {
|
|
|
2457
2328
|
if (basepathChanged || rewriteChanged) {
|
|
2458
2329
|
this.basepath = nextBasepath;
|
|
2459
2330
|
const rewrites = [];
|
|
2460
|
-
|
|
2331
|
+
const trimmed = trimPath(nextBasepath);
|
|
2332
|
+
if (trimmed && trimmed !== "/") {
|
|
2461
2333
|
rewrites.push(
|
|
2462
2334
|
rewriteBasepath({
|
|
2463
2335
|
basepath: nextBasepath
|
|
@@ -2492,7 +2364,7 @@ class RouterCore {
|
|
|
2492
2364
|
);
|
|
2493
2365
|
};
|
|
2494
2366
|
this.buildRouteTree = () => {
|
|
2495
|
-
const
|
|
2367
|
+
const result = processRouteTree(
|
|
2496
2368
|
this.routeTree,
|
|
2497
2369
|
this.options.caseSensitive,
|
|
2498
2370
|
(route, i) => {
|
|
@@ -2502,18 +2374,9 @@ class RouterCore {
|
|
|
2502
2374
|
}
|
|
2503
2375
|
);
|
|
2504
2376
|
if (this.options.routeMasks) {
|
|
2505
|
-
processRouteMasks(this.options.routeMasks, processedTree);
|
|
2506
|
-
}
|
|
2507
|
-
this.routesById = routesById;
|
|
2508
|
-
this.routesByPath = routesByPath;
|
|
2509
|
-
this.processedTree = processedTree;
|
|
2510
|
-
const notFoundRoute = this.options.notFoundRoute;
|
|
2511
|
-
if (notFoundRoute) {
|
|
2512
|
-
notFoundRoute.init({
|
|
2513
|
-
originalIndex: 99999999999
|
|
2514
|
-
});
|
|
2515
|
-
this.routesById[notFoundRoute.id] = notFoundRoute;
|
|
2377
|
+
processRouteMasks(this.options.routeMasks, result.processedTree);
|
|
2516
2378
|
}
|
|
2379
|
+
return result;
|
|
2517
2380
|
};
|
|
2518
2381
|
this.subscribe = (eventType, fn) => {
|
|
2519
2382
|
const listener = {
|
|
@@ -2546,8 +2409,8 @@ class RouterCore {
|
|
|
2546
2409
|
return {
|
|
2547
2410
|
href: fullPath,
|
|
2548
2411
|
publicHref: href,
|
|
2549
|
-
url,
|
|
2550
2412
|
pathname: decodePath(url.pathname),
|
|
2413
|
+
external: !!this.rewrite && url.origin !== this.origin,
|
|
2551
2414
|
searchStr,
|
|
2552
2415
|
search: replaceEqualDeep(previousLocation?.search, parsedSearch),
|
|
2553
2416
|
hash: decodePath(url.hash.split("#").reverse()[0] ?? ""),
|
|
@@ -2568,7 +2431,6 @@ class RouterCore {
|
|
|
2568
2431
|
}
|
|
2569
2432
|
return location;
|
|
2570
2433
|
};
|
|
2571
|
-
this.resolvePathCache = createLRUCache(1e3);
|
|
2572
2434
|
this.resolvePathWithBase = (from, path) => {
|
|
2573
2435
|
const resolvedPath = resolvePath({
|
|
2574
2436
|
base: from,
|
|
@@ -2586,9 +2448,9 @@ class RouterCore {
|
|
|
2586
2448
|
search: locationSearchOrOpts
|
|
2587
2449
|
},
|
|
2588
2450
|
opts
|
|
2589
|
-
)
|
|
2451
|
+
);
|
|
2590
2452
|
}
|
|
2591
|
-
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts)
|
|
2453
|
+
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
2592
2454
|
};
|
|
2593
2455
|
this.getMatchedRoutes = (pathname) => {
|
|
2594
2456
|
return getMatchedRoutes({
|
|
@@ -2623,15 +2485,12 @@ class RouterCore {
|
|
|
2623
2485
|
this.buildLocation = (opts) => {
|
|
2624
2486
|
const build = (dest = {}) => {
|
|
2625
2487
|
const currentLocation = dest._fromLocation || this.pendingBuiltLocation || this.latestLocation;
|
|
2626
|
-
const
|
|
2627
|
-
_buildLocation: true
|
|
2628
|
-
});
|
|
2629
|
-
const lastMatch = last(allCurrentLocationMatches);
|
|
2488
|
+
const lightweightResult = this.matchRoutesLightweight(currentLocation);
|
|
2630
2489
|
if (dest.from && false) ;
|
|
2631
|
-
const defaultedFromPath = dest.unsafeRelative === "path" ? currentLocation.pathname : dest.from ??
|
|
2490
|
+
const defaultedFromPath = dest.unsafeRelative === "path" ? currentLocation.pathname : dest.from ?? lightweightResult.fullPath;
|
|
2632
2491
|
const fromPath = this.resolvePathWithBase(defaultedFromPath, ".");
|
|
2633
|
-
const fromSearch =
|
|
2634
|
-
const fromParams = { ...
|
|
2492
|
+
const fromSearch = lightweightResult.search;
|
|
2493
|
+
const fromParams = { ...lightweightResult.params };
|
|
2635
2494
|
const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
2636
2495
|
const nextParams = dest.params === false || dest.params === null ? {} : (dest.params ?? true) === true ? fromParams : Object.assign(
|
|
2637
2496
|
fromParams,
|
|
@@ -2643,14 +2502,12 @@ class RouterCore {
|
|
|
2643
2502
|
}).interpolatedPath;
|
|
2644
2503
|
const destMatchResult = this.getMatchedRoutes(interpolatedNextTo);
|
|
2645
2504
|
let destRoutes = destMatchResult.matchedRoutes;
|
|
2646
|
-
const rawParams = destMatchResult.routeParams;
|
|
2647
2505
|
const isGlobalNotFound = destMatchResult.foundRoute ? destMatchResult.foundRoute.path !== "/" && destMatchResult.routeParams["**"] : trimPathRight(interpolatedNextTo);
|
|
2648
|
-
let globalNotFoundRouteId;
|
|
2649
2506
|
if (isGlobalNotFound) {
|
|
2650
2507
|
if (this.options.notFoundRoute) {
|
|
2651
2508
|
destRoutes = [...destRoutes, this.options.notFoundRoute];
|
|
2652
2509
|
} else {
|
|
2653
|
-
|
|
2510
|
+
findGlobalNotFoundRouteId(
|
|
2654
2511
|
this.options.notFoundMode,
|
|
2655
2512
|
destRoutes
|
|
2656
2513
|
);
|
|
@@ -2672,7 +2529,7 @@ class RouterCore {
|
|
|
2672
2529
|
interpolatePath({
|
|
2673
2530
|
path: nextTo,
|
|
2674
2531
|
params: nextParams,
|
|
2675
|
-
|
|
2532
|
+
decoder: this.pathParamsDecoder
|
|
2676
2533
|
}).interpolatedPath
|
|
2677
2534
|
);
|
|
2678
2535
|
let nextSearch = fromSearch;
|
|
@@ -2706,31 +2563,34 @@ class RouterCore {
|
|
|
2706
2563
|
const hashStr = hash ? `#${hash}` : "";
|
|
2707
2564
|
let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
|
|
2708
2565
|
nextState = replaceEqualDeep(currentLocation.state, nextState);
|
|
2709
|
-
const snapshotParams = {
|
|
2710
|
-
...rawParams,
|
|
2711
|
-
...nextParams
|
|
2712
|
-
};
|
|
2713
|
-
const matchSnapshot = buildMatchSnapshotFromRoutes({
|
|
2714
|
-
routes: destRoutes,
|
|
2715
|
-
params: snapshotParams,
|
|
2716
|
-
searchStr,
|
|
2717
|
-
globalNotFoundRouteId
|
|
2718
|
-
});
|
|
2719
2566
|
const fullPath = `${nextPathname}${searchStr}${hashStr}`;
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2567
|
+
let href;
|
|
2568
|
+
let publicHref;
|
|
2569
|
+
let external = false;
|
|
2570
|
+
if (this.rewrite) {
|
|
2571
|
+
const url = new URL(fullPath, this.origin);
|
|
2572
|
+
const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
|
|
2573
|
+
href = url.href.replace(url.origin, "");
|
|
2574
|
+
if (rewrittenUrl.origin !== this.origin) {
|
|
2575
|
+
publicHref = rewrittenUrl.href;
|
|
2576
|
+
external = true;
|
|
2577
|
+
} else {
|
|
2578
|
+
publicHref = rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash;
|
|
2579
|
+
}
|
|
2580
|
+
} else {
|
|
2581
|
+
href = encodeNonAscii(fullPath);
|
|
2582
|
+
publicHref = href;
|
|
2583
|
+
}
|
|
2723
2584
|
return {
|
|
2724
|
-
publicHref
|
|
2725
|
-
href
|
|
2726
|
-
url: rewrittenUrl,
|
|
2585
|
+
publicHref,
|
|
2586
|
+
href,
|
|
2727
2587
|
pathname: nextPathname,
|
|
2728
2588
|
search: nextSearch,
|
|
2729
2589
|
searchStr,
|
|
2730
2590
|
state: nextState,
|
|
2731
2591
|
hash: hash ?? "",
|
|
2732
|
-
|
|
2733
|
-
|
|
2592
|
+
external,
|
|
2593
|
+
unmaskOnReload: dest.unmaskOnReload
|
|
2734
2594
|
};
|
|
2735
2595
|
};
|
|
2736
2596
|
const buildWithMatches = (dest = {}, maskedDest) => {
|
|
@@ -2802,73 +2662,50 @@ class RouterCore {
|
|
|
2802
2662
|
});
|
|
2803
2663
|
if (isSameUrl && isSameState()) {
|
|
2804
2664
|
this.load();
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
__TSR_key: void 0,
|
|
2831
|
-
key: void 0
|
|
2832
|
-
// TODO: Remove in v2 - use __TSR_key instead
|
|
2665
|
+
} else {
|
|
2666
|
+
let {
|
|
2667
|
+
// eslint-disable-next-line prefer-const
|
|
2668
|
+
maskedLocation,
|
|
2669
|
+
// eslint-disable-next-line prefer-const
|
|
2670
|
+
hashScrollIntoView,
|
|
2671
|
+
...nextHistory
|
|
2672
|
+
} = next;
|
|
2673
|
+
if (maskedLocation) {
|
|
2674
|
+
nextHistory = {
|
|
2675
|
+
...maskedLocation,
|
|
2676
|
+
state: {
|
|
2677
|
+
...maskedLocation.state,
|
|
2678
|
+
__tempKey: void 0,
|
|
2679
|
+
__tempLocation: {
|
|
2680
|
+
...nextHistory,
|
|
2681
|
+
search: nextHistory.searchStr,
|
|
2682
|
+
state: {
|
|
2683
|
+
...nextHistory.state,
|
|
2684
|
+
__tempKey: void 0,
|
|
2685
|
+
__tempLocation: void 0,
|
|
2686
|
+
__TSR_key: void 0,
|
|
2687
|
+
key: void 0
|
|
2688
|
+
// TODO: Remove in v2 - use __TSR_key instead
|
|
2689
|
+
}
|
|
2833
2690
|
}
|
|
2834
2691
|
}
|
|
2692
|
+
};
|
|
2693
|
+
if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
|
|
2694
|
+
nextHistory.state.__tempKey = this.tempLocationKey;
|
|
2835
2695
|
}
|
|
2836
|
-
};
|
|
2837
|
-
if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
|
|
2838
|
-
nextHistory.state.__tempKey = this.tempLocationKey;
|
|
2839
2696
|
}
|
|
2697
|
+
nextHistory.state.__hashScrollIntoViewOptions = hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true;
|
|
2698
|
+
this.shouldViewTransition = viewTransition;
|
|
2699
|
+
this.history[next.replace ? "replace" : "push"](
|
|
2700
|
+
nextHistory.publicHref,
|
|
2701
|
+
nextHistory.state,
|
|
2702
|
+
{ ignoreBlocker }
|
|
2703
|
+
);
|
|
2840
2704
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
nextHistory.state.__TSR_sessionId = this.sessionId;
|
|
2845
|
-
nextHistory.state.__TSR_matches = next._matchSnapshot ?? buildMatchSnapshot({
|
|
2846
|
-
matchResult: this.getMatchedRoutes(next.pathname),
|
|
2847
|
-
pathname: next.pathname,
|
|
2848
|
-
searchStr: next.searchStr,
|
|
2849
|
-
notFoundRoute: this.options.notFoundRoute,
|
|
2850
|
-
notFoundMode: this.options.notFoundMode
|
|
2851
|
-
});
|
|
2852
|
-
const precomputedLocation = {
|
|
2853
|
-
...next,
|
|
2854
|
-
publicHref: nextHistory.publicHref,
|
|
2855
|
-
state: nextHistory.state,
|
|
2856
|
-
maskedLocation
|
|
2857
|
-
};
|
|
2858
|
-
const result = await this.history[next.replace ? "replace" : "push"](
|
|
2859
|
-
nextHistory.publicHref,
|
|
2860
|
-
nextHistory.state,
|
|
2861
|
-
{ ignoreBlocker, skipTransitionerLoad: true }
|
|
2862
|
-
);
|
|
2863
|
-
if (result.type === "BLOCKED") {
|
|
2864
|
-
this.commitLocationPromise?.resolve();
|
|
2865
|
-
return this.commitLocationPromise;
|
|
2866
|
-
}
|
|
2867
|
-
if (this.history.location.href !== nextHistory.publicHref) {
|
|
2868
|
-
return this.commitLocationPromise;
|
|
2705
|
+
this.resetNextScroll = next.resetScroll ?? true;
|
|
2706
|
+
if (!this.history.subscribers.size) {
|
|
2707
|
+
this.load();
|
|
2869
2708
|
}
|
|
2870
|
-
this.latestLocation = precomputedLocation;
|
|
2871
|
-
this.load({ _skipUpdateLatestLocation: true });
|
|
2872
2709
|
return this.commitLocationPromise;
|
|
2873
2710
|
};
|
|
2874
2711
|
this.buildAndCommitLocation = ({
|
|
@@ -2932,8 +2769,8 @@ class RouterCore {
|
|
|
2932
2769
|
if (reloadDocument) {
|
|
2933
2770
|
if (to !== void 0 || !href) {
|
|
2934
2771
|
const location = this.buildLocation({ to, ...rest });
|
|
2935
|
-
href = href ?? location.
|
|
2936
|
-
publicHref = publicHref ?? location.
|
|
2772
|
+
href = href ?? location.publicHref;
|
|
2773
|
+
publicHref = publicHref ?? location.publicHref;
|
|
2937
2774
|
}
|
|
2938
2775
|
const reloadHref = !hrefIsUrl && publicHref ? publicHref : href;
|
|
2939
2776
|
if (isDangerousProtocol(reloadHref)) {
|
|
@@ -2970,12 +2807,10 @@ class RouterCore {
|
|
|
2970
2807
|
_isNavigate: true
|
|
2971
2808
|
});
|
|
2972
2809
|
};
|
|
2973
|
-
this.beforeLoad = (
|
|
2810
|
+
this.beforeLoad = () => {
|
|
2974
2811
|
this.cancelMatches();
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
}
|
|
2978
|
-
if (this.isServer) {
|
|
2812
|
+
this.updateLatestLocation();
|
|
2813
|
+
{
|
|
2979
2814
|
const nextLocation = this.buildLocation({
|
|
2980
2815
|
to: this.latestLocation.pathname,
|
|
2981
2816
|
search: true,
|
|
@@ -2984,13 +2819,12 @@ class RouterCore {
|
|
|
2984
2819
|
state: true,
|
|
2985
2820
|
_includeValidateSearch: true
|
|
2986
2821
|
});
|
|
2987
|
-
if (this.latestLocation.publicHref !== nextLocation.publicHref
|
|
2822
|
+
if (this.latestLocation.publicHref !== nextLocation.publicHref) {
|
|
2988
2823
|
const href = this.getParsedLocationHref(nextLocation);
|
|
2989
2824
|
throw redirect({ href });
|
|
2990
2825
|
}
|
|
2991
2826
|
}
|
|
2992
|
-
const
|
|
2993
|
-
const pendingMatches = this.matchRoutes(this.latestLocation, { snapshot });
|
|
2827
|
+
const pendingMatches = this.matchRoutes(this.latestLocation);
|
|
2994
2828
|
this.__store.setState((s) => ({
|
|
2995
2829
|
...s,
|
|
2996
2830
|
status: "pending",
|
|
@@ -3011,9 +2845,7 @@ class RouterCore {
|
|
|
3011
2845
|
loadPromise = new Promise((resolve) => {
|
|
3012
2846
|
this.startTransition(async () => {
|
|
3013
2847
|
try {
|
|
3014
|
-
this.beforeLoad(
|
|
3015
|
-
_skipUpdateLatestLocation: opts?._skipUpdateLatestLocation
|
|
3016
|
-
});
|
|
2848
|
+
this.beforeLoad();
|
|
3017
2849
|
const next = this.latestLocation;
|
|
3018
2850
|
const prevLocation = this.state.resolvedLocation;
|
|
3019
2851
|
if (!this.state.redirect) {
|
|
@@ -3098,13 +2930,6 @@ class RouterCore {
|
|
|
3098
2930
|
} catch (err) {
|
|
3099
2931
|
if (isRedirect(err)) {
|
|
3100
2932
|
redirect2 = err;
|
|
3101
|
-
if (!this.isServer) {
|
|
3102
|
-
this.navigate({
|
|
3103
|
-
...redirect2.options,
|
|
3104
|
-
replace: true,
|
|
3105
|
-
ignoreBlocker: true
|
|
3106
|
-
});
|
|
3107
|
-
}
|
|
3108
2933
|
} else if (isNotFound(err)) {
|
|
3109
2934
|
notFound = err;
|
|
3110
2935
|
}
|
|
@@ -3208,11 +3033,7 @@ class RouterCore {
|
|
|
3208
3033
|
return this.load({ sync: opts?.sync });
|
|
3209
3034
|
};
|
|
3210
3035
|
this.getParsedLocationHref = (location) => {
|
|
3211
|
-
|
|
3212
|
-
if (this.origin && location.url.origin === this.origin) {
|
|
3213
|
-
href = href.replace(this.origin, "") || "/";
|
|
3214
|
-
}
|
|
3215
|
-
return href;
|
|
3036
|
+
return location.publicHref || "/";
|
|
3216
3037
|
};
|
|
3217
3038
|
this.resolveRedirect = (redirect2) => {
|
|
3218
3039
|
const locationHeader = redirect2.headers.get("Location");
|
|
@@ -3370,7 +3191,6 @@ class RouterCore {
|
|
|
3370
3191
|
(d) => d.status === "notFound" || d.globalNotFound
|
|
3371
3192
|
);
|
|
3372
3193
|
};
|
|
3373
|
-
this.sessionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
3374
3194
|
this.update({
|
|
3375
3195
|
defaultPreloadDelay: 50,
|
|
3376
3196
|
defaultPendingMs: 1e3,
|
|
@@ -3395,61 +3215,53 @@ class RouterCore {
|
|
|
3395
3215
|
get state() {
|
|
3396
3216
|
return this.__store.state;
|
|
3397
3217
|
}
|
|
3218
|
+
setRoutes({
|
|
3219
|
+
routesById,
|
|
3220
|
+
routesByPath,
|
|
3221
|
+
processedTree
|
|
3222
|
+
}) {
|
|
3223
|
+
this.routesById = routesById;
|
|
3224
|
+
this.routesByPath = routesByPath;
|
|
3225
|
+
this.processedTree = processedTree;
|
|
3226
|
+
const notFoundRoute = this.options.notFoundRoute;
|
|
3227
|
+
if (notFoundRoute) {
|
|
3228
|
+
notFoundRoute.init({
|
|
3229
|
+
originalIndex: 99999999999
|
|
3230
|
+
});
|
|
3231
|
+
this.routesById[notFoundRoute.id] = notFoundRoute;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3398
3234
|
get looseRoutesById() {
|
|
3399
3235
|
return this.routesById;
|
|
3400
3236
|
}
|
|
3401
3237
|
matchRoutesInternal(next, opts) {
|
|
3402
|
-
const
|
|
3403
|
-
const
|
|
3404
|
-
let matchedRoutes;
|
|
3405
|
-
let
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
const { foundRoute, routeParams: rp } = matchedRoutesResult;
|
|
3418
|
-
routeParams = rp;
|
|
3419
|
-
rawParams = { ...rp };
|
|
3420
|
-
matchedRoutes = matchedRoutesResult.matchedRoutes;
|
|
3421
|
-
parsedParams = matchedRoutesResult.parsedParams;
|
|
3422
|
-
let isGlobalNotFound = false;
|
|
3423
|
-
if (
|
|
3424
|
-
// If we found a route, and it's not an index route and we have left over path
|
|
3425
|
-
foundRoute ? foundRoute.path !== "/" && routeParams["**"] : (
|
|
3426
|
-
// Or if we didn't find a route and we have left over path
|
|
3427
|
-
trimPathRight(next.pathname)
|
|
3428
|
-
)
|
|
3429
|
-
) {
|
|
3430
|
-
if (this.options.notFoundRoute) {
|
|
3431
|
-
matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
|
|
3432
|
-
} else {
|
|
3433
|
-
isGlobalNotFound = true;
|
|
3434
|
-
}
|
|
3238
|
+
const matchedRoutesResult = this.getMatchedRoutes(next.pathname);
|
|
3239
|
+
const { foundRoute, routeParams, parsedParams } = matchedRoutesResult;
|
|
3240
|
+
let { matchedRoutes } = matchedRoutesResult;
|
|
3241
|
+
let isGlobalNotFound = false;
|
|
3242
|
+
if (
|
|
3243
|
+
// If we found a route, and it's not an index route and we have left over path
|
|
3244
|
+
foundRoute ? foundRoute.path !== "/" && routeParams["**"] : (
|
|
3245
|
+
// Or if we didn't find a route and we have left over path
|
|
3246
|
+
trimPathRight(next.pathname)
|
|
3247
|
+
)
|
|
3248
|
+
) {
|
|
3249
|
+
if (this.options.notFoundRoute) {
|
|
3250
|
+
matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
|
|
3251
|
+
} else {
|
|
3252
|
+
isGlobalNotFound = true;
|
|
3435
3253
|
}
|
|
3436
|
-
globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
|
|
3437
3254
|
}
|
|
3255
|
+
const globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
|
|
3438
3256
|
const matches = [];
|
|
3439
3257
|
const getParentContext = (parentMatch) => {
|
|
3440
3258
|
const parentMatchId = parentMatch?.id;
|
|
3441
3259
|
const parentContext = !parentMatchId ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
|
|
3442
3260
|
return parentContext;
|
|
3443
3261
|
};
|
|
3444
|
-
const canUseCachedSearch = snapshotValid && snapshot.searchStr === next.searchStr && snapshot.validatedSearches?.length === matchedRoutes.length;
|
|
3445
|
-
const validatedSearchesToCache = [];
|
|
3446
3262
|
matchedRoutes.forEach((route, index) => {
|
|
3447
3263
|
const parentMatch = matches[index - 1];
|
|
3448
3264
|
const [preMatchSearch, strictMatchSearch, searchError] = (() => {
|
|
3449
|
-
if (canUseCachedSearch) {
|
|
3450
|
-
const cached = snapshot.validatedSearches[index];
|
|
3451
|
-
return [cached.search, cached.strictSearch, void 0];
|
|
3452
|
-
}
|
|
3453
3265
|
const parentSearch = parentMatch?.search ?? next.search;
|
|
3454
3266
|
const parentStrictSearch = parentMatch?._strictSearch ?? void 0;
|
|
3455
3267
|
try {
|
|
@@ -3475,12 +3287,6 @@ class RouterCore {
|
|
|
3475
3287
|
return [parentSearch, {}, searchParamError];
|
|
3476
3288
|
}
|
|
3477
3289
|
})();
|
|
3478
|
-
if (!canUseCachedSearch) {
|
|
3479
|
-
validatedSearchesToCache.push({
|
|
3480
|
-
search: preMatchSearch,
|
|
3481
|
-
strictSearch: strictMatchSearch
|
|
3482
|
-
});
|
|
3483
|
-
}
|
|
3484
3290
|
const loaderDeps = route.options.loaderDeps?.({
|
|
3485
3291
|
search: preMatchSearch
|
|
3486
3292
|
}) ?? "";
|
|
@@ -3488,7 +3294,7 @@ class RouterCore {
|
|
|
3488
3294
|
const { interpolatedPath, usedParams } = interpolatePath({
|
|
3489
3295
|
path: route.fullPath,
|
|
3490
3296
|
params: routeParams,
|
|
3491
|
-
|
|
3297
|
+
decoder: this.pathParamsDecoder
|
|
3492
3298
|
});
|
|
3493
3299
|
const matchId = (
|
|
3494
3300
|
// route.id for disambiguation
|
|
@@ -3503,32 +3309,18 @@ class RouterCore {
|
|
|
3503
3309
|
const strictParams = existingMatch?._strictParams ?? usedParams;
|
|
3504
3310
|
let paramsError = void 0;
|
|
3505
3311
|
if (!existingMatch) {
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3312
|
+
try {
|
|
3313
|
+
extractStrictParams(route, usedParams, parsedParams, strictParams);
|
|
3314
|
+
} catch (err) {
|
|
3315
|
+
if (isNotFound(err) || isRedirect(err)) {
|
|
3316
|
+
paramsError = err;
|
|
3317
|
+
} else {
|
|
3318
|
+
paramsError = new PathParamError(err.message, {
|
|
3319
|
+
cause: err
|
|
3320
|
+
});
|
|
3511
3321
|
}
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
if (strictParseParams) {
|
|
3515
|
-
try {
|
|
3516
|
-
Object.assign(
|
|
3517
|
-
strictParams,
|
|
3518
|
-
strictParseParams(strictParams)
|
|
3519
|
-
);
|
|
3520
|
-
} catch (err) {
|
|
3521
|
-
if (isNotFound(err) || isRedirect(err)) {
|
|
3522
|
-
paramsError = err;
|
|
3523
|
-
} else {
|
|
3524
|
-
paramsError = new PathParamError(err.message, {
|
|
3525
|
-
cause: err
|
|
3526
|
-
});
|
|
3527
|
-
}
|
|
3528
|
-
if (opts?.throwOnError) {
|
|
3529
|
-
throw paramsError;
|
|
3530
|
-
}
|
|
3531
|
-
}
|
|
3322
|
+
if (opts?.throwOnError) {
|
|
3323
|
+
throw paramsError;
|
|
3532
3324
|
}
|
|
3533
3325
|
}
|
|
3534
3326
|
}
|
|
@@ -3548,7 +3340,7 @@ class RouterCore {
|
|
|
3548
3340
|
const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
|
|
3549
3341
|
match = {
|
|
3550
3342
|
id: matchId,
|
|
3551
|
-
ssr:
|
|
3343
|
+
ssr: void 0,
|
|
3552
3344
|
index,
|
|
3553
3345
|
routeId: route.id,
|
|
3554
3346
|
params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
@@ -3594,17 +3386,10 @@ class RouterCore {
|
|
|
3594
3386
|
};
|
|
3595
3387
|
matches.push(match);
|
|
3596
3388
|
});
|
|
3597
|
-
if (!canUseCachedSearch && validatedSearchesToCache.length > 0) {
|
|
3598
|
-
const existingSnapshot = next.state?.__TSR_matches;
|
|
3599
|
-
if (existingSnapshot) {
|
|
3600
|
-
existingSnapshot.searchStr = next.searchStr;
|
|
3601
|
-
existingSnapshot.validatedSearches = validatedSearchesToCache;
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
3389
|
matches.forEach((match, index) => {
|
|
3605
3390
|
const route = this.looseRoutesById[match.routeId];
|
|
3606
3391
|
const existingMatch = this.getMatch(match.id);
|
|
3607
|
-
if (!existingMatch
|
|
3392
|
+
if (!existingMatch) {
|
|
3608
3393
|
const parentMatch = matches[index - 1];
|
|
3609
3394
|
const parentContext = getParentContext(parentMatch);
|
|
3610
3395
|
if (route.options.context) {
|
|
@@ -3629,7 +3414,54 @@ class RouterCore {
|
|
|
3629
3414
|
};
|
|
3630
3415
|
}
|
|
3631
3416
|
});
|
|
3632
|
-
return
|
|
3417
|
+
return matches;
|
|
3418
|
+
}
|
|
3419
|
+
/**
|
|
3420
|
+
* Lightweight route matching for buildLocation.
|
|
3421
|
+
* Only computes fullPath, accumulated search, and params - skipping expensive
|
|
3422
|
+
* operations like AbortController, ControlledPromise, loaderDeps, and full match objects.
|
|
3423
|
+
*/
|
|
3424
|
+
matchRoutesLightweight(location) {
|
|
3425
|
+
const { matchedRoutes, routeParams, parsedParams } = this.getMatchedRoutes(
|
|
3426
|
+
location.pathname
|
|
3427
|
+
);
|
|
3428
|
+
const lastRoute = last(matchedRoutes);
|
|
3429
|
+
const accumulatedSearch = { ...location.search };
|
|
3430
|
+
for (const route of matchedRoutes) {
|
|
3431
|
+
try {
|
|
3432
|
+
Object.assign(
|
|
3433
|
+
accumulatedSearch,
|
|
3434
|
+
validateSearch(route.options.validateSearch, accumulatedSearch)
|
|
3435
|
+
);
|
|
3436
|
+
} catch {
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
const lastStateMatch = last(this.state.matches);
|
|
3440
|
+
const canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && location.pathname === this.state.location.pathname;
|
|
3441
|
+
let params;
|
|
3442
|
+
if (canReuseParams) {
|
|
3443
|
+
params = lastStateMatch.params;
|
|
3444
|
+
} else {
|
|
3445
|
+
const strictParams = { ...routeParams };
|
|
3446
|
+
for (const route of matchedRoutes) {
|
|
3447
|
+
try {
|
|
3448
|
+
extractStrictParams(
|
|
3449
|
+
route,
|
|
3450
|
+
routeParams,
|
|
3451
|
+
parsedParams ?? {},
|
|
3452
|
+
strictParams
|
|
3453
|
+
);
|
|
3454
|
+
} catch {
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
params = strictParams;
|
|
3458
|
+
}
|
|
3459
|
+
return {
|
|
3460
|
+
matchedRoutes,
|
|
3461
|
+
fullPath: lastRoute.fullPath,
|
|
3462
|
+
search: accumulatedSearch,
|
|
3463
|
+
params
|
|
3464
|
+
};
|
|
3633
3465
|
}
|
|
3634
3466
|
}
|
|
3635
3467
|
class SearchParamError extends Error {
|
|
@@ -3678,7 +3510,7 @@ function getMatchedRoutes({
|
|
|
3678
3510
|
const routeParams = {};
|
|
3679
3511
|
const trimmedPath = trimPathRight(pathname);
|
|
3680
3512
|
let foundRoute = void 0;
|
|
3681
|
-
let parsedParams =
|
|
3513
|
+
let parsedParams = void 0;
|
|
3682
3514
|
const match = findRouteMatch(trimmedPath, processedTree, true);
|
|
3683
3515
|
if (match) {
|
|
3684
3516
|
foundRoute = match.route;
|
|
@@ -3688,64 +3520,6 @@ function getMatchedRoutes({
|
|
|
3688
3520
|
const matchedRoutes = match?.branch || [routesById[rootRouteId]];
|
|
3689
3521
|
return { matchedRoutes, routeParams, foundRoute, parsedParams };
|
|
3690
3522
|
}
|
|
3691
|
-
function buildMatchSnapshot({
|
|
3692
|
-
matchResult,
|
|
3693
|
-
pathname,
|
|
3694
|
-
searchStr,
|
|
3695
|
-
notFoundRoute,
|
|
3696
|
-
notFoundMode
|
|
3697
|
-
}) {
|
|
3698
|
-
const snapshot = {
|
|
3699
|
-
routeIds: matchResult.matchedRoutes.map((r) => r.id),
|
|
3700
|
-
params: matchResult.routeParams,
|
|
3701
|
-
parsedParams: matchResult.parsedParams,
|
|
3702
|
-
searchStr
|
|
3703
|
-
};
|
|
3704
|
-
const isGlobalNotFound = matchResult.foundRoute ? matchResult.foundRoute.path !== "/" && matchResult.routeParams["**"] : trimPathRight(pathname);
|
|
3705
|
-
if (isGlobalNotFound) {
|
|
3706
|
-
if (notFoundRoute) {
|
|
3707
|
-
snapshot.globalNotFoundRouteId = notFoundRoute.id;
|
|
3708
|
-
} else {
|
|
3709
|
-
if (notFoundMode !== "root") {
|
|
3710
|
-
for (let i = matchResult.matchedRoutes.length - 1; i >= 0; i--) {
|
|
3711
|
-
const route = matchResult.matchedRoutes[i];
|
|
3712
|
-
if (route.children) {
|
|
3713
|
-
snapshot.globalNotFoundRouteId = route.id;
|
|
3714
|
-
break;
|
|
3715
|
-
}
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
if (!snapshot.globalNotFoundRouteId) {
|
|
3719
|
-
snapshot.globalNotFoundRouteId = rootRouteId;
|
|
3720
|
-
}
|
|
3721
|
-
}
|
|
3722
|
-
}
|
|
3723
|
-
return snapshot;
|
|
3724
|
-
}
|
|
3725
|
-
function buildMatchSnapshotFromRoutes({
|
|
3726
|
-
routes,
|
|
3727
|
-
params,
|
|
3728
|
-
searchStr,
|
|
3729
|
-
globalNotFoundRouteId
|
|
3730
|
-
}) {
|
|
3731
|
-
const stringParams = {};
|
|
3732
|
-
for (const key in params) {
|
|
3733
|
-
const value = params[key];
|
|
3734
|
-
if (value != null) {
|
|
3735
|
-
stringParams[key] = String(value);
|
|
3736
|
-
}
|
|
3737
|
-
}
|
|
3738
|
-
const snapshot = {
|
|
3739
|
-
routeIds: routes.map((r) => r.id),
|
|
3740
|
-
params: stringParams,
|
|
3741
|
-
parsedParams: params,
|
|
3742
|
-
searchStr
|
|
3743
|
-
};
|
|
3744
|
-
if (globalNotFoundRouteId) {
|
|
3745
|
-
snapshot.globalNotFoundRouteId = globalNotFoundRouteId;
|
|
3746
|
-
}
|
|
3747
|
-
return snapshot;
|
|
3748
|
-
}
|
|
3749
3523
|
function applySearchMiddleware({
|
|
3750
3524
|
search,
|
|
3751
3525
|
dest,
|
|
@@ -3841,7 +3615,21 @@ function findGlobalNotFoundRouteId(notFoundMode, routes) {
|
|
|
3841
3615
|
}
|
|
3842
3616
|
return rootRouteId;
|
|
3843
3617
|
}
|
|
3844
|
-
|
|
3618
|
+
function extractStrictParams(route, referenceParams, parsedParams, accumulatedParams) {
|
|
3619
|
+
const parseParams = route.options.params?.parse ?? route.options.parseParams;
|
|
3620
|
+
if (parseParams) {
|
|
3621
|
+
if (route.options.skipRouteOnParseError) {
|
|
3622
|
+
for (const key in referenceParams) {
|
|
3623
|
+
if (key in parsedParams) {
|
|
3624
|
+
accumulatedParams[key] = parsedParams[key];
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
} else {
|
|
3628
|
+
const result = parseParams(accumulatedParams);
|
|
3629
|
+
Object.assign(accumulatedParams, result);
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3845
3633
|
class BaseRoute {
|
|
3846
3634
|
constructor(options) {
|
|
3847
3635
|
this.init = (opts) => {
|
|
@@ -3929,620 +3717,7 @@ class BaseRootRoute extends BaseRoute {
|
|
|
3929
3717
|
super(options);
|
|
3930
3718
|
}
|
|
3931
3719
|
}
|
|
3932
|
-
const GLOBAL_TSR = "$_TSR";
|
|
3933
3720
|
const TSR_SCRIPT_BARRIER_ID = "$tsr-stream-barrier";
|
|
3934
|
-
function createSerializationAdapter(opts) {
|
|
3935
|
-
return opts;
|
|
3936
|
-
}
|
|
3937
|
-
function makeSsrSerovalPlugin(serializationAdapter, options) {
|
|
3938
|
-
return ni({
|
|
3939
|
-
tag: "$TSR/t/" + serializationAdapter.key,
|
|
3940
|
-
test: serializationAdapter.test,
|
|
3941
|
-
parse: {
|
|
3942
|
-
stream(value, ctx) {
|
|
3943
|
-
return ctx.parse(serializationAdapter.toSerializable(value));
|
|
3944
|
-
}
|
|
3945
|
-
},
|
|
3946
|
-
serialize(node, ctx) {
|
|
3947
|
-
options.didRun = true;
|
|
3948
|
-
return GLOBAL_TSR + '.t.get("' + serializationAdapter.key + '")(' + ctx.serialize(node) + ")";
|
|
3949
|
-
},
|
|
3950
|
-
// we never deserialize on the server during SSR
|
|
3951
|
-
deserialize: void 0
|
|
3952
|
-
});
|
|
3953
|
-
}
|
|
3954
|
-
function makeSerovalPlugin(serializationAdapter) {
|
|
3955
|
-
return ni({
|
|
3956
|
-
tag: "$TSR/t/" + serializationAdapter.key,
|
|
3957
|
-
test: serializationAdapter.test,
|
|
3958
|
-
parse: {
|
|
3959
|
-
sync(value, ctx) {
|
|
3960
|
-
return ctx.parse(serializationAdapter.toSerializable(value));
|
|
3961
|
-
},
|
|
3962
|
-
async async(value, ctx) {
|
|
3963
|
-
return await ctx.parse(serializationAdapter.toSerializable(value));
|
|
3964
|
-
},
|
|
3965
|
-
stream(value, ctx) {
|
|
3966
|
-
return ctx.parse(serializationAdapter.toSerializable(value));
|
|
3967
|
-
}
|
|
3968
|
-
},
|
|
3969
|
-
// we don't generate JS code outside of SSR (for now)
|
|
3970
|
-
serialize: void 0,
|
|
3971
|
-
deserialize(node, ctx) {
|
|
3972
|
-
return serializationAdapter.fromSerializable(ctx.deserialize(node));
|
|
3973
|
-
}
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
|
-
const ShallowErrorPlugin = /* @__PURE__ */ ni({
|
|
3977
|
-
tag: "$TSR/Error",
|
|
3978
|
-
test(value) {
|
|
3979
|
-
return value instanceof Error;
|
|
3980
|
-
},
|
|
3981
|
-
parse: {
|
|
3982
|
-
sync(value, ctx) {
|
|
3983
|
-
return {
|
|
3984
|
-
message: ctx.parse(value.message)
|
|
3985
|
-
};
|
|
3986
|
-
},
|
|
3987
|
-
async async(value, ctx) {
|
|
3988
|
-
return {
|
|
3989
|
-
message: await ctx.parse(value.message)
|
|
3990
|
-
};
|
|
3991
|
-
},
|
|
3992
|
-
stream(value, ctx) {
|
|
3993
|
-
return {
|
|
3994
|
-
message: ctx.parse(value.message)
|
|
3995
|
-
};
|
|
3996
|
-
}
|
|
3997
|
-
},
|
|
3998
|
-
serialize(node, ctx) {
|
|
3999
|
-
return "new Error(" + ctx.serialize(node.message) + ")";
|
|
4000
|
-
},
|
|
4001
|
-
deserialize(node, ctx) {
|
|
4002
|
-
return new Error(ctx.deserialize(node.message));
|
|
4003
|
-
}
|
|
4004
|
-
});
|
|
4005
|
-
class RawStream {
|
|
4006
|
-
constructor(stream, options) {
|
|
4007
|
-
this.stream = stream;
|
|
4008
|
-
this.hint = options?.hint ?? "binary";
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4011
|
-
const BufferCtor = globalThis.Buffer;
|
|
4012
|
-
const hasNodeBuffer = !!BufferCtor && typeof BufferCtor.from === "function";
|
|
4013
|
-
function uint8ArrayToBase64(bytes) {
|
|
4014
|
-
if (bytes.length === 0) return "";
|
|
4015
|
-
if (hasNodeBuffer) {
|
|
4016
|
-
return BufferCtor.from(bytes).toString("base64");
|
|
4017
|
-
}
|
|
4018
|
-
const CHUNK_SIZE = 32768;
|
|
4019
|
-
const chunks = [];
|
|
4020
|
-
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
4021
|
-
const chunk = bytes.subarray(i, i + CHUNK_SIZE);
|
|
4022
|
-
chunks.push(String.fromCharCode.apply(null, chunk));
|
|
4023
|
-
}
|
|
4024
|
-
return btoa(chunks.join(""));
|
|
4025
|
-
}
|
|
4026
|
-
function base64ToUint8Array(base64) {
|
|
4027
|
-
if (base64.length === 0) return new Uint8Array(0);
|
|
4028
|
-
if (hasNodeBuffer) {
|
|
4029
|
-
const buf = BufferCtor.from(base64, "base64");
|
|
4030
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
4031
|
-
}
|
|
4032
|
-
const binary = atob(base64);
|
|
4033
|
-
const bytes = new Uint8Array(binary.length);
|
|
4034
|
-
for (let i = 0; i < binary.length; i++) {
|
|
4035
|
-
bytes[i] = binary.charCodeAt(i);
|
|
4036
|
-
}
|
|
4037
|
-
return bytes;
|
|
4038
|
-
}
|
|
4039
|
-
const RAW_STREAM_FACTORY_BINARY = /* @__PURE__ */ Object.create(null);
|
|
4040
|
-
const RAW_STREAM_FACTORY_TEXT = /* @__PURE__ */ Object.create(null);
|
|
4041
|
-
const RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY = (stream) => new ReadableStream({
|
|
4042
|
-
start(controller) {
|
|
4043
|
-
stream.on({
|
|
4044
|
-
next(base64) {
|
|
4045
|
-
try {
|
|
4046
|
-
controller.enqueue(base64ToUint8Array(base64));
|
|
4047
|
-
} catch {
|
|
4048
|
-
}
|
|
4049
|
-
},
|
|
4050
|
-
throw(error) {
|
|
4051
|
-
controller.error(error);
|
|
4052
|
-
},
|
|
4053
|
-
return() {
|
|
4054
|
-
try {
|
|
4055
|
-
controller.close();
|
|
4056
|
-
} catch {
|
|
4057
|
-
}
|
|
4058
|
-
}
|
|
4059
|
-
});
|
|
4060
|
-
}
|
|
4061
|
-
});
|
|
4062
|
-
const textEncoderForFactory = new TextEncoder();
|
|
4063
|
-
const RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT = (stream) => {
|
|
4064
|
-
return new ReadableStream({
|
|
4065
|
-
start(controller) {
|
|
4066
|
-
stream.on({
|
|
4067
|
-
next(value) {
|
|
4068
|
-
try {
|
|
4069
|
-
if (typeof value === "string") {
|
|
4070
|
-
controller.enqueue(textEncoderForFactory.encode(value));
|
|
4071
|
-
} else {
|
|
4072
|
-
controller.enqueue(base64ToUint8Array(value.$b64));
|
|
4073
|
-
}
|
|
4074
|
-
} catch {
|
|
4075
|
-
}
|
|
4076
|
-
},
|
|
4077
|
-
throw(error) {
|
|
4078
|
-
controller.error(error);
|
|
4079
|
-
},
|
|
4080
|
-
return() {
|
|
4081
|
-
try {
|
|
4082
|
-
controller.close();
|
|
4083
|
-
} catch {
|
|
4084
|
-
}
|
|
4085
|
-
}
|
|
4086
|
-
});
|
|
4087
|
-
}
|
|
4088
|
-
});
|
|
4089
|
-
};
|
|
4090
|
-
const FACTORY_BINARY = `(s=>new ReadableStream({start(c){s.on({next(b){try{const d=atob(b),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}catch(_){}},throw(e){c.error(e)},return(){try{c.close()}catch(_){}}})}}))`;
|
|
4091
|
-
const FACTORY_TEXT = `(s=>{const e=new TextEncoder();return new ReadableStream({start(c){s.on({next(v){try{if(typeof v==='string'){c.enqueue(e.encode(v))}else{const d=atob(v.$b64),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}}catch(_){}},throw(x){c.error(x)},return(){try{c.close()}catch(_){}}})}})})`;
|
|
4092
|
-
function toBinaryStream(readable) {
|
|
4093
|
-
const stream = te();
|
|
4094
|
-
const reader = readable.getReader();
|
|
4095
|
-
(async () => {
|
|
4096
|
-
try {
|
|
4097
|
-
while (true) {
|
|
4098
|
-
const { done, value } = await reader.read();
|
|
4099
|
-
if (done) {
|
|
4100
|
-
stream.return(void 0);
|
|
4101
|
-
break;
|
|
4102
|
-
}
|
|
4103
|
-
stream.next(uint8ArrayToBase64(value));
|
|
4104
|
-
}
|
|
4105
|
-
} catch (error) {
|
|
4106
|
-
stream.throw(error);
|
|
4107
|
-
} finally {
|
|
4108
|
-
reader.releaseLock();
|
|
4109
|
-
}
|
|
4110
|
-
})();
|
|
4111
|
-
return stream;
|
|
4112
|
-
}
|
|
4113
|
-
function toTextStream(readable) {
|
|
4114
|
-
const stream = te();
|
|
4115
|
-
const reader = readable.getReader();
|
|
4116
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
4117
|
-
(async () => {
|
|
4118
|
-
try {
|
|
4119
|
-
while (true) {
|
|
4120
|
-
const { done, value } = await reader.read();
|
|
4121
|
-
if (done) {
|
|
4122
|
-
try {
|
|
4123
|
-
const remaining = decoder.decode();
|
|
4124
|
-
if (remaining.length > 0) {
|
|
4125
|
-
stream.next(remaining);
|
|
4126
|
-
}
|
|
4127
|
-
} catch {
|
|
4128
|
-
}
|
|
4129
|
-
stream.return(void 0);
|
|
4130
|
-
break;
|
|
4131
|
-
}
|
|
4132
|
-
try {
|
|
4133
|
-
const text = decoder.decode(value, { stream: true });
|
|
4134
|
-
if (text.length > 0) {
|
|
4135
|
-
stream.next(text);
|
|
4136
|
-
}
|
|
4137
|
-
} catch {
|
|
4138
|
-
stream.next({ $b64: uint8ArrayToBase64(value) });
|
|
4139
|
-
}
|
|
4140
|
-
}
|
|
4141
|
-
} catch (error) {
|
|
4142
|
-
stream.throw(error);
|
|
4143
|
-
} finally {
|
|
4144
|
-
reader.releaseLock();
|
|
4145
|
-
}
|
|
4146
|
-
})();
|
|
4147
|
-
return stream;
|
|
4148
|
-
}
|
|
4149
|
-
const RawStreamFactoryBinaryPlugin = ni({
|
|
4150
|
-
tag: "tss/RawStreamFactory",
|
|
4151
|
-
test(value) {
|
|
4152
|
-
return value === RAW_STREAM_FACTORY_BINARY;
|
|
4153
|
-
},
|
|
4154
|
-
parse: {
|
|
4155
|
-
sync() {
|
|
4156
|
-
return void 0;
|
|
4157
|
-
},
|
|
4158
|
-
async() {
|
|
4159
|
-
return Promise.resolve(void 0);
|
|
4160
|
-
},
|
|
4161
|
-
stream() {
|
|
4162
|
-
return void 0;
|
|
4163
|
-
}
|
|
4164
|
-
},
|
|
4165
|
-
serialize() {
|
|
4166
|
-
return FACTORY_BINARY;
|
|
4167
|
-
},
|
|
4168
|
-
deserialize() {
|
|
4169
|
-
return RAW_STREAM_FACTORY_BINARY;
|
|
4170
|
-
}
|
|
4171
|
-
});
|
|
4172
|
-
const RawStreamFactoryTextPlugin = ni({
|
|
4173
|
-
tag: "tss/RawStreamFactoryText",
|
|
4174
|
-
test(value) {
|
|
4175
|
-
return value === RAW_STREAM_FACTORY_TEXT;
|
|
4176
|
-
},
|
|
4177
|
-
parse: {
|
|
4178
|
-
sync() {
|
|
4179
|
-
return void 0;
|
|
4180
|
-
},
|
|
4181
|
-
async() {
|
|
4182
|
-
return Promise.resolve(void 0);
|
|
4183
|
-
},
|
|
4184
|
-
stream() {
|
|
4185
|
-
return void 0;
|
|
4186
|
-
}
|
|
4187
|
-
},
|
|
4188
|
-
serialize() {
|
|
4189
|
-
return FACTORY_TEXT;
|
|
4190
|
-
},
|
|
4191
|
-
deserialize() {
|
|
4192
|
-
return RAW_STREAM_FACTORY_TEXT;
|
|
4193
|
-
}
|
|
4194
|
-
});
|
|
4195
|
-
const RawStreamSSRPlugin = ni({
|
|
4196
|
-
tag: "tss/RawStream",
|
|
4197
|
-
extends: [RawStreamFactoryBinaryPlugin, RawStreamFactoryTextPlugin],
|
|
4198
|
-
test(value) {
|
|
4199
|
-
return value instanceof RawStream;
|
|
4200
|
-
},
|
|
4201
|
-
parse: {
|
|
4202
|
-
sync(value, ctx) {
|
|
4203
|
-
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
4204
|
-
return {
|
|
4205
|
-
hint: value.hint,
|
|
4206
|
-
factory: ctx.parse(factory),
|
|
4207
|
-
stream: ctx.parse(te())
|
|
4208
|
-
};
|
|
4209
|
-
},
|
|
4210
|
-
async async(value, ctx) {
|
|
4211
|
-
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
4212
|
-
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
4213
|
-
return {
|
|
4214
|
-
hint: value.hint,
|
|
4215
|
-
factory: await ctx.parse(factory),
|
|
4216
|
-
stream: await ctx.parse(encodedStream)
|
|
4217
|
-
};
|
|
4218
|
-
},
|
|
4219
|
-
stream(value, ctx) {
|
|
4220
|
-
const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
|
|
4221
|
-
const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
|
|
4222
|
-
return {
|
|
4223
|
-
hint: value.hint,
|
|
4224
|
-
factory: ctx.parse(factory),
|
|
4225
|
-
stream: ctx.parse(encodedStream)
|
|
4226
|
-
};
|
|
4227
|
-
}
|
|
4228
|
-
},
|
|
4229
|
-
serialize(node, ctx) {
|
|
4230
|
-
return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
|
|
4231
|
-
},
|
|
4232
|
-
deserialize(node, ctx) {
|
|
4233
|
-
const stream = ctx.deserialize(node.stream);
|
|
4234
|
-
return node.hint === "text" ? RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT(stream) : RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY(stream);
|
|
4235
|
-
}
|
|
4236
|
-
});
|
|
4237
|
-
function createRawStreamRPCPlugin(onRawStream) {
|
|
4238
|
-
let nextStreamId = 1;
|
|
4239
|
-
return ni({
|
|
4240
|
-
tag: "tss/RawStream",
|
|
4241
|
-
test(value) {
|
|
4242
|
-
return value instanceof RawStream;
|
|
4243
|
-
},
|
|
4244
|
-
parse: {
|
|
4245
|
-
async(value) {
|
|
4246
|
-
const streamId = nextStreamId++;
|
|
4247
|
-
onRawStream(streamId, value.stream);
|
|
4248
|
-
return Promise.resolve({ streamId });
|
|
4249
|
-
},
|
|
4250
|
-
stream(value) {
|
|
4251
|
-
const streamId = nextStreamId++;
|
|
4252
|
-
onRawStream(streamId, value.stream);
|
|
4253
|
-
return { streamId };
|
|
4254
|
-
}
|
|
4255
|
-
},
|
|
4256
|
-
serialize() {
|
|
4257
|
-
throw new Error(
|
|
4258
|
-
"RawStreamRPCPlugin.serialize should not be called. RPC uses JSON serialization, not JS code generation."
|
|
4259
|
-
);
|
|
4260
|
-
},
|
|
4261
|
-
deserialize() {
|
|
4262
|
-
throw new Error(
|
|
4263
|
-
"RawStreamRPCPlugin.deserialize should not be called. Use createRawStreamDeserializePlugin on client."
|
|
4264
|
-
);
|
|
4265
|
-
}
|
|
4266
|
-
});
|
|
4267
|
-
}
|
|
4268
|
-
const defaultSerovalPlugins = [
|
|
4269
|
-
ShallowErrorPlugin,
|
|
4270
|
-
// RawStreamSSRPlugin must come before ReadableStreamPlugin to match first
|
|
4271
|
-
RawStreamSSRPlugin,
|
|
4272
|
-
// ReadableStreamNode is not exported by seroval
|
|
4273
|
-
p
|
|
4274
|
-
];
|
|
4275
|
-
const minifiedTsrBootStrapScript = "self.$_TSR={h(){this.hydrated=!0,this.c()},e(){this.streamEnded=!0,this.c()},c(){this.hydrated&&this.streamEnded&&(delete self.$_TSR,delete self.$R.tsr)},p(e){this.initialized?e():this.buffer.push(e)},buffer:[]};\n";
|
|
4276
|
-
const SCOPE_ID = "tsr";
|
|
4277
|
-
function dehydrateMatch(match) {
|
|
4278
|
-
const dehydratedMatch = {
|
|
4279
|
-
i: match.id,
|
|
4280
|
-
u: match.updatedAt,
|
|
4281
|
-
s: match.status
|
|
4282
|
-
};
|
|
4283
|
-
const properties = [
|
|
4284
|
-
["__beforeLoadContext", "b"],
|
|
4285
|
-
["loaderData", "l"],
|
|
4286
|
-
["error", "e"],
|
|
4287
|
-
["ssr", "ssr"]
|
|
4288
|
-
];
|
|
4289
|
-
for (const [key, shorthand] of properties) {
|
|
4290
|
-
if (match[key] !== void 0) {
|
|
4291
|
-
dehydratedMatch[shorthand] = match[key];
|
|
4292
|
-
}
|
|
4293
|
-
}
|
|
4294
|
-
return dehydratedMatch;
|
|
4295
|
-
}
|
|
4296
|
-
const INITIAL_SCRIPTS = [
|
|
4297
|
-
mn(SCOPE_ID),
|
|
4298
|
-
minifiedTsrBootStrapScript
|
|
4299
|
-
];
|
|
4300
|
-
class ScriptBuffer {
|
|
4301
|
-
constructor(router) {
|
|
4302
|
-
this._scriptBarrierLifted = false;
|
|
4303
|
-
this._cleanedUp = false;
|
|
4304
|
-
this._pendingMicrotask = false;
|
|
4305
|
-
this.router = router;
|
|
4306
|
-
this._queue = INITIAL_SCRIPTS.slice();
|
|
4307
|
-
}
|
|
4308
|
-
enqueue(script) {
|
|
4309
|
-
if (this._cleanedUp) return;
|
|
4310
|
-
this._queue.push(script);
|
|
4311
|
-
if (this._scriptBarrierLifted && !this._pendingMicrotask) {
|
|
4312
|
-
this._pendingMicrotask = true;
|
|
4313
|
-
queueMicrotask(() => {
|
|
4314
|
-
this._pendingMicrotask = false;
|
|
4315
|
-
this.injectBufferedScripts();
|
|
4316
|
-
});
|
|
4317
|
-
}
|
|
4318
|
-
}
|
|
4319
|
-
liftBarrier() {
|
|
4320
|
-
if (this._scriptBarrierLifted || this._cleanedUp) return;
|
|
4321
|
-
this._scriptBarrierLifted = true;
|
|
4322
|
-
if (this._queue.length > 0 && !this._pendingMicrotask) {
|
|
4323
|
-
this._pendingMicrotask = true;
|
|
4324
|
-
queueMicrotask(() => {
|
|
4325
|
-
this._pendingMicrotask = false;
|
|
4326
|
-
this.injectBufferedScripts();
|
|
4327
|
-
});
|
|
4328
|
-
}
|
|
4329
|
-
}
|
|
4330
|
-
/**
|
|
4331
|
-
* Flushes any pending scripts synchronously.
|
|
4332
|
-
* Call this before emitting onSerializationFinished to ensure all scripts are injected.
|
|
4333
|
-
*
|
|
4334
|
-
* IMPORTANT: Only injects if the barrier has been lifted. Before the barrier is lifted,
|
|
4335
|
-
* scripts should remain in the queue so takeBufferedScripts() can retrieve them
|
|
4336
|
-
*/
|
|
4337
|
-
flush() {
|
|
4338
|
-
if (!this._scriptBarrierLifted) return;
|
|
4339
|
-
if (this._cleanedUp) return;
|
|
4340
|
-
this._pendingMicrotask = false;
|
|
4341
|
-
const scriptsToInject = this.takeAll();
|
|
4342
|
-
if (scriptsToInject && this.router?.serverSsr) {
|
|
4343
|
-
this.router.serverSsr.injectScript(scriptsToInject);
|
|
4344
|
-
}
|
|
4345
|
-
}
|
|
4346
|
-
takeAll() {
|
|
4347
|
-
const bufferedScripts = this._queue;
|
|
4348
|
-
this._queue = [];
|
|
4349
|
-
if (bufferedScripts.length === 0) {
|
|
4350
|
-
return void 0;
|
|
4351
|
-
}
|
|
4352
|
-
return bufferedScripts.join(";") + ";document.currentScript.remove()";
|
|
4353
|
-
}
|
|
4354
|
-
injectBufferedScripts() {
|
|
4355
|
-
if (this._cleanedUp) return;
|
|
4356
|
-
if (this._queue.length === 0) return;
|
|
4357
|
-
const scriptsToInject = this.takeAll();
|
|
4358
|
-
if (scriptsToInject && this.router?.serverSsr) {
|
|
4359
|
-
this.router.serverSsr.injectScript(scriptsToInject);
|
|
4360
|
-
}
|
|
4361
|
-
}
|
|
4362
|
-
cleanup() {
|
|
4363
|
-
this._cleanedUp = true;
|
|
4364
|
-
this._queue = [];
|
|
4365
|
-
this.router = void 0;
|
|
4366
|
-
}
|
|
4367
|
-
}
|
|
4368
|
-
function attachRouterServerSsrUtils({
|
|
4369
|
-
router,
|
|
4370
|
-
manifest
|
|
4371
|
-
}) {
|
|
4372
|
-
router.ssr = {
|
|
4373
|
-
manifest
|
|
4374
|
-
};
|
|
4375
|
-
let _dehydrated = false;
|
|
4376
|
-
let _serializationFinished = false;
|
|
4377
|
-
const renderFinishedListeners = [];
|
|
4378
|
-
const serializationFinishedListeners = [];
|
|
4379
|
-
const scriptBuffer = new ScriptBuffer(router);
|
|
4380
|
-
let injectedHtmlBuffer = [];
|
|
4381
|
-
router.serverSsr = {
|
|
4382
|
-
injectHtml: (html) => {
|
|
4383
|
-
if (!html) return;
|
|
4384
|
-
injectedHtmlBuffer.push(html);
|
|
4385
|
-
router.emit({
|
|
4386
|
-
type: "onInjectedHtml"
|
|
4387
|
-
});
|
|
4388
|
-
},
|
|
4389
|
-
injectScript: (script) => {
|
|
4390
|
-
if (!script) return;
|
|
4391
|
-
const html = `<script${router.options.ssr?.nonce ? ` nonce='${router.options.ssr.nonce}'` : ""}>${script}<\/script>`;
|
|
4392
|
-
router.serverSsr.injectHtml(html);
|
|
4393
|
-
},
|
|
4394
|
-
dehydrate: async () => {
|
|
4395
|
-
invariant(!_dehydrated);
|
|
4396
|
-
let matchesToDehydrate = router.state.matches;
|
|
4397
|
-
if (router.isShell()) {
|
|
4398
|
-
matchesToDehydrate = matchesToDehydrate.slice(0, 1);
|
|
4399
|
-
}
|
|
4400
|
-
const matches = matchesToDehydrate.map(dehydrateMatch);
|
|
4401
|
-
let manifestToDehydrate = void 0;
|
|
4402
|
-
if (manifest) {
|
|
4403
|
-
const currentRouteIds = new Set(
|
|
4404
|
-
router.state.matches.map((k) => k.routeId)
|
|
4405
|
-
);
|
|
4406
|
-
const filteredRoutes = Object.fromEntries(
|
|
4407
|
-
Object.entries(manifest.routes).flatMap(
|
|
4408
|
-
([routeId, routeManifest]) => {
|
|
4409
|
-
if (currentRouteIds.has(routeId)) {
|
|
4410
|
-
return [[routeId, routeManifest]];
|
|
4411
|
-
} else if (routeManifest.assets && routeManifest.assets.length > 0) {
|
|
4412
|
-
return [
|
|
4413
|
-
[
|
|
4414
|
-
routeId,
|
|
4415
|
-
{
|
|
4416
|
-
assets: routeManifest.assets
|
|
4417
|
-
}
|
|
4418
|
-
]
|
|
4419
|
-
];
|
|
4420
|
-
}
|
|
4421
|
-
return [];
|
|
4422
|
-
}
|
|
4423
|
-
)
|
|
4424
|
-
);
|
|
4425
|
-
manifestToDehydrate = {
|
|
4426
|
-
routes: filteredRoutes
|
|
4427
|
-
};
|
|
4428
|
-
}
|
|
4429
|
-
const dehydratedRouter = {
|
|
4430
|
-
manifest: manifestToDehydrate,
|
|
4431
|
-
matches
|
|
4432
|
-
};
|
|
4433
|
-
const lastMatchId = matchesToDehydrate[matchesToDehydrate.length - 1]?.id;
|
|
4434
|
-
if (lastMatchId) {
|
|
4435
|
-
dehydratedRouter.lastMatchId = lastMatchId;
|
|
4436
|
-
}
|
|
4437
|
-
const dehydratedData = await router.options.dehydrate?.();
|
|
4438
|
-
if (dehydratedData) {
|
|
4439
|
-
dehydratedRouter.dehydratedData = dehydratedData;
|
|
4440
|
-
}
|
|
4441
|
-
_dehydrated = true;
|
|
4442
|
-
const trackPlugins = { didRun: false };
|
|
4443
|
-
const serializationAdapters = router.options.serializationAdapters;
|
|
4444
|
-
const plugins = serializationAdapters ? serializationAdapters.map((t) => makeSsrSerovalPlugin(t, trackPlugins)).concat(defaultSerovalPlugins) : defaultSerovalPlugins;
|
|
4445
|
-
const signalSerializationComplete = () => {
|
|
4446
|
-
_serializationFinished = true;
|
|
4447
|
-
try {
|
|
4448
|
-
serializationFinishedListeners.forEach((l) => l());
|
|
4449
|
-
router.emit({ type: "onSerializationFinished" });
|
|
4450
|
-
} catch (err) {
|
|
4451
|
-
console.error("Serialization listener error:", err);
|
|
4452
|
-
} finally {
|
|
4453
|
-
serializationFinishedListeners.length = 0;
|
|
4454
|
-
renderFinishedListeners.length = 0;
|
|
4455
|
-
}
|
|
4456
|
-
};
|
|
4457
|
-
cn(dehydratedRouter, {
|
|
4458
|
-
refs: /* @__PURE__ */ new Map(),
|
|
4459
|
-
plugins,
|
|
4460
|
-
onSerialize: (data, initial) => {
|
|
4461
|
-
let serialized = initial ? GLOBAL_TSR + ".router=" + data : data;
|
|
4462
|
-
if (trackPlugins.didRun) {
|
|
4463
|
-
serialized = GLOBAL_TSR + ".p(()=>" + serialized + ")";
|
|
4464
|
-
}
|
|
4465
|
-
scriptBuffer.enqueue(serialized);
|
|
4466
|
-
},
|
|
4467
|
-
scopeId: SCOPE_ID,
|
|
4468
|
-
onDone: () => {
|
|
4469
|
-
scriptBuffer.enqueue(GLOBAL_TSR + ".e()");
|
|
4470
|
-
scriptBuffer.flush();
|
|
4471
|
-
signalSerializationComplete();
|
|
4472
|
-
},
|
|
4473
|
-
onError: (err) => {
|
|
4474
|
-
console.error("Serialization error:", err);
|
|
4475
|
-
signalSerializationComplete();
|
|
4476
|
-
}
|
|
4477
|
-
});
|
|
4478
|
-
},
|
|
4479
|
-
isDehydrated() {
|
|
4480
|
-
return _dehydrated;
|
|
4481
|
-
},
|
|
4482
|
-
isSerializationFinished() {
|
|
4483
|
-
return _serializationFinished;
|
|
4484
|
-
},
|
|
4485
|
-
onRenderFinished: (listener) => renderFinishedListeners.push(listener),
|
|
4486
|
-
onSerializationFinished: (listener) => serializationFinishedListeners.push(listener),
|
|
4487
|
-
setRenderFinished: () => {
|
|
4488
|
-
try {
|
|
4489
|
-
renderFinishedListeners.forEach((l) => l());
|
|
4490
|
-
} catch (err) {
|
|
4491
|
-
console.error("Error in render finished listener:", err);
|
|
4492
|
-
} finally {
|
|
4493
|
-
renderFinishedListeners.length = 0;
|
|
4494
|
-
}
|
|
4495
|
-
scriptBuffer.liftBarrier();
|
|
4496
|
-
},
|
|
4497
|
-
takeBufferedScripts() {
|
|
4498
|
-
const scripts = scriptBuffer.takeAll();
|
|
4499
|
-
const serverBufferedScript = {
|
|
4500
|
-
tag: "script",
|
|
4501
|
-
attrs: {
|
|
4502
|
-
nonce: router.options.ssr?.nonce,
|
|
4503
|
-
className: "$tsr",
|
|
4504
|
-
id: TSR_SCRIPT_BARRIER_ID
|
|
4505
|
-
},
|
|
4506
|
-
children: scripts
|
|
4507
|
-
};
|
|
4508
|
-
return serverBufferedScript;
|
|
4509
|
-
},
|
|
4510
|
-
liftScriptBarrier() {
|
|
4511
|
-
scriptBuffer.liftBarrier();
|
|
4512
|
-
},
|
|
4513
|
-
takeBufferedHtml() {
|
|
4514
|
-
if (injectedHtmlBuffer.length === 0) {
|
|
4515
|
-
return void 0;
|
|
4516
|
-
}
|
|
4517
|
-
const buffered = injectedHtmlBuffer.join("");
|
|
4518
|
-
injectedHtmlBuffer = [];
|
|
4519
|
-
return buffered;
|
|
4520
|
-
},
|
|
4521
|
-
cleanup() {
|
|
4522
|
-
if (!router.serverSsr) return;
|
|
4523
|
-
renderFinishedListeners.length = 0;
|
|
4524
|
-
serializationFinishedListeners.length = 0;
|
|
4525
|
-
injectedHtmlBuffer = [];
|
|
4526
|
-
scriptBuffer.cleanup();
|
|
4527
|
-
router.serverSsr = void 0;
|
|
4528
|
-
}
|
|
4529
|
-
};
|
|
4530
|
-
}
|
|
4531
|
-
function getOrigin(request) {
|
|
4532
|
-
try {
|
|
4533
|
-
return new URL(request.url).origin;
|
|
4534
|
-
} catch {
|
|
4535
|
-
}
|
|
4536
|
-
return "http://localhost";
|
|
4537
|
-
}
|
|
4538
|
-
function getNormalizedURL(url, base) {
|
|
4539
|
-
if (typeof url === "string") url = url.replace("\\", "%5C");
|
|
4540
|
-
const rawUrl = new URL(url, base);
|
|
4541
|
-
const decodedPathname = decodePath(rawUrl.pathname);
|
|
4542
|
-
const searchParams = new URLSearchParams(rawUrl.search);
|
|
4543
|
-
const normalizedHref = decodedPathname + (searchParams.size > 0 ? "?" : "") + searchParams.toString() + rawUrl.hash;
|
|
4544
|
-
return new URL(normalizedHref, rawUrl.origin);
|
|
4545
|
-
}
|
|
4546
3721
|
function defineHandlerCallback(handler) {
|
|
4547
3722
|
return handler;
|
|
4548
3723
|
}
|
|
@@ -4596,6 +3771,87 @@ function findLastClosingTagEnd(str) {
|
|
|
4596
3771
|
return -1;
|
|
4597
3772
|
}
|
|
4598
3773
|
function transformStreamWithRouter(router, appStream, opts) {
|
|
3774
|
+
const serializationAlreadyFinished = router.serverSsr?.isSerializationFinished() ?? false;
|
|
3775
|
+
const initialBufferedHtml = router.serverSsr?.takeBufferedHtml();
|
|
3776
|
+
if (serializationAlreadyFinished && !initialBufferedHtml) {
|
|
3777
|
+
let cleanedUp2 = false;
|
|
3778
|
+
let controller2;
|
|
3779
|
+
let isStreamClosed2 = false;
|
|
3780
|
+
let lifetimeTimeoutHandle2;
|
|
3781
|
+
const cleanup2 = () => {
|
|
3782
|
+
if (cleanedUp2) return;
|
|
3783
|
+
cleanedUp2 = true;
|
|
3784
|
+
if (lifetimeTimeoutHandle2 !== void 0) {
|
|
3785
|
+
clearTimeout(lifetimeTimeoutHandle2);
|
|
3786
|
+
lifetimeTimeoutHandle2 = void 0;
|
|
3787
|
+
}
|
|
3788
|
+
router.serverSsr?.cleanup();
|
|
3789
|
+
};
|
|
3790
|
+
const safeClose2 = () => {
|
|
3791
|
+
if (isStreamClosed2) return;
|
|
3792
|
+
isStreamClosed2 = true;
|
|
3793
|
+
try {
|
|
3794
|
+
controller2?.close();
|
|
3795
|
+
} catch {
|
|
3796
|
+
}
|
|
3797
|
+
};
|
|
3798
|
+
const safeError2 = (error) => {
|
|
3799
|
+
if (isStreamClosed2) return;
|
|
3800
|
+
isStreamClosed2 = true;
|
|
3801
|
+
try {
|
|
3802
|
+
controller2?.error(error);
|
|
3803
|
+
} catch {
|
|
3804
|
+
}
|
|
3805
|
+
};
|
|
3806
|
+
const lifetimeMs2 = DEFAULT_LIFETIME_TIMEOUT_MS;
|
|
3807
|
+
lifetimeTimeoutHandle2 = setTimeout(() => {
|
|
3808
|
+
if (!cleanedUp2 && !isStreamClosed2) {
|
|
3809
|
+
console.warn(
|
|
3810
|
+
`SSR stream transform exceeded maximum lifetime (${lifetimeMs2}ms), forcing cleanup`
|
|
3811
|
+
);
|
|
3812
|
+
safeError2(new Error("Stream lifetime exceeded"));
|
|
3813
|
+
cleanup2();
|
|
3814
|
+
}
|
|
3815
|
+
}, lifetimeMs2);
|
|
3816
|
+
const stream2 = new ReadableStream$1({
|
|
3817
|
+
start(c) {
|
|
3818
|
+
controller2 = c;
|
|
3819
|
+
},
|
|
3820
|
+
cancel() {
|
|
3821
|
+
isStreamClosed2 = true;
|
|
3822
|
+
cleanup2();
|
|
3823
|
+
}
|
|
3824
|
+
});
|
|
3825
|
+
(async () => {
|
|
3826
|
+
const reader = appStream.getReader();
|
|
3827
|
+
try {
|
|
3828
|
+
while (true) {
|
|
3829
|
+
const { done, value } = await reader.read();
|
|
3830
|
+
if (done) break;
|
|
3831
|
+
if (cleanedUp2 || isStreamClosed2) return;
|
|
3832
|
+
controller2?.enqueue(value);
|
|
3833
|
+
}
|
|
3834
|
+
if (cleanedUp2 || isStreamClosed2) return;
|
|
3835
|
+
router.serverSsr?.setRenderFinished();
|
|
3836
|
+
safeClose2();
|
|
3837
|
+
cleanup2();
|
|
3838
|
+
} catch (error) {
|
|
3839
|
+
if (cleanedUp2) return;
|
|
3840
|
+
console.error("Error reading appStream:", error);
|
|
3841
|
+
router.serverSsr?.setRenderFinished();
|
|
3842
|
+
safeError2(error);
|
|
3843
|
+
cleanup2();
|
|
3844
|
+
} finally {
|
|
3845
|
+
reader.releaseLock();
|
|
3846
|
+
}
|
|
3847
|
+
})().catch((error) => {
|
|
3848
|
+
if (cleanedUp2) return;
|
|
3849
|
+
console.error("Error in stream transform:", error);
|
|
3850
|
+
safeError2(error);
|
|
3851
|
+
cleanup2();
|
|
3852
|
+
});
|
|
3853
|
+
return stream2;
|
|
3854
|
+
}
|
|
4599
3855
|
let stopListeningToInjectedHtml;
|
|
4600
3856
|
let stopListeningToSerializationFinished;
|
|
4601
3857
|
let serializationTimeoutHandle;
|
|
@@ -4603,31 +3859,14 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4603
3859
|
let cleanedUp = false;
|
|
4604
3860
|
let controller;
|
|
4605
3861
|
let isStreamClosed = false;
|
|
4606
|
-
const serializationAlreadyFinished = router.serverSsr?.isSerializationFinished() ?? false;
|
|
4607
|
-
function cleanup() {
|
|
4608
|
-
if (cleanedUp) return;
|
|
4609
|
-
cleanedUp = true;
|
|
4610
|
-
try {
|
|
4611
|
-
stopListeningToInjectedHtml?.();
|
|
4612
|
-
stopListeningToSerializationFinished?.();
|
|
4613
|
-
} catch (e) {
|
|
4614
|
-
}
|
|
4615
|
-
stopListeningToInjectedHtml = void 0;
|
|
4616
|
-
stopListeningToSerializationFinished = void 0;
|
|
4617
|
-
if (serializationTimeoutHandle !== void 0) {
|
|
4618
|
-
clearTimeout(serializationTimeoutHandle);
|
|
4619
|
-
serializationTimeoutHandle = void 0;
|
|
4620
|
-
}
|
|
4621
|
-
if (lifetimeTimeoutHandle !== void 0) {
|
|
4622
|
-
clearTimeout(lifetimeTimeoutHandle);
|
|
4623
|
-
lifetimeTimeoutHandle = void 0;
|
|
4624
|
-
}
|
|
4625
|
-
pendingRouterHtmlParts = [];
|
|
4626
|
-
leftover = "";
|
|
4627
|
-
pendingClosingTags = "";
|
|
4628
|
-
router.serverSsr?.cleanup();
|
|
4629
|
-
}
|
|
4630
3862
|
const textDecoder = new TextDecoder();
|
|
3863
|
+
let pendingRouterHtml = initialBufferedHtml ?? "";
|
|
3864
|
+
let leftover = "";
|
|
3865
|
+
let pendingClosingTags = "";
|
|
3866
|
+
const MAX_LEFTOVER_CHARS = 2048;
|
|
3867
|
+
let isAppRendering = true;
|
|
3868
|
+
let streamBarrierLifted = false;
|
|
3869
|
+
let serializationFinished = serializationAlreadyFinished;
|
|
4631
3870
|
function safeEnqueue(chunk) {
|
|
4632
3871
|
if (isStreamClosed) return;
|
|
4633
3872
|
if (typeof chunk === "string") {
|
|
@@ -4652,6 +3891,29 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4652
3891
|
} catch {
|
|
4653
3892
|
}
|
|
4654
3893
|
}
|
|
3894
|
+
function cleanup() {
|
|
3895
|
+
if (cleanedUp) return;
|
|
3896
|
+
cleanedUp = true;
|
|
3897
|
+
try {
|
|
3898
|
+
stopListeningToInjectedHtml?.();
|
|
3899
|
+
stopListeningToSerializationFinished?.();
|
|
3900
|
+
} catch {
|
|
3901
|
+
}
|
|
3902
|
+
stopListeningToInjectedHtml = void 0;
|
|
3903
|
+
stopListeningToSerializationFinished = void 0;
|
|
3904
|
+
if (serializationTimeoutHandle !== void 0) {
|
|
3905
|
+
clearTimeout(serializationTimeoutHandle);
|
|
3906
|
+
serializationTimeoutHandle = void 0;
|
|
3907
|
+
}
|
|
3908
|
+
if (lifetimeTimeoutHandle !== void 0) {
|
|
3909
|
+
clearTimeout(lifetimeTimeoutHandle);
|
|
3910
|
+
lifetimeTimeoutHandle = void 0;
|
|
3911
|
+
}
|
|
3912
|
+
pendingRouterHtml = "";
|
|
3913
|
+
leftover = "";
|
|
3914
|
+
pendingClosingTags = "";
|
|
3915
|
+
router.serverSsr?.cleanup();
|
|
3916
|
+
}
|
|
4655
3917
|
const stream = new ReadableStream$1({
|
|
4656
3918
|
start(c) {
|
|
4657
3919
|
controller = c;
|
|
@@ -4661,21 +3923,14 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4661
3923
|
cleanup();
|
|
4662
3924
|
}
|
|
4663
3925
|
});
|
|
4664
|
-
let isAppRendering = true;
|
|
4665
|
-
let streamBarrierLifted = false;
|
|
4666
|
-
let leftover = "";
|
|
4667
|
-
let pendingClosingTags = "";
|
|
4668
|
-
let serializationFinished = serializationAlreadyFinished;
|
|
4669
|
-
let pendingRouterHtmlParts = [];
|
|
4670
|
-
const bufferedHtml = router.serverSsr?.takeBufferedHtml();
|
|
4671
|
-
if (bufferedHtml) {
|
|
4672
|
-
pendingRouterHtmlParts.push(bufferedHtml);
|
|
4673
|
-
}
|
|
4674
3926
|
function flushPendingRouterHtml() {
|
|
4675
|
-
if (
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
3927
|
+
if (!pendingRouterHtml) return;
|
|
3928
|
+
safeEnqueue(pendingRouterHtml);
|
|
3929
|
+
pendingRouterHtml = "";
|
|
3930
|
+
}
|
|
3931
|
+
function appendRouterHtml(html) {
|
|
3932
|
+
if (!html) return;
|
|
3933
|
+
pendingRouterHtml += html;
|
|
4679
3934
|
}
|
|
4680
3935
|
function tryFinish() {
|
|
4681
3936
|
if (isAppRendering || !serializationFinished) return;
|
|
@@ -4707,8 +3962,8 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4707
3962
|
if (cleanedUp || isStreamClosed) return;
|
|
4708
3963
|
const html = router.serverSsr?.takeBufferedHtml();
|
|
4709
3964
|
if (!html) return;
|
|
4710
|
-
if (isAppRendering) {
|
|
4711
|
-
|
|
3965
|
+
if (isAppRendering || leftover || pendingClosingTags) {
|
|
3966
|
+
appendRouterHtml(html);
|
|
4712
3967
|
} else {
|
|
4713
3968
|
safeEnqueue(html);
|
|
4714
3969
|
}
|
|
@@ -4729,13 +3984,18 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4729
3984
|
if (done) break;
|
|
4730
3985
|
if (cleanedUp || isStreamClosed) return;
|
|
4731
3986
|
const text = value instanceof Uint8Array ? textDecoder.decode(value, { stream: true }) : String(value);
|
|
4732
|
-
const chunkString = leftover + text;
|
|
3987
|
+
const chunkString = leftover ? leftover + text : text;
|
|
4733
3988
|
if (!streamBarrierLifted) {
|
|
4734
3989
|
if (chunkString.includes(TSR_SCRIPT_BARRIER_ID)) {
|
|
4735
3990
|
streamBarrierLifted = true;
|
|
4736
3991
|
router.serverSsr?.liftScriptBarrier();
|
|
4737
3992
|
}
|
|
4738
3993
|
}
|
|
3994
|
+
if (pendingClosingTags) {
|
|
3995
|
+
pendingClosingTags += chunkString;
|
|
3996
|
+
leftover = "";
|
|
3997
|
+
continue;
|
|
3998
|
+
}
|
|
4739
3999
|
const bodyEndIndex = chunkString.indexOf(BODY_END_TAG);
|
|
4740
4000
|
const htmlEndIndex = chunkString.indexOf(HTML_END_TAG);
|
|
4741
4001
|
if (bodyEndIndex !== -1 && htmlEndIndex !== -1 && bodyEndIndex < htmlEndIndex) {
|
|
@@ -4750,8 +4010,19 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4750
4010
|
safeEnqueue(chunkString.slice(0, lastClosingTagEnd));
|
|
4751
4011
|
flushPendingRouterHtml();
|
|
4752
4012
|
leftover = chunkString.slice(lastClosingTagEnd);
|
|
4013
|
+
if (leftover.length > MAX_LEFTOVER_CHARS) {
|
|
4014
|
+
safeEnqueue(leftover.slice(0, leftover.length - MAX_LEFTOVER_CHARS));
|
|
4015
|
+
leftover = leftover.slice(-MAX_LEFTOVER_CHARS);
|
|
4016
|
+
}
|
|
4753
4017
|
} else {
|
|
4754
|
-
|
|
4018
|
+
const combined = chunkString;
|
|
4019
|
+
if (combined.length > MAX_LEFTOVER_CHARS) {
|
|
4020
|
+
const flushUpto = combined.length - MAX_LEFTOVER_CHARS;
|
|
4021
|
+
safeEnqueue(combined.slice(0, flushUpto));
|
|
4022
|
+
leftover = combined.slice(flushUpto);
|
|
4023
|
+
} else {
|
|
4024
|
+
leftover = combined;
|
|
4025
|
+
}
|
|
4755
4026
|
}
|
|
4756
4027
|
}
|
|
4757
4028
|
if (cleanedUp || isStreamClosed) return;
|
|
@@ -4790,40 +4061,25 @@ function transformStreamWithRouter(router, appStream, opts) {
|
|
|
4790
4061
|
return stream;
|
|
4791
4062
|
}
|
|
4792
4063
|
export {
|
|
4793
|
-
attachRouterServerSsrUtils as A,
|
|
4794
4064
|
BaseRootRoute as B,
|
|
4795
|
-
createSerializationAdapter as C,
|
|
4796
|
-
createRawStreamRPCPlugin as D,
|
|
4797
|
-
isResolvedRedirect as E,
|
|
4798
|
-
executeRewriteInput as F,
|
|
4799
|
-
defaultSerovalPlugins as G,
|
|
4800
|
-
makeSerovalPlugin as H,
|
|
4801
|
-
defineHandlerCallback as I,
|
|
4802
4065
|
RouterCore as R,
|
|
4803
4066
|
restoreScroll as a,
|
|
4804
4067
|
rootRouteId as b,
|
|
4805
|
-
|
|
4068
|
+
isRedirect as c,
|
|
4806
4069
|
defaultGetScrollRestorationKey as d,
|
|
4807
4070
|
escapeHtml as e,
|
|
4808
|
-
|
|
4071
|
+
transformPipeableStreamWithRouter as f,
|
|
4809
4072
|
getLocationChangeInfo as g,
|
|
4810
|
-
|
|
4073
|
+
isDangerousProtocol as h,
|
|
4811
4074
|
isNotFound as i,
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4075
|
+
exactPathTest as j,
|
|
4076
|
+
removeTrailingSlash as k,
|
|
4077
|
+
deepEqual as l,
|
|
4815
4078
|
functionalUpdate as m,
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
deepEqual as q,
|
|
4079
|
+
BaseRoute as n,
|
|
4080
|
+
isModuleNotFoundError as o,
|
|
4081
|
+
defineHandlerCallback as p,
|
|
4820
4082
|
replaceEqualDeep as r,
|
|
4821
4083
|
storageKey as s,
|
|
4822
|
-
|
|
4823
|
-
BaseRoute as u,
|
|
4824
|
-
isModuleNotFoundError as v,
|
|
4825
|
-
parseRedirect as w,
|
|
4826
|
-
mergeHeaders as x,
|
|
4827
|
-
getNormalizedURL as y,
|
|
4828
|
-
getOrigin as z
|
|
4084
|
+
transformReadableStreamWithRouter as t
|
|
4829
4085
|
};
|