@dxos/config 0.8.3 → 0.8.4-main.f9ba587

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/lib/browser/index.mjs +5 -5
  2. package/dist/lib/browser/meta.json +1 -1
  3. package/dist/lib/node-esm/index.mjs +23 -13
  4. package/dist/lib/node-esm/index.mjs.map +3 -3
  5. package/dist/lib/node-esm/meta.json +1 -1
  6. package/dist/plugin/browser/chunk-AN62TER6.mjs +231 -0
  7. package/dist/plugin/browser/chunk-AN62TER6.mjs.map +7 -0
  8. package/dist/plugin/browser/esbuild-plugin.mjs +25 -0
  9. package/dist/plugin/{node/esbuild-plugin.cjs.map → browser/esbuild-plugin.mjs.map} +2 -2
  10. package/dist/plugin/browser/meta.json +1 -0
  11. package/dist/plugin/browser/rollup-plugin.mjs +19 -0
  12. package/dist/plugin/{node/rollup-plugin.cjs.map → browser/rollup-plugin.mjs.map} +2 -2
  13. package/dist/plugin/browser/vite-plugin.mjs +30 -0
  14. package/dist/plugin/browser/vite-plugin.mjs.map +7 -0
  15. package/dist/plugin/node-esm/{chunk-PAFU3TJI.mjs → chunk-HYTOW36U.mjs} +19 -9
  16. package/dist/plugin/node-esm/chunk-HYTOW36U.mjs.map +7 -0
  17. package/dist/plugin/node-esm/esbuild-plugin.mjs +2 -2
  18. package/dist/plugin/node-esm/meta.json +1 -1
  19. package/dist/plugin/node-esm/rollup-plugin.mjs +2 -2
  20. package/dist/plugin/node-esm/vite-plugin.mjs +6 -6
  21. package/dist/plugin/node-esm/vite-plugin.mjs.map +3 -3
  22. package/dist/types/src/plugin/definitions.d.ts +3 -3
  23. package/dist/types/src/plugin/definitions.d.ts.map +1 -1
  24. package/dist/types/src/plugin/types.d.ts +4 -0
  25. package/dist/types/src/plugin/types.d.ts.map +1 -1
  26. package/dist/types/src/plugin/vite-plugin.d.ts +1 -1
  27. package/dist/types/src/plugin/vite-plugin.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +7 -6
  30. package/src/plugin/definitions.ts +3 -3
  31. package/src/plugin/types.ts +5 -0
  32. package/src/plugin/vite-plugin.ts +8 -5
  33. package/src/testing/build.js +1 -1
  34. package/README.yml +0 -1
  35. package/dist/lib/node/index.cjs +0 -357
  36. package/dist/lib/node/index.cjs.map +0 -7
  37. package/dist/lib/node/meta.json +0 -1
  38. package/dist/plugin/node/chunk-SLXRWZWZ.cjs +0 -249
  39. package/dist/plugin/node/chunk-SLXRWZWZ.cjs.map +0 -7
  40. package/dist/plugin/node/esbuild-plugin.cjs +0 -45
  41. package/dist/plugin/node/meta.json +0 -1
  42. package/dist/plugin/node/rollup-plugin.cjs +0 -39
  43. package/dist/plugin/node/vite-plugin.cjs +0 -50
  44. package/dist/plugin/node/vite-plugin.cjs.map +0 -7
  45. package/dist/plugin/node-esm/chunk-PAFU3TJI.mjs.map +0 -7
