piral-ng 0.15.0-beta.4813 → 0.15.0-beta.4816
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/README.md +48 -2
- package/esm/types.d.ts +12 -3
- package/lib/types.d.ts +12 -3
- package/package.json +3 -3
- package/src/types.ts +11 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ The extension slot module to be used in Angular components. This is not really n
|
|
|
30
30
|
|
|
31
31
|
You can use the `fromNg` function from the Pilet API to convert your Angular components to components usable by your Piral instance.
|
|
32
32
|
|
|
33
|
-
Example
|
|
33
|
+
### Example Usage
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
import { PiletApi } from '<name-of-piral-instance>';
|
|
@@ -75,7 +75,53 @@ export function setup(piral: PiletApi) {
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
### Lazy Loading
|
|
79
|
+
|
|
80
|
+
Even better, you can also lazy load the respective Angular module and components using the callback-based overload of `defineNgModule`:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { PiletApi } from '<name-of-piral-instance>';
|
|
84
|
+
|
|
85
|
+
export function setup(piral: PiletApi) {
|
|
86
|
+
// this "teaches" Piral about the given module, which is lazy loaded
|
|
87
|
+
// important; in this case `./AppModule.ts` has a `default` export
|
|
88
|
+
const loadComponent = piral.defineNgModule(() => import('./AppModule'));
|
|
89
|
+
|
|
90
|
+
// to fully lazy load we cannot reference the class anymore;
|
|
91
|
+
// instead we reference the selector of the component
|
|
92
|
+
piral.registerPage('/sample', loadComponent('angular-page'));
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
In the example above, the `AngularPage` would have been defined to look like
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
// ...
|
|
100
|
+
@Component({
|
|
101
|
+
// ...
|
|
102
|
+
selector: 'angular-page',
|
|
103
|
+
})
|
|
104
|
+
export class AngularPage { /* ... */ }
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
which defines the selector (`angular-page`) matching the specified selector in the `setup` function.
|
|
108
|
+
|
|
109
|
+
### Standalone Components
|
|
110
|
+
|
|
111
|
+
The `piral-ng` plugin also supports Angular standalone components as rendering source.
|
|
112
|
+
|
|
113
|
+
Standalone components can also be used with lazy loading.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { PiletApi } from '<name-of-piral-instance>';
|
|
117
|
+
|
|
118
|
+
export function setup(piral: PiletApi) {
|
|
119
|
+
// Just make sure that `AngularPage` exports the component as `default` export
|
|
120
|
+
piral.registerPage('/sample', piral.fromNg(() => import('./AngularPage')));
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Angular Options
|
|
79
125
|
|
|
80
126
|
You can optionally provide Options to `defineNgModule`, which are identical to those given to `bootstrapModule` during the Angular boot process. See https://angular.io/api/core/PlatformRef#bootstrapModule for possible values.
|
|
81
127
|
|
package/esm/types.d.ts
CHANGED
|
@@ -38,6 +38,17 @@ export interface NgLazyType {
|
|
|
38
38
|
opts: NgOptions;
|
|
39
39
|
state: any;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* The lazy loading interface for retrieving Angular components.
|
|
43
|
+
*/
|
|
44
|
+
export interface LazyType<T> {
|
|
45
|
+
/**
|
|
46
|
+
* Callback to be invoked for lazy loading an Angular module or component.
|
|
47
|
+
*/
|
|
48
|
+
(): Promise<{
|
|
49
|
+
default: Type<T>;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
41
52
|
/**
|
|
42
53
|
* Represents the interface implemented by a module definer function.
|
|
43
54
|
*/
|
|
@@ -54,9 +65,7 @@ export interface NgModuleDefiner {
|
|
|
54
65
|
* @param opts The options to pass when bootstrapping.
|
|
55
66
|
* @returns The module ID to be used to reference components.
|
|
56
67
|
*/
|
|
57
|
-
<T>(getModule:
|
|
58
|
-
default: Type<T>;
|
|
59
|
-
}>, opts?: NgOptions): NgComponentLoader;
|
|
68
|
+
<T>(getModule: LazyType<T>, opts?: NgOptions): NgComponentLoader;
|
|
60
69
|
}
|
|
61
70
|
export interface NgComponent {
|
|
62
71
|
/**
|
package/lib/types.d.ts
CHANGED
|
@@ -38,6 +38,17 @@ export interface NgLazyType {
|
|
|
38
38
|
opts: NgOptions;
|
|
39
39
|
state: any;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* The lazy loading interface for retrieving Angular components.
|
|
43
|
+
*/
|
|
44
|
+
export interface LazyType<T> {
|
|
45
|
+
/**
|
|
46
|
+
* Callback to be invoked for lazy loading an Angular module or component.
|
|
47
|
+
*/
|
|
48
|
+
(): Promise<{
|
|
49
|
+
default: Type<T>;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
41
52
|
/**
|
|
42
53
|
* Represents the interface implemented by a module definer function.
|
|
43
54
|
*/
|
|
@@ -54,9 +65,7 @@ export interface NgModuleDefiner {
|
|
|
54
65
|
* @param opts The options to pass when bootstrapping.
|
|
55
66
|
* @returns The module ID to be used to reference components.
|
|
56
67
|
*/
|
|
57
|
-
<T>(getModule:
|
|
58
|
-
default: Type<T>;
|
|
59
|
-
}>, opts?: NgOptions): NgComponentLoader;
|
|
68
|
+
<T>(getModule: LazyType<T>, opts?: NgOptions): NgComponentLoader;
|
|
60
69
|
}
|
|
61
70
|
export interface NgComponent {
|
|
62
71
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-ng",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.4816",
|
|
4
4
|
"description": "Plugin for integrating Angular components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@angular/platform-browser": "^14.0.0",
|
|
80
80
|
"@angular/platform-browser-dynamic": "^14.0.0",
|
|
81
81
|
"@angular/router": "^14.0.0",
|
|
82
|
-
"piral-core": "0.15.0-beta.
|
|
82
|
+
"piral-core": "0.15.0-beta.4816",
|
|
83
83
|
"rxjs": "^7.3.0"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"@angular/router": "^2.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
91
91
|
"rxjs": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "f6af0640e919d26b25a5dc51d6559c9201728ccd"
|
|
94
94
|
}
|
package/src/types.ts
CHANGED
|
@@ -42,6 +42,16 @@ export interface NgLazyType {
|
|
|
42
42
|
state: any;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The lazy loading interface for retrieving Angular components.
|
|
47
|
+
*/
|
|
48
|
+
export interface LazyType<T> {
|
|
49
|
+
/**
|
|
50
|
+
* Callback to be invoked for lazy loading an Angular module or component.
|
|
51
|
+
*/
|
|
52
|
+
(): Promise<{ default: Type<T> }>;
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
/**
|
|
46
56
|
* Represents the interface implemented by a module definer function.
|
|
47
57
|
*/
|
|
@@ -58,7 +68,7 @@ export interface NgModuleDefiner {
|
|
|
58
68
|
* @param opts The options to pass when bootstrapping.
|
|
59
69
|
* @returns The module ID to be used to reference components.
|
|
60
70
|
*/
|
|
61
|
-
<T>(getModule:
|
|
71
|
+
<T>(getModule: LazyType<T>, opts?: NgOptions): NgComponentLoader;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
export interface NgComponent {
|