fix(core): update
This commit is contained in:
		
							
								
								
									
										18
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,6 +1,22 @@
 | 
				
			|||||||
.nogit/
 | 
					.nogit/
 | 
				
			||||||
node_modules/
 | 
					
 | 
				
			||||||
 | 
					# artifacts
 | 
				
			||||||
coverage/
 | 
					coverage/
 | 
				
			||||||
public/
 | 
					public/
 | 
				
			||||||
pages/
 | 
					pages/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# installs
 | 
				
			||||||
 | 
					node_modules/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# caches
 | 
				
			||||||
.yarn/
 | 
					.yarn/
 | 
				
			||||||
 | 
					.cache/
 | 
				
			||||||
 | 
					.rpt2_cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# builds
 | 
				
			||||||
 | 
					dist/
 | 
				
			||||||
 | 
					dist_web/
 | 
				
			||||||
 | 
					dist_serve/
 | 
				
			||||||
 | 
					dist_ts_web/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# custom
 | 
				
			||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
# gitzone standard
 | 
					# gitzone ci_default
 | 
				
			||||||
image: hosttoday/ht-docker-node:npmci
 | 
					image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cache:
 | 
					cache:
 | 
				
			||||||
  paths:
 | 
					  paths:
 | 
				
			||||||
@@ -38,19 +38,7 @@ snyk:
 | 
				
			|||||||
# test stage
 | 
					# test stage
 | 
				
			||||||
# ====================
 | 
					# ====================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
testLTS:
 | 
					testStable:
 | 
				
			||||||
  stage: test
 | 
					 | 
				
			||||||
  script:
 | 
					 | 
				
			||||||
  - npmci npm prepare
 | 
					 | 
				
			||||||
  - npmci node install lts
 | 
					 | 
				
			||||||
  - npmci npm install
 | 
					 | 
				
			||||||
  - npmci npm test
 | 
					 | 
				
			||||||
  coverage: /\d+.?\d+?\%\s*coverage/
 | 
					 | 
				
			||||||
  tags:
 | 
					 | 
				
			||||||
  - docker
 | 
					 | 
				
			||||||
  - notpriv
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
testSTABLE:
 | 
					 | 
				
			||||||
  stage: test
 | 
					  stage: test
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
  - npmci npm prepare
 | 
					  - npmci npm prepare
 | 
				
			||||||
@@ -60,6 +48,18 @@ testSTABLE:
 | 
				
			|||||||
  coverage: /\d+.?\d+?\%\s*coverage/
 | 
					  coverage: /\d+.?\d+?\%\s*coverage/
 | 
				
			||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
  - docker
 | 
					  - docker
 | 
				
			||||||
 | 
					  - priv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					testBuild:
 | 
				
			||||||
 | 
					  stage: test
 | 
				
			||||||
 | 
					  script:
 | 
				
			||||||
 | 
					  - npmci npm prepare
 | 
				
			||||||
 | 
					  - npmci node install stable
 | 
				
			||||||
 | 
					  - npmci npm install
 | 
				
			||||||
 | 
					  - npmci command npm run build
 | 
				
			||||||
 | 
					  coverage: /\d+.?\d+?\%\s*coverage/
 | 
				
			||||||
 | 
					  tags:
 | 
				
			||||||
 | 
					  - docker
 | 
				
			||||||
  - notpriv
 | 
					  - notpriv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
release:
 | 
					release:
 | 
				
			||||||
@@ -78,19 +78,11 @@ release:
 | 
				
			|||||||
# ====================
 | 
					# ====================
 | 
				
			||||||
codequality:
 | 
					codequality:
 | 
				
			||||||
  stage: metadata
 | 
					  stage: metadata
 | 
				
			||||||
  image: docker:stable
 | 
					 | 
				
			||||||
  allow_failure: true
 | 
					  allow_failure: true
 | 
				
			||||||
  services:
 | 
					 | 
				
			||||||
    - docker:stable-dind
 | 
					 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
 | 
					    - npmci command npm install -g tslint typescript
 | 
				
			||||||
    - docker run
 | 
					    - npmci npm install
 | 
				
			||||||
        --env SOURCE_CODE="$PWD"
 | 
					    - npmci command "tslint -c tslint.json ./ts/**/*.ts"
 | 
				
			||||||
        --volume "$PWD":/code
 | 
					 | 
				
			||||||
        --volume /var/run/docker.sock:/var/run/docker.sock
 | 
					 | 
				
			||||||
        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
 | 
					 | 
				
			||||||
  artifacts:
 | 
					 | 
				
			||||||
    paths: [codeclimate.json]
 | 
					 | 
				
			||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
  - docker
 | 
					  - docker
 | 
				
			||||||
  - priv
 | 
					  - priv
 | 
				
			||||||
