@adviser/cement 0.3.2 → 0.3.4
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 → base-sys-abstraction-B-PcaG0B.d.ts} +1 -1
- package/{base-sys-abstraction-DWtPI7Kg.d.cts → base-sys-abstraction-CLlfCI2Q.d.cts} +1 -1
- package/cf/index.cjs +100 -273
- package/cf/index.cjs.map +1 -1
- package/cf/index.d.cts +3 -16
- package/cf/index.d.ts +3 -16
- package/cf/index.js +39 -6
- package/cf/index.js.map +1 -1
- package/{chunk-R2EEZNZN.js → chunk-5GJADB3C.js} +8 -6
- package/{chunk-R2EEZNZN.js.map → chunk-5GJADB3C.js.map} +1 -1
- package/chunk-MFC4AD5O.js +88 -0
- package/chunk-MFC4AD5O.js.map +1 -0
- package/{chunk-DZPKZQIT.js → chunk-OQ4NGEJR.js} +58 -502
- package/chunk-OQ4NGEJR.js.map +1 -0
- package/deno/index.cjs +86 -165
- package/deno/index.cjs.map +1 -1
- package/deno/index.d.cts +3 -23
- package/deno/index.d.ts +3 -23
- package/deno/index.js +174 -8
- package/deno/index.js.map +1 -1
- package/{index-BfZxTAe_.d.cts → index-CI2cJ0-W.d.cts} +1 -1
- package/{index-CfSl8Gmj.d.ts → index-ChpAZoUE.d.ts} +1 -1
- package/index.cjs +102 -265
- package/index.cjs.map +1 -1
- package/index.d.cts +5 -5
- package/index.d.ts +5 -5
- package/index.js +7 -6
- package/index.js.map +1 -1
- package/node/index.cjs +55 -134
- package/node/index.cjs.map +1 -1
- package/node/index.d.cts +3 -16
- package/node/index.d.ts +3 -16
- package/node/index.js +179 -8
- package/node/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cf/cf-env-actions.ts +53 -0
- package/src/cf/cf-sys-abstraction.ts +1 -45
- package/src/deno/deno-env-actions.ts +57 -0
- package/src/deno/deno-sys-abstraction.ts +1 -57
- package/src/jsr.json +1 -1
- package/src/node/node-env-actions.ts +45 -0
- package/src/node/node-sys-abstraction.ts +1 -45
- package/src/sys-env.ts +4 -4
- package/src/web/web-env-actions.ts +41 -0
- package/src/web/web-sys-abstraction.ts +1 -41
- package/{sys-abstraction-GNnBj2sz.d.cts → sys-abstraction-Coxu8BjZ.d.cts} +1 -1
- package/{sys-abstraction-GNnBj2sz.d.ts → sys-abstraction-Coxu8BjZ.d.ts} +1 -1
- package/test/index.cjs +72 -235
- package/test/index.cjs.map +1 -1
- package/test/index.d.cts +2 -2
- package/test/index.d.ts +2 -2
- package/test/index.js +3 -2
- package/ts/cf/cf-env-actions.d.ts +16 -0
- package/ts/cf/cf-env-actions.d.ts.map +1 -0
- package/ts/cf/cf-env-actions.js +51 -0
- package/ts/cf/cf-env-actions.js.map +1 -0
- package/ts/cf/cf-sys-abstraction.d.ts +1 -14
- package/ts/cf/cf-sys-abstraction.d.ts.map +1 -1
- package/ts/cf/cf-sys-abstraction.js +0 -42
- package/ts/cf/cf-sys-abstraction.js.map +1 -1
- package/ts/crypto.test.js +8 -1
- package/ts/crypto.test.js.map +1 -1
- package/ts/deno/deno-env-actions.d.ts +23 -0
- package/ts/deno/deno-env-actions.d.ts.map +1 -0
- package/ts/deno/deno-env-actions.js +46 -0
- package/ts/deno/deno-env-actions.js.map +1 -0
- package/ts/deno/deno-sys-abstraction.d.ts +1 -22
- package/ts/deno/deno-sys-abstraction.d.ts.map +1 -1
- package/ts/deno/deno-sys-abstraction.js +0 -45
- package/ts/deno/deno-sys-abstraction.js.map +1 -1
- package/ts/node/node-env-actions.d.ts +15 -0
- package/ts/node/node-env-actions.d.ts.map +1 -0
- package/ts/node/node-env-actions.js +44 -0
- package/ts/node/node-env-actions.js.map +1 -0
- package/ts/node/node-sys-abstraction.d.ts +1 -14
- package/ts/node/node-sys-abstraction.d.ts.map +1 -1
- package/ts/node/node-sys-abstraction.js +0 -43
- package/ts/node/node-sys-abstraction.js.map +1 -1
- package/ts/sys-env.js +4 -4
- package/ts/sys-env.js.map +1 -1
- package/ts/sys-env.test.js +2 -2
- package/ts/sys-env.test.js.map +1 -1
- package/ts/web/web-env-actions.d.ts +14 -0
- package/ts/web/web-env-actions.d.ts.map +1 -0
- package/ts/web/web-env-actions.js +35 -0
- package/ts/web/web-env-actions.js.map +1 -0
- package/ts/web/web-sys-abstraction.d.ts +0 -13
- package/ts/web/web-sys-abstraction.d.ts.map +1 -1
- package/ts/web/web-sys-abstraction.js +0 -34
- package/ts/web/web-sys-abstraction.js.map +1 -1
- package/web/index.cjs +63 -238
- package/web/index.cjs.map +1 -1
- package/web/index.d.cts +3 -15
- package/web/index.d.ts +3 -15
- package/web/index.js +2 -3
- package/chunk-DZPKZQIT.js.map +0 -1
@@ -0,0 +1,53 @@
|
|
1
|
+
import { ResolveOnce } from "../resolve-once.js";
|
2
|
+
import { runtimeFn } from "../runtime.js";
|
3
|
+
import { EnvActions, EnvImpl, EnvFactoryOpts, Env } from "../sys-env.js";
|
4
|
+
|
5
|
+
const once = new ResolveOnce<CFEnvActions>();
|
6
|
+
export class CFEnvActions implements EnvActions {
|
7
|
+
readonly injectOnRegister: Record<string, string> = {};
|
8
|
+
readonly cfEnv: Map<string, string>;
|
9
|
+
env?: EnvImpl;
|
10
|
+
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
11
|
+
return once.once(() => new CFEnvActions(opts));
|
12
|
+
}
|
13
|
+
static inject(o: Record<string, string>): void {
|
14
|
+
const env = CFEnvActions.new({}) as CFEnvActions;
|
15
|
+
for (const key in o) {
|
16
|
+
const value = o[key];
|
17
|
+
if (typeof value === "string") {
|
18
|
+
if (env.env) {
|
19
|
+
env.env.set(key, value);
|
20
|
+
} else {
|
21
|
+
env.injectOnRegister[key] = value;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
private constructor(env: Partial<EnvFactoryOpts>) {
|
27
|
+
this.cfEnv = new Map<string, string>(Object.entries(env.presetEnv || {}));
|
28
|
+
}
|
29
|
+
active(): boolean {
|
30
|
+
return runtimeFn().isCFWorker;
|
31
|
+
}
|
32
|
+
register(env: Env): Env {
|
33
|
+
this.env = env as EnvImpl;
|
34
|
+
for (const key in this.injectOnRegister) {
|
35
|
+
env.set(key, this.injectOnRegister[key]);
|
36
|
+
}
|
37
|
+
return env;
|
38
|
+
}
|
39
|
+
get(key: string): string | undefined {
|
40
|
+
return this.cfEnv.get(key);
|
41
|
+
}
|
42
|
+
set(key: string, value?: string): void {
|
43
|
+
if (value) {
|
44
|
+
this.cfEnv.set(key, value);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
delete(key: string): void {
|
48
|
+
this.cfEnv.delete(key);
|
49
|
+
}
|
50
|
+
keys(): string[] {
|
51
|
+
return Array.from(this.cfEnv.keys());
|
52
|
+
}
|
53
|
+
}
|
@@ -1,53 +1,9 @@
|
|
1
1
|
import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from "../base-sys-abstraction.js";
|
2
|
-
import { ResolveOnce } from "../resolve-once.js";
|
3
|
-
import { runtimeFn } from "../runtime.js";
|
4
2
|
import { SysAbstraction, SystemService, VoidFunc } from "../sys-abstraction.js";
|
5
|
-
import { Env,
|
3
|
+
import { Env, envFactory } from "../sys-env.js";
|
6
4
|
import { Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
|
7
5
|
import { WebFileService } from "../web/web-sys-abstraction.js";
|
8
6
|
|
9
|
-
const once = new ResolveOnce<CFEnvActions>();
|
10
|
-
export class CFEnvActions implements EnvActions {
|
11
|
-
readonly cfEnv: Map<string, string>;
|
12
|
-
env?: EnvImpl;
|
13
|
-
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
14
|
-
return once.once(() => new CFEnvActions(opts));
|
15
|
-
}
|
16
|
-
static inject(o: Record<string, string>): void {
|
17
|
-
const env = CFEnvActions.new({}) as CFEnvActions;
|
18
|
-
for (const key in o) {
|
19
|
-
const value = o[key];
|
20
|
-
if (typeof value === "string") {
|
21
|
-
env.env?.set(key, value);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
private constructor(env: Partial<EnvFactoryOpts>) {
|
26
|
-
this.cfEnv = new Map<string, string>(Object.entries(env.presetEnv || {}));
|
27
|
-
}
|
28
|
-
active(): boolean {
|
29
|
-
return runtimeFn().isCFWorker;
|
30
|
-
}
|
31
|
-
register(env: Env): Env {
|
32
|
-
this.env = env as EnvImpl;
|
33
|
-
return env;
|
34
|
-
}
|
35
|
-
get(key: string): string | undefined {
|
36
|
-
return this.cfEnv.get(key);
|
37
|
-
}
|
38
|
-
set(key: string, value?: string): void {
|
39
|
-
if (value) {
|
40
|
-
this.cfEnv.set(key, value);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
delete(key: string): void {
|
44
|
-
this.cfEnv.delete(key);
|
45
|
-
}
|
46
|
-
keys(): string[] {
|
47
|
-
return Array.from(this.cfEnv.keys());
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
7
|
export class CFSystemService implements SystemService {
|
52
8
|
Env(): Env {
|
53
9
|
return envFactory();
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { ResolveOnce } from "../resolve-once.js";
|
2
|
+
import { runtimeFn } from "../runtime.js";
|
3
|
+
import { Env, EnvActions, EnvFactoryOpts } from "../sys-env.js";
|
4
|
+
|
5
|
+
interface DenoEnv {
|
6
|
+
get: (key: string) => string | undefined;
|
7
|
+
toObject: () => Record<string, string>;
|
8
|
+
set: (key: string, value: string) => void;
|
9
|
+
has: (key: string) => boolean;
|
10
|
+
delete: (key: string) => void;
|
11
|
+
}
|
12
|
+
|
13
|
+
const once = new ResolveOnce<DenoEnvActions>();
|
14
|
+
export class DenoEnvActions implements EnvActions {
|
15
|
+
readonly #deno = globalThis as unknown as {
|
16
|
+
Deno: {
|
17
|
+
env: DenoEnv;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
|
21
|
+
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
22
|
+
return once.once(() => new DenoEnvActions(opts));
|
23
|
+
}
|
24
|
+
|
25
|
+
get _env(): DenoEnv {
|
26
|
+
return this.#deno.Deno.env;
|
27
|
+
}
|
28
|
+
|
29
|
+
readonly opts: Partial<EnvFactoryOpts>;
|
30
|
+
private constructor(opts: Partial<EnvFactoryOpts>) {
|
31
|
+
this.opts = opts;
|
32
|
+
}
|
33
|
+
|
34
|
+
register(env: Env): Env {
|
35
|
+
for (const key of env.keys()) {
|
36
|
+
this._env.set(key, env.get(key) || "");
|
37
|
+
}
|
38
|
+
return env;
|
39
|
+
}
|
40
|
+
active(): boolean {
|
41
|
+
return runtimeFn().isDeno;
|
42
|
+
}
|
43
|
+
keys(): string[] {
|
44
|
+
return Object.keys(this._env.toObject());
|
45
|
+
}
|
46
|
+
get(key: string): string | undefined {
|
47
|
+
return this._env.get(key);
|
48
|
+
}
|
49
|
+
set(key: string, value?: string): void {
|
50
|
+
if (value) {
|
51
|
+
this._env.set(key, value);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
delete(key: string): void {
|
55
|
+
this._env.delete(key);
|
56
|
+
}
|
57
|
+
}
|
@@ -5,10 +5,8 @@ import {
|
|
5
5
|
WrapperSysAbstractionParams,
|
6
6
|
WrapperSysAbstraction,
|
7
7
|
} from "../base-sys-abstraction.js";
|
8
|
-
import { ResolveOnce } from "../resolve-once.js";
|
9
|
-
import { runtimeFn } from "../runtime.js";
|
10
8
|
import { SysAbstraction, SystemService, VoidFunc } from "../sys-abstraction.js";
|
11
|
-
import { Env,
|
9
|
+
import { Env, envFactory } from "../sys-env.js";
|
12
10
|
import { Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
|
13
11
|
// import * as process from "node:process";
|
14
12
|
import { DenoFileService } from "./deno-file-service.js";
|
@@ -19,60 +17,6 @@ const Deno = (globalThis as unknown as { Deno: unknown }).Deno as {
|
|
19
17
|
args: string[];
|
20
18
|
};
|
21
19
|
|
22
|
-
interface DenoEnv {
|
23
|
-
get: (key: string) => string | undefined;
|
24
|
-
toObject: () => Record<string, string>;
|
25
|
-
set: (key: string, value: string) => void;
|
26
|
-
has: (key: string) => boolean;
|
27
|
-
delete: (key: string) => void;
|
28
|
-
}
|
29
|
-
|
30
|
-
const once = new ResolveOnce<DenoEnvActions>();
|
31
|
-
export class DenoEnvActions implements EnvActions {
|
32
|
-
readonly #deno = globalThis as unknown as {
|
33
|
-
Deno: {
|
34
|
-
env: DenoEnv;
|
35
|
-
};
|
36
|
-
};
|
37
|
-
|
38
|
-
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
39
|
-
return once.once(() => new DenoEnvActions(opts));
|
40
|
-
}
|
41
|
-
|
42
|
-
get _env(): DenoEnv {
|
43
|
-
return this.#deno.Deno.env;
|
44
|
-
}
|
45
|
-
|
46
|
-
readonly opts: Partial<EnvFactoryOpts>;
|
47
|
-
private constructor(opts: Partial<EnvFactoryOpts>) {
|
48
|
-
this.opts = opts;
|
49
|
-
}
|
50
|
-
|
51
|
-
register(env: Env): Env {
|
52
|
-
for (const key of env.keys()) {
|
53
|
-
this._env.set(key, env.get(key) || "");
|
54
|
-
}
|
55
|
-
return env;
|
56
|
-
}
|
57
|
-
active(): boolean {
|
58
|
-
return runtimeFn().isDeno;
|
59
|
-
}
|
60
|
-
keys(): string[] {
|
61
|
-
return Object.keys(this._env.toObject());
|
62
|
-
}
|
63
|
-
get(key: string): string | undefined {
|
64
|
-
return this._env.get(key);
|
65
|
-
}
|
66
|
-
set(key: string, value?: string): void {
|
67
|
-
if (value) {
|
68
|
-
this._env.set(key, value);
|
69
|
-
}
|
70
|
-
}
|
71
|
-
delete(key: string): void {
|
72
|
-
this._env.delete(key);
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
20
|
export class DenoExitServiceImpl implements ExitService {
|
77
21
|
constructor() {
|
78
22
|
globalThis.addEventListener("unhandledrejection", (e) => {
|
package/src/jsr.json
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
import { ResolveOnce } from "../resolve-once.js";
|
2
|
+
import { runtimeFn } from "../runtime.js";
|
3
|
+
import { Env, EnvActions, EnvFactoryOpts } from "../sys-env.js";
|
4
|
+
|
5
|
+
const once = new ResolveOnce<NodeEnvActions>();
|
6
|
+
export class NodeEnvActions implements EnvActions {
|
7
|
+
readonly #node = globalThis as unknown as { process: { env: Record<string, string> } };
|
8
|
+
|
9
|
+
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
10
|
+
return once.once(() => new NodeEnvActions(opts));
|
11
|
+
}
|
12
|
+
|
13
|
+
readonly opts: Partial<EnvFactoryOpts>;
|
14
|
+
private constructor(opts: Partial<EnvFactoryOpts>) {
|
15
|
+
this.opts = opts;
|
16
|
+
}
|
17
|
+
|
18
|
+
register(env: Env): Env {
|
19
|
+
for (const key of env.keys()) {
|
20
|
+
this._env[key] = env.get(key) || "";
|
21
|
+
}
|
22
|
+
return env;
|
23
|
+
}
|
24
|
+
|
25
|
+
active(): boolean {
|
26
|
+
return runtimeFn().isNodeIsh;
|
27
|
+
// typeof this.#node === "object" && typeof this.#node.process === "object" && typeof this.#node.process.env === "object";
|
28
|
+
}
|
29
|
+
readonly _env: Record<string, string> = this.active() ? this.#node.process.env : {};
|
30
|
+
keys(): string[] {
|
31
|
+
return Object.keys(this._env);
|
32
|
+
}
|
33
|
+
get(key: string): string | undefined {
|
34
|
+
return this._env[key];
|
35
|
+
}
|
36
|
+
set(key: string, value?: string): void {
|
37
|
+
if (value) {
|
38
|
+
this._env[key] = value;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
delete(key: string): void {
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
43
|
+
delete this._env[key];
|
44
|
+
}
|
45
|
+
}
|
@@ -7,53 +7,9 @@ import {
|
|
7
7
|
WrapperSysAbstractionParams,
|
8
8
|
} from "../base-sys-abstraction.js";
|
9
9
|
import { NodeFileService } from "./node-file-service.js";
|
10
|
-
import { Env,
|
10
|
+
import { Env, envFactory } from "../sys-env.js";
|
11
11
|
import { Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
|
12
12
|
import process from "node:process";
|
13
|
-
import { runtimeFn } from "../runtime.js";
|
14
|
-
import { ResolveOnce } from "../resolve-once.js";
|
15
|
-
|
16
|
-
const once = new ResolveOnce<NodeEnvActions>();
|
17
|
-
export class NodeEnvActions implements EnvActions {
|
18
|
-
readonly #node = globalThis as unknown as { process: { env: Record<string, string> } };
|
19
|
-
|
20
|
-
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
21
|
-
return once.once(() => new NodeEnvActions(opts));
|
22
|
-
}
|
23
|
-
|
24
|
-
readonly opts: Partial<EnvFactoryOpts>;
|
25
|
-
private constructor(opts: Partial<EnvFactoryOpts>) {
|
26
|
-
this.opts = opts;
|
27
|
-
}
|
28
|
-
|
29
|
-
register(env: Env): Env {
|
30
|
-
for (const key of env.keys()) {
|
31
|
-
this._env[key] = env.get(key) || "";
|
32
|
-
}
|
33
|
-
return env;
|
34
|
-
}
|
35
|
-
|
36
|
-
active(): boolean {
|
37
|
-
return runtimeFn().isNodeIsh;
|
38
|
-
// typeof this.#node === "object" && typeof this.#node.process === "object" && typeof this.#node.process.env === "object";
|
39
|
-
}
|
40
|
-
readonly _env: Record<string, string> = this.active() ? this.#node.process.env : {};
|
41
|
-
keys(): string[] {
|
42
|
-
return Object.keys(this._env);
|
43
|
-
}
|
44
|
-
get(key: string): string | undefined {
|
45
|
-
return this._env[key];
|
46
|
-
}
|
47
|
-
set(key: string, value?: string): void {
|
48
|
-
if (value) {
|
49
|
-
this._env[key] = value;
|
50
|
-
}
|
51
|
-
}
|
52
|
-
delete(key: string): void {
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
54
|
-
delete this._env[key];
|
55
|
-
}
|
56
|
-
}
|
57
13
|
|
58
14
|
export class NodeExitServiceImpl implements ExitService {
|
59
15
|
constructor() {
|
package/src/sys-env.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { DenoEnvActions } from "./deno/deno-
|
2
|
-
import { NodeEnvActions } from "./node/node-
|
3
|
-
import { BrowserEnvActions } from "./web/web-
|
4
|
-
import { CFEnvActions } from "./cf/cf-
|
1
|
+
import { DenoEnvActions } from "./deno/deno-env-actions.js";
|
2
|
+
import { NodeEnvActions } from "./node/node-env-actions.js";
|
3
|
+
import { BrowserEnvActions } from "./web/web-env-actions.js";
|
4
|
+
import { CFEnvActions } from "./cf/cf-env-actions.js";
|
5
5
|
import { KeyedResolvOnce } from "./resolve-once.js";
|
6
6
|
|
7
7
|
export interface EnvMap {
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { ResolveOnce } from "../resolve-once.js";
|
2
|
+
import { EnvActions, EnvFactoryOpts, Env } from "../sys-env.js";
|
3
|
+
|
4
|
+
const once = new ResolveOnce<BrowserEnvActions>();
|
5
|
+
export class BrowserEnvActions implements EnvActions {
|
6
|
+
readonly env: Map<string, string> = new Map<string, string>();
|
7
|
+
readonly opts: Partial<EnvFactoryOpts>;
|
8
|
+
|
9
|
+
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
10
|
+
return once.once(() => new BrowserEnvActions(opts));
|
11
|
+
}
|
12
|
+
|
13
|
+
private constructor(opts: Partial<EnvFactoryOpts>) {
|
14
|
+
this.opts = opts;
|
15
|
+
}
|
16
|
+
|
17
|
+
get(key: string): string | undefined {
|
18
|
+
return this.env.get(key);
|
19
|
+
}
|
20
|
+
set(key: string, value?: string): void {
|
21
|
+
if (value) {
|
22
|
+
this.env.set(key, value);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
delete(key: string): void {
|
26
|
+
this.env.delete(key);
|
27
|
+
}
|
28
|
+
keys(): string[] {
|
29
|
+
return Array.from(this.env.keys());
|
30
|
+
}
|
31
|
+
active(): boolean {
|
32
|
+
return true; // that should work on every runtime
|
33
|
+
}
|
34
|
+
|
35
|
+
register(env: Env): Env {
|
36
|
+
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
37
|
+
const browser = globalThis as unknown as Record<symbol, Env>;
|
38
|
+
browser[sym] = env;
|
39
|
+
return env;
|
40
|
+
}
|
41
|
+
}
|
@@ -1,49 +1,9 @@
|
|
1
1
|
import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from "../base-sys-abstraction.js";
|
2
2
|
import { FileService, NamedWritableStream } from "../file-service.js";
|
3
|
-
import { ResolveOnce } from "../resolve-once.js";
|
4
3
|
import { SysAbstraction, SystemService, VoidFunc } from "../sys-abstraction.js";
|
5
|
-
import { Env,
|
4
|
+
import { Env, envFactory } from "../sys-env.js";
|
6
5
|
import { Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
|
7
6
|
|
8
|
-
const once = new ResolveOnce<BrowserEnvActions>();
|
9
|
-
export class BrowserEnvActions implements EnvActions {
|
10
|
-
readonly env: Map<string, string> = new Map<string, string>();
|
11
|
-
readonly opts: Partial<EnvFactoryOpts>;
|
12
|
-
|
13
|
-
static new(opts: Partial<EnvFactoryOpts>): EnvActions {
|
14
|
-
return once.once(() => new BrowserEnvActions(opts));
|
15
|
-
}
|
16
|
-
|
17
|
-
private constructor(opts: Partial<EnvFactoryOpts>) {
|
18
|
-
this.opts = opts;
|
19
|
-
}
|
20
|
-
|
21
|
-
get(key: string): string | undefined {
|
22
|
-
return this.env.get(key);
|
23
|
-
}
|
24
|
-
set(key: string, value?: string): void {
|
25
|
-
if (value) {
|
26
|
-
this.env.set(key, value);
|
27
|
-
}
|
28
|
-
}
|
29
|
-
delete(key: string): void {
|
30
|
-
this.env.delete(key);
|
31
|
-
}
|
32
|
-
keys(): string[] {
|
33
|
-
return Array.from(this.env.keys());
|
34
|
-
}
|
35
|
-
active(): boolean {
|
36
|
-
return true; // that should work on every runtime
|
37
|
-
}
|
38
|
-
|
39
|
-
register(env: Env): Env {
|
40
|
-
const sym = Symbol.for(this.opts.symbol || "CP_ENV");
|
41
|
-
const browser = globalThis as unknown as Record<symbol, Env>;
|
42
|
-
browser[sym] = env;
|
43
|
-
return env;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
7
|
export class WebFileService implements FileService {
|
48
8
|
get baseDir(): string {
|
49
9
|
throw new Error("basedir-Method not implemented.");
|
@@ -99,4 +99,4 @@ interface SysAbstraction {
|
|
99
99
|
FileSystem(): FileService;
|
100
100
|
}
|
101
101
|
|
102
|
-
export { type Duration as D, type
|
102
|
+
export { type Duration as D, type Env as E, type FileService as F, IDMode as I, type NamedWritableStream as N, type OnSetItem as O, RandomMode as R, type SystemService as S, Time as T, type VoidFunc as V, type SysAbstraction as a, TimeMode as b, String2TimeMode as c, type EnvMap as d, type EnvActions as e, type EnvFactoryOpts as f, type EnvFactoryFn as g, envFactory as h, EnvImpl as i, TimeUnits as j, registerEnvAction as r };
|
@@ -99,4 +99,4 @@ interface SysAbstraction {
|
|
99
99
|
FileSystem(): FileService;
|
100
100
|
}
|
101
101
|
|
102
|
-
export { type Duration as D, type
|
102
|
+
export { type Duration as D, type Env as E, type FileService as F, IDMode as I, type NamedWritableStream as N, type OnSetItem as O, RandomMode as R, type SystemService as S, Time as T, type VoidFunc as V, type SysAbstraction as a, TimeMode as b, String2TimeMode as c, type EnvMap as d, type EnvActions as e, type EnvFactoryOpts as f, type EnvFactoryFn as g, envFactory as h, EnvImpl as i, TimeUnits as j, registerEnvAction as r };
|