@resee-movies/nuxt-ux 0.0.2 → 0.0.4
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 +1 -1
- package/dist/module.mjs +60 -38
- package/dist/runtime/types/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import { useNuxt, addTemplate, resolvePath, logger,
|
|
1
|
+
import { useNuxt, addTemplate, resolvePath, logger, addVitePlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addServerScanDir } from '@nuxt/kit';
|
|
2
|
+
import { toNonNullableArray } from '@resee-movies/utilities/arrays/to-non-nullable-array';
|
|
2
3
|
import { readFile } from 'node:fs/promises';
|
|
3
4
|
import { join } from 'node:path';
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
|
|
8
|
+
function resolveModuleDirectory(entry, ...packagePaths) {
|
|
9
|
+
const packageName = entry.includes("/") ? entry.startsWith("@") ? entry.split("/").slice(0, 2).join("/") : entry.split("/")[0] : entry;
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const lookupPaths = require.resolve.paths(entry)?.map((p) => join(p, packageName));
|
|
12
|
+
const directory = lookupPaths?.find((p) => existsSync(p));
|
|
13
|
+
if (directory && packagePaths.length) {
|
|
14
|
+
return join(directory, ...packagePaths);
|
|
15
|
+
}
|
|
16
|
+
return directory;
|
|
17
|
+
}
|
|
4
18
|
|
|
5
19
|
const IMPORT_REGEX = /(?<=\s|^|;|\})@import\s+["']tailwindcss["']/gmu;
|
|
6
20
|
function getDefaults(config) {
|
|
@@ -16,9 +30,9 @@ async function importCSS(nuxt = useNuxt(), options) {
|
|
|
16
30
|
const sources = nuxt.options._layers.map(
|
|
17
31
|
(layer) => layer.config.srcDir || layer.cwd
|
|
18
32
|
);
|
|
19
|
-
const plugins = options?.plugins ?? [];
|
|
33
|
+
const plugins = toNonNullableArray(options?.plugins ?? []);
|
|
20
34
|
if (options?.sources) {
|
|
21
|
-
sources.push(...options.sources);
|
|
35
|
+
sources.push(...toNonNullableArray(options.sources));
|
|
22
36
|
}
|
|
23
37
|
await nuxt.callHook("tailwindcss:sources:extend", sources);
|
|
24
38
|
const sourcesTemplate = addTemplate({
|
|
@@ -68,9 +82,9 @@ async function importCSS(nuxt = useNuxt(), options) {
|
|
|
68
82
|
write: true,
|
|
69
83
|
getContents: () => {
|
|
70
84
|
return [
|
|
71
|
-
`@import
|
|
85
|
+
`@import ${JSON.stringify(resolveModuleDirectory("tailwindcss"))};`,
|
|
72
86
|
`@import ${JSON.stringify(sourcesTemplate.dst)};`,
|
|
73
|
-
...(options?.imports ?? []).map((item) => `@import ${JSON.stringify(item)};`)
|
|
87
|
+
...toNonNullableArray(options?.imports ?? []).map((item) => `@import ${JSON.stringify(item)};`)
|
|
74
88
|
].join("\n");
|
|
75
89
|
}
|
|
76
90
|
}).dst
|
|
@@ -91,38 +105,46 @@ async function importCSS(nuxt = useNuxt(), options) {
|
|
|
91
105
|
});
|
|
92
106
|
}
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
function importModules() {
|
|
109
|
+
const NuxtFonts = {
|
|
110
|
+
defaults: {
|
|
111
|
+
families: [
|
|
112
|
+
{
|
|
113
|
+
name: "Archivo",
|
|
114
|
+
provider: "google",
|
|
115
|
+
styles: ["normal"],
|
|
116
|
+
weights: [200, 300, 400, 500]
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const Primevue = {
|
|
122
|
+
defaults: {
|
|
123
|
+
autoImport: false,
|
|
124
|
+
loadStyles: false,
|
|
125
|
+
importPT: {
|
|
126
|
+
from: "#resee-movies-nuxt-ux-primevue-passthrough"
|
|
127
|
+
},
|
|
128
|
+
options: {
|
|
129
|
+
unstyled: true
|
|
130
|
+
},
|
|
131
|
+
composables: {
|
|
132
|
+
include: ["useToast"]
|
|
133
|
+
},
|
|
134
|
+
directives: {
|
|
135
|
+
prefix: "Prime",
|
|
136
|
+
include: ["Tooltip"]
|
|
137
|
+
},
|
|
138
|
+
components: {
|
|
139
|
+
prefix: "Prime",
|
|
140
|
+
include: ["Message", "ProgressBar", "ProgressSpinner", "Tag", "Toast"]
|
|
102
141
|
}
|
|
103
|
-
]
|
|
104
|
-
});
|
|
105
|
-
await installModule("@primevue/nuxt-module", {
|
|
106
|
-
autoImport: false,
|
|
107
|
-
loadStyles: false,
|
|
108
|
-
importPT: {
|
|
109
|
-
from: "#resee-movies-nuxt-ux-primevue-passthrough"
|
|
110
|
-
},
|
|
111
|
-
options: {
|
|
112
|
-
unstyled: true
|
|
113
|
-
},
|
|
114
|
-
composables: {
|
|
115
|
-
include: ["useToast"]
|
|
116
|
-
},
|
|
117
|
-
directives: {
|
|
118
|
-
prefix: "Prime",
|
|
119
|
-
include: ["Tooltip"]
|
|
120
|
-
},
|
|
121
|
-
components: {
|
|
122
|
-
prefix: "Prime",
|
|
123
|
-
include: ["Message", "ProgressBar", "ProgressSpinner", "Tag", "Toast"]
|
|
124
142
|
}
|
|
125
|
-
}
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
"@nuxt/fonts": NuxtFonts,
|
|
146
|
+
"@primevue/nuxt-module": Primevue
|
|
147
|
+
};
|
|
126
148
|
}
|
|
127
149
|
|
|
128
150
|
const Builder = "@nuxt/vite-builder";
|
|
@@ -158,24 +180,24 @@ const module = defineNuxtModule({
|
|
|
158
180
|
name: "@resee-movies/nuxt-ux",
|
|
159
181
|
configKey: "ux"
|
|
160
182
|
},
|
|
183
|
+
moduleDependencies: () => importModules(),
|
|
161
184
|
async setup(options, nuxt) {
|
|
162
185
|
const resolver = createResolver(import.meta.url);
|
|
163
186
|
const components = resolver.resolve("./runtime/components/");
|
|
164
187
|
const composables = resolver.resolve("./runtime/composables/");
|
|
165
188
|
const server = resolver.resolve("./runtime/server/");
|
|
166
189
|
const stylesheet = resolver.resolve("./runtime/theme/css/styles.css");
|
|
167
|
-
nuxt.options.alias["#resee-movies-nuxt-ux-primevue-passthrough"] = resolver.
|
|
190
|
+
nuxt.options.alias["#resee-movies-nuxt-ux-primevue-passthrough"] = await resolver.resolvePath("./runtime/theme/primevue/index", { extensions: ["ts", "js"] });
|
|
168
191
|
const sources = options.tailwind?.sources?.slice() ?? [];
|
|
169
192
|
const plugins = options.tailwind?.plugins?.slice() ?? [];
|
|
170
193
|
const imports = options.tailwind?.plugins?.slice() ?? [];
|
|
171
194
|
sources.push(components);
|
|
172
|
-
plugins.push("@egoist/tailwindcss-icons");
|
|
195
|
+
plugins.push(await resolvePath("@egoist/tailwindcss-icons"));
|
|
173
196
|
imports.push(stylesheet);
|
|
174
197
|
addComponentsDir({ path: components });
|
|
175
198
|
addImportsDir([composables]);
|
|
176
199
|
addServerScanDir([server]);
|
|
177
200
|
await importTailwind(nuxt);
|
|
178
|
-
await importModules(nuxt);
|
|
179
201
|
nuxt.hook("modules:done", async () => {
|
|
180
202
|
await importCSS(nuxt, { sources, plugins, imports });
|
|
181
203
|
});
|
|
@@ -2,9 +2,9 @@ export interface ModuleOptions {
|
|
|
2
2
|
defaultColorMode?: 'lite' | 'dark';
|
|
3
3
|
usePreferredColorScheme?: boolean;
|
|
4
4
|
tailwind?: {
|
|
5
|
-
plugins?: string[];
|
|
6
|
-
sources?: string[];
|
|
7
|
-
imports?: string[];
|
|
5
|
+
plugins?: (string | undefined)[];
|
|
6
|
+
sources?: (string | undefined)[];
|
|
7
|
+
imports?: (string | undefined)[];
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
export interface ModuleHooks {
|
package/package.json
CHANGED