@adviser/cement 0.4.0 → 0.4.2

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.
Files changed (79) hide show
  1. package/cf/index.cjs.map +1 -1
  2. package/cf/index.js +2 -2
  3. package/{chunk-YVACAIUX.js → chunk-C5L2FW7O.js} +5 -4
  4. package/chunk-C5L2FW7O.js.map +1 -0
  5. package/{chunk-YKGCONBX.js → chunk-MBLJQD6G.js} +9 -2
  6. package/chunk-MBLJQD6G.js.map +1 -0
  7. package/{chunk-6F3ACVHD.js → chunk-S5OZRDIH.js} +6 -5
  8. package/chunk-S5OZRDIH.js.map +1 -0
  9. package/{chunk-X3IV2RYT.js → chunk-XJ3SFZPE.js} +2 -2
  10. package/deno/index.cjs.map +1 -1
  11. package/deno/index.js +2 -2
  12. package/index.cjs +100 -51
  13. package/index.cjs.map +1 -1
  14. package/index.d.cts +10 -1
  15. package/index.d.ts +10 -1
  16. package/index.js +44 -5
  17. package/index.js.map +1 -1
  18. package/metafile-cjs.json +1 -1
  19. package/metafile-esm.json +1 -1
  20. package/node/index.cjs.map +1 -1
  21. package/node/index.js +2 -2
  22. package/package.json +2 -2
  23. package/src/coerce-binary.ts +39 -0
  24. package/src/index.ts +2 -0
  25. package/src/is-promise.ts +15 -0
  26. package/src/jsr.json +1 -1
  27. package/src/logger-impl.ts +1 -1
  28. package/src/logger.ts +2 -1
  29. package/src/result.ts +3 -1
  30. package/src/tracer.ts +2 -1
  31. package/src/utils/stream-map.ts +3 -1
  32. package/test/index.cjs +55 -49
  33. package/test/index.cjs.map +1 -1
  34. package/test/index.js +3 -3
  35. package/ts/src/coerce-binary.d.ts +6 -0
  36. package/ts/src/coerce-binary.d.ts.map +1 -0
  37. package/ts/src/coerce-binary.js +32 -0
  38. package/ts/src/coerce-binary.js.map +1 -0
  39. package/ts/src/coerce-binary.test.d.ts +2 -0
  40. package/ts/src/coerce-binary.test.d.ts.map +1 -0
  41. package/ts/src/coerce-binary.test.js +39 -0
  42. package/ts/src/coerce-binary.test.js.map +1 -0
  43. package/ts/src/index.d.ts +2 -0
  44. package/ts/src/index.d.ts.map +1 -1
  45. package/ts/src/index.js +2 -0
  46. package/ts/src/index.js.map +1 -1
  47. package/ts/src/is-promise.d.ts +3 -0
  48. package/ts/src/is-promise.d.ts.map +1 -0
  49. package/ts/src/is-promise.js +10 -0
  50. package/ts/src/is-promise.js.map +1 -0
  51. package/ts/src/is-promise.test.d.ts +2 -0
  52. package/ts/src/is-promise.test.d.ts.map +1 -0
  53. package/ts/src/is-promise.test.js +48 -0
  54. package/ts/src/is-promise.test.js.map +1 -0
  55. package/ts/src/logger-impl.d.ts +1 -1
  56. package/ts/src/logger-impl.d.ts.map +1 -1
  57. package/ts/src/logger-impl.js +1 -1
  58. package/ts/src/logger-impl.js.map +1 -1
  59. package/ts/src/logger.d.ts.map +1 -1
  60. package/ts/src/logger.js +2 -1
  61. package/ts/src/logger.js.map +1 -1
  62. package/ts/src/result.d.ts.map +1 -1
  63. package/ts/src/result.js +2 -1
  64. package/ts/src/result.js.map +1 -1
  65. package/ts/src/tracer.d.ts.map +1 -1
  66. package/ts/src/tracer.js +2 -1
  67. package/ts/src/tracer.js.map +1 -1
  68. package/ts/src/utils/stream-map.d.ts.map +1 -1
  69. package/ts/src/utils/stream-map.js +2 -1
  70. package/ts/src/utils/stream-map.js.map +1 -1
  71. package/utils/index.cjs +7 -1
  72. package/utils/index.cjs.map +1 -1
  73. package/utils/index.js +2 -2
  74. package/web/index.cjs.map +1 -1
  75. package/web/index.js +2 -2
  76. package/chunk-6F3ACVHD.js.map +0 -1
  77. package/chunk-YKGCONBX.js.map +0 -1
  78. package/chunk-YVACAIUX.js.map +0 -1
  79. /package/{chunk-X3IV2RYT.js.map → chunk-XJ3SFZPE.js.map} +0 -0
