@viewfly/router 1.0.0-alpha.2 → 1.0.0-alpha.4

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, withAnnotation, SkipSelf, InjectFlags } from '@viewfly/core';
2
+ import { Injectable, inject, createSignal, onUnmounted, makeError, withAnnotation, SkipSelf, InjectFlags } from '@viewfly/core';
3
3
  import { Subject, Subscription, fromEvent } from '@tanbo/stream';
4
4
 
5
5
  /******************************************************************************
@@ -268,6 +268,7 @@ function Link(props) {
268
268
  };
269
269
  }
270
270
 
271
+ const routerErrorFn = makeError('RouterOutlet');
271
272
  const RouterOutlet = withAnnotation({
272
273
  providers: [{
273
274
  provide: Router,
@@ -281,8 +282,11 @@ const RouterOutlet = withAnnotation({
281
282
  }]
282
283
  }, function RouterOutlet(props) {
283
284
  const children = createSignal(null);
284
- const router = inject(Router, InjectFlags.SkipSelf);
285
+ const router = inject(Router, null, InjectFlags.SkipSelf);
285
286
  const childRouter = inject(Router);
287
+ if (router === null) {
288
+ throw routerErrorFn('cannot found parent Router.');
289
+ }
286
290
  const subscription = router.onRefresh.subscribe(() => {
287
291
  updateChildren();
288
292
  });
package/bundles/index.js CHANGED
@@ -270,6 +270,7 @@ function Link(props) {
270
270
  };
271
271
  }
272
272
 
273
+ const routerErrorFn = core.makeError('RouterOutlet');
273
274
  const RouterOutlet = core.withAnnotation({
274
275
  providers: [{
275
276
  provide: Router,
@@ -283,8 +284,11 @@ const RouterOutlet = core.withAnnotation({
283
284
  }]
284
285
  }, function RouterOutlet(props) {
285
286
  const children = core.createSignal(null);
286
- const router = core.inject(Router, core.InjectFlags.SkipSelf);
287
+ const router = core.inject(Router, null, core.InjectFlags.SkipSelf);
287
288
  const childRouter = core.inject(Router);
289
+ if (router === null) {
290
+ throw routerErrorFn('cannot found parent Router.');
291
+ }
288
292
  const subscription = router.onRefresh.subscribe(() => {
289
293
  updateChildren();
290
294
  });
package/bundles/link.d.ts CHANGED
@@ -7,5 +7,6 @@ export interface LinkProps extends Props {
7
7
  queryParams?: QueryParams;
8
8
  fragment?: string;
9
9
  tag?: string;
10
+ [key: string]: any;
10
11
  }
11
12
  export declare function Link(props: LinkProps): () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/router",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.4",
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": "^1.0.0-alpha.2",
16
+ "@viewfly/core": "^1.0.0-alpha.4",
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": "494829c8d0cde30d0a35c61351c863ea14515ac2"
37
+ "gitHead": "176e9fdb7415d029541a1da102001d9bab6c3319"
38
38
  }