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