@hywax/cms 3.4.0 → 3.4.1

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/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "configKey": "cms",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -7,7 +7,7 @@ import { pascalCase, kebabCase, camelCase } from 'scule';
7
7
  import { globSync } from 'tinyglobby';
8
8
 
9
9
  const name = "@hywax/cms";
10
- const version = "3.4.0";
10
+ const version = "3.4.1";
11
11
 
12
12
  function createContext(options, nuxt) {
13
13
  const { resolve } = createResolver(import.meta.url);
@@ -219,7 +219,7 @@ function resolveComponentDependencies(component, dependencyGraph, resolved = /*
219
219
  }
220
220
  return resolved;
221
221
  }
222
- async function detectUsedComponents([dirs, type], prefix, componentDir, includeComponents) {
222
+ async function detectUsedComponents({ dirs, prefix, componentDir, includeComponents = [], allowComponents = [] }) {
223
223
  const detectedComponents = /* @__PURE__ */ new Set();
224
224
  if (includeComponents && includeComponents.length > 0) {
225
225
  for (const component of includeComponents) {
@@ -227,10 +227,16 @@ async function detectUsedComponents([dirs, type], prefix, componentDir, includeC
227
227
  }
228
228
  }
229
229
  const componentPattern = new RegExp(`<(?:Lazy)?${prefix}([A-Z][a-zA-Z]+)|\\b(?:Lazy)?${prefix}([A-Z][a-zA-Z]+)\\b`, "g");
230
- if (type === "files") {
231
- for (const file of dirs) {
230
+ const filesPattern = allowComponents.length ? `**/(${allowComponents.join("|")}).{vue,ts,js,tsx,jsx}` : "**/*.{vue,ts,js,tsx,jsx}";
231
+ for (const dir of dirs) {
232
+ const appFiles = globSync([filesPattern], {
233
+ cwd: dir,
234
+ ignore: ["node_modules/**", ".nuxt/**", "dist/**"]
235
+ });
236
+ for (const file of appFiles) {
232
237
  try {
233
- const content = await readFile(file, "utf-8");
238
+ const filePath = join(dir, file);
239
+ const content = await readFile(filePath, "utf-8");
234
240
  const matches = content.matchAll(componentPattern);
235
241
  for (const match of matches) {
236
242
  const componentName = match[1] || match[2];
@@ -241,27 +247,6 @@ async function detectUsedComponents([dirs, type], prefix, componentDir, includeC
241
247
  } catch {
242
248
  }
243
249
  }
244
- } else if (type === "dirs") {
245
- for (const dir of dirs) {
246
- const appFiles = globSync(["**/*.{vue,ts,js,tsx,jsx}"], {
247
- cwd: dir,
248
- ignore: ["node_modules/**", ".nuxt/**", "dist/**"]
249
- });
250
- for (const file of appFiles) {
251
- try {
252
- const filePath = join(dir, file);
253
- const content = await readFile(filePath, "utf-8");
254
- const matches = content.matchAll(componentPattern);
255
- for (const match of matches) {
256
- const componentName = match[1] || match[2];
257
- if (componentName) {
258
- detectedComponents.add(componentName);
259
- }
260
- }
261
- } catch {
262
- }
263
- }
264
- }
265
250
  }
266
251
  if (detectedComponents.size === 0) {
267
252
  return void 0;
@@ -269,7 +254,7 @@ async function detectUsedComponents([dirs, type], prefix, componentDir, includeC
269
254
  const dependencyGraph = await buildComponentDependencyGraph(componentDir, componentPattern);
270
255
  const allComponents = /* @__PURE__ */ new Set();
271
256
  for (const component of detectedComponents) {
272
- const resolved = resolveComponentDependencies(component, dependencyGraph);
257
+ const resolved = resolveComponentDependencies(component, dependencyGraph, /* @__PURE__ */ new Set());
273
258
  for (const resolvedComponent of resolved) {
274
259
  allComponents.add(resolvedComponent);
275
260
  }
@@ -347,11 +332,12 @@ async function prepareMergeConfigs({ nuxt, options, resolve, detectedComponents:
347
332
  }
348
333
  }
349
334
  });
350
- const detectedComponents = await detectUsedComponents(
351
- [[...contextDetectedComponents].map((component) => resolve(`./runtime/components/${component}.vue`)), "files"],
352
- "U",
353
- resolve("./runtime/components")
354
- );
335
+ const detectedComponents = await detectUsedComponents({
336
+ dirs: [resolve("./runtime/components"), resolve("./runtime/composables")],
337
+ prefix: "U",
338
+ componentDir: resolve("./runtime/components"),
339
+ allowComponents: [...contextDetectedComponents]
340
+ });
355
341
  nuxt.options.ui = defu(nuxt.options.ui || {}, {
356
342
  colorMode: true,
357
343
  fonts: true,
@@ -624,12 +610,12 @@ async function getAppTemplates({ options, resolve, nuxt, detectedComponents: con
624
610
  const sources2 = [];
625
611
  const layers = getLayerDirectories(nuxt).map((layer) => layer.app);
626
612
  if (options.componentDetection) {
627
- const detectedComponents = await detectUsedComponents(
628
- [layers, "dirs"],
629
- options.componentsPrefix,
630
- resolve("./runtime/components"),
631
- Array.isArray(options.componentDetection) ? options.componentDetection : void 0
632
- );
613
+ const detectedComponents = await detectUsedComponents({
614
+ dirs: layers,
615
+ prefix: options.componentsPrefix,
616
+ componentDir: resolve("./runtime/components"),
617
+ includeComponents: Array.isArray(options.componentDetection) ? options.componentDetection : void 0
618
+ });
633
619
  if (detectedComponents && detectedComponents.size > 0) {
634
620
  if (previousDetectedComponents) {
635
621
  const newComponents = Array.from(detectedComponents).filter(
@@ -650,8 +636,8 @@ async function getAppTemplates({ options, resolve, nuxt, detectedComponents: con
650
636
  const camelComponent = camelCase(component);
651
637
  if (theme[camelComponent]) {
652
638
  sources2.push(`@source "./cms/${kebabComponent}.ts";`);
653
- contextDetectedComponents.add(component);
654
639
  }
640
+ contextDetectedComponents.add(component);
655
641
  }
656
642
  } else {
657
643
  if (!previousDetectedComponents || previousDetectedComponents.size > 0) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hywax/cms",
3
3
  "type": "module",
4
- "version": "3.4.0",
4
+ "version": "3.4.1",
5
5
  "description": "Hywax CMS. ⚠️ This package is intended for internal use only.",
6
6
  "imports": {
7
7
  "#build/cms/*": "./.nuxt/cms/*.ts",