@adviser/cement 0.2.41 → 0.2.42

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 (58) hide show
  1. package/{chunk-USQXEZHL.js → chunk-3RHIVQAA.js} +2 -2
  2. package/{chunk-W2GV5KXV.js → chunk-N3NUTN4B.js} +3 -3
  3. package/{chunk-F5W6VELE.js → chunk-N5LQQXOU.js} +2 -2
  4. package/chunk-PPS4L4VW.js +38 -0
  5. package/{chunk-GES3MUGV.js.map → chunk-PPS4L4VW.js.map} +1 -1
  6. package/index.cjs +352 -86
  7. package/index.cjs.map +1 -1
  8. package/index.d.cts +31 -1
  9. package/index.d.ts +31 -1
  10. package/index.js +355 -44
  11. package/index.js.map +1 -1
  12. package/node/index.js +2 -2
  13. package/package.json +2 -2
  14. package/src/http_header.ts +161 -0
  15. package/src/index.ts +1 -0
  16. package/src/jsr.json +1 -1
  17. package/src/uri.ts +31 -9
  18. package/src/utils/relative-path.ts +161 -0
  19. package/ts/http_header.d.ts +29 -0
  20. package/ts/http_header.d.ts.map +1 -0
  21. package/ts/http_header.js +155 -0
  22. package/ts/http_header.js.map +1 -0
  23. package/ts/http_header.test.d.ts +2 -0
  24. package/ts/http_header.test.d.ts.map +1 -0
  25. package/ts/http_header.test.js +90 -0
  26. package/ts/http_header.test.js.map +1 -0
  27. package/ts/index.d.ts +1 -0
  28. package/ts/index.d.ts.map +1 -1
  29. package/ts/index.js +1 -0
  30. package/ts/index.js.map +1 -1
  31. package/ts/logger-impl.js +8 -5
  32. package/ts/logger-impl.js.map +1 -1
  33. package/ts/logger.js +9 -3
  34. package/ts/logger.js.map +1 -1
  35. package/ts/tracer.js +24 -6
  36. package/ts/tracer.js.map +1 -1
  37. package/ts/uri.d.ts +1 -0
  38. package/ts/uri.d.ts.map +1 -1
  39. package/ts/uri.js +26 -10
  40. package/ts/uri.js.map +1 -1
  41. package/ts/uri.test.js +34 -5
  42. package/ts/uri.test.js.map +1 -1
  43. package/ts/utils/relative-path.d.ts +17 -0
  44. package/ts/utils/relative-path.d.ts.map +1 -0
  45. package/ts/utils/relative-path.js +148 -0
  46. package/ts/utils/relative-path.js.map +1 -0
  47. package/ts/utils/relative-path.test.d.ts +2 -0
  48. package/ts/utils/relative-path.test.d.ts.map +1 -0
  49. package/ts/utils/relative-path.test.js +187 -0
  50. package/ts/utils/relative-path.test.js.map +1 -0
  51. package/ts/utils/stripper.js +1 -1
  52. package/ts/utils/stripper.js.map +1 -1
  53. package/utils/index.js +2 -2
  54. package/web/index.js +3 -3
  55. package/chunk-GES3MUGV.js +0 -92
  56. /package/{chunk-USQXEZHL.js.map → chunk-3RHIVQAA.js.map} +0 -0
  57. /package/{chunk-W2GV5KXV.js.map → chunk-N3NUTN4B.js.map} +0 -0
  58. /package/{chunk-F5W6VELE.js.map → chunk-N5LQQXOU.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Utf8EnDecoderSingleton,
3
3
  __export
4
- } from "./chunk-GES3MUGV.js";
4
+ } from "./chunk-PPS4L4VW.js";
5
5
 
6
6
  // src/utils/index.ts
7
7
  var utils_exports = {};
@@ -308,4 +308,4 @@ export {
308
308
  uint8array2stream,
309
309
  utils_exports
310
310
  };
