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