@e7w/easy-routes 0.1.2 → 0.1.4
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 +3 -1
- package/dist/index.d.mts +26 -0
- package/dist/index.mjs +470 -0
- package/dist/style.css +838 -0
- package/package.json +33 -11
- package/tsconfig.json +2 -1
- package/dist/assets/index.css +0 -109
- package/dist/components/DefaultOutlet.d.ts +0 -2
- package/dist/components/DefaultOutlet.js +0 -3
- package/dist/components/ErrorBoundary.d.ts +0 -2
- package/dist/components/ErrorBoundary.js +0 -6
- package/dist/components/Loading.d.ts +0 -3
- package/dist/components/Loading.js +0 -12
- package/dist/components/ProgressLayout.d.ts +0 -3
- package/dist/components/ProgressLayout.js +0 -25
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/models/system.d.ts +0 -7
- package/dist/models/system.js +0 -145
- package/dist/router.d.ts +0 -3
- package/dist/router.js +0 -153
- package/dist/types/index.d.ts +0 -23
- package/dist/types/index.js +0 -20
- package/dist/utils/hooks.d.ts +0 -1
- package/dist/utils/hooks.js +0 -15
package/package.json
CHANGED
|
@@ -1,43 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e7w/easy-routes",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
".": "./dist/index.mjs",
|
|
11
|
+
"./package.json": "./package.json",
|
|
12
|
+
"./style.css": "./dist/style.css"
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
|
14
|
-
"build": "
|
|
15
|
-
"lint": "
|
|
15
|
+
"build": "vp pack",
|
|
16
|
+
"lint": "vp lint . --fix",
|
|
17
|
+
"prepare": "vp config",
|
|
18
|
+
"prepublishOnly": "vp pack"
|
|
16
19
|
},
|
|
17
20
|
"dependencies": {
|
|
18
21
|
"@e7w/easy-model": "^0.2.1",
|
|
19
22
|
"nprogress": "^0.2.0",
|
|
20
23
|
"react": "^19.2.0",
|
|
21
24
|
"react-router": "^7.13.1",
|
|
22
|
-
"tailwindcss": "^4.2.1",
|
|
23
25
|
"zod": "^4.3.6"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
28
|
+
"@babel/core": "^7.29.0",
|
|
29
|
+
"@babel/plugin-proposal-decorators": "^7.29.0",
|
|
30
|
+
"@bosh-code/tsdown-plugin-inject-css": "^2.0.0",
|
|
31
|
+
"@bosh-code/tsdown-plugin-tailwindcss": "^1.0.1",
|
|
26
32
|
"@eslint/js": "^9.39.1",
|
|
33
|
+
"@rolldown/plugin-babel": "^0.2.2",
|
|
34
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
35
|
+
"@tsdown/css": "^0.21.5",
|
|
27
36
|
"@types/node": "^24.10.1",
|
|
28
37
|
"@types/nprogress": "^0.2.3",
|
|
29
38
|
"@types/react": "^19.2.7",
|
|
30
39
|
"@types/react-dom": "^19.2.3",
|
|
31
|
-
"@
|
|
40
|
+
"@typescript/native-preview": "7.0.0-dev.20260326.1",
|
|
41
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
42
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
32
43
|
"copyfiles": "^2.4.1",
|
|
33
|
-
"eslint": "^9.39.1",
|
|
34
44
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
35
45
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
36
46
|
"globals": "^16.5.0",
|
|
47
|
+
"tailwindcss": "^4.2.1",
|
|
37
48
|
"typescript": "~5.9.3",
|
|
38
49
|
"typescript-eslint": "^8.48.0",
|
|
39
|
-
"vite": "
|
|
40
|
-
"
|
|
50
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
51
|
+
"vite-plus": "latest",
|
|
52
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
41
53
|
},
|
|
42
54
|
"files": [
|
|
43
55
|
"dist",
|
|
@@ -45,5 +57,15 @@
|
|
|
45
57
|
"LICENSE.md",
|
|
46
58
|
"tsconfig.json"
|
|
47
59
|
],
|
|
48
|
-
"license": "MIT"
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"packageManager": "pnpm@10.33.0",
|
|
62
|
+
"pnpm": {
|
|
63
|
+
"overrides": {
|
|
64
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
65
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
66
|
+
},
|
|
67
|
+
"onlyBuiltDependencies": [
|
|
68
|
+
"esbuild"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
49
71
|
}
|
package/tsconfig.json
CHANGED
package/dist/assets/index.css
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
@import "tailwindcss";
|
|
2
|
-
|
|
3
|
-
/* KEYFRAMES */
|
|
4
|
-
|
|
5
|
-
@keyframes spin {
|
|
6
|
-
from {
|
|
7
|
-
transform: rotate(0);
|
|
8
|
-
}
|
|
9
|
-
to {
|
|
10
|
-
transform: rotate(359deg);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@keyframes spin3D {
|
|
15
|
-
from {
|
|
16
|
-
transform: rotate3d(0.5, 0.5, 0.5, 360deg);
|
|
17
|
-
}
|
|
18
|
-
to {
|
|
19
|
-
transform: rotate3d(0deg);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@keyframes configure-clockwise {
|
|
24
|
-
0% {
|
|
25
|
-
transform: rotate(0);
|
|
26
|
-
}
|
|
27
|
-
25% {
|
|
28
|
-
transform: rotate(90deg);
|
|
29
|
-
}
|
|
30
|
-
50% {
|
|
31
|
-
transform: rotate(180deg);
|
|
32
|
-
}
|
|
33
|
-
75% {
|
|
34
|
-
transform: rotate(270deg);
|
|
35
|
-
}
|
|
36
|
-
100% {
|
|
37
|
-
transform: rotate(360deg);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@keyframes configure-xclockwise {
|
|
42
|
-
0% {
|
|
43
|
-
transform: rotate(45deg);
|
|
44
|
-
}
|
|
45
|
-
25% {
|
|
46
|
-
transform: rotate(-45deg);
|
|
47
|
-
}
|
|
48
|
-
50% {
|
|
49
|
-
transform: rotate(-135deg);
|
|
50
|
-
}
|
|
51
|
-
75% {
|
|
52
|
-
transform: rotate(-225deg);
|
|
53
|
-
}
|
|
54
|
-
100% {
|
|
55
|
-
transform: rotate(-315deg);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@keyframes pulse {
|
|
60
|
-
from {
|
|
61
|
-
opacity: 1;
|
|
62
|
-
transform: scale(1);
|
|
63
|
-
}
|
|
64
|
-
to {
|
|
65
|
-
opacity: 0.25;
|
|
66
|
-
transform: scale(0.75);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* GRID STYLING */
|
|
71
|
-
.spinner-box {
|
|
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
|
-
}
|
|
74
|
-
|
|
75
|
-
.leo {
|
|
76
|
-
@apply absolute flex justify-center items-center rounded-full;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.blue-orbit {
|
|
80
|
-
@apply w-41.25 h-41.25 border-4 border-blue-400/70 border-solid animate-[spin3D_3s_linear_0.2s_infinite];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.green-orbit {
|
|
84
|
-
@apply w-30 h-30 border-3 border-solid border-green-400/70 animate-[spin3D_2s_linear_0s_infinite_alternate];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.red-orbit {
|
|
88
|
-
@apply w-22.5 h-7.5 border-2 border-solid border-orange-400/70 animate-[spin3D_1s_linear_0s_infinite_alternate];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.white-orbit {
|
|
92
|
-
@apply w-15 h-15 border-2 border-solid border-white animate-[spin3D_10s_linear_0s_infinite_alternate];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.w1 {
|
|
96
|
-
transform: rotate3D(1, 1, 1, 90deg);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.w2 {
|
|
100
|
-
transform: rotate3D(1, 2, 0.5, 90deg);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.w3 {
|
|
104
|
-
transform: rotate3D(0.5, 1, 2, 90deg);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.markdown-body {
|
|
108
|
-
background-color: var(--color-base-300);
|
|
109
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { isRouteErrorResponse, useRouteError } from "react-router";
|
|
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
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {} from "react";
|
|
3
|
-
import { useDebouncedValue } from "../utils/hooks";
|
|
4
|
-
import { useLoader } from "@e7w/easy-model";
|
|
5
|
-
import "../assets/index.css";
|
|
6
|
-
export var Loading = function () {
|
|
7
|
-
var isGlobalLoading = useLoader().isGlobalLoading;
|
|
8
|
-
var visible = useDebouncedValue(isGlobalLoading);
|
|
9
|
-
if (!visible)
|
|
10
|
-
return;
|
|
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" })] }));
|
|
12
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { Outlet, useNavigation } from "react-router";
|
|
4
|
-
import nProgress from "nprogress";
|
|
5
|
-
import "nprogress/nprogress.css";
|
|
6
|
-
import { Loading } from "./Loading";
|
|
7
|
-
nProgress.configure({
|
|
8
|
-
showSpinner: false, // 是否显示右上角螺旋加载提示(通常关掉更简洁)
|
|
9
|
-
speed: 500, // 动画速度(毫秒)
|
|
10
|
-
minimum: 0.1, // 进度条开始时的最小百分比
|
|
11
|
-
easing: "ease", // 动画缓动函数
|
|
12
|
-
trickleSpeed: 200, // 进度条自动递增的频率(毫秒)
|
|
13
|
-
});
|
|
14
|
-
export var ProgressLayout = function () {
|
|
15
|
-
var state = useNavigation().state;
|
|
16
|
-
useEffect(function () {
|
|
17
|
-
if (state === "loading") {
|
|
18
|
-
nProgress.start();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
nProgress.done();
|
|
22
|
-
}
|
|
23
|
-
}, [state]);
|
|
24
|
-
return (_jsxs(_Fragment, { children: [_jsx(Outlet, {}), _jsx(Loading, {})] }));
|
|
25
|
-
};
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
package/dist/models/system.d.ts
DELETED
package/dist/models/system.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
-
var useValue = arguments.length > 2;
|
|
3
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
-
}
|
|
6
|
-
return useValue ? value : void 0;
|
|
7
|
-
};
|
|
8
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
-
var _, done = false;
|
|
14
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
-
var context = {};
|
|
16
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
-
if (kind === "accessor") {
|
|
21
|
-
if (result === void 0) continue;
|
|
22
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
-
}
|
|
27
|
-
else if (_ = accept(result)) {
|
|
28
|
-
if (kind === "field") initializers.unshift(_);
|
|
29
|
-
else descriptor[key] = _;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
-
done = true;
|
|
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
|
-
};
|
|
71
|
-
import { inject, loader, provide } from "@e7w/easy-model";
|
|
72
|
-
import { Permission, PermissionSchema } from "../types";
|
|
73
|
-
export var system = provide((function () {
|
|
74
|
-
var _a;
|
|
75
|
-
var _b;
|
|
76
|
-
var _instanceExtraInitializers = [];
|
|
77
|
-
var _router_decorators;
|
|
78
|
-
var _router_initializers = [];
|
|
79
|
-
var _router_extraInitializers = [];
|
|
80
|
-
var _init_decorators;
|
|
81
|
-
return _a = /** @class */ (function () {
|
|
82
|
-
function System() {
|
|
83
|
-
Object.defineProperty(this, "router", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
configurable: true,
|
|
86
|
-
writable: true,
|
|
87
|
-
value: (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _router_initializers, void 0))
|
|
88
|
-
});
|
|
89
|
-
__runInitializers(this, _router_extraInitializers);
|
|
90
|
-
}
|
|
91
|
-
Object.defineProperty(System.prototype, "init", {
|
|
92
|
-
enumerable: false,
|
|
93
|
-
configurable: true,
|
|
94
|
-
writable: true,
|
|
95
|
-
value: function (req) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
var _b;
|
|
98
|
-
return __generator(this, function (_c) {
|
|
99
|
-
switch (_c.label) {
|
|
100
|
-
case 0: return [4 /*yield*/, ((_b = this.router) === null || _b === void 0 ? void 0 : _b.init(req))];
|
|
101
|
-
case 1:
|
|
102
|
-
_c.sent();
|
|
103
|
-
return [2 /*return*/];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
Object.defineProperty(System.prototype, "hasPermission", {
|
|
110
|
-
enumerable: false,
|
|
111
|
-
configurable: true,
|
|
112
|
-
writable: true,
|
|
113
|
-
value: function (permission) {
|
|
114
|
-
var _b;
|
|
115
|
-
if (permission === void 0) { permission = 0; }
|
|
116
|
-
return ((((_b = this.router) === null || _b === void 0 ? void 0 : _b.permission) || 0) & permission) === permission;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
Object.defineProperty(System.prototype, "getCtx", {
|
|
120
|
-
enumerable: false,
|
|
121
|
-
configurable: true,
|
|
122
|
-
writable: true,
|
|
123
|
-
value: function (req, permission) {
|
|
124
|
-
var _b, _c;
|
|
125
|
-
if (permission === void 0) { permission = 1; }
|
|
126
|
-
return {
|
|
127
|
-
title: (_c = (_b = this.router) === null || _b === void 0 ? void 0 : _b.defaultTitle) !== null && _c !== void 0 ? _c : document.title,
|
|
128
|
-
signed: (permission & 1) === 0 || this.hasPermission(1),
|
|
129
|
-
noPermission: !this.hasPermission(permission),
|
|
130
|
-
req: req,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return System;
|
|
135
|
-
}()),
|
|
136
|
-
(function () {
|
|
137
|
-
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
138
|
-
_router_decorators = [inject(PermissionSchema)];
|
|
139
|
-
_init_decorators = [(_b = loader).once.bind(_b), loader.load(true)];
|
|
140
|
-
__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);
|
|
141
|
-
__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);
|
|
142
|
-
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
143
|
-
})(),
|
|
144
|
-
_a;
|
|
145
|
-
})())();
|
package/dist/router.d.ts
DELETED
package/dist/router.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
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
|
-
};
|
|
48
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
49
|
-
import { Navigate, redirect } from "react-router";
|
|
50
|
-
import { DefaultOutlet } from "./components/DefaultOutlet";
|
|
51
|
-
import { ErrorBoundary } from "./components/ErrorBoundary";
|
|
52
|
-
import { ProgressLayout } from "./components/ProgressLayout";
|
|
53
|
-
import { system } from "./models/system";
|
|
54
|
-
var pages = import.meta.glob("/src/**/pages/**/index.tsx", {
|
|
55
|
-
eager: true,
|
|
56
|
-
import: "Page",
|
|
57
|
-
});
|
|
58
|
-
var layouts = import.meta.glob("/src/**/pages/**/layout.tsx", {
|
|
59
|
-
eager: true,
|
|
60
|
-
import: "Layout",
|
|
61
|
-
});
|
|
62
|
-
var metas = import.meta.glob("/src/**/pages/**/meta.ts", {
|
|
63
|
-
eager: true,
|
|
64
|
-
});
|
|
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);
|
|
79
|
-
obj[path] = {
|
|
80
|
-
path: path,
|
|
81
|
-
element: _jsx(Layout, {}),
|
|
82
|
-
children: [
|
|
83
|
-
{
|
|
84
|
-
element: hasPage ? _jsx(Page, {}) : _jsx(Navigate, { to: "/", replace: true }),
|
|
85
|
-
index: true,
|
|
86
|
-
loader: hasPage
|
|
87
|
-
? function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
88
|
-
var url, req, ctx;
|
|
89
|
-
var _c, _d, _e, _f, _g;
|
|
90
|
-
var params = _b.params, request = _b.request;
|
|
91
|
-
return __generator(this, function (_h) {
|
|
92
|
-
switch (_h.label) {
|
|
93
|
-
case 0:
|
|
94
|
-
url = new URL(request.url);
|
|
95
|
-
req = {
|
|
96
|
-
params: params,
|
|
97
|
-
query: Object.fromEntries(url.searchParams),
|
|
98
|
-
pathname: url.pathname.replace(/\/?$/, "/"),
|
|
99
|
-
};
|
|
100
|
-
return [4 /*yield*/, ((_d = (_c = system.init(req)) === null || _c === void 0 ? void 0 : _c.catch) === null || _d === void 0 ? void 0 : _d.call(_c, function () { }))];
|
|
101
|
-
case 1:
|
|
102
|
-
_h.sent();
|
|
103
|
-
ctx = system.getCtx(req, meta.permission);
|
|
104
|
-
return [4 /*yield*/, ((_g = (_f = (_e = meta.loader) === null || _e === void 0 ? void 0 : _e.call(meta, ctx)) === null || _f === void 0 ? void 0 : _f.catch) === null || _g === void 0 ? void 0 : _g.call(_f, function () { }))];
|
|
105
|
-
case 2:
|
|
106
|
-
_h.sent();
|
|
107
|
-
if (!ctx.signed) {
|
|
108
|
-
return [2 /*return*/, redirect("/login?from=".concat(encodeURIComponent(request.url)))];
|
|
109
|
-
}
|
|
110
|
-
if (ctx.noPermission)
|
|
111
|
-
return [2 /*return*/, redirect("/403")];
|
|
112
|
-
document.title = ctx.title;
|
|
113
|
-
return [2 /*return*/, ctx.data];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}); }
|
|
117
|
-
: undefined,
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
filePaths.forEach(function (filePath) {
|
|
123
|
-
var path = filePath.replace(/.*\/pages/, "").replace(/\[([^\]]+)\]/, ":$1") || "/";
|
|
124
|
-
if (path === "/")
|
|
125
|
-
return;
|
|
126
|
-
var currentObj = obj[path];
|
|
127
|
-
var segments = path.split("/").filter(Boolean);
|
|
128
|
-
var paths = ["/"];
|
|
129
|
-
segments.reduce(function (acc, curr) {
|
|
130
|
-
var newPath = acc + "/" + curr;
|
|
131
|
-
if (newPath !== path)
|
|
132
|
-
paths.unshift(newPath);
|
|
133
|
-
return newPath;
|
|
134
|
-
}, "");
|
|
135
|
-
for (var index = 0; index < paths.length; index++) {
|
|
136
|
-
var p = paths[index];
|
|
137
|
-
if (obj[p]) {
|
|
138
|
-
obj[p].children.push(currentObj);
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
obj["/"].errorElement = _jsx(ErrorBoundary, {});
|
|
144
|
-
routes.push({
|
|
145
|
-
path: "/",
|
|
146
|
-
element: _jsx(ProgressLayout, {}),
|
|
147
|
-
children: [obj["/"]],
|
|
148
|
-
});
|
|
149
|
-
routes.push({
|
|
150
|
-
path: "*",
|
|
151
|
-
element: _jsx(Navigate, { to: obj["/404"] ? "/404" : "/", replace: true }),
|
|
152
|
-
});
|
|
153
|
-
export { routes };
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Params } from "react-router";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
export interface Ctx {
|
|
4
|
-
title: string;
|
|
5
|
-
signed: boolean;
|
|
6
|
-
noPermission: boolean;
|
|
7
|
-
req: {
|
|
8
|
-
params: Params;
|
|
9
|
-
query: Params;
|
|
10
|
-
pathname: string;
|
|
11
|
-
};
|
|
12
|
-
data?: any;
|
|
13
|
-
}
|
|
14
|
-
export type Meta = {
|
|
15
|
-
permission?: number;
|
|
16
|
-
loader?(ctx: Ctx): void | Promise<void>;
|
|
17
|
-
} & Record<string, unknown>;
|
|
18
|
-
export declare abstract class Permission {
|
|
19
|
-
permission: number;
|
|
20
|
-
abstract defaultTitle: string;
|
|
21
|
-
abstract init(req: Ctx['req']): Promise<void> | void;
|
|
22
|
-
}
|
|
23
|
-
export declare const PermissionSchema: z.ZodType<Permission, Permission>;
|
package/dist/types/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
var Permission = /** @class */ (function () {
|
|
3
|
-
function Permission() {
|
|
4
|
-
Object.defineProperty(this, "permission", {
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true,
|
|
8
|
-
value: 0
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
return Permission;
|
|
12
|
-
}());
|
|
13
|
-
export { Permission };
|
|
14
|
-
export var PermissionSchema = z.object({
|
|
15
|
-
init: z.function({
|
|
16
|
-
output: z.union([z.promise(z.void()), z.void()]),
|
|
17
|
-
}),
|
|
18
|
-
permission: z.number(),
|
|
19
|
-
defaultTitle: z.string(),
|
|
20
|
-
});
|
package/dist/utils/hooks.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useDebouncedValue<T>(value: T): T;
|
package/dist/utils/hooks.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
export function useDebouncedValue(value) {
|
|
3
|
-
var _a = useState(value), result = _a[0], setResult = _a[1];
|
|
4
|
-
var timer = useRef(undefined);
|
|
5
|
-
useEffect(function () {
|
|
6
|
-
clearTimeout(timer.current);
|
|
7
|
-
timer.current = window.setTimeout(function () {
|
|
8
|
-
setResult(value);
|
|
9
|
-
}, 700);
|
|
10
|
-
return function () {
|
|
11
|
-
window.clearTimeout(timer.current);
|
|
12
|
-
};
|
|
13
|
-
}, [result, value]);
|
|
14
|
-
return result;
|
|
15
|
-
}
|