@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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var af = af || {};
|
|
3
2
|
af.common = (() => {
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
@@ -32,6 +31,10 @@ af.common = (() => {
|
|
|
32
31
|
return to;
|
|
33
32
|
};
|
|
34
33
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
+
var __publicField = (obj, key2, value) => {
|
|
35
|
+
__defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
35
38
|
|
|
36
39
|
// src/index.ts
|
|
37
40
|
var src_exports = {};
|
|
@@ -40,18 +43,12 @@ af.common = (() => {
|
|
|
40
43
|
UserSession: () => UserSession,
|
|
41
44
|
downloadBlob: () => downloadBlob,
|
|
42
45
|
downloadRequest: () => downloadRequest,
|
|
43
|
-
exportOptionsFromDataObject: () => exportOptionsFromDataObject,
|
|
44
46
|
expose: () => expose,
|
|
45
|
-
formDataToDataObjectRecord: () => formDataToDataObjectRecord,
|
|
46
|
-
formDataToObject: () => formDataToObject,
|
|
47
|
-
formDataToProcedureParameters: () => formDataToProcedureParameters,
|
|
48
|
-
getDataObjectReportRequest: () => getDataObjectReportRequest,
|
|
49
47
|
getLocalizedString: () => getLocalizedString,
|
|
50
48
|
getSettings: () => getSettings,
|
|
51
49
|
has: () => has,
|
|
52
50
|
localStorage: () => localStorage_default,
|
|
53
51
|
mitt: () => mitt_default,
|
|
54
|
-
openDataObjectReport: () => openDataObjectReport,
|
|
55
52
|
saveSettings: () => saveSettings,
|
|
56
53
|
version: () => version
|
|
57
54
|
});
|
|
@@ -98,224 +95,6 @@ af.common = (() => {
|
|
|
98
95
|
} };
|
|
99
96
|
}
|
|
100
97
|
|
|
101
|
-
// src/downloadBlob.ts
|
|
102
|
-
function downloadBlob(blob, fileName) {
|
|
103
|
-
return new Promise(function(resolve, reject) {
|
|
104
|
-
try {
|
|
105
|
-
const url = URL.createObjectURL(blob);
|
|
106
|
-
const parent = document.body;
|
|
107
|
-
const anchor = document.createElement("a");
|
|
108
|
-
anchor.setAttribute("download", fileName);
|
|
109
|
-
anchor.href = url;
|
|
110
|
-
parent.append(anchor);
|
|
111
|
-
anchor.click();
|
|
112
|
-
parent.removeChild(anchor);
|
|
113
|
-
setTimeout(function() {
|
|
114
|
-
URL.revokeObjectURL(url);
|
|
115
|
-
resolve();
|
|
116
|
-
}, 250);
|
|
117
|
-
} catch (ex) {
|
|
118
|
-
reject(ex);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/downloadRequest.ts
|
|
124
|
-
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
125
|
-
var _a;
|
|
126
|
-
function reportProgress(progress) {
|
|
127
|
-
if (typeof onProgress === "function") {
|
|
128
|
-
onProgress(__spreadValues({}, progress));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
let bytesReceived = 0;
|
|
132
|
-
reportProgress({ status: "requested" });
|
|
133
|
-
try {
|
|
134
|
-
let response = await fetch(request);
|
|
135
|
-
if (!response.ok || !response.body) {
|
|
136
|
-
if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
|
|
137
|
-
let data = await response.json();
|
|
138
|
-
if (data.error) {
|
|
139
|
-
throw new Error(data.error);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
throw new Error(`${response.status} ${response.statusText}`);
|
|
143
|
-
}
|
|
144
|
-
try {
|
|
145
|
-
const reader = response.body.getReader();
|
|
146
|
-
const stream = new ReadableStream({
|
|
147
|
-
start: function(controller) {
|
|
148
|
-
function pump() {
|
|
149
|
-
return reader.read().then(function(read) {
|
|
150
|
-
if (read.done) {
|
|
151
|
-
controller.close();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
bytesReceived += read.value.length;
|
|
155
|
-
reportProgress({ bytesReceived, status: "downloading" });
|
|
156
|
-
controller.enqueue(read.value);
|
|
157
|
-
return pump();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return pump();
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
response = new Response(stream);
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.warn("Failed to replace response stream to log download progress.");
|
|
166
|
-
}
|
|
167
|
-
const blob = await response.blob();
|
|
168
|
-
reportProgress({ bytesReceived, status: "downloaded" });
|
|
169
|
-
await downloadBlob(blob, fileName);
|
|
170
|
-
reportProgress({ bytesReceived, status: "completed" });
|
|
171
|
-
} catch (err) {
|
|
172
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
173
|
-
reportProgress({ status: "cancelled" });
|
|
174
|
-
} else {
|
|
175
|
-
reportProgress({ error: err.message, status: "error" });
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// src/exportDataObject.ts
|
|
181
|
-
function exportOptionsFromDataObject(dataObject, specifiedOptions) {
|
|
182
|
-
return __spreadValues({
|
|
183
|
-
columns: dataObject.getFields().map((field) => ({ name: field.name })),
|
|
184
|
-
distinctRows: dataObject.getParameter("distinctRows"),
|
|
185
|
-
filterObject: dataObject.getParameter("filterObject"),
|
|
186
|
-
filterString: dataObject.getParameter("filterString"),
|
|
187
|
-
maxRecords: dataObject.getParameter("maxRecords"),
|
|
188
|
-
sortOrder: dataObject.getParameter("sortOrder"),
|
|
189
|
-
whereClause: dataObject.getParameter("whereClause"),
|
|
190
|
-
whereObject: dataObject.getParameter("whereObject")
|
|
191
|
-
}, specifiedOptions);
|
|
192
|
-
}
|
|
193
|
-
var defaultOptions = {
|
|
194
|
-
columns: [],
|
|
195
|
-
distinctRows: false,
|
|
196
|
-
filterObject: null,
|
|
197
|
-
filterString: "",
|
|
198
|
-
maxRecords: -1,
|
|
199
|
-
sortOrder: [],
|
|
200
|
-
whereClause: "",
|
|
201
|
-
whereObject: null
|
|
202
|
-
};
|
|
203
|
-
function getDataObjectReportRequest(params) {
|
|
204
|
-
var _a;
|
|
205
|
-
const { articleId, dataObject, format, options } = params;
|
|
206
|
-
const reportOptions = options ? Object.assign({}, defaultOptions, options) : defaultOptions;
|
|
207
|
-
const body = "data=" + encodeURIComponent(JSON.stringify(reportOptions));
|
|
208
|
-
const requestUrl = `/api/data-object/export/${articleId}/${dataObject}/${format}`;
|
|
209
|
-
const controller = (_a = params.controller) != null ? _a : new AbortController();
|
|
210
|
-
return {
|
|
211
|
-
controller,
|
|
212
|
-
request: new Request(requestUrl, {
|
|
213
|
-
body,
|
|
214
|
-
credentials: "same-origin",
|
|
215
|
-
headers: {
|
|
216
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
217
|
-
},
|
|
218
|
-
method: "POST",
|
|
219
|
-
signal: controller.signal
|
|
220
|
-
})
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function openDataObjectReport(params) {
|
|
224
|
-
const { dataObject, fileName, format } = params;
|
|
225
|
-
const { request } = getDataObjectReportRequest(params);
|
|
226
|
-
return downloadRequest(request, {
|
|
227
|
-
fileName: `${fileName || dataObject}.${format}`
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// src/has.ts
|
|
232
|
-
function has(obj, key2) {
|
|
233
|
-
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// src/parseFunc.ts
|
|
237
|
-
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)*)\}$/;
|
|
238
|
-
function parseFunc(func) {
|
|
239
|
-
var match = func.toString().match(funcRegex);
|
|
240
|
-
if (match === null) {
|
|
241
|
-
throw new TypeError("Unable to parse function!");
|
|
242
|
-
}
|
|
243
|
-
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/Namespace.ts
|
|
247
|
-
function Namespace() {
|
|
248
|
-
}
|
|
249
|
-
Namespace.prototype = /* @__PURE__ */ Object.create(null);
|
|
250
|
-
var Namespace_default = Namespace;
|
|
251
|
-
|
|
252
|
-
// src/requireNamespace.ts
|
|
253
|
-
function requireNamespace(root, namespace) {
|
|
254
|
-
if (typeof root === "object") {
|
|
255
|
-
if (typeof namespace === "string") {
|
|
256
|
-
let path = namespace.split(".");
|
|
257
|
-
return requireNamespace(root, path);
|
|
258
|
-
} else if (Array.isArray(namespace)) {
|
|
259
|
-
let current = root;
|
|
260
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
261
|
-
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
262
|
-
}
|
|
263
|
-
return current;
|
|
264
|
-
} else {
|
|
265
|
-
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
throw new TypeError("Invalid type of parameter 'root'");
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// src/warn.ts
|
|
273
|
-
function warn(message, fallbackToAlert) {
|
|
274
|
-
console.warn(message);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// src/expose.ts
|
|
278
|
-
function expose(name, value) {
|
|
279
|
-
if (arguments.length !== 2) {
|
|
280
|
-
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
281
|
-
}
|
|
282
|
-
if (Array.isArray(value)) {
|
|
283
|
-
for (let func of value) {
|
|
284
|
-
const { name: funcName } = parseFunc(func);
|
|
285
|
-
if (funcName) {
|
|
286
|
-
expose(name, func);
|
|
287
|
-
} else {
|
|
288
|
-
throw new Error(
|
|
289
|
-
"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
let keyName;
|
|
295
|
-
let namespace;
|
|
296
|
-
if (typeof value === "function") {
|
|
297
|
-
keyName = parseFunc(value).name;
|
|
298
|
-
}
|
|
299
|
-
if (typeof name === "string") {
|
|
300
|
-
let pathParts = name.split(".");
|
|
301
|
-
if (!keyName) {
|
|
302
|
-
keyName = pathParts[pathParts.length - 1];
|
|
303
|
-
pathParts = pathParts.slice(0, pathParts.length - 1);
|
|
304
|
-
}
|
|
305
|
-
namespace = requireNamespace(window, pathParts);
|
|
306
|
-
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
307
|
-
namespace = name;
|
|
308
|
-
} else {
|
|
309
|
-
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
310
|
-
}
|
|
311
|
-
if (has(namespace, keyName)) {
|
|
312
|
-
warn([name, keyName].join(".") + " is already defined!");
|
|
313
|
-
} else {
|
|
314
|
-
namespace[keyName] = value;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
98
|
// src/getLocalizedString.ts
|
|
320
99
|
async function getLocalizedStringAsync(string) {
|
|
321
100
|
try {
|
|
@@ -438,55 +217,12 @@ return s;
|
|
|
438
217
|
return localized;
|
|
439
218
|
}
|
|
440
219
|
|
|
441
|
-
// src/localStorage.ts
|
|
442
|
-
function getLocalKey(key2) {
|
|
443
|
-
var _a;
|
|
444
|
-
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key2].join(".");
|
|
445
|
-
}
|
|
446
|
-
var LocalStorage = class {
|
|
447
|
-
isPersisted() {
|
|
448
|
-
return true;
|
|
449
|
-
}
|
|
450
|
-
getLocalStorageKey(key2, global) {
|
|
451
|
-
return global ? ["common", key2].join(".") : getLocalKey(key2);
|
|
452
|
-
}
|
|
453
|
-
get(key2, defaultValue, global) {
|
|
454
|
-
const lsKey = this.getLocalStorageKey(key2, global);
|
|
455
|
-
const value = localStorage.getItem(lsKey);
|
|
456
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
457
|
-
}
|
|
458
|
-
set(key2, value, global) {
|
|
459
|
-
localStorage.setItem(
|
|
460
|
-
this.getLocalStorageKey(key2, global),
|
|
461
|
-
JSON.stringify(value)
|
|
462
|
-
);
|
|
463
|
-
}
|
|
464
|
-
remove(key2, global) {
|
|
465
|
-
const lsKey = this.getLocalStorageKey(key2, global);
|
|
466
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
467
|
-
localStorage.removeItem(lsKey);
|
|
468
|
-
return true;
|
|
469
|
-
} else {
|
|
470
|
-
return false;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
clear() {
|
|
474
|
-
const baseKey = getLocalKey("");
|
|
475
|
-
for (let key2 in localStorage) {
|
|
476
|
-
if (key2.slice(0, baseKey.length) === baseKey) {
|
|
477
|
-
localStorage.removeItem(key2);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
var localStorage_default = new LocalStorage();
|
|
483
|
-
|
|
484
220
|
// src/SessionHandler.ts
|
|
485
221
|
var _SessionHandler = class {
|
|
486
222
|
constructor() {
|
|
487
|
-
this
|
|
488
|
-
this
|
|
489
|
-
this
|
|
223
|
+
__publicField(this, "eventHandler", mitt_default());
|
|
224
|
+
__publicField(this, "showingDialog", false);
|
|
225
|
+
__publicField(this, "dialog", null);
|
|
490
226
|
}
|
|
491
227
|
expired(callback) {
|
|
492
228
|
af.userSession = af.userSession || {
|
|
@@ -620,72 +356,249 @@ return s;
|
|
|
620
356
|
}
|
|
621
357
|
};
|
|
622
358
|
var SessionHandler = _SessionHandler;
|
|
623
|
-
SessionHandler
|
|
359
|
+
__publicField(SessionHandler, "messages", {
|
|
624
360
|
login: "Log in",
|
|
625
361
|
relog: "Session expired - log in"
|
|
626
|
-
};
|
|
362
|
+
});
|
|
627
363
|
|
|
628
364
|
// src/UserSession.ts
|
|
629
365
|
var UserSession = class extends SessionHandler {
|
|
630
366
|
constructor(userData) {
|
|
631
367
|
super();
|
|
632
|
-
this
|
|
633
|
-
this
|
|
634
|
-
this
|
|
635
|
-
this
|
|
636
|
-
this
|
|
368
|
+
__publicField(this, "amDesignator", "a.m.");
|
|
369
|
+
__publicField(this, "dayNames", ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]);
|
|
370
|
+
__publicField(this, "dayNamesShort", ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]);
|
|
371
|
+
__publicField(this, "decimalSeparator", ".");
|
|
372
|
+
__publicField(this, "domain", "OB");
|
|
373
|
+
__publicField(this, "email");
|
|
374
|
+
__publicField(this, "formats");
|
|
375
|
+
__publicField(this, "groupSeparator", null);
|
|
376
|
+
__publicField(this, "integratedSecurity", false);
|
|
377
|
+
__publicField(this, "isDeveloper", false);
|
|
378
|
+
__publicField(this, "login", "");
|
|
379
|
+
__publicField(this, "loginType");
|
|
380
|
+
__publicField(this, "monthNames", ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december", ""]);
|
|
381
|
+
__publicField(this, "monthNamesShort", ["jan", "feb", "mar", "apr", "may", "jun", "jul", "augt", "sep", "oct", "nov", "dec", ""]);
|
|
382
|
+
__publicField(this, "name");
|
|
383
|
+
__publicField(this, "pmDesignator", "p.m.");
|
|
384
|
+
__publicField(this, "shortDateFormat", "dd.MM.yyyy");
|
|
385
|
+
__publicField(this, "culture", "en-GB");
|
|
386
|
+
__publicField(this, "uiculture", "en-GB");
|
|
387
|
+
__publicField(this, "expired", () => null);
|
|
637
388
|
this.formats = {};
|
|
638
389
|
Object.assign(this, userData);
|
|
639
390
|
}
|
|
640
391
|
};
|
|
641
392
|
|
|
642
|
-
// src/
|
|
643
|
-
function
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
393
|
+
// src/downloadBlob.ts
|
|
394
|
+
function downloadBlob(blob, fileName) {
|
|
395
|
+
return new Promise(function(resolve, reject) {
|
|
396
|
+
try {
|
|
397
|
+
const url = URL.createObjectURL(blob);
|
|
398
|
+
const parent = document.body;
|
|
399
|
+
const anchor = document.createElement("a");
|
|
400
|
+
anchor.setAttribute("download", fileName);
|
|
401
|
+
anchor.href = url;
|
|
402
|
+
parent.append(anchor);
|
|
403
|
+
anchor.click();
|
|
404
|
+
parent.removeChild(anchor);
|
|
405
|
+
setTimeout(function() {
|
|
406
|
+
URL.revokeObjectURL(url);
|
|
407
|
+
resolve();
|
|
408
|
+
}, 250);
|
|
409
|
+
} catch (ex) {
|
|
410
|
+
reject(ex);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
658
413
|
}
|
|
659
|
-
|
|
414
|
+
|
|
415
|
+
// src/downloadRequest.ts
|
|
416
|
+
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
660
417
|
var _a;
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
418
|
+
function reportProgress(progress) {
|
|
419
|
+
if (typeof onProgress === "function") {
|
|
420
|
+
onProgress(__spreadValues({}, progress));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
let bytesReceived = 0;
|
|
424
|
+
reportProgress({ status: "requested" });
|
|
425
|
+
try {
|
|
426
|
+
let response = await fetch(request);
|
|
427
|
+
if (!response.ok || !response.body) {
|
|
428
|
+
if ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
|
|
429
|
+
let data = await response.json();
|
|
430
|
+
if (data.error) {
|
|
431
|
+
throw new Error(data.error);
|
|
432
|
+
}
|
|
672
433
|
}
|
|
434
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
435
|
+
}
|
|
436
|
+
try {
|
|
437
|
+
const reader = response.body.getReader();
|
|
438
|
+
const stream = new ReadableStream({
|
|
439
|
+
start: function(controller) {
|
|
440
|
+
function pump() {
|
|
441
|
+
return reader.read().then(function(read) {
|
|
442
|
+
if (read.done) {
|
|
443
|
+
controller.close();
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
bytesReceived += read.value.length;
|
|
447
|
+
reportProgress({ bytesReceived, status: "downloading" });
|
|
448
|
+
controller.enqueue(read.value);
|
|
449
|
+
return pump();
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return pump();
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
response = new Response(stream);
|
|
456
|
+
} catch (error) {
|
|
457
|
+
console.warn("Failed to replace response stream to log download progress.");
|
|
458
|
+
}
|
|
459
|
+
const blob = await response.blob();
|
|
460
|
+
reportProgress({ bytesReceived, status: "downloaded" });
|
|
461
|
+
await downloadBlob(blob, fileName);
|
|
462
|
+
reportProgress({ bytesReceived, status: "completed" });
|
|
463
|
+
} catch (err) {
|
|
464
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
465
|
+
reportProgress({ status: "cancelled" });
|
|
673
466
|
} else {
|
|
674
|
-
|
|
467
|
+
reportProgress({ error: err.message, status: "error" });
|
|
675
468
|
}
|
|
676
469
|
}
|
|
677
|
-
return result;
|
|
678
470
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
return
|
|
471
|
+
|
|
472
|
+
// src/has.ts
|
|
473
|
+
function has(obj, key2) {
|
|
474
|
+
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// src/parseFunc.ts
|
|
478
|
+
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)*)\}$/;
|
|
479
|
+
function parseFunc(func) {
|
|
480
|
+
var match = func.toString().match(funcRegex);
|
|
481
|
+
if (match === null) {
|
|
482
|
+
throw new TypeError("Unable to parse function!");
|
|
483
|
+
}
|
|
484
|
+
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
683
485
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
return formDataToObject(form, types);
|
|
486
|
+
|
|
487
|
+
// src/Namespace.ts
|
|
488
|
+
function Namespace() {
|
|
688
489
|
}
|
|
490
|
+
Namespace.prototype = /* @__PURE__ */ Object.create(null);
|
|
491
|
+
var Namespace_default = Namespace;
|
|
492
|
+
|
|
493
|
+
// src/requireNamespace.ts
|
|
494
|
+
function requireNamespace(root, namespace) {
|
|
495
|
+
if (typeof root === "object") {
|
|
496
|
+
if (typeof namespace === "string") {
|
|
497
|
+
let path = namespace.split(".");
|
|
498
|
+
return requireNamespace(root, path);
|
|
499
|
+
} else if (Array.isArray(namespace)) {
|
|
500
|
+
let current = root;
|
|
501
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
502
|
+
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
503
|
+
}
|
|
504
|
+
return current;
|
|
505
|
+
} else {
|
|
506
|
+
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
507
|
+
}
|
|
508
|
+
} else {
|
|
509
|
+
throw new TypeError("Invalid type of parameter 'root'");
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/warn.ts
|
|
514
|
+
function warn(message, fallbackToAlert) {
|
|
515
|
+
console.warn(message);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/expose.ts
|
|
519
|
+
function expose(name, value) {
|
|
520
|
+
if (arguments.length !== 2) {
|
|
521
|
+
throw new Error("Incorrect number of arguments passed to the expose function!");
|
|
522
|
+
}
|
|
523
|
+
if (Array.isArray(value)) {
|
|
524
|
+
for (let func of value) {
|
|
525
|
+
const { name: funcName } = parseFunc(func);
|
|
526
|
+
if (funcName) {
|
|
527
|
+
expose(name, func);
|
|
528
|
+
} else {
|
|
529
|
+
throw new Error(
|
|
530
|
+
"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
} else {
|
|
535
|
+
let keyName;
|
|
536
|
+
let namespace;
|
|
537
|
+
if (typeof value === "function") {
|
|
538
|
+
keyName = parseFunc(value).name;
|
|
539
|
+
}
|
|
540
|
+
if (typeof name === "string") {
|
|
541
|
+
let pathParts = name.split(".");
|
|
542
|
+
if (!keyName) {
|
|
543
|
+
keyName = pathParts[pathParts.length - 1];
|
|
544
|
+
pathParts = pathParts.slice(0, pathParts.length - 1);
|
|
545
|
+
}
|
|
546
|
+
namespace = requireNamespace(window, pathParts);
|
|
547
|
+
} else if (keyName && (typeof name === "object" || typeof name === "function")) {
|
|
548
|
+
namespace = name;
|
|
549
|
+
} else {
|
|
550
|
+
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
551
|
+
}
|
|
552
|
+
if (has(namespace, keyName)) {
|
|
553
|
+
warn([name, keyName].join(".") + " is already defined!");
|
|
554
|
+
} else {
|
|
555
|
+
namespace[keyName] = value;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// src/localStorage.ts
|
|
561
|
+
function getLocalKey(key2) {
|
|
562
|
+
var _a;
|
|
563
|
+
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key2].join(".");
|
|
564
|
+
}
|
|
565
|
+
var LocalStorage = class {
|
|
566
|
+
isPersisted() {
|
|
567
|
+
return true;
|
|
568
|
+
}
|
|
569
|
+
getLocalStorageKey(key2, global) {
|
|
570
|
+
return global ? ["common", key2].join(".") : getLocalKey(key2);
|
|
571
|
+
}
|
|
572
|
+
get(key2, defaultValue, global) {
|
|
573
|
+
const lsKey = this.getLocalStorageKey(key2, global);
|
|
574
|
+
const value = localStorage.getItem(lsKey);
|
|
575
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
576
|
+
}
|
|
577
|
+
set(key2, value, global) {
|
|
578
|
+
localStorage.setItem(
|
|
579
|
+
this.getLocalStorageKey(key2, global),
|
|
580
|
+
JSON.stringify(value)
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
remove(key2, global) {
|
|
584
|
+
const lsKey = this.getLocalStorageKey(key2, global);
|
|
585
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
586
|
+
localStorage.removeItem(lsKey);
|
|
587
|
+
return true;
|
|
588
|
+
} else {
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
clear() {
|
|
593
|
+
const baseKey = getLocalKey("");
|
|
594
|
+
for (let key2 in localStorage) {
|
|
595
|
+
if (key2.slice(0, baseKey.length) === baseKey) {
|
|
596
|
+
localStorage.removeItem(key2);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
var localStorage_default = new LocalStorage();
|
|
689
602
|
|
|
690
603
|
// src/settings.ts
|
|
691
604
|
function getKey(article) {
|
|
@@ -716,6 +629,6 @@ return s;
|
|
|
716
629
|
}
|
|
717
630
|
|
|
718
631
|
// src/index.ts
|
|
719
|
-
var version = "
|
|
632
|
+
var version = "2.0.1";
|
|
720
633
|
return __toCommonJS(src_exports);
|
|
721
634
|
})();
|