@ngxs/store 3.7.4-dev.master-a63a5af → 3.7.4-dev.master-c961545
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 +30 -112
- 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/state-operations.js +3 -12
- package/esm2015/src/module.js +3 -1
- package/esm2015/src/modules/ngxs-root.module.js +5 -8
- package/esm2015/src/symbols.js +4 -3
- 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/state-operations.js +3 -12
- package/esm5/src/module.js +3 -1
- package/esm5/src/modules/ngxs-root.module.js +4 -7
- package/esm5/src/symbols.js +4 -3
- package/fesm2015/ngxs-store-internals.js +2 -240
- package/fesm2015/ngxs-store-internals.js.map +1 -1
- package/fesm2015/ngxs-store.js +32 -108
- 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 +25 -108
- 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/src/symbols.d.ts +3 -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;;;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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,MAIa,gBAAgB;IAD7B;;;;QAKU,eAAU,GAAG,IAAI,aAAa,CAAU,CAAC,CAAC,CAAC;KAcpD;;;;IAZC,IAAI,gBAAgB;QA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;;QAEtB,QAAQ,GAAG,IAAI,CAAC;QAChB,UAAU,GAAG,IAAI,CAAC;KACnB,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 {
|
|
2
|
+
import { 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';
|
|
@@ -235,8 +235,9 @@ if (false) {
|
|
|
235
235
|
* - Object.freeze on the state and actions to guarantee immutability
|
|
236
236
|
* (default: false)
|
|
237
237
|
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
238
|
+
* Note: this property will be accounted only in development mode when using the Ivy compiler.
|
|
239
|
+
* It makes sense to use it only during development to ensure there're no state mutations.
|
|
240
|
+
* When building for production, the Object.freeze will be tree-shaken away.
|
|
240
241
|
* @type {?}
|
|
241
242
|
*/
|
|
242
243
|
NgxsConfig.prototype.developmentMode;
|
|
@@ -1963,21 +1964,13 @@ class InternalStateOperations {
|
|
|
1963
1964
|
*/
|
|
1964
1965
|
(actionOrActions) => this._dispatcher.dispatch(actionOrActions))
|
|
1965
1966
|
};
|
|
1966
|
-
|
|
1967
|
-
// and `deepFreeze` in Ivy production build.
|
|
1968
|
-
// The below `if` condition checks 2 things:
|
|
1969
|
-
// 1) if we're in View Engine (`ngDevMode` is `undefined`)
|
|
1970
|
-
// 2) if we're running tests, we should fallback to `config.developmentMode` to be backwards-compatible
|
|
1971
|
-
if (typeof ngDevMode === 'undefined' || (ngDevMode && isAngularInTestMode())) {
|
|
1967
|
+
if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
|
1972
1968
|
return this._config.developmentMode
|
|
1973
1969
|
? ensureStateAndActionsAreImmutable(rootStateOperations)
|
|
1974
1970
|
: rootStateOperations;
|
|
1975
1971
|
}
|
|
1976
1972
|
else {
|
|
1977
|
-
|
|
1978
|
-
return ngDevMode
|
|
1979
|
-
? ensureStateAndActionsAreImmutable(rootStateOperations)
|
|
1980
|
-
: rootStateOperations;
|
|
1973
|
+
return rootStateOperations;
|
|
1981
1974
|
}
|
|
1982
1975
|
}
|
|
1983
1976
|
/**
|
|
@@ -3290,14 +3283,13 @@ class SelectFactory {
|
|
|
3290
3283
|
SelectFactory.store = null;
|
|
3291
3284
|
SelectFactory.config = null;
|
|
3292
3285
|
SelectFactory.decorators = [
|
|
3293
|
-
{ type: Injectable
|
|
3286
|
+
{ type: Injectable }
|
|
3294
3287
|
];
|
|
3295
3288
|
/** @nocollapse */
|
|
3296
3289
|
SelectFactory.ctorParameters = () => [
|
|
3297
3290
|
{ type: Store },
|
|
3298
3291
|
{ type: NgxsConfig }
|
|
3299
3292
|
];
|
|
3300
|
-
/** @nocollapse */ SelectFactory.ngInjectableDef = defineInjectable({ factory: function SelectFactory_Factory() { return new SelectFactory(inject(Store), inject(NgxsConfig)); }, token: SelectFactory, providedIn: "root" });
|
|
3301
3293
|
if (false) {
|
|
3302
3294
|
/** @type {?} */
|
|
3303
3295
|
SelectFactory.store;
|
|
@@ -3357,14 +3349,11 @@ class NgxsRootModule {
|
|
|
3357
3349
|
* @param {?} factory
|
|
3358
3350
|
* @param {?} internalStateOperations
|
|
3359
3351
|
* @param {?} _store
|
|
3360
|
-
* @param {?}
|
|
3352
|
+
* @param {?} _select
|
|
3361
3353
|
* @param {?=} states
|
|
3362
3354
|
* @param {?=} lifecycleStateManager
|
|
3363
3355
|
*/
|
|
3364
|
-
constructor(factory, internalStateOperations, _store,
|
|
3365
|
-
// If the user is running View Engine then we create the `SelectFactory` instance,
|
|
3366
|
-
// otherwise it'll be tree-shaken away in Ivy.
|
|
3367
|
-
!ɵivyEnabled && injector.get(SelectFactory);
|
|
3356
|
+
constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
|
|
3368
3357
|
// Add stores to the state graph and return their defaults
|
|
3369
3358
|
/** @type {?} */
|
|
3370
3359
|
const results = factory.addAndReturnDefaults(states);
|
|
@@ -3383,7 +3372,7 @@ NgxsRootModule.ctorParameters = () => [
|
|
|
3383
3372
|
{ type: StateFactory },
|
|
3384
3373
|
{ type: InternalStateOperations },
|
|
3385
3374
|
{ type: Store },
|
|
3386
|
-
{ type:
|
|
3375
|
+
{ type: SelectFactory },
|
|
3387
3376
|
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [ROOT_STATE_TOKEN,] }] },
|
|
3388
3377
|
{ type: LifecycleStateManager }
|
|
3389
3378
|
];
|
|
@@ -3474,6 +3463,7 @@ class NgxsModule {
|
|
|
3474
3463
|
InternalNgxsExecutionStrategy,
|
|
3475
3464
|
Store,
|
|
3476
3465
|
StateStream,
|
|
3466
|
+
SelectFactory,
|
|
3477
3467
|
PluginManager,
|
|
3478
3468
|
...states,
|
|
3479
3469
|
...NgxsModule.ngxsTokenProviders(states, options)
|
|
@@ -3713,37 +3703,30 @@ const DOLLAR_CHAR_CODE = 36;
|
|
|
3713
3703
|
/**
|
|
3714
3704
|
* @template T
|
|
3715
3705
|
* @param {?} selector
|
|
3716
|
-
* @param {?} store
|
|
3717
3706
|
* @return {?}
|
|
3718
3707
|
*/
|
|
3719
|
-
function createSelectObservable(selector
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
: createSelectObservableViewEngine(selector);
|
|
3708
|
+
function createSelectObservable(selector) {
|
|
3709
|
+
if (!SelectFactory.store) {
|
|
3710
|
+
throwSelectFactoryNotConnectedError();
|
|
3711
|
+
}
|
|
3712
|
+
return (/** @type {?} */ (SelectFactory.store)).select(selector);
|
|
3725
3713
|
}
|
|
3726
3714
|
/**
|
|
3727
|
-
* @param {?} config
|
|
3728
3715
|
* @param {?} name
|
|
3729
3716
|
* @param {?=} rawSelector
|
|
3730
3717
|
* @param {?=} paths
|
|
3731
3718
|
* @return {?}
|
|
3732
3719
|
*/
|
|
3733
|
-
function createSelectorFn(
|
|
3734
|
-
rawSelector = rawSelector
|
|
3735
|
-
if (typeof rawSelector
|
|
3736
|
-
return rawSelector;
|
|
3737
|
-
}
|
|
3738
|
-
else {
|
|
3720
|
+
function createSelectorFn(name, rawSelector, paths = []) {
|
|
3721
|
+
rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
|
|
3722
|
+
if (typeof rawSelector === 'string') {
|
|
3739
3723
|
/** @type {?} */
|
|
3740
3724
|
const propsArray = paths.length
|
|
3741
3725
|
? [rawSelector, ...paths]
|
|
3742
3726
|
: rawSelector.split('.');
|
|
3743
|
-
return
|
|
3744
|
-
? createSelectorFnIvy(propsArray, config)
|
|
3745
|
-
: createSelectorFnViewEngine(propsArray);
|
|
3727
|
+
return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
|
|
3746
3728
|
}
|
|
3729
|
+
return rawSelector;
|
|
3747
3730
|
}
|
|
3748
3731
|
/**
|
|
3749
3732
|
* \@example If `foo$` => make it just `foo`
|
|
@@ -3757,42 +3740,6 @@ function removeDollarAtTheEnd(name) {
|
|
|
3757
3740
|
const dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
|
|
3758
3741
|
return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
|
|
3759
3742
|
}
|
|
3760
|
-
/**
|
|
3761
|
-
* @template T
|
|
3762
|
-
* @param {?} selector
|
|
3763
|
-
* @param {?} store
|
|
3764
|
-
* @return {?}
|
|
3765
|
-
*/
|
|
3766
|
-
function createSelectObservableIvy(selector, store) {
|
|
3767
|
-
return ngDevMode && !store ? throwSelectFactoryNotConnectedError() : (/** @type {?} */ (store)).select(selector);
|
|
3768
|
-
}
|
|
3769
|
-
/**
|
|
3770
|
-
* @template T
|
|
3771
|
-
* @param {?} selector
|
|
3772
|
-
* @return {?}
|
|
3773
|
-
*/
|
|
3774
|
-
function createSelectObservableViewEngine(selector) {
|
|
3775
|
-
return SelectFactory.store
|
|
3776
|
-
? SelectFactory.store.select(selector)
|
|
3777
|
-
: throwSelectFactoryNotConnectedError();
|
|
3778
|
-
}
|
|
3779
|
-
/**
|
|
3780
|
-
* @param {?} propsArray
|
|
3781
|
-
* @param {?} config
|
|
3782
|
-
* @return {?}
|
|
3783
|
-
*/
|
|
3784
|
-
function createSelectorFnIvy(propsArray, config) {
|
|
3785
|
-
return ngDevMode && !config
|
|
3786
|
-
? throwSelectFactoryNotConnectedError()
|
|
3787
|
-
: propGetter(propsArray, (/** @type {?} */ (config)));
|
|
3788
|
-
}
|
|
3789
|
-
/**
|
|
3790
|
-
* @param {?} propsArray
|
|
3791
|
-
* @return {?}
|
|
3792
|
-
*/
|
|
3793
|
-
function createSelectorFnViewEngine(propsArray) {
|
|
3794
|
-
return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
|
|
3795
|
-
}
|
|
3796
3743
|
|
|
3797
3744
|
/**
|
|
3798
3745
|
* @fileoverview added by tsickle
|
|
@@ -3800,6 +3747,7 @@ function createSelectorFnViewEngine(propsArray) {
|
|
|
3800
3747
|
*/
|
|
3801
3748
|
/**
|
|
3802
3749
|
* Decorator for selecting a slice of state from the store.
|
|
3750
|
+
* @deprecated
|
|
3803
3751
|
* @template T
|
|
3804
3752
|
* @param {?=} rawSelector
|
|
3805
3753
|
* @param {...?} paths
|
|
@@ -3812,17 +3760,19 @@ function Select(rawSelector, ...paths) {
|
|
|
3812
3760
|
* @return {?}
|
|
3813
3761
|
*/
|
|
3814
3762
|
function (target, key) {
|
|
3763
|
+
console.warn(`
|
|
3764
|
+
The @Select decorator has been deprecated due to the following reasons:
|
|
3765
|
+
1) Lack of type-safety (compare to 'store.select()')
|
|
3766
|
+
2) Not compatible with server-side rendering because it uses a global 'Store' instance, which might change between renders
|
|
3767
|
+
3) Not compatible with module federation
|
|
3768
|
+
Consider replacing it the with store.select.
|
|
3769
|
+
`);
|
|
3815
3770
|
/** @type {?} */
|
|
3816
3771
|
const name = key.toString();
|
|
3817
3772
|
/** @type {?} */
|
|
3818
3773
|
const selectorId = `__${name}__selector`;
|
|
3819
3774
|
/** @type {?} */
|
|
3820
|
-
|
|
3821
|
-
/** @type {?} */
|
|
3822
|
-
let injectorNotifier$ = null;
|
|
3823
|
-
if (ɵivyEnabled) {
|
|
3824
|
-
injectorNotifier$ = ensureInjectorNotifierIsCaptured(target);
|
|
3825
|
-
}
|
|
3775
|
+
const selector = createSelectorFn(name, rawSelector, paths);
|
|
3826
3776
|
Object.defineProperties(target, {
|
|
3827
3777
|
[selectorId]: {
|
|
3828
3778
|
writable: true,
|
|
@@ -3836,36 +3786,10 @@ function Select(rawSelector, ...paths) {
|
|
|
3836
3786
|
* @return {?}
|
|
3837
3787
|
*/
|
|
3838
3788
|
get() {
|
|
3839
|
-
|
|
3840
|
-
return this[selectorId];
|
|
3841
|
-
}
|
|
3842
|
-
// The `localInject` will be tree-shaken away in apps that
|
|
3843
|
-
// still use the View Engine.
|
|
3844
|
-
if (ɵivyEnabled) {
|
|
3845
|
-
this[selectorId] = (/** @type {?} */ (injectorNotifier$)).pipe(mergeMap((/**
|
|
3846
|
-
* @return {?}
|
|
3847
|
-
*/
|
|
3848
|
-
() => {
|
|
3849
|
-
/** @type {?} */
|
|
3850
|
-
const store = localInject(this, Store);
|
|
3851
|
-
/** @type {?} */
|
|
3852
|
-
const config = localInject(this, NgxsConfig);
|
|
3853
|
-
selector = selector || createSelectorFn(config, name, rawSelector, paths);
|
|
3854
|
-
return createSelectObservable(selector, store);
|
|
3855
|
-
})));
|
|
3856
|
-
}
|
|
3857
|
-
else {
|
|
3858
|
-
selector = selector || createSelectorFn(null, name, rawSelector, paths);
|
|
3859
|
-
this[selectorId] = createSelectObservable(selector, null);
|
|
3860
|
-
}
|
|
3861
|
-
return this[selectorId];
|
|
3789
|
+
return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
|
|
3862
3790
|
}
|
|
3863
3791
|
}
|
|
3864
3792
|
});
|
|
3865
|
-
// Keep this `if` guard here so the below stuff will be tree-shaken away in apps that still use the View Engine.
|
|
3866
|
-
if (ɵivyEnabled) {
|
|
3867
|
-
ensureLocalInjectorCaptured(target);
|
|
3868
|
-
}
|
|
3869
3793
|
});
|
|
3870
3794
|
}
|
|
3871
3795
|
|
|
@@ -4086,5 +4010,5 @@ if (false) {
|
|
|
4086
4010
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4087
4011
|
*/
|
|
4088
4012
|
|
|
4089
|
-
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
|
|
4013
|
+
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 };
|
|
4090
4014
|
//# sourceMappingURL=ngxs-store.js.map
|