convex-cms 0.0.5-alpha.5 → 0.0.7-alpha.0
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 +59 -97
- package/admin/src/components/ContentEntryEditor.tsx +2 -2
- package/admin/src/components/ContentTypeFormModal.tsx +121 -81
- package/admin/src/components/fields/ReferenceField.tsx +9 -9
- package/admin/src/pages/ContentPage.tsx +11 -19
- package/admin/src/pages/ContentTypesPage.tsx +62 -16
- package/admin/src/routes/entries/$entryId.tsx +1 -1
- package/admin/src/routes/entries/type/$contentTypeId.tsx +1 -1
- package/admin-dist/nitro.json +1 -1
- package/admin-dist/public/assets/CmsEmptyState-CXVkI3FZ.js +1 -0
- package/admin-dist/public/assets/CmsPageHeader-DU9fD34s.js +1 -0
- package/admin-dist/public/assets/{CmsStatusBadge-Dd9uToHE.js → CmsStatusBadge-nZ9TeLBL.js} +1 -1
- package/admin-dist/public/assets/{CmsSurface-DBy5Lumx.js → CmsSurface-DF7OcKg_.js} +1 -1
- package/admin-dist/public/assets/CmsToolbar-5S8FQrSx.js +1 -0
- package/admin-dist/public/assets/ContentEntryEditor-BDb44eTo.js +4 -0
- package/admin-dist/public/assets/TaxonomyFilter-DEN2Q9Lo.js +1 -0
- package/admin-dist/public/assets/_contentTypeId-Ba5iowxH.js +1 -0
- package/admin-dist/public/assets/_entryId-OY3sLz6O.js +1 -0
- package/admin-dist/public/assets/alert-BbW1Q9CR.js +1 -0
- package/admin-dist/public/assets/badge-DdM8Eua8.js +1 -0
- package/admin-dist/public/assets/{circle-check-big-CpLxAvEj.js → circle-check-big-B7eCOM8r.js} +1 -1
- package/admin-dist/public/assets/command-BIjzeKOv.js +1 -0
- package/admin-dist/public/assets/content-BV3YeSSW.js +1 -0
- package/admin-dist/public/assets/content-types-Bm4b2tf8.js +1 -0
- package/admin-dist/public/assets/globals-D41WzvyZ.css +1 -0
- package/admin-dist/public/assets/index-DnJ5Twlv.js +1 -0
- package/admin-dist/public/assets/main-BZB1uYTH.js +102 -0
- package/admin-dist/public/assets/media-BIMN5jXt.js +1 -0
- package/admin-dist/public/assets/new._contentTypeId-DTWb8ZDl.js +1 -0
- package/admin-dist/public/assets/pencil-BDQ1ZWRw.js +1 -0
- package/admin-dist/public/assets/{rotate-ccw-BZpZtw0N.js → rotate-ccw-BWblSIsl.js} +1 -1
- package/admin-dist/public/assets/scroll-area-BoaB6x8v.js +1 -0
- package/admin-dist/public/assets/{search-BvgYr-c9.js → search-CYMIpd39.js} +1 -1
- package/admin-dist/public/assets/settings-DaNDUtr5.js +1 -0
- package/admin-dist/public/assets/switch-DN7TOCa5.js +1 -0
- package/admin-dist/public/assets/tabs-RN__emeJ.js +1 -0
- package/admin-dist/public/assets/tanstack-adapter-DQcKErwf.js +1 -0
- package/admin-dist/public/assets/taxonomies-DylY9HE1.js +1 -0
- package/admin-dist/public/assets/trash-Dp_a2mpb.js +1 -0
- package/admin-dist/public/assets/{useBreadcrumbLabel-D00rvqjw.js → useBreadcrumbLabel-BQ9dJI6T.js} +1 -1
- package/admin-dist/public/assets/usePermissions-WUBNg_Id.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 +110 -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-DYh_PPQE.mjs +38 -0
- package/admin-dist/server/_ssr/{CmsPageHeader-ClNPU7Up.mjs → CmsPageHeader-BcniLh49.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsStatusBadge-CojMbrY7.mjs → CmsStatusBadge-BShWDxwE.mjs} +2 -2
- package/admin-dist/server/_ssr/{CmsSurface-Dcv440rp.mjs → CmsSurface-CHEv-Kba.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsToolbar-BKv1nL6u.mjs → CmsToolbar-Dqqb216_.mjs} +2 -3
- package/admin-dist/server/_ssr/{ContentEntryEditor-weiXSBdZ.mjs → ContentEntryEditor-DOIAyWME.mjs} +18 -21
- package/admin-dist/server/_ssr/{TaxonomyFilter-BPQ57Mwk.mjs → TaxonomyFilter-BfsPAZ-Y.mjs} +4 -5
- package/admin-dist/server/_ssr/{_contentTypeId-DyyauLOs.mjs → _contentTypeId-CPjmri90.mjs} +34 -43
- package/admin-dist/server/_ssr/{_entryId-9Cafwxmw.mjs → _entryId-D0yu8HuP.mjs} +35 -47
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-DgCpSt_y.mjs +4 -0
- package/admin-dist/server/_ssr/badge-Cp61aQNc.mjs +39 -0
- package/admin-dist/server/_ssr/{command-CEf8YBxY.mjs → command-BfjE1WJf.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-DrODe6sA.mjs} +40 -49
- package/admin-dist/server/_ssr/content-types-BPgMwxiT.mjs +459 -0
- package/admin-dist/server/_ssr/{index-BlSIlH4Z.mjs → index-BTHmIC9W.mjs} +26 -28
- package/admin-dist/server/_ssr/index.mjs +3459 -62
- package/admin-dist/server/_ssr/{media-CD2_NUMw.mjs → media-DkvBfmD9.mjs} +31 -43
- package/admin-dist/server/_ssr/{new._contentTypeId-dmZy6PBX.mjs → new._contentTypeId-Co_73sDJ.mjs} +33 -45
- package/admin-dist/server/_ssr/router-CaDgRHfQ.mjs +3031 -0
- package/admin-dist/server/_ssr/{scroll-area-BH_1K-WT.mjs → scroll-area-D3v-O_jk.mjs} +1 -1
- package/admin-dist/server/_ssr/{settings-DVdsoWoh.mjs → settings-MaEXh2Hz.mjs} +30 -39
- package/admin-dist/server/_ssr/{switch-DX_X8vZl.mjs → switch-DmbR03dm.mjs} +1 -1
- package/admin-dist/server/_ssr/{tabs-4FWM0sn8.mjs → tabs-5oFlAGLz.mjs} +2 -3
- package/admin-dist/server/_ssr/{tanstack-adapter-D3ZcKtbY.mjs → tanstack-adapter-DNaUioIZ.mjs} +1 -1
- package/admin-dist/server/_ssr/{taxonomies-BHFfO9Yr.mjs → taxonomies-D3xMK23a.mjs} +30 -39
- package/admin-dist/server/_ssr/{trash-9tUB2KwI.mjs → trash-CNw1mtF1.mjs} +30 -39
- package/admin-dist/server/_ssr/{useBreadcrumbLabel-DVme3DSb.mjs → useBreadcrumbLabel-BQGjOTcy.mjs} +1 -1
- package/admin-dist/server/_ssr/{usePermissions-zAQj-ruE.mjs → usePermissions-D0qtvmNi.mjs} +1 -1
- package/admin-dist/server/index.mjs +162 -204
- 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 +303 -290
- package/dist/client/admin/contentTypes.d.ts.map +1 -1
- package/dist/client/admin/contentTypes.js +101 -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 +6 -8
- package/dist/client/admin/entries.js.map +1 -1
- package/dist/client/admin/index.d.ts +690 -642
- package/dist/client/admin/index.d.ts.map +1 -1
- package/dist/client/admin/index.js +29 -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 +181 -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 +77 -48
- 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.js +2 -2
- 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/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,378 +1,4 @@
|
|
|
1
1
|
const stateIndexKey = "__TSR_index";
|
|
2
|
-
const popStateEvent = "popstate";
|
|
3
|
-
const beforeUnloadEvent = "beforeunload";
|
|
4
|
-
function createHistory(opts) {
|
|
5
|
-
let location = opts.getLocation();
|
|
6
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
7
|
-
const notify = (action, navigateOpts) => {
|
|
8
|
-
location = opts.getLocation();
|
|
9
|
-
subscribers.forEach(
|
|
10
|
-
(subscriber) => subscriber({ location, action, navigateOpts })
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
const handleIndexChange = (action) => {
|
|
14
|
-
if (opts.notifyOnIndexChange ?? true) notify(action);
|
|
15
|
-
else location = opts.getLocation();
|
|
16
|
-
};
|
|
17
|
-
const tryNavigation = async ({
|
|
18
|
-
task,
|
|
19
|
-
navigateOpts,
|
|
20
|
-
...actionInfo
|
|
21
|
-
}) => {
|
|
22
|
-
const ignoreBlocker = navigateOpts?.ignoreBlocker ?? false;
|
|
23
|
-
if (ignoreBlocker) {
|
|
24
|
-
task();
|
|
25
|
-
return { type: "SUCCESS" };
|
|
26
|
-
}
|
|
27
|
-
const blockers = opts.getBlockers?.() ?? [];
|
|
28
|
-
const isPushOrReplace = actionInfo.type === "PUSH" || actionInfo.type === "REPLACE";
|
|
29
|
-
if (typeof document !== "undefined" && blockers.length && isPushOrReplace) {
|
|
30
|
-
for (const blocker of blockers) {
|
|
31
|
-
const nextLocation = parseHref(actionInfo.path, actionInfo.state);
|
|
32
|
-
const isBlocked = await blocker.blockerFn({
|
|
33
|
-
currentLocation: location,
|
|
34
|
-
nextLocation,
|
|
35
|
-
action: actionInfo.type
|
|
36
|
-
});
|
|
37
|
-
if (isBlocked) {
|
|
38
|
-
opts.onBlocked?.();
|
|
39
|
-
return { type: "BLOCKED" };
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
task();
|
|
44
|
-
return { type: "SUCCESS" };
|
|
45
|
-
};
|
|
46
|
-
return {
|
|
47
|
-
get location() {
|
|
48
|
-
return location;
|
|
49
|
-
},
|
|
50
|
-
get length() {
|
|
51
|
-
return opts.getLength();
|
|
52
|
-
},
|
|
53
|
-
subscribers,
|
|
54
|
-
subscribe: (cb) => {
|
|
55
|
-
subscribers.add(cb);
|
|
56
|
-
return () => {
|
|
57
|
-
subscribers.delete(cb);
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
push: (path, state, navigateOpts) => {
|
|
61
|
-
const currentIndex = location.state[stateIndexKey];
|
|
62
|
-
state = assignKeyAndIndex(currentIndex + 1, state);
|
|
63
|
-
return tryNavigation({
|
|
64
|
-
task: () => {
|
|
65
|
-
opts.pushState(path, state);
|
|
66
|
-
notify({ type: "PUSH" }, navigateOpts);
|
|
67
|
-
},
|
|
68
|
-
navigateOpts,
|
|
69
|
-
type: "PUSH",
|
|
70
|
-
path,
|
|
71
|
-
state
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
replace: (path, state, navigateOpts) => {
|
|
75
|
-
const currentIndex = location.state[stateIndexKey];
|
|
76
|
-
state = assignKeyAndIndex(currentIndex, state);
|
|
77
|
-
return tryNavigation({
|
|
78
|
-
task: () => {
|
|
79
|
-
opts.replaceState(path, state);
|
|
80
|
-
notify({ type: "REPLACE" }, navigateOpts);
|
|
81
|
-
},
|
|
82
|
-
navigateOpts,
|
|
83
|
-
type: "REPLACE",
|
|
84
|
-
path,
|
|
85
|
-
state
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
go: (index, navigateOpts) => {
|
|
89
|
-
tryNavigation({
|
|
90
|
-
task: () => {
|
|
91
|
-
opts.go(index);
|
|
92
|
-
handleIndexChange({ type: "GO", index });
|
|
93
|
-
},
|
|
94
|
-
navigateOpts,
|
|
95
|
-
type: "GO"
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
back: (navigateOpts) => {
|
|
99
|
-
tryNavigation({
|
|
100
|
-
task: () => {
|
|
101
|
-
opts.back(navigateOpts?.ignoreBlocker ?? false);
|
|
102
|
-
handleIndexChange({ type: "BACK" });
|
|
103
|
-
},
|
|
104
|
-
navigateOpts,
|
|
105
|
-
type: "BACK"
|
|
106
|
-
});
|
|
107
|
-
},
|
|
108
|
-
forward: (navigateOpts) => {
|
|
109
|
-
tryNavigation({
|
|
110
|
-
task: () => {
|
|
111
|
-
opts.forward(navigateOpts?.ignoreBlocker ?? false);
|
|
112
|
-
handleIndexChange({ type: "FORWARD" });
|
|
113
|
-
},
|
|
114
|
-
navigateOpts,
|
|
115
|
-
type: "FORWARD"
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
canGoBack: () => location.state[stateIndexKey] !== 0,
|
|
119
|
-
createHref: (str) => opts.createHref(str),
|
|
120
|
-
block: (blocker) => {
|
|
121
|
-
if (!opts.setBlockers) return () => {
|
|
122
|
-
};
|
|
123
|
-
const blockers = opts.getBlockers?.() ?? [];
|
|
124
|
-
opts.setBlockers([...blockers, blocker]);
|
|
125
|
-
return () => {
|
|
126
|
-
const blockers2 = opts.getBlockers?.() ?? [];
|
|
127
|
-
opts.setBlockers?.(blockers2.filter((b) => b !== blocker));
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
flush: () => opts.flush?.(),
|
|
131
|
-
destroy: () => opts.destroy?.(),
|
|
132
|
-
notify
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function assignKeyAndIndex(index, state) {
|
|
136
|
-
if (!state) {
|
|
137
|
-
state = {};
|
|
138
|
-
}
|
|
139
|
-
const key = createRandomKey();
|
|
140
|
-
return {
|
|
141
|
-
...state,
|
|
142
|
-
key,
|
|
143
|
-
// TODO: Remove in v2 - use __TSR_key instead
|
|
144
|
-
__TSR_key: key,
|
|
145
|
-
[stateIndexKey]: index
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
function createBrowserHistory(opts) {
|
|
149
|
-
const win = typeof document !== "undefined" ? window : void 0;
|
|
150
|
-
const originalPushState = win.history.pushState;
|
|
151
|
-
const originalReplaceState = win.history.replaceState;
|
|
152
|
-
let blockers = [];
|
|
153
|
-
const _getBlockers = () => blockers;
|
|
154
|
-
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
|
155
|
-
const createHref = ((path) => path);
|
|
156
|
-
const parseLocation = (() => parseHref(
|
|
157
|
-
`${win.location.pathname}${win.location.search}${win.location.hash}`,
|
|
158
|
-
win.history.state
|
|
159
|
-
));
|
|
160
|
-
if (!win.history.state?.__TSR_key && !win.history.state?.key) {
|
|
161
|
-
const addedKey = createRandomKey();
|
|
162
|
-
win.history.replaceState(
|
|
163
|
-
{
|
|
164
|
-
[stateIndexKey]: 0,
|
|
165
|
-
key: addedKey,
|
|
166
|
-
// TODO: Remove in v2 - use __TSR_key instead
|
|
167
|
-
__TSR_key: addedKey
|
|
168
|
-
},
|
|
169
|
-
""
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
let currentLocation = parseLocation();
|
|
173
|
-
let rollbackLocation;
|
|
174
|
-
let nextPopIsGo = false;
|
|
175
|
-
let ignoreNextPop = false;
|
|
176
|
-
let skipBlockerNextPop = false;
|
|
177
|
-
let ignoreNextBeforeUnload = false;
|
|
178
|
-
const getLocation = () => currentLocation;
|
|
179
|
-
let next;
|
|
180
|
-
let scheduled;
|
|
181
|
-
const flush = () => {
|
|
182
|
-
if (!next) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
history._ignoreSubscribers = true;
|
|
186
|
-
(next.isPush ? win.history.pushState : win.history.replaceState)(
|
|
187
|
-
next.state,
|
|
188
|
-
"",
|
|
189
|
-
next.href
|
|
190
|
-
);
|
|
191
|
-
history._ignoreSubscribers = false;
|
|
192
|
-
next = void 0;
|
|
193
|
-
scheduled = void 0;
|
|
194
|
-
rollbackLocation = void 0;
|
|
195
|
-
};
|
|
196
|
-
const queueHistoryAction = (type, destHref, state) => {
|
|
197
|
-
const href = createHref(destHref);
|
|
198
|
-
if (!scheduled) {
|
|
199
|
-
rollbackLocation = currentLocation;
|
|
200
|
-
}
|
|
201
|
-
currentLocation = parseHref(destHref, state);
|
|
202
|
-
next = {
|
|
203
|
-
href,
|
|
204
|
-
state,
|
|
205
|
-
isPush: next?.isPush || type === "push"
|
|
206
|
-
};
|
|
207
|
-
if (!scheduled) {
|
|
208
|
-
scheduled = Promise.resolve().then(() => flush());
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
const onPushPop = (type) => {
|
|
212
|
-
currentLocation = parseLocation();
|
|
213
|
-
history.notify({ type });
|
|
214
|
-
};
|
|
215
|
-
const onPushPopEvent = async () => {
|
|
216
|
-
if (ignoreNextPop) {
|
|
217
|
-
ignoreNextPop = false;
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const nextLocation = parseLocation();
|
|
221
|
-
const delta = nextLocation.state[stateIndexKey] - currentLocation.state[stateIndexKey];
|
|
222
|
-
const isForward = delta === 1;
|
|
223
|
-
const isBack = delta === -1;
|
|
224
|
-
const isGo = !isForward && !isBack || nextPopIsGo;
|
|
225
|
-
nextPopIsGo = false;
|
|
226
|
-
const action = isGo ? "GO" : isBack ? "BACK" : "FORWARD";
|
|
227
|
-
const notify = isGo ? {
|
|
228
|
-
type: "GO",
|
|
229
|
-
index: delta
|
|
230
|
-
} : {
|
|
231
|
-
type: isBack ? "BACK" : "FORWARD"
|
|
232
|
-
};
|
|
233
|
-
if (skipBlockerNextPop) {
|
|
234
|
-
skipBlockerNextPop = false;
|
|
235
|
-
} else {
|
|
236
|
-
const blockers2 = _getBlockers();
|
|
237
|
-
if (typeof document !== "undefined" && blockers2.length) {
|
|
238
|
-
for (const blocker of blockers2) {
|
|
239
|
-
const isBlocked = await blocker.blockerFn({
|
|
240
|
-
currentLocation,
|
|
241
|
-
nextLocation,
|
|
242
|
-
action
|
|
243
|
-
});
|
|
244
|
-
if (isBlocked) {
|
|
245
|
-
ignoreNextPop = true;
|
|
246
|
-
win.history.go(1);
|
|
247
|
-
history.notify(notify);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
currentLocation = parseLocation();
|
|
254
|
-
history.notify(notify);
|
|
255
|
-
};
|
|
256
|
-
const onBeforeUnload = (e) => {
|
|
257
|
-
if (ignoreNextBeforeUnload) {
|
|
258
|
-
ignoreNextBeforeUnload = false;
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
let shouldBlock = false;
|
|
262
|
-
const blockers2 = _getBlockers();
|
|
263
|
-
if (typeof document !== "undefined" && blockers2.length) {
|
|
264
|
-
for (const blocker of blockers2) {
|
|
265
|
-
const shouldHaveBeforeUnload = blocker.enableBeforeUnload ?? true;
|
|
266
|
-
if (shouldHaveBeforeUnload === true) {
|
|
267
|
-
shouldBlock = true;
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
if (typeof shouldHaveBeforeUnload === "function" && shouldHaveBeforeUnload() === true) {
|
|
271
|
-
shouldBlock = true;
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (shouldBlock) {
|
|
277
|
-
e.preventDefault();
|
|
278
|
-
return e.returnValue = "";
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
};
|
|
282
|
-
const history = createHistory({
|
|
283
|
-
getLocation,
|
|
284
|
-
getLength: () => win.history.length,
|
|
285
|
-
pushState: (href, state) => queueHistoryAction("push", href, state),
|
|
286
|
-
replaceState: (href, state) => queueHistoryAction("replace", href, state),
|
|
287
|
-
back: (ignoreBlocker) => {
|
|
288
|
-
if (ignoreBlocker) skipBlockerNextPop = true;
|
|
289
|
-
ignoreNextBeforeUnload = true;
|
|
290
|
-
return win.history.back();
|
|
291
|
-
},
|
|
292
|
-
forward: (ignoreBlocker) => {
|
|
293
|
-
if (ignoreBlocker) skipBlockerNextPop = true;
|
|
294
|
-
ignoreNextBeforeUnload = true;
|
|
295
|
-
win.history.forward();
|
|
296
|
-
},
|
|
297
|
-
go: (n) => {
|
|
298
|
-
nextPopIsGo = true;
|
|
299
|
-
win.history.go(n);
|
|
300
|
-
},
|
|
301
|
-
createHref: (href) => createHref(href),
|
|
302
|
-
flush,
|
|
303
|
-
destroy: () => {
|
|
304
|
-
win.history.pushState = originalPushState;
|
|
305
|
-
win.history.replaceState = originalReplaceState;
|
|
306
|
-
win.removeEventListener(beforeUnloadEvent, onBeforeUnload, {
|
|
307
|
-
capture: true
|
|
308
|
-
});
|
|
309
|
-
win.removeEventListener(popStateEvent, onPushPopEvent);
|
|
310
|
-
},
|
|
311
|
-
onBlocked: () => {
|
|
312
|
-
if (rollbackLocation && currentLocation !== rollbackLocation) {
|
|
313
|
-
currentLocation = rollbackLocation;
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
getBlockers: _getBlockers,
|
|
317
|
-
setBlockers: _setBlockers,
|
|
318
|
-
notifyOnIndexChange: false
|
|
319
|
-
});
|
|
320
|
-
win.addEventListener(beforeUnloadEvent, onBeforeUnload, { capture: true });
|
|
321
|
-
win.addEventListener(popStateEvent, onPushPopEvent);
|
|
322
|
-
win.history.pushState = function(...args) {
|
|
323
|
-
const res = originalPushState.apply(win.history, args);
|
|
324
|
-
if (!history._ignoreSubscribers) onPushPop("PUSH");
|
|
325
|
-
return res;
|
|
326
|
-
};
|
|
327
|
-
win.history.replaceState = function(...args) {
|
|
328
|
-
const res = originalReplaceState.apply(win.history, args);
|
|
329
|
-
if (!history._ignoreSubscribers) onPushPop("REPLACE");
|
|
330
|
-
return res;
|
|
331
|
-
};
|
|
332
|
-
return history;
|
|
333
|
-
}
|
|
334
|
-
function createMemoryHistory(opts = {
|
|
335
|
-
initialEntries: ["/"]
|
|
336
|
-
}) {
|
|
337
|
-
const entries = opts.initialEntries;
|
|
338
|
-
let index = opts.initialIndex ? Math.min(Math.max(opts.initialIndex, 0), entries.length - 1) : entries.length - 1;
|
|
339
|
-
const states = entries.map(
|
|
340
|
-
(_entry, index2) => assignKeyAndIndex(index2, void 0)
|
|
341
|
-
);
|
|
342
|
-
const getLocation = () => parseHref(entries[index], states[index]);
|
|
343
|
-
let blockers = [];
|
|
344
|
-
const _getBlockers = () => blockers;
|
|
345
|
-
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
|
346
|
-
return createHistory({
|
|
347
|
-
getLocation,
|
|
348
|
-
getLength: () => entries.length,
|
|
349
|
-
pushState: (path, state) => {
|
|
350
|
-
if (index < entries.length - 1) {
|
|
351
|
-
entries.splice(index + 1);
|
|
352
|
-
states.splice(index + 1);
|
|
353
|
-
}
|
|
354
|
-
states.push(state);
|
|
355
|
-
entries.push(path);
|
|
356
|
-
index = Math.max(entries.length - 1, 0);
|
|
357
|
-
},
|
|
358
|
-
replaceState: (path, state) => {
|
|
359
|
-
states[index] = state;
|
|
360
|
-
entries[index] = path;
|
|
361
|
-
},
|
|
362
|
-
back: () => {
|
|
363
|
-
index = Math.max(index - 1, 0);
|
|
364
|
-
},
|
|
365
|
-
forward: () => {
|
|
366
|
-
index = Math.min(index + 1, entries.length - 1);
|
|
367
|
-
},
|
|
368
|
-
go: (n) => {
|
|
369
|
-
index = Math.min(Math.max(index + n, 0), entries.length - 1);
|
|
370
|
-
},
|
|
371
|
-
createHref: (path) => path,
|
|
372
|
-
getBlockers: _getBlockers,
|
|
373
|
-
setBlockers: _setBlockers
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
2
|
function sanitizePath(path) {
|
|
377
3
|
let sanitized = path.replace(/[\x00-\x1f\x7f]/g, "");
|
|
378
4
|
if (sanitized.startsWith("//")) {
|
|
@@ -403,7 +29,5 @@ function createRandomKey() {
|
|
|
403
29
|
return (Math.random() + 1).toString(36).substring(7);
|
|
404
30
|
}
|
|
405
31
|
export {
|
|
406
|
-
createMemoryHistory as a,
|
|
407
|
-
createBrowserHistory as c,
|
|
408
32
|
parseHref as p
|
|
409
33
|
};
|