silgi 0.23.10 → 0.24.0

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 (42) hide show
  1. package/dist/cli/compatibility.mjs +1 -1
  2. package/dist/cli/dev.mjs +2 -1
  3. package/dist/cli/index.mjs +4 -1
  4. package/dist/cli/init.mjs +1 -1
  5. package/dist/cli/install.mjs +2 -1
  6. package/dist/cli/prepare.mjs +7 -6
  7. package/dist/cli/types.mjs +1 -1
  8. package/dist/{core/index.d.mts → index.d.mts} +1 -1
  9. package/dist/{core/index.d.ts → index.d.ts} +1 -1
  10. package/dist/{core/index.mjs → index.mjs} +3 -3
  11. package/dist/kit/index.d.mts +2 -11
  12. package/dist/kit/index.d.ts +2 -11
  13. package/dist/kit/index.mjs +3 -104
  14. package/dist/runtime/index.d.ts +2 -0
  15. package/dist/runtime/index.mjs +2 -0
  16. package/dist/runtime/internal/config.d.ts +10 -0
  17. package/dist/runtime/internal/config.mjs +110 -0
  18. package/dist/runtime/internal/index.d.ts +1 -0
  19. package/dist/runtime/internal/index.mjs +1 -0
  20. package/dist/runtime/internal/nitro.mjs +1 -1
  21. package/lib/config.d.mts +7 -0
  22. package/lib/config.mjs +5 -0
  23. package/lib/meta.d.mts +4 -0
  24. package/lib/meta.mjs +6 -0
  25. package/{runtime-meta.mjs → lib/runtime-meta.mjs} +3 -3
  26. package/package.json +14 -63
  27. package/cli.d.ts +0 -1
  28. package/config.d.ts +0 -1
  29. package/core.d.ts +0 -1
  30. package/dist/_chunks/index.mjs +0 -72
  31. package/dist/config/index.d.mts +0 -5
  32. package/dist/config/index.d.ts +0 -5
  33. package/dist/config/index.mjs +0 -5
  34. package/dist/meta/index.d.mts +0 -70
  35. package/dist/meta/index.d.ts +0 -70
  36. package/dist/meta/index.mjs +0 -1
  37. package/kit.d.ts +0 -1
  38. package/meta.d.ts +0 -1
  39. package/presets.d.ts +0 -1
  40. package/runtime.d.ts +0 -1
  41. package/types.d.ts +0 -1
  42. /package/{runtime-meta.d.ts → lib/runtime-meta.d.mts} +0 -0
@@ -1,5 +1,5 @@
1
1
  import satisfies from 'semver/functions/satisfies.js';
2
- import { useSilgiCLI } from 'silgi/core';
2
+ import { useSilgiCLI } from 'silgi';
3
3
  import { version } from 'silgi/meta';
4
4
 
5
5
  const SEMANTIC_VERSION_RE = /-\d+\.[0-9a-f]+/;
package/dist/cli/dev.mjs CHANGED
@@ -3,7 +3,7 @@ import { watch } from 'chokidar';
3
3
  import { defineCommand, runCommand } from 'citty';
4
4
  import consola from 'consola';
5
5
  import { join } from 'pathe';
6
- import { useSilgiCLI } from 'silgi/core';
6
+ import { useSilgiCLI } from 'silgi';
7
7
  import { version } from 'silgi/meta';
