@fireproof/core 0.19.111 → 0.19.112-dev-iife
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/{chunk-OFGPKRCM.js → chunk-D4E6UX6S.js} +3 -8
- package/chunk-D4E6UX6S.js.map +1 -0
- package/{chunk-WS3YRPIA.js → chunk-OKACCIGZ.js} +15 -29
- package/chunk-OKACCIGZ.js.map +1 -0
- package/chunk-PZ5AY32C.js +10 -0
- package/deno.json +1 -2
- package/gateway-3YJXDXD3.js +59 -0
- package/gateway-3YJXDXD3.js.map +1 -0
- package/{gateway-5FCWPX5W.js → gateway-HUSQCAA7.js} +5 -4
- package/gateway-HUSQCAA7.js.map +1 -0
- package/index.cjs +64 -274
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -3
- package/index.d.ts +1 -3
- package/index.global.js +575 -312
- package/index.global.js.map +1 -1
- package/index.js +19 -19
- package/index.js.map +1 -1
- package/{key-bag-file-WADZBHYG.js → key-bag-file-QCOF7UFH.js} +4 -3
- package/{key-bag-file-WADZBHYG.js.map → key-bag-file-QCOF7UFH.js.map} +1 -1
- package/{key-bag-indexdb-PGVAI3FJ.js → key-bag-indexdb-VHX3MZ66.js} +4 -3
- package/{key-bag-indexdb-PGVAI3FJ.js.map → key-bag-indexdb-VHX3MZ66.js.map} +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/metafile-iife.json +1 -1
- package/node/chunk-4A4RAVNS.js +17 -0
- package/node/chunk-4A4RAVNS.js.map +1 -0
- package/node/mem-filesystem.cjs +72 -0
- package/node/mem-filesystem.cjs.map +1 -0
- package/node/mem-filesystem.d.cts +25 -0
- package/node/mem-filesystem.d.ts +25 -0
- package/{mem-filesystem-YPPJV7Q2.js → node/mem-filesystem.js} +3 -4
- package/node/mem-filesystem.js.map +1 -0
- package/node/metafile-cjs.json +1 -0
- package/node/metafile-esm.json +1 -0
- package/node/node-filesystem.cjs +86 -0
- package/node/node-filesystem.cjs.map +1 -0
- package/node/node-filesystem.d.cts +36 -0
- package/node/node-filesystem.d.ts +36 -0
- package/{node-filesystem-INX4ZTHE.js → node/node-filesystem.js} +3 -4
- package/node/node-filesystem.js.map +1 -0
- package/node/types-DARSfXlb.d.cts +23 -0
- package/node/types-DARSfXlb.d.ts +23 -0
- package/package.json +15 -6
- package/tests/blockstore/keyed-crypto.test.ts +2 -2
- package/tests/blockstore/store.test.ts +3 -5
- package/tests/fireproof/all-gateway.test.ts +11 -9
- package/utils-GYG2FMCZ.js +13 -0
- package/utils-GYG2FMCZ.js.map +1 -0
- package/web/gateway-impl.cjs +319 -0
- package/web/gateway-impl.cjs.map +1 -0
- package/web/gateway-impl.d.cts +86 -0
- package/web/gateway-impl.d.ts +86 -0
- package/{gateway-H7UD6TNB.js → web/gateway-impl.js} +165 -20
- package/web/gateway-impl.js.map +1 -0
- package/web/metafile-cjs.json +1 -0
- package/web/metafile-esm.json +1 -0
- package/chunk-OFGPKRCM.js.map +0 -1
- package/chunk-PB4BKL4O.js +0 -7
- package/chunk-PB4BKL4O.js.map +0 -1
- package/chunk-WS3YRPIA.js.map +0 -1
- package/gateway-5FCWPX5W.js.map +0 -1
- package/gateway-H7UD6TNB.js.map +0 -1
- package/mem-filesystem-YPPJV7Q2.js.map +0 -1
- package/node-filesystem-INX4ZTHE.js.map +0 -1
- package/utils-QO2HIWGI.js +0 -14
- /package/{utils-QO2HIWGI.js.map → chunk-PZ5AY32C.js.map} +0 -0
package/index.global.js
CHANGED
@@ -34,13 +34,13 @@ var Fireproof = (() => {
|
|
34
34
|
));
|
35
35
|
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
36
36
|
|
37
|
-
// node_modules/.pnpm/@adviser+cement@0.2.
|
37
|
+
// node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-GES3MUGV.js
|
38
38
|
function Utf8EnDecoderSingleton() {
|
39
39
|
return utf8EnDecoder;
|
40
40
|
}
|
41
41
|
var __defProp2, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp2, __propIsEnum, __typeError, __defNormalProp, __spreadValues, __spreadProps, __export2, __accessCheck, __privateGet, __privateAdd, __privateSet, encoder, decoder, Utf8EnDecoder, utf8EnDecoder;
|
42
42
|
var init_chunk_GES3MUGV = __esm({
|
43
|
-
"node_modules/.pnpm/@adviser+cement@0.2.
|
43
|
+
"node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-GES3MUGV.js"() {
|
44
44
|
"use strict";
|
45
45
|
__defProp2 = Object.defineProperty;
|
46
46
|
__defProps = Object.defineProperties;
|
@@ -86,7 +86,7 @@ var Fireproof = (() => {
|
|
86
86
|
}
|
87
87
|
});
|
88
88
|
|
89
|
-
// node_modules/.pnpm/@adviser+cement@0.2.
|
89
|
+
// node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-USQXEZHL.js
|
90
90
|
function streamMap(s, sm) {
|
91
91
|
const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
|
92
92
|
return new ReadableStream({
|
@@ -261,8 +261,8 @@ var Fireproof = (() => {
|
|
261
261
|
});
|
262
262
|
}
|
263
263
|
var utils_exports, ConsoleWriterStreamDefaultWriter, ConsoleWriterStream, FanoutWriteStream;
|
264
|
-
var
|
265
|
-
"node_modules/.pnpm/@adviser+cement@0.2.
|
264
|
+
var init_chunk_USQXEZHL = __esm({
|
265
|
+
"node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-USQXEZHL.js"() {
|
266
266
|
"use strict";
|
267
267
|
init_chunk_GES3MUGV();
|
268
268
|
utils_exports = {};
|
@@ -302,22 +302,22 @@ var Fireproof = (() => {
|
|
302
302
|
this.closed = Promise.resolve(void 0);
|
303
303
|
}
|
304
304
|
async write(chunk) {
|
305
|
-
|
305
|
+
let strObj = this.decoder.decode(chunk).trimEnd();
|
306
306
|
let output = "log";
|
307
307
|
try {
|
308
|
-
|
309
|
-
output =
|
308
|
+
strObj = JSON.parse(strObj);
|
309
|
+
output = strObj.level;
|
310
310
|
} catch (e) {
|
311
311
|
}
|
312
312
|
switch (output) {
|
313
313
|
case "error":
|
314
|
-
console.error(
|
314
|
+
console.error(strObj);
|
315
315
|
break;
|
316
316
|
case "warn":
|
317
|
-
console.warn(
|
317
|
+
console.warn(strObj);
|
318
318
|
break;
|
319
319
|
default:
|
320
|
-
console.log(
|
320
|
+
console.log(strObj);
|
321
321
|
}
|
322
322
|
}
|
323
323
|
};
|
@@ -370,7 +370,7 @@ var Fireproof = (() => {
|
|
370
370
|
}
|
371
371
|
});
|
372
372
|
|
373
|
-
// node_modules/.pnpm/@adviser+cement@0.2.
|
373
|
+
// node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-Q65HLCNL.js
|
374
374
|
function TimeFactory(timeMode) {
|
375
375
|
switch (timeMode) {
|
376
376
|
case "real":
|
@@ -395,7 +395,7 @@ var Fireproof = (() => {
|
|
395
395
|
}
|
396
396
|
var Time, SysTime, ConstTime, StepTime, RandomService, IdService, BaseSysAbstraction, WrapperSysAbstraction, _promise, _resolveFn, _rejectFn, Future, ResolveSeq, ResolveOnce, Keyed, KeyedResolvOnce, _node, NodeEnvActions, _deno, DenoEnvActions, BrowserEnvActions, _envFactory, EnvImpl;
|
397
397
|
var init_chunk_Q65HLCNL = __esm({
|
398
|
-
"node_modules/.pnpm/@adviser+cement@0.2.
|
398
|
+
"node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-Q65HLCNL.js"() {
|
399
399
|
"use strict";
|
400
400
|
init_chunk_GES3MUGV();
|
401
401
|
Time = class {
|
@@ -894,7 +894,7 @@ var Fireproof = (() => {
|
|
894
894
|
}
|
895
895
|
});
|
896
896
|
|
897
|
-
// node_modules/.pnpm/@adviser+cement@0.2.
|
897
|
+
// node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-WMMUXBDX.js
|
898
898
|
function WebSysAbstraction(param) {
|
899
899
|
if (!my) {
|
900
900
|
my = new BaseSysAbstraction({
|
@@ -907,7 +907,7 @@ var Fireproof = (() => {
|
|
907
907
|
}
|
908
908
|
var WebFileService, WebSystemService, my;
|
909
909
|
var init_chunk_WMMUXBDX = __esm({
|
910
|
-
"node_modules/.pnpm/@adviser+cement@0.2.
|
910
|
+
"node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/chunk-WMMUXBDX.js"() {
|
911
911
|
"use strict";
|
912
912
|
init_chunk_Q65HLCNL();
|
913
913
|
init_chunk_GES3MUGV();
|
@@ -8095,7 +8095,7 @@ ${end.comment}` : end.comment;
|
|
8095
8095
|
}
|
8096
8096
|
});
|
8097
8097
|
|
8098
|
-
// node_modules/.pnpm/@adviser+cement@0.2.
|
8098
|
+
// node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/index.js
|
8099
8099
|
function bin2text(hex, lineFn, size = 0) {
|
8100
8100
|
const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
|
8101
8101
|
let cutted = " ";
|
@@ -8140,16 +8140,6 @@ ${end.comment}` : end.comment;
|
|
8140
8140
|
);
|
8141
8141
|
return collector.join("\n");
|
8142
8142
|
}
|
8143
|
-
function removeSelfRef(lineEnd) {
|
8144
|
-
const cache2 = /* @__PURE__ */ new Set();
|
8145
|
-
return function(key, value) {
|
8146
|
-
if (typeof value === "object" && value !== null) {
|
8147
|
-
if (cache2.has(value)) return "...";
|
8148
|
-
cache2.add(value);
|
8149
|
-
}
|
8150
|
-
return lineEnd ? value + lineEnd : value;
|
8151
|
-
};
|
8152
|
-
}
|
8153
8143
|
function asyncLogValue(val) {
|
8154
8144
|
throw new Error("Not implemented");
|
8155
8145
|
}
|
@@ -8176,19 +8166,31 @@ ${end.comment}` : end.comment;
|
|
8176
8166
|
case "boolean":
|
8177
8167
|
return new LogValue(() => val);
|
8178
8168
|
case "object": {
|
8169
|
+
if (val === null) {
|
8170
|
+
return new LogValue(() => "null");
|
8171
|
+
}
|
8179
8172
|
if (ArrayBuffer.isView(val)) {
|
8180
8173
|
return logValue(bin2string(val, 512));
|
8181
8174
|
}
|
8182
8175
|
if (Array.isArray(val)) {
|
8183
8176
|
return new LogValue(() => val.map((v) => logValue(v).value()));
|
8184
8177
|
}
|
8185
|
-
if (val
|
8186
|
-
return new LogValue(() =>
|
8178
|
+
if (val instanceof Headers) {
|
8179
|
+
return new LogValue(() => Object.fromEntries(val.entries()));
|
8180
|
+
}
|
8181
|
+
if (val instanceof ReadableStream) {
|
8182
|
+
return new LogValue(() => ">Stream<");
|
8183
|
+
}
|
8184
|
+
if (val instanceof Promise) {
|
8185
|
+
return new LogValue(() => ">Promise<");
|
8187
8186
|
}
|
8188
8187
|
if (state.has(val)) {
|
8189
8188
|
return new LogValue(() => "...");
|
8190
8189
|
}
|
8191
8190
|
state.add(val);
|
8191
|
+
if (typeof val.toJSON === "function") {
|
8192
|
+
return new LogValue(() => val.toJSON());
|
8193
|
+
}
|
8192
8194
|
const res = {};
|
8193
8195
|
const typedVal = val;
|
8194
8196
|
for (const key in typedVal) {
|
@@ -8196,7 +8198,9 @@ ${end.comment}` : end.comment;
|
|
8196
8198
|
if (element instanceof LogValue) {
|
8197
8199
|
res[key] = element;
|
8198
8200
|
} else {
|
8199
|
-
|
8201
|
+
if (typeof element !== "function") {
|
8202
|
+
res[key] = logValue(element, state);
|
8203
|
+
}
|
8200
8204
|
}
|
8201
8205
|
}
|
8202
8206
|
return new LogValue(() => res);
|
@@ -8239,6 +8243,72 @@ ${end.comment}` : end.comment;
|
|
8239
8243
|
return Result.Err(e);
|
8240
8244
|
}
|
8241
8245
|
}
|
8246
|
+
function stripper(strip, obj) {
|
8247
|
+
const strips = Array.isArray(strip) ? strip : [strip];
|
8248
|
+
const restrips = strips.map((s) => {
|
8249
|
+
if (typeof s === "string") {
|
8250
|
+
const escaped = s.replace(/[-\\[\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\^\\$\\|]/g, "\\$&");
|
8251
|
+
return new RegExp(`^${escaped}$`);
|
8252
|
+
}
|
8253
|
+
return s;
|
8254
|
+
});
|
8255
|
+
return localStripper(void 0, restrips, obj);
|
8256
|
+
}
|
8257
|
+
function localStripper(path, restrips, obj) {
|
8258
|
+
if (typeof obj !== "object" || obj === null) {
|
8259
|
+
return obj;
|
8260
|
+
}
|
8261
|
+
if (Array.isArray(obj)) {
|
8262
|
+
return obj.map((i) => localStripper(path, restrips, i));
|
8263
|
+
}
|
8264
|
+
const ret = __spreadValues({}, obj);
|
8265
|
+
const matcher = (key, nextPath) => {
|
8266
|
+
for (const re of restrips) {
|
8267
|
+
if (re.test(key) || re.test(nextPath)) {
|
8268
|
+
return true;
|
8269
|
+
}
|
8270
|
+
}
|
8271
|
+
return false;
|
8272
|
+
};
|
8273
|
+
for (const key in ret) {
|
8274
|
+
if (Object.prototype.hasOwnProperty.call(ret, key)) {
|
8275
|
+
let nextPath;
|
8276
|
+
if (path) {
|
8277
|
+
nextPath = [path, key].join(".");
|
8278
|
+
} else {
|
8279
|
+
nextPath = key;
|
8280
|
+
}
|
8281
|
+
if (matcher(key, nextPath)) {
|
8282
|
+
delete ret[key];
|
8283
|
+
continue;
|
8284
|
+
}
|
8285
|
+
if (typeof ret[key] === "object") {
|
8286
|
+
if (Array.isArray(ret[key])) {
|
8287
|
+
ret[key] = ret[key].reduce((acc, v, i) => {
|
8288
|
+
const toDelete = matcher(key, `${nextPath}[${i}]`);
|
8289
|
+
if (!toDelete) {
|
8290
|
+
acc.push(localStripper(`${nextPath}[${i}]`, restrips, v));
|
8291
|
+
}
|
8292
|
+
return acc;
|
8293
|
+
}, []);
|
8294
|
+
} else {
|
8295
|
+
ret[key] = localStripper(nextPath, restrips, ret[key]);
|
8296
|
+
}
|
8297
|
+
}
|
8298
|
+
}
|
8299
|
+
}
|
8300
|
+
return ret;
|
8301
|
+
}
|
8302
|
+
function coerceKey(key, def) {
|
8303
|
+
if (typeof key === "object") {
|
8304
|
+
const keys = Object.keys(key);
|
8305
|
+
if (keys.length !== 1) {
|
8306
|
+
throw new Error(`Invalid key: ${JSON.stringify(key)}`);
|
8307
|
+
}
|
8308
|
+
return { key: keys[0], def: key[keys[0]] };
|
8309
|
+
}
|
8310
|
+
return { key, def };
|
8311
|
+
}
|
8242
8312
|
function falsy2undef(value) {
|
8243
8313
|
return value === void 0 || value === null ? void 0 : value;
|
8244
8314
|
}
|
@@ -8278,6 +8348,49 @@ ${end.comment}` : end.comment;
|
|
8278
8348
|
throw new Error(`Invalid argument: ${typeof strURLUri}`);
|
8279
8349
|
}
|
8280
8350
|
}
|
8351
|
+
function getParamResult(key, val, msgFn = (key2) => {
|
8352
|
+
return `missing parameter: ${key2}`;
|
8353
|
+
}) {
|
8354
|
+
if (val === void 0) {
|
8355
|
+
return Result.Err(msgFn(key));
|
8356
|
+
}
|
8357
|
+
return Result.Ok(val);
|
8358
|
+
}
|
8359
|
+
function getParamsResult(keys, getParam) {
|
8360
|
+
const keyDef = keys.flat().reduce(
|
8361
|
+
(acc, i) => {
|
8362
|
+
if (typeof i === "string") {
|
8363
|
+
acc.push({ key: i });
|
8364
|
+
} else if (typeof i === "object") {
|
8365
|
+
acc.push(...Object.keys(i).map((k) => ({ key: k, def: i[k] })));
|
8366
|
+
}
|
8367
|
+
return acc;
|
8368
|
+
},
|
8369
|
+
[]
|
8370
|
+
);
|
8371
|
+
const msgFn = keys.find((k) => typeof k === "function") || ((...keys2) => {
|
8372
|
+
const msg = keys2.join(",");
|
8373
|
+
return `missing parameters: ${msg}`;
|
8374
|
+
});
|
8375
|
+
const errors = [];
|
8376
|
+
const result = {};
|
8377
|
+
for (const kd of keyDef) {
|
8378
|
+
const val = getParam.getParam(kd.key);
|
8379
|
+
if (val === void 0) {
|
8380
|
+
if (kd.def) {
|
8381
|
+
result[kd.key] = kd.def;
|
8382
|
+
} else {
|
8383
|
+
errors.push(kd.key);
|
8384
|
+
}
|
8385
|
+
} else {
|
8386
|
+
result[kd.key] = val;
|
8387
|
+
}
|
8388
|
+
}
|
8389
|
+
if (errors.length) {
|
8390
|
+
return Result.Err(msgFn(...errors));
|
8391
|
+
}
|
8392
|
+
return Result.Ok(result);
|
8393
|
+
}
|
8281
8394
|
function isSet(value, ref = globalThis) {
|
8282
8395
|
const [head, ...tail] = value.split(".");
|
8283
8396
|
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
@@ -8353,9 +8466,9 @@ ${end.comment}` : end.comment;
|
|
8353
8466
|
}
|
8354
8467
|
var LogValue, Result, ResultOK, ResultError, MutableURL, BuildURI, hasHostPartProtocols, URI, LogWriterStream, LevelHandlerImpl, levelSingleton, JSONFormatter, YAMLFormatter, LoggerImpl, WithLoggerBuilder, VERSION;
|
8355
8468
|
var init_cement = __esm({
|
8356
|
-
"node_modules/.pnpm/@adviser+cement@0.2.
|
8469
|
+
"node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/index.js"() {
|
8357
8470
|
"use strict";
|
8358
|
-
|
8471
|
+
init_chunk_USQXEZHL();
|
8359
8472
|
init_chunk_WMMUXBDX();
|
8360
8473
|
init_chunk_Q65HLCNL();
|
8361
8474
|
init_chunk_GES3MUGV();
|
@@ -8365,7 +8478,11 @@ ${end.comment}` : end.comment;
|
|
8365
8478
|
this.fn = fn;
|
8366
8479
|
}
|
8367
8480
|
value() {
|
8368
|
-
|
8481
|
+
try {
|
8482
|
+
return this.fn();
|
8483
|
+
} catch (e) {
|
8484
|
+
return `LogValue:${e.message}`;
|
8485
|
+
}
|
8369
8486
|
}
|
8370
8487
|
toJSON() {
|
8371
8488
|
return this.value();
|
@@ -8592,6 +8709,22 @@ ${end.comment}` : end.comment;
|
|
8592
8709
|
// this._url.host = h;
|
8593
8710
|
// return this;
|
8594
8711
|
// }
|
8712
|
+
appendRelative(p) {
|
8713
|
+
const appendUrl = URI.from(p);
|
8714
|
+
let pathname = appendUrl.pathname;
|
8715
|
+
let basePath = this._url.pathname;
|
8716
|
+
if (pathname.startsWith("/")) {
|
8717
|
+
pathname = pathname.replace(/^\//, "");
|
8718
|
+
}
|
8719
|
+
if (basePath.length > 0) {
|
8720
|
+
basePath = basePath.replace(/\/$/, "");
|
8721
|
+
}
|
8722
|
+
this.pathname(basePath + "/" + pathname);
|
8723
|
+
for (const [key, value] of appendUrl.getParams) {
|
8724
|
+
this.setParam(key, value);
|
8725
|
+
}
|
8726
|
+
return this;
|
8727
|
+
}
|
8595
8728
|
delParam(key) {
|
8596
8729
|
this._url.searchParams.delete(key);
|
8597
8730
|
return this;
|
@@ -8609,8 +8742,22 @@ ${end.comment}` : end.comment;
|
|
8609
8742
|
hasParam(key) {
|
8610
8743
|
return this._url.searchParams.has(key);
|
8611
8744
|
}
|
8612
|
-
|
8613
|
-
return
|
8745
|
+
get getParams() {
|
8746
|
+
return this._url.searchParams.entries();
|
8747
|
+
}
|
8748
|
+
getParam(key, def) {
|
8749
|
+
const { key: k, def: d } = coerceKey(key, def);
|
8750
|
+
let val = this._url.searchParams.get(k);
|
8751
|
+
if (!falsy2undef(val) && d) {
|
8752
|
+
val = d;
|
8753
|
+
}
|
8754
|
+
return falsy2undef(val);
|
8755
|
+
}
|
8756
|
+
getParamResult(key, msgFn) {
|
8757
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
8758
|
+
}
|
8759
|
+
getParamsResult(...keys) {
|
8760
|
+
return getParamsResult(keys, this);
|
8614
8761
|
}
|
8615
8762
|
toString() {
|
8616
8763
|
this._url.searchParams.sort();
|
@@ -8619,6 +8766,15 @@ ${end.comment}` : end.comment;
|
|
8619
8766
|
toJSON() {
|
8620
8767
|
return this.toString();
|
8621
8768
|
}
|
8769
|
+
asURL() {
|
8770
|
+
return this.URI().asURL();
|
8771
|
+
}
|
8772
|
+
asObj(...strips) {
|
8773
|
+
return this.URI().asObj(...strips);
|
8774
|
+
}
|
8775
|
+
clone() {
|
8776
|
+
return _BuildURI.from(this.toString());
|
8777
|
+
}
|
8622
8778
|
URI() {
|
8623
8779
|
return URI.from(this._url);
|
8624
8780
|
}
|
@@ -8698,8 +8854,19 @@ ${end.comment}` : end.comment;
|
|
8698
8854
|
hasParam(key) {
|
8699
8855
|
return this._url.searchParams.has(key);
|
8700
8856
|
}
|
8701
|
-
getParam(key) {
|
8702
|
-
|
8857
|
+
getParam(key, def) {
|
8858
|
+
const { key: k, def: d } = coerceKey(key, def);
|
8859
|
+
let val = this._url.searchParams.get(k);
|
8860
|
+
if (!falsy2undef(val) && d) {
|
8861
|
+
val = d;
|
8862
|
+
}
|
8863
|
+
return falsy2undef(val);
|
8864
|
+
}
|
8865
|
+
getParamResult(key, msgFn) {
|
8866
|
+
return getParamResult(key, this.getParam(key), msgFn);
|
8867
|
+
}
|
8868
|
+
getParamsResult(...keys) {
|
8869
|
+
return getParamsResult(keys, this);
|
8703
8870
|
}
|
8704
8871
|
clone() {
|
8705
8872
|
return new _URI(this._url);
|
@@ -8713,7 +8880,7 @@ ${end.comment}` : end.comment;
|
|
8713
8880
|
toJSON() {
|
8714
8881
|
return this.toString();
|
8715
8882
|
}
|
8716
|
-
asObj() {
|
8883
|
+
asObj(...strips) {
|
8717
8884
|
const pathURI = {
|
8718
8885
|
style: "path",
|
8719
8886
|
protocol: this.protocol,
|
@@ -8721,13 +8888,13 @@ ${end.comment}` : end.comment;
|
|
8721
8888
|
searchParams: Object.fromEntries(this.getParams)
|
8722
8889
|
};
|
8723
8890
|
if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
|
8724
|
-
return __spreadProps(__spreadValues({}, pathURI), {
|
8891
|
+
return stripper(strips, __spreadProps(__spreadValues({}, pathURI), {
|
8725
8892
|
style: "host",
|
8726
8893
|
hostname: this.hostname,
|
8727
8894
|
port: this.port
|
8728
|
-
});
|
8895
|
+
}));
|
8729
8896
|
}
|
8730
|
-
return pathURI;
|
8897
|
+
return stripper(strips, pathURI);
|
8731
8898
|
}
|
8732
8899
|
};
|
8733
8900
|
LogWriterStream = class {
|
@@ -8863,7 +9030,13 @@ ${end.comment}` : end.comment;
|
|
8863
9030
|
this._space = space;
|
8864
9031
|
}
|
8865
9032
|
format(attr) {
|
8866
|
-
|
9033
|
+
let ret;
|
9034
|
+
try {
|
9035
|
+
ret = JSON.stringify(attr, null, this._space);
|
9036
|
+
} catch (e) {
|
9037
|
+
ret = JSON.stringify({ internal: { message: e.message, stack: e.stack } });
|
9038
|
+
}
|
9039
|
+
return this._txtEnDe.encode(ret + "\n");
|
8867
9040
|
}
|
8868
9041
|
};
|
8869
9042
|
YAMLFormatter = class {
|
@@ -8872,7 +9045,7 @@ ${end.comment}` : end.comment;
|
|
8872
9045
|
this._space = space;
|
8873
9046
|
}
|
8874
9047
|
format(attr) {
|
8875
|
-
return this._txtEnDe.encode("---\n" + browser_default.stringify(attr,
|
9048
|
+
return this._txtEnDe.encode("---\n" + browser_default.stringify(attr, null, this._space) + "\n");
|
8876
9049
|
}
|
8877
9050
|
};
|
8878
9051
|
LoggerImpl = class _LoggerImpl {
|
@@ -8933,7 +9106,7 @@ ${end.comment}` : end.comment;
|
|
8933
9106
|
return this._txtEnDe;
|
8934
9107
|
}
|
8935
9108
|
Attributes() {
|
8936
|
-
return JSON.parse(JSON.stringify(this._attributes,
|
9109
|
+
return JSON.parse(JSON.stringify(this._attributes, null));
|
8937
9110
|
}
|
8938
9111
|
SetExposeStack(enable) {
|
8939
9112
|
this._levelHandler.setExposeStack(enable);
|
@@ -9029,7 +9202,37 @@ ${end.comment}` : end.comment;
|
|
9029
9202
|
return this;
|
9030
9203
|
}
|
9031
9204
|
Bool(key, value) {
|
9032
|
-
this.
|
9205
|
+
this.coerceKey(key, !!value);
|
9206
|
+
return this;
|
9207
|
+
}
|
9208
|
+
Http(res, req, key) {
|
9209
|
+
if (Result.Is(res)) {
|
9210
|
+
if (res.isErr()) {
|
9211
|
+
this.Err(res.Err());
|
9212
|
+
return this;
|
9213
|
+
}
|
9214
|
+
res = res.Ok();
|
9215
|
+
}
|
9216
|
+
let reqRes = res;
|
9217
|
+
if (req) {
|
9218
|
+
reqRes = { res, req };
|
9219
|
+
}
|
9220
|
+
this.Any(key || "Http", reqRes);
|
9221
|
+
return this;
|
9222
|
+
}
|
9223
|
+
Pair(x) {
|
9224
|
+
for (const key of Object.keys(x)) {
|
9225
|
+
const value = x[key];
|
9226
|
+
if (value instanceof LogValue) {
|
9227
|
+
this._attributes[key] = value;
|
9228
|
+
continue;
|
9229
|
+
}
|
9230
|
+
if (Result.Is(value)) {
|
9231
|
+
this.Result(key, value);
|
9232
|
+
continue;
|
9233
|
+
}
|
9234
|
+
this.Any(key, value);
|
9235
|
+
}
|
9033
9236
|
return this;
|
9034
9237
|
}
|
9035
9238
|
Result(key, res) {
|
@@ -9052,12 +9255,19 @@ ${end.comment}` : end.comment;
|
|
9052
9255
|
this.Ref(key, () => URI.from(url).toString());
|
9053
9256
|
return this;
|
9054
9257
|
}
|
9258
|
+
coerceKey(key, value) {
|
9259
|
+
if (typeof key === "string") {
|
9260
|
+
this._attributes[key] = logValue(value);
|
9261
|
+
} else {
|
9262
|
+
this.Pair(key);
|
9263
|
+
}
|
9264
|
+
}
|
9055
9265
|
Str(key, value) {
|
9056
|
-
this.
|
9266
|
+
this.coerceKey(key, value);
|
9057
9267
|
return this;
|
9058
9268
|
}
|
9059
9269
|
Any(key, value) {
|
9060
|
-
this.
|
9270
|
+
this.coerceKey(key, value);
|
9061
9271
|
return this;
|
9062
9272
|
}
|
9063
9273
|
Dur(key, nsec) {
|
@@ -9065,7 +9275,7 @@ ${end.comment}` : end.comment;
|
|
9065
9275
|
return this;
|
9066
9276
|
}
|
9067
9277
|
Uint64(key, value) {
|
9068
|
-
this.
|
9278
|
+
this.coerceKey(key, value);
|
9069
9279
|
return this;
|
9070
9280
|
}
|
9071
9281
|
Int(key, value) {
|
@@ -9117,8 +9327,10 @@ ${end.comment}` : end.comment;
|
|
9117
9327
|
}
|
9118
9328
|
return fnRet;
|
9119
9329
|
});
|
9330
|
+
const asError = () => new Error(this._txtEnDe.decode(fnError()));
|
9120
9331
|
return {
|
9121
|
-
|
9332
|
+
ResultError: () => Result.Err(asError()),
|
9333
|
+
AsError: asError
|
9122
9334
|
};
|
9123
9335
|
}
|
9124
9336
|
};
|
@@ -9160,6 +9372,14 @@ ${end.comment}` : end.comment;
|
|
9160
9372
|
this._li.SetDebug(...modules);
|
9161
9373
|
return this;
|
9162
9374
|
}
|
9375
|
+
Http(res, req, key) {
|
9376
|
+
this._li.Http(res, req, key);
|
9377
|
+
return this;
|
9378
|
+
}
|
9379
|
+
Pair(x) {
|
9380
|
+
this._li.Pair(x);
|
9381
|
+
return this;
|
9382
|
+
}
|
9163
9383
|
Str(key, value) {
|
9164
9384
|
this._li.Str(key, value);
|
9165
9385
|
return this;
|
@@ -12095,7 +12315,9 @@ ${end.comment}` : end.comment;
|
|
12095
12315
|
};
|
12096
12316
|
pathOps = new pathOpsImpl();
|
12097
12317
|
txtOps = {
|
12318
|
+
// eslint-disable-next-line no-restricted-globals
|
12098
12319
|
encode: (input) => new TextEncoder().encode(input),
|
12320
|
+
// eslint-disable-next-line no-restricted-globals
|
12099
12321
|
decode: (input) => new TextDecoder().decode(input)
|
12100
12322
|
};
|
12101
12323
|
NotFoundError2 = class extends Error {
|
@@ -12204,6 +12426,128 @@ ${end.comment}` : end.comment;
|
|
12204
12426
|
}
|
12205
12427
|
});
|
12206
12428
|
|
12429
|
+
// src/runtime/gateways/file/utils.ts
|
12430
|
+
var utils_exports2 = {};
|
12431
|
+
__export(utils_exports2, {
|
12432
|
+
getFileName: () => getFileName,
|
12433
|
+
getFileSystem: () => getFileSystem,
|
12434
|
+
getPath: () => getPath
|
12435
|
+
});
|
12436
|
+
async function getFileSystem(url) {
|
12437
|
+
const name6 = url.getParam("fs", "node");
|
12438
|
+
let fs;
|
12439
|
+
switch (name6) {
|
12440
|
+
case "mem":
|
12441
|
+
fs = await externalLoaders.get(name6).once(async () => {
|
12442
|
+
const { MemFileSystem } = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
|
12443
|
+
return new MemFileSystem();
|
12444
|
+
});
|
12445
|
+
break;
|
12446
|
+
// case 'deno': {
|
12447
|
+
// const { DenoFileSystem } = await import("./deno-filesystem.js");
|
12448
|
+
// fs = new DenoFileSystem();
|
12449
|
+
// break;
|
12450
|
+
// }
|
12451
|
+
default:
|
12452
|
+
fs = await externalLoaders.get(name6).once(async () => {
|
12453
|
+
const { NodeFileSystem } = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
|
12454
|
+
return new NodeFileSystem();
|
12455
|
+
});
|
12456
|
+
}
|
12457
|
+
return fs.start();
|
12458
|
+
}
|
12459
|
+
function getPath(url, sthis) {
|
12460
|
+
const basePath = url.pathname;
|
12461
|
+
const name6 = url.getParam("name");
|
12462
|
+
if (name6) {
|
12463
|
+
const version = url.getParam("version");
|
12464
|
+
if (!version) throw sthis.logger.Error().Url(url).Msg(`version not found`).AsError();
|
12465
|
+
return sthis.pathOps.join(basePath, version, name6);
|
12466
|
+
}
|
12467
|
+
return sthis.pathOps.join(basePath);
|
12468
|
+
}
|
12469
|
+
function getFileName(url, sthis) {
|
12470
|
+
const key = url.getParam("key");
|
12471
|
+
if (!key) throw sthis.logger.Error().Url(url).Msg(`key not found`).AsError();
|
12472
|
+
const res = getStore(url, sthis, (...a) => a.join("-"));
|
12473
|
+
switch (res.store) {
|
12474
|
+
case "data":
|
12475
|
+
return sthis.pathOps.join(res.name, key + ".car");
|
12476
|
+
case "wal":
|
12477
|
+
case "meta":
|
12478
|
+
return sthis.pathOps.join(res.name, key + ".json");
|
12479
|
+
default:
|
12480
|
+
throw sthis.logger.Error().Url(url).Msg(`unsupported store type`).AsError();
|
12481
|
+
}
|
12482
|
+
}
|
12483
|
+
var externalLoaders;
|
12484
|
+
var init_utils2 = __esm({
|
12485
|
+
"src/runtime/gateways/file/utils.ts"() {
|
12486
|
+
"use strict";
|
12487
|
+
init_cement();
|
12488
|
+
init_utils();
|
12489
|
+
externalLoaders = new KeyedResolvOnce();
|
12490
|
+
}
|
12491
|
+
});
|
12492
|
+
|
12493
|
+
// src/runtime/key-bag-file.ts
|
12494
|
+
var key_bag_file_exports = {};
|
12495
|
+
__export(key_bag_file_exports, {
|
12496
|
+
KeyBagProviderFile: () => KeyBagProviderFile
|
12497
|
+
});
|
12498
|
+
var KeyBagProviderFile;
|
12499
|
+
var init_key_bag_file = __esm({
|
12500
|
+
"src/runtime/key-bag-file.ts"() {
|
12501
|
+
"use strict";
|
12502
|
+
init_utils();
|
12503
|
+
KeyBagProviderFile = class {
|
12504
|
+
async _prepare(id) {
|
12505
|
+
await this.sthis.start();
|
12506
|
+
let sysFS;
|
12507
|
+
switch (this.url.protocol) {
|
12508
|
+
case "file:": {
|
12509
|
+
const { getFileSystem: getFileSystem2 } = await Promise.resolve().then(() => (init_utils2(), utils_exports2));
|
12510
|
+
sysFS = await getFileSystem2(this.url);
|
12511
|
+
break;
|
12512
|
+
}
|
12513
|
+
default:
|
12514
|
+
throw this.logger.Error().Url(this.url).Msg("unsupported protocol").AsError();
|
12515
|
+
}
|
12516
|
+
const dirName = this.url.pathname;
|
12517
|
+
await sysFS.mkdir(dirName, { recursive: true });
|
12518
|
+
return {
|
12519
|
+
dirName,
|
12520
|
+
sysFS,
|
12521
|
+
fName: this.sthis.pathOps.join(dirName, `${id.replace(/[^a-zA-Z0-9]/g, "_")}.json`)
|
12522
|
+
};
|
12523
|
+
}
|
12524
|
+
constructor(url, sthis) {
|
12525
|
+
this.url = url;
|
12526
|
+
this.sthis = sthis;
|
12527
|
+
this.logger = sthis.logger;
|
12528
|
+
}
|
12529
|
+
async get(id) {
|
12530
|
+
const ctx = await this._prepare(id);
|
12531
|
+
try {
|
12532
|
+
const p = await ctx.sysFS.readfile(ctx.fName);
|
12533
|
+
const ki = JSON.parse(this.sthis.txt.decode(p));
|
12534
|
+
return ki;
|
12535
|
+
} catch (e) {
|
12536
|
+
if (isNotFoundError(e)) {
|
12537
|
+
return void 0;
|
12538
|
+
}
|
12539
|
+
throw this.logger.Error().Err(e).Str("file", ctx.dirName).Msg("read bag failed").AsError();
|
12540
|
+
}
|
12541
|
+
}
|
12542
|
+
async set(id, item) {
|
12543
|
+
const ctx = await this._prepare(id);
|
12544
|
+
const p = this.sthis.txt.encode(JSON.stringify(item, null, 2));
|
12545
|
+
await ctx.sysFS.writefile(ctx.fName, p);
|
12546
|
+
}
|
12547
|
+
};
|
12548
|
+
}
|
12549
|
+
});
|
12550
|
+
|
12207
12551
|
// node_modules/.pnpm/idb@8.0.0/node_modules/idb/build/index.js
|
12208
12552
|
function getIdbProxyableTypes() {
|
12209
12553
|
return idbProxyableTypes || (idbProxyableTypes = [
|
@@ -12443,124 +12787,6 @@ ${end.comment}` : end.comment;
|
|
12443
12787
|
}
|
12444
12788
|
});
|
12445
12789
|
|
12446
|
-
// src/runtime/gateways/file/node-filesystem.ts
|
12447
|
-
var node_filesystem_exports = {};
|
12448
|
-
__export(node_filesystem_exports, {
|
12449
|
-
NodeFileSystem: () => NodeFileSystem
|
12450
|
-
});
|
12451
|
-
var NodeFileSystem;
|
12452
|
-
var init_node_filesystem = __esm({
|
12453
|
-
"src/runtime/gateways/file/node-filesystem.ts"() {
|
12454
|
-
"use strict";
|
12455
|
-
init_utils2();
|
12456
|
-
init_cement();
|
12457
|
-
NodeFileSystem = class {
|
12458
|
-
async start() {
|
12459
|
-
this.fs = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
|
12460
|
-
return this;
|
12461
|
-
}
|
12462
|
-
async mkdir(path, options) {
|
12463
|
-
return this.fs?.mkdir(path, options);
|
12464
|
-
}
|
12465
|
-
async readdir(path, options) {
|
12466
|
-
return this.fs?.readdir(path, options);
|
12467
|
-
}
|
12468
|
-
async rm(path, options) {
|
12469
|
-
return this.fs?.rm(path, options);
|
12470
|
-
}
|
12471
|
-
async copyFile(source, destination) {
|
12472
|
-
return this.fs?.copyFile(source, destination);
|
12473
|
-
}
|
12474
|
-
async readfile(path, options) {
|
12475
|
-
const ret = await this.fs?.readFile(path, options);
|
12476
|
-
return toArrayBuffer(ret);
|
12477
|
-
}
|
12478
|
-
stat(path) {
|
12479
|
-
return this.fs?.stat(path);
|
12480
|
-
}
|
12481
|
-
async unlink(path) {
|
12482
|
-
return this.fs?.unlink(path);
|
12483
|
-
}
|
12484
|
-
async writefile(path, data) {
|
12485
|
-
if (runtimeFn().isDeno) {
|
12486
|
-
return this.fs?.writeFile(path, data);
|
12487
|
-
}
|
12488
|
-
return this.fs?.writeFile(path, Buffer.from(data));
|
12489
|
-
}
|
12490
|
-
};
|
12491
|
-
}
|
12492
|
-
});
|
12493
|
-
|
12494
|
-
// src/runtime/gateways/file/utils.ts
|
12495
|
-
async function getFileSystem(url) {
|
12496
|
-
const name6 = url.getParam("fs");
|
12497
|
-
let fs;
|
12498
|
-
switch (name6) {
|
12499
|
-
case "mem":
|
12500
|
-
{
|
12501
|
-
const { MemFileSystem } = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
|
12502
|
-
fs = new MemFileSystem();
|
12503
|
-
}
|
12504
|
-
break;
|
12505
|
-
// case 'deno': {
|
12506
|
-
// const { DenoFileSystem } = await import("./deno-filesystem.js");
|
12507
|
-
// fs = new DenoFileSystem();
|
12508
|
-
// break;
|
12509
|
-
// }
|
12510
|
-
case "node": {
|
12511
|
-
const { NodeFileSystem: NodeFileSystem2 } = await Promise.resolve().then(() => (init_node_filesystem(), node_filesystem_exports));
|
12512
|
-
fs = new NodeFileSystem2();
|
12513
|
-
break;
|
12514
|
-
}
|
12515
|
-
case "sys":
|
12516
|
-
default: {
|
12517
|
-
return getFileSystem(url.build().setParam("fs", "node").URI());
|
12518
|
-
}
|
12519
|
-
}
|
12520
|
-
return fs.start();
|
12521
|
-
}
|
12522
|
-
function getPath(url, sthis) {
|
12523
|
-
const basePath = url.pathname;
|
12524
|
-
const name6 = url.getParam("name");
|
12525
|
-
if (name6) {
|
12526
|
-
const version = url.getParam("version");
|
12527
|
-
if (!version) throw sthis.logger.Error().Url(url).Msg(`version not found`).AsError();
|
12528
|
-
return sthis.pathOps.join(basePath, version, name6);
|
12529
|
-
}
|
12530
|
-
return sthis.pathOps.join(basePath);
|
12531
|
-
}
|
12532
|
-
function getFileName(url, sthis) {
|
12533
|
-
const key = url.getParam("key");
|
12534
|
-
if (!key) throw sthis.logger.Error().Url(url).Msg(`key not found`).AsError();
|
12535
|
-
const res = getStore(url, sthis, (...a) => a.join("-"));
|
12536
|
-
switch (res.store) {
|
12537
|
-
case "data":
|
12538
|
-
return sthis.pathOps.join(res.name, key + ".car");
|
12539
|
-
case "wal":
|
12540
|
-
case "meta":
|
12541
|
-
return sthis.pathOps.join(res.name, key + ".json");
|
12542
|
-
default:
|
12543
|
-
throw sthis.logger.Error().Url(url).Msg(`unsupported store type`).AsError();
|
12544
|
-
}
|
12545
|
-
}
|
12546
|
-
function toArrayBuffer(buffer2) {
|
12547
|
-
if (typeof buffer2 === "string") {
|
12548
|
-
buffer2 = Buffer.from(buffer2);
|
12549
|
-
}
|
12550
|
-
const ab = new ArrayBuffer(buffer2.length);
|
12551
|
-
const view = new Uint8Array(ab);
|
12552
|
-
for (let i = 0; i < buffer2.length; ++i) {
|
12553
|
-
view[i] = buffer2[i];
|
12554
|
-
}
|
12555
|
-
return view;
|
12556
|
-
}
|
12557
|
-
var init_utils2 = __esm({
|
12558
|
-
"src/runtime/gateways/file/utils.ts"() {
|
12559
|
-
"use strict";
|
12560
|
-
init_utils();
|
12561
|
-
}
|
12562
|
-
});
|
12563
|
-
|
12564
12790
|
// src/runtime/key-bag-indexdb.ts
|
12565
12791
|
var key_bag_indexdb_exports = {};
|
12566
12792
|
__export(key_bag_indexdb_exports, {
|
@@ -12845,173 +13071,213 @@ ${end.comment}` : end.comment;
|
|
12845
13071
|
}
|
12846
13072
|
});
|
12847
13073
|
|
12848
|
-
// src/runtime/gateways/
|
12849
|
-
var
|
13074
|
+
// src/runtime/gateways/file/version.ts
|
13075
|
+
var FILESTORE_VERSION;
|
12850
13076
|
var init_version = __esm({
|
12851
|
-
"src/runtime/gateways/
|
13077
|
+
"src/runtime/gateways/file/version.ts"() {
|
12852
13078
|
"use strict";
|
12853
|
-
|
13079
|
+
FILESTORE_VERSION = "v0.19-file";
|
12854
13080
|
}
|
12855
13081
|
});
|
12856
13082
|
|
12857
|
-
// src/runtime/gateways/
|
13083
|
+
// src/runtime/gateways/file/gateway.ts
|
12858
13084
|
var gateway_exports = {};
|
12859
13085
|
__export(gateway_exports, {
|
12860
|
-
|
12861
|
-
|
12862
|
-
getIndexDBName: () => getIndexDBName
|
13086
|
+
FileGateway: () => FileGateway,
|
13087
|
+
FileTestStore: () => FileTestStore
|
12863
13088
|
});
|
12864
|
-
|
12865
|
-
return url.build().defParam("version", INDEXDB_VERSION).URI();
|
12866
|
-
}
|
12867
|
-
function sanitzeKey(key) {
|
12868
|
-
if (key.length === 1) {
|
12869
|
-
key = key[0];
|
12870
|
-
}
|
12871
|
-
return key;
|
12872
|
-
}
|
12873
|
-
async function connectIdb(url, sthis) {
|
12874
|
-
const dbName = getIndexDBName(url, sthis);
|
12875
|
-
const once = await onceIndexDB.get(dbName.fullDb).once(async () => {
|
12876
|
-
const db = await openDB(dbName.fullDb, 1, {
|
12877
|
-
upgrade(db2) {
|
12878
|
-
["version", "data", "wal", "meta", "idx.data", "idx.wal", "idx.meta"].map((store) => {
|
12879
|
-
db2.createObjectStore(store, {
|
12880
|
-
autoIncrement: false
|
12881
|
-
});
|
12882
|
-
});
|
12883
|
-
}
|
12884
|
-
});
|
12885
|
-
const found = await db.get("version", "version");
|
12886
|
-
const version = ensureVersion(url).getParam("version");
|
12887
|
-
if (!found) {
|
12888
|
-
await db.put("version", { version }, "version");
|
12889
|
-
} else if (found.version !== version) {
|
12890
|
-
sthis.logger.Warn().Str("url", url.toString()).Str("version", version).Str("found", found.version).Msg("version mismatch");
|
12891
|
-
}
|
12892
|
-
return { db, dbName, version, url };
|
12893
|
-
});
|
12894
|
-
return {
|
12895
|
-
...once,
|
12896
|
-
url: url.build().setParam("version", once.version).URI()
|
12897
|
-
};
|
12898
|
-
}
|
12899
|
-
function joinDBName(...names) {
|
12900
|
-
return names.map((i) => i.replace(/^[^a-zA-Z0-9]+/g, "").replace(/[^a-zA-Z0-9]+/g, "_")).filter((i) => i.length).join(".");
|
12901
|
-
}
|
12902
|
-
function getIndexDBName(iurl, sthis) {
|
12903
|
-
const url = ensureVersion(iurl);
|
12904
|
-
const fullDb = url.pathname.replace(/^\/+/, "").replace(/\?.*$/, "");
|
12905
|
-
const dbName = url.getParam("name");
|
12906
|
-
if (!dbName) throw sthis.logger.Error().Str("url", url.toString()).Msg(`name not found`).AsError();
|
12907
|
-
const result = joinDBName(fullDb, dbName);
|
12908
|
-
const objStore = getStore(url, sthis, joinDBName).name;
|
12909
|
-
const connectionKey = [result, objStore].join(":");
|
12910
|
-
return {
|
12911
|
-
fullDb: result,
|
12912
|
-
objStore,
|
12913
|
-
connectionKey,
|
12914
|
-
dbName
|
12915
|
-
};
|
12916
|
-
}
|
12917
|
-
var onceIndexDB, IndexDBGateway, IndexDBTestStore;
|
13089
|
+
var versionFiles, FileGateway, FileTestStore;
|
12918
13090
|
var init_gateway = __esm({
|
12919
|
-
"src/runtime/gateways/
|
13091
|
+
"src/runtime/gateways/file/gateway.ts"() {
|
12920
13092
|
"use strict";
|
12921
|
-
init_build();
|
12922
|
-
init_cement();
|
12923
13093
|
init_version();
|
13094
|
+
init_cement();
|
12924
13095
|
init_utils();
|
12925
|
-
|
12926
|
-
|
13096
|
+
init_utils2();
|
13097
|
+
versionFiles = new KeyedResolvOnce();
|
13098
|
+
FileGateway = class {
|
13099
|
+
get fs() {
|
13100
|
+
if (!this._fs) throw this.logger.Error().Msg("fs not initialized").AsError();
|
13101
|
+
return this._fs;
|
13102
|
+
}
|
12927
13103
|
constructor(sthis) {
|
12928
|
-
this._db = {};
|
12929
|
-
this.logger = ensureLogger(sthis, "IndexDBGateway");
|
12930
13104
|
this.sthis = sthis;
|
13105
|
+
this.logger = sthis.logger;
|
12931
13106
|
}
|
12932
|
-
async
|
13107
|
+
async getVersionFromFile(path, logger) {
|
13108
|
+
return versionFiles.get(path).once(async () => {
|
13109
|
+
await this.fs.mkdir(path, { recursive: true });
|
13110
|
+
const vFile = this.sthis.pathOps.join(path, "version");
|
13111
|
+
const vFileStat = await this.fs.stat(vFile).catch(() => void 0);
|
13112
|
+
if (!vFileStat) {
|
13113
|
+
await this.fs.writefile(this.sthis.pathOps.join(path, "version"), FILESTORE_VERSION);
|
13114
|
+
return FILESTORE_VERSION;
|
13115
|
+
} else if (!vFileStat.isFile()) {
|
13116
|
+
throw logger.Error().Str("file", vFile).Msg(`version file is a directory`).AsError();
|
13117
|
+
}
|
13118
|
+
const v = await this.fs.readfile(vFile);
|
13119
|
+
const vStr = this.sthis.txt.decode(v);
|
13120
|
+
if (vStr !== FILESTORE_VERSION) {
|
13121
|
+
logger.Warn().Str("file", vFile).Str("from", vStr).Str("expected", FILESTORE_VERSION).Msg(`version mismatch`);
|
13122
|
+
}
|
13123
|
+
return vStr;
|
13124
|
+
});
|
13125
|
+
}
|
13126
|
+
start(baseURL) {
|
12933
13127
|
return exception2Result(async () => {
|
12934
|
-
this.
|
12935
|
-
await this.
|
12936
|
-
const
|
12937
|
-
|
12938
|
-
this.
|
12939
|
-
|
13128
|
+
this._fs = await getFileSystem(baseURL);
|
13129
|
+
await this.fs.start();
|
13130
|
+
const url = baseURL.build();
|
13131
|
+
url.defParam("version", FILESTORE_VERSION);
|
13132
|
+
const dbUrl = await this.buildUrl(url.URI(), "dummy");
|
13133
|
+
const dbdirFile = this.getFilePath(dbUrl.Ok());
|
13134
|
+
await this.fs.mkdir(this.sthis.pathOps.dirname(dbdirFile), { recursive: true });
|
13135
|
+
const dbroot = this.sthis.pathOps.dirname(dbdirFile);
|
13136
|
+
this.logger.Debug().Url(url.URI()).Str("dbroot", dbroot).Msg("start");
|
13137
|
+
url.setParam("version", await this.getVersionFromFile(dbroot, this.logger));
|
13138
|
+
return url.URI();
|
12940
13139
|
});
|
12941
13140
|
}
|
13141
|
+
async buildUrl(baseUrl, key) {
|
13142
|
+
return Result.Ok(baseUrl.build().setParam("key", key).URI());
|
13143
|
+
}
|
12942
13144
|
async close() {
|
12943
13145
|
return Result.Ok(void 0);
|
12944
13146
|
}
|
12945
|
-
|
13147
|
+
// abstract buildUrl(baseUrl: URL, key: string): Promise<Result<URL>>;
|
13148
|
+
getFilePath(url) {
|
13149
|
+
const key = url.getParam("key");
|
13150
|
+
if (!key) throw this.logger.Error().Url(url).Msg(`key not found`).AsError();
|
13151
|
+
return this.sthis.pathOps.join(getPath(url, this.sthis), getFileName(url, this.sthis));
|
13152
|
+
}
|
13153
|
+
async put(url, body) {
|
12946
13154
|
return exception2Result(async () => {
|
12947
|
-
const
|
12948
|
-
|
12949
|
-
|
12950
|
-
const object_store = trans.objectStore(type2);
|
12951
|
-
const toDelete = [];
|
12952
|
-
for (let cursor = await object_store.openCursor(); cursor; cursor = await cursor.continue()) {
|
12953
|
-
toDelete.push(cursor.primaryKey);
|
12954
|
-
}
|
12955
|
-
for (const key of toDelete) {
|
12956
|
-
await trans.db.delete(type2, key);
|
12957
|
-
}
|
12958
|
-
await trans.done;
|
13155
|
+
const file = await this.getFilePath(url);
|
13156
|
+
this.logger.Debug().Str("url", url.toString()).Str("file", file).Msg("put");
|
13157
|
+
await this.fs.writefile(file, body);
|
12959
13158
|
});
|
12960
13159
|
}
|
12961
|
-
buildUrl(baseUrl, key) {
|
12962
|
-
return Promise.resolve(Result.Ok(baseUrl.build().setParam("key", key).URI()));
|
12963
|
-
}
|
12964
13160
|
async get(url) {
|
12965
13161
|
return exceptionWrapper(async () => {
|
12966
|
-
const
|
12967
|
-
|
12968
|
-
|
12969
|
-
|
12970
|
-
|
12971
|
-
|
12972
|
-
|
12973
|
-
|
13162
|
+
const file = this.getFilePath(url);
|
13163
|
+
try {
|
13164
|
+
const res = await this.fs.readfile(file);
|
13165
|
+
this.logger.Debug().Url(url.asURL()).Str("file", file).Msg("get");
|
13166
|
+
return Result.Ok(new Uint8Array(res));
|
13167
|
+
} catch (e) {
|
13168
|
+
if (isNotFoundError(e)) {
|
13169
|
+
return Result.Err(new NotFoundError2(`file not found: ${file}`));
|
13170
|
+
}
|
13171
|
+
return Result.Err(e);
|
12974
13172
|
}
|
12975
|
-
return Result.Ok(bytes);
|
12976
13173
|
});
|
12977
13174
|
}
|
12978
|
-
async
|
13175
|
+
async delete(url) {
|
12979
13176
|
return exception2Result(async () => {
|
12980
|
-
|
12981
|
-
const store = getStore(url, this.sthis, joinDBName).name;
|
12982
|
-
this.logger.Debug().Url(url).Str("key", key).Str("store", store).Msg("putting");
|
12983
|
-
const tx = this._db.transaction([store], "readwrite");
|
12984
|
-
await tx.objectStore(store).put(value, sanitzeKey(key));
|
12985
|
-
await tx.done;
|
13177
|
+
await this.fs.unlink(this.getFilePath(url));
|
12986
13178
|
});
|
12987
13179
|
}
|
12988
|
-
async
|
12989
|
-
|
12990
|
-
|
12991
|
-
|
12992
|
-
|
12993
|
-
|
12994
|
-
await
|
12995
|
-
|
12996
|
-
|
13180
|
+
async destroy(baseURL) {
|
13181
|
+
const url = await this.buildUrl(baseURL, "x");
|
13182
|
+
if (url.isErr()) return url;
|
13183
|
+
const filepath = this.sthis.pathOps.dirname(this.getFilePath(url.Ok()));
|
13184
|
+
let files = [];
|
13185
|
+
try {
|
13186
|
+
files = await this.fs.readdir(filepath);
|
13187
|
+
} catch (e) {
|
13188
|
+
if (!isNotFoundError(e)) {
|
13189
|
+
throw this.logger.Error().Err(e).Str("dir", filepath).Msg("destroy:readdir").AsError();
|
13190
|
+
}
|
13191
|
+
}
|
13192
|
+
for (const file of files) {
|
13193
|
+
const pathed = this.sthis.pathOps.join(filepath, file);
|
13194
|
+
try {
|
13195
|
+
await this.fs.unlink(pathed);
|
13196
|
+
} catch (e) {
|
13197
|
+
if (!isNotFoundError(e)) {
|
13198
|
+
throw this.logger.Error().Err(e).Str("file", pathed).Msg("destroy:unlink").AsError();
|
13199
|
+
}
|
13200
|
+
}
|
13201
|
+
}
|
13202
|
+
return Result.Ok(void 0);
|
13203
|
+
}
|
13204
|
+
};
|
13205
|
+
FileTestStore = class {
|
13206
|
+
constructor(sthis) {
|
13207
|
+
this.logger = ensureLogger(sthis, "FileTestStore");
|
13208
|
+
this.sthis = sthis;
|
13209
|
+
}
|
13210
|
+
async get(iurl, key) {
|
13211
|
+
const url = iurl.build().setParam("key", key).URI();
|
13212
|
+
const dbFile = this.sthis.pathOps.join(getPath(url, this.sthis), getFileName(url, this.sthis));
|
13213
|
+
this.logger.Debug().Url(url).Str("dbFile", dbFile).Msg("get");
|
13214
|
+
const buffer2 = await (await getFileSystem(url)).readfile(dbFile);
|
13215
|
+
this.logger.Debug().Url(url).Str("dbFile", dbFile).Len(buffer2).Msg("got");
|
13216
|
+
return buffer2;
|
13217
|
+
}
|
13218
|
+
};
|
13219
|
+
}
|
13220
|
+
});
|
13221
|
+
|
13222
|
+
// src/runtime/gateways/indexdb/gateway.ts
|
13223
|
+
var gateway_exports2 = {};
|
13224
|
+
__export(gateway_exports2, {
|
13225
|
+
IndexDBGateway: () => IndexDBGateway,
|
13226
|
+
IndexDBTestStore: () => IndexDBTestStore
|
13227
|
+
});
|
13228
|
+
var loadExternal, IndexDBGateway, IndexDBTestStore;
|
13229
|
+
var init_gateway2 = __esm({
|
13230
|
+
"src/runtime/gateways/indexdb/gateway.ts"() {
|
13231
|
+
"use strict";
|
13232
|
+
init_cement();
|
13233
|
+
loadExternal = new ResolveOnce();
|
13234
|
+
IndexDBGateway = class {
|
13235
|
+
constructor(sthis) {
|
13236
|
+
this.sthis = sthis;
|
13237
|
+
}
|
13238
|
+
getGateway() {
|
13239
|
+
return loadExternal.once(() => {
|
13240
|
+
return Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1)).then(({ IndexDBGatewayImpl }) => new IndexDBGatewayImpl(this.sthis));
|
12997
13241
|
});
|
12998
13242
|
}
|
13243
|
+
buildUrl(baseUrl, key) {
|
13244
|
+
return this.getGateway().then((gw) => gw.buildUrl(baseUrl, key));
|
13245
|
+
}
|
13246
|
+
start(baseUrl) {
|
13247
|
+
return this.getGateway().then((gw) => gw.start(baseUrl));
|
13248
|
+
}
|
13249
|
+
close(baseUrl) {
|
13250
|
+
return this.getGateway().then((gw) => gw.close(baseUrl));
|
13251
|
+
}
|
13252
|
+
destroy(baseUrl) {
|
13253
|
+
return this.getGateway().then((gw) => gw.destroy(baseUrl));
|
13254
|
+
}
|
13255
|
+
put(url, body) {
|
13256
|
+
return this.getGateway().then((gw) => gw.put(url, body));
|
13257
|
+
}
|
13258
|
+
get(url) {
|
13259
|
+
return this.getGateway().then((gw) => gw.get(url));
|
13260
|
+
}
|
13261
|
+
delete(url) {
|
13262
|
+
return this.getGateway().then((gw) => gw.delete(url));
|
13263
|
+
}
|
13264
|
+
// subscribe?(url: URI, callback: (meta: Uint8Array) => void): Promise<UnsubscribeResult> {
|
13265
|
+
// // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
13266
|
+
// return this.getGateway().then(gw => gw.subscribe!(url, callback));
|
13267
|
+
// }
|
12999
13268
|
};
|
13000
13269
|
IndexDBTestStore = class {
|
13001
13270
|
constructor(sthis) {
|
13271
|
+
this.loadExternal = new ResolveOnce();
|
13002
13272
|
this.sthis = sthis;
|
13003
|
-
this.logger = ensureLogger(sthis, "IndexDBTestStore", {});
|
13004
13273
|
}
|
13005
|
-
|
13006
|
-
|
13007
|
-
|
13008
|
-
|
13009
|
-
|
13010
|
-
|
13011
|
-
|
13012
|
-
bytes = this.sthis.txt.encode(bytes);
|
13013
|
-
}
|
13014
|
-
return bytes;
|
13274
|
+
getGateway() {
|
13275
|
+
return this.loadExternal.once(() => {
|
13276
|
+
return Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1)).then(({ IndexDBTestStore: IndexDBTestStore2 }) => new IndexDBTestStore2(this.sthis));
|
13277
|
+
});
|
13278
|
+
}
|
13279
|
+
get(url, key) {
|
13280
|
+
return this.getGateway().then((gw) => gw.get(url, key));
|
13015
13281
|
}
|
13016
13282
|
};
|
13017
13283
|
}
|
@@ -26371,8 +26637,8 @@ You can use close({ resize: true }) to resize header`);
|
|
26371
26637
|
{
|
26372
26638
|
protocol: "file:",
|
26373
26639
|
factory: async (url, sthis) => {
|
26374
|
-
const { KeyBagProviderFile } = await Promise.resolve().then(() =>
|
26375
|
-
return new
|
26640
|
+
const { KeyBagProviderFile: KeyBagProviderFile2 } = await Promise.resolve().then(() => (init_key_bag_file(), key_bag_file_exports));
|
26641
|
+
return new KeyBagProviderFile2(url, sthis);
|
26376
26642
|
}
|
26377
26643
|
},
|
26378
26644
|
{
|
@@ -27261,7 +27527,7 @@ You can use close({ resize: true }) to resize header`);
|
|
27261
27527
|
async function decodeGatewayMetaBytesToDbMeta(sthis, byteHeads) {
|
27262
27528
|
const crdtEntries = JSON.parse(sthis.txt.decode(byteHeads));
|
27263
27529
|
if (!crdtEntries.length) {
|
27264
|
-
sthis.logger.Debug().
|
27530
|
+
sthis.logger.Debug().Any("byteHeads", byteHeads).Msg("No CRDT entries found");
|
27265
27531
|
return [];
|
27266
27532
|
}
|
27267
27533
|
if (!crdtEntries.map) {
|
@@ -27298,7 +27564,7 @@ You can use close({ resize: true }) to resize header`);
|
|
27298
27564
|
sthis.logger.Debug().Str("dbMeta.key", dbMeta.key).Str("uri", uri.toString()).Msg("Set crypto key from gateway meta payload");
|
27299
27565
|
return Result.Ok(dbMeta);
|
27300
27566
|
}
|
27301
|
-
sthis.logger.Debug().
|
27567
|
+
sthis.logger.Debug().Any("data", data).Msg("No crypto in gateway meta payload");
|
27302
27568
|
return Result.Ok(void 0);
|
27303
27569
|
} catch (error) {
|
27304
27570
|
sthis.logger.Debug().Err(error).Msg("Failed to set crypto key from gateway meta payload");
|
@@ -28131,22 +28397,22 @@ You can use close({ resize: true }) to resize header`);
|
|
28131
28397
|
registerStoreProtocol({
|
28132
28398
|
protocol: "file:",
|
28133
28399
|
gateway: async (sthis) => {
|
28134
|
-
const { FileGateway } = await Promise.resolve().then(() =>
|
28135
|
-
return new
|
28400
|
+
const { FileGateway: FileGateway2 } = await Promise.resolve().then(() => (init_gateway(), gateway_exports));
|
28401
|
+
return new FileGateway2(sthis);
|
28136
28402
|
},
|
28137
28403
|
test: async (sthis) => {
|
28138
|
-
const { FileTestStore } = await Promise.resolve().then(() =>
|
28139
|
-
return new
|
28404
|
+
const { FileTestStore: FileTestStore2 } = await Promise.resolve().then(() => (init_gateway(), gateway_exports));
|
28405
|
+
return new FileTestStore2(sthis);
|
28140
28406
|
}
|
28141
28407
|
});
|
28142
28408
|
registerStoreProtocol({
|
28143
28409
|
protocol: "indexdb:",
|
28144
28410
|
gateway: async (sthis) => {
|
28145
|
-
const { IndexDBGateway: IndexDBGateway2 } = await Promise.resolve().then(() => (
|
28411
|
+
const { IndexDBGateway: IndexDBGateway2 } = await Promise.resolve().then(() => (init_gateway2(), gateway_exports2));
|
28146
28412
|
return new IndexDBGateway2(sthis);
|
28147
28413
|
},
|
28148
28414
|
test: async (sthis) => {
|
28149
|
-
const { IndexDBTestStore: IndexDBTestStore2 } = await Promise.resolve().then(() => (
|
28415
|
+
const { IndexDBTestStore: IndexDBTestStore2 } = await Promise.resolve().then(() => (init_gateway2(), gateway_exports2));
|
28150
28416
|
return new IndexDBTestStore2(sthis);
|
28151
28417
|
}
|
28152
28418
|
});
|
@@ -30519,8 +30785,7 @@ You can use close({ resize: true }) to resize header`);
|
|
30519
30785
|
kb: () => key_bag_exports,
|
30520
30786
|
kc: () => keyed_crypto_exports,
|
30521
30787
|
mf: () => wait_pr_multiformats_exports,
|
30522
|
-
runtimeFn: () => runtimeFn
|
30523
|
-
toArrayBuffer: () => toArrayBuffer
|
30788
|
+
runtimeFn: () => runtimeFn
|
30524
30789
|
});
|
30525
30790
|
init_utils2();
|
30526
30791
|
|
@@ -30536,19 +30801,17 @@ You can use close({ resize: true }) to resize header`);
|
|
30536
30801
|
|
30537
30802
|
// src/runtime/index.ts
|
30538
30803
|
init_cement();
|
30539
|
-
|
30540
|
-
// src/runtime/gateways/file/version.ts
|
30541
|
-
var FILESTORE_VERSION = "v0.19-file";
|
30542
|
-
|
30543
|
-
// src/runtime/index.ts
|
30544
30804
|
init_version();
|
30545
30805
|
|
30806
|
+
// src/runtime/gateways/indexdb/version.ts
|
30807
|
+
var INDEXDB_VERSION = "v0.19-indexdb";
|
30808
|
+
|
30546
30809
|
// src/index.ts
|
30547
30810
|
init_utils();
|
30548
30811
|
|
30549
30812
|
// src/version.ts
|
30550
30813
|
var PACKAGE_VERSION = Object.keys({
|
30551
|
-
"0.19.
|
30814
|
+
"0.19.112-dev-iife": "xxxx"
|
30552
30815
|
})[0];
|
30553
30816
|
return __toCommonJS(src_exports6);
|
30554
30817
|
})();
|