reactive-route 0.0.1-alpha.4 → 0.0.1-alpha.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.
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/adapters/mobx.ts
21
+ var mobx_exports = {};
22
+ __export(mobx_exports, {
23
+ adapters: () => adapters
24
+ });
25
+ module.exports = __toCommonJS(mobx_exports);
26
+ var import_mobx = require("mobx");
27
+ var adapters = {
28
+ batch: import_mobx.runInAction,
29
+ autorun: import_mobx.autorun,
30
+ replaceObject: (obj, newObj) => {
31
+ (0, import_mobx.runInAction)(() => {
32
+ for (const variableKey in obj) {
33
+ if (obj.hasOwnProperty(variableKey)) {
34
+ delete obj[variableKey];
35
+ }
36
+ }
37
+ Object.assign(obj, newObj);
38
+ });
39
+ return obj;
40
+ },
41
+ makeObservable: import_mobx.observable
42
+ };
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/adapters/solid.ts
21
+ var solid_exports = {};
22
+ __export(solid_exports, {
23
+ adapters: () => adapters
24
+ });
25
+ module.exports = __toCommonJS(solid_exports);
26
+ var import_solid_js = require("solid-js");
27
+ var import_store = require("solid-js/store");
28
+ var adapters = {
29
+ batch: import_solid_js.batch,
30
+ autorun: import_solid_js.createRenderEffect,
31
+ replaceObject: (obj, newObj) => {
32
+ (0, import_store.modifyMutable)(
33
+ obj,
34
+ (0, import_store.produce)((state) => {
35
+ if (typeof state === "object" && state != null) {
36
+ for (const variableKey in state) {
37
+ if (state.hasOwnProperty(variableKey)) {
38
+ delete state[variableKey];
39
+ }
40
+ }
41
+ }
42
+ Object.assign(state || {}, newObj);
43
+ })
44
+ );
45
+ },
46
+ makeObservable: import_store.createMutable
47
+ };
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
package/dist/cjs/index.js CHANGED
@@ -191,30 +191,22 @@ function replaceDynamicValues({
191
191
 
192
192
  // packages/core/createRouterStore.ts
193
193
  function createRouterStore({
194
- batch,
194
+ adapters,
195
195
  routes,
196
- autorun,
197
- replaceObject,
198
196
  routeError500,
199
- makeObservable,
200
197
  lifecycleParams
201
198
  }) {
202
- const routerStore = makeObservable({
199
+ const routerStore = adapters.makeObservable({
203
200
  routesHistory: [],
204
201
  currentRoute: {},
205
202
  isRedirecting: false,
206
203
  redirectTo: void 0,
207
204
  restoreFromURL: void 0,
208
205
  restoreFromServer: void 0,
209
- utils: {
210
- batch,
211
- autorun,
212
- replaceObject,
213
- makeObservable
214
- }
206
+ adapters
215
207
  });
216
208
  routerStore.restoreFromServer = function restoreFromServer(obj) {
217
- batch(() => {
209
+ adapters.batch(() => {
218
210
  routerStore.routesHistory.push(...obj.routesHistory || []);
219
211
  Object.assign(routerStore.currentRoute, obj.currentRoute);
220
212
  });
@@ -269,8 +261,8 @@ function createRouterStore({
269
261
  if (currentUrl === nextUrl) return Promise.resolve();
270
262
  if (currentPathname === nextPathname) {
271
263
  if (currentSearch !== nextSearch) {
272
- batch(() => {
273
- replaceObject(routerStore.currentRoute.query, nextQuery || {});
264
+ adapters.batch(() => {
265
+ adapters.replaceObject(routerStore.currentRoute.query, nextQuery || {});
274
266
  routerStore.routesHistory.push(nextUrl);
275
267
  });
276
268
  if (history && !noHistoryPush) {
@@ -283,7 +275,7 @@ function createRouterStore({
283
275
  }
284
276
  return Promise.resolve();
285
277
  }
286
- batch(() => {
278
+ adapters.batch(() => {
287
279
  routerStore.isRedirecting = true;
288
280
  });
289
281
  try {
@@ -344,8 +336,8 @@ function createRouterStore({
344
336
  }
345
337
  console.error(error);
346
338
  await loadComponentToConfig({ route: routeError500 });
347
- batch(() => {
348
- replaceObject(routerStore.currentRoute, {
339
+ adapters.batch(() => {
340
+ adapters.replaceObject(routerStore.currentRoute, {
349
341
  name: routeError500.name,
350
342
  path: routeError500.path,
351
343
  props: routes[routeError500.name].props,
@@ -357,8 +349,8 @@ function createRouterStore({
357
349
  });
358
350
  return Promise.resolve();
359
351
  }
360
- batch(() => {
361
- replaceObject(routerStore.currentRoute, {
352
+ adapters.batch(() => {
353
+ adapters.replaceObject(routerStore.currentRoute, {
362
354
  name: nextRoute.name,
363
355
  path: nextRoute.path,
364
356
  props: routes[nextRoute.name].props,
@@ -75,14 +75,14 @@ var VM = class {
75
75
  loadedComponentPage = void 0;
76
76
  loadedComponent;
77
77
  currentProps = {};
78
- get utils() {
79
- return this.props.routerStore.utils;
78
+ get adapters() {
79
+ return this.props.routerStore.adapters;
80
80
  }
81
81
  beforeMount() {
82
82
  this.props.beforeMount?.();
83
83
  this.redirectOnHistoryPop();
84
84
  this.setLoadedComponent();
85
- this.autorunDisposers.push(this.utils.autorun(this.setLoadedComponent));
85
+ this.autorunDisposers.push(this.adapters.autorun(this.setLoadedComponent));
86
86
  }
87
87
  redirectOnHistoryPop() {
88
88
  if (!import_reactive_route.history) return;
@@ -90,7 +90,7 @@ var VM = class {
90
90
  if (params.action !== "POP") return;
91
91
  const previousRoutePathname = this.props.routerStore.routesHistory[this.props.routerStore.routesHistory.length - 2];
92
92
  if (previousRoutePathname === params.location.pathname) {
93
- this.utils.batch(() => this.props.routerStore.routesHistory.pop());
93
+ this.adapters.batch(() => this.props.routerStore.routesHistory.pop());
94
94
  }
95
95
  void this.props.routerStore.redirectTo({
96
96
  noHistoryPush: true,
@@ -113,14 +113,14 @@ var VM = class {
113
113
  else if (loadedComponentPage != null && currentRouteName != null) {
114
114
  if (loadedComponentPage === currentRoutePage) {
115
115
  const componentConfig = this.props.routes[currentRouteName];
116
- this.utils.batch(() => {
116
+ this.adapters.batch(() => {
117
117
  this.currentProps = "props" in componentConfig ? componentConfig.props || {} : {};
118
118
  });
119
119
  preventRedirect = true;
120
120
  }
121
121
  }
122
122
  if (preventRedirect) return;
123
- this.utils.batch(() => {
123
+ this.adapters.batch(() => {
124
124
  if (!loadedComponentName) {
125
125
  this.setComponent(currentRouteName);
126
126
  } else {
@@ -52,13 +52,13 @@ var VM = class {
52
52
  loadedComponentName = void 0;
53
53
  loadedComponentPage = void 0;
54
54
  currentProps = {};
55
- get utils() {
56
- return this.props.routerStore.utils;
55
+ get adapters() {
56
+ return this.props.routerStore.adapters;
57
57
  }
58
58
  beforeMount() {
59
59
  this.props.beforeMount?.();
60
60
  this.redirectOnHistoryPop();
61
- this.utils.autorun(() => this.setLoadedComponent());
61
+ this.adapters.autorun(() => this.setLoadedComponent());
62
62
  }
63
63
  redirectOnHistoryPop() {
64
64
  if (!import_reactive_route.history) return;
@@ -88,12 +88,12 @@ var VM = class {
88
88
  } else if (this.loadedComponentPage != null && currentRouteName != null) {
89
89
  if (this.loadedComponentPage === currentRoutePage) {
90
90
  const componentConfig = this.props.routes[currentRouteName];
91
- this.utils.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
91
+ this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
92
92
  preventRedirect = true;
93
93
  }
94
94
  }
95
95
  if (preventRedirect) return;
96
- this.utils.batch(() => {
96
+ this.adapters.batch(() => {
97
97
  if (!this.loadedComponentName) {
98
98
  this.setComponent();
99
99
  } else {
@@ -106,8 +106,8 @@ var VM = class {
106
106
  const currentRouteName = this.props.routerStore.currentRoute.name;
107
107
  const componentConfig = this.props.routes[currentRouteName];
108
108
  this.props.beforeSetPageComponent?.(componentConfig);
109
- this.utils.batch(() => {
110
- this.utils.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
109
+ this.adapters.batch(() => {
110
+ this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
111
111
  this.loadedComponentName = currentRouteName;
112
112
  this.loadedComponentPage = componentConfig.pageName;
113
113
  });
@@ -0,0 +1,21 @@
1
+ // packages/adapters/mobx.ts
2
+ import { autorun, observable, runInAction } from "mobx";
3
+ var adapters = {
4
+ batch: runInAction,
5
+ autorun,
6
+ replaceObject: (obj, newObj) => {
7
+ runInAction(() => {
8
+ for (const variableKey in obj) {
9
+ if (obj.hasOwnProperty(variableKey)) {
10
+ delete obj[variableKey];
11
+ }
12
+ }
13
+ Object.assign(obj, newObj);
14
+ });
15
+ return obj;
16
+ },
17
+ makeObservable: observable
18
+ };
19
+ export {
20
+ adapters
21
+ };
@@ -0,0 +1 @@
1
+ {"type": "module"}
@@ -0,0 +1,26 @@
1
+ // packages/adapters/solid.ts
2
+ import { batch, createRenderEffect } from "solid-js";
3
+ import { createMutable, modifyMutable, produce } from "solid-js/store";
4
+ var adapters = {
5
+ batch,
6
+ autorun: createRenderEffect,
7
+ replaceObject: (obj, newObj) => {
8
+ modifyMutable(
9
+ obj,
10
+ produce((state) => {
11
+ if (typeof state === "object" && state != null) {
12
+ for (const variableKey in state) {
13
+ if (state.hasOwnProperty(variableKey)) {
14
+ delete state[variableKey];
15
+ }
16
+ }
17
+ }
18
+ Object.assign(state || {}, newObj);
19
+ })
20
+ );
21
+ },
22
+ makeObservable: createMutable
23
+ };
24
+ export {
25
+ adapters
26
+ };
@@ -0,0 +1 @@
1
+ {"type": "module"}
package/dist/esm/index.js CHANGED
@@ -148,30 +148,22 @@ function replaceDynamicValues({
148
148
 
149
149
  // packages/core/createRouterStore.ts
150
150
  function createRouterStore({
151
- batch,
151
+ adapters,
152
152
  routes,
153
- autorun,
154
- replaceObject,
155
153
  routeError500,
156
- makeObservable,
157
154
  lifecycleParams
158
155
  }) {
159
- const routerStore = makeObservable({
156
+ const routerStore = adapters.makeObservable({
160
157
  routesHistory: [],
161
158
  currentRoute: {},
162
159
  isRedirecting: false,
163
160
  redirectTo: void 0,
164
161
  restoreFromURL: void 0,
165
162
  restoreFromServer: void 0,
166
- utils: {
167
- batch,
168
- autorun,
169
- replaceObject,
170
- makeObservable
171
- }
163
+ adapters
172
164
  });
173
165
  routerStore.restoreFromServer = function restoreFromServer(obj) {
174
- batch(() => {
166
+ adapters.batch(() => {
175
167
  routerStore.routesHistory.push(...obj.routesHistory || []);
176
168
  Object.assign(routerStore.currentRoute, obj.currentRoute);
177
169
  });
@@ -226,8 +218,8 @@ function createRouterStore({
226
218
  if (currentUrl === nextUrl) return Promise.resolve();
227
219
  if (currentPathname === nextPathname) {
228
220
  if (currentSearch !== nextSearch) {
229
- batch(() => {
230
- replaceObject(routerStore.currentRoute.query, nextQuery || {});
221
+ adapters.batch(() => {
222
+ adapters.replaceObject(routerStore.currentRoute.query, nextQuery || {});
231
223
  routerStore.routesHistory.push(nextUrl);
232
224
  });
233
225
  if (history && !noHistoryPush) {
@@ -240,7 +232,7 @@ function createRouterStore({
240
232
  }
241
233
  return Promise.resolve();
242
234
  }
243
- batch(() => {
235
+ adapters.batch(() => {
244
236
  routerStore.isRedirecting = true;
245
237
  });
246
238
  try {
@@ -301,8 +293,8 @@ function createRouterStore({
301
293
  }
302
294
  console.error(error);
303
295
  await loadComponentToConfig({ route: routeError500 });
304
- batch(() => {
305
- replaceObject(routerStore.currentRoute, {
296
+ adapters.batch(() => {
297
+ adapters.replaceObject(routerStore.currentRoute, {
306
298
  name: routeError500.name,
307
299
  path: routeError500.path,
308
300
  props: routes[routeError500.name].props,
@@ -314,8 +306,8 @@ function createRouterStore({
314
306
  });
315
307
  return Promise.resolve();
316
308
  }
317
- batch(() => {
318
- replaceObject(routerStore.currentRoute, {
309
+ adapters.batch(() => {
310
+ adapters.replaceObject(routerStore.currentRoute, {
319
311
  name: nextRoute.name,
320
312
  path: nextRoute.path,
321
313
  props: routes[nextRoute.name].props,
@@ -49,14 +49,14 @@ var VM = class {
49
49
  loadedComponentPage = void 0;
50
50
  loadedComponent;
51
51
  currentProps = {};
52
- get utils() {
53
- return this.props.routerStore.utils;
52
+ get adapters() {
53
+ return this.props.routerStore.adapters;
54
54
  }
55
55
  beforeMount() {
56
56
  this.props.beforeMount?.();
57
57
  this.redirectOnHistoryPop();
58
58
  this.setLoadedComponent();
59
- this.autorunDisposers.push(this.utils.autorun(this.setLoadedComponent));
59
+ this.autorunDisposers.push(this.adapters.autorun(this.setLoadedComponent));
60
60
  }
61
61
  redirectOnHistoryPop() {
62
62
  if (!history) return;
@@ -64,7 +64,7 @@ var VM = class {
64
64
  if (params.action !== "POP") return;
65
65
  const previousRoutePathname = this.props.routerStore.routesHistory[this.props.routerStore.routesHistory.length - 2];
66
66
  if (previousRoutePathname === params.location.pathname) {
67
- this.utils.batch(() => this.props.routerStore.routesHistory.pop());
67
+ this.adapters.batch(() => this.props.routerStore.routesHistory.pop());
68
68
  }
69
69
  void this.props.routerStore.redirectTo({
70
70
  noHistoryPush: true,
@@ -87,14 +87,14 @@ var VM = class {
87
87
  else if (loadedComponentPage != null && currentRouteName != null) {
88
88
  if (loadedComponentPage === currentRoutePage) {
89
89
  const componentConfig = this.props.routes[currentRouteName];
90
- this.utils.batch(() => {
90
+ this.adapters.batch(() => {
91
91
  this.currentProps = "props" in componentConfig ? componentConfig.props || {} : {};
92
92
  });
93
93
  preventRedirect = true;
94
94
  }
95
95
  }
96
96
  if (preventRedirect) return;
97
- this.utils.batch(() => {
97
+ this.adapters.batch(() => {
98
98
  if (!loadedComponentName) {
99
99
  this.setComponent(currentRouteName);
100
100
  } else {
@@ -26,13 +26,13 @@ var VM = class {
26
26
  loadedComponentName = void 0;
27
27
  loadedComponentPage = void 0;
28
28
  currentProps = {};
29
- get utils() {
30
- return this.props.routerStore.utils;
29
+ get adapters() {
30
+ return this.props.routerStore.adapters;
31
31
  }
32
32
  beforeMount() {
33
33
  this.props.beforeMount?.();
34
34
  this.redirectOnHistoryPop();
35
- this.utils.autorun(() => this.setLoadedComponent());
35
+ this.adapters.autorun(() => this.setLoadedComponent());
36
36
  }
37
37
  redirectOnHistoryPop() {
38
38
  if (!history) return;
@@ -62,12 +62,12 @@ var VM = class {
62
62
  } else if (this.loadedComponentPage != null && currentRouteName != null) {
63
63
  if (this.loadedComponentPage === currentRoutePage) {
64
64
  const componentConfig = this.props.routes[currentRouteName];
65
- this.utils.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
65
+ this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
66
66
  preventRedirect = true;
67
67
  }
68
68
  }
69
69
  if (preventRedirect) return;
70
- this.utils.batch(() => {
70
+ this.adapters.batch(() => {
71
71
  if (!this.loadedComponentName) {
72
72
  this.setComponent();
73
73
  } else {
@@ -80,8 +80,8 @@ var VM = class {
80
80
  const currentRouteName = this.props.routerStore.currentRoute.name;
81
81
  const componentConfig = this.props.routes[currentRouteName];
82
82
  this.props.beforeSetPageComponent?.(componentConfig);
83
- this.utils.batch(() => {
84
- this.utils.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
83
+ this.adapters.batch(() => {
84
+ this.adapters.replaceObject(this.currentProps, "props" in componentConfig ? componentConfig.props : {});
85
85
  this.loadedComponentName = currentRouteName;
86
86
  this.loadedComponentPage = componentConfig.pageName;
87
87
  });
@@ -0,0 +1,3 @@
1
+ import { TypeAdapters } from 'reactive-route';
2
+ export declare const adapters: TypeAdapters;
3
+ //# sourceMappingURL=mobx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mobx.d.ts","sourceRoot":"","sources":["../../../packages/adapters/mobx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,YAgBtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { TypeAdapters } from 'reactive-route';
2
+ export declare const adapters: TypeAdapters;
3
+ //# sourceMappingURL=solid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../../../packages/adapters/solid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,eAAO,MAAM,QAAQ,EAAE,YAoBtB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { InterfaceRouterStore, TypeCreateRouterStore } from './types/InterfaceRouterStore';
2
2
  import { TypeRoute } from './types/TypeRoute';
3
- export declare function createRouterStore<TRoutes extends Record<string, TypeRoute>>({ batch, routes, autorun, replaceObject, routeError500, makeObservable, lifecycleParams, }: TypeCreateRouterStore<TRoutes>): InterfaceRouterStore<TRoutes>;
3
+ export declare function createRouterStore<TRoutes extends Record<string, TypeRoute>>({ adapters, routes, routeError500, lifecycleParams, }: TypeCreateRouterStore<TRoutes>): InterfaceRouterStore<TRoutes>;
4
4
  //# sourceMappingURL=createRouterStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRouterStore.d.ts","sourceRoot":"","sources":["../../../packages/core/createRouterStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAS9C,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAC3E,KAAK,EACL,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,GAChB,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,oBAAoB,CAAC,OAAO,CAAC,CA+PhE"}
1
+ {"version":3,"file":"createRouterStore.d.ts","sourceRoot":"","sources":["../../../packages/core/createRouterStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE3F,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAS9C,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAC3E,QAAQ,EACR,MAAM,EACN,aAAa,EACb,eAAe,GAChB,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,oBAAoB,CAAC,OAAO,CAAC,CA0PhE"}
@@ -1,6 +1,6 @@
1
1
  export { createRouterConfig } from './createRouterConfig';
2
2
  export { createRouterStore } from './createRouterStore';
3
- export type { InterfaceRouterStore } from './types/InterfaceRouterStore';
3
+ export type { InterfaceRouterStore, TypeAdapters } from './types/InterfaceRouterStore';
4
4
  export type { TypeCurrentRoute } from './types/TypeCurrentRoute';
5
5
  export type { TypePropsRouter } from './types/TypePropsRouter';
6
6
  export type { TypeRedirectToParams } from './types/TypeRedirectToParams';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/index.ts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,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
@@ -1,19 +1,20 @@
1
1
  import { TypeCurrentRoute } from './TypeCurrentRoute';
2
2
  import { TypeRedirectToParams } from './TypeRedirectToParams';
3
3
  import { TypeRoute } from './TypeRoute';
4
- type TypeUtils = {
4
+ export type TypeAdapters = {
5
5
  batch: (cb: () => void) => void;
6
6
  autorun: (cb: () => void) => any;
7
7
  replaceObject: <TObj extends Record<string, any>>(obj: TObj, newObj: TObj) => void;
8
8
  makeObservable: <TObj extends Record<string, any>>(obj: TObj) => TObj;
9
9
  };
10
- export type TypeCreateRouterStore<TRoutes extends Record<string, TypeRoute>> = TypeUtils & {
10
+ export type TypeCreateRouterStore<TRoutes extends Record<string, TypeRoute>> = {
11
11
  routes: TRoutes;
12
12
  routeError500: TRoutes[keyof TRoutes];
13
13
  lifecycleParams?: Array<any>;
14
+ adapters: TypeAdapters;
14
15
  };
15
16
  export type InterfaceRouterStore<TRoutes extends Record<string, TypeRoute>> = {
16
- utils: TypeUtils;
17
+ adapters: TypeAdapters;
17
18
  currentRoute: TypeCurrentRoute<TRoutes[keyof TRoutes]>;
18
19
  routesHistory: Array<string>;
19
20
  isRedirecting: boolean;
@@ -24,5 +25,4 @@ export type InterfaceRouterStore<TRoutes extends Record<string, TypeRoute>> = {
24
25
  }): Promise<void>;
25
26
  restoreFromServer(obj: InterfaceRouterStore<TRoutes>): Promise<void>;
26
27
  };
27
- export {};
28
28
  //# sourceMappingURL=InterfaceRouterStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InterfaceRouterStore.d.ts","sourceRoot":"","sources":["../../../../packages/core/types/InterfaceRouterStore.ts"],"names":[],"m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xB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI;IAC5E,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC;IACvD,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,UAAU,SAAS,MAAM,OAAO,EACzC,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,UAAU,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;KAC1C,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,iBAAiB,CAAC,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE,CAAC"}
@@ -1 +1 @@
1
- {"root":["../../packages/core/createRouterConfig.ts","../../packages/core/createRouterStore.ts","../../packages/core/index.ts","../../packages/core/types/InterfaceRouterStore.ts","../../packages/core/types/TypeCurrentRoute.ts","../../packages/core/types/TypeLifecycleConfig.ts","../../packages/core/types/TypePropsRouter.ts","../../packages/core/types/TypeRedirectToParams.ts","../../packages/core/types/TypeRoute.ts","../../packages/core/types/TypeRouteRaw.ts","../../packages/core/types/TypeRouteWithParams.ts","../../packages/core/types/TypeValidator.ts","../../packages/core/utils/addNames.ts","../../packages/core/utils/constants.ts","../../packages/core/utils/dynamic.ts","../../packages/core/utils/findRouteByPathname.ts","../../packages/core/utils/getDynamicValues.ts","../../packages/core/utils/getInitialRoute.ts","../../packages/core/utils/getQueryValues.ts","../../packages/core/utils/getTypedEntries.ts","../../packages/core/utils/history.ts","../../packages/core/utils/loadComponentToConfig.ts","../../packages/core/utils/replaceDynamicValues.ts","../../packages/react/Router.tsx","../../packages/react/index.ts","../../packages/react/useStore.ts","../../packages/solid/Router.tsx","../../packages/solid/index.ts","../../packages/solid/useStore.ts"],"version":"5.9.2"}
1
+ {"root":["../../packages/adapters/mobx.ts","../../packages/adapters/solid.ts","../../packages/core/createRouterConfig.ts","../../packages/core/createRouterStore.ts","../../packages/core/index.ts","../../packages/core/types/InterfaceRouterStore.ts","../../packages/core/types/TypeCurrentRoute.ts","../../packages/core/types/TypeLifecycleConfig.ts","../../packages/core/types/TypePropsRouter.ts","../../packages/core/types/TypeRedirectToParams.ts","../../packages/core/types/TypeRoute.ts","../../packages/core/types/TypeRouteRaw.ts","../../packages/core/types/TypeRouteWithParams.ts","../../packages/core/types/TypeValidator.ts","../../packages/core/utils/addNames.ts","../../packages/core/utils/constants.ts","../../packages/core/utils/dynamic.ts","../../packages/core/utils/findRouteByPathname.ts","../../packages/core/utils/getDynamicValues.ts","../../packages/core/utils/getInitialRoute.ts","../../packages/core/utils/getQueryValues.ts","../../packages/core/utils/getTypedEntries.ts","../../packages/core/utils/history.ts","../../packages/core/utils/loadComponentToConfig.ts","../../packages/core/utils/replaceDynamicValues.ts","../../packages/react/Router.tsx","../../packages/react/index.ts","../../packages/react/useStore.ts","../../packages/solid/Router.tsx","../../packages/solid/index.ts","../../packages/solid/useStore.ts"],"version":"5.9.2"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "reactive-route",
3
3
  "author": "Dmitry Kazakov",
4
4
  "license": "MIT",
5
- "version": "0.0.1-alpha.4",
5
+ "version": "0.0.1-alpha.5",
6
6
  "description": "Reactive Router for different frameworks",
7
7
  "repository": {
8
8
  "type": "git",
@@ -17,9 +17,14 @@
17
17
  "analyze:js": "biome check --no-errors-on-unmatched .",
18
18
  "format:js": "biome check --no-errors-on-unmatched --write",
19
19
  "check-types": "tsc --project tsconfig.json",
20
- "check-types-example": "tsc --project ./examples/simple_ssr/tsconfig.json",
20
+ "check-types-example": "tsc --project examples/react-mobx/tsconfig.json",
21
21
  "prepare": "husky"
22
22
  },
23
+ "lint-staged": {
24
+ "(*.js|*.ts|*.tsx|*.mjs)": [
25
+ "pnpm run format:js"
26
+ ]
27
+ },
23
28
  "dependencies": {
24
29
  "history": "5.3.0",
25
30
  "query-string": "7.1.3"
@@ -69,6 +74,16 @@
69
74
  "types": "./dist/types/solid/index.d.ts",
70
75
  "require": "./dist/cjs/solid/index.js",
71
76
  "import": "./dist/esm/solid/index.js"
77
+ },
78
+ "./adapters/mobx": {
79
+ "types": "./dist/types/adapters/mobx.d.ts",
80
+ "require": "./dist/cjs/adapters/mobx/index.js",
81
+ "import": "./dist/esm/adapters/mobx/index.js"
82
+ },
83
+ "./adapters/solid": {
84
+ "types": "./dist/types/adapters/solid.d.ts",
85
+ "require": "./dist/cjs/adapters/solid/index.js",
86
+ "import": "./dist/esm/adapters/solid/index.js"
72
87
  }
73
88
  },
74
89
  "main": "dist/cjs/index.js",