@@ -0,0 +1 @@
1
+ {"inputs":{"src/config.ts":{"bytes":15734,"imports":[{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/plugin/definitions.ts":{"bytes":12061,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"@dxos/node-std/child_process","kind":"import-statement","external":true},{"path":"@dxos/node-std/fs","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"}],"format":"esm"},"src/plugin/esbuild-plugin.ts":{"bytes":2571,"imports":[{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"src/plugin/rollup-plugin.ts":{"bytes":2055,"imports":[{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"src/plugin/vite-plugin.ts":{"bytes":3666,"imports":[{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"}},"outputs":{"dist/plugin/browser/esbuild-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1316},"dist/plugin/browser/esbuild-plugin.mjs":{"imports":[{"path":"dist/plugin/browser/chunk-AN62TER6.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/esbuild-plugin.ts","inputs":{"src/plugin/esbuild-plugin.ts":{"bytesInOutput":436}},"bytes":594},"dist/plugin/browser/rollup-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1072},"dist/plugin/browser/rollup-plugin.mjs":{"imports":[{"path":"dist/plugin/browser/chunk-AN62TER6.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/rollup-plugin.ts","inputs":{"src/plugin/rollup-plugin.ts":{"bytesInOutput":281}},"bytes":437},"dist/plugin/browser/vite-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1835},"dist/plugin/browser/vite-plugin.mjs":{"imports":[{"path":"dist/plugin/browser/chunk-AN62TER6.mjs","kind":"import-statement"},{"path":"@dxos/node-std/path","kind":"import-statement","external":true}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/vite-plugin.ts","inputs":{"src/plugin/vite-plugin.ts":{"bytesInOutput":684}},"bytes":836},"dist/plugin/browser/chunk-AN62TER6.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13091},"dist/plugin/browser/chunk-AN62TER6.mjs":{"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"@dxos/node-std/child_process","kind":"import-statement","external":true},{"path":"@dxos/node-std/fs","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["definitions"],"inputs":{"src/plugin/definitions.ts":{"bytesInOutput":3234},"src/config.ts":{"bytesInOutput":3576}},"bytes":6958}}}
@@ -0,0 +1,19 @@
1
+ import {
2
+ definitions
3
+ } from "./chunk-AN62TER6.mjs";
4
+
5
+ // src/plugin/rollup-plugin.ts
6
+ var ConfigPlugin = (options = {}) => {
7
+ const contents = Object.entries(definitions({
8
+ ...options,
9
+ mode: "development"
10
+ })).map(([key, value]) => `globalThis.${key} = ${JSON.stringify(value)};`).join("\n");
11
+ return {
12
+ name: "dxos-config",
13
+ banner: contents
14
+ };
15
+ };
16
+ export {
17
+ ConfigPlugin
18
+ };
19
+ //# sourceMappingURL=rollup-plugin.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugin/rollup-plugin.ts"],
4
4
  "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Plugin } from 'rollup';\n\nimport { definitions } from './definitions';\nimport { type ConfigPluginOpts } from './types';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => {\n const contents = Object.entries(definitions({ ...options, mode: process.env.NODE_ENV }))\n .map(([key, value]) => `globalThis.${key} = ${JSON.stringify(value)};`)\n .join('\\n');\n\n return {\n name: 'dxos-config',\n banner: contents,\n };\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AASO,IAAMA,eAAe,CAACC,UAA4B,CAAC,MAAC;AACzD,QAAMC,WAAWC,OAAOC,YAAQC,mCAAY;IAAE,GAAGJ;IAASK,MAAMC,QAAQC,IAAIC;EAAS,CAAA,CAAA,EAClFC,IAAI,CAAC,CAACC,KAAKC,KAAAA,MAAW,cAAcD,GAAAA,MAASE,KAAKC,UAAUF,KAAAA,CAAAA,GAAS,EACrEG,KAAK,IAAA;AAER,SAAO;IACLC,MAAM;IACNC,QAAQf;EACV;AACF;",
6
- "names": ["ConfigPlugin", "options", "contents", "Object", "entries", "definitions", "mode", "process", "env", "NODE_ENV", "map", "key", "value", "JSON", "stringify", "join", "name", "banner"]
5
+ "mappings": ";;;;;AASO,IAAMA,eAAe,CAACC,UAA4B,CAAC,MAAC;AACzD,QAAMC,WAAWC,OAAOC,QAAQC,YAAY;IAAE,GAAGJ;IAASK,MAAMC;EAAqB,CAAA,CAAA,EAClFC,IAAI,CAAC,CAACC,KAAKC,KAAAA,MAAW,cAAcD,GAAAA,MAASE,KAAKC,UAAUF,KAAAA,CAAAA,GAAS,EACrEG,KAAK,IAAA;AAER,SAAO;IACLC,MAAM;IACNC,QAAQb;EACV;AACF;",
6
+ "names": ["ConfigPlugin", "options", "contents", "Object", "entries", "definitions", "mode", "process", "map", "key", "value", "JSON", "stringify", "join", "name", "banner"]
7
7
  }
@@ -0,0 +1,30 @@
1
+ import {
2
+ definitions
3
+ } from "./chunk-AN62TER6.mjs";
4
+
5
+ // src/plugin/vite-plugin.ts
6
+ import { resolve } from "@dxos/node-std/path";
7
+ var ConfigPlugin = (options = {}) => ({
8
+ name: "dxos-config",
9
+ config: () => {
10
+ const configPath = options.root && resolve(options.root, options.configPath ?? "dx.yml");
11
+ const envPath = options.root && resolve(options.root, options.envPath ?? "dx-env.yml");
12
+ const devPath = options.root && resolve(options.root, options.devPath ?? "dx-local.yml");
13
+ const define = Object.entries(definitions({
14
+ ...options,
15
+ configPath,
16
+ envPath,
17
+ devPath
18
+ })).reduce((define2, [key, value]) => {
19
+ define2[key] = JSON.stringify(value);
20
+ return define2;
21
+ }, {});
22
+ return {
23
+ define
24
+ };
25
+ }
26
+ });
27
+ export {
28
+ ConfigPlugin
29
+ };
30
+ //# sourceMappingURL=vite-plugin.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugin/vite-plugin.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { resolve } from 'node:path';\nimport { type Plugin } from 'vite';\n\nimport { definitions } from './definitions';\nimport { type ConfigPluginOpts } from './types';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => ({\n name: 'dxos-config',\n config: () => {\n // Update paths.\n const configPath = options.root && resolve(options.root, options.configPath ?? 'dx.yml');\n const envPath = options.root && resolve(options.root, options.envPath ?? 'dx-env.yml');\n // TODO(burdon): Change to dx-dev.yml?\n const devPath = options.root && resolve(options.root, options.devPath ?? 'dx-local.yml');\n\n const define = Object.entries(definitions({ ...options, configPath, envPath, devPath })).reduce(\n (define, [key, value]) => {\n define[key] = JSON.stringify(value);\n return define;\n },\n {} as { [key: string]: string },\n );\n\n return { define };\n },\n});\n"],
5
+ "mappings": ";;;;;AAIA,SAASA,eAAe;AAMjB,IAAMC,eAAe,CAACC,UAA4B,CAAC,OAAe;EACvEC,MAAM;EACNC,QAAQ,MAAA;AAEN,UAAMC,aAAaH,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQG,cAAc,QAAA;AAC/E,UAAMG,UAAUN,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQM,WAAW,YAAA;AAEzE,UAAMC,UAAUP,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQO,WAAW,cAAA;AAEzE,UAAMC,SAASC,OAAOC,QAAQC,YAAY;MAAE,GAAGX;MAASG;MAAYG;MAASC;IAAQ,CAAA,CAAA,EAAIK,OACvF,CAACJ,SAAQ,CAACK,KAAKC,KAAAA,MAAM;AACnBN,MAAAA,QAAOK,GAAAA,IAAOE,KAAKC,UAAUF,KAAAA;AAC7B,aAAON;IACT,GACA,CAAC,CAAA;AAGH,WAAO;MAAEA;IAAO;EAClB;AACF;",
6
+ "names": ["resolve", "ConfigPlugin", "options", "name", "config", "configPath", "root", "resolve", "envPath", "devPath", "define", "Object", "entries", "definitions", "reduce", "key", "value", "JSON", "stringify"]
7
+ }
@@ -1,15 +1,16 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // packages/sdk/config/src/plugin/definitions.ts
3
+ // src/plugin/definitions.ts
4
4
  import yaml from "js-yaml";
5
5
  import { execSync } from "node:child_process";
6
6
  import { readFileSync } from "node:fs";
7
7
  import { resolve } from "node:path";
8
8
  import pkgUp from "pkg-up";
9
+ import { invariant } from "@dxos/invariant";
9
10
  import { log } from "@dxos/log";
10
11
  import { setDeep as setDeep2 } from "@dxos/util";
11
12
 
12
- // packages/sdk/config/src/config.ts
13
+ // src/config.ts
13
14
  import { boolean } from "boolean";
14
15
  import defaultsDeep from "lodash.defaultsdeep";
15
16
  import isMatch from "lodash.ismatch";
@@ -125,8 +126,8 @@ Config = _ts_decorate([
125
126
  })
126
127
  ], Config);
