@viewfly/router 1.1.10 → 2.0.0-alpha.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/bundles/index.d.ts +1 -1
- package/bundles/index.esm.js +13 -19
- package/bundles/index.js +11 -17
- package/package.json +3 -3
package/bundles/index.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ declare function Link(props: LinkProps): () => _viewfly_core_jsx_runtime.JSX.Ele
|
|
|
81
81
|
interface RouterOutletProps extends Props {
|
|
82
82
|
config: RouteConfig[];
|
|
83
83
|
}
|
|
84
|
-
declare
|
|
84
|
+
declare function RouterOutlet(props: RouterOutletProps): () => _viewfly_core_jsx_runtime.JSX.Element;
|
|
85
85
|
|
|
86
86
|
declare class RouterModule implements Module {
|
|
87
87
|
baseUrl: string;
|
package/bundles/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { Injectable, inject, createSignal, onUnmounted, makeError,
|
|
1
|
+
import { jsx } from '@viewfly/core/jsx-runtime';
|
|
2
|
+
import { Injectable, inject, createSignal, onUnmounted, makeError, createContext } from '@viewfly/core';
|
|
3
3
|
import { Subject, Subscription, fromEvent } from '@tanbo/stream';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -316,24 +316,18 @@ function Link(props) {
|
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
const routerErrorFn = makeError('RouterOutlet');
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
provide: Router,
|
|
322
|
-
useFactory(navigator, router) {
|
|
323
|
-
return new Router(navigator, router, '');
|
|
324
|
-
},
|
|
325
|
-
deps: [
|
|
326
|
-
[Navigator],
|
|
327
|
-
[Router, new SkipSelf()]
|
|
328
|
-
]
|
|
329
|
-
}]
|
|
330
|
-
}, function RouterOutlet(props) {
|
|
331
|
-
const children = createSignal(null);
|
|
332
|
-
const router = inject(Router, null, InjectFlags.SkipSelf);
|
|
333
|
-
const childRouter = inject(Router);
|
|
319
|
+
function RouterOutlet(props) {
|
|
320
|
+
const router = inject(Router, null);
|
|
334
321
|
if (router === null) {
|
|
335
322
|
throw routerErrorFn('cannot found parent Router.');
|
|
336
323
|
}
|
|
324
|
+
const navigator = inject(Navigator);
|
|
325
|
+
const childRouter = new Router(navigator, router, '');
|
|
326
|
+
const Context = createContext([{
|
|
327
|
+
provide: Router,
|
|
328
|
+
useValue: childRouter
|
|
329
|
+
}]);
|
|
330
|
+
const children = createSignal(null);
|
|
337
331
|
const subscription = router.onRefresh.subscribe(() => {
|
|
338
332
|
updateChildren();
|
|
339
333
|
});
|
|
@@ -367,9 +361,9 @@ const RouterOutlet = withAnnotation({
|
|
|
367
361
|
}
|
|
368
362
|
updateChildren();
|
|
369
363
|
return () => {
|
|
370
|
-
return jsx(
|
|
364
|
+
return jsx(Context, { children: children() });
|
|
371
365
|
};
|
|
372
|
-
}
|
|
366
|
+
}
|
|
373
367
|
|
|
374
368
|
class RouterModule {
|
|
375
369
|
constructor(baseUrl = '') {
|
package/bundles/index.js
CHANGED
|
@@ -318,24 +318,18 @@ function Link(props) {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
const routerErrorFn = core.makeError('RouterOutlet');
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
provide: Router,
|
|
324
|
-
useFactory(navigator, router) {
|
|
325
|
-
return new Router(navigator, router, '');
|
|
326
|
-
},
|
|
327
|
-
deps: [
|
|
328
|
-
[Navigator],
|
|
329
|
-
[Router, new core.SkipSelf()]
|
|
330
|
-
]
|
|
331
|
-
}]
|
|
332
|
-
}, function RouterOutlet(props) {
|
|
333
|
-
const children = core.createSignal(null);
|
|
334
|
-
const router = core.inject(Router, null, core.InjectFlags.SkipSelf);
|
|
335
|
-
const childRouter = core.inject(Router);
|
|
321
|
+
function RouterOutlet(props) {
|
|
322
|
+
const router = core.inject(Router, null);
|
|
336
323
|
if (router === null) {
|
|
337
324
|
throw routerErrorFn('cannot found parent Router.');
|
|
338
325
|
}
|
|
326
|
+
const navigator = core.inject(Navigator);
|
|
327
|
+
const childRouter = new Router(navigator, router, '');
|
|
328
|
+
const Context = core.createContext([{
|
|
329
|
+
provide: Router,
|
|
330
|
+
useValue: childRouter
|
|
331
|
+
}]);
|
|
332
|
+
const children = core.createSignal(null);
|
|
339
333
|
const subscription = router.onRefresh.subscribe(() => {
|
|
340
334
|
updateChildren();
|
|
341
335
|
});
|
|
@@ -369,9 +363,9 @@ const RouterOutlet = core.withAnnotation({
|
|
|
369
363
|
}
|
|
370
364
|
updateChildren();
|
|
371
365
|
return () => {
|
|
372
|
-
return jsxRuntime.jsx(
|
|
366
|
+
return jsxRuntime.jsx(Context, { children: children() });
|
|
373
367
|
};
|
|
374
|
-
}
|
|
368
|
+
}
|
|
375
369
|
|
|
376
370
|
class RouterModule {
|
|
377
371
|
constructor(baseUrl = '') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/router",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"description": "A routing library based on the Viewfly framework that can be run in the browser or Nodejs background.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@tanbo/stream": "^1.2.4",
|
|
18
|
-
"@viewfly/core": "^
|
|
18
|
+
"@viewfly/core": "^2.0.0-alpha.0",
|
|
19
19
|
"url": "^0.11.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"bugs": {
|
|
38
38
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "5fdcdcdca224d1eecdfd6a68abb1c3fb9c01d88a"
|
|
41
41
|
}
|