@kissflow/lowcode-client-sdk 1.0.6 → 1.0.8-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.
@@ -1,896 +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/.pnpm/nanoid@3.3.3/node_modules/nanoid/index.browser.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
- _this.user = props.user;
654
- _this.account = props.account;
655
- return _this;
656
- }
657
- LowcodeSDK.prototype.api = function (url, args) {
658
- if (args === void 0) { args = {}; }
659
- return this._postMessageAsync(constants_1.LISTENER_CMDS.API, { url: url, args: args });
660
- };
661
- LowcodeSDK.prototype.watchParams = function (func) {
662
- this._postMessage(constants_1.LISTENER_CMDS.PARAMS, func);
663
- };
664
- LowcodeSDK.prototype.getContext = function () {
665
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_CONTEXT, {});
666
- };
667
- return LowcodeSDK;
668
- }(base_1.BaseSDK));
669
- function initSDK(config) {
670
- if (config === void 0) { config = {}; }
671
- return new LowcodeSDK(config);
672
- }
673
- exports["default"] = initSDK;
674
-
675
-
676
- /***/ }),
677
-
678
- /***/ "./src/page.ts":
679
- /*!*********************!*\
680
- !*** ./src/page.ts ***!
681
- \*********************/
682
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
683
-
684
-
685
- var __extends = (this && this.__extends) || (function () {
686
- var extendStatics = function (d, b) {
687
- extendStatics = Object.setPrototypeOf ||
688
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
689
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
690
- return extendStatics(d, b);
691
- };
692
- return function (d, b) {
693
- if (typeof b !== "function" && b !== null)
694
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
695
- extendStatics(d, b);
696
- function __() { this.constructor = d; }
697
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
698
- };
699
- })();
700
- Object.defineProperty(exports, "__esModule", ({ value: true }));
701
- exports.Page = void 0;
702
- var component_1 = __webpack_require__(/*! ./component */ "./src/component.ts");
703
- var base_1 = __webpack_require__(/*! ./base */ "./src/base.ts");
704
- var constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
705
- var Page = /** @class */ (function (_super) {
706
- __extends(Page, _super);
707
- function Page(pageId) {
708
- var _this = _super.call(this, {}) || this;
709
- _this._id = pageId;
710
- return _this;
711
- }
712
- Page.prototype.getParameter = function (key) {
713
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_PAGE_PARAMS, {
714
- key: key
715
- });
716
- };
717
- Page.prototype.getVariable = function (key) {
718
- return this._postMessageAsync(constants_1.LISTENER_CMDS.GET_PAGE_VARIABLE, {
719
- key: key
720
- });
721
- };
722
- Page.prototype.setVariable = function (key, value) {
723
- return this._postMessageAsync(constants_1.LISTENER_CMDS.SET_PAGE_VARIABLE, {
724
- key: key,
725
- value: value
726
- });
727
- };
728
- Page.prototype.openPopup = function (popupId, popupParams) {
729
- //TODO: add popup class
730
- return this._postMessageAsync(constants_1.LISTENER_CMDS.OPEN_POPUP_PAGE, {
731
- popupId: popupId,
732
- popupParams: popupParams
733
- });
734
- };
735
- Page.prototype.closePopup = function () {
736
- return this._postMessageAsync(constants_1.LISTENER_CMDS.CLOSE_POPUP, {});
737
- };
738
- Page.prototype.getComponent = function (componentId) {
739
- return new component_1.Component(componentId);
740
- };
741
- Page.prototype.onClose = function (callback) {
742
- this._registerEventListener(this._id, constants_1.EVENT_TYPES.ON_CLOSE, callback);
743
- };
744
- return Page;
745
- }(base_1.BaseSDK));
746
- exports.Page = Page;
747
-
748
-
749
- /***/ }),
750
-
751
- /***/ "./node_modules/.pnpm/nanoid@3.3.3/node_modules/nanoid/index.browser.js":
752
- /*!******************************************************************************!*\
753
- !*** ./node_modules/.pnpm/nanoid@3.3.3/node_modules/nanoid/index.browser.js ***!
754
- \******************************************************************************/
755
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
756
-
757
- __webpack_require__.r(__webpack_exports__);
758
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
759
- /* harmony export */ "customAlphabet": () => (/* binding */ customAlphabet),
760
- /* harmony export */ "customRandom": () => (/* binding */ customRandom),
761
- /* harmony export */ "nanoid": () => (/* binding */ nanoid),
762
- /* harmony export */ "random": () => (/* binding */ random),
763
- /* harmony export */ "urlAlphabet": () => (/* reexport safe */ _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__.urlAlphabet)
764
- /* harmony export */ });
765
- /* harmony import */ var _url_alphabet_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./url-alphabet/index.js */ "./node_modules/.pnpm/nanoid@3.3.3/node_modules/nanoid/url-alphabet/index.js");
766
-
767
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
768
- let customRandom = (alphabet, defaultSize, getRandom) => {
769
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
770
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
771
- return (size = defaultSize) => {
772
- let id = ''
773
- while (true) {
774
- let bytes = getRandom(step)
775
- let j = step
776
- while (j--) {
777
- id += alphabet[bytes[j] & mask] || ''
778
- if (id.length === size) return id
779
- }
780
- }
781
- }
782
- }
783
- let customAlphabet = (alphabet, size = 21) =>
784
- customRandom(alphabet, size, random)
785
- let nanoid = (size = 21) =>
786
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
787
- byte &= 63
788
- if (byte < 36) {
789
- id += byte.toString(36)
790
- } else if (byte < 62) {
791
- id += (byte - 26).toString(36).toUpperCase()
792
- } else if (byte > 62) {
793
- id += '-'
794
- } else {
795
- id += '_'
796
- }
797
- return id
798
- }, '')
799
-
800
-
801
-
802
- /***/ }),
803
-
804
- /***/ "./node_modules/.pnpm/nanoid@3.3.3/node_modules/nanoid/url-alphabet/index.js":
805
- /*!***********************************************************************************!*\
806
- !*** ./node_modules/.pnpm/nanoid@3.3.3/node_modules/nanoid/url-alphabet/index.js ***!
807
- \***********************************************************************************/
808
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
809
-
810
- __webpack_require__.r(__webpack_exports__);
811
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
812
- /* harmony export */ "urlAlphabet": () => (/* binding */ urlAlphabet)
813
- /* harmony export */ });
814
- let urlAlphabet =
815
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
816
-
817
-
818
-
819
- /***/ })
820
-
821
- /******/ });
822
- /************************************************************************/
823
- /******/ // The module cache
824
- /******/ var __webpack_module_cache__ = {};
825
- /******/
826
- /******/ // The require function
827
- /******/ function __webpack_require__(moduleId) {
828
- /******/ // Check if module is in cache
829
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
830
- /******/ if (cachedModule !== undefined) {
831
- /******/ return cachedModule.exports;
832
- /******/ }
833
- /******/ // Create a new module (and put it into the cache)
834
- /******/ var module = __webpack_module_cache__[moduleId] = {
835
- /******/ // no module.id needed
836
- /******/ // no module.loaded needed
837
- /******/ exports: {}
838
- /******/ };
839
- /******/
840
- /******/ // Execute the module function
841
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
842
- /******/
843
- /******/ // Return the exports of the module
844
- /******/ return module.exports;
845
- /******/ }
846
- /******/
847
- /************************************************************************/
848
- /******/ /* webpack/runtime/define property getters */
849
- /******/ (() => {
850
- /******/ // define getter functions for harmony exports
851
- /******/ __webpack_require__.d = (exports, definition) => {
852
- /******/ for(var key in definition) {
853
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
854
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
855
- /******/ }
856
- /******/ }
857
- /******/ };
858
- /******/ })();
859
- /******/
860
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
861
- /******/ (() => {
862
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
863
- /******/ })();
864
- /******/
865
- /******/ /* webpack/runtime/make namespace object */
866
- /******/ (() => {
867
- /******/ // define __esModule on exports
868
- /******/ __webpack_require__.r = (exports) => {
869
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
870
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
871
- /******/ }
872
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
873
- /******/ };
874
- /******/ })();
875
- /******/
876
- /************************************************************************/
877
- var __webpack_exports__ = {};
878
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
879
- (() => {
880
- var exports = __webpack_exports__;
881
- /*!**********************!*\
882
- !*** ./src/index.ts ***!
883
- \**********************/
884
-
885
- Object.defineProperty(exports, "__esModule", ({ value: true }));
886
- var lowcode_sdk_1 = __webpack_require__(/*! ./lowcode.sdk */ "./src/lowcode.sdk.ts");
887
- if (true) {
888
- self.KF = lowcode_sdk_1.default;
889
- }
890
- exports["default"] = lowcode_sdk_1.default;
891
-
892
- })();
893
-
894
- /******/ })()
895
- ;
896
- //# sourceMappingURL=kflowcode.sdk.js.map