127
128
 
128
- // packages/sdk/config/src/plugin/definitions.ts
129
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/config/src/plugin/definitions.ts";
129
+ // src/plugin/definitions.ts
130
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/config/src/plugin/definitions.ts";
130
131
  var CWD = process.cwd();
131
132
  var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV, publicUrl = "", env }) => {
132
133
  const KEYS_TO_FILE = {
@@ -137,6 +138,15 @@ var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV,
137
138
  KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? resolve(CWD, "dx-local.yml");
138
139
  }
139
140
  return Object.entries(KEYS_TO_FILE).reduce((prev, [key, value]) => {
141
+ invariant(key, void 0, {
142
+ F: __dxlog_file,
143
+ L: 38,
144
+ S: void 0,
145
+ A: [
146
+ "key",
147
+ ""
148
+ ]
149
+ });
140
150
  let content = {};
141
151
  try {
142
152
  content = yaml.load(readFileSync(value, "utf-8"));
@@ -207,17 +217,17 @@ var definitions = ({ configPath, envPath, devPath, mode = process.env.NODE_ENV,
207
217
  [key]: content
208
218
  };
209
219
  }, {
220
+ __CONFIG_DEFAULTS__: {},
221
+ __CONFIG_ENVS__: {},
222
+ __CONFIG_LOCAL__: {},
210
223
  __DXOS_CONFIG__: {
211
224
  dynamic: mode === "production",
212
225
  publicUrl
213
- },
214
- __CONFIG_DEFAULTS__: {},
215
- __CONFIG_ENVS__: {},
216
- __CONFIG_LOCAL__: {}
226
+ }
217
227
  });
218
228
  };
219
229
 
220
230
  export {
221
231
  definitions
222
232
  };
223
- //# sourceMappingURL=chunk-PAFU3TJI.mjs.map
233
+ //# sourceMappingURL=chunk-HYTOW36U.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugin/definitions.ts", "../../../src/config.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport yaml from 'js-yaml';\nimport { execSync } from 'node:child_process';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport pkgUp from 'pkg-up';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { setDeep } from '@dxos/util';\n\nimport { type ConfigPluginOpts } from './types';\nimport { mapFromKeyValues } from '../config';\n\nconst CWD = process.cwd();\n\nexport const definitions = ({\n configPath,\n envPath,\n devPath,\n mode = process.env.NODE_ENV,\n publicUrl = '',\n env,\n}: ConfigPluginOpts) => {\n const KEYS_TO_FILE = {\n __CONFIG_DEFAULTS__: configPath?.length ? configPath : resolve(CWD, 'dx.yml'),\n __CONFIG_ENVS__: envPath?.length ? envPath : resolve(CWD, 'dx-env.yml'),\n } as { [key: string]: string };\n if (mode !== 'production') {\n KEYS_TO_FILE.__CONFIG_LOCAL__ = devPath ?? resolve(CWD, 'dx-local.yml');\n }\n\n return Object.entries(KEYS_TO_FILE).reduce(\n (prev, [key, value]) => {\n invariant(key);\n let content = {};\n try {\n content = yaml.load(readFileSync(value, 'utf-8')) as any;\n\n // Map environment variables to config values.\n if (key === '__CONFIG_ENVS__') {\n content = mapFromKeyValues(content, process.env);\n }\n\n if (key === '__CONFIG_DEFAULTS__') {\n // Load app environment variables into default config.\n Object.entries(process.env).forEach(([key, value]) => {\n if (key.startsWith('DX_') || env?.includes(key)) {\n setDeep(content, ['runtime', 'app', 'env', key], value);\n }\n });\n\n // Set build info automatically if available.\n try {\n const timestamp = new Date().toISOString();\n const commitHash =\n process.env.DX_COMMIT_HASH ??\n execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).replace('\\n', '');\n const packagePath = pkgUp.sync();\n const packageJson = packagePath && JSON.parse(readFileSync(packagePath, 'utf-8'));\n setDeep(content, ['runtime', 'app', 'build', 'timestamp'], timestamp);\n setDeep(content, ['runtime', 'app', 'build', 'commitHash'], commitHash);\n setDeep(content, ['runtime', 'app', 'build', 'version'], packageJson?.version);\n } catch {}\n }\n } catch (err: any) {\n if (err.message.includes('YAMLException')) {\n log.error(`Failed to parse file ${value}:`, err);\n } else {\n log(`Failed to load file ${value}:`, err);\n }\n\n if (key === '__CONFIG_DEFAULTS__') {\n // Default config is required.\n throw new Error(`Failed to load default config file from ${value}`);\n }\n }\n\n return {\n ...prev,\n [key]: content,\n };\n },\n {\n __CONFIG_DEFAULTS__: {},\n __CONFIG_ENVS__: {},\n __CONFIG_LOCAL__: {},\n __DXOS_CONFIG__: { dynamic: mode === 'production', publicUrl },\n },\n );\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport { boolean } from 'boolean';\nimport defaultsDeep from 'lodash.defaultsdeep';\nimport isMatch from 'lodash.ismatch';\n\nimport { InvalidConfigError } from '@dxos/protocols';\nimport { schema } from '@dxos/protocols/proto';\nimport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\nimport { trace } from '@dxos/tracing';\nimport { getDeep, setDeep } from '@dxos/util';\n\nimport { type ConfigKey, type DeepIndex, type ParseKey } from './types';\n\ntype MappingSpec = Record<string, { path: string; type?: string }>;\nconst configRootType = schema.getCodecForType('dxos.config.Config');\n\n/**\n * Maps the given objects onto a flattened set of (key x values).\n *\n * Expects parsed yaml content of the form:\n *\n * ```\n * ENV_VAR:\n * path: config.selector.path\n * ```\n *\n * @param {object} spec\n * @param {object} values\n * @return {object}\n */\nexport const mapFromKeyValues = (spec: MappingSpec, values: Record<string, any>) => {\n const config = {};\n\n for (const [key, { path, type }] of Object.entries(spec)) {\n let value = values[key];\n\n if (value !== undefined) {\n if (type) {\n switch (type) {\n case 'boolean': {\n value = boolean(value);\n break;\n }\n\n case 'number': {\n value = Number(value);\n break;\n }\n\n case 'string': {\n break;\n }\n\n case 'json': {\n value = value ? JSON.parse(value) : null;\n break;\n }\n\n default: {\n throw new Error(`Invalid type: ${type}`);\n }\n }\n }\n\n setDeep(config, path.split('.'), value);\n }\n }\n\n return config;\n};\n\n/**\n * Maps the given flattend set of (key x values) onto a JSON object.\n * @param {object} spec\n * @param {object} values\n */\nexport const mapToKeyValues = (spec: MappingSpec, values: any) => {\n const config: Record<string, any> = {};\n\n for (const [key, { path, type }] of Object.entries(spec)) {\n const value = getDeep(values, path.split('.'));\n if (value !== undefined) {\n switch (type) {\n case 'json':\n config[key] = JSON.stringify(value);\n break;\n default:\n config[key] = value;\n }\n }\n }\n\n return config;\n};\n\n/**\n * Validate config object.\n */\nexport const validateConfig = (config: ConfigProto): ConfigProto => {\n if (!('version' in config)) {\n throw new InvalidConfigError('Version not specified');\n }\n\n if (config?.version !== 1) {\n throw new InvalidConfigError(`Invalid config version: ${config.version}`);\n }\n\n const error = configRootType.protoType.verify(config);\n if (error) {\n throw new InvalidConfigError(error);\n }\n\n return config;\n};\n\nexport const ConfigResource = Symbol.for('dxos.resource.Config');\n\n/**\n * Global configuration object.\n * NOTE: Config objects are immutable.\n */\n@trace.resource({ annotation: ConfigResource })\nexport class Config {\n private readonly _config: any;\n\n /**\n * Creates an immutable instance.\n * @constructor\n */\n constructor(config: ConfigProto = {}, ...objects: ConfigProto[]) {\n this._config = validateConfig(defaultsDeep(config, ...objects, { version: 1 }));\n }\n\n /**\n * Returns an immutable config JSON object.\n */\n get values(): ConfigProto {\n return this._config;\n }\n\n /**\n * Returns the given config property.\n *\n * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.\n * @param defaultValue Default value to return if option is not present in the config.\n * @returns The config value or undefined if the option is not present.\n */\n get<K extends ConfigKey>(\n key: K,\n defaultValue?: DeepIndex<ConfigProto, ParseKey<K>>,\n ): DeepIndex<ConfigProto, ParseKey<K>> | undefined {\n return getDeep(this._config, key.split('.')) ?? defaultValue;\n }\n\n /**\n * Get unique key.\n */\n find<T = any>(path: string, test: object): T | undefined {\n const values = getDeep(this._config, path.split('.'));\n if (!Array.isArray(values)) {\n return;\n }\n\n return values.find((value) => isMatch(value, test));\n }\n\n /**\n * Returns the given config property or throw if it doesn't exist.\n *\n * @param key A key in the config object. Can be a nested property with keys separated by dots: 'services.signal.server'.\n */\n getOrThrow<K extends ConfigKey>(key: K): Exclude<DeepIndex<ConfigProto, ParseKey<K>>, undefined> {\n const value: DeepIndex<ConfigProto, ParseKey<K>> | undefined = getDeep(this._config, key.split('.'));\n if (!value) {\n throw new Error(`Config option not present: ${key}`);\n }\n return value;\n }\n}\n"],
5
+ "mappings": ";;;AAIA,OAAOA,UAAU;AACjB,SAASC,gBAAgB;AACzB,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AACxB,OAAOC,WAAW;AAElB,SAASC,iBAAiB;AAC1B,SAASC,WAAW;AACpB,SAASC,WAAAA,gBAAe;;;ACRxB,SAASC,eAAe;AACx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AAO;MACpE;IACF;AAEA,WAAO;MACL,GAAGF;MACH,CAACC,GAAAA,GAAMG;IACT;EACF,GACA;IACEZ,qBAAqB,CAAC;IACtBG,iBAAiB,CAAC;IAClBC,kBAAkB,CAAC;IACnBqC,iBAAiB;MAAEC,SAAS/C,SAAS;MAAcG;IAAU;EAC/D,CAAA;AAEJ;",
6
+ "names": ["yaml", "execSync", "readFileSync", "resolve", "pkgUp", "invariant", "log", "setDeep", "boolean", "defaultsDeep", "isMatch", "InvalidConfigError", "schema", "trace", "getDeep", "setDeep", "configRootType", "schema", "getCodecForType", "mapFromKeyValues", "spec", "values", "config", "key", "path", "type", "Object", "entries", "value", "undefined", "boolean", "Number", "JSON", "parse", "Error", "setDeep", "split", "validateConfig", "config", "InvalidConfigError", "version", "error", "configRootType", "protoType", "verify", "ConfigResource", "Symbol", "for", "Config", "objects", "_config", "defaultsDeep", "values", "get", "key", "defaultValue", "getDeep", "split", "find", "path", "test", "Array", "isArray", "value", "isMatch", "getOrThrow", "Error", "resource", "annotation", "CWD", "process", "cwd", "definitions", "configPath", "envPath", "devPath", "mode", "env", "NODE_ENV", "publicUrl", "KEYS_TO_FILE", "__CONFIG_DEFAULTS__", "length", "resolve", "__CONFIG_ENVS__", "__CONFIG_LOCAL__", "Object", "entries", "reduce", "prev", "key", "value", "invariant", "content", "yaml", "load", "readFileSync", "mapFromKeyValues", "forEach", "startsWith", "includes", "setDeep", "timestamp", "Date", "toISOString", "commitHash", "DX_COMMIT_HASH", "execSync", "encoding", "replace", "packagePath", "pkgUp", "sync", "packageJson", "JSON", "parse", "version", "err", "message", "log", "error", "Error", "__DXOS_CONFIG__", "dynamic"]
7
+ }
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  definitions
4
- } from "./chunk-PAFU3TJI.mjs";
4
+ } from "./chunk-HYTOW36U.mjs";
5
5
 
