@claspo/renderer 18.6.0-ctx.0 → 18.6.0-ctx.1
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/package.json
CHANGED
package/sdk/source/Source.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { SourceUpdateDataI } from '../context/ContextSDK';
|
|
|
2
2
|
export interface SubscriptionEntryI {
|
|
3
3
|
subscribe(cb: (data: SourceUpdateDataI) => void): void;
|
|
4
4
|
getValue(key?: string): any;
|
|
5
|
-
getSessionHistory?(): string[];
|
|
6
5
|
}
|
|
7
6
|
export interface SourceConfigI {
|
|
8
7
|
[key: string]: any;
|
|
@@ -15,6 +14,5 @@ export default class Source {
|
|
|
15
14
|
constructor(id: string, subscriptionEntry: SubscriptionEntryI, config?: SourceConfigI);
|
|
16
15
|
subscribe(cb: (data: SourceUpdateDataI) => void): void;
|
|
17
16
|
getValue(key?: string): any;
|
|
18
|
-
getSessionHistory(): string[];
|
|
19
17
|
isSubscribed(): boolean;
|
|
20
18
|
}
|
package/sdk/source/Source.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default class Source{constructor(s,i,t={}){this.id=s,this.subscriptionEntry=i,this.config=t,this.subscribed=!1}subscribe(s){this.subscribed=!0,this.subscriptionEntry.subscribe(s)}getValue(s){return this.subscriptionEntry.getValue(s)}
|
|
1
|
+
export default class Source{constructor(s,i,t={}){this.id=s,this.subscriptionEntry=i,this.config=t,this.subscribed=!1}subscribe(s){this.subscribed=!0,this.subscriptionEntry.subscribe(s)}getValue(s){return this.subscriptionEntry.getValue(s)}isSubscribed(){return this.subscribed}}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Source from "./Source";
|
|
2
2
|
import { UrlQueryParamsConfigI } from "./sources/UrlQueryParamsSource";
|
|
3
|
-
import { JSApiVariablesConfigI } from "./sources/JSApiVariablesSource";
|
|
4
3
|
import FormGroup from '../../form/FormGroup';
|
|
5
|
-
export interface SourceRegistryConfigI extends UrlQueryParamsConfigI
|
|
4
|
+
export interface SourceRegistryConfigI extends UrlQueryParamsConfigI {
|
|
6
5
|
jsSource?: Source;
|
|
7
6
|
[key: string]: any;
|
|
8
7
|
}
|
|
@@ -24,14 +24,11 @@ export interface JSApiVariablesProcessorResultI {
|
|
|
24
24
|
export default class JSApiVariablesSource extends DefaultEventEmitter {
|
|
25
25
|
static sourceId: SourceType;
|
|
26
26
|
instanceName: string | undefined;
|
|
27
|
-
private subscribers;
|
|
28
27
|
constructor(config?: JSApiVariablesConfigI);
|
|
29
28
|
get appInstance(): any;
|
|
30
29
|
get variables(): any;
|
|
31
30
|
subscribe(cb: (data: SourceUpdateDataI) => void): void;
|
|
32
|
-
getValue(key?: string): JSApiVariablesProcessorResultI |
|
|
33
|
-
[k: string]: any;
|
|
34
|
-
};
|
|
31
|
+
getValue(key?: string): JSApiVariablesProcessorResultI | Record<string, never>;
|
|
35
32
|
addValues<T extends {
|
|
36
33
|
[key: string]: any;
|
|
37
34
|
}>(values: T): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import{SourceType}from"@claspo/common/document/hidden-fields.interface";class JSApiVariablesSource extends DefaultEventEmitter{constructor(e={}){super(),this.
|
|
1
|
+
import DefaultEventEmitter from"@claspo/common/DefaultEventEmitter";import{SourceType}from"@claspo/common/document/hidden-fields.interface";class JSApiVariablesSource extends DefaultEventEmitter{constructor(e={}){super(),this.instanceName=e.instanceName}get appInstance(){return window[this.instanceName]}get variables(){var e;return(null===(e=this.appInstance)||void 0===e?void 0:e.variables)||{}}subscribe(e){this.on("CHANGE",({values:r})=>{for(let t in r)e({key:t,value:r[t]})})}getValue(e){return e?{processor:(e,r)=>JSApiVariablesSource.processModel(r,this.instanceName)}:{}}addValues(e){if(!this.appInstance)throw new Error("Instatiate first");if(!e||"object"!=typeof e)throw new Error("Values should be object");Object.keys(e).length&&(this.appInstance.variables=Object.assign(Object.assign({},this.variables),e),this.emit("CHANGE",{values:e}))}static processModel(e,r){var t;if(!e.arguments)return"";const a=e.arguments.find(e=>"JavaScriptVariable"===e.name);if(!(null==a?void 0:a.value)||!r||!(null===(t=window[r])||void 0===t?void 0:t.variables))return"";try{return window[r].variables[a.value]||""}catch(r){return console.error("JSApiVariablesSource: error while getting variable. Model: ",e,"Error: ",r),""}}}JSApiVariablesSource.sourceId=SourceType.JS_API_VARIABLE;export default JSApiVariablesSource;
|