@fireproof/core 0.19.111 → 0.19.112-dev-web

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/{chunk-OFGPKRCM.js → chunk-GZANCVTS.js} +3 -1
  2. package/chunk-GZANCVTS.js.map +1 -0
  3. package/{chunk-WS3YRPIA.js → chunk-LNFBDD6E.js} +4 -4
  4. package/chunk-LNFBDD6E.js.map +1 -0
  5. package/deno.json +1 -2
  6. package/{gateway-H7UD6TNB.js → gateway@skip-esm-O655UEIP.js} +3 -3
  7. package/gateway@skip-esm-O655UEIP.js.map +1 -0
  8. package/{gateway-5FCWPX5W.js → gateway@skip-iife-OZ2V32XH.js} +5 -5
  9. package/gateway@skip-iife-OZ2V32XH.js.map +1 -0
  10. package/index.cjs +32 -30
  11. package/index.cjs.map +1 -1
  12. package/index.global.js +417 -178
  13. package/index.global.js.map +1 -1
  14. package/index.js +11 -11
  15. package/index.js.map +1 -1
  16. package/{key-bag-file-WADZBHYG.js → key-bag-file-4TYN2H7F.js} +3 -3
  17. package/{key-bag-indexdb-PGVAI3FJ.js → key-bag-indexdb-JEOAS4WM.js} +3 -3
  18. package/{mem-filesystem-YPPJV7Q2.js → mem-filesystem@skip-iife-CJI7IIKV.js} +4 -4
  19. package/mem-filesystem@skip-iife-CJI7IIKV.js.map +1 -0
  20. package/metafile-cjs.json +1 -1
  21. package/metafile-esm.json +1 -1
  22. package/metafile-iife.json +1 -1
  23. package/{node-filesystem-INX4ZTHE.js → node-filesystem@skip-iife-O74VAABQ.js} +4 -4
  24. package/node-filesystem@skip-iife-O74VAABQ.js.map +1 -0
  25. package/package.json +15 -6
  26. package/tests/blockstore/keyed-crypto.test.ts +2 -2
  27. package/tests/blockstore/store.test.ts +3 -5
  28. package/tests/fireproof/all-gateway.test.ts +11 -9
  29. package/{utils-QO2HIWGI.js → utils-L7MUZUJX.js} +3 -3
  30. package/web/bundle-not-impl-UH74NK5L.js +5 -0
  31. package/web/bundle-not-impl-UH74NK5L.js.map +1 -0
  32. package/web/chunk-2DC5ZIR4.js +7 -0
  33. package/web/chunk-2DC5ZIR4.js.map +1 -0
  34. package/web/chunk-Q5W7UNMP.js +292 -0
  35. package/web/chunk-Q5W7UNMP.js.map +1 -0
  36. package/web/chunk-S4HRSKEO.js +75 -0
  37. package/web/chunk-S4HRSKEO.js.map +1 -0
  38. package/web/gateway@skip-esm-GI5PRACF.js +165 -0
  39. package/web/gateway@skip-esm-GI5PRACF.js.map +1 -0
  40. package/web/index.cjs +4138 -0
  41. package/web/index.cjs.map +1 -0
  42. package/web/index.d.cts +1139 -0
  43. package/web/index.d.ts +1139 -0
  44. package/web/index.js +3478 -0
  45. package/web/index.js.map +1 -0
  46. package/web/key-bag-file-4SJQGORQ.js +54 -0
  47. package/web/key-bag-file-4SJQGORQ.js.map +1 -0
  48. package/web/key-bag-indexdb-GSQOUUVQ.js +50 -0
  49. package/web/key-bag-indexdb-GSQOUUVQ.js.map +1 -0
  50. package/web/metafile-cjs.json +1 -0
  51. package/web/metafile-esm.json +1 -0
  52. package/web/utils-EFZJNXH5.js +14 -0
  53. package/web/utils-EFZJNXH5.js.map +1 -0
  54. package/chunk-OFGPKRCM.js.map +0 -1
  55. package/chunk-WS3YRPIA.js.map +0 -1
  56. package/gateway-5FCWPX5W.js.map +0 -1
  57. package/gateway-H7UD6TNB.js.map +0 -1
  58. package/mem-filesystem-YPPJV7Q2.js.map +0 -1
  59. package/node-filesystem-INX4ZTHE.js.map +0 -1
  60. /package/{key-bag-file-WADZBHYG.js.map → key-bag-file-4TYN2H7F.js.map} +0 -0
  61. /package/{key-bag-indexdb-PGVAI3FJ.js.map → key-bag-indexdb-JEOAS4WM.js.map} +0 -0
  62. /package/{utils-QO2HIWGI.js.map → utils-L7MUZUJX.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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-GES3MUGV.js
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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-GES3MUGV.js"() {
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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-7KFVMTOS.js
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 init_chunk_7KFVMTOS = __esm({
265
- "node_modules/.pnpm/@adviser+cement@0.2.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-7KFVMTOS.js"() {
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
- const str = this.decoder.decode(chunk).trimEnd();
305
+ let strObj = this.decoder.decode(chunk).trimEnd();
306
306
  let output = "log";
307
307
  try {
308
- const decode17 = JSON.parse(str);
309
- output = decode17.level;
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(str);
314
+ console.error(strObj);
315
315
  break;
316
316
  case "warn":
317
- console.warn(str);
317
+ console.warn(strObj);
318
318
  break;
319
319
  default:
320
- console.log(str);
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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-Q65HLCNL.js
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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-Q65HLCNL.js"() {
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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-WMMUXBDX.js
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.31_typescript@5.6.2/node_modules/@adviser/cement/chunk-WMMUXBDX.js"() {
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.31_typescript@5.6.2/node_modules/@adviser/cement/index.js
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 === null) {
8186
- return new LogValue(() => "null");
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
- res[key] = logValue(element, state);
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.31_typescript@5.6.2/node_modules/@adviser/cement/index.js"() {
8469
+ "node_modules/.pnpm/@adviser+cement@0.2.36_typescript@5.6.2/node_modules/@adviser/cement/index.js"() {
8357
8470
  "use strict";
8358
- init_chunk_7KFVMTOS();
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
- return this.fn();
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
- getParam(key) {
8613
- return falsy2undef(this._url.searchParams.get(key));
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
- return falsy2undef(this._url.searchParams.get(key));
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
- return this._txtEnDe.encode(JSON.stringify(attr, removeSelfRef(), this._space) + "\n");
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, removeSelfRef(), this._space) + "\n");
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, removeSelfRef()));
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._attributes[key] = logValue(!!value);
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._attributes[key] = logValue(value);
9266
+ this.coerceKey(key, value);
9057
9267
  return this;
9058
9268
  }
9059
9269
  Any(key, value) {
9060
- this._attributes[key] = logValue(value);
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._attributes[key] = logValue(value);
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
- AsError: () => new Error(this._txtEnDe.decode(fnError()))
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,141 @@ ${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
+ toArrayBuffer: () => toArrayBuffer
12436
+ });
12437
+ async function getFileSystem(url) {
12438
+ const name6 = url.getParam("fs");
12439
+ let fs;
12440
+ switch (name6) {
12441
+ case "mem":
12442
+ {
12443
+ const { MemFileSystem } = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
12444
+ fs = new MemFileSystem();
12445
+ }
12446
+ break;
12447
+ // case 'deno': {
12448
+ // const { DenoFileSystem } = await import("./deno-filesystem.js");
12449
+ // fs = new DenoFileSystem();
12450
+ // break;
12451
+ // }
12452
+ case "node": {
12453
+ const { NodeFileSystem } = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
12454
+ fs = new NodeFileSystem();
12455
+ break;
12456
+ }
12457
+ case "sys":
12458
+ default: {
12459
+ return getFileSystem(url.build().setParam("fs", "node").URI());
12460
+ }
12461
+ }
12462
+ return fs.start();
12463
+ }
12464
+ function getPath(url, sthis) {
12465
+ const basePath = url.pathname;
12466
+ const name6 = url.getParam("name");
12467
+ if (name6) {
12468
+ const version = url.getParam("version");
12469
+ if (!version) throw sthis.logger.Error().Url(url).Msg(`version not found`).AsError();
12470
+ return sthis.pathOps.join(basePath, version, name6);
12471
+ }
12472
+ return sthis.pathOps.join(basePath);
12473
+ }
12474
+ function getFileName(url, sthis) {
12475
+ const key = url.getParam("key");
12476
+ if (!key) throw sthis.logger.Error().Url(url).Msg(`key not found`).AsError();
12477
+ const res = getStore(url, sthis, (...a) => a.join("-"));
12478
+ switch (res.store) {
12479
+ case "data":
12480
+ return sthis.pathOps.join(res.name, key + ".car");
12481
+ case "wal":
12482
+ case "meta":
12483
+ return sthis.pathOps.join(res.name, key + ".json");
12484
+ default:
12485
+ throw sthis.logger.Error().Url(url).Msg(`unsupported store type`).AsError();
12486
+ }
12487
+ }
12488
+ function toArrayBuffer(buffer2) {
12489
+ if (typeof buffer2 === "string") {
12490
+ buffer2 = Buffer.from(buffer2);
12491
+ }
12492
+ const ab = new ArrayBuffer(buffer2.length);
12493
+ const view = new Uint8Array(ab);
12494
+ for (let i = 0; i < buffer2.length; ++i) {
12495
+ view[i] = buffer2[i];
12496
+ }
12497
+ return view;
12498
+ }
12499
+ var init_utils2 = __esm({
12500
+ "src/runtime/gateways/file/utils.ts"() {
12501
+ "use strict";
12502
+ init_utils();
12503
+ }
12504
+ });
12505
+
12506
+ // src/runtime/key-bag-file.ts
12507
+ var key_bag_file_exports = {};
12508
+ __export(key_bag_file_exports, {
12509
+ KeyBagProviderFile: () => KeyBagProviderFile
12510
+ });
12511
+ var KeyBagProviderFile;
12512
+ var init_key_bag_file = __esm({
12513
+ "src/runtime/key-bag-file.ts"() {
12514
+ "use strict";
12515
+ init_utils();
12516
+ KeyBagProviderFile = class {
12517
+ async _prepare(id) {
12518
+ await this.sthis.start();
12519
+ let sysFS;
12520
+ switch (this.url.protocol) {
12521
+ case "file:": {
12522
+ const { getFileSystem: getFileSystem2 } = await Promise.resolve().then(() => (init_utils2(), utils_exports2));
12523
+ sysFS = await getFileSystem2(this.url);
12524
+ break;
12525
+ }
12526
+ default:
12527
+ throw this.logger.Error().Url(this.url).Msg("unsupported protocol").AsError();
12528
+ }
12529
+ const dirName = this.url.pathname;
12530
+ await sysFS.mkdir(dirName, { recursive: true });
12531
+ return {
12532
+ dirName,
12533
+ sysFS,
12534
+ fName: this.sthis.pathOps.join(dirName, `${id.replace(/[^a-zA-Z0-9]/g, "_")}.json`)
12535
+ };
12536
+ }
12537
+ constructor(url, sthis) {
12538
+ this.url = url;
12539
+ this.sthis = sthis;
12540
+ this.logger = sthis.logger;
12541
+ }
12542
+ async get(id) {
12543
+ const ctx = await this._prepare(id);
12544
+ try {
12545
+ const p = await ctx.sysFS.readfile(ctx.fName);
12546
+ const ki = JSON.parse(this.sthis.txt.decode(p));
12547
+ return ki;
12548
+ } catch (e) {
12549
+ if (isNotFoundError(e)) {
12550
+ return void 0;
12551
+ }
12552
+ throw this.logger.Error().Err(e).Str("file", ctx.dirName).Msg("read bag failed").AsError();
12553
+ }
12554
+ }
12555
+ async set(id, item) {
12556
+ const ctx = await this._prepare(id);
12557
+ const p = this.sthis.txt.encode(JSON.stringify(item, null, 2));
12558
+ await ctx.sysFS.writefile(ctx.fName, p);
12559
+ }
12560
+ };
12561
+ }
12562
+ });
12563
+
12207
12564
  // node_modules/.pnpm/idb@8.0.0/node_modules/idb/build/index.js
12208
12565
  function getIdbProxyableTypes() {
12209
12566
  return idbProxyableTypes || (idbProxyableTypes = [
@@ -12443,124 +12800,6 @@ ${end.comment}` : end.comment;
12443
12800
  }
12444
12801
  });
12445
12802
 
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
12803
  // src/runtime/key-bag-indexdb.ts
12565
12804
  var key_bag_indexdb_exports = {};
12566
12805
  __export(key_bag_indexdb_exports, {
@@ -12854,9 +13093,9 @@ ${end.comment}` : end.comment;
12854
13093
  }
12855
13094
  });
12856
13095
 
12857
- // src/runtime/gateways/indexdb/gateway.ts
12858
- var gateway_exports = {};
12859
- __export(gateway_exports, {
13096
+ // src/runtime/gateways/indexdb/gateway@skip-esm.ts
13097
+ var gateway_skip_esm_exports = {};
13098
+ __export(gateway_skip_esm_exports, {
12860
13099
  IndexDBGateway: () => IndexDBGateway,
12861
13100
  IndexDBTestStore: () => IndexDBTestStore,
12862
13101
  getIndexDBName: () => getIndexDBName
@@ -12915,8 +13154,8 @@ ${end.comment}` : end.comment;
12915
13154
  };
12916
13155
  }
12917
13156
  var onceIndexDB, IndexDBGateway, IndexDBTestStore;
12918
- var init_gateway = __esm({
12919
- "src/runtime/gateways/indexdb/gateway.ts"() {
13157
+ var init_gateway_skip_esm = __esm({
13158
+ "src/runtime/gateways/indexdb/gateway@skip-esm.ts"() {
12920
13159
  "use strict";
12921
13160
  init_build();
12922
13161
  init_cement();
@@ -26371,8 +26610,8 @@ You can use close({ resize: true }) to resize header`);
26371
26610
  {
26372
26611
  protocol: "file:",
26373
26612
  factory: async (url, sthis) => {
26374
- const { KeyBagProviderFile } = await Promise.resolve().then(() => __toESM(require_bundle_not_impl(), 1));
26375
- return new KeyBagProviderFile(url, sthis);
26613
+ const { KeyBagProviderFile: KeyBagProviderFile2 } = await Promise.resolve().then(() => (init_key_bag_file(), key_bag_file_exports));
26614
+ return new KeyBagProviderFile2(url, sthis);
26376
26615
  }
26377
26616
  },
26378
26617
  {
@@ -27261,7 +27500,7 @@ You can use close({ resize: true }) to resize header`);
27261
27500
  async function decodeGatewayMetaBytesToDbMeta(sthis, byteHeads) {
27262
27501
  const crdtEntries = JSON.parse(sthis.txt.decode(byteHeads));
27263
27502
  if (!crdtEntries.length) {
27264
- sthis.logger.Debug().Str("byteHeads", new TextDecoder().decode(byteHeads)).Msg("No CRDT entries found");
27503
+ sthis.logger.Debug().Any("byteHeads", byteHeads).Msg("No CRDT entries found");
27265
27504
  return [];
27266
27505
  }
27267
27506
  if (!crdtEntries.map) {
@@ -27298,7 +27537,7 @@ You can use close({ resize: true }) to resize header`);
27298
27537
  sthis.logger.Debug().Str("dbMeta.key", dbMeta.key).Str("uri", uri.toString()).Msg("Set crypto key from gateway meta payload");
27299
27538
  return Result.Ok(dbMeta);
27300
27539
  }
27301
- sthis.logger.Debug().Str("data", new TextDecoder().decode(data)).Msg("No crypto in gateway meta payload");
27540
+ sthis.logger.Debug().Any("data", data).Msg("No crypto in gateway meta payload");
27302
27541
  return Result.Ok(void 0);
27303
27542
  } catch (error) {
27304
27543
  sthis.logger.Debug().Err(error).Msg("Failed to set crypto key from gateway meta payload");
@@ -28142,11 +28381,11 @@ You can use close({ resize: true }) to resize header`);
28142
28381
  registerStoreProtocol({
28143
28382
  protocol: "indexdb:",
28144
28383
  gateway: async (sthis) => {
28145
- const { IndexDBGateway: IndexDBGateway2 } = await Promise.resolve().then(() => (init_gateway(), gateway_exports));
28384
+ const { IndexDBGateway: IndexDBGateway2 } = await Promise.resolve().then(() => (init_gateway_skip_esm(), gateway_skip_esm_exports));
28146
28385
  return new IndexDBGateway2(sthis);
28147
28386
  },
28148
28387
  test: async (sthis) => {
28149
- const { IndexDBTestStore: IndexDBTestStore2 } = await Promise.resolve().then(() => (init_gateway(), gateway_exports));
28388
+ const { IndexDBTestStore: IndexDBTestStore2 } = await Promise.resolve().then(() => (init_gateway_skip_esm(), gateway_skip_esm_exports));
28150
28389
  return new IndexDBTestStore2(sthis);
28151
28390
  }
28152
28391
  });
@@ -30548,7 +30787,7 @@ You can use close({ resize: true }) to resize header`);
30548
30787
 
30549
30788
  // src/version.ts
30550
30789
  var PACKAGE_VERSION = Object.keys({
30551
- "0.19.111": "xxxx"
30790
+ "0.19.112-dev-web": "xxxx"
30552
30791
  })[0];
30553
30792
  return __toCommonJS(src_exports6);
30554
30793
  })();