6
- // packages/sdk/config/src/plugin/esbuild-plugin.ts
6
+ // src/plugin/esbuild-plugin.ts
7
7
  var ConfigPlugin = (options = {}) => {
8
8
  return {
9
9
  name: "dxos-config",
@@ -1 +1 @@
1
- {"inputs":{"packages/sdk/config/src/config.ts":{"bytes":15747,"imports":[{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/sdk/config/src/plugin/definitions.ts":{"bytes":11670,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/sdk/config/src/config.ts","kind":"import-statement","original":"../config"}],"format":"esm"},"packages/sdk/config/src/plugin/esbuild-plugin.ts":{"bytes":2584,"imports":[{"path":"packages/sdk/config/src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"packages/sdk/config/src/plugin/rollup-plugin.ts":{"bytes":2068,"imports":[{"path":"packages/sdk/config/src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"packages/sdk/config/src/plugin/vite-plugin.ts":{"bytes":3319,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"packages/sdk/config/src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"}},"outputs":{"packages/sdk/config/dist/plugin/node-esm/esbuild-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1347},"packages/sdk/config/dist/plugin/node-esm/esbuild-plugin.mjs":{"imports":[{"path":"packages/sdk/config/dist/plugin/node-esm/chunk-PAFU3TJI.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"packages/sdk/config/src/plugin/esbuild-plugin.ts","inputs":{"packages/sdk/config/src/plugin/esbuild-plugin.ts":{"bytesInOutput":443}},"bytes":713},"packages/sdk/config/dist/plugin/node-esm/rollup-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1103},"packages/sdk/config/dist/plugin/node-esm/rollup-plugin.mjs":{"imports":[{"path":"packages/sdk/config/dist/plugin/node-esm/chunk-PAFU3TJI.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"packages/sdk/config/src/plugin/rollup-plugin.ts","inputs":{"packages/sdk/config/src/plugin/rollup-plugin.ts":{"bytesInOutput":288}},"bytes":556},"packages/sdk/config/dist/plugin/node-esm/vite-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1708},"packages/sdk/config/dist/plugin/node-esm/vite-plugin.mjs":{"imports":[{"path":"packages/sdk/config/dist/plugin/node-esm/chunk-PAFU3TJI.mjs","kind":"import-statement"},{"path":"node:path","kind":"import-statement","external":true}],"exports":["ConfigPlugin"],"entryPoint":"packages/sdk/config/src/plugin/vite-plugin.ts","inputs":{"packages/sdk/config/src/plugin/vite-plugin.ts":{"bytesInOutput":634}},"bytes":898},"packages/sdk/config/dist/plugin/node-esm/chunk-PAFU3TJI.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12976},"packages/sdk/config/dist/plugin/node-esm/chunk-PAFU3TJI.mjs":{"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["definitions"],"inputs":{"packages/sdk/config/src/plugin/definitions.ts":{"bytesInOutput":3044},"packages/sdk/config/src/config.ts":{"bytesInOutput":3576}},"bytes":6921}}}
1
+ {"inputs":{"src/config.ts":{"bytes":15734,"imports":[{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/plugin/definitions.ts":{"bytes":12061,"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/config.ts","kind":"import-statement","original":"../config"}],"format":"esm"},"src/plugin/esbuild-plugin.ts":{"bytes":2571,"imports":[{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"src/plugin/rollup-plugin.ts":{"bytes":2055,"imports":[{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"},"src/plugin/vite-plugin.ts":{"bytes":3666,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"src/plugin/definitions.ts","kind":"import-statement","original":"./definitions"}],"format":"esm"}},"outputs":{"dist/plugin/node-esm/esbuild-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1347},"dist/plugin/node-esm/esbuild-plugin.mjs":{"imports":[{"path":"dist/plugin/node-esm/chunk-HYTOW36U.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/esbuild-plugin.ts","inputs":{"src/plugin/esbuild-plugin.ts":{"bytesInOutput":443}},"bytes":693},"dist/plugin/node-esm/rollup-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1103},"dist/plugin/node-esm/rollup-plugin.mjs":{"imports":[{"path":"dist/plugin/node-esm/chunk-HYTOW36U.mjs","kind":"import-statement"}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/rollup-plugin.ts","inputs":{"src/plugin/rollup-plugin.ts":{"bytesInOutput":288}},"bytes":536},"dist/plugin/node-esm/vite-plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1836},"dist/plugin/node-esm/vite-plugin.mjs":{"imports":[{"path":"dist/plugin/node-esm/chunk-HYTOW36U.mjs","kind":"import-statement"},{"path":"node:path","kind":"import-statement","external":true}],"exports":["ConfigPlugin"],"entryPoint":"src/plugin/vite-plugin.ts","inputs":{"src/plugin/vite-plugin.ts":{"bytesInOutput":674}},"bytes":918},"dist/plugin/node-esm/chunk-HYTOW36U.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":13118},"dist/plugin/node-esm/chunk-HYTOW36U.mjs":{"imports":[{"path":"js-yaml","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"pkg-up","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"boolean","kind":"import-statement","external":true},{"path":"lodash.defaultsdeep","kind":"import-statement","external":true},{"path":"lodash.ismatch","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto","kind":"import-statement","external":true},{"path":"@dxos/tracing","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["definitions"],"inputs":{"src/plugin/definitions.ts":{"bytesInOutput":3211},"src/config.ts":{"bytesInOutput":3576}},"bytes":7028}}}
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  definitions
4
- } from "./chunk-PAFU3TJI.mjs";
4
+ } from "./chunk-HYTOW36U.mjs";
5
5
 
6
- // packages/sdk/config/src/plugin/rollup-plugin.ts
6
+ // src/plugin/rollup-plugin.ts
7
7
  var ConfigPlugin = (options = {}) => {
8
8
  const contents = Object.entries(definitions({
9
9
  ...options,
@@ -1,16 +1,16 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  definitions
4
- } from "./chunk-PAFU3TJI.mjs";
4
+ } from "./chunk-HYTOW36U.mjs";
5
5
 
6
- // packages/sdk/config/src/plugin/vite-plugin.ts
6
+ // src/plugin/vite-plugin.ts
7
7
  import { resolve } from "node:path";
8
8
  var ConfigPlugin = (options = {}) => ({
9
9
  name: "dxos-config",
10
- config: ({ root }) => {
11
- const configPath = root && resolve(root, options.configPath ?? "dx.yml");
12
- const envPath = root && resolve(root, options.envPath ?? "dx-env.yml");
13
- const devPath = root && resolve(root, options.devPath ?? "dx-local.yml");
10
+ config: () => {
11
+ const configPath = options.root && resolve(options.root, options.configPath ?? "dx.yml");
12
+ const envPath = options.root && resolve(options.root, options.envPath ?? "dx-env.yml");
13
+ const devPath = options.root && resolve(options.root, options.devPath ?? "dx-local.yml");
14
14
  const define = Object.entries(definitions({
15
15
  ...options,
16
16
  configPath,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugin/vite-plugin.ts"],
4
- "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { resolve } from 'node:path';\nimport type { Plugin } from 'vite';\n\nimport { definitions } from './definitions';\nimport { type ConfigPluginOpts } from './types';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => ({\n name: 'dxos-config',\n config: ({ root }) => {\n const configPath = root && resolve(root, options.configPath ?? 'dx.yml');\n const envPath = root && resolve(root, options.envPath ?? 'dx-env.yml');\n const devPath = root && resolve(root, options.devPath ?? 'dx-local.yml');\n const define = Object.entries(definitions({ ...options, configPath, envPath, devPath })).reduce(\n (define, [key, value]) => {\n define[key] = JSON.stringify(value);\n return define;\n },\n {} as { [key: string]: string },\n );\n\n return { define };\n },\n});\n"],
5
- "mappings": ";;;;;;AAIA,SAASA,eAAe;AAMjB,IAAMC,eAAe,CAACC,UAA4B,CAAC,OAAe;EACvEC,MAAM;EACNC,QAAQ,CAAC,EAAEC,KAAI,MAAE;AACf,UAAMC,aAAaD,QAAQE,QAAQF,MAAMH,QAAQI,cAAc,QAAA;AAC/D,UAAME,UAAUH,QAAQE,QAAQF,MAAMH,QAAQM,WAAW,YAAA;AACzD,UAAMC,UAAUJ,QAAQE,QAAQF,MAAMH,QAAQO,WAAW,cAAA;AACzD,UAAMC,SAASC,OAAOC,QAAQC,YAAY;MAAE,GAAGX;MAASI;MAAYE;MAASC;IAAQ,CAAA,CAAA,EAAIK,OACvF,CAACJ,SAAQ,CAACK,KAAKC,KAAAA,MAAM;AACnBN,MAAAA,QAAOK,GAAAA,IAAOE,KAAKC,UAAUF,KAAAA;AAC7B,aAAON;IACT,GACA,CAAC,CAAA;AAGH,WAAO;MAAEA;IAAO;EAClB;AACF;",
6
- "names": ["resolve", "ConfigPlugin", "options", "name", "config", "root", "configPath", "resolve", "envPath", "devPath", "define", "Object", "entries", "definitions", "reduce", "key", "value", "JSON", "stringify"]
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { resolve } from 'node:path';\nimport { type Plugin } from 'vite';\n\nimport { definitions } from './definitions';\nimport { type ConfigPluginOpts } from './types';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => ({\n name: 'dxos-config',\n config: () => {\n // Update paths.\n const configPath = options.root && resolve(options.root, options.configPath ?? 'dx.yml');\n const envPath = options.root && resolve(options.root, options.envPath ?? 'dx-env.yml');\n // TODO(burdon): Change to dx-dev.yml?\n const devPath = options.root && resolve(options.root, options.devPath ?? 'dx-local.yml');\n\n const define = Object.entries(definitions({ ...options, configPath, envPath, devPath })).reduce(\n (define, [key, value]) => {\n define[key] = JSON.stringify(value);\n return define;\n },\n {} as { [key: string]: string },\n );\n\n return { define };\n },\n});\n"],
5
+ "mappings": ";;;;;;AAIA,SAASA,eAAe;AAMjB,IAAMC,eAAe,CAACC,UAA4B,CAAC,OAAe;EACvEC,MAAM;EACNC,QAAQ,MAAA;AAEN,UAAMC,aAAaH,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQG,cAAc,QAAA;AAC/E,UAAMG,UAAUN,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQM,WAAW,YAAA;AAEzE,UAAMC,UAAUP,QAAQI,QAAQC,QAAQL,QAAQI,MAAMJ,QAAQO,WAAW,cAAA;AAEzE,UAAMC,SAASC,OAAOC,QAAQC,YAAY;MAAE,GAAGX;MAASG;MAAYG;MAASC;IAAQ,CAAA,CAAA,EAAIK,OACvF,CAACJ,SAAQ,CAACK,KAAKC,KAAAA,MAAM;AACnBN,MAAAA,QAAOK,GAAAA,IAAOE,KAAKC,UAAUF,KAAAA;AAC7B,aAAON;IACT,GACA,CAAC,CAAA;AAGH,WAAO;MAAEA;IAAO;EAClB;AACF;",
6
+ "names": ["resolve", "ConfigPlugin", "options", "name", "config", "configPath", "root", "resolve", "envPath", "devPath", "define", "Object", "entries", "definitions", "reduce", "key", "value", "JSON", "stringify"]
7
7
  }
@@ -1,11 +1,11 @@
1
1
  import { type ConfigPluginOpts } from './types';
2
2
  export declare const definitions: ({ configPath, envPath, devPath, mode, publicUrl, env, }: ConfigPluginOpts) => {
3
+ __CONFIG_DEFAULTS__: {};
4
+ __CONFIG_ENVS__: {};
5
+ __CONFIG_LOCAL__: {};
3
6
  __DXOS_CONFIG__: {
4
7
  dynamic: boolean;
5
8
  publicUrl: string;
6
9
  };
7
- __CONFIG_DEFAULTS__: {};
8
- __CONFIG_ENVS__: {};
9
- __CONFIG_LOCAL__: {};
10
10
  };
11
11
  //# sourceMappingURL=definitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/plugin/definitions.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKhD,eAAO,MAAM,WAAW,GAAI,yDAOzB,gBAAgB;;;;;;;;CAoElB,CAAC"}
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/plugin/definitions.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKhD,eAAO,MAAM,WAAW,GAAI,yDAOzB,gBAAgB;;;;;;;;CAmElB,CAAC"}
@@ -1,4 +1,8 @@
1
1
  export interface ConfigPluginOpts {
2
+ /**
3
+ * Root directory of the project.
4
+ */
5
+ root?: string;
2
6
  /**
3
7
  * Path to the DX config files, defaults to current working directory.
4
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/plugin/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB"}
@@ -1,4 +1,4 @@
1
- import type { Plugin } from 'vite';
1
+ import { type Plugin } from 'vite';
2
2
  import { type ConfigPluginOpts } from './types';
3
3
  export declare const ConfigPlugin: (options?: ConfigPluginOpts) => Plugin;
4
4
  //# sourceMappingURL=vite-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugin/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,YAAY,GAAI,UAAS,gBAAqB,KAAG,MAgB5D,CAAC"}
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugin/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,YAAY,GAAI,UAAS,gBAAqB,KAAG,MAmB5D,CAAC"}