piral-ng 1.0.0-pre.2196 → 1.0.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/LICENSE +1 -1
- package/README.md +701 -42
- package/common/NgExtension.d.ts +14 -0
- package/common/ResourceUrlPipe.d.ts +10 -0
- package/common/SharedModule.d.ts +10 -0
- package/common/esm2022/NgExtension.mjs +47 -0
- package/common/esm2022/ResourceUrlPipe.mjs +23 -0
- package/common/esm2022/SharedModule.mjs +25 -0
- package/common/esm2022/piral-ng-common.mjs +5 -0
- package/common/esm2022/public_api.mjs +4 -0
- package/common/fesm2022/piral-ng-common.mjs +93 -0
- package/common/fesm2022/piral-ng-common.mjs.map +1 -0
- package/common/index.d.ts +1 -0
- package/common/package.json +35 -0
- package/common/piral-ng-common.js +3 -0
- package/common/public_api.d.ts +3 -0
- package/convert.d.ts +17 -7
- package/convert.js +17 -11
- package/esm/RoutingService.d.ts +13 -0
- package/esm/RoutingService.js +109 -0
- package/esm/RoutingService.js.map +1 -0
- package/esm/bootstrap.d.ts +6 -5
- package/esm/bootstrap.js +52 -87
- package/esm/bootstrap.js.map +1 -1
- package/esm/common/NgExtension.d.ts +11 -0
- package/esm/common/NgExtension.js +41 -0
- package/esm/common/NgExtension.js.map +1 -0
- package/esm/common/ResourceUrlPipe.d.ts +7 -0
- package/esm/common/ResourceUrlPipe.js +18 -0
- package/esm/common/ResourceUrlPipe.js.map +1 -0
- package/esm/common/SharedModule.d.ts +3 -0
- package/esm/common/SharedModule.js +21 -0
- package/esm/common/SharedModule.js.map +1 -0
- package/esm/common/public_api.d.ts +3 -0
- package/esm/common/public_api.js +4 -0
- package/esm/common/public_api.js.map +1 -0
- package/esm/converter.d.ts +10 -2
- package/esm/converter.js +35 -16
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +2 -16
- package/esm/create.js +9 -13
- package/esm/create.js.map +1 -1
- package/esm/module.d.ts +24 -0
- package/esm/module.js +131 -0
- package/esm/module.js.map +1 -0
- package/esm/queue.d.ts +1 -1
- package/esm/queue.js +3 -3
- package/esm/queue.js.map +1 -1
- package/esm/startup.d.ts +8 -0
- package/esm/startup.js +115 -0
- package/esm/startup.js.map +1 -0
- package/esm/types.d.ts +71 -3
- package/esm/utils.d.ts +18 -0
- package/esm/utils.js +46 -0
- package/esm/utils.js.map +1 -0
- package/extend-webpack.js +107 -0
- package/lib/RoutingService.d.ts +13 -0
- package/lib/RoutingService.js +112 -0
- package/lib/RoutingService.js.map +1 -0
- package/lib/bootstrap.d.ts +6 -5
- package/lib/bootstrap.js +55 -91
- package/lib/bootstrap.js.map +1 -1
- package/lib/common/NgExtension.d.ts +11 -0
- package/lib/common/NgExtension.js +44 -0
- package/lib/common/NgExtension.js.map +1 -0
- package/lib/common/ResourceUrlPipe.d.ts +7 -0
- package/lib/common/ResourceUrlPipe.js +21 -0
- package/lib/common/ResourceUrlPipe.js.map +1 -0
- package/lib/common/SharedModule.d.ts +3 -0
- package/lib/common/SharedModule.js +24 -0
- package/lib/common/SharedModule.js.map +1 -0
- package/lib/common/public_api.d.ts +3 -0
- package/lib/common/public_api.js +7 -0
- package/lib/common/public_api.js.map +1 -0
- package/lib/converter.d.ts +10 -2
- package/lib/converter.js +36 -17
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +2 -16
- package/lib/create.js +10 -14
- package/lib/create.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/module.d.ts +24 -0
- package/lib/module.js +139 -0
- package/lib/module.js.map +1 -0
- package/lib/queue.d.ts +1 -1
- package/lib/queue.js +3 -3
- package/lib/queue.js.map +1 -1
- package/lib/startup.d.ts +8 -0
- package/lib/startup.js +120 -0
- package/lib/startup.js.map +1 -0
- package/lib/types.d.ts +71 -3
- package/lib/utils.d.ts +18 -0
- package/lib/utils.js +55 -0
- package/lib/utils.js.map +1 -0
- package/package.json +51 -16
- package/src/RoutingService.ts +114 -0
- package/src/bootstrap.ts +57 -104
- package/src/common/NgExtension.ts +33 -0
- package/src/common/ResourceUrlPipe.ts +12 -0
- package/src/common/SharedModule.ts +18 -0
- package/src/common/index.d.ts +1 -0
- package/src/common/ng-package.json +11 -0
- package/src/common/package.json +19 -0
- package/src/common/piral-ng-common.js +3 -0
- package/src/common/public_api.ts +3 -0
- package/src/converter.ts +58 -20
- package/src/create.ts +6 -23
- package/src/module.ts +163 -0
- package/src/queue.ts +1 -1
- package/src/startup.ts +148 -0
- package/src/types.ts +73 -3
- package/src/utils.ts +69 -0
- package/convert.ts +0 -16
- package/esm/extension.d.ts +0 -1
- package/esm/extension.js +0 -41
- package/esm/extension.js.map +0 -1
- package/lib/extension.d.ts +0 -1
- package/lib/extension.js +0 -45
- package/lib/extension.js.map +0 -1
- package/src/extension.ts +0 -29
package/lib/module.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineModule = exports.findModule = exports.createModuleInstance = exports.getModuleInstance = exports.activateModuleInstance = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const platform_browser_1 = require("@angular/platform-browser");
|
|
6
|
+
const common_1 = require("@angular/common");
|
|
7
|
+
const core_1 = require("@angular/core");
|
|
8
|
+
const startup_1 = require("./startup");
|
|
9
|
+
const RoutingService_1 = require("./RoutingService");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const common_2 = require("../common");
|
|
12
|
+
const availableModules = [];
|
|
13
|
+
function instantiateModule(moduleDef, piral) {
|
|
14
|
+
var BootstrapModule_1;
|
|
15
|
+
const { module, components } = moduleDef;
|
|
16
|
+
const imports = [platform_browser_1.BrowserModule, common_2.SharedModule, module];
|
|
17
|
+
const props = { current: undefined };
|
|
18
|
+
const providers = [
|
|
19
|
+
RoutingService_1.RoutingService,
|
|
20
|
+
{ provide: 'Props', useFactory: () => props.current.value, deps: [] },
|
|
21
|
+
{ provide: 'piral', useFactory: () => piral, deps: [] },
|
|
22
|
+
];
|
|
23
|
+
let BootstrapModule = BootstrapModule_1 = class BootstrapModule {
|
|
24
|
+
constructor(resolver, zone, routing) {
|
|
25
|
+
this.resolver = resolver;
|
|
26
|
+
this.zone = zone;
|
|
27
|
+
this.routing = routing;
|
|
28
|
+
this.refs = [];
|
|
29
|
+
}
|
|
30
|
+
ngDoBootstrap(appRef) {
|
|
31
|
+
this.appRef = appRef;
|
|
32
|
+
}
|
|
33
|
+
attach(component, node, $props) {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
const factory = this.resolver.resolveComponentFactory(component);
|
|
36
|
+
props.current = $props;
|
|
37
|
+
if (factory) {
|
|
38
|
+
const ref = this.zone.run(() => this.appRef.bootstrap(factory, node));
|
|
39
|
+
const name = (_c = (_b = (_a = ref.componentType) === null || _a === void 0 ? void 0 : _a.ɵcmp) === null || _b === void 0 ? void 0 : _b.inputs) === null || _c === void 0 ? void 0 : _c.Props;
|
|
40
|
+
if (typeof name === 'string') {
|
|
41
|
+
const sub = $props.subscribe((props) => {
|
|
42
|
+
var _a;
|
|
43
|
+
ref.instance[name] = props;
|
|
44
|
+
(_a = ref.changeDetectorRef) === null || _a === void 0 ? void 0 : _a.detectChanges();
|
|
45
|
+
});
|
|
46
|
+
ref.onDestroy(() => sub.unsubscribe());
|
|
47
|
+
}
|
|
48
|
+
this.refs.push([component, node, ref]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
detach(component, node) {
|
|
52
|
+
for (let i = this.refs.length; i--;) {
|
|
53
|
+
const [sourceComponent, sourceNode, ref] = this.refs[i];
|
|
54
|
+
if (sourceComponent === component && sourceNode === node) {
|
|
55
|
+
ref.destroy();
|
|
56
|
+
this.refs.splice(i, 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (this.refs.length === 0) {
|
|
60
|
+
(0, startup_1.teardown)(BootstrapModule_1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
BootstrapModule = BootstrapModule_1 = tslib_1.__decorate([
|
|
65
|
+
(0, core_1.NgModule)({
|
|
66
|
+
imports,
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
entryComponents: components,
|
|
69
|
+
providers,
|
|
70
|
+
}),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [core_1.ComponentFactoryResolver, core_1.NgZone, RoutingService_1.RoutingService])
|
|
72
|
+
], BootstrapModule);
|
|
73
|
+
return BootstrapModule;
|
|
74
|
+
}
|
|
75
|
+
function activateModuleInstance(moduleDef, piral) {
|
|
76
|
+
if (!moduleDef.active) {
|
|
77
|
+
moduleDef.active = instantiateModule(moduleDef, piral);
|
|
78
|
+
}
|
|
79
|
+
return [moduleDef.active, moduleDef.opts];
|
|
80
|
+
}
|
|
81
|
+
exports.activateModuleInstance = activateModuleInstance;
|
|
82
|
+
function getModuleInstance(component, standalone, piral) {
|
|
83
|
+
const [moduleDef] = availableModules.filter((m) => m.components.includes(component));
|
|
84
|
+
if (moduleDef) {
|
|
85
|
+
return activateModuleInstance(moduleDef, piral);
|
|
86
|
+
}
|
|
87
|
+
if (process.env.NODE_ENV === 'development') {
|
|
88
|
+
if (!standalone) {
|
|
89
|
+
console.warn('Component not found in all defined Angular modules. Make sure to define (using `defineNgModule`) a module with your component(s) referenced in the exports section of the `@NgModule` decorator.', component, piral.meta);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
exports.getModuleInstance = getModuleInstance;
|
|
95
|
+
function createModuleInstance(component, standalone, piral) {
|
|
96
|
+
const declarations = standalone ? [] : [component];
|
|
97
|
+
const importsDef = standalone ? [common_1.CommonModule, component] : [common_1.CommonModule];
|
|
98
|
+
const exportsDef = [component];
|
|
99
|
+
const schemasDef = [core_1.CUSTOM_ELEMENTS_SCHEMA];
|
|
100
|
+
let Module = class Module {
|
|
101
|
+
};
|
|
102
|
+
Module = tslib_1.__decorate([
|
|
103
|
+
(0, core_1.NgModule)({
|
|
104
|
+
declarations,
|
|
105
|
+
imports: importsDef,
|
|
106
|
+
exports: exportsDef,
|
|
107
|
+
schemas: schemasDef,
|
|
108
|
+
})
|
|
109
|
+
], Module);
|
|
110
|
+
defineModule(Module);
|
|
111
|
+
return getModuleInstance(component, standalone, piral);
|
|
112
|
+
}
|
|
113
|
+
exports.createModuleInstance = createModuleInstance;
|
|
114
|
+
function findModule(module) {
|
|
115
|
+
return availableModules.find((m) => m.module === module);
|
|
116
|
+
}
|
|
117
|
+
exports.findModule = findModule;
|
|
118
|
+
function defineModule(module, opts = undefined) {
|
|
119
|
+
const [annotation] = (0, utils_1.getAnnotations)(module);
|
|
120
|
+
if (annotation) {
|
|
121
|
+
availableModules.push({
|
|
122
|
+
active: undefined,
|
|
123
|
+
components: (0, utils_1.findComponents)(annotation.exports),
|
|
124
|
+
module,
|
|
125
|
+
opts,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else if (typeof module === 'function') {
|
|
129
|
+
const state = {
|
|
130
|
+
current: undefined,
|
|
131
|
+
};
|
|
132
|
+
return (selector) => ({
|
|
133
|
+
component: { selector, module, opts, state },
|
|
134
|
+
type: 'ng',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.defineModule = defineModule;
|
|
139
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;AAGA,gEAA0D;AAC1D,4CAA+C;AAC/C,wCAOuB;AACvB,uCAAqC;AACrC,qDAAkD;AAClD,mCAAyD;AACzD,sCAAyC;AASzC,MAAM,gBAAgB,GAA4B,EAAE,CAAC;AAErD,SAAS,iBAAiB,CAAC,SAA2B,EAAE,KAAe;;IACrE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;IACzC,MAAM,OAAO,GAAG,CAAC,gCAAa,EAAE,qBAAY,EAAE,MAAM,C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C;OACI,MAAM,CAAG;IAEf,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,iBAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AACzD,CAAC;AAhBD,oDAgBC;AAED,SAAgB,UAAU,CAAC,MAAW;IACpC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAC3D,CAAC;AAFD,gCAEC;AAED,SAAgB,YAAY,CAAC,MAAW,EAAE,OAAkB,SAAS;IACnE,MAAM,CAAC,UAAU,CAAC,GAAG,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC;IAE5C,IAAI,UAAU,EAAE;QACd,gBAAgB,CAAC,IAAI,CAAC;YACpB,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,IAAA,sBAAc,EAAC,UAAU,CAAC,OAAO,CAAC;YAC9C,MAAM;YACN,IAAI;SACL,CAAC,CAAC;KACJ;SAAM,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;QACvC,MAAM,KAAK,GAAG;YACZ,OAAO,EAAE,SAAS;SACnB,CAAC;QAEF,OAAO,CAAC,QAAgB,EAAE,EAAE,CAAC,CAAC;YAC5B,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE;YAC5C,IAAI,EAAE,IAAa;SACpB,CAAC,CAAC;KACJ;AACH,CAAC;AApBD,oCAoBC"}
|
package/lib/queue.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function enqueue<T>(callback: () => Promise<T>): Promise<T>;
|
|
1
|
+
export declare function enqueue<T>(callback: () => T | Promise<T>): Promise<T>;
|
package/lib/queue.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enqueue = void 0;
|
|
4
|
-
|
|
4
|
+
let queue = Promise.resolve();
|
|
5
5
|
function enqueue(callback) {
|
|
6
|
-
|
|
7
|
-
queue = next.then(
|
|
6
|
+
const next = queue.then(callback);
|
|
7
|
+
queue = next.then(() => { });
|
|
8
8
|
return next;
|
|
9
9
|
}
|
|
10
10
|
exports.enqueue = enqueue;
|
package/lib/queue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":";;;AAAA,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AAE9B,SAAgB,OAAO,CAAI,
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":";;;AAAA,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AAE9B,SAAgB,OAAO,CAAI,QAA8B;IACvD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAJD,0BAIC"}
|
package/lib/startup.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ComponentContext } from 'piral-core';
|
|
2
|
+
import type { NgOptions } from './types';
|
|
3
|
+
import { NgModuleRef } from '@angular/core';
|
|
4
|
+
export type NgModuleInt = NgModuleRef<any> & {
|
|
5
|
+
_destroyed: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function teardown(BootstrapModule: any): void;
|
|
8
|
+
export declare function startup(BootstrapModule: any, context: ComponentContext, ngOptions?: NgOptions): Promise<void | NgModuleInt>;
|
package/lib/startup.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startup = exports.teardown = void 0;
|
|
4
|
+
const core_1 = require("@angular/core");
|
|
5
|
+
const common_1 = require("@angular/common");
|
|
6
|
+
const platform_browser_dynamic_1 = require("@angular/platform-browser-dynamic");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
function getVersionHandler(versions) {
|
|
9
|
+
const major = (0, utils_1.getNgVersion)();
|
|
10
|
+
const version = `v${major}`;
|
|
11
|
+
return versions[version];
|
|
12
|
+
}
|
|
13
|
+
// Equivalent to platformBrowserDynamic, but with support for multiple platforms
|
|
14
|
+
const customPlatformDynamicFactory = (0, core_1.createPlatformFactory)(platform_browser_dynamic_1.ɵplatformCoreDynamic, 'piralDynamic', [
|
|
15
|
+
...platform_browser_dynamic_1.ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
|
16
|
+
{
|
|
17
|
+
provide: core_1.ɵALLOW_MULTIPLE_PLATFORMS,
|
|
18
|
+
useValue: true,
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
const runningModules = [];
|
|
22
|
+
function startNew(BootstrapModule, context, ngOptions) {
|
|
23
|
+
const path = context.publicPath || '/';
|
|
24
|
+
const platform = customPlatformDynamicFactory([
|
|
25
|
+
{ provide: 'Context', useValue: context },
|
|
26
|
+
{ provide: common_1.APP_BASE_HREF, useValue: path },
|
|
27
|
+
]);
|
|
28
|
+
const id = (0, utils_1.getId)();
|
|
29
|
+
const zoneIdentifier = `piral-ng:${id}`;
|
|
30
|
+
// This is a hack, since NgZone doesn't allow you to configure the property that identifies your zone.
|
|
31
|
+
// See:
|
|
32
|
+
// - https://github.com/PlaceMe-SAS/single-spa-angular-cli/issues/33
|
|
33
|
+
// - https://github.com/angular/angular/blob/a14dc2d7a4821a19f20a9547053a5734798f541e/packages/core/src/zone/ng_zone.ts#L144
|
|
34
|
+
// - https://github.com/angular/angular/blob/a14dc2d7a4821a19f20a9547053a5734798f541e/packages/core/src/zone/ng_zone.ts#L257
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
core_1.NgZone.isInAngularZone = () => window.Zone.current._properties[zoneIdentifier] === true;
|
|
37
|
+
return platform
|
|
38
|
+
.bootstrapModule(BootstrapModule, ngOptions)
|
|
39
|
+
.catch((err) => console.log(err))
|
|
40
|
+
.then((instance) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (instance) {
|
|
43
|
+
const zone = instance.injector.get(core_1.NgZone);
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
const z = (_a = zone === null || zone === void 0 ? void 0 : zone._inner) !== null && _a !== void 0 ? _a : zone === null || zone === void 0 ? void 0 : zone.inner;
|
|
46
|
+
if (z && '_properties' in z) {
|
|
47
|
+
z._properties[zoneIdentifier] = true;
|
|
48
|
+
}
|
|
49
|
+
runningModules.push([BootstrapModule, instance, platform]);
|
|
50
|
+
}
|
|
51
|
+
return instance;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function teardown(BootstrapModule) {
|
|
55
|
+
const runningModuleIndex = runningModules.findIndex(([ref]) => ref === BootstrapModule);
|
|
56
|
+
if (runningModuleIndex !== -1) {
|
|
57
|
+
const [, , platform] = runningModules[runningModuleIndex];
|
|
58
|
+
runningModules.splice(runningModuleIndex, 1);
|
|
59
|
+
if (!platform.destroyed) {
|
|
60
|
+
platform.destroy();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.teardown = teardown;
|
|
65
|
+
function startup(BootstrapModule, context, ngOptions) {
|
|
66
|
+
const runningModule = runningModules.find(([ref]) => ref === BootstrapModule);
|
|
67
|
+
if (runningModule) {
|
|
68
|
+
const [, instance, platform] = runningModule;
|
|
69
|
+
if (platform.destroyed) {
|
|
70
|
+
teardown(BootstrapModule);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return Promise.resolve(instance);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return startNew(BootstrapModule, context, ngOptions);
|
|
77
|
+
}
|
|
78
|
+
exports.startup = startup;
|
|
79
|
+
if (process.env.NODE_ENV === 'development') {
|
|
80
|
+
// May be used later for something useful. Right now only debugging output.
|
|
81
|
+
const versionHandlers = {
|
|
82
|
+
legacy() {
|
|
83
|
+
console.log('Running in legacy mode (Angular 2, Angular 4)');
|
|
84
|
+
},
|
|
85
|
+
outdated() {
|
|
86
|
+
console.log('Running in outdated mode (Angular 5-8)');
|
|
87
|
+
},
|
|
88
|
+
current() {
|
|
89
|
+
console.log('Running in current mode (Angular 9-15)');
|
|
90
|
+
},
|
|
91
|
+
next() {
|
|
92
|
+
console.log('Running in next mode (Angular 16)');
|
|
93
|
+
},
|
|
94
|
+
unknown() {
|
|
95
|
+
console.log('Running with an unknown version of Angular');
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const versions = {
|
|
99
|
+
v2: versionHandlers.legacy,
|
|
100
|
+
v4: versionHandlers.legacy,
|
|
101
|
+
v5: versionHandlers.outdated,
|
|
102
|
+
v6: versionHandlers.outdated,
|
|
103
|
+
v7: versionHandlers.outdated,
|
|
104
|
+
v8: versionHandlers.outdated,
|
|
105
|
+
v9: versionHandlers.current,
|
|
106
|
+
v10: versionHandlers.current,
|
|
107
|
+
v11: versionHandlers.current,
|
|
108
|
+
v12: versionHandlers.current,
|
|
109
|
+
v13: versionHandlers.current,
|
|
110
|
+
v14: versionHandlers.current,
|
|
111
|
+
v15: versionHandlers.current,
|
|
112
|
+
v16: versionHandlers.next,
|
|
113
|
+
};
|
|
114
|
+
const handler = getVersionHandler(versions) || versionHandlers.unknown;
|
|
115
|
+
handler();
|
|
116
|
+
}
|
|
117
|
+
if (process.env.NODE_ENV === 'production') {
|
|
118
|
+
(0, core_1.enableProdMode)();
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=startup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup.js","sourceRoot":"","sources":["../src/startup.ts"],"names":[],"mappings":";;;AAEA,wCAOuB;AACvB,4CAAgD;AAChD,gFAG2C;AAC3C,mCAA8C;AA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,EAAE,eAAe,CAAC,OAAO;QAC5B,GAAG,EAAE,eAAe,CAAC,IAAI;KAC1B,CAAC;IAEF,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC;IACvE,OAAO,EAAE,CAAC;CACX;AAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAA,qBAAc,GAAE,CAAC;CAClB"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { PlatformRef, NgModuleRef } from '@angular/core';
|
|
1
2
|
import type { ForeignComponent } from 'piral-core';
|
|
3
|
+
import type { Type } from '@angular/core';
|
|
2
4
|
declare module 'piral-core/lib/types/custom' {
|
|
3
5
|
interface PiletCustomApi extends PiletNgApi {
|
|
4
6
|
}
|
|
@@ -6,11 +8,70 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
6
8
|
ng(component: NgComponent): ForeignComponent<TProps>;
|
|
7
9
|
}
|
|
8
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Options passed through to Angular `bootstrapModule`.
|
|
13
|
+
*
|
|
14
|
+
* Mainly to specify Noop Zone, but also includes compiler specific settings.
|
|
15
|
+
* See https://angular.io/api/core/PlatformRef#bootstrapModule for possible values.
|
|
16
|
+
*/
|
|
17
|
+
export type NgOptions = Parameters<PlatformRef['bootstrapModule']>[1];
|
|
18
|
+
export type ModuleInstanceResult = [any, NgOptions];
|
|
19
|
+
export type PrepareBootstrapResult = [...ModuleInstanceResult, any];
|
|
20
|
+
export type NgModuleInt = NgModuleRef<any> & {
|
|
21
|
+
_destroyed: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Gives you the ability to use a component from a lazy loaded module.
|
|
25
|
+
*/
|
|
26
|
+
export interface NgComponentLoader {
|
|
27
|
+
/**
|
|
28
|
+
* Uses a component from a lazy loaded module.
|
|
29
|
+
* @param selector The selector defined for the component to load.
|
|
30
|
+
*/
|
|
31
|
+
(selector: string): NgComponent;
|
|
32
|
+
}
|
|
33
|
+
export interface NgLazyType {
|
|
34
|
+
selector: string;
|
|
35
|
+
module: () => Promise<{
|
|
36
|
+
default: Type<any>;
|
|
37
|
+
}>;
|
|
38
|
+
opts: NgOptions;
|
|
39
|
+
state: any;
|
|
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
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Represents the interface implemented by a module definer function.
|
|
54
|
+
*/
|
|
55
|
+
export interface NgModuleDefiner {
|
|
56
|
+
/**
|
|
57
|
+
* Defines the module to use when bootstrapping the Angular pilet.
|
|
58
|
+
* @param ngModule The module to use for running Angular.
|
|
59
|
+
* @param opts The options to pass when bootstrapping.
|
|
60
|
+
*/
|
|
61
|
+
<T>(module: Type<T>, opts?: NgOptions): void;
|
|
62
|
+
/**
|
|
63
|
+
* Defines the module to lazy load for bootstrapping the Angular pilet.
|
|
64
|
+
* @param getModule The module lazy loader to use for running Angular.
|
|
65
|
+
* @param opts The options to pass when bootstrapping.
|
|
66
|
+
* @returns The module ID to be used to reference components.
|
|
67
|
+
*/
|
|
68
|
+
<T>(getModule: LazyType<T>, opts?: NgOptions): NgComponentLoader;
|
|
69
|
+
}
|
|
9
70
|
export interface NgComponent {
|
|
10
71
|
/**
|
|
11
72
|
* The component root.
|
|
12
73
|
*/
|
|
13
|
-
component: any;
|
|
74
|
+
component: Type<any> | NgLazyType;
|
|
14
75
|
/**
|
|
15
76
|
* The type of the Angular component.
|
|
16
77
|
*/
|
|
@@ -21,11 +82,18 @@ export interface NgComponent {
|
|
|
21
82
|
*/
|
|
22
83
|
export interface PiletNgApi {
|
|
23
84
|
/**
|
|
24
|
-
*
|
|
85
|
+
* Defines the module to use when bootstrapping the Angular pilet.
|
|
86
|
+
*/
|
|
87
|
+
defineNgModule: NgModuleDefiner;
|
|
88
|
+
/**
|
|
89
|
+
* Wraps an Angular component for use in Piral. Might reuse a previously
|
|
90
|
+
* defined module if the component was exported from it.
|
|
91
|
+
* Alternatively, a module might be passed in, where the first component
|
|
92
|
+
* of either the bootstrap or the entryComponents declaration is used.
|
|
25
93
|
* @param component The component root.
|
|
26
94
|
* @returns The Piral Ng component.
|
|
27
95
|
*/
|
|
28
|
-
fromNg(component:
|
|
96
|
+
fromNg<T>(component: Type<T>): NgComponent;
|
|
29
97
|
/**
|
|
30
98
|
* Angular component for displaying extensions of the given name.
|
|
31
99
|
*/
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StaticProvider } from '@angular/core';
|
|
2
|
+
export interface NgAnnotation {
|
|
3
|
+
_initial?: Array<StaticProvider>;
|
|
4
|
+
standalone?: boolean;
|
|
5
|
+
providers: Array<StaticProvider>;
|
|
6
|
+
imports: Array<any>;
|
|
7
|
+
exports: Array<any>;
|
|
8
|
+
declarations: Array<any>;
|
|
9
|
+
entryComponents: Array<any>;
|
|
10
|
+
bootstrap: any;
|
|
11
|
+
selector: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function getId(): string;
|
|
14
|
+
export declare function getNgVersion(): string;
|
|
15
|
+
export declare function getMinVersion(): string;
|
|
16
|
+
export declare function getAnnotations(component: any): Array<NgAnnotation>;
|
|
17
|
+
export declare function hasSelector(component: any, selector: string): boolean;
|
|
18
|
+
export declare function findComponents(exports: Array<any>): Array<any>;
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findComponents = exports.hasSelector = exports.getAnnotations = exports.getMinVersion = exports.getNgVersion = exports.getId = void 0;
|
|
4
|
+
const core_1 = require("@angular/core");
|
|
5
|
+
function getId() {
|
|
6
|
+
return Math.random().toString(36);
|
|
7
|
+
}
|
|
8
|
+
exports.getId = getId;
|
|
9
|
+
function getNgVersion() {
|
|
10
|
+
return core_1.VERSION.major || core_1.VERSION.full.split('.')[0];
|
|
11
|
+
}
|
|
12
|
+
exports.getNgVersion = getNgVersion;
|
|
13
|
+
function getMinVersion() {
|
|
14
|
+
const major = getNgVersion();
|
|
15
|
+
return `${major}.0.0`;
|
|
16
|
+
}
|
|
17
|
+
exports.getMinVersion = getMinVersion;
|
|
18
|
+
function getAnnotations(component) {
|
|
19
|
+
let annotations = component === null || component === void 0 ? void 0 : component.__annotations__;
|
|
20
|
+
if (!annotations && typeof Reflect !== 'undefined' && 'getOwnMetadata' in Reflect) {
|
|
21
|
+
annotations = Reflect.getOwnMetadata('annotations', component);
|
|
22
|
+
}
|
|
23
|
+
if (!annotations && typeof component.ɵcmp !== 'undefined') {
|
|
24
|
+
annotations = [{}];
|
|
25
|
+
}
|
|
26
|
+
if (!annotations && typeof component.ɵmod !== 'undefined') {
|
|
27
|
+
annotations = [component.ɵmod];
|
|
28
|
+
}
|
|
29
|
+
return annotations || [];
|
|
30
|
+
}
|
|
31
|
+
exports.getAnnotations = getAnnotations;
|
|
32
|
+
function hasSelector(component, selector) {
|
|
33
|
+
const [annotation] = getAnnotations(component);
|
|
34
|
+
return annotation && annotation.selector === selector;
|
|
35
|
+
}
|
|
36
|
+
exports.hasSelector = hasSelector;
|
|
37
|
+
function findComponents(exports) {
|
|
38
|
+
const components = [];
|
|
39
|
+
if (Array.isArray(exports)) {
|
|
40
|
+
for (const ex of exports) {
|
|
41
|
+
const [annotation] = getAnnotations(ex);
|
|
42
|
+
if (annotation) {
|
|
43
|
+
if (annotation.exports) {
|
|
44
|
+
components.push(...findComponents(annotation.exports));
|
|
45
|
+
}
|
|
46
|
+
else if (!annotation.imports || annotation.standalone) {
|
|
47
|
+
components.push(ex);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return components;
|
|
53
|
+
}
|
|
54
|
+
exports.findComponents = findComponents;
|
|
55
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,wCAAwD;AAcxD,SAAgB,KAAK;IACnB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC;AAFD,sBAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,cAAO,CAAC,KAAK,IAAI,cAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa;IAC3B,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAC7B,OAAO,GAAG,KAAK,MAAM,CAAC;AACxB,CAAC;AAHD,sCAGC;AAED,SAAgB,cAAc,CAAC,SAAc;IAC3C,IAAI,WAAW,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,CAAC;IAE7C,IAAI,CAAC,WAAW,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,gBAAgB,IAAI,OAAO,EAAE;QACjF,WAAW,GAAI,OAAe,CAAC,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;KACzE;IAED,IAAI,CAAC,WAAW,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,WAAW,EAAE;QACzD,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC;KACpB;IAED,IAAI,CAAC,WAAW,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,WAAW,EAAE;QACzD,WAAW,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KAChC;IAED,OAAO,WAAW,IAAI,EAAE,CAAC;AAC3B,CAAC;AAhBD,wCAgBC;AAED,SAAgB,WAAW,CAAC,SAAc,EAAE,QAAgB;IAC1D,MAAM,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,UAAU,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACxD,CAAC;AAHD,kCAGC;AAED,SAAgB,cAAc,CAAC,OAAmB;IAChD,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC1B,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE;YACxB,MAAM,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;YAExC,IAAI,UAAU,EAAE;gBACd,IAAI,UAAU,CAAC,OAAO,EAAE;oBACtB,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;iBACxD;qBAAM,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,UAAU,EAAE;oBACvD,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;iBACrB;aACF;SACF;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAlBD,wCAkBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-ng",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Plugin for integrating Angular components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -19,14 +19,41 @@
|
|
|
19
19
|
"module": "esm/index.js",
|
|
20
20
|
"main": "lib/index.js",
|
|
21
21
|
"typings": "lib/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./esm/index.js",
|
|
25
|
+
"require": "./lib/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./common": {
|
|
28
|
+
"import": "./common"
|
|
29
|
+
},
|
|
30
|
+
"./convert": {
|
|
31
|
+
"import": "./convert.js"
|
|
32
|
+
},
|
|
33
|
+
"./extend-webpack": {
|
|
34
|
+
"require": "./extend-webpack.js"
|
|
35
|
+
},
|
|
36
|
+
"./esm/*": {
|
|
37
|
+
"import": "./esm/*"
|
|
38
|
+
},
|
|
39
|
+
"./lib/*": {
|
|
40
|
+
"require": "./lib/*"
|
|
41
|
+
},
|
|
42
|
+
"./_/*": {
|
|
43
|
+
"import": "./esm/*.js",
|
|
44
|
+
"require": "./lib/*.js"
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
22
48
|
"sideEffects": false,
|
|
23
49
|
"files": [
|
|
50
|
+
"common",
|
|
24
51
|
"esm",
|
|
25
52
|
"lib",
|
|
26
53
|
"src",
|
|
27
54
|
"convert.d.ts",
|
|
28
|
-
"convert.
|
|
29
|
-
"
|
|
55
|
+
"convert.js",
|
|
56
|
+
"extend-webpack.js"
|
|
30
57
|
],
|
|
31
58
|
"repository": {
|
|
32
59
|
"type": "git",
|
|
@@ -36,26 +63,34 @@
|
|
|
36
63
|
"url": "https://github.com/smapiot/piral/issues"
|
|
37
64
|
},
|
|
38
65
|
"scripts": {
|
|
39
|
-
"
|
|
40
|
-
"build
|
|
66
|
+
"cleanup": "rimraf common esm lib convert.d.ts convert.js",
|
|
67
|
+
"build": "yarn build:ng && yarn build:commonjs && yarn build:esnext && yarn build:convert",
|
|
68
|
+
"build:ng": "ng-packagr -p src/common/ng-package.json",
|
|
69
|
+
"build:convert": "tsc convert.ts --skipLibCheck --declaration --module esnext",
|
|
41
70
|
"build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
|
|
42
71
|
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
|
|
43
72
|
"typedoc": "typedoc --json ../../../docs/types/piral-ng.json src --exclude \"src/**/*.test.*\"",
|
|
44
73
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
45
74
|
},
|
|
46
75
|
"devDependencies": {
|
|
47
|
-
"@angular/common": "^
|
|
48
|
-
"@angular/compiler": "^
|
|
49
|
-
"@angular/
|
|
50
|
-
"@angular/
|
|
51
|
-
"@angular/platform-browser
|
|
52
|
-
"
|
|
76
|
+
"@angular/common": "^16.0.0",
|
|
77
|
+
"@angular/compiler": "^16.0.0",
|
|
78
|
+
"@angular/compiler-cli": "^16.0.0",
|
|
79
|
+
"@angular/core": "^16.0.0",
|
|
80
|
+
"@angular/platform-browser": "^16.0.0",
|
|
81
|
+
"@angular/platform-browser-dynamic": "^16.0.0",
|
|
82
|
+
"@angular/router": "^16.0.0",
|
|
83
|
+
"ng-packagr": "^16.0.0",
|
|
84
|
+
"piral-core": "^1.0.0",
|
|
85
|
+
"rxjs": "^7.3.0"
|
|
53
86
|
},
|
|
54
87
|
"peerDependencies": {
|
|
55
|
-
"@angular/
|
|
56
|
-
"@angular/
|
|
57
|
-
"@angular/platform-browser
|
|
58
|
-
"
|
|
88
|
+
"@angular/common": "^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 || ^15.0.0 || ^16.0.0",
|
|
89
|
+
"@angular/core": "^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 || ^15.0.0 || ^16.0.0",
|
|
90
|
+
"@angular/platform-browser": "^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 || ^15.0.0 || ^16.0.0",
|
|
91
|
+
"@angular/platform-browser-dynamic": "^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 || ^15.0.0 || ^16.0.0",
|
|
92
|
+
"@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 || ^15.0.0 || ^16.0.0",
|
|
93
|
+
"rxjs": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
59
94
|
},
|
|
60
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "67d9a2920bd5231baf10bc87ae8985666b18fa3a"
|
|
61
96
|
}
|