@kissflow/lowcode-client-sdk 1.0.12-beta.1 → 1.0.13
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/README.md +28 -12
- package/dist/kfsdk.es.js +66 -53
- package/dist/kfsdk.umd.js +1 -1
- package/dist/kfworkersdk.es.js +109 -70
- package/package.json +4 -12
package/README.md
CHANGED
|
@@ -54,6 +54,9 @@ let resp = await kf.api(url, config)
|
|
|
54
54
|
- [3. Application](#3-application)
|
|
55
55
|
- [4. Page](#4-page)
|
|
56
56
|
- [5. Component](#5-component)
|
|
57
|
+
- [Standard Component methods](#standard-component-methods)
|
|
58
|
+
- [Component Specific methods](#component-specific-methods)
|
|
59
|
+
- [Tab](#521-tab-component)
|
|
57
60
|
- [6. Popup](#6-popup)
|
|
58
61
|
- [7. Formatter](#7-formatter)
|
|
59
62
|
|
|
@@ -345,26 +348,40 @@ kf.app.page.openPopup("popupId", { inputParam1: "value" });
|
|
|
345
348
|
```
|
|
346
349
|
|
|
347
350
|
### 5) Component
|
|
348
|
-
|
|
351
|
+
#### getComponent(id)
|
|
352
|
+
Parameter: Component's Id
|
|
353
|
+
Returns: Component class instance
|
|
349
354
|
```js
|
|
350
355
|
const component = await kf.app.page.getComponent(componentId);
|
|
351
356
|
```
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
##### Refresh a component
|
|
357
|
+
##### Standard Component Methods
|
|
355
358
|
```js
|
|
356
|
-
component.refresh();
|
|
359
|
+
component.refresh(); // Refreshes the component
|
|
360
|
+
component.hide(); // Hides the component
|
|
361
|
+
component.show(); // Shows the component if it's been hidden previously
|
|
357
362
|
```
|
|
363
|
+
##### Component Specific Methods
|
|
358
364
|
|
|
359
|
-
|
|
365
|
+
|
|
366
|
+
##### 5.2.0) Component onMount
|
|
367
|
+
Component onMount takes in callBack function as argument.
|
|
368
|
+
> ##### Note: Any component specific methods that are used on Page load must be called inside component's onMount event.
|
|
369
|
+
Parameter: function
|
|
360
370
|
```js
|
|
361
|
-
|
|
371
|
+
component.onMount(() => {
|
|
372
|
+
// function logic goes here... For eg.
|
|
373
|
+
// component.setActiveTab(2)
|
|
374
|
+
})
|
|
362
375
|
```
|
|
363
|
-
|
|
364
|
-
#####
|
|
376
|
+
##### 5.2.1) Tab component
|
|
377
|
+
##### 1) setActiveTab
|
|
378
|
+
Sets specified tab as active.
|
|
379
|
+
Parameter: Tabs' Number (Starts from 1 to N)
|
|
365
380
|
```js
|
|
366
|
-
component.
|
|
381
|
+
component.setActiveTab(2) // sets 2nd tab as active one
|
|
367
382
|
```
|
|
383
|
+
|
|
384
|
+
|
|
368
385
|
### 6) Popup
|
|
369
386
|
`kf.app.page.popup` returns the active popup instance opened inside the page and its id can be accessed via `kf.app.page.popup._id`
|
|
370
387
|
And `kf.app.page.getPopup(id)` returns this popup class instance.
|
|
@@ -376,7 +393,7 @@ let value = await kf.app.page.popup.getParameter("parameterId"); // for retreivi
|
|
|
376
393
|
Get all popup parameters
|
|
377
394
|
```js
|
|
378
395
|
let allParams = await kf.app.page.popup.getAllParameters();
|
|
379
|
-
//
|
|
396
|
+
// Returns an object
|
|
380
397
|
{
|
|
381
398
|
parameterName: "Sample value",
|
|
382
399
|
parameterName2: "Sample value 2"
|
|
@@ -441,4 +458,3 @@ let value = await kf.formatter.toBoolean("no");
|
|
|
441
458
|
let value = await kf.formatter.toBoolean("0");
|
|
442
459
|
let value = await kf.formatter.toBoolean("false");
|
|
443
460
|
```
|
|
444
|
-
|
package/dist/kfsdk.es.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
1
|
var __accessCheck = (obj, member, msg) => {
|
|
18
2
|
if (!member.has(obj))
|
|
19
3
|
throw TypeError("Cannot " + msg);
|
|
@@ -155,7 +139,9 @@ class EventBase {
|
|
|
155
139
|
}
|
|
156
140
|
_dispatchEvent(eventName, eventParams) {
|
|
157
141
|
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
158
|
-
__privateGet(this, _listeners)[eventName].forEach(
|
|
142
|
+
__privateGet(this, _listeners)[eventName].forEach(
|
|
143
|
+
(callBack) => callBack(eventParams)
|
|
144
|
+
);
|
|
159
145
|
return true;
|
|
160
146
|
}
|
|
161
147
|
return false;
|
|
@@ -183,7 +169,7 @@ class BaseSDK extends EventBase {
|
|
|
183
169
|
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
184
170
|
return new Promise((resolve, reject) => {
|
|
185
171
|
const _id = generateId(command.toLowerCase());
|
|
186
|
-
postMessage(
|
|
172
|
+
postMessage({ _id, command, ...args });
|
|
187
173
|
globalInstances[_id] = this;
|
|
188
174
|
this._addEventListener(_id, async (data) => {
|
|
189
175
|
if (data == null ? void 0 : data.errorMessage) {
|
|
@@ -199,7 +185,7 @@ class BaseSDK extends EventBase {
|
|
|
199
185
|
}
|
|
200
186
|
_postMessage(command, args, callBack) {
|
|
201
187
|
const _id = generateId(command.toLowerCase());
|
|
202
|
-
postMessage(
|
|
188
|
+
postMessage({ _id, command, ...args });
|
|
203
189
|
if (callBack) {
|
|
204
190
|
this._addEventListener(args.eventName, callBack);
|
|
205
191
|
}
|
|
@@ -215,13 +201,17 @@ class Component extends BaseSDK {
|
|
|
215
201
|
__privateMethod(this, _registerComponentAPIs, registerComponentAPIs_fn).call(this, props.componentMethods);
|
|
216
202
|
}
|
|
217
203
|
onMount(callback) {
|
|
218
|
-
this._postMessage(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
204
|
+
this._postMessage(
|
|
205
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
206
|
+
{
|
|
207
|
+
id: this._id,
|
|
208
|
+
eventName: EVENT_TYPES.COMPONENT_ON_MOUNT,
|
|
209
|
+
eventConfig: {
|
|
210
|
+
once: true
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
callback
|
|
214
|
+
);
|
|
225
215
|
}
|
|
226
216
|
refresh() {
|
|
227
217
|
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_REFRESH, {
|
|
@@ -249,11 +239,15 @@ registerComponentAPIs_fn = function(componentAPIs) {
|
|
|
249
239
|
parameters: args
|
|
250
240
|
});
|
|
251
241
|
} else if (Api.type === "event") {
|
|
252
|
-
this._postMessage(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
242
|
+
this._postMessage(
|
|
243
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
244
|
+
{
|
|
245
|
+
id: this._id,
|
|
246
|
+
eventName: Api.name,
|
|
247
|
+
eventConfig: args[1]
|
|
248
|
+
},
|
|
249
|
+
args[0]
|
|
250
|
+
);
|
|
257
251
|
}
|
|
258
252
|
};
|
|
259
253
|
});
|
|
@@ -266,13 +260,17 @@ class CustomComponent extends BaseSDK {
|
|
|
266
260
|
globalInstances[this._id] = this;
|
|
267
261
|
}
|
|
268
262
|
watchParams(callBack) {
|
|
269
|
-
this._postMessage(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
263
|
+
this._postMessage(
|
|
264
|
+
LISTENER_CMDS.CC_WATCH_PARAMS,
|
|
265
|
+
{
|
|
266
|
+
id: this._id,
|
|
267
|
+
eventName: EVENT_TYPES.CC_ON_PARAMS_CHANGE,
|
|
268
|
+
eventConfig: {
|
|
269
|
+
once: false
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
callBack
|
|
273
|
+
);
|
|
276
274
|
}
|
|
277
275
|
}
|
|
278
276
|
class Popup extends BaseSDK {
|
|
@@ -296,9 +294,14 @@ class Popup extends BaseSDK {
|
|
|
296
294
|
return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
|
|
297
295
|
}
|
|
298
296
|
getComponent(componentId) {
|
|
299
|
-
return this._postMessageAsync(
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
return this._postMessageAsync(
|
|
298
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
299
|
+
{ componentId },
|
|
300
|
+
true,
|
|
301
|
+
(data) => {
|
|
302
|
+
return new Component(data);
|
|
303
|
+
}
|
|
304
|
+
);
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
class Page extends BaseSDK {
|
|
@@ -336,7 +339,12 @@ class Page extends BaseSDK {
|
|
|
336
339
|
});
|
|
337
340
|
}
|
|
338
341
|
getComponent(componentId) {
|
|
339
|
-
return this._postMessageAsync(
|
|
342
|
+
return this._postMessageAsync(
|
|
343
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
344
|
+
{ componentId },
|
|
345
|
+
true,
|
|
346
|
+
(data) => new Component(data)
|
|
347
|
+
);
|
|
340
348
|
}
|
|
341
349
|
}
|
|
342
350
|
class Application extends BaseSDK {
|
|
@@ -417,17 +425,22 @@ class CustomComponentSDK extends BaseSDK {
|
|
|
417
425
|
return this._postMessageAsync(LISTENER_CMDS.API, { url, args });
|
|
418
426
|
}
|
|
419
427
|
initialize() {
|
|
420
|
-
return this._postMessageAsync(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
428
|
+
return this._postMessageAsync(
|
|
429
|
+
LISTENER_CMDS.CC_INITIALIZE,
|
|
430
|
+
{},
|
|
431
|
+
true,
|
|
432
|
+
(data) => {
|
|
433
|
+
this.app = new Application(data);
|
|
434
|
+
this.page = new Page(data);
|
|
435
|
+
this.context = new CustomComponent(data.componentId);
|
|
436
|
+
this.client = new Client();
|
|
437
|
+
this.formatter = new Formatter();
|
|
438
|
+
this.user = data.user;
|
|
439
|
+
this.account = data.account;
|
|
440
|
+
this.env = data.envDetails;
|
|
441
|
+
return this;
|
|
442
|
+
}
|
|
443
|
+
);
|
|
431
444
|
}
|
|
432
445
|
initialise() {
|
|
433
446
|
return this.initialize();
|
package/dist/kfsdk.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=(E,t,i)=>{if(!t.has(E))throw TypeError("Cannot "+i)};var o=(E,t,i)=>(c(E,t,"read from private field"),i?i.call(E):t.get(E)),p=(E,t,i)=>{if(t.has(E))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(E):t.set(E,i)},g=(E,t,i,a)=>(c(E,t,"write to private field"),a?a.call(E,i):t.set(E,i),i);var l=(E,t,i)=>(c(E,t,"access private method"),i);(function(E,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(E=typeof globalThis!="undefined"?globalThis:E||self,E.kf=t())})(this,function(){var A,M,L;"use strict";let E=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,s)=>(s&=63,s<36?e+=s.toString(36):s<62?e+=(s-26).toString(36).toUpperCase():s>62?e+="-":e+="_",e),"");const t={API:"API",GET_CONTEXT:"GET_CONTEXT",RETURN:"RETURN",GET_FORM_FIELD:"GET_FORM_FIELD",UPDATE_FORM:"UPDATE_FORM",GET_TABLE:"GET_TABLE",GET_TABLE_ROW:"GET_TABLE_ROW",ADD_TABLE_ROW:"ADD_TABLE_ROW",DELETE_TABLE_ROW:"DELETE_TABLE_ROW",TO_JSON:"TO_JSON",GET_TABLE_ROWS:"GET_TABLE_ROWS",MESSAGE:"MESSAGE",CONFIRM:"CONFIRM",ALERT:"ALERT",REDIRECT:"REDIRECT",OPEN_PAGE:"OPEN_PAGE",FORMAT_DATE:"FORMAT_DATE",FORMAT_DATE_TIME:"FORMAT_DATE_TIME",FORMAT_NUMBER:"FORMAT_NUMBER",FORMAT_CURRENCY:"FORMAT_CURRENCY",FORMAT_BOOLEAN:"FORMAT_BOOLEAN",GET_APP_VARIABLE:"GET_APP_VARIABLE",SET_APP_VARIABLE:"SET_APP_VARIABLE",GET_PAGE_VARIABLE:"GET_PAGE_VARIABLE",SET_PAGE_VARIABLE:"SET_PAGE_VARIABLE",GET_PAGE_PARAMS:"GET_PAGE_PARAMS",GET_ALL_PAGE_PARAMS:"GET_ALL_PAGE_PARAMS",PAGE_ON_CLOSE:"PAGE_ON_CLOSE",OPEN_POPUP:"OPEN_POPUP",GET_POPUP_PARAMS:"GET_POPUP_PARAMS",GET_ALL_POPUP_PARAMS:"GET_ALL_POPUP_PARAMS",CLOSE_POPUP:"CLOSE_POPUP",COMPONENT_GET:"COMPONENT_GET",COMPONENT_REFRESH:"COMPONENT_REFRESH",COMPONENT_SHOW:"COMPONENT_SHOW",COMPONENT_HIDE:"COMPONENT_HIDE",COMPONENT_ADD_EVENT_LISTENER:"COMPONENT_ADD_EVENT_LISTENER",CC_INITIALIZE:"CC_INITIALIZE",CC_WATCH_PARAMS:"CC_WATCH_PARAMS",WINDOW_NDEF_READER_NEW:"WINDOW_NDEF_READER_NEW",WINDOW_NDEF_READER_SCAN:"WINDOW_NDEF_READER_SCAN",WINDOW_NDEF_READER_WRITE:"WINDOW_NDEF_READER_WRITE",WINDOW_NDEF_READER_ADD_EVENT_LISTENER:"WINDOW_NDEF_READER_ADD_EVENT_LISTENER",WINDOW_NDEF_READER_MAKE_READONLY:"WINDOW_NDEF_READER_MAKE_READONLY",WINDOW_NDEF_READER_ABORT_SCAN:"WINDOW_NDEF_READER_ABORT_SCAN"},i={COMPONENT_ON_MOUNT:"componentOnMount",CC_ON_PARAMS_CHANGE:"onCustomComponentParamsChange"},a={POPUP_ID:"ACTIVE_POP_UP"};function u(n="lcncsdk"){return`${n}-${E()}`}const P={};function C(n){globalThis.parent&&globalThis.parent!==globalThis?globalThis.parent.postMessage(n,"*"):globalThis.postMessage(n)}function d(n){if(n.origin!==globalThis.location.origin){const e=n.data;if(e!=null&&e.isEvent){const{target:r,eventParams:R,eventName:h,eventConfig:N={}}=e;let T=P[r];T._dispatchEvent(h,R),N.once&&T._removeEventListener(h);return}let{_req:s,resp:_}=e;s!=null&&s._id&&P[s._id]._dispatchMessageEvents(s,_)}}globalThis.addEventListener("message",d);class S{constructor(){p(this,A,void 0);g(this,A,{})}_addEventListener(e,s){var _;o(this,A)[e]=((_=o(this,A))==null?void 0:_[e])||[],o(this,A)[e].push(s)}_removeEventListener(e,s){if(s){let _=o(this,A)[e].findIndex(s);_>-1&&o(this,A)[e].splice(_,1);return}Reflect.deleteProperty(o(this,A),e)}_dispatchEvent(e,s){return Array.isArray(o(this,A)[e])?(o(this,A)[e].forEach(_=>_(s)),!0):!1}_dispatchMessageEvents(e,s){let _=e._id;Array.isArray(o(this,A)[_])&&(o(this,A)[_].forEach(r=>{try{s&&Object.keys(s).length===1&&e.command!==t.API?r(Object.values(s)[0]):r(s)}catch(R){console.error("Message callback error: ",R)}}),this._removeEventListener(_))}}A=new WeakMap;class O extends S{_postMessageAsync(e,s,_,r){return new Promise((R,h)=>{const N=u(e.toLowerCase());C({_id:N,command:e,...s}),P[N]=this,this._addEventListener(N,async T=>{T!=null&&T.errorMessage?h(T):(_&&r&&(T=await r(T)),R(T))})})}_postMessage(e,s,_){const r=u(e.toLowerCase());C({_id:r,command:e,...s}),_&&this._addEventListener(s.eventName,_)}}class D extends O{constructor(s){super();p(this,M);this._id=s.componentId,this.type="Component",P[this._id]=this,l(this,M,L).call(this,s.componentMethods)}onMount(s){this._postMessage(t.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:i.COMPONENT_ON_MOUNT,eventConfig:{once:!0}},s)}refresh(){return this._postMessageAsync(t.COMPONENT_REFRESH,{id:this._id})}show(){return this._postMessageAsync(t.COMPONENT_SHOW,{id:this._id})}hide(){return this._postMessageAsync(t.COMPONENT_HIDE,{id:this._id})}}M=new WeakSet,L=function(s){s==null||s.forEach(_=>{this[_.name]=(...r)=>{if(_.type==="method")return this._postMessageAsync(`COMPONENT_${_.name}`,{id:this._id,parameters:r});_.type==="event"&&this._postMessage(t.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:_.name,eventConfig:r[1]},r[0])}})};class G extends O{constructor(e){super(),this._id=e,this.type="CustomComponent",P[this._id]=this}watchParams(e){this._postMessage(t.CC_WATCH_PARAMS,{id:this._id,eventName:i.CC_ON_PARAMS_CHANGE,eventConfig:{once:!1}},e)}}class f extends O{constructor(e){super(),this.type="Popup",this._id=e.popupId||a.POPUP_ID}getParameter(e){return this._postMessageAsync(t.GET_POPUP_PARAMS,{key:e,popupId:this._id})}getAllParameters(){return this._postMessageAsync(t.GET_ALL_POPUP_PARAMS,{popupId:this._id})}close(){return this._postMessageAsync(t.CLOSE_POPUP,{})}getComponent(e){return this._postMessageAsync(t.COMPONENT_GET,{componentId:e},!0,s=>new D(s))}}class I extends O{constructor(e){super(),this.type="Page",this.popup=new f({}),this._id=e.pageId}getParameter(e){return this._postMessageAsync(t.GET_PAGE_PARAMS,{key:e})}getAllParameters(){return this._postMessageAsync(t.GET_ALL_PAGE_PARAMS,{pageId:this._id})}getVariable(e){return this._postMessageAsync(t.GET_PAGE_VARIABLE,{key:e})}setVariable(e,s){return this._postMessageAsync(t.SET_PAGE_VARIABLE,{key:e,value:s})}openPopup(e,s){return this._postMessageAsync(t.OPEN_POPUP,{popupId:e,popupParams:s})}getComponent(e){return this._postMessageAsync(t.COMPONENT_GET,{componentId:e},!0,s=>new D(s))}}class y extends O{constructor(e){super(),this._id=e.appId,this.page=new I(e)}getVariable(e){return this._postMessageAsync(t.GET_APP_VARIABLE,{key:e})}setVariable(e,s){return this._postMessageAsync(t.SET_APP_VARIABLE,{key:e,value:s})}openPage(e,s){return this._postMessageAsync(t.OPEN_PAGE,{pageId:e,pageParams:s})}}class W extends O{showInfo(e){return super._postMessageAsync(t.MESSAGE,{message:e})}showConfirm(e){return super._postMessageAsync(t.CONFIRM,{data:{title:e.title,content:e.content,okText:e.okText||"Ok",cancelText:e.cancelText||"Cancel"}})}redirect(e){return super._postMessageAsync(t.REDIRECT,{url:e})}}class F extends O{toDate(e){return this._postMessageAsync(t.FORMAT_DATE,{date:e})}toDateTime(e){return this._postMessageAsync(t.FORMAT_DATE_TIME,{date:e})}toNumber(e){return this._postMessageAsync(t.FORMAT_NUMBER,{value:e})}toCurrency(e,s){return this._postMessageAsync(t.FORMAT_CURRENCY,{value:e,currencyCode:s})}toBoolean(e){return this._postMessageAsync(t.FORMAT_BOOLEAN,{value:e})}}class m extends O{constructor(){super()}api(e,s={}){return this._postMessageAsync(t.API,{url:e,args:s})}initialize(){return this._postMessageAsync(t.CC_INITIALIZE,{},!0,e=>(this.app=new y(e),this.page=new I(e),this.context=new G(e.componentId),this.client=new W,this.formatter=new F,this.user=e.user,this.account=e.account,this.env=e.envDetails,this))}initialise(){return this.initialize()}}var B=new m;return B});
|
package/dist/kfworkersdk.es.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
var __accessCheck = (obj, member, msg) => {
|
|
21
2
|
if (!member.has(obj))
|
|
22
3
|
throw TypeError("Cannot " + msg);
|
|
@@ -158,7 +139,9 @@ class EventBase {
|
|
|
158
139
|
}
|
|
159
140
|
_dispatchEvent(eventName, eventParams) {
|
|
160
141
|
if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
|
|
161
|
-
__privateGet(this, _listeners)[eventName].forEach(
|
|
142
|
+
__privateGet(this, _listeners)[eventName].forEach(
|
|
143
|
+
(callBack) => callBack(eventParams)
|
|
144
|
+
);
|
|
162
145
|
return true;
|
|
163
146
|
}
|
|
164
147
|
return false;
|
|
@@ -186,7 +169,7 @@ class BaseSDK extends EventBase {
|
|
|
186
169
|
_postMessageAsync(command, args, hasCallBack, callBack) {
|
|
187
170
|
return new Promise((resolve, reject) => {
|
|
188
171
|
const _id = generateId(command.toLowerCase());
|
|
189
|
-
postMessage(
|
|
172
|
+
postMessage({ _id, command, ...args });
|
|
190
173
|
globalInstances[_id] = this;
|
|
191
174
|
this._addEventListener(_id, async (data) => {
|
|
192
175
|
if (data == null ? void 0 : data.errorMessage) {
|
|
@@ -202,7 +185,7 @@ class BaseSDK extends EventBase {
|
|
|
202
185
|
}
|
|
203
186
|
_postMessage(command, args, callBack) {
|
|
204
187
|
const _id = generateId(command.toLowerCase());
|
|
205
|
-
postMessage(
|
|
188
|
+
postMessage({ _id, command, ...args });
|
|
206
189
|
if (callBack) {
|
|
207
190
|
this._addEventListener(args.eventName, callBack);
|
|
208
191
|
}
|
|
@@ -241,14 +224,22 @@ class Table extends BaseSDK {
|
|
|
241
224
|
this.instanceId = instanceId;
|
|
242
225
|
}
|
|
243
226
|
toJSON() {
|
|
244
|
-
return this._postMessageAsync(
|
|
245
|
-
|
|
246
|
-
|
|
227
|
+
return this._postMessageAsync(
|
|
228
|
+
LISTENER_CMDS.TO_JSON,
|
|
229
|
+
{
|
|
230
|
+
tableId: this.tableId
|
|
231
|
+
}
|
|
232
|
+
);
|
|
247
233
|
}
|
|
248
234
|
getRows() {
|
|
249
|
-
return this._postMessageAsync(
|
|
250
|
-
|
|
251
|
-
|
|
235
|
+
return this._postMessageAsync(
|
|
236
|
+
LISTENER_CMDS.GET_TABLE_ROWS,
|
|
237
|
+
{ tableId: this.tableId },
|
|
238
|
+
true,
|
|
239
|
+
(data) => {
|
|
240
|
+
return data.map((row) => new TableForm(this.instanceId, this.tableId, row.id));
|
|
241
|
+
}
|
|
242
|
+
);
|
|
252
243
|
}
|
|
253
244
|
getRow(rowId) {
|
|
254
245
|
return new TableForm(this.instanceId, this.tableId, rowId);
|
|
@@ -356,13 +347,17 @@ class Component extends BaseSDK {
|
|
|
356
347
|
__privateMethod(this, _registerComponentAPIs, registerComponentAPIs_fn).call(this, props.componentMethods);
|
|
357
348
|
}
|
|
358
349
|
onMount(callback) {
|
|
359
|
-
this._postMessage(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
350
|
+
this._postMessage(
|
|
351
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
352
|
+
{
|
|
353
|
+
id: this._id,
|
|
354
|
+
eventName: EVENT_TYPES.COMPONENT_ON_MOUNT,
|
|
355
|
+
eventConfig: {
|
|
356
|
+
once: true
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
callback
|
|
360
|
+
);
|
|
366
361
|
}
|
|
367
362
|
refresh() {
|
|
368
363
|
return this._postMessageAsync(LISTENER_CMDS.COMPONENT_REFRESH, {
|
|
@@ -390,11 +385,15 @@ registerComponentAPIs_fn = function(componentAPIs) {
|
|
|
390
385
|
parameters: args
|
|
391
386
|
});
|
|
392
387
|
} else if (Api.type === "event") {
|
|
393
|
-
this._postMessage(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
388
|
+
this._postMessage(
|
|
389
|
+
LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
|
|
390
|
+
{
|
|
391
|
+
id: this._id,
|
|
392
|
+
eventName: Api.name,
|
|
393
|
+
eventConfig: args[1]
|
|
394
|
+
},
|
|
395
|
+
args[0]
|
|
396
|
+
);
|
|
398
397
|
}
|
|
399
398
|
};
|
|
400
399
|
});
|
|
@@ -420,9 +419,14 @@ class Popup extends BaseSDK {
|
|
|
420
419
|
return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
|
|
421
420
|
}
|
|
422
421
|
getComponent(componentId) {
|
|
423
|
-
return this._postMessageAsync(
|
|
424
|
-
|
|
425
|
-
|
|
422
|
+
return this._postMessageAsync(
|
|
423
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
424
|
+
{ componentId },
|
|
425
|
+
true,
|
|
426
|
+
(data) => {
|
|
427
|
+
return new Component(data);
|
|
428
|
+
}
|
|
429
|
+
);
|
|
426
430
|
}
|
|
427
431
|
}
|
|
428
432
|
class Page extends BaseSDK {
|
|
@@ -460,7 +464,12 @@ class Page extends BaseSDK {
|
|
|
460
464
|
});
|
|
461
465
|
}
|
|
462
466
|
getComponent(componentId) {
|
|
463
|
-
return this._postMessageAsync(
|
|
467
|
+
return this._postMessageAsync(
|
|
468
|
+
LISTENER_CMDS.COMPONENT_GET,
|
|
469
|
+
{ componentId },
|
|
470
|
+
true,
|
|
471
|
+
(data) => new Component(data)
|
|
472
|
+
);
|
|
464
473
|
}
|
|
465
474
|
}
|
|
466
475
|
class Application extends BaseSDK {
|
|
@@ -492,44 +501,68 @@ class NDEFReader extends BaseSDK {
|
|
|
492
501
|
super();
|
|
493
502
|
this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
|
|
494
503
|
globalInstances[this.id] = this;
|
|
495
|
-
this._postMessage(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
504
|
+
this._postMessage(
|
|
505
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
|
|
506
|
+
{
|
|
507
|
+
id: this.id,
|
|
508
|
+
operation: "new"
|
|
509
|
+
},
|
|
510
|
+
(data) => {
|
|
511
|
+
}
|
|
512
|
+
);
|
|
500
513
|
}
|
|
501
514
|
scan() {
|
|
502
515
|
return new Promise((resolve, reject) => {
|
|
503
|
-
this._postMessage(
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
516
|
+
this._postMessage(
|
|
517
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
|
|
518
|
+
{ id: this.id, operation: "scan" },
|
|
519
|
+
({ data, err }) => {
|
|
520
|
+
console.log("scan data from main window ", data);
|
|
521
|
+
resolve(data);
|
|
522
|
+
}
|
|
523
|
+
);
|
|
507
524
|
});
|
|
508
525
|
}
|
|
509
526
|
write(data) {
|
|
510
527
|
return new Promise((resolve, reject) => {
|
|
511
|
-
this._postMessage(
|
|
512
|
-
|
|
528
|
+
this._postMessage(
|
|
529
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
|
|
530
|
+
{ id: this.id, operation: "write", data },
|
|
531
|
+
({ data: data2, err }) => {
|
|
532
|
+
}
|
|
533
|
+
);
|
|
513
534
|
});
|
|
514
535
|
}
|
|
515
536
|
addEventListener(eventName, cb) {
|
|
516
|
-
this._postMessage(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
537
|
+
this._postMessage(
|
|
538
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
|
|
539
|
+
{
|
|
540
|
+
id: this.id,
|
|
541
|
+
operation: "addEventListener",
|
|
542
|
+
eventName
|
|
543
|
+
},
|
|
544
|
+
() => {
|
|
545
|
+
}
|
|
546
|
+
);
|
|
522
547
|
}
|
|
523
548
|
makeReadOnly() {
|
|
524
549
|
return new Promise((resolve, reject) => {
|
|
525
|
-
this._postMessage(
|
|
526
|
-
|
|
550
|
+
this._postMessage(
|
|
551
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
|
|
552
|
+
{ id: this.id, operation: "makeReadOnly" },
|
|
553
|
+
({ data, err }) => {
|
|
554
|
+
}
|
|
555
|
+
);
|
|
527
556
|
});
|
|
528
557
|
}
|
|
529
558
|
abortScan() {
|
|
530
559
|
return new Promise((resolve, reject) => {
|
|
531
|
-
this._postMessage(
|
|
532
|
-
|
|
560
|
+
this._postMessage(
|
|
561
|
+
LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
|
|
562
|
+
{ id: this.id, operation: "abortScan" },
|
|
563
|
+
({ data, err }) => {
|
|
564
|
+
}
|
|
565
|
+
);
|
|
533
566
|
});
|
|
534
567
|
}
|
|
535
568
|
}
|
|
@@ -541,7 +574,11 @@ class LowcodeSDK extends BaseSDK {
|
|
|
541
574
|
super();
|
|
542
575
|
__privateAdd(this, _csrfToken, void 0);
|
|
543
576
|
if (props.tableId && props.tableRowId) {
|
|
544
|
-
this.context = new TableForm(
|
|
577
|
+
this.context = new TableForm(
|
|
578
|
+
props.formInstanceId,
|
|
579
|
+
props.tableId,
|
|
580
|
+
props.tableRowId
|
|
581
|
+
);
|
|
545
582
|
} else if (props.formInstanceId) {
|
|
546
583
|
this.context = new Form(props.formInstanceId);
|
|
547
584
|
} else if (props.popupId) {
|
|
@@ -562,11 +599,13 @@ class LowcodeSDK extends BaseSDK {
|
|
|
562
599
|
__privateSet(this, _csrfToken, props.csrfToken);
|
|
563
600
|
}
|
|
564
601
|
async api(url, args) {
|
|
565
|
-
const response = await globalThis.fetch(url,
|
|
566
|
-
|
|
602
|
+
const response = await globalThis.fetch(url, {
|
|
603
|
+
...args,
|
|
604
|
+
headers: {
|
|
605
|
+
...(args == null ? void 0 : args.headers) || {},
|
|
567
606
|
"X-Csrf-Token": __privateGet(this, _csrfToken)
|
|
568
|
-
}
|
|
569
|
-
})
|
|
607
|
+
}
|
|
608
|
+
});
|
|
570
609
|
const contentType = response.headers.get("content-type");
|
|
571
610
|
if (contentType && contentType.includes("application/json")) {
|
|
572
611
|
return await response.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kissflow/lowcode-client-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "JavaScript SDK for developing over the Kissflow lowcode platform",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -29,20 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/kissflow/lcnc-sdk-js#readme",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"http-server": "^0.12.3",
|
|
34
|
-
"ts-loader": "^9.2.5",
|
|
32
|
+
"ts-file-parser": "0.0.21",
|
|
35
33
|
"typescript": "^4.3.5",
|
|
36
|
-
"vite": "^2.9.8"
|
|
37
|
-
"webpack": "^5.52.1",
|
|
38
|
-
"webpack-cli": "^4.8.0",
|
|
39
|
-
"webpack-dev-server": "^3.11.2"
|
|
34
|
+
"vite": "^2.9.8"
|
|
40
35
|
},
|
|
41
36
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"@lingui/react": "^2",
|
|
44
|
-
"nanoid": "^3.1.30",
|
|
45
|
-
"ts-file-parser": "0.0.21"
|
|
37
|
+
"nanoid": "^3.1.30"
|
|
46
38
|
},
|
|
47
39
|
"scripts": {
|
|
48
40
|
"start": "vite serve",
|