package/index.cjs CHANGED
@@ -99,6 +99,7 @@ __export(index_exports, {
99
99
  exception2Result: () => exception2Result,
100
100
  hasHostPartProtocols: () => hasHostPartProtocols,
101
101
  isCoerceURI: () => isCoerceURI,
102
+ isPromise: () => isPromise,
102
103
  isURL: () => isURL,
103
104
  logValue: () => logValue,
104
105
  param: () => param,
@@ -106,6 +107,10 @@ __export(index_exports, {
106
107
  registerEnvAction: () => registerEnvAction,
107
108
  runtimeFn: () => runtimeFn,
108
109
  toCryptoRuntime: () => toCryptoRuntime,
110
+ to_arraybuf: () => to_arraybuf,
111
+ to_blob: () => to_blob,
112
+ to_uint8: () => to_uint8,
113
+ top_uint8: () => top_uint8,
109
114
  utils: () => utils_exports
110
115
  });
111
116
  module.exports = __toCommonJS(index_exports);
@@ -113,6 +118,12 @@ module.exports = __toCommonJS(index_exports);
113
118
  // src/logger-impl.ts
114
119
  var import_yaml = __toESM(require("yaml"), 1);
115
120
 
121
+ // src/is-promise.ts
122
+ function isPromise(a) {
123
+ const mayBe = a;
124
+ return mayBe instanceof Promise || !!(mayBe && mayBe !== null && typeof mayBe.then === "function" && typeof mayBe.catch === "function" && typeof mayBe.finally === "function");
125
+ }
126
+
116
127
  // src/bin2text.ts
117
128
  function bin2text(hex, lineFn, size = 0) {
118
129
  const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
@@ -247,7 +258,7 @@ function logValueInternal(val, ctx) {
247
258
  if (val instanceof ReadableStream) {
248
259
  return new LogValue(() => ">Stream<");
249
260
  }
250
- if (val instanceof Promise) {
261
+ if (isPromise(val)) {
251
262
  return new LogValue(() => ">Promise<");
252
263
  }
253
264
  if ((_a = ctx.state) == null ? void 0 : _a.has(val)) {
@@ -384,7 +395,7 @@ var ResultError = class extends Result {
384
395
  function exception2Result(fn) {
385
396
  try {
386
397
  const res = fn();
387
- if (res instanceof Promise) {
398
+ if (isPromise(res)) {
388
399
  return res.then((value) => Result.Ok(value)).catch((e) => Result.Err(e));
389
400
  }
390
401
  return Result.Ok(res);
@@ -1118,53 +1129,6 @@ var URI = class _URI {
1118
1129
  }
1119
1130
  };
1120
1131
 
1121
- // src/log-writer-impl.ts
1122
- var LogWriterStream = class {
1123
- constructor(out) {
1124
- this._toFlush = [];
1125
- this._flushIsRunning = false;
1126
- this._flushDoneFns = [];
1127
- this._out = out;
1128
- this._id = Math.random();
1129
- }
1130
- write(encoded) {
1131
- const my = async () => {
1132
- try {
1133
- const writer = this._out.getWriter();
1134
- await writer.ready;
1135
- await writer.write(encoded);
1136
- writer.releaseLock();
1137
- } catch (err) {
1138
- console.error("Chunk error:", err);
1139
- }
1140
- };
1141
- this._toFlush.push(my);
1142
- this._flush();
1143
- }
1144
- _flush(toFlush = void 0, done) {
1145
- if (done) {
1146
- this._flushDoneFns.push(done);
1147
- }
1148
- if (this._toFlush.length == 0) {
1149
- this._flushIsRunning = false;
1150
- this._flushDoneFns.forEach((fn) => fn());
1151
- this._flushDoneFns = [];
1152
- return;
1153
- }
1154
- if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
1155
- this._flushIsRunning = true;
1156
- } else if (!toFlush) {
1157
- return;
1158
- }
1159
- const my = this._toFlush.shift();
1160
- my == null ? void 0 : my().catch((e) => {
1161
- console.error("Flush error:", e);
1162
- }).finally(() => {
1163
- this._flush(this._toFlush);
1164
- });
1165
- }
1166
- };
1167
-
1168
1132
  // src/future.ts
1169
1133
  var _promise, _resolveFn, _rejectFn;
1170
1134
  var Future = class {
@@ -2541,6 +2505,53 @@ var WrapperRuntimeSysAbstraction = class extends WrapperBasicSysAbstraction {
2541
2505
  }
2542
2506
  };
2543
2507
 
2508
+ // src/log-writer-impl.ts
2509
+ var LogWriterStream = class {
2510
+ constructor(out) {
2511
+ this._toFlush = [];
2512
+ this._flushIsRunning = false;
2513
+ this._flushDoneFns = [];
2514
+ this._out = out;
2515
+ this._id = Math.random();
2516
+ }
2517
+ write(encoded) {
2518
+ const my = async () => {
2519
+ try {
2520
+ const writer = this._out.getWriter();
2521
+ await writer.ready;
2522
+ await writer.write(encoded);
2523
+ writer.releaseLock();
2524
+ } catch (err) {
2525
+ console.error("Chunk error:", err);
2526
+ }
2527
+ };
2528
+ this._toFlush.push(my);
2529
+ this._flush();
2530
+ }
2531
+ _flush(toFlush = void 0, done) {
2532
+ if (done) {
2533
+ this._flushDoneFns.push(done);
2534
+ }
2535
+ if (this._toFlush.length == 0) {
2536
+ this._flushIsRunning = false;
2537
+ this._flushDoneFns.forEach((fn) => fn());
2538
+ this._flushDoneFns = [];
2539
+ return;
2540
+ }
2541
+ if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
2542
+ this._flushIsRunning = true;
2543
+ } else if (!toFlush) {
2544
+ return;
2545
+ }
2546
+ const my = this._toFlush.shift();
2547
+ my == null ? void 0 : my().catch((e) => {
2548
+ console.error("Flush error:", e);
2549
+ }).finally(() => {
2550
+ this._flush(this._toFlush);
2551
+ });
2552
+ }
2553
+ };
2554
+
2544
2555
  // src/logger-impl.ts
2545
2556
  function getLen(value, lvs) {
2546
2557
  if (Array.isArray(value)) {
@@ -3280,7 +3291,7 @@ var TraceNode = class _TraceNode {
3280
3291
  spanTrace.invokations.push(invokation);
3281
3292
  try {
3282
3293
  const possiblePromise = fn(spanTrace);
3283
- if (possiblePromise instanceof Promise) {
3294
+ if (isPromise(possiblePromise)) {
3284
3295
  return possiblePromise.then((v) => {
3285
3296
  return v;
3286
3297
  }).catch((e) => {
@@ -3560,6 +3571,39 @@ function JSONEnDecoderSingleton(txtEnde) {
3560
3571
  return jsonEnDecoder;
3561
3572
  }
3562
3573
 
3574
+ // src/coerce-binary.ts
3575
+ async function top_uint8(input) {
3576
+ if (input instanceof Blob) {
3577
+ return new Uint8Array(await input.arrayBuffer());
3578
+ }
3579
+ return to_uint8(input);
3580
+ }
3581
+ function to_uint8(input, encoder) {
3582
+ if (typeof input === "string") {
3583
+ return (encoder != null ? encoder : new TextEncoder()).encode(input);
3584
+ }
3585
+ if (input instanceof ArrayBuffer) {
3586
+ return new Uint8Array(input);
3587
+ }
3588
+ if (input instanceof Uint8Array) {
3589
+ return input;
3590
+ }
3591
+ return new Uint8Array(input);
3592
+ }
3593
+ function to_blob(input, encoder) {
3594
+ if (input instanceof Blob) {
3595
+ return input;
3596
+ }
3597
+ return new Blob([to_uint8(input, encoder)]);
3598
+ }
3599
+ function to_arraybuf(input, encoder) {
3600
+ if (input instanceof ArrayBuffer) {
3601
+ return input;
3602
+ }
3603
+ const u8 = to_uint8(input, encoder);
3604
+ return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
3605
+ }
3606
+
3563
3607
  // src/utils/index.ts
3564
3608
  var utils_exports = {};
3565
3609
  __export(utils_exports, {
@@ -3601,7 +3645,7 @@ function streamMap(s, sm) {
3601
3645
  }
3602
3646
  const promiseOrU = state.streamMap.Map(value, state.idx++);
3603
3647
  let mapped;
3604
- if (promiseOrU instanceof Promise || typeof promiseOrU.then === "function") {
3648
+ if (isPromise(promiseOrU)) {
3605
3649
  mapped = await promiseOrU;
3606
3650
  } else {
3607
3651
  mapped = promiseOrU;
@@ -3859,6 +3903,7 @@ function UInt8ArrayEqual(a, b) {
3859
3903
  exception2Result,
3860
3904
  hasHostPartProtocols,
3861
3905
  isCoerceURI,
3906
+ isPromise,
3862
3907
  isURL,
3863
3908
  logValue,
3864
3909
  param,
@@ -3866,6 +3911,10 @@ function UInt8ArrayEqual(a, b) {
3866
3911
  registerEnvAction,
3867
3912
  runtimeFn,
3868
3913
  toCryptoRuntime,
3914
+ to_arraybuf,
3915
+ to_blob,
3916
+ to_uint8,
3917
+ top_uint8,
3869
3918
  utils
3870
3919
  });
3871
3920
  //# sourceMappingURL=index.cjs.map