8
8
  import { s as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
9
9
  import { c as commonArgs, p as prepare } from './prepare.mjs';
@@ -31,6 +31,7 @@ import 'globby';
31
31
  import 'ignore';
32
32
  import '@oxc-parser/wasm';
33
33
  import 'klona';
34
+ import 'silgi/runtime';
34
35
  import 'unstorage';
35
36
  import './types.mjs';
36
37
  import 'c12';
@@ -1,5 +1,8 @@
1
1
  import { defineCommand, runMain } from 'citty';
2
- import { p as packageJson } from '../_chunks/index.mjs';
2
+
3
+ const version = "0.24.0";
4
+ const packageJson = {
5
+ version: version};
3
6
 
4
7
  const main = defineCommand({
5
8
  meta: {
package/dist/cli/init.mjs CHANGED
@@ -39,7 +39,7 @@ const init = defineCommand({
39
39
  ];
40
40
  if (framework === "nitro" || framework === "nuxt") {
41
41
  const plugin = [
42
- `import { buildSilgi } from '../silgi/core'`,
42
+ `import { buildSilgi } from '../silgi'`,
43
43
  "",
44
44
  "export default defineNitroPlugin(async (nitro) => {",
45
45
  " const _silgi = buildSilgi(",
@@ -10,7 +10,7 @@ import 'knitwork';
10
10
  import 'silgi/kit';
11
11
  import 'node:fs/promises';
12
12
  import 'hookable';
13
- import 'silgi/core';
13
+ import 'silgi';
14
14
  import 'silgi/runtime/meta';
15
15
  import 'silgi/types';
16
16
  import 'unimport';
@@ -31,6 +31,7 @@ import 'globby';
31
31
  import 'ignore';
32
32
  import '@oxc-parser/wasm';
33
33
  import 'klona';
34
+ import 'silgi/runtime';
34
35
  import 'unstorage';
35
36
  import 'pathe/utils';
36
37
  import 'picocolors';
@@ -2,12 +2,12 @@ import { defineCommand, runCommand } from 'citty';
2
2
  import { join, resolve, relative, dirname, basename, extname, isAbsolute } from 'pathe';
3
3
  import { peerDependencies, version } from 'silgi/meta';
4
4
  import { genObjectFromRawEntries, genObjectFromRaw, genObjectFromValues } from 'knitwork';
5
- import { writeFile, relativeWithDot, hash, resolveAlias, directoryToURL, addTemplate, hasError, parseServices, useSilgiRuntimeConfig, normalizeTemplate, useLogger, initRuntimeConfig, resolveSilgiPath, genEnsureSafeVar, isDirectory } from 'silgi/kit';
5
+ import { writeFile, relativeWithDot, hash, resolveAlias, directoryToURL, addTemplate, hasError, parseServices, normalizeTemplate, useLogger, initRuntimeConfig, resolveSilgiPath, genEnsureSafeVar, isDirectory } from 'silgi/kit';
6
6
  import { existsSync, promises, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
7
7
  import { readdir, readFile } from 'node:fs/promises';
8
8
  import consola, { consola as consola$1 } from 'consola';
9
9
  import { createHooks, createDebugger } from 'hookable';
10
- import { useSilgiCLI, replaceRuntimeValues, silgiCLICtx } from 'silgi/core';
10
+ import { useSilgiCLI, replaceRuntimeValues, silgiCLICtx } from 'silgi';
11
11
  import { runtimeDir } from 'silgi/runtime/meta';
12
12
  import { autoImportTypes } from 'silgi/types';
13
13
  import { scanExports, createUnimport, toExports } from 'unimport';
@@ -26,6 +26,7 @@ import { globby } from 'globby';
26
26
  import ignore from 'ignore';
27
27
  import { parseSync } from '@oxc-parser/wasm';
28
28
  import { klona } from 'klona';
29
+ import { useSilgiRuntimeConfig } from 'silgi/runtime';
29
30
  import { createStorage, builtinDrivers } from 'unstorage';
30
31
  import { l as loadOptions, s as silgiGenerateType } from './types.mjs';
31
32
  import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
@@ -863,7 +864,7 @@ function resolveGroupSyntax(group) {
863
864
 
864
865
  const safeFiles = [
865
866
  "silgi/configs",
866
- "silgi/core",
867
+ "silgi",
867
868
  "silgi/rules",
868
869
  "silgi/scan",
869
870
  "silgi/vfs"
@@ -1628,7 +1629,6 @@ async function scanDir(silgi, dir, name) {
1628
1629
 
1629
1630
  async function createSilgiCLI(config = {}, opts = {}) {
1630
1631
  const options = await loadOptions(config, opts);
1631
- await prepareEnv(options);
1632
1632
  const hooks = createHooks();
1633
1633
  const silgi = {
1634
1634
  modulesURIs: {},
@@ -1655,6 +1655,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
1655
1655
  },
1656
1656
  routeRules: void 0
1657
1657
  };
1658
+ await prepareEnv(options);
1658
1659
  const routeRules = createRouteRules();
1659
1660
  routeRules.importRules(options.routeRules ?? {});
1660
1661
  silgi.routeRules = routeRules;
@@ -1746,7 +1747,7 @@ async function prepareConfigs(silgi) {
1746
1747
  await silgi.callHook("prepare:configs.ts", _data);
1747
1748
  const importData = [
1748
1749
  "import type { SilgiRuntimeOptions, SilgiRuntimeConfig, SilgiOptions } from 'silgi/types'",
1749
- "import { useSilgiRuntimeConfig } from 'silgi/kit'",
1750
+ "import { useSilgiRuntimeConfig } from 'silgi'",
1750
1751
  "",
1751
1752
  `export const runtimeConfig: Partial<SilgiRuntimeConfig> = ${genObjectFromRawEntries(
1752
1753
  Object.entries(_data.runtimeConfig).map(([key, value]) => [key, genEnsureSafeVar(value)]),
@@ -2536,7 +2537,7 @@ const run = defineCommand({
2536
2537
  alias: silgiConfig.alias
2537
2538
  });
2538
2539
  let cleanHandler = cmd.handler.handler.replace(/\n/g, "");
2539
- cleanHandler = `import { silgiCLICtx } from 'silgi/core'
2540
+ cleanHandler = `import { silgiCLICtx } from 'silgi'
2540
2541
  ${cleanHandler}
2541
2542
  `;
2542
2543
  await jiti.evalModule(cleanHandler, {
@@ -285,7 +285,7 @@ function getSilgiImportsPreset() {
285
285
  // ],
286
286
  // },
287
287
  {
288
- from: "silgi/core",
288
+ from: "silgi",
289
289
  imports: ["useSilgiStorage"]
290
290
  }
291
291
  // {
@@ -1,5 +1,5 @@
1
1
  import { SilgiConfig, Silgi, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, SilgiRuntimeSharedsExtend, SilgiEvents, SilgiRuntimeContext, DefaultNamespaces, BaseSchemaType, SilgiRuntimeShareds, StorageConfig, SilgiCLI, SilgiStorageBase } from 'silgi/types';
2
- export { s as silgi } from '../shared/silgi.Cs0ZUUXV.mjs';
2
+ export { s as silgi } from './shared/silgi.Cs0ZUUXV.mjs';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Storage, StorageValue } from 'unstorage';
5
5
  import * as unctx from 'unctx';
@@ -1,5 +1,5 @@
1
1
  import { SilgiConfig, Silgi, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, SilgiRuntimeSharedsExtend, SilgiEvents, SilgiRuntimeContext, DefaultNamespaces, BaseSchemaType, SilgiRuntimeShareds, StorageConfig, SilgiCLI, SilgiStorageBase } from 'silgi/types';
2
- export { s as silgi } from '../shared/silgi.Cs0ZUUXV.js';
2
+ export { s as silgi } from './shared/silgi.Cs0ZUUXV.js';
3
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
4
4
  import { Storage, StorageValue } from 'unstorage';
5
5
  import * as unctx from 'unctx';
@@ -1,12 +1,12 @@
1
1
  import { createConsola } from 'consola';
2
2
  import defu, { defu as defu$1 } from 'defu';
3
3
  import { createHooks } from 'hookable';
4
- import { c as createRouteRules } from '../_chunks/silgiApp.mjs';
5
- export { a as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
4
+ import { c as createRouteRules } from './_chunks/silgiApp.mjs';
5
+ export { a as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from './_chunks/silgiApp.mjs';
6
6
  import { getContext } from 'unctx';
7
7
  import { Buffer } from 'node:buffer';
8
8
  import { klona } from 'klona';
9
- import { useSilgiRuntimeConfig } from 'silgi/kit';
9
+ import { useSilgiRuntimeConfig } from 'silgi/runtime';
10
10
  import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
11
11
  import 'ufo';
12
12
 
@@ -1,4 +1,4 @@
1
- import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiRuntimeConfig, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
1
+ import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
2
2
  import { Buffer } from 'node:buffer';
3
3
  import * as consola from 'consola';
4
4
  import { ConsolaOptions } from 'consola';
@@ -106,15 +106,6 @@ interface Resolver {
106
106
  declare function createResolver(base: string | URL): Resolver;
107
107
  declare function resolveSilgiModule(base: string, paths: string[]): Promise<string[]>;
108
108
 
109
- /**
110
- * Access 'resolved' Nuxt runtime configuration, with values updated from environment.
111
- *
112
- * This mirrors the runtime behavior of Nitro.
113
- */
114
- declare function useSilgiRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvents, inlineRuntimeConfig?: Record<string, any>): SilgiRuntimeConfig;
115
- declare function initRuntimeConfig(envOptions?: EnvOptions, inlineRuntimeConfig?: Record<string, any>): Readonly<Record<string, any>>;
116
- declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
117
-
118
109
  /**
119
110
  * Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
120
111
  */
@@ -158,4 +149,4 @@ declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolea
158
149
  declare const baseHeaderBannerComment: string[];
159
150
  declare function processFilePath(src: string): string;
160
151
 
161
- export { MODE_RE, addTemplate, applyEnv, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, useSilgiRuntimeConfig, writeFile };
152
+ export { MODE_RE, addTemplate, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
@@ -1,4 +1,4 @@
1
- import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, EnvOptions, SilgiRuntimeConfig, SilgiEvents, SilgiTemplate, ResolvedSilgiTemplate } from 'silgi/types';
1
+ import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
2
2
  import { Buffer } from 'node:buffer';
3
3
  import * as consola from 'consola';
4
4
  import { ConsolaOptions } from 'consola';
@@ -106,15 +106,6 @@ interface Resolver {
106
106
  declare function createResolver(base: string | URL): Resolver;
107
107
  declare function resolveSilgiModule(base: string, paths: string[]): Promise<string[]>;
108
108
 
109
- /**
110
- * Access 'resolved' Nuxt runtime configuration, with values updated from environment.
111
- *
112
- * This mirrors the runtime behavior of Nitro.
113
- */
114
- declare function useSilgiRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvents, inlineRuntimeConfig?: Record<string, any>): SilgiRuntimeConfig;
115
- declare function initRuntimeConfig(envOptions?: EnvOptions, inlineRuntimeConfig?: Record<string, any>): Readonly<Record<string, any>>;
116
- declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
117
-
118
109
  /**
119
110
  * Renders given template during build into the virtual file system (and optionally to disk in the project `buildDir`)
120
111
  */
@@ -158,4 +149,4 @@ declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolea
158
149
  declare const baseHeaderBannerComment: string[];
159
150
  declare function processFilePath(src: string): string;
160
151
 
161
- export { MODE_RE, addTemplate, applyEnv, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, useSilgiRuntimeConfig, writeFile };
152
+ export { MODE_RE, addTemplate, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
@@ -1,4 +1,4 @@
1
- import { tryUseSilgiCLI, useSilgiCLI, useSilgi, tryUseSilgi } from 'silgi/core';
1
+ import { tryUseSilgiCLI, useSilgiCLI, useSilgi } from 'silgi';
2
2
  import { pathToFileURL, fileURLToPath } from 'node:url';
3
3
  import { resolvePath as resolvePath$1 } from 'mlly';
4
4
  import fsp from 'node:fs/promises';
@@ -8,14 +8,12 @@ import { colors } from 'consola/utils';
8
8
  import { getProperty } from 'dot-prop';
9
9
  import { genString, genObjectFromRaw, genObjectFromValues, genObjectFromRawEntries } from 'knitwork';
10
10
  import { hash as hash$1 } from 'ohash';
11
- import { camelCase, snakeCase } from 'scule';
11
+ import { camelCase } from 'scule';
12
12
  import { defu } from 'defu';
13
13
  import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
14
14
  import { withLeadingSlash } from 'ufo';
15
15
  import { existsSync, promises } from 'node:fs';
16
16
  import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
17
- import destr from 'destr';
18
- import { klona } from 'klona';
19
17
  import { hash as hash$2 } from 'silgi/kit';
20
18
  import 'semver/functions/satisfies.js';
21
19
  import 'silgi/meta';
@@ -359,105 +357,6 @@ async function resolveSilgiModule(base, paths) {
359
357
  return resolved;
360
358
  }
361
359
 
362
- const silgiRuntimeConfig = process.env.RUNTIME_CONFIG;
363
- const envOptions = {
364
- prefix: "NITRO_",
365
- altPrefix: silgiRuntimeConfig?.nitro.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
366
- silgiPrefix: "SILGI_",
367
- envExpansion: silgiRuntimeConfig?.nitro.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false
368
- };
369
- let _sharedRuntimeConfig = _deepFreeze(
370
- applyEnv(klona(silgiRuntimeConfig ?? {}), envOptions)
371
- );
372
- function useSilgiRuntimeConfig(event, inlineRuntimeConfig = {}) {
373
- const silgi = tryUseSilgi();
374
- if (!silgi) {
375
- if (globalThis.$silgiSharedRuntimeConfig) {
376
- inlineRuntimeConfig = globalThis.$silgiSharedRuntimeConfig;
377
- if (inlineRuntimeConfig && !event) {
378
- return inlineRuntimeConfig;
379
- }
380
- }
381
- if (!silgiRuntimeConfig) {
382
- _sharedRuntimeConfig = initRuntimeConfig(envOptions, inlineRuntimeConfig);
383
- }
384
- if (!event) {
385
- return _sharedRuntimeConfig;
386
- }
387
- const runtimeConfig2 = klona(silgiRuntimeConfig);
388
- applyEnv(runtimeConfig2, envOptions);
389
- return runtimeConfig2;
390
- }
391
- if (!silgiRuntimeConfig) {
392
- _sharedRuntimeConfig = initRuntimeConfig(envOptions, inlineRuntimeConfig);
393
- }
394
- if (!event) {
395
- return _sharedRuntimeConfig;
396
- }
397
- const runtimeConfig = klona(silgiRuntimeConfig);
398
- applyEnv(runtimeConfig, envOptions);
399
- return runtimeConfig;
400
- }
401
- function initRuntimeConfig(envOptions2 = {}, inlineRuntimeConfig = {}) {
402
- const finalEnvOptions = {
403
- prefix: "NITRO_",
404
- altPrefix: inlineRuntimeConfig?.nitro?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
405
- silgiPrefix: "SILGI_",
406
- envExpansion: inlineRuntimeConfig?.nitro?.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false,
407
- ...envOptions2
408
- };
409
- return _deepFreeze(
410
- applyEnv(klona(inlineRuntimeConfig), finalEnvOptions)
411
- );
412
- }
413
- function getEnv(key, opts, env = process.env) {
414
- const envKey = snakeCase(key).toUpperCase();
415
- return destr(
416
- env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey] ?? env[opts.silgiPrefix + envKey]
417
- );
418
- }
419
- function _isObject(input) {
420
- return typeof input === "object" && !Array.isArray(input);
421
- }
422
- function applyEnv(obj, opts, parentKey = "") {
423
- for (const key in obj) {
424
- const subKey = parentKey ? `${parentKey}_${key}` : key;
425
- const envValue = getEnv(subKey, opts);
426
- if (_isObject(obj[key])) {
427
- if (_isObject(envValue)) {
428
- obj[key] = { ...obj[key], ...envValue };
429
- applyEnv(obj[key], opts, subKey);
430
- } else if (envValue === void 0) {
431
- applyEnv(obj[key], opts, subKey);
432
- } else {
433
- obj[key] = envValue ?? obj[key];
434
- }
435
- } else {
436
- obj[key] = envValue ?? obj[key];
437
- }
438
- if (opts.envExpansion && typeof obj[key] === "string") {
439
- obj[key] = _expandFromEnv(obj[key]);
440
- }
441
- }
442
- return obj;
443
- }
444
- const envExpandRx = /\{\{([^{}]*)\}\}/g;
445
- function _expandFromEnv(value, env = process.env) {
446
- return value.replace(envExpandRx, (match, key) => {
447
- return env[key] || match;
448
- });
449
- }
450
- function _deepFreeze(object) {
451
- const propNames = Object.getOwnPropertyNames(object);
452
- for (const name of propNames) {
453
- const value = object[name];
454
- if (value && typeof value === "object") {
455
- _deepFreeze(value);
456
- }
457
- }
458
- return Object.freeze(object);
459
- }
460
-
461
360
  const RELATIVE_RE = /^([^.])/;
462
361
  function relativeWithDot(from, to) {
463
362
  return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
@@ -627,4 +526,4 @@ function isValidIp(ip) {
627
526
  return false;
628
527
  }
629
528
 
630
- export { MODE_RE, addTemplate, applyEnv, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, useSilgiRuntimeConfig, writeFile };
529
+ export { MODE_RE, addTemplate, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
@@ -1 +1,3 @@
1
+ export { useSilgiRuntimeConfig } from './internal/config';
1
2
  export { defineSilgiPlugin } from './internal/plugin';
3
+ export { mergeDeep } from './internal/defu';
@@ -1 +1,3 @@
1
+ export { useSilgiRuntimeConfig } from "./internal/config.mjs";
1
2
  export { defineSilgiPlugin } from "./internal/plugin.mjs";
3
+ export { mergeDeep } from "./internal/defu.mjs";
@@ -0,0 +1,10 @@
1
+ import type { EnvOptions, SilgiEvents, SilgiRuntimeConfig } from 'silgi/types';
2
+ /**
3
+ * Access 'resolved' Nuxt runtime configuration, with values updated from environment.
4
+ *
5
+ * This mirrors the runtime behavior of Nitro.
6
+ */
7
+ export declare function useSilgiRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvents, inlineRuntimeConfig?: Record<string, any>): SilgiRuntimeConfig;
8
+ export declare function initRuntimeConfig(envOptions?: EnvOptions, inlineRuntimeConfig?: Record<string, any>): Readonly<Record<string, any>>;
9
+ export declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void;
10
+ export declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
@@ -0,0 +1,110 @@
1
+ import defu from "defu";
2
+ import destr from "destr";
3
+ import { klona } from "klona";
4
+ import { snakeCase } from "scule";
5
+ import { tryUseSilgi, useSilgi } from "silgi";
6
+ const silgiRuntimeConfig = globalThis.__nitro__?.useRuntimeConfig?.() || process.env.RUNTIME_CONFIG;
7
+ const envOptions = {
8
+ prefix: "NITRO_",
9
+ altPrefix: silgiRuntimeConfig?.nitro?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
10
+ silgiPrefix: "SILGI_",
11
+ envExpansion: silgiRuntimeConfig?.nitro.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false
12
+ };
13
+ let _sharedRuntimeConfig = _deepFreeze(
14
+ applyEnv(klona(silgiRuntimeConfig ?? {}), envOptions)
15
+ );
16
+ export function useSilgiRuntimeConfig(event, inlineRuntimeConfig = {}) {
17
+ const silgi = tryUseSilgi();
18
+ if (!silgi) {
19
+ if (globalThis.$silgiSharedRuntimeConfig) {
20
+ inlineRuntimeConfig = globalThis.$silgiSharedRuntimeConfig;
21
+ if (inlineRuntimeConfig && !event) {
22
+ return inlineRuntimeConfig;
23
+ }
24
+ }
25
+ if (!silgiRuntimeConfig) {
26
+ _sharedRuntimeConfig = initRuntimeConfig(envOptions, inlineRuntimeConfig);
27
+ }
28
+ if (!event) {
29
+ return _sharedRuntimeConfig;
30
+ }
31
+ const runtimeConfig2 = klona(silgiRuntimeConfig);
32
+ applyEnv(runtimeConfig2, envOptions);
33
+ return runtimeConfig2;
34
+ }
35
+ if (!silgiRuntimeConfig) {
36
+ _sharedRuntimeConfig = initRuntimeConfig(envOptions, inlineRuntimeConfig);
37
+ }
38
+ if (!event) {
39
+ return _sharedRuntimeConfig;
40
+ }
41
+ const runtimeConfig = klona(silgiRuntimeConfig);
42
+ applyEnv(runtimeConfig, envOptions);
43
+ return runtimeConfig;
44
+ }
45
+ export function initRuntimeConfig(envOptions2 = {}, inlineRuntimeConfig = {}) {
46
+ const finalEnvOptions = {
47
+ prefix: "NITRO_",
48
+ altPrefix: inlineRuntimeConfig?.nitro?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
49
+ silgiPrefix: "SILGI_",
50
+ envExpansion: inlineRuntimeConfig?.nitro?.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false,
51
+ ...envOptions2
52
+ };
53
+ return _deepFreeze(
54
+ applyEnv(klona(inlineRuntimeConfig), finalEnvOptions)
55
+ );
56
+ }
57
+ export function updateRuntimeConfig(runtimeConfig) {
58
+ const nuxt = useSilgi();
59
+ Object.assign(nuxt.options.nitro.runtimeConfig, defu(runtimeConfig, nuxt.options.nitro.runtimeConfig));
60
+ try {
61
+ } catch {
62
+ }
63
+ }
64
+ function getEnv(key, opts, env = process.env) {
65
+ const envKey = snakeCase(key).toUpperCase();
66
+ return destr(
67
+ env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey] ?? env[opts.silgiPrefix + envKey]
68
+ );
69
+ }
70
+ function _isObject(input) {
71
+ return typeof input === "object" && !Array.isArray(input);
72
+ }
73
+ export function applyEnv(obj, opts, parentKey = "") {
74
+ for (const key in obj) {
75
+ const subKey = parentKey ? `${parentKey}_${key}` : key;
76
+ const envValue = getEnv(subKey, opts);
77
+ if (_isObject(obj[key])) {
78
+ if (_isObject(envValue)) {
79
+ obj[key] = { ...obj[key], ...envValue };
80
+ applyEnv(obj[key], opts, subKey);
81
+ } else if (envValue === void 0) {
82
+ applyEnv(obj[key], opts, subKey);
83
+ } else {
84
+ obj[key] = envValue ?? obj[key];
85
+ }
86
+ } else {
87
+ obj[key] = envValue ?? obj[key];
88
+ }
89
+ if (opts.envExpansion && typeof obj[key] === "string") {
90
+ obj[key] = _expandFromEnv(obj[key]);
91
+ }
92
+ }
93
+ return obj;
94
+ }
95
+ const envExpandRx = /\{\{([^{}]*)\}\}/g;
96
+ function _expandFromEnv(value, env = process.env) {
97
+ return value.replace(envExpandRx, (match, key) => {
98
+ return env[key] || match;
99
+ });
100
+ }
101
+ function _deepFreeze(object) {
102
+ const propNames = Object.getOwnPropertyNames(object);
103
+ for (const name of propNames) {
104
+ const value = object[name];
105
+ if (value && typeof value === "object") {
106
+ _deepFreeze(value);
107
+ }
108
+ }
109
+ return Object.freeze(object);
110
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { createError, defineEventHandler, getQuery, H3Error, readBody } from "h3";
2
- import { ErrorFactory, HttpStatus, parseURI, silgi, SilgiError, useSilgi } from "silgi/core";
2
+ import { ErrorFactory, HttpStatus, parseURI, silgi, SilgiError, useSilgi } from "silgi";
3
3
  export default async function addNitroApp(silgiCtx = useSilgi()) {
4
4
  const nitro = silgiCtx.framework;
5
5
  nitro.router.use("/srn/**", defineEventHandler(async (event) => {
@@ -0,0 +1,7 @@
1
+ import type { SilgiCLIConfig } from 'silgi/types'
2
+
3
+ export { SilgiCLIConfig } from 'silgi/types'
4
+
5
+ declare function defineSilgiConfig(config: SilgiCLIConfig): SilgiCLIConfig
6
+
7
+ export { defineSilgiConfig }
package/lib/config.mjs ADDED
@@ -0,0 +1,5 @@
1
+ function defineNitroConfig(config) {
2
+ return config
3
+ }
4
+
5
+ export { defineNitroConfig }
package/lib/meta.d.mts ADDED
@@ -0,0 +1,4 @@
1
+ export const version: string
2
+ export const dependencies: string
3
+ export const devDependencies: string
4
+ export const peerDependencies: string
package/lib/meta.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import packageJson from '../../package.json' with { type: "json" };
2
+
3
+ export const version = packageJson.version;
4
+ export const dependencies = packageJson.dependencies;
5
+ export const devDependencies = packageJson.devDependencies;
6
+ export const peerDependencies = packageJson.peerDependencies;
@@ -1,9 +1,9 @@
1
1
  import { fileURLToPath } from 'node:url'
2
2
 
3
- export const pkgDir = fileURLToPath(new URL('.', import.meta.url))
3
+ export const pkgDir = fileURLToPath(new URL('..', import.meta.url))
4
4
 
5
5
  export const runtimeDir = fileURLToPath(
6
- new URL('dist/runtime/', import.meta.url),
6
+ new URL('../dist/runtime/', import.meta.url),
7
7
  )
8
8
 
9
9
  export const runtimeDependencies = [
@@ -14,7 +14,7 @@ export const runtimeDependencies = [
14
14
  'hookable',
15
15
  'iron-webcrypto',
16
16
  'klona',
17
- 'node-fetch-native',
17
+ 'node-mock-http',
18
18
  'ofetch',
19
19
  'ohash',
20
20
  'pathe',
package/package.json CHANGED
@@ -1,79 +1,30 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.23.10",
4
+ "version": "0.24.0",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
8
- "./cli": {
9
- "types": "./cli.d.ts",
10
- "import": "./dist/cli/index.mjs"
11
- },
12
- "./cli/config": {
13
- "types": "./dist/cli/config/index.d.ts",
14
- "import": "./dist/cli/config/index.mjs"
15
- },
16
- "./config": {
17
- "types": "./config.d.ts",
18
- "import": "./dist/config/index.mjs"
19
- },
20
- ".": {
21
- "types": "./dist/core/index.d.ts",
22
- "import": "./dist/core/index.mjs"
23
- },
24
- "./meta": {
25
- "types": "./dist/meta/index.d.ts",
26
- "import": "./dist/meta/index.mjs"
27
- },
28
- "./types": {
29
- "types": "./types.d.ts",
30
- "import": "./dist/types/index.mjs"
31
- },
32
- "./kit": {
33
- "types": "./kit.d.ts",
34
- "import": "./dist/kit/index.mjs"
35
- },
36
- "./core": {
37
- "types": "./core.d.ts",
38
- "import": "./dist/core/index.mjs"
39
- },
40
- "./presets": {
41
- "types": "./presets.d.ts",
42
- "import": "./dist/presets/index.mjs"
43
- },
44
- "./runtime": {
45
- "silgiCore": "./dist/runtime/*.ts",
46
- "silgiCoreTypes": "./dist/runtime/*.ts",
47
- "types": "./runtime.d.ts",
48
- "import": "./dist/runtime/index.mjs"
49
- },
50
- "./runtime/meta": {
51
- "types": "./runtime-meta.d.ts",
52
- "import": "./runtime-meta.mjs"
53
- },
54
- "./runtime/*": {
55
- "silgiCore": "./dist/runtime/*.ts",
56
- "silgiCoreTypes": "./dist/runtime/*.ts",
57
- "types": "./dist/runtime/*.d.ts",
58
- "import": "./dist/runtime/*.mjs"
59
- },
60
- "./dist/runtime/*": {
61
- "types": "./dist/runtime/*.d.ts",
62
- "import": "./dist/runtime/*.mjs"
63
- },
64
- "./package.json": "./package.json"
8
+ "./package.json": "./package.json",
9
+ ".": "./dist/index.mjs",
10
+ "./cli": "./dist/cli/index.mjs",
11
+ "./cli/config": "./dist/cli/config/index.mjs",
12
+ "./kit": "./dist/kit/index.mjs",
13
+ "./config": "./lib/config.mjs",
14
+ "./types": "./dist/types/index.d.mts",
15
+ "./meta": "./lib/meta.mjs",
16
+ "./presets": "./dist/presets/index.mjs",
17
+ "./runtime": "./dist/runtime/index.mjs",
18
+ "./runtime/internal": "./dist/runtime/internal/index.mjs",
19
+ "./runtime/meta": "./lib/runtime-meta.mjs"
65
20
  },
66
- "main": "./dist/core/index.mjs",
67
- "types": "./dist/core/index.d.ts",
68
21
  "bin": {
69
22
  "silgi": "./dist/cli/index.mjs"
70
23
  },
71
24
  "files": [
72
- "*.d.ts",
73
25
  "bin",
74
26
  "dist",
75
- "package.json",
76
- "runtime-meta.*"
27
+ "lib"
77
28
  ],
78
29
  "peerDependencies": {
79
30
  "@fastify/deepmerge": "^3.0.0",
package/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/cli/index';
package/config.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/config/index';
package/core.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/core/index';
@@ -1,72 +0,0 @@
1
- const version = "0.23.10";
2
- const peerDependencies = {
3
- "@fastify/deepmerge": "^3.0.0",
4
- "@nuxt/kit": "^3.15.3",
5
- "@nuxt/schema": "^3.15.4",
6
- "@silgi/ecosystem": "^0.3.0",
7
- h3: "^1.15.1",
8
- nitropack: "^2.10.4",
9
- nuxt: "^3.15.3",
10
- typescript: "^5.7.3",
11
- vue: "^3.5.13",
12
- zod: "^3.24.1"
13
- };
14
- const dependencies = {
15
- "@clack/prompts": "catalog:",
16
- "@fastify/deepmerge": "catalog:",
17
- "@oxc-parser/wasm": "catalog:",
18
- "@standard-schema/spec": "catalog:",
19
- c12: "catalog:",
20
- chokidar: "catalog:",
21
- citty: "catalog:",
22
- compatx: "catalog:",
23
- consola: "catalog:",
24
- defu: "catalog:",
25
- destr: "catalog:",
26
- "dev-jiti": "catalog:",
27
- "dot-prop": "catalog:",
28
- dotenv: "catalog:",
29
- "escape-string-regexp": "catalog:",
30
- exsolve: "^1.0.4",
31
- globby: "catalog:",
32
- hookable: "catalog:",
33
- ignore: "catalog:",
34
- klona: "catalog:",
35
- knitwork: "catalog:",
36
- mlly: "catalog:",
37
- ofetch: "catalog:",
38
- ohash: "catalog:",
39
- pathe: "catalog:",
40
- picocolors: "catalog:",
41
- "pkg-types": "catalog:",
42
- scule: "catalog:",
43
- semver: "catalog:",
44
- "std-env": "catalog:",
45
- ufo: "catalog:",
46
- unctx: "catalog:",
47
- unimport: "catalog:",
48
- unstorage: "catalog:",
49
- untyped: "catalog:"
50
- };
51
- const devDependencies = {
52
- "@antfu/eslint-config": "catalog:",
53
- "@nuxt/kit": "catalog:",
54
- "@nuxt/schema": "catalog:",
55
- "@silgi/ecosystem": "catalog:",
56
- "@types/node": "catalog:",
57
- "@types/semver": "catalog:",
58
- "@vitest/coverage-v8": "catalog:",
59
- eslint: "catalog:",
60
- h3: "catalog:",
61
- nitropack: "catalog:",
62
- nuxt: "catalog:",
63
- typescript: "catalog:",
64
- unbuild: "catalog:",
65
- vitest: "catalog:",
66
- vue: "catalog:",
67
- zod: "catalog:"
68
- };
69
- const packageJson = {
70
- version: version};
71
-
72
- export { devDependencies as a, peerDependencies as b, dependencies as d, packageJson as p, version as v };
@@ -1,5 +0,0 @@
1
- import { SilgiCLIConfig } from 'silgi/types';
2
-
3
- declare function defineSilgiConfig(config: SilgiCLIConfig): SilgiCLIConfig;
4
-
5
- export { defineSilgiConfig };
@@ -1,5 +0,0 @@
1
- import { SilgiCLIConfig } from 'silgi/types';
2
-
3
- declare function defineSilgiConfig(config: SilgiCLIConfig): SilgiCLIConfig;
4
-
5
- export { defineSilgiConfig };
@@ -1,5 +0,0 @@
1
- function defineSilgiConfig(config) {
2
- return config;
3
- }
4
-
5
- export { defineSilgiConfig };
@@ -1,70 +0,0 @@
1
- declare let version: string;
2
- declare let peerDependencies: {
3
- "@fastify/deepmerge": string;
4
- "@nuxt/kit": string;
5
- "@nuxt/schema": string;
6
- "@silgi/ecosystem": string;
7
- h3: string;
8
- nitropack: string;
9
- nuxt: string;
10
- typescript: string;
11
- vue: string;
12
- zod: string;
13
- };
14
- declare let dependencies: {
15
- "@clack/prompts": string;
16
- "@fastify/deepmerge": string;
17
- "@oxc-parser/wasm": string;
18
- "@standard-schema/spec": string;
19
- c12: string;
20
- chokidar: string;
21
- citty: string;
22
- compatx: string;
23
- consola: string;
24
- defu: string;
25
- destr: string;
26
- "dev-jiti": string;
27
- "dot-prop": string;
28
- dotenv: string;
29
- "escape-string-regexp": string;
30
- exsolve: string;
31
- globby: string;
32
- hookable: string;
33
- ignore: string;
34
- klona: string;
35
- knitwork: string;
36
- mlly: string;
37
- ofetch: string;
38
- ohash: string;
39
- pathe: string;
40
- picocolors: string;
41
- "pkg-types": string;
42
- scule: string;
43
- semver: string;
44
- "std-env": string;
45
- ufo: string;
46
- unctx: string;
47
- unimport: string;
48
- unstorage: string;
49
- untyped: string;
50
- };
51
- declare let devDependencies: {
52
- "@antfu/eslint-config": string;
53
- "@nuxt/kit": string;
54
- "@nuxt/schema": string;
55
- "@silgi/ecosystem": string;
56
- "@types/node": string;
57
- "@types/semver": string;
58
- "@vitest/coverage-v8": string;
59
- eslint: string;
60
- h3: string;
61
- nitropack: string;
62
- nuxt: string;
63
- typescript: string;
64
- unbuild: string;
65
- vitest: string;
66
- vue: string;
67
- zod: string;
68
- };
69
-
70
- export { dependencies, devDependencies, peerDependencies, version };
@@ -1,70 +0,0 @@
1
- declare let version: string;
2
- declare let peerDependencies: {
3
- "@fastify/deepmerge": string;
4
- "@nuxt/kit": string;
5
- "@nuxt/schema": string;
6
- "@silgi/ecosystem": string;
7
- h3: string;
8
- nitropack: string;
9
- nuxt: string;
10
- typescript: string;
11
- vue: string;
12
- zod: string;
13
- };
14
- declare let dependencies: {
15
- "@clack/prompts": string;
16
- "@fastify/deepmerge": string;
17
- "@oxc-parser/wasm": string;
18
- "@standard-schema/spec": string;
19
- c12: string;
20
- chokidar: string;
21
- citty: string;
22
- compatx: string;
23
- consola: string;
24
- defu: string;
25
- destr: string;
26
- "dev-jiti": string;
27
- "dot-prop": string;
28
- dotenv: string;
29
- "escape-string-regexp": string;
30
- exsolve: string;
31
- globby: string;
32
- hookable: string;
33
- ignore: string;
34
- klona: string;
35
- knitwork: string;
36
- mlly: string;
37
- ofetch: string;
38
- ohash: string;
39
- pathe: string;
40
- picocolors: string;
41
- "pkg-types": string;
42
- scule: string;
43
- semver: string;
44
- "std-env": string;
45
- ufo: string;
46
- unctx: string;
47
- unimport: string;
48
- unstorage: string;
49
- untyped: string;
50
- };
51
- declare let devDependencies: {
52
- "@antfu/eslint-config": string;
53
- "@nuxt/kit": string;
54
- "@nuxt/schema": string;
55
- "@silgi/ecosystem": string;
56
- "@types/node": string;
57
- "@types/semver": string;
58
- "@vitest/coverage-v8": string;
59
- eslint: string;
60
- h3: string;
61
- nitropack: string;
62
- nuxt: string;
63
- typescript: string;
64
- unbuild: string;
65
- vitest: string;
66
- vue: string;
67
- zod: string;
68
- };
69
-
70
- export { dependencies, devDependencies, peerDependencies, version };
@@ -1 +0,0 @@
1
- export { d as dependencies, a as devDependencies, b as peerDependencies, v as version } from '../_chunks/index.mjs';
package/kit.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/kit/index';
package/meta.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/meta/index';
package/presets.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/presets/index';
package/runtime.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/runtime/index';
package/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './dist/types/index';
File without changes