@kissflow/lowcode-client-sdk 1.0.0 → 1.0.2-0.beta.1

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.
@@ -0,0 +1,649 @@
1
+ var __accessCheck = (obj, member, msg) => {
2
+ if (!member.has(obj))
3
+ throw TypeError("Cannot " + msg);
4
+ };
5
+ var __privateGet = (obj, member, getter) => {
6
+ __accessCheck(obj, member, "read from private field");
7
+ return getter ? getter.call(obj) : member.get(obj);
8
+ };
9
+ var __privateAdd = (obj, member, value) => {
10
+ if (member.has(obj))
11
+ throw TypeError("Cannot add the same private member more than once");
12
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ };
14
+ var __privateSet = (obj, member, value, setter) => {
15
+ __accessCheck(obj, member, "write to private field");
16
+ setter ? setter.call(obj, value) : member.set(obj, value);
17
+ return value;
18
+ };
19
+ var __privateMethod = (obj, member, method) => {
20
+ __accessCheck(obj, member, "access private method");
21
+ return method;
22
+ };
23
+ var _listeners, _registerComponentAPIs, registerComponentAPIs_fn, _csrfToken;
24
+ let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
25
+ byte &= 63;
26
+ if (byte < 36) {
27
+ id += byte.toString(36);
28
+ } else if (byte < 62) {
29
+ id += (byte - 26).toString(36).toUpperCase();
30
+ } else if (byte > 62) {
31
+ id += "-";
32
+ } else {
33
+ id += "_";
34
+ }
35
+ return id;
36
+ }, "");
37
+ const LISTENER_CMDS = {
38
+ API: "API",
39
+ GET_CONTEXT: "GET_CONTEXT",
40
+ RETURN: "RETURN",
41
+ GET_FORM_FIELD: "GET_FORM_FIELD",
42
+ UPDATE_FORM: "UPDATE_FORM",
43
+ GET_TABLE: "GET_TABLE",
44
+ GET_TABLE_ROW: "GET_TABLE_ROW",
45
+ ADD_TABLE_ROW: "ADD_TABLE_ROW",
46
+ ADD_TABLE_ROWS: "ADD_TABLE_ROWS",
47
+ DELETE_TABLE_ROW: "DELETE_TABLE_ROW",
48
+ TO_JSON: "TO_JSON",
49
+ GET_TABLE_ROWS: "GET_TABLE_ROWS",
50
+ MESSAGE: "MESSAGE",
51
+ CONFIRM: "CONFIRM",
52
+ ALERT: "ALERT",
53
+ REDIRECT: "REDIRECT",
54
+ OPEN_PAGE: "OPEN_PAGE",
55
+ FORMAT_DATE: "FORMAT_DATE",
56
+ FORMAT_DATE_TIME: "FORMAT_DATE_TIME",
57
+ FORMAT_NUMBER: "FORMAT_NUMBER",
58
+ FORMAT_CURRENCY: "FORMAT_CURRENCY",
59
+ FORMAT_BOOLEAN: "FORMAT_BOOLEAN",
60
+ GET_APP_VARIABLE: "GET_APP_VARIABLE",
61
+ SET_APP_VARIABLE: "SET_APP_VARIABLE",
62
+ GET_PAGE_VARIABLE: "GET_PAGE_VARIABLE",
63
+ SET_PAGE_VARIABLE: "SET_PAGE_VARIABLE",
64
+ GET_PAGE_PARAMS: "GET_PAGE_PARAMS",
65
+ GET_ALL_PAGE_PARAMS: "GET_ALL_PAGE_PARAMS",
66
+ PAGE_ON_CLOSE: "PAGE_ON_CLOSE",
67
+ OPEN_POPUP: "OPEN_POPUP",
68
+ GET_POPUP_PARAMS: "GET_POPUP_PARAMS",
69
+ GET_ALL_POPUP_PARAMS: "GET_ALL_POPUP_PARAMS",
70
+ CLOSE_POPUP: "CLOSE_POPUP",
71
+ COMPONENT_GET: "COMPONENT_GET",
72
+ COMPONENT_REFRESH: "COMPONENT_REFRESH",
73
+ COMPONENT_SHOW: "COMPONENT_SHOW",
74
+ COMPONENT_HIDE: "COMPONENT_HIDE",
75
+ COMPONENT_ADD_EVENT_LISTENER: "COMPONENT_ADD_EVENT_LISTENER",
76
+ CC_INITIALIZE: "CC_INITIALIZE",
77
+ CC_WATCH_PARAMS: "CC_WATCH_PARAMS",
78
+ WINDOW_NDEF_READER_NEW: "WINDOW_NDEF_READER_NEW",
79
+ WINDOW_NDEF_READER_SCAN: "WINDOW_NDEF_READER_SCAN",
80
+ WINDOW_NDEF_READER_WRITE: "WINDOW_NDEF_READER_WRITE",
81
+ WINDOW_NDEF_READER_ADD_EVENT_LISTENER: "WINDOW_NDEF_READER_ADD_EVENT_LISTENER",
82
+ WINDOW_NDEF_READER_MAKE_READONLY: "WINDOW_NDEF_READER_MAKE_READONLY",
83
+ WINDOW_NDEF_READER_ABORT_SCAN: "WINDOW_NDEF_READER_ABORT_SCAN",
84
+ DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE"
85
+ };
86
+ const EVENT_TYPES = {
87
+ COMPONENT_ON_MOUNT: "componentOnMount",
88
+ CC_ON_PARAMS_CHANGE: "onCustomComponentParamsChange"
89
+ };
90
+ const DEFAULTS = {
91
+ POPUP_ID: "ACTIVE_POP_UP"
92
+ };
93
+ function generateId(prefix = "lcncsdk") {
94
+ return `${prefix}-${nanoid()}`;
95
+ }
96
+ const globalInstances = {};
97
+ function postMessage(args) {
98
+ if (globalThis.parent && globalThis.parent !== globalThis) {
99
+ globalThis.parent.postMessage(args, "*");
100
+ } else {
101
+ globalThis.postMessage(args);
102
+ }
103
+ }
104
+ function onMessage(event) {
105
+ if (event.origin !== globalThis.location.origin) {
106
+ const data = event.data;
107
+ if (data == null ? void 0 : data.isEvent) {
108
+ const { target, eventParams, eventName, eventConfig = {} } = data;
109
+ let targetInstance = globalInstances[target];
110
+ targetInstance._dispatchEvent(eventName, eventParams);
111
+ if (eventConfig.once) {
112
+ targetInstance._removeEventListener(eventName);
113
+ }
114
+ return;
115
+ }
116
+ let { _req: req, resp } = data;
117
+ if (req == null ? void 0 : req._id) {
118
+ let targetInstance = globalInstances[req._id];
119
+ targetInstance._dispatchMessageEvents(req, resp);
120
+ }
121
+ }
122
+ }
123
+ globalThis.addEventListener("message", onMessage);
124
+ class EventBase {
125
+ constructor() {
126
+ __privateAdd(this, _listeners, void 0);
127
+ __privateSet(this, _listeners, {});
128
+ }
129
+ _addEventListener(eventName, callBack) {
130
+ var _a;
131
+ __privateGet(this, _listeners)[eventName] = ((_a = __privateGet(this, _listeners)) == null ? void 0 : _a[eventName]) || [];
132
+ __privateGet(this, _listeners)[eventName].push(callBack);
133
+ }
134
+ _removeEventListener(eventName, callBack) {
135
+ if (callBack) {
136
+ let index = __privateGet(this, _listeners)[eventName].findIndex(callBack);
137
+ index > -1 && __privateGet(this, _listeners)[eventName].splice(index, 1);
138
+ return;
139
+ }
140
+ Reflect.deleteProperty(__privateGet(this, _listeners), eventName);
141
+ }
142
+ _dispatchEvent(eventName, eventParams) {
143
+ if (Array.isArray(__privateGet(this, _listeners)[eventName])) {
144
+ __privateGet(this, _listeners)[eventName].forEach(
145
+ (callBack) => callBack(eventParams)
146
+ );
147
+ return true;
148
+ }
149
+ return false;
150
+ }
151
+ _dispatchMessageEvents(req, resp) {
152
+ let target = req._id;
153
+ if (Array.isArray(__privateGet(this, _listeners)[target])) {
154
+ __privateGet(this, _listeners)[target].forEach((listener) => {
155
+ try {
156
+ if (resp && Object.keys(resp).length === 1 && req.command !== LISTENER_CMDS.API) {
157
+ listener(Object.values(resp)[0]);
158
+ } else {
159
+ listener(resp);
160
+ }
161
+ } catch (err) {
162
+ console.error("Message callback error: ", err);
163
+ }
164
+ });
165
+ this._removeEventListener(target);
166
+ }
167
+ }
168
+ }
169
+ _listeners = new WeakMap();
170
+ class BaseSDK extends EventBase {
171
+ _postMessageAsync(command, args, hasCallBack, callBack) {
172
+ return new Promise((resolve, reject) => {
173
+ const _id = generateId(command.toLowerCase());
174
+ postMessage({ _id, command, ...args });
175
+ globalInstances[_id] = this;
176
+ this._addEventListener(_id, async (data) => {
177
+ if (data == null ? void 0 : data.errorMessage) {
178
+ reject(data);
179
+ } else {
180
+ if (hasCallBack && callBack) {
181
+ data = await callBack(data);
182
+ }
183
+ resolve(data);
184
+ }
185
+ });
186
+ });
187
+ }
188
+ _postMessage(command, args, callBack) {
189
+ const _id = generateId(command.toLowerCase());
190
+ postMessage({ _id, command, ...args });
191
+ if (callBack) {
192
+ this._addEventListener(args.eventName, callBack);
193
+ }
194
+ }
195
+ }
196
+ class Form extends BaseSDK {
197
+ constructor(instanceId) {
198
+ super();
199
+ this.type = "Form";
200
+ this.instanceId = instanceId;
201
+ }
202
+ toJSON() {
203
+ return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
204
+ instanceId: this.instanceId
205
+ });
206
+ }
207
+ getField(fieldId) {
208
+ return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
209
+ instanceId: this.instanceId,
210
+ fieldId
211
+ });
212
+ }
213
+ updateField(args) {
214
+ return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
215
+ data: args
216
+ });
217
+ }
218
+ getTable(tableId) {
219
+ return new Table(this.instanceId, tableId);
220
+ }
221
+ }
222
+ class Table extends BaseSDK {
223
+ constructor(instanceId, tableId) {
224
+ super();
225
+ this.tableId = tableId;
226
+ this.instanceId = instanceId;
227
+ }
228
+ toJSON() {
229
+ return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
230
+ tableId: this.tableId
231
+ });
232
+ }
233
+ getRows() {
234
+ return this._postMessageAsync(
235
+ LISTENER_CMDS.GET_TABLE_ROWS,
236
+ { tableId: this.tableId },
237
+ true,
238
+ (data) => {
239
+ return data.map(
240
+ (row) => new TableForm(this.instanceId, this.tableId, row.id)
241
+ );
242
+ }
243
+ );
244
+ }
245
+ getRow(rowId) {
246
+ return new TableForm(this.instanceId, this.tableId, rowId);
247
+ }
248
+ addRow(rowObject) {
249
+ return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROW, {
250
+ tableId: this.tableId,
251
+ rowObject
252
+ });
253
+ }
254
+ addRows(rows) {
255
+ return this._postMessageAsync(LISTENER_CMDS.ADD_TABLE_ROWS, {
256
+ tableId: this.tableId,
257
+ rows
258
+ });
259
+ }
260
+ deleteRow(rowId) {
261
+ return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
262
+ tableId: this.tableId,
263
+ rows: [rowId]
264
+ });
265
+ }
266
+ deleteRows(rows) {
267
+ return this._postMessageAsync(LISTENER_CMDS.DELETE_TABLE_ROW, {
268
+ tableId: this.tableId,
269
+ rows
270
+ });
271
+ }
272
+ }
273
+ class TableForm extends BaseSDK {
274
+ constructor(instanceId, tableId, rowId) {
275
+ super();
276
+ this.instanceId = instanceId;
277
+ this.type = "TabelForm";
278
+ this.tableId = tableId;
279
+ this.rowId = rowId;
280
+ }
281
+ getParent() {
282
+ return new Form(this.instanceId);
283
+ }
284
+ toJSON() {
285
+ return this._postMessageAsync(LISTENER_CMDS.TO_JSON, {
286
+ tableId: this.tableId,
287
+ rowId: this.rowId
288
+ });
289
+ }
290
+ getField(fieldId) {
291
+ return this._postMessageAsync(LISTENER_CMDS.GET_FORM_FIELD, {
292
+ instanceId: this.instanceId,
293
+ tableId: this.tableId,
294
+ rowId: this.rowId,
295
+ fieldId
296
+ });
297
+ }
298
+ updateField(args) {
299
+ return this._postMessageAsync(LISTENER_CMDS.UPDATE_FORM, {
300
+ instanceId: this.instanceId,
301
+ tableId: this.tableId,
302
+ rowId: this.rowId,
303
+ data: args
304
+ });
305
+ }
306
+ }
307
+ class Client extends BaseSDK {
308
+ showInfo(message) {
309
+ return super._postMessageAsync(LISTENER_CMDS.MESSAGE, { message });
310
+ }
311
+ showConfirm(args) {
312
+ return super._postMessageAsync(LISTENER_CMDS.CONFIRM, {
313
+ data: {
314
+ title: args.title,
315
+ content: args.content,
316
+ okText: args.okText || "Ok",
317
+ cancelText: args.cancelText || "Cancel"
318
+ }
319
+ });
320
+ }
321
+ redirect(url) {
322
+ return super._postMessageAsync(LISTENER_CMDS.REDIRECT, { url });
323
+ }
324
+ }
325
+ class Formatter extends BaseSDK {
326
+ toDate(date) {
327
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE, {
328
+ date
329
+ });
330
+ }
331
+ toDateTime(date) {
332
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_DATE_TIME, {
333
+ date
334
+ });
335
+ }
336
+ toNumber(value) {
337
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_NUMBER, {
338
+ value
339
+ });
340
+ }
341
+ toCurrency(value, currencyCode) {
342
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_CURRENCY, {
343
+ value,
344
+ currencyCode
345
+ });
346
+ }
347
+ toBoolean(value) {
348
+ return this._postMessageAsync(LISTENER_CMDS.FORMAT_BOOLEAN, {
349
+ value
350
+ });
351
+ }
352
+ }
353
+ class Component extends BaseSDK {
354
+ constructor(props) {
355
+ super();
356
+ __privateAdd(this, _registerComponentAPIs);
357
+ this._id = props.componentId;
358
+ this.type = "Component";
359
+ globalInstances[this._id] = this;
360
+ __privateMethod(this, _registerComponentAPIs, registerComponentAPIs_fn).call(this, props.componentMethods);
361
+ }
362
+ onMount(callback) {
363
+ this._postMessage(
364
+ LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
365
+ {
366
+ id: this._id,
367
+ eventName: EVENT_TYPES.COMPONENT_ON_MOUNT,
368
+ eventConfig: {
369
+ once: true
370
+ }
371
+ },
372
+ callback
373
+ );
374
+ }
375
+ refresh() {
376
+ return this._postMessageAsync(LISTENER_CMDS.COMPONENT_REFRESH, {
377
+ id: this._id
378
+ });
379
+ }
380
+ show() {
381
+ return this._postMessageAsync(LISTENER_CMDS.COMPONENT_SHOW, {
382
+ id: this._id
383
+ });
384
+ }
385
+ hide() {
386
+ return this._postMessageAsync(LISTENER_CMDS.COMPONENT_HIDE, {
387
+ id: this._id
388
+ });
389
+ }
390
+ }
391
+ _registerComponentAPIs = new WeakSet();
392
+ registerComponentAPIs_fn = function(componentAPIs) {
393
+ componentAPIs == null ? void 0 : componentAPIs.forEach((Api) => {
394
+ this[Api.name] = (...args) => {
395
+ if (Api.type === "method") {
396
+ return this._postMessageAsync(`COMPONENT_${Api.name}`, {
397
+ id: this._id,
398
+ parameters: args
399
+ });
400
+ } else if (Api.type === "event") {
401
+ this._postMessage(
402
+ LISTENER_CMDS.COMPONENT_ADD_EVENT_LISTENER,
403
+ {
404
+ id: this._id,
405
+ eventName: Api.name,
406
+ eventConfig: args[1]
407
+ },
408
+ args[0]
409
+ );
410
+ }
411
+ };
412
+ });
413
+ };
414
+ class Popup extends BaseSDK {
415
+ constructor(props) {
416
+ super();
417
+ this.type = "Popup";
418
+ this._id = props.popupId || DEFAULTS.POPUP_ID;
419
+ }
420
+ getParameter(key) {
421
+ return this._postMessageAsync(LISTENER_CMDS.GET_POPUP_PARAMS, {
422
+ key,
423
+ popupId: this._id
424
+ });
425
+ }
426
+ getAllParameters() {
427
+ return this._postMessageAsync(LISTENER_CMDS.GET_ALL_POPUP_PARAMS, {
428
+ popupId: this._id
429
+ });
430
+ }
431
+ close() {
432
+ return this._postMessageAsync(LISTENER_CMDS.CLOSE_POPUP, {});
433
+ }
434
+ getComponent(componentId) {
435
+ return this._postMessageAsync(
436
+ LISTENER_CMDS.COMPONENT_GET,
437
+ { componentId },
438
+ true,
439
+ (data) => {
440
+ return new Component(data);
441
+ }
442
+ );
443
+ }
444
+ }
445
+ class Page extends BaseSDK {
446
+ constructor(props) {
447
+ super();
448
+ this.type = "Page";
449
+ this.popup = new Popup({});
450
+ this._id = props.pageId;
451
+ }
452
+ getParameter(key) {
453
+ return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_PARAMS, {
454
+ key
455
+ });
456
+ }
457
+ getAllParameters() {
458
+ return this._postMessageAsync(LISTENER_CMDS.GET_ALL_PAGE_PARAMS, {
459
+ pageId: this._id
460
+ });
461
+ }
462
+ getVariable(key) {
463
+ return this._postMessageAsync(LISTENER_CMDS.GET_PAGE_VARIABLE, {
464
+ key
465
+ });
466
+ }
467
+ setVariable(key, value) {
468
+ return this._postMessageAsync(LISTENER_CMDS.SET_PAGE_VARIABLE, {
469
+ key,
470
+ value
471
+ });
472
+ }
473
+ openPopup(popupId, popupParams) {
474
+ return this._postMessageAsync(LISTENER_CMDS.OPEN_POPUP, {
475
+ popupId,
476
+ popupParams
477
+ });
478
+ }
479
+ getComponent(componentId) {
480
+ return this._postMessageAsync(
481
+ LISTENER_CMDS.COMPONENT_GET,
482
+ { componentId },
483
+ true,
484
+ (data) => new Component(data)
485
+ );
486
+ }
487
+ }
488
+ class DecisionTable extends BaseSDK {
489
+ constructor(flowId) {
490
+ super();
491
+ this.flowId = flowId;
492
+ }
493
+ evaluate(payload) {
494
+ return this._postMessageAsync(LISTENER_CMDS.DECISION_TABLE_EXECUTE, {
495
+ flowId: this.flowId,
496
+ payload
497
+ });
498
+ }
499
+ }
500
+ class Application extends BaseSDK {
501
+ constructor(props) {
502
+ super();
503
+ this._id = props.appId;
504
+ this.page = new Page(props);
505
+ }
506
+ getVariable(key) {
507
+ return this._postMessageAsync(LISTENER_CMDS.GET_APP_VARIABLE, {
508
+ key
509
+ });
510
+ }
511
+ setVariable(key, value) {
512
+ return this._postMessageAsync(LISTENER_CMDS.SET_APP_VARIABLE, {
513
+ key,
514
+ value
515
+ });
516
+ }
517
+ openPage(pageId, pageParams) {
518
+ return this._postMessageAsync(LISTENER_CMDS.OPEN_PAGE, {
519
+ pageId,
520
+ pageParams
521
+ });
522
+ }
523
+ getDecisionTable(flowId) {
524
+ return new DecisionTable(flowId);
525
+ }
526
+ }
527
+ class NDEFReader extends BaseSDK {
528
+ constructor() {
529
+ super();
530
+ this.id = generateId(LISTENER_CMDS.WINDOW_NDEF_READER_NEW);
531
+ globalInstances[this.id] = this;
532
+ this._postMessage(
533
+ LISTENER_CMDS.WINDOW_NDEF_READER_NEW,
534
+ {
535
+ id: this.id,
536
+ operation: "new"
537
+ },
538
+ (data) => {
539
+ }
540
+ );
541
+ }
542
+ scan() {
543
+ return new Promise((resolve, reject) => {
544
+ this._postMessage(
545
+ LISTENER_CMDS.WINDOW_NDEF_READER_SCAN,
546
+ { id: this.id, operation: "scan" },
547
+ ({ data, err }) => {
548
+ console.log("scan data from main window ", data);
549
+ resolve(data);
550
+ }
551
+ );
552
+ });
553
+ }
554
+ write(data) {
555
+ return new Promise((resolve, reject) => {
556
+ this._postMessage(
557
+ LISTENER_CMDS.WINDOW_NDEF_READER_WRITE,
558
+ { id: this.id, operation: "write", data },
559
+ ({ data: data2, err }) => {
560
+ }
561
+ );
562
+ });
563
+ }
564
+ addEventListener(eventName, cb) {
565
+ this._postMessage(
566
+ LISTENER_CMDS.WINDOW_NDEF_READER_ADD_EVENT_LISTENER,
567
+ {
568
+ id: this.id,
569
+ operation: "addEventListener",
570
+ eventName
571
+ },
572
+ () => {
573
+ }
574
+ );
575
+ }
576
+ makeReadOnly() {
577
+ return new Promise((resolve, reject) => {
578
+ this._postMessage(
579
+ LISTENER_CMDS.WINDOW_NDEF_READER_MAKE_READONLY,
580
+ { id: this.id, operation: "makeReadOnly" },
581
+ ({ data, err }) => {
582
+ }
583
+ );
584
+ });
585
+ }
586
+ abortScan() {
587
+ return new Promise((resolve, reject) => {
588
+ this._postMessage(
589
+ LISTENER_CMDS.WINDOW_NDEF_READER_ABORT_SCAN,
590
+ { id: this.id, operation: "abortScan" },
591
+ ({ data, err }) => {
592
+ }
593
+ );
594
+ });
595
+ }
596
+ }
597
+ const window = {
598
+ NDEFReader
599
+ };
600
+ class LowcodeSDK extends BaseSDK {
601
+ constructor(props) {
602
+ super();
603
+ __privateAdd(this, _csrfToken, void 0);
604
+ if (props.tableId && props.tableRowId) {
605
+ this.context = new TableForm(
606
+ props.formInstanceId,
607
+ props.tableId,
608
+ props.tableRowId
609
+ );
610
+ } else if (props.formInstanceId) {
611
+ this.context = new Form(props.formInstanceId);
612
+ } else if (props.popupId) {
613
+ this.context = new Popup(props);
614
+ } else if (props.pageId && !props.componentId) {
615
+ this.context = new Page(props);
616
+ } else if (props.componentId) {
617
+ this.context = new Component(props);
618
+ }
619
+ this.client = new Client();
620
+ this.formatter = new Formatter();
621
+ if (props.appId) {
622
+ this.app = new Application(props);
623
+ }
624
+ this.user = props.user;
625
+ this.env = props.envDetails;
626
+ this.account = props.account;
627
+ __privateSet(this, _csrfToken, props.csrfToken);
628
+ }
629
+ async api(url, args) {
630
+ const response = await globalThis.fetch(url, {
631
+ ...args,
632
+ headers: {
633
+ ...(args == null ? void 0 : args.headers) || {},
634
+ "X-Csrf-Token": __privateGet(this, _csrfToken)
635
+ }
636
+ });
637
+ const contentType = response.headers.get("content-type");
638
+ if (contentType && contentType.includes("application/json")) {
639
+ return await response.json();
640
+ } else {
641
+ return response;
642
+ }
643
+ }
644
+ }
645
+ _csrfToken = new WeakMap();
646
+ function initSDK(config) {
647
+ return new LowcodeSDK(config);
648
+ }
649
+ export { initSDK as default, window };