@e7w/easy-routes 0.1.3 → 0.1.5

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 +300 -54
  2. package/package.json +6 -2
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
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";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
5
  import { useEffect, useRef, useState } from "react";
5
6
  import nProgress from "nprogress";
@@ -14,75 +15,150 @@ const PermissionSchema = z.object({
14
15
  init: z.function({ output: z.union([z.promise(z.void()), z.void()]) }),
15
16
  permission: z.number(),
16
17
  defaultTitle: z.string()
17
- });
18
+ }).describe("权限");
18
19
  //#endregion
19
20
  //#region src/components/DefaultOutlet.tsx
20
- const DefaultOutlet = () => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Outlet, {}) });
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
+ };
21
34
  //#endregion
22
35
  //#region src/components/ErrorBoundary.tsx
23
36
  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
+ }
24
42
  const error = useRouteError();
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",
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",
29
61
  children: [
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
- })
62
+ error.status,
63
+ " ",
64
+ error.statusText
50
65
  ]
51
- })
52
- });
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;
53
101
  };
54
102
  //#endregion
55
103
  //#region src/utils/hooks.ts
56
104
  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
+ }
57
110
  const [result, setResult] = useState(value);
58
111
  const timer = useRef(void 0);
59
- useEffect(() => {
60
- clearTimeout(timer.current);
61
- timer.current = window.setTimeout(() => {
62
- setResult(value);
63
- }, 700);
64
- return () => {
65
- window.clearTimeout(timer.current);
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
+ };
66
122
  };
67
- }, [result, value]);
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);
68
134
  return result;
69
135
  }
70
136
  //#endregion
71
137
  //#region src/components/Loading.tsx
72
138
  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
+ }
73
144
  const { isGlobalLoading } = useLoader();
74
145
  if (!useDebouncedValue(isGlobalLoading)) return;
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
- });
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;
86
162
  };
87
163
  //#endregion
88
164
  //#region src/components/ProgressLayout.tsx
@@ -94,18 +170,188 @@ nProgress.configure({
94
170
  trickleSpeed: 200
95
171
  });
96
172
  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
+ }
97
178
  const { state } = useNavigation();
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, {})] });
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;
103
201
  };
104
202
  //#endregion
105
203
  //#region src/models/system.ts
