1 | import { __read, __values } from "tslib";
|
2 | import { mergeMaps, objectToMap } from "./collections.js";
|
3 | export function setup(config, runtime) {
|
4 | if (runtime === void 0) { runtime = DefaultRuntime; }
|
5 | runtime.assign(config);
|
6 | }
|
7 |
|
8 | var s = [
|
9 | "defaultCachingStore",
|
10 | "defaultCachingTimeoutSeconds",
|
11 | "globalCacheDisable",
|
12 | "enableCacheExpiration",
|
13 | "cacheExpirationIntervalMilliseconds",
|
14 | "spfxContext",
|
15 | "ie11",
|
16 | ];
|
17 | var runtimeCreateHooks = [];
|
18 | export function onRuntimeCreate(hook) {
|
19 | if (runtimeCreateHooks.indexOf(hook) < 0) {
|
20 |
|
21 | hook(DefaultRuntime);
|
22 | runtimeCreateHooks.push(hook);
|
23 | }
|
24 | }
|
25 | var Runtime = (function () {
|
26 | function Runtime(_v) {
|
27 | var _this = this;
|
28 | if (_v === void 0) { _v = new Map(); }
|
29 | this._v = _v;
|
30 | var defaulter = function (key, def) {
|
31 | if (!_this._v.has(key)) {
|
32 | _this._v.set(key, def);
|
33 | }
|
34 | };
|
35 |
|
36 | defaulter(s[0], "session");
|
37 | defaulter(s[1], 60);
|
38 | defaulter(s[2], false);
|
39 | defaulter(s[3], false);
|
40 | defaulter(s[4], 750);
|
41 | defaulter(s[5], null);
|
42 | defaulter(s[6], false);
|
43 | runtimeCreateHooks.forEach(function (hook) { return hook(_this); });
|
44 | }
|
45 | |
46 |
|
47 |
|
48 |
|
49 | Runtime.prototype.assign = function (config) {
|
50 | this._v = mergeMaps(this._v, objectToMap(config));
|
51 | };
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 | Runtime.prototype.get = function (key) {
|
58 | return this._v.get(key);
|
59 | };
|
60 | |
61 |
|
62 |
|
63 | Runtime.prototype.export = function () {
|
64 | var e_1, _a;
|
65 | var expt = new Map();
|
66 | try {
|
67 | for (var _b = __values(this._v), _c = _b.next(); !_c.done; _c = _b.next()) {
|
68 | var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
69 | if (key !== "__isDefault__") {
|
70 | expt.set(key, value);
|
71 | }
|
72 | }
|
73 | }
|
74 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
75 | finally {
|
76 | try {
|
77 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
78 | }
|
79 | finally { if (e_1) throw e_1.error; }
|
80 | }
|
81 | return expt;
|
82 | };
|
83 | return Runtime;
|
84 | }());
|
85 | export { Runtime };
|
86 |
|
87 | var _runtime = new Runtime(new Map([["__isDefault__", true]]));
|
88 | export var DefaultRuntime = _runtime;
|
89 |
|
\ | No newline at end of file |