@ngxs/store 3.7.4-dev.master-38cbcac → 3.7.4-dev.master-80a3014
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/bundles/ngxs-store-internals.umd.js +0 -241
- package/bundles/ngxs-store-internals.umd.js.map +1 -1
- package/bundles/ngxs-store-internals.umd.min.js +1 -1
- package/bundles/ngxs-store-internals.umd.min.js.map +1 -1
- package/bundles/ngxs-store.umd.js +32 -105
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.min.js +1 -1
- package/bundles/ngxs-store.umd.min.js.map +1 -1
- package/esm2015/internals/index.js +1 -2
- package/esm2015/internals/ngxs-store-internals.js +2 -2
- package/esm2015/ngxs-store.js +5 -4
- package/esm2015/src/decorators/select/select-factory.js +2 -6
- package/esm2015/src/decorators/select/select.js +11 -39
- package/esm2015/src/decorators/select/symbols.js +11 -55
- package/esm2015/src/internal/dispatcher.js +8 -6
- package/esm2015/src/module.js +3 -1
- package/esm2015/src/modules/ngxs-root.module.js +5 -8
- package/esm5/internals/index.js +1 -2
- package/esm5/internals/ngxs-store-internals.js +2 -2
- package/esm5/ngxs-store.js +5 -4
- package/esm5/src/decorators/select/select-factory.js +2 -6
- package/esm5/src/decorators/select/select.js +5 -40
- package/esm5/src/decorators/select/symbols.js +11 -55
- package/esm5/src/internal/dispatcher.js +8 -6
- package/esm5/src/module.js +3 -1
- package/esm5/src/modules/ngxs-root.module.js +4 -7
- package/fesm2015/ngxs-store-internals.js +2 -240
- package/fesm2015/ngxs-store-internals.js.map +1 -1
- package/fesm2015/ngxs-store.js +34 -101
- package/fesm2015/ngxs-store.js.map +1 -1
- package/fesm5/ngxs-store-internals.js +2 -240
- package/fesm5/ngxs-store-internals.js.map +1 -1
- package/fesm5/ngxs-store.js +27 -101
- package/fesm5/ngxs-store.js.map +1 -1
- package/internals/index.d.ts +0 -1
- package/internals/ngxs-store-internals.metadata.json +1 -1
- package/ngxs-store.d.ts +5 -4
- package/ngxs-store.metadata.json +1 -1
- package/package.json +1 -1
- package/src/decorators/select/select.d.ts +1 -0
- package/src/decorators/select/symbols.d.ts +2 -6
- package/src/modules/ngxs-root.module.d.ts +2 -2
- package/esm2015/internals/decorator-injector-adapter.js +0 -242
- package/esm5/internals/decorator-injector-adapter.js +0 -242
- package/internals/decorator-injector-adapter.d.ts +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable, InjectionToken
|
|
1
|
+
import { Injectable, InjectionToken } from '@angular/core';
|
|
2
2
|
import { ReplaySubject } from 'rxjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -203,244 +203,6 @@ var NGXS_STATE_CONTEXT_FACTORY = new InjectionToken('Internals.StateContextFacto
|
|
|
203
203
|
*/
|
|
204
204
|
var NGXS_STATE_FACTORY = new InjectionToken('Internals.StateFactory');
|
|
205
205
|
|
|
206
|
-
/**
|
|
207
|
-
* @fileoverview added by tsickle
|
|
208
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
209
|
-
*/
|
|
210
|
-
// Angular doesn't export `NG_FACTORY_DEF`.
|
|
211
|
-
/** @type {?} */
|
|
212
|
-
var NG_FACTORY_DEF = 'ɵfac';
|
|
213
|
-
// A `Symbol` which is used to save the `Injector` onto the class instance.
|
|
214
|
-
/** @type {?} */
|
|
215
|
-
var InjectorInstance = Symbol('InjectorInstance');
|
|
216
|
-
// A `Symbol` which is used to determine if factory has been decorated previously or not.
|
|
217
|
-
/** @type {?} */
|
|
218
|
-
var FactoryHasBeenDecorated = Symbol('FactoryHasBeenDecorated');
|
|
219
|
-
// A `Symbol` which is used to save the notifier on the class instance. The `InjectorInstance` cannot
|
|
220
|
-
// be retrieved within the `constructor` since it's set after the `factory()` is called.
|
|
221
|
-
/** @type {?} */
|
|
222
|
-
var InjectorNotifier = Symbol('InjectorNotifier');
|
|
223
|
-
/**
|
|
224
|
-
* @record
|
|
225
|
-
*/
|
|
226
|
-
function PrototypeWithInjectorNotifier() { }
|
|
227
|
-
if (false) {
|
|
228
|
-
/* Skipping unnamed member:
|
|
229
|
-
[InjectorNotifier]?: ReplaySubject<boolean>;*/
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* @param {?} target
|
|
233
|
-
* @return {?}
|
|
234
|
-
*/
|
|
235
|
-
function ensureInjectorNotifierIsCaptured(target) {
|
|
236
|
-
if (target[InjectorNotifier]) {
|
|
237
|
-
return (/** @type {?} */ (target[InjectorNotifier]));
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
/** @type {?} */
|
|
241
|
-
var injectorNotifier$_1 = new ReplaySubject(1);
|
|
242
|
-
Object.defineProperty(target, InjectorNotifier, {
|
|
243
|
-
get: (/**
|
|
244
|
-
* @return {?}
|
|
245
|
-
*/
|
|
246
|
-
function () { return injectorNotifier$_1; })
|
|
247
|
-
});
|
|
248
|
-
return injectorNotifier$_1;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
252
|
-
/**
|
|
253
|
-
* @param {?} target
|
|
254
|
-
* @return {?}
|
|
255
|
-
*/
|
|
256
|
-
function ensureLocalInjectorCaptured(target) {
|
|
257
|
-
if (FactoryHasBeenDecorated in target.constructor.prototype) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
/** @type {?} */
|
|
261
|
-
var constructor = target.constructor;
|
|
262
|
-
// The factory is set later by the Angular compiler in JIT mode, and we're not able to patch the factory now.
|
|
263
|
-
// We can't use any asynchronous code like `Promise.resolve().then(...)` since this is not functional in unit
|
|
264
|
-
// tests that are being run in `SyncTestZoneSpec`.
|
|
265
|
-
// Given the following example:
|
|
266
|
-
// @Component()
|
|
267
|
-
// class BaseComponent {}
|
|
268
|
-
// @Component()
|
|
269
|
-
// class MainComponent extends BaseComponent {
|
|
270
|
-
// @Select(AnimalsState) animals$: Observable<string[]>;
|
|
271
|
-
// }
|
|
272
|
-
// In this example, the factory will be defined for the `BaseComponent`, but will not be defined for the `MainComponent`.
|
|
273
|
-
// If we try to decorate the factory immediately, we'll get `Cannot redefine property` exception when Angular will try to define
|
|
274
|
-
// an original factory for the `MainComponent`.
|
|
275
|
-
// Note: the factory is defined statically in the code in AOT mode.
|
|
276
|
-
// AppComponent.ɵfac = function AppComponent_Factory(t) {
|
|
277
|
-
// return new (t || AppComponent)();
|
|
278
|
-
// };
|
|
279
|
-
// __decorate([Select], AppComponent.prototype, 'animals$', void 0);
|
|
280
|
-
/** @type {?} */
|
|
281
|
-
var isJitModeOrIsAngularInTestMode = isAngularInTestMode() || !!(ɵglobal.ng && ɵglobal.ng.ɵcompilerFacade);
|
|
282
|
-
// If we're in development mode AND we're running unit tests or there's a compiler facade exposed,
|
|
283
|
-
// then patch `Object.defineProperty`. The compiler facade is exposed in JIT mode.
|
|
284
|
-
if (ngDevMode && isJitModeOrIsAngularInTestMode) {
|
|
285
|
-
patchObjectDefineProperty();
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
decorateFactory(constructor);
|
|
289
|
-
}
|
|
290
|
-
target.constructor.prototype[FactoryHasBeenDecorated] = true;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* @template T
|
|
294
|
-
* @param {?} instance
|
|
295
|
-
* @param {?} token
|
|
296
|
-
* @return {?}
|
|
297
|
-
*/
|
|
298
|
-
function localInject(instance, token) {
|
|
299
|
-
/** @type {?} */
|
|
300
|
-
var injector = instance[InjectorInstance];
|
|
301
|
-
return injector ? injector.get(token) : null;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* @param {?} constructor
|
|
305
|
-
* @return {?}
|
|
306
|
-
*/
|
|
307
|
-
function decorateFactory(constructor) {
|
|
308
|
-
/** @type {?} */
|
|
309
|
-
var factory = constructor[NG_FACTORY_DEF];
|
|
310
|
-
if (typeof factory !== 'function') {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
// Let's try to get any definition.
|
|
314
|
-
// Caretaker note: this will be compatible only with Angular 9+, since Angular 9 is the first
|
|
315
|
-
// Ivy-stable version. Previously definition properties were named differently (e.g. `ngComponentDef`).
|
|
316
|
-
/** @type {?} */
|
|
317
|
-
var def = constructor.ɵprov || constructor.ɵpipe || constructor.ɵcmp || constructor.ɵdir;
|
|
318
|
-
/** @type {?} */
|
|
319
|
-
var decoratedFactory = (/**
|
|
320
|
-
* @return {?}
|
|
321
|
-
*/
|
|
322
|
-
function () {
|
|
323
|
-
/** @type {?} */
|
|
324
|
-
var instance = factory();
|
|
325
|
-
// Caretaker note: `inject()` won't work here.
|
|
326
|
-
// We can use the `directiveInject` only during the component
|
|
327
|
-
// construction, since Angular captures the currently active injector.
|
|
328
|
-
// We're not able to use this function inside the getter (when the `selectorId` property is
|
|
329
|
-
// requested for the first time), since the currently active injector will be null.
|
|
330
|
-
instance[InjectorInstance] = ɵɵdirectiveInject(
|
|
331
|
-
// We're using `INJECTOR` token except of the `Injector` class since the compiler
|
|
332
|
-
// throws: `Cannot assign an abstract constructor type to a non-abstract constructor type.`.
|
|
333
|
-
// Caretaker note: that this is the same way of getting the injector.
|
|
334
|
-
INJECTOR);
|
|
335
|
-
// Caretaker note: the notifier will be available only if consumers call the `ensureInjectorNotifierIsCaptured()`.
|
|
336
|
-
/** @type {?} */
|
|
337
|
-
var injectorNotifier$ = instance[InjectorNotifier];
|
|
338
|
-
if (injectorNotifier$) {
|
|
339
|
-
injectorNotifier$.next(true);
|
|
340
|
-
injectorNotifier$.complete();
|
|
341
|
-
}
|
|
342
|
-
return instance;
|
|
343
|
-
});
|
|
344
|
-
// If we've found any definition then it's enough to override the `def.factory` since Angular
|
|
345
|
-
// code uses the `def.factory` and then fallbacks to `ɵfac`.
|
|
346
|
-
if (def) {
|
|
347
|
-
def.factory = decoratedFactory;
|
|
348
|
-
}
|
|
349
|
-
// `@NgModule()` doesn't doesn't have definition factory, also providers have definitions but Angular
|
|
350
|
-
// still uses the `ɵfac`.
|
|
351
|
-
Object.defineProperty(constructor, NG_FACTORY_DEF, {
|
|
352
|
-
get: (/**
|
|
353
|
-
* @return {?}
|
|
354
|
-
*/
|
|
355
|
-
function () { return decoratedFactory; })
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
// Note: this function will be tree-shaken in production.
|
|
359
|
-
var ɵ0 = /**
|
|
360
|
-
* @return {?}
|
|
361
|
-
*/
|
|
362
|
-
function () {
|
|
363
|
-
/** @type {?} */
|
|
364
|
-
var objectDefinePropertyPatched = false;
|
|
365
|
-
return (/**
|
|
366
|
-
* @return {?}
|
|
367
|
-
*/
|
|
368
|
-
function () {
|
|
369
|
-
if (objectDefinePropertyPatched) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
/** @type {?} */
|
|
373
|
-
var defineProperty = Object.defineProperty;
|
|
374
|
-
// We should not be patching globals, but there's no other way to know when it's appropriate
|
|
375
|
-
// to decorate the original factory. There're different edge cases, e.g., when the class extends
|
|
376
|
-
// another class, the factory will be defined for the base class but not for the child class.
|
|
377
|
-
// The patching will be done only during the development and in JIT mode.
|
|
378
|
-
Object.defineProperty = (/**
|
|
379
|
-
* @template T
|
|
380
|
-
* @param {?} object
|
|
381
|
-
* @param {?} propertyKey
|
|
382
|
-
* @param {?} attributes
|
|
383
|
-
* @return {?}
|
|
384
|
-
*/
|
|
385
|
-
function (object, propertyKey, attributes) {
|
|
386
|
-
// Angular calls `Object.defineProperty(target, 'ɵfac', { get: ..., configurable: true })` when defining a factory function.
|
|
387
|
-
// We only want to intercept `ɵfac` key.
|
|
388
|
-
// If the property is `ɵfac` AND `configurable` equals `true`, then let's call the original
|
|
389
|
-
// implementation and then decorate the factory.
|
|
390
|
-
// // https://github.com/angular/angular/blob/3a60063a54d850c50ce962a8a39ce01cfee71398/packages/core/src/render3/jit/pipe.ts#L21-L39
|
|
391
|
-
if (propertyKey !== NG_FACTORY_DEF ||
|
|
392
|
-
// We also call `Object.defineProperty(target, 'ɵfac', ...)`, but we don't set `configurable` property.
|
|
393
|
-
(propertyKey === NG_FACTORY_DEF && !attributes.configurable)) {
|
|
394
|
-
return (/** @type {?} */ (defineProperty.call(this, object, propertyKey, attributes)));
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
// If the property is `ɵfac` AND `configurable` equals `true`, then let's call the original
|
|
398
|
-
// implementation and then decorate the factory.
|
|
399
|
-
defineProperty.call(this, object, propertyKey, attributes);
|
|
400
|
-
decorateFactory((/** @type {?} */ (((/** @type {?} */ (object))))));
|
|
401
|
-
return object;
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
objectDefinePropertyPatched = true;
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
/** @type {?} */
|
|
408
|
-
var patchObjectDefineProperty = ((ɵ0))();
|
|
409
|
-
/**
|
|
410
|
-
* @record
|
|
411
|
-
*/
|
|
412
|
-
function Definition() { }
|
|
413
|
-
if (false) {
|
|
414
|
-
/** @type {?} */
|
|
415
|
-
Definition.prototype.factory;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* @record
|
|
419
|
-
*/
|
|
420
|
-
function ConstructorWithDefinitionAndFactory() { }
|
|
421
|
-
if (false) {
|
|
422
|
-
/** @type {?|undefined} */
|
|
423
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵprov;
|
|
424
|
-
/** @type {?|undefined} */
|
|
425
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵpipe;
|
|
426
|
-
/** @type {?|undefined} */
|
|
427
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵcmp;
|
|
428
|
-
/** @type {?|undefined} */
|
|
429
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵdir;
|
|
430
|
-
/* Skipping unnamed member:
|
|
431
|
-
[NG_FACTORY_DEF]?: Factory;*/
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* @record
|
|
435
|
-
*/
|
|
436
|
-
function PrivateInstance() { }
|
|
437
|
-
if (false) {
|
|
438
|
-
/* Skipping unnamed member:
|
|
439
|
-
[InjectorInstance]?: Injector;*/
|
|
440
|
-
/* Skipping unnamed member:
|
|
441
|
-
[InjectorNotifier]?: ReplaySubject<boolean>;*/
|
|
442
|
-
}
|
|
443
|
-
|
|
444
206
|
/**
|
|
445
207
|
* @fileoverview added by tsickle
|
|
446
208
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -451,5 +213,5 @@ if (false) {
|
|
|
451
213
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
452
214
|
*/
|
|
453
215
|
|
|
454
|
-
export { INITIAL_STATE_TOKEN, InitialState, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, NgxsBootstrapper,
|
|
216
|
+
export { INITIAL_STATE_TOKEN, InitialState, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, NgxsBootstrapper, isAngularInTestMode, memoize };
|
|
455
217
|
//# sourceMappingURL=ngxs-store-internals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals.js","sources":["ng://@ngxs/store/internals/angular.ts","ng://@ngxs/store/internals/ngxs-bootstrapper.ts","ng://@ngxs/store/internals/memoize.ts","ng://@ngxs/store/internals/initial-state.ts","ng://@ngxs/store/internals/internal-tokens.ts","ng://@ngxs/store/internals/decorator-injector-adapter.ts"],"sourcesContent":["declare const __karma__: unknown;\ndeclare const jasmine: unknown;\ndeclare const jest: unknown;\ndeclare const Mocha: unknown;\n\nexport function isAngularInTestMode(): boolean {\n // This is safe to check for these properties in the following way since `typeof` does not\n // throw an exception if the value does not exist in the scope.\n // We should not try to read these values from the global scope (e.g. `ɵglobal` from the `@angular/core`).\n // This is related to how these frameworks compile and execute modules. E.g. Jest wraps the module into\n // its internal code where `jest` variable exists in the scope. It cannot be read from the global scope, e.g.\n // this will return undefined `global.jest`, but `jest` will not equal undefined.\n return (\n typeof __karma__ !== 'undefined' ||\n typeof jasmine !== 'undefined' ||\n typeof jest !== 'undefined' ||\n typeof Mocha !== 'undefined'\n );\n}\n","import { Injectable } from '@angular/core';\nimport { Observable, ReplaySubject } from 'rxjs';\n\n@Injectable()\nexport class NgxsBootstrapper {\n /**\n * Use `ReplaySubject`, thus we can get cached value even if the stream is completed\n */\n private bootstrap$ = new ReplaySubject<boolean>(1);\n\n get appBootstrapped$(): Observable<boolean> {\n return this.bootstrap$.asObservable();\n }\n\n /**\n * This event will be emitted after attaching `ComponentRef` of the root component\n * to the tree of views, that's a signal that application has been fully rendered\n */\n bootstrap(): void {\n this.bootstrap$.next(true);\n this.bootstrap$.complete();\n }\n}\n","function defaultEqualityCheck(a: any, b: any) {\n return a === b;\n}\n\nfunction areArgumentsShallowlyEqual(\n equalityCheck: (a: any, b: any) => boolean,\n prev: IArguments | null,\n next: IArguments | null\n) {\n if (prev === null || next === null || prev.length !== next.length) {\n return false;\n }\n\n // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.\n const length = prev.length;\n for (let i = 0; i < length; i++) {\n if (!equalityCheck(prev[i], next[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Memoize a function on its last inputs only.\n * Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js\n *\n * @ignore\n */\nexport function memoize<T extends (...args: any[]) => any>(\n func: T,\n equalityCheck = defaultEqualityCheck\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n lastResult = (<Function>func).apply(null, arguments);\n }\n\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function() {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { InjectionToken } from '@angular/core';\nimport { PlainObject } from './symbols';\n\nexport const INITIAL_STATE_TOKEN = new InjectionToken<any>('INITIAL_STATE_TOKEN');\n\nexport class InitialState {\n private static value: PlainObject = {};\n\n public static set(state: PlainObject) {\n this.value = state;\n }\n\n public static pop(): PlainObject {\n const state: PlainObject = this.value;\n this.value = {};\n return state;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * @see StateContextFactory as it's referenced by this token to be accessed by plugins internally\n */\nexport const NGXS_STATE_CONTEXT_FACTORY: InjectionToken<any> = new InjectionToken(\n 'Internals.StateContextFactory'\n);\n\n/**\n * @see StateFactory as it's referenced by this token to be accessed by plugins internally\n */\nexport const NGXS_STATE_FACTORY: InjectionToken<any> = new InjectionToken(\n 'Internals.StateFactory'\n);\n","import {\n InjectionToken,\n Injector,\n INJECTOR,\n Type,\n ɵglobal,\n ɵɵdirectiveInject\n} from '@angular/core';\nimport { ReplaySubject } from 'rxjs';\n\nimport { isAngularInTestMode } from './angular';\n\n// Will be provided through Terser global definitions by Angular CLI\n// during the production build. This is how Angular does tree-shaking internally.\ndeclare const ngDevMode: boolean;\n\n// Angular doesn't export `NG_FACTORY_DEF`.\nconst NG_FACTORY_DEF = 'ɵfac';\n\n// A `Symbol` which is used to save the `Injector` onto the class instance.\nconst InjectorInstance: unique symbol = Symbol('InjectorInstance');\n\n// A `Symbol` which is used to determine if factory has been decorated previously or not.\nconst FactoryHasBeenDecorated: unique symbol = Symbol('FactoryHasBeenDecorated');\n\n// A `Symbol` which is used to save the notifier on the class instance. The `InjectorInstance` cannot\n// be retrieved within the `constructor` since it's set after the `factory()` is called.\nconst InjectorNotifier: unique symbol = Symbol('InjectorNotifier');\n\ninterface PrototypeWithInjectorNotifier extends Object {\n [InjectorNotifier]?: ReplaySubject<boolean>;\n}\n\nexport function ensureInjectorNotifierIsCaptured(\n target: PrototypeWithInjectorNotifier | PrivateInstance\n): ReplaySubject<boolean> {\n if (target[InjectorNotifier]) {\n return target[InjectorNotifier]!;\n } else {\n const injectorNotifier$ = new ReplaySubject<boolean>(1);\n Object.defineProperty(target, InjectorNotifier, {\n get: () => injectorNotifier$\n });\n return injectorNotifier$;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function ensureLocalInjectorCaptured(target: Object): void {\n if (FactoryHasBeenDecorated in target.constructor.prototype) {\n return;\n }\n\n const constructor: ConstructorWithDefinitionAndFactory = target.constructor;\n\n // The factory is set later by the Angular compiler in JIT mode, and we're not able to patch the factory now.\n // We can't use any asynchronous code like `Promise.resolve().then(...)` since this is not functional in unit\n // tests that are being run in `SyncTestZoneSpec`.\n // Given the following example:\n // @Component()\n // class BaseComponent {}\n // @Component()\n // class MainComponent extends BaseComponent {\n // @Select(AnimalsState) animals$: Observable<string[]>;\n // }\n // In this example, the factory will be defined for the `BaseComponent`, but will not be defined for the `MainComponent`.\n // If we try to decorate the factory immediately, we'll get `Cannot redefine property` exception when Angular will try to define\n // an original factory for the `MainComponent`.\n\n // Note: the factory is defined statically in the code in AOT mode.\n // AppComponent.ɵfac = function AppComponent_Factory(t) {\n // return new (t || AppComponent)();\n // };\n // __decorate([Select], AppComponent.prototype, 'animals$', void 0);\n\n const isJitModeOrIsAngularInTestMode =\n isAngularInTestMode() || !!(ɵglobal.ng && ɵglobal.ng.ɵcompilerFacade);\n\n // If we're in development mode AND we're running unit tests or there's a compiler facade exposed,\n // then patch `Object.defineProperty`. The compiler facade is exposed in JIT mode.\n if (ngDevMode && isJitModeOrIsAngularInTestMode) {\n patchObjectDefineProperty();\n } else {\n decorateFactory(constructor);\n }\n\n target.constructor.prototype[FactoryHasBeenDecorated] = true;\n}\n\nexport function localInject<T>(\n instance: PrivateInstance,\n token: InjectionToken<T> | Type<T>\n): T | null {\n const injector: Injector | undefined = instance[InjectorInstance];\n return injector ? injector.get(token) : null;\n}\n\nfunction decorateFactory(constructor: ConstructorWithDefinitionAndFactory): void {\n const factory = constructor[NG_FACTORY_DEF];\n\n if (typeof factory !== 'function') {\n return;\n }\n\n // Let's try to get any definition.\n // Caretaker note: this will be compatible only with Angular 9+, since Angular 9 is the first\n // Ivy-stable version. Previously definition properties were named differently (e.g. `ngComponentDef`).\n const def = constructor.ɵprov || constructor.ɵpipe || constructor.ɵcmp || constructor.ɵdir;\n\n const decoratedFactory = () => {\n const instance = factory();\n // Caretaker note: `inject()` won't work here.\n // We can use the `directiveInject` only during the component\n // construction, since Angular captures the currently active injector.\n // We're not able to use this function inside the getter (when the `selectorId` property is\n // requested for the first time), since the currently active injector will be null.\n instance[InjectorInstance] = ɵɵdirectiveInject(\n // We're using `INJECTOR` token except of the `Injector` class since the compiler\n // throws: `Cannot assign an abstract constructor type to a non-abstract constructor type.`.\n // Caretaker note: that this is the same way of getting the injector.\n INJECTOR\n );\n\n // Caretaker note: the notifier will be available only if consumers call the `ensureInjectorNotifierIsCaptured()`.\n const injectorNotifier$ = instance[InjectorNotifier];\n if (injectorNotifier$) {\n injectorNotifier$.next(true);\n injectorNotifier$.complete();\n }\n\n return instance;\n };\n\n // If we've found any definition then it's enough to override the `def.factory` since Angular\n // code uses the `def.factory` and then fallbacks to `ɵfac`.\n if (def) {\n def.factory = decoratedFactory;\n }\n\n // `@NgModule()` doesn't doesn't have definition factory, also providers have definitions but Angular\n // still uses the `ɵfac`.\n Object.defineProperty(constructor, NG_FACTORY_DEF, {\n get: () => decoratedFactory\n });\n}\n\n// Note: this function will be tree-shaken in production.\nconst patchObjectDefineProperty = (() => {\n let objectDefinePropertyPatched = false;\n return () => {\n if (objectDefinePropertyPatched) {\n return;\n }\n const defineProperty = Object.defineProperty;\n // We should not be patching globals, but there's no other way to know when it's appropriate\n // to decorate the original factory. There're different edge cases, e.g., when the class extends\n // another class, the factory will be defined for the base class but not for the child class.\n // The patching will be done only during the development and in JIT mode.\n Object.defineProperty = function<T>(\n object: T,\n propertyKey: PropertyKey,\n attributes: PropertyDescriptor & ThisType<any>\n ) {\n // Angular calls `Object.defineProperty(target, 'ɵfac', { get: ..., configurable: true })` when defining a factory function.\n // We only want to intercept `ɵfac` key.\n // If the property is `ɵfac` AND `configurable` equals `true`, then let's call the original\n // implementation and then decorate the factory.\n // // https://github.com/angular/angular/blob/3a60063a54d850c50ce962a8a39ce01cfee71398/packages/core/src/render3/jit/pipe.ts#L21-L39\n if (\n propertyKey !== NG_FACTORY_DEF ||\n // We also call `Object.defineProperty(target, 'ɵfac', ...)`, but we don't set `configurable` property.\n (propertyKey === NG_FACTORY_DEF && !attributes.configurable)\n ) {\n return defineProperty.call(this, object, propertyKey, attributes) as T;\n } else {\n // If the property is `ɵfac` AND `configurable` equals `true`, then let's call the original\n // implementation and then decorate the factory.\n defineProperty.call(this, object, propertyKey, attributes);\n decorateFactory((object as unknown) as ConstructorWithDefinitionAndFactory);\n return object;\n }\n };\n objectDefinePropertyPatched = true;\n };\n})();\n\n// We could've used `ɵɵFactoryDef` but we try to be backwards-compatible,\n// since it's not exported in older Angular versions.\ntype Factory = () => PrivateInstance;\n\n// We could've used `ɵɵInjectableDef`, `ɵɵPipeDef`, etc. We try to be backwards-compatible\n// since they're not exported in older Angular versions.\ninterface Definition {\n factory: Factory | null;\n}\n\ninterface ConstructorWithDefinitionAndFactory extends Function {\n // Provider definition for the `@Injectable()` class.\n ɵprov?: Definition;\n // Pipe definition for the `@Pipe()` class.\n ɵpipe?: Definition;\n // Component definition for the `@Component()` class.\n ɵcmp?: Definition;\n // Directive definition for the `@Directive()` class.\n ɵdir?: Definition;\n [NG_FACTORY_DEF]?: Factory;\n}\n\ninterface PrivateInstance {\n [InjectorInstance]?: Injector;\n [InjectorNotifier]?: ReplaySubject<boolean>;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKA,SAAgB,mBAAmB;;;;;;;IAOjC,QACE,OAAO,SAAS,KAAK,WAAW;QAChC,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,IAAI,KAAK,WAAW;QAC3B,OAAO,KAAK,KAAK,WAAW,EAC5B;CACH;;;;;;AClBD;IAGA;;;;QAKU,eAAU,GAAG,IAAI,aAAa,CAA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;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-store-internals.js","sources":["ng://@ngxs/store/internals/angular.ts","ng://@ngxs/store/internals/ngxs-bootstrapper.ts","ng://@ngxs/store/internals/memoize.ts","ng://@ngxs/store/internals/initial-state.ts","ng://@ngxs/store/internals/internal-tokens.ts"],"sourcesContent":["declare const __karma__: unknown;\ndeclare const jasmine: unknown;\ndeclare const jest: unknown;\ndeclare const Mocha: unknown;\n\nexport function isAngularInTestMode(): boolean {\n // This is safe to check for these properties in the following way since `typeof` does not\n // throw an exception if the value does not exist in the scope.\n // We should not try to read these values from the global scope (e.g. `ɵglobal` from the `@angular/core`).\n // This is related to how these frameworks compile and execute modules. E.g. Jest wraps the module into\n // its internal code where `jest` variable exists in the scope. It cannot be read from the global scope, e.g.\n // this will return undefined `global.jest`, but `jest` will not equal undefined.\n return (\n typeof __karma__ !== 'undefined' ||\n typeof jasmine !== 'undefined' ||\n typeof jest !== 'undefined' ||\n typeof Mocha !== 'undefined'\n );\n}\n","import { Injectable } from '@angular/core';\nimport { Observable, ReplaySubject } from 'rxjs';\n\n@Injectable()\nexport class NgxsBootstrapper {\n /**\n * Use `ReplaySubject`, thus we can get cached value even if the stream is completed\n */\n private bootstrap$ = new ReplaySubject<boolean>(1);\n\n get appBootstrapped$(): Observable<boolean> {\n return this.bootstrap$.asObservable();\n }\n\n /**\n * This event will be emitted after attaching `ComponentRef` of the root component\n * to the tree of views, that's a signal that application has been fully rendered\n */\n bootstrap(): void {\n this.bootstrap$.next(true);\n this.bootstrap$.complete();\n }\n}\n","function defaultEqualityCheck(a: any, b: any) {\n return a === b;\n}\n\nfunction areArgumentsShallowlyEqual(\n equalityCheck: (a: any, b: any) => boolean,\n prev: IArguments | null,\n next: IArguments | null\n) {\n if (prev === null || next === null || prev.length !== next.length) {\n return false;\n }\n\n // Do this in a for loop (and not a `forEach` or an `every`) so we can determine equality as fast as possible.\n const length = prev.length;\n for (let i = 0; i < length; i++) {\n if (!equalityCheck(prev[i], next[i])) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Memoize a function on its last inputs only.\n * Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js\n *\n * @ignore\n */\nexport function memoize<T extends (...args: any[]) => any>(\n func: T,\n equalityCheck = defaultEqualityCheck\n): T {\n let lastArgs: IArguments | null = null;\n let lastResult: any = null;\n // we reference arguments instead of spreading them for performance reasons\n function memoized() {\n if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) {\n // apply arguments instead of spreading for performance.\n lastResult = (<Function>func).apply(null, arguments);\n }\n\n lastArgs = arguments;\n return lastResult;\n }\n (<any>memoized).reset = function() {\n // The hidden (for now) ability to reset the memoization\n lastArgs = null;\n lastResult = null;\n };\n return memoized as T;\n}\n","import { InjectionToken } from '@angular/core';\nimport { PlainObject } from './symbols';\n\nexport const INITIAL_STATE_TOKEN = new InjectionToken<any>('INITIAL_STATE_TOKEN');\n\nexport class InitialState {\n private static value: PlainObject = {};\n\n public static set(state: PlainObject) {\n this.value = state;\n }\n\n public static pop(): PlainObject {\n const state: PlainObject = this.value;\n this.value = {};\n return state;\n }\n}\n","import { InjectionToken } from '@angular/core';\n\n/**\n * @see StateContextFactory as it's referenced by this token to be accessed by plugins internally\n */\nexport const NGXS_STATE_CONTEXT_FACTORY: InjectionToken<any> = new InjectionToken(\n 'Internals.StateContextFactory'\n);\n\n/**\n * @see StateFactory as it's referenced by this token to be accessed by plugins internally\n */\nexport const NGXS_STATE_FACTORY: InjectionToken<any> = new InjectionToken(\n 'Internals.StateFactory'\n);\n"],"names":[],"mappings":";;;;;;;;;;AAKA,SAAgB,mBAAmB;;;;;;;IAOjC,QACE,OAAO,SAAS,KAAK,WAAW;QAChC,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,IAAI,KAAK,WAAW;QAC3B,OAAO,KAAK,KAAK,WAAW,EAC5B;CACH;;;;;;AClBD;IAGA;;;;QAKU,eAAU,GAAG,IAAI,aAAa,CAAU,CA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,SAAS,CAAC,CAAC;SACtD;QAED,QAAQ,GAAG,SAAS,CAAC;QACrB,OAAO,UAAU,CAAC;KACnB;IACD,oBAAM,QAAQ,IAAE,KAAK;;;IAAG;;QAEtB,QAAQ,GAAG,IAAI,CAAC;QAChB,UAAU,GAAG,IAAI,CAAC;KACnB,CAAA,CAAC;IACF,0BAAO,QAAQ,GAAM;CACtB;;;;;;ACpDD;AAGA,IAAa,mBAAmB,GAAG,IAAI,cAAc,CAAM,qBAAqB,CAAC;AAEjF;IAAA;KAYC;;;;;IATe,gBAAG;;;;IAAjB,UAAkB,KAAkB;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KACpB;;;;IAEa,gBAAG;;;IAAjB;;YACQ,KAAK,GAAgB,IAAI,CAAC,KAAK;QACrC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;KACd;IAVc,kBAAK,GAAgB,EAAE,CAAC;IAWzC,mBAAC;CAZD,IAYC;;;;;;IAXC,mBAAuC;;;;;;;ACNzC;;;;AAKA,IAAa,0BAA0B,GAAwB,IAAI,cAAc,CAC/E,+BAA+B,CAChC;;;;;AAKD,IAAa,kBAAkB,GAAwB,IAAI,cAAc,CACvE,wBAAwB,CACzB;;;;;;;;;;;;;;"}
|
package/fesm5/ngxs-store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __spread, __extends, __values } from 'tslib';
|
|
2
2
|
import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, Optional, SkipSelf, ErrorHandler, Injector, ɵivyEnabled, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
3
|
-
import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState
|
|
3
|
+
import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
|
|
4
4
|
import { isPlatformServer } from '@angular/common';
|
|
5
5
|
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from } from 'rxjs';
|
|
6
6
|
import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap, publishReplay, refCount, distinctUntilChanged } from 'rxjs/operators';
|
|
@@ -1916,12 +1916,14 @@ var InternalDispatcher = /** @class */ (function () {
|
|
|
1916
1916
|
*/
|
|
1917
1917
|
function (action) {
|
|
1918
1918
|
var _this = this;
|
|
1919
|
-
|
|
1920
|
-
var type = getActionTypeFromInstance(action);
|
|
1921
|
-
if (!type) {
|
|
1919
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1922
1920
|
/** @type {?} */
|
|
1923
|
-
var
|
|
1924
|
-
|
|
1921
|
+
var type = getActionTypeFromInstance(action);
|
|
1922
|
+
if (!type) {
|
|
1923
|
+
/** @type {?} */
|
|
1924
|
+
var error = new Error("This action doesn't have a type property: " + action.constructor.name);
|
|
1925
|
+
return throwError(error);
|
|
1926
|
+
}
|
|
1925
1927
|
}
|
|
1926
1928
|
/** @type {?} */
|
|
1927
1929
|
var prevState = this._stateStream.getValue();
|
|
@@ -3707,14 +3709,13 @@ var SelectFactory = /** @class */ (function () {
|
|
|
3707
3709
|
SelectFactory.store = null;
|
|
3708
3710
|
SelectFactory.config = null;
|
|
3709
3711
|
SelectFactory.decorators = [
|
|
3710
|
-
{ type: Injectable
|
|
3712
|
+
{ type: Injectable }
|
|
3711
3713
|
];
|
|
3712
3714
|
/** @nocollapse */
|
|
3713
3715
|
SelectFactory.ctorParameters = function () { return [
|
|
3714
3716
|
{ type: Store },
|
|
3715
3717
|
{ type: NgxsConfig }
|
|
3716
3718
|
]; };
|
|
3717
|
-
/** @nocollapse */ SelectFactory.ngInjectableDef = defineInjectable({ factory: function SelectFactory_Factory() { return new SelectFactory(inject(Store), inject(NgxsConfig)); }, token: SelectFactory, providedIn: "root" });
|
|
3718
3719
|
return SelectFactory;
|
|
3719
3720
|
}());
|
|
3720
3721
|
if (false) {
|
|
@@ -3787,11 +3788,8 @@ if (false) {
|
|
|
3787
3788
|
* @ignore
|
|
3788
3789
|
*/
|
|
3789
3790
|
var NgxsRootModule = /** @class */ (function () {
|
|
3790
|
-
function NgxsRootModule(factory, internalStateOperations, _store,
|
|
3791
|
+
function NgxsRootModule(factory, internalStateOperations, _store, _select, states, lifecycleStateManager) {
|
|
3791
3792
|
if (states === void 0) { states = []; }
|
|
3792
|
-
// If the user is running View Engine then we create the `SelectFactory` instance,
|
|
3793
|
-
// otherwise it'll be tree-shaken away in Ivy.
|
|
3794
|
-
!ɵivyEnabled && injector.get(SelectFactory);
|
|
3795
3793
|
// Add stores to the state graph and return their defaults
|
|
3796
3794
|
/** @type {?} */
|
|
3797
3795
|
var results = factory.addAndReturnDefaults(states);
|
|
@@ -3809,7 +3807,7 @@ var NgxsRootModule = /** @class */ (function () {
|
|
|
3809
3807
|
{ type: StateFactory },
|
|
3810
3808
|
{ type: InternalStateOperations },
|
|
3811
3809
|
{ type: Store },
|
|
3812
|
-
{ type:
|
|
3810
|
+
{ type: SelectFactory },
|
|
3813
3811
|
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [ROOT_STATE_TOKEN,] }] },
|
|
3814
3812
|
{ type: LifecycleStateManager }
|
|
3815
3813
|
]; };
|
|
@@ -3916,6 +3914,7 @@ var NgxsModule = /** @class */ (function () {
|
|
|
3916
3914
|
InternalNgxsExecutionStrategy,
|
|
3917
3915
|
Store,
|
|
3918
3916
|
StateStream,
|
|
3917
|
+
SelectFactory,
|
|
3919
3918
|
PluginManager
|
|
3920
3919
|
], states, NgxsModule.ngxsTokenProviders(states, options))
|
|
3921
3920
|
};
|
|
@@ -4194,37 +4193,30 @@ var DOLLAR_CHAR_CODE = 36;
|
|
|
4194
4193
|
/**
|
|
4195
4194
|
* @template T
|
|
4196
4195
|
* @param {?} selector
|
|
4197
|
-
* @param {?} store
|
|
4198
4196
|
* @return {?}
|
|
4199
4197
|
*/
|
|
4200
|
-
function createSelectObservable(selector
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
: createSelectObservableViewEngine(selector);
|
|
4198
|
+
function createSelectObservable(selector) {
|
|
4199
|
+
if (!SelectFactory.store) {
|
|
4200
|
+
throwSelectFactoryNotConnectedError();
|
|
4201
|
+
}
|
|
4202
|
+
return (/** @type {?} */ (SelectFactory.store)).select(selector);
|
|
4206
4203
|
}
|
|
4207
4204
|
/**
|
|
4208
|
-
* @param {?} config
|
|
4209
4205
|
* @param {?} name
|
|
4210
4206
|
* @param {?=} rawSelector
|
|
4211
4207
|
* @param {?=} paths
|
|
4212
4208
|
* @return {?}
|
|
4213
4209
|
*/
|
|
4214
|
-
function createSelectorFn(
|
|
4210
|
+
function createSelectorFn(name, rawSelector, paths) {
|
|
4215
4211
|
if (paths === void 0) { paths = []; }
|
|
4216
|
-
rawSelector = rawSelector
|
|
4217
|
-
if (typeof rawSelector
|
|
4218
|
-
return rawSelector;
|
|
4219
|
-
}
|
|
4220
|
-
else {
|
|
4212
|
+
rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
|
|
4213
|
+
if (typeof rawSelector === 'string') {
|
|
4221
4214
|
/** @type {?} */
|
|
4222
4215
|
var propsArray = paths.length
|
|
4223
4216
|
? __spread([rawSelector], paths) : rawSelector.split('.');
|
|
4224
|
-
return
|
|
4225
|
-
? createSelectorFnIvy(propsArray, config)
|
|
4226
|
-
: createSelectorFnViewEngine(propsArray);
|
|
4217
|
+
return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
|
|
4227
4218
|
}
|
|
4219
|
+
return rawSelector;
|
|
4228
4220
|
}
|
|
4229
4221
|
/**
|
|
4230
4222
|
* \@example If `foo$` => make it just `foo`
|
|
@@ -4238,42 +4230,6 @@ function removeDollarAtTheEnd(name) {
|
|
|
4238
4230
|
var dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
|
|
4239
4231
|
return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
|
|
4240
4232
|
}
|
|
4241
|
-
/**
|
|
4242
|
-
* @template T
|
|
4243
|
-
* @param {?} selector
|
|
4244
|
-
* @param {?} store
|
|
4245
|
-
* @return {?}
|
|
4246
|
-
*/
|
|
4247
|
-
function createSelectObservableIvy(selector, store) {
|
|
4248
|
-
return ngDevMode && !store ? throwSelectFactoryNotConnectedError() : (/** @type {?} */ (store)).select(selector);
|
|
4249
|
-
}
|
|
4250
|
-
/**
|
|
4251
|
-
* @template T
|
|
4252
|
-
* @param {?} selector
|
|
4253
|
-
* @return {?}
|
|
4254
|
-
*/
|
|
4255
|
-
function createSelectObservableViewEngine(selector) {
|
|
4256
|
-
return SelectFactory.store
|
|
4257
|
-
? SelectFactory.store.select(selector)
|
|
4258
|
-
: throwSelectFactoryNotConnectedError();
|
|
4259
|
-
}
|
|
4260
|
-
/**
|
|
4261
|
-
* @param {?} propsArray
|
|
4262
|
-
* @param {?} config
|
|
4263
|
-
* @return {?}
|
|
4264
|
-
*/
|
|
4265
|
-
function createSelectorFnIvy(propsArray, config) {
|
|
4266
|
-
return ngDevMode && !config
|
|
4267
|
-
? throwSelectFactoryNotConnectedError()
|
|
4268
|
-
: propGetter(propsArray, (/** @type {?} */ (config)));
|
|
4269
|
-
}
|
|
4270
|
-
/**
|
|
4271
|
-
* @param {?} propsArray
|
|
4272
|
-
* @return {?}
|
|
4273
|
-
*/
|
|
4274
|
-
function createSelectorFnViewEngine(propsArray) {
|
|
4275
|
-
return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
|
|
4276
|
-
}
|
|
4277
4233
|
|
|
4278
4234
|
/**
|
|
4279
4235
|
* @fileoverview added by tsickle
|
|
@@ -4281,6 +4237,7 @@ function createSelectorFnViewEngine(propsArray) {
|
|
|
4281
4237
|
*/
|
|
4282
4238
|
/**
|
|
4283
4239
|
* Decorator for selecting a slice of state from the store.
|
|
4240
|
+
* @deprecated
|
|
4284
4241
|
* @template T
|
|
4285
4242
|
* @param {?=} rawSelector
|
|
4286
4243
|
* @param {...?} paths
|
|
@@ -4298,17 +4255,13 @@ function Select(rawSelector) {
|
|
|
4298
4255
|
*/
|
|
4299
4256
|
function (target, key) {
|
|
4300
4257
|
var _a;
|
|
4258
|
+
console.warn("\n The @Select decorator has been deprecated due to the following reasons:\n 1) Lack of type-safety (compare to 'store.select()')\n 2) Not compatible with server-side rendering because it uses a global 'Store' instance, which might change between renders\n 3) Not compatible with module federation\n Consider replacing it the with store.select.\n ");
|
|
4301
4259
|
/** @type {?} */
|
|
4302
4260
|
var name = key.toString();
|
|
4303
4261
|
/** @type {?} */
|
|
4304
4262
|
var selectorId = "__" + name + "__selector";
|
|
4305
4263
|
/** @type {?} */
|
|
4306
|
-
var selector =
|
|
4307
|
-
/** @type {?} */
|
|
4308
|
-
var injectorNotifier$ = null;
|
|
4309
|
-
if (ɵivyEnabled) {
|
|
4310
|
-
injectorNotifier$ = ensureInjectorNotifierIsCaptured(target);
|
|
4311
|
-
}
|
|
4264
|
+
var selector = createSelectorFn(name, rawSelector, paths);
|
|
4312
4265
|
Object.defineProperties(target, (_a = {},
|
|
4313
4266
|
_a[selectorId] = {
|
|
4314
4267
|
writable: true,
|
|
@@ -4322,37 +4275,10 @@ function Select(rawSelector) {
|
|
|
4322
4275
|
* @return {?}
|
|
4323
4276
|
*/
|
|
4324
4277
|
function () {
|
|
4325
|
-
|
|
4326
|
-
if (this[selectorId]) {
|
|
4327
|
-
return this[selectorId];
|
|
4328
|
-
}
|
|
4329
|
-
// The `localInject` will be tree-shaken away in apps that
|
|
4330
|
-
// still use the View Engine.
|
|
4331
|
-
if (ɵivyEnabled) {
|
|
4332
|
-
this[selectorId] = (/** @type {?} */ (injectorNotifier$)).pipe(mergeMap((/**
|
|
4333
|
-
* @return {?}
|
|
4334
|
-
*/
|
|
4335
|
-
function () {
|
|
4336
|
-
/** @type {?} */
|
|
4337
|
-
var store = localInject(_this, Store);
|
|
4338
|
-
/** @type {?} */
|
|
4339
|
-
var config = localInject(_this, NgxsConfig);
|
|
4340
|
-
selector = selector || createSelectorFn(config, name, rawSelector, paths);
|
|
4341
|
-
return createSelectObservable(selector, store);
|
|
4342
|
-
})));
|
|
4343
|
-
}
|
|
4344
|
-
else {
|
|
4345
|
-
selector = selector || createSelectorFn(null, name, rawSelector, paths);
|
|
4346
|
-
this[selectorId] = createSelectObservable(selector, null);
|
|
4347
|
-
}
|
|
4348
|
-
return this[selectorId];
|
|
4278
|
+
return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
|
|
4349
4279
|
}
|
|
4350
4280
|
},
|
|
4351
4281
|
_a));
|
|
4352
|
-
// Keep this `if` guard here so the below stuff will be tree-shaken away in apps that still use the View Engine.
|
|
4353
|
-
if (ɵivyEnabled) {
|
|
4354
|
-
ensureLocalInjectorCaptured(target);
|
|
4355
|
-
}
|
|
4356
4282
|
});
|
|
4357
4283
|
}
|
|
4358
4284
|
|
|
@@ -4581,5 +4507,5 @@ if (false) {
|
|
|
4581
4507
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4582
4508
|
*/
|
|
4583
4509
|
|
|
4584
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, ensureStoreMetadata as
|
|
4510
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, SelectFactory as ɵr, ensureStoreMetadata as ɵt, getStoreMetadata as ɵu, ensureSelectorMetadata as ɵv, getSelectorMetadata as ɵw, LifecycleStateManager as ɵx, NgxsFeatureModule as ɵy };
|
|
4585
4511
|
//# sourceMappingURL=ngxs-store.js.map
|