204
+ let _initProto, _init_router, _init_extra_router;
205
+ function _applyDecs(e, t, n, r, o, i) {
206
+ var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length;
207
+ function g(t, n, r) {
208
+ return function(o, i) {
209
+ n && (i = o, o = e);
210
+ for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []);
211
+ return r ? i : o;
212
+ };
213
+ }
214
+ function b(e, t, n, r) {
215
+ if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined"));
216
+ return e;
217
+ }
218
+ function applyDec(e, t, n, r, o, i, u, s, f, l, p) {
219
+ function d(e) {
220
+ if (!p(e)) throw new TypeError("Attempted to access private element on non-instance");
221
+ }
222
+ var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o;
223
+ function I(t, n, r) {
224
+ return function(o, i) {
225
+ return n && (i = o, o = e), r && r(o), P[t].call(o, i);
226
+ };
227
+ }
228
+ if (!w) {
229
+ var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value";
230
+ if (f ? (l || D ? P = {
231
+ get: _setFunctionName(function() {
232
+ return v(this);
233
+ }, r, "get"),
234
+ set: function(e) {
235
+ t[4](this, e);
236
+ }
237
+ } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) {
238
+ if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet");
239
+ y[+s][r] = o < 3 ? 1 : o;
240
+ }
241
+ }
242
+ for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) {
243
+ var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = {
244
+ kind: [
245
+ "field",
246
+ "accessor",
247
+ "method",
248
+ "getter",
249
+ "setter",
250
+ "class"
251
+ ][o],
252
+ name: r,
253
+ metadata: a,
254
+ addInitializer: function(e, t) {
255
+ if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished");
256
+ b(t, "An initializer", "be", !0), i.push(t);
257
+ }.bind(null, A)
258
+ };
259
+ if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);
260
+ else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function(e) {
261
+ return r in e;
262
+ } }, j || (c.get = f ? E ? function(e) {
263
+ return d(e), P.value;
264
+ } : I("get", 0, d) : function(e) {
265
+ return e[r];
266
+ }), E || S || (c.set = f ? I("set", 0, d) : function(e, t) {
267
+ e[r] = t;
268
+ }), N = T.call(z, D ? {
269
+ get: P.get,
270
+ set: P.set
271
+ } : P[F], H), A.v = 1, D) {
272
+ if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);
273
+ else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined");
274
+ } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N);
275
+ }
276
+ return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N;
277
+ }
278
+ function w(e) {
279
+ return m(e, d, {
280
+ configurable: !0,
281
+ enumerable: !0,
282
+ value: a
283
+ });
284
+ }
285
+ return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function(e) {
286
+ e && f.push(g(e));
287
+ }, p = function(t, r) {
288
+ for (var i = 0; i < n.length; i++) {
289
+ var a = n[i], c = a[1], l = 7 & c;
290
+ if ((8 & c) == t && !l == r) {
291
+ var p = a[2], d = !!a[3], m = 16 & c;
292
+ applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function(t) {
293
+ return _checkInRHS(t) === e;
294
+ } : o);
295
+ }
296
+ }
297
+ }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), {
298
+ e: c,
299
+ get c() {
300
+ var n = [];
301
+ return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)];
302
+ }
303
+ };
304
+ }
305
+ function _toPropertyKey(t) {
306
+ var i = _toPrimitive(t, "string");
307
+ return "symbol" == typeof i ? i : i + "";
308
+ }
309
+ function _toPrimitive(t, r) {
310
+ if ("object" != typeof t || !t) return t;
311
+ var e = t[Symbol.toPrimitive];
312
+ if (void 0 !== e) {
313
+ var i = e.call(t, r || "default");
314
+ if ("object" != typeof i) return i;
315
+ throw new TypeError("@@toPrimitive must return a primitive value.");
316
+ }
317
+ return ("string" === r ? String : Number)(t);
318
+ }
319
+ function _setFunctionName(e, t, n) {
320
+ "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : "");
321
+ try {
322
+ Object.defineProperty(e, "name", {
323
+ configurable: !0,
324
+ value: n ? n + " " + t : t
325
+ });
326
+ } catch (e) {}
327
+ return e;
328
+ }
329
+ function _checkInRHS(e) {
330
+ if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null"));
331
+ return e;
332
+ }
106
333
  const system = provide(class System {
107
- @inject(PermissionSchema) router;
108
- @loader.once @loader.load(true) async init(req) {
334
+ static {
335
+ [_init_router, _init_extra_router, _initProto] = _applyDecs(this, [], [[
336
+ inject(PermissionSchema),
337
+ 0,
338
+ "router"
339
+ ], [
340
+ [
341
+ loader,
342
+ loader.once,
343
+ void 0,
344
+ loader.load(true)
345
+ ],
346
+ 18,
347
+ "init"
348
+ ]]).e;
349
+ }
350
+ constructor() {
351
+ _init_extra_router(this);
352
+ }
353
+ router = (_initProto(this), _init_router(this));
354
+ async init(req) {
109
355
  await this.router?.init(req);
110
356
  }
111
357
  hasPermission(permission = 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e7w/easy-routes",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -25,9 +25,12 @@
25
25
  "zod": "^4.3.6"
26
26
  },
27
27
  "devDependencies": {
28
+ "@babel/core": "^7.29.0",
29
+ "@babel/plugin-proposal-decorators": "^7.29.0",
28
30
  "@bosh-code/tsdown-plugin-inject-css": "^2.0.0",
29
31
  "@bosh-code/tsdown-plugin-tailwindcss": "^1.0.1",
30
32
  "@eslint/js": "^9.39.1",
33
+ "@rolldown/plugin-babel": "^0.2.2",
31
34
  "@tailwindcss/vite": "^4.2.2",
32
35
  "@tsdown/css": "^0.21.5",
33
36
  "@types/node": "^24.10.1",
@@ -35,7 +38,8 @@
35
38
  "@types/react": "^19.2.7",
36
39
  "@types/react-dom": "^19.2.3",
37
40
  "@typescript/native-preview": "7.0.0-dev.20260326.1",
38
- "@vitejs/plugin-react": "^5.1.1",
41
+ "@vitejs/plugin-react": "^6.0.1",
42
+ "babel-plugin-react-compiler": "^1.0.0",
39
43
  "copyfiles": "^2.4.1",
40
44
  "eslint-plugin-react-hooks": "^7.0.1",
41
45
  "eslint-plugin-react-refresh": "^0.4.24",