silgi 0.9.27 → 0.9.29
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/dist/_chunks/index.mjs +1 -1
- package/dist/kit/index.d.mts +2 -3
- package/dist/kit/index.d.ts +2 -3
- package/dist/kit/index.mjs +30 -2
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import * as consola from 'consola';
|
|
3
3
|
import { ConsolaOptions } from 'consola';
|
|
4
|
-
import
|
|
5
|
-
import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
|
|
4
|
+
import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Resolve a module from a given root path using an algorithm patterned on
|
|
@@ -83,7 +82,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
|
|
|
83
82
|
*
|
|
84
83
|
* This mirrors the runtime behavior of Nitro.
|
|
85
84
|
*/
|
|
86
|
-
declare function useSilgiRuntimeConfig():
|
|
85
|
+
declare function useSilgiRuntimeConfig(event?: SilgiEvents): any;
|
|
87
86
|
declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
|
|
88
87
|
|
|
89
88
|
/**
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import * as consola from 'consola';
|
|
3
3
|
import { ConsolaOptions } from 'consola';
|
|
4
|
-
import
|
|
5
|
-
import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
|
|
4
|
+
import { ModuleOptionsCustom, ModuleDefinition, SilgiModule, SilgiCLI, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Resolve a module from a given root path using an algorithm patterned on
|
|
@@ -83,7 +82,7 @@ declare function resolveSilgiModule(base: string, paths: string[]): Promise<stri
|
|
|
83
82
|
*
|
|
84
83
|
* This mirrors the runtime behavior of Nitro.
|
|
85
84
|
*/
|
|
86
|
-
declare function useSilgiRuntimeConfig():
|
|
85
|
+
declare function useSilgiRuntimeConfig(event?: SilgiEvents): any;
|
|
87
86
|
declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
|
|
88
87
|
|
|
89
88
|
/**
|
package/dist/kit/index.mjs
CHANGED
|
@@ -256,10 +256,28 @@ async function resolveSilgiModule(base, paths) {
|
|
|
256
256
|
return resolved;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
const _inlineRuntimeConfig = process$1.env.RUNTIME_CONFIG;
|
|
260
|
+
const envOptions = {
|
|
261
|
+
prefix: "NITRO_",
|
|
262
|
+
altPrefix: _inlineRuntimeConfig?.nitro.envPrefix ?? process$1.env.NITRO_ENV_PREFIX ?? "_",
|
|
263
|
+
envExpansion: _inlineRuntimeConfig?.nitro.envExpansion ?? process$1.env.NITRO_ENV_EXPANSION ?? false
|
|
264
|
+
};
|
|
265
|
+
const _sharedRuntimeConfig = _deepFreeze(
|
|
266
|
+
applyEnv(klona(_inlineRuntimeConfig ?? {}), envOptions)
|
|
267
|
+
);
|
|
268
|
+
function useSilgiRuntimeConfig(event) {
|
|
260
269
|
const silgi = tryUseSilgi();
|
|
261
270
|
if (!silgi) {
|
|
262
|
-
|
|
271
|
+
const data = globalThis.$silgiSharedRuntimeConfig;
|
|
272
|
+
if (data) {
|
|
273
|
+
return data;
|
|
274
|
+
}
|
|
275
|
+
if (!event) {
|
|
276
|
+
return _sharedRuntimeConfig;
|
|
277
|
+
}
|
|
278
|
+
const runtimeConfig = klona(_inlineRuntimeConfig);
|
|
279
|
+
applyEnv(runtimeConfig, envOptions);
|
|
280
|
+
return runtimeConfig;
|
|
263
281
|
}
|
|
264
282
|
return applyEnv(klona(silgi.runtimeConfig), {
|
|
265
283
|
prefix: "NITRO_",
|
|
@@ -306,6 +324,16 @@ function _expandFromEnv(value, env = process$1.env) {
|
|
|
306
324
|
return env[key] || match;
|
|
307
325
|
});
|
|
308
326
|
}
|
|
327
|
+
function _deepFreeze(object) {
|
|
328
|
+
const propNames = Object.getOwnPropertyNames(object);
|
|
329
|
+
for (const name of propNames) {
|
|
330
|
+
const value = object[name];
|
|
331
|
+
if (value && typeof value === "object") {
|
|
332
|
+
_deepFreeze(value);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return Object.freeze(object);
|
|
336
|
+
}
|
|
309
337
|
|
|
310
338
|
const RELATIVE_RE = /^([^.])/;
|
|
311
339
|
function relativeWithDot(from, to) {
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED