@zdigambar/ngx-element 2.0.0 → 4.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.
@@ -1,790 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/elements'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@zdigambar/ngx-element', ['exports', '@angular/core', '@angular/elements', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.zdigambar = global.zdigambar || {}, global.zdigambar['ngx-element'] = {}), global.ng.core, global.ng.elements, global.rxjs, global.rxjs.operators));
5
- }(this, (function (exports, i0, elements, rxjs, operators) { 'use strict';
6
-
7
- /******************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
22
- var extendStatics = function (d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b)
26
- if (Object.prototype.hasOwnProperty.call(b, p))
27
- d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- function __extends(d, b) {
31
- if (typeof b !== "function" && b !== null)
32
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33
- extendStatics(d, b);
34
- function __() { this.constructor = d; }
35
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36
- }
37
- var __assign = function () {
38
- __assign = Object.assign || function __assign(t) {
39
- for (var s, i = 1, n = arguments.length; i < n; i++) {
40
- s = arguments[i];
41
- for (var p in s)
42
- if (Object.prototype.hasOwnProperty.call(s, p))
43
- t[p] = s[p];
44
- }
45
- return t;
46
- };
47
- return __assign.apply(this, arguments);
48
- };
49
- function __rest(s, e) {
50
- var t = {};
51
- for (var p in s)
52
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
- t[p] = s[p];
54
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
- t[p[i]] = s[p[i]];
58
- }
59
- return t;
60
- }
61
- function __decorate(decorators, target, key, desc) {
62
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64
- r = Reflect.decorate(decorators, target, key, desc);
65
- else
66
- for (var i = decorators.length - 1; i >= 0; i--)
67
- if (d = decorators[i])
68
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69
- return c > 3 && r && Object.defineProperty(target, key, r), r;
70
- }
71
- function __param(paramIndex, decorator) {
72
- return function (target, key) { decorator(target, key, paramIndex); };
73
- }
74
- function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
75
- function accept(f) { if (f !== void 0 && typeof f !== "function")
76
- throw new TypeError("Function expected"); return f; }
77
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
78
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
79
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
80
- var _, done = false;
81
- for (var i = decorators.length - 1; i >= 0; i--) {
82
- var context = {};
83
- for (var p in contextIn)
84
- context[p] = p === "access" ? {} : contextIn[p];
85
- for (var p in contextIn.access)
86
- context.access[p] = contextIn.access[p];
87
- context.addInitializer = function (f) { if (done)
88
- throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
89
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
90
- if (kind === "accessor") {
91
- if (result === void 0)
92
- continue;
93
- if (result === null || typeof result !== "object")
94
- throw new TypeError("Object expected");
95
- if (_ = accept(result.get))
96
- descriptor.get = _;
97
- if (_ = accept(result.set))
98
- descriptor.set = _;
99
- if (_ = accept(result.init))
100
- initializers.unshift(_);
101
- }
102
- else if (_ = accept(result)) {
103
- if (kind === "field")
104
- initializers.unshift(_);
105
- else
106
- descriptor[key] = _;
107
- }
108
- }
109
- if (target)
110
- Object.defineProperty(target, contextIn.name, descriptor);
111
- done = true;
112
- }
113
- ;
114
- function __runInitializers(thisArg, initializers, value) {
115
- var useValue = arguments.length > 2;
116
- for (var i = 0; i < initializers.length; i++) {
117
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
118
- }
119
- return useValue ? value : void 0;
120
- }
121
- ;
122
- function __propKey(x) {
123
- return typeof x === "symbol" ? x : "".concat(x);
124
- }
125
- ;
126
- function __setFunctionName(f, name, prefix) {
127
- if (typeof name === "symbol")
128
- name = name.description ? "[".concat(name.description, "]") : "";
129
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
130
- }
131
- ;
132
- function __metadata(metadataKey, metadataValue) {
133
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
134
- return Reflect.metadata(metadataKey, metadataValue);
135
- }
136
- function __awaiter(thisArg, _arguments, P, generator) {
137
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
138
- return new (P || (P = Promise))(function (resolve, reject) {
139
- function fulfilled(value) { try {
140
- step(generator.next(value));
141
- }
142
- catch (e) {
143
- reject(e);
144
- } }
145
- function rejected(value) { try {
146
- step(generator["throw"](value));
147
- }
148
- catch (e) {
149
- reject(e);
150
- } }
151
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
152
- step((generator = generator.apply(thisArg, _arguments || [])).next());
153
- });
154
- }
155
- function __generator(thisArg, body) {
156
- var _ = { label: 0, sent: function () { if (t[0] & 1)
157
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
158
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
159
- function verb(n) { return function (v) { return step([n, v]); }; }
160
- function step(op) {
161
- if (f)
162
- throw new TypeError("Generator is already executing.");
163
- while (g && (g = 0, op[0] && (_ = 0)), _)
164
- try {
165
- 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)
166
- return t;
167
- if (y = 0, t)
168
- op = [op[0] & 2, t.value];
169
- switch (op[0]) {
170
- case 0:
171
- case 1:
172
- t = op;
173
- break;
174
- case 4:
175
- _.label++;
176
- return { value: op[1], done: false };
177
- case 5:
178
- _.label++;
179
- y = op[1];
180
- op = [0];
181
- continue;
182
- case 7:
183
- op = _.ops.pop();
184
- _.trys.pop();
185
- continue;
186
- default:
187
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
188
- _ = 0;
189
- continue;
190
- }
191
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
192
- _.label = op[1];
193
- break;
194
- }
195
- if (op[0] === 6 && _.label < t[1]) {
196
- _.label = t[1];
197
- t = op;
198
- break;
199
- }
200
- if (t && _.label < t[2]) {
201
- _.label = t[2];
202
- _.ops.push(op);
203
- break;
204
- }
205
- if (t[2])
206
- _.ops.pop();
207
- _.trys.pop();
208
- continue;
209
- }
210
- op = body.call(thisArg, _);
211
- }
212
- catch (e) {
213
- op = [6, e];
214
- y = 0;
215
- }
216
- finally {
217
- f = t = 0;
218
- }
219
- if (op[0] & 5)
220
- throw op[1];
221
- return { value: op[0] ? op[1] : void 0, done: true };
222
- }
223
- }
224
- var __createBinding = Object.create ? (function (o, m, k, k2) {
225
- if (k2 === undefined)
226
- k2 = k;
227
- var desc = Object.getOwnPropertyDescriptor(m, k);
228
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
229
- desc = { enumerable: true, get: function () { return m[k]; } };
230
- }
231
- Object.defineProperty(o, k2, desc);
232
- }) : (function (o, m, k, k2) {
233
- if (k2 === undefined)
234
- k2 = k;
235
- o[k2] = m[k];
236
- });
237
- function __exportStar(m, o) {
238
- for (var p in m)
239
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
240
- __createBinding(o, m, p);
241
- }
242
- function __values(o) {
243
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
244
- if (m)
245
- return m.call(o);
246
- if (o && typeof o.length === "number")
247
- return {
248
- next: function () {
249
- if (o && i >= o.length)
250
- o = void 0;
251
- return { value: o && o[i++], done: !o };
252
- }
253
- };
254
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
255
- }
256
- function __read(o, n) {
257
- var m = typeof Symbol === "function" && o[Symbol.iterator];
258
- if (!m)
259
- return o;
260
- var i = m.call(o), r, ar = [], e;
261
- try {
262
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
263
- ar.push(r.value);
264
- }
265
- catch (error) {
266
- e = { error: error };
267
- }
268
- finally {
269
- try {
270
- if (r && !r.done && (m = i["return"]))
271
- m.call(i);
272
- }
273
- finally {
274
- if (e)
275
- throw e.error;
276
- }
277
- }
278
- return ar;
279
- }
280
- /** @deprecated */
281
- function __spread() {
282
- for (var ar = [], i = 0; i < arguments.length; i++)
283
- ar = ar.concat(__read(arguments[i]));
284
- return ar;
285
- }
286
- /** @deprecated */
287
- function __spreadArrays() {
288
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
289
- s += arguments[i].length;
290
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
291
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
292
- r[k] = a[j];
293
- return r;
294
- }
295
- function __spreadArray(to, from, pack) {
296
- if (pack || arguments.length === 2)
297
- for (var i = 0, l = from.length, ar; i < l; i++) {
298
- if (ar || !(i in from)) {
299
- if (!ar)
300
- ar = Array.prototype.slice.call(from, 0, i);
301
- ar[i] = from[i];
302
- }
303
- }
304
- return to.concat(ar || Array.prototype.slice.call(from));
305
- }
306
- function __await(v) {
307
- return this instanceof __await ? (this.v = v, this) : new __await(v);
308
- }
309
- function __asyncGenerator(thisArg, _arguments, generator) {
310
- if (!Symbol.asyncIterator)
311
- throw new TypeError("Symbol.asyncIterator is not defined.");
312
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
313
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
314
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
315
- function verb(n, f) { if (g[n]) {
316
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); };
317
- if (f)
318
- i[n] = f(i[n]);
319
- } }
320
- function resume(n, v) { try {
321
- step(g[n](v));
322
- }
323
- catch (e) {
324
- settle(q[0][3], e);
325
- } }
326
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
327
- function fulfill(value) { resume("next", value); }
328
- function reject(value) { resume("throw", value); }
329
- function settle(f, v) { if (f(v), q.shift(), q.length)
330
- resume(q[0][0], q[0][1]); }
331
- }
332
- function __asyncDelegator(o) {
333
- var i, p;
334
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
335
- 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; }
336
- }
337
- function __asyncValues(o) {
338
- if (!Symbol.asyncIterator)
339
- throw new TypeError("Symbol.asyncIterator is not defined.");
340
- var m = o[Symbol.asyncIterator], i;
341
- 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);
342
- 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); }); }; }
343
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
344
- }
345
- function __makeTemplateObject(cooked, raw) {
346
- if (Object.defineProperty) {
347
- Object.defineProperty(cooked, "raw", { value: raw });
348
- }
349
- else {
350
- cooked.raw = raw;
351
- }
352
- return cooked;
353
- }
354
- ;
355
- var __setModuleDefault = Object.create ? (function (o, v) {
356
- Object.defineProperty(o, "default", { enumerable: true, value: v });
357
- }) : function (o, v) {
358
- o["default"] = v;
359
- };
360
- function __importStar(mod) {
361
- if (mod && mod.__esModule)
362
- return mod;
363
- var result = {};
364
- if (mod != null)
365
- for (var k in mod)
366
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
367
- __createBinding(result, mod, k);
368
- __setModuleDefault(result, mod);
369
- return result;
370
- }
371
- function __importDefault(mod) {
372
- return (mod && mod.__esModule) ? mod : { default: mod };
373
- }
374
- function __classPrivateFieldGet(receiver, state, kind, f) {
375
- if (kind === "a" && !f)
376
- throw new TypeError("Private accessor was defined without a getter");
377
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
378
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
379
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
380
- }
381
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
382
- if (kind === "m")
383
- throw new TypeError("Private method is not writable");
384
- if (kind === "a" && !f)
385
- throw new TypeError("Private accessor was defined without a setter");
386
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
387
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
388
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
389
- }
390
- function __classPrivateFieldIn(state, receiver) {
391
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
392
- throw new TypeError("Cannot use 'in' operator on non-object");
393
- return typeof state === "function" ? receiver === state : state.has(receiver);
394
- }
395
- function __addDisposableResource(env, value, async) {
396
- if (value !== null && value !== void 0) {
397
- if (typeof value !== "object" && typeof value !== "function")
398
- throw new TypeError("Object expected.");
399
- var dispose, inner;
400
- if (async) {
401
- if (!Symbol.asyncDispose)
402
- throw new TypeError("Symbol.asyncDispose is not defined.");
403
- dispose = value[Symbol.asyncDispose];
404
- }
405
- if (dispose === void 0) {
406
- if (!Symbol.dispose)
407
- throw new TypeError("Symbol.dispose is not defined.");
408
- dispose = value[Symbol.dispose];
409
- if (async)
410
- inner = dispose;
411
- }
412
- if (typeof dispose !== "function")
413
- throw new TypeError("Object not disposable.");
414
- if (inner)
415
- dispose = function () { try {
416
- inner.call(this);
417
- }
418
- catch (e) {
419
- return Promise.reject(e);
420
- } };
421
- env.stack.push({ value: value, dispose: dispose, async: async });
422
- }
423
- else if (async) {
424
- env.stack.push({ async: true });
425
- }
426
- return value;
427
- }
428
- var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
429
- var e = new Error(message);
430
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
431
- };
432
- function __disposeResources(env) {
433
- function fail(e) {
434
- env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
435
- env.hasError = true;
436
- }
437
- var r, s = 0;
438
- function next() {
439
- while (r = env.stack.pop()) {
440
- try {
441
- if (!r.async && s === 1)
442
- return s = 0, env.stack.push(r), Promise.resolve().then(next);
443
- if (r.dispose) {
444
- var result = r.dispose.call(r.value);
445
- if (r.async)
446
- return s |= 2, Promise.resolve(result).then(next, function (e) { fail(e); return next(); });
447
- }
448
- else
449
- s |= 1;
450
- }
451
- catch (e) {
452
- fail(e);
453
- }
454
- }
455
- if (s === 1)
456
- return env.hasError ? Promise.reject(env.error) : Promise.resolve();
457
- if (env.hasError)
458
- throw env.error;
459
- }
460
- return next();
461
- }
462
- function __rewriteRelativeImportExtension(path, preserveJsx) {
463
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
464
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
465
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
466
- });
467
- }
468
- return path;
469
- }
470
- var tslib_es6 = {
471
- __extends: __extends,
472
- __assign: __assign,
473
- __rest: __rest,
474
- __decorate: __decorate,
475
- __param: __param,
476
- __esDecorate: __esDecorate,
477
- __runInitializers: __runInitializers,
478
- __propKey: __propKey,
479
- __setFunctionName: __setFunctionName,
480
- __metadata: __metadata,
481
- __awaiter: __awaiter,
482
- __generator: __generator,
483
- __createBinding: __createBinding,
484
- __exportStar: __exportStar,
485
- __values: __values,
486
- __read: __read,
487
- __spread: __spread,
488
- __spreadArrays: __spreadArrays,
489
- __spreadArray: __spreadArray,
490
- __await: __await,
491
- __asyncGenerator: __asyncGenerator,
492
- __asyncDelegator: __asyncDelegator,
493
- __asyncValues: __asyncValues,
494
- __makeTemplateObject: __makeTemplateObject,
495
- __importStar: __importStar,
496
- __importDefault: __importDefault,
497
- __classPrivateFieldGet: __classPrivateFieldGet,
498
- __classPrivateFieldSet: __classPrivateFieldSet,
499
- __classPrivateFieldIn: __classPrivateFieldIn,
500
- __addDisposableResource: __addDisposableResource,
501
- __disposeResources: __disposeResources,
502
- __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
503
- };
504
-
505
- /* Injection token to provide the element path modules. */
506
- var LAZY_CMPS_PATH_TOKEN = new i0.InjectionToken('ngx-lazy-cmp-registry');
507
-
508
- var NgxElementService = /** @class */ (function () {
509
- function NgxElementService(modulePaths, compiler, injector) {
510
- this.compiler = compiler;
511
- this.injector = injector;
512
- this.loadedComponents = new Map();
513
- this.elementsLoading = new Map();
514
- this.injectors = new Map();
515
- this.componentFactoryResolvers = new Map();
516
- var ELEMENT_MODULE_PATHS = new Map();
517
- modulePaths.forEach(function (route) {
518
- ELEMENT_MODULE_PATHS.set(route.selector, route);
519
- });
520
- this.componentsToLoad = ELEMENT_MODULE_PATHS;
521
- }
522
- NgxElementService.prototype.receiveContext = function (component, injector) {
523
- this.injectors.set(component, injector);
524
- this.componentFactoryResolvers.set(component, injector.get(i0.ComponentFactoryResolver));
525
- };
526
- NgxElementService.prototype.getInjector = function (component) {
527
- return this.injectors.get(component);
528
- };
529
- NgxElementService.prototype.getComponentFactoryResolver = function (component) {
530
- return this.componentFactoryResolvers.get(component);
531
- };
532
- NgxElementService.prototype.getComponentsToLoad = function () {
533
- return this.componentsToLoad;
534
- };
535
- NgxElementService.prototype.getComponentToLoad = function (selector) {
536
- // Returns observable that completes when the lazy module has been loaded.
537
- var registered = this.loadComponent(selector);
538
- return rxjs.from(registered);
539
- };
540
- /**
541
- * Allows to lazy load a component given its selector.
542
- * If the component selector has been registered, it's according module
543
- * will be fetched lazily
544
- * @param componentTag selector of the component to load
545
- */
546
- NgxElementService.prototype.loadComponent = function (componentSelector) {
547
- var _this = this;
548
- if (this.elementsLoading.has(componentSelector)) {
549
- return this.elementsLoading.get(componentSelector);
550
- }
551
- if (this.componentsToLoad.has(componentSelector)) {
552
- var cmpRegistryEntry = this.componentsToLoad.get(componentSelector);
553
- var path_1 = cmpRegistryEntry.loadChildren;
554
- var loadPromise = new Promise(function (resolve, reject) {
555
- path_1()
556
- .then(function (elementModuleOrFactory) {
557
- /**
558
- * With View Engine, the NgModule factory is created and provided when loaded.
559
- * With Ivy, only the NgModule class is provided loaded and must be compiled.
560
- * This uses the same mechanism as the deprecated `SystemJsNgModuleLoader` in
561
- * in `packages/core/src/linker/system_js_ng_module_factory_loader.ts`
562
- * to pass on the NgModuleFactory, or compile the NgModule and return its NgModuleFactory.
563
- */
564
- if (elementModuleOrFactory instanceof i0.NgModuleFactory) {
565
- return elementModuleOrFactory;
566
- }
567
- else {
568
- try {
569
- return _this.compiler.compileModuleAsync(elementModuleOrFactory);
570
- }
571
- catch (err) {
572
- // return the error
573
- reject(err);
574
- // break the promise chain
575
- throw err;
576
- }
577
- }
578
- })
579
- .then(function (moduleFactory) {
580
- var elementModuleRef = moduleFactory.create(_this.injector);
581
- var componentClass;
582
- if (typeof elementModuleRef.instance.customElementComponent === 'object') {
583
- componentClass = elementModuleRef.instance.customElementComponent[componentSelector];
584
- if (!componentClass) {
585
- // tslint:disable-next-line: no-string-throw
586
- throw "You specified multiple component elements in module " + elementModuleRef + " but there was no match for tag\n " + componentSelector + " in " + JSON.stringify(elementModuleRef.instance.customElementComponent) + ".\n Make sure the selector in the module is aligned with the one specified in the lazy module definition.";
587
- }
588
- }
589
- else {
590
- componentClass = elementModuleRef.instance.customElementComponent;
591
- }
592
- // Register injector of the lazy module.
593
- // This is needed to share the entryComponents between the lazy module and the application
594
- var moduleInjector = elementModuleRef.injector;
595
- _this.receiveContext(componentClass, moduleInjector);
596
- _this.loadedComponents.set(componentSelector, componentClass);
597
- _this.elementsLoading.delete(componentSelector);
598
- _this.componentsToLoad.delete(componentSelector);
599
- resolve({
600
- selector: componentSelector,
601
- componentClass: componentClass
602
- });
603
- })
604
- .catch(function (err) {
605
- _this.elementsLoading.delete(componentSelector);
606
- return Promise.reject(err);
607
- });
608
- });
609
- this.elementsLoading.set(componentSelector, loadPromise);
610
- return loadPromise;
611
- }
612
- else if (this.loadedComponents.has(componentSelector)) {
613
- // component already loaded
614
- return new Promise(function (resolve) {
615
- resolve({
616
- selector: componentSelector,
617
- componentClass: _this.loadedComponents.get(componentSelector)
618
- });
619
- });
620
- }
621
- else {
622
- throw new Error("Unrecognized component \"" + componentSelector + "\". Make sure it is registered in the component registry");
623
- }
624
- };
625
- return NgxElementService;
626
- }());
627
- NgxElementService.ɵprov = i0.ɵɵdefineInjectable({ factory: function NgxElementService_Factory() { return new NgxElementService(i0.ɵɵinject(LAZY_CMPS_PATH_TOKEN), i0.ɵɵinject(i0.Compiler), i0.ɵɵinject(i0.INJECTOR)); }, token: NgxElementService, providedIn: "root" });
628
- NgxElementService.decorators = [
629
- { type: i0.Injectable, args: [{
630
- providedIn: 'root'
631
- },] }
632
- ];
633
- NgxElementService.ctorParameters = function () { return [
634
- { type: Array, decorators: [{ type: i0.Inject, args: [LAZY_CMPS_PATH_TOKEN,] }] },
635
- { type: i0.Compiler },
636
- { type: i0.Injector }
637
- ]; };
638
-
639
- var NgxElementComponent = /** @class */ (function () {
640
- function NgxElementComponent(ngxElementService, elementRef) {
641
- this.ngxElementService = ngxElementService;
642
- this.elementRef = elementRef;
643
- }
644
- /**
645
- * Subscribe to event emitters of a lazy loaded and dynamically instantiated Angular component
646
- * and dispatch them as Custom Events on the NgxElementComponent that is used in a template.
647
- */
648
- NgxElementComponent.prototype.setProxiedOutputs = function (factory) {
649
- var _this = this;
650
- var eventEmitters = factory.outputs.map(function (_a) {
651
- var propName = _a.propName, templateName = _a.templateName;
652
- var emitter = _this.componentRef.instance[propName];
653
- return emitter.pipe(operators.map(function (value) { return ({ name: templateName, value: value }); }));
654
- });
655
- var outputEvents = rxjs.merge.apply(void 0, __spread(eventEmitters));
656
- this.ngElementEventsSubscription = outputEvents.subscribe(function (subscription) {
657
- var customEvent = document.createEvent('CustomEvent');
658
- customEvent.initCustomEvent(subscription.name, false, false, subscription.value);
659
- _this.elementRef.nativeElement.dispatchEvent(customEvent);
660
- });
661
- };
662
- NgxElementComponent.prototype.ngOnInit = function () {
663
- var _this = this;
664
- this.ngxElementService.getComponentToLoad(this.selector).subscribe(function (event) {
665
- _this.componentToLoad = event.componentClass;
666
- _this.componentFactoryResolver = _this.ngxElementService.getComponentFactoryResolver(_this.componentToLoad);
667
- _this.injector = _this.ngxElementService.getInjector(_this.componentToLoad);
668
- var attributes = _this.getElementAttributes();
669
- _this.createComponent(attributes);
670
- });
671
- };
672
- NgxElementComponent.prototype.createComponent = function (attributes) {
673
- this.container.clear();
674
- var factory = this.componentFactoryResolver.resolveComponentFactory(this.componentToLoad);
675
- this.refInjector = i0.ReflectiveInjector.resolveAndCreate([{ provide: this.componentToLoad, useValue: this.componentToLoad }], this.injector);
676
- this.componentRef = this.container.createComponent(factory, 0, this.refInjector);
677
- this.setAttributes(attributes);
678
- this.listenToAttributeChanges();
679
- this.setProxiedOutputs(factory);
680
- };
681
- NgxElementComponent.prototype.setAttributes = function (attributes) {
682
- var _this = this;
683
- attributes.forEach(function (attr) {
684
- _this.componentRef.instance[attr.name] = attr.value;
685
- });
686
- };
687
- NgxElementComponent.prototype.getElementAttributes = function () {
688
- var attrs = this.elementRef.nativeElement.attributes;
689
- var attributes = [];
690
- for (var attr = void 0, i = 0; i < attrs.length; i++) {
691
- attr = attrs[i];
692
- if (attr.nodeName.match('^data-')) {
693
- attributes.push({
694
- name: this.camelCaseAttribute(attr.nodeName),
695
- value: attr.nodeValue
696
- });
697
- }
698
- }
699
- return attributes;
700
- };
701
- NgxElementComponent.prototype.camelCaseAttribute = function (attribute) {
702
- var attr = attribute.replace('data-', '');
703
- var chunks = attr.split('-');
704
- if (chunks.length > 1) {
705
- return chunks[0] + chunks.slice(1).map(function (chunk) { return chunk.replace(/^\w/, function (c) { return c.toUpperCase(); }); }).join('');
706
- }
707
- return attr;
708
- };
709
- NgxElementComponent.prototype.listenToAttributeChanges = function () {
710
- var _this = this;
711
- var observer = new MutationObserver(function (mutations) {
712
- mutations.forEach(function (mutation) {
713
- if (mutation.type === 'attributes') {
714
- var attributes = _this.getElementAttributes();
715
- _this.setAttributes(attributes);
716
- }
717
- });
718
- });
719
- observer.observe(this.elementRef.nativeElement, {
720
- attributes: true
721
- });
722
- };
723
- NgxElementComponent.prototype.ngOnDestroy = function () {
724
- this.componentRef.destroy();
725
- this.ngElementEventsSubscription.unsubscribe();
726
- };
727
- return NgxElementComponent;
728
- }());
729
- NgxElementComponent.decorators = [
730
- { type: i0.Component, args: [{
731
- selector: 'lib-ngx-element',
732
- template: "\n <ng-template #container></ng-template>\n "
733
- },] }
734
- ];
735
- NgxElementComponent.ctorParameters = function () { return [
736
- { type: NgxElementService },
737
- { type: i0.ElementRef }
738
- ]; };
739
- NgxElementComponent.propDecorators = {
740
- selector: [{ type: i0.Input }],
741
- container: [{ type: i0.ViewChild, args: ['container', { read: i0.ViewContainerRef },] }]
742
- };
743
-
744
- var NgxElementModule = /** @class */ (function () {
745
- function NgxElementModule(injector) {
746
- this.injector = injector;
747
- var ngxElement = elements.createCustomElement(NgxElementComponent, { injector: injector });
748
- customElements.define('ngx-element', ngxElement);
749
- }
750
- NgxElementModule.forRoot = function (modulePaths) {
751
- return {
752
- ngModule: NgxElementModule,
753
- providers: [
754
- {
755
- provide: LAZY_CMPS_PATH_TOKEN,
756
- useValue: modulePaths
757
- }
758
- ]
759
- };
760
- };
761
- NgxElementModule.prototype.ngDoBootstrap = function () { };
762
- return NgxElementModule;
763
- }());
764
- NgxElementModule.decorators = [
765
- { type: i0.NgModule, args: [{
766
- declarations: [NgxElementComponent],
767
- entryComponents: [NgxElementComponent]
768
- },] }
769
- ];
770
- NgxElementModule.ctorParameters = function () { return [
771
- { type: i0.Injector }
772
- ]; };
773
-
774
- /*
775
- * Public API Surface of ngx-element
776
- */
777
-
778
- /**
779
- * Generated bundle index. Do not edit.
780
- */
781
-
782
- exports.NgxElementModule = NgxElementModule;
783
- exports.ɵa = NgxElementComponent;
784
- exports.ɵb = NgxElementService;
785
- exports.ɵc = LAZY_CMPS_PATH_TOKEN;
786
-
787
- Object.defineProperty(exports, '__esModule', { value: true });
788
-
789
- })));
790
- //# sourceMappingURL=zdigambar-ngx-element.umd.js.map