@koordinates/xstate-tree 4.3.0-beta.2 → 4.3.0-beta.3
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/lib/routing/index.js +2 -1
- package/lib/routing/providers.js +9 -1
- package/lib/xstateTree.js +8 -0
- package/package.json +4 -3
package/lib/routing/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestRoutingContext = exports.RoutingContext = exports.useRouteArgsIfActive = exports.useIsRouteActive = exports.handleLocationChange = exports.matchRoute = exports.Link = exports.joinRoutes = exports.buildCreateRoute = void 0;
|
|
3
|
+
exports.useInRoutingContext = exports.TestRoutingContext = exports.RoutingContext = exports.useRouteArgsIfActive = exports.useIsRouteActive = exports.handleLocationChange = exports.matchRoute = exports.Link = exports.joinRoutes = exports.buildCreateRoute = void 0;
|
|
4
4
|
var createRoute_1 = require("./createRoute");
|
|
5
5
|
Object.defineProperty(exports, "buildCreateRoute", { enumerable: true, get: function () { return createRoute_1.buildCreateRoute; } });
|
|
6
6
|
var joinRoutes_1 = require("./joinRoutes");
|
|
@@ -18,3 +18,4 @@ Object.defineProperty(exports, "useRouteArgsIfActive", { enumerable: true, get:
|
|
|
18
18
|
var providers_1 = require("./providers");
|
|
19
19
|
Object.defineProperty(exports, "RoutingContext", { enumerable: true, get: function () { return providers_1.RoutingContext; } });
|
|
20
20
|
Object.defineProperty(exports, "TestRoutingContext", { enumerable: true, get: function () { return providers_1.TestRoutingContext; } });
|
|
21
|
+
Object.defineProperty(exports, "useInRoutingContext", { enumerable: true, get: function () { return providers_1.useInRoutingContext; } });
|
package/lib/routing/providers.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TestRoutingContext = exports.useActiveRouteEvents = exports.RoutingContext = void 0;
|
|
6
|
+
exports.TestRoutingContext = exports.useActiveRouteEvents = exports.useInRoutingContext = exports.RoutingContext = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const react_2 = require("react");
|
|
9
9
|
exports.RoutingContext = (0, react_2.createContext)(undefined);
|
|
@@ -14,6 +14,14 @@ function useRoutingContext() {
|
|
|
14
14
|
}
|
|
15
15
|
return context;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
function useInRoutingContext() {
|
|
21
|
+
const context = (0, react_2.useContext)(exports.RoutingContext);
|
|
22
|
+
return context !== undefined;
|
|
23
|
+
}
|
|
24
|
+
exports.useInRoutingContext = useInRoutingContext;
|
|
17
25
|
function useActiveRouteEvents() {
|
|
18
26
|
var _a;
|
|
19
27
|
try {
|
package/lib/xstateTree.js
CHANGED
|
@@ -251,6 +251,14 @@ function buildRootComponent(machine, routing) {
|
|
|
251
251
|
const setActiveRouteEvents = (events) => {
|
|
252
252
|
activeRouteEventsRef.current = events;
|
|
253
253
|
};
|
|
254
|
+
const insideRoutingContext = (0, routing_1.useInRoutingContext)();
|
|
255
|
+
if (insideRoutingContext && typeof routing !== "undefined") {
|
|
256
|
+
const m = "Routing root rendered inside routing context, this implies a bug";
|
|
257
|
+
if (process.env.NODE_ENV !== "production") {
|
|
258
|
+
throw new Error(m);
|
|
259
|
+
}
|
|
260
|
+
console.error(m);
|
|
261
|
+
}
|
|
254
262
|
(0, react_2.useEffect)(() => {
|
|
255
263
|
function handler(event) {
|
|
256
264
|
recursivelySend(interpreter, event);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@koordinates/xstate-tree",
|
|
3
3
|
"main": "lib/index.js",
|
|
4
4
|
"types": "lib/xstate-tree.d.ts",
|
|
5
|
-
"version": "4.3.0-beta.
|
|
5
|
+
"version": "4.3.0-beta.3",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Build UIs with Actors using xstate and React",
|
|
8
8
|
"keywords": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@testing-library/user-event": "^14.4.3",
|
|
38
38
|
"@types/history": "^4.7.7",
|
|
39
39
|
"@types/jest": "^28.1.4",
|
|
40
|
+
"@types/node": "^20.4.9",
|
|
40
41
|
"@types/react": "^17.0.29",
|
|
41
42
|
"@types/react-dom": "^18.0.6",
|
|
42
43
|
"@types/testing-library__jest-dom": "^5.14.1",
|
|
@@ -72,9 +73,9 @@
|
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"@xstate/react": "^3.x",
|
|
76
|
+
"react": ">= 16.8.0 < 19.0.0",
|
|
75
77
|
"xstate": ">= 4.20 < 5.0.0",
|
|
76
|
-
"zod": "^3.x"
|
|
77
|
-
"react": ">= 16.8.0 < 19.0.0"
|
|
78
|
+
"zod": "^3.x"
|
|
78
79
|
},
|
|
79
80
|
"scripts": {
|
|
80
81
|
"lint": "eslint 'src/**/*'",
|