@ts-core/angular 11.0.88 → 11.0.89

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,9 +1,9 @@
1
1
  import { DestroyableContainer, LoadableEvent, Destroyable, IDestroyable, Loadable, LoadableStatus } from '@ts-core/common';
2
2
  import { PromiseHandler } from '@ts-core/common/promise';
3
- import { isNil, isNaN as isNaN$1, isEmpty, isFunction, assign, find, camelCase, isDate, isString, isNumber, keys, truncate, capitalize, isBoolean, findIndex } from 'lodash';
3
+ import { isNil, isNaN as isNaN$1, isEmpty, isFunction, assign, find, camelCase, isDate, isString, isNumber, keys, truncate, capitalize, isBoolean, findIndex, includes } from 'lodash';
4
4
  import { Assets } from '@ts-core/frontend/asset';
5
5
  import { takeUntil, filter as filter$1, map } from 'rxjs/operators';
6
- import { ViewContainerRef, Input, HostListener, Component, ɵɵdefineInjectable, ɵɵinject, Injectable, Directive, ElementRef, Pipe, NgModule, InjectionToken, EventEmitter, Output, TemplateRef, ComponentFactoryResolver, RendererStyleFlags2 } from '@angular/core';
6
+ import { ViewContainerRef, Input, HostListener, Component, ɵɵdefineInjectable, ɵɵinject, Injectable, Directive, ElementRef, Pipe, NgModule, InjectionToken, EventEmitter, Output, TemplateRef, ComponentFactoryResolver, RendererStyleFlags2, NgModuleFactory, Compiler, INJECTOR, Injector } from '@angular/core';
7
7
  import moment from 'moment';
8
8
  import numeral from 'numeral';
9
9
  import { MatDialogConfig, MatDialog, MatDialogModule } from '@angular/material/dialog';
@@ -39,10 +39,11 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
39
39
  import { MomentDateAdapter } from '@angular/material-moment-adapter';
40
40
  import { __awaiter } from 'tslib';
41
41
  import { ExtendedError } from '@ts-core/common/error';
42
- import { TransportTimeoutError, TransportNoConnectionError } from '@ts-core/common/transport';
43
- import { FilterableMapCollection } from '@ts-core/common/map';
42
+ import { TransportTimeoutError, TransportNoConnectionError, TransportEvent } from '@ts-core/common/transport';
43
+ import { FilterableMapCollection, MapCollection } from '@ts-core/common/map';
44
44
  import { BreakpointObserver } from '@angular/cdk/layout';
45
45
  import { NavigationStart, NavigationEnd, NavigationCancel, NavigationError, ActivatedRoute } from '@angular/router';
46
+ import { TransportLocal } from '@ts-core/common/transport/local';
46
47
 
