@viewfly/router 0.6.3 → 1.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.
@@ -1,5 +1,5 @@
1
1
  import { jsx, Fragment } from '@viewfly/core/jsx-runtime';
2
- import { Injectable, inject, createSignal, onUnmounted, provide } from '@viewfly/core';
2
+ import { Injectable, inject, createSignal, onUnmounted, withAnnotation, SkipSelf, InjectFlags } from '@viewfly/core';
3
3
  import { Subject, Subscription, fromEvent } from '@tanbo/stream';
4
4
 
5
5
  /******************************************************************************
@@ -268,14 +268,21 @@ function Link(props) {
268
268
  };
269
269
  }
270
270
 
271
- function RouterOutlet(props) {
271
+ const RouterOutlet = withAnnotation({
272
+ providers: [{
273
+ provide: Router,
274
+ useFactory(navigator, router) {
275
+ return new Router(navigator, router, '');
276
+ },
277
+ deps: [
278
+ [Navigator],
279
+ [Router, new SkipSelf()]
280
+ ]
281
+ }]
282
+ }, function RouterOutlet(props) {
272
283
  const children = createSignal(null);
273
- const router = inject(Router);
274
- const childRouter = new Router(inject(Navigator), router, '');
275
- provide({
276
- provide: Router,
277
- useValue: childRouter
278
- });
284
+ const router = inject(Router, InjectFlags.SkipSelf);
285
+ const childRouter = inject(Router);
279
286
  const subscription = router.onRefresh.subscribe(() => {
280
287
  updateChildren();
281
288
  });
@@ -311,7 +318,7 @@ function RouterOutlet(props) {
311
318
  return () => {
312
319
  return jsx(Fragment, { children: children() });
313
320
  };
314
- }
321
+ });
315
322
 
316
323
  class RouterModule {
317
324
  constructor(baseUrl = '') {
package/bundles/index.js CHANGED
@@ -270,14 +270,21 @@ function Link(props) {
270
270
  };
271
271
  }
272
272
 
273
- function RouterOutlet(props) {
273
+ const RouterOutlet = core.withAnnotation({
274
+ providers: [{
275
+ provide: Router,
276
+ useFactory(navigator, router) {
277
+ return new Router(navigator, router, '');
278
+ },
279
+ deps: [
280
+ [Navigator],
281
+ [Router, new core.SkipSelf()]
282
+ ]
283
+ }]
284
+ }, function RouterOutlet(props) {
274
285
  const children = core.createSignal(null);
275
- const router = core.inject(Router);
276
- const childRouter = new Router(core.inject(Navigator), router, '');
277
- core.provide({
278
- provide: Router,
279
- useValue: childRouter
280
- });
286
+ const router = core.inject(Router, core.InjectFlags.SkipSelf);
287
+ const childRouter = core.inject(Router);
281
288
  const subscription = router.onRefresh.subscribe(() => {
282
289
  updateChildren();
283
290
  });
@@ -313,7 +320,7 @@ function RouterOutlet(props) {
313
320
  return () => {
314
321
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children() });
315
322
  };
316
- }
323
+ });
317
324
 
318
325
  class RouterModule {
319
326
  constructor(baseUrl = '') {
@@ -3,4 +3,4 @@ import { RouteConfig } from './providers/_api';
3
3
  export interface RouterOutletProps extends Props {
4
4
  config: RouteConfig[];
5
5
  }
6
- export declare function RouterOutlet(props: RouterOutletProps): () => any;
6
+ export declare const RouterOutlet: (props: RouterOutletProps) => () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/router",
3
- "version": "0.6.3",
3
+ "version": "1.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",
@@ -13,7 +13,7 @@
13
13
  "keywords": [],
14
14
  "dependencies": {
15
15
  "@tanbo/stream": "^1.2.3",
16
- "@viewfly/core": "^0.6.3",
16
+ "@viewfly/core": "^1.0.0-alpha.0",
17
17
  "url": "^0.11.1"
18
18
  },
19
19
  "devDependencies": {
@@ -34,5 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/viewfly/viewfly.git/issues"
36
36
  },
37
- "gitHead": "67d1ad7eff77c30dfafa3bc6a51a21ecde114aec"
37
+ "gitHead": "49d0f91818ce7bf9474ae386d8eb52624b31dbde"
38
38
  }