@adviser/cement 0.3.1 → 0.3.3
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/base-sys-abstraction-CR_Z-Ceg.d.ts +84 -0
- package/base-sys-abstraction-DWtPI7Kg.d.cts +84 -0
- package/cf/index.cjs +936 -0
- package/cf/index.cjs.map +1 -0
- package/cf/index.d.cts +27 -0
- package/cf/index.d.ts +27 -0
- package/cf/index.js +12 -0
- package/cf/index.js.map +1 -0
- package/{chunk-3RHIVQAA.js → chunk-A7OPSHUV.js} +6 -94
- package/chunk-A7OPSHUV.js.map +1 -0
- package/chunk-HFP74WLI.js +96 -0
- package/chunk-HFP74WLI.js.map +1 -0
- package/chunk-P6LDM7PY.js +1189 -0
- package/chunk-P6LDM7PY.js.map +1 -0
- package/chunk-PRCFKZR7.js +1742 -0
- package/chunk-PRCFKZR7.js.map +1 -0
- package/deno/index.cjs +947 -0
- package/deno/index.cjs.map +1 -0
- package/deno/index.d.cts +59 -0
- package/deno/index.d.ts +59 -0
- package/deno/index.js +16 -0
- package/deno/index.js.map +1 -0
- package/index-BfZxTAe_.d.cts +318 -0
- package/index-CfSl8Gmj.d.ts +318 -0
- package/index.cjs +400 -143
- package/index.cjs.map +1 -1
- package/index.d.cts +7 -317
- package/index.d.ts +7 -317
- package/index.js +34 -1729
- package/index.js.map +1 -1
- package/node/index.cjs +272 -217
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +16 -21
- package/node/index.d.ts +16 -21
- package/node/index.js +8 -352
- package/node/index.js.map +1 -1
- package/package.json +18 -11
- package/src/cf/cf-sys-abstraction.ts +86 -0
- package/src/cf/index.ts +1 -0
- package/src/{node → deno}/deno-file-service.ts +2 -2
- package/src/{node → deno}/deno-sys-abstraction.ts +64 -7
- package/src/deno/index.ts +2 -0
- package/src/index.ts +1 -2
- package/src/jsr.json +1 -1
- package/src/logger-impl.ts +2 -2
- package/src/logger.ts +10 -3
- package/src/node/index.ts +0 -1
- package/src/node/node-sys-abstraction.ts +45 -1
- package/src/runtime.ts +13 -3
- package/src/sys-env.ts +19 -113
- package/src/test/index.ts +2 -0
- package/src/web/web-sys-abstraction.ts +42 -2
- package/sys-abstraction-GNnBj2sz.d.cts +102 -0
- package/sys-abstraction-GNnBj2sz.d.ts +102 -0
- package/test/index.cjs +2688 -0
- package/test/index.cjs.map +1 -0
- package/test/index.d.cts +3 -0
- package/test/index.d.ts +3 -0
- package/test/index.js +14 -0
- package/test/index.js.map +1 -0
- package/ts/base-sys-abstraction.test.js +8 -2
- package/ts/base-sys-abstraction.test.js.map +1 -1
- package/ts/cf/cf-sys-abstraction.d.ts +25 -0
- package/ts/cf/cf-sys-abstraction.d.ts.map +1 -0
- package/ts/cf/cf-sys-abstraction.js +80 -0
- package/ts/cf/cf-sys-abstraction.js.map +1 -0
- package/ts/cf/index.d.ts +2 -0
- package/ts/cf/index.d.ts.map +1 -0
- package/ts/cf/index.js +2 -0
- package/ts/cf/index.js.map +1 -0
- package/ts/crypto.test.js +1 -1
- package/ts/crypto.test.js.map +1 -1
- package/ts/{node → deno}/deno-file-service.d.ts.map +1 -1
- package/ts/{node → deno}/deno-file-service.js +1 -1
- package/ts/{node → deno}/deno-file-service.js.map +1 -1
- package/ts/deno/deno-sys-abstraction.d.ts +43 -0
- package/ts/deno/deno-sys-abstraction.d.ts.map +1 -0
- package/ts/{node → deno}/deno-sys-abstraction.js +46 -2
- package/ts/deno/deno-sys-abstraction.js.map +1 -0
- package/ts/deno/index.d.ts +3 -0
- package/ts/deno/index.d.ts.map +1 -0
- package/ts/deno/index.js +3 -0
- package/ts/deno/index.js.map +1 -0
- package/ts/index.d.ts +1 -2
- package/ts/index.d.ts.map +1 -1
- package/ts/index.js +1 -2
- package/ts/index.js.map +1 -1
- package/ts/logger-impl.js +2 -2
- package/ts/logger-impl.js.map +1 -1
- package/ts/logger.d.ts.map +1 -1
- package/ts/logger.js +9 -3
- package/ts/logger.js.map +1 -1
- package/ts/logger.test.js +9 -9
- package/ts/logger.test.js.map +1 -1
- package/ts/node/index.d.ts +0 -1
- package/ts/node/index.d.ts.map +1 -1
- package/ts/node/index.js +0 -1
- package/ts/node/index.js.map +1 -1
- package/ts/node/node-sys-abstraction.d.ts +14 -1
- package/ts/node/node-sys-abstraction.d.ts.map +1 -1
- package/ts/node/node-sys-abstraction.js +43 -0
- package/ts/node/node-sys-abstraction.js.map +1 -1
- package/ts/runtime.d.ts +1 -0
- package/ts/runtime.d.ts.map +1 -1
- package/ts/runtime.js +10 -3
- package/ts/runtime.js.map +1 -1
- package/ts/sys-env.d.ts +0 -11
- package/ts/sys-env.d.ts.map +1 -1
- package/ts/sys-env.js +19 -104
- package/ts/sys-env.js.map +1 -1
- package/ts/sys-env.test.js +16 -3
- package/ts/sys-env.test.js.map +1 -1
- package/ts/test/index.d.ts +3 -0
- package/ts/test/index.d.ts.map +1 -0
- package/ts/test/index.js +3 -0
- package/ts/test/index.js.map +1 -0
- package/ts/test/test-exit-handler.js +1 -1
- package/ts/web/web-sys-abstraction.d.ts +27 -0
- package/ts/web/web-sys-abstraction.d.ts.map +1 -1
- package/ts/web/web-sys-abstraction.js +35 -1
- package/ts/web/web-sys-abstraction.js.map +1 -1
- package/utils/index.js +6 -4
- package/web/index.cjs +396 -67
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +28 -2
- package/web/index.d.ts +28 -2
- package/web/index.js +5 -2
- package/base-sys-abstraction-BPFyK8XL.d.ts +0 -195
- package/base-sys-abstraction-KYXfUGd6.d.cts +0 -195
- package/chunk-3RHIVQAA.js.map +0 -1
- package/chunk-PSPOGR2I.js +0 -627
- package/chunk-PSPOGR2I.js.map +0 -1
- package/chunk-STUPETPE.js +0 -87
- package/chunk-STUPETPE.js.map +0 -1
- package/ts/node/deno-sys-abstraction.d.ts +0 -22
- package/ts/node/deno-sys-abstraction.d.ts.map +0 -1
- package/ts/node/deno-sys-abstraction.js.map +0 -1
- /package/ts/{node → deno}/deno-file-service.d.ts +0 -0
package/index.cjs
CHANGED
@@ -38,10 +38,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
38
38
|
var src_exports = {};
|
39
39
|
__export(src_exports, {
|
40
40
|
BaseSysAbstraction: () => BaseSysAbstraction,
|
41
|
-
BrowserEnvActions: () => BrowserEnvActions,
|
42
41
|
BuildURI: () => BuildURI,
|
43
42
|
ConstTime: () => ConstTime,
|
44
|
-
EnvImpl: () =>
|
43
|
+
EnvImpl: () => EnvImpl2,
|
45
44
|
Future: () => Future,
|
46
45
|
HeadersImpl: () => HeadersImpl,
|
47
46
|
HttpHeader: () => HttpHeader,
|
@@ -200,11 +199,16 @@ function logValueInternal(val, ctx) {
|
|
200
199
|
return logValueInternal(ret, ctx);
|
201
200
|
}
|
202
201
|
} catch (e) {
|
203
|
-
|
204
|
-
const
|
205
|
-
return new LogValue(() =>
|
202
|
+
try {
|
203
|
+
const url = new URL(val);
|
204
|
+
return new LogValue(() => url.toString());
|
205
|
+
} catch (e2) {
|
206
206
|
}
|
207
207
|
}
|
208
|
+
if (val.match(/[\n\r]/)) {
|
209
|
+
const lines = val.split(/[\n\r]+/).map((v) => v.trim());
|
210
|
+
return new LogValue(() => lines);
|
211
|
+
}
|
208
212
|
return new LogValue(() => val.toString());
|
209
213
|
}
|
210
214
|
case "number":
|
@@ -344,9 +348,9 @@ var SysTime = class extends Time {
|
|
344
348
|
return /* @__PURE__ */ new Date();
|
345
349
|
}
|
346
350
|
Sleep(duration) {
|
347
|
-
return new Promise((
|
351
|
+
return new Promise((resolve2) => {
|
348
352
|
setTimeout(() => {
|
349
|
-
|
353
|
+
resolve2();
|
350
354
|
}, duration);
|
351
355
|
});
|
352
356
|
}
|
@@ -536,8 +540,8 @@ var Future = class {
|
|
536
540
|
__privateAdd(this, _rejectFn, () => {
|
537
541
|
throw new Error("This Promise is not working as expected.");
|
538
542
|
});
|
539
|
-
__privateSet(this, _promise, new Promise((
|
540
|
-
__privateSet(this, _resolveFn,
|
543
|
+
__privateSet(this, _promise, new Promise((resolve2, reject) => {
|
544
|
+
__privateSet(this, _resolveFn, resolve2);
|
541
545
|
__privateSet(this, _rejectFn, reject);
|
542
546
|
}));
|
543
547
|
}
|
@@ -699,53 +703,86 @@ var KeyedResolvSeq = class extends Keyed {
|
|
699
703
|
}
|
700
704
|
};
|
701
705
|
|
702
|
-
// src/
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
register(env) {
|
711
|
-
return env;
|
712
|
-
}
|
713
|
-
active() {
|
714
|
-
return typeof __privateGet(this, _node) === "object" && typeof __privateGet(this, _node).process === "object" && typeof __privateGet(this, _node).process.env === "object";
|
706
|
+
// src/runtime.ts
|
707
|
+
function isSet(value, ref = globalThis) {
|
708
|
+
const [head, ...tail] = value.split(".");
|
709
|
+
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
710
|
+
if (tail.length <= 1) {
|
711
|
+
return true;
|
712
|
+
}
|
713
|
+
return isSet(tail.join("."), ref[head]);
|
715
714
|
}
|
716
|
-
|
717
|
-
|
715
|
+
return false;
|
716
|
+
}
|
717
|
+
function runtimeFn() {
|
718
|
+
const gt = globalThis;
|
719
|
+
let isReactNative = isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative";
|
720
|
+
let isNodeIsh = false;
|
721
|
+
if (!isSet("Deno")) {
|
722
|
+
isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
718
723
|
}
|
719
|
-
|
720
|
-
|
724
|
+
let isDeno = isSet("Deno");
|
725
|
+
const isCFWorker = isSet("caches.default") && isSet("WebSocketPair");
|
726
|
+
if (isCFWorker) {
|
727
|
+
isDeno = false;
|
728
|
+
isNodeIsh = false;
|
729
|
+
isReactNative = false;
|
721
730
|
}
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
731
|
+
return {
|
732
|
+
isNodeIsh,
|
733
|
+
isBrowser: !(isNodeIsh || isDeno || isCFWorker || isReactNative),
|
734
|
+
isDeno,
|
735
|
+
isReactNative,
|
736
|
+
isCFWorker
|
737
|
+
};
|
738
|
+
}
|
739
|
+
|
740
|
+
// src/txt-en-decoder.ts
|
741
|
+
var encoder = new TextEncoder();
|
742
|
+
var decoder = new TextDecoder();
|
743
|
+
var Utf8EnDecoder = class {
|
744
|
+
encode(str) {
|
745
|
+
return encoder.encode(str);
|
726
746
|
}
|
727
|
-
|
728
|
-
|
747
|
+
decode(data) {
|
748
|
+
return decoder.decode(data);
|
729
749
|
}
|
730
750
|
};
|
731
|
-
|
751
|
+
var utf8EnDecoder = new Utf8EnDecoder();
|
752
|
+
function Utf8EnDecoderSingleton() {
|
753
|
+
return utf8EnDecoder;
|
754
|
+
}
|
755
|
+
|
756
|
+
// src/deno/deno-file-service.ts
|
757
|
+
var path = __toESM(require("path"), 1);
|
758
|
+
var Deno = globalThis.Deno;
|
759
|
+
|
760
|
+
// src/deno/deno-sys-abstraction.ts
|
761
|
+
var Deno2 = globalThis.Deno;
|
762
|
+
var once = new ResolveOnce();
|
732
763
|
var _deno;
|
733
|
-
var
|
734
|
-
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-unused-vars
|
764
|
+
var _DenoEnvActions = class _DenoEnvActions {
|
735
765
|
constructor(opts) {
|
736
766
|
__privateAdd(this, _deno, globalThis);
|
767
|
+
this.opts = opts;
|
768
|
+
}
|
769
|
+
static new(opts) {
|
770
|
+
return once.once(() => new _DenoEnvActions(opts));
|
737
771
|
}
|
738
772
|
get _env() {
|
739
773
|
return __privateGet(this, _deno).Deno.env;
|
740
774
|
}
|
741
775
|
register(env) {
|
776
|
+
for (const key2 of env.keys()) {
|
777
|
+
this._env.set(key2, env.get(key2) || "");
|
778
|
+
}
|
742
779
|
return env;
|
743
780
|
}
|
744
781
|
active() {
|
745
|
-
return
|
782
|
+
return runtimeFn().isDeno;
|
746
783
|
}
|
747
784
|
keys() {
|
748
|
-
return
|
785
|
+
return Object.keys(this._env.toObject());
|
749
786
|
}
|
750
787
|
get(key2) {
|
751
788
|
return this._env.get(key2);
|
@@ -760,44 +797,274 @@ var DenoEnvActions = class {
|
|
760
797
|
}
|
761
798
|
};
|
762
799
|
_deno = new WeakMap();
|
763
|
-
var
|
800
|
+
var DenoEnvActions = _DenoEnvActions;
|
801
|
+
var DenoExitServiceImpl = class {
|
802
|
+
constructor() {
|
803
|
+
this._exitHandlers = [];
|
804
|
+
this.invoked = false;
|
805
|
+
this._handleExit = async () => {
|
806
|
+
if (this.invoked) {
|
807
|
+
return;
|
808
|
+
}
|
809
|
+
this.invoked = true;
|
810
|
+
for (const h of this._exitHandlers) {
|
811
|
+
try {
|
812
|
+
const ret = h.hdl();
|
813
|
+
if (typeof ret.then === "function") {
|
814
|
+
await ret;
|
815
|
+
}
|
816
|
+
} finally {
|
817
|
+
}
|
818
|
+
}
|
819
|
+
};
|
820
|
+
globalThis.addEventListener("unhandledrejection", (e) => {
|
821
|
+
e.preventDefault();
|
822
|
+
this.exit(19);
|
823
|
+
});
|
824
|
+
globalThis.addEventListener("error", () => {
|
825
|
+
this.exit(19);
|
826
|
+
});
|
827
|
+
globalThis.addEventListener("uncaughtException", () => {
|
828
|
+
this.exit(19);
|
829
|
+
});
|
830
|
+
globalThis.addEventListener("unload", () => {
|
831
|
+
this.exit(0);
|
832
|
+
});
|
833
|
+
Deno2.addSignalListener("SIGQUIT", () => {
|
834
|
+
this.exit(3);
|
835
|
+
});
|
836
|
+
Deno2.addSignalListener("SIGINT", () => {
|
837
|
+
this.exit(2);
|
838
|
+
});
|
839
|
+
Deno2.addSignalListener("SIGTERM", () => {
|
840
|
+
this.exit(9);
|
841
|
+
});
|
842
|
+
}
|
843
|
+
injectExitHandlers(hdls) {
|
844
|
+
this._exitHandlers = hdls;
|
845
|
+
}
|
846
|
+
exit(code) {
|
847
|
+
this._handleExit().then(() => {
|
848
|
+
Deno2.exit(code);
|
849
|
+
}).catch((err) => {
|
850
|
+
console.error("ExitService: failed to handle exit", err);
|
851
|
+
Deno2.exit(code);
|
852
|
+
});
|
853
|
+
}
|
854
|
+
};
|
855
|
+
var _DenoSystemService = class _DenoSystemService {
|
856
|
+
constructor() {
|
857
|
+
this._exitService = new DenoExitServiceImpl();
|
858
|
+
this._exitService.injectExitHandlers(_DenoSystemService._exitHandlers);
|
859
|
+
}
|
860
|
+
Env() {
|
861
|
+
return envFactory();
|
862
|
+
}
|
863
|
+
Args() {
|
864
|
+
return Deno2.args;
|
865
|
+
}
|
866
|
+
OnExit(hdl) {
|
867
|
+
const id = crypto.randomUUID();
|
868
|
+
_DenoSystemService._exitHandlers.push({ hdl, id });
|
869
|
+
return () => {
|
870
|
+
const idx = _DenoSystemService._exitHandlers.findIndex((h) => h.id === id);
|
871
|
+
if (idx >= 0) {
|
872
|
+
_DenoSystemService._exitHandlers.splice(idx, 1);
|
873
|
+
}
|
874
|
+
};
|
875
|
+
}
|
876
|
+
Exit(code) {
|
877
|
+
this._exitService.exit(code);
|
878
|
+
}
|
879
|
+
};
|
880
|
+
_DenoSystemService._exitHandlers = [];
|
881
|
+
var DenoSystemService = _DenoSystemService;
|
882
|
+
|
883
|
+
// src/node/node-file-service.ts
|
884
|
+
var import_node_path = __toESM(require("path"), 1);
|
885
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
886
|
+
var import_node_process = __toESM(require("process"), 1);
|
887
|
+
|
888
|
+
// src/node/node-sys-abstraction.ts
|
889
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
890
|
+
var once2 = new ResolveOnce();
|
891
|
+
var _node;
|
892
|
+
var _NodeEnvActions = class _NodeEnvActions {
|
764
893
|
constructor(opts) {
|
765
|
-
this
|
894
|
+
__privateAdd(this, _node, globalThis);
|
895
|
+
this._env = this.active() ? __privateGet(this, _node).process.env : {};
|
766
896
|
this.opts = opts;
|
767
897
|
}
|
898
|
+
static new(opts) {
|
899
|
+
return once2.once(() => new _NodeEnvActions(opts));
|
900
|
+
}
|
901
|
+
register(env) {
|
902
|
+
for (const key2 of env.keys()) {
|
903
|
+
this._env[key2] = env.get(key2) || "";
|
904
|
+
}
|
905
|
+
return env;
|
906
|
+
}
|
907
|
+
active() {
|
908
|
+
return runtimeFn().isNodeIsh;
|
909
|
+
}
|
910
|
+
keys() {
|
911
|
+
return Object.keys(this._env);
|
912
|
+
}
|
768
913
|
get(key2) {
|
769
|
-
return this.
|
914
|
+
return this._env[key2];
|
770
915
|
}
|
771
916
|
set(key2, value) {
|
772
917
|
if (value) {
|
773
|
-
this.
|
918
|
+
this._env[key2] = value;
|
774
919
|
}
|
775
920
|
}
|
776
921
|
delete(key2) {
|
777
|
-
this.
|
922
|
+
delete this._env[key2];
|
778
923
|
}
|
779
|
-
|
780
|
-
|
924
|
+
};
|
925
|
+
_node = new WeakMap();
|
926
|
+
var NodeEnvActions = _NodeEnvActions;
|
927
|
+
var NodeExitServiceImpl = class {
|
928
|
+
constructor() {
|
929
|
+
this._exitHandlers = [];
|
930
|
+
this.invoked = false;
|
931
|
+
this._handleExit = async () => {
|
932
|
+
if (this.invoked) {
|
933
|
+
return;
|
934
|
+
}
|
935
|
+
this.invoked = true;
|
936
|
+
for (const h of this._exitHandlers) {
|
937
|
+
try {
|
938
|
+
const ret = h.hdl();
|
939
|
+
if (typeof ret.then === "function") {
|
940
|
+
await ret;
|
941
|
+
}
|
942
|
+
} finally {
|
943
|
+
}
|
944
|
+
}
|
945
|
+
};
|
946
|
+
import_node_process2.default.on("unhandledRejection", (reason, p) => {
|
947
|
+
this.exit(19);
|
948
|
+
});
|
949
|
+
import_node_process2.default.on("uncaughtException", (error) => {
|
950
|
+
this.exit(18);
|
951
|
+
});
|
952
|
+
import_node_process2.default.on("close", () => {
|
953
|
+
this.exit(0);
|
954
|
+
});
|
955
|
+
import_node_process2.default.on("exit", () => {
|
956
|
+
this.exit(0);
|
957
|
+
});
|
958
|
+
import_node_process2.default.on("SIGQUIT", () => {
|
959
|
+
this.exit(3);
|
960
|
+
});
|
961
|
+
import_node_process2.default.on("SIGINT", () => {
|
962
|
+
this.exit(2);
|
963
|
+
});
|
964
|
+
import_node_process2.default.on("SIGTERM", () => {
|
965
|
+
this.exit(9);
|
966
|
+
});
|
967
|
+
}
|
968
|
+
injectExitHandlers(hdls) {
|
969
|
+
this._exitHandlers = hdls;
|
970
|
+
}
|
971
|
+
exit(code) {
|
972
|
+
this._handleExit().then(() => {
|
973
|
+
import_node_process2.default.exit(code);
|
974
|
+
}).catch((err) => {
|
975
|
+
console.error("ExitService: failed to handle exit", err);
|
976
|
+
import_node_process2.default.exit(code);
|
977
|
+
});
|
978
|
+
}
|
979
|
+
};
|
980
|
+
var _NodeSystemService = class _NodeSystemService {
|
981
|
+
constructor() {
|
982
|
+
this._exitService = new NodeExitServiceImpl();
|
983
|
+
this._exitService.injectExitHandlers(_NodeSystemService._exitHandlers);
|
984
|
+
}
|
985
|
+
Env() {
|
986
|
+
return envFactory();
|
987
|
+
}
|
988
|
+
Args() {
|
989
|
+
return import_node_process2.default.argv;
|
990
|
+
}
|
991
|
+
OnExit(hdl) {
|
992
|
+
const id = crypto.randomUUID();
|
993
|
+
_NodeSystemService._exitHandlers.push({ hdl, id });
|
994
|
+
return () => {
|
995
|
+
const idx = _NodeSystemService._exitHandlers.findIndex((h) => h.id === id);
|
996
|
+
if (idx >= 0) {
|
997
|
+
_NodeSystemService._exitHandlers.splice(idx, 1);
|
998
|
+
}
|
999
|
+
};
|
1000
|
+
}
|
1001
|
+
Exit(code) {
|
1002
|
+
this._exitService.exit(code);
|
1003
|
+
}
|
1004
|
+
};
|
1005
|
+
_NodeSystemService._exitHandlers = [];
|
1006
|
+
var NodeSystemService = _NodeSystemService;
|
1007
|
+
|
1008
|
+
// src/cf/cf-sys-abstraction.ts
|
1009
|
+
var once3 = new ResolveOnce();
|
1010
|
+
var CFEnvActions = class _CFEnvActions {
|
1011
|
+
constructor(env) {
|
1012
|
+
this.injectOnRegister = {};
|
1013
|
+
this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
|
1014
|
+
}
|
1015
|
+
static new(opts) {
|
1016
|
+
return once3.once(() => new _CFEnvActions(opts));
|
1017
|
+
}
|
1018
|
+
static inject(o) {
|
1019
|
+
const env = _CFEnvActions.new({});
|
1020
|
+
for (const key2 in o) {
|
1021
|
+
const value = o[key2];
|
1022
|
+
if (typeof value === "string") {
|
1023
|
+
if (env.env) {
|
1024
|
+
env.env.set(key2, value);
|
1025
|
+
} else {
|
1026
|
+
env.injectOnRegister[key2] = value;
|
1027
|
+
}
|
1028
|
+
}
|
1029
|
+
}
|
781
1030
|
}
|
782
1031
|
active() {
|
783
|
-
return
|
1032
|
+
return runtimeFn().isCFWorker;
|
784
1033
|
}
|
785
1034
|
register(env) {
|
786
|
-
|
787
|
-
const
|
788
|
-
|
1035
|
+
this.env = env;
|
1036
|
+
for (const key2 in this.injectOnRegister) {
|
1037
|
+
env.set(key2, this.injectOnRegister[key2]);
|
1038
|
+
}
|
789
1039
|
return env;
|
790
1040
|
}
|
1041
|
+
get(key2) {
|
1042
|
+
return this.cfEnv.get(key2);
|
1043
|
+
}
|
1044
|
+
set(key2, value) {
|
1045
|
+
if (value) {
|
1046
|
+
this.cfEnv.set(key2, value);
|
1047
|
+
}
|
1048
|
+
}
|
1049
|
+
delete(key2) {
|
1050
|
+
this.cfEnv.delete(key2);
|
1051
|
+
}
|
1052
|
+
keys() {
|
1053
|
+
return Array.from(this.cfEnv.keys());
|
1054
|
+
}
|
791
1055
|
};
|
1056
|
+
|
1057
|
+
// src/sys-env.ts
|
792
1058
|
var envActions = [
|
793
|
-
{ id: "
|
794
|
-
{ id: "
|
795
|
-
{ id: "
|
1059
|
+
{ id: "cf", fn: (opts) => CFEnvActions.new(opts) },
|
1060
|
+
{ id: "node", fn: (opts) => NodeEnvActions.new(opts) },
|
1061
|
+
{ id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
|
1062
|
+
{ id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
|
796
1063
|
];
|
797
1064
|
function registerEnvAction(fn) {
|
798
1065
|
const id = `id-${Math.random()}`;
|
799
1066
|
envActions.unshift({ id, fn });
|
800
|
-
|
1067
|
+
_envFactories.unget(id);
|
801
1068
|
return () => {
|
802
1069
|
const index = envActions.findIndex((i) => i.id === id);
|
803
1070
|
if (index >= 0) {
|
@@ -805,19 +1072,20 @@ function registerEnvAction(fn) {
|
|
805
1072
|
}
|
806
1073
|
};
|
807
1074
|
}
|
808
|
-
var
|
1075
|
+
var _envFactories = new KeyedResolvOnce();
|
809
1076
|
function envFactory(opts = {}) {
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
const
|
816
|
-
|
1077
|
+
const found = envActions.find((fi) => fi.fn(opts).active());
|
1078
|
+
if (!found) {
|
1079
|
+
throw new Error("SysContainer:envFactory: no env available");
|
1080
|
+
}
|
1081
|
+
return _envFactories.get(found.id).once(() => {
|
1082
|
+
const action = found.fn(opts);
|
1083
|
+
const ret = new EnvImpl2(action, opts);
|
1084
|
+
action.register(ret);
|
817
1085
|
return ret;
|
818
1086
|
});
|
819
1087
|
}
|
820
|
-
var
|
1088
|
+
var EnvImpl2 = class {
|
821
1089
|
constructor(map, opts = {}) {
|
822
1090
|
this._onSet = [];
|
823
1091
|
this._map = map;
|
@@ -885,23 +1153,40 @@ var EnvImpl = class {
|
|
885
1153
|
}
|
886
1154
|
};
|
887
1155
|
|
888
|
-
// src/
|
889
|
-
var
|
890
|
-
var
|
891
|
-
|
892
|
-
|
893
|
-
|
1156
|
+
// src/web/web-sys-abstraction.ts
|
1157
|
+
var once4 = new ResolveOnce();
|
1158
|
+
var BrowserEnvActions = class _BrowserEnvActions {
|
1159
|
+
constructor(opts) {
|
1160
|
+
this.env = /* @__PURE__ */ new Map();
|
1161
|
+
this.opts = opts;
|
894
1162
|
}
|
895
|
-
|
896
|
-
return
|
1163
|
+
static new(opts) {
|
1164
|
+
return once4.once(() => new _BrowserEnvActions(opts));
|
1165
|
+
}
|
1166
|
+
get(key2) {
|
1167
|
+
return this.env.get(key2);
|
1168
|
+
}
|
1169
|
+
set(key2, value) {
|
1170
|
+
if (value) {
|
1171
|
+
this.env.set(key2, value);
|
1172
|
+
}
|
1173
|
+
}
|
1174
|
+
delete(key2) {
|
1175
|
+
this.env.delete(key2);
|
1176
|
+
}
|
1177
|
+
keys() {
|
1178
|
+
return Array.from(this.env.keys());
|
1179
|
+
}
|
1180
|
+
active() {
|
1181
|
+
return true;
|
1182
|
+
}
|
1183
|
+
register(env) {
|
1184
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
1185
|
+
const browser = globalThis;
|
1186
|
+
browser[sym] = env;
|
1187
|
+
return env;
|
897
1188
|
}
|
898
1189
|
};
|
899
|
-
var utf8EnDecoder = new Utf8EnDecoder();
|
900
|
-
function Utf8EnDecoderSingleton() {
|
901
|
-
return utf8EnDecoder;
|
902
|
-
}
|
903
|
-
|
904
|
-
// src/web/web-sys-abstraction.ts
|
905
1190
|
var WebFileService = class {
|
906
1191
|
get baseDir() {
|
907
1192
|
throw new Error("basedir-Method not implemented.");
|
@@ -1112,23 +1397,23 @@ var Path = class {
|
|
1112
1397
|
this.parts.push(part);
|
1113
1398
|
}
|
1114
1399
|
};
|
1115
|
-
function splitPath(
|
1400
|
+
function splitPath(path3) {
|
1116
1401
|
const p = new Path();
|
1117
|
-
if (
|
1402
|
+
if (path3 === "") {
|
1118
1403
|
return p;
|
1119
1404
|
}
|
1120
|
-
for (let count = 0;
|
1121
|
-
if (
|
1405
|
+
for (let count = 0; path3.length; count++) {
|
1406
|
+
if (path3.match(/^\/+/)) {
|
1122
1407
|
if (count === 0) {
|
1123
1408
|
p.add(3 /* Root */);
|
1124
1409
|
} else {
|
1125
1410
|
p.add(1 /* Slash */);
|
1126
1411
|
}
|
1127
|
-
|
1412
|
+
path3 = path3.replace(/^\/+/, "");
|
1128
1413
|
} else {
|
1129
|
-
const part =
|
1414
|
+
const part = path3.replace(/\/.*$/, "");
|
1130
1415
|
p.add(part);
|
1131
|
-
|
1416
|
+
path3 = path3.replace(/^[^/]+/, "");
|
1132
1417
|
}
|
1133
1418
|
}
|
1134
1419
|
return p;
|
@@ -1137,29 +1422,29 @@ function pathJoin(...paths) {
|
|
1137
1422
|
let prev = "";
|
1138
1423
|
const res = [];
|
1139
1424
|
for (let i = 0; i < paths.length; i++) {
|
1140
|
-
const
|
1141
|
-
if (
|
1425
|
+
const path3 = paths[i];
|
1426
|
+
if (path3 === "") {
|
1142
1427
|
continue;
|
1143
1428
|
}
|
1144
|
-
if (!(prev.endsWith("/") ||
|
1429
|
+
if (!(prev.endsWith("/") || path3.startsWith("/"))) {
|
1145
1430
|
if (prev !== "") {
|
1146
1431
|
res.push("/");
|
1147
1432
|
}
|
1148
|
-
res.push(
|
1433
|
+
res.push(path3);
|
1149
1434
|
} else {
|
1150
|
-
res.push(
|
1435
|
+
res.push(path3);
|
1151
1436
|
}
|
1152
|
-
prev =
|
1437
|
+
prev = path3;
|
1153
1438
|
}
|
1154
1439
|
return res.join("");
|
1155
1440
|
}
|
1156
|
-
function relativePath(
|
1157
|
-
const relativeParts = splitPath(
|
1441
|
+
function relativePath(path3, relative2) {
|
1442
|
+
const relativeParts = splitPath(relative2);
|
1158
1443
|
let result;
|
1159
1444
|
if (relativeParts.parts[0] === 3 /* Root */) {
|
1160
|
-
result =
|
1445
|
+
result = relative2;
|
1161
1446
|
} else {
|
1162
|
-
result = pathJoin(
|
1447
|
+
result = pathJoin(path3, relative2);
|
1163
1448
|
}
|
1164
1449
|
const unoptPath = splitPath(result);
|
1165
1450
|
const out = [];
|
@@ -1211,12 +1496,12 @@ function stripper(strip, obj) {
|
|
1211
1496
|
});
|
1212
1497
|
return localStripper(void 0, restrips, obj);
|
1213
1498
|
}
|
1214
|
-
function localStripper(
|
1499
|
+
function localStripper(path3, restrips, obj) {
|
1215
1500
|
if (typeof obj !== "object" || obj === null) {
|
1216
1501
|
return obj;
|
1217
1502
|
}
|
1218
1503
|
if (Array.isArray(obj)) {
|
1219
|
-
return obj.map((i) => localStripper(
|
1504
|
+
return obj.map((i) => localStripper(path3, restrips, i));
|
1220
1505
|
}
|
1221
1506
|
const ret = { ...obj };
|
1222
1507
|
const matcher = (key2, nextPath) => {
|
@@ -1230,8 +1515,8 @@ function localStripper(path, restrips, obj) {
|
|
1230
1515
|
for (const key2 in ret) {
|
1231
1516
|
if (Object.prototype.hasOwnProperty.call(ret, key2)) {
|
1232
1517
|
let nextPath;
|
1233
|
-
if (
|
1234
|
-
nextPath = [
|
1518
|
+
if (path3) {
|
1519
|
+
nextPath = [path3, key2].join(".");
|
1235
1520
|
} else {
|
1236
1521
|
nextPath = key2;
|
1237
1522
|
}
|
@@ -1708,33 +1993,6 @@ var URI = class _URI {
|
|
1708
1993
|
}
|
1709
1994
|
};
|
1710
1995
|
|
1711
|
-
// src/runtime.ts
|
1712
|
-
function isSet(value, ref = globalThis) {
|
1713
|
-
const [head, ...tail] = value.split(".");
|
1714
|
-
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
1715
|
-
if (tail.length <= 1) {
|
1716
|
-
return true;
|
1717
|
-
}
|
1718
|
-
return isSet(tail.join("."), ref[head]);
|
1719
|
-
}
|
1720
|
-
return false;
|
1721
|
-
}
|
1722
|
-
function runtimeFn() {
|
1723
|
-
const gt = globalThis;
|
1724
|
-
const isReactNative = isSet("navigator.product") && typeof gt["navigator"] === "object" && gt["navigator"]["product"] === "ReactNative";
|
1725
|
-
let isNodeIsh = false;
|
1726
|
-
if (!isSet("Deno")) {
|
1727
|
-
isNodeIsh = isSet("process.versions.node") && !isReactNative;
|
1728
|
-
}
|
1729
|
-
const isDeno = isSet("Deno");
|
1730
|
-
return {
|
1731
|
-
isNodeIsh,
|
1732
|
-
isBrowser: !(isNodeIsh || isDeno) && !isReactNative,
|
1733
|
-
isDeno,
|
1734
|
-
isReactNative
|
1735
|
-
};
|
1736
|
-
}
|
1737
|
-
|
1738
1996
|
// src/utils/console-write-stream.ts
|
1739
1997
|
var ConsoleWriterStreamDefaultWriter = class {
|
1740
1998
|
constructor(stream) {
|
@@ -2067,7 +2325,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2067
2325
|
if (rt.isBrowser) {
|
2068
2326
|
stream = new ConsoleWriterStream();
|
2069
2327
|
} else {
|
2070
|
-
if (rt.isNodeIsh || rt.isReactNative || rt.isDeno) {
|
2328
|
+
if (rt.isNodeIsh || rt.isReactNative || rt.isDeno || rt.isCFWorker) {
|
2071
2329
|
stream = this._sys.Stdout();
|
2072
2330
|
} else {
|
2073
2331
|
throw new Error("No output defined for runtime");
|
@@ -2171,7 +2429,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2171
2429
|
}
|
2172
2430
|
if (this.levelHandler.isStackExposed) {
|
2173
2431
|
this._attributes["stack"] = logValue(
|
2174
|
-
(_a = err.stack) == null ? void 0 : _a.split(
|
2432
|
+
(_a = err.stack) == null ? void 0 : _a.split(/[\r\n]+/).map((s) => s.trim()),
|
2175
2433
|
toLogValueCtx(this.levelHandler)
|
2176
2434
|
);
|
2177
2435
|
}
|
@@ -2287,8 +2545,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
2287
2545
|
return this.Uint64(key2, value);
|
2288
2546
|
}
|
2289
2547
|
async Flush() {
|
2290
|
-
return new Promise((
|
2291
|
-
this._logWriter._flush(void 0,
|
2548
|
+
return new Promise((resolve2) => {
|
2549
|
+
this._logWriter._flush(void 0, resolve2);
|
2292
2550
|
});
|
2293
2551
|
}
|
2294
2552
|
With() {
|
@@ -2599,8 +2857,8 @@ function MockLogger(params) {
|
|
2599
2857
|
|
2600
2858
|
// src/tracer.ts
|
2601
2859
|
var Metric = class {
|
2602
|
-
constructor(
|
2603
|
-
this.path =
|
2860
|
+
constructor(path3) {
|
2861
|
+
this.path = path3;
|
2604
2862
|
}
|
2605
2863
|
set(value) {
|
2606
2864
|
this.value = value;
|
@@ -2635,23 +2893,23 @@ var Metrics = class {
|
|
2635
2893
|
return obj;
|
2636
2894
|
}
|
2637
2895
|
get(ipath) {
|
2638
|
-
const
|
2639
|
-
if (
|
2640
|
-
if (
|
2641
|
-
throw new Error(`Metrics path must contain value /:${
|
2896
|
+
const path3 = ipath.replace(/[/]+/g, "/").trim();
|
2897
|
+
if (path3.startsWith("/")) {
|
2898
|
+
if (path3.slice(1).length === 0) {
|
2899
|
+
throw new Error(`Metrics path must contain value /:${path3}`);
|
2642
2900
|
}
|
2643
|
-
let metric = this.map.get(
|
2901
|
+
let metric = this.map.get(path3);
|
2644
2902
|
if (!metric) {
|
2645
|
-
metric = new Metric(
|
2646
|
-
this.map.set(
|
2903
|
+
metric = new Metric(path3);
|
2904
|
+
this.map.set(path3, metric);
|
2647
2905
|
}
|
2648
|
-
this.spanRefs.set(
|
2906
|
+
this.spanRefs.set(path3, metric);
|
2649
2907
|
return metric;
|
2650
|
-
} else if (
|
2651
|
-
throw new Error(`Metrics path must start with /:${
|
2908
|
+
} else if (path3.includes("/")) {
|
2909
|
+
throw new Error(`Metrics path must start with /:${path3}`);
|
2652
2910
|
}
|
2653
2911
|
const rootPath = this.tracenode.getRootPath();
|
2654
|
-
return this.get(`${rootPath}/${
|
2912
|
+
return this.get(`${rootPath}/${path3}`);
|
2655
2913
|
}
|
2656
2914
|
};
|
2657
2915
|
var TraceNode = class _TraceNode {
|
@@ -3075,8 +3333,8 @@ function rebuffer(a, chunkSize) {
|
|
3075
3333
|
};
|
3076
3334
|
return new ReadableStream({
|
3077
3335
|
async pull(controller) {
|
3078
|
-
return new Promise((
|
3079
|
-
pump(state, controller,
|
3336
|
+
return new Promise((resolve2) => {
|
3337
|
+
pump(state, controller, resolve2);
|
3080
3338
|
});
|
3081
3339
|
}
|
3082
3340
|
});
|
@@ -3144,7 +3402,6 @@ function uint8array2stream(str) {
|
|
3144
3402
|
// Annotate the CommonJS export names for ESM import in node:
|
3145
3403
|
0 && (module.exports = {
|
3146
3404
|
BaseSysAbstraction,
|
3147
|
-
BrowserEnvActions,
|
3148
3405
|
BuildURI,
|
3149
3406
|
ConstTime,
|
3150
3407
|
EnvImpl,
|