silgi 0.37.37 → 0.37.39
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/cli/build.mjs +7 -6
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.d.mts +1 -16
- package/dist/core/index.mjs +4 -8
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/runtime/index.d.mts +1 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/internal/config.d.mts +1 -1
- package/dist/runtime/internal/config.mjs +1 -1
- package/dist/types/index.d.mts +505 -520
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { createHooks, createDebugger } from 'hookable';
|
|
|
3
3
|
import { resolve, join, relative, extname, basename, dirname, isAbsolute } from 'pathe';
|
|
4
4
|
import { useSilgiCLI, replaceRuntimeValues, silgiCLICtx, autoImportTypes } from 'silgi';
|
|
5
5
|
import { isPresents, addTemplate, addCoreFile, genEnsureSafeVar, writeFile, relativeWithDot, hash, removeExtension, resolveAlias, directoryToURL, addImports, baseHeaderBannerComment, normalizeTemplate, useLogger, resolveSilgiPath, hasSilgiModule, toArray, isDirectory } from 'silgi/kit';
|
|
6
|
-
import {
|
|
6
|
+
import { useRuntimeConfig, initRuntimeConfig, sharedRuntimeConfig } from 'silgi/runtime';
|
|
7
7
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
8
8
|
import { scanExports, createUnimport, toExports } from 'unimport';
|
|
9
9
|
import * as p from '@clack/prompts';
|
|
@@ -1169,7 +1169,7 @@ async function writeScanFiles(silgi) {
|
|
|
1169
1169
|
|
|
1170
1170
|
async function createStorageCLI(silgi) {
|
|
1171
1171
|
const storage = createStorage();
|
|
1172
|
-
const runtime =
|
|
1172
|
+
const runtime = useRuntimeConfig();
|
|
1173
1173
|
const mounts = klona({
|
|
1174
1174
|
...silgi.options.storage,
|
|
1175
1175
|
...silgi.options.devStorage
|
|
@@ -1413,6 +1413,7 @@ async function scanDir(silgi, dir, name) {
|
|
|
1413
1413
|
|
|
1414
1414
|
async function createSilgiCLI(config = {}, opts = {}) {
|
|
1415
1415
|
const options = await loadOptions(config, opts);
|
|
1416
|
+
await prepareEnv(options);
|
|
1416
1417
|
const hooks = createHooks();
|
|
1417
1418
|
const silgi = {
|
|
1418
1419
|
scannedURIs: /* @__PURE__ */ new Map(),
|
|
@@ -1434,9 +1435,9 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1434
1435
|
hook: hooks.hook,
|
|
1435
1436
|
async updateConfig(_config) {
|
|
1436
1437
|
},
|
|
1437
|
-
adapters: {}
|
|
1438
|
+
adapters: {},
|
|
1439
|
+
useLocalConfig: () => useRuntimeConfig(void 0, options.runtimeConfig, true)
|
|
1438
1440
|
};
|
|
1439
|
-
await prepareEnv(options);
|
|
1440
1441
|
sharedRuntimeConfig(silgi.options.runtimeConfig);
|
|
1441
1442
|
if (silgiCLICtx.tryUse()) {
|
|
1442
1443
|
silgiCLICtx.unset();
|
|
@@ -1622,14 +1623,14 @@ async function prepareConfigs(silgi) {
|
|
|
1622
1623
|
await silgi.callHook("prepare:configs.ts", _data);
|
|
1623
1624
|
const importData = [
|
|
1624
1625
|
"import type { SilgiRuntimeOptions, SilgiRuntimeConfig, SilgiOptions } from 'silgi/types'",
|
|
1625
|
-
"import {
|
|
1626
|
+
"import { useRuntimeConfig } from 'silgi/runtime'",
|
|
1626
1627
|
"",
|
|
1627
1628
|
`export const runtimeConfig: SilgiRuntimeConfig = ${genObjectFromRawEntries(
|
|
1628
1629
|
Object.entries(_data.runtimeConfig).map(([key, value]) => [key, genEnsureSafeVar(value)]),
|
|
1629
1630
|
""
|
|
1630
1631
|
)}`,
|
|
1631
1632
|
"",
|
|
1632
|
-
"export const
|
|
1633
|
+
"export const localConfig = useRuntimeConfig(undefined, runtimeConfig)",
|
|
1633
1634
|
""
|
|
1634
1635
|
];
|
|
1635
1636
|
delete _data.runtimeConfig;
|
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -279,8 +279,6 @@ declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
|
279
279
|
declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage['mount']>[1]) => T;
|
|
280
280
|
|
|
281
281
|
declare function updateRuntimeStorage(runtime: any): void;
|
|
282
|
-
/** Direct access to the silgi context with asyncLocalStorage - see https://github.com/unjs/unctx. */
|
|
283
|
-
declare const getRuntimeCtx: () => SilgiRuntimeConfig | null;
|
|
284
282
|
/**
|
|
285
283
|
* Get access to silgi instance.
|
|
286
284
|
*
|
|
@@ -291,20 +289,7 @@ declare const getRuntimeCtx: () => SilgiRuntimeConfig | null;
|
|
|
291
289
|
* ```
|
|
292
290
|
*/
|
|
293
291
|
declare function useRuntime(): SilgiRuntimeConfig;
|
|
294
|
-
/**
|
|
295
|
-
* Get access to Runtime instance.
|
|
296
|
-
*
|
|
297
|
-
* Returns null if Runtime instance is unavailable.
|
|
298
|
-
* @example
|
|
299
|
-
* ```js
|
|
300
|
-
* const runtime = tryUseRuntime()
|
|
301
|
-
* if (runtime) {
|
|
302
|
-
* // Do something
|
|
303
|
-
* }
|
|
304
|
-
* ```
|
|
305
|
-
*/
|
|
306
|
-
declare function tryUseRuntime(): SilgiRuntimeConfig | null;
|
|
307
292
|
|
|
308
293
|
declare const autoImportTypes: string[];
|
|
309
294
|
|
|
310
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
295
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createConsola } from 'consola';
|
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { createHooks } from 'hookable';
|
|
4
4
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
5
|
-
import {
|
|
5
|
+
import { useRuntimeConfig, sharedRuntimeConfig } from 'silgi/runtime';
|
|
6
6
|
import { getContext, createContext } from 'unctx';
|
|
7
7
|
import { Buffer } from 'node:buffer';
|
|
8
8
|
import { klona } from 'klona';
|
|
@@ -187,7 +187,7 @@ function replaceRuntimeValues(obj, runtime) {
|
|
|
187
187
|
|
|
188
188
|
async function createStorage(silgi) {
|
|
189
189
|
const storage = createStorage$1();
|
|
190
|
-
const runtime =
|
|
190
|
+
const runtime = useRuntimeConfig();
|
|
191
191
|
const mounts = klona({
|
|
192
192
|
...silgi.options.storage,
|
|
193
193
|
...silgi.options.devStorage
|
|
@@ -322,7 +322,7 @@ async function createSilgi(config) {
|
|
|
322
322
|
silgi.shared.storage = (...data) => {
|
|
323
323
|
return useSilgiStorage(...data);
|
|
324
324
|
};
|
|
325
|
-
silgi.shared.useRuntimeConfig =
|
|
325
|
+
silgi.shared.useRuntimeConfig = useRuntimeConfig;
|
|
326
326
|
if (silgiCtx.tryUse()) {
|
|
327
327
|
silgiCtx.unset();
|
|
328
328
|
silgiCtx.set(silgi);
|
|
@@ -976,7 +976,6 @@ function updateRuntimeStorage(runtime) {
|
|
|
976
976
|
asyncRuntimeStorage.set(runtime);
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
const getRuntimeCtx = () => asyncRuntimeStorage.tryUse();
|
|
980
979
|
function useRuntime() {
|
|
981
980
|
const instance = asyncRuntimeStorage.tryUse();
|
|
982
981
|
if (!instance) {
|
|
@@ -984,9 +983,6 @@ function useRuntime() {
|
|
|
984
983
|
}
|
|
985
984
|
return instance;
|
|
986
985
|
}
|
|
987
|
-
function tryUseRuntime() {
|
|
988
|
-
return asyncRuntimeStorage.tryUse();
|
|
989
|
-
}
|
|
990
986
|
|
|
991
987
|
const autoImportTypes = [
|
|
992
988
|
"ExtractInputFromURI",
|
|
@@ -995,4 +991,4 @@ const autoImportTypes = [
|
|
|
995
991
|
"ExtractQueryParamsFromURI"
|
|
996
992
|
];
|
|
997
993
|
|
|
998
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
994
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
import 'silgi/types';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unstorage';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext,
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from './_chunks/silgiApp.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'defu';
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { initRuntimeConfig, sharedRuntimeConfig,
|
|
1
|
+
export { initRuntimeConfig, sharedRuntimeConfig, useRuntimeConfig } from "./internal/config.mjs";
|
|
2
2
|
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
3
3
|
export { mergeDeep } from "./internal/defu.mjs";
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { initRuntimeConfig, sharedRuntimeConfig,
|
|
1
|
+
export { initRuntimeConfig, sharedRuntimeConfig, useRuntimeConfig } from "./internal/config.mjs";
|
|
2
2
|
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
3
3
|
export { mergeDeep } from "./internal/defu.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EnvOptions, SilgiEvent, SilgiRuntimeConfig } from 'silgi/types';
|
|
2
2
|
export declare function updateEnvOptions(runtime: SilgiRuntimeConfig): EnvOptions;
|
|
3
3
|
export declare function sharedRuntimeConfig(runtime: SilgiRuntimeConfig, force?: boolean): SilgiRuntimeConfig;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function useRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvent, localRuntimeConfig?: SilgiRuntimeConfig, force?: boolean): SilgiRuntimeConfig;
|
|
5
5
|
export declare function initRuntimeConfig(envOptions?: EnvOptions, inlineRuntimeConfig?: Record<string, any>): Readonly<Record<string, any>>;
|
|
6
6
|
export declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void;
|
|
7
7
|
export declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
|
|
@@ -23,7 +23,7 @@ export function sharedRuntimeConfig(runtime, force) {
|
|
|
23
23
|
updateRuntimeStorage(inlineRuntimeConfig);
|
|
24
24
|
return inlineRuntimeConfig;
|
|
25
25
|
}
|
|
26
|
-
export function
|
|
26
|
+
export function useRuntimeConfig(event, localRuntimeConfig, force) {
|
|
27
27
|
if (localRuntimeConfig) {
|
|
28
28
|
return sharedRuntimeConfig(localRuntimeConfig, force);
|
|
29
29
|
}
|