@kissflow/lowcode-client-sdk 1.0.4-beta.1 → 1.0.6-beta

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.
@@ -1,922 +0,0 @@
1
- /******/ var __webpack_modules__ = ({
2
-
3
- /***/ "./src/app.ts":
4
- /*!********************!*\
5
- !*** ./src/app.ts ***!
6
- \********************/
7
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
8
-
9
-
10
- var __extends = (this && this.__extends) || (function () {
11
- var extendStatics = function (d, b) {
12
- extendStatics = Object.setPrototypeOf ||
13
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
15
- return extendStatics(d, b);
16
- };
17
- return function (d, b) {
18
- if (typeof b !== "function" && b !== null)
19
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
20
- extendStatics(d, b);
21
- function __() { this.constructor = d; }
22
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23
- };
24
- })();
25
- Object.defineProperty(exports, "__esModule", ({ value: true }));
26
- exports.Application = void 0;
27
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
28
- var page_1 = __webpack_require__(/*! ./page */ "./src/page.ts");
29
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
30
- var Application = /** @class */ (function (_super) {
31
- __extends(Application, _super);
32
- function Application(props) {
33
- var _this = _super.call(this, {}) || this;
34
- _this.page = new page_1.Page({});
35
- return _this;
36
- }
37
- Application.prototype.getVariable = function (key) {
38
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_APP_VARIABLE, {
39
- key: key
40
- });
41
- };
42
- Application.prototype.setVariable = function (key, value) {
43
- return this._postMessageAsync(constants_1.LISTENER_CMDS.SET_APP_VARIABLE, {
44
- key: key,
45
- value: value
46
- });
47
- };
48
- Application.prototype.openPage = function (pageId, pageParams) {
49
- return _super.prototype._postMessageAsync.call(this, constants_1.LISTENER_CMDS.OPEN_PAGE, {
50
- pageId: pageId,
51
- pageParams: pageParams
52
- });
53
- };
54
- return Application;
55
- }(base_1.BaseSDK));
56
- exports.Application = Application;
57
-
58
-
59
- /***/ }),
60
-
61
- /***/ "./src/base.ts":
62
- /*!*********************!*\
63
- !*** ./src/base.ts ***!
64
- \*********************/
65
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
66
-
67
-
68
- var __assign = (this && this.__assign) || function () {
69
- __assign = Object.assign || function(t) {
70
- for (var s, i = 1, n = arguments.length; i < n; i++) {
71
- s = arguments[i];
72
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
73
- t[p] = s[p];
74
- }
75
- return t;
76
- };
77
- return __assign.apply(this, arguments);
78
- };
79
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
80
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
81
- return new (P || (P = Promise))(function (resolve, reject) {
82
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
83
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
84
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
85
- step((generator = generator.apply(thisArg, _arguments || [])).next());
86
- });
87
- };
88
- var __generator = (this && this.__generator) || function (thisArg, body) {
89
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
90
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
91
- function verb(n) { return function (v) { return step([n, v]); }; }
92
- function step(op) {
93
- if (f) throw new TypeError("Generator is already executing.");
94
- while (_) try {
95
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
96
- if (y = 0, t) op = [op[0] & 2, t.value];
97
- switch (op[0]) {
98
- case 0: case 1: t = op; break;
99
- case 4: _.label++; return { value: op[1], done: false };
100
- case 5: _.label++; y = op[1]; op = [0]; continue;
101
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
102
- default:
103
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
104
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
105
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
106
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
107
- if (t[2]) _.ops.pop();
108
- _.trys.pop(); continue;
109
- }
110
- op = body.call(thisArg, _);
111
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
112
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
113
- }
114
- };
115
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
116
- if (kind === "m") throw new TypeError("Private method is not writable");
117
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
118
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
119
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
120
- };
121
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
122
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
123
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
124
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
125
- };
126
- var _BaseSDK_instances, _BaseSDK_listeners, _BaseSDK_eventListeners, _BaseSDK_addListener, _BaseSDK_appendEventListeners, _BaseSDK_checkEvents, _BaseSDK_onMessage;
127
- Object.defineProperty(exports, "__esModule", ({ value: true }));
128
- exports.BaseSDK = void 0;
129
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
130
- var nanoid = (__webpack_require__(/*! nanoid */ "./node_modules/nanoid/index.dev.js").nanoid);
131
- function generateId(prefix) {
132
- if (prefix === void 0) { prefix = "lcncsdk"; }
133
- return "".concat(prefix, "-").concat(nanoid());
134
- }
135
- function postMessage(args) {
136
- console.log("SDK : @postMessage ", args);
137
- if (self.parent && self.parent !== self) {
138
- self.parent.postMessage(args, "*");
139
- }
140
- else {
141
- self.postMessage(args);
142
- }
143
- }
144
- var BaseSDK = /** @class */ (function () {
145
- function BaseSDK(props) {
146
- _BaseSDK_instances.add(this);
147
- _BaseSDK_listeners.set(this, void 0);
148
- _BaseSDK_eventListeners.set(this, void 0);
149
- console.log("SDK : Initializing ", props);
150
- __classPrivateFieldSet(this, _BaseSDK_listeners, {}, "f");
151
- __classPrivateFieldSet(this, _BaseSDK_eventListeners, {}, "f");
152
- self.addEventListener("message", __classPrivateFieldGet(this, _BaseSDK_instances, "m", _BaseSDK_onMessage).bind(this), false);
153
- }
154
- BaseSDK.prototype._postMessageAsync = function (command, args, hasCallBack, callBack) {
155
- var _this = this;
156
- return new Promise(function (resolve, reject) {
157
- var _id = generateId(command.toLowerCase());
158
- postMessage(__assign({ _id: _id, command: command }, args));
159
- __classPrivateFieldGet(_this, _BaseSDK_instances, "m", _BaseSDK_addListener).call(_this, _id, function (data) { return __awaiter(_this, void 0, void 0, function () {
160
- return __generator(this, function (_a) {
161
- switch (_a.label) {
162
- case 0:
163
- if (!data.errorMessage) return [3 /*break*/, 1];
164
- reject(data);
165
- return [3 /*break*/, 4];
166
- case 1:
167
- if (!(hasCallBack && callBack)) return [3 /*break*/, 3];
168
- return [4 /*yield*/, callBack(data)];
169
- case 2:
170
- data = _a.sent();
171
- _a.label = 3;
172
- case 3:
173
- resolve(data);
174
- _a.label = 4;
175
- case 4: return [2 /*return*/];
176
- }
177
- });
178
- }); });
179
- });
180
- };
181
- BaseSDK.prototype._postMessage = function (command, func, args) {
182
- if (args === void 0) { args = {}; }
183
- var _id = generateId(command.toLowerCase());
184
- postMessage(__assign({ _id: _id, command: command }, args));
185
- __classPrivateFieldGet(this, _BaseSDK_instances, "m", _BaseSDK_addListener).call(this, _id, function (data) { return func(data); });
186
- };
187
- BaseSDK.prototype._registerEventListener = function (_id, eventType, callback) {
188
- __classPrivateFieldGet(this, _BaseSDK_instances, "m", _BaseSDK_appendEventListeners).call(this, _id, eventType, callback);
189
- };
190
- return BaseSDK;
191
- }());
192
- exports.BaseSDK = BaseSDK;
193
- _BaseSDK_listeners = new WeakMap(), _BaseSDK_eventListeners = new WeakMap(), _BaseSDK_instances = new WeakSet(), _BaseSDK_addListener = function _BaseSDK_addListener(_id, callback) {
194
- __classPrivateFieldGet(this, _BaseSDK_listeners, "f")[_id] = __classPrivateFieldGet(this, _BaseSDK_listeners, "f")[_id] || [];
195
- __classPrivateFieldGet(this, _BaseSDK_listeners, "f")[_id].push(callback);
196
- }, _BaseSDK_appendEventListeners = function _BaseSDK_appendEventListeners(_id, eventType, callback) {
197
- if (!__classPrivateFieldGet(this, _BaseSDK_eventListeners, "f")[_id]) {
198
- __classPrivateFieldGet(this, _BaseSDK_eventListeners, "f")[_id] = {};
199
- }
200
- __classPrivateFieldGet(this, _BaseSDK_eventListeners, "f")[_id][eventType] = callback;
201
- }, _BaseSDK_checkEvents = function _BaseSDK_checkEvents(data) {
202
- var _id = data._id, eventType = data.eventType, eventParams = data.eventParams;
203
- if (!_id || !eventType)
204
- return;
205
- var eventListener = __classPrivateFieldGet(this, _BaseSDK_eventListeners, "f")[_id] || {};
206
- if (eventListener[eventType]) {
207
- eventListener[eventType](eventParams || {});
208
- }
209
- }, _BaseSDK_onMessage = function _BaseSDK_onMessage(event) {
210
- if (event.origin !== self.location.origin) {
211
- console.log("SDK : @onMessage ", event);
212
- var data_1 = event.data;
213
- if (data_1.isEvent) {
214
- return __classPrivateFieldGet(this, _BaseSDK_instances, "m", _BaseSDK_checkEvents).call(this, data_1);
215
- }
216
- var _req_1 = (data_1 === null || data_1 === void 0 ? void 0 : data_1._req) || {};
217
- var listeners = __classPrivateFieldGet(this, _BaseSDK_listeners, "f")[_req_1 === null || _req_1 === void 0 ? void 0 : _req_1._id] || [];
218
- if (listeners) {
219
- listeners.forEach(function (listener) {
220
- try {
221
- if (data_1.resp &&
222
- Object.keys(data_1.resp).length === 1 &&
223
- _req_1.command !== constants_1.LISTENER_CMDS.API) {
224
- listener(Object.values(data_1.resp)[0]);
225
- }
226
- else {
227
- listener(data_1.resp);
228
- }
229
- }
230
- catch (err) {
231
- console.error("Message callback error: ", err);
232
- }
233
- });
234
- }
235
- }
236
- };
237
-
238
-
239
- /***/ }),
240
-
241
- /***/ "./src/client.ts":
242
- /*!***********************!*\
243
- !*** ./src/client.ts ***!
244
- \***********************/
245
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
246
-
247
-
248
- var __extends = (this && this.__extends) || (function () {
249
- var extendStatics = function (d, b) {
250
- extendStatics = Object.setPrototypeOf ||
251
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
252
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
253
- return extendStatics(d, b);
254
- };
255
- return function (d, b) {
256
- if (typeof b !== "function" && b !== null)
257
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
258
- extendStatics(d, b);
259
- function __() { this.constructor = d; }
260
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
261
- };
262
- })();
263
- Object.defineProperty(exports, "__esModule", ({ value: true }));
264
- exports.Client = void 0;
265
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
266
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
267
- var Client = /** @class */ (function (_super) {
268
- __extends(Client, _super);
269
- function Client() {
270
- return _super !== null && _super.apply(this, arguments) || this;
271
- }
272
- Client.prototype.showInfo = function (message) {
273
- return _super.prototype._postMessageAsync.call(this, constants_1.LISTENER_CMDS.MESSAGE, { message: message });
274
- };
275
- Client.prototype.showConfirm = function (args) {
276
- return _super.prototype._postMessageAsync.call(this, constants_1.LISTENER_CMDS.CONFIRM, {
277
- data: {
278
- title: args.title,
279
- content: args.content,
280
- okText: args.okText || "Ok",
281
- cancelText: args.cancelText || "Cancel"
282
- }
283
- });
284
- };
285
- Client.prototype.redirect = function (url) {
286
- return _super.prototype._postMessageAsync.call(this, constants_1.LISTENER_CMDS.REDIRECT, { url: url });
287
- };
288
- return Client;
289
- }(base_1.BaseSDK));
290
- exports.Client = Client;
291
-
292
-
293
- /***/ }),
294
-
295
- /***/ "./src/component.ts":
296
- /*!**************************!*\
297
- !*** ./src/component.ts ***!
298
- \**************************/
299
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
300
-
301
-
302
- var __extends = (this && this.__extends) || (function () {
303
- var extendStatics = function (d, b) {
304
- extendStatics = Object.setPrototypeOf ||
305
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
306
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
307
- return extendStatics(d, b);
308
- };
309
- return function (d, b) {
310
- if (typeof b !== "function" && b !== null)
311
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
312
- extendStatics(d, b);
313
- function __() { this.constructor = d; }
314
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
315
- };
316
- })();
317
- Object.defineProperty(exports, "__esModule", ({ value: true }));
318
- exports.Component = void 0;
319
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
320
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
321
- var Component = /** @class */ (function (_super) {
322
- __extends(Component, _super);
323
- function Component(id) {
324
- var _this = _super.call(this, {}) || this;
325
- _this.id = id;
326
- return _this;
327
- }
328
- Component.prototype.refresh = function () {
329
- return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_REFRESH, {
330
- id: this.id
331
- });
332
- };
333
- Component.prototype.show = function () {
334
- return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_SHOW, {
335
- id: this.id
336
- });
337
- };
338
- Component.prototype.hide = function () {
339
- return this._postMessageAsync(constants_1.LISTENER_CMDS.COMPONENT_HIDE, {
340
- id: this.id
341
- });
342
- };
343
- return Component;
344
- }(base_1.BaseSDK));
345
- exports.Component = Component;
346
-
347
-
348
- /***/ }),
349
-
350
- /***/ "./src/constants.ts":
351
- /*!**************************!*\
352
- !*** ./src/constants.ts ***!
353
- \**************************/
354
- /***/ ((__unused_webpack_module, exports) => {
355
-
356
-
357
- Object.defineProperty(exports, "__esModule", ({ value: true }));
358
- exports.EVENT_TYPES = exports.LISTENER_CMDS = void 0;
359
- exports.LISTENER_CMDS = {
360
- API: "API",
361
- PARAMS: "PARAMS",
362
- GET_CONTEXT: "GET_CONTEXT",
363
- RETURN: "RETURN",
364
- //Forms SDK Functions
365
- GET_FORM_FIELD: "GET_FORM_FIELD",
366
- UPDATE_FORM: "UPDATE_FORM",
367
- GET_TABLE: "GET_TABLE",
368
- GET_TABLE_ROW: "GET_TABLE_ROW",
369
- ADD_TABLE_ROW: "ADD_TABLE_ROW",
370
- DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
371
- TO_JSON: "TO_JSON",
372
- GET_TABLE_ROWS: "GET_TABLE_ROWS",
373
- //Client SDK functions
374
- MESSAGE: "MESSAGE",
375
- CONFIRM: "CONFIRM",
376
- ALERT: "ALERT",
377
- REDIRECT: "REDIRECT",
378
- OPEN_PAGE: "OPEN_PAGE",
379
- //Formatter SDK Functions
380
- FORMAT_DATE: "FORMAT_DATE",
381
- FORMAT_DATE_TIME: "FORMAT_DATE_TIME",
382
- FORMAT_NUMBER: "FORMAT_NUMBER",
383
- FORMAT_CURRENCY: "FORMAT_CURRENCY",
384
- FORMAT_BOOLEAN: "FORMAT_BOOLEAN",
385
- //Application SDK functions
386
- GET_APP_VARIABLE: "GET_APP_VARIABLE",
387
- SET_APP_VARIABLE: "SET_APP_VARIABLE",
388
- //Application page sdk functions
389
- GET_PAGE_VARIABLE: "GET_PAGE_VARIABLE",
390
- SET_PAGE_VARIABLE: "SET_PAGE_VARIABLE",
391
- GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
392
- OPEN_POPUP_PAGE: "OPEN_POPUP_PAGE",
393
- PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
394
- CLOSE_POPUP: "CLOSE_POPUP",
395
- COMPONENT_REFRESH: "COMPONENT_REFRESH",
396
- COMPONENT_SHOW: "COMPONENT_SHOW",
397
- COMPONENT_HIDE: "COMPONENT_HIDE"
398
- };
399
- exports.EVENT_TYPES = {
400
- ON_CLOSE: "onClose",
401
- ON_CHANGE: "onChange",
402
- ON_LOAD: "onLoad",
403
- };
404
-
405
-
406
- /***/ }),
407
-
408
- /***/ "./src/form.ts":
409
- /*!*********************!*\
410
- !*** ./src/form.ts ***!
411
- \*********************/
412
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
413
-
414
-
415
- var __extends = (this && this.__extends) || (function () {
416
- var extendStatics = function (d, b) {
417
- extendStatics = Object.setPrototypeOf ||
418
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
419
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
420
- return extendStatics(d, b);
421
- };
422
- return function (d, b) {
423
- if (typeof b !== "function" && b !== null)
424
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
425
- extendStatics(d, b);
426
- function __() { this.constructor = d; }
427
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
428
- };
429
- })();
430
- Object.defineProperty(exports, "__esModule", ({ value: true }));
431
- exports.TableForm = exports.Form = void 0;
432
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
433
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
434
- var Form = /** @class */ (function (_super) {
435
- __extends(Form, _super);
436
- function Form(instanceId) {
437
- var _this = _super.call(this, {}) || this;
438
- _this.instanceId = instanceId;
439
- return _this;
440
- }
441
- Form.prototype.toJSON = function () {
442
- return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
443
- instanceId: this.instanceId
444
- });
445
- };
446
- Form.prototype.getField = function (fieldId) {
447
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
448
- instanceId: this.instanceId,
449
- fieldId: fieldId
450
- });
451
- };
452
- Form.prototype.updateField = function (args) {
453
- return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
454
- data: args
455
- });
456
- };
457
- Form.prototype.getTable = function (tableId) {
458
- return new Table(this.instanceId, tableId);
459
- };
460
- return Form;
461
- }(base_1.BaseSDK));
462
- exports.Form = Form;
463
- var Table = /** @class */ (function (_super) {
464
- __extends(Table, _super);
465
- function Table(instanceId, tableId) {
466
- var _this = _super.call(this, {}) || this;
467
- _this.tableId = tableId;
468
- _this.instanceId = instanceId;
469
- return _this;
470
- }
471
- // list of obj of rows
472
- Table.prototype.toJSON = function () {
473
- return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
474
- tableId: this.tableId
475
- });
476
- };
477
- Table.prototype.getRows = function () {
478
- var _this = this;
479
- // list of TableForm class
480
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_TABLE_ROWS, { tableId: this.tableId }, true, // has callBack
481
- function (data) {
482
- console.log(data);
483
- return data.map(function (row) { return new TableForm(_this.instanceId, _this.tableId, row.id); });
484
- });
485
- };
486
- Table.prototype.getRow = function (rowId) {
487
- return new TableForm(this.instanceId, this.tableId, rowId);
488
- };
489
- Table.prototype.addRow = function (rowObject) {
490
- return this._postMessageAsync(constants_1.LISTENER_CMDS.ADD_TABLE_ROW, {
491
- tableId: this.tableId,
492
- rowObject: rowObject
493
- });
494
- };
495
- Table.prototype.deleteRow = function (rowId) {
496
- return this._postMessageAsync(constants_1.LISTENER_CMDS.DELETE_TABLE_ROW, {
497
- tableId: this.tableId,
498
- rowId: rowId
499
- });
500
- };
501
- return Table;
502
- }(base_1.BaseSDK));
503
- var TableForm = /** @class */ (function (_super) {
504
- __extends(TableForm, _super);
505
- function TableForm(instanceId, tableId, rowId) {
506
- var _this = _super.call(this, {}) || this;
507
- _this.instanceId = instanceId;
508
- _this.tableId = tableId;
509
- _this.rowId = rowId;
510
- return _this;
511
- }
512
- TableForm.prototype.getParent = function () {
513
- return new Form(this.instanceId);
514
- };
515
- TableForm.prototype.toJSON = function () {
516
- return this._postMessageAsync(constants_1.LISTENER_CMDS.TO_JSON, {
517
- tableId: this.tableId,
518
- rowId: this.rowId
519
- });
520
- };
521
- TableForm.prototype.getField = function (fieldId) {
522
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_FORM_FIELD, {
523
- instanceId: this.instanceId,
524
- tableId: this.tableId,
525
- rowId: this.rowId,
526
- fieldId: fieldId
527
- });
528
- };
529
- TableForm.prototype.updateField = function (args) {
530
- return this._postMessageAsync(constants_1.LISTENER_CMDS.UPDATE_FORM, {
531
- instanceId: this.instanceId,
532
- tableId: this.tableId,
533
- rowId: this.rowId,
534
- data: args
535
- });
536
- };
537
- return TableForm;
538
- }(base_1.BaseSDK));
539
- exports.TableForm = TableForm;
540
-
541
-
542
- /***/ }),
543
-
544
- /***/ "./src/formatter.ts":
545
- /*!**************************!*\
546
- !*** ./src/formatter.ts ***!
547
- \**************************/
548
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
549
-
550
-
551
- var __extends = (this && this.__extends) || (function () {
552
- var extendStatics = function (d, b) {
553
- extendStatics = Object.setPrototypeOf ||
554
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
555
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
556
- return extendStatics(d, b);
557
- };
558
- return function (d, b) {
559
- if (typeof b !== "function" && b !== null)
560
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
561
- extendStatics(d, b);
562
- function __() { this.constructor = d; }
563
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
564
- };
565
- })();
566
- Object.defineProperty(exports, "__esModule", ({ value: true }));
567
- exports.Formatter = void 0;
568
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
569
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
570
- var Formatter = /** @class */ (function (_super) {
571
- __extends(Formatter, _super);
572
- function Formatter() {
573
- return _super !== null && _super.apply(this, arguments) || this;
574
- }
575
- Formatter.prototype.toDate = function (date) {
576
- return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_DATE, {
577
- date: date,
578
- });
579
- };
580
- Formatter.prototype.toDateTime = function (date) {
581
- return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_DATE_TIME, {
582
- date: date,
583
- });
584
- };
585
- Formatter.prototype.toNumber = function (value) {
586
- return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_NUMBER, {
587
- value: value,
588
- });
589
- };
590
- Formatter.prototype.toCurrency = function (value, currencyCode) {
591
- return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_CURRENCY, {
592
- value: value,
593
- currencyCode: currencyCode,
594
- });
595
- };
596
- Formatter.prototype.toBoolean = function (value) {
597
- return this._postMessageAsync(constants_1.LISTENER_CMDS.FORMAT_BOOLEAN, {
598
- value: value
599
- });
600
- };
601
- return Formatter;
602
- }(base_1.BaseSDK));
603
- exports.Formatter = Formatter;
604
-
605
-
606
- /***/ }),
607
-
608
- /***/ "./src/lowcode.sdk.ts":
609
- /*!****************************!*\
610
- !*** ./src/lowcode.sdk.ts ***!
611
- \****************************/
612
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
613
-
614
-
615
- var __extends = (this && this.__extends) || (function () {
616
- var extendStatics = function (d, b) {
617
- extendStatics = Object.setPrototypeOf ||
618
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
619
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
620
- return extendStatics(d, b);
621
- };
622
- return function (d, b) {
623
- if (typeof b !== "function" && b !== null)
624
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
625
- extendStatics(d, b);
626
- function __() { this.constructor = d; }
627
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
628
- };
629
- })();
630
- Object.defineProperty(exports, "__esModule", ({ value: true }));
631
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
632
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
633
- var form_1 = __webpack_require__(/*! ./form */ "./src/form.ts");
634
- var form_2 = __webpack_require__(/*! ./form */ "./src/form.ts");
635
- var client_1 = __webpack_require__(/*! ./client */ "./src/client.ts");
636
- var formatter_1 = __webpack_require__(/*! ./formatter */ "./src/formatter.ts");
637
- var app_1 = __webpack_require__(/*! ./app */ "./src/app.ts");
638
- var LowcodeSDK = /** @class */ (function (_super) {
639
- __extends(LowcodeSDK, _super);
640
- function LowcodeSDK(props) {
641
- var _this = _super.call(this, {}) || this;
642
- if (props.tableId && props.rowId) {
643
- _this.currentForm = new form_2.TableForm(props.instanceId, props.tableId, props.rowId);
644
- }
645
- else if (props.instanceId) {
646
- _this.currentForm = new form_1.Form(props.instanceId);
647
- }
648
- _this.client = new client_1.Client({});
649
- _this.formatter = new formatter_1.Formatter({});
650
- _this.app = new app_1.Application({});
651
- return _this;
652
- }
653
- LowcodeSDK.prototype.api = function (url, args) {
654
- if (args === void 0) { args = {}; }
655
- return this._postMessageAsync(constants_1.LISTENER_CMDS.API, { url: url, args: args });
656
- };
657
- LowcodeSDK.prototype.watchParams = function (func) {
658
- this._postMessage(constants_1.LISTENER_CMDS.PARAMS, func);
659
- };
660
- LowcodeSDK.prototype.getContext = function () {
661
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_CONTEXT, {});
662
- };
663
- return LowcodeSDK;
664
- }(base_1.BaseSDK));
665
- function initSDK(config) {
666
- if (config === void 0) { config = {}; }
667
- return new LowcodeSDK(config);
668
- }
669
- exports["default"] = initSDK;
670
-
671
-
672
- /***/ }),
673
-
674
- /***/ "./src/page.ts":
675
- /*!*********************!*\
676
- !*** ./src/page.ts ***!
677
- \*********************/
678
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
679
-
680
-
681
- var __extends = (this && this.__extends) || (function () {
682
- var extendStatics = function (d, b) {
683
- extendStatics = Object.setPrototypeOf ||
684
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
685
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
686
- return extendStatics(d, b);
687
- };
688
- return function (d, b) {
689
- if (typeof b !== "function" && b !== null)
690
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
691
- extendStatics(d, b);
692
- function __() { this.constructor = d; }
693
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
694
- };
695
- })();
696
- Object.defineProperty(exports, "__esModule", ({ value: true }));
697
- exports.Page = void 0;
698
- var component_1 = __webpack_require__(/*! ./component */ "./src/component.ts");
699
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
700
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
701
- var Page = /** @class */ (function (_super) {
702
- __extends(Page, _super);
703
- function Page(pageId) {
704
- var _this = _super.call(this, {}) || this;
705
- _this._id = pageId;
706
- return _this;
707
- }
708
- Page.prototype.getParameter = function (key) {
709
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_PAGE_PARAMS, {
710
- key: key
711
- });
712
- };
713
- Page.prototype.getVariable = function (key) {
714
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_PAGE_VARIABLE, {
715
- key: key
716
- });
717
- };
718
- Page.prototype.setVariable = function (key, value) {
719
- return this._postMessageAsync(constants_1.LISTENER_CMDS.SET_PAGE_VARIABLE, {
720
- key: key,
721
- value: value
722
- });
723
- };
724
- Page.prototype.openPopup = function (popupId, popupParams) {
725
- //TODO: add popup class
726
- return this._postMessageAsync(constants_1.LISTENER_CMDS.OPEN_POPUP_PAGE, {
727
- popupId: popupId,
728
- popupParams: popupParams
729
- });
730
- };
731
- Page.prototype.closePopup = function () {
732
- return this._postMessageAsync(constants_1.LISTENER_CMDS.CLOSE_POPUP, {});
733
- };
734
- Page.prototype.getComponent = function (componentId) {
735
- return new component_1.Component(componentId);
736
- };
737
- Page.prototype.onClose = function (callback) {
738
- this._registerEventListener(this._id, constants_1.EVENT_TYPES.ON_CLOSE, callback);
739
- };
740
- return Page;
741
- }(base_1.BaseSDK));
742
- exports.Page = Page;
743
-
744
-
745
- /***/ }),
746
-
747
- /***/ "./node_modules/nanoid/index.dev.js":
748
- /*!******************************************!*\
749
- !*** ./node_modules/nanoid/index.dev.js ***!
750
- \******************************************/
751
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
752
-
753
- __webpack_require__.r(__webpack_exports__);
754
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
755
- /* harmony export */ "nanoid": () => (/* binding */ nanoid),
756
- /* harmony export */ "customAlphabet": () => (/* binding */ customAlphabet),
757
- /* harmony export */ "customRandom": () => (/* binding */ customRandom),
758
- /* harmony export */ "urlAlphabet": () => (/* reexport safe */ _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__.urlAlphabet),
759
- /* harmony export */ "random": () => (/* binding */ random)
760
- /* harmony export */ });
761
- /* harmony import */ var _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./url-alphabet/index.js */ "./node_modules/nanoid/url-alphabet/index.js");
762
-
763
- if (true) {
764
- if (
765
- typeof navigator !== 'undefined' &&
766
- navigator.product === 'ReactNative' &&
767
- typeof crypto === 'undefined'
768
- ) {
769
- throw new Error(
770
- 'React Native does not have a built-in secure random generator. ' +
771
- 'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
772
- 'For secure IDs, import `react-native-get-random-values` ' +
773
- 'before Nano ID.'
774
- )
775
- }
776
- if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {
777
- throw new Error(
778
- 'Import file with `if (!window.crypto) window.crypto = window.msCrypto`' +
779
- ' before importing Nano ID to fix IE 11 support'
780
- )
781
- }
782
- if (typeof crypto === 'undefined') {
783
- throw new Error(
784
- 'Your browser does not have secure random generator. ' +
785
- 'If you don’t need unpredictable IDs, you can use nanoid/non-secure.'
786
- )
787
- }
788
- }
789
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
790
- let customRandom = (alphabet, size, getRandom) => {
791
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
792
- let step = -~((1.6 * mask * size) / alphabet.length)
793
- return () => {
794
- let id = ''
795
- while (true) {
796
- let bytes = getRandom(step)
797
- let j = step
798
- while (j--) {
799
- id += alphabet[bytes[j] & mask] || ''
800
- if (id.length === size) return id
801
- }
802
- }
803
- }
804
- }
805
- let customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)
806
- let nanoid = (size = 21) => {
807
- let id = ''
808
- let bytes = crypto.getRandomValues(new Uint8Array(size))
809
- while (size--) {
810
- let byte = bytes[size] & 63
811
- if (byte < 36) {
812
- id += byte.toString(36)
813
- } else if (byte < 62) {
814
- id += (byte - 26).toString(36).toUpperCase()
815
- } else if (byte < 63) {
816
- id += '_'
817
- } else {
818
- id += '-'
819
- }
820
- }
821
- return id
822
- }
823
-
824
-
825
-
826
- /***/ }),
827
-
828
- /***/ "./node_modules/nanoid/url-alphabet/index.js":
829
- /*!***************************************************!*\
830
- !*** ./node_modules/nanoid/url-alphabet/index.js ***!
831
- \***************************************************/
832
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
833
-
834
- __webpack_require__.r(__webpack_exports__);
835
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
836
- /* harmony export */ "urlAlphabet": () => (/* binding */ urlAlphabet)
837
- /* harmony export */ });
838
- let urlAlphabet =
839
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
840
-
841
-
842
-
843
- /***/ })
844
-
845
- /******/ });
846
- /************************************************************************/
847
- /******/ // The module cache
848
- /******/ var __webpack_module_cache__ = {};
849
- /******/
850
- /******/ // The require function
851
- /******/ function __webpack_require__(moduleId) {
852
- /******/ // Check if module is in cache
853
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
854
- /******/ if (cachedModule !== undefined) {
855
- /******/ return cachedModule.exports;
856
- /******/ }
857
- /******/ // Create a new module (and put it into the cache)
858
- /******/ var module = __webpack_module_cache__[moduleId] = {
859
- /******/ // no module.id needed
860
- /******/ // no module.loaded needed
861
- /******/ exports: {}
862
- /******/ };
863
- /******/
864
- /******/ // Execute the module function
865
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
866
- /******/
867
- /******/ // Return the exports of the module
868
- /******/ return module.exports;
869
- /******/ }
870
- /******/
871
- /************************************************************************/
872
- /******/ /* webpack/runtime/define property getters */
873
- /******/ (() => {
874
- /******/ // define getter functions for harmony exports
875
- /******/ __webpack_require__.d = (exports, definition) => {
876
- /******/ for(var key in definition) {
877
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
878
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
879
- /******/ }
880
- /******/ }
881
- /******/ };
882
- /******/ })();
883
- /******/
884
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
885
- /******/ (() => {
886
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
887
- /******/ })();
888
- /******/
889
- /******/ /* webpack/runtime/make namespace object */
890
- /******/ (() => {
891
- /******/ // define __esModule on exports
892
- /******/ __webpack_require__.r = (exports) => {
893
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
894
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
895
- /******/ }
896
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
897
- /******/ };
898
- /******/ })();
899
- /******/
900
- /************************************************************************/
901
- var __webpack_exports__ = {};
902
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
903
- (() => {
904
- var exports = __webpack_exports__;
905
- /*!**********************!*\
906
- !*** ./src/index.ts ***!
907
- \**********************/
908
-
909
- Object.defineProperty(exports, "__esModule", ({ value: true }));
910
- var lowcode_sdk_1 = __webpack_require__(/*! ./lowcode.sdk */ "./src/lowcode.sdk.ts");
911
- if (true) {
912
- self.KF = lowcode_sdk_1.default;
913
- }
914
- exports["default"] = lowcode_sdk_1.default;
915
-
916
- })();
917
-
918
- var __webpack_exports___esModule = __webpack_exports__.__esModule;
919
- var __webpack_exports__default = __webpack_exports__["default"];
920
- export { __webpack_exports___esModule as __esModule, __webpack_exports__default as default };
921
-
922
- //# sourceMappingURL=kflowcode.sdk.module.js.map