reactive-route 0.0.1-alpha.31 → 0.0.1-alpha.33
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/core/createRouter.d.ts.map +1 -1
- package/core/index.d.ts +0 -1
- package/core/index.d.ts.map +1 -1
- package/core/types/TypeRouter.d.ts +1 -2
- package/core/types/TypeRouter.d.ts.map +1 -1
- package/core/utils/getInitialRoute.d.ts +1 -0
- package/core/utils/getInitialRoute.d.ts.map +1 -1
- package/index.cjs +19 -25
- package/index.mjs +19 -25
- package/package.json +1 -4
- package/preact/Router.d.ts.map +1 -1
- package/preact/index.cjs +0 -15
- package/preact/index.mjs +2 -17
- package/react/Router.d.ts.map +1 -1
- package/react/index.cjs +0 -15
- package/react/index.mjs +2 -17
- package/solid/Router.d.ts.map +1 -1
- package/solid/index.cjs +4 -16
- package/solid/index.mjs +6 -18
- package/vue/index.cjs +0 -0
- package/vue/index.mjs +0 -0
- package/core/utils/history.d.ts +0 -7
- package/core/utils/history.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../../packages/core/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../../packages/core/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWhD,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CAC9B,GAAG,UAAU,CAAC,OAAO,CAAC,CAuPtB"}
|
package/core/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export type { TypePropsRouter } from './types/TypePropsRouter';
|
|
|
6
6
|
export type { TypeRedirectParams } from './types/TypeRedirectParams';
|
|
7
7
|
export type { TypeRoute } from './types/TypeRoute';
|
|
8
8
|
export type { TypeRouter } from './types/TypeRouter';
|
|
9
|
-
export { history } from './utils/history';
|
|
10
9
|
export { loadComponentToConfig } from './utils/loadComponentToConfig';
|
|
11
10
|
export { RedirectError } from './utils/RedirectError';
|
|
12
11
|
export { replaceDynamicValues } from './utils/replaceDynamicValues';
|
package/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -6,7 +6,6 @@ export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalErr
|
|
|
6
6
|
routes: TRoutes;
|
|
7
7
|
adapters: TypeAdapters;
|
|
8
8
|
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
9
|
-
routesHistory: Array<string>;
|
|
10
9
|
isRedirecting: boolean;
|
|
11
10
|
redirect<TRouteName extends keyof TRoutes>(config: TypeRedirectParams<TRoutes, TRouteName>): Promise<void>;
|
|
12
11
|
restoreFromURL(params: {
|
|
@@ -14,9 +13,9 @@ export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalErr
|
|
|
14
13
|
replace?: boolean;
|
|
15
14
|
}): Promise<void>;
|
|
16
15
|
restoreFromServer(obj: {
|
|
17
|
-
routesHistory: Array<string>;
|
|
18
16
|
currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
|
|
19
17
|
}): Promise<void>;
|
|
20
18
|
lifecycleParams?: Array<any>;
|
|
19
|
+
destroy(): void;
|
|
21
20
|
};
|
|
22
21
|
//# sourceMappingURL=TypeRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,IAAI;IACjG,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;IACvD,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"TypeRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,IAAI;IACjG,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;IACvD,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,UAAU,SAAS,MAAM,OAAO,EACvC,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,iBAAiB,CAAC,GAAG,EAAE;QAAE,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClG,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
|
|
@@ -3,5 +3,6 @@ import { TypeRoute } from '../types/TypeRoute';
|
|
|
3
3
|
export declare function getInitialRoute<TRoutes extends Record<string | 'notFound' | 'internalError', TypeRoute>>(params: {
|
|
4
4
|
routes: TRoutes;
|
|
5
5
|
pathname: string;
|
|
6
|
+
replace?: boolean;
|
|
6
7
|
}): TypeRedirectParams<TRoutes, keyof TRoutes>;
|
|
7
8
|
//# sourceMappingURL=getInitialRoute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInitialRoute.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getInitialRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,wBAAgB,eAAe,CAC7B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"getInitialRoute.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getInitialRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,wBAAgB,eAAe,CAC7B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,CAW7C"}
|
package/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(core_exports, {
|
|
|
23
23
|
RedirectError: () => RedirectError,
|
|
24
24
|
createRouter: () => createRouter,
|
|
25
25
|
createRoutes: () => createRoutes,
|
|
26
|
-
history: () => history,
|
|
27
26
|
loadComponentToConfig: () => loadComponentToConfig,
|
|
28
27
|
replaceDynamicValues: () => replaceDynamicValues,
|
|
29
28
|
routerSetLoadedComponent: () => routerSetLoadedComponent
|
|
@@ -132,14 +131,11 @@ function getInitialRoute(params) {
|
|
|
132
131
|
return {
|
|
133
132
|
route: route.name,
|
|
134
133
|
query: getQueryValues({ route, pathname: params.pathname }),
|
|
135
|
-
params: getDynamicValues({ route, pathname: params.pathname })
|
|
134
|
+
params: getDynamicValues({ route, pathname: params.pathname }),
|
|
135
|
+
replace: params.replace
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
// packages/core/utils/history.ts
|
|
140
|
-
var import_history = require("history");
|
|
141
|
-
var history = constants.isClient ? (0, import_history.createBrowserHistory)() : null;
|
|
142
|
-
|
|
143
139
|
// packages/core/utils/loadComponentToConfig.ts
|
|
144
140
|
function loadComponentToConfig(params) {
|
|
145
141
|
const { route } = params;
|
|
@@ -190,12 +186,12 @@ function replaceDynamicValues({
|
|
|
190
186
|
// packages/core/createRouter.ts
|
|
191
187
|
function createRouter(config) {
|
|
192
188
|
const router = config.adapters.makeObservable({
|
|
193
|
-
routesHistory: [],
|
|
194
189
|
currentRoute: {},
|
|
195
190
|
isRedirecting: false,
|
|
196
191
|
redirect: void 0,
|
|
197
192
|
restoreFromURL: void 0,
|
|
198
193
|
restoreFromServer: void 0,
|
|
194
|
+
destroy: void 0,
|
|
199
195
|
get adapters() {
|
|
200
196
|
return config.adapters;
|
|
201
197
|
},
|
|
@@ -208,7 +204,6 @@ function createRouter(config) {
|
|
|
208
204
|
});
|
|
209
205
|
router.restoreFromServer = function restoreFromServer(obj) {
|
|
210
206
|
router.adapters.batch(() => {
|
|
211
|
-
router.routesHistory.push(...obj.routesHistory || []);
|
|
212
207
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
213
208
|
});
|
|
214
209
|
const preloadedRouteName = Object.keys(router.routes).find(
|
|
@@ -263,14 +258,9 @@ function createRouter(config) {
|
|
|
263
258
|
...router.currentRoute,
|
|
264
259
|
query: nextQuery || {}
|
|
265
260
|
});
|
|
266
|
-
router.routesHistory.push(nextUrl);
|
|
267
261
|
});
|
|
268
|
-
if (
|
|
269
|
-
history
|
|
270
|
-
hash: history.location.hash,
|
|
271
|
-
search: nextSearch,
|
|
272
|
-
pathname: nextPathname
|
|
273
|
-
});
|
|
262
|
+
if (constants.isClient) {
|
|
263
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
274
264
|
}
|
|
275
265
|
}
|
|
276
266
|
return Promise.resolve();
|
|
@@ -348,21 +338,25 @@ function createRouter(config) {
|
|
|
348
338
|
params: getDynamicValues({ route: nextRoute, pathname: nextUrl }),
|
|
349
339
|
pageId: router.routes[nextRoute.name].pageId
|
|
350
340
|
});
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
router.routesHistory.push(nextUrl);
|
|
354
|
-
}
|
|
355
|
-
if (history && !replace) {
|
|
356
|
-
history.push({
|
|
357
|
-
hash: history.location.hash,
|
|
358
|
-
search: "query" in config2 ? `?${queryString.stringify(config2.query)}` : "",
|
|
359
|
-
pathname: nextPathname
|
|
360
|
-
});
|
|
341
|
+
if (constants.isClient) {
|
|
342
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
361
343
|
}
|
|
362
344
|
router.isRedirecting = false;
|
|
363
345
|
});
|
|
364
346
|
return Promise.resolve();
|
|
365
347
|
};
|
|
348
|
+
function popHandler() {
|
|
349
|
+
const currentUrl = `${location.pathname}${location.search}`;
|
|
350
|
+
void router.restoreFromURL({ pathname: currentUrl, replace: true });
|
|
351
|
+
}
|
|
352
|
+
if (constants.isClient) {
|
|
353
|
+
window.addEventListener("popstate", popHandler);
|
|
354
|
+
}
|
|
355
|
+
router.destroy = function destroy() {
|
|
356
|
+
if (constants.isClient) {
|
|
357
|
+
window.removeEventListener("popstate", popHandler);
|
|
358
|
+
}
|
|
359
|
+
};
|
|
366
360
|
return router;
|
|
367
361
|
}
|
|
368
362
|
|
package/index.mjs
CHANGED
|
@@ -100,14 +100,11 @@ function getInitialRoute(params) {
|
|
|
100
100
|
return {
|
|
101
101
|
route: route.name,
|
|
102
102
|
query: getQueryValues({ route, pathname: params.pathname }),
|
|
103
|
-
params: getDynamicValues({ route, pathname: params.pathname })
|
|
103
|
+
params: getDynamicValues({ route, pathname: params.pathname }),
|
|
104
|
+
replace: params.replace
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
// packages/core/utils/history.ts
|
|
108
|
-
import { createBrowserHistory } from "history";
|
|
109
|
-
var history = constants.isClient ? createBrowserHistory() : null;
|
|
110
|
-
|
|
111
108
|
// packages/core/utils/loadComponentToConfig.ts
|
|
112
109
|
function loadComponentToConfig(params) {
|
|
113
110
|
const { route } = params;
|
|
@@ -158,12 +155,12 @@ function replaceDynamicValues({
|
|
|
158
155
|
// packages/core/createRouter.ts
|
|
159
156
|
function createRouter(config) {
|
|
160
157
|
const router = config.adapters.makeObservable({
|
|
161
|
-
routesHistory: [],
|
|
162
158
|
currentRoute: {},
|
|
163
159
|
isRedirecting: false,
|
|
164
160
|
redirect: void 0,
|
|
165
161
|
restoreFromURL: void 0,
|
|
166
162
|
restoreFromServer: void 0,
|
|
163
|
+
destroy: void 0,
|
|
167
164
|
get adapters() {
|
|
168
165
|
return config.adapters;
|
|
169
166
|
},
|
|
@@ -176,7 +173,6 @@ function createRouter(config) {
|
|
|
176
173
|
});
|
|
177
174
|
router.restoreFromServer = function restoreFromServer(obj) {
|
|
178
175
|
router.adapters.batch(() => {
|
|
179
|
-
router.routesHistory.push(...obj.routesHistory || []);
|
|
180
176
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
181
177
|
});
|
|
182
178
|
const preloadedRouteName = Object.keys(router.routes).find(
|
|
@@ -231,14 +227,9 @@ function createRouter(config) {
|
|
|
231
227
|
...router.currentRoute,
|
|
232
228
|
query: nextQuery || {}
|
|
233
229
|
});
|
|
234
|
-
router.routesHistory.push(nextUrl);
|
|
235
230
|
});
|
|
236
|
-
if (
|
|
237
|
-
history
|
|
238
|
-
hash: history.location.hash,
|
|
239
|
-
search: nextSearch,
|
|
240
|
-
pathname: nextPathname
|
|
241
|
-
});
|
|
231
|
+
if (constants.isClient) {
|
|
232
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
242
233
|
}
|
|
243
234
|
}
|
|
244
235
|
return Promise.resolve();
|
|
@@ -316,21 +307,25 @@ function createRouter(config) {
|
|
|
316
307
|
params: getDynamicValues({ route: nextRoute, pathname: nextUrl }),
|
|
317
308
|
pageId: router.routes[nextRoute.name].pageId
|
|
318
309
|
});
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
router.routesHistory.push(nextUrl);
|
|
322
|
-
}
|
|
323
|
-
if (history && !replace) {
|
|
324
|
-
history.push({
|
|
325
|
-
hash: history.location.hash,
|
|
326
|
-
search: "query" in config2 ? `?${queryString.stringify(config2.query)}` : "",
|
|
327
|
-
pathname: nextPathname
|
|
328
|
-
});
|
|
310
|
+
if (constants.isClient) {
|
|
311
|
+
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
329
312
|
}
|
|
330
313
|
router.isRedirecting = false;
|
|
331
314
|
});
|
|
332
315
|
return Promise.resolve();
|
|
333
316
|
};
|
|
317
|
+
function popHandler() {
|
|
318
|
+
const currentUrl = `${location.pathname}${location.search}`;
|
|
319
|
+
void router.restoreFromURL({ pathname: currentUrl, replace: true });
|
|
320
|
+
}
|
|
321
|
+
if (constants.isClient) {
|
|
322
|
+
window.addEventListener("popstate", popHandler);
|
|
323
|
+
}
|
|
324
|
+
router.destroy = function destroy() {
|
|
325
|
+
if (constants.isClient) {
|
|
326
|
+
window.removeEventListener("popstate", popHandler);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
334
329
|
return router;
|
|
335
330
|
}
|
|
336
331
|
|
|
@@ -376,7 +371,6 @@ export {
|
|
|
376
371
|
RedirectError,
|
|
377
372
|
createRouter,
|
|
378
373
|
createRoutes,
|
|
379
|
-
history,
|
|
380
374
|
loadComponentToConfig,
|
|
381
375
|
replaceDynamicValues,
|
|
382
376
|
routerSetLoadedComponent
|
package/package.json
CHANGED
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
"name": "reactive-route",
|
|
3
3
|
"author": "Dmitry Kazakov",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.1-alpha.
|
|
5
|
+
"version": "0.0.1-alpha.33",
|
|
6
6
|
"description": "Reactive Router for different frameworks",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/dkazakov8/reactive-route.git"
|
|
10
10
|
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"history": "5.3.0"
|
|
13
|
-
},
|
|
14
11
|
"engines": {
|
|
15
12
|
"node": ">=22"
|
|
16
13
|
},
|
package/preact/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/preact/Router.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/preact/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6CtF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAK1D,GAAG,CACzC"}
|
package/preact/index.cjs
CHANGED
|
@@ -30,20 +30,6 @@ var import_reactive_route = require("reactive-route");
|
|
|
30
30
|
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
31
31
|
function RouterInner(props) {
|
|
32
32
|
const disposerRef = (0, import_hooks.useRef)(null);
|
|
33
|
-
const redirectOnHistoryPop = (0, import_hooks.useCallback)(() => {
|
|
34
|
-
if (!import_reactive_route.history) return;
|
|
35
|
-
import_reactive_route.history.listen((params) => {
|
|
36
|
-
if (params.action !== "POP") return;
|
|
37
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
38
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
39
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
40
|
-
}
|
|
41
|
-
void props.router.restoreFromURL({
|
|
42
|
-
pathname: import_reactive_route.history.location.pathname,
|
|
43
|
-
replace: true
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}, []);
|
|
47
33
|
const [config] = (0, import_hooks.useState)(
|
|
48
34
|
() => props.router.adapters.makeObservable({
|
|
49
35
|
loadedComponentName: void 0,
|
|
@@ -54,7 +40,6 @@ function RouterInner(props) {
|
|
|
54
40
|
(0, import_hooks.useState)(() => {
|
|
55
41
|
props.router.adapters.batch(() => {
|
|
56
42
|
props.beforeMount?.();
|
|
57
|
-
redirectOnHistoryPop();
|
|
58
43
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
|
59
44
|
disposerRef.current = props.router.adapters.autorun(
|
|
60
45
|
() => (0, import_reactive_route.routerSetLoadedComponent)(props, config)
|
package/preact/index.mjs
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
// packages/preact/Router.tsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from "preact/hooks";
|
|
3
|
+
import { routerSetLoadedComponent } from "reactive-route";
|
|
4
4
|
import { jsx } from "preact/jsx-runtime";
|
|
5
5
|
function RouterInner(props) {
|
|
6
6
|
const disposerRef = useRef(null);
|
|
7
|
-
const redirectOnHistoryPop = useCallback(() => {
|
|
8
|
-
if (!history) return;
|
|
9
|
-
history.listen((params) => {
|
|
10
|
-
if (params.action !== "POP") return;
|
|
11
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
12
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
13
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
14
|
-
}
|
|
15
|
-
void props.router.restoreFromURL({
|
|
16
|
-
pathname: history.location.pathname,
|
|
17
|
-
replace: true
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}, []);
|
|
21
7
|
const [config] = useState(
|
|
22
8
|
() => props.router.adapters.makeObservable({
|
|
23
9
|
loadedComponentName: void 0,
|
|
@@ -28,7 +14,6 @@ function RouterInner(props) {
|
|
|
28
14
|
useState(() => {
|
|
29
15
|
props.router.adapters.batch(() => {
|
|
30
16
|
props.beforeMount?.();
|
|
31
|
-
redirectOnHistoryPop();
|
|
32
17
|
routerSetLoadedComponent(props, config);
|
|
33
18
|
disposerRef.current = props.router.adapters.autorun(
|
|
34
19
|
() => routerSetLoadedComponent(props, config)
|
package/react/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/react/Router.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/react/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA6CtF,iBAAS,aAAa,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,GAK1D,GAAG,CACzC;AAED,eAAO,MAAM,MAAM,EAA0B,OAAO,aAAa,CAAC"}
|
package/react/index.cjs
CHANGED
|
@@ -30,20 +30,6 @@ var import_reactive_route = require("reactive-route");
|
|
|
30
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
31
|
function RouterInner(props) {
|
|
32
32
|
const disposerRef = (0, import_react.useRef)(null);
|
|
33
|
-
const redirectOnHistoryPop = (0, import_react.useCallback)(() => {
|
|
34
|
-
if (!import_reactive_route.history) return;
|
|
35
|
-
import_reactive_route.history.listen((params) => {
|
|
36
|
-
if (params.action !== "POP") return;
|
|
37
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
38
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
39
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
40
|
-
}
|
|
41
|
-
void props.router.restoreFromURL({
|
|
42
|
-
pathname: import_reactive_route.history.location.pathname,
|
|
43
|
-
replace: true
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}, []);
|
|
47
33
|
const [config] = (0, import_react.useState)(
|
|
48
34
|
() => props.router.adapters.makeObservable({
|
|
49
35
|
loadedComponentName: void 0,
|
|
@@ -54,7 +40,6 @@ function RouterInner(props) {
|
|
|
54
40
|
(0, import_react.useState)(() => {
|
|
55
41
|
props.router.adapters.batch(() => {
|
|
56
42
|
props.beforeMount?.();
|
|
57
|
-
redirectOnHistoryPop();
|
|
58
43
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
|
59
44
|
disposerRef.current = props.router.adapters.autorun(
|
|
60
45
|
() => (0, import_reactive_route.routerSetLoadedComponent)(props, config)
|
package/react/index.mjs
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
// packages/react/Router.tsx
|
|
2
|
-
import { memo,
|
|
3
|
-
import {
|
|
2
|
+
import { memo, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { routerSetLoadedComponent } from "reactive-route";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
function RouterInner(props) {
|
|
6
6
|
const disposerRef = useRef(null);
|
|
7
|
-
const redirectOnHistoryPop = useCallback(() => {
|
|
8
|
-
if (!history) return;
|
|
9
|
-
history.listen((params) => {
|
|
10
|
-
if (params.action !== "POP") return;
|
|
11
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
12
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
13
|
-
props.router.adapters.batch(() => props.router.routesHistory.pop());
|
|
14
|
-
}
|
|
15
|
-
void props.router.restoreFromURL({
|
|
16
|
-
pathname: history.location.pathname,
|
|
17
|
-
replace: true
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}, []);
|
|
21
7
|
const [config] = useState(
|
|
22
8
|
() => props.router.adapters.makeObservable({
|
|
23
9
|
loadedComponentName: void 0,
|
|
@@ -28,7 +14,6 @@ function RouterInner(props) {
|
|
|
28
14
|
useState(() => {
|
|
29
15
|
props.router.adapters.batch(() => {
|
|
30
16
|
props.beforeMount?.();
|
|
31
|
-
redirectOnHistoryPop();
|
|
32
17
|
routerSetLoadedComponent(props, config);
|
|
33
18
|
disposerRef.current = props.router.adapters.autorun(
|
|
34
19
|
() => routerSetLoadedComponent(props, config)
|
package/solid/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAItF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,kCAsChG"}
|
package/solid/index.cjs
CHANGED
|
@@ -36,28 +36,16 @@ function Router(props) {
|
|
|
36
36
|
loadedComponentPage: void 0,
|
|
37
37
|
currentProps: {}
|
|
38
38
|
});
|
|
39
|
-
function redirectOnHistoryPop() {
|
|
40
|
-
if (!import_reactive_route.history) return;
|
|
41
|
-
import_reactive_route.history.listen((params) => {
|
|
42
|
-
if (params.action !== "POP") return;
|
|
43
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
44
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
45
|
-
props.router.routesHistory.pop();
|
|
46
|
-
}
|
|
47
|
-
void props.router.restoreFromURL({
|
|
48
|
-
pathname: import_reactive_route.history.location.pathname,
|
|
49
|
-
replace: true
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
39
|
props.beforeMount?.();
|
|
54
|
-
redirectOnHistoryPop();
|
|
55
40
|
if (props.router.adapters.immediateSetComponent) {
|
|
56
41
|
props.router.adapters.batch(() => {
|
|
57
42
|
(0, import_reactive_route.routerSetLoadedComponent)(props, config);
|
|
58
43
|
});
|
|
59
44
|
}
|
|
60
|
-
props.router.adapters.autorun(() => (0, import_reactive_route.routerSetLoadedComponent)(props, config));
|
|
45
|
+
const disposer = props.router.adapters.autorun(() => (0, import_reactive_route.routerSetLoadedComponent)(props, config));
|
|
46
|
+
(0, import_solid_js.onCleanup)(() => {
|
|
47
|
+
if (typeof disposer === "function") disposer();
|
|
48
|
+
});
|
|
61
49
|
return (
|
|
62
50
|
// @ts-ignore
|
|
63
51
|
(0, import_web.createComponent)(import_solid_js.Show, {
|
package/solid/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// packages/solid/Router.tsx
|
|
2
2
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3
3
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
4
|
-
import {
|
|
5
|
-
import { Show } from "solid-js";
|
|
4
|
+
import { routerSetLoadedComponent } from "reactive-route";
|
|
5
|
+
import { onCleanup, Show } from "solid-js";
|
|
6
6
|
import { Dynamic } from "solid-js/web";
|
|
7
7
|
function Router(props) {
|
|
8
8
|
const config = props.router.adapters.makeObservable({
|
|
@@ -10,28 +10,16 @@ function Router(props) {
|
|
|
10
10
|
loadedComponentPage: void 0,
|
|
11
11
|
currentProps: {}
|
|
12
12
|
});
|
|
13
|
-
function redirectOnHistoryPop() {
|
|
14
|
-
if (!history) return;
|
|
15
|
-
history.listen((params) => {
|
|
16
|
-
if (params.action !== "POP") return;
|
|
17
|
-
const previousRoutePathname = props.router.routesHistory[props.router.routesHistory.length - 2];
|
|
18
|
-
if (previousRoutePathname === params.location.pathname) {
|
|
19
|
-
props.router.routesHistory.pop();
|
|
20
|
-
}
|
|
21
|
-
void props.router.restoreFromURL({
|
|
22
|
-
pathname: history.location.pathname,
|
|
23
|
-
replace: true
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
13
|
props.beforeMount?.();
|
|
28
|
-
redirectOnHistoryPop();
|
|
29
14
|
if (props.router.adapters.immediateSetComponent) {
|
|
30
15
|
props.router.adapters.batch(() => {
|
|
31
16
|
routerSetLoadedComponent(props, config);
|
|
32
17
|
});
|
|
33
18
|
}
|
|
34
|
-
props.router.adapters.autorun(() => routerSetLoadedComponent(props, config));
|
|
19
|
+
const disposer = props.router.adapters.autorun(() => routerSetLoadedComponent(props, config));
|
|
20
|
+
onCleanup(() => {
|
|
21
|
+
if (typeof disposer === "function") disposer();
|
|
22
|
+
});
|
|
35
23
|
return (
|
|
36
24
|
// @ts-ignore
|
|
37
25
|
_$createComponent(Show, {
|
package/vue/index.cjs
CHANGED
|
Binary file
|
package/vue/index.mjs
CHANGED
|
Binary file
|
package/core/utils/history.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAI/C;;;GAGG;AAEH,eAAO,MAAM,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAEnD,CAAC"}
|