@e7w/easy-routes 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/index.mjs +56 -150
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import z from "zod";
2
2
  import { Navigate, Outlet, isRouteErrorResponse, redirect, useNavigation, useRouteError } from "react-router";
3
- import { c } from "react/compiler-runtime";
4
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
4
  import { useEffect, useRef, useState } from "react";
6
5
  import nProgress from "nprogress";
@@ -18,147 +17,72 @@ const PermissionSchema = z.object({
18
17
  }).describe("权限");
19
18
  //#endregion
20
19
  //#region src/components/DefaultOutlet.tsx
21
- const DefaultOutlet = () => {
22
- const $ = c(2);
23
- if ($[0] !== "86245ef798e2727374ee553b08ad2562f91d79b38190dfff1bf2e15388787321") {
24
- for (let $i = 0; $i < 2; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
25
- $[0] = "86245ef798e2727374ee553b08ad2562f91d79b38190dfff1bf2e15388787321";
26
- }
27
- let t0;
28
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
29
- t0 = /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Outlet, {}) });
30
- $[1] = t0;
31
- } else t0 = $[1];
32
- return t0;
33
- };
20
+ const DefaultOutlet = () => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Outlet, {}) });
34
21
  //#endregion
35
22
  //#region src/components/ErrorBoundary.tsx
36
23
  const ErrorBoundary = () => {
37
- const $ = c(10);
38
- if ($[0] !== "c0519d7cbaee7b0126a2e952b78b40bd9558a23ee78ea987eb3dcf5c9585862b") {
39
- for (let $i = 0; $i < 10; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
40
- $[0] = "c0519d7cbaee7b0126a2e952b78b40bd9558a23ee78ea987eb3dcf5c9585862b";
41
- }
42
24
  const error = useRouteError();
43
- let t0;
44
- let t1;
45
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
46
- t0 = /* @__PURE__ */ jsx("h1", {
47
- className: "text-2xl font-bold mb-4",
48
- children: "Error"
49
- });
50
- t1 = /* @__PURE__ */ jsx("p", { children: "Something went wrong." });
51
- $[1] = t0;
52
- $[2] = t1;
53
- } else {
54
- t0 = $[1];
55
- t1 = $[2];
56
- }
57
- let t2;
58
- if ($[3] !== error) {
59
- t2 = isRouteErrorResponse(error) && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", {
60
- className: "text-red-300",
25
+ return /* @__PURE__ */ jsx("div", {
26
+ className: "flex h-screen w-full items-center justify-center",
27
+ children: /* @__PURE__ */ jsxs("div", {
28
+ className: "flex flex-col items-center justify-center",
61
29
  children: [
62
- error.status,
63
- " ",
64
- error.statusText
30
+ /* @__PURE__ */ jsx("h1", {
31
+ className: "text-2xl font-bold mb-4",
32
+ children: "Error"
33
+ }),
34
+ /* @__PURE__ */ jsx("p", { children: "Something went wrong." }),
35
+ isRouteErrorResponse(error) && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("p", {
36
+ className: "text-red-300",
37
+ children: [
38
+ error.status,
39
+ " ",
40
+ error.statusText
41
+ ]
42
+ }), /* @__PURE__ */ jsx("p", {
43
+ className: "text-red-300",
44
+ children: JSON.stringify(error.data)
45
+ })] }),
46
+ error instanceof Error && /* @__PURE__ */ jsx("p", {
47
+ className: "text-red-300",
48
+ children: error.message
49
+ })
65
50
  ]
66
- }), /* @__PURE__ */ jsx("p", {
67
- className: "text-red-300",
68
- children: JSON.stringify(error.data)
69
- })] });
70
- $[3] = error;
71
- $[4] = t2;
72
- } else t2 = $[4];
73
- let t3;
74
- if ($[5] !== error) {
75
- t3 = error instanceof Error && /* @__PURE__ */ jsx("p", {
76
- className: "text-red-300",
77
- children: error.message
78
- });
79
- $[5] = error;
80
- $[6] = t3;
81
- } else t3 = $[6];
82
- let t4;
83
- if ($[7] !== t2 || $[8] !== t3) {
84
- t4 = /* @__PURE__ */ jsx("div", {
85
- className: "flex h-screen w-full items-center justify-center",
86
- children: /* @__PURE__ */ jsxs("div", {
87
- className: "flex flex-col items-center justify-center",
88
- children: [
89
- t0,
90
- t1,
91
- t2,
92
- t3
93
- ]
94
- })
95
- });
96
- $[7] = t2;
97
- $[8] = t3;
98
- $[9] = t4;
99
- } else t4 = $[9];
100
- return t4;
51
+ })
52
+ });
101
53
  };
102
54
  //#endregion
103
55
  //#region src/utils/hooks.ts