311
- //# sourceMappingURL=chunk-USQXEZHL.js.map
311
+ //# sourceMappingURL=chunk-3RHIVQAA.js.map
@@ -2,10 +2,10 @@ import {
2
2
  BaseSysAbstraction,
3
3
  WrapperSysAbstraction,
4
4
  envFactory
5
- } from "./chunk-F5W6VELE.js";
5
+ } from "./chunk-N5LQQXOU.js";
6
6
  import {
7
7
  Utf8EnDecoderSingleton
8
- } from "./chunk-GES3MUGV.js";
8
+ } from "./chunk-PPS4L4VW.js";
9
9
 
10
10
  // src/web/web-sys-abstraction.ts
11
11
  var WebFileService = class {
@@ -84,4 +84,4 @@ function WebSysAbstraction(param) {
84
84
  export {
85
85
  WebSysAbstraction
86
86
  };
87
- //# sourceMappingURL=chunk-W2GV5KXV.js.map
87
+ //# sourceMappingURL=chunk-N3NUTN4B.js.map
@@ -2,7 +2,7 @@ import {
2
2
  __privateAdd,
3
3
  __privateGet,
4
4
  __privateSet
5
- } from "./chunk-GES3MUGV.js";
5
+ } from "./chunk-PPS4L4VW.js";
6
6
 
7
7
  // src/sys-abstraction.ts
8
8
  var TimeMode = /* @__PURE__ */ ((TimeMode2) => {
@@ -607,4 +607,4 @@ export {
607
607
  envFactory,
608
608
  EnvImpl
609
609
  };
610
- //# sourceMappingURL=chunk-F5W6VELE.js.map
610
+ //# sourceMappingURL=chunk-N5LQQXOU.js.map
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
10
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
11
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
12
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
13
+
14
+ // src/txt-en-decoder.ts
15
+ var encoder = new TextEncoder();
16
+ var decoder = new TextDecoder();
17
+ var Utf8EnDecoder = class {
18
+ encode(str) {
19
+ return encoder.encode(str);
20
+ }
21
+ decode(data) {
22
+ return decoder.decode(data);
23
+ }
24
+ };
25
+ var utf8EnDecoder = new Utf8EnDecoder();
26
+ function Utf8EnDecoderSingleton() {
27
+ return utf8EnDecoder;
28
+ }
29
+
30
+ export {
31
+ __export,
32
+ __privateGet,
33
+ __privateAdd,
34
+ __privateSet,
35
+ Utf8EnDecoder,
36
+ Utf8EnDecoderSingleton
37
+ };
38
+ //# sourceMappingURL=chunk-PPS4L4VW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/txt-en-decoder.ts"],"sourcesContent":["export interface TxtEnDecoder {\n encode(str: string): Uint8Array;\n decode(data: Uint8Array): string;\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport class Utf8EnDecoder implements TxtEnDecoder {\n encode(str: string): Uint8Array {\n return encoder.encode(str);\n }\n decode(data: Uint8Array): string {\n return decoder.decode(data);\n }\n}\n\nconst utf8EnDecoder = new Utf8EnDecoder();\nexport function Utf8EnDecoderSingleton(): TxtEnDecoder {\n return utf8EnDecoder;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAEzB,IAAM,gBAAN,MAA4C;AAAA,EACjD,OAAO,KAAyB;AAC9B,WAAO,QAAQ,OAAO,GAAG;AAAA,EAC3B;AAAA,EACA,OAAO,MAA0B;AAC/B,WAAO,QAAQ,OAAO,IAAI;AAAA,EAC5B;AACF;AAEA,IAAM,gBAAgB,IAAI,cAAc;AACjC,SAAS,yBAAuC;AACrD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/txt-en-decoder.ts"],"sourcesContent":["export interface TxtEnDecoder {\n encode(str: string): Uint8Array;\n decode(data: Uint8Array): string;\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport class Utf8EnDecoder implements TxtEnDecoder {\n encode(str: string): Uint8Array {\n return encoder.encode(str);\n }\n decode(data: Uint8Array): string {\n return decoder.decode(data);\n }\n}\n\nconst utf8EnDecoder = new Utf8EnDecoder();\nexport function Utf8EnDecoderSingleton(): TxtEnDecoder {\n return utf8EnDecoder;\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAEzB,IAAM,gBAAN,MAA4C;AAAA,EACjD,OAAO,KAAyB;AAC9B,WAAO,QAAQ,OAAO,GAAG;AAAA,EAC3B;AAAA,EACA,OAAO,MAA0B;AAC/B,WAAO,QAAQ,OAAO,IAAI;AAAA,EAC5B;AACF;AAEA,IAAM,gBAAgB,IAAI,cAAc;AACjC,SAAS,yBAAuC;AACrD,SAAO;AACT;","names":[]}
package/index.cjs CHANGED
@@ -1,31 +1,13 @@
1
1
  "use strict";
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
6
  var __getProtoOf = Object.getPrototypeOf;
10
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
13
8
  var __typeError = (msg) => {
14
9
  throw TypeError(msg);
15
10
  };
16
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
- var __spreadValues = (a, b) => {
18
- for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- if (__getOwnPropSymbols)
22
- for (var prop of __getOwnPropSymbols(b)) {
23
- if (__propIsEnum.call(b, prop))
24
- __defNormalProp(a, prop, b[prop]);
25
- }
26
- return a;
27
- };
28
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
29
11
  var __export = (target, all) => {
30
12
  for (var name in all)
31
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -51,38 +33,6 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
51
33
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
52
34
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53
35
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
54
- var __await = function(promise, isYieldStar) {
55
- this[0] = promise;
56
- this[1] = isYieldStar;
57
- };
58
- var __yieldStar = (value) => {
59
- var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
60
- if (obj == null) {
61
- obj = value[__knownSymbol("iterator")]();
62
- method = (k) => it[k] = (x) => obj[k](x);
63
- } else {
64
- obj = obj.call(value);
65
- method = (k) => it[k] = (v) => {
66
- if (isAwait) {
67
- isAwait = false;
68
- if (k === "throw") throw v;
69
- return v;
70
- }
71
- isAwait = true;
72
- return {
73
- done: false,
74
- value: new __await(new Promise((resolve) => {
75
- var x = obj[k](v);
76
- if (!(x instanceof Object)) __typeError("Object expected");
77
- resolve(x);
78
- }), 1)
79
- };
80
- };
81
- }
82
- return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
83
- throw x;
84
- }, "return" in obj && method("return"), it;
85
- };
86
36
 
87
37
  // src/index.ts
88
38
  var src_exports = {};
@@ -93,6 +43,8 @@ __export(src_exports, {
93
43
  ConstTime: () => ConstTime,
94
44
  EnvImpl: () => EnvImpl,
95
45
  Future: () => Future,
46
+ HeadersImpl: () => HeadersImpl,
47
+ HttpHeader: () => HttpHeader,
96
48
  IDMode: () => IDMode,
97
49
  IdService: () => IdService,
98
50
  IsLogger: () => IsLogger,
@@ -226,15 +178,17 @@ function asyncLogValue(val) {
226
178
  throw new Error("Not implemented");
227
179
  }
228
180
  function logValue(val, ctx) {
229
- return logValueInternal(val, __spreadProps(__spreadValues({}, ctx), {
181
+ return logValueInternal(val, {
182
+ ...ctx,
230
183
  state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
231
- }));
184
+ });
232
185
  }
233
186
  function logValueInternal(val, ctx) {
234
187
  var _a, _b;
235
- ctx = __spreadProps(__spreadValues({}, ctx), {
188
+ ctx = {
189
+ ...ctx,
236
190
  state: ctx.state || /* @__PURE__ */ new Set([Math.random()])
237
- });
191
+ };
238
192
  switch (typeof val) {
239
193
  case "function":
240
194
  return new LogValue(val);
@@ -272,7 +226,7 @@ function logValueInternal(val, ctx) {
272
226
  }
273
227
  if (Array.isArray(val)) {
274
228
  return new LogValue(
275
- () => val.map((v) => logValue(v, __spreadProps(__spreadValues({}, ctx), { state: void 0 })).value())
229
+ () => val.map((v) => logValue(v, { ...ctx, state: void 0 }).value())
276
230
  );
277
231
  }
278
232
  if (val instanceof Headers) {
@@ -1095,6 +1049,139 @@ function exception2Result(fn) {
1095
1049
  }
1096
1050
  }
1097
1051
 
1052
+ // src/utils/relative-path.ts
1053
+ var Path = class {
1054
+ constructor(parts = []) {
1055
+ this.parts = parts;
1056
+ }
1057
+ toString() {
1058
+ return this.parts.map((part) => {
1059
+ if (typeof part === "string") {
1060
+ return part;
1061
+ } else {
1062
+ switch (part) {
1063
+ case 1 /* Slash */:
1064
+ case 3 /* Root */:
1065
+ return "/";
1066
+ case 4 /* Up */:
1067
+ return "..";
1068
+ default:
1069
+ return part;
1070
+ }
1071
+ }
1072
+ }).join("");
1073
+ }
1074
+ add(part) {
1075
+ if (this.parts.includes(3 /* Root */) && part === 3 /* Root */) {
1076
+ throw new Error("Cannot add absolute part to absolute path");
1077
+ }
1078
+ const last = this.parts[this.parts.length - 1];
1079
+ if (last & 1 /* Slash */ && part === 1 /* Slash */) {
1080
+ return;
1081
+ }
1082
+ switch (part) {
1083
+ case ".":
1084
+ this.parts.push(8 /* Noop */);
1085
+ return;
1086
+ case "..":
1087
+ part = 4 /* Up */;
1088
+ }
1089
+ if (last === 8 /* Noop */ && part === 1 /* Slash */) {
1090
+ if (last === 8 /* Noop */) {
1091
+ this.parts.pop();
1092
+ }
1093
+ return;
1094
+ }
1095
+ this.parts.push(part);
1096
+ }
1097
+ };
1098
+ function splitPath(path) {
1099
+ const p = new Path();
1100
+ if (path === "") {
1101
+ return p;
1102
+ }
1103
+ for (let count = 0; path.length; count++) {
1104
+ if (path.match(/^\/+/)) {
1105
+ if (count === 0) {
1106
+ p.add(3 /* Root */);
1107
+ } else {
1108
+ p.add(1 /* Slash */);
1109
+ }
1110
+ path = path.replace(/^\/+/, "");
1111
+ } else {
1112
+ const part = path.replace(/\/.*$/, "");
1113
+ p.add(part);
1114
+ path = path.replace(/^[^/]+/, "");
1115
+ }
1116
+ }
1117
+ return p;
1118
+ }
1119
+ function pathJoin(...paths) {
1120
+ let prev = "";
1121
+ const res = [];
1122
+ for (let i = 0; i < paths.length; i++) {
1123
+ const path = paths[i];
1124
+ if (path === "") {
1125
+ continue;
1126
+ }
1127
+ if (!(prev.endsWith("/") || path.startsWith("/"))) {
1128
+ if (prev !== "") {
1129
+ res.push("/");
1130
+ }
1131
+ res.push(path);
1132
+ } else {
1133
+ res.push(path);
1134
+ }
1135
+ prev = path;
1136
+ }
1137
+ return res.join("");
1138
+ }
1139
+ function relativePath(path, relative) {
1140
+ const relativeParts = splitPath(relative);
1141
+ let result;
1142
+ if (relativeParts.parts[0] === 3 /* Root */) {
1143
+ result = relative;
1144
+ } else {
1145
+ result = pathJoin(path, relative);
1146
+ }
1147
+ const unoptPath = splitPath(result);
1148
+ const out = [];
1149
+ let topUp = false;
1150
+ for (const part of unoptPath.parts) {
1151
+ switch (part) {
1152
+ case 3 /* Root */:
1153
+ out.push(3 /* Root */);
1154
+ break;
1155
+ case 4 /* Up */:
1156
+ if (out.length && !topUp) {
1157
+ const last = out.length - 1;
1158
+ if (typeof out[last] === "string" && out[last - 1] == 3 /* Root */) {
1159
+ out.pop();
1160
+ } else {
1161
+ out.pop();
1162
+ out.pop();
1163
+ }
1164
+ if (out.length === 0) {
1165
+ topUp = !topUp ? true : topUp;
1166
+ out.push(4 /* Up */);
1167
+ }
1168
+ } else {
1169
+ out.push(4 /* Up */);
1170
+ }
1171
+ break;
1172
+ case 1 /* Slash */:
1173
+ if (!(out[out.length - 1] & 1 /* Slash */)) {
1174
+ out.push(1 /* Slash */);
1175
+ }
1176
+ break;
1177
+ default:
1178
+ out.push(part);
1179
+ break;
1180
+ }
1181
+ }
1182
+ return new Path(out).toString();
1183
+ }
1184
+
1098
1185
  // src/utils/stripper.ts
1099
1186
  function stripper(strip, obj) {
1100
1187
  const strips = Array.isArray(strip) ? strip : [strip];
@@ -1114,7 +1201,7 @@ function localStripper(path, restrips, obj) {
1114
1201
  if (Array.isArray(obj)) {
1115
1202
  return obj.map((i) => localStripper(path, restrips, i));
1116
1203
  }
1117
- const ret = __spreadValues({}, obj);
1204
+ const ret = { ...obj };
1118
1205
  const matcher = (key, nextPath) => {
1119
1206
  for (const re of restrips) {
1120
1207
  if (re.test(key) || re.test(nextPath)) {
@@ -1375,17 +1462,29 @@ var BuildURI = class _BuildURI {
1375
1462
  this._url.pathname = p;
1376
1463
  return this;
1377
1464
  }
1378
- appendRelative(p) {
1379
- const appendUrl = URI.from(p);
1380
- let pathname = appendUrl.pathname;
1381
- let basePath = this._url.pathname;
1382
- if (pathname.startsWith("/")) {
1383
- pathname = pathname.replace(/^\//, "");
1465
+ // could pass a relative path or a full URL
1466
+ // if relative path, it will be appended to the current path
1467
+ resolve(p) {
1468
+ if (!p) {
1469
+ return this;
1384
1470
  }
1385
- if (basePath.length > 0) {
1386
- basePath = basePath.replace(/\/$/, "");
1471
+ if (typeof p === "string") {
1472
+ if (!p.match(/^[a-zA-Z0-9]+:/)) {
1473
+ if (p.startsWith("/")) {
1474
+ this.pathname(p);
1475
+ return this;
1476
+ }
1477
+ return this.appendRelative(p);
1478
+ }
1387
1479
  }
1388
- this.pathname(basePath + "/" + pathname);
1480
+ this._url = new MutableURL(p.toString());
1481
+ return this;
1482
+ }
1483
+ appendRelative(p) {
1484
+ const appendUrl = URI.from(p);
1485
+ const pathname = "./" + appendUrl.pathname;
1486
+ const basePath = this._url.pathname;
1487
+ this.pathname(relativePath(basePath, pathname));
1389
1488
  for (const [key, value] of appendUrl.getParams) {
1390
1489
  this.setParam(key, value);
1391
1490
  }
@@ -1560,11 +1659,12 @@ var URI = class _URI {
1560
1659
  searchParams: Object.fromEntries(this.getParams)
1561
1660
  };
1562
1661
  if (hasHostPartProtocols.has(this.protocol.replace(/:$/, ""))) {
1563
- return stripper(strips, __spreadProps(__spreadValues({}, pathURI), {
1662
+ return stripper(strips, {
1663
+ ...pathURI,
1564
1664
  style: "host",
1565
1665
  hostname: this.hostname,
1566
1666
  port: this.port
1567
- }));
1667
+ });
1568
1668
  }
1569
1669
  return stripper(strips, pathURI);
1570
1670
  }
@@ -1943,9 +2043,9 @@ var LoggerImpl = class _LoggerImpl {
1943
2043
  if (!params.withAttributes) {
1944
2044
  this._withAttributes = {};
1945
2045
  } else {
1946
- this._withAttributes = __spreadValues({}, params.withAttributes);
2046
+ this._withAttributes = { ...params.withAttributes };
1947
2047
  }
1948
- this._attributes = __spreadValues({}, this._withAttributes);
2048
+ this._attributes = { ...this._withAttributes };
1949
2049
  if (params.levelHandler) {
1950
2050
  this.levelHandler = params.levelHandler;
1951
2051
  } else {
@@ -2153,9 +2253,10 @@ var LoggerImpl = class _LoggerImpl {
2153
2253
  sys: this._sys,
2154
2254
  levelHandler: this.levelHandler,
2155
2255
  formatter: this._formatter,
2156
- withAttributes: __spreadValues({
2157
- module: this._attributes["module"]
2158
- }, this._withAttributes)
2256
+ withAttributes: {
2257
+ module: this._attributes["module"],
2258
+ ...this._withAttributes
2259
+ }
2159
2260
  })
2160
2261
  );
2161
2262
  }
@@ -2179,7 +2280,7 @@ var LoggerImpl = class _LoggerImpl {
2179
2280
  if (typeof msg === "string" && !msg.trim().length) {
2180
2281
  delete this._attributes["msg"];
2181
2282
  }
2182
- let fnRet = () => this._formatter.format(__spreadValues({}, this._attributes));
2283
+ let fnRet = () => this._formatter.format({ ...this._attributes });
2183
2284
  if (doWrite) {
2184
2285
  const encoded = fnRet();
2185
2286
  this._logWriter.write(encoded);
@@ -2207,7 +2308,7 @@ var WithLoggerBuilder = class {
2207
2308
  return this._li;
2208
2309
  }
2209
2310
  Attributes() {
2210
- return __spreadValues({}, this._li._attributes);
2311
+ return { ...this._li._attributes };
2211
2312
  }
2212
2313
  SetExposeStack(enable) {
2213
2314
  this._li.levelHandler.setExposeStack(enable);
@@ -2413,7 +2514,7 @@ var LogCollector = class {
2413
2514
  new Uint8Array(
2414
2515
  function* (res) {
2415
2516
  for (const x of res) {
2416
- yield* __yieldStar(x);
2517
+ yield* x;
2417
2518
  }
2418
2519
  }(this._bufferArr)
2419
2520
  )
@@ -2532,22 +2633,24 @@ var TraceNode = class _TraceNode {
2532
2633
  return this.ctx.parent.getRootPath(rpath.concat(this.ctx.spanId));
2533
2634
  }
2534
2635
  invokes() {
2535
- const cleanCtx = __spreadValues({}, this.ctx);
2636
+ const cleanCtx = { ...this.ctx };
2536
2637
  delete cleanCtx.parent;
2537
2638
  delete cleanCtx.time;
2538
2639
  delete cleanCtx.logger;
2539
2640
  delete cleanCtx.metrics;
2540
2641
  const spanRefs = this.metrics.toJSON.call({ map: this.metrics.spanRefs });
2541
2642
  const metricsRefs = Object.keys(spanRefs).length > 0 ? { metricRefs: spanRefs } : {};
2542
- return __spreadValues({
2643
+ return {
2543
2644
  ctx: cleanCtx,
2544
- invokations: this.invokations
2545
- }, metricsRefs);
2645
+ invokations: this.invokations,
2646
+ ...metricsRefs
2647
+ };
2546
2648
  }
2547
2649
  ctxWith(spanId, logger) {
2548
- const ctx = __spreadProps(__spreadValues({}, this.ctx), {
2650
+ const ctx = {
2651
+ ...this.ctx,
2549
2652
  spanId
2550
- });
2653
+ };
2551
2654
  if (logger) {
2552
2655
  ctx.logger = logger;
2553
2656
  }
@@ -2557,17 +2660,23 @@ var TraceNode = class _TraceNode {
2557
2660
  span(inSpanId, fn) {
2558
2661
  let ctx;
2559
2662
  if (typeof inSpanId === "string") {
2560
- ctx = __spreadProps(__spreadValues({}, this.ctx), {
2663
+ ctx = {
2664
+ ...this.ctx,
2561
2665
  spanId: inSpanId,
2562
2666
  parent: this
2563
- });
2667
+ };
2564
2668
  } else {
2565
- ctx = __spreadProps(__spreadValues(__spreadValues({}, this.ctx), inSpanId), {
2669
+ ctx = {
2670
+ ...this.ctx,
2671
+ ...inSpanId,
2566
2672
  parent: this
2567
- });
2673
+ };
2568
2674
  }
2569
2675
  if (ctx.logger) {
2570
- ctx = __spreadValues(__spreadValues({}, ctx), ctx.logger.Attributes());
2676
+ ctx = {
2677
+ ...ctx,
2678
+ ...ctx.logger.Attributes()
2679
+ };
2571
2680
  }
2572
2681
  const spanId = ctx.spanId;
2573
2682
  let spanTrace = this.childs.get(spanId);
@@ -2631,6 +2740,161 @@ var VERSION = Object.keys({
2631
2740
  __packageVersion__: "xxxx"
2632
2741
  })[0];
2633
2742
 
2743
+ // src/http_header.ts
2744
+ var HeadersImpl = class extends Headers {
2745
+ constructor(init) {
2746
+ super();
2747
+ this._headers = init;
2748
+ }
2749
+ [Symbol.iterator]() {
2750
+ return this.entries();
2751
+ }
2752
+ entries() {
2753
+ return this._headers.entries();
2754
+ }
2755
+ keys() {
2756
+ return this._headers.keys();
2757
+ }
2758
+ values() {
2759
+ return this._headers.values();
2760
+ }
2761
+ append(key, value) {
2762
+ const values = this._headers.get(key);
2763
+ if (typeof value === "undefined") {
2764
+ value = "";
2765
+ }
2766
+ if (Array.isArray(value)) {
2767
+ this._headers.set(key, [values, ...value].filter((i) => i).join(", "));
2768
+ } else {
2769
+ this._headers.set(key, [values, value].filter((i) => i).join(", "));
2770
+ }
2771
+ return this;
2772
+ }
2773
+ };
2774
+ var HttpHeader = class _HttpHeader {
2775
+ constructor() {
2776
+ this._headers = /* @__PURE__ */ new Map();
2777
+ }
2778
+ static from(headers) {
2779
+ const h = new _HttpHeader();
2780
+ if (headers) {
2781
+ if (Array.isArray(headers)) {
2782
+ for (const [k, v] of headers) {
2783
+ if (v) {
2784
+ h.Add(k, v);
2785
+ }
2786
+ }
2787
+ } else if (headers instanceof Headers) {
2788
+ for (const [k, v] of headers.entries()) {
2789
+ if (v) {
2790
+ h.Add(
2791
+ k,
2792
+ v.split(",").map((v2) => v2.trim())
2793
+ );
2794
+ }
2795
+ }
2796
+ } else {
2797
+ for (const k in headers) {
2798
+ const v = headers[k];
2799
+ if (v) {
2800
+ h.Add(k, v);
2801
+ }
2802
+ }
2803
+ }
2804
+ }
2805
+ return h;
2806
+ }
2807
+ _asStringString() {
2808
+ const ret = /* @__PURE__ */ new Map();
2809
+ for (const [key, values] of this._headers) {
2810
+ ret.set(key, values.join(", "));
2811
+ }
2812
+ return ret;
2813
+ }
2814
+ _key(key) {
2815
+ return key.toLowerCase();
2816
+ }
2817
+ Values(key) {
2818
+ const values = this._headers.get(this._key(key));
2819
+ return values || [];
2820
+ }
2821
+ Get(key) {
2822
+ const values = this._headers.get(this._key(key));
2823
+ if (values === void 0 || values.length === 0) {
2824
+ return void 0;
2825
+ }
2826
+ return values[0];
2827
+ }
2828
+ Set(key, valueOr) {
2829
+ const value = Array.isArray(valueOr) ? valueOr : [valueOr];
2830
+ this._headers.set(this._key(key), value);
2831
+ return this;
2832
+ }
2833
+ Add(key, value) {
2834
+ if (typeof value === "undefined") {
2835
+ return this;
2836
+ }
2837
+ const vs = Array.isArray(value) ? value : [value];
2838
+ const values = this._headers.get(this._key(key));
2839
+ if (values === void 0) {
2840
+ this._headers.set(this._key(key), vs);
2841
+ } else {
2842
+ values.push(...vs);
2843
+ }
2844
+ return this;
2845
+ }
2846
+ Del(ey) {
2847
+ this._headers.delete(this._key(ey));
2848
+ return this;
2849
+ }
2850
+ Items() {
2851
+ return Array.from(this._headers).filter(([_, vs]) => vs.length > 0);
2852
+ }
2853
+ SortItems() {
2854
+ return this.Items().sort(([[a]], [[b]]) => a.localeCompare(b));
2855
+ }
2856
+ Clone() {
2857
+ const clone = new _HttpHeader();
2858
+ for (const [key, values] of this._headers.entries()) {
2859
+ clone._headers.set(key, values.slice());
2860
+ }
2861
+ return clone;
2862
+ }
2863
+ AsRecordStringStringArray() {
2864
+ const obj = {};
2865
+ for (const [key, values] of this._headers.entries()) {
2866
+ obj[key] = [...values];
2867
+ }
2868
+ return obj;
2869
+ }
2870
+ AsRecordStringString() {
2871
+ const obj = {};
2872
+ for (const [key, values] of this._headers.entries()) {
2873
+ obj[key] = values.join(", ");
2874
+ }
2875
+ return obj;
2876
+ }
2877
+ AsHeaderInit() {
2878
+ const obj = {};
2879
+ for (const [key, values] of this._headers.entries()) {
2880
+ obj[key] = values[0];
2881
+ }
2882
+ return obj;
2883
+ }
2884
+ AsHeaders() {
2885
+ return new HeadersImpl(this._asStringString());
2886
+ }
2887
+ Merge(other) {
2888
+ const ret = this.Clone();
2889
+ if (other) {
2890
+ for (const [key, values] of other.Items()) {
2891
+ ret.Add(key, values);
2892
+ }
2893
+ }
2894
+ return ret;
2895
+ }
2896
+ };
2897
+
2634
2898
  // src/utils/index.ts
2635
2899
  var utils_exports = {};
2636
2900
  __export(utils_exports, {
@@ -2837,6 +3101,8 @@ function uint8array2stream(str) {
2837
3101
  ConstTime,
2838
3102
  EnvImpl,
2839
3103
  Future,
3104
+ HeadersImpl,
3105
+ HttpHeader,
2840
3106
  IDMode,
2841
3107
  IdService,
2842
3108
  IsLogger,