@microzord/angular 1.0.0-alpha.1 → 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.
Files changed (67) hide show
  1. package/README.md +3 -4
  2. package/bundles/microzord-angular-child.umd.js +173 -18
  3. package/bundles/microzord-angular-child.umd.js.map +1 -1
  4. package/bundles/microzord-angular.umd.js +664 -44
  5. package/bundles/microzord-angular.umd.js.map +1 -1
  6. package/child/src/create-app.d.ts +2 -2
  7. package/esm2015/child/src/create-app.js.map +1 -1
  8. package/esm2015/index.js +5 -2
  9. package/esm2015/index.js.map +1 -1
  10. package/esm2015/index.metadata.json +1 -1
  11. package/esm2015/lib/microzord-app/microzord-app.directive.js +51 -0
  12. package/esm2015/lib/microzord-app/microzord-app.directive.js.map +1 -0
  13. package/esm2015/lib/microzord-app/microzord-app.directive.metadata.json +1 -0
  14. package/esm2015/lib/microzord-app/microzord-app.module.js +11 -0
  15. package/esm2015/lib/microzord-app/microzord-app.module.js.map +1 -0
  16. package/esm2015/lib/microzord-app/microzord-app.module.metadata.json +1 -0
  17. package/esm2015/lib/microzord-host.module.js +25 -10
  18. package/esm2015/lib/microzord-host.module.js.map +1 -1
  19. package/esm2015/lib/microzord-host.module.metadata.json +1 -1
  20. package/esm2015/lib/microzord-module/microzord-ng-compiler.service.js +39 -0
  21. package/esm2015/lib/microzord-module/microzord-ng-compiler.service.js.map +1 -0
  22. package/esm2015/lib/microzord-module/microzord-ng-compiler.service.metadata.json +1 -0
  23. package/esm2015/lib/microzord-module/microzord-ng-module.directive.js +52 -0
  24. package/esm2015/lib/microzord-module/microzord-ng-module.directive.js.map +1 -0
  25. package/esm2015/lib/microzord-module/microzord-ng-module.directive.metadata.json +1 -0
  26. package/esm2015/lib/microzord-module/microzord-ng-module.module.js +11 -0
  27. package/esm2015/lib/microzord-module/microzord-ng-module.module.js.map +1 -0
  28. package/esm2015/lib/microzord-module/microzord-ng-module.module.metadata.json +1 -0
  29. package/esm2015/lib/operators/complete.js +6 -0
  30. package/esm2015/lib/operators/complete.js.map +1 -0
  31. package/esm2015/lib/operators/complete.metadata.json +1 -0
  32. package/esm2015/lib/services/registry.service.js +5 -9
  33. package/esm2015/lib/services/registry.service.js.map +1 -1
  34. package/esm2015/lib/services/registry.service.metadata.json +1 -1
  35. package/esm2015/lib/tokens/microzord-apps.js +6 -1
  36. package/esm2015/lib/tokens/microzord-apps.js.map +1 -1
  37. package/esm2015/lib/tokens/microzord-apps.metadata.json +1 -1
  38. package/esm2015/lib/types/ng-module.js +2 -0
  39. package/esm2015/lib/types/ng-module.js.map +1 -0
  40. package/esm2015/lib/types/ng-module.metadata.json +1 -0
  41. package/esm2015/microzord-angular.js +1 -0
  42. package/esm2015/microzord-angular.js.map +1 -1
  43. package/esm2015/microzord-angular.metadata.json +1 -1
  44. package/fesm2015/microzord-angular-child.js.map +1 -1
  45. package/fesm2015/microzord-angular.js +162 -42
  46. package/fesm2015/microzord-angular.js.map +1 -1
  47. package/index.d.ts +6 -2
  48. package/lib/{microzord/microzord.directive.d.ts → microzord-app/microzord-app.directive.d.ts} +6 -4
  49. package/lib/microzord-app/microzord-app.module.d.ts +2 -0
  50. package/lib/microzord-host.module.d.ts +7 -5
  51. package/lib/microzord-module/microzord-ng-compiler.service.d.ts +12 -0
  52. package/lib/microzord-module/microzord-ng-module.directive.d.ts +16 -0
  53. package/lib/microzord-module/microzord-ng-module.module.d.ts +2 -0
  54. package/lib/operators/complete.d.ts +1 -0
  55. package/lib/services/registry.service.d.ts +4 -3
  56. package/lib/tokens/microzord-apps.d.ts +4 -3
  57. package/lib/types/ng-module.d.ts +8 -0
  58. package/microzord-angular.d.ts +1 -0
  59. package/microzord-angular.metadata.json +1 -1
  60. package/package.json +6 -6
  61. package/esm2015/lib/microzord/microzord.directive.js +0 -41
  62. package/esm2015/lib/microzord/microzord.directive.js.map +0 -1
  63. package/esm2015/lib/microzord/microzord.directive.metadata.json +0 -1
  64. package/esm2015/lib/microzord/microzord.module.js +0 -11
  65. package/esm2015/lib/microzord/microzord.module.js.map +0 -1
  66. package/esm2015/lib/microzord/microzord.module.metadata.json +0 -1
  67. package/lib/microzord/microzord.module.d.ts +0 -2
