@argon-router/core 0.11.1 → 1.0.0-rc.0

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/index.js CHANGED
@@ -1,1173 +1,1174 @@
1
- import { createEffect, createStore, createEvent, attach, sample, split, scopeBind, withFactory } from "effector";
2
- import queryString from "query-string";
3
- import { or, not } from "patronum";
4
- function createRoute(config) {
5
- let asyncImport;
6
- const openFx = createEffect(async (payload) => {
7
- await waitForAsyncBundleFx();
8
- await beforeOpenFx();
9
- const parent = config.parent;
10
- if (parent) {
11
- await parent.internal.openFx({
12
- ...payload ?? {
13
- params: {}
14
- },
15
- navigate: false
16
- });
17
- }
18
- return payload;
1
+ import { createEffect as D, attach as B, createStore as $, createEvent as f, sample as i, withFactory as E, scopeBind as _, split as ee } from "effector";
2
+ import { createAction as T, createAsyncAction as te } from "effector-action";
3
+ import { compile as Q } from "@argon-router/paths";
4
+ import H from "query-string";
5
+ import { or as K, not as ne } from "patronum";
6
+ function V(e, t) {
7
+ var n = Object.keys(e);
8
+ if (Object.getOwnPropertySymbols) {
9
+ var r = Object.getOwnPropertySymbols(e);
10
+ t && (r = r.filter(function(a) {
11
+ return Object.getOwnPropertyDescriptor(e, a).enumerable;
12
+ })), n.push.apply(n, r);
13
+ }
14
+ return n;
15
+ }
16
+ function A(e) {
17
+ for (var t = 1; t < arguments.length; t++) {
18
+ var n = arguments[t] != null ? arguments[t] : {};
19
+ t % 2 ? V(Object(n), !0).forEach(function(r) {
20
+ re(e, r, n[r]);
21
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : V(Object(n)).forEach(function(r) {
22
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
23
+ });
24
+ }
25
+ return e;
26
+ }
27
+ function re(e, t, n) {
28
+ return (t = oe(t)) in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
29
+ }
30
+ function oe(e) {
31
+ var t = ae(e, "string");
32
+ return typeof t == "symbol" ? t : t + "";
33
+ }
34
+ function ae(e, t) {
35
+ if (typeof e != "object" || !e) return e;
36
+ var n = e[Symbol.toPrimitive];
37
+ if (n !== void 0) {
38
+ var r = n.call(e, t);
39
+ if (typeof r != "object") return r;
40
+ throw new TypeError("@@toPrimitive must return a primitive value.");
41
+ }
42
+ return (t === "string" ? String : Number)(e);
43
+ }
44
+ function we() {
45
+ var e;
46
+ let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n;
47
+ const r = (e = t.beforeOpen) !== null && e !== void 0 ? e : [], a = D(async (d) => {
48
+ await h(), await q();
49
+ const k = t.parent;
50
+ return k && await k.internal.openFx(A(A({}, d ?? {
51
+ params: {}
52
+ }), {}, {
53
+ navigate: !1
54
+ })), d;
19
55
  }, {
20
56
  name: "openFx",
21
- sid: "awhgwd"
22
- });
23
- const $params = createStore({}, {
57
+ sid: "sf5hhk"
58
+ }), s = D(async (d) => {
59
+ const k = t.parent;
60
+ return k && await k.internal.forceOpenParentFx(A(A({}, d ?? {
61
+ params: {}
62
+ }), {}, {
63
+ navigate: !1
64
+ })), d;
65
+ }, {
66
+ name: "forceOpenParentFx",
67
+ sid: "acd7wj"
68
+ }), g = B({
69
+ and: {
70
+ effect: a
71
+ },
72
+ or: {
73
+ name: "navigatedFx",
74
+ sid: "ci6eci"
75
+ }
76
+ }), v = $({}, {
24
77
  name: "$params",
25
- sid: "-oahffx"
26
- });
27
- const $isOpened = createStore(false, {
78
+ sid: "p3bnh9"
79
+ }), y = $(!1, {
28
80
  name: "$isOpened",
29
- sid: "-6l68oe"
30
- });
31
- const $isPending = openFx.pending;
32
- const open = createEvent({
81
+ sid: "o5kkev"
82
+ }), p = a.pending, l = f({
33
83
  name: "open",
34
- sid: "gjsrgc"
35
- });
36
- const close = createEvent({
84
+ sid: "-bhgc3p"
85
+ }), P = f({
37
86
  name: "close",
38
- sid: "-yagmc8"
39
- });
40
- const opened = createEvent({
87
+ sid: "vypd6z"
88
+ }), O = f({
41
89
  name: "opened",
42
- sid: "x0iwhi"
43
- });
44
- const openedOnServer = createEvent({
90
+ sid: "-uyucke"
91
+ }), x = f({
45
92
  name: "openedOnServer",
46
- sid: "346r3u"
47
- });
48
- const openedOnClient = createEvent({
93
+ sid: "mewjoi"
94
+ }), o = f({
49
95
  name: "openedOnClient",
50
- sid: "31q95t"
51
- });
52
- const navigated = createEvent({
96
+ sid: "63cfjt"
97
+ }), u = f({
53
98
  name: "navigated",
54
- sid: "-t30l0x"
55
- });
56
- const closed = createEvent({
99
+ sid: "mycajg"
100
+ }), b = f({
57
101
  name: "closed",
58
- sid: "uue4ce"
59
- });
60
- const waitForAsyncBundleFx = createEffect(() => asyncImport == null ? void 0 : asyncImport(), {
102
+ sid: "5idv7d"
103
+ }), h = D(() => {
104
+ var d;
105
+ return (d = n) === null || d === void 0 ? void 0 : d();
106
+ }, {
61
107
  name: "waitForAsyncBundleFx",
62
- sid: "-nml5ho"
63
- });
64
- const beforeOpenFx = createEffect(async () => {
65
- for (const fx of config.beforeOpen ?? []) {
66
- await fx();
67
- }
108
+ sid: "-6s0q41"
109
+ }), q = D(async () => {
110
+ for (const d of r)
111
+ await d();
68
112
  }, {
69
113
  name: "beforeOpenFx",
70
- sid: "-vqlnbm"
71
- });
72
- const navigatedFx = attach({
73
- and: {
74
- effect: openFx
75
- },
76
- or: {
77
- name: "navigatedFx",
78
- sid: "a4yadj"
79
- }
80
- });
81
- const defaultParams = {};
82
- sample({
114
+ sid: "7f9gfq"
115
+ }), R = {};
116
+ return i({
83
117
  and: [{
84
- clock: open,
85
- target: openFx
118
+ clock: l,
119
+ target: a
86
120
  }],
87
121
  or: {
88
- sid: "ynxuww"
122
+ sid: "-yxhjaa"
89
123
  }
90
- });
91
- sample({
124
+ }), i({
92
125
  and: [{
93
- clock: navigated,
94
- fn: (payload) => ({
95
- navigate: false,
96
- ...payload
97
- }),
98
- target: navigatedFx
126
+ clock: u,
127
+ fn: (d) => A({
128
+ navigate: !1
129
+ }, d),
130
+ target: g
99
131
  }],
100
132
  or: {
101
- sid: "z28ica"
133
+ sid: "-yj6vuw"
102
134
  }
103
- });
104
- sample({
135
+ }), i({
105
136
  and: [{
106
- clock: navigatedFx.doneData,
107
- fn: (payload) => {
108
- if (!payload) {
109
- return defaultParams;
110
- }
111
- return "params" in payload ? {
112
- ...payload.params
113
- } : defaultParams;
137
+ clock: g.done,
138
+ fn: (d) => {
139
+ let {
140
+ params: k
141
+ } = d;
142
+ return k;
114
143
  },
115
- target: $params
116
- }],
117
- or: {
118
- sid: "z5j9wg"
119
- }
120
- });
121
- sample({
122
- and: [{
123
- clock: navigatedFx.failData,
124
- fn: () => defaultParams,
125
- target: $params
144
+ target: s
126
145
  }],
127
146
  or: {
128
- sid: "-z1vw16"
147
+ sid: "-yfw4aq"
129
148
  }
130
- });
131
- split({
149
+ }), E({
150
+ sid: "-y11o9z",
151
+ fn: () => T({
152
+ clock: s.doneData,
153
+ target: {
154
+ $params: v
155
+ },
156
+ fn: (d, k) => k ? d.$params("params" in k ? A({}, k.params) : R) : d.$params(R)
157
+ }),
158
+ name: "none",
159
+ method: "createAction"
160
+ }), i({
132
161
  and: [{
133
- source: navigatedFx.doneData,
134
- match: () => typeof window === "undefined" ? "server" : "client",
135
- cases: {
136
- server: openedOnServer,
137
- client: openedOnClient
138
- }
162
+ clock: g.failData,
163
+ fn: () => R,
164
+ target: v
139
165
  }],
140
166
  or: {
141
- sid: "-yyl4h0"
167
+ sid: "-xhsvic"
142
168
  }
143
- });
144
- sample({
169
+ }), E({
170
+ sid: "-x2yfhl",
171
+ fn: () => T({
172
+ clock: s.doneData,
173
+ target: {
174
+ openedOnServer: x,
175
+ openedOnClient: o
176
+ },
177
+ fn: (d, k) => typeof window > "u" ? d.openedOnServer(k) : d.openedOnClient(k)
178
+ }),
179
+ name: "none",
180
+ method: "createAction"
181
+ }), i({
145
182
  and: [{
146
- clock: [openedOnClient, openedOnServer],
147
- target: opened
183
+ clock: [o, x],
184
+ target: O
148
185
  }],
149
186
  or: {
150
- sid: "-yhji2t"
187
+ sid: "-w72d2n"
151
188
  }
152
- });
153
- sample({
189
+ }), i({
154
190
  and: [{
155
- clock: close,
156
- target: closed
191
+ clock: P,
192
+ target: b
157
193
  }],
158
194
  or: {
159
- sid: "-y38unf"
195
+ sid: "-w4be3u"
160
196
  }
161
- });
162
- sample({
197
+ }), i({
163
198
  and: [{
164
- clock: [opened.map(() => true), closed.map(() => false)],
165
- target: $isOpened
199
+ clock: [O.map(() => !0), b.map(() => !1)],
200
+ target: y
166
201
  }],
167
202
  or: {
168
- sid: "-y0hvom"
203
+ sid: "-ls2oed"
169
204
  }
170
- });
171
- return {
172
- $params,
173
- $isOpened,
174
- $isPending,
175
- open,
176
- closed,
177
- opened,
178
- openedOnClient,
179
- openedOnServer,
180
- ...config,
205
+ }), A(A({
206
+ $params: v,
207
+ $isOpened: y,
208
+ $isPending: p,
209
+ // @ts-expect-error :((
210
+ open: l,
211
+ closed: b,
212
+ opened: O,
213
+ openedOnClient: o,
214
+ openedOnServer: x
215
+ }, t), {}, {
181
216
  internal: {
182
- navigated,
183
- close,
184
- openFx,
185
- setAsyncImport: (value) => asyncImport = value
217
+ navigated: u,
218
+ close: P,
219
+ openFx: a,
220
+ forceOpenParentFx: s,
221
+ setAsyncImport: (d) => n = d
186
222
  },
187
223
  "@@unitShape": () => ({
188
- params: $params,
189
- isPending: $isPending,
190
- isOpened: $isOpened,
191
- onOpen: open
224
+ params: v,
225
+ isPending: p,
226
+ isOpened: y,
227
+ // @ts-expect-error :((
228
+ onOpen: l
192
229
  })
193
- };
230
+ });
194
231
  }
195
- function isForRouteActive(forRoutes, activeRoutes) {
196
- for (const route of forRoutes) {
197
- if (activeRoutes.includes(route)) {
198
- return true;
199
- }
232
+ function W(e, t) {
233
+ var n = Object.keys(e);
234
+ if (Object.getOwnPropertySymbols) {
235
+ var r = Object.getOwnPropertySymbols(e);
236
+ t && (r = r.filter(function(a) {
237
+ return Object.getOwnPropertyDescriptor(e, a).enumerable;
238
+ })), n.push.apply(n, r);
200
239
  }
201
- return false;
240
+ return n;
241
+ }
242
+ function G(e) {
243
+ for (var t = 1; t < arguments.length; t++) {
244
+ var n = arguments[t] != null ? arguments[t] : {};
245
+ t % 2 ? W(Object(n), !0).forEach(function(r) {
246
+ se(e, r, n[r]);
247
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : W(Object(n)).forEach(function(r) {
248
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
249
+ });
250
+ }
251
+ return e;
252
+ }
253
+ function se(e, t, n) {
254
+ return (t = ce(t)) in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
255
+ }
256
+ function ce(e) {
257
+ var t = ie(e, "string");
258
+ return typeof t == "symbol" ? t : t + "";
202
259
  }
203
- function trackQueryControlsFactory(_ref) {
260
+ function ie(e, t) {
261
+ if (typeof e != "object" || !e) return e;
262
+ var n = e[Symbol.toPrimitive];
263
+ if (n !== void 0) {
264
+ var r = n.call(e, t);
265
+ if (typeof r != "object") return r;
266
+ throw new TypeError("@@toPrimitive must return a primitive value.");
267
+ }
268
+ return (t === "string" ? String : Number)(e);
269
+ }
270
+ function L(e, t) {
271
+ for (const n of e)
272
+ if (t.includes(n))
273
+ return !0;
274
+ return !1;
275
+ }
276
+ function ue(e) {
204
277
  let {
205
- $query,
206
- navigate
207
- } = _ref;
208
- return trackQueryFactory({
209
- $activeRoutes: createStore([], {
278
+ $query: t,
279
+ navigate: n
280
+ } = e;
281
+ return X({
282
+ $activeRoutes: $([], {
210
283
  name: "$activeRoutes",
211
- sid: "ni3bf8"
284
+ sid: "og6k7m"
212
285
  }),
213
- $query,
214
- navigate
286
+ $query: t,
287
+ navigate: n
215
288
  });
216
289
  }
217
- function trackQueryFactory(_ref2) {
290
+ function X(e) {
218
291
  let {
219
- $activeRoutes,
220
- $query,
221
- navigate
222
- } = _ref2;
223
- return (config) => {
292
+ $activeRoutes: t,
293
+ $query: n,
294
+ navigate: r
295
+ } = e;
296
+ return (a) => {
224
297
  const {
225
- parameters,
226
- forRoutes
227
- } = config;
228
- const $entered = createStore(false, {
298
+ check: s,
299
+ parameters: g,
300
+ forRoutes: v
301
+ } = a, y = $(!1, {
229
302
  name: "$entered",
230
- sid: "-i5493b"
231
- });
232
- const entered = createEvent({
303
+ sid: "-792y0u"
304
+ }), p = f({
233
305
  name: "entered",
234
- sid: "9i8bun"
235
- });
236
- const exited = createEvent({
306
+ sid: "agbkn1"
307
+ }), l = f({
237
308
  name: "exited",
238
- sid: "-p2hcsy"
239
- });
240
- const enter = createEvent({
309
+ sid: "-o4e40k"
310
+ }), P = f({
241
311
  name: "enter",
242
- sid: "30cmky"
243
- });
244
- const exit = createEvent({
312
+ sid: "3yfvdc"
313
+ }), O = f({
245
314
  name: "exit",
246
- sid: "-2657ec"
247
- });
248
- const changeEntered = createEvent({
315
+ sid: "-181yly"
316
+ }), x = f({
249
317
  name: "changeEntered",
250
- sid: "-5jm7r1"
318
+ sid: "-4liyyn"
251
319
  });
252
- sample({
320
+ return i({
253
321
  and: [{
254
- clock: changeEntered,
255
- target: $entered
322
+ clock: x,
323
+ target: y
256
324
  }],
257
325
  or: {
258
- sid: "-j6nk9y"
326
+ sid: "-iu0amn"
259
327
  }
260
- });
261
- sample({
328
+ }), s ? i({
262
329
  and: [{
330
+ clock: s,
263
331
  source: {
264
- activeRoutes: $activeRoutes,
265
- query: $query
332
+ activeRoutes: t,
333
+ query: n
266
334
  },
267
- filter: (_ref3) => {
335
+ filter: (o) => {
268
336
  let {
269
- activeRoutes,
270
- query
271
- } = _ref3;
272
- return (!forRoutes || isForRouteActive(forRoutes, activeRoutes)) && parameters.safeParse(query).success;
337
+ activeRoutes: u,
338
+ query: b
339
+ } = o;
340
+ return (!v || L(v, u)) && g.safeParse(b).success;
273
341
  },
274
- fn: (_ref4) => {
342
+ fn: (o) => {
275
343
  let {
276
- query
277
- } = _ref4;
278
- return parameters.safeParse(query).data;
344
+ query: u
345
+ } = o;
346
+ return g.safeParse(u).data;
279
347
  },
280
- target: [entered, changeEntered.prepend(() => true)]
348
+ target: [p, x.prepend(() => !0)]
281
349
  }],
282
350
  or: {
283
- sid: "-iscwuk"
351
+ sid: "-iqpj0r"
284
352
  }
285
- });
286
- sample({
353
+ }) : i({
287
354
  and: [{
288
355
  source: {
289
- activeRoutes: $activeRoutes,
290
- query: $query,
291
- entered: $entered
356
+ activeRoutes: t,
357
+ query: n
358
+ },
359
+ filter: (o) => {
360
+ let {
361
+ activeRoutes: u,
362
+ query: b
363
+ } = o;
364
+ return (!v || L(v, u)) && g.safeParse(b).success;
292
365
  },
293
- filter: (_ref5) => {
366
+ fn: (o) => {
294
367
  let {
295
- activeRoutes,
296
- query,
297
- entered: entered2
298
- } = _ref5;
299
- return entered2 && !((!forRoutes || isForRouteActive(forRoutes, activeRoutes)) && parameters.safeParse(query).success);
368
+ query: u
369
+ } = o;
370
+ return g.safeParse(u).data;
300
371
  },
301
- target: [exited.prepend(() => void 0), changeEntered.prepend(() => false)]
372
+ target: [p, x.prepend(() => !0)]
302
373
  }],
303
374
  or: {
304
- sid: "-ibv31q"
375
+ sid: "-i9nwmk"
305
376
  }
306
- });
307
- sample({
377
+ }), i({
308
378
  and: [{
309
- clock: enter,
310
- source: $query,
311
- fn: (query, payload) => {
312
- return {
313
- query: {
314
- ...query,
315
- ...payload
316
- }
317
- };
379
+ source: {
380
+ activeRoutes: t,
381
+ query: n,
382
+ entered: y
318
383
  },
319
- target: navigate
384
+ filter: (o) => {
385
+ let {
386
+ activeRoutes: u,
387
+ query: b,
388
+ entered: h
389
+ } = o;
390
+ return h && !((!v || L(v, u)) && g.safeParse(b).success);
391
+ },
392
+ target: [l.prepend(() => {
393
+ }), x.prepend(() => !1)]
320
394
  }],
321
395
  or: {
322
396
  sid: "-hsmaa3"
323
397
  }
324
- });
325
- sample({
398
+ }), i({
326
399
  and: [{
327
- clock: exit,
328
- source: $query,
329
- fn: (query, payload) => {
330
- if (payload && payload.ignoreParams) {
331
- const copy = {};
332
- for (const key of payload.ignoreParams) {
333
- if (query[key]) {
334
- copy[key] = query[key];
335
- }
336
- }
400
+ clock: P,
401
+ source: n,
402
+ fn: (o, u) => ({
403
+ query: G(G({}, o), u)
404
+ }),
405
+ target: r
406
+ }],
407
+ or: {
408
+ sid: "-w2mjl9"
409
+ }
410
+ }), i({
411
+ and: [{
412
+ clock: O,
413
+ source: n,
414
+ fn: (o, u) => {
415
+ if (u && u.ignoreParams) {
416
+ const b = {};
417
+ for (const h of u.ignoreParams)
418
+ o[h] && (b[h] = o[h]);
337
419
  return {
338
- query: copy
420
+ query: b
339
421
  };
340
422
  }
341
423
  return {
342
424
  query: {}
343
425
  };
344
426
  },
345
- target: navigate
427
+ target: r
346
428
  }],
347
429
  or: {
348
- sid: "-whgzm0"
349
- }
350
- });
351
- return {
352
- enter,
353
- entered,
354
- exited,
355
- exit
356
- };
357
- };
358
- }
359
- function prepareParser(tokens) {
360
- return (input) => {
361
- const rawTokens = input.split("/").map((part) => part.trim()).filter((part) => part !== "");
362
- let params = null;
363
- function setKey(key, value) {
364
- if (!params) {
365
- params = {};
430
+ sid: "-vlkx72"
366
431
  }
367
- params[key] = value;
368
- }
369
- if (tokens.length === 0) {
370
- return rawTokens.length === 0 ? {
371
- path: input,
372
- params: null
373
- } : null;
374
- }
375
- for (let i = 0; i < tokens.length; i++) {
376
- const token = tokens[i];
377
- switch (token.type) {
378
- case "const": {
379
- if (token.name !== rawTokens.shift()) {
380
- return null;
381
- }
382
- continue;
383
- }
384
- case "parameter": {
385
- const {
386
- arrayProps,
387
- genericProps,
388
- required
389
- } = token.payload;
390
- if (arrayProps) {
391
- const array = [];
392
- let rawToken2;
393
- while (true) {
394
- rawToken2 = rawTokens.shift();
395
- if (!rawToken2) {
396
- break;
397
- }
398
- switch (genericProps == null ? void 0 : genericProps.type) {
399
- case "number": {
400
- if (isNaN(+rawToken2)) {
401
- return null;
402
- }
403
- array.push(+rawToken2);
404
- break;
405
- }
406
- case "union": {
407
- if (!genericProps.items.includes(rawToken2)) {
408
- return null;
409
- }
410
- array.push(rawToken2);
411
- break;
412
- }
413
- default: {
414
- array.push(rawToken2);
415
- break;
416
- }
417
- }
418
- if (array.length >= (arrayProps.max ?? Infinity)) {
419
- break;
420
- }
421
- }
422
- if (array.length < (arrayProps.min ?? 0)) {
423
- return null;
424
- }
425
- if (rawTokens.length > 0 && !tokens[i + 1]) {
426
- return null;
427
- }
428
- setKey(token.name, array);
429
- break;
430
- }
431
- const rawToken = rawTokens.shift();
432
- if (required && !rawToken) {
433
- return null;
434
- }
435
- if (!rawToken) {
436
- setKey(token.name, void 0);
437
- continue;
438
- }
439
- switch (genericProps == null ? void 0 : genericProps.type) {
440
- case "number": {
441
- if (isNaN(+rawToken)) {
442
- return null;
443
- }
444
- setKey(token.name, +rawToken);
445
- break;
446
- }
447
- case "union": {
448
- if (!genericProps.items.includes(rawToken)) {
449
- return null;
450
- }
451
- setKey(token.name, rawToken);
452
- break;
453
- }
454
- default: {
455
- setKey(token.name, rawToken);
456
- break;
457
- }
458
- }
459
- }
460
- }
461
- }
462
- if (rawTokens.length > 0) {
463
- return null;
464
- }
465
- return {
466
- path: input,
467
- params
432
+ }), {
433
+ enter: P,
434
+ entered: p,
435
+ exited: l,
436
+ exit: O
468
437
  };
469
438
  };
470
439
  }
471
- function getTokenParameters(params) {
472
- if (!params) {
473
- return null;
440
+ function J(e, t) {
441
+ var n = Object.keys(e);
442
+ if (Object.getOwnPropertySymbols) {
443
+ var r = Object.getOwnPropertySymbols(e);
444
+ t && (r = r.filter(function(a) {
445
+ return Object.getOwnPropertyDescriptor(e, a).enumerable;
446
+ })), n.push.apply(n, r);
474
447
  }
475
- const name = params[1];
476
- let genericProps;
477
- let arrayProps;
478
- let modificator;
479
- for (const parameter of params.slice(2)) {
480
- if (!parameter) {
481
- continue;
482
- }
483
- if (parameter.includes("<")) {
484
- genericProps = parameter.replaceAll(/\s/g, "").replace("<", "").replace(">", "");
485
- continue;
486
- }
487
- if (parameter.includes("{")) {
488
- arrayProps = parameter.replace("{", "").replace("}", "").split(",").map((item) => parseInt(item));
489
- }
490
- if (["*", "?", "+"].includes(parameter)) {
491
- modificator = parameter;
492
- continue;
493
- }
448
+ return n;
449
+ }
450
+ function N(e) {
451
+ for (var t = 1; t < arguments.length; t++) {
452
+ var n = arguments[t] != null ? arguments[t] : {};
453
+ t % 2 ? J(Object(n), !0).forEach(function(r) {
454
+ de(e, r, n[r]);
455
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : J(Object(n)).forEach(function(r) {
456
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
457
+ });
494
458
  }
495
- return {
496
- name,
497
- genericProps,
498
- arrayProps,
499
- modificator
500
- };
459
+ return e;
501
460
  }
502
- function prepareBuilder(tokens) {
503
- return (params) => {
504
- const result = [];
505
- if (tokens.length === 0) {
506
- return "/";
507
- }
508
- for (const token of tokens) {
509
- switch (token.type) {
510
- case "const": {
511
- result.push(token.name);
512
- break;
513
- }
514
- case "parameter": {
515
- if (!params[token.name]) {
516
- continue;
517
- }
518
- if (Array.isArray(params[token.name])) {
519
- for (const param of params[token.name]) {
520
- result.push(param.toString());
521
- }
522
- } else {
523
- result.push(params[token.name].toString());
524
- }
525
- break;
526
- }
527
- }
528
- }
529
- return `/${result.join("/")}`;
530
- };
461
+ function de(e, t, n) {
462
+ return (t = le(t)) in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
531
463
  }
532
- function compile(path) {
533
- const tokens = [];
534
- const regexp = /:(\w+)(<[\s?\w|]+>)?({\d+\,\d+})?([+*?])?/;
535
- const parsedTokens = path.split("/").filter(Boolean);
536
- for (let i = 0; i < parsedTokens.length; i++) {
537
- const parsedToken = parsedTokens[i];
538
- if (!parsedToken) {
539
- continue;
540
- }
541
- const parameters = getTokenParameters(parsedToken.match(regexp));
542
- if (!parameters) {
543
- tokens.push({
544
- type: "const",
545
- name: parsedToken,
546
- payload: void 0
547
- });
548
- continue;
549
- }
550
- const {
551
- arrayProps,
552
- genericProps,
553
- modificator,
554
- name
555
- } = parameters;
556
- if (!name) {
557
- throw new Error(`Invalid path: "${path}". Name for argument must be provided`);
558
- }
559
- const token = {
560
- type: "parameter",
561
- name,
562
- payload: {
563
- required: true
564
- }
565
- };
566
- if (genericProps && genericProps === "number") {
567
- token.payload.genericProps = {
568
- type: "number"
569
- };
570
- }
571
- if (genericProps && genericProps.includes("|")) {
572
- token.payload.genericProps = {
573
- type: "union",
574
- items: genericProps.split("|")
575
- };
576
- }
577
- switch (modificator) {
578
- case "*": {
579
- token.payload.arrayProps = {};
580
- break;
581
- }
582
- case "+": {
583
- token.payload.arrayProps = {
584
- min: 1
585
- };
586
- break;
587
- }
588
- case "?": {
589
- token.payload.required = false;
590
- break;
591
- }
592
- }
593
- if (arrayProps) {
594
- token.payload.arrayProps = {
595
- ...token.payload.arrayProps,
596
- min: arrayProps[0],
597
- max: arrayProps[1]
598
- };
599
- }
600
- tokens.push(token);
464
+ function le(e) {
465
+ var t = pe(e, "string");
466
+ return typeof t == "symbol" ? t : t + "";
467
+ }
468
+ function pe(e, t) {
469
+ if (typeof e != "object" || !e) return e;
470
+ var n = e[Symbol.toPrimitive];
471
+ if (n !== void 0) {
472
+ var r = n.call(e, t);
473
+ if (typeof r != "object") return r;
474
+ throw new TypeError("@@toPrimitive must return a primitive value.");
601
475
  }
602
- return {
603
- /**
604
- * @param input Input path
605
- * @returns `{ path: string; params: Params }` | `null`
606
- */
607
- parse: prepareParser(tokens),
608
- /**
609
- * @param params Route parameters
610
- * @returns string
611
- */
612
- build: prepareBuilder(tokens)
613
- };
476
+ return (t === "string" ? String : Number)(e);
614
477
  }
615
- function createRouterControls() {
616
- const $history = createStore(null, {
478
+ function fe() {
479
+ const e = $(null, {
617
480
  and: {
618
481
  serialize: "ignore"
619
482
  },
620
483
  name: "$history",
621
- sid: "-ld7lzl"
622
- });
623
- const $locationState = createStore({
484
+ sid: "-kw5zle"
485
+ }), t = $({
624
486
  query: {},
625
487
  path: null
626
488
  }, {
627
489
  name: "$locationState",
628
- sid: "-4u3w85"
629
- });
630
- const $query = $locationState.map((state) => state.query);
631
- const $path = $locationState.map((state) => state.path);
632
- const setHistory = createEvent({
490
+ sid: "-2xxend"
491
+ }), n = $(null, {
492
+ name: "$subscription",
493
+ sid: "27a2zr"
494
+ }), r = t.map((o) => o.query), a = t.map((o) => o.path), s = f({
633
495
  name: "setHistory",
634
- sid: "-ormmkk"
635
- });
636
- const navigate = createEvent({
496
+ sid: "-lxcw7e"
497
+ }), g = f({
637
498
  name: "navigate",
638
- sid: "tawqep"
639
- });
640
- const back = createEvent({
499
+ sid: "w56grv"
500
+ }), v = f({
641
501
  name: "back",
642
- sid: "bxy8rt"
643
- });
644
- const forward = createEvent({
502
+ sid: "es7z4z"
503
+ }), y = f({
645
504
  name: "forward",
646
- sid: "-bpmzb1"
647
- });
648
- const locationUpdated = createEvent({
505
+ sid: "12ktc8"
506
+ }), p = f({
649
507
  name: "locationUpdated",
650
- sid: "lkzldx"
651
- });
652
- const navigateFx = attach({
508
+ sid: "yd7e16"
509
+ }), l = B({
653
510
  and: {
654
- source: $history,
655
- effect: (history, _ref) => {
511
+ source: e,
512
+ effect: (o, u) => {
656
513
  let {
657
- path,
658
- query,
659
- replace
660
- } = _ref;
661
- if (!history) {
514
+ path: b,
515
+ query: h,
516
+ replace: q
517
+ } = u;
518
+ if (!o)
662
519
  throw new Error("history not found");
663
- }
664
- const payload = {
665
- pathname: path,
666
- search: `?${queryString.stringify(query)}`
520
+ const R = {
521
+ pathname: b,
522
+ search: "?".concat(H.stringify(h))
667
523
  };
668
- if (replace) {
669
- history.replace(payload);
670
- } else {
671
- history.push(payload);
672
- }
524
+ q ? o.replace(R) : o.push(R);
673
525
  }
674
526
  },
675
527
  or: {
676
528
  name: "navigateFx",
677
- sid: "-ov1xn7"
529
+ sid: "-m0s7a1"
678
530
  }
679
- });
680
- const subscribeHistoryFx = createEffect((history) => {
681
- const historyLocationUpdated = scopeBind(locationUpdated);
682
- historyLocationUpdated({
683
- pathname: history.location.pathname,
684
- query: {
685
- ...queryString.parse(history.location.search)
531
+ }), P = E({
532
+ sid: "-jbr50m",
533
+ fn: () => te({
534
+ target: {
535
+ locationUpdated: p,
536
+ $subscription: n
537
+ },
538
+ source: {
539
+ $subscription: n
540
+ },
541
+ fn: async (o, u, b) => {
542
+ if (!b)
543
+ throw Error("Cannot initialize router controls with empty history adapter. Please provide some provider or check your code for passing of nullable value");
544
+ const h = await u();
545
+ h.subscription && h.subscription.unsubscribe(), o.locationUpdated({
546
+ pathname: b.location.pathname,
547
+ query: N({}, H.parse(b.location.search))
548
+ }), o.$subscription(b.listen((q) => {
549
+ o.locationUpdated({
550
+ pathname: q.pathname,
551
+ query: N({}, H.parse(q.search))
552
+ });
553
+ }));
686
554
  }
687
- });
688
- if (!history) {
689
- throw new Error();
690
- }
691
- history.listen((_ref2) => {
692
- let {
693
- location
694
- } = _ref2;
695
- historyLocationUpdated({
696
- pathname: location.pathname,
697
- query: {
698
- ...queryString.parse(location.search)
699
- }
700
- });
701
- });
702
- }, {
555
+ }),
703
556
  name: "subscribeHistoryFx",
704
- sid: "-m60vds"
557
+ method: "createAsyncAction"
558
+ }), O = B({
559
+ and: {
560
+ source: e,
561
+ effect: (o) => {
562
+ if (!o)
563
+ throw new Error("history not found");
564
+ o.goBack();
565
+ }
566
+ },
567
+ or: {
568
+ name: "goBackFx",
569
+ sid: "k3gxue"
570
+ }
571
+ }), x = B({
572
+ and: {
573
+ source: e,
574
+ effect: (o) => {
575
+ if (!o)
576
+ throw new Error("history not found");
577
+ o.goForward();
578
+ }
579
+ },
580
+ or: {
581
+ name: "goForwardFx",
582
+ sid: "1m1c40"
583
+ }
705
584
  });
706
- sample({
585
+ return i({
707
586
  and: [{
708
- clock: setHistory,
709
- target: $history
587
+ clock: s,
588
+ target: e
710
589
  }],
711
590
  or: {
712
- sid: "ii4q"
591
+ sid: "1ycdhl"
713
592
  }
714
- });
715
- sample({
593
+ }), i({
716
594
  and: [{
717
- clock: $history,
595
+ clock: e,
718
596
  filter: Boolean,
719
- target: subscribeHistoryFx
597
+ target: P
720
598
  }],
721
599
  or: {
722
- sid: "39h3j"
600
+ sid: "213cge"
723
601
  }
724
- });
725
- sample({
602
+ }), i({
726
603
  and: [{
727
- clock: locationUpdated,
728
- fn: (location) => ({
729
- path: location.pathname,
730
- query: location.query
604
+ clock: p,
605
+ fn: (o) => ({
606
+ path: o.pathname,
607
+ query: o.query
731
608
  }),
732
- target: $locationState
609
+ target: t
733
610
  }],
734
611
  or: {
735
- sid: "i3x4a"
612
+ sid: "2fxsh5"
736
613
  }
737
- });
738
- sample({
614
+ }), i({
739
615
  and: [{
740
- clock: navigate,
741
- source: $path,
742
- fn: (path, payload) => ({
743
- path,
744
- ...payload
745
- }),
746
- target: navigateFx
616
+ clock: g,
617
+ source: a,
618
+ fn: (o, u) => N({
619
+ path: o
620
+ }, u),
621
+ target: l
747
622
  }],
748
623
  or: {
749
- sid: "ylqx4"
624
+ sid: "2wfm9z"
750
625
  }
751
- });
752
- return {
753
- $history,
754
- $locationState,
755
- $query,
756
- $path,
757
- setHistory,
758
- navigate,
759
- back,
760
- forward,
761
- locationUpdated,
762
- trackQuery: trackQueryControlsFactory({
763
- $query,
764
- navigate
626
+ }), i({
627
+ and: [{
628
+ clock: v,
629
+ target: O
630
+ }],
631
+ or: {
632
+ sid: "3btuw3"
633
+ }
634
+ }), i({
635
+ and: [{
636
+ clock: y,
637
+ target: x
638
+ }],
639
+ or: {
640
+ sid: "3ektuw"
641
+ }
642
+ }), {
643
+ $history: e,
644
+ $locationState: t,
645
+ $query: r,
646
+ $path: a,
647
+ setHistory: s,
648
+ navigate: g,
649
+ back: v,
650
+ forward: y,
651
+ locationUpdated: p,
652
+ trackQuery: ue({
653
+ $query: r,
654
+ navigate: g
765
655
  })
766
656
  };
767
657
  }
768
- function createRouter(config) {
769
- const {
770
- base = "/",
771
- routes
772
- } = config;
658
+ const U = {
659
+ route(e) {
660
+ return U.pathRoute(e) || U.pathlessRoute(e);
661
+ },
662
+ pathRoute(e) {
663
+ return typeof e == "object" && e !== null && "@@type" in e && e["@@type"] === "path-route";
664
+ },
665
+ pathlessRoute(e) {
666
+ return typeof e == "object" && e !== null && "@@type" in e && e["@@type"] === "pathless-route";
667
+ },
668
+ router(e) {
669
+ return typeof e == "object" && e !== null && "@@type" in e && e["@@type"] === "router";
670
+ }
671
+ }, C = {
672
+ pathlessRoute(e) {
673
+ return "route" in e;
674
+ },
675
+ pathRoute(e) {
676
+ return !this.pathlessRoute(e) && !this.router(e);
677
+ },
678
+ router(e) {
679
+ return U.router(e);
680
+ }
681
+ };
682
+ function Oe(e) {
683
+ var t;
773
684
  const {
774
- $path,
775
- $query,
776
- back,
777
- forward,
778
- navigate,
779
- setHistory,
780
- locationUpdated
781
- } = createRouterControls();
782
- const mappedRoutes = routes.map((route) => {
783
- let internalRoute = route;
784
- const path = [];
785
- path.unshift(internalRoute.path);
786
- while (internalRoute.parent) {
787
- internalRoute = internalRoute.parent;
788
- if (internalRoute.path !== "/") {
789
- path.unshift(internalRoute.path);
790
- }
685
+ base: n = "/",
686
+ routes: r
687
+ } = e, {
688
+ $path: a,
689
+ $query: s,
690
+ $history: g,
691
+ back: v,
692
+ forward: y,
693
+ navigate: p,
694
+ setHistory: l,
695
+ locationUpdated: P
696
+ } = (t = e.controls) !== null && t !== void 0 ? t : fe();
697
+ function O(c) {
698
+ return n === "/" ? c : c === "/" ? n : "".concat(n).concat(c);
699
+ }
700
+ const x = f({
701
+ name: "connectToParentRouter",
702
+ sid: "t0jaae"
703
+ });
704
+ let o = null;
705
+ const u = [];
706
+ function b(c) {
707
+ if (C.pathlessRoute(c)) {
708
+ const {
709
+ build: I,
710
+ parse: Z
711
+ } = Q(O(c.path));
712
+ return {
713
+ route: c.route,
714
+ path: c.path,
715
+ build: I,
716
+ parse: Z
717
+ };
791
718
  }
792
- const joinedPath = base === "/" ? path.join("") : [base, ...path].join("");
793
- const {
794
- build,
795
- parse
796
- } = compile(joinedPath);
719
+ if (C.router(c))
720
+ return i({
721
+ and: [{
722
+ clock: l,
723
+ target: c.setHistory
724
+ }],
725
+ or: {
726
+ sid: "ez3kyw"
727
+ }
728
+ }), null;
729
+ let m = c;
730
+ const j = [];
731
+ for (j.unshift(m.path); m.parent && !U.pathlessRoute(m.parent); )
732
+ m = m.parent, m.path !== "/" && j.unshift(m.path);
733
+ const F = O(j.join("")), {
734
+ build: w,
735
+ parse: S
736
+ } = Q(F);
797
737
  return {
798
- route,
799
- path: joinedPath,
800
- build,
801
- parse
738
+ route: c,
739
+ path: F,
740
+ build: w,
741
+ parse: S
802
742
  };
803
- });
804
- const $activeRoutes = $path.map((path) => {
805
- const result = [];
806
- if (!path) {
807
- return result;
808
- }
743
+ }
744
+ const h = r.reduce((c, m) => {
745
+ const j = b(m);
746
+ return j && (u.push(j), c.push(j)), C.router(m) && u.push(...m.knownRoutes), c;
747
+ }, []), q = a.map((c) => {
748
+ const m = [];
749
+ if (!c)
750
+ return m;
809
751
  for (const {
810
- route,
811
- parse
812
- } of mappedRoutes) {
813
- if (parse(path)) {
814
- result.push(route);
815
- }
816
- }
817
- return result;
818
- });
819
- const openRoutesByPathFx = attach({
752
+ route: j,
753
+ parse: F
754
+ } of h)
755
+ F(c) && m.push(j);
756
+ return m;
757
+ }), R = B({
820
758
  and: {
821
759
  source: {
822
- query: $query,
823
- path: $path
760
+ query: s,
761
+ path: a
824
762
  },
825
- effect: async (_ref) => {
763
+ effect: (c) => {
826
764
  let {
827
- query,
828
- path
829
- } = _ref;
765
+ query: m,
766
+ path: j
767
+ } = c;
830
768
  for (const {
831
- route,
832
- parse
833
- } of mappedRoutes) {
834
- const matchResult = parse(path);
835
- const [routeClosed, routeNavigated] = [scopeBind(route.internal.close), scopeBind(route.internal.navigated)];
836
- if (!matchResult) {
837
- routeClosed();
838
- } else {
839
- routeNavigated({
840
- query,
841
- params: matchResult.params
842
- });
843
- }
769
+ route: F,
770
+ parse: w
771
+ } of h) {
772
+ const S = w(j), [z, I] = [_(F.internal.close), _(F.internal.navigated)];
773
+ S ? I({
774
+ query: m,
775
+ params: S.params
776
+ }) : z();
844
777
  }
845
778
  }
846
779
  },
847
780
  or: {
848
781
  name: "openRoutesByPathFx",
849
- sid: "-3zl7vq"
782
+ sid: "-bl0nuq"
850
783
  }
851
784
  });
852
- for (const {
853
- route,
854
- build
855
- } of mappedRoutes) {
856
- sample({
857
- and: [{
858
- clock: route.internal.openFx.doneData,
859
- filter: (payload) => (payload == null ? void 0 : payload.navigate) !== false,
860
- fn: (payload) => {
861
- return {
862
- path: build(payload && "params" in payload ? payload.params : void 0),
863
- query: (payload == null ? void 0 : payload.query) ?? {},
864
- replace: payload == null ? void 0 : payload.replace
865
- };
785
+ function d(c) {
786
+ let {
787
+ route: m,
788
+ build: j
789
+ } = c;
790
+ E({
791
+ sid: "t83mj3",
792
+ fn: () => T({
793
+ clock: m.internal.openFx.doneData,
794
+ target: {
795
+ navigate: p
866
796
  },
867
- target: navigate
868
- }],
869
- or: {
870
- sid: "exzzqg"
871
- }
797
+ fn: (F, w) => {
798
+ var S;
799
+ if (w?.navigate === !1)
800
+ return;
801
+ const z = {
802
+ path: j(w && "params" in w ? w.params : void 0),
803
+ query: (S = w?.query) !== null && S !== void 0 ? S : {},
804
+ replace: w?.replace
805
+ };
806
+ return F.navigate(z);
807
+ }
808
+ }),
809
+ name: "none",
810
+ method: "createAction"
872
811
  });
873
812
  }
874
- sample({
813
+ for (const c of h)
814
+ d(c);
815
+ return i({
875
816
  and: [{
876
- clock: locationUpdated,
877
- fn: (location) => ({
878
- path: location.pathname,
879
- query: location.query
817
+ clock: P,
818
+ fn: (c) => ({
819
+ path: c.pathname,
820
+ query: c.query
880
821
  }),
881
- target: openRoutesByPathFx
822
+ target: R
882
823
  }],
883
824
  or: {
884
- sid: "ficdn3"
825
+ sid: "ukhip5"
885
826
  }
886
- });
887
- return {
888
- $query,
889
- $path,
890
- $activeRoutes,
891
- back,
892
- forward,
893
- navigate,
894
- routes,
895
- setHistory,
896
- mappedRoutes,
897
- trackQuery: trackQueryFactory({
898
- $activeRoutes,
899
- $query,
900
- navigate
827
+ }), {
828
+ "@@type": "router",
829
+ $query: s,
830
+ $path: a,
831
+ $history: g,
832
+ $activeRoutes: q,
833
+ back: v,
834
+ forward: y,
835
+ navigate: p,
836
+ setHistory: l,
837
+ ownRoutes: h,
838
+ knownRoutes: u,
839
+ internal: {
840
+ connectToParentRouter: x,
841
+ get parent() {
842
+ return o;
843
+ },
844
+ set parent(c) {
845
+ o = c;
846
+ },
847
+ base: n
848
+ },
849
+ trackQuery: X({
850
+ $activeRoutes: q,
851
+ $query: s,
852
+ navigate: p
901
853
  }),
854
+ registerRoute: (c) => {
855
+ const m = b(c);
856
+ m && (u.push(m), h.push(m), d(m)), C.router(c) && u.push(...c.knownRoutes);
857
+ },
902
858
  "@@unitShape": () => ({
903
- query: $query,
904
- path: $path,
905
- activeRoutes: $activeRoutes,
906
- onBack: back,
907
- onForward: forward,
908
- onNavigate: navigate
859
+ query: s,
860
+ path: a,
861
+ activeRoutes: q,
862
+ onBack: v,
863
+ onForward: y,
864
+ onNavigate: p
909
865
  })
910
866
  };
911
867
  }
912
- function createVirtualRoute() {
913
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
868
+ function Y() {
869
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
914
870
  const {
915
- beforeOpen,
916
- $isPending = createStore(false, {
871
+ $isPending: t = $(!1, {
917
872
  name: "$isPending",
918
- sid: "-f18bwu"
873
+ sid: "-t8kzqo"
919
874
  }),
920
- transformer = (payload) => payload ?? null
921
- } = options;
922
- const $params = createStore(null, {
875
+ transformer: n = (O) => O ?? null
876
+ } = e, r = $(null, {
923
877
  name: "$params",
924
- sid: "v2ropa"
925
- });
926
- const $isOpened = createStore(false, {
878
+ sid: "gvf0vg"
879
+ }), a = $(!1, {
927
880
  name: "$isOpened",
928
- sid: "mzzqqr"
929
- });
930
- const open = createEvent({
881
+ sid: "8sn2wx"
882
+ }), s = f({
931
883
  name: "open",
932
- sid: "f33vnd"
933
- });
934
- const opened = createEvent({
884
+ sid: "vr7tj"
885
+ }), g = f({
935
886
  name: "opened",
936
- sid: "-efpvez"
937
- });
938
- const openedOnServer = createEvent({
887
+ sid: "-sn2j8t"
888
+ }), v = f({
939
889
  name: "openedOnServer",
940
- sid: "o8st20"
941
- });
942
- const openedOnClient = createEvent({
890
+ sid: "a1g586"
891
+ }), y = f({
943
892
  name: "openedOnClient",
944
- sid: "xaagqn"
945
- });
946
- const close = createEvent({
893
+ sid: "j2xswt"
894
+ }), p = f({
947
895
  name: "close",
948
- sid: "-20upkw"
949
- });
950
- const closed = createEvent({
896
+ sid: "-g87deq"
897
+ }), l = f({
951
898
  name: "closed",
952
- sid: "avevxu"
953
- });
954
- const cancelled = createEvent({
899
+ sid: "-3bxrw0"
900
+ }), P = f({
955
901
  name: "cancelled",
956
- sid: "808tq5"
902
+ sid: "3qu86e"
957
903
  });
958
- sample({
904
+ return i({
959
905
  and: [{
960
- clock: open,
961
- target: [opened]
906
+ clock: s,
907
+ target: [g]
962
908
  }],
963
909
  or: {
964
- sid: "p3r2ad"
910
+ sid: "on98hj"
965
911
  }
966
- });
967
- sample({
912
+ }), i({
968
913
  and: [{
969
- clock: open,
970
- fn: transformer,
971
- target: $params
914
+ clock: s,
915
+ fn: n,
916
+ target: r
972
917
  }],
973
918
  or: {
974
- sid: "p6i196"
919
+ sid: "oq07gc"
975
920
  }
976
- });
977
- split({
921
+ }), ee({
978
922
  and: [{
979
- source: opened,
980
- match: () => typeof window === "undefined" ? "server" : "client",
923
+ source: g,
924
+ match: () => typeof window > "u" ? "server" : "client",
981
925
  cases: {
982
- server: openedOnServer,
983
- client: openedOnClient
926
+ server: v,
927
+ client: y
984
928
  }
985
929
  }],
986
930
  or: {
987
- sid: "plch9x"
931
+ sid: "p4unh3"
988
932
  }
989
- });
990
- sample({
933
+ }), i({
991
934
  and: [{
992
- clock: close,
993
- target: closed
935
+ clock: p,
936
+ target: l
994
937
  }],
995
938
  or: {
996
- sid: "q1ub2r"
939
+ sid: "plch9x"
997
940
  }
998
- });
999
- sample({
941
+ }), i({
1000
942
  and: [{
1001
- clock: [opened.map(() => true), closed.map(() => false)],
1002
- target: $isOpened
943
+ clock: [g.map(() => !0), l.map(() => !1)],
944
+ target: a
1003
945
  }],
1004
946
  or: {
1005
- sid: "q4la1k"
947
+ sid: "po3g8q"
1006
948
  }
1007
- });
1008
- return {
1009
- $params,
1010
- $isOpened,
1011
- $isPending,
1012
- open,
1013
- opened,
1014
- openedOnClient,
1015
- openedOnServer,
1016
- close,
1017
- closed,
1018
- cancelled,
949
+ }), {
950
+ "@@type": "pathless-route",
951
+ $params: r,
952
+ $isOpened: a,
953
+ $isPending: t,
954
+ open: s,
955
+ opened: g,
956
+ openedOnClient: y,
957
+ openedOnServer: v,
958
+ close: p,
959
+ closed: l,
960
+ cancelled: P,
1019
961
  path: "",
1020
- beforeOpen,
1021
962
  "@@unitShape": () => ({
1022
- params: $params,
1023
- isOpened: $isOpened,
1024
- isPending: $isPending,
1025
- onOpen: open,
1026
- onClose: close
963
+ params: r,
964
+ isOpened: a,
965
+ isPending: t,
966
+ onOpen: s,
967
+ onClose: p
1027
968
  })
1028
969
  };
1029
970
  }
1030
- function chainRoute(props) {
971
+ function ke(e) {
1031
972
  const {
1032
- route,
1033
- beforeOpen,
1034
- openOn,
1035
- cancelOn
1036
- } = props;
1037
- let asyncImport;
1038
- const waitForAsyncBundleFx = createEffect(() => asyncImport == null ? void 0 : asyncImport(), {
973
+ route: t,
974
+ beforeOpen: n,
975
+ openOn: r,
976
+ cancelOn: a
977
+ } = e;
978
+ let s;
979
+ const g = D(() => {
980
+ var l;
981
+ return (l = s) === null || l === void 0 ? void 0 : l();
982
+ }, {
1039
983
  name: "waitForAsyncBundleFx",
1040
- sid: "qdkcuo"
1041
- });
1042
- const openFx = createEffect(async (payload) => {
1043
- await waitForAsyncBundleFx();
1044
- for (const trigger of [].concat(beforeOpen)) {
1045
- await trigger(payload);
1046
- }
984
+ sid: "t7u37u"
985
+ }), v = D(async (l) => {
986
+ await g();
987
+ for (const P of [].concat(n))
988
+ await P(l);
1047
989
  }, {
1048
990
  name: "openFx",
1049
- sid: "-fwntqy"
991
+ sid: "-34g13p"
992
+ }), y = (l) => l ? "params" in l ? l.params : {} : {}, p = Y({
993
+ transformer: y
1050
994
  });
1051
- const transformer = (payload) => {
1052
- if (!payload) {
1053
- return null;
995
+ return i({
996
+ and: [{
997
+ clock: t.opened,
998
+ target: v
999
+ }],
1000
+ or: {
1001
+ sid: "-1tngcz"
1054
1002
  }
1055
- return "params" in payload ? payload.params : null;
1056
- };
1057
- const virtualRoute = createVirtualRoute({
1058
- transformer
1059
- });
1060
- sample({
1003
+ }), i({
1061
1004
  and: [{
1062
- clock: route.opened,
1063
- target: openFx
1005
+ clock: t.opened,
1006
+ fn: y,
1007
+ target: p.$params
1064
1008
  }],
1065
1009
  or: {
1066
- sid: "-s9xf6p"
1010
+ sid: "-1qwhe6"
1067
1011
  }
1068
- });
1069
- sample({
1012
+ }), r && i({
1070
1013
  and: [{
1071
- clock: route.opened,
1072
- fn: transformer,
1073
- target: virtualRoute.$params
1014
+ clock: r,
1015
+ source: p.$params,
1016
+ fn: (l) => ({
1017
+ params: l
1018
+ }),
1019
+ target: p.open
1074
1020
  }],
1075
1021
  or: {
1076
- sid: "-1u78yc"
1022
+ sid: "-1bi8qc"
1077
1023
  }
1078
- });
1079
- if (openOn) {
1080
- sample({
1081
- and: [{
1082
- clock: openOn,
1083
- source: virtualRoute.$params,
1084
- fn: (params) => params,
1085
- target: virtualRoute.open
1086
- }],
1087
- or: {
1088
- sid: "-1qcor3"
1089
- }
1090
- });
1091
- }
1092
- if (cancelOn) {
1093
- sample({
1094
- and: [{
1095
- clock: [route.closed].concat(cancelOn),
1096
- target: virtualRoute.close
1097
- }],
1098
- or: {
1099
- sid: "-19uuy9"
1100
- }
1101
- });
1102
- sample({
1103
- and: [{
1104
- clock: [].concat(cancelOn),
1105
- target: virtualRoute.cancelled
1106
- }],
1107
- or: {
1108
- sid: "-vk7iv"
1109
- }
1110
- });
1111
- }
1112
- return Object.assign(virtualRoute, {
1024
+ }), a && (i({
1025
+ and: [{
1026
+ clock: [t.closed].concat(a),
1027
+ target: p.close
1028
+ }],
1029
+ or: {
1030
+ sid: "-v0exi"
1031
+ }
1032
+ }), i({
1033
+ and: [{
1034
+ clock: [].concat(a),
1035
+ target: p.cancelled
1036
+ }],
1037
+ or: {
1038
+ sid: "-s9fyp"
1039
+ }
1040
+ })), Object.assign(p, {
1113
1041
  internal: {
1114
- setAsyncImport: (value) => asyncImport = value
1042
+ setAsyncImport: (l) => s = l
1115
1043
  }
1116
1044
  });
1117
1045
  }
1118
- function group(routes) {
1119
- const virtual = createVirtualRoute({
1120
- $isPending: withFactory({
1046
+ function Pe(e) {
1047
+ const t = Y({
1048
+ $isPending: E({
1121
1049
  sid: "-u1putn",
1122
- fn: () => or(...routes.map((route) => route.$isPending)),
1050
+ fn: () => K(...e.map((n) => n.$isPending)),
1123
1051
  name: "$isPending",
1124
1052
  method: "or"
1125
1053
  })
1126
1054
  });
1127
- sample({
1055
+ return i({
1128
1056
  and: [{
1129
- clock: routes.map((route) => route.$isOpened),
1130
- filter: withFactory({
1057
+ clock: e.map((n) => n.$isOpened),
1058
+ filter: E({
1131
1059
  sid: "76kf3k",
1132
- fn: () => or(...routes.map((route) => route.$isOpened)),
1060
+ fn: () => K(...e.map((n) => n.$isOpened)),
1133
1061
  name: "filter",
1134
1062
  method: "or"
1135
1063
  }),
1136
- fn: () => void 0,
1137
- target: virtual.open
1064
+ fn: () => {
1065
+ },
1066
+ target: t.open
1138
1067
  }],
1139
1068
  or: {
1140
1069
  sid: "-xmoke0"
1141
1070
  }
1142
- });
1143
- sample({
1071
+ }), i({
1144
1072
  and: [{
1145
- clock: routes.map((route) => route.$isOpened),
1146
- filter: withFactory({
1073
+ clock: e.map((n) => n.$isOpened),
1074
+ filter: E({
1147
1075
  sid: "ahvrux",
1148
- fn: () => not(withFactory({
1076
+ fn: () => ne(E({
1149
1077
  sid: "xs5yb9",
1150
- fn: () => or(...routes.map((route) => route.$isOpened)),
1078
+ fn: () => K(...e.map((n) => n.$isOpened)),
1151
1079
  name: "fn",
1152
1080
  method: "or"
1153
1081
  })),
1154
1082
  name: "filter",
1155
1083
  method: "not"
1156
1084
  }),
1157
- fn: () => void 0,
1158
- target: virtual.close
1085
+ fn: () => {
1086
+ },
1087
+ target: t.close
1159
1088
  }],
1160
1089
  or: {
1161
1090
  sid: "-x7abrw"
1162
1091
  }
1163
- });
1164
- return virtual;
1092
+ }), t;
1093
+ }
1094
+ function je(e) {
1095
+ return {
1096
+ location: e.location,
1097
+ push: e.push.bind(e),
1098
+ replace: e.replace.bind(e),
1099
+ goBack: e.back.bind(e),
1100
+ goForward: e.forward.bind(e),
1101
+ listen: (t) => {
1102
+ const n = e.listen((r) => {
1103
+ let {
1104
+ location: a
1105
+ } = r;
1106
+ return t(a);
1107
+ });
1108
+ return Object.assign(n, {
1109
+ unsubscribe: n
1110
+ });
1111
+ }
1112
+ };
1113
+ }
1114
+ function M(e) {
1115
+ const t = new URL(decodeURIComponent(e.search));
1116
+ return {
1117
+ pathname: t.pathname,
1118
+ search: t.search,
1119
+ hash: t.hash
1120
+ };
1121
+ }
1122
+ function xe(e) {
1123
+ return {
1124
+ location: M(e.location),
1125
+ push: (t) => {
1126
+ if (typeof t == "string") {
1127
+ const s = new URL(e.location.pathname);
1128
+ s.search = t, e.push(s.toString());
1129
+ } else {
1130
+ var n, r, a;
1131
+ const s = new URL(e.location.pathname);
1132
+ s.search = "".concat((n = t.pathname) !== null && n !== void 0 ? n : "").concat((r = t.search) !== null && r !== void 0 ? r : "").concat((a = t.hash) !== null && a !== void 0 ? a : ""), e.push(s.toString());
1133
+ }
1134
+ },
1135
+ replace: (t) => {
1136
+ if (typeof t == "string") {
1137
+ const s = new URL(e.location.pathname);
1138
+ s.search = t, e.replace(s.toString());
1139
+ } else {
1140
+ var n, r, a;
1141
+ const s = new URL(e.location.pathname);
1142
+ s.search = "".concat((n = t.pathname) !== null && n !== void 0 ? n : "").concat((r = t.search) !== null && r !== void 0 ? r : "").concat((a = t.hash) !== null && a !== void 0 ? a : ""), e.replace(s.toString());
1143
+ }
1144
+ },
1145
+ goBack: () => {
1146
+ e.back();
1147
+ },
1148
+ goForward: () => {
1149
+ e.forward();
1150
+ },
1151
+ listen: (t) => {
1152
+ const n = e.listen((r) => {
1153
+ let {
1154
+ location: a
1155
+ } = r;
1156
+ return t(M(a));
1157
+ });
1158
+ return Object.assign(n, {
1159
+ unsubscribe: n
1160
+ });
1161
+ }
1162
+ };
1165
1163
  }
1166
1164
  export {
1167
- chainRoute,
1168
- createRoute,
1169
- createRouter,
1170
- createRouterControls,
1171
- createVirtualRoute,
1172
- group
1165
+ ke as chainRoute,
1166
+ we as createRoute,
1167
+ Oe as createRouter,
1168
+ fe as createRouterControls,
1169
+ Y as createVirtualRoute,
1170
+ Pe as group,
1171
+ je as historyAdapter,
1172
+ U as is,
1173
+ xe as queryAdapter
1173
1174
  };