@wordpress/route 0.1.1-next.16d95556a.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 ADDED
@@ -0,0 +1,50 @@
1
+ # Route
2
+
3
+ Routing utilities for WordPress admin interfaces, providing a shared instance of TanStack Router.
4
+
5
+ ## Installation
6
+
7
+ Install the module:
8
+
9
+ ```bash
10
+ npm install @wordpress/route --save
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ This package provides a shared instance of TanStack Router to ensure consistent routing across WordPress admin interfaces.
16
+
17
+ ### Public API
18
+
19
+ The following hooks and components are available for use in routes:
20
+
21
+ ```js
22
+ import { Link, useNavigate, useParams, useRouter, useSearch } from '@wordpress/route';
23
+
24
+ function MyRoute() {
25
+ const params = useParams();
26
+ const navigate = useNavigate();
27
+ const search = useSearch();
28
+
29
+ return (
30
+ <div>
31
+ <Link to="/other-route">Go to other route</Link>
32
+ <button onClick={() => navigate({ to: '/somewhere' })}>
33
+ Navigate
34
+ </button>
35
+ </div>
36
+ );
37
+ }
38
+ ```
39
+
40
+ ### Private API
41
+
42
+ The boot package uses private APIs for router setup. These should not be used by individual routes.
43
+
44
+ ## Contributing to this package
45
+
46
+ This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose.
47
+
48
+ To find out more about contributing to this package or Gutenberg as a whole, please read the [project's main contributor guide](https://github.com/WordPress/gutenberg/blob/HEAD/CONTRIBUTING.md).
49
+
50
+ <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
package/build/index.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/route/src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Link: () => import_react_router2.Link,
24
+ privateApis: () => import_private_apis.privateApis,
25
+ redirect: () => import_react_router2.redirect,
26
+ useInvalidate: () => useInvalidate,
27
+ useNavigate: () => import_react_router2.useNavigate,
28
+ useParams: () => import_react_router2.useParams,
29
+ useSearch: () => import_react_router2.useSearch
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+ var import_react_router = require("@tanstack/react-router");
33
+ var import_react_router2 = require("@tanstack/react-router");
34
+ var import_private_apis = require("./private-apis");
35
+ function useInvalidate() {
36
+ const router = (0, import_react_router.useRouter)();
37
+ return () => router.invalidate();
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ Link,
42
+ privateApis,
43
+ redirect,
44
+ useInvalidate,
45
+ useNavigate,
46
+ useParams,
47
+ useSearch
48
+ });
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { useRouter } from '@tanstack/react-router';\nexport {\n\tLink,\n\tredirect,\n\tuseNavigate,\n\tuseParams,\n\tuseSearch,\n} from '@tanstack/react-router';\nexport type {\n\tAnyRoute,\n\tLinkProps,\n\tNavigateOptions,\n\tRouteOptions,\n\tRouterOptions,\n\tToOptions,\n\tUseNavigateResult,\n} from '@tanstack/react-router';\n\n/**\n * Internal dependencies\n */\nexport { privateApis } from './private-apis';\n\n/**\n * Hook to invalidate the router cache and trigger a re-render.\n * This is useful when you want to refetch data without changing the URL.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const invalidate = useInvalidate();\n *\n * const handleRefresh = () => {\n * invalidate();\n * };\n *\n * return <button onClick={handleRefresh}>Refresh</button>;\n * }\n * ```\n *\n * @return A function to invalidate the router.\n */\nexport function useInvalidate() {\n\tconst router = useRouter();\n\treturn () => router.invalidate();\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA0B;AAC1B,IAAAA,uBAMO;AAcP,0BAA4B;AAqBrB,SAAS,gBAAgB;AAC/B,QAAM,aAAS,+BAAU;AACzB,SAAO,MAAM,OAAO,WAAW;AAChC;",
6
+ "names": ["import_react_router"]
7
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/route/src/lock-unlock.ts
21
+ var lock_unlock_exports = {};
22
+ __export(lock_unlock_exports, {
23
+ lock: () => lock,
24
+ unlock: () => unlock
25
+ });
26
+ module.exports = __toCommonJS(lock_unlock_exports);
27
+ var import_private_apis = require("@wordpress/private-apis");
28
+ var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
29
+ "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
30
+ "@wordpress/route"
31
+ );
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ lock,
35
+ unlock
36
+ });
37
+ //# sourceMappingURL=lock-unlock.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lock-unlock.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/route'\n\t);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/route/src/private-apis.ts
21
+ var private_apis_exports = {};
22
+ __export(private_apis_exports, {
23
+ privateApis: () => privateApis
24
+ });
25
+ module.exports = __toCommonJS(private_apis_exports);
26
+ var import_history = require("@tanstack/history");
27
+ var import_react_router = require("@tanstack/react-router");
28
+ var import_lock_unlock = require("./lock-unlock");
29
+ var privateApis = {};
30
+ (0, import_lock_unlock.lock)(privateApis, {
31
+ // Router creation and setup
32
+ createBrowserHistory: import_react_router.createBrowserHistory,
33
+ createRouter: import_react_router.createRouter,
34
+ createRootRoute: import_react_router.createRootRoute,
35
+ createRoute: import_react_router.createRoute,
36
+ Outlet: import_react_router.Outlet,
37
+ RouterProvider: import_react_router.RouterProvider,
38
+ // Internal routing utilities
39
+ redirect: import_react_router.redirect,
40
+ createLink: import_react_router.createLink,
41
+ useCanGoBack: import_react_router.useCanGoBack,
42
+ useMatches: import_react_router.useMatches,
43
+ useRouter: import_react_router.useRouter,
44
+ // History utilities
45
+ parseHref: import_history.parseHref
46
+ });
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ privateApis
50
+ });
51
+ //# sourceMappingURL=private-apis.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-apis.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { parseHref } from '@tanstack/history';\nimport {\n\tcreateBrowserHistory,\n\tcreateLink,\n\tcreateRootRoute,\n\tcreateRoute,\n\tcreateRouter,\n\tOutlet,\n\tredirect,\n\tRouterProvider,\n\tuseCanGoBack,\n\tuseMatches,\n\tuseRouter,\n} from '@tanstack/react-router';\n\n/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\n\n/**\n * Private APIs for the boot package only.\n * These are router setup and internal utilities that should not be used\n * by individual routes.\n */\nexport const privateApis = {};\n\n// Lock the private APIs so only authorized modules can access them\nlock( privateApis, {\n\t// Router creation and setup\n\tcreateBrowserHistory,\n\tcreateRouter,\n\tcreateRootRoute,\n\tcreateRoute,\n\tOutlet,\n\tRouterProvider,\n\n\t// Internal routing utilities\n\tredirect,\n\tcreateLink,\n\tuseCanGoBack,\n\tuseMatches,\n\tuseRouter,\n\n\t// History utilities\n\tparseHref,\n} );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0B;AAC1B,0BAYO;AAKP,yBAAqB;AAOd,IAAM,cAAc,CAAC;AAAA,IAG5B,yBAAM,aAAa;AAAA;AAAA,EAElB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,24 @@
1
+ // packages/route/src/index.ts
2
+ import { useRouter } from "@tanstack/react-router";
3
+ import {
4
+ Link,
5
+ redirect,
6
+ useNavigate,
7
+ useParams,
8
+ useSearch
9
+ } from "@tanstack/react-router";
10
+ import { privateApis } from "./private-apis";
11
+ function useInvalidate() {
12
+ const router = useRouter();
13
+ return () => router.invalidate();
14
+ }
15
+ export {
16
+ Link,
17
+ privateApis,
18
+ redirect,
19
+ useInvalidate,
20
+ useNavigate,
21
+ useParams,
22
+ useSearch
23
+ };
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { useRouter } from '@tanstack/react-router';\nexport {\n\tLink,\n\tredirect,\n\tuseNavigate,\n\tuseParams,\n\tuseSearch,\n} from '@tanstack/react-router';\nexport type {\n\tAnyRoute,\n\tLinkProps,\n\tNavigateOptions,\n\tRouteOptions,\n\tRouterOptions,\n\tToOptions,\n\tUseNavigateResult,\n} from '@tanstack/react-router';\n\n/**\n * Internal dependencies\n */\nexport { privateApis } from './private-apis';\n\n/**\n * Hook to invalidate the router cache and trigger a re-render.\n * This is useful when you want to refetch data without changing the URL.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const invalidate = useInvalidate();\n *\n * const handleRefresh = () => {\n * invalidate();\n * };\n *\n * return <button onClick={handleRefresh}>Refresh</button>;\n * }\n * ```\n *\n * @return A function to invalidate the router.\n */\nexport function useInvalidate() {\n\tconst router = useRouter();\n\treturn () => router.invalidate();\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAcP,SAAS,mBAAmB;AAqBrB,SAAS,gBAAgB;AAC/B,QAAM,SAAS,UAAU;AACzB,SAAO,MAAM,OAAO,WAAW;AAChC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,11 @@
1
+ // packages/route/src/lock-unlock.ts
2
+ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
3
+ var { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
4
+ "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
5
+ "@wordpress/route"
6
+ );
7
+ export {
8
+ lock,
9
+ unlock
10
+ };
11
+ //# sourceMappingURL=lock-unlock.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lock-unlock.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/route'\n\t);\n"],
5
+ "mappings": ";AAGA,SAAS,wDAAwD;AAE1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ // packages/route/src/private-apis.ts
2
+ import { parseHref } from "@tanstack/history";
3
+ import {
4
+ createBrowserHistory,
5
+ createLink,
6
+ createRootRoute,
7
+ createRoute,
8
+ createRouter,
9
+ Outlet,
10
+ redirect,
11
+ RouterProvider,
12
+ useCanGoBack,
13
+ useMatches,
14
+ useRouter
15
+ } from "@tanstack/react-router";
16
+ import { lock } from "./lock-unlock";
17
+ var privateApis = {};
18
+ lock(privateApis, {
19
+ // Router creation and setup
20
+ createBrowserHistory,
21
+ createRouter,
22
+ createRootRoute,
23
+ createRoute,
24
+ Outlet,
25
+ RouterProvider,
26
+ // Internal routing utilities
27
+ redirect,
28
+ createLink,
29
+ useCanGoBack,
30
+ useMatches,
31
+ useRouter,
32
+ // History utilities
33
+ parseHref
34
+ });
35
+ export {
36
+ privateApis
37
+ };
38
+ //# sourceMappingURL=private-apis.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-apis.ts"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { parseHref } from '@tanstack/history';\nimport {\n\tcreateBrowserHistory,\n\tcreateLink,\n\tcreateRootRoute,\n\tcreateRoute,\n\tcreateRouter,\n\tOutlet,\n\tredirect,\n\tRouterProvider,\n\tuseCanGoBack,\n\tuseMatches,\n\tuseRouter,\n} from '@tanstack/react-router';\n\n/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\n\n/**\n * Private APIs for the boot package only.\n * These are router setup and internal utilities that should not be used\n * by individual routes.\n */\nexport const privateApis = {};\n\n// Lock the private APIs so only authorized modules can access them\nlock( privateApis, {\n\t// Router creation and setup\n\tcreateBrowserHistory,\n\tcreateRouter,\n\tcreateRootRoute,\n\tcreateRoute,\n\tOutlet,\n\tRouterProvider,\n\n\t// Internal routing utilities\n\tredirect,\n\tcreateLink,\n\tuseCanGoBack,\n\tuseMatches,\n\tuseRouter,\n\n\t// History utilities\n\tparseHref,\n} );\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,YAAY;AAOd,IAAM,cAAc,CAAC;AAG5B,KAAM,aAAa;AAAA;AAAA,EAElB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAGA;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,27 @@
1
+ export { Link, redirect, useNavigate, useParams, useSearch, } from '@tanstack/react-router';
2
+ export type { AnyRoute, LinkProps, NavigateOptions, RouteOptions, RouterOptions, ToOptions, UseNavigateResult, } from '@tanstack/react-router';
3
+ /**
4
+ * Internal dependencies
5
+ */
6
+ export { privateApis } from './private-apis';
7
+ /**
8
+ * Hook to invalidate the router cache and trigger a re-render.
9
+ * This is useful when you want to refetch data without changing the URL.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function MyComponent() {
14
+ * const invalidate = useInvalidate();
15
+ *
16
+ * const handleRefresh = () => {
17
+ * invalidate();
18
+ * };
19
+ *
20
+ * return <button onClick={handleRefresh}>Refresh</button>;
21
+ * }
22
+ * ```
23
+ *
24
+ * @return A function to invalidate the router.
25
+ */
26
+ export declare function useInvalidate(): () => Promise<void>;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,SAAS,GACT,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACX,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,iBAAiB,GACjB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,wBAG5B"}
@@ -0,0 +1,2 @@
1
+ export declare const lock: (object: unknown, privateData: unknown) => void, unlock: <T = any>(object: unknown) => T;
2
+ //# sourceMappingURL=lock-unlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock-unlock.d.ts","sourceRoot":"","sources":["../src/lock-unlock.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,IAAI,mDAAE,MAAM,iCAIzB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Private APIs for the boot package only.
3
+ * These are router setup and internal utilities that should not be used
4
+ * by individual routes.
5
+ */
6
+ export declare const privateApis: {};
7
+ //# sourceMappingURL=private-apis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH,eAAO,MAAM,WAAW,IAAK,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@wordpress/route",
3
+ "version": "0.1.1-next.16d95556a.0",
4
+ "description": "Routing utilities for WordPress admin interfaces.",
5
+ "author": "The WordPress Contributors",
6
+ "license": "GPL-2.0-or-later",
7
+ "keywords": [
8
+ "wordpress",
9
+ "routing"
10
+ ],
11
+ "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/route/README.md",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/WordPress/gutenberg.git",
15
+ "directory": "packages/route"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/WordPress/gutenberg/issues"
19
+ },
20
+ "engines": {
21
+ "node": ">=18.12.0",
22
+ "npm": ">=8.19.2"
23
+ },
24
+ "main": "build/index.js",
25
+ "module": "build-module/index.js",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./build-types/index.d.ts",
29
+ "import": "./build-module/index.js",
30
+ "default": "./build/index.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "react-native": "src/index",
35
+ "wpScriptModuleExports": "./build-module/index.js",
36
+ "types": "build-types",
37
+ "sideEffects": false,
38
+ "dependencies": {
39
+ "@tanstack/history": "^1.133.28",
40
+ "@tanstack/react-router": "^1.120.5",
41
+ "@wordpress/private-apis": "^1.35.1-next.16d95556a.0"
42
+ },
43
+ "peerDependencies": {
44
+ "react": "^18.0.0"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "gitHead": "59a9383612bbe16e21af84d13b035bfbca7fe833"
50
+ }
package/src/index.ts ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { useRouter } from '@tanstack/react-router';
5
+ export {
6
+ Link,
7
+ redirect,
8
+ useNavigate,
9
+ useParams,
10
+ useSearch,
11
+ } from '@tanstack/react-router';
12
+ export type {
13
+ AnyRoute,
14
+ LinkProps,
15
+ NavigateOptions,
16
+ RouteOptions,
17
+ RouterOptions,
18
+ ToOptions,
19
+ UseNavigateResult,
20
+ } from '@tanstack/react-router';
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+ export { privateApis } from './private-apis';
26
+
27
+ /**
28
+ * Hook to invalidate the router cache and trigger a re-render.
29
+ * This is useful when you want to refetch data without changing the URL.
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * function MyComponent() {
34
+ * const invalidate = useInvalidate();
35
+ *
36
+ * const handleRefresh = () => {
37
+ * invalidate();
38
+ * };
39
+ *
40
+ * return <button onClick={handleRefresh}>Refresh</button>;
41
+ * }
42
+ * ```
43
+ *
44
+ * @return A function to invalidate the router.
45
+ */
46
+ export function useInvalidate() {
47
+ const router = useRouter();
48
+ return () => router.invalidate();
49
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
5
+
6
+ export const { lock, unlock } =
7
+ __dangerousOptInToUnstableAPIsOnlyForCoreModules(
8
+ 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',
9
+ '@wordpress/route'
10
+ );
@@ -0,0 +1,50 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { parseHref } from '@tanstack/history';
5
+ import {
6
+ createBrowserHistory,
7
+ createLink,
8
+ createRootRoute,
9
+ createRoute,
10
+ createRouter,
11
+ Outlet,
12
+ redirect,
13
+ RouterProvider,
14
+ useCanGoBack,
15
+ useMatches,
16
+ useRouter,
17
+ } from '@tanstack/react-router';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { lock } from './lock-unlock';
23
+
24
+ /**
25
+ * Private APIs for the boot package only.
26
+ * These are router setup and internal utilities that should not be used
27
+ * by individual routes.
28
+ */
29
+ export const privateApis = {};
30
+
31
+ // Lock the private APIs so only authorized modules can access them
32
+ lock( privateApis, {
33
+ // Router creation and setup
34
+ createBrowserHistory,
35
+ createRouter,
36
+ createRootRoute,
37
+ createRoute,
38
+ Outlet,
39
+ RouterProvider,
40
+
41
+ // Internal routing utilities
42
+ redirect,
43
+ createLink,
44
+ useCanGoBack,
45
+ useMatches,
46
+ useRouter,
47
+
48
+ // History utilities
49
+ parseHref,
50
+ } );
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "declarationDir": "build-types"
6
+ },
7
+ "references": [
8
+ {
9
+ "path": "../private-apis"
10
+ }
11
+ ],
12
+ "include": [ "src/**/*" ]
13
+ }