@modelform/react-native 0.1.1 → 0.2.0
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/{chunk-L4SQVIJV.js → chunk-M5R44SAF.js} +132 -72
- package/dist/{chunk-PIHXMZ4G.mjs → chunk-MRHC6AEU.mjs} +87 -27
- package/dist/core/index.js +6 -2
- package/dist/core/index.mjs +5 -1
- package/dist/core/manifest.d.ts +40 -6
- package/dist/index.js +135 -131
- package/dist/index.mjs +5 -1
- package/package.json +1 -1
|
@@ -8068,11 +8068,28 @@ function resolveUrl(base, rel) {
|
|
|
8068
8068
|
}
|
|
8069
8069
|
return origin + out.join("/");
|
|
8070
8070
|
}
|
|
8071
|
-
|
|
8072
|
-
const
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8071
|
+
function httpFetchJson(options = {}) {
|
|
8072
|
+
const seen = /* @__PURE__ */ new Map();
|
|
8073
|
+
return async (url, { accept = "application/json", signal } = {}) => {
|
|
8074
|
+
const extra = await options.headers?.() ?? {};
|
|
8075
|
+
const key = JSON.stringify([url, accept, extra]);
|
|
8076
|
+
const last = seen.get(key);
|
|
8077
|
+
const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
|
|
8078
|
+
const res = await get(last?.etag).catch((e) => {
|
|
8079
|
+
if (!last || signal?.aborted) throw e;
|
|
8080
|
+
seen.delete(key);
|
|
8081
|
+
return get();
|
|
8082
|
+
});
|
|
8083
|
+
if (res.status === 304 && last) return last.json;
|
|
8084
|
+
if (!res.ok) throw new Error(options.httpError?.(res.status) ?? `HTTP ${res.status}`);
|
|
8085
|
+
const json = JSON.parse(await res.text());
|
|
8086
|
+
const etag = res.headers.get("ETag");
|
|
8087
|
+
if (etag) seen.set(key, { etag, json });
|
|
8088
|
+
else seen.delete(key);
|
|
8089
|
+
return json;
|
|
8090
|
+
};
|
|
8091
|
+
}
|
|
8092
|
+
var defaultFetchJson = httpFetchJson();
|
|
8076
8093
|
var fileName = (url) => url.replace(/[?#].*$/, "").split("/").pop() || url;
|
|
8077
8094
|
var BUNDLE_TYPE = "application/vnd.modelform.bundle+json";
|
|
8078
8095
|
var BUNDLE_ACCEPT = `${BUNDLE_TYPE}, application/json;q=0.9`;
|
|
@@ -8085,7 +8102,7 @@ function bundleRoot(manifestUrl, manifestPath) {
|
|
|
8085
8102
|
return bare.endsWith(manifestPath) ? bare.slice(0, bare.length - manifestPath.length) : bare.replace(/[^/]*$/, "");
|
|
8086
8103
|
}
|
|
8087
8104
|
var NOT_IN_BUNDLE = "not found in the config";
|
|
8088
|
-
async function assembleFromResponse(url, response, fetchJson = defaultFetchJson) {
|
|
8105
|
+
async function assembleFromResponse(url, response, fetchJson = defaultFetchJson, signal) {
|
|
8089
8106
|
const root = bundleRoot(url, response.manifest);
|
|
8090
8107
|
const file = fileName(url);
|
|
8091
8108
|
const parse3 = (path) => {
|
|
@@ -8103,7 +8120,7 @@ async function assembleFromResponse(url, response, fetchJson = defaultFetchJson)
|
|
|
8103
8120
|
manifest,
|
|
8104
8121
|
async (ref) => {
|
|
8105
8122
|
const abs = resolveUrl(url, ref).replace(/[?#].*$/, "");
|
|
8106
|
-
return abs.startsWith(root) ? parse3(abs.slice(root.length)) : fetchJson(resolveUrl(url, ref));
|
|
8123
|
+
return abs.startsWith(root) ? parse3(abs.slice(root.length)) : fetchJson(resolveUrl(url, ref), { signal });
|
|
8107
8124
|
},
|
|
8108
8125
|
file
|
|
8109
8126
|
);
|
|
@@ -8131,16 +8148,33 @@ async function assembleBundle(manifest, load, file = "manifest") {
|
|
|
8131
8148
|
issues.push(...validateBundle(bundle, file));
|
|
8132
8149
|
return issues.some((i) => i.severity === "error") ? { issues } : { bundle, issues };
|
|
8133
8150
|
}
|
|
8134
|
-
async function fetchBundle(url, fetchJson = defaultFetchJson) {
|
|
8151
|
+
async function fetchBundle(url, fetchJson = defaultFetchJson, signal) {
|
|
8135
8152
|
let manifest;
|
|
8136
8153
|
try {
|
|
8137
|
-
manifest = await fetchJson(url, { accept: BUNDLE_ACCEPT });
|
|
8154
|
+
manifest = await fetchJson(url, { accept: BUNDLE_ACCEPT, signal });
|
|
8138
8155
|
} catch (e) {
|
|
8139
|
-
return { issues: [{ severity: "error", path: fileName(url), message: e.message }] };
|
|
8156
|
+
return { issues: [{ severity: "error", path: fileName(url), message: e.message }], ...!(e instanceof SyntaxError) && { unreachable: true } };
|
|
8157
|
+
}
|
|
8158
|
+
if (isBundleResponse(manifest)) return assembleFromResponse(url, manifest, fetchJson, signal);
|
|
8159
|
+
return assembleBundle(manifest, (path) => fetchJson(resolveUrl(url, path), { signal }), fileName(url));
|
|
8160
|
+
}
|
|
8161
|
+
function revalidateBundle(bundle) {
|
|
8162
|
+
try {
|
|
8163
|
+
const { manifest } = bundle;
|
|
8164
|
+
if (validateManifest(manifest).length) return void 0;
|
|
8165
|
+
const documents = {};
|
|
8166
|
+
for (const id of Object.keys(manifest.documents)) {
|
|
8167
|
+
const { dashboard } = prepareDashboard(bundle.documents[id], id);
|
|
8168
|
+
if (!dashboard) return void 0;
|
|
8169
|
+
documents[id] = dashboard;
|
|
8170
|
+
}
|
|
8171
|
+
const checked = { manifest, documents };
|
|
8172
|
+
return validateBundle(checked).some((i) => i.severity === "error") ? void 0 : checked;
|
|
8173
|
+
} catch {
|
|
8174
|
+
return void 0;
|
|
8140
8175
|
}
|
|
8141
|
-
if (isBundleResponse(manifest)) return assembleFromResponse(url, manifest, fetchJson);
|
|
8142
|
-
return assembleBundle(manifest, (path) => fetchJson(resolveUrl(url, path)), fileName(url));
|
|
8143
8176
|
}
|
|
8177
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
8144
8178
|
var ConfigLoader = class {
|
|
8145
8179
|
constructor(options) {
|
|
8146
8180
|
this.options = options;
|
|
@@ -8153,6 +8187,8 @@ var ConfigLoader = class {
|
|
|
8153
8187
|
snapshot;
|
|
8154
8188
|
lastJson;
|
|
8155
8189
|
inflight;
|
|
8190
|
+
controller;
|
|
8191
|
+
disposed = false;
|
|
8156
8192
|
get state() {
|
|
8157
8193
|
return this.snapshot;
|
|
8158
8194
|
}
|
|
@@ -8163,27 +8199,45 @@ var ConfigLoader = class {
|
|
|
8163
8199
|
};
|
|
8164
8200
|
};
|
|
8165
8201
|
getSnapshot = () => this.snapshot;
|
|
8166
|
-
/** Loads the cached copy (if it was fetched from the same URL), then fetches. */
|
|
8202
|
+
/** Loads the cached copy (if it was fetched from the same URL and still checks out), then fetches. */
|
|
8167
8203
|
async start() {
|
|
8168
8204
|
const { url, cache: cache2 } = this.options;
|
|
8169
8205
|
if (!url) return;
|
|
8170
8206
|
const cached = await cache2?.read().catch(() => null);
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
this.
|
|
8207
|
+
const bundle = cached?.url === url ? revalidateBundle(cached.bundle) : void 0;
|
|
8208
|
+
if (cached && bundle && !this.snapshot.fetchedAt) {
|
|
8209
|
+
this.lastJson = JSON.stringify(bundle);
|
|
8210
|
+
this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
|
|
8174
8211
|
}
|
|
8175
8212
|
await this.refresh();
|
|
8176
8213
|
}
|
|
8177
8214
|
/** Fetches now. Concurrent calls share one fetch. Only notifies listeners when something changed. */
|
|
8178
8215
|
refresh() {
|
|
8179
|
-
const { url, cache: cache2, fetchJson } = this.options;
|
|
8180
|
-
if (!url) return Promise.resolve();
|
|
8216
|
+
const { url, cache: cache2, fetchJson, timeoutMs = DEFAULT_TIMEOUT_MS } = this.options;
|
|
8217
|
+
if (!url || this.disposed) return Promise.resolve();
|
|
8181
8218
|
this.inflight ??= (async () => {
|
|
8219
|
+
const controller = new AbortController();
|
|
8220
|
+
this.controller = controller;
|
|
8221
|
+
let timer;
|
|
8222
|
+
const abandoned = new Promise((resolve) => {
|
|
8223
|
+
const fail = (message) => resolve({ issues: [{ severity: "error", path: fileName(url), message }], unreachable: true });
|
|
8224
|
+
timer = setTimeout(() => {
|
|
8225
|
+
fail(`no answer in ${timeoutMs / 1e3}s`);
|
|
8226
|
+
controller.abort();
|
|
8227
|
+
}, timeoutMs);
|
|
8228
|
+
controller.signal.addEventListener("abort", () => fail("cancelled"));
|
|
8229
|
+
});
|
|
8182
8230
|
try {
|
|
8183
|
-
const
|
|
8231
|
+
const result = await Promise.race([fetchBundle(url, fetchJson, controller.signal), abandoned]);
|
|
8232
|
+
if (this.disposed) return;
|
|
8233
|
+
const { bundle, issues, revision, unreachable } = result;
|
|
8184
8234
|
if (!bundle) {
|
|
8185
8235
|
const errors = issues.filter((i) => i.severity === "error").length;
|
|
8186
|
-
|
|
8236
|
+
const error = unreachable ? issues[0]?.message : errors === 1 ? "1 error" : `${errors} errors`;
|
|
8237
|
+
return this.set(
|
|
8238
|
+
{ loading: false, error, unreachable: !!unreachable, issues },
|
|
8239
|
+
this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || !sameIssues(issues, this.snapshot.issues)
|
|
8240
|
+
);
|
|
8187
8241
|
}
|
|
8188
8242
|
const json = JSON.stringify(bundle);
|
|
8189
8243
|
const changed = json !== this.lastJson;
|
|
@@ -8192,18 +8246,26 @@ var ConfigLoader = class {
|
|
|
8192
8246
|
if (changed || revision !== this.snapshot.revision) cache2?.write({ url, fetchedAt, bundle, revision }).catch(() => {
|
|
8193
8247
|
});
|
|
8194
8248
|
this.set(
|
|
8195
|
-
{ ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, issues },
|
|
8249
|
+
{ ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, issues },
|
|
8196
8250
|
changed || revision !== this.snapshot.revision || this.snapshot.source !== "remote" || !!this.snapshot.error || this.snapshot.loading || !sameIssues(issues, this.snapshot.issues)
|
|
8197
8251
|
);
|
|
8198
8252
|
} finally {
|
|
8253
|
+
clearTimeout(timer);
|
|
8254
|
+
if (this.controller === controller) this.controller = void 0;
|
|
8199
8255
|
this.inflight = void 0;
|
|
8200
8256
|
}
|
|
8201
8257
|
})();
|
|
8202
8258
|
return this.inflight;
|
|
8203
8259
|
}
|
|
8260
|
+
/** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
|
|
8261
|
+
dispose() {
|
|
8262
|
+
this.disposed = true;
|
|
8263
|
+
this.controller?.abort();
|
|
8264
|
+
this.listeners.clear();
|
|
8265
|
+
}
|
|
8204
8266
|
/** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
|
|
8205
8267
|
set(patch, notify = true) {
|
|
8206
|
-
if (!notify) return;
|
|
8268
|
+
if (!notify || this.disposed) return;
|
|
8207
8269
|
this.snapshot = { ...this.snapshot, ...patch };
|
|
8208
8270
|
this.listeners.forEach((l) => l());
|
|
8209
8271
|
}
|
|
@@ -10177,11 +10239,7 @@ var HttpConfigFiles = class {
|
|
|
10177
10239
|
}
|
|
10178
10240
|
};
|
|
10179
10241
|
function fetchJsonWithToken(token) {
|
|
10180
|
-
return
|
|
10181
|
-
const res = await fetch(url, { headers: { Accept: options?.accept ?? "application/json", ...await authHeaders(token) }, cache: "no-store" });
|
|
10182
|
-
if (!res.ok) throw new Error(res.status === 401 ? "not signed in" : `HTTP ${res.status}`);
|
|
10183
|
-
return JSON.parse(await res.text());
|
|
10184
|
-
};
|
|
10242
|
+
return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
|
|
10185
10243
|
}
|
|
10186
10244
|
async function readConfigFiles(source) {
|
|
10187
10245
|
const all = await source.readAll?.();
|
|
@@ -10564,6 +10622,7 @@ export {
|
|
|
10564
10622
|
validateDashboard2 as validateDashboard,
|
|
10565
10623
|
validateBundle,
|
|
10566
10624
|
resolveUrl,
|
|
10625
|
+
httpFetchJson,
|
|
10567
10626
|
defaultFetchJson,
|
|
10568
10627
|
BUNDLE_TYPE,
|
|
10569
10628
|
BUNDLE_ACCEPT,
|
|
@@ -10572,6 +10631,7 @@ export {
|
|
|
10572
10631
|
assembleFromResponse,
|
|
10573
10632
|
assembleBundle,
|
|
10574
10633
|
fetchBundle,
|
|
10634
|
+
revalidateBundle,
|
|
10575
10635
|
ConfigLoader,
|
|
10576
10636
|
tabIdFor,
|
|
10577
10637
|
screenOfType,
|
package/dist/core/index.js
CHANGED
|
@@ -187,9 +187,9 @@
|
|
|
187
187
|
|
|
188
188
|
|
|
189
189
|
|
|
190
|
-
var _chunkL4SQVIJVjs = require('../chunk-L4SQVIJV.js');
|
|
191
190
|
|
|
192
191
|
|
|
192
|
+
var _chunkM5R44SAFjs = require('../chunk-M5R44SAF.js');
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
|
|
@@ -377,4 +377,8 @@ var _chunkL4SQVIJVjs = require('../chunk-L4SQVIJV.js');
|
|
|
377
377
|
|
|
378
378
|
|
|
379
379
|
|
|
380
|
-
exports.ALL = _chunkL4SQVIJVjs.ALL; exports.BUNDLE_ACCEPT = _chunkL4SQVIJVjs.BUNDLE_ACCEPT; exports.BUNDLE_TYPE = _chunkL4SQVIJVjs.BUNDLE_TYPE; exports.CANVAS_GAP = _chunkL4SQVIJVjs.CANVAS_GAP; exports.CANVAS_ROW_HEADER = _chunkL4SQVIJVjs.CANVAS_ROW_HEADER; exports.ConfigLoader = _chunkL4SQVIJVjs.ConfigLoader; exports.DASHBOARD_DS = _chunkL4SQVIJVjs.DASHBOARD_DS; exports.DEFAULT_GAZETTEER = _chunkL4SQVIJVjs.DEFAULT_GAZETTEER; exports.EDITABLE_VARIABLE_TYPES = _chunkL4SQVIJVjs.EDITABLE_VARIABLE_TYPES; exports.GRID_COLUMNS = _chunkL4SQVIJVjs.GRID_COLUMNS; exports.GrafanaClient = _chunkL4SQVIJVjs.GrafanaClient; exports.GrafanaDataSource = _chunkL4SQVIJVjs.GrafanaDataSource; exports.GrafanaError = _chunkL4SQVIJVjs.GrafanaError; exports.HttpConfigFiles = _chunkL4SQVIJVjs.HttpConfigFiles; exports.INPUT_OPTION_KEYS = _chunkL4SQVIJVjs.INPUT_OPTION_KEYS; exports.INPUT_TYPES = _chunkL4SQVIJVjs.INPUT_TYPES; exports.LOCAL_DATASOURCE_TYPE = _chunkL4SQVIJVjs.LOCAL_DATASOURCE_TYPE; exports.LocalDataSource = _chunkL4SQVIJVjs.LocalDataSource; exports.MANIFEST_VERSION = _chunkL4SQVIJVjs.MANIFEST_VERSION; exports.MAPPING_TYPES = _chunkL4SQVIJVjs.MAPPING_TYPES; exports.MemoryEntryStore = _chunkL4SQVIJVjs.MemoryEntryStore; exports.NAMED_COLORS = _chunkL4SQVIJVjs.NAMED_COLORS; exports.OPTION_CATEGORIES = _chunkL4SQVIJVjs.OPTION_CATEGORIES; exports.OVERRIDE_MATCHERS = _chunkL4SQVIJVjs.OVERRIDE_MATCHERS; exports.PANEL_TYPES = _chunkL4SQVIJVjs.PANEL_TYPES; exports.REDUCER_LABELS = _chunkL4SQVIJVjs.REDUCER_LABELS; exports.REFRESH_CHOICES = _chunkL4SQVIJVjs.REFRESH_CHOICES; exports.RELATIVE_RANGES = _chunkL4SQVIJVjs.RELATIVE_RANGES; exports.SERIES_PALETTE = _chunkL4SQVIJVjs.SERIES_PALETTE; exports.SPECIAL_MATCHES = _chunkL4SQVIJVjs.SPECIAL_MATCHES; exports.SaveConflictError = _chunkL4SQVIJVjs.SaveConflictError; exports.TIME_PRESETS = _chunkL4SQVIJVjs.TIME_PRESETS; exports.UNIT_CHOICES = _chunkL4SQVIJVjs.UNIT_CHOICES; exports.addTime = _chunkL4SQVIJVjs.addTime; exports.appSchema = _chunkL4SQVIJVjs.appSchema; exports.applyDashboardLink = _chunkL4SQVIJVjs.applyDashboardLink; exports.applyJsonEdits = _chunkL4SQVIJVjs.applyJsonEdits; exports.applyTransformations = _chunkL4SQVIJVjs.applyTransformations; exports.assembleBundle = _chunkL4SQVIJVjs.assembleBundle; exports.assembleFromResponse = _chunkL4SQVIJVjs.assembleFromResponse; exports.buildFrames = _chunkL4SQVIJVjs.buildFrames; exports.bundleFromFiles = _chunkL4SQVIJVjs.bundleFromFiles; exports.bundleRoot = _chunkL4SQVIJVjs.bundleRoot; exports.calculateInterval = _chunkL4SQVIJVjs.calculateInterval; exports.checkFiles = _chunkL4SQVIJVjs.checkFiles; exports.cleanDashboard = _chunkL4SQVIJVjs.cleanDashboard; exports.cleanPanelOptions = _chunkL4SQVIJVjs.cleanPanelOptions; exports.dashboardSchema = _chunkL4SQVIJVjs.dashboardSchema; exports.dashboardSchemaIssues = _chunkL4SQVIJVjs.dashboardSchemaIssues; exports.dashboardSourceIds = _chunkL4SQVIJVjs.dashboardSourceIds; exports.defaultFetchJson = _chunkL4SQVIJVjs.defaultFetchJson; exports.describeRange = _chunkL4SQVIJVjs.describeRange; exports.diffJson = _chunkL4SQVIJVjs.diffJson; exports.documentIdFor = _chunkL4SQVIJVjs.documentIdFor; exports.documentUses = _chunkL4SQVIJVjs.documentUses; exports.dropTarget = _chunkL4SQVIJVjs.dropTarget; exports.duplicatePanel = _chunkL4SQVIJVjs.duplicatePanel; exports.entriesSavedWith = _chunkL4SQVIJVjs.entriesSavedWith; exports.entryToInputValue = _chunkL4SQVIJVjs.entryToInputValue; exports.expandRow = _chunkL4SQVIJVjs.expandRow; exports.fetchBundle = _chunkL4SQVIJVjs.fetchBundle; exports.fetchJsonWithToken = _chunkL4SQVIJVjs.fetchJsonWithToken; exports.fieldDisplayName = _chunkL4SQVIJVjs.fieldDisplayName; exports.fieldMatches = _chunkL4SQVIJVjs.fieldMatches; exports.formatClock = _chunkL4SQVIJVjs.formatClock; exports.formatDisplay = _chunkL4SQVIJVjs.formatDisplay; exports.formatDuration = _chunkL4SQVIJVjs.formatDuration; exports.formatJsonText = _chunkL4SQVIJVjs.formatJsonText; exports.formatLocalDateTime = _chunkL4SQVIJVjs.formatLocalDateTime; exports.formatValue = _chunkL4SQVIJVjs.formatValue; exports.frameLength = _chunkL4SQVIJVjs.frameLength; exports.framesToOptions = _chunkL4SQVIJVjs.framesToOptions; exports.fromWire = _chunkL4SQVIJVjs.fromWire; exports.getPath = _chunkL4SQVIJVjs.getPath; exports.gridUnitsToPx = _chunkL4SQVIJVjs.gridUnitsToPx; exports.initialVariableValues = _chunkL4SQVIJVjs.initialVariableValues; exports.inputPanels = _chunkL4SQVIJVjs.inputPanels; exports.inputProblem = _chunkL4SQVIJVjs.inputProblem; exports.insertPanel = _chunkL4SQVIJVjs.insertPanel; exports.interpolate = _chunkL4SQVIJVjs.interpolate; exports.interpolateDeep = _chunkL4SQVIJVjs.interpolateDeep; exports.isBundleResponse = _chunkL4SQVIJVjs.isBundleResponse; exports.isEditableVariableType = _chunkL4SQVIJVjs.isEditableVariableType; exports.isInputPanel = _chunkL4SQVIJVjs.isInputPanel; exports.isInputType = _chunkL4SQVIJVjs.isInputType; exports.isLocalDatasource = _chunkL4SQVIJVjs.isLocalDatasource; exports.isReducer = _chunkL4SQVIJVjs.isReducer; exports.isRow = _chunkL4SQVIJVjs.isRow; exports.isSqlDatasource = _chunkL4SQVIJVjs.isSqlDatasource; exports.layoutCanvas = _chunkL4SQVIJVjs.layoutCanvas; exports.layoutDashboard = _chunkL4SQVIJVjs.layoutDashboard; exports.lineColumn = _chunkL4SQVIJVjs.lineColumn; exports.loadGazetteer = _chunkL4SQVIJVjs.loadGazetteer; exports.locate = _chunkL4SQVIJVjs.locate; exports.manifestSchemaIssues = _chunkL4SQVIJVjs.manifestSchemaIssues; exports.mappedResult = _chunkL4SQVIJVjs.mappedResult; exports.mappingProblem = _chunkL4SQVIJVjs.mappingProblem; exports.mappingRow = _chunkL4SQVIJVjs.mappingRow; exports.mappingRows = _chunkL4SQVIJVjs.mappingRows; exports.metricChanges = _chunkL4SQVIJVjs.metricChanges; exports.movePanel = _chunkL4SQVIJVjs.movePanel; exports.newDocument = _chunkL4SQVIJVjs.newDocument; exports.newPanel = _chunkL4SQVIJVjs.newPanel; exports.newVariable = _chunkL4SQVIJVjs.newVariable; exports.nextPanelId = _chunkL4SQVIJVjs.nextPanelId; exports.normalizeRef = _chunkL4SQVIJVjs.normalizeRef; exports.numberFields = _chunkL4SQVIJVjs.numberFields; exports.optionValue = _chunkL4SQVIJVjs.optionValue; exports.overrideProperties = _chunkL4SQVIJVjs.overrideProperties; exports.panelEdits = _chunkL4SQVIJVjs.panelEdits; exports.panelHasQueries = _chunkL4SQVIJVjs.panelHasQueries; exports.panelKey = _chunkL4SQVIJVjs.panelKey; exports.panelOptions = _chunkL4SQVIJVjs.panelOptions; exports.panelOverrides = _chunkL4SQVIJVjs.panelOverrides; exports.panelSize = _chunkL4SQVIJVjs.panelSize; exports.panelSpan = _chunkL4SQVIJVjs.panelSpan; exports.parseClockDigits = _chunkL4SQVIJVjs.parseClockDigits; exports.parseDashboardLink = _chunkL4SQVIJVjs.parseDashboardLink; exports.parseDuration = _chunkL4SQVIJVjs.parseDuration; exports.parseGazetteer = _chunkL4SQVIJVjs.parseGazetteer; exports.parseJsonText = _chunkL4SQVIJVjs.parseJsonText; exports.parseLocalDateTime = _chunkL4SQVIJVjs.parseLocalDateTime; exports.parseRange = _chunkL4SQVIJVjs.parseRange; exports.parseTime = _chunkL4SQVIJVjs.parseTime; exports.pointerToPath = _chunkL4SQVIJVjs.pointerToPath; exports.prepareDashboard = _chunkL4SQVIJVjs.prepareDashboard; exports.queryPanel = _chunkL4SQVIJVjs.queryPanel; exports.queryParam = _chunkL4SQVIJVjs.queryParam; exports.readConfigFiles = _chunkL4SQVIJVjs.readConfigFiles; exports.readingOrder = _chunkL4SQVIJVjs.readingOrder; exports.reduce = _chunkL4SQVIJVjs.reduce; exports.refineOptions = _chunkL4SQVIJVjs.refineOptions; exports.refreshedVariables = _chunkL4SQVIJVjs.refreshedVariables; exports.removeDocumentFromManifest = _chunkL4SQVIJVjs.removeDocumentFromManifest; exports.removePanel = _chunkL4SQVIJVjs.removePanel; exports.renameDocumentInManifest = _chunkL4SQVIJVjs.renameDocumentInManifest; exports.renameVariableInPanels = _chunkL4SQVIJVjs.renameVariableInPanels; exports.repack = _chunkL4SQVIJVjs.repack; exports.repeatOptions = _chunkL4SQVIJVjs.repeatOptions; exports.resizePanel = _chunkL4SQVIJVjs.resizePanel; exports.resolveColor = _chunkL4SQVIJVjs.resolveColor; exports.resolveFieldConfig = _chunkL4SQVIJVjs.resolveFieldConfig; exports.resolveLinks = _chunkL4SQVIJVjs.resolveLinks; exports.resolveTimezone = _chunkL4SQVIJVjs.resolveTimezone; exports.resolveUrl = _chunkL4SQVIJVjs.resolveUrl; exports.resolveVariables = _chunkL4SQVIJVjs.resolveVariables; exports.rowsToMappings = _chunkL4SQVIJVjs.rowsToMappings; exports.sampleEntries = _chunkL4SQVIJVjs.sampleEntries; exports.screenDocuments = _chunkL4SQVIJVjs.screenDocuments; exports.screenOfType = _chunkL4SQVIJVjs.screenOfType; exports.selectValue = _chunkL4SQVIJVjs.selectValue; exports.seriesColor = _chunkL4SQVIJVjs.seriesColor; exports.setHiddenOnPhones = _chunkL4SQVIJVjs.setHiddenOnPhones; exports.setJsonValue = _chunkL4SQVIJVjs.setJsonValue; exports.setOption = _chunkL4SQVIJVjs.setOption; exports.setOptionValue = _chunkL4SQVIJVjs.setOptionValue; exports.setOverrides = _chunkL4SQVIJVjs.setOverrides; exports.splitPath = _chunkL4SQVIJVjs.splitPath; exports.startOf = _chunkL4SQVIJVjs.startOf; exports.stringifyCompact = _chunkL4SQVIJVjs.stringifyCompact; exports.tabIdFor = _chunkL4SQVIJVjs.tabIdFor; exports.textSuggestions = _chunkL4SQVIJVjs.textSuggestions; exports.thresholdStep = _chunkL4SQVIJVjs.thresholdStep; exports.timeExprError = _chunkL4SQVIJVjs.timeExprError; exports.timeField = _chunkL4SQVIJVjs.timeField; exports.toEntries = _chunkL4SQVIJVjs.toEntries; exports.toMillis = _chunkL4SQVIJVjs.toMillis; exports.toSeries = _chunkL4SQVIJVjs.toSeries; exports.toXYSeries = _chunkL4SQVIJVjs.toXYSeries; exports.uniqueNames = _chunkL4SQVIJVjs.uniqueNames; exports.validateBundle = _chunkL4SQVIJVjs.validateBundle; exports.validateDashboard = _chunkL4SQVIJVjs.validateDashboard; exports.validateManifest = _chunkL4SQVIJVjs.validateManifest; exports.valueColor = _chunkL4SQVIJVjs.valueColor; exports.valueText = _chunkL4SQVIJVjs.valueText; exports.variableDependents = _chunkL4SQVIJVjs.variableDependents; exports.variableInfo = _chunkL4SQVIJVjs.variableInfo; exports.variableNameError = _chunkL4SQVIJVjs.variableNameError; exports.variableOptions = _chunkL4SQVIJVjs.variableOptions; exports.variableOrder = _chunkL4SQVIJVjs.variableOrder; exports.variableReferences = _chunkL4SQVIJVjs.variableReferences; exports.variableUses = _chunkL4SQVIJVjs.variableUses; exports.variableWithCurrent = _chunkL4SQVIJVjs.variableWithCurrent; exports.variableWithFlags = _chunkL4SQVIJVjs.variableWithFlags; exports.variableWithQuery = _chunkL4SQVIJVjs.variableWithQuery; exports.variableWithType = _chunkL4SQVIJVjs.variableWithType; exports.visibleVariables = _chunkL4SQVIJVjs.visibleVariables; exports.zoomRange = _chunkL4SQVIJVjs.zoomRange;
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
exports.ALL = _chunkM5R44SAFjs.ALL; exports.BUNDLE_ACCEPT = _chunkM5R44SAFjs.BUNDLE_ACCEPT; exports.BUNDLE_TYPE = _chunkM5R44SAFjs.BUNDLE_TYPE; exports.CANVAS_GAP = _chunkM5R44SAFjs.CANVAS_GAP; exports.CANVAS_ROW_HEADER = _chunkM5R44SAFjs.CANVAS_ROW_HEADER; exports.ConfigLoader = _chunkM5R44SAFjs.ConfigLoader; exports.DASHBOARD_DS = _chunkM5R44SAFjs.DASHBOARD_DS; exports.DEFAULT_GAZETTEER = _chunkM5R44SAFjs.DEFAULT_GAZETTEER; exports.EDITABLE_VARIABLE_TYPES = _chunkM5R44SAFjs.EDITABLE_VARIABLE_TYPES; exports.GRID_COLUMNS = _chunkM5R44SAFjs.GRID_COLUMNS; exports.GrafanaClient = _chunkM5R44SAFjs.GrafanaClient; exports.GrafanaDataSource = _chunkM5R44SAFjs.GrafanaDataSource; exports.GrafanaError = _chunkM5R44SAFjs.GrafanaError; exports.HttpConfigFiles = _chunkM5R44SAFjs.HttpConfigFiles; exports.INPUT_OPTION_KEYS = _chunkM5R44SAFjs.INPUT_OPTION_KEYS; exports.INPUT_TYPES = _chunkM5R44SAFjs.INPUT_TYPES; exports.LOCAL_DATASOURCE_TYPE = _chunkM5R44SAFjs.LOCAL_DATASOURCE_TYPE; exports.LocalDataSource = _chunkM5R44SAFjs.LocalDataSource; exports.MANIFEST_VERSION = _chunkM5R44SAFjs.MANIFEST_VERSION; exports.MAPPING_TYPES = _chunkM5R44SAFjs.MAPPING_TYPES; exports.MemoryEntryStore = _chunkM5R44SAFjs.MemoryEntryStore; exports.NAMED_COLORS = _chunkM5R44SAFjs.NAMED_COLORS; exports.OPTION_CATEGORIES = _chunkM5R44SAFjs.OPTION_CATEGORIES; exports.OVERRIDE_MATCHERS = _chunkM5R44SAFjs.OVERRIDE_MATCHERS; exports.PANEL_TYPES = _chunkM5R44SAFjs.PANEL_TYPES; exports.REDUCER_LABELS = _chunkM5R44SAFjs.REDUCER_LABELS; exports.REFRESH_CHOICES = _chunkM5R44SAFjs.REFRESH_CHOICES; exports.RELATIVE_RANGES = _chunkM5R44SAFjs.RELATIVE_RANGES; exports.SERIES_PALETTE = _chunkM5R44SAFjs.SERIES_PALETTE; exports.SPECIAL_MATCHES = _chunkM5R44SAFjs.SPECIAL_MATCHES; exports.SaveConflictError = _chunkM5R44SAFjs.SaveConflictError; exports.TIME_PRESETS = _chunkM5R44SAFjs.TIME_PRESETS; exports.UNIT_CHOICES = _chunkM5R44SAFjs.UNIT_CHOICES; exports.addTime = _chunkM5R44SAFjs.addTime; exports.appSchema = _chunkM5R44SAFjs.appSchema; exports.applyDashboardLink = _chunkM5R44SAFjs.applyDashboardLink; exports.applyJsonEdits = _chunkM5R44SAFjs.applyJsonEdits; exports.applyTransformations = _chunkM5R44SAFjs.applyTransformations; exports.assembleBundle = _chunkM5R44SAFjs.assembleBundle; exports.assembleFromResponse = _chunkM5R44SAFjs.assembleFromResponse; exports.buildFrames = _chunkM5R44SAFjs.buildFrames; exports.bundleFromFiles = _chunkM5R44SAFjs.bundleFromFiles; exports.bundleRoot = _chunkM5R44SAFjs.bundleRoot; exports.calculateInterval = _chunkM5R44SAFjs.calculateInterval; exports.checkFiles = _chunkM5R44SAFjs.checkFiles; exports.cleanDashboard = _chunkM5R44SAFjs.cleanDashboard; exports.cleanPanelOptions = _chunkM5R44SAFjs.cleanPanelOptions; exports.dashboardSchema = _chunkM5R44SAFjs.dashboardSchema; exports.dashboardSchemaIssues = _chunkM5R44SAFjs.dashboardSchemaIssues; exports.dashboardSourceIds = _chunkM5R44SAFjs.dashboardSourceIds; exports.defaultFetchJson = _chunkM5R44SAFjs.defaultFetchJson; exports.describeRange = _chunkM5R44SAFjs.describeRange; exports.diffJson = _chunkM5R44SAFjs.diffJson; exports.documentIdFor = _chunkM5R44SAFjs.documentIdFor; exports.documentUses = _chunkM5R44SAFjs.documentUses; exports.dropTarget = _chunkM5R44SAFjs.dropTarget; exports.duplicatePanel = _chunkM5R44SAFjs.duplicatePanel; exports.entriesSavedWith = _chunkM5R44SAFjs.entriesSavedWith; exports.entryToInputValue = _chunkM5R44SAFjs.entryToInputValue; exports.expandRow = _chunkM5R44SAFjs.expandRow; exports.fetchBundle = _chunkM5R44SAFjs.fetchBundle; exports.fetchJsonWithToken = _chunkM5R44SAFjs.fetchJsonWithToken; exports.fieldDisplayName = _chunkM5R44SAFjs.fieldDisplayName; exports.fieldMatches = _chunkM5R44SAFjs.fieldMatches; exports.formatClock = _chunkM5R44SAFjs.formatClock; exports.formatDisplay = _chunkM5R44SAFjs.formatDisplay; exports.formatDuration = _chunkM5R44SAFjs.formatDuration; exports.formatJsonText = _chunkM5R44SAFjs.formatJsonText; exports.formatLocalDateTime = _chunkM5R44SAFjs.formatLocalDateTime; exports.formatValue = _chunkM5R44SAFjs.formatValue; exports.frameLength = _chunkM5R44SAFjs.frameLength; exports.framesToOptions = _chunkM5R44SAFjs.framesToOptions; exports.fromWire = _chunkM5R44SAFjs.fromWire; exports.getPath = _chunkM5R44SAFjs.getPath; exports.gridUnitsToPx = _chunkM5R44SAFjs.gridUnitsToPx; exports.httpFetchJson = _chunkM5R44SAFjs.httpFetchJson; exports.initialVariableValues = _chunkM5R44SAFjs.initialVariableValues; exports.inputPanels = _chunkM5R44SAFjs.inputPanels; exports.inputProblem = _chunkM5R44SAFjs.inputProblem; exports.insertPanel = _chunkM5R44SAFjs.insertPanel; exports.interpolate = _chunkM5R44SAFjs.interpolate; exports.interpolateDeep = _chunkM5R44SAFjs.interpolateDeep; exports.isBundleResponse = _chunkM5R44SAFjs.isBundleResponse; exports.isEditableVariableType = _chunkM5R44SAFjs.isEditableVariableType; exports.isInputPanel = _chunkM5R44SAFjs.isInputPanel; exports.isInputType = _chunkM5R44SAFjs.isInputType; exports.isLocalDatasource = _chunkM5R44SAFjs.isLocalDatasource; exports.isReducer = _chunkM5R44SAFjs.isReducer; exports.isRow = _chunkM5R44SAFjs.isRow; exports.isSqlDatasource = _chunkM5R44SAFjs.isSqlDatasource; exports.layoutCanvas = _chunkM5R44SAFjs.layoutCanvas; exports.layoutDashboard = _chunkM5R44SAFjs.layoutDashboard; exports.lineColumn = _chunkM5R44SAFjs.lineColumn; exports.loadGazetteer = _chunkM5R44SAFjs.loadGazetteer; exports.locate = _chunkM5R44SAFjs.locate; exports.manifestSchemaIssues = _chunkM5R44SAFjs.manifestSchemaIssues; exports.mappedResult = _chunkM5R44SAFjs.mappedResult; exports.mappingProblem = _chunkM5R44SAFjs.mappingProblem; exports.mappingRow = _chunkM5R44SAFjs.mappingRow; exports.mappingRows = _chunkM5R44SAFjs.mappingRows; exports.metricChanges = _chunkM5R44SAFjs.metricChanges; exports.movePanel = _chunkM5R44SAFjs.movePanel; exports.newDocument = _chunkM5R44SAFjs.newDocument; exports.newPanel = _chunkM5R44SAFjs.newPanel; exports.newVariable = _chunkM5R44SAFjs.newVariable; exports.nextPanelId = _chunkM5R44SAFjs.nextPanelId; exports.normalizeRef = _chunkM5R44SAFjs.normalizeRef; exports.numberFields = _chunkM5R44SAFjs.numberFields; exports.optionValue = _chunkM5R44SAFjs.optionValue; exports.overrideProperties = _chunkM5R44SAFjs.overrideProperties; exports.panelEdits = _chunkM5R44SAFjs.panelEdits; exports.panelHasQueries = _chunkM5R44SAFjs.panelHasQueries; exports.panelKey = _chunkM5R44SAFjs.panelKey; exports.panelOptions = _chunkM5R44SAFjs.panelOptions; exports.panelOverrides = _chunkM5R44SAFjs.panelOverrides; exports.panelSize = _chunkM5R44SAFjs.panelSize; exports.panelSpan = _chunkM5R44SAFjs.panelSpan; exports.parseClockDigits = _chunkM5R44SAFjs.parseClockDigits; exports.parseDashboardLink = _chunkM5R44SAFjs.parseDashboardLink; exports.parseDuration = _chunkM5R44SAFjs.parseDuration; exports.parseGazetteer = _chunkM5R44SAFjs.parseGazetteer; exports.parseJsonText = _chunkM5R44SAFjs.parseJsonText; exports.parseLocalDateTime = _chunkM5R44SAFjs.parseLocalDateTime; exports.parseRange = _chunkM5R44SAFjs.parseRange; exports.parseTime = _chunkM5R44SAFjs.parseTime; exports.pointerToPath = _chunkM5R44SAFjs.pointerToPath; exports.prepareDashboard = _chunkM5R44SAFjs.prepareDashboard; exports.queryPanel = _chunkM5R44SAFjs.queryPanel; exports.queryParam = _chunkM5R44SAFjs.queryParam; exports.readConfigFiles = _chunkM5R44SAFjs.readConfigFiles; exports.readingOrder = _chunkM5R44SAFjs.readingOrder; exports.reduce = _chunkM5R44SAFjs.reduce; exports.refineOptions = _chunkM5R44SAFjs.refineOptions; exports.refreshedVariables = _chunkM5R44SAFjs.refreshedVariables; exports.removeDocumentFromManifest = _chunkM5R44SAFjs.removeDocumentFromManifest; exports.removePanel = _chunkM5R44SAFjs.removePanel; exports.renameDocumentInManifest = _chunkM5R44SAFjs.renameDocumentInManifest; exports.renameVariableInPanels = _chunkM5R44SAFjs.renameVariableInPanels; exports.repack = _chunkM5R44SAFjs.repack; exports.repeatOptions = _chunkM5R44SAFjs.repeatOptions; exports.resizePanel = _chunkM5R44SAFjs.resizePanel; exports.resolveColor = _chunkM5R44SAFjs.resolveColor; exports.resolveFieldConfig = _chunkM5R44SAFjs.resolveFieldConfig; exports.resolveLinks = _chunkM5R44SAFjs.resolveLinks; exports.resolveTimezone = _chunkM5R44SAFjs.resolveTimezone; exports.resolveUrl = _chunkM5R44SAFjs.resolveUrl; exports.resolveVariables = _chunkM5R44SAFjs.resolveVariables; exports.revalidateBundle = _chunkM5R44SAFjs.revalidateBundle; exports.rowsToMappings = _chunkM5R44SAFjs.rowsToMappings; exports.sampleEntries = _chunkM5R44SAFjs.sampleEntries; exports.screenDocuments = _chunkM5R44SAFjs.screenDocuments; exports.screenOfType = _chunkM5R44SAFjs.screenOfType; exports.selectValue = _chunkM5R44SAFjs.selectValue; exports.seriesColor = _chunkM5R44SAFjs.seriesColor; exports.setHiddenOnPhones = _chunkM5R44SAFjs.setHiddenOnPhones; exports.setJsonValue = _chunkM5R44SAFjs.setJsonValue; exports.setOption = _chunkM5R44SAFjs.setOption; exports.setOptionValue = _chunkM5R44SAFjs.setOptionValue; exports.setOverrides = _chunkM5R44SAFjs.setOverrides; exports.splitPath = _chunkM5R44SAFjs.splitPath; exports.startOf = _chunkM5R44SAFjs.startOf; exports.stringifyCompact = _chunkM5R44SAFjs.stringifyCompact; exports.tabIdFor = _chunkM5R44SAFjs.tabIdFor; exports.textSuggestions = _chunkM5R44SAFjs.textSuggestions; exports.thresholdStep = _chunkM5R44SAFjs.thresholdStep; exports.timeExprError = _chunkM5R44SAFjs.timeExprError; exports.timeField = _chunkM5R44SAFjs.timeField; exports.toEntries = _chunkM5R44SAFjs.toEntries; exports.toMillis = _chunkM5R44SAFjs.toMillis; exports.toSeries = _chunkM5R44SAFjs.toSeries; exports.toXYSeries = _chunkM5R44SAFjs.toXYSeries; exports.uniqueNames = _chunkM5R44SAFjs.uniqueNames; exports.validateBundle = _chunkM5R44SAFjs.validateBundle; exports.validateDashboard = _chunkM5R44SAFjs.validateDashboard; exports.validateManifest = _chunkM5R44SAFjs.validateManifest; exports.valueColor = _chunkM5R44SAFjs.valueColor; exports.valueText = _chunkM5R44SAFjs.valueText; exports.variableDependents = _chunkM5R44SAFjs.variableDependents; exports.variableInfo = _chunkM5R44SAFjs.variableInfo; exports.variableNameError = _chunkM5R44SAFjs.variableNameError; exports.variableOptions = _chunkM5R44SAFjs.variableOptions; exports.variableOrder = _chunkM5R44SAFjs.variableOrder; exports.variableReferences = _chunkM5R44SAFjs.variableReferences; exports.variableUses = _chunkM5R44SAFjs.variableUses; exports.variableWithCurrent = _chunkM5R44SAFjs.variableWithCurrent; exports.variableWithFlags = _chunkM5R44SAFjs.variableWithFlags; exports.variableWithQuery = _chunkM5R44SAFjs.variableWithQuery; exports.variableWithType = _chunkM5R44SAFjs.variableWithType; exports.visibleVariables = _chunkM5R44SAFjs.visibleVariables; exports.zoomRange = _chunkM5R44SAFjs.zoomRange;
|
package/dist/core/index.mjs
CHANGED
|
@@ -74,6 +74,7 @@ import {
|
|
|
74
74
|
fromWire,
|
|
75
75
|
getPath,
|
|
76
76
|
gridUnitsToPx,
|
|
77
|
+
httpFetchJson,
|
|
77
78
|
initialVariableValues,
|
|
78
79
|
inputPanels,
|
|
79
80
|
inputProblem,
|
|
@@ -145,6 +146,7 @@ import {
|
|
|
145
146
|
resolveTimezone,
|
|
146
147
|
resolveUrl,
|
|
147
148
|
resolveVariables,
|
|
149
|
+
revalidateBundle,
|
|
148
150
|
rowsToMappings,
|
|
149
151
|
sampleEntries,
|
|
150
152
|
screenDocuments,
|
|
@@ -187,7 +189,7 @@ import {
|
|
|
187
189
|
variableWithType,
|
|
188
190
|
visibleVariables,
|
|
189
191
|
zoomRange
|
|
190
|
-
} from "../chunk-
|
|
192
|
+
} from "../chunk-MRHC6AEU.mjs";
|
|
191
193
|
export {
|
|
192
194
|
ALL,
|
|
193
195
|
BUNDLE_ACCEPT,
|
|
@@ -264,6 +266,7 @@ export {
|
|
|
264
266
|
fromWire,
|
|
265
267
|
getPath,
|
|
266
268
|
gridUnitsToPx,
|
|
269
|
+
httpFetchJson,
|
|
267
270
|
initialVariableValues,
|
|
268
271
|
inputPanels,
|
|
269
272
|
inputProblem,
|
|
@@ -335,6 +338,7 @@ export {
|
|
|
335
338
|
resolveTimezone,
|
|
336
339
|
resolveUrl,
|
|
337
340
|
resolveVariables,
|
|
341
|
+
revalidateBundle,
|
|
338
342
|
rowsToMappings,
|
|
339
343
|
sampleEntries,
|
|
340
344
|
screenDocuments,
|
package/dist/core/manifest.d.ts
CHANGED
|
@@ -96,10 +96,23 @@ export declare function validateBundle(bundle: ConfigBundle, file?: string): Con
|
|
|
96
96
|
* React Native's URL polyfill doesn't support relative resolution.
|
|
97
97
|
*/
|
|
98
98
|
export declare function resolveUrl(base: string, rel: string): string;
|
|
99
|
-
/** `accept` replaces the default Accept header, e.g. to ask for a bundle. */
|
|
99
|
+
/** `accept` replaces the default Accept header, e.g. to ask for a bundle. `signal` cancels the request. */
|
|
100
100
|
export type FetchJson = (url: string, options?: {
|
|
101
101
|
accept?: string;
|
|
102
|
+
signal?: AbortSignal;
|
|
102
103
|
}) => Promise<unknown>;
|
|
104
|
+
export interface HttpFetchJsonOptions {
|
|
105
|
+
/** Extra request headers, e.g. Authorization. */
|
|
106
|
+
headers?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
107
|
+
/** The error message for a failed response. Defaults to `HTTP <status>`. */
|
|
108
|
+
httpError?: (status: number) => string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A FetchJson over fetch(). It remembers each response's ETag and sends it back as
|
|
112
|
+
* If-None-Match, so a file that hasn't changed comes back as a 304 and is answered from
|
|
113
|
+
* memory. On the web that only happens where the server exposes ETag to scripts.
|
|
114
|
+
*/
|
|
115
|
+
export declare function httpFetchJson(options?: HttpFetchJsonOptions): FetchJson;
|
|
103
116
|
export declare const defaultFetchJson: FetchJson;
|
|
104
117
|
export interface LoadResult {
|
|
105
118
|
/** Present when there are no errors. */
|
|
@@ -107,6 +120,8 @@ export interface LoadResult {
|
|
|
107
120
|
issues: ConfigIssue[];
|
|
108
121
|
/** The config's revision, when the server sent it as one bundle. */
|
|
109
122
|
revision?: string;
|
|
123
|
+
/** True when the manifest couldn't be fetched at all (no network, an HTTP error, a timeout), as opposed to a config with errors. */
|
|
124
|
+
unreachable?: boolean;
|
|
110
125
|
}
|
|
111
126
|
/** Asked for on the manifest's URL, a server that can returns the whole config in one response. */
|
|
112
127
|
export declare const BUNDLE_TYPE = "application/vnd.modelform.bundle+json";
|
|
@@ -133,7 +148,7 @@ export declare function bundleRoot(manifestUrl: string, manifestPath: string): s
|
|
|
133
148
|
* Builds a bundle from a server's bundle response. Documents inside the config come from the
|
|
134
149
|
* response; one elsewhere (an absolute URL) is still fetched.
|
|
135
150
|
*/
|
|
136
|
-
export declare function assembleFromResponse(url: string, response: BundleResponse, fetchJson?: FetchJson): Promise<LoadResult>;
|
|
151
|
+
export declare function assembleFromResponse(url: string, response: BundleResponse, fetchJson?: FetchJson, signal?: AbortSignal): Promise<LoadResult>;
|
|
137
152
|
/**
|
|
138
153
|
* Builds a bundle from a parsed manifest, getting each path document with `load`.
|
|
139
154
|
* Never throws: failures to fetch or parse come back as issues.
|
|
@@ -143,7 +158,13 @@ export declare function assembleBundle(manifest: unknown, load: (path: string) =
|
|
|
143
158
|
* Fetches a config: in one response from a server that bundles (all of it from the same
|
|
144
159
|
* moment), or else the manifest and then each document it points to, resolved against its URL.
|
|
145
160
|
*/
|
|
146
|
-
export declare function fetchBundle(url: string, fetchJson?: FetchJson): Promise<LoadResult>;
|
|
161
|
+
export declare function fetchBundle(url: string, fetchJson?: FetchJson, signal?: AbortSignal): Promise<LoadResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Checks a bundle that was assembled earlier (a cached copy, say) as if it had just been
|
|
164
|
+
* fetched, since the checks may have changed since. Returns it readied for rendering, or
|
|
165
|
+
* nothing if it no longer loads.
|
|
166
|
+
*/
|
|
167
|
+
export declare function revalidateBundle(bundle: ConfigBundle): ConfigBundle | undefined;
|
|
147
168
|
/** Where the last good config is kept between launches. */
|
|
148
169
|
export interface ConfigCache {
|
|
149
170
|
read(): Promise<CachedConfig | null>;
|
|
@@ -164,8 +185,14 @@ export interface ConfigState {
|
|
|
164
185
|
/** The shown config's revision, when the server gives one. */
|
|
165
186
|
revision?: string;
|
|
166
187
|
loading: boolean;
|
|
167
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* Set when the last fetch failed; the bundle shown is then the last good one. See `issues`.
|
|
190
|
+
* A summary ("2 errors") for a config with errors, or why the server couldn't be reached
|
|
191
|
+
* ("HTTP 503", "no answer in 15s") when `unreachable`.
|
|
192
|
+
*/
|
|
168
193
|
error?: string;
|
|
194
|
+
/** True when the last fetch failed because the config couldn't be fetched at all, not because it has errors. */
|
|
195
|
+
unreachable?: boolean;
|
|
169
196
|
/** From the last fetch, good or bad. */
|
|
170
197
|
issues: ConfigIssue[];
|
|
171
198
|
}
|
|
@@ -176,11 +203,14 @@ export interface ConfigLoaderOptions {
|
|
|
176
203
|
/** Shown until something better loads, e.g. a config bundled with the app. */
|
|
177
204
|
fallback?: ConfigBundle;
|
|
178
205
|
fetchJson?: FetchJson;
|
|
206
|
+
/** How long a fetch may take before it's abandoned. Defaults to 15 seconds. */
|
|
207
|
+
timeoutMs?: number;
|
|
179
208
|
}
|
|
180
209
|
/**
|
|
181
210
|
* Keeps the app's config current. Shows the bundled fallback, then the cached copy,
|
|
182
211
|
* then each newer fetch that validates. A bad fetch never replaces a good config: it's
|
|
183
|
-
* reported in `error`/`issues` and the last good bundle stays.
|
|
212
|
+
* reported in `error`/`issues` and the last good bundle stays. Call `dispose` when done
|
|
213
|
+
* with a loader, so a fetch still in flight can't write the cache afterwards.
|
|
184
214
|
*/
|
|
185
215
|
export declare class ConfigLoader {
|
|
186
216
|
private options;
|
|
@@ -188,14 +218,18 @@ export declare class ConfigLoader {
|
|
|
188
218
|
private snapshot;
|
|
189
219
|
private lastJson?;
|
|
190
220
|
private inflight?;
|
|
221
|
+
private controller?;
|
|
222
|
+
private disposed;
|
|
191
223
|
constructor(options: ConfigLoaderOptions);
|
|
192
224
|
get state(): ConfigState;
|
|
193
225
|
subscribe: (listener: () => void) => () => void;
|
|
194
226
|
getSnapshot: () => ConfigState;
|
|
195
|
-
/** Loads the cached copy (if it was fetched from the same URL), then fetches. */
|
|
227
|
+
/** Loads the cached copy (if it was fetched from the same URL and still checks out), then fetches. */
|
|
196
228
|
start(): Promise<void>;
|
|
197
229
|
/** Fetches now. Concurrent calls share one fetch. Only notifies listeners when something changed. */
|
|
198
230
|
refresh(): Promise<void>;
|
|
231
|
+
/** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
|
|
232
|
+
dispose(): void;
|
|
199
233
|
/** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
|
|
200
234
|
private set;
|
|
201
235
|
}
|