@frontic/nuxt 0.1.4 → 0.1.6
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.mjs +31 -25
- package/package.json +3 -2
package/dist/module.mjs
CHANGED
|
@@ -51,16 +51,19 @@ const module$1 = defineNuxtModule({
|
|
|
51
51
|
const { resolve, resolvePath } = createResolver(ROOT_DIR_PATH);
|
|
52
52
|
const { resolve: resolveModule } = createResolver(_dirname);
|
|
53
53
|
const runtimeDir = resolveModule("./runtime");
|
|
54
|
+
const fronticClientFile = "generated-client.ts";
|
|
55
|
+
const fronticDir = join(ROOT_DIR_PATH, ".frontic");
|
|
56
|
+
const frontstackDir = join(ROOT_DIR_PATH, ".frontstack");
|
|
57
|
+
const fronticClientDir = existsSync(join(fronticDir, fronticClientFile)) ? fronticDir : frontstackDir;
|
|
58
|
+
const fronticClientPath = join(fronticClientDir, fronticClientFile);
|
|
59
|
+
const hasFronticClient = existsSync(fronticClientPath);
|
|
54
60
|
const proxyPath = typeof proxyConfig === "string" ? proxyConfig : proxyConfig !== false ? "/api/stack" : void 0;
|
|
55
|
-
if (proxyPath) {
|
|
61
|
+
if (proxyPath && hasFronticClient) {
|
|
56
62
|
addServerHandler({
|
|
57
63
|
route: `${proxyPath}/**`,
|
|
58
64
|
handler: resolveModule("./runtime/server/api/stack/[...path]")
|
|
59
65
|
});
|
|
60
66
|
}
|
|
61
|
-
const fronticClientDir = join(ROOT_DIR_PATH, ".frontstack");
|
|
62
|
-
const fronticClientPath = join(fronticClientDir, "generated-client.ts");
|
|
63
|
-
const hasFronticClient = existsSync(fronticClientPath);
|
|
64
67
|
const blockEnabled = isComposableEnabled(composablesConfig, "block");
|
|
65
68
|
const listingEnabled = isComposableEnabled(composablesConfig, "listing");
|
|
66
69
|
const searchEnabled = isComposableEnabled(composablesConfig, "search");
|
|
@@ -75,17 +78,18 @@ const module$1 = defineNuxtModule({
|
|
|
75
78
|
});
|
|
76
79
|
console.warn(
|
|
77
80
|
`
|
|
78
|
-
[@frontic/nuxt] Frontic client not found at .
|
|
81
|
+
[@frontic/nuxt] Frontic client not found at .frontic directory
|
|
79
82
|
The following composables require the Frontic client: ${enabledList.join(", ")}
|
|
80
83
|
Run \`npx @frontic/cli generate\` to generate the client, or disable composables:
|
|
81
84
|
frontic: { composables: false }
|
|
82
85
|
`
|
|
83
86
|
);
|
|
84
87
|
}
|
|
88
|
+
const clientDirName = fronticClientDir === fronticDir ? ".frontic" : ".frontstack";
|
|
85
89
|
nuxt.hook("prepare:types", ({ tsConfig }) => {
|
|
86
90
|
tsConfig.compilerOptions ||= {};
|
|
87
91
|
tsConfig.compilerOptions.paths ||= {};
|
|
88
|
-
tsConfig.compilerOptions.paths["@frontic/stack/*"] = [
|
|
92
|
+
tsConfig.compilerOptions.paths["@frontic/stack/*"] = [`../${clientDirName}/*`];
|
|
89
93
|
});
|
|
90
94
|
if (anyComposableEnabled) {
|
|
91
95
|
const composablesDir = resolve(runtimeDir, "composables");
|
|
@@ -178,25 +182,27 @@ frontic: { composables: false }
|
|
|
178
182
|
prepend: true
|
|
179
183
|
}
|
|
180
184
|
);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
if (existsSync(componentsPath)) {
|
|
186
|
+
try {
|
|
187
|
+
await Promise.all(
|
|
188
|
+
readdirSync(componentsPath).map(async (dir) => {
|
|
189
|
+
try {
|
|
190
|
+
const filePath = await resolvePath(join(COMPONENT_DIR_PATH, dir, "index"), {
|
|
191
|
+
extensions: [".ts", ".js"]
|
|
192
|
+
});
|
|
193
|
+
addComponentExports({
|
|
194
|
+
prefix,
|
|
195
|
+
filePath: resolve(filePath),
|
|
196
|
+
priority: 1
|
|
197
|
+
});
|
|
198
|
+
} catch (err) {
|
|
199
|
+
if (err instanceof Error) console.warn("Module error: ", err.message);
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
);
|
|
203
|
+
} catch (err) {
|
|
204
|
+
if (err instanceof Error) console.warn(err.message);
|
|
205
|
+
}
|
|
200
206
|
}
|
|
201
207
|
}
|
|
202
208
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontic/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Nuxt module for Frontstack headless commerce - zero config data fetching composables with smart caching, page routing, and context management",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontic",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@nuxt/kit": "^3.17.0",
|
|
44
44
|
"@pinia/colada": "^0.14.0",
|
|
45
|
-
"@vueuse/core": "^12.0.0"
|
|
45
|
+
"@vueuse/core": "^12.0.0",
|
|
46
|
+
"pinia": "^2.2.6"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@nuxt/module-builder": "^1.0.2",
|