104
56
  function useDebouncedValue(value) {
105
- const $ = c(6);
106
- if ($[0] !== "cafc571037d3460a1577637e6ed6134f48e275412c9fbdd1e3259d6b7886985f") {
107
- for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
108
- $[0] = "cafc571037d3460a1577637e6ed6134f48e275412c9fbdd1e3259d6b7886985f";
109
- }
110
57
  const [result, setResult] = useState(value);
111
58
  const timer = useRef(void 0);
112
- let t0;
113
- if ($[1] !== value) {
114
- t0 = () => {
115
- clearTimeout(timer.current);
116
- timer.current = window.setTimeout(() => {
117
- setResult(value);
118
- }, 700);
119
- return () => {
120
- window.clearTimeout(timer.current);
121
- };
59
+ useEffect(() => {
60
+ clearTimeout(timer.current);
61
+ timer.current = window.setTimeout(() => {
62
+ setResult(value);
63
+ }, 700);
64
+ return () => {
65
+ window.clearTimeout(timer.current);
122
66
  };
123
- $[1] = value;
124
- $[2] = t0;
125
- } else t0 = $[2];
126
- let t1;
127
- if ($[3] !== result || $[4] !== value) {
128
- t1 = [result, value];
129
- $[3] = result;
130
- $[4] = value;
131
- $[5] = t1;
132
- } else t1 = $[5];
133
- useEffect(t0, t1);
67
+ }, [result, value]);
134
68
  return result;
135
69
  }
136
70
  //#endregion
137
71
  //#region src/components/Loading.tsx
138
72
  const Loading = () => {
139
- const $ = c(2);
140
- if ($[0] !== "9ba59b6b2e9bf36d0d2119a54dc7f29c23de32230207b1503967b02ba51f79d2") {
141
- for (let $i = 0; $i < 2; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
142
- $[0] = "9ba59b6b2e9bf36d0d2119a54dc7f29c23de32230207b1503967b02ba51f79d2";
143
- }
144
73
  const { isGlobalLoading } = useLoader();
145
74
  if (!useDebouncedValue(isGlobalLoading)) return;
146
- let t0;
147
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
148
- t0 = /* @__PURE__ */ jsxs("div", {
149
- className: "spinner-box",
150
- children: [
151
- /* @__PURE__ */ jsx("div", { className: "blue-orbit leo" }),
152
- /* @__PURE__ */ jsx("div", { className: "green-orbit leo" }),
153
- /* @__PURE__ */ jsx("div", { className: "red-orbit leo" }),
154
- /* @__PURE__ */ jsx("div", { className: "white-orbit w1 leo" }),
155
- /* @__PURE__ */ jsx("div", { className: "white-orbit w2 leo" }),
156
- /* @__PURE__ */ jsx("div", { className: "white-orbit w3 leo" })
157
- ]
158
- });
159
- $[1] = t0;
160
- } else t0 = $[1];
161
- return t0;
75
+ return /* @__PURE__ */ jsxs("div", {
76
+ className: "spinner-box",
77
+ children: [
78
+ /* @__PURE__ */ jsx("div", { className: "blue-orbit leo" }),
79
+ /* @__PURE__ */ jsx("div", { className: "green-orbit leo" }),
80
+ /* @__PURE__ */ jsx("div", { className: "red-orbit leo" }),
81
+ /* @__PURE__ */ jsx("div", { className: "white-orbit w1 leo" }),
82
+ /* @__PURE__ */ jsx("div", { className: "white-orbit w2 leo" }),
83
+ /* @__PURE__ */ jsx("div", { className: "white-orbit w3 leo" })
84
+ ]
85
+ });
162
86
  };
163
87
  //#endregion
164
88
  //#region src/components/ProgressLayout.tsx
@@ -170,34 +94,12 @@ nProgress.configure({
170
94
  trickleSpeed: 200
171
95
  });
172
96
  const ProgressLayout = () => {
173
- const $ = c(5);
174
- if ($[0] !== "de22e6cf6e3aceb20c6d7925d182a0e90b0719d98cf1e99dbf79a6686dd7cae1") {
175
- for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
176
- $[0] = "de22e6cf6e3aceb20c6d7925d182a0e90b0719d98cf1e99dbf79a6686dd7cae1";
177
- }
178
97
  const { state } = useNavigation();
179
- let t0;
180
- let t1;
181
- if ($[1] !== state) {
182
- t0 = () => {
183
- if (state === "loading") nProgress.start();
184
- else nProgress.done();
185
- };
186
- t1 = [state];
187
- $[1] = state;
188
- $[2] = t0;
189
- $[3] = t1;
190
- } else {
191
- t0 = $[2];
192
- t1 = $[3];
193
- }
194
- useEffect(t0, t1);
195
- let t2;
196
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
197
- t2 = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Outlet, {}), /* @__PURE__ */ jsx(Loading, {})] });
198
- $[4] = t2;
199
- } else t2 = $[4];
200
- return t2;
98
+ useEffect(() => {
99
+ if (state === "loading") nProgress.start();
100
+ else nProgress.done();
101
+ }, [state]);
102
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Outlet, {}), /* @__PURE__ */ jsx(Loading, {})] });
201
103
  };
202
104
  //#endregion
203
105
  //#region src/models/system.ts
@@ -409,7 +311,11 @@ filePaths.forEach((filePath) => {
409
311
  query: Object.fromEntries(url.searchParams),
410
312
  pathname: url.pathname.replace(/\/?$/, "/")
411
313
  };
412
- await system.init(req)?.catch?.(() => {});
314
+ try {
315
+ await system.init(req);
316
+ } catch (error) {
317
+ console.error(error);
318
+ }
413
319
  const ctx = system.getCtx(req, meta.permission);
414
320
  try {
415
321
  await meta.loader?.(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e7w/easy-routes",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"