@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
|
/**
|
|
@@ -178,244 +178,6 @@ const NGXS_STATE_CONTEXT_FACTORY = new InjectionToken('Internals.StateContextFac
|
|
|
178
178
|
*/
|
|
179
179
|
const NGXS_STATE_FACTORY = new InjectionToken('Internals.StateFactory');
|
|
180
180
|
|
|
181
|
-
/**
|
|
182
|
-
* @fileoverview added by tsickle
|
|
183
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
184
|
-
*/
|
|
185
|
-
// Angular doesn't export `NG_FACTORY_DEF`.
|
|
186
|
-
/** @type {?} */
|
|
187
|
-
const NG_FACTORY_DEF = 'ɵfac';
|
|
188
|
-
// A `Symbol` which is used to save the `Injector` onto the class instance.
|
|
189
|
-
/** @type {?} */
|
|
190
|
-
const InjectorInstance = Symbol('InjectorInstance');
|
|
191
|
-
// A `Symbol` which is used to determine if factory has been decorated previously or not.
|
|
192
|
-
/** @type {?} */
|
|
193
|
-
const FactoryHasBeenDecorated = Symbol('FactoryHasBeenDecorated');
|
|
194
|
-
// A `Symbol` which is used to save the notifier on the class instance. The `InjectorInstance` cannot
|
|
195
|
-
// be retrieved within the `constructor` since it's set after the `factory()` is called.
|
|
196
|
-
/** @type {?} */
|
|
197
|
-
const InjectorNotifier = Symbol('InjectorNotifier');
|
|
198
|
-
/**
|
|
199
|
-
* @record
|
|
200
|
-
*/
|
|
201
|
-
function PrototypeWithInjectorNotifier() { }
|
|
202
|
-
if (false) {
|
|
203
|
-
/* Skipping unnamed member:
|
|
204
|
-
[InjectorNotifier]?: ReplaySubject<boolean>;*/
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @param {?} target
|
|
208
|
-
* @return {?}
|
|
209
|
-
*/
|
|
210
|
-
function ensureInjectorNotifierIsCaptured(target) {
|
|
211
|
-
if (target[InjectorNotifier]) {
|
|
212
|
-
return (/** @type {?} */ (target[InjectorNotifier]));
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
/** @type {?} */
|
|
216
|
-
const injectorNotifier$ = new ReplaySubject(1);
|
|
217
|
-
Object.defineProperty(target, InjectorNotifier, {
|
|
218
|
-
get: (/**
|
|
219
|
-
* @return {?}
|
|
220
|
-
*/
|
|
221
|
-
() => injectorNotifier$)
|
|
222
|
-
});
|
|
223
|
-
return injectorNotifier$;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
227
|
-
/**
|
|
228
|
-
* @param {?} target
|
|
229
|
-
* @return {?}
|
|
230
|
-
*/
|
|
231
|
-
function ensureLocalInjectorCaptured(target) {
|
|
232
|
-
if (FactoryHasBeenDecorated in target.constructor.prototype) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
/** @type {?} */
|
|
236
|
-
const constructor = target.constructor;
|
|
237
|
-
// The factory is set later by the Angular compiler in JIT mode, and we're not able to patch the factory now.
|
|
238
|
-
// We can't use any asynchronous code like `Promise.resolve().then(...)` since this is not functional in unit
|
|
239
|
-
// tests that are being run in `SyncTestZoneSpec`.
|
|
240
|
-
// Given the following example:
|
|
241
|
-
// @Component()
|
|
242
|
-
// class BaseComponent {}
|
|
243
|
-
// @Component()
|
|
244
|
-
// class MainComponent extends BaseComponent {
|
|
245
|
-
// @Select(AnimalsState) animals$: Observable<string[]>;
|
|
246
|
-
// }
|
|
247
|
-
// In this example, the factory will be defined for the `BaseComponent`, but will not be defined for the `MainComponent`.
|
|
248
|
-
// If we try to decorate the factory immediately, we'll get `Cannot redefine property` exception when Angular will try to define
|
|
249
|
-
// an original factory for the `MainComponent`.
|
|
250
|
-
// Note: the factory is defined statically in the code in AOT mode.
|
|
251
|
-
// AppComponent.ɵfac = function AppComponent_Factory(t) {
|
|
252
|
-
// return new (t || AppComponent)();
|
|
253
|
-
// };
|
|
254
|
-
// __decorate([Select], AppComponent.prototype, 'animals$', void 0);
|
|
255
|
-
/** @type {?} */
|
|
256
|
-
const isJitModeOrIsAngularInTestMode = isAngularInTestMode() || !!(ɵglobal.ng && ɵglobal.ng.ɵcompilerFacade);
|
|
257
|
-
// If we're in development mode AND we're running unit tests or there's a compiler facade exposed,
|
|
258
|
-
// then patch `Object.defineProperty`. The compiler facade is exposed in JIT mode.
|
|
259
|
-
if (ngDevMode && isJitModeOrIsAngularInTestMode) {
|
|
260
|
-
patchObjectDefineProperty();
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
decorateFactory(constructor);
|
|
264
|
-
}
|
|
265
|
-
target.constructor.prototype[FactoryHasBeenDecorated] = true;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* @template T
|
|
269
|
-
* @param {?} instance
|
|
270
|
-
* @param {?} token
|
|
271
|
-
* @return {?}
|
|
272
|
-
*/
|
|
273
|
-
function localInject(instance, token) {
|
|
274
|
-
/** @type {?} */
|
|
275
|
-
const injector = instance[InjectorInstance];
|
|
276
|
-
return injector ? injector.get(token) : null;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* @param {?} constructor
|
|
280
|
-
* @return {?}
|
|
281
|
-
*/
|
|
282
|
-
function decorateFactory(constructor) {
|
|
283
|
-
/** @type {?} */
|
|
284
|
-
const factory = constructor[NG_FACTORY_DEF];
|
|
285
|
-
if (typeof factory !== 'function') {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
// Let's try to get any definition.
|
|
289
|
-
// Caretaker note: this will be compatible only with Angular 9+, since Angular 9 is the first
|
|
290
|
-
// Ivy-stable version. Previously definition properties were named differently (e.g. `ngComponentDef`).
|
|
291
|
-
/** @type {?} */
|
|
292
|
-
const def = constructor.ɵprov || constructor.ɵpipe || constructor.ɵcmp || constructor.ɵdir;
|
|
293
|
-
/** @type {?} */
|
|
294
|
-
const decoratedFactory = (/**
|
|
295
|
-
* @return {?}
|
|
296
|
-
*/
|
|
297
|
-
() => {
|
|
298
|
-
/** @type {?} */
|
|
299
|
-
const instance = factory();
|
|
300
|
-
// Caretaker note: `inject()` won't work here.
|
|
301
|
-
// We can use the `directiveInject` only during the component
|
|
302
|
-
// construction, since Angular captures the currently active injector.
|
|
303
|
-
// We're not able to use this function inside the getter (when the `selectorId` property is
|
|
304
|
-
// requested for the first time), since the currently active injector will be null.
|
|
305
|
-
instance[InjectorInstance] = ɵɵdirectiveInject(
|
|
306
|
-
// We're using `INJECTOR` token except of the `Injector` class since the compiler
|
|
307
|
-
// throws: `Cannot assign an abstract constructor type to a non-abstract constructor type.`.
|
|
308
|
-
// Caretaker note: that this is the same way of getting the injector.
|
|
309
|
-
INJECTOR);
|
|
310
|
-
// Caretaker note: the notifier will be available only if consumers call the `ensureInjectorNotifierIsCaptured()`.
|
|
311
|
-
/** @type {?} */
|
|
312
|
-
const injectorNotifier$ = instance[InjectorNotifier];
|
|
313
|
-
if (injectorNotifier$) {
|
|
314
|
-
injectorNotifier$.next(true);
|
|
315
|
-
injectorNotifier$.complete();
|
|
316
|
-
}
|
|
317
|
-
return instance;
|
|
318
|
-
});
|
|
319
|
-
// If we've found any definition then it's enough to override the `def.factory` since Angular
|
|
320
|
-
// code uses the `def.factory` and then fallbacks to `ɵfac`.
|
|
321
|
-
if (def) {
|
|
322
|
-
def.factory = decoratedFactory;
|
|
323
|
-
}
|
|
324
|
-
// `@NgModule()` doesn't doesn't have definition factory, also providers have definitions but Angular
|
|
325
|
-
// still uses the `ɵfac`.
|
|
326
|
-
Object.defineProperty(constructor, NG_FACTORY_DEF, {
|
|
327
|
-
get: (/**
|
|
328
|
-
* @return {?}
|
|
329
|
-
*/
|
|
330
|
-
() => decoratedFactory)
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
// Note: this function will be tree-shaken in production.
|
|
334
|
-
const ɵ0 = /**
|
|
335
|
-
* @return {?}
|
|
336
|
-
*/
|
|
337
|
-
() => {
|
|
338
|
-
/** @type {?} */
|
|
339
|
-
let objectDefinePropertyPatched = false;
|
|
340
|
-
return (/**
|
|
341
|
-
* @return {?}
|
|
342
|
-
*/
|
|
343
|
-
() => {
|
|
344
|
-
if (objectDefinePropertyPatched) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
/** @type {?} */
|
|
348
|
-
const defineProperty = Object.defineProperty;
|
|
349
|
-
// We should not be patching globals, but there's no other way to know when it's appropriate
|
|
350
|
-
// to decorate the original factory. There're different edge cases, e.g., when the class extends
|
|
351
|
-
// another class, the factory will be defined for the base class but not for the child class.
|
|
352
|
-
// The patching will be done only during the development and in JIT mode.
|
|
353
|
-
Object.defineProperty = (/**
|
|
354
|
-
* @template T
|
|
355
|
-
* @param {?} object
|
|
356
|
-
* @param {?} propertyKey
|
|
357
|
-
* @param {?} attributes
|
|
358
|
-
* @return {?}
|
|
359
|
-
*/
|
|
360
|
-
function (object, propertyKey, attributes) {
|
|
361
|
-
// Angular calls `Object.defineProperty(target, 'ɵfac', { get: ..., configurable: true })` when defining a factory function.
|
|
362
|
-
// We only want to intercept `ɵfac` key.
|
|
363
|
-
// If the property is `ɵfac` AND `configurable` equals `true`, then let's call the original
|
|
364
|
-
// implementation and then decorate the factory.
|
|
365
|
-
// // https://github.com/angular/angular/blob/3a60063a54d850c50ce962a8a39ce01cfee71398/packages/core/src/render3/jit/pipe.ts#L21-L39
|
|
366
|
-
if (propertyKey !== NG_FACTORY_DEF ||
|
|
367
|
-
// We also call `Object.defineProperty(target, 'ɵfac', ...)`, but we don't set `configurable` property.
|
|
368
|
-
(propertyKey === NG_FACTORY_DEF && !attributes.configurable)) {
|
|
369
|
-
return (/** @type {?} */ (defineProperty.call(this, object, propertyKey, attributes)));
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
// If the property is `ɵfac` AND `configurable` equals `true`, then let's call the original
|
|
373
|
-
// implementation and then decorate the factory.
|
|
374
|
-
defineProperty.call(this, object, propertyKey, attributes);
|
|
375
|
-
decorateFactory((/** @type {?} */ (((/** @type {?} */ (object))))));
|
|
376
|
-
return object;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
objectDefinePropertyPatched = true;
|
|
380
|
-
});
|
|
381
|
-
};
|
|
382
|
-
/** @type {?} */
|
|
383
|
-
const patchObjectDefineProperty = ((ɵ0))();
|
|
384
|
-
/**
|
|
385
|
-
* @record
|
|
386
|
-
*/
|
|
387
|
-
function Definition() { }
|
|
388
|
-
if (false) {
|
|
389
|
-
/** @type {?} */
|
|
390
|
-
Definition.prototype.factory;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* @record
|
|
394
|
-
*/
|
|
395
|
-
function ConstructorWithDefinitionAndFactory() { }
|
|
396
|
-
if (false) {
|
|
397
|
-
/** @type {?|undefined} */
|
|
398
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵprov;
|
|
399
|
-
/** @type {?|undefined} */
|
|
400
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵpipe;
|
|
401
|
-
/** @type {?|undefined} */
|
|
402
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵcmp;
|
|
403
|
-
/** @type {?|undefined} */
|
|
404
|
-
ConstructorWithDefinitionAndFactory.prototype.ɵdir;
|
|
405
|
-
/* Skipping unnamed member:
|
|
406
|
-
[NG_FACTORY_DEF]?: Factory;*/
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* @record
|
|
410
|
-
*/
|
|
411
|
-
function PrivateInstance() { }
|
|
412
|
-
if (false) {
|
|
413
|
-
/* Skipping unnamed member:
|
|
414
|
-
[InjectorInstance]?: Injector;*/
|
|
415
|
-
/* Skipping unnamed member:
|
|
416
|
-
[InjectorNotifier]?: ReplaySubject<boolean>;*/
|
|
417
|
-
}
|
|
418
|
-
|
|
419
181
|
/**
|
|
420
182
|
* @fileoverview added by tsickle
|
|
421
183
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -426,5 +188,5 @@ if (false) {
|
|
|
426
188
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
427
189
|
*/
|
|
428
190
|
|
|
429
|
-
export { INITIAL_STATE_TOKEN, InitialState, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, NgxsBootstrapper,
|
|
191
|
+
export { INITIAL_STATE_TOKEN, InitialState, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, NgxsBootstrapper, isAngularInTestMode, memoize };
|
|
430
192
|
//# 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,MAIa,gBAAgB;IAD7B;;;;QAKU,eAAU,GAAG,IAAI,aAAa,CAA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/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,MAIa,gBAAgB;IAD7B;;;;QAKU,eAAU,GAAG,IAAI,aAAa,CAAU,CAAC,CAAC,CAAC;KAcpD;;;;IAZC,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;KACvC;;;;;;IAMD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B,CAAA,CAAC;IACF,0BAAO,QAAQ,GAAM;CACtB;;;;;;ACpDD;AAGA,MAAa,mBAAmB,GAAG,IAAI,cAAc,CAAM,qBAAqB,CAAC;AAEjF,MAAa,YAAY;;;;;IAGhB,OAAO,GAAG,CAAC,KAAkB;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;KACpB;;;;IAEM,OAAO,GAAG;;cACT,KAAK,GAAgB,IAAI,CAAC,KAAK;QACrC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;KACd;;AAVc,kBAAK,GAAgB,EAAE,CAAC;;;;;;IAAvC,mBAAuC;;;;;;;ACNzC;;;;AAKA,MAAa,0BAA0B,GAAwB,IAAI,cAAc,CAC/E,+BAA+B,CAChC;;;;;AAKD,MAAa,kBAAkB,GAAwB,IAAI,cAAc,CACvE,wBAAwB,CACzB;;;;;;;;;;;;;;"}
|
package/fesm2015/ngxs-store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, Optional, SkipSelf, ErrorHandler, Injector, ɵivyEnabled, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
2
|
-
import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState
|
|
2
|
+
import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
|
|
3
3
|
import { isPlatformServer } from '@angular/common';
|
|
4
4
|
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from } from 'rxjs';
|
|
5
5
|
import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap, publishReplay, refCount, distinctUntilChanged } from 'rxjs/operators';
|
|
@@ -1765,12 +1765,14 @@ class InternalDispatcher {
|
|
|
1765
1765
|
* @return {?}
|
|
1766
1766
|
*/
|
|
1767
1767
|
dispatchSingle(action) {
|
|
1768
|
-
|
|
1769
|
-
const type = getActionTypeFromInstance(action);
|
|
1770
|
-
if (!type) {
|
|
1768
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1771
1769
|
/** @type {?} */
|
|
1772
|
-
const
|
|
1773
|
-
|
|
1770
|
+
const type = getActionTypeFromInstance(action);
|
|
1771
|
+
if (!type) {
|
|
1772
|
+
/** @type {?} */
|
|
1773
|
+
const error = new Error(`This action doesn't have a type property: ${action.constructor.name}`);
|
|
1774
|
+
return throwError(error);
|
|
1775
|
+
}
|
|
1774
1776
|
}
|
|
1775
1777
|
/** @type {?} */
|
|
1776
1778
|
const prevState = this._stateStream.getValue();
|
|
@@ -3288,14 +3290,13 @@ class SelectFactory {
|
|
|
3288
3290
|
SelectFactory.store = null;
|
|
3289
3291
|
SelectFactory.config = null;
|
|
3290
3292
|
SelectFactory.decorators = [
|
|
3291
|
-
{ type: Injectable
|
|
3293
|
+
{ type: Injectable }
|
|
3292
3294
|
];
|
|
3293
3295
|
/** @nocollapse */
|
|
3294
3296
|
SelectFactory.ctorParameters = () => [
|
|
3295
3297
|
{ type: Store },
|
|
3296
3298
|
{ type: NgxsConfig }
|
|
3297
3299
|
];
|
|
3298
|
-
/** @nocollapse */ SelectFactory.ngInjectableDef = defineInjectable({ factory: function SelectFactory_Factory() { return new SelectFactory(inject(Store), inject(NgxsConfig)); }, token: SelectFactory, providedIn: "root" });
|
|
3299
3300
|
if (false) {
|
|
3300
3301
|
/** @type {?} */
|
|
3301
3302
|
SelectFactory.store;
|
|
@@ -3355,14 +3356,11 @@ class NgxsRootModule {
|
|
|
3355
3356
|
* @param {?} factory
|
|
3356
3357
|
* @param {?} internalStateOperations
|
|
3357
3358
|
* @param {?} _store
|
|
3358
|
-
* @param {?}
|
|
3359
|
+
* @param {?} _select
|
|
3359
3360
|
* @param {?=} states
|
|
3360
3361
|
* @param {?=} lifecycleStateManager
|
|
3361
3362
|
*/
|
|
3362
|
-
constructor(factory, internalStateOperations, _store,
|
|
3363
|
-
// If the user is running View Engine then we create the `SelectFactory` instance,
|
|
3364
|
-
// otherwise it'll be tree-shaken away in Ivy.
|
|
3365
|
-
!ɵivyEnabled && injector.get(SelectFactory);
|
|
3363
|
+
constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
|
|
3366
3364
|
// Add stores to the state graph and return their defaults
|
|
3367
3365
|
/** @type {?} */
|
|
3368
3366
|
const results = factory.addAndReturnDefaults(states);
|
|
@@ -3381,7 +3379,7 @@ NgxsRootModule.ctorParameters = () => [
|
|
|
3381
3379
|
{ type: StateFactory },
|
|
3382
3380
|
{ type: InternalStateOperations },
|
|
3383
3381
|
{ type: Store },
|
|
3384
|
-
{ type:
|
|
3382
|
+
{ type: SelectFactory },
|
|
3385
3383
|
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [ROOT_STATE_TOKEN,] }] },
|
|
3386
3384
|
{ type: LifecycleStateManager }
|
|
3387
3385
|
];
|
|
@@ -3472,6 +3470,7 @@ class NgxsModule {
|
|
|
3472
3470
|
InternalNgxsExecutionStrategy,
|
|
3473
3471
|
Store,
|
|
3474
3472
|
StateStream,
|
|
3473
|
+
SelectFactory,
|
|
3475
3474
|
PluginManager,
|
|
3476
3475
|
...states,
|
|
3477
3476
|
...NgxsModule.ngxsTokenProviders(states, options)
|
|
@@ -3711,37 +3710,30 @@ const DOLLAR_CHAR_CODE = 36;
|
|
|
3711
3710
|
/**
|
|
3712
3711
|
* @template T
|
|
3713
3712
|
* @param {?} selector
|
|
3714
|
-
* @param {?} store
|
|
3715
3713
|
* @return {?}
|
|
3716
3714
|
*/
|
|
3717
|
-
function createSelectObservable(selector
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
: createSelectObservableViewEngine(selector);
|
|
3715
|
+
function createSelectObservable(selector) {
|
|
3716
|
+
if (!SelectFactory.store) {
|
|
3717
|
+
throwSelectFactoryNotConnectedError();
|
|
3718
|
+
}
|
|
3719
|
+
return (/** @type {?} */ (SelectFactory.store)).select(selector);
|
|
3723
3720
|
}
|
|
3724
3721
|
/**
|
|
3725
|
-
* @param {?} config
|
|
3726
3722
|
* @param {?} name
|
|
3727
3723
|
* @param {?=} rawSelector
|
|
3728
3724
|
* @param {?=} paths
|
|
3729
3725
|
* @return {?}
|
|
3730
3726
|
*/
|
|
3731
|
-
function createSelectorFn(
|
|
3732
|
-
rawSelector = rawSelector
|
|
3733
|
-
if (typeof rawSelector
|
|
3734
|
-
return rawSelector;
|
|
3735
|
-
}
|
|
3736
|
-
else {
|
|
3727
|
+
function createSelectorFn(name, rawSelector, paths = []) {
|
|
3728
|
+
rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
|
|
3729
|
+
if (typeof rawSelector === 'string') {
|
|
3737
3730
|
/** @type {?} */
|
|
3738
3731
|
const propsArray = paths.length
|
|
3739
3732
|
? [rawSelector, ...paths]
|
|
3740
3733
|
: rawSelector.split('.');
|
|
3741
|
-
return
|
|
3742
|
-
? createSelectorFnIvy(propsArray, config)
|
|
3743
|
-
: createSelectorFnViewEngine(propsArray);
|
|
3734
|
+
return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
|
|
3744
3735
|
}
|
|
3736
|
+
return rawSelector;
|
|
3745
3737
|
}
|
|
3746
3738
|
/**
|
|
3747
3739
|
* \@example If `foo$` => make it just `foo`
|
|
@@ -3755,42 +3747,6 @@ function removeDollarAtTheEnd(name) {
|
|
|
3755
3747
|
const dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
|
|
3756
3748
|
return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
|
|
3757
3749
|
}
|
|
3758
|
-
/**
|
|
3759
|
-
* @template T
|
|
3760
|
-
* @param {?} selector
|
|
3761
|
-
* @param {?} store
|
|
3762
|
-
* @return {?}
|
|
3763
|
-
*/
|
|
3764
|
-
function createSelectObservableIvy(selector, store) {
|
|
3765
|
-
return ngDevMode && !store ? throwSelectFactoryNotConnectedError() : (/** @type {?} */ (store)).select(selector);
|
|
3766
|
-
}
|
|
3767
|
-
/**
|
|
3768
|
-
* @template T
|
|
3769
|
-
* @param {?} selector
|
|
3770
|
-
* @return {?}
|
|
3771
|
-
*/
|
|
3772
|
-
function createSelectObservableViewEngine(selector) {
|
|
3773
|
-
return SelectFactory.store
|
|
3774
|
-
? SelectFactory.store.select(selector)
|
|
3775
|
-
: throwSelectFactoryNotConnectedError();
|
|
3776
|
-
}
|
|
3777
|
-
/**
|
|
3778
|
-
* @param {?} propsArray
|
|
3779
|
-
* @param {?} config
|
|
3780
|
-
* @return {?}
|
|
3781
|
-
*/
|
|
3782
|
-
function createSelectorFnIvy(propsArray, config) {
|
|
3783
|
-
return ngDevMode && !config
|
|
3784
|
-
? throwSelectFactoryNotConnectedError()
|
|
3785
|
-
: propGetter(propsArray, (/** @type {?} */ (config)));
|
|
3786
|
-
}
|
|
3787
|
-
/**
|
|
3788
|
-
* @param {?} propsArray
|
|
3789
|
-
* @return {?}
|
|
3790
|
-
*/
|
|
3791
|
-
function createSelectorFnViewEngine(propsArray) {
|
|
3792
|
-
return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
|
|
3793
|
-
}
|
|
3794
3750
|
|
|
3795
3751
|
/**
|
|
3796
3752
|
* @fileoverview added by tsickle
|
|
@@ -3798,6 +3754,7 @@ function createSelectorFnViewEngine(propsArray) {
|
|
|
3798
3754
|
*/
|
|
3799
3755
|
/**
|
|
3800
3756
|
* Decorator for selecting a slice of state from the store.
|
|
3757
|
+
* @deprecated
|
|
3801
3758
|
* @template T
|
|
3802
3759
|
* @param {?=} rawSelector
|
|
3803
3760
|
* @param {...?} paths
|
|
@@ -3810,17 +3767,19 @@ function Select(rawSelector, ...paths) {
|
|
|
3810
3767
|
* @return {?}
|
|
3811
3768
|
*/
|
|
3812
3769
|
function (target, key) {
|
|
3770
|
+
console.warn(`
|
|
3771
|
+
The @Select decorator has been deprecated due to the following reasons:
|
|
3772
|
+
1) Lack of type-safety (compare to 'store.select()')
|
|
3773
|
+
2) Not compatible with server-side rendering because it uses a global 'Store' instance, which might change between renders
|
|
3774
|
+
3) Not compatible with module federation
|
|
3775
|
+
Consider replacing it the with store.select.
|
|
3776
|
+
`);
|
|
3813
3777
|
/** @type {?} */
|
|
3814
3778
|
const name = key.toString();
|
|
3815
3779
|
/** @type {?} */
|
|
3816
3780
|
const selectorId = `__${name}__selector`;
|
|
3817
3781
|
/** @type {?} */
|
|
3818
|
-
|
|
3819
|
-
/** @type {?} */
|
|
3820
|
-
let injectorNotifier$ = null;
|
|
3821
|
-
if (ɵivyEnabled) {
|
|
3822
|
-
injectorNotifier$ = ensureInjectorNotifierIsCaptured(target);
|
|
3823
|
-
}
|
|
3782
|
+
const selector = createSelectorFn(name, rawSelector, paths);
|
|
3824
3783
|
Object.defineProperties(target, {
|
|
3825
3784
|
[selectorId]: {
|
|
3826
3785
|
writable: true,
|
|
@@ -3834,36 +3793,10 @@ function Select(rawSelector, ...paths) {
|
|
|
3834
3793
|
* @return {?}
|
|
3835
3794
|
*/
|
|
3836
3795
|
get() {
|
|
3837
|
-
|
|
3838
|
-
return this[selectorId];
|
|
3839
|
-
}
|
|
3840
|
-
// The `localInject` will be tree-shaken away in apps that
|
|
3841
|
-
// still use the View Engine.
|
|
3842
|
-
if (ɵivyEnabled) {
|
|
3843
|
-
this[selectorId] = (/** @type {?} */ (injectorNotifier$)).pipe(mergeMap((/**
|
|
3844
|
-
* @return {?}
|
|
3845
|
-
*/
|
|
3846
|
-
() => {
|
|
3847
|
-
/** @type {?} */
|
|
3848
|
-
const store = localInject(this, Store);
|
|
3849
|
-
/** @type {?} */
|
|
3850
|
-
const config = localInject(this, NgxsConfig);
|
|
3851
|
-
selector = selector || createSelectorFn(config, name, rawSelector, paths);
|
|
3852
|
-
return createSelectObservable(selector, store);
|
|
3853
|
-
})));
|
|
3854
|
-
}
|
|
3855
|
-
else {
|
|
3856
|
-
selector = selector || createSelectorFn(null, name, rawSelector, paths);
|
|
3857
|
-
this[selectorId] = createSelectObservable(selector, null);
|
|
3858
|
-
}
|
|
3859
|
-
return this[selectorId];
|
|
3796
|
+
return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
|
|
3860
3797
|
}
|
|
3861
3798
|
}
|
|
3862
3799
|
});
|
|
3863
|
-
// Keep this `if` guard here so the below stuff will be tree-shaken away in apps that still use the View Engine.
|
|
3864
|
-
if (ɵivyEnabled) {
|
|
3865
|
-
ensureLocalInjectorCaptured(target);
|
|
3866
|
-
}
|
|
3867
3800
|
});
|
|
3868
3801
|
}
|
|
3869
3802
|
|
|
@@ -4084,5 +4017,5 @@ if (false) {
|
|
|
4084
4017
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4085
4018
|
*/
|
|
4086
4019
|
|
|
4087
|
-
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
|
|
4020
|
+
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 };
|
|
4088
4021
|
//# sourceMappingURL=ngxs-store.js.map
|