silgi 0.20.30 → 0.20.32

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.
@@ -1,4 +1,4 @@
1
- const version = "0.20.30";
1
+ const version = "0.20.32";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1201,6 +1201,8 @@ class SchemaParser {
1201
1201
  // }
1202
1202
  }
1203
1203
 
1204
+ const processedScanItems = /* @__PURE__ */ new Map();
1205
+ const processedSchemaItems = /* @__PURE__ */ new Map();
1204
1206
  async function scanFiles$1(silgi, watchFiles) {
1205
1207
  const isWatch = watchFiles && watchFiles.length > 0;
1206
1208
  const filePaths = /* @__PURE__ */ new Set();
@@ -1220,6 +1222,13 @@ async function scanFiles$1(silgi, watchFiles) {
1220
1222
  }
1221
1223
  }
1222
1224
  }
1225
+ if (isWatch && watchFiles) {
1226
+ for (const file of watchFiles) {
1227
+ const filePath = resolve(dir, file);
1228
+ processedScanItems.delete(filePath);
1229
+ processedSchemaItems.delete(filePath);
1230
+ }
1231
+ }
1223
1232
  for (const _file of files) {
1224
1233
  const filePath = resolve(dir, _file);
1225
1234
  if (scannedPaths.find((d) => filePath.startsWith(withTrailingSlash(d))) || isIgnored(filePath, silgi)) {
@@ -1299,20 +1308,68 @@ async function scanFiles$1(silgi, watchFiles) {
1299
1308
  }
1300
1309
  silgi.hook("prepare:scan.ts", (options) => {
1301
1310
  for (const { exportName, path, _name, type } of scanTS) {
1302
- options.schemas.push(_name);
1303
- options.importItems[path] ??= {
1304
- import: [],
1305
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1306
- };
1307
- options.importItems[path].import.push({
1308
- name: `${exportName} as ${_name}`,
1309
- key: _name
1310
- });
1311
+ const itemKey = `${path}:${exportName}`;
1312
+ if (!processedScanItems.has(path)) {
1313
+ processedScanItems.set(path, /* @__PURE__ */ new Set());
1314
+ }
1315
+ if (processedScanItems.get(path).has(itemKey)) {
1316
+ continue;
1317
+ }
1318
+ processedScanItems.get(path).add(itemKey);
1319
+ switch (type) {
1320
+ case "service":
1321
+ options.services.push(_name);
1322
+ break;
1323
+ case "shared":
1324
+ options.shareds.push(_name);
1325
+ break;
1326
+ case "schema":
1327
+ options.schemas.push(_name);
1328
+ break;
1329
+ }
1330
+ addImport(options, path, exportName, _name, silgi.options.silgi.serverDir);
1331
+ }
1332
+ });
1333
+ silgi.hook("prepare:schema.ts", (options) => {
1334
+ for (const { exportName, path, _name, type } of schemaTS) {
1335
+ const itemKey = `${path}:${exportName}`;
1336
+ if (!processedSchemaItems.has(path)) {
1337
+ processedSchemaItems.set(path, /* @__PURE__ */ new Set());
1338
+ }
1339
+ if (processedSchemaItems.get(path).has(itemKey)) {
1340
+ continue;
1341
+ }
1342
+ processedSchemaItems.get(path).add(itemKey);
1343
+ if (type === "shared") {
1344
+ options.shareds.push({
1345
+ key: _name,
1346
+ value: _name
1347
+ });
1348
+ } else if (type === "context") {
1349
+ options.contexts.push({
1350
+ key: _name,
1351
+ value: _name
1352
+ });
1353
+ }
1354
+ addImport(options, path, exportName, _name, silgi.options.silgi.serverDir);
1311
1355
  }
1312
1356
  });
1313
1357
  }
1314
1358
  }
1315
1359
  }
1360
+ function addImport(options, path, exportName, _name, serverDir) {
1361
+ const existingItem = options.importItems[path]?.import.find((item) => item.key === _name);
1362
+ if (existingItem)
1363
+ return;
1364
+ options.importItems[path] ??= {
1365
+ import: [],
1366
+ from: relativeWithDot(serverDir, path)
1367
+ };
1368
+ options.importItems[path].import.push({
1369
+ name: `${exportName} as ${_name}`,
1370
+ key: _name
1371
+ });
1372
+ }
1316
1373
 
1317
1374
  async function createStorageCLI(silgi) {
1318
1375
  const storage = createStorage();
@@ -1,4 +1,4 @@
1
- const version = "0.20.30";
1
+ const version = "0.20.32";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.20.30";
1
+ const version = "0.20.32";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.20.30",
4
+ "version": "0.20.32",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {