@adviser/cement 0.3.1 → 0.3.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.
- package/base-sys-abstraction-CR_Z-Ceg.d.ts +84 -0
- package/base-sys-abstraction-DWtPI7Kg.d.cts +84 -0
- package/cf/index.cjs +929 -0
- package/cf/index.cjs.map +1 -0
- package/cf/index.d.cts +26 -0
- package/cf/index.d.ts +26 -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-DZPKZQIT.js +1182 -0
- package/chunk-DZPKZQIT.js.map +1 -0
- package/chunk-HFP74WLI.js +96 -0
- package/chunk-HFP74WLI.js.map +1 -0
- package/chunk-R2EEZNZN.js +1742 -0
- package/chunk-R2EEZNZN.js.map +1 -0
- package/deno/index.cjs +940 -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 +393 -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 +265 -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 +78 -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 +2681 -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 +24 -0
- package/ts/cf/cf-sys-abstraction.d.ts.map +1 -0
- package/ts/cf/cf-sys-abstraction.js +72 -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 +389 -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,267 @@ 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
|
+
static new(opts) {
|
1012
|
+
return once3.once(() => new _CFEnvActions(opts));
|
1013
|
+
}
|
1014
|
+
static inject(o) {
|
1015
|
+
var _a;
|
1016
|
+
const env = _CFEnvActions.new({});
|
1017
|
+
for (const key2 in o) {
|
1018
|
+
const value = o[key2];
|
1019
|
+
if (typeof value === "string") {
|
1020
|
+
(_a = env.env) == null ? void 0 : _a.set(key2, value);
|
1021
|
+
}
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
constructor(env) {
|
1025
|
+
this.cfEnv = new Map(Object.entries(env.presetEnv || {}));
|
781
1026
|
}
|
782
1027
|
active() {
|
783
|
-
return
|
1028
|
+
return runtimeFn().isCFWorker;
|
784
1029
|
}
|
785
1030
|
register(env) {
|
786
|
-
|
787
|
-
const browser = globalThis;
|
788
|
-
browser[sym] = env;
|
1031
|
+
this.env = env;
|
789
1032
|
return env;
|
790
1033
|
}
|
1034
|
+
get(key2) {
|
1035
|
+
return this.cfEnv.get(key2);
|
1036
|
+
}
|
1037
|
+
set(key2, value) {
|
1038
|
+
if (value) {
|
1039
|
+
this.cfEnv.set(key2, value);
|
1040
|
+
}
|
1041
|
+
}
|
1042
|
+
delete(key2) {
|
1043
|
+
this.cfEnv.delete(key2);
|
1044
|
+
}
|
1045
|
+
keys() {
|
1046
|
+
return Array.from(this.cfEnv.keys());
|
1047
|
+
}
|
791
1048
|
};
|
1049
|
+
|
1050
|
+
// src/sys-env.ts
|
792
1051
|
var envActions = [
|
793
|
-
{ id: "
|
794
|
-
{ id: "
|
795
|
-
{ id: "
|
1052
|
+
{ id: "cf", fn: (opts) => CFEnvActions.new(opts) },
|
1053
|
+
{ id: "node", fn: (opts) => NodeEnvActions.new(opts) },
|
1054
|
+
{ id: "deno", fn: (opts) => DenoEnvActions.new(opts) },
|
1055
|
+
{ id: "browser", fn: (opts) => BrowserEnvActions.new(opts) }
|
796
1056
|
];
|
797
1057
|
function registerEnvAction(fn) {
|
798
1058
|
const id = `id-${Math.random()}`;
|
799
1059
|
envActions.unshift({ id, fn });
|
800
|
-
|
1060
|
+
_envFactories.unget(id);
|
801
1061
|
return () => {
|
802
1062
|
const index = envActions.findIndex((i) => i.id === id);
|
803
1063
|
if (index >= 0) {
|
@@ -805,19 +1065,20 @@ function registerEnvAction(fn) {
|
|
805
1065
|
}
|
806
1066
|
};
|
807
1067
|
}
|
808
|
-
var
|
1068
|
+
var _envFactories = new KeyedResolvOnce();
|
809
1069
|
function envFactory(opts = {}) {
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
const
|
816
|
-
|
1070
|
+
const found = envActions.find((fi) => fi.fn(opts).active());
|
1071
|
+
if (!found) {
|
1072
|
+
throw new Error("SysContainer:envFactory: no env available");
|
1073
|
+
}
|
1074
|
+
return _envFactories.get(found.id).once(() => {
|
1075
|
+
const action = found.fn(opts);
|
1076
|
+
const ret = new EnvImpl2(action, opts);
|
1077
|
+
action.register(ret);
|
817
1078
|
return ret;
|
818
1079
|
});
|
819
1080
|
}
|
820
|
-
var
|
1081
|
+
var EnvImpl2 = class {
|
821
1082
|
constructor(map, opts = {}) {
|
822
1083
|
this._onSet = [];
|
823
1084
|
this._map = map;
|
@@ -885,23 +1146,40 @@ var EnvImpl = class {
|
|
885
1146
|
}
|
886
1147
|
};
|
887
1148
|
|
888
|
-
// src/
|
889
|
-
var
|
890
|
-
var
|
891
|
-
|
892
|
-
|
893
|
-
|
1149
|
+
// src/web/web-sys-abstraction.ts
|
1150
|
+
var once4 = new ResolveOnce();
|
1151
|
+
var BrowserEnvActions = class _BrowserEnvActions {
|
1152
|
+
constructor(opts) {
|
1153
|
+
this.env = /* @__PURE__ */ new Map();
|
1154
|
+
this.opts = opts;
|
894
1155
|
}
|
895
|
-
|
896
|
-
return
|
1156
|
+
static new(opts) {
|
1157
|
+
return once4.once(() => new _BrowserEnvActions(opts));
|
1158
|
+
}
|
1159
|
+
get(key2) {
|
1160
|
+
return this.env.get(key2);
|
1161
|
+
}
|
1162
|
+
set(key2, value) {
|
1163
|
+
if (value) {
|
1164
|
+
this.env.set(key2, value);
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
delete(key2) {
|
1168
|
+
this.env.delete(key2);
|
1169
|
+
}
|
1170
|
+
keys() {
|
1171
|
+
return Array.from(this.env.keys());
|
1172
|
+
}
|
1173
|
+
active() {
|
1174
|
+
return true;
|
1175
|
+
}
|
1176
|
+
register(env) {
|
1177
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
1178
|
+
const browser = globalThis;
|
1179
|
+
browser[sym] = env;
|
1180
|
+
return env;
|
897
1181
|
}
|
898
1182
|
};
|
899
|
-
var utf8EnDecoder = new Utf8EnDecoder();
|
900
|
-
function Utf8EnDecoderSingleton() {
|
901
|
-
return utf8EnDecoder;
|
902
|
-
}
|
903
|
-
|
904
|
-
// src/web/web-sys-abstraction.ts
|
905
1183
|
var WebFileService = class {
|
906
1184
|
get baseDir() {
|
907
1185
|
throw new Error("basedir-Method not implemented.");
|
@@ -1112,23 +1390,23 @@ var Path = class {
|
|
1112
1390
|
this.parts.push(part);
|
1113
1391
|
}
|
1114
1392
|
};
|
1115
|
-
function splitPath(
|
1393
|
+
function splitPath(path3) {
|
1116
1394
|
const p = new Path();
|
1117
|
-
if (
|
1395
|
+
if (path3 === "") {
|
1118
1396
|
return p;
|
1119
1397
|
}
|
1120
|
-
for (let count = 0;
|
1121
|
-
if (
|
1398
|
+
for (let count = 0; path3.length; count++) {
|
1399
|
+
if (path3.match(/^\/+/)) {
|
1122
1400
|
if (count === 0) {
|
1123
1401
|
p.add(3 /* Root */);
|
1124
1402
|
} else {
|
1125
1403
|
p.add(1 /* Slash */);
|
1126
1404
|
}
|
1127
|
-
|
1405
|
+
path3 = path3.replace(/^\/+/, "");
|
1128
1406
|
} else {
|
1129
|
-
const part =
|
1407
|
+
const part = path3.replace(/\/.*$/, "");
|
1130
1408
|
p.add(part);
|
1131
|
-
|
1409
|
+
path3 = path3.replace(/^[^/]+/, "");
|
1132
1410
|
}
|
1133
1411
|
}
|
1134
1412
|
return p;
|
@@ -1137,29 +1415,29 @@ function pathJoin(...paths) {
|
|
1137
1415
|
let prev = "";
|
1138
1416
|
const res = [];
|
1139
1417
|
for (let i = 0; i < paths.length; i++) {
|
1140
|
-
const
|
1141
|
-
if (
|
1418
|
+
const path3 = paths[i];
|
1419
|
+
if (path3 === "") {
|
1142
1420
|
continue;
|
1143
1421
|
}
|
1144
|
-
if (!(prev.endsWith("/") ||
|
1422
|
+
if (!(prev.endsWith("/") || path3.startsWith("/"))) {
|
1145
1423
|
if (prev !== "") {
|
1146
1424
|
res.push("/");
|
1147
1425
|
}
|
1148
|
-
res.push(
|
1426
|
+
res.push(path3);
|
1149
1427
|
} else {
|
1150
|
-
res.push(
|
1428
|
+
res.push(path3);
|
1151
1429
|
}
|
1152
|
-
prev =
|
1430
|
+
prev = path3;
|
1153
1431
|
}
|
1154
1432
|
return res.join("");
|
1155
1433
|
}
|
1156
|
-
function relativePath(
|
1157
|
-
const relativeParts = splitPath(
|
1434
|
+
function relativePath(path3, relative2) {
|
1435
|
+
const relativeParts = splitPath(relative2);
|
1158
1436
|
let result;
|
1159
1437
|
if (relativeParts.parts[0] === 3 /* Root */) {
|
1160
|
-
result =
|
1438
|
+
result = relative2;
|
1161
1439
|
} else {
|
1162
|
-
result = pathJoin(
|
1440
|
+
result = pathJoin(path3, relative2);
|
1163
1441
|
}
|
1164
1442
|
const unoptPath = splitPath(result);
|
1165
1443
|
const out = [];
|
@@ -1211,12 +1489,12 @@ function stripper(strip, obj) {
|
|
1211
1489
|
});
|
1212
1490
|
return localStripper(void 0, restrips, obj);
|
1213
1491
|
}
|
1214
|
-
function localStripper(
|
1492
|
+
function localStripper(path3, restrips, obj) {
|
1215
1493
|
if (typeof obj !== "object" || obj === null) {
|
1216
1494
|
return obj;
|
1217
1495
|
}
|
1218
1496
|
if (Array.isArray(obj)) {
|
1219
|
-
return obj.map((i) => localStripper(
|
1497
|
+
return obj.map((i) => localStripper(path3, restrips, i));
|
1220
1498
|
}
|
1221
1499
|
const ret = { ...obj };
|
1222
1500
|
const matcher = (key2, nextPath) => {
|
@@ -1230,8 +1508,8 @@ function localStripper(path, restrips, obj) {
|
|
1230
1508
|
for (const key2 in ret) {
|
1231
1509
|
if (Object.prototype.hasOwnProperty.call(ret, key2)) {
|
1232
1510
|
let nextPath;
|
1233
|
-
if (
|
1234
|
-
nextPath = [
|
1511
|
+
if (path3) {
|
1512
|
+
nextPath = [path3, key2].join(".");
|
1235
1513
|
} else {
|
1236
1514
|
nextPath = key2;
|
1237
1515
|
}
|
@@ -1708,33 +1986,6 @@ var URI = class _URI {
|
|
1708
1986
|
}
|
1709
1987
|
};
|
1710
1988
|
|
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
1989
|
// src/utils/console-write-stream.ts
|
1739
1990
|
var ConsoleWriterStreamDefaultWriter = class {
|
1740
1991
|
constructor(stream) {
|
@@ -2067,7 +2318,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2067
2318
|
if (rt.isBrowser) {
|
2068
2319
|
stream = new ConsoleWriterStream();
|
2069
2320
|
} else {
|
2070
|
-
if (rt.isNodeIsh || rt.isReactNative || rt.isDeno) {
|
2321
|
+
if (rt.isNodeIsh || rt.isReactNative || rt.isDeno || rt.isCFWorker) {
|
2071
2322
|
stream = this._sys.Stdout();
|
2072
2323
|
} else {
|
2073
2324
|
throw new Error("No output defined for runtime");
|
@@ -2171,7 +2422,7 @@ var LoggerImpl = class _LoggerImpl {
|
|
2171
2422
|
}
|
2172
2423
|
if (this.levelHandler.isStackExposed) {
|
2173
2424
|
this._attributes["stack"] = logValue(
|
2174
|
-
(_a = err.stack) == null ? void 0 : _a.split(
|
2425
|
+
(_a = err.stack) == null ? void 0 : _a.split(/[\r\n]+/).map((s) => s.trim()),
|
2175
2426
|
toLogValueCtx(this.levelHandler)
|
2176
2427
|
);
|
2177
2428
|
}
|
@@ -2287,8 +2538,8 @@ var LoggerImpl = class _LoggerImpl {
|
|
2287
2538
|
return this.Uint64(key2, value);
|
2288
2539
|
}
|
2289
2540
|
async Flush() {
|
2290
|
-
return new Promise((
|
2291
|
-
this._logWriter._flush(void 0,
|
2541
|
+
return new Promise((resolve2) => {
|
2542
|
+
this._logWriter._flush(void 0, resolve2);
|
2292
2543
|
});
|
2293
2544
|
}
|
2294
2545
|
With() {
|
@@ -2599,8 +2850,8 @@ function MockLogger(params) {
|
|
2599
2850
|
|
2600
2851
|
// src/tracer.ts
|
2601
2852
|
var Metric = class {
|
2602
|
-
constructor(
|
2603
|
-
this.path =
|
2853
|
+
constructor(path3) {
|
2854
|
+
this.path = path3;
|
2604
2855
|
}
|
2605
2856
|
set(value) {
|
2606
2857
|
this.value = value;
|
@@ -2635,23 +2886,23 @@ var Metrics = class {
|
|
2635
2886
|
return obj;
|
2636
2887
|
}
|
2637
2888
|
get(ipath) {
|
2638
|
-
const
|
2639
|
-
if (
|
2640
|
-
if (
|
2641
|
-
throw new Error(`Metrics path must contain value /:${
|
2889
|
+
const path3 = ipath.replace(/[/]+/g, "/").trim();
|
2890
|
+
if (path3.startsWith("/")) {
|
2891
|
+
if (path3.slice(1).length === 0) {
|
2892
|
+
throw new Error(`Metrics path must contain value /:${path3}`);
|
2642
2893
|
}
|
2643
|
-
let metric = this.map.get(
|
2894
|
+
let metric = this.map.get(path3);
|
2644
2895
|
if (!metric) {
|
2645
|
-
metric = new Metric(
|
2646
|
-
this.map.set(
|
2896
|
+
metric = new Metric(path3);
|
2897
|
+
this.map.set(path3, metric);
|
2647
2898
|
}
|
2648
|
-
this.spanRefs.set(
|
2899
|
+
this.spanRefs.set(path3, metric);
|
2649
2900
|
return metric;
|
2650
|
-
} else if (
|
2651
|
-
throw new Error(`Metrics path must start with /:${
|
2901
|
+
} else if (path3.includes("/")) {
|
2902
|
+
throw new Error(`Metrics path must start with /:${path3}`);
|
2652
2903
|
}
|
2653
2904
|
const rootPath = this.tracenode.getRootPath();
|
2654
|
-
return this.get(`${rootPath}/${
|
2905
|
+
return this.get(`${rootPath}/${path3}`);
|
2655
2906
|
}
|
2656
2907
|
};
|
2657
2908
|
var TraceNode = class _TraceNode {
|
@@ -3075,8 +3326,8 @@ function rebuffer(a, chunkSize) {
|
|
3075
3326
|
};
|
3076
3327
|
return new ReadableStream({
|
3077
3328
|
async pull(controller) {
|
3078
|
-
return new Promise((
|
3079
|
-
pump(state, controller,
|
3329
|
+
return new Promise((resolve2) => {
|
3330
|
+
pump(state, controller, resolve2);
|
3080
3331
|
});
|
3081
3332
|
}
|
3082
3333
|
});
|
@@ -3144,7 +3395,6 @@ function uint8array2stream(str) {
|
|
3144
3395
|
// Annotate the CommonJS export names for ESM import in node:
|
3145
3396
|
0 && (module.exports = {
|
3146
3397
|
BaseSysAbstraction,
|
3147
|
-
BrowserEnvActions,
|
3148
3398
|
BuildURI,
|
3149
3399
|
ConstTime,
|
3150
3400
|
EnvImpl,
|