47
48
  class ApplicationBaseComponent extends DestroyableContainer {
48
49
  // --------------------------------------------------------------------------
@@ -7834,7 +7835,7 @@ class LoginBaseService extends Loadable {
7834
7835
  yield this.logoutRequest();
7835
7836
  }
7836
7837
  catch (error) {
7837
- this.parseLogoutErrorResponse(ExtendedError.create(error));
7838
+ this.parseLogoutErrorResponse(error);
7838
7839
  }
7839
7840
  finally {
7840
7841
  this.reset();
@@ -9070,13 +9071,13 @@ class UserBaseService {
9070
9071
  //
9071
9072
  // --------------------------------------------------------------------------
9072
9073
  isUser(value) {
9073
- if (!value || !this.user) {
9074
+ if (isNil(value) || isNil(this.user)) {
9074
9075
  return false;
9075
9076
  }
9076
- if (value.hasOwnProperty('id')) {
9077
- return this.user.id === value.id;
9077
+ if (isString(value) || isNumber(value)) {
9078
+ return value === this.user.id;
9078
9079
  }
9079
- return this.user.id === value;
9080
+ return value.id === this.user.id;
9080
9081
  }
9081
9082
  userUpdate(data) {
9082
9083
  if (!this.hasUser) {
@@ -9122,11 +9123,239 @@ var UserBaseServiceEvent;
9122
9123
  UserBaseServiceEvent["LOGOUTED"] = "LOGOUTED";
9123
9124
  })(UserBaseServiceEvent || (UserBaseServiceEvent = {}));
9124
9125
 
9126
+ class LazyModuleLoader extends Loadable {
9127
+ //--------------------------------------------------------------------------
9128
+ //
9129
+ // Constructor
9130
+ //
9131
+ //--------------------------------------------------------------------------
9132
+ constructor(compiler, injector) {
9133
+ super();
9134
+ this.compiler = compiler;
9135
+ this.injector = injector;
9136
+ this._modules = new MapCollection('id');
9137
+ }
9138
+ //--------------------------------------------------------------------------
9139
+ //
9140
+ // Protected Methods
9141
+ //
9142
+ //--------------------------------------------------------------------------
9143
+ load(item) {
9144
+ return __awaiter(this, void 0, void 0, function* () {
9145
+ item.reference = yield this.loadReference(item.path);
9146
+ });
9147
+ }
9148
+ loadReference(path) {
9149
+ return __awaiter(this, void 0, void 0, function* () {
9150
+ let moduleFactory = null;
9151
+ let elementModuleOrFactory = yield path();
9152
+ if (elementModuleOrFactory instanceof NgModuleFactory) {
9153
+ moduleFactory = elementModuleOrFactory;
9154
+ }
9155
+ else {
9156
+ moduleFactory = yield this.compiler.compileModuleAsync(elementModuleOrFactory);
9157
+ }
9158
+ return moduleFactory.create(this.injector);
9159
+ });
9160
+ }
9161
+ isNeedLoad(item) {
9162
+ return isNil(item.reference);
9163
+ }
9164
+ //--------------------------------------------------------------------------
9165
+ //
9166
+ // Public Methods
9167
+ //
9168
+ //--------------------------------------------------------------------------
9169
+ loadIfNeed(id) {
9170
+ return __awaiter(this, void 0, void 0, function* () {
9171
+ let item = this.modules.get(id);
9172
+ if (isNil(item)) {
9173
+ throw new ExtendedError(`Unable to find "${id}" module: it must be registered first`);
9174
+ }
9175
+ if (!this.isNeedLoad(item)) {
9176
+ return item;
9177
+ }
9178
+ try {
9179
+ this.observer.next(new ObservableData(LoadableEvent.STARTED));
9180
+ yield this.load(item);
9181
+ }
9182
+ finally {
9183
+ this.observer.next(new ObservableData(LoadableEvent.FINISHED));
9184
+ }
9185
+ return item;
9186
+ });
9187
+ }
9188
+ destroy() {
9189
+ if (this.isDestroyed) {
9190
+ return;
9191
+ }
9192
+ super.destroy();
9193
+ if (!isNil(this._modules)) {
9194
+ this._modules.destroy();
9195
+ this._modules = null;
9196
+ }
9197
+ }
9198
+ //--------------------------------------------------------------------------
9199
+ //
9200
+ // Public Properties
9201
+ //
9202
+ //--------------------------------------------------------------------------
9203
+ get modules() {
9204
+ return this._modules;
9205
+ }
9206
+ }
9207
+ LazyModuleLoader.ɵprov = ɵɵdefineInjectable({ factory: function LazyModuleLoader_Factory() { return new LazyModuleLoader(ɵɵinject(Compiler), ɵɵinject(INJECTOR)); }, token: LazyModuleLoader, providedIn: "root" });
9208
+ LazyModuleLoader.decorators = [
9209
+ { type: Injectable, args: [{ providedIn: 'root' },] }
9210
+ ];
9211
+ LazyModuleLoader.ctorParameters = () => [
9212
+ { type: Compiler },
9213
+ { type: Injector }
9214
+ ];
9215
+
9216
+ class TransportLazyModuleLoadedEvent extends TransportEvent {
9217
+ // --------------------------------------------------------------------------
9218
+ //
9219
+ // Constructor
9220
+ //
9221
+ // --------------------------------------------------------------------------
9222
+ constructor(request) {
9223
+ super(TransportLazyModuleLoadedEvent.NAME, request);
9224
+ }
9225
+ }
9226
+ // --------------------------------------------------------------------------
9227
+ //
9228
+ // Public Static Properties
9229
+ //
9230
+ // --------------------------------------------------------------------------
9231
+ TransportLazyModuleLoadedEvent.NAME = 'TransportLazyModuleLoadedEvent';
9232
+
9233
+ class TransportLazy extends TransportLocal {
9234
+ // --------------------------------------------------------------------------
9235
+ //
9236
+ // Constructor
9237
+ //
9238
+ // --------------------------------------------------------------------------
9239
+ constructor(logger, loader, settings) {
9240
+ super(logger, settings, null);
9241
+ this.loader = loader;
9242
+ this.getDispatcher(TransportLazyModuleLoadedEvent.NAME).subscribe(event => this.moduleLoadedHandler(event.data));
9243
+ }
9244
+ // --------------------------------------------------------------------------
9245
+ //
9246
+ // Event Handlers
9247
+ //
9248
+ // --------------------------------------------------------------------------
9249
+ moduleLoadedHandler(module) {
9250
+ let item = this.loader.modules.get(module.id);
9251
+ if (isNil(item)) {
9252
+ item = this.loader.modules.add(module);
9253
+ }
9254
+ if (isNil(item.reference)) {
9255
+ item.reference = module.reference;
9256
+ }
9257
+ }
9258
+ // --------------------------------------------------------------------------
9259
+ //
9260
+ // Protected Methods
9261
+ //
9262
+ // --------------------------------------------------------------------------
9263
+ dispatchCommand(command, options, isNeedReply) {
9264
+ const _super = Object.create(null, {
9265
+ dispatchCommand: { get: () => super.dispatchCommand }
9266
+ });
9267
+ return __awaiter(this, void 0, void 0, function* () {
9268
+ let item = this.getModuleByCommand(command.name);
9269
+ console.log(command.name, item);
9270
+ if (!isNil(item)) {
9271
+ yield this.loader.loadIfNeed(item.id);
9272
+ }
9273
+ _super.dispatchCommand.call(this, command, options, isNeedReply);
9274
+ });
9275
+ }
9276
+ getModuleByCommand(name) {
9277
+ if (this.loader.modules.length === 0) {
9278
+ return null;
9279
+ }
9280
+ for (let item of this.loader.modules.collection) {
9281
+ if (isEmpty(item.commands)) {
9282
+ continue;
9283
+ }
9284
+ if (includes(item.commands, name)) {
9285
+ return item;
9286
+ }
9287
+ }
9288
+ return null;
9289
+ }
9290
+ getModuleByEvent(name) {
9291
+ if (isNil(this.loader) || this.loader.modules.length === 0) {
9292
+ return null;
9293
+ }
9294
+ for (let item of this.loader.modules.collection) {
9295
+ if (isEmpty(item.events)) {
9296
+ continue;
9297
+ }
9298
+ if (includes(item.events, name)) {
9299
+ return item;
9300
+ }
9301
+ }
9302
+ return null;
9303
+ }
9304
+ // --------------------------------------------------------------------------
9305
+ //
9306
+ // Public Methods
9307
+ //
9308
+ // --------------------------------------------------------------------------
9309
+ dispatch(event) {
9310
+ let item = this.getModuleByEvent(event.name);
9311
+ if (!isNil(this.loader) && !isNil(item)) {
9312
+ this.loader.loadIfNeed(item.id).then(() => super.dispatch(event));
9313
+ }
9314
+ else {
9315
+ super.dispatch(event);
9316
+ }
9317
+ }
9318
+ destroy() {
9319
+ if (this.isDestroyed) {
9320
+ return;
9321
+ }
9322
+ super.destroy();
9323
+ this.loader = null;
9324
+ }
9325
+ }
9326
+
9327
+ class TransportLazyModule {
9328
+ //--------------------------------------------------------------------------
9329
+ //
9330
+ // Constructor
9331
+ //
9332
+ //--------------------------------------------------------------------------
9333
+ constructor(reference, transport) {
9334
+ this.reference = reference;
9335
+ this.transport = transport;
9336
+ this.moduleLoadedDispatch();
9337
+ }
9338
+ //--------------------------------------------------------------------------
9339
+ //
9340
+ // Protected Methods
9341
+ //
9342
+ //--------------------------------------------------------------------------
9343
+ moduleLoadedDispatch() {
9344
+ this.transport.dispatch(new TransportLazyModuleLoadedEvent(this));
9345
+ }
9346
+ get events() {
9347
+ return new Array();
9348
+ }
9349
+ get commands() {
9350
+ return new Array();
9351
+ }
9352
+ }
9353
+
9125
9354
  /* ======= */
9126
9355
 
9127
9356
  /**
9128
9357
  * Generated bundle index. Do not edit.
9129
9358
  */
9130
9359
 
9131
- export { APPLICATION_INJECTOR, ApplicationBaseComponent, ApplicationComponent, ApplicationComponent2, AspectRatioResizeDirective, AssetBackgroundDirective, AssetBackgroundPipe, AssetIconPipe, AssetImagePipe, AssetModule, AutoScrollBottomDirective, BootstrapBreakpoint, BootstrapBreakpointService, BootstrapBreakpointServiceEvent, BottomSheetService, COOKIE_OPTIONS, CamelCasePipe, CanDeactivateGuard, CdkTableBaseComponent, CdkTableDataSource, CdkTableFilterableMapCollection, CdkTablePaginableBookmarkMapCollection, CdkTablePaginableMapCollection, ClickToCopyDirective, ClickToSelectDirective, CookieModule, CookieOptions, CookieService, Direction, FinancePipe, FocusDirective, FocusManager, FormElementAsync, FormElementSync, HTMLContentTitleDirective, INotification, INotificationContent, IUser, IVICommonOptions, IWindow, IWindowContent, InfiniteScrollDirective, LANGUAGE_OPTIONS, LanguageDirective, LanguageHasDirective, LanguageMatPaginatorIntl, LanguageModule, LanguageMomentDateAdapter, LanguagePipe, LanguagePipeHas, LanguagePipeHasPure, LanguagePipePure, LanguageRequireResolver, LanguageResolver, LanguageSelectorComponent, ListItem, ListItems, LoginBaseService, LoginBaseServiceEvent, LoginGuard, LoginRedirectResolver, LoginRequireResolver, LoginResolver, MenuItem, MenuItemBase, MenuItems, MenuListComponent, MessageBaseComponent, MomentDateAdaptivePipe, MomentDateFromNowPipe, MomentDatePipe, MomentTimePipe, NavigationMenuItem, NgModelErrorPipe, NotificationConfig, NotificationEvent, NotificationFactory, NotificationModule, NotificationService, NotificationServiceEvent, PipeBaseService, PrettifyPipe, PropertiesManager, QuestionEvent, QuestionManager, QuestionMode, ResizeDirective, ResizeManager, RouterBaseService, SanitizePipe, ScrollDirective, SelectListComponent, SelectListItem, SelectListItems, SelectOnFocusDirective, ShellBaseComponent, StartCasePipe, THEME_OPTIONS, TabGroupComponent, ThemeAssetBackgroundDirective, ThemeAssetDirective, ThemeAssetImageDirective, ThemeModule, ThemeStyleDirective, ThemeStyleHoverDirective, ThemeToggleDirective, TimePipe, TruncatePipe, UserBaseService, UserBaseServiceEvent, VICommonModule, VIComponentModule, VI_ANGULAR_OPTIONS, ViewUtil, WindowAlign, WindowBase, WindowConfig, WindowEvent, WindowFactory, WindowImpl, WindowModule, WindowService, WindowServiceEvent, cookieServiceFactory, languageServiceFactory, loggerServiceFactory, themeAssetServiceFactory, themeServiceFactory, AssetFilePipe as ɵa, AssetSoundPipe as ɵb, AssetVideoPipe as ɵc, WindowDragAreaDirective as ɵd, WindowQuestionComponent as ɵe, WindowQuestionBaseComponent as ɵf, WindowCloseElementComponent as ɵg, WindowElement as ɵh, WindowResizeElementComponent as ɵi, WindowMinimizeElementComponent as ɵj, NotificationComponent as ɵk, NotificationQuestionBaseComponent as ɵl, BottomSheetModule as ɵm, BottomSheetCloseElementComponent as ɵn, CdkTableColumnValuePipe as ɵo, CdkTableColumnClassNamePipe as ɵp, CdkTableColumnStyleNamePipe as ɵq, CdkTableRowStyleNamePipe as ɵr, CdkTableRowClassNamePipe as ɵs, CdkTableCellClassNamePipe as ɵt, CdkTablePaginableComponent as ɵu, CdkTableFilterableComponent as ɵv, ValueAccessor as ɵw };
9360
+ export { APPLICATION_INJECTOR, ApplicationBaseComponent, ApplicationComponent, ApplicationComponent2, AspectRatioResizeDirective, AssetBackgroundDirective, AssetBackgroundPipe, AssetIconPipe, AssetImagePipe, AssetModule, AutoScrollBottomDirective, BootstrapBreakpoint, BootstrapBreakpointService, BootstrapBreakpointServiceEvent, BottomSheetService, COOKIE_OPTIONS, CamelCasePipe, CanDeactivateGuard, CdkTableBaseComponent, CdkTableDataSource, CdkTableFilterableMapCollection, CdkTablePaginableBookmarkMapCollection, CdkTablePaginableMapCollection, ClickToCopyDirective, ClickToSelectDirective, CookieModule, CookieOptions, CookieService, Direction, FinancePipe, FocusDirective, FocusManager, FormElementAsync, FormElementSync, HTMLContentTitleDirective, INotification, INotificationContent, IUser, IVICommonOptions, IWindow, IWindowContent, InfiniteScrollDirective, LANGUAGE_OPTIONS, LanguageDirective, LanguageHasDirective, LanguageMatPaginatorIntl, LanguageModule, LanguageMomentDateAdapter, LanguagePipe, LanguagePipeHas, LanguagePipeHasPure, LanguagePipePure, LanguageRequireResolver, LanguageResolver, LanguageSelectorComponent, LazyModuleLoader, ListItem, ListItems, LoginBaseService, LoginBaseServiceEvent, LoginGuard, LoginRedirectResolver, LoginRequireResolver, LoginResolver, MenuItem, MenuItemBase, MenuItems, MenuListComponent, MessageBaseComponent, MomentDateAdaptivePipe, MomentDateFromNowPipe, MomentDatePipe, MomentTimePipe, NavigationMenuItem, NgModelErrorPipe, NotificationConfig, NotificationEvent, NotificationFactory, NotificationModule, NotificationService, NotificationServiceEvent, PipeBaseService, PrettifyPipe, PropertiesManager, QuestionEvent, QuestionManager, QuestionMode, ResizeDirective, ResizeManager, RouterBaseService, SanitizePipe, ScrollDirective, SelectListComponent, SelectListItem, SelectListItems, SelectOnFocusDirective, ShellBaseComponent, StartCasePipe, THEME_OPTIONS, TabGroupComponent, ThemeAssetBackgroundDirective, ThemeAssetDirective, ThemeAssetImageDirective, ThemeModule, ThemeStyleDirective, ThemeStyleHoverDirective, ThemeToggleDirective, TimePipe, TransportLazy, TransportLazyModule, TransportLazyModuleLoadedEvent, TruncatePipe, UserBaseService, UserBaseServiceEvent, VICommonModule, VIComponentModule, VI_ANGULAR_OPTIONS, ViewUtil, WindowAlign, WindowBase, WindowConfig, WindowEvent, WindowFactory, WindowImpl, WindowModule, WindowService, WindowServiceEvent, cookieServiceFactory, languageServiceFactory, loggerServiceFactory, themeAssetServiceFactory, themeServiceFactory, AssetFilePipe as ɵa, AssetSoundPipe as ɵb, AssetVideoPipe as ɵc, WindowDragAreaDirective as ɵd, WindowQuestionComponent as ɵe, WindowQuestionBaseComponent as ɵf, WindowCloseElementComponent as ɵg, WindowElement as ɵh, WindowResizeElementComponent as ɵi, WindowMinimizeElementComponent as ɵj, NotificationComponent as ɵk, NotificationQuestionBaseComponent as ɵl, BottomSheetModule as ɵm, BottomSheetCloseElementComponent as ɵn, CdkTableColumnValuePipe as ɵo, CdkTableColumnClassNamePipe as ɵp, CdkTableColumnStyleNamePipe as ɵq, CdkTableRowStyleNamePipe as ɵr, CdkTableRowClassNamePipe as ɵs, CdkTableCellClassNamePipe as ɵt, CdkTablePaginableComponent as ɵu, CdkTableFilterableComponent as ɵv, ValueAccessor as ɵw };
9132
9361
  //# sourceMappingURL=ts-core-angular.js.map