silgi 0.37.33 → 0.37.35
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/build.mjs +1 -1
- package/dist/cli/build.mjs +4 -4
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +1 -1
- package/dist/cli/install.mjs +1 -1
- package/dist/cli/watch.mjs +1 -1
- package/dist/core/index.d.mts +1 -3
- package/dist/core/index.mjs +29 -30
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/runtime/internal/config.d.mts +1 -1
- package/dist/runtime/internal/config.mjs +5 -9
- package/package.json +1 -1
package/dist/build.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import 'silgi';
|
|
|
9
9
|
import './cli/build.mjs';
|
|
10
10
|
import 'hookable';
|
|
11
11
|
import 'silgi/kit';
|
|
12
|
+
import 'silgi/runtime';
|
|
12
13
|
import 'silgi/runtime/meta';
|
|
13
14
|
import 'unimport';
|
|
14
15
|
import '@clack/prompts';
|
|
@@ -29,7 +30,6 @@ import 'globby';
|
|
|
29
30
|
import 'oxc-parser';
|
|
30
31
|
import 'ignore';
|
|
31
32
|
import 'klona';
|
|
32
|
-
import 'silgi/runtime';
|
|
33
33
|
import 'unstorage';
|
|
34
34
|
import 'scule';
|
|
35
35
|
import './cli/types.mjs';
|
package/dist/cli/build.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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, 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 { useSilgiRuntimeConfig, initRuntimeConfig, sharedRuntimeConfig } from 'silgi/runtime';
|
|
6
7
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
7
8
|
import { scanExports, createUnimport, toExports } from 'unimport';
|
|
8
9
|
import * as p from '@clack/prompts';
|
|
@@ -21,7 +22,6 @@ import { globby } from 'globby';
|
|
|
21
22
|
import { parseAsync } from 'oxc-parser';
|
|
22
23
|
import ignore from 'ignore';
|
|
23
24
|
import { klona } from 'klona';
|
|
24
|
-
import { useSilgiRuntimeConfig, initRuntimeConfig } from 'silgi/runtime';
|
|
25
25
|
import { createStorage, builtinDrivers } from 'unstorage';
|
|
26
26
|
import { snakeCase } from 'scule';
|
|
27
27
|
import { l as loadOptions, s as silgiGenerateType } from './types.mjs';
|
|
@@ -1437,7 +1437,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1437
1437
|
adapters: {}
|
|
1438
1438
|
};
|
|
1439
1439
|
await prepareEnv(options);
|
|
1440
|
-
|
|
1440
|
+
sharedRuntimeConfig(silgi.options.runtimeConfig);
|
|
1441
1441
|
if (silgiCLICtx.tryUse()) {
|
|
1442
1442
|
silgiCLICtx.unset();
|
|
1443
1443
|
silgiCLICtx.set(silgi);
|
|
@@ -1508,7 +1508,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1508
1508
|
}
|
|
1509
1509
|
await registerModuleExportScan(silgi);
|
|
1510
1510
|
await writeScanFiles(silgi);
|
|
1511
|
-
|
|
1511
|
+
sharedRuntimeConfig(silgi.options.runtimeConfig);
|
|
1512
1512
|
return silgi;
|
|
1513
1513
|
}
|
|
1514
1514
|
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import './build.mjs';
|
|
|
10
10
|
import 'hookable';
|
|
11
11
|
import 'silgi';
|
|
12
12
|
import 'silgi/kit';
|
|
13
|
+
import 'silgi/runtime';
|
|
13
14
|
import 'silgi/runtime/meta';
|
|
14
15
|
import 'unimport';
|
|
15
16
|
import 'dotenv';
|
|
@@ -26,7 +27,6 @@ import 'globby';
|
|
|
26
27
|
import 'oxc-parser';
|
|
27
28
|
import 'ignore';
|
|
28
29
|
import 'klona';
|
|
29
|
-
import 'silgi/runtime';
|
|
30
30
|
import 'unstorage';
|
|
31
31
|
import 'scule';
|
|
32
32
|
import './types.mjs';
|
package/dist/cli/install.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import 'pathe';
|
|
|
10
10
|
import './build.mjs';
|
|
11
11
|
import 'hookable';
|
|
12
12
|
import 'silgi';
|
|
13
|
+
import 'silgi/runtime';
|
|
13
14
|
import 'silgi/runtime/meta';
|
|
14
15
|
import 'unimport';
|
|
15
16
|
import '@clack/prompts';
|
|
@@ -29,7 +30,6 @@ import 'globby';
|
|
|
29
30
|
import 'oxc-parser';
|
|
30
31
|
import 'ignore';
|
|
31
32
|
import 'klona';
|
|
32
|
-
import 'silgi/runtime';
|
|
33
33
|
import 'unstorage';
|
|
34
34
|
import 'scule';
|
|
35
35
|
import './types.mjs';
|
package/dist/cli/watch.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import 'silgi';
|
|
|
12
12
|
import './build.mjs';
|
|
13
13
|
import 'hookable';
|
|
14
14
|
import 'silgi/kit';
|
|
15
|
+
import 'silgi/runtime';
|
|
15
16
|
import 'silgi/runtime/meta';
|
|
16
17
|
import 'unimport';
|
|
17
18
|
import '@clack/prompts';
|
|
@@ -31,7 +32,6 @@ import 'globby';
|
|
|
31
32
|
import 'oxc-parser';
|
|
32
33
|
import 'ignore';
|
|
33
34
|
import 'klona';
|
|
34
|
-
import 'silgi/runtime';
|
|
35
35
|
import 'unstorage';
|
|
36
36
|
import 'scule';
|
|
37
37
|
import './types.mjs';
|
package/dist/core/index.d.mts
CHANGED
|
@@ -278,8 +278,6 @@ declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
|
278
278
|
|
|
279
279
|
declare function storageMount<T extends Storage = Storage>(silgi?: Silgi): (base: keyof SilgiStorageBase, driver: Parameters<Storage['mount']>[1]) => T;
|
|
280
280
|
|
|
281
|
-
/** async local storage for the name of the current silgi instance */
|
|
282
|
-
declare const asyncRuntimeStorage: UseContext<SilgiRuntimeConfig>;
|
|
283
281
|
declare function updateRuntimeStorage(runtime: any): void;
|
|
284
282
|
/** Direct access to the silgi context with asyncLocalStorage - see https://github.com/unjs/unctx. */
|
|
285
283
|
declare const getRuntimeCtx: () => SilgiRuntimeConfig | null;
|
|
@@ -309,4 +307,4 @@ declare function tryUseRuntime(): SilgiRuntimeConfig | null;
|
|
|
309
307
|
|
|
310
308
|
declare const autoImportTypes: string[];
|
|
311
309
|
|
|
312
|
-
export { SilgiError,
|
|
310
|
+
export { SilgiError, 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
|
@@ -2,39 +2,14 @@ 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 {
|
|
6
|
-
import {
|
|
7
|
-
import { createContext, getContext } from 'unctx';
|
|
5
|
+
import { useSilgiRuntimeConfig, sharedRuntimeConfig } from 'silgi/runtime';
|
|
6
|
+
import { getContext, createContext } from 'unctx';
|
|
8
7
|
import { Buffer } from 'node:buffer';
|
|
9
8
|
import { klona } from 'klona';
|
|
10
9
|
import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
|
|
11
10
|
import { FastURL, FastResponse } from 'srvx';
|
|
12
11
|
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
13
|
-
|
|
14
|
-
const asyncRuntimeStorage = createContext({
|
|
15
|
-
asyncContext: true,
|
|
16
|
-
AsyncLocalStorage
|
|
17
|
-
});
|
|
18
|
-
function updateRuntimeStorage(runtime) {
|
|
19
|
-
if (asyncRuntimeStorage.tryUse()) {
|
|
20
|
-
asyncRuntimeStorage.unset();
|
|
21
|
-
asyncRuntimeStorage.set(runtime);
|
|
22
|
-
} else {
|
|
23
|
-
asyncRuntimeStorage.set(runtime);
|
|
24
|
-
}
|
|
25
|
-
sharedRuntimeConfig(runtime, true);
|
|
26
|
-
}
|
|
27
|
-
const getRuntimeCtx = () => asyncRuntimeStorage.tryUse();
|
|
28
|
-
function useRuntime() {
|
|
29
|
-
const instance = asyncRuntimeStorage.tryUse();
|
|
30
|
-
if (!instance) {
|
|
31
|
-
throw new Error("Runtime instance is unavailable!");
|
|
32
|
-
}
|
|
33
|
-
return instance;
|
|
34
|
-
}
|
|
35
|
-
function tryUseRuntime() {
|
|
36
|
-
return asyncRuntimeStorage.tryUse();
|
|
37
|
-
}
|
|
12
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
38
13
|
|
|
39
14
|
const silgiCtx = getContext("silgi");
|
|
40
15
|
function useSilgi() {
|
|
@@ -308,7 +283,7 @@ async function createSilgi(config) {
|
|
|
308
283
|
captureError: config.captureError ?? (() => {
|
|
309
284
|
})
|
|
310
285
|
};
|
|
311
|
-
|
|
286
|
+
sharedRuntimeConfig(silgi.options.runtimeConfig);
|
|
312
287
|
if (!silgi.router) {
|
|
313
288
|
silgi.router = createRouter();
|
|
314
289
|
}
|
|
@@ -989,6 +964,30 @@ function storageMount(silgi) {
|
|
|
989
964
|
};
|
|
990
965
|
}
|
|
991
966
|
|
|
967
|
+
const asyncRuntimeStorage = createContext({
|
|
968
|
+
asyncContext: true,
|
|
969
|
+
AsyncLocalStorage
|
|
970
|
+
});
|
|
971
|
+
function updateRuntimeStorage(runtime) {
|
|
972
|
+
if (asyncRuntimeStorage.tryUse()) {
|
|
973
|
+
asyncRuntimeStorage.unset();
|
|
974
|
+
asyncRuntimeStorage.set(runtime);
|
|
975
|
+
} else {
|
|
976
|
+
asyncRuntimeStorage.set(runtime);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
const getRuntimeCtx = () => asyncRuntimeStorage.tryUse();
|
|
980
|
+
function useRuntime() {
|
|
981
|
+
const instance = asyncRuntimeStorage.tryUse();
|
|
982
|
+
if (!instance) {
|
|
983
|
+
throw new Error("Runtime instance is unavailable!");
|
|
984
|
+
}
|
|
985
|
+
return instance;
|
|
986
|
+
}
|
|
987
|
+
function tryUseRuntime() {
|
|
988
|
+
return asyncRuntimeStorage.tryUse();
|
|
989
|
+
}
|
|
990
|
+
|
|
992
991
|
const autoImportTypes = [
|
|
993
992
|
"ExtractInputFromURI",
|
|
994
993
|
"ExtractOutputFromURI",
|
|
@@ -996,4 +995,4 @@ const autoImportTypes = [
|
|
|
996
995
|
"ExtractQueryParamsFromURI"
|
|
997
996
|
];
|
|
998
997
|
|
|
999
|
-
export { SilgiError,
|
|
998
|
+
export { SilgiError, 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,
|
|
1
|
+
export { SilgiError, 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,13 +1,13 @@
|
|
|
1
|
-
export { SilgiError,
|
|
1
|
+
export { SilgiError, 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';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
import 'rou3';
|
|
7
7
|
import 'silgi/runtime';
|
|
8
|
-
import 'node:async_hooks';
|
|
9
8
|
import 'unctx';
|
|
10
9
|
import 'node:buffer';
|
|
11
10
|
import 'klona';
|
|
12
11
|
import 'unstorage';
|
|
13
12
|
import 'srvx';
|
|
13
|
+
import 'node:async_hooks';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EnvOptions, SilgiEvent, SilgiRuntimeConfig } from 'silgi/types';
|
|
2
2
|
export declare function updateEnvOptions(runtime: SilgiRuntimeConfig): EnvOptions;
|
|
3
|
-
export declare function sharedRuntimeConfig(runtime: SilgiRuntimeConfig, force
|
|
3
|
+
export declare function sharedRuntimeConfig(runtime: SilgiRuntimeConfig, force?: boolean): SilgiRuntimeConfig;
|
|
4
4
|
export declare function useSilgiRuntimeConfig<T extends SilgiRuntimeConfig>(event?: SilgiEvent, localRuntimeConfig?: SilgiRuntimeConfig): 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;
|
|
@@ -2,7 +2,7 @@ import { defu } from "defu";
|
|
|
2
2
|
import destr from "destr";
|
|
3
3
|
import { klona } from "klona";
|
|
4
4
|
import { snakeCase } from "scule";
|
|
5
|
-
import {
|
|
5
|
+
import { updateRuntimeStorage, useRuntime, useSilgi } from "silgi";
|
|
6
6
|
export function updateEnvOptions(runtime) {
|
|
7
7
|
const envOptions = {
|
|
8
8
|
prefix: "NITRO_",
|
|
@@ -12,20 +12,16 @@ export function updateEnvOptions(runtime) {
|
|
|
12
12
|
};
|
|
13
13
|
return envOptions;
|
|
14
14
|
}
|
|
15
|
-
let inlineRuntimeConfig
|
|
15
|
+
let inlineRuntimeConfig;
|
|
16
16
|
export function sharedRuntimeConfig(runtime, force) {
|
|
17
|
-
|
|
17
|
+
updateRuntimeStorage(inlineRuntimeConfig);
|
|
18
|
+
if (inlineRuntimeConfig && !force) {
|
|
18
19
|
return inlineRuntimeConfig;
|
|
19
20
|
}
|
|
20
21
|
inlineRuntimeConfig = _deepFreeze(
|
|
21
22
|
applyEnv(klona(runtime ?? {}), updateEnvOptions(runtime))
|
|
22
23
|
);
|
|
23
|
-
|
|
24
|
-
asyncRuntimeStorage.unset();
|
|
25
|
-
asyncRuntimeStorage.set(inlineRuntimeConfig);
|
|
26
|
-
} else {
|
|
27
|
-
asyncRuntimeStorage.set(inlineRuntimeConfig);
|
|
28
|
-
}
|
|
24
|
+
updateRuntimeStorage(inlineRuntimeConfig);
|
|
29
25
|
return inlineRuntimeConfig;
|
|
30
26
|
}
|
|
31
27
|
export function useSilgiRuntimeConfig(event, localRuntimeConfig) {
|