@zoobzio/nuxt 0.0.1 → 0.0.3

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,5 @@
1
1
  import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
2
3
  import {
3
4
  addComponent,
4
5
  addImports,
@@ -6,21 +7,42 @@ import {
6
7
  defineNuxtModule,
7
8
  } from "@nuxt/kit";
8
9
 
9
- import { COMPONENTS, DEFINITIONS, LAYER, LAYER_TYPES } from "./constant";
10
- import { pascal } from "./util";
10
+ import {
11
+ COMPONENTS,
12
+ DEFINITIONS,
13
+ LAYER,
14
+ LAYER_TYPES,
15
+ VUE_TYPES,
16
+ WRAPPED,
17
+ } from "./constant";
18
+ import { pascal, wrapped } from "./util";
11
19
 
12
20
  export default defineNuxtModule({
13
21
  meta: { name: "@zoobzio/nuxt/imports" },
14
- setup() {
15
- // @zoobzio/vue: components into #components, define* into #imports.
22
+ setup(_, nuxt) {
16
23
  const require = createRequire(import.meta.url);
17
24
  const resolve = (subpath: string): string =>
18
25
  require.resolve(`@zoobzio/vue/${subpath}`);
26
+ const dist = (subpath: string): string =>
27
+ join(
28
+ dirname(require.resolve("@zoobzio/vue/package.json")),
29
+ ".dist",
30
+ subpath,
31
+ );
32
+
33
+ const resolver = createResolver(import.meta.url);
34
+ const app = (subpath: string): string =>
35
+ resolver.resolve("../../app", subpath);
19
36
 
20
37
  for (const name of COMPONENTS) {
21
38
  addComponent({
22
39
  name: pascal(name),
23
- filePath: resolve(`components/${name}.vue`),
40
+ filePath: wrapped(name, WRAPPED)
41
+ ? app(`components/${name}.vue`)
42
+ : resolve(`components/${name}.vue`),
43
+ declarationPath: wrapped(name, WRAPPED)
44
+ ? undefined
45
+ : dist(`components/${name}.vue`),
24
46
  export: "default",
25
47
  });
26
48
  }
@@ -29,24 +51,39 @@ export default defineNuxtModule({
29
51
  DEFINITIONS.map((name) => ({
30
52
  name: `define${pascal(name)}`,
31
53
  from: resolve(`definitions/${name}`),
54
+ typeFrom: dist(`definitions/${name}.d.ts`),
32
55
  })),
33
56
  );
34
57
 
35
- // The layer's own app/ files into #imports, values and types alike.
36
- const resolver = createResolver(import.meta.url);
37
- const app = (subpath: string): string =>
38
- resolver.resolve("../../app", `${subpath}.ts`);
58
+ addImports(
59
+ Object.entries(VUE_TYPES).flatMap(([subpath, names]) =>
60
+ names.map((name) => ({
61
+ name,
62
+ from: resolve(`types/${subpath}`),
63
+ typeFrom: dist(`types/${subpath}.d.ts`),
64
+ type: true,
65
+ })),
66
+ ),
67
+ );
39
68
 
40
69
  addImports(
41
70
  Object.entries(LAYER).flatMap(([subpath, names]) =>
42
- names.map((name) => ({ name, from: app(subpath) })),
71
+ names.map((name) => ({ name, from: app(`${subpath}.ts`) })),
43
72
  ),
44
73
  );
45
74
 
46
75
  addImports(
47
76
  Object.entries(LAYER_TYPES).flatMap(([subpath, names]) =>
48
- names.map((name) => ({ name, from: app(subpath), type: true })),
77
+ names.map((name) => ({
78
+ name,
79
+ from: app(`${subpath}.ts`),
80
+ type: true,
81
+ })),
49
82
  ),
50
83
  );
84
+
85
+ nuxt.hook("prepare:types", ({ references }) => {
86
+ references.push({ path: resolver.resolve("../../app/app.d.ts") });
87
+ });
51
88
  },
52
89
  });
@@ -1,2 +1,11 @@
1
1
  export const pascal = (kebab: string): string =>
2
2
  kebab.replace(/(^|-)([a-z])/g, (_, __, c: string) => c.toUpperCase());
3
+
4
+ /**
5
+ * Whether a component name is in the wrapped set. A guard, so the readonly
6
+ * tuple's `includes` takes the wider name.
7
+ */
8
+ export const wrapped = <W extends string>(
9
+ name: string,
10
+ set: readonly W[],
11
+ ): name is W => set.some((entry) => entry === name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoobzio/nuxt",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Nuxt layer for the foundation design system: the Nuxt wiring over @zoobzio/vue and the headless services (useState stores, hook-bus factories, app shell).",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -40,10 +40,10 @@
40
40
  "ltrl-http": "^0.0.20",
41
41
  "objectively": "^0.3.0",
42
42
  "reka-ui": "^2.6.0",
43
- "@zoobzio/browser": "0.0.1",
44
- "@zoobzio/form": "0.0.1",
45
- "@zoobzio/table": "0.0.1",
46
- "@zoobzio/vue": "0.0.1"
43
+ "@zoobzio/browser": "0.0.3",
44
+ "@zoobzio/table": "0.0.3",
45
+ "@zoobzio/form": "0.0.3",
46
+ "@zoobzio/vue": "0.0.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@vitejs/plugin-vue": "^6.0.6",