silgi 0.42.5 → 0.43.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 (266) hide show
  1. package/dist/_virtual/rolldown_runtime.mjs +11 -0
  2. package/dist/build.d.mts +3 -11
  3. package/dist/build.mjs +4 -48
  4. package/dist/cli/build/build.mjs +17 -0
  5. package/dist/cli/build/dev.d.mts +9 -0
  6. package/dist/cli/build/dev.mjs +59 -0
  7. package/dist/cli/build/prepare.d.mts +6 -0
  8. package/dist/cli/build/prepare.mjs +15 -0
  9. package/dist/cli/commands/commands.mjs +90 -0
  10. package/dist/cli/commands/env.mjs +53 -0
  11. package/dist/cli/commands/init.mjs +84 -0
  12. package/dist/cli/commands/install.mjs +52 -0
  13. package/dist/cli/commands/prepare.mjs +65 -0
  14. package/dist/cli/commands/reset.mjs +46 -0
  15. package/dist/cli/commands/run.mjs +105 -0
  16. package/dist/cli/commands/watch.mjs +48 -0
  17. package/dist/cli/config/defaults.mjs +117 -0
  18. package/dist/cli/config/index.d.mts +3 -11
  19. package/dist/cli/config/index.mjs +4 -17
  20. package/dist/cli/config/loader.d.mts +6 -0
  21. package/dist/cli/config/loader.mjs +71 -0
  22. package/dist/cli/config/resolvers/compatibility.mjs +71 -0
  23. package/dist/cli/config/resolvers/imports.mjs +35 -0
  24. package/dist/cli/config/resolvers/paths.mjs +98 -0
  25. package/dist/cli/config/resolvers/storage.mjs +23 -0
  26. package/dist/cli/config/resolvers/url.mjs +9 -0
  27. package/dist/cli/config/types.d.mts +14 -0
  28. package/dist/cli/config/types.mjs +147 -0
  29. package/dist/cli/core/apiful.mjs +36 -0
  30. package/dist/cli/core/app.mjs +105 -0
  31. package/dist/cli/core/devServer.mjs +10 -0
  32. package/dist/cli/core/env.mjs +68 -0
  33. package/dist/cli/core/installPackage.mjs +60 -0
  34. package/dist/cli/core/runtimeConfig.mjs +70 -0
  35. package/dist/cli/core/scan.mjs +35 -0
  36. package/dist/cli/core/silgi.mjs +111 -0
  37. package/dist/cli/core/templates.mjs +38 -0
  38. package/dist/cli/framework/emptyFramework.mjs +7 -0
  39. package/dist/cli/framework/h3.mjs +55 -0
  40. package/dist/cli/framework/index.mjs +15 -0
  41. package/dist/cli/framework/nitro.mjs +24 -0
  42. package/dist/cli/framework/nuxt.mjs +10 -0
  43. package/dist/cli/index.d.mts +1 -1
  44. package/dist/cli/index.mjs +24 -27
  45. package/dist/cli/module/exportScan.mjs +180 -0
  46. package/dist/cli/module/install.mjs +49 -0
  47. package/dist/cli/module/scan.mjs +195 -0
  48. package/dist/cli/scan/prepareCommands.mjs +40 -0
  49. package/dist/cli/scan/prepareConfigs.mjs +33 -0
  50. package/dist/cli/scan/prepareCoreFile.mjs +118 -0
  51. package/dist/cli/scan/prepareScanFile.mjs +59 -0
  52. package/dist/cli/scan/prepareSchema.mjs +140 -0
  53. package/dist/cli/scan/scanExportFile.mjs +312 -0
  54. package/dist/cli/scan/writeCoreFile.mjs +22 -0
  55. package/dist/cli/scan/writeTypesAndFiles.mjs +72 -0
  56. package/dist/cli/utils/cancel.mjs +14 -0
  57. package/dist/cli/utils/common.mjs +15 -0
  58. package/dist/cli/utils/compatibility.mjs +33 -0
  59. package/dist/cli/utils/debug.mjs +11 -0
  60. package/dist/cli/utils/ignore.mjs +56 -0
  61. package/dist/cli/utils/readScanFile.mjs +58 -0
  62. package/dist/cli/utils/storage.mjs +23 -0
  63. package/dist/core/context.d.mts +30 -0
  64. package/dist/core/context.mjs +32 -0
  65. package/dist/core/createSilgi.d.mts +6 -0
  66. package/dist/core/createSilgi.mjs +152 -0
  67. package/dist/core/error.d.mts +65 -0
  68. package/dist/core/error.mjs +106 -0
  69. package/dist/core/event.d.mts +26 -0
  70. package/dist/core/event.mjs +44 -0
  71. package/dist/core/index.d.mts +24 -316
  72. package/dist/core/index.mjs +27 -1345
  73. package/dist/core/orchestrate.mjs +113 -0
  74. package/dist/core/response.d.mts +20 -0
  75. package/dist/core/response.mjs +105 -0
  76. package/dist/core/silgi.d.mts +19 -0
  77. package/dist/core/silgi.mjs +141 -0
  78. package/dist/core/silgiApp.d.mts +9 -0
  79. package/dist/core/silgiApp.mjs +23 -0
  80. package/dist/core/storage.d.mts +7 -0
  81. package/dist/core/storage.mjs +15 -0
  82. package/dist/core/unctx.d.mts +21 -0
  83. package/dist/core/unctx.mjs +35 -0
  84. package/dist/core/utils/event-stream.d.mts +53 -0
  85. package/dist/core/utils/event-stream.mjs +38 -0
  86. package/dist/core/utils/event.d.mts +8 -0
  87. package/dist/core/utils/event.mjs +12 -0
  88. package/dist/core/utils/internal/event-stream.d.mts +45 -0
  89. package/dist/core/utils/internal/event-stream.mjs +137 -0
  90. package/dist/core/utils/internal/obj.mjs +9 -0
  91. package/dist/core/utils/internal/object.mjs +29 -0
  92. package/dist/core/utils/internal/query.mjs +73 -0
  93. package/dist/core/utils/internal/req.mjs +35 -0
  94. package/dist/core/utils/merge.d.mts +14 -0
  95. package/dist/core/utils/merge.mjs +27 -0
  96. package/dist/{shared/silgi.DTwQEdSr.d.mts → core/utils/middleware.d.mts} +11 -13
  97. package/dist/core/utils/middleware.mjs +12 -0
  98. package/dist/core/utils/request.mjs +35 -0
  99. package/dist/core/utils/resolver.d.mts +7 -0
  100. package/dist/core/utils/resolver.mjs +29 -0
  101. package/dist/core/utils/runtime.d.mts +7 -0
  102. package/dist/core/utils/runtime.mjs +20 -0
  103. package/dist/core/utils/sanitize.mjs +22 -0
  104. package/dist/core/utils/schema.d.mts +34 -0
  105. package/dist/core/utils/schema.mjs +33 -0
  106. package/dist/core/utils/service.d.mts +13 -0
  107. package/dist/core/utils/service.mjs +19 -0
  108. package/dist/core/utils/shared.d.mts +6 -0
  109. package/dist/core/utils/shared.mjs +7 -0
  110. package/dist/core/utils/storage.d.mts +24 -0
  111. package/dist/core/utils/storage.mjs +54 -0
  112. package/dist/index.d.mts +21 -6
  113. package/dist/index.mjs +22 -16
  114. package/dist/kit/add/add-commands.d.mts +6 -0
  115. package/dist/kit/add/add-commands.mjs +12 -0
  116. package/dist/kit/add/add-core-file.d.mts +9 -0
  117. package/dist/kit/add/add-core-file.mjs +11 -0
  118. package/dist/kit/add/add-imports.d.mts +14 -0
  119. package/dist/kit/add/add-imports.mjs +56 -0
  120. package/dist/kit/add/add-npm.d.mts +14 -0
  121. package/dist/kit/add/add-npm.mjs +23 -0
  122. package/dist/kit/define.d.mts +28 -0
  123. package/dist/kit/define.mjs +25 -0
  124. package/dist/kit/errors.d.mts +6 -0
  125. package/dist/kit/errors.mjs +11 -0
  126. package/dist/kit/esm.d.mts +11 -0
  127. package/dist/kit/esm.mjs +21 -0
  128. package/dist/kit/fs.d.mts +7 -0
  129. package/dist/kit/fs.mjs +23 -0
  130. package/dist/kit/function-utils.d.mts +27 -0
  131. package/dist/kit/function-utils.mjs +75 -0
  132. package/dist/kit/gen.d.mts +5 -0
  133. package/dist/kit/gen.mjs +26 -0
  134. package/dist/kit/hash.d.mts +4 -0
  135. package/dist/kit/hash.mjs +10 -0
  136. package/dist/kit/index.d.mts +22 -321
  137. package/dist/kit/index.mjs +23 -1039
  138. package/dist/kit/isFramework.d.mts +6 -0
  139. package/dist/kit/isFramework.mjs +21 -0
  140. package/dist/kit/logger.d.mts +6 -0
  141. package/dist/kit/logger.mjs +10 -0
  142. package/dist/kit/migration.d.mts +113 -0
  143. package/dist/kit/migration.mjs +301 -0
  144. package/dist/kit/module.d.mts +14 -0
  145. package/dist/kit/module.mjs +53 -0
  146. package/dist/kit/path.d.mts +7 -0
  147. package/dist/kit/path.mjs +26 -0
  148. package/dist/kit/preset.d.mts +8 -0
  149. package/dist/kit/preset.mjs +11 -0
  150. package/dist/kit/resolve.d.mts +37 -0
  151. package/dist/kit/resolve.mjs +82 -0
  152. package/dist/kit/template.d.mts +14 -0
  153. package/dist/kit/template.mjs +59 -0
  154. package/dist/kit/useRequest.d.mts +19 -0
  155. package/dist/kit/useRequest.mjs +63 -0
  156. package/dist/kit/utils.d.mts +34 -0
  157. package/dist/kit/utils.mjs +90 -0
  158. package/dist/package.mjs +176 -0
  159. package/dist/presets/_all.gen.d.mts +5 -2
  160. package/dist/presets/_all.gen.mjs +16 -13
  161. package/dist/presets/_resolve.d.mts +10 -6
  162. package/dist/presets/_resolve.mjs +51 -65
  163. package/dist/presets/_types.gen.d.mts +8 -5
  164. package/dist/presets/_types.gen.mjs +5 -1
  165. package/dist/presets/h3/preset.d.mts +5 -2
  166. package/dist/presets/h3/preset.mjs +33 -38
  167. package/dist/presets/hono/preset.d.mts +5 -2
  168. package/dist/presets/hono/preset.mjs +28 -35
  169. package/dist/presets/index.d.mts +3 -2
  170. package/dist/presets/index.mjs +3 -1
  171. package/dist/presets/nitro/preset.d.mts +5 -2
  172. package/dist/presets/nitro/preset.mjs +35 -42
  173. package/dist/presets/npmpackage/preset.d.mts +5 -2
  174. package/dist/presets/npmpackage/preset.mjs +27 -32
  175. package/dist/presets/nuxt/preset.d.mts +5 -2
  176. package/dist/presets/nuxt/preset.mjs +39 -44
  177. package/dist/runtime/index.d.mts +4 -3
  178. package/dist/runtime/index.mjs +5 -3
  179. package/dist/runtime/internal/config.d.mts +11 -7
  180. package/dist/runtime/internal/config.mjs +79 -90
  181. package/dist/runtime/internal/debug.d.mts +6 -3
  182. package/dist/runtime/internal/debug.mjs +9 -4
  183. package/dist/runtime/internal/defu.d.mts +4 -1
  184. package/dist/runtime/internal/defu.mjs +7 -2
  185. package/dist/runtime/internal/index.d.mts +7 -6
  186. package/dist/runtime/internal/index.mjs +8 -20
  187. package/dist/runtime/internal/nitro.d.mts +6 -3
  188. package/dist/runtime/internal/nitro.mjs +29 -37
  189. package/dist/runtime/internal/nuxt.d.mts +12 -8
  190. package/dist/runtime/internal/nuxt.mjs +12 -7
  191. package/dist/runtime/internal/ofetch.d.mts +8 -4
  192. package/dist/runtime/internal/ofetch.mjs +33 -34
  193. package/dist/runtime/internal/plugin.d.mts +7 -3
  194. package/dist/runtime/internal/plugin.mjs +7 -3
  195. package/dist/types/cliConfig.d.mts +288 -0
  196. package/dist/types/cliConfig.mjs +0 -0
  197. package/dist/types/cliHooks.d.mts +154 -0
  198. package/dist/types/cliHooks.mjs +0 -0
  199. package/dist/types/compatibility.d.mts +13 -0
  200. package/dist/types/compatibility.mjs +0 -0
  201. package/dist/types/config.d.mts +46 -0
  202. package/dist/types/config.mjs +0 -0
  203. package/dist/types/dotenv.d.mts +29 -0
  204. package/dist/types/dotenv.mjs +0 -0
  205. package/dist/types/event.d.mts +63 -0
  206. package/dist/types/event.mjs +0 -0
  207. package/dist/types/global.d.mts +24 -0
  208. package/dist/types/global.mjs +0 -0
  209. package/dist/types/helper.d.mts +25 -0
  210. package/dist/types/helper.mjs +0 -0
  211. package/dist/types/hooks.d.mts +37 -0
  212. package/dist/types/hooks.mjs +0 -0
  213. package/dist/types/index.d.mts +26 -1306
  214. package/dist/types/index.mjs +0 -1
  215. package/dist/types/kits.d.mts +32 -0
  216. package/dist/types/kits.mjs +0 -0
  217. package/dist/types/middleware.d.mts +31 -0
  218. package/dist/types/middleware.mjs +0 -0
  219. package/dist/types/module.d.mts +102 -0
  220. package/dist/types/module.mjs +0 -0
  221. package/dist/types/preset.d.mts +20 -0
  222. package/dist/types/preset.mjs +0 -0
  223. package/dist/types/route.d.mts +59 -0
  224. package/dist/types/route.mjs +0 -0
  225. package/dist/types/runtime/index.d.mts +5 -0
  226. package/dist/types/runtime/index.mjs +0 -0
  227. package/dist/types/runtime/nuxt.d.mts +13 -0
  228. package/dist/types/runtime/nuxt.mjs +0 -0
  229. package/dist/types/runtime/ofetch.d.mts +14 -0
  230. package/dist/types/runtime/ofetch.mjs +0 -0
  231. package/dist/types/runtime/plugin.d.mts +8 -0
  232. package/dist/types/runtime/plugin.mjs +0 -0
  233. package/dist/types/runtime/silgi.d.mts +11 -0
  234. package/dist/types/runtime/silgi.mjs +0 -0
  235. package/dist/types/schema.d.mts +86 -0
  236. package/dist/types/schema.mjs +0 -0
  237. package/dist/types/service.d.mts +102 -0
  238. package/dist/types/service.mjs +0 -0
  239. package/dist/types/shared.d.mts +19 -0
  240. package/dist/types/shared.mjs +0 -0
  241. package/dist/types/silgi.d.mts +71 -0
  242. package/dist/types/silgi.mjs +0 -0
  243. package/dist/types/silgiCLI.d.mts +118 -0
  244. package/dist/types/silgiCLI.mjs +0 -0
  245. package/dist/types/standard-schema.d.mts +61 -0
  246. package/dist/types/standard-schema.mjs +0 -0
  247. package/dist/types/storage.d.mts +30 -0
  248. package/dist/types/storage.mjs +0 -0
  249. package/package.json +20 -35
  250. package/dist/_chunks/silgiApp.mjs +0 -25
  251. package/dist/cli/build.mjs +0 -2190
  252. package/dist/cli/common.mjs +0 -13
  253. package/dist/cli/compatibility.mjs +0 -30
  254. package/dist/cli/dev.mjs +0 -67
  255. package/dist/cli/init.mjs +0 -112
  256. package/dist/cli/install.mjs +0 -151
  257. package/dist/cli/loader.mjs +0 -618
  258. package/dist/cli/prepare.mjs +0 -188
  259. package/dist/cli/reset.mjs +0 -55
  260. package/dist/cli/run.mjs +0 -159
  261. package/dist/cli/types.mjs +0 -232
  262. package/dist/cli/watch.mjs +0 -91
  263. package/dist/presets/next/preset.d.mts +0 -3
  264. package/dist/presets/next/preset.mjs +0 -38
  265. package/dist/runtime/internal/next.d.mts +0 -9
  266. package/dist/runtime/internal/next.mjs +0 -22
