@stonecrop/nuxt 0.4.35 → 0.4.37

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.d.mts CHANGED
@@ -1,11 +1,10 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
- declare const _default: _nuxt_schema.NuxtModule<{
4
- router: {};
5
- docbuilder: boolean;
6
- }, {
7
- router: {};
8
- docbuilder: boolean;
9
- }, false>;
3
+ interface ModuleOptions {
4
+ router?: Record<string, unknown>;
5
+ docbuilder?: boolean;
6
+ }
7
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
10
8
 
11
9
  export { _default as default };
10
+ export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@stonecrop/nuxt",
3
3
  "configKey": "stonecrop",
4
- "version": "0.4.35",
4
+ "version": "0.4.37",
5
5
  "builder": {
6
- "@nuxt/module-builder": "1.0.1",
6
+ "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import { createResolver, defineNuxtModule, addLayout, extendPages, addPlugin } from '@nuxt/kit';
2
- import { existsSync, readdirSync } from 'node:fs';
1
+ import { existsSync } from 'node:fs';
2
+ import { readdir, readFile } from 'node:fs/promises';
3
3
  import { extname } from 'node:path';
4
+ import { createResolver, defineNuxtModule, useLogger, addLayout, extendPages, addPlugin } from '@nuxt/kit';
4
5
 
5
6
  const { resolve } = createResolver(import.meta.url);
6
7
  const module = defineNuxtModule({
@@ -8,53 +9,93 @@ const module = defineNuxtModule({
8
9
  name: "@stonecrop/nuxt",
9
10
  configKey: "stonecrop"
10
11
  },
11
- defaults: (nuxt) => {
12
+ defaults: (_nuxt) => {
12
13
  return {
13
14
  router: {},
14
15
  docbuilder: false
15
16
  };
16
17
  },
17
- setup(_options, nuxt) {
18
+ async setup(_options, nuxt) {
19
+ const logger = useLogger("@stonecrop/nuxt", { level: nuxt.options.dev ? 3 : 0 });
18
20
  const layoutsDir = resolve("runtime/layouts");
19
- const homeLayoutPath = resolve(layoutsDir, "StonecropHome.vue");
20
- addLayout(homeLayoutPath, "home");
21
- const rootDir = nuxt.options.srcDir;
22
- const doctypesDir = resolve(rootDir, "doctypes");
21
+ const homepage = resolve(layoutsDir, "StonecropHome.vue");
22
+ addLayout(homepage, "home");
23
+ const appDir = nuxt.options.srcDir;
24
+ const doctypesDir = resolve(appDir, "doctypes");
23
25
  if (existsSync(doctypesDir)) {
24
- const schemas = readdirSync(doctypesDir).filter((file) => extname(file) === ".json");
25
- const pagesDir = resolve("runtime/pages");
26
- const homePagePath = resolve(pagesDir, "StonecropPage.vue");
27
- extendPages((pages) => {
28
- const pagePaths = pages.map((page) => page.path);
29
- if (pagePaths.includes("/")) {
30
- throw new Error("[@stonecrop/nuxt] Conflict found with existing root page");
31
- }
32
- pages.unshift({
33
- name: "stonecrop-home",
34
- path: "/",
35
- file: homeLayoutPath
36
- });
37
- for (const schema of schemas) {
38
- const schemaName = schema.replace(".json", "");
39
- if (pagePaths.includes(`/${schemaName}`)) {
40
- throw new Error(`[@stonecrop/nuxt] Conflict found with existing page for doctype: ${schemaName}`);
41
- }
42
- const schemaPath = resolve(doctypesDir, schema);
43
- const jsonData = require(schemaPath);
44
- if (jsonData.schema) {
26
+ try {
27
+ const dirContents = await readdir(doctypesDir);
28
+ const schemas = dirContents.filter((file) => extname(file) === ".json");
29
+ const pagesDir = resolve("runtime/pages");
30
+ const stonecropPage = resolve(pagesDir, "StonecropPage.vue");
31
+ extendPages(async (pages) => {
32
+ try {
33
+ const pagePaths = pages.map((page) => page.path);
34
+ if (pagePaths.includes("/")) {
35
+ logger.error('Conflict found: existing root page "/" detected.');
36
+ throw new Error("[@stonecrop/nuxt] Conflict found with existing root page");
37
+ }
45
38
  pages.unshift({
46
- name: `stonecrop-${schemaName}`,
47
- path: `/${schemaName}`,
48
- file: homePagePath,
49
- meta: {
50
- schema: jsonData.schema
51
- }
39
+ name: "stonecrop-home",
40
+ path: "/",
41
+ file: homepage
52
42
  });
43
+ for (const schema of schemas) {
44
+ try {
45
+ const schemaName = schema.replace(".json", "");
46
+ if (pagePaths.includes(`/${schemaName}`)) {
47
+ logger.warn(`Skipping doctype '${schemaName}': conflicts with existing page`);
48
+ continue;
49
+ }
50
+ const schemaPath = resolve(doctypesDir, schema);
51
+ const fileContents = await readFile(schemaPath, "utf-8");
52
+ let schemaData;
53
+ try {
54
+ schemaData = JSON.parse(fileContents);
55
+ } catch (parseError) {
56
+ logger.error(`Failed to parse schema file '${schema}':`, parseError);
57
+ continue;
58
+ }
59
+ if (schemaData.schema) {
60
+ pages.unshift({
61
+ name: `stonecrop-${schemaName}`,
62
+ path: `/${schemaName}`,
63
+ file: stonecropPage,
64
+ meta: {
65
+ schema: schemaData.schema
66
+ }
67
+ });
68
+ logger.log(`Added page for doctype: ${schemaName}`);
69
+ } else {
70
+ logger.warn(`Schema file '${schema}' missing 'schema' property, skipping`);
71
+ }
72
+ } catch (schemaError) {
73
+ logger.error(`Error processing schema '${schema}':`, schemaError);
74
+ }
75
+ }
76
+ } catch (pagesError) {
77
+ logger.error("Failed to setup doctype pages:", pagesError);
78
+ throw new Error(
79
+ `[@stonecrop/nuxt] Failed to setup pages: ${pagesError instanceof Error ? pagesError.message : String(pagesError)}`
80
+ );
53
81
  }
82
+ });
83
+ } catch (doctypeError) {
84
+ logger.error("Error setting up doctype pages:", doctypeError);
85
+ if (nuxt.options.dev) {
86
+ logger.warn("Continuing without doctype pages due to error");
87
+ } else {
88
+ throw doctypeError;
54
89
  }
55
- });
90
+ }
91
+ }
92
+ const pluginPath = resolve("./runtime/plugin");
93
+ try {
94
+ addPlugin(pluginPath);
95
+ } catch (pluginError) {
96
+ logger.error("Error adding plugin:", pluginError);
97
+ throw new Error(`[@stonecrop/nuxt] Failed to add plugin at ${pluginPath}`);
56
98
  }
57
- addPlugin(resolve("./runtime/plugin"));
58
99
  }
59
100
  });
60
101
 
@@ -1,5 +1,4 @@
1
1
  <template>
2
- <div>Stonecrop Home</div>
3
2
  <pre>{{ stonecrop }}</pre>
4
3
  </template>
5
4
 
@@ -1,2 +1,3 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
2
3
  export default _default;
@@ -1,6 +1,5 @@
1
1
  <template>
2
- <div>Stonecrop Page</div>
3
- <AForm v-model="schema" :data="schemaData" :key="componentKey" />
2
+ <AForm :key="componentKey" v-model="schema" :data="schemaData" />
4
3
  </template>
5
4
 
6
5
  <script setup>
@@ -1,2 +1,3 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
2
3
  export default _default;
package/dist/types.d.mts CHANGED
@@ -1,7 +1,3 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module.mjs'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
1
  export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/nuxt",
3
- "version": "0.4.35",
3
+ "version": "0.4.37",
4
4
  "description": "Nuxt module for Stonecrop",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,39 +31,47 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@nuxt/kit": "^3.17.6",
34
+ "@nuxt/kit": "^4.2.0",
35
35
  "pinia": "^3.0.3",
36
- "@stonecrop/atable": "0.4.35",
37
- "@stonecrop/stonecrop": "0.4.35",
38
- "@stonecrop/aform": "0.4.35"
36
+ "@stonecrop/aform": "0.4.37",
37
+ "@stonecrop/stonecrop": "0.4.37",
38
+ "@stonecrop/atable": "0.4.37"
39
39
  },
40
40
  "devDependencies": {
41
- "@nuxt/devtools": "^2.6.2",
42
- "@nuxt/module-builder": "^1.0.1",
43
- "@nuxt/schema": "^3.17.6",
44
- "@nuxt/test-utils": "^3.19.2",
45
- "eslint": "^8.57.1",
46
- "happy-dom": "^18.0.1",
47
- "h3": "*",
48
- "nitropack": "*",
49
- "nuxi": "^3.25.1",
50
- "nuxt": "^3.17.6",
51
- "typescript": "^5.8.3",
52
- "vue": "^3.5.18",
53
- "vite": "^7.0.6",
54
- "vitest": "^3.2.4",
55
- "vue-router": "^4.5.1",
56
- "vue-tsc": "~2.2.10"
41
+ "@eslint/js": "^9.38.0",
42
+ "@nuxt/devtools": "^3.0.0",
43
+ "@nuxt/eslint": "1.10.0",
44
+ "@nuxt/eslint-config": "^1.10.0",
45
+ "@nuxt/module-builder": "^1.0.2",
46
+ "@nuxt/schema": "^4.2.0",
47
+ "@nuxt/test-utils": "^3.20.1",
48
+ "eslint": "^9.38.0",
49
+ "eslint-config-prettier": "^10.1.8",
50
+ "eslint-plugin-vue": "^10.5.1",
51
+ "globals": "^16.4.0",
52
+ "nuxt": "^4.2.0",
53
+ "typescript": "^5.9.3",
54
+ "typescript-eslint": "^8.46.2",
55
+ "vue": "^3.5.22",
56
+ "vite": "^7.1.1",
57
+ "vitest": "^4.0.5",
58
+ "vue-router": "^4.6.3",
59
+ "vue-tsc": "^3.1.2"
60
+ },
61
+ "engines": {
62
+ "node": ">=22.5.0"
57
63
  },
58
64
  "scripts": {
59
65
  "_phase:build": "rushx dev:prepare && nuxt-module-build build",
60
66
  "prepublish": "rushx dev:prepare && nuxt-module-build build",
61
67
  "build": "rushx dev:prepare && nuxt-module-build build",
62
- "dev": "nuxi dev playground",
68
+ "dev": "rushx dev:prepare && nuxi dev playground",
63
69
  "dev:build": "nuxi build playground",
64
70
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
65
- "lint": "eslint . --ext .ts,.vue",
66
- "test": "vitest",
67
- "test:ui": "vitest --ui"
71
+ "lint": "eslint .",
72
+ "test": "vitest run",
73
+ "test:ui": "vitest --ui",
74
+ "test:watch": "vitest watch",
75
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
68
76
  }
69
77
  }