@olenbetong/appframe-core 1.3.7 → 2.0.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.
- package/dist/esm/af.common.js +231 -315
- package/dist/esm/af.common.legacy.js +230 -316
- package/dist/esm/af.common.legacy.min.js +6 -6
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +5 -5
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +229 -316
- package/dist/iife/af.common.legacy.js +230 -317
- package/dist/iife/af.common.legacy.min.js +6 -6
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +8 -8
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/UserSession.d.ts +17 -3
- package/es/UserSession.js +13 -2
- package/es/index.d.ts +31 -3
- package/es/index.js +3 -4
- package/package.json +2 -2
- package/src/UserSession.ts +17 -3
- package/src/index.ts +36 -3
- package/es/exportDataObject.d.ts +0 -73
- package/es/exportDataObject.js +0 -61
- package/es/formDataToObject.d.ts +0 -26
- package/es/formDataToObject.js +0 -73
- package/src/exportDataObject.ts +0 -110
- package/src/formDataToObject.ts +0 -80
- package/src/global.d.ts +0 -56
|
@@ -14,6 +14,10 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
var __publicField = (obj, key2, value) => {
|
|
18
|
+
__defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
17
21
|
|
|
18
22
|
// src/errorHandler.ts
|
|
19
23
|
window.addEventListener("error", (event) => {
|
|
@@ -57,224 +61,6 @@ function mitt_default(n) {
|
|
|
57
61
|
} };
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
// src/downloadBlob.ts
|
|
61
|
-
function downloadBlob(blob, fileName) {
|
|
62
|
-
return new Promise(function(resolve, reject) {
|
|
63
|
-
try {
|
|
64
|
-
const url = URL.createObjectURL(blob);
|
|
65
|
-
const parent = document.body;
|
|
66
|
-
const anchor = document.createElement("a");
|
|
67
|
-
anchor.setAttribute("download", fileName);
|
|
68
|
-
anchor.href = url;
|
|
69
|
-
parent.append(anchor);
|
|
70
|
-
anchor.click();
|
|
71
|
-
parent.removeChild(anchor);
|
|
72
|
-
setTimeout(function() {
|
|
73
|
-
URL.revokeObjectURL(url);
|
|
74
|
-
resolve();
|
|
75
|
-
}, 250);
|
|
76
|
-
} catch (ex) {
|
|
77
|
-
reject(ex);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/downloadRequest.ts
|
|
83
|
-
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
84
|
-
var _a;
|
|
85
|
-
function reportProgress(progress) {
|
|
86
|
-
if (typeof onProgress === "function") {
|
|
87
|
-
onProgress(__spreadValues({}, progress));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
let bytesReceived = 0;
|
|
91
|
-
reportProgress({ status: "requested" });
|
|
92
|
-
try {
|
|
93
|
-
let response = await fetch(request);
|
|
94
|
-
if (!response.ok || !response.body) {
|
|
95
|
-
if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
|
|
96
|
-
let data = await response.json();
|
|
97
|
-
if (data.error) {
|
|
98
|
-
throw new Error(data.error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`${response.status} ${response.statusText}`);
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
const reader = response.body.getReader();
|
|
105
|
-
const stream = new ReadableStream({
|
|
106
|
-
start: function(controller) {
|
|
107
|
-
function pump() {
|
|
108
|
-
return reader.read().then(function(read) {
|
|
109
|
-
if (read.done) {
|
|
110
|
-
controller.close();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
bytesReceived += read.value.length;
|
|
114
|
-
reportProgress({ bytesReceived, status: "downloading" });
|
|
115
|
-
controller.enqueue(read.value);
|
|
116
|
-
return pump();
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return pump();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
response = new Response(stream);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.warn("Failed to replace response stream to log download progress.");
|
|
125
|
-
}
|
|
126
|
-
const blob = await response.blob();
|
|
127
|
-
reportProgress({ bytesReceived, status: "downloaded" });
|
|
128
|
-
await downloadBlob(blob, fileName);
|
|
129
|
-
reportProgress({ bytesReceived, status: "completed" });
|
|
130
|
-
} catch (err) {
|
|
131
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
132
|
-
reportProgress({ status: "cancelled" });
|
|
133
|
-
} else {
|
|
134
|
-
reportProgress({ error: err.message, status: "error" });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/exportDataObject.ts
|
|
140
|
-
function exportOptionsFromDataObject(dataObject, specifiedOptions) {
|
|
141
|
-
return __spreadValues({
|
|
142
|
-
columns: dataObject.getFields().map((field) => ({ name: field.name })),
|
|
143
|
-
distinctRows: dataObject.getParameter("distinctRows"),
|
|
144
|
-
filterObject: dataObject.getParameter("filterObject"),
|
|
145
|
-
filterString: dataObject.getParameter("filterString"),
|
|
146
|
-
maxRecords: dataObject.getParameter("maxRecords"),
|
|
147
|
-
sortOrder: dataObject.getParameter("sortOrder"),
|
|
148
|
-
whereClause: dataObject.getParameter("whereClause"),
|
|
149
|
-
whereObject: dataObject.getParameter("whereObject")
|
|
150
|
-
}, specifiedOptions);
|
|
151
|
-
}
|
|
152
|
-
var defaultOptions = {
|
|
153
|
-
columns: [],
|
|
154
|
-
distinctRows: false,
|
|
155
|
-
filterObject: null,
|
|
156
|
-
filterString: "",
|
|
157
|
-
maxRecords: -1,
|
|
158
|
-
sortOrder: [],
|
|
159
|
-
whereClause: "",
|
|
160
|
-
whereObject: null
|
|
161
|
-
};
|
|
162
|
-
function getDataObjectReportRequest(params) {
|
|
163
|
-
var _a;
|
|
164
|
-
const { articleId, dataObject, format, options } = params;
|
|
165
|
-
const reportOptions = options ? Object.assign({}, defaultOptions, options) : defaultOptions;
|
|
166
|
-
const body = "data=" + encodeURIComponent(JSON.stringify(reportOptions));
|
|
167
|
-
const requestUrl = `/api/data-object/export/${articleId}/${dataObject}/${format}`;
|
|
168
|
-
const controller = (_a = params.controller) != null ? _a : new AbortController();
|
|
169
|
-
return {
|
|
170
|
-
controller,
|
|
171
|
-
request: new Request(requestUrl, {
|
|
172
|
-
body,
|
|
173
|
-
credentials: "same-origin",
|
|
174
|
-
headers: {
|
|
175
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
176
|
-
},
|
|
177
|
-
method: "POST",
|
|
178
|
-
signal: controller.signal
|
|
179
|
-
})
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function openDataObjectReport(params) {
|
|
183
|
-
const { dataObject, fileName, format } = params;
|
|
184
|
-
const { request } = getDataObjectReportRequest(params);
|
|
185
|
-
return downloadRequest(request, {
|
|
186
|
-
fileName: `${fileName || dataObject}.${format}`
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// src/has.ts
|
|
191
|
-
function has(obj, key2) {
|
|
192
|
-
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/parseFunc.ts
|
|
196
|
-
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
197
|
-
function parseFunc(func) {
|
|
198
|
-
var match = func.toString().match(funcRegex);
|
|
199
|
-
if (match === null) {
|
|
200
|
-
throw new TypeError("Unable to parse function!");
|
|
201
|
-
}
|
|
202
|
-
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// src/Namespace.ts
|
|
206
|
-
function Namespace() {
|
|
207
|
-
}
|
|
208
|
-
Namespace.prototype = /* @__PURE__ */ Object.create(null);
|
|
209
|
-
var Namespace_default = Namespace;
|
|
210
|
-
|
|
211
|
-
// src/requireNamespace.ts
|
|
212
|
-
function requireNamespace(root, namespace) {
|
|
213
|
-
if (typeof root === "object") {
|
|
214
|
-
if (typeof namespace === "string") {
|
|
215
|
-
let path = namespace.split(".");
|
|
216
|
-
return requireNamespace(root, path);
|
|
217
|
-
} else if (Array.isArray(namespace)) {
|
|
218
|
-
let current = root;
|
|
219
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
220
|
-
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
221
|
-
}
|
|
222
|
-
return current;
|
|
223
|
-
} else {
|
|
224
|
-
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
throw new TypeError("Invalid type of parameter 'root'");
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// src/warn.ts
|
|
232
|
-
function warn(message, fallbackToAlert) {
|
|
233
|
-
console.warn(message);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/expose.ts
|
|
237
|
-
function expose(name, value) {
|
|
238
|
-
if (arguments.length !== 2) {
|
|
239
|
-
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
240
|
-
}
|
|
241
|
-
if (Array.isArray(value)) {
|
|
242
|
-
for (let func of value) {
|
|
243
|
-
const { name: funcName } = parseFunc(func);
|
|
244
|
-
if (funcName) {
|
|
245
|
-
expose(name, func);
|
|
246
|
-
} else {
|
|
247
|
-
throw new Error(
|
|
248
|
-
"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
} else {
|
|
253
|
-
let keyName;
|
|
254
|
-
let namespace;
|
|
255
|
-
if (typeof value === "function") {
|
|
256
|
-
keyName = parseFunc(value).name;
|
|
257
|
-
}
|
|
258
|
-
if (typeof name === "string") {
|
|
259
|
-
let pathParts = name.split(".");
|
|
260
|
-
if (!keyName) {
|
|
261
|
-
keyName = pathParts[pathParts.length - 1];
|
|
262
|
-
pathParts = pathParts.slice(0, pathParts.length - 1);
|
|
263
|
-
}
|
|
264
|
-
namespace = requireNamespace(window, pathParts);
|
|
265
|
-
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
266
|
-
namespace = name;
|
|
267
|
-
} else {
|
|
268
|
-
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
269
|
-
}
|
|
270
|
-
if (has(namespace, keyName)) {
|
|
271
|
-
warn([name, keyName].join(".") + " is already defined!");
|
|
272
|
-
} else {
|
|
273
|
-
namespace[keyName] = value;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
64
|
// src/getLocalizedString.ts
|
|
279
65
|
async function getLocalizedStringAsync(string) {
|
|
280
66
|
try {
|
|
@@ -397,55 +183,12 @@ function getLocalizedString(string) {
|
|
|
397
183
|
return localized;
|
|
398
184
|
}
|
|
399
185
|
|
|
400
|
-
// src/localStorage.ts
|
|
401
|
-
function getLocalKey(key2) {
|
|
402
|
-
var _a;
|
|
403
|
-
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key2].join(".");
|
|
404
|
-
}
|
|
405
|
-
var LocalStorage = class {
|
|
406
|
-
isPersisted() {
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
getLocalStorageKey(key2, global) {
|
|
410
|
-
return global ? ["common", key2].join(".") : getLocalKey(key2);
|
|
411
|
-
}
|
|
412
|
-
get(key2, defaultValue, global) {
|
|
413
|
-
const lsKey = this.getLocalStorageKey(key2, global);
|
|
414
|
-
const value = localStorage.getItem(lsKey);
|
|
415
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
416
|
-
}
|
|
417
|
-
set(key2, value, global) {
|
|
418
|
-
localStorage.setItem(
|
|
419
|
-
this.getLocalStorageKey(key2, global),
|
|
420
|
-
JSON.stringify(value)
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
remove(key2, global) {
|
|
424
|
-
const lsKey = this.getLocalStorageKey(key2, global);
|
|
425
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
426
|
-
localStorage.removeItem(lsKey);
|
|
427
|
-
return true;
|
|
428
|
-
} else {
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
clear() {
|
|
433
|
-
const baseKey = getLocalKey("");
|
|
434
|
-
for (let key2 in localStorage) {
|
|
435
|
-
if (key2.slice(0, baseKey.length) === baseKey) {
|
|
436
|
-
localStorage.removeItem(key2);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
var localStorage_default = new LocalStorage();
|
|
442
|
-
|
|
443
186
|
// src/SessionHandler.ts
|
|
444
187
|
var _SessionHandler = class {
|
|
445
188
|
constructor() {
|
|
446
|
-
this
|
|
447
|
-
this
|
|
448
|
-
this
|
|
189
|
+
__publicField(this, "eventHandler", mitt_default());
|
|
190
|
+
__publicField(this, "showingDialog", false);
|
|
191
|
+
__publicField(this, "dialog", null);
|
|
449
192
|
}
|
|
450
193
|
expired(callback) {
|
|
451
194
|
af.userSession = af.userSession || {
|
|
@@ -579,72 +322,249 @@ var _SessionHandler = class {
|
|
|
579
322
|
}
|
|
580
323
|
};
|
|
581
324
|
var SessionHandler = _SessionHandler;
|
|
582
|
-
SessionHandler
|
|
325
|
+
__publicField(SessionHandler, "messages", {
|
|
583
326
|
login: "Log in",
|
|
584
327
|
relog: "Session expired - log in"
|
|
585
|
-
};
|
|
328
|
+
});
|
|
586
329
|
|
|
587
330
|
// src/UserSession.ts
|
|
588
331
|
var UserSession = class extends SessionHandler {
|
|
589
332
|
constructor(userData) {
|
|
590
333
|
super();
|
|
591
|
-
this
|
|
592
|
-
this
|
|
593
|
-
this
|
|
594
|
-
this
|
|
595
|
-
this
|
|
334
|
+
__publicField(this, "amDesignator", "a.m.");
|
|
335
|
+
__publicField(this, "dayNames", ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]);
|
|
336
|
+
__publicField(this, "dayNamesShort", ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);
|
|
337
|
+
__publicField(this, "decimalSeparator", ".");
|
|
338
|
+
__publicField(this, "domain", "OB");
|
|
339
|
+
__publicField(this, "email");
|
|
340
|
+
__publicField(this, "formats");
|
|
341
|
+
__publicField(this, "groupSeparator", null);
|
|
342
|
+
__publicField(this, "integratedSecurity", false);
|
|
343
|
+
__publicField(this, "isDeveloper", false);
|
|
344
|
+
__publicField(this, "login", "");
|
|
345
|
+
__publicField(this, "loginType");
|
|
346
|
+
__publicField(this, "monthNames", ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", ""]);
|
|
347
|
+
__publicField(this, "monthNamesShort", ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""]);
|
|
348
|
+
__publicField(this, "name");
|
|
349
|
+
__publicField(this, "pmDesignator", "p.m.");
|
|
350
|
+
__publicField(this, "shortDateFormat", "dd.MM.yyyy");
|
|
351
|
+
__publicField(this, "culture", "en-GB");
|
|
352
|
+
__publicField(this, "uiculture", "en-GB");
|
|
353
|
+
__publicField(this, "expired", () => null);
|
|
596
354
|
this.formats = {};
|
|
597
355
|
Object.assign(this, userData);
|
|
598
356
|
}
|
|
599
357
|
};
|
|
600
358
|
|
|
601
|
-
// src/
|
|
602
|
-
function
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
359
|
+
// src/downloadBlob.ts
|
|
360
|
+
function downloadBlob(blob, fileName) {
|
|
361
|
+
return new Promise(function(resolve, reject) {
|
|
362
|
+
try {
|
|
363
|
+
const url = URL.createObjectURL(blob);
|
|
364
|
+
const parent = document.body;
|
|
365
|
+
const anchor = document.createElement("a");
|
|
366
|
+
anchor.setAttribute("download", fileName);
|
|
367
|
+
anchor.href = url;
|
|
368
|
+
parent.append(anchor);
|
|
369
|
+
anchor.click();
|
|
370
|
+
parent.removeChild(anchor);
|
|
371
|
+
setTimeout(function() {
|
|
372
|
+
URL.revokeObjectURL(url);
|
|
373
|
+
resolve();
|
|
374
|
+
}, 250);
|
|
375
|
+
} catch (ex) {
|
|
376
|
+
reject(ex);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
617
379
|
}
|
|
618
|
-
|
|
380
|
+
|
|
381
|
+
// src/downloadRequest.ts
|
|
382
|
+
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
619
383
|
var _a;
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
384
|
+
function reportProgress(progress) {
|
|
385
|
+
if (typeof onProgress === "function") {
|
|
386
|
+
onProgress(__spreadValues({}, progress));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
let bytesReceived = 0;
|
|
390
|
+
reportProgress({ status: "requested" });
|
|
391
|
+
try {
|
|
392
|
+
let response = await fetch(request);
|
|
393
|
+
if (!response.ok || !response.body) {
|
|
394
|
+
if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
|
|
395
|
+
let data = await response.json();
|
|
396
|
+
if (data.error) {
|
|
397
|
+
throw new Error(data.error);
|
|
398
|
+
}
|
|
631
399
|
}
|
|
400
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const reader = response.body.getReader();
|
|
404
|
+
const stream = new ReadableStream({
|
|
405
|
+
start: function(controller) {
|
|
406
|
+
function pump() {
|
|
407
|
+
return reader.read().then(function(read) {
|
|
408
|
+
if (read.done) {
|
|
409
|
+
controller.close();
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
bytesReceived += read.value.length;
|
|
413
|
+
reportProgress({ bytesReceived, status: "downloading" });
|
|
414
|
+
controller.enqueue(read.value);
|
|
415
|
+
return pump();
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
return pump();
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
response = new Response(stream);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
console.warn("Failed to replace response stream to log download progress.");
|
|
424
|
+
}
|
|
425
|
+
const blob = await response.blob();
|
|
426
|
+
reportProgress({ bytesReceived, status: "downloaded" });
|
|
427
|
+
await downloadBlob(blob, fileName);
|
|
428
|
+
reportProgress({ bytesReceived, status: "completed" });
|
|
429
|
+
} catch (err) {
|
|
430
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
431
|
+
reportProgress({ status: "cancelled" });
|
|
632
432
|
} else {
|
|
633
|
-
|
|
433
|
+
reportProgress({ error: err.message, status: "error" });
|
|
634
434
|
}
|
|
635
435
|
}
|
|
636
|
-
return result;
|
|
637
436
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
return
|
|
437
|
+
|
|
438
|
+
// src/has.ts
|
|
439
|
+
function has(obj, key2) {
|
|
440
|
+
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/parseFunc.ts
|
|
444
|
+
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
445
|
+
function parseFunc(func) {
|
|
446
|
+
var match = func.toString().match(funcRegex);
|
|
447
|
+
if (match === null) {
|
|
448
|
+
throw new TypeError("Unable to parse function!");
|
|
449
|
+
}
|
|
450
|
+
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
642
451
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return formDataToObject(form, types);
|
|
452
|
+
|
|
453
|
+
// src/Namespace.ts
|
|
454
|
+
function Namespace() {
|
|
647
455
|
}
|
|
456
|
+
Namespace.prototype = /* @__PURE__ */ Object.create(null);
|
|
457
|
+
var Namespace_default = Namespace;
|
|
458
|
+
|
|
459
|
+
// src/requireNamespace.ts
|
|
460
|
+
function requireNamespace(root, namespace) {
|
|
461
|
+
if (typeof root === "object") {
|
|
462
|
+
if (typeof namespace === "string") {
|
|
463
|
+
let path = namespace.split(".");
|
|
464
|
+
return requireNamespace(root, path);
|
|
465
|
+
} else if (Array.isArray(namespace)) {
|
|
466
|
+
let current = root;
|
|
467
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
468
|
+
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
469
|
+
}
|
|
470
|
+
return current;
|
|
471
|
+
} else {
|
|
472
|
+
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
473
|
+
}
|
|
474
|
+
} else {
|
|
475
|
+
throw new TypeError("Invalid type of parameter 'root'");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/warn.ts
|
|
480
|
+
function warn(message, fallbackToAlert) {
|
|
481
|
+
console.warn(message);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/expose.ts
|
|
485
|
+
function expose(name, value) {
|
|
486
|
+
if (arguments.length !== 2) {
|
|
487
|
+
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
488
|
+
}
|
|
489
|
+
if (Array.isArray(value)) {
|
|
490
|
+
for (let func of value) {
|
|
491
|
+
const { name: funcName } = parseFunc(func);
|
|
492
|
+
if (funcName) {
|
|
493
|
+
expose(name, func);
|
|
494
|
+
} else {
|
|
495
|
+
throw new Error(
|
|
496
|
+
"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
let keyName;
|
|
502
|
+
let namespace;
|
|
503
|
+
if (typeof value === "function") {
|
|
504
|
+
keyName = parseFunc(value).name;
|
|
505
|
+
}
|
|
506
|
+
if (typeof name === "string") {
|
|
507
|
+
let pathParts = name.split(".");
|
|
508
|
+
if (!keyName) {
|
|
509
|
+
keyName = pathParts[pathParts.length - 1];
|
|
510
|
+
pathParts = pathParts.slice(0, pathParts.length - 1);
|
|
511
|
+
}
|
|
512
|
+
namespace = requireNamespace(window, pathParts);
|
|
513
|
+
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
514
|
+
namespace = name;
|
|
515
|
+
} else {
|
|
516
|
+
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
517
|
+
}
|
|
518
|
+
if (has(namespace, keyName)) {
|
|
519
|
+
warn([name, keyName].join(".") + " is already defined!");
|
|
520
|
+
} else {
|
|
521
|
+
namespace[keyName] = value;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// src/localStorage.ts
|
|
527
|
+
function getLocalKey(key2) {
|
|
528
|
+
var _a;
|
|
529
|
+
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key2].join(".");
|
|
530
|
+
}
|
|
531
|
+
var LocalStorage = class {
|
|
532
|
+
isPersisted() {
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
getLocalStorageKey(key2, global) {
|
|
536
|
+
return global ? ["common", key2].join(".") : getLocalKey(key2);
|
|
537
|
+
}
|
|
538
|
+
get(key2, defaultValue, global) {
|
|
539
|
+
const lsKey = this.getLocalStorageKey(key2, global);
|
|
540
|
+
const value = localStorage.getItem(lsKey);
|
|
541
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
542
|
+
}
|
|
543
|
+
set(key2, value, global) {
|
|
544
|
+
localStorage.setItem(
|
|
545
|
+
this.getLocalStorageKey(key2, global),
|
|
546
|
+
JSON.stringify(value)
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
remove(key2, global) {
|
|
550
|
+
const lsKey = this.getLocalStorageKey(key2, global);
|
|
551
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
552
|
+
localStorage.removeItem(lsKey);
|
|
553
|
+
return true;
|
|
554
|
+
} else {
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
clear() {
|
|
559
|
+
const baseKey = getLocalKey("");
|
|
560
|
+
for (let key2 in localStorage) {
|
|
561
|
+
if (key2.slice(0, baseKey.length) === baseKey) {
|
|
562
|
+
localStorage.removeItem(key2);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
var localStorage_default = new LocalStorage();
|
|
648
568
|
|
|
649
569
|
// src/settings.ts
|
|
650
570
|
function getKey(article) {
|
|
@@ -675,24 +595,18 @@ function saveSettings(setting, value, article) {
|
|
|
675
595
|
}
|
|
676
596
|
|
|
677
597
|
// src/index.ts
|
|
678
|
-
var version = "
|
|
598
|
+
var version = "2.0.1";
|
|
679
599
|
export {
|
|
680
600
|
SessionHandler,
|
|
681
601
|
UserSession,
|
|
682
602
|
downloadBlob,
|
|
683
603
|
downloadRequest,
|
|
684
|
-
exportOptionsFromDataObject,
|
|
685
604
|
expose,
|
|
686
|
-
formDataToDataObjectRecord,
|
|
687
|
-
formDataToObject,
|
|
688
|
-
formDataToProcedureParameters,
|
|
689
|
-
getDataObjectReportRequest,
|
|
690
605
|
getLocalizedString,
|
|
691
606
|
getSettings,
|
|
692
607
|
has,
|
|
693
608
|
localStorage_default as localStorage,
|
|
694
609
|
mitt_default as mitt,
|
|
695
|
-
openDataObjectReport,
|
|
696
610
|
saveSettings,
|
|
697
611
|
version
|
|
698
612
|
};
|