@e7w/easy-routes 0.0.5 → 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/dist/assets/index.css +5 -5
- package/dist/components/DefaultOutlet.js +1 -1
- package/dist/components/ErrorBoundary.js +3 -3
- package/dist/components/Loading.js +3 -3
- package/dist/components/ProgressLayout.js +3 -3
- package/dist/models/system.d.ts +1 -0
- package/dist/models/system.js +114 -39
- package/dist/router.js +102 -36
- package/dist/utils/hooks.js +5 -5
- package/package.json +1 -1
package/dist/assets/index.css
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
|
|
70
70
|
/* GRID STYLING */
|
|
71
71
|
.spinner-box {
|
|
72
|
-
@apply top-0 left-0 w-full h-full flex justify-center items-center bg-
|
|
72
|
+
@apply top-0 left-0 w-full h-full flex justify-center items-center bg-black/30 fixed z-9999 backdrop-blur-sm;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
.leo {
|
|
@@ -77,19 +77,19 @@
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
.blue-orbit {
|
|
80
|
-
@apply w-
|
|
80
|
+
@apply w-41.25 h-41.25 border-4 border-blue-400/70 border-solid animate-[spin3D_3s_linear_0.2s_infinite];
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
.green-orbit {
|
|
84
|
-
@apply w-
|
|
84
|
+
@apply w-30 h-30 border-3 border-solid border-green-400/70 animate-[spin3D_2s_linear_0s_infinite_alternate];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
.red-orbit {
|
|
88
|
-
@apply w-
|
|
88
|
+
@apply w-22.5 h-7.5 border-2 border-solid border-orange-400/70 animate-[spin3D_1s_linear_0s_infinite_alternate];
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.white-orbit {
|
|
92
|
-
@apply w-
|
|
92
|
+
@apply w-15 h-15 border-2 border-solid border-white animate-[spin3D_10s_linear_0s_infinite_alternate];
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
.w1 {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Outlet } from "react-router";
|
|
3
|
-
export
|
|
3
|
+
export var DefaultOutlet = function () { return (_jsx(_Fragment, { children: _jsx(Outlet, {}) })); };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { isRouteErrorResponse, useRouteError } from "react-router";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
return (_jsx("div", { className: "flex h-
|
|
3
|
+
export var ErrorBoundary = function () {
|
|
4
|
+
var error = useRouteError();
|
|
5
|
+
return (_jsx("div", { className: "flex h-screen w-full items-center justify-center", children: _jsxs("div", { className: "flex flex-col items-center justify-center", children: [_jsx("h1", { className: "text-2xl font-bold mb-4", children: "Error" }), _jsx("p", { children: "Something went wrong." }), isRouteErrorResponse(error) && (_jsxs(_Fragment, { children: [_jsxs("p", { className: "text-red-300", children: [error.status, " ", error.statusText] }), _jsx("p", { className: "text-red-300", children: JSON.stringify(error.data) })] })), error instanceof Error && (_jsx("p", { className: "text-red-300", children: error.message }))] }) }));
|
|
6
6
|
};
|
|
@@ -3,9 +3,9 @@ import {} from "react";
|
|
|
3
3
|
import { useDebouncedValue } from "../utils/hooks";
|
|
4
4
|
import { useLoader } from "@e7w/easy-model";
|
|
5
5
|
import "../assets/index.css";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export var Loading = function () {
|
|
7
|
+
var isGlobalLoading = useLoader().isGlobalLoading;
|
|
8
|
+
var visible = useDebouncedValue(isGlobalLoading);
|
|
9
9
|
if (!visible)
|
|
10
10
|
return;
|
|
11
11
|
return (_jsxs("div", { className: "spinner-box", children: [_jsx("div", { className: "blue-orbit leo" }), _jsx("div", { className: "green-orbit leo" }), _jsx("div", { className: "red-orbit leo" }), _jsx("div", { className: "white-orbit w1 leo" }), _jsx("div", { className: "white-orbit w2 leo" }), _jsx("div", { className: "white-orbit w3 leo" })] }));
|
|
@@ -11,9 +11,9 @@ nProgress.configure({
|
|
|
11
11
|
easing: "ease", // 动画缓动函数
|
|
12
12
|
trickleSpeed: 200, // 进度条自动递增的频率(毫秒)
|
|
13
13
|
});
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
useEffect(()
|
|
14
|
+
export var ProgressLayout = function () {
|
|
15
|
+
var state = useNavigation().state;
|
|
16
|
+
useEffect(function () {
|
|
17
17
|
if (state === "loading") {
|
|
18
18
|
nProgress.start();
|
|
19
19
|
}
|
package/dist/models/system.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface RouterSchema {
|
|
|
9
9
|
export declare const routerSchema: z.ZodType<RouterSchema, RouterSchema>;
|
|
10
10
|
export declare const system: {
|
|
11
11
|
router: RouterSchema;
|
|
12
|
+
ready: boolean;
|
|
12
13
|
init(): Promise<void>;
|
|
13
14
|
hasPermission(permission?: number): boolean;
|
|
14
15
|
getCtx(params: Params, request: Request, permission?: number): Ctx;
|
package/dist/models/system.js
CHANGED
|
@@ -32,53 +32,128 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
32
32
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
33
|
done = true;
|
|
34
34
|
};
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
35
71
|
import { inject, loader, provide } from "@e7w/easy-model";
|
|
36
72
|
import z from "zod";
|
|
37
|
-
export
|
|
73
|
+
export var routerSchema = z.object({
|
|
38
74
|
init: z.function({
|
|
39
75
|
output: z.union([z.promise(z.void()), z.void()]),
|
|
40
76
|
}),
|
|
41
77
|
permission: z.number(),
|
|
42
78
|
defaultTitle: z.string().optional(),
|
|
43
79
|
});
|
|
44
|
-
export
|
|
80
|
+
export var system = provide((function () {
|
|
45
81
|
var _a;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return class
|
|
52
|
-
|
|
53
|
-
|
|
82
|
+
var _instanceExtraInitializers = [];
|
|
83
|
+
var _router_decorators;
|
|
84
|
+
var _router_initializers = [];
|
|
85
|
+
var _router_extraInitializers = [];
|
|
86
|
+
var _init_decorators;
|
|
87
|
+
return _a = /** @class */ (function () {
|
|
88
|
+
function System() {
|
|
89
|
+
Object.defineProperty(this, "router", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _router_initializers, {
|
|
94
|
+
init: function () { },
|
|
95
|
+
permission: 0,
|
|
96
|
+
defaultTitle: document.title,
|
|
97
|
+
}))
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(this, "ready", {
|
|
100
|
+
enumerable: true,
|
|
101
|
+
configurable: true,
|
|
102
|
+
writable: true,
|
|
103
|
+
value: (__runInitializers(this, _router_extraInitializers), false)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
Object.defineProperty(System.prototype, "init", {
|
|
107
|
+
enumerable: false,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
value: function () {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
return __generator(this, function (_b) {
|
|
113
|
+
switch (_b.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, this.router.init()];
|
|
115
|
+
case 1:
|
|
116
|
+
_b.sent();
|
|
117
|
+
this.ready = true;
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(System.prototype, "hasPermission", {
|
|
125
|
+
enumerable: false,
|
|
126
|
+
configurable: true,
|
|
127
|
+
writable: true,
|
|
128
|
+
value: function (permission) {
|
|
129
|
+
if (permission === void 0) { permission = 0; }
|
|
130
|
+
return (this.router.permission & permission) === permission;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(System.prototype, "getCtx", {
|
|
134
|
+
enumerable: false,
|
|
135
|
+
configurable: true,
|
|
136
|
+
writable: true,
|
|
137
|
+
value: function (params, request, permission) {
|
|
138
|
+
if (permission === void 0) { permission = 1; }
|
|
139
|
+
return {
|
|
140
|
+
title: this.router.defaultTitle || document.title,
|
|
141
|
+
signed: (permission & 1) === 0 || this.hasPermission(1),
|
|
142
|
+
noPermission: !this.hasPermission(permission),
|
|
143
|
+
params: params,
|
|
144
|
+
query: Object.fromEntries(new URL(request.url).searchParams),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return System;
|
|
149
|
+
}()),
|
|
150
|
+
(function () {
|
|
151
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
54
152
|
_router_decorators = [inject(routerSchema)];
|
|
55
|
-
_init_decorators = [
|
|
56
|
-
__esDecorate(
|
|
57
|
-
__esDecorate(null, null, _router_decorators, { kind: "field", name: "router", static: false, private: false, access: { has: obj
|
|
58
|
-
if (_metadata) Object.defineProperty(
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
init() { },
|
|
62
|
-
permission: 0,
|
|
63
|
-
defaultTitle: document.title,
|
|
64
|
-
}));
|
|
65
|
-
async init() {
|
|
66
|
-
await this.router.init();
|
|
67
|
-
}
|
|
68
|
-
hasPermission(permission = 0) {
|
|
69
|
-
return (this.router.permission & permission) === permission;
|
|
70
|
-
}
|
|
71
|
-
getCtx(params, request, permission = 1) {
|
|
72
|
-
return {
|
|
73
|
-
title: this.router.defaultTitle || document.title,
|
|
74
|
-
signed: (permission & 1) === 0 || this.hasPermission(1),
|
|
75
|
-
noPermission: !this.hasPermission(permission),
|
|
76
|
-
params,
|
|
77
|
-
query: Object.fromEntries(new URL(request.url).searchParams),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
constructor() {
|
|
81
|
-
__runInitializers(this, _router_extraInitializers);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
153
|
+
_init_decorators = [loader.load(true)];
|
|
154
|
+
__esDecorate(_a, null, _init_decorators, { kind: "method", name: "init", static: false, private: false, access: { has: function (obj) { return "init" in obj; }, get: function (obj) { return obj.init; } }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
155
|
+
__esDecorate(null, null, _router_decorators, { kind: "field", name: "router", static: false, private: false, access: { has: function (obj) { return "router" in obj; }, get: function (obj) { return obj.router; }, set: function (obj, value) { obj.router = value; } }, metadata: _metadata }, _router_initializers, _router_extraInitializers);
|
|
156
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
157
|
+
})(),
|
|
158
|
+
_a;
|
|
84
159
|
})())();
|
package/dist/router.js
CHANGED
|
@@ -1,71 +1,137 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
1
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
49
|
import { Navigate, redirect } from "react-router";
|
|
3
50
|
import { DefaultOutlet } from "./components/DefaultOutlet";
|
|
4
51
|
import { ErrorBoundary } from "./components/ErrorBoundary";
|
|
5
52
|
import { ProgressLayout } from "./components/ProgressLayout";
|
|
6
53
|
import { system } from "./models/system";
|
|
7
|
-
|
|
54
|
+
var pages = import.meta.glob("/src/pages/**/index.tsx", {
|
|
8
55
|
eager: true,
|
|
9
56
|
import: "Page",
|
|
10
57
|
});
|
|
11
|
-
|
|
58
|
+
var layouts = import.meta.glob("/src/pages/**/layout.tsx", {
|
|
12
59
|
eager: true,
|
|
13
60
|
import: "Layout",
|
|
14
61
|
});
|
|
15
|
-
|
|
62
|
+
var metas = import.meta.glob("/src/pages/**/meta.ts", {
|
|
16
63
|
eager: true,
|
|
17
64
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
65
|
+
var routes = [];
|
|
66
|
+
var obj = {};
|
|
67
|
+
var filePaths = new Set(Object.keys(__assign(__assign({}, pages), layouts)).map(function (p) {
|
|
68
|
+
return p.replace(/\/(index|layout)\.tsx$/, "");
|
|
69
|
+
}));
|
|
70
|
+
filePaths.forEach(function (filePath) {
|
|
71
|
+
var pagePath = filePath + "/index.tsx";
|
|
72
|
+
var Page = pages[pagePath];
|
|
73
|
+
var layoutPath = filePath + "/layout.tsx";
|
|
74
|
+
var Layout = layouts[layoutPath] || DefaultOutlet;
|
|
75
|
+
var metaPath = filePath + "/meta.ts";
|
|
76
|
+
var meta = metas[metaPath] || {};
|
|
77
|
+
var path = filePath.replace(/.*\/pages/, "").replace(/\[([^\]]+)\]/, ":$1") || "/";
|
|
78
|
+
var hasPage = Boolean(Page);
|
|
30
79
|
obj[path] = {
|
|
31
|
-
path,
|
|
80
|
+
path: path,
|
|
32
81
|
element: _jsx(Layout, {}),
|
|
33
82
|
children: [
|
|
34
83
|
{
|
|
35
84
|
element: hasPage ? _jsx(Page, {}) : _jsx(Navigate, { to: "/", replace: true }),
|
|
36
85
|
index: true,
|
|
37
86
|
loader: hasPage
|
|
38
|
-
?
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
87
|
+
? function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
88
|
+
var ctx;
|
|
89
|
+
var _c, _d, _e, _f;
|
|
90
|
+
var params = _b.params, request = _b.request;
|
|
91
|
+
return __generator(this, function (_g) {
|
|
92
|
+
switch (_g.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
if (!!system.ready) return [3 /*break*/, 2];
|
|
95
|
+
return [4 /*yield*/, ((_c = system.init()) === null || _c === void 0 ? void 0 : _c.catch(function () { }))];
|
|
96
|
+
case 1:
|
|
97
|
+
_g.sent();
|
|
98
|
+
_g.label = 2;
|
|
99
|
+
case 2:
|
|
100
|
+
ctx = system.getCtx(params, request, meta.permission);
|
|
101
|
+
return [4 /*yield*/, ((_f = (_e = (_d = meta.loader) === null || _d === void 0 ? void 0 : _d.call(meta, ctx, meta)) === null || _e === void 0 ? void 0 : _e.catch) === null || _f === void 0 ? void 0 : _f.call(_e, function () { }))];
|
|
102
|
+
case 3:
|
|
103
|
+
_g.sent();
|
|
104
|
+
if (!ctx.signed) {
|
|
105
|
+
system.ready = false;
|
|
106
|
+
return [2 /*return*/, redirect("/login")];
|
|
107
|
+
}
|
|
108
|
+
if (ctx.noPermission)
|
|
109
|
+
return [2 /*return*/, redirect("/403")];
|
|
110
|
+
document.title = ctx.title;
|
|
111
|
+
return [2 /*return*/, ctx.data];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); }
|
|
49
115
|
: undefined,
|
|
50
116
|
},
|
|
51
117
|
],
|
|
52
118
|
};
|
|
53
119
|
});
|
|
54
|
-
filePaths.forEach((filePath)
|
|
55
|
-
|
|
120
|
+
filePaths.forEach(function (filePath) {
|
|
121
|
+
var path = filePath.replace(/.*\/pages/, "").replace(/\[([^\]]+)\]/, ":$1") || "/";
|
|
56
122
|
if (path === "/")
|
|
57
123
|
return;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
segments.reduce((acc, curr)
|
|
62
|
-
|
|
124
|
+
var currentObj = obj[path];
|
|
125
|
+
var segments = path.split("/").filter(Boolean);
|
|
126
|
+
var paths = ["/"];
|
|
127
|
+
segments.reduce(function (acc, curr) {
|
|
128
|
+
var newPath = acc + "/" + curr;
|
|
63
129
|
if (newPath !== path)
|
|
64
130
|
paths.unshift(newPath);
|
|
65
131
|
return newPath;
|
|
66
132
|
}, "");
|
|
67
|
-
for (
|
|
68
|
-
|
|
133
|
+
for (var index = 0; index < paths.length; index++) {
|
|
134
|
+
var p = paths[index];
|
|
69
135
|
if (obj[p]) {
|
|
70
136
|
obj[p].children.push(currentObj);
|
|
71
137
|
break;
|
package/dist/utils/hooks.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
export function useDebouncedValue(value) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
useEffect(()
|
|
3
|
+
var _a = useState(value), result = _a[0], setResult = _a[1];
|
|
4
|
+
var timer = useRef(undefined);
|
|
5
|
+
useEffect(function () {
|
|
6
6
|
clearTimeout(timer.current);
|
|
7
|
-
timer.current = window.setTimeout(()
|
|
7
|
+
timer.current = window.setTimeout(function () {
|
|
8
8
|
setResult(value);
|
|
9
9
|
}, 700);
|
|
10
|
-
return ()
|
|
10
|
+
return function () {
|
|
11
11
|
window.clearTimeout(timer.current);
|
|
12
12
|
};
|
|
13
13
|
}, [result, value]);
|