@dxos/config 0.8.4-main.ead640a → 0.8.4-main.f466a3d56e
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/chunk-VQRJY4AQ.mjs +11 -0
- package/dist/lib/browser/chunk-VQRJY4AQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZY4D4E3Q.mjs +146 -0
- package/dist/lib/browser/chunk-ZY4D4E3Q.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +136 -222
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/loaders/browser.mjs +73 -0
- package/dist/lib/browser/loaders/browser.mjs.map +7 -0
- package/dist/lib/browser/loaders/index.mjs +66 -0
- package/dist/lib/browser/loaders/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/plugin/browser.mjs +8 -0
- package/dist/lib/browser/plugin/browser.mjs.map +7 -0
- package/dist/lib/browser/plugin/index.mjs +98 -0
- package/dist/lib/browser/plugin/index.mjs.map +7 -0
- package/dist/lib/browser/savers/browser.mjs +25 -0
- package/dist/lib/browser/savers/browser.mjs.map +7 -0
- package/dist/lib/browser/savers/index.mjs +7 -0
- package/dist/lib/browser/savers/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-T6NFH3CC.mjs +13 -0
- package/dist/lib/node-esm/chunk-T6NFH3CC.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WIJROCKQ.mjs +148 -0
- package/dist/lib/node-esm/chunk-WIJROCKQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +132 -312
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/loaders/browser.mjs +75 -0
- package/dist/lib/node-esm/loaders/browser.mjs.map +7 -0
- package/dist/lib/node-esm/loaders/index.mjs +67 -0
- package/dist/lib/node-esm/loaders/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/plugin/browser.mjs +10 -0
- package/dist/lib/node-esm/plugin/browser.mjs.map +7 -0
- package/dist/lib/node-esm/plugin/index.mjs +99 -0
- package/dist/lib/node-esm/plugin/index.mjs.map +7 -0
- package/dist/lib/node-esm/savers/browser.mjs +27 -0
- package/dist/lib/node-esm/savers/browser.mjs.map +7 -0
- package/dist/lib/node-esm/savers/index.mjs +9 -0
- package/dist/lib/node-esm/savers/index.mjs.map +7 -0
- package/dist/plugin/node-esm/{chunk-KVRVDEOZ.mjs → chunk-XCZNYAQT.mjs} +27 -53
- package/dist/plugin/node-esm/chunk-XCZNYAQT.mjs.map +7 -0
- package/dist/plugin/node-esm/esbuild-plugin.mjs +2 -3
- package/dist/plugin/node-esm/esbuild-plugin.mjs.map +1 -1
- package/dist/plugin/node-esm/meta.json +1 -1
- package/dist/plugin/node-esm/rollup-plugin.mjs +1 -1
- package/dist/plugin/node-esm/vite-plugin.mjs +1 -1
- package/dist/plugin/node-esm/vite-plugin.mjs.map +2 -2
- package/dist/types/src/config-service.d.ts +19 -0
- package/dist/types/src/config-service.d.ts.map +1 -0
- package/dist/types/src/config.d.ts +0 -1
- package/dist/types/src/config.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +6 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/loaders/browser.d.ts +11 -15
- package/dist/types/src/loaders/browser.d.ts.map +1 -1
- package/dist/types/src/loaders/index.d.ts.map +1 -1
- package/dist/types/src/plugin/browser.d.ts +3 -0
- package/dist/types/src/plugin/browser.d.ts.map +1 -0
- package/dist/types/src/plugin/definitions.d.ts.map +1 -1
- package/dist/types/src/plugin/esbuild-plugin.d.ts.map +1 -1
- package/dist/types/src/plugin/rollup-plugin.d.ts.map +1 -1
- package/dist/types/src/plugin/vite-plugin.d.ts.map +1 -1
- package/dist/types/src/preset.d.ts +10 -0
- package/dist/types/src/preset.d.ts.map +1 -0
- package/dist/types/src/savers/browser.d.ts +2 -1
- package/dist/types/src/savers/browser.d.ts.map +1 -1
- package/dist/types/src/savers/index.d.ts.map +1 -1
- package/dist/types/src/telemetry.d.ts +17 -0
- package/dist/types/src/telemetry.d.ts.map +1 -0
- package/dist/types/src/testing/defaults.d.ts +6 -6
- package/dist/types/src/testing/defaults.d.ts.map +1 -1
- package/dist/types/src/testing/envs-map.d.ts +12 -14
- package/dist/types/src/testing/envs-map.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -32
- package/src/config-service.ts +116 -0
- package/src/config.ts +4 -7
- package/src/index.ts +6 -3
- package/src/loaders/{browser.js → browser.ts} +15 -9
- package/src/loaders/index.ts +2 -3
- package/src/plugin/browser.ts +11 -0
- package/src/plugin/definitions.ts +2 -4
- package/src/plugin/vite-plugin.ts +0 -1
- package/src/preset.ts +40 -0
- package/src/savers/{browser.js → browser.ts} +3 -3
- package/src/telemetry.ts +25 -0
- package/src/testing/build.js +2 -1
- package/dist/plugin/node-esm/chunk-KVRVDEOZ.mjs.map +0 -7
|
@@ -1,250 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FILE_DEFAULTS,
|
|
3
|
+
FILE_DYNAMICS,
|
|
4
|
+
FILE_ENVS
|
|
5
|
+
} from "./chunk-VQRJY4AQ.mjs";
|
|
6
|
+
import {
|
|
7
|
+
Config,
|
|
8
|
+
ConfigResource,
|
|
9
|
+
mapFromKeyValues,
|
|
10
|
+
mapToKeyValues,
|
|
11
|
+
validateConfig
|
|
12
|
+
} from "./chunk-ZY4D4E3Q.mjs";
|
|
13
|
+
|
|
1
14
|
// src/index.ts
|
|
2
15
|
import * as defs from "@dxos/protocols/proto/dxos/config";
|
|
3
16
|
|
|
4
|
-
// src/config.ts
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
26
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
-
}
|
|
31
|
-
var configRootType = schema.getCodecForType("dxos.config.Config");
|
|
32
|
-
var mapFromKeyValues = (spec, values) => {
|
|
33
|
-
const config = {};
|
|
34
|
-
for (const [key, { path, type }] of Object.entries(spec)) {
|
|
35
|
-
let value = values[key];
|
|
36
|
-
if (value !== void 0) {
|
|
37
|
-
if (type) {
|
|
38
|
-
switch (type) {
|
|
39
|
-
case "boolean": {
|
|
40
|
-
value = boolean(value);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case "number": {
|
|
44
|
-
value = Number(value);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case "string": {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case "json": {
|
|
51
|
-
value = value ? JSON.parse(value) : null;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
default: {
|
|
55
|
-
throw new Error(`Invalid type: ${type}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
17
|
+
// src/config-service.ts
|
|
18
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
19
|
+
import * as Context from "effect/Context";
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import * as Layer from "effect/Layer";
|
|
22
|
+
import * as Option from "effect/Option";
|
|
23
|
+
import { dirname } from "@dxos/node-std/path";
|
|
24
|
+
import * as Yaml from "yaml";
|
|
25
|
+
import { DX_CONFIG, DX_DATA, getProfileConfigPath, getProfilePath } from "@dxos/client-protocol";
|
|
26
|
+
import { invariant } from "@dxos/invariant";
|
|
27
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/config/src/config-service.ts";
|
|
28
|
+
var memoryConfig = new Config({
|
|
29
|
+
runtime: {
|
|
30
|
+
client: {
|
|
31
|
+
edgeFeatures: {
|
|
32
|
+
echoReplicator: true,
|
|
33
|
+
feedReplicator: true,
|
|
34
|
+
signaling: true,
|
|
35
|
+
agents: true
|
|
58
36
|
}
|
|
59
|
-
setDeep(config, path.split("."), value);
|
|
60
37
|
}
|
|
61
38
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
39
|
+
});
|
|
40
|
+
var defaultConfig = new Config({
|
|
41
|
+
runtime: {
|
|
42
|
+
client: {
|
|
43
|
+
edgeFeatures: {
|
|
44
|
+
echoReplicator: true,
|
|
45
|
+
feedReplicator: true,
|
|
46
|
+
signaling: true,
|
|
47
|
+
agents: true
|
|
48
|
+
},
|
|
49
|
+
storage: {
|
|
50
|
+
persistent: true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
services: {
|
|
54
|
+
edge: {
|
|
55
|
+
url: "wss://edge-production.dxos.workers.dev/"
|
|
56
|
+
},
|
|
57
|
+
iceProviders: [
|
|
58
|
+
{
|
|
59
|
+
urls: "https://edge-production.dxos.workers.dev/ice"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
ai: {
|
|
63
|
+
server: "https://ai-service.dxos.workers.dev"
|
|
64
|
+
},
|
|
65
|
+
ipfs: {
|
|
66
|
+
server: "https://api.ipfs.dxos.network/api/v0",
|
|
67
|
+
gateway: "https://gateway.ipfs.dxos.network/ipfs"
|
|
75
68
|
}
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.
|
|
105
|
-
* @param defaultValue Default value to return if option is not present in the config.
|
|
106
|
-
* @returns The config value or undefined if the option is not present.
|
|
107
|
-
*/
|
|
108
|
-
get(key, defaultValue) {
|
|
109
|
-
return getDeep(this._config, key.split(".")) ?? defaultValue;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get unique key.
|
|
113
|
-
*/
|
|
114
|
-
find(path, test) {
|
|
115
|
-
const values = getDeep(this._config, path.split("."));
|
|
116
|
-
if (!Array.isArray(values)) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
return values.find((value) => isMatch(value, test));
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns the given config property or throw if it doesn't exist.
|
|
123
|
-
*
|
|
124
|
-
* @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.
|
|
125
|
-
*/
|
|
126
|
-
getOrThrow(key) {
|
|
127
|
-
const value = getDeep(this._config, key.split("."));
|
|
128
|
-
if (!value) {
|
|
129
|
-
throw new Error(`Config option not present: ${key}`);
|
|
130
|
-
}
|
|
131
|
-
return value;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Creates an immutable instance.
|
|
135
|
-
* @constructor
|
|
136
|
-
*/
|
|
137
|
-
constructor(config = {}, ...objects) {
|
|
138
|
-
_define_property(this, "_config", void 0);
|
|
139
|
-
this._config = validateConfig(defaultsDeep(config, ...objects, {
|
|
140
|
-
version: 1
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
Config = _ts_decorate([
|
|
145
|
-
trace.resource({
|
|
146
|
-
annotation: ConfigResource
|
|
147
|
-
})
|
|
148
|
-
], Config);
|
|
149
|
-
|
|
150
|
-
// src/loaders/browser.js
|
|
151
|
-
import localforage from "localforage";
|
|
152
|
-
import { log } from "@dxos/log";
|
|
153
|
-
var CONFIG_ENDPOINT = "/.well-known/dx/config";
|
|
154
|
-
var Local = () => {
|
|
155
|
-
return typeof __CONFIG_LOCAL__ !== "undefined" ? __CONFIG_LOCAL__ : {};
|
|
156
|
-
};
|
|
157
|
-
var Dynamics = async () => {
|
|
158
|
-
const { publicUrl = "", dynamic } = __DXOS_CONFIG__;
|
|
159
|
-
if (!dynamic) {
|
|
160
|
-
log("dynamics disabled");
|
|
161
|
-
return {};
|
|
162
|
-
}
|
|
163
|
-
log("fetching config...", { publicUrl });
|
|
164
|
-
return await fetch(`${publicUrl}${CONFIG_ENDPOINT}`).then((res) => res.json()).catch((error) => {
|
|
165
|
-
log.warn("Failed to fetch dynamic config.", error);
|
|
166
|
-
return {};
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
var Envs = () => {
|
|
170
|
-
return typeof __CONFIG_ENVS__ !== "undefined" ? __CONFIG_ENVS__ : {};
|
|
171
|
-
};
|
|
172
|
-
var Defaults = () => {
|
|
173
|
-
return typeof __CONFIG_DEFAULTS__ !== "undefined" ? __CONFIG_DEFAULTS__ : {};
|
|
174
|
-
};
|
|
175
|
-
var Storage = async () => {
|
|
176
|
-
try {
|
|
177
|
-
const config = await localforage.getItem("dxos.org/settings/config");
|
|
178
|
-
if (config) {
|
|
179
|
-
return config;
|
|
180
|
-
}
|
|
181
|
-
} catch (err) {
|
|
182
|
-
log.warn("Failed to load config", { err });
|
|
183
|
-
}
|
|
184
|
-
return {};
|
|
71
|
+
});
|
|
72
|
+
var ConfigService = class _ConfigService extends Context.Tag("ConfigService")() {
|
|
73
|
+
static layerMemory = Layer.effect(_ConfigService, Effect.succeed(memoryConfig));
|
|
74
|
+
static fromConfig = (config) => Layer.succeed(_ConfigService, config);
|
|
75
|
+
static load = (args) => {
|
|
76
|
+
const defaultConfigPath = getProfileConfigPath(DX_CONFIG, args.profile);
|
|
77
|
+
return Effect.gen(function* () {
|
|
78
|
+
const fs = yield* FileSystem.FileSystem;
|
|
79
|
+
const configPath = Option.getOrElse(args.config, () => defaultConfigPath);
|
|
80
|
+
const configContent = yield* fs.readFileString(configPath);
|
|
81
|
+
const configValues = Yaml.parse(configContent);
|
|
82
|
+
return _ConfigService.of(new Config(configValues, profileBuiltinDefaults(args.profile).values));
|
|
83
|
+
}).pipe(
|
|
84
|
+
// If the config file doesn't exist, create it.
|
|
85
|
+
Effect.catchTag("SystemError", () => Effect.gen(function* () {
|
|
86
|
+
const configValues = defaultConfig.values;
|
|
87
|
+
const fs = yield* FileSystem.FileSystem;
|
|
88
|
+
const pathToCreate = Option.getOrElse(args.config, () => defaultConfigPath);
|
|
89
|
+
yield* fs.makeDirectory(dirname(pathToCreate), {
|
|
90
|
+
recursive: true
|
|
91
|
+
});
|
|
92
|
+
yield* fs.writeFileString(pathToCreate, Yaml.stringify(configValues));
|
|
93
|
+
return _ConfigService.of(new Config(configValues));
|
|
94
|
+
}))
|
|
95
|
+
);
|
|
96
|
+
};
|
|
185
97
|
};
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
98
|
+
var profileBuiltinDefaults = (profile) => {
|
|
99
|
+
invariant(!profile.endsWith(".yml"), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: void 0, A: ["!profile.endsWith('.yml')", ""] });
|
|
100
|
+
return new Config({
|
|
101
|
+
runtime: {
|
|
102
|
+
client: {
|
|
103
|
+
edgeFeatures: {
|
|
104
|
+
echoReplicator: true,
|
|
105
|
+
feedReplicator: true,
|
|
106
|
+
signaling: true,
|
|
107
|
+
agents: true
|
|
108
|
+
},
|
|
109
|
+
storage: {
|
|
110
|
+
persistent: true,
|
|
111
|
+
dataRoot: getProfilePath(DX_DATA, profile)
|
|
199
112
|
}
|
|
200
113
|
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
log.catch(err);
|
|
204
|
-
return {};
|
|
205
|
-
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
206
116
|
};
|
|
207
117
|
|
|
208
|
-
// src/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
PERFORMING_CONFIG_SAVE = true;
|
|
218
|
-
try {
|
|
219
|
-
await localforage2.setItem("dxos.org/settings/config", config);
|
|
220
|
-
} catch (err) {
|
|
221
|
-
log2.warn("Failed to save config", { err });
|
|
222
|
-
return {};
|
|
223
|
-
} finally {
|
|
224
|
-
PERFORMING_CONFIG_SAVE = false;
|
|
225
|
-
}
|
|
118
|
+
// src/index.ts
|
|
119
|
+
export * from "#loaders";
|
|
120
|
+
export * from "#savers";
|
|
121
|
+
export * from "#plugin";
|
|
122
|
+
|
|
123
|
+
// src/telemetry.ts
|
|
124
|
+
import { isNode } from "@dxos/util";
|
|
125
|
+
var resolveTelemetryTag = (config) => {
|
|
126
|
+
return config?.get("runtime.app.env.DX_TELEMETRY_TAG") ?? (isNode() ? process.env.DX_TELEMETRY_TAG : void 0);
|
|
226
127
|
};
|
|
227
128
|
|
|
228
|
-
// src/
|
|
229
|
-
|
|
230
|
-
var
|
|
231
|
-
|
|
129
|
+
// src/preset.ts
|
|
130
|
+
import * as Match from "effect/Match";
|
|
131
|
+
var configPreset = ({ edge = "main" } = {}) => new Config({
|
|
132
|
+
version: 1,
|
|
133
|
+
runtime: {
|
|
134
|
+
client: {
|
|
135
|
+
edgeFeatures: {
|
|
136
|
+
signaling: true,
|
|
137
|
+
echoReplicator: true,
|
|
138
|
+
feedReplicator: true
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
services: {
|
|
142
|
+
edge: {
|
|
143
|
+
url: Match.value(edge).pipe(Match.when("local", () => "http://localhost:8787"), Match.when("dev", () => "https://edge.dxos.workers.dev"), Match.when("main", () => "https://edge-main.dxos.workers.dev"), Match.when("production", () => "https://edge-production.dxos.workers.dev"), Match.exhaustive)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
232
148
|
export {
|
|
233
149
|
Config,
|
|
234
150
|
ConfigResource,
|
|
235
|
-
|
|
236
|
-
Dynamics,
|
|
237
|
-
Envs,
|
|
151
|
+
ConfigService,
|
|
238
152
|
FILE_DEFAULTS,
|
|
239
153
|
FILE_DYNAMICS,
|
|
240
154
|
FILE_ENVS,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
SaveConfig,
|
|
244
|
-
Storage,
|
|
155
|
+
configPreset,
|
|
156
|
+
defaultConfig,
|
|
245
157
|
defs,
|
|
246
158
|
mapFromKeyValues,
|
|
247
159
|
mapToKeyValues,
|
|
160
|
+
memoryConfig,
|
|
161
|
+
resolveTelemetryTag,
|
|
248
162
|
validateConfig
|
|
249
163
|
};
|
|
250
164
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/config.ts", "../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\n// TODO(burdon): Why is this exported? (Rename).\nexport * as defs from '@dxos/protocols/proto/dxos/config';\n\nexport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nexport * from './config';\nexport * from './loaders';\nexport * from '
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["defs", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/config-service.ts", "../../../src/telemetry.ts", "../../../src/preset.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\n// TODO(burdon): Why is this exported? (Rename).\nexport * as defs from '@dxos/protocols/proto/dxos/config';\n\nexport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nexport * from './config';\nexport * from './config-service';\nexport * from '#loaders';\nexport * from '#savers';\nexport * from '#plugin';\nexport * from './telemetry';\nexport * from './types';\nexport * from './preset';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FileSystem from '@effect/platform/FileSystem';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport { dirname } from 'node:path';\nimport * as Yaml from 'yaml';\n\nimport { DX_CONFIG, DX_DATA, getProfileConfigPath, getProfilePath } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\n\nimport { Config } from './config';\n\nexport const memoryConfig = new Config({\n runtime: {\n client: {\n edgeFeatures: {\n echoReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n },\n },\n});\n\nexport const defaultConfig = new Config({\n runtime: {\n client: {\n edgeFeatures: {\n echoReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n storage: {\n persistent: true,\n },\n },\n services: {\n edge: {\n url: 'wss://edge-production.dxos.workers.dev/',\n },\n iceProviders: [\n {\n urls: 'https://edge-production.dxos.workers.dev/ice',\n },\n ],\n ai: {\n server: 'https://ai-service.dxos.workers.dev',\n },\n ipfs: {\n server: 'https://api.ipfs.dxos.network/api/v0',\n gateway: 'https://gateway.ipfs.dxos.network/ipfs',\n },\n },\n },\n});\n\nexport class ConfigService extends Context.Tag('ConfigService')<ConfigService, Config>() {\n static layerMemory = Layer.effect(ConfigService, Effect.succeed(memoryConfig));\n\n static fromConfig = (config: Config) => Layer.succeed(ConfigService, config);\n\n static load = (args: { config: Option.Option<string>; profile: string }) => {\n const defaultConfigPath = getProfileConfigPath(DX_CONFIG, args.profile);\n return Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const configPath = Option.getOrElse(args.config, () => defaultConfigPath);\n const configContent = yield* fs.readFileString(configPath);\n const configValues = Yaml.parse(configContent);\n return ConfigService.of(new Config(configValues, profileBuiltinDefaults(args.profile).values));\n }).pipe(\n // If the config file doesn't exist, create it.\n Effect.catchTag('SystemError', () =>\n Effect.gen(function* () {\n const configValues = defaultConfig.values;\n const fs = yield* FileSystem.FileSystem;\n const pathToCreate = Option.getOrElse(args.config, () => defaultConfigPath);\n yield* fs.makeDirectory(dirname(pathToCreate), { recursive: true });\n yield* fs.writeFileString(pathToCreate, Yaml.stringify(configValues));\n return ConfigService.of(new Config(configValues));\n }),\n ),\n );\n };\n}\n\n/**\n * Default config for a profile.\n * Always merged with the default config.\n */\nconst profileBuiltinDefaults = (profile: string) => {\n invariant(!profile.endsWith('.yml'));\n\n return new Config({\n runtime: {\n client: {\n edgeFeatures: {\n echoReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n storage: {\n persistent: true,\n dataRoot: getProfilePath(DX_DATA, profile),\n },\n },\n },\n });\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { isNode } from '@dxos/util';\n\nimport { type Config } from './config';\n\n/**\n * Resolves the telemetry tag used as the `X-DXOS-Client-Tag` header on edge\n * requests AND as the `ctx.tag` attribute / resource on observability traces.\n *\n * Keeping a single resolver ensures the same tag identifies a session across\n * edge and telemetry tiers. Precedence:\n *\n * 1. `config.runtime.app.env.DX_TELEMETRY_TAG` — the explicit, deterministic\n * path. Populated from `.env`/build-time by the app's config loaders.\n * 2. `process.env.DX_TELEMETRY_TAG` — Node-only, for dev/CI convenience.\n *\n * Returns `undefined` when unset; callers should no-op on undefined rather\n * than stamping empty strings.\n */\nexport const resolveTelemetryTag = (config?: Config): string | undefined => {\n return config?.get('runtime.app.env.DX_TELEMETRY_TAG') ?? (isNode() ? process.env.DX_TELEMETRY_TAG : undefined);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\n\nimport { Config } from './config';\n\nexport type ConfigPresetOptions = {\n /**\n * Edge service.\n * @default main\n */\n edge?: 'local' | 'dev' | 'main' | 'production';\n};\n\nexport const configPreset = ({ edge = 'main' }: ConfigPresetOptions = {}) =>\n new Config({\n version: 1,\n runtime: {\n client: {\n edgeFeatures: {\n signaling: true,\n echoReplicator: true,\n feedReplicator: true,\n },\n },\n services: {\n edge: {\n url: Match.value(edge).pipe(\n Match.when('local', () => 'http://localhost:8787'),\n Match.when('dev', () => 'https://edge.dxos.workers.dev'),\n Match.when('main', () => 'https://edge-main.dxos.workers.dev'),\n Match.when('production', () => 'https://edge-production.dxos.workers.dev'),\n Match.exhaustive,\n ),\n },\n },\n },\n });\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["defs", "FileSystem", "Context", "Effect", "Layer", "Option", "dirname", "Yaml", "DX_CONFIG", "DX_DATA", "getProfileConfigPath", "getProfilePath", "invariant", "memoryConfig", "client", "edgeFeatures", "echoReplicator", "feedReplicator", "signaling", "agents", "storage", "services", "url", "iceProviders", "ipfs", "gateway", "fromConfig", "succeed", "ConfigService", "config", "load", "args", "defaultConfigPath", "getProfileConfigPath", "DX_CONFIG", "Effect", "FileSystem", "configPath", "getOrElse", "configContent", "fs", "configValues", "parse", "of", "Config", "profileBuiltinDefaults", "pipe", "catchTag", "pathToCreate", "Option", "makeDirectory", "dirname", "recursive", "writeFileString", "runtime", "dataRoot", "isNode", "resolveTelemetryTag", "config", "get", "process", "env", "DX_TELEMETRY_TAG", "undefined", "Match", "configPreset", "edge", "Config", "version", "runtime", "client", "edgeFeatures", "signaling", "echoReplicator", "feedReplicator", "services", "url", "value", "pipe", "when", "exhaustive"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/loaders/browser.ts
|
|
2
|
+
import localforage from "localforage";
|
|
3
|
+
import { log } from "@dxos/log";
|
|
4
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/config/src/loaders/browser.ts";
|
|
5
|
+
var CONFIG_ENDPOINT = "/.well-known/dx/config";
|
|
6
|
+
var Profile = (_profile = "default") => ({});
|
|
7
|
+
var Local = () => {
|
|
8
|
+
return typeof __CONFIG_LOCAL__ !== "undefined" ? __CONFIG_LOCAL__ : {};
|
|
9
|
+
};
|
|
10
|
+
var Dynamics = async () => {
|
|
11
|
+
const { publicUrl = "", dynamic } = __DXOS_CONFIG__;
|
|
12
|
+
if (!dynamic) {
|
|
13
|
+
log("dynamics disabled", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 14, S: void 0 });
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
log("fetching config...", {
|
|
17
|
+
publicUrl
|
|
18
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17, S: void 0 });
|
|
19
|
+
return await fetch(`${publicUrl}${CONFIG_ENDPOINT}`).then((res) => res.json()).catch((error) => {
|
|
20
|
+
log.warn("Failed to fetch dynamic config.", error, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 21, S: void 0 });
|
|
21
|
+
return {};
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var Envs = (_basePath) => {
|
|
25
|
+
return typeof __CONFIG_ENVS__ !== "undefined" ? __CONFIG_ENVS__ : {};
|
|
26
|
+
};
|
|
27
|
+
var Defaults = (_basePath) => {
|
|
28
|
+
return typeof __CONFIG_DEFAULTS__ !== "undefined" ? __CONFIG_DEFAULTS__ : {};
|
|
29
|
+
};
|
|
30
|
+
var Storage = async () => {
|
|
31
|
+
try {
|
|
32
|
+
const config = await localforage.getItem("org.dxos.settings.config");
|
|
33
|
+
if (config) {
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
36
|
+
} catch (err) {
|
|
37
|
+
log.warn("Failed to load config", {
|
|
38
|
+
err
|
|
39
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 40, S: void 0 });
|
|
40
|
+
}
|
|
41
|
+
return {};
|
|
42
|
+
};
|
|
43
|
+
var Remote = (target, authenticationToken) => {
|
|
44
|
+
if (!target) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL(target);
|
|
49
|
+
const protocol = url.protocol.slice(0, -1);
|
|
50
|
+
return {
|
|
51
|
+
runtime: {
|
|
52
|
+
client: {
|
|
53
|
+
// TODO(burdon): Remove vault.html.
|
|
54
|
+
remoteSource: url.origin + (protocol.startsWith("http") ? "/vault.html" : ""),
|
|
55
|
+
remoteSourceAuthenticationToken: authenticationToken
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
} catch (err) {
|
|
60
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 63, S: void 0 });
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
Defaults,
|
|
66
|
+
Dynamics,
|
|
67
|
+
Envs,
|
|
68
|
+
Local,
|
|
69
|
+
Profile,
|
|
70
|
+
Remote,
|
|
71
|
+
Storage
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=browser.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/loaders/browser.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\n/* THIS FILE WILL BE LOADED BY CONTEXT REPLACEMENT PLUGIN IN BROWSER ENVS. */\n\nimport localforage from 'localforage';\n\nimport { log } from '@dxos/log';\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\ndeclare const __DXOS_CONFIG__: { publicUrl?: string; dynamic?: boolean };\ndeclare const __CONFIG_ENVS__: Partial<ConfigProto> | undefined;\ndeclare const __CONFIG_DEFAULTS__: Partial<ConfigProto> | undefined;\ndeclare const __CONFIG_LOCAL__: Partial<ConfigProto> | undefined;\n\nconst CONFIG_ENDPOINT = '/.well-known/dx/config';\n\nexport const Profile = (_profile = 'default'): Partial<ConfigProto> => ({});\n\nexport const Local = (): Partial<ConfigProto> => {\n return typeof __CONFIG_LOCAL__ !== 'undefined' ? __CONFIG_LOCAL__ : {};\n};\n\nexport const Dynamics = async (): Promise<Partial<ConfigProto>> => {\n const { publicUrl = '', dynamic } = __DXOS_CONFIG__;\n if (!dynamic) {\n log('dynamics disabled');\n return {};\n }\n\n log('fetching config...', { publicUrl });\n return await fetch(`${publicUrl}${CONFIG_ENDPOINT}`)\n .then((res) => res.json())\n .catch((error) => {\n log.warn('Failed to fetch dynamic config.', error);\n return {};\n });\n};\n\nexport const Envs = (_basePath?: string): Partial<ConfigProto> => {\n return typeof __CONFIG_ENVS__ !== 'undefined' ? __CONFIG_ENVS__ : {};\n};\n\nexport const Defaults = (_basePath?: string): Partial<ConfigProto> => {\n return typeof __CONFIG_DEFAULTS__ !== 'undefined' ? __CONFIG_DEFAULTS__ : {};\n};\n\n/**\n * Settings config from browser storage.\n */\nexport const Storage = async (): Promise<Partial<ConfigProto>> => {\n try {\n const config = await localforage.getItem<Partial<ConfigProto>>('org.dxos.settings.config');\n if (config) {\n return config;\n }\n } catch (err) {\n log.warn('Failed to load config', { err });\n }\n return {};\n};\n\nexport const Remote = (target: string | undefined, authenticationToken?: string): Partial<ConfigProto> => {\n if (!target) {\n return {};\n }\n\n try {\n const url = new URL(target);\n const protocol = url.protocol.slice(0, -1);\n\n return {\n runtime: {\n client: {\n // TODO(burdon): Remove vault.html.\n remoteSource: url.origin + (protocol.startsWith('http') ? '/vault.html' : ''),\n remoteSourceAuthenticationToken: authenticationToken,\n },\n },\n };\n } catch (err) {\n log.catch(err);\n return {};\n }\n};\n"],
|
|
5
|
+
"mappings": ";AAMA,OAAOA,iBAAiB;AAExB,SAASC,WAAW;AAQpB,IAAA,eAAMC;AAIN,IAAA,kBAAqB;AACnB,IAAO,UAAOC,CAAAA,WAAAA,eAAqB,CAAA;AACnC,IAAA,QAAA,MAAA;AAEF,SAAO,OAAMC,qBAAW,cAAA,mBAAA,CAAA;;AAEtB,IAAKC,WAAS,YAAA;QACZJ,EAAI,YAAA,IAAA,QAAA,IAAA;MACJ,CAAA,SAAQ;AACV,QAAA,qBAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;AAEI,WAAA,CAAA;;AAAkC,MAAA,sBAAA;IACtC;mBAGa,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAmCK,CAAAA;SAC5C,MAAQ,MAAA,GAAA,SAAA,GAAA,eAAA,EAAA,EAAA,KAAA,CAAA,QAAA,IAAA,KAAA,CAAA,EAAA,MAAA,CAAA,UAAA;AACV,QAAA,KAAA,mCAAA,OAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;AACF,WAAA,CAAA;EAEF,CAAA;;AAEE,IAAA,OAAA,CAAA,cAAA;AAEF,SAAO,OAAMC,oBAAYC,cAAAA,kBAAAA,CAAAA;;AAEvB,IAAA,WAAA,CAAA,cAAA;AAEF,SAAA,OAAA,wBAAA,cAAA,sBAAA,CAAA;;AAKI,IAAMC,UAAS,YAAMT;MACrB;UACE,SAAOS,MAAAA,YAAAA,QAAAA,0BAAAA;AACT,QAAA,QAAA;AACA,aAAY;IACZR;WAAoCS,KAAAA;AAAI,QAAA,KAAA,yBAAA;MAC1C;IACA,GAAA,EAAO,YAAC,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;EACR;AAEF,SAAO,CAAA;;IAEH,SAAQ,CAAA,QAAA,wBAAA;AACV,MAAA,CAAA,QAAA;AAEI,WAAA,CAAA;;MAEF;AAEA,UAAA,MAAO,IAAA,IAAA,MAAA;UACLC,WAAS,IAAA,SAAA,MAAA,GAAA,EAAA;;eAEL;gBACAC;;UAEF,cAAA,IAAA,UAAA,SAAA,WAAA,MAAA,IAAA,gBAAA;UACF,iCAAA;QACF;MACA;IACAX;WACA,KAAQ;AACV,QAAA,MAAA,KAAA,QAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,OAAA,CAAA;AACA,WAAA,CAAA;;;",
|
|
6
|
+
"names": ["localforage", "log", "CONFIG_ENDPOINT", "__CONFIG_LOCAL__", "Dynamics", "dynamic", "error", "Defaults", "_basePath", "config", "err", "runtime", "remoteSource"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FILE_DEFAULTS,
|
|
3
|
+
FILE_ENVS
|
|
4
|
+
} from "../chunk-VQRJY4AQ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
mapFromKeyValues
|
|
7
|
+
} from "../chunk-ZY4D4E3Q.mjs";
|
|
8
|
+
|
|
9
|
+
// src/loaders/index.ts
|
|
10
|
+
import fs from "@dxos/node-std/fs";
|
|
11
|
+
import path from "@dxos/node-std/path";
|
|
12
|
+
import { parse } from "yaml";
|
|
13
|
+
import { log } from "@dxos/log";
|
|
14
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/config/src/loaders/index.ts";
|
|
15
|
+
var DEFAULT_BASE_PATH = path.resolve(process.cwd(), "config");
|
|
16
|
+
var maybeLoadFile = (file) => {
|
|
17
|
+
try {
|
|
18
|
+
return parse(fs.readFileSync(file, {
|
|
19
|
+
encoding: "utf8"
|
|
20
|
+
}));
|
|
21
|
+
} catch (err) {
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var Profile = (profile = "default") => {
|
|
25
|
+
const configFile = path.join(process.env.HOME ?? "~", `.config/dx/profile/${profile}.yml`);
|
|
26
|
+
return maybeLoadFile(configFile);
|
|
27
|
+
};
|
|
28
|
+
var Local = () => ({});
|
|
29
|
+
var Dynamics = () => ({});
|
|
30
|
+
var Envs = (basePath = DEFAULT_BASE_PATH) => {
|
|
31
|
+
const content = maybeLoadFile(path.resolve(basePath, FILE_ENVS));
|
|
32
|
+
return content ? mapFromKeyValues(content, process.env) : {};
|
|
33
|
+
};
|
|
34
|
+
var Defaults = (basePath = DEFAULT_BASE_PATH) => maybeLoadFile(path.resolve(basePath, FILE_DEFAULTS)) ?? {};
|
|
35
|
+
var Storage = async () => ({});
|
|
36
|
+
var Remote = (target, authenticationToken) => {
|
|
37
|
+
if (!target) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const url = new URL(target);
|
|
42
|
+
const protocol = url.protocol.slice(0, -1);
|
|
43
|
+
return {
|
|
44
|
+
runtime: {
|
|
45
|
+
client: {
|
|
46
|
+
// TODO(burdon): Remove vault.html.
|
|
47
|
+
remoteSource: url.origin + (protocol.startsWith("http") ? "/vault.html" : ""),
|
|
48
|
+
remoteSourceAuthenticationToken: authenticationToken
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
} catch (err) {
|
|
53
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 66, S: void 0 });
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
Defaults,
|
|
59
|
+
Dynamics,
|
|
60
|
+
Envs,
|
|
61
|
+
Local,
|
|
62
|
+
Profile,
|
|
63
|
+
Remote,
|
|
64
|
+
Storage
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=index.mjs.map
|