silgi 0.9.17 → 0.9.20
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/_chunks/index.mjs +1 -1
- package/dist/cli/prepare.mjs +26 -30
- package/dist/core/index.mjs +2 -0
- package/dist/kit/index.mjs +2 -2
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.d.ts +4 -4
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -627,12 +627,12 @@ async function silgiCoreFile(data, frameworkContext, silgi) {
|
|
|
627
627
|
" modulesURIs,",
|
|
628
628
|
` plugins: [${plugins.join(", ")}],`,
|
|
629
629
|
_data._silgiConfigs.length > 0 ? ` ${_data._silgiConfigs.map((config) => typeof config === "string" ? config : typeof config === "object" ? Object.entries(config).map(([key, value]) => `${key}: ${value}`).join(",\n ") : "").join(",\n ")},` : "",
|
|
630
|
+
" runtimeConfig: {},",
|
|
630
631
|
" ...buildOptions,",
|
|
631
632
|
" options: mergeDeep(",
|
|
632
633
|
" moduleOptions || {},",
|
|
633
634
|
" {",
|
|
634
635
|
` present: '${silgi.options.preset}',`,
|
|
635
|
-
" runtimeConfig: {},",
|
|
636
636
|
" ...cliOptions,",
|
|
637
637
|
" },",
|
|
638
638
|
" ) as any,",
|
|
@@ -1179,36 +1179,43 @@ function createDependencyGraph(modules) {
|
|
|
1179
1179
|
if (key) {
|
|
1180
1180
|
graph.set(key, /* @__PURE__ */ new Set());
|
|
1181
1181
|
inDegree.set(key, 0);
|
|
1182
|
-
logger$1.debug(`Module registered: ${key}`);
|
|
1183
1182
|
}
|
|
1184
1183
|
});
|
|
1185
1184
|
modules.forEach((module) => {
|
|
1186
1185
|
const key = module.meta?.configKey;
|
|
1187
|
-
if (!key)
|
|
1186
|
+
if (!key) {
|
|
1188
1187
|
return;
|
|
1188
|
+
}
|
|
1189
1189
|
const requiredDeps = module.meta?.requiredDependencies || [];
|
|
1190
|
+
const beforeDeps = module.meta?.beforeDependencies || [];
|
|
1190
1191
|
const afterDeps = module.meta?.afterDependencies || [];
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1192
|
+
const processedDeps = /* @__PURE__ */ new Set();
|
|
1193
|
+
requiredDeps.forEach((dep) => {
|
|
1194
|
+
if (!graph.has(dep)) {
|
|
1195
|
+
throw new Error(`Required dependency "${dep}" for module "${key}" is missing`);
|
|
1196
|
+
}
|
|
1197
|
+
graph.get(dep)?.add(key);
|
|
1198
|
+
inDegree.set(key, (inDegree.get(key) || 0) + 1);
|
|
1199
|
+
processedDeps.add(dep);
|
|
1200
|
+
});
|
|
1201
|
+
beforeDeps.forEach((dep) => {
|
|
1202
|
+
if (!graph.has(dep)) {
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
graph.get(key)?.add(dep);
|
|
1206
|
+
inDegree.set(dep, (inDegree.get(dep) || 0) + 1);
|
|
1207
|
+
});
|
|
1208
|
+
afterDeps.forEach((dep) => {
|
|
1209
|
+
if (processedDeps.has(dep)) {
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1193
1212
|
if (!graph.has(dep)) {
|
|
1194
|
-
if (requiredDeps.includes(dep)) {
|
|
1195
|
-
throw new Error(`Required dependency "${dep}" for module "${key}" is missing`);
|
|
1196
|
-
}
|
|
1197
|
-
logger$1.debug(`Optional dependency for ${key}: "${dep}" not found, skipping`);
|
|
1198
1213
|
return;
|
|
1199
1214
|
}
|
|
1200
1215
|
graph.get(dep)?.add(key);
|
|
1201
1216
|
inDegree.set(key, (inDegree.get(key) || 0) + 1);
|
|
1202
|
-
const depType = requiredDeps.includes(dep) ? "required" : "after";
|
|
1203
|
-
logger$1.debug(`${key} depends on ${dep} (${depType})`);
|
|
1204
1217
|
});
|
|
1205
1218
|
});
|
|
1206
|
-
logger$1.debug("\nDependency Graph:");
|
|
1207
|
-
for (const [module, deps] of graph.entries()) {
|
|
1208
|
-
const depsStr = Array.from(deps).join(", ");
|
|
1209
|
-
logger$1.debug(`${module} -> ${depsStr} (deps run after this module)`);
|
|
1210
|
-
logger$1.debug(`${module} in-degree: ${inDegree.get(module)}`);
|
|
1211
|
-
}
|
|
1212
1219
|
return { graph, inDegree };
|
|
1213
1220
|
}
|
|
1214
1221
|
function findCyclicDependencies(graph) {
|
|
@@ -1243,35 +1250,25 @@ function topologicalSort(graphData) {
|
|
|
1243
1250
|
const { graph, inDegree } = graphData;
|
|
1244
1251
|
const order = [];
|
|
1245
1252
|
const queue = [];
|
|
1246
|
-
logger$1.debug("\nStarting topological sort:");
|
|
1247
|
-
logger$1.debug("Initial in-degrees:", Object.fromEntries(inDegree));
|
|
1248
1253
|
for (const [node, degree] of inDegree.entries()) {
|
|
1249
1254
|
if (degree === 0) {
|
|
1250
1255
|
queue.push(node);
|
|
1251
|
-
logger$1.debug(`Adding initial module: ${node} (no dependencies)`);
|
|
1252
1256
|
}
|
|
1253
1257
|
}
|
|
1254
1258
|
while (queue.length > 0) {
|
|
1255
1259
|
const node = queue.shift();
|
|
1256
1260
|
order.push(node);
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
for (const neighbor of graph.get(node) || []) {
|
|
1261
|
+
const neighbors = Array.from(graph.get(node) || []);
|
|
1262
|
+
for (const neighbor of neighbors) {
|
|
1260
1263
|
const newDegree = (inDegree.get(neighbor) || 0) - 1;
|
|
1261
1264
|
inDegree.set(neighbor, newDegree);
|
|
1262
|
-
logger$1.debug(` ${neighbor} dependencies remaining: ${newDegree}`);
|
|
1263
1265
|
if (newDegree === 0) {
|
|
1264
1266
|
queue.push(neighbor);
|
|
1265
|
-
logger$1.debug(` Queuing: ${neighbor}`);
|
|
1266
1267
|
}
|
|
1267
1268
|
}
|
|
1268
1269
|
}
|
|
1269
1270
|
if (order.length !== graph.size) {
|
|
1270
1271
|
const cycles = findCyclicDependencies(graph);
|
|
1271
|
-
logger$1.debug("\nDependency graph state:");
|
|
1272
|
-
graph.forEach((deps, module) => {
|
|
1273
|
-
logger$1.debug(`${module} -> ${Array.from(deps).join(", ")}`);
|
|
1274
|
-
});
|
|
1275
1272
|
if (cycles.length > 0) {
|
|
1276
1273
|
const cycleStr = cycles.map((cycle) => ` ${cycle.join(" -> ")}`).join("\n");
|
|
1277
1274
|
throw new Error(`Circular dependencies detected:
|
|
@@ -1281,7 +1278,6 @@ ${cycleStr}`);
|
|
|
1281
1278
|
throw new Error(`Unable to resolve dependencies for modules: ${unresolvedModules.join(", ")}`);
|
|
1282
1279
|
}
|
|
1283
1280
|
}
|
|
1284
|
-
logger$1.debug("\nFinal module order:", order.join(" -> "));
|
|
1285
1281
|
return order;
|
|
1286
1282
|
}
|
|
1287
1283
|
|
package/dist/core/index.mjs
CHANGED
|
@@ -503,6 +503,8 @@ async function createSilgi(config) {
|
|
|
503
503
|
ready: () => {
|
|
504
504
|
return hooks.callHook("ready", silgi);
|
|
505
505
|
},
|
|
506
|
+
envOptions: config.envOptions ?? {},
|
|
507
|
+
runtimeConfig: config.runtimeConfig ?? {},
|
|
506
508
|
close: () => hooks.callHook("close", silgi),
|
|
507
509
|
logger: createConsola(defu(config.options?.consolaOptions ?? {}, {
|
|
508
510
|
tag: "silgi"
|
package/dist/kit/index.mjs
CHANGED
|
@@ -248,12 +248,12 @@ function useSilgiRuntimeConfig() {
|
|
|
248
248
|
if (!silgi) {
|
|
249
249
|
return globalThis.$silgiSharedRuntimeConfig;
|
|
250
250
|
}
|
|
251
|
-
return applyEnv(klona(silgi.
|
|
251
|
+
return applyEnv(klona(silgi.runtimeConfig), {
|
|
252
252
|
prefix: "NITRO_",
|
|
253
253
|
altPrefix: "NUXT_",
|
|
254
254
|
silgiPrefix: "SILGI_",
|
|
255
255
|
envExpansion: silgi.options.experimental?.envExpansion ?? !!process$1.env.NITRO_ENV_EXPANSION,
|
|
256
|
-
...silgi.
|
|
256
|
+
...silgi.envOptions
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
function getEnv(key, opts, env = process$1.env) {
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -934,6 +934,10 @@ interface Silgi {
|
|
|
934
934
|
close: () => Promise<void>;
|
|
935
935
|
logger: ConsolaInstance;
|
|
936
936
|
storage: Storage;
|
|
937
|
+
envOptions: EnvOptions;
|
|
938
|
+
runtimeConfig: SilgiRuntimeOptions & {
|
|
939
|
+
[key: string]: any;
|
|
940
|
+
};
|
|
937
941
|
options: SilgiOptions & SilgiRuntimeOptions;
|
|
938
942
|
captureError: CaptureError;
|
|
939
943
|
}
|
|
@@ -957,10 +961,6 @@ type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
|
957
961
|
interface SilgiOptions {
|
|
958
962
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
959
963
|
present: PresetNameInput;
|
|
960
|
-
envOptions: EnvOptions;
|
|
961
|
-
runtimeConfig: SilgiRuntimeOptions & {
|
|
962
|
-
[key: string]: any;
|
|
963
|
-
};
|
|
964
964
|
/**
|
|
965
965
|
* Set to `true` to enable debug mode.
|
|
966
966
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -934,6 +934,10 @@ interface Silgi {
|
|
|
934
934
|
close: () => Promise<void>;
|
|
935
935
|
logger: ConsolaInstance;
|
|
936
936
|
storage: Storage;
|
|
937
|
+
envOptions: EnvOptions;
|
|
938
|
+
runtimeConfig: SilgiRuntimeOptions & {
|
|
939
|
+
[key: string]: any;
|
|
940
|
+
};
|
|
937
941
|
options: SilgiOptions & SilgiRuntimeOptions;
|
|
938
942
|
captureError: CaptureError;
|
|
939
943
|
}
|
|
@@ -957,10 +961,6 @@ type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
|
957
961
|
interface SilgiOptions {
|
|
958
962
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
959
963
|
present: PresetNameInput;
|
|
960
|
-
envOptions: EnvOptions;
|
|
961
|
-
runtimeConfig: SilgiRuntimeOptions & {
|
|
962
|
-
[key: string]: any;
|
|
963
|
-
};
|
|
964
964
|
/**
|
|
965
965
|
* Set to `true` to enable debug mode.
|
|
966
966
|
*
|