@kissflow/lowcode-client-sdk 1.0.23 → 1.0.24-beta.2
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/dist/index.d.ts +50 -38
- package/dist/kf.lowcodeworkersdk.es.js +138 -22
- package/dist/kf.nocodeworkersdk.es.js +73 -8
- package/dist/kfsdk.es.js +180 -64
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +23 -11
- package/dist/lowcode.types.d.ts +2 -1
- package/dist/nocode.d.ts +22 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ declare module "core/constants" {
|
|
|
48
48
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
49
|
DECISION_TABLE_EXECUTE: string;
|
|
50
50
|
DATAFORM_IMPORT_CSV: string;
|
|
51
|
-
BOARD_IMPORT_CSV: string;
|
|
52
51
|
};
|
|
53
52
|
export const EVENT_TYPES: {
|
|
54
53
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -72,9 +71,47 @@ declare module "core/index" {
|
|
|
72
71
|
export class BaseSDK extends EventBase {
|
|
73
72
|
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
74
73
|
_postMessage(command: string, args: any, callBack?: any): void;
|
|
74
|
+
_postMessageSync(command: string, args: any): any;
|
|
75
75
|
}
|
|
76
76
|
export * from "core/constants";
|
|
77
77
|
}
|
|
78
|
+
declare module "utils/client" {
|
|
79
|
+
import { BaseSDK } from "core/index";
|
|
80
|
+
export class Client extends BaseSDK {
|
|
81
|
+
showInfo(message: string): any;
|
|
82
|
+
showConfirm(args: {
|
|
83
|
+
title: string;
|
|
84
|
+
content: string;
|
|
85
|
+
okText: string;
|
|
86
|
+
cancelText: string;
|
|
87
|
+
}): any;
|
|
88
|
+
redirect(url: string): any;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
declare module "utils/formatter" {
|
|
92
|
+
import { BaseSDK } from "core/index";
|
|
93
|
+
export class Formatter extends BaseSDK {
|
|
94
|
+
toDate(date: string): any;
|
|
95
|
+
toDateTime(date: string): any;
|
|
96
|
+
toNumber(value: string): any;
|
|
97
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
98
|
+
toBoolean(value: string): any;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
declare module "utils/index" {
|
|
102
|
+
export * from "utils/client";
|
|
103
|
+
export * from "utils/formatter";
|
|
104
|
+
export const isObject: (value: any) => boolean;
|
|
105
|
+
}
|
|
106
|
+
declare module "core/proxy" {
|
|
107
|
+
export class CreateProxy {
|
|
108
|
+
path: string[];
|
|
109
|
+
parent: object;
|
|
110
|
+
constructor(parent: object, target?: {}, path?: any[]);
|
|
111
|
+
get(target: object, property: string): any;
|
|
112
|
+
set(target: object, property: string, value: any, reciever: any): any;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
78
115
|
declare module "types/external" {
|
|
79
116
|
export type userObject = {
|
|
80
117
|
_id: string;
|
|
@@ -168,6 +205,7 @@ declare module "app/page" {
|
|
|
168
205
|
_id: string;
|
|
169
206
|
popup: Popup;
|
|
170
207
|
type: string;
|
|
208
|
+
variable: PageVariable;
|
|
171
209
|
constructor(props: PageContext);
|
|
172
210
|
getParameter(key: string): any;
|
|
173
211
|
getAllParameters(): any;
|
|
@@ -176,6 +214,11 @@ declare module "app/page" {
|
|
|
176
214
|
openPopup(popupId: string, popupParams: object): any;
|
|
177
215
|
getComponent(componentId: string): Component;
|
|
178
216
|
}
|
|
217
|
+
class PageVariable extends BaseSDK {
|
|
218
|
+
constructor();
|
|
219
|
+
get(key: any, path: any): any;
|
|
220
|
+
set(key: any, value: any, path: any): any;
|
|
221
|
+
}
|
|
179
222
|
}
|
|
180
223
|
declare module "app/decisiontable" {
|
|
181
224
|
import { BaseSDK } from "core/index";
|
|
@@ -193,23 +236,15 @@ declare module "app/dataform" {
|
|
|
193
236
|
importCSV(defaultValues: object): any;
|
|
194
237
|
}
|
|
195
238
|
}
|
|
196
|
-
declare module "board/index" {
|
|
197
|
-
import { BaseSDK } from "core/index";
|
|
198
|
-
export class Board extends BaseSDK {
|
|
199
|
-
private _id;
|
|
200
|
-
constructor(flowId: string);
|
|
201
|
-
importCSV(defaultValues: object): any;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
239
|
declare module "app/index" {
|
|
205
240
|
import { BaseSDK } from "core/index";
|
|
206
241
|
import { Page } from "app/page";
|
|
207
242
|
import { AppContext } from "types/internal";
|
|
208
243
|
import { DecisionTable } from "app/decisiontable";
|
|
209
244
|
import { Dataform } from "app/dataform";
|
|
210
|
-
import { Board } from "board/index";
|
|
211
245
|
export class Application extends BaseSDK {
|
|
212
246
|
page: Page;
|
|
247
|
+
variable: AppVariable;
|
|
213
248
|
_id: string;
|
|
214
249
|
constructor(props: AppContext);
|
|
215
250
|
getVariable(key: string): any;
|
|
@@ -217,39 +252,16 @@ declare module "app/index" {
|
|
|
217
252
|
openPage(pageId: string, pageParams: object): any;
|
|
218
253
|
getDecisionTable(flowId: string): DecisionTable;
|
|
219
254
|
getDataform(flowId: string): Dataform;
|
|
220
|
-
|
|
255
|
+
}
|
|
256
|
+
class AppVariable extends BaseSDK {
|
|
257
|
+
constructor();
|
|
258
|
+
get(key: any, path: any): any;
|
|
259
|
+
set(key: any, value: any, path: any): any;
|
|
221
260
|
}
|
|
222
261
|
export * from "app/component";
|
|
223
262
|
export { Page };
|
|
224
263
|
export * from "app/popup";
|
|
225
264
|
}
|
|
226
|
-
declare module "utils/client" {
|
|
227
|
-
import { BaseSDK } from "core/index";
|
|
228
|
-
export class Client extends BaseSDK {
|
|
229
|
-
showInfo(message: string): any;
|
|
230
|
-
showConfirm(args: {
|
|
231
|
-
title: string;
|
|
232
|
-
content: string;
|
|
233
|
-
okText: string;
|
|
234
|
-
cancelText: string;
|
|
235
|
-
}): any;
|
|
236
|
-
redirect(url: string): any;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
declare module "utils/formatter" {
|
|
240
|
-
import { BaseSDK } from "core/index";
|
|
241
|
-
export class Formatter extends BaseSDK {
|
|
242
|
-
toDate(date: string): any;
|
|
243
|
-
toDateTime(date: string): any;
|
|
244
|
-
toNumber(value: string): any;
|
|
245
|
-
toCurrency(value: string, currencyCode: string): any;
|
|
246
|
-
toBoolean(value: string): any;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
declare module "utils/index" {
|
|
250
|
-
export * from "utils/client";
|
|
251
|
-
export * from "utils/formatter";
|
|
252
|
-
}
|
|
253
265
|
declare module "index" {
|
|
254
266
|
import { BaseSDK } from "core/index";
|
|
255
267
|
import { Application, Page, CustomComponent } from "app/index";
|
|
@@ -20,7 +20,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
20
20
|
__accessCheck(obj, member, "access private method");
|
|
21
21
|
return method;
|
|
22
22
|
};
|
|
23
|
-
var _listeners, _registerComponentAPIs, registerComponentAPIs_fn, _csrfToken;
|
|
23
|
+
var _listeners, _textEncoder, _textDecoder, _registerComponentAPIs, registerComponentAPIs_fn, _csrfToken;
|
|
24
24
|
let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
25
25
|
byte &= 63;
|
|
26
26
|
if (byte < 36) {
|
|
@@ -82,8 +82,7 @@ const LISTENER_CMDS = {
|
|
|
82
82
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
83
83
|
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
84
84
|
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
85
|
-
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
86
|
-
BOARD_IMPORT_CSV: "BOARD_IMPORT_CSV"
|
|
85
|
+
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
87
86
|
};
|
|
88
87
|
const EVENT_TYPES = {
|
|
89
88
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
@@ -96,6 +95,16 @@ function generateId(prefix = "lcncsdk") {
|
|
|
96
95
|
return `${prefix}-${nanoid()}`;
|
|
97
96
|
}
|
|
98
97
|
const globalInstances = {};
|
|
98
|
+
function processResponse(req, resp) {
|
|
99
|
+
if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
|
|
100
|
+
let value = Object.values(resp)[0];
|
|
101
|
+
if (value === "undefined")
|
|
102
|
+
return void 0;
|
|
103
|
+
return value;
|
|
104
|
+
} else {
|
|
105
|
+
return resp;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
99
108
|
function postMessage(args) {
|
|
100
109
|
if (globalThis.parent && globalThis.parent !== globalThis) {
|
|
101
110
|
globalThis.parent.postMessage(args, "*");
|
|
@@ -155,11 +164,8 @@ class EventBase {
|
|
|
155
164
|
if (Array.isArray(__privateGet(this, _listeners)[target])) {
|
|
156
165
|
__privateGet(this, _listeners)[target].forEach((listener) => {
|
|
157
166
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
} else {
|
|
161
|
-
listener(resp);
|
|
162
|
-
}
|
|
167
|
+
let processedResp = processResponse(req, resp);
|
|
168
|
+
listener(processedResp);
|
|
163
169
|
} catch (err) {
|
|
164
170
|
console.error("Message callback error: ", err);
|
|
165
171
|
}
|
|
@@ -194,7 +200,66 @@ class BaseSDK extends EventBase {
|
|
|
194
200
|
this._addEventListener(args.eventName, callBack);
|
|
195
201
|
}
|
|
196
202
|
}
|
|
203
|
+
_postMessageSync(command, args) {
|
|
204
|
+
let intialValue = 0;
|
|
205
|
+
const _id = generateId(command.toLowerCase());
|
|
206
|
+
let data = { _id, command, ...args };
|
|
207
|
+
let atomics = new AtomicsHandler();
|
|
208
|
+
atomics.reset();
|
|
209
|
+
atomics.store(0, intialValue);
|
|
210
|
+
atomics.encodeData(1, data);
|
|
211
|
+
postMessage(atomics.sab);
|
|
212
|
+
atomics.wait(0, intialValue, 1e4);
|
|
213
|
+
let decodedData = atomics.decodeData();
|
|
214
|
+
let { _req: req, resp } = decodedData;
|
|
215
|
+
let processedResp = processResponse(req, resp);
|
|
216
|
+
if (processedResp == null ? void 0 : processedResp.isError) {
|
|
217
|
+
throw new Error(`Error: ${JSON.stringify(processedResp, null, 2)}`);
|
|
218
|
+
}
|
|
219
|
+
return processedResp;
|
|
220
|
+
}
|
|
197
221
|
}
|
|
222
|
+
let sharedArrayBufferInstance;
|
|
223
|
+
class AtomicsHandler {
|
|
224
|
+
constructor() {
|
|
225
|
+
__privateAdd(this, _textEncoder, void 0);
|
|
226
|
+
__privateAdd(this, _textDecoder, void 0);
|
|
227
|
+
__privateSet(this, _textEncoder, new TextEncoder());
|
|
228
|
+
__privateSet(this, _textDecoder, new TextDecoder());
|
|
229
|
+
sharedArrayBufferInstance = sharedArrayBufferInstance || new SharedArrayBuffer(1024 * 1024);
|
|
230
|
+
this.sab = sharedArrayBufferInstance;
|
|
231
|
+
this.int32Array = new Int32Array(this.sab);
|
|
232
|
+
}
|
|
233
|
+
load(index = 0) {
|
|
234
|
+
return Atomics.load(this.int32Array, index);
|
|
235
|
+
}
|
|
236
|
+
store(index = 0, data) {
|
|
237
|
+
return Atomics.store(this.int32Array, index, data);
|
|
238
|
+
}
|
|
239
|
+
reset() {
|
|
240
|
+
return this.int32Array.fill(0);
|
|
241
|
+
}
|
|
242
|
+
notify(index = 0, count = 1) {
|
|
243
|
+
return Atomics.notify(this.int32Array, index, count);
|
|
244
|
+
}
|
|
245
|
+
wait(index, value, timeout) {
|
|
246
|
+
return Atomics.wait(this.int32Array, index, value, timeout);
|
|
247
|
+
}
|
|
248
|
+
encodeData(index = 0, data) {
|
|
249
|
+
const replacer = (key, value) => value === void 0 ? "undefined" : value;
|
|
250
|
+
let string = JSON.stringify(data, replacer);
|
|
251
|
+
let encodedData = __privateGet(this, _textEncoder).encode(string);
|
|
252
|
+
this.int32Array.set(encodedData, index);
|
|
253
|
+
return this.int32Array;
|
|
254
|
+
}
|
|
255
|
+
decodeData() {
|
|
256
|
+
let uInt8Array = new Uint8Array(this.int32Array);
|
|
257
|
+
let string = __privateGet(this, _textDecoder).decode(uInt8Array).replaceAll(/\x00/g, "");
|
|
258
|
+
return JSON.parse(string);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
_textEncoder = new WeakMap();
|
|
262
|
+
_textDecoder = new WeakMap();
|
|
198
263
|
class Form extends BaseSDK {
|
|
199
264
|
constructor(instanceId) {
|
|
200
265
|
super();
|
|
@@ -352,6 +417,28 @@ class Formatter extends BaseSDK {
|
|
|
352
417
|
});
|
|
353
418
|
}
|
|
354
419
|
}
|
|
420
|
+
const isObject = (value) => value !== null && typeof value === "object";
|
|
421
|
+
class CreateProxy {
|
|
422
|
+
constructor(parent, target = {}, path = []) {
|
|
423
|
+
this.parent = parent;
|
|
424
|
+
this.path = path;
|
|
425
|
+
return new Proxy(target, this);
|
|
426
|
+
}
|
|
427
|
+
get(target, property) {
|
|
428
|
+
let value = this.parent.get(property, this.path);
|
|
429
|
+
if (isObject(value)) {
|
|
430
|
+
return new CreateProxy(this.parent, value, [...this.path, property]);
|
|
431
|
+
}
|
|
432
|
+
return value;
|
|
433
|
+
}
|
|
434
|
+
set(target, property, value, reciever) {
|
|
435
|
+
let updatedValue = this.parent.set(property, value, this.path);
|
|
436
|
+
if (isObject(updatedValue)) {
|
|
437
|
+
return new CreateProxy(this.parent, updatedValue, [...this.path, property]);
|
|
438
|
+
}
|
|
439
|
+
return updatedValue;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
355
442
|
class Component extends BaseSDK {
|
|
356
443
|
constructor(props) {
|
|
357
444
|
super();
|
|
@@ -450,6 +537,7 @@ class Page extends BaseSDK {
|
|
|
450
537
|
this.type = "Page";
|
|
451
538
|
this.popup = new Popup({});
|
|
452
539
|
this._id = props.pageId;
|
|
540
|
+
this.variable = new PageVariable();
|
|
453
541
|
}
|
|
454
542
|
getParameter(key) {
|
|
455
543
|
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_PARAMS, {
|
|
@@ -487,6 +575,27 @@ class Page extends BaseSDK {
|
|
|
487
575
|
);
|
|
488
576
|
}
|
|
489
577
|
}
|
|
578
|
+
class PageVariable extends BaseSDK {
|
|
579
|
+
constructor() {
|
|
580
|
+
super();
|
|
581
|
+
return new CreateProxy(this);
|
|
582
|
+
}
|
|
583
|
+
get(key, path) {
|
|
584
|
+
let args = {
|
|
585
|
+
key,
|
|
586
|
+
path
|
|
587
|
+
};
|
|
588
|
+
return this._postMessageSync(LISTENER_CMDS.GET_PAGE_VARIABLE, args);
|
|
589
|
+
}
|
|
590
|
+
set(key, value, path) {
|
|
591
|
+
let args = {
|
|
592
|
+
key,
|
|
593
|
+
value,
|
|
594
|
+
path
|
|
595
|
+
};
|
|
596
|
+
return this._postMessageSync(LISTENER_CMDS.SET_PAGE_VARIABLE, args);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
490
599
|
class DecisionTable extends BaseSDK {
|
|
491
600
|
constructor(flowId) {
|
|
492
601
|
super();
|
|
@@ -511,23 +620,12 @@ class Dataform extends BaseSDK {
|
|
|
511
620
|
});
|
|
512
621
|
}
|
|
513
622
|
}
|
|
514
|
-
class Board extends BaseSDK {
|
|
515
|
-
constructor(flowId) {
|
|
516
|
-
super();
|
|
517
|
-
this._id = flowId;
|
|
518
|
-
}
|
|
519
|
-
importCSV(defaultValues) {
|
|
520
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_IMPORT_CSV, {
|
|
521
|
-
flowId: this._id,
|
|
522
|
-
defaultValues
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
623
|
class Application extends BaseSDK {
|
|
527
624
|
constructor(props) {
|
|
528
625
|
super();
|
|
529
626
|
this._id = props.appId;
|
|
530
627
|
this.page = new Page(props);
|
|
628
|
+
this.variable = new AppVariable();
|
|
531
629
|
}
|
|
532
630
|
getVariable(key) {
|
|
533
631
|
return this._postMessageAsync(LISTENER_CMDS.GET_APP_VARIABLE, {
|
|
@@ -552,8 +650,26 @@ class Application extends BaseSDK {
|
|
|
552
650
|
getDataform(flowId) {
|
|
553
651
|
return new Dataform(flowId);
|
|
554
652
|
}
|
|
555
|
-
|
|
556
|
-
|
|
653
|
+
}
|
|
654
|
+
class AppVariable extends BaseSDK {
|
|
655
|
+
constructor() {
|
|
656
|
+
super();
|
|
657
|
+
return new CreateProxy(this);
|
|
658
|
+
}
|
|
659
|
+
get(key, path) {
|
|
660
|
+
let args = {
|
|
661
|
+
key,
|
|
662
|
+
path
|
|
663
|
+
};
|
|
664
|
+
return this._postMessageSync(LISTENER_CMDS.GET_APP_VARIABLE, args);
|
|
665
|
+
}
|
|
666
|
+
set(key, value, path) {
|
|
667
|
+
let args = {
|
|
668
|
+
key,
|
|
669
|
+
value,
|
|
670
|
+
path
|
|
671
|
+
};
|
|
672
|
+
return this._postMessageSync(LISTENER_CMDS.SET_APP_VARIABLE, args);
|
|
557
673
|
}
|
|
558
674
|
}
|
|
559
675
|
class NDEFReader extends BaseSDK {
|
|
@@ -16,7 +16,7 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
16
16
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
17
|
return value;
|
|
18
18
|
};
|
|
19
|
-
var _listeners, _csrfToken;
|
|
19
|
+
var _listeners, _textEncoder, _textDecoder, _csrfToken;
|
|
20
20
|
let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
21
21
|
byte &= 63;
|
|
22
22
|
if (byte < 36) {
|
|
@@ -78,13 +78,22 @@ const LISTENER_CMDS = {
|
|
|
78
78
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
79
79
|
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
80
80
|
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
81
|
-
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
82
|
-
BOARD_IMPORT_CSV: "BOARD_IMPORT_CSV"
|
|
81
|
+
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
83
82
|
};
|
|
84
83
|
function generateId(prefix = "lcncsdk") {
|
|
85
84
|
return `${prefix}-${nanoid()}`;
|
|
86
85
|
}
|
|
87
86
|
const globalInstances = {};
|
|
87
|
+
function processResponse(req, resp) {
|
|
88
|
+
if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
|
|
89
|
+
let value = Object.values(resp)[0];
|
|
90
|
+
if (value === "undefined")
|
|
91
|
+
return void 0;
|
|
92
|
+
return value;
|
|
93
|
+
} else {
|
|
94
|
+
return resp;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
88
97
|
function postMessage(args) {
|
|
89
98
|
if (globalThis.parent && globalThis.parent !== globalThis) {
|
|
90
99
|
globalThis.parent.postMessage(args, "*");
|
|
@@ -144,11 +153,8 @@ class EventBase {
|
|
|
144
153
|
if (Array.isArray(__privateGet(this, _listeners)[target])) {
|
|
145
154
|
__privateGet(this, _listeners)[target].forEach((listener) => {
|
|
146
155
|
try {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} else {
|
|
150
|
-
listener(resp);
|
|
151
|
-
}
|
|
156
|
+
let processedResp = processResponse(req, resp);
|
|
157
|
+
listener(processedResp);
|
|
152
158
|
} catch (err) {
|
|
153
159
|
console.error("Message callback error: ", err);
|
|
154
160
|
}
|
|
@@ -183,7 +189,66 @@ class BaseSDK extends EventBase {
|
|
|
183
189
|
this._addEventListener(args.eventName, callBack);
|
|
184
190
|
}
|
|
185
191
|
}
|
|
192
|
+
_postMessageSync(command, args) {
|
|
193
|
+
let intialValue = 0;
|
|
194
|
+
const _id = generateId(command.toLowerCase());
|
|
195
|
+
let data = { _id, command, ...args };
|
|
196
|
+
let atomics = new AtomicsHandler();
|
|
197
|
+
atomics.reset();
|
|
198
|
+
atomics.store(0, intialValue);
|
|
199
|
+
atomics.encodeData(1, data);
|
|
200
|
+
postMessage(atomics.sab);
|
|
201
|
+
atomics.wait(0, intialValue, 1e4);
|
|
202
|
+
let decodedData = atomics.decodeData();
|
|
203
|
+
let { _req: req, resp } = decodedData;
|
|
204
|
+
let processedResp = processResponse(req, resp);
|
|
205
|
+
if (processedResp == null ? void 0 : processedResp.isError) {
|
|
206
|
+
throw new Error(`Error: ${JSON.stringify(processedResp, null, 2)}`);
|
|
207
|
+
}
|
|
208
|
+
return processedResp;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
let sharedArrayBufferInstance;
|
|
212
|
+
class AtomicsHandler {
|
|
213
|
+
constructor() {
|
|
214
|
+
__privateAdd(this, _textEncoder, void 0);
|
|
215
|
+
__privateAdd(this, _textDecoder, void 0);
|
|
216
|
+
__privateSet(this, _textEncoder, new TextEncoder());
|
|
217
|
+
__privateSet(this, _textDecoder, new TextDecoder());
|
|
218
|
+
sharedArrayBufferInstance = sharedArrayBufferInstance || new SharedArrayBuffer(1024 * 1024);
|
|
219
|
+
this.sab = sharedArrayBufferInstance;
|
|
220
|
+
this.int32Array = new Int32Array(this.sab);
|
|
221
|
+
}
|
|
222
|
+
load(index = 0) {
|
|
223
|
+
return Atomics.load(this.int32Array, index);
|
|
224
|
+
}
|
|
225
|
+
store(index = 0, data) {
|
|
226
|
+
return Atomics.store(this.int32Array, index, data);
|
|
227
|
+
}
|
|
228
|
+
reset() {
|
|
229
|
+
return this.int32Array.fill(0);
|
|
230
|
+
}
|
|
231
|
+
notify(index = 0, count = 1) {
|
|
232
|
+
return Atomics.notify(this.int32Array, index, count);
|
|
233
|
+
}
|
|
234
|
+
wait(index, value, timeout) {
|
|
235
|
+
return Atomics.wait(this.int32Array, index, value, timeout);
|
|
236
|
+
}
|
|
237
|
+
encodeData(index = 0, data) {
|
|
238
|
+
const replacer = (key, value) => value === void 0 ? "undefined" : value;
|
|
239
|
+
let string = JSON.stringify(data, replacer);
|
|
240
|
+
let encodedData = __privateGet(this, _textEncoder).encode(string);
|
|
241
|
+
this.int32Array.set(encodedData, index);
|
|
242
|
+
return this.int32Array;
|
|
243
|
+
}
|
|
244
|
+
decodeData() {
|
|
245
|
+
let uInt8Array = new Uint8Array(this.int32Array);
|
|
246
|
+
let string = __privateGet(this, _textDecoder).decode(uInt8Array).replaceAll(/\x00/g, "");
|
|
247
|
+
return JSON.parse(string);
|
|
248
|
+
}
|
|
186
249
|
}
|
|
250
|
+
_textEncoder = new WeakMap();
|
|
251
|
+
_textDecoder = new WeakMap();
|
|
187
252
|
class Form extends BaseSDK {
|
|
188
253
|
constructor(instanceId) {
|
|
189
254
|
super();
|
package/dist/kfsdk.es.js
CHANGED
|
@@ -20,7 +20,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
20
20
|
__accessCheck(obj, member, "access private method");
|
|
21
21
|
return method;
|
|
22
22
|
};
|
|
23
|
-
var _listeners, _registerComponentAPIs, registerComponentAPIs_fn;
|
|
23
|
+
var _listeners, _textEncoder, _textDecoder, _registerComponentAPIs, registerComponentAPIs_fn;
|
|
24
24
|
let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
25
25
|
byte &= 63;
|
|
26
26
|
if (byte < 36) {
|
|
@@ -82,8 +82,7 @@ const LISTENER_CMDS = {
|
|
|
82
82
|
WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
|
|
83
83
|
WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
|
|
84
84
|
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",
|
|
85
|
-
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
86
|
-
BOARD_IMPORT_CSV: "BOARD_IMPORT_CSV"
|
|
85
|
+
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
|
|
87
86
|
};
|
|
88
87
|
const EVENT_TYPES = {
|
|
89
88
|
COMPONENT_ON_MOUNT: "componentOnMount",
|
|
@@ -96,6 +95,16 @@ function generateId(prefix = "lcncsdk") {
|
|
|
96
95
|
return `${prefix}-${nanoid()}`;
|
|
97
96
|
}
|
|
98
97
|
const globalInstances = {};
|
|
98
|
+
function processResponse(req, resp) {
|
|
99
|
+
if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
|
|
100
|
+
let value = Object.values(resp)[0];
|
|
101
|
+
if (value === "undefined")
|
|
102
|
+
return void 0;
|
|
103
|
+
return value;
|
|
104
|
+
} else {
|
|
105
|
+
return resp;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
99
108
|
function postMessage(args) {
|
|
100
109
|
if (globalThis.parent && globalThis.parent !== globalThis) {
|
|
101
110
|
globalThis.parent.postMessage(args, "*");
|
|
@@ -155,11 +164,8 @@ class EventBase {
|
|
|
155
164
|
if (Array.isArray(__privateGet(this, _listeners)[target])) {
|
|
156
165
|
__privateGet(this, _listeners)[target].forEach((listener) => {
|
|
157
166
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
} else {
|
|
161
|
-
listener(resp);
|
|
162
|
-
}
|
|
167
|
+
let processedResp = processResponse(req, resp);
|
|
168
|
+
listener(processedResp);
|
|
163
169
|
} catch (err) {
|
|
164
170
|
console.error("Message callback error: ", err);
|
|
165
171
|
}
|
|
@@ -194,6 +200,133 @@ class BaseSDK extends EventBase {
|
|
|
194
200
|
this._addEventListener(args.eventName, callBack);
|
|
195
201
|
}
|
|
196
202
|
}
|
|
203
|
+
_postMessageSync(command, args) {
|
|
204
|
+
let intialValue = 0;
|
|
205
|
+
const _id = generateId(command.toLowerCase());
|
|
206
|
+
let data = { _id, command, ...args };
|
|
207
|
+
let atomics = new AtomicsHandler();
|
|
208
|
+
atomics.reset();
|
|
209
|
+
atomics.store(0, intialValue);
|
|
210
|
+
atomics.encodeData(1, data);
|
|
211
|
+
postMessage(atomics.sab);
|
|
212
|
+
atomics.wait(0, intialValue, 1e4);
|
|
213
|
+
let decodedData = atomics.decodeData();
|
|
214
|
+
let { _req: req, resp } = decodedData;
|
|
215
|
+
let processedResp = processResponse(req, resp);
|
|
216
|
+
if (processedResp == null ? void 0 : processedResp.isError) {
|
|
217
|
+
throw new Error(`Error: ${JSON.stringify(processedResp, null, 2)}`);
|
|
218
|
+
}
|
|
219
|
+
return processedResp;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
let sharedArrayBufferInstance;
|
|
223
|
+
class AtomicsHandler {
|
|
224
|
+
constructor() {
|
|
225
|
+
__privateAdd(this, _textEncoder, void 0);
|
|
226
|
+
__privateAdd(this, _textDecoder, void 0);
|
|
227
|
+
__privateSet(this, _textEncoder, new TextEncoder());
|
|
228
|
+
__privateSet(this, _textDecoder, new TextDecoder());
|
|
229
|
+
sharedArrayBufferInstance = sharedArrayBufferInstance || new SharedArrayBuffer(1024 * 1024);
|
|
230
|
+
this.sab = sharedArrayBufferInstance;
|
|
231
|
+
this.int32Array = new Int32Array(this.sab);
|
|
232
|
+
}
|
|
233
|
+
load(index2 = 0) {
|
|
234
|
+
return Atomics.load(this.int32Array, index2);
|
|
235
|
+
}
|
|
236
|
+
store(index2 = 0, data) {
|
|
237
|
+
return Atomics.store(this.int32Array, index2, data);
|
|
238
|
+
}
|
|
239
|
+
reset() {
|
|
240
|
+
return this.int32Array.fill(0);
|
|
241
|
+
}
|
|
242
|
+
notify(index2 = 0, count = 1) {
|
|
243
|
+
return Atomics.notify(this.int32Array, index2, count);
|
|
244
|
+
}
|
|
245
|
+
wait(index2, value, timeout) {
|
|
246
|
+
return Atomics.wait(this.int32Array, index2, value, timeout);
|
|
247
|
+
}
|
|
248
|
+
encodeData(index2 = 0, data) {
|
|
249
|
+
const replacer = (key, value) => value === void 0 ? "undefined" : value;
|
|
250
|
+
let string = JSON.stringify(data, replacer);
|
|
251
|
+
let encodedData = __privateGet(this, _textEncoder).encode(string);
|
|
252
|
+
this.int32Array.set(encodedData, index2);
|
|
253
|
+
return this.int32Array;
|
|
254
|
+
}
|
|
255
|
+
decodeData() {
|
|
256
|
+
let uInt8Array = new Uint8Array(this.int32Array);
|
|
257
|
+
let string = __privateGet(this, _textDecoder).decode(uInt8Array).replaceAll(/\x00/g, "");
|
|
258
|
+
return JSON.parse(string);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
_textEncoder = new WeakMap();
|
|
262
|
+
_textDecoder = new WeakMap();
|
|
263
|
+
class Client extends BaseSDK {
|
|
264
|
+
showInfo(message) {
|
|
265
|
+
return super._postMessageAsync(LISTENER_CMDS.MESSAGE, { message });
|
|
266
|
+
}
|
|
267
|
+
showConfirm(args) {
|
|
268
|
+
return super._postMessageAsync(LISTENER_CMDS.CONFIRM, {
|
|
269
|
+
data: {
|
|
270
|
+
title: args.title,
|
|
271
|
+
content: args.content,
|
|
272
|
+
okText: args.okText || "Ok",
|
|
273
|
+
cancelText: args.cancelText || "Cancel"
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
redirect(url) {
|
|
278
|
+
return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
class Formatter extends BaseSDK {
|
|
282
|
+
toDate(date) {
|
|
283
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE, {
|
|
284
|
+
date
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
toDateTime(date) {
|
|
288
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
289
|
+
date
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
toNumber(value) {
|
|
293
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_NUMBER, {
|
|
294
|
+
value
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
toCurrency(value, currencyCode) {
|
|
298
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_CURRENCY, {
|
|
299
|
+
value,
|
|
300
|
+
currencyCode
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
toBoolean(value) {
|
|
304
|
+
return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
|
|
305
|
+
value
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const isObject = (value) => value !== null && typeof value === "object";
|
|
310
|
+
class CreateProxy {
|
|
311
|
+
constructor(parent, target = {}, path = []) {
|
|
312
|
+
this.parent = parent;
|
|
313
|
+
this.path = path;
|
|
314
|
+
return new Proxy(target, this);
|
|
315
|
+
}
|
|
316
|
+
get(target, property) {
|
|
317
|
+
let value = this.parent.get(property, this.path);
|
|
318
|
+
if (isObject(value)) {
|
|
319
|
+
return new CreateProxy(this.parent, value, [...this.path, property]);
|
|
320
|
+
}
|
|
321
|
+
return value;
|
|
322
|
+
}
|
|
323
|
+
set(target, property, value, reciever) {
|
|
324
|
+
let updatedValue = this.parent.set(property, value, this.path);
|
|
325
|
+
if (isObject(updatedValue)) {
|
|
326
|
+
return new CreateProxy(this.parent, updatedValue, [...this.path, property]);
|
|
327
|
+
}
|
|
328
|
+
return updatedValue;
|
|
329
|
+
}
|
|
197
330
|
}
|
|
198
331
|
class Component extends BaseSDK {
|
|
199
332
|
constructor(props) {
|
|
@@ -314,6 +447,7 @@ class Page extends BaseSDK {
|
|
|
314
447
|
this.type = "Page";
|
|
315
448
|
this.popup = new Popup({});
|
|
316
449
|
this._id = props.pageId;
|
|
450
|
+
this.variable = new PageVariable();
|
|
317
451
|
}
|
|
318
452
|
getParameter(key) {
|
|
319
453
|
return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_PARAMS, {
|
|
@@ -351,6 +485,27 @@ class Page extends BaseSDK {
|
|
|
351
485
|
);
|
|
352
486
|
}
|
|
353
487
|
}
|
|
488
|
+
class PageVariable extends BaseSDK {
|
|
489
|
+
constructor() {
|
|
490
|
+
super();
|
|
491
|
+
return new CreateProxy(this);
|
|
492
|
+
}
|
|
493
|
+
get(key, path) {
|
|
494
|
+
let args = {
|
|
495
|
+
key,
|
|
496
|
+
path
|
|
497
|
+
};
|
|
498
|
+
return this._postMessageSync(LISTENER_CMDS.GET_PAGE_VARIABLE, args);
|
|
499
|
+
}
|
|
500
|
+
set(key, value, path) {
|
|
501
|
+
let args = {
|
|
502
|
+
key,
|
|
503
|
+
value,
|
|
504
|
+
path
|
|
505
|
+
};
|
|
506
|
+
return this._postMessageSync(LISTENER_CMDS.SET_PAGE_VARIABLE, args);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
354
509
|
class DecisionTable extends BaseSDK {
|
|
355
510
|
constructor(flowId) {
|
|
356
511
|
super();
|
|
@@ -375,23 +530,12 @@ class Dataform extends BaseSDK {
|
|
|
375
530
|
});
|
|
376
531
|
}
|
|
377
532
|
}
|
|
378
|
-
class Board extends BaseSDK {
|
|
379
|
-
constructor(flowId) {
|
|
380
|
-
super();
|
|
381
|
-
this._id = flowId;
|
|
382
|
-
}
|
|
383
|
-
importCSV(defaultValues) {
|
|
384
|
-
return this._postMessageAsync(LISTENER_CMDS.BOARD_IMPORT_CSV, {
|
|
385
|
-
flowId: this._id,
|
|
386
|
-
defaultValues
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
533
|
class Application extends BaseSDK {
|
|
391
534
|
constructor(props) {
|
|
392
535
|
super();
|
|
393
536
|
this._id = props.appId;
|
|
394
537
|
this.page = new Page(props);
|
|
538
|
+
this.variable = new AppVariable();
|
|
395
539
|
}
|
|
396
540
|
getVariable(key) {
|
|
397
541
|
return this._postMessageAsync(LISTENER_CMDS.GET_APP_VARIABLE, {
|
|
@@ -416,54 +560,26 @@ class Application extends BaseSDK {
|
|
|
416
560
|
getDataform(flowId) {
|
|
417
561
|
return new Dataform(flowId);
|
|
418
562
|
}
|
|
419
|
-
getBoard(flowId) {
|
|
420
|
-
return new Board(flowId);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
class Client extends BaseSDK {
|
|
424
|
-
showInfo(message) {
|
|
425
|
-
return super._postMessageAsync(LISTENER_CMDS.MESSAGE, { message });
|
|
426
|
-
}
|
|
427
|
-
showConfirm(args) {
|
|
428
|
-
return super._postMessageAsync(LISTENER_CMDS.CONFIRM, {
|
|
429
|
-
data: {
|
|
430
|
-
title: args.title,
|
|
431
|
-
content: args.content,
|
|
432
|
-
okText: args.okText || "Ok",
|
|
433
|
-
cancelText: args.cancelText || "Cancel"
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
redirect(url) {
|
|
438
|
-
return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
|
|
439
|
-
}
|
|
440
563
|
}
|
|
441
|
-
class
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
toDateTime(date) {
|
|
448
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
|
|
449
|
-
date
|
|
450
|
-
});
|
|
564
|
+
class AppVariable extends BaseSDK {
|
|
565
|
+
constructor() {
|
|
566
|
+
super();
|
|
567
|
+
return new CreateProxy(this);
|
|
451
568
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
569
|
+
get(key, path) {
|
|
570
|
+
let args = {
|
|
571
|
+
key,
|
|
572
|
+
path
|
|
573
|
+
};
|
|
574
|
+
return this._postMessageSync(LISTENER_CMDS.GET_APP_VARIABLE, args);
|
|
456
575
|
}
|
|
457
|
-
|
|
458
|
-
|
|
576
|
+
set(key, value, path) {
|
|
577
|
+
let args = {
|
|
578
|
+
key,
|
|
459
579
|
value,
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
toBoolean(value) {
|
|
464
|
-
return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
|
|
465
|
-
value
|
|
466
|
-
});
|
|
580
|
+
path
|
|
581
|
+
};
|
|
582
|
+
return this._postMessageSync(LISTENER_CMDS.SET_APP_VARIABLE, args);
|
|
467
583
|
}
|
|
468
584
|
}
|
|
469
585
|
class CustomComponentSDK extends BaseSDK {
|
package/dist/kfsdk.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=(n,t,i)=>{if(!t.has(n))throw TypeError("Cannot "+i)};var T=(n,t,i)=>(h(n,t,"read from private field"),i?i.call(n):t.get(n)),p=(n,t,i)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,i)},l=(n,t,i,M)=>(h(n,t,"write to private field"),M?M.call(n,i):t.set(n,i),i);var g=(n,t,i)=>(h(n,t,"access private method"),i);(function(n,t){typeof exports=="object"&&typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(t):(n=typeof globalThis!="undefined"?globalThis:n||self,n.kf=t())})(this,function(){var A,N,d;"use strict";let n=(E=21)=>crypto.getRandomValues(new Uint8Array(E)).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",ADD_TABLE_ROWS:"ADD_TABLE_ROWS",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",DECISION_TABLE_EXECUTE:"DECISION_TABLE_EXECUTE",DATAFORM_IMPORT_CSV:"DATAFORM_IMPORT_CSV",BOARD_IMPORT_CSV:"BOARD_IMPORT_CSV"},i={COMPONENT_ON_MOUNT:"componentOnMount",CC_ON_PARAMS_CHANGE:"onCustomComponentParamsChange"},M={POPUP_ID:"ACTIVE_POP_UP"};function u(E="lcncsdk"){return`${E}-${n()}`}const a={};function C(E){globalThis.parent&&globalThis.parent!==globalThis?globalThis.parent.postMessage(E,"*"):globalThis.postMessage(E)}function S(E){if(E.origin!==globalThis.location.origin){const e=E.data;if(e!=null&&e.isEvent){const{target:r,eventParams:P,eventName:c,eventConfig:R={}}=e;let O=a[r];O._dispatchEvent(c,P),R.once&&O._removeEventListener(c);return}let{_req:s,resp:_}=e;s!=null&&s._id&&a[s._id]._dispatchMessageEvents(s,_)}}globalThis.addEventListener("message",S);class L{constructor(){p(this,A,void 0);l(this,A,{})}_addEventListener(e,s){var _;T(this,A)[e]=((_=T(this,A))==null?void 0:_[e])||[],T(this,A)[e].push(s)}_removeEventListener(e,s){if(s){let _=T(this,A)[e].findIndex(s);_>-1&&T(this,A)[e].splice(_,1);return}Reflect.deleteProperty(T(this,A),e)}_dispatchEvent(e,s){return Array.isArray(T(this,A)[e])?(T(this,A)[e].forEach(_=>_(s)),!0):!1}_dispatchMessageEvents(e,s){let _=e._id;Array.isArray(T(this,A)[_])&&(T(this,A)[_].forEach(r=>{try{s&&Object.keys(s).length===1&&e.command!==t.API?r(Object.values(s)[0]):r(s)}catch(P){console.error("Message callback error: ",P)}}),this._removeEventListener(_))}}A=new WeakMap;class o extends L{_postMessageAsync(e,s,_,r){return new Promise((P,c)=>{const R=u(e.toLowerCase());C({_id:R,command:e,...s}),a[R]=this,this._addEventListener(R,async O=>{O!=null&&O.errorMessage?c(O):(_&&r&&(O=await r(O)),P(O))})})}_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,N);this._id=s.componentId,this.type="Component",a[this._id]=this,g(this,N,d).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})}}N=new WeakSet,d=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 f extends o{constructor(e){super(),this._id=e,this.type="CustomComponent",a[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 G extends o{constructor(e){super(),this.type="Popup",this._id=e.popupId||M.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 G({}),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.flowId=e}evaluate(e){return this._postMessageAsync(t.DECISION_TABLE_EXECUTE,{flowId:this.flowId,payload:e})}}class F extends o{constructor(e){super(),this._id=e}importCSV(e){return this._postMessageAsync(t.DATAFORM_IMPORT_CSV,{flowId:this._id,defaultValues:e})}}class W extends o{constructor(e){super(),this._id=e}importCSV(e){return this._postMessageAsync(t.BOARD_IMPORT_CSV,{flowId:this._id,defaultValues:e})}}class m 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})}getDecisionTable(e){return new y(e)}getDataform(e){return new F(e)}getBoard(e){return new W(e)}}class B 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 U 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 V extends o{constructor(){super()}api(e,s={}){return this._postMessageAsync(t.API,{url:e,args:s})}initialize(){return globalThis.parent&&globalThis.parent===globalThis?Promise.reject("SDK can be initialized only inside the Kissflow platform."):this._postMessageAsync(t.CC_INITIALIZE,{},!0,e=>(this.app=new m(e),this.page=new I(e),this.context=new f(e.componentId),this.client=new B,this.formatter=new U,this.user=e.user,this.account=e.account,this.env=e.envDetails,this))}initialise(){return this.initialize()}}var w=new V;return w});
|
|
1
|
+
var S=(i,s,E)=>{if(!s.has(i))throw TypeError("Cannot "+E)};var a=(i,s,E)=>(S(i,s,"read from private field"),E?E.call(i):s.get(i)),N=(i,s,E)=>{if(s.has(i))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(i):s.set(i,E)},D=(i,s,E,M)=>(S(i,s,"write to private field"),M?M.call(i,E):s.set(i,E),E);var m=(i,s,E)=>(S(i,s,"access private method"),E);(function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.kf=s())})(this,function(){var o,R,l,d,w;"use strict";let i=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");const s={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",ADD_TABLE_ROWS:"ADD_TABLE_ROWS",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",DECISION_TABLE_EXECUTE:"DECISION_TABLE_EXECUTE",DATAFORM_IMPORT_CSV:"DATAFORM_IMPORT_CSV"},E={COMPONENT_ON_MOUNT:"componentOnMount",CC_ON_PARAMS_CHANGE:"onCustomComponentParamsChange"},M={POPUP_ID:"ACTIVE_POP_UP"};function g(r="lcncsdk"){return`${r}-${i()}`}const P={};function L(r,e){if(e&&Object.keys(e).length===1&&r.command!==s.API){let t=Object.values(e)[0];return t==="undefined"?void 0:t}else return e}function C(r){globalThis.parent&&globalThis.parent!==globalThis?globalThis.parent.postMessage(r,"*"):globalThis.postMessage(r)}function F(r){if(r.origin!==globalThis.location.origin){const e=r.data;if(e!=null&&e.isEvent){const{target:_,eventParams:A,eventName:c,eventConfig:O={}}=e;let h=P[_];h._dispatchEvent(c,A),O.once&&h._removeEventListener(c);return}let{_req:t,resp:n}=e;t!=null&&t._id&&P[t._id]._dispatchMessageEvents(t,n)}}globalThis.addEventListener("message",F);class W{constructor(){N(this,o,void 0);D(this,o,{})}_addEventListener(e,t){var n;a(this,o)[e]=((n=a(this,o))==null?void 0:n[e])||[],a(this,o)[e].push(t)}_removeEventListener(e,t){if(t){let n=a(this,o)[e].findIndex(t);n>-1&&a(this,o)[e].splice(n,1);return}Reflect.deleteProperty(a(this,o),e)}_dispatchEvent(e,t){return Array.isArray(a(this,o)[e])?(a(this,o)[e].forEach(n=>n(t)),!0):!1}_dispatchMessageEvents(e,t){let n=e._id;Array.isArray(a(this,o)[n])&&(a(this,o)[n].forEach(_=>{try{let A=L(e,t);_(A)}catch(A){console.error("Message callback error: ",A)}}),this._removeEventListener(n))}}o=new WeakMap;class T extends W{_postMessageAsync(e,t,n,_){return new Promise((A,c)=>{const O=g(e.toLowerCase());C({_id:O,command:e,...t}),P[O]=this,this._addEventListener(O,async h=>{h!=null&&h.errorMessage?c(h):(n&&_&&(h=await _(h)),A(h))})})}_postMessage(e,t,n){const _=g(e.toLowerCase());C({_id:_,command:e,...t}),n&&this._addEventListener(t.eventName,n)}_postMessageSync(e,t){let n=0,A={_id:g(e.toLowerCase()),command:e,...t},c=new B;c.reset(),c.store(0,n),c.encodeData(1,A),C(c.sab),c.wait(0,n,1e4);let O=c.decodeData(),{_req:h,resp:X}=O,p=L(h,X);if(p!=null&&p.isError)throw new Error(`Error: ${JSON.stringify(p,null,2)}`);return p}}let I;class B{constructor(){N(this,R,void 0);N(this,l,void 0);D(this,R,new TextEncoder),D(this,l,new TextDecoder),I=I||new SharedArrayBuffer(1024*1024),this.sab=I,this.int32Array=new Int32Array(this.sab)}load(e=0){return Atomics.load(this.int32Array,e)}store(e=0,t){return Atomics.store(this.int32Array,e,t)}reset(){return this.int32Array.fill(0)}notify(e=0,t=1){return Atomics.notify(this.int32Array,e,t)}wait(e,t,n){return Atomics.wait(this.int32Array,e,t,n)}encodeData(e=0,t){const n=(c,O)=>O===void 0?"undefined":O;let _=JSON.stringify(t,n),A=a(this,R).encode(_);return this.int32Array.set(A,e),this.int32Array}decodeData(){let e=new Uint8Array(this.int32Array),t=a(this,l).decode(e).replaceAll(/\x00/g,"");return JSON.parse(t)}}R=new WeakMap,l=new WeakMap;class V extends T{showInfo(e){return super._postMessageAsync(s.MESSAGE,{message:e})}showConfirm(e){return super._postMessageAsync(s.CONFIRM,{data:{title:e.title,content:e.content,okText:e.okText||"Ok",cancelText:e.cancelText||"Cancel"}})}redirect(e){return super._postMessageAsync(s.REDIRECT,{url:e})}}class U extends T{toDate(e){return this._postMessageAsync(s.FORMAT_DATE,{date:e})}toDateTime(e){return this._postMessageAsync(s.FORMAT_DATE_TIME,{date:e})}toNumber(e){return this._postMessageAsync(s.FORMAT_NUMBER,{value:e})}toCurrency(e,t){return this._postMessageAsync(s.FORMAT_CURRENCY,{value:e,currencyCode:t})}toBoolean(e){return this._postMessageAsync(s.FORMAT_BOOLEAN,{value:e})}}const f=r=>r!==null&&typeof r=="object";class u{constructor(e,t={},n=[]){return this.parent=e,this.path=n,new Proxy(t,this)}get(e,t){let n=this.parent.get(t,this.path);return f(n)?new u(this.parent,n,[...this.path,t]):n}set(e,t,n,_){let A=this.parent.set(t,n,this.path);return f(A)?new u(this.parent,A,[...this.path,t]):A}}class y extends T{constructor(t){super();N(this,d);this._id=t.componentId,this.type="Component",P[this._id]=this,m(this,d,w).call(this,t.componentMethods)}onMount(t){this._postMessage(s.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:E.COMPONENT_ON_MOUNT,eventConfig:{once:!0}},t)}refresh(){return this._postMessageAsync(s.COMPONENT_REFRESH,{id:this._id})}show(){return this._postMessageAsync(s.COMPONENT_SHOW,{id:this._id})}hide(){return this._postMessageAsync(s.COMPONENT_HIDE,{id:this._id})}}d=new WeakSet,w=function(t){t==null||t.forEach(n=>{this[n.name]=(..._)=>{if(n.type==="method")return this._postMessageAsync(`COMPONENT_${n.name}`,{id:this._id,parameters:_});n.type==="event"&&this._postMessage(s.COMPONENT_ADD_EVENT_LISTENER,{id:this._id,eventName:n.name,eventConfig:_[1]},_[0])}})};class v extends T{constructor(e){super(),this._id=e,this.type="CustomComponent",P[this._id]=this}watchParams(e){this._postMessage(s.CC_WATCH_PARAMS,{id:this._id,eventName:E.CC_ON_PARAMS_CHANGE,eventConfig:{once:!1}},e)}}class x extends T{constructor(e){super(),this.type="Popup",this._id=e.popupId||M.POPUP_ID}getParameter(e){return this._postMessageAsync(s.GET_POPUP_PARAMS,{key:e,popupId:this._id})}getAllParameters(){return this._postMessageAsync(s.GET_ALL_POPUP_PARAMS,{popupId:this._id})}close(){return this._postMessageAsync(s.CLOSE_POPUP,{})}getComponent(e){return this._postMessageAsync(s.COMPONENT_GET,{componentId:e},!0,t=>new y(t))}}class G extends T{constructor(e){super(),this.type="Page",this.popup=new x({}),this._id=e.pageId,this.variable=new b}getParameter(e){return this._postMessageAsync(s.GET_PAGE_PARAMS,{key:e})}getAllParameters(){return this._postMessageAsync(s.GET_ALL_PAGE_PARAMS,{pageId:this._id})}getVariable(e){return this._postMessageAsync(s.GET_PAGE_VARIABLE,{key:e})}setVariable(e,t){return this._postMessageAsync(s.SET_PAGE_VARIABLE,{key:e,value:t})}openPopup(e,t){return this._postMessageAsync(s.OPEN_POPUP,{popupId:e,popupParams:t})}getComponent(e){return this._postMessageAsync(s.COMPONENT_GET,{componentId:e},!0,t=>new y(t))}}class b extends T{constructor(){return super(),new u(this)}get(e,t){let n={key:e,path:t};return this._postMessageSync(s.GET_PAGE_VARIABLE,n)}set(e,t,n){let _={key:e,value:t,path:n};return this._postMessageSync(s.SET_PAGE_VARIABLE,_)}}class H extends T{constructor(e){super(),this.flowId=e}evaluate(e){return this._postMessageAsync(s.DECISION_TABLE_EXECUTE,{flowId:this.flowId,payload:e})}}class j extends T{constructor(e){super(),this._id=e}importCSV(e){return this._postMessageAsync(s.DATAFORM_IMPORT_CSV,{flowId:this._id,defaultValues:e})}}class K extends T{constructor(e){super(),this._id=e.appId,this.page=new G(e),this.variable=new Y}getVariable(e){return this._postMessageAsync(s.GET_APP_VARIABLE,{key:e})}setVariable(e,t){return this._postMessageAsync(s.SET_APP_VARIABLE,{key:e,value:t})}openPage(e,t){return this._postMessageAsync(s.OPEN_PAGE,{pageId:e,pageParams:t})}getDecisionTable(e){return new H(e)}getDataform(e){return new j(e)}}class Y extends T{constructor(){return super(),new u(this)}get(e,t){let n={key:e,path:t};return this._postMessageSync(s.GET_APP_VARIABLE,n)}set(e,t,n){let _={key:e,value:t,path:n};return this._postMessageSync(s.SET_APP_VARIABLE,_)}}class k extends T{constructor(){super()}api(e,t={}){return this._postMessageAsync(s.API,{url:e,args:t})}initialize(){return globalThis.parent&&globalThis.parent===globalThis?Promise.reject("SDK can be initialized only inside the Kissflow platform."):this._postMessageAsync(s.CC_INITIALIZE,{},!0,e=>(this.app=new K(e),this.page=new G(e),this.context=new v(e.componentId),this.client=new V,this.formatter=new U,this.user=e.user,this.account=e.account,this.env=e.envDetails,this))}initialise(){return this.initialize()}}var J=new k;return J});
|
package/dist/lowcode.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ declare module "core/constants" {
|
|
|
48
48
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
49
|
DECISION_TABLE_EXECUTE: string;
|
|
50
50
|
DATAFORM_IMPORT_CSV: string;
|
|
51
|
-
BOARD_IMPORT_CSV: string;
|
|
52
51
|
};
|
|
53
52
|
export const EVENT_TYPES: {
|
|
54
53
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -72,6 +71,7 @@ declare module "core/index" {
|
|
|
72
71
|
export class BaseSDK extends EventBase {
|
|
73
72
|
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
74
73
|
_postMessage(command: string, args: any, callBack?: any): void;
|
|
74
|
+
_postMessageSync(command: string, args: any): any;
|
|
75
75
|
}
|
|
76
76
|
export * from "core/constants";
|
|
77
77
|
}
|
|
@@ -136,6 +136,16 @@ declare module "utils/formatter" {
|
|
|
136
136
|
declare module "utils/index" {
|
|
137
137
|
export * from "utils/client";
|
|
138
138
|
export * from "utils/formatter";
|
|
139
|
+
export const isObject: (value: any) => boolean;
|
|
140
|
+
}
|
|
141
|
+
declare module "core/proxy" {
|
|
142
|
+
export class CreateProxy {
|
|
143
|
+
path: string[];
|
|
144
|
+
parent: object;
|
|
145
|
+
constructor(parent: object, target?: {}, path?: any[]);
|
|
146
|
+
get(target: object, property: string): any;
|
|
147
|
+
set(target: object, property: string, value: any, reciever: any): any;
|
|
148
|
+
}
|
|
139
149
|
}
|
|
140
150
|
declare module "types/external" {
|
|
141
151
|
export type userObject = {
|
|
@@ -230,6 +240,7 @@ declare module "app/page" {
|
|
|
230
240
|
_id: string;
|
|
231
241
|
popup: Popup;
|
|
232
242
|
type: string;
|
|
243
|
+
variable: PageVariable;
|
|
233
244
|
constructor(props: PageContext);
|
|
234
245
|
getParameter(key: string): any;
|
|
235
246
|
getAllParameters(): any;
|
|
@@ -238,6 +249,11 @@ declare module "app/page" {
|
|
|
238
249
|
openPopup(popupId: string, popupParams: object): any;
|
|
239
250
|
getComponent(componentId: string): Component;
|
|
240
251
|
}
|
|
252
|
+
class PageVariable extends BaseSDK {
|
|
253
|
+
constructor();
|
|
254
|
+
get(key: any, path: any): any;
|
|
255
|
+
set(key: any, value: any, path: any): any;
|
|
256
|
+
}
|
|
241
257
|
}
|
|
242
258
|
declare module "app/decisiontable" {
|
|
243
259
|
import { BaseSDK } from "core/index";
|
|
@@ -255,23 +271,15 @@ declare module "app/dataform" {
|
|
|
255
271
|
importCSV(defaultValues: object): any;
|
|
256
272
|
}
|
|
257
273
|
}
|
|
258
|
-
declare module "board/index" {
|
|
259
|
-
import { BaseSDK } from "core/index";
|
|
260
|
-
export class Board extends BaseSDK {
|
|
261
|
-
private _id;
|
|
262
|
-
constructor(flowId: string);
|
|
263
|
-
importCSV(defaultValues: object): any;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
274
|
declare module "app/index" {
|
|
267
275
|
import { BaseSDK } from "core/index";
|
|
268
276
|
import { Page } from "app/page";
|
|
269
277
|
import { AppContext } from "types/internal";
|
|
270
278
|
import { DecisionTable } from "app/decisiontable";
|
|
271
279
|
import { Dataform } from "app/dataform";
|
|
272
|
-
import { Board } from "board/index";
|
|
273
280
|
export class Application extends BaseSDK {
|
|
274
281
|
page: Page;
|
|
282
|
+
variable: AppVariable;
|
|
275
283
|
_id: string;
|
|
276
284
|
constructor(props: AppContext);
|
|
277
285
|
getVariable(key: string): any;
|
|
@@ -279,7 +287,11 @@ declare module "app/index" {
|
|
|
279
287
|
openPage(pageId: string, pageParams: object): any;
|
|
280
288
|
getDecisionTable(flowId: string): DecisionTable;
|
|
281
289
|
getDataform(flowId: string): Dataform;
|
|
282
|
-
|
|
290
|
+
}
|
|
291
|
+
class AppVariable extends BaseSDK {
|
|
292
|
+
constructor();
|
|
293
|
+
get(key: any, path: any): any;
|
|
294
|
+
set(key: any, value: any, path: any): any;
|
|
283
295
|
}
|
|
284
296
|
export * from "app/component";
|
|
285
297
|
export { Page };
|
package/dist/lowcode.types.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ declare class Page {
|
|
|
59
59
|
_id: string
|
|
60
60
|
popup: Popup
|
|
61
61
|
type: string
|
|
62
|
+
variable: PageVariable
|
|
62
63
|
getParameter(key: string): any;
|
|
63
64
|
getAllParameters(): any;
|
|
64
65
|
getVariable(key: string): any;
|
|
@@ -74,13 +75,13 @@ declare class Dataform {
|
|
|
74
75
|
}
|
|
75
76
|
declare class Application {
|
|
76
77
|
page: Page
|
|
78
|
+
variable: AppVariable
|
|
77
79
|
_id: string
|
|
78
80
|
getVariable(key: string): any;
|
|
79
81
|
setVariable(key: string | object, value?: any): any;
|
|
80
82
|
openPage(pageId: string, pageParams: object): any;
|
|
81
83
|
getDecisionTable(flowId: string): DecisionTable;
|
|
82
84
|
getDataform(flowId: string): Dataform;
|
|
83
|
-
getBoard(flowId: string): Board;
|
|
84
85
|
}
|
|
85
86
|
declare class kf {
|
|
86
87
|
static context: Component
|
package/dist/nocode.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ declare module "core/constants" {
|
|
|
48
48
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
49
49
|
DECISION_TABLE_EXECUTE: string;
|
|
50
50
|
DATAFORM_IMPORT_CSV: string;
|
|
51
|
-
BOARD_IMPORT_CSV: string;
|
|
52
51
|
};
|
|
53
52
|
export const EVENT_TYPES: {
|
|
54
53
|
COMPONENT_ON_MOUNT: string;
|
|
@@ -72,6 +71,7 @@ declare module "core/index" {
|
|
|
72
71
|
export class BaseSDK extends EventBase {
|
|
73
72
|
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
74
73
|
_postMessage(command: string, args: any, callBack?: any): void;
|
|
74
|
+
_postMessageSync(command: string, args: any): any;
|
|
75
75
|
}
|
|
76
76
|
export * from "core/constants";
|
|
77
77
|
}
|
|
@@ -136,6 +136,7 @@ declare module "utils/formatter" {
|
|
|
136
136
|
declare module "utils/index" {
|
|
137
137
|
export * from "utils/client";
|
|
138
138
|
export * from "utils/formatter";
|
|
139
|
+
export const isObject: (value: any) => boolean;
|
|
139
140
|
}
|
|
140
141
|
declare module "window/NDEFReader" {
|
|
141
142
|
import { BaseSDK } from "core/index";
|
|
@@ -263,6 +264,15 @@ declare module "app/decisiontable" {
|
|
|
263
264
|
evaluate(payload?: object): any;
|
|
264
265
|
}
|
|
265
266
|
}
|
|
267
|
+
declare module "core/proxy" {
|
|
268
|
+
export class CreateProxy {
|
|
269
|
+
path: string[];
|
|
270
|
+
parent: object;
|
|
271
|
+
constructor(parent: object, target?: {}, path?: any[]);
|
|
272
|
+
get(target: object, property: string): any;
|
|
273
|
+
set(target: object, property: string, value: any, reciever: any): any;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
266
276
|
declare module "app/popup" {
|
|
267
277
|
import { BaseSDK } from "core/index";
|
|
268
278
|
import { Component } from "app/component";
|
|
@@ -286,6 +296,7 @@ declare module "app/page" {
|
|
|
286
296
|
_id: string;
|
|
287
297
|
popup: Popup;
|
|
288
298
|
type: string;
|
|
299
|
+
variable: PageVariable;
|
|
289
300
|
constructor(props: PageContext);
|
|
290
301
|
getParameter(key: string): any;
|
|
291
302
|
getAllParameters(): any;
|
|
@@ -294,13 +305,10 @@ declare module "app/page" {
|
|
|
294
305
|
openPopup(popupId: string, popupParams: object): any;
|
|
295
306
|
getComponent(componentId: string): Component;
|
|
296
307
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
private _id;
|
|
302
|
-
constructor(flowId: string);
|
|
303
|
-
importCSV(defaultValues: object): any;
|
|
308
|
+
class PageVariable extends BaseSDK {
|
|
309
|
+
constructor();
|
|
310
|
+
get(key: any, path: any): any;
|
|
311
|
+
set(key: any, value: any, path: any): any;
|
|
304
312
|
}
|
|
305
313
|
}
|
|
306
314
|
declare module "app/index" {
|
|
@@ -309,9 +317,9 @@ declare module "app/index" {
|
|
|
309
317
|
import { AppContext } from "types/internal";
|
|
310
318
|
import { DecisionTable } from "app/decisiontable";
|
|
311
319
|
import { Dataform } from "app/dataform";
|
|
312
|
-
import { Board } from "board/index";
|
|
313
320
|
export class Application extends BaseSDK {
|
|
314
321
|
page: Page;
|
|
322
|
+
variable: AppVariable;
|
|
315
323
|
_id: string;
|
|
316
324
|
constructor(props: AppContext);
|
|
317
325
|
getVariable(key: string): any;
|
|
@@ -319,7 +327,11 @@ declare module "app/index" {
|
|
|
319
327
|
openPage(pageId: string, pageParams: object): any;
|
|
320
328
|
getDecisionTable(flowId: string): DecisionTable;
|
|
321
329
|
getDataform(flowId: string): Dataform;
|
|
322
|
-
|
|
330
|
+
}
|
|
331
|
+
class AppVariable extends BaseSDK {
|
|
332
|
+
constructor();
|
|
333
|
+
get(key: any, path: any): any;
|
|
334
|
+
set(key: any, value: any, path: any): any;
|
|
323
335
|
}
|
|
324
336
|
export * from "app/component";
|
|
325
337
|
export { Page };
|