silgi 0.37.21 → 0.37.23
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 +3 -11
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.d.mts +2 -1
- package/dist/core/index.mjs +10 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/runtime/internal/config.d.mts +1 -1
- package/dist/runtime/internal/config.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { consola } from 'consola';
|
|
2
2
|
import { createHooks, createDebugger } from 'hookable';
|
|
3
3
|
import { resolve, join, relative, extname, basename, dirname, isAbsolute } from 'pathe';
|
|
4
|
-
import { useSilgiCLI, replaceRuntimeValues,
|
|
4
|
+
import { useSilgiCLI, replaceRuntimeValues, updateRuntimeStorage, 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
6
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
7
7
|
import { scanExports, createUnimport, toExports } from 'unimport';
|
|
@@ -1048,10 +1048,6 @@ async function readScanFile(silgi) {
|
|
|
1048
1048
|
alias: silgi.options.alias
|
|
1049
1049
|
});
|
|
1050
1050
|
try {
|
|
1051
|
-
globalThis._silgi_runtime = silgi.options.runtimeConfig;
|
|
1052
|
-
injectedResult.code = `globalThis._silgi_runtime = ${JSON.stringify(silgi.options.runtimeConfig)};
|
|
1053
|
-
${injectedResult.code}`;
|
|
1054
|
-
injectedResult.code = injectedResult.code.replace(/runtimeConfig: \{\}/, `runtimeConfig: ${JSON.stringify(silgi.options.runtimeConfig)}`);
|
|
1055
1051
|
const scanFile = await jiti.evalModule(
|
|
1056
1052
|
injectedResult.code,
|
|
1057
1053
|
{
|
|
@@ -1457,10 +1453,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1457
1453
|
},
|
|
1458
1454
|
adapters: {}
|
|
1459
1455
|
};
|
|
1460
|
-
|
|
1461
|
-
globalThis.__silgi__.useRuntimeConfig = function() {
|
|
1462
|
-
return silgi?.options?.runtimeConfig || {};
|
|
1463
|
-
};
|
|
1456
|
+
updateRuntimeStorage(silgi.options.runtimeConfig);
|
|
1464
1457
|
if (silgi.options.adapters && Object.keys(silgi.options.adapters)?.length > 0) {
|
|
1465
1458
|
for (const [key, value] of Object.entries(silgi.options.adapters)) {
|
|
1466
1459
|
silgi.adapters[key] = value;
|
|
@@ -1491,7 +1484,6 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1491
1484
|
await framework(silgi);
|
|
1492
1485
|
}
|
|
1493
1486
|
await writeScanFiles(silgi);
|
|
1494
|
-
asyncRuntimeStorage.set(silgi.options.runtimeConfig);
|
|
1495
1487
|
silgi.storage = await createStorageCLI(silgi);
|
|
1496
1488
|
silgi.hooks.hook("close", async () => {
|
|
1497
1489
|
await silgi.storage.dispose();
|
|
@@ -1528,7 +1520,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1528
1520
|
}
|
|
1529
1521
|
await registerModuleExportScan(silgi);
|
|
1530
1522
|
await writeScanFiles(silgi);
|
|
1531
|
-
|
|
1523
|
+
updateRuntimeStorage(silgi.options.runtimeConfig);
|
|
1532
1524
|
return silgi;
|
|
1533
1525
|
}
|
|
1534
1526
|
|
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -280,6 +280,7 @@ declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base
|
|
|
280
280
|
|
|
281
281
|
/** async local storage for the name of the current silgi instance */
|
|
282
282
|
declare const asyncRuntimeStorage: UseContext<SilgiRuntimeConfig>;
|
|
283
|
+
declare function updateRuntimeStorage(runtime: any): void;
|
|
283
284
|
/** Direct access to the silgi context with asyncLocalStorage - see https://github.com/unjs/unctx. */
|
|
284
285
|
declare const getRuntimeCtx: () => SilgiRuntimeConfig | null;
|
|
285
286
|
/**
|
|
@@ -308,4 +309,4 @@ declare function tryUseRuntime(): SilgiRuntimeConfig | null;
|
|
|
308
309
|
|
|
309
310
|
declare const autoImportTypes: string[];
|
|
310
311
|
|
|
311
|
-
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseRuntime, tryUseSilgi, tryUseSilgiCLI, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
|
312
|
+
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseRuntime, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -15,6 +15,14 @@ const asyncRuntimeStorage = createContext({
|
|
|
15
15
|
asyncContext: true,
|
|
16
16
|
AsyncLocalStorage
|
|
17
17
|
});
|
|
18
|
+
function updateRuntimeStorage(runtime) {
|
|
19
|
+
if (asyncRuntimeStorage.tryUse()) {
|
|
20
|
+
asyncRuntimeStorage.unset();
|
|
21
|
+
asyncRuntimeStorage.set(runtime);
|
|
22
|
+
} else {
|
|
23
|
+
asyncRuntimeStorage.set(runtime);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
18
26
|
const getRuntimeCtx = () => asyncRuntimeStorage.tryUse();
|
|
19
27
|
function useRuntime() {
|
|
20
28
|
const instance = asyncRuntimeStorage.tryUse();
|
|
@@ -299,7 +307,7 @@ async function createSilgi(config) {
|
|
|
299
307
|
captureError: config.captureError ?? (() => {
|
|
300
308
|
})
|
|
301
309
|
};
|
|
302
|
-
|
|
310
|
+
updateRuntimeStorage(silgi.options.runtimeConfig);
|
|
303
311
|
if (!silgi.router) {
|
|
304
312
|
silgi.router = createRouter();
|
|
305
313
|
}
|
|
@@ -987,4 +995,4 @@ const autoImportTypes = [
|
|
|
987
995
|
"ExtractQueryParamsFromURI"
|
|
988
996
|
];
|
|
989
997
|
|
|
990
|
-
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseRuntime, tryUseSilgi, useRuntime, useSilgi, useSilgiStorage };
|
|
998
|
+
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseRuntime, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseRuntime, tryUseSilgi, tryUseSilgiCLI, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
1
|
+
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseRuntime, 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, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseRuntime, tryUseSilgi, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
|
|
1
|
+
export { SilgiError, asyncRuntimeStorage, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createSilgiCore, createStorage, deepMergeObjects, getEvent, getEventContext, getRuntimeCtx, getUrlPrefix, handleResponse, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseRuntime, 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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EnvOptions, SilgiEvent, SilgiRuntimeConfig } from 'silgi/types';
|
|
2
2
|
export declare function updateEnvOptions(): EnvOptions;
|
|
3
|
-
export declare function useSilgiRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvent
|
|
3
|
+
export declare function useSilgiRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvent): SilgiRuntimeConfig;
|
|
4
4
|
export declare function initRuntimeConfig(envOptions?: EnvOptions, inlineRuntimeConfig?: Record<string, any>): Readonly<Record<string, any>>;
|
|
5
5
|
export declare function updateRuntimeConfig(runtimeConfig: Record<string, unknown>): void;
|
|
6
6
|
export declare function applyEnv(obj: Record<string, any>, opts: EnvOptions, parentKey?: string): Record<string, any>;
|
|
@@ -17,7 +17,7 @@ export function updateEnvOptions() {
|
|
|
17
17
|
asyncRuntimeStorage.set(_sharedRuntimeConfig);
|
|
18
18
|
return envOptions;
|
|
19
19
|
}
|
|
20
|
-
export function useSilgiRuntimeConfig(event
|
|
20
|
+
export function useSilgiRuntimeConfig(event) {
|
|
21
21
|
const runtime = useRuntime();
|
|
22
22
|
if (!event) {
|
|
23
23
|
return runtime;
|