@@ -24,22 +24,30 @@
24
24
 
25
25
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
26
 
27
- var MicrozordDirective = /** @class */ (function () {
28
- function MicrozordDirective(elementRef, ngZone) {
27
+ var complete = function (fn) { return operators.switchMap(function (value) { return rxjs.NEVER.pipe(operators.startWith(value), operators.finalize(function () {
28
+ fn(value);
29
+ })); }); };
30
+
31
+ var MicrozordAppDirective = /** @class */ (function () {
32
+ function MicrozordAppDirective(elementRef, ngZone, errorHandler) {
29
33
  var _this = this;
30
34
  this.elementRef = elementRef;
31
35
  this.ngZone = ngZone;
36
+ this.errorHandler = errorHandler;
32
37
  this.destroy$ = new rxjs.Subject();
33
38
  this.name$ = new rxjs.Subject();
34
- this.application = this.name$.pipe(operators.tap(function () { return i0.NgZone.assertNotInAngularZone(); }), operators.switchMap(function (name) { return name
35
- ? core.bootstrapApp(name, _this.elementRef.nativeElement).pipe(operators.switchMap(function (app) { return rxjs.NEVER.pipe(operators.startWith(app), operators.finalize(function () {
36
- app.destroy();
37
- })); }))
38
- : rxjs.of(null); }), operators.takeUntil(this.destroy$));
39
- this.hook = this.application.pipe(operators.filter((function (app) { return !!app; })), operators.switchMap(function (app) { return new rxjs.Observable(function (subscriber) { return app.onHook(function (event) { return subscriber.next(event); }); }); }));
39
+ var app$ = this.name$.pipe(operators.tap(function () { return i0.NgZone.assertNotInAngularZone(); }), operators.switchMap(function (name) { return (name ? core.constructApp(name) : rxjs.of(null)); }), operators.catchError(function (error) { return _this.handleError(error); }), operators.takeUntil(this.destroy$), operators.shareReplay(1));
40
+ this.application = app$.pipe(complete(function (app) {
41
+ app === null || app === void 0 ? void 0 : app.destroy();
42
+ }), operators.switchMap(function (name) { return name
43
+ ? core.bootstrapApp(name, _this.elementRef.nativeElement).pipe(operators.catchError(function (error) { return _this.handleError(error); }))
44
+ : rxjs.of(null); }), operators.takeUntil(this.destroy$), operators.shareReplay(1));
45
+ this.hook = app$.pipe(operators.switchMap(function (app) { return app
46
+ ? new rxjs.Observable(function (subscriber) { return app.onHook(function (event) { return subscriber.next(event); }); })
47
+ : rxjs.NEVER; }));
40
48
  this.application.subscribe();
41
49
  }
42
- Object.defineProperty(MicrozordDirective.prototype, "name", {
50
+ Object.defineProperty(MicrozordAppDirective.prototype, "name", {
43
51
  set: function (appName) {
44
52
  var _this = this;
45
53
  this.ngZone.runOutsideAngular(function () { return _this.name$.next(appName); });
@@ -47,55 +55,650 @@
47
55
  enumerable: false,
48
56
  configurable: true
49
57
  });
50
- MicrozordDirective.prototype.ngOnDestroy = function () {
58
+ MicrozordAppDirective.prototype.ngOnDestroy = function () {
51
59
  this.destroy$.next();
52
60
  this.destroy$.complete();
53
61
  };
54
- return MicrozordDirective;
62
+ MicrozordAppDirective.prototype.handleError = function (error) {
63
+ this.errorHandler.handleError(error);
64
+ return rxjs.of(null);
65
+ };
66
+ return MicrozordAppDirective;
55
67
  }());
56
- MicrozordDirective.decorators = [
68
+ MicrozordAppDirective.decorators = [
57
69
  { type: i0.Directive, args: [{
58
- selector: '[microzord]:not(ng-container)',
70
+ selector: '[microzordApp]:not(ng-container)',
59
71
  },] }
60
72
  ];
61
- MicrozordDirective.ctorParameters = function () { return [
73
+ MicrozordAppDirective.ctorParameters = function () { return [
62
74
  { type: i0.ElementRef },
63
- { type: i0.NgZone }
75
+ { type: i0.NgZone },
76
+ { type: i0.ErrorHandler }
64
77
  ]; };
65
- MicrozordDirective.propDecorators = {
78
+ MicrozordAppDirective.propDecorators = {
66
79
  hook: [{ type: i0.Output }],
67
80
  application: [{ type: i0.Output }],
68
- name: [{ type: i0.Input, args: ['microzord',] }]
81
+ name: [{ type: i0.Input, args: ['microzordApp',] }]
69
82
  };
70
83
 
71
- var MicrozordModule = /** @class */ (function () {
72
- function MicrozordModule() {
84
+ var MicrozordAppModule = /** @class */ (function () {
85
+ function MicrozordAppModule() {
73
86
  }
74
- return MicrozordModule;
87
+ return MicrozordAppModule;
75
88
  }());
76
- MicrozordModule.decorators = [
89
+ MicrozordAppModule.decorators = [
77
90
  { type: i0.NgModule, args: [{
78
- declarations: [MicrozordDirective],
79
- exports: [MicrozordDirective],
91
+ declarations: [MicrozordAppDirective],
92
+ exports: [MicrozordAppDirective],
80
93
  },] }
81
94
  ];
82
95
 
83
- var MICROZORD_APPS = new i0.InjectionToken('Microzord apps');
96
+ /******************************************************************************
97
+ Copyright (c) Microsoft Corporation.
98
+
99
+ Permission to use, copy, modify, and/or distribute this software for any
100
+ purpose with or without fee is hereby granted.
101
+
102
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
103
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
104
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
105
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
106
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
107
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
108
+ PERFORMANCE OF THIS SOFTWARE.
109
+ ***************************************************************************** */
110
+ /* global Reflect, Promise, SuppressedError, Symbol */
111
+ var extendStatics = function (d, b) {
112
+ extendStatics = Object.setPrototypeOf ||
113
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
114
+ function (d, b) { for (var p in b)
115
+ if (Object.prototype.hasOwnProperty.call(b, p))
116
+ d[p] = b[p]; };
117
+ return extendStatics(d, b);
118
+ };
119
+ function __extends(d, b) {
120
+ if (typeof b !== "function" && b !== null)
121
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
122
+ extendStatics(d, b);
123
+ function __() { this.constructor = d; }
124
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
125
+ }
126
+ var __assign = function () {
127
+ __assign = Object.assign || function __assign(t) {
128
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
129
+ s = arguments[i];
130
+ for (var p in s)
131
+ if (Object.prototype.hasOwnProperty.call(s, p))
132
+ t[p] = s[p];
133
+ }
134
+ return t;
135
+ };
136
+ return __assign.apply(this, arguments);
137
+ };
138
+ function __rest(s, e) {
139
+ var t = {};
140
+ for (var p in s)
141
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
142
+ t[p] = s[p];
143
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
144
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
145
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
146
+ t[p[i]] = s[p[i]];
147
+ }
148
+ return t;
149
+ }
150
+ function __decorate(decorators, target, key, desc) {
151
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
152
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
153
+ r = Reflect.decorate(decorators, target, key, desc);
154
+ else
155
+ for (var i = decorators.length - 1; i >= 0; i--)
156
+ if (d = decorators[i])
157
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
158
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
159
+ }
160
+ function __param(paramIndex, decorator) {
161
+ return function (target, key) { decorator(target, key, paramIndex); };
162
+ }
163
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
164
+ function accept(f) { if (f !== void 0 && typeof f !== "function")
165
+ throw new TypeError("Function expected"); return f; }
166
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
167
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
168
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
169
+ var _, done = false;
170
+ for (var i = decorators.length - 1; i >= 0; i--) {
171
+ var context = {};
172
+ for (var p in contextIn)
173
+ context[p] = p === "access" ? {} : contextIn[p];
174
+ for (var p in contextIn.access)
175
+ context.access[p] = contextIn.access[p];
176
+ context.addInitializer = function (f) { if (done)
177
+ throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
178
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
179
+ if (kind === "accessor") {
180
+ if (result === void 0)
181
+ continue;
182
+ if (result === null || typeof result !== "object")
183
+ throw new TypeError("Object expected");
184
+ if (_ = accept(result.get))
185
+ descriptor.get = _;
186
+ if (_ = accept(result.set))
187
+ descriptor.set = _;
188
+ if (_ = accept(result.init))
189
+ initializers.unshift(_);
190
+ }
191
+ else if (_ = accept(result)) {
192
+ if (kind === "field")
193
+ initializers.unshift(_);
194
+ else
195
+ descriptor[key] = _;
196
+ }
197
+ }
198
+ if (target)
199
+ Object.defineProperty(target, contextIn.name, descriptor);
200
+ done = true;
201
+ }
202
+ ;
203
+ function __runInitializers(thisArg, initializers, value) {
204
+ var useValue = arguments.length > 2;
205
+ for (var i = 0; i < initializers.length; i++) {
206
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
207
+ }
208
+ return useValue ? value : void 0;
209
+ }
210
+ ;
211
+ function __propKey(x) {
212
+ return typeof x === "symbol" ? x : "".concat(x);
213
+ }
214
+ ;
215
+ function __setFunctionName(f, name, prefix) {
216
+ if (typeof name === "symbol")
217
+ name = name.description ? "[".concat(name.description, "]") : "";
218
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
219
+ }
220
+ ;
221
+ function __metadata(metadataKey, metadataValue) {
222
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
223
+ return Reflect.metadata(metadataKey, metadataValue);
224
+ }
225
+ function __awaiter(thisArg, _arguments, P, generator) {
226
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
227
+ return new (P || (P = Promise))(function (resolve, reject) {
228
+ function fulfilled(value) { try {
229
+ step(generator.next(value));
230
+ }
231
+ catch (e) {
232
+ reject(e);
233
+ } }
234
+ function rejected(value) { try {
235
+ step(generator["throw"](value));
236
+ }
237
+ catch (e) {
238
+ reject(e);
239
+ } }
240
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
241
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
242
+ });
243
+ }
244
+ function __generator(thisArg, body) {
245
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
246
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
247
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
248
+ function verb(n) { return function (v) { return step([n, v]); }; }
249
+ function step(op) {
250
+ if (f)
251
+ throw new TypeError("Generator is already executing.");
252
+ while (g && (g = 0, op[0] && (_ = 0)), _)
253
+ try {
254
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
255
+ return t;
256
+ if (y = 0, t)
257
+ op = [op[0] & 2, t.value];
258
+ switch (op[0]) {
259
+ case 0:
260
+ case 1:
261
+ t = op;
262
+ break;
263
+ case 4:
264
+ _.label++;
265
+ return { value: op[1], done: false };
266
+ case 5:
267
+ _.label++;
268
+ y = op[1];
269
+ op = [0];
270
+ continue;
271
+ case 7:
272
+ op = _.ops.pop();
273
+ _.trys.pop();
274
+ continue;
275
+ default:
276
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
277
+ _ = 0;
278
+ continue;
279
+ }
280
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
281
+ _.label = op[1];
282
+ break;
283
+ }
284
+ if (op[0] === 6 && _.label < t[1]) {
285
+ _.label = t[1];
286
+ t = op;
287
+ break;
288
+ }
289
+ if (t && _.label < t[2]) {
290
+ _.label = t[2];
291
+ _.ops.push(op);
292
+ break;
293
+ }
294
+ if (t[2])
295
+ _.ops.pop();
296
+ _.trys.pop();
297
+ continue;
298
+ }
299
+ op = body.call(thisArg, _);
300
+ }
301
+ catch (e) {
302
+ op = [6, e];
303
+ y = 0;
304
+ }
305
+ finally {
306
+ f = t = 0;
307
+ }
308
+ if (op[0] & 5)
309
+ throw op[1];
310
+ return { value: op[0] ? op[1] : void 0, done: true };
311
+ }
312
+ }
313
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
314
+ if (k2 === undefined)
315
+ k2 = k;
316
+ var desc = Object.getOwnPropertyDescriptor(m, k);
317
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
318
+ desc = { enumerable: true, get: function () { return m[k]; } };
319
+ }
320
+ Object.defineProperty(o, k2, desc);
321
+ }) : (function (o, m, k, k2) {
322
+ if (k2 === undefined)
323
+ k2 = k;
324
+ o[k2] = m[k];
325
+ });
326
+ function __exportStar(m, o) {
327
+ for (var p in m)
328
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
329
+ __createBinding(o, m, p);
330
+ }
331
+ function __values(o) {
332
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
333
+ if (m)
334
+ return m.call(o);
335
+ if (o && typeof o.length === "number")
336
+ return {
337
+ next: function () {
338
+ if (o && i >= o.length)
339
+ o = void 0;
340
+ return { value: o && o[i++], done: !o };
341
+ }
342
+ };
343
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
344
+ }
345
+ function __read(o, n) {
346
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
347
+ if (!m)
348
+ return o;
349
+ var i = m.call(o), r, ar = [], e;
350
+ try {
351
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
352
+ ar.push(r.value);
353
+ }
354
+ catch (error) {
355
+ e = { error: error };
356
+ }
357
+ finally {
358
+ try {
359
+ if (r && !r.done && (m = i["return"]))
360
+ m.call(i);
361
+ }
362
+ finally {
363
+ if (e)
364
+ throw e.error;
365
+ }
366
+ }
367
+ return ar;
368
+ }
369
+ /** @deprecated */
370
+ function __spread() {
371
+ for (var ar = [], i = 0; i < arguments.length; i++)
372
+ ar = ar.concat(__read(arguments[i]));
373
+ return ar;
374
+ }
375
+ /** @deprecated */
376
+ function __spreadArrays() {
377
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
378
+ s += arguments[i].length;
379
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
380
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
381
+ r[k] = a[j];
382
+ return r;
383
+ }
384
+ function __spreadArray(to, from, pack) {
385
+ if (pack || arguments.length === 2)
386
+ for (var i = 0, l = from.length, ar; i < l; i++) {
387
+ if (ar || !(i in from)) {
388
+ if (!ar)
389
+ ar = Array.prototype.slice.call(from, 0, i);
390
+ ar[i] = from[i];
391
+ }
392
+ }
393
+ return to.concat(ar || Array.prototype.slice.call(from));
394
+ }
395
+ function __await(v) {
396
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
397
+ }
398
+ function __asyncGenerator(thisArg, _arguments, generator) {
399
+ if (!Symbol.asyncIterator)
400
+ throw new TypeError("Symbol.asyncIterator is not defined.");
401
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
402
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
403
+ function verb(n) { if (g[n])
404
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
405
+ function resume(n, v) { try {
406
+ step(g[n](v));
407
+ }
408
+ catch (e) {
409
+ settle(q[0][3], e);
410
+ } }
411
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
412
+ function fulfill(value) { resume("next", value); }
413
+ function reject(value) { resume("throw", value); }
414
+ function settle(f, v) { if (f(v), q.shift(), q.length)
415
+ resume(q[0][0], q[0][1]); }
416
+ }
417
+ function __asyncDelegator(o) {
418
+ var i, p;
419
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
420
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
421
+ }
422
+ function __asyncValues(o) {
423
+ if (!Symbol.asyncIterator)
424
+ throw new TypeError("Symbol.asyncIterator is not defined.");
425
+ var m = o[Symbol.asyncIterator], i;
426
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
427
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
428
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
429
+ }
430
+ function __makeTemplateObject(cooked, raw) {
431
+ if (Object.defineProperty) {
432
+ Object.defineProperty(cooked, "raw", { value: raw });
433
+ }
434
+ else {
435
+ cooked.raw = raw;
436
+ }
437
+ return cooked;
438
+ }
439
+ ;
440
+ var __setModuleDefault = Object.create ? (function (o, v) {
441
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
442
+ }) : function (o, v) {
443
+ o["default"] = v;
444
+ };
445
+ function __importStar(mod) {
446
+ if (mod && mod.__esModule)
447
+ return mod;
448
+ var result = {};
449
+ if (mod != null)
450
+ for (var k in mod)
451
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
452
+ __createBinding(result, mod, k);
453
+ __setModuleDefault(result, mod);
454
+ return result;
455
+ }
456
+ function __importDefault(mod) {
457
+ return (mod && mod.__esModule) ? mod : { default: mod };
458
+ }
459
+ function __classPrivateFieldGet(receiver, state, kind, f) {
460
+ if (kind === "a" && !f)
461
+ throw new TypeError("Private accessor was defined without a getter");
462
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
463
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
464
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
465
+ }
466
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
467
+ if (kind === "m")
468
+ throw new TypeError("Private method is not writable");
469
+ if (kind === "a" && !f)
470
+ throw new TypeError("Private accessor was defined without a setter");
471
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
472
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
473
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
474
+ }
475
+ function __classPrivateFieldIn(state, receiver) {
476
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
477
+ throw new TypeError("Cannot use 'in' operator on non-object");
478
+ return typeof state === "function" ? receiver === state : state.has(receiver);
479
+ }
480
+ function __addDisposableResource(env, value, async) {
481
+ if (value !== null && value !== void 0) {
482
+ if (typeof value !== "object" && typeof value !== "function")
483
+ throw new TypeError("Object expected.");
484
+ var dispose;
485
+ if (async) {
486
+ if (!Symbol.asyncDispose)
487
+ throw new TypeError("Symbol.asyncDispose is not defined.");
488
+ dispose = value[Symbol.asyncDispose];
489
+ }
490
+ if (dispose === void 0) {
491
+ if (!Symbol.dispose)
492
+ throw new TypeError("Symbol.dispose is not defined.");
493
+ dispose = value[Symbol.dispose];
494
+ }
495
+ if (typeof dispose !== "function")
496
+ throw new TypeError("Object not disposable.");
497
+ env.stack.push({ value: value, dispose: dispose, async: async });
498
+ }
499
+ else if (async) {
500
+ env.stack.push({ async: true });
501
+ }
502
+ return value;
503
+ }
504
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
505
+ var e = new Error(message);
506
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
507
+ };
508
+ function __disposeResources(env) {
509
+ function fail(e) {
510
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
511
+ env.hasError = true;
512
+ }
513
+ function next() {
514
+ while (env.stack.length) {
515
+ var rec = env.stack.pop();
516
+ try {
517
+ var result = rec.dispose && rec.dispose.call(rec.value);
518
+ if (rec.async)
519
+ return Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
520
+ }
521
+ catch (e) {
522
+ fail(e);
523
+ }
524
+ }
525
+ if (env.hasError)
526
+ throw env.error;
527
+ }
528
+ return next();
529
+ }
530
+ var tslib_es6 = {
531
+ __extends: __extends,
532
+ __assign: __assign,
533
+ __rest: __rest,
534
+ __decorate: __decorate,
535
+ __param: __param,
536
+ __metadata: __metadata,
537
+ __awaiter: __awaiter,
538
+ __generator: __generator,
539
+ __createBinding: __createBinding,
540
+ __exportStar: __exportStar,
541
+ __values: __values,
542
+ __read: __read,
543
+ __spread: __spread,
544
+ __spreadArrays: __spreadArrays,
545
+ __spreadArray: __spreadArray,
546
+ __await: __await,
547
+ __asyncGenerator: __asyncGenerator,
548
+ __asyncDelegator: __asyncDelegator,
549
+ __asyncValues: __asyncValues,
550
+ __makeTemplateObject: __makeTemplateObject,
551
+ __importStar: __importStar,
552
+ __importDefault: __importDefault,
553
+ __classPrivateFieldGet: __classPrivateFieldGet,
554
+ __classPrivateFieldSet: __classPrivateFieldSet,
555
+ __classPrivateFieldIn: __classPrivateFieldIn,
556
+ __addDisposableResource: __addDisposableResource,
557
+ __disposeResources: __disposeResources,
558
+ };
559
+
560
+ var MicrozordNgCompilerService = /** @class */ (function () {
561
+ function MicrozordNgCompilerService(compiler, componentFactoryResolver, injector, viewContainerRef) {
562
+ this.compiler = compiler;
563
+ this.componentFactoryResolver = componentFactoryResolver;
564
+ this.injector = injector;
565
+ this.viewContainerRef = viewContainerRef;
566
+ }
567
+ MicrozordNgCompilerService.prototype.createModule = function (Module, injector) {
568
+ if (injector === void 0) { injector = this.injector; }
569
+ return __awaiter(this, void 0, void 0, function () {
570
+ var moduleFactory;
571
+ return __generator(this, function (_a) {
572
+ switch (_a.label) {
573
+ case 0: return [4 /*yield*/, this.compiler.compileModuleAsync(Module)];
574
+ case 1:
575
+ moduleFactory = _a.sent();
576
+ return [2 /*return*/, moduleFactory.create(injector)];
577
+ }
578
+ });
579
+ });
580
+ };
581
+ MicrozordNgCompilerService.prototype.createEntryPoint = function (moduleRef, injector, viewContainerRef) {
582
+ if (injector === void 0) { injector = this.injector; }
583
+ if (viewContainerRef === void 0) { viewContainerRef = this.viewContainerRef; }
584
+ return __awaiter(this, void 0, void 0, function () {
585
+ var componentFactory;
586
+ return __generator(this, function (_a) {
587
+ componentFactory = this.componentFactoryResolver.resolveComponentFactory(moduleRef.instance.getEntryPoint());
588
+ viewContainerRef.clear();
589
+ return [2 /*return*/, viewContainerRef.createComponent(componentFactory, undefined, injector, [], moduleRef)];
590
+ });
591
+ });
592
+ };
593
+ MicrozordNgCompilerService.prototype.createEntryPointFromModule = function (Module, injector, viewContainerRef) {
594
+ if (injector === void 0) { injector = this.injector; }
595
+ if (viewContainerRef === void 0) { viewContainerRef = this.viewContainerRef; }
596
+ return __awaiter(this, void 0, void 0, function () {
597
+ var moduleRef;
598
+ return __generator(this, function (_a) {
599
+ switch (_a.label) {
600
+ case 0: return [4 /*yield*/, this.createModule(Module, injector)];
601
+ case 1:
602
+ moduleRef = _a.sent();
603
+ return [2 /*return*/, this.createEntryPoint(moduleRef, injector, viewContainerRef)];
604
+ }
605
+ });
606
+ });
607
+ };
608
+ return MicrozordNgCompilerService;
609
+ }());
610
+ MicrozordNgCompilerService.decorators = [
611
+ { type: i0.Injectable }
612
+ ];
613
+ MicrozordNgCompilerService.ctorParameters = function () { return [
614
+ { type: i0.Compiler },
615
+ { type: i0.ComponentFactoryResolver },
616
+ { type: i0.Injector, decorators: [{ type: i0.Optional }] },
617
+ { type: i0.ViewContainerRef, decorators: [{ type: i0.Optional }] }
618
+ ]; };
619
+
620
+ var MicrozordNgModuleDirective = /** @class */ (function () {
621
+ function MicrozordNgModuleDirective(ngZone, mzNgCompiler, errorHandler) {
622
+ var _this = this;
623
+ this.ngZone = ngZone;
624
+ this.mzNgCompiler = mzNgCompiler;
625
+ this.errorHandler = errorHandler;
626
+ this.name$ = new rxjs.Subject();
627
+ this.destroy$ = new rxjs.Subject();
628
+ this.module = this.name$.pipe(operators.tap(function () { return i0.NgZone.assertNotInAngularZone(); }), operators.switchMap(function (name) { return name
629
+ ? _this.loadModuleAndBootstrap(name).pipe(operators.catchError(function (error) {
630
+ _this.errorHandler.handleError(error);
631
+ return rxjs.of(null);
632
+ }))
633
+ : rxjs.of(null); }), operators.map(function (componentRef) { var _a; return (_a = componentRef === null || componentRef === void 0 ? void 0 : componentRef.injector.get(i0.NgModuleRef)) !== null && _a !== void 0 ? _a : null; }), operators.shareReplay(1), operators.takeUntil(this.destroy$));
634
+ this.module.subscribe();
635
+ }
636
+ Object.defineProperty(MicrozordNgModuleDirective.prototype, "name", {
637
+ set: function (moduleName) {
638
+ var _this = this;
639
+ this.ngZone.runOutsideAngular(function () { return _this.name$.next(moduleName); });
640
+ },
641
+ enumerable: false,
642
+ configurable: true
643
+ });
644
+ MicrozordNgModuleDirective.prototype.loadModuleAndBootstrap = function (name) {
645
+ var _this = this;
646
+ return core.loadEntity(name).pipe(operators.switchMap(function (Module) { return _this.mzNgCompiler.createEntryPointFromModule(Module); }), complete(function (componentRef) { return _this.destroyComponentAndModule(componentRef); }));
647
+ };
648
+ MicrozordNgModuleDirective.prototype.destroyComponentAndModule = function (componentRef) {
649
+ componentRef.destroy();
650
+ componentRef.injector.get(i0.NgModuleRef).destroy();
651
+ };
652
+ MicrozordNgModuleDirective.prototype.ngOnDestroy = function () {
653
+ this.destroy$.next();
654
+ this.destroy$.complete();
655
+ };
656
+ return MicrozordNgModuleDirective;
657
+ }());
658
+ MicrozordNgModuleDirective.decorators = [
659
+ { type: i0.Directive, args: [{
660
+ selector: '[microzordNgModule]',
661
+ providers: [MicrozordNgCompilerService],
662
+ },] }
663
+ ];
664
+ MicrozordNgModuleDirective.ctorParameters = function () { return [
665
+ { type: i0.NgZone },
666
+ { type: MicrozordNgCompilerService },
667
+ { type: i0.ErrorHandler }
668
+ ]; };
669
+ MicrozordNgModuleDirective.propDecorators = {
670
+ module: [{ type: i0.Output }],
671
+ name: [{ type: i0.Input, args: ['microzordNgModule',] }]
672
+ };
673
+
674
+ var MicrozordNgModuleModule = /** @class */ (function () {
675
+ function MicrozordNgModuleModule() {
676
+ }
677
+ return MicrozordNgModuleModule;
678
+ }());
679
+ MicrozordNgModuleModule.decorators = [
680
+ { type: i0.NgModule, args: [{
681
+ declarations: [MicrozordNgModuleDirective],
682
+ exports: [MicrozordNgModuleDirective],
683
+ },] }
684
+ ];
685
+
686
+ var MICROZORD_APPS = new i0.InjectionToken('Microzord apps', {
687
+ factory: function () { return []; },
688
+ });
689
+ var MICROZORD_NG_MODULES = new i0.InjectionToken('Microzord Angular modules', {
690
+ factory: function () { return []; },
691
+ });
84
692
 
85
693
  var RegistryService = /** @class */ (function () {
86
694
  function RegistryService() {
87
695
  }
88
- RegistryService.prototype.registerApps = function (apps) {
696
+ RegistryService.prototype.registerMany = function (apps) {
89
697
  var _this = this;
90
- apps.map(function (app) { return _this.register(app); });
698
+ apps.forEach(function (app) { return _this.register(app); });
91
699
  };
92
- RegistryService.prototype.register = function (_a) {
93
- var name = _a.name, loadApp = _a.loadApp, props = _a.props;
94
- core.registerApp({
95
- name: name,
96
- props: props,
97
- loadApp: loadApp,
98
- });
700
+ RegistryService.prototype.register = function (options) {
701
+ core.registerEntity(options);
99
702
  };
100
703
  return RegistryService;
101
704
  }());
@@ -107,29 +710,42 @@
107
710
  ];
108
711
 
109
712
  var MicrozordHostModule = /** @class */ (function () {
110
- function MicrozordHostModule(allApps, registry) {
111
- allApps.forEach(function (apps) { return registry.registerApps(apps); });
713
+ function MicrozordHostModule(allApps, allModules, registry) {
714
+ allApps.forEach(function (apps) { return registry.registerMany(apps); });
715
+ allModules.forEach(function (modules) { return registry.registerMany(modules); });
112
716
  }
113
717
  MicrozordHostModule.register = function (_a) {
114
- var apps = _a.apps;
718
+ var apps = _a.apps, modules = _a.modules;
115
719
  return {
116
720
  ngModule: MicrozordHostModule,
117
721
  providers: [
118
- {
119
- provide: MICROZORD_APPS,
120
- useValue: apps,
121
- multi: true,
122
- },
722
+ apps
723
+ ? {
724
+ provide: MICROZORD_APPS,
725
+ useValue: apps,
726
+ multi: true,
727
+ }
728
+ : [],
729
+ modules
730
+ ? {
731
+ provide: MICROZORD_NG_MODULES,
732
+ useValue: modules,
733
+ multi: true,
734
+ }
735
+ : [],
123
736
  ],
124
737
  };
125
738
  };
126
739
  return MicrozordHostModule;
127
740
  }());
128
741
  MicrozordHostModule.decorators = [
129
- { type: i0.NgModule, args: [{},] }
742
+ { type: i0.NgModule, args: [{
743
+ exports: [MicrozordAppModule, MicrozordNgModuleModule],
744
+ },] }
130
745
  ];
131
746
  MicrozordHostModule.ctorParameters = function () { return [
132
747
  { type: Array, decorators: [{ type: i0.Inject, args: [MICROZORD_APPS,] }] },
748
+ { type: Array, decorators: [{ type: i0.Inject, args: [MICROZORD_NG_MODULES,] }] },
133
749
  { type: RegistryService }
134
750
  ]; };
135
751
 
@@ -138,10 +754,14 @@
138
754
  */
139
755
 
140
756
  exports.MICROZORD_APPS = MICROZORD_APPS;
141
- exports.MicrozordDirective = MicrozordDirective;
757
+ exports.MICROZORD_NG_MODULES = MICROZORD_NG_MODULES;
758
+ exports.MicrozordAppDirective = MicrozordAppDirective;
759
+ exports.MicrozordAppModule = MicrozordAppModule;
142
760
  exports.MicrozordHostModule = MicrozordHostModule;
143
- exports.MicrozordModule = MicrozordModule;
761
+ exports.MicrozordNgModuleDirective = MicrozordNgModuleDirective;
762
+ exports.MicrozordNgModuleModule = MicrozordNgModuleModule;
144
763
  exports.RegistryService = RegistryService;
764
+ exports["ɵa"] = MicrozordNgCompilerService;
145
765
 
146
766
  Object.defineProperty(exports, '__esModule', { value: true });
147
767