@@ -106,13 +98,15 @@ trigger:
 | 
				
			|||||||
  - notpriv
 | 
					  - notpriv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pages:
 | 
					pages:
 | 
				
			||||||
  image: hosttoday/ht-docker-node:npmci
 | 
					  image: hosttoday/ht-docker-dbase:npmci
 | 
				
			||||||
 | 
					  services:
 | 
				
			||||||
 | 
					   - docker:stable-dind
 | 
				
			||||||
  stage: metadata
 | 
					  stage: metadata
 | 
				
			||||||
  script:
 | 
					  script:
 | 
				
			||||||
    - npmci command npm install -g typedoc typescript
 | 
					    - npmci command npm install -g @gitzone/tsdoc
 | 
				
			||||||
    - npmci npm prepare
 | 
					    - npmci npm prepare
 | 
				
			||||||
    - npmci npm install
 | 
					    - npmci npm install
 | 
				
			||||||
    - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
 | 
					    - npmci command tsdoc
 | 
				
			||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
    - docker
 | 
					    - docker
 | 
				
			||||||
    - notpriv
 | 
					    - notpriv
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										939
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										939
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										28
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								package.json
									
									
									
									
									
								
							@@ -13,15 +13,27 @@
 | 
				
			|||||||
    "format": "(gitzone format)"
 | 
					    "format": "(gitzone format)"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "@gitzone/tsbuild": "^2.1.8",
 | 
					    "@gitzone/tsbuild": "^2.1.17",
 | 
				
			||||||
    "@gitzone/tstest": "^1.0.20",
 | 
					    "@gitzone/tstest": "^1.0.24",
 | 
				
			||||||
    "@pushrocks/tapbundle": "^3.0.9",
 | 
					    "@pushrocks/tapbundle": "^3.0.13",
 | 
				
			||||||
    "@types/node": "^11.13.8",
 | 
					    "@types/node": "^12.7.7",
 | 
				
			||||||
    "tslint": "^5.16.0",
 | 
					    "tslint": "^5.20.0",
 | 
				
			||||||
    "tslint-config-prettier": "^1.18.0"
 | 
					    "tslint-config-prettier": "^1.18.0"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "@pushrocks/lik": "^3.0.5",
 | 
					    "@pushrocks/lik": "^3.0.11",
 | 
				
			||||||
    "rxjs": "^6.5.1"
 | 
					    "@pushrocks/smartpromise": "^3.0.5",
 | 
				
			||||||
  }
 | 
					    "rxjs": "^6.5.3"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "files": [
 | 
				
			||||||
 | 
					    "ts/*",
 | 
				
			||||||
 | 
					    "ts_web/*",
 | 
				
			||||||
 | 
					    "dist/*",
 | 
				
			||||||
 | 
					    "dist_web/*",
 | 
				
			||||||
 | 
					    "dist_ts_web/*",
 | 
				
			||||||
 | 
					    "assets/*",
 | 
				
			||||||
 | 
					    "cli.js",
 | 
				
			||||||
 | 
					    "npmextra.json",
 | 
				
			||||||
 | 
					    "readme.md"
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,6 @@ a package that handles state in a good way
 | 
				
			|||||||
For further information read the linked docs at the top of this readme.
 | 
					For further information read the linked docs at the top of this readme.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
 | 
					> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
 | 
				
			||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
 | 
					| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[](https://maintainedby.lossless.com)
 | 
					[](https://maintainedby.lossless.com)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ export class Smartstate<StatePartNameType> {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  constructor() {}
 | 
					  constructor() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getStatePart<PayloadType>(
 | 
					  public getStatePart<PayloadType>(
 | 
				
			||||||
    statePartNameArg: StatePartNameType,
 | 
					    statePartNameArg: StatePartNameType,
 | 
				
			||||||
    initialArg?: PayloadType
 | 
					    initialArg?: PayloadType
 | 
				
			||||||
  ): StatePart<StatePartNameType, PayloadType> {
 | 
					  ): StatePart<StatePartNameType, PayloadType> {
 | 
				
			||||||
@@ -48,5 +48,5 @@ export class Smartstate<StatePartNameType> {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * dispatches an action on the main level
 | 
					   * dispatches an action on the main level
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  dispatch() {}
 | 
					  public dispatch() {}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,5 +9,9 @@ export interface IActionDef<TStateType, TActionPayloadType> {
 | 
				
			|||||||
 * an actionmodifier for the state
 | 
					 * an actionmodifier for the state
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export class StateAction<TStateType, TActionPayloadType> {
 | 
					export class StateAction<TStateType, TActionPayloadType> {
 | 
				
			||||||
  constructor(public actionDef: IActionDef<TStateType, TActionPayloadType>) {}
 | 
					  constructor(public statePartRef: StatePart<any, any>, public actionDef: IActionDef<TStateType, TActionPayloadType>) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public trigger(payload: TActionPayloadType) {
 | 
				
			||||||
 | 
					    this.statePartRef.dispatchAction(this, payload);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,9 +6,9 @@ import { startWith, takeUntil, map } from 'rxjs/operators';
 | 
				
			|||||||
import { StateAction, IActionDef } from './smartstate.classes.stateaction';
 | 
					import { StateAction, IActionDef } from './smartstate.classes.stateaction';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class StatePart<TStatePartName, TStatePayload> {
 | 
					export class StatePart<TStatePartName, TStatePayload> {
 | 
				
			||||||
  name: TStatePartName;
 | 
					  public name: TStatePartName;
 | 
				
			||||||
  state = new Subject<TStatePayload>();
 | 
					  public state = new Subject<TStatePayload>();
 | 
				
			||||||
  stateStore: TStatePayload;
 | 
					  public stateStore: TStatePayload;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(nameArg: TStatePartName) {
 | 
					  constructor(nameArg: TStatePartName) {
 | 
				
			||||||
    this.name = nameArg;
 | 
					    this.name = nameArg;
 | 
				
			||||||
@@ -17,7 +17,7 @@ export class StatePart<TStatePartName, TStatePayload> {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * gets the state from the state store
 | 
					   * gets the state from the state store
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  getState(): TStatePayload {
 | 
					  public getState(): TStatePayload {
 | 
				
			||||||
    return this.stateStore;
 | 
					    return this.stateStore;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,7 +25,7 @@ export class StatePart<TStatePartName, TStatePayload> {
 | 
				
			|||||||
   * sets the stateStore to the new state
 | 
					   * sets the stateStore to the new state
 | 
				
			||||||
   * @param newStateArg
 | 
					   * @param newStateArg
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  setState(newStateArg: TStatePayload) {
 | 
					  public setState(newStateArg: TStatePayload) {
 | 
				
			||||||
    this.stateStore = newStateArg;
 | 
					    this.stateStore = newStateArg;
 | 
				
			||||||
    this.notifyChange();
 | 
					    this.notifyChange();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -33,21 +33,27 @@ export class StatePart<TStatePartName, TStatePayload> {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * notifies of a change on the state
 | 
					   * notifies of a change on the state
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  notifyChange() {
 | 
					  public notifyChange() {
 | 
				
			||||||
    this.state.next(this.stateStore);
 | 
					    this.state.next(this.stateStore);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * selects a state or a substate
 | 
					   * selects a state or a substate
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  select<T = TStatePayload>(selectorFn?: (state: TStatePayload) => T): Observable<T> {
 | 
					  public select<T = TStatePayload>(selectorFn?: (state: TStatePayload) => T): Observable<T> {
 | 
				
			||||||
    if (!selectorFn) {
 | 
					    if (!selectorFn) {
 | 
				
			||||||
      selectorFn = (state: TStatePayload) => <T>(<any>state);
 | 
					      selectorFn = (state: TStatePayload) => <T>(<any>state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const mapped = this.state.pipe(
 | 
					    const mapped = this.state.pipe(
 | 
				
			||||||
      startWith(this.getState()),
 | 
					      startWith(this.getState()),
 | 
				
			||||||
      map(selectorFn)
 | 
					      map((stateArg) => {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					          return selectorFn(stateArg);
 | 
				
			||||||
 | 
					        } catch (e) {
 | 
				
			||||||
 | 
					          // Nothing here
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return mapped;
 | 
					    return mapped;
 | 
				
			||||||
@@ -56,17 +62,33 @@ export class StatePart<TStatePartName, TStatePayload> {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * creates an action capable of modifying the state
 | 
					   * creates an action capable of modifying the state
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  createAction<TActionPayload>(
 | 
					  public createAction<TActionPayload>(
 | 
				
			||||||
    actionDef: IActionDef<TStatePayload, TActionPayload>
 | 
					    actionDef: IActionDef<TStatePayload, TActionPayload>
 | 
				
			||||||
  ): StateAction<TStatePayload, TActionPayload> {
 | 
					  ): StateAction<TStatePayload, TActionPayload> {
 | 
				
			||||||
    return new StateAction(actionDef);
 | 
					    return new StateAction(this, actionDef);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * dispatches an action on the statepart level
 | 
					   * dispatches an action on the statepart level
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  async dispatchAction<T>(stateAction: StateAction<TStatePayload, T>, actionPayload: T) {
 | 
					  public async dispatchAction<T>(stateAction: StateAction<TStatePayload, T>, actionPayload: T) {
 | 
				
			||||||
    const newState = await stateAction.actionDef(this, actionPayload);
 | 
					    const newState = await stateAction.actionDef(this, actionPayload);
 | 
				
			||||||
    this.setState(newState);
 | 
					    this.setState(newState);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * waits until a certain part of the state becomes available
 | 
				
			||||||
 | 
					   * @param selectorFn
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public async waitUntilPresent<T = TStatePayload>(selectorFn?: (state: TStatePayload) => T): Promise<T> {
 | 
				
			||||||
 | 
					    const done = plugins.smartpromise.defer<T>();
 | 
				
			||||||
 | 
					    const selectedObservable = this.select(selectorFn);
 | 
				
			||||||
 | 
					    const subscription = selectedObservable.subscribe(value => {
 | 
				
			||||||
 | 
					      if (value) {
 | 
				
			||||||
 | 
					        subscription.unsubscribe();
 | 
				
			||||||
 | 
					        done.resolve(value);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    return await done.promise;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,3 +5,9 @@ const rxjsPart = {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export { rxjsPart };
 | 
					export { rxjsPart };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import * as smartpromise from '@pushrocks/smartpromise';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export {
 | 
				
			||||||
 | 
					  smartpromise
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user