@@ -1,108 +1,97 @@
1
+ import { updateRuntimeStorage, useRuntime, useSilgi } from "silgi";
1
2
  import { defu } from "defu";
2
- import destr from "destr";
3
- import { klona } from "klona";
4
3
  import { snakeCase } from "scule";
5
- import { updateRuntimeStorage, useRuntime, useSilgi } from "silgi";
6
- export function updateEnvOptions(runtime) {
7
- const envOptions = {
8
- prefix: "NITRO_",
9
- altPrefix: runtime?.silgi?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
10
- silgiPrefix: "SILGI_",
11
- envExpansion: runtime?.silgi?.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false
12
- };
13
- return envOptions;
4
+ import { klona } from "klona";
5
+ import destr from "destr";
6
+
7
+ //#region src/runtime/internal/config.ts
8
+ function updateEnvOptions(runtime) {
9
+ const envOptions = {
10
+ prefix: "NITRO_",
11
+ altPrefix: runtime?.silgi?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
12
+ silgiPrefix: "SILGI_",
13
+ envExpansion: runtime?.silgi?.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false
14
+ };
15
+ return envOptions;
14
16
  }
15
17
  let inlineRuntimeConfig;
16
- export function sharedRuntimeConfig(runtime, force) {
17
- if (inlineRuntimeConfig && !force) {
18
- return inlineRuntimeConfig;
19
- }
20
- inlineRuntimeConfig = _deepFreeze(
21
- applyEnv(klona(runtime ?? {}), updateEnvOptions(runtime))
22
- );
23
- updateRuntimeStorage(inlineRuntimeConfig);
24
- return inlineRuntimeConfig;
18
+ function sharedRuntimeConfig(runtime, force) {
19
+ if (inlineRuntimeConfig && !force) return inlineRuntimeConfig;
20
+ inlineRuntimeConfig = _deepFreeze(applyEnv(klona(runtime ?? {}), updateEnvOptions(runtime)));
21
+ updateRuntimeStorage(inlineRuntimeConfig);
22
+ return inlineRuntimeConfig;
25
23
  }
26
- export function useRuntimeConfig(event, localRuntimeConfig, force) {
27
- if (localRuntimeConfig) {
28
- return sharedRuntimeConfig(localRuntimeConfig, force);
29
- }
30
- const runtime = useRuntime();
31
- if (!event) {
32
- return sharedRuntimeConfig(runtime);
33
- }
34
- if (event.context.silgi.runtimeConfig) {
35
- return event.context.silgi.runtimeConfig;
36
- }
37
- const runtimeConfig = klona(runtime);
38
- const envOptions = updateEnvOptions(runtime);
39
- applyEnv(runtimeConfig, envOptions);
40
- event.context.silgi.runtimeConfig = runtimeConfig;
41
- return runtimeConfig;
24
+ function useRuntimeConfig(event, localRuntimeConfig, force) {
25
+ if (localRuntimeConfig) return sharedRuntimeConfig(localRuntimeConfig, force);
26
+ const runtime = useRuntime();
27
+ if (!event) return sharedRuntimeConfig(runtime);
28
+ if (event.context.silgi.runtimeConfig) return event.context.silgi.runtimeConfig;
29
+ const runtimeConfig = klona(runtime);
30
+ const envOptions = updateEnvOptions(runtime);
31
+ applyEnv(runtimeConfig, envOptions);
32
+ event.context.silgi.runtimeConfig = runtimeConfig;
33
+ return runtimeConfig;
42
34
  }
43
- export function initRuntimeConfig(envOptions = {}, inlineRuntimeConfig2 = {}) {
44
- const finalEnvOptions = {
45
- prefix: "NITRO_",
46
- altPrefix: inlineRuntimeConfig2?.nitro?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
47
- silgiPrefix: "SILGI_",
48
- envExpansion: inlineRuntimeConfig2?.nitro?.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false,
49
- ...envOptions
50
- };
51
- return _deepFreeze(
52
- applyEnv(klona(inlineRuntimeConfig2), finalEnvOptions)
53
- );
35
+ function initRuntimeConfig(envOptions = {}, inlineRuntimeConfig$1 = {}) {
36
+ const finalEnvOptions = {
37
+ prefix: "NITRO_",
38
+ altPrefix: inlineRuntimeConfig$1?.nitro?.envPrefix ?? process.env.NITRO_ENV_PREFIX ?? "_",
39
+ silgiPrefix: "SILGI_",
40
+ envExpansion: inlineRuntimeConfig$1?.nitro?.envExpansion ?? process.env.NITRO_ENV_EXPANSION ?? false,
41
+ ...envOptions
42
+ };
43
+ return _deepFreeze(applyEnv(klona(inlineRuntimeConfig$1), finalEnvOptions));
54
44
  }
55
- export function updateRuntimeConfig(runtimeConfig) {
56
- const nuxt = useSilgi();
57
- Object.assign(nuxt.options.nitro.runtimeConfig, defu(runtimeConfig, nuxt.options.nitro.runtimeConfig));
58
- try {
59
- } catch {
60
- }
45
+ function updateRuntimeConfig(runtimeConfig) {
46
+ const nuxt = useSilgi();
47
+ Object.assign(nuxt.options.nitro.runtimeConfig, defu(runtimeConfig, nuxt.options.nitro.runtimeConfig));
61
48
  }
49
+ /**
50
+ * https://github.com/nitrojs/nitro/blob/main/src/runtime/internal/utils.env.ts.
51
+ *
52
+ * These utils will be replaced by util exposed from nitropack. See https://github.com/nitrojs/nitro/pull/2404
53
+ * for more context and future plans.)
54
+ *
55
+ * @internal
56
+ */
62
57
  function getEnv(key, opts, env = process.env) {
63
- const envKey = snakeCase(key).toUpperCase();
64
- return destr(
65
- env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey] ?? env[opts.silgiPrefix + envKey]
66
- );
58
+ const envKey = snakeCase(key).toUpperCase();
59
+ return destr(env[opts.prefix + envKey] ?? env[opts.altPrefix + envKey] ?? env[opts.silgiPrefix + envKey]);
67
60
  }
68
61
  function _isObject(input) {
69
- return typeof input === "object" && !Array.isArray(input);
62
+ return typeof input === "object" && !Array.isArray(input);
70
63
  }
71
- export function applyEnv(obj, opts, parentKey = "") {
72
- for (const key in obj) {
73
- const subKey = parentKey ? `${parentKey}_${key}` : key;
74
- const envValue = getEnv(subKey, opts);
75
- if (_isObject(obj[key])) {
76
- if (_isObject(envValue)) {
77
- obj[key] = { ...obj[key], ...envValue };
78
- applyEnv(obj[key], opts, subKey);
79
- } else if (envValue === void 0) {
80
- applyEnv(obj[key], opts, subKey);
81
- } else {
82
- obj[key] = envValue ?? obj[key];
83
- }
84
- } else {
85
- obj[key] = envValue ?? obj[key];
86
- }
87
- if (opts.envExpansion && typeof obj[key] === "string") {
88
- obj[key] = _expandFromEnv(obj[key]);
89
- }
90
- }
91
- return obj;
64
+ function applyEnv(obj, opts, parentKey = "") {
65
+ for (const key in obj) {
66
+ const subKey = parentKey ? `${parentKey}_${key}` : key;
67
+ const envValue = getEnv(subKey, opts);
68
+ if (_isObject(obj[key])) if (_isObject(envValue)) {
69
+ obj[key] = {
70
+ ...obj[key],
71
+ ...envValue
72
+ };
73
+ applyEnv(obj[key], opts, subKey);
74
+ } else if (envValue === void 0) applyEnv(obj[key], opts, subKey);
75
+ else obj[key] = envValue ?? obj[key];
76
+ else obj[key] = envValue ?? obj[key];
77
+ if (opts.envExpansion && typeof obj[key] === "string") obj[key] = _expandFromEnv(obj[key]);
78
+ }
79
+ return obj;
92
80
  }
93
81
  const envExpandRx = /\{\{([^{}]*)\}\}/g;
94
82
  function _expandFromEnv(value, env = process.env) {
95
- return value.replace(envExpandRx, (match, key) => {
96
- return env[key] || match;
97
- });
83
+ return value.replace(envExpandRx, (match, key) => {
84
+ return env[key] || match;
85
+ });
98
86
  }
99
87
  function _deepFreeze(object) {
100
- const propNames = Object.getOwnPropertyNames(object);
101
- for (const name of propNames) {
102
- const value = object[name];
103
- if (value && typeof value === "object") {
104
- _deepFreeze(value);
105
- }
106
- }
107
- return Object.freeze(object);
88
+ const propNames = Object.getOwnPropertyNames(object);
89
+ for (const name of propNames) {
90
+ const value = object[name];
91
+ if (value && typeof value === "object") _deepFreeze(value);
92
+ }
93
+ return Object.freeze(object);
108
94
  }
95
+
96
+ //#endregion
97
+ export { applyEnv, initRuntimeConfig, sharedRuntimeConfig, updateEnvOptions, updateRuntimeConfig, useRuntimeConfig };
@@ -1,3 +1,6 @@
1
- import type { SilgiAppPlugin } from 'silgi/types';
2
- export declare const debugPlugin: SilgiAppPlugin;
3
- export default debugPlugin;
1
+ import { SilgiAppPlugin } from "silgi/types";
2
+
3
+ //#region src/runtime/internal/debug.d.ts
4
+ declare const debugPlugin: SilgiAppPlugin;
5
+ //#endregion
6
+ export { debugPlugin, debugPlugin as default };
@@ -1,6 +1,11 @@
1
+ import { defineSilgiPlugin } from "./plugin.mjs";
1
2
  import { createDebugger } from "hookable";
2
- import { defineSilgiPlugin } from "./plugin.mjs";
3
- export const debugPlugin = defineSilgiPlugin((silgi) => {
4
- createDebugger(silgi.hooks, { tag: "silgi-runtime" });
3
+
4
+ //#region src/runtime/internal/debug.ts
5
+ const debugPlugin = defineSilgiPlugin((silgi) => {
6
+ createDebugger(silgi.hooks, { tag: "silgi-runtime" });
5
7
  });
6
- export default debugPlugin;
8
+ var debug_default = debugPlugin;
9
+
10
+ //#endregion
11
+ export { debugPlugin, debug_default as default };
@@ -1 +1,4 @@
1
- export declare function mergeDeep(source: any, ...defaults: any[]): any;
1
+ //#region src/runtime/internal/defu.d.ts
2
+ declare function mergeDeep(source: any, ...defaults: any[]): any;
3
+ //#endregion
4
+ export { mergeDeep };
@@ -1,4 +1,9 @@
1
1
  import { defu } from "defu";
2
- export function mergeDeep(source, ...defaults) {
3
- return defu(source, ...defaults);
2
+
3
+ //#region src/runtime/internal/defu.ts
4
+ function mergeDeep(source, ...defaults) {
5
+ return defu(source, ...defaults);
4
6
  }
7
+
8
+ //#endregion
9
+ export { mergeDeep };
@@ -1,6 +1,7 @@
1
- export { debugPlugin, } from "./debug.mjs";
2
- export { mergeDeep, } from "./defu.mjs";
3
- export { addNitroApp, } from "./nitro.mjs";
4
- export { useSilgiFetch, } from "./nuxt.mjs";
5
- export { createSilgiFetch, silgi$fetch, } from "./ofetch.mjs";
6
- export { defineSilgiPlugin, silgiPlugin, } from "./plugin.mjs";
1
+ import { defineSilgiPlugin, silgiPlugin } from "./plugin.mjs";
2
+ import { mergeDeep } from "./defu.mjs";
3
+ import { debugPlugin } from "./debug.mjs";
4
+ import { addNitroApp } from "./nitro.mjs";
5
+ import { useSilgiFetch } from "./nuxt.mjs";
6
+ import { createSilgiFetch, silgi$fetch } from "./ofetch.mjs";
7
+ export { addNitroApp, createSilgiFetch, debugPlugin, defineSilgiPlugin, mergeDeep, silgi$fetch, silgiPlugin, useSilgiFetch };
@@ -1,20 +1,8 @@
1
- export {
2
- debugPlugin
3
- } from "./debug.mjs";
4
- export {
5
- mergeDeep
6
- } from "./defu.mjs";
7
- export {
8
- addNitroApp
9
- } from "./nitro.mjs";
10
- export {
11
- useSilgiFetch
12
- } from "./nuxt.mjs";
13
- export {
14
- createSilgiFetch,
15
- silgi$fetch
16
- } from "./ofetch.mjs";
17
- export {
18
- defineSilgiPlugin,
19
- silgiPlugin
20
- } from "./plugin.mjs";
1
+ import { defineSilgiPlugin, silgiPlugin } from "./plugin.mjs";
2
+ import { mergeDeep } from "./defu.mjs";
3
+ import { debugPlugin } from "./debug.mjs";
4
+ import { addNitroApp } from "./nitro.mjs";
5
+ import { useSilgiFetch } from "./nuxt.mjs";
6
+ import { createSilgiFetch, silgi$fetch } from "./ofetch.mjs";
7
+
8
+ export { addNitroApp, createSilgiFetch, debugPlugin, defineSilgiPlugin, mergeDeep, silgi$fetch, silgiPlugin, useSilgiFetch };
@@ -1,3 +1,6 @@
1
- import type { Silgi } from 'silgi/types';
2
- export declare function addNitroApp(silgiContext?: Silgi): Promise<void>;
3
- export default addNitroApp;
1
+ import { Silgi } from "silgi/types";
2
+
3
+ //#region src/runtime/internal/nitro.d.ts
4
+ declare function addNitroApp(silgiContext?: Silgi): Promise<void>;
5
+ //#endregion
6
+ export { addNitroApp, addNitroApp as default };
@@ -1,38 +1,30 @@
1
- import {
2
- defineEventHandler,
3
- toWebRequest
4
- } from "h3";
5
- import {
6
- silgiFetch,
7
- useSilgi
8
- } from "silgi";
9
- export async function addNitroApp(silgiContext = useSilgi()) {
10
- const nitro = silgiContext.framework?.nitro;
11
- if (!nitro) {
12
- throw new Error("Nitro framework not found");
13
- }
14
- const prefixs = silgiContext.routerPrefixs;
15
- for (const prefix of prefixs) {
16
- let type = "http";
17
- let path = "";
18
- const parts = prefix.split(":");
19
- type = parts[0].toUpperCase();
20
- path = parts[1];
21
- if (type === "HTTP") {
22
- nitro.router.use(`${path}/**`, defineEventHandler(async (event) => {
23
- const evet = toWebRequest(event);
24
- const resolvedRoute = await silgiFetch(evet);
25
- return resolvedRoute;
26
- }));
27
- }
28
- }
29
- const webhookServices = Object.entries(silgiContext.services).filter(([key]) => key.startsWith("websocket:")).map(([, value]) => value);
30
- for (const webhook of webhookServices) {
31
- nitro.router.use(webhook.path, defineEventHandler({
32
- handler: () => {
33
- },
34
- websocket: webhook.websocket || {}
35
- }));
36
- }
1
+ import { silgiFetch, useSilgi } from "silgi";
2
+ import { defineEventHandler, toWebRequest } from "h3";
3
+
4
+ //#region src/runtime/internal/nitro.ts
5
+ async function addNitroApp(silgiContext = useSilgi()) {
6
+ const nitro = silgiContext.framework?.nitro;
7
+ if (!nitro) throw new Error("Nitro framework not found");
8
+ const prefixs = silgiContext.routerPrefixs;
9
+ for (const prefix of prefixs) {
10
+ let type = "http";
11
+ let path = "";
12
+ const parts = prefix.split(":");
13
+ type = parts[0] ? parts[0].toUpperCase() : "HTTP";
14
+ path = parts[1] ?? "";
15
+ if (type === "HTTP") nitro.router.use(`${path}/**`, defineEventHandler(async (event) => {
16
+ const evet = toWebRequest(event);
17
+ const resolvedRoute = await silgiFetch(evet);
18
+ return resolvedRoute;
19
+ }));
20
+ }
21
+ const webhookServices = Object.entries(silgiContext.services).filter(([key]) => key.startsWith("websocket:")).map(([, value]) => value);
22
+ for (const webhook of webhookServices) nitro.router.use(webhook.path, defineEventHandler({
23
+ handler: () => {},
24
+ websocket: webhook.websocket || {}
25
+ }));
37
26
  }
38
- export default addNitroApp;
27
+ var nitro_default = addNitroApp;
28
+
29
+ //#endregion
30
+ export { addNitroApp, nitro_default as default };
@@ -1,8 +1,12 @@
1
- import type { AsyncData, UseFetchOptions } from 'nuxt/app';
2
- import type { FetchError } from 'ofetch';
3
- import type { AllPaths, ExtractPathParams, SilgiRouterTypes, TrimAfterFourSlashes } from 'silgi/types';
4
- export declare function useSilgiFetch<T, P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(path: P, options?: {
5
- method?: M;
6
- params?: ExtractPathParams<P>;
7
- body?: SilgiRouterTypes[BasePath][M]['input'];
8
- } & Omit<UseFetchOptions<T>, 'method' | 'body' | 'params'>): AsyncData<SilgiRouterTypes[BasePath][M]["output"], FetchError | null>;
1
+ import { AsyncData, UseFetchOptions } from "nuxt/app";
2
+ import { AllPaths, ExtractPathParams, SilgiRouterTypes, TrimAfterFourSlashes } from "silgi/types";
3
+ import { FetchError } from "ofetch";
4
+
5
+ //#region src/runtime/internal/nuxt.d.ts
6
+ declare function useSilgiFetch<T, P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = (TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never), M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(path: P, options?: {
7
+ method?: M;
8
+ params?: ExtractPathParams<P>;
9
+ body?: SilgiRouterTypes[BasePath][M]["input"];
10
+ } & Omit<UseFetchOptions<T>, "method" | "body" | "params">): AsyncData<SilgiRouterTypes[BasePath][M]["output"], FetchError | null>;
11
+ //#endregion
12
+ export { useSilgiFetch };
@@ -1,11 +1,16 @@
1
1
  import { useFetch } from "nuxt/app";
2
+
3
+ //#region src/runtime/internal/nuxt.ts
2
4
  function replacePathParams(template, params) {
3
- return template.replace(/:([^/]+)/g, (_, param) => params[param] || `:${param}`);
5
+ return template.replace(/:([^/]+)/g, (_, param) => params[param] || `:${param}`);
4
6
  }
5
- export function useSilgiFetch(path, options) {
6
- const resolvedPath = options?.params ? replacePathParams(path, options.params) : path;
7
- return useFetch(resolvedPath, {
8
- method: options?.method,
9
- body: options?.body
10
- });
7
+ function useSilgiFetch(path, options) {
8
+ const resolvedPath = options?.params ? replacePathParams(path, options.params) : path;
9
+ return useFetch(resolvedPath, {
10
+ method: options?.method,
11
+ body: options?.body
12
+ });
11
13
  }
14
+
15
+ //#endregion
16
+ export { useSilgiFetch };
@@ -1,4 +1,8 @@
1
- import type { FetchOptions, FetchResponse } from 'ofetch';
2
- import type { AllPaths, SilgiFetchClient, SilgiFetchOptions, SilgiRouterTypes, TrimAfterFourSlashes } from 'silgi/types';
3
- export declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
4
- export declare function silgi$fetch<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: P, opts?: SilgiFetchOptions<P, BasePath, M>): Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
1
+ import { AllPaths, SilgiFetchClient, SilgiFetchOptions, SilgiRouterTypes, TrimAfterFourSlashes } from "silgi/types";
2
+ import { FetchOptions, FetchResponse } from "ofetch";
3
+
4
+ //#region src/runtime/internal/ofetch.d.ts
5
+ declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
6
+ declare function silgi$fetch<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = (TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never), M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: P, opts?: SilgiFetchOptions<P, BasePath, M>): Promise<FetchResponse<SilgiRouterTypes[BasePath][M]["output"]>>;
7
+ //#endregion
8
+ export { createSilgiFetch, silgi$fetch };
@@ -1,40 +1,39 @@
1
- export function createSilgiFetch(options, localFetch) {
2
- return (url, opts) => {
3
- const finalOpts = {
4
- ...typeof options === "function" ? options(opts) : options,
5
- ...opts,
6
- method: opts?.method || "get"
7
- };
8
- const $fetch = getFetch(url, finalOpts, localFetch);
9
- return $fetch(fillPath(url, opts?.params), finalOpts);
10
- };
1
+ //#region src/runtime/internal/ofetch.ts
2
+ function createSilgiFetch(options, localFetch) {
3
+ return (url, opts) => {
4
+ const finalOpts = {
5
+ ...typeof options === "function" ? options(opts) : options,
6
+ ...opts,
7
+ method: opts?.method || "get"
8
+ };
9
+ const $fetch = getFetch(url, finalOpts, localFetch);
10
+ return $fetch(fillPath(url, opts?.params), finalOpts);
11
+ };
11
12
  }
12
- export function silgi$fetch(url, opts) {
13
- const finalOpts = {
14
- ...opts,
15
- method: opts?.method || "get"
16
- };
17
- const $fetch = getFetch(url, finalOpts);
18
- return $fetch(fillPath(url, opts?.params), finalOpts);
13
+ function silgi$fetch(url, opts) {
14
+ const finalOpts = {
15
+ ...opts,
16
+ method: opts?.method || "get"
17
+ };
18
+ const $fetch = getFetch(url, finalOpts);
19
+ return $fetch(fillPath(url, opts?.params), finalOpts);
19
20
  }
20
21
  function getFetch(url, opts, localFetch) {
21
- if (import.meta.server && localFetch) {
22
- const isLocalFetch = url[0] === "/" && (!opts.baseURL || opts.baseURL[0] === "/");
23
- if (isLocalFetch)
24
- return localFetch;
25
- }
26
- return globalThis.$fetch;
22
+ if (import.meta.server && localFetch) {
23
+ const isLocalFetch = url[0] === "/" && (!opts.baseURL || opts.baseURL[0] === "/");
24
+ if (isLocalFetch) return localFetch;
25
+ }
26
+ return globalThis.$fetch;
27
27
  }
28
28
  function fillPath(path, params) {
29
- if (!params || Object.keys(params).length === 0) {
30
- return path;
31
- }
32
- let result = path;
33
- for (const [key, value] of Object.entries(params)) {
34
- const pattern = `:${key}`;
35
- if (result.includes(pattern)) {
36
- result = result.replace(pattern, value);
37
- }
38
- }
39
- return result;
29
+ if (!params || Object.keys(params).length === 0) return path;
30
+ let result = path;
31
+ for (const [key, value] of Object.entries(params)) {
32
+ const pattern = `:${key}`;
33
+ if (result.includes(pattern)) result = result.replace(pattern, value);
34
+ }
35
+ return result;
40
36
  }
37
+
38
+ //#endregion
39
+ export { createSilgiFetch, silgi$fetch };
@@ -1,3 +1,7 @@
1
- import type { SilgiAppPlugin } from 'silgi/types';
2
- export declare function defineSilgiPlugin(def: SilgiAppPlugin): SilgiAppPlugin;
3
- export declare const silgiPlugin: typeof defineSilgiPlugin;
1
+ import { SilgiAppPlugin } from "silgi/types";
2
+
3
+ //#region src/runtime/internal/plugin.d.ts
4
+ declare function defineSilgiPlugin(def: SilgiAppPlugin): SilgiAppPlugin;
5
+ declare const silgiPlugin: typeof defineSilgiPlugin;
6
+ //#endregion
7
+ export { defineSilgiPlugin, silgiPlugin };
@@ -1,4 +1,8 @@
1
- export function defineSilgiPlugin(def) {
2
- return def;
1
+ //#region src/runtime/internal/plugin.ts
2
+ function defineSilgiPlugin(def) {
3
+ return def;
3
4
  }
4
- export const silgiPlugin = defineSilgiPlugin;
5
+ const silgiPlugin = defineSilgiPlugin;
6
+
7
+ //#endregion
8
+ export { defineSilgiPlugin, silgiPlugin };