@nuvler/cli 0.5.2 → 0.5.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/README.md +10 -4
- package/dist/api/theme-context.js +1 -0
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/create.js +3 -2
- package/dist/commands/theme/create.js.map +1 -1
- package/dist/config/connection-key.js +1 -1
- package/dist/config/connection-key.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/nuvler.js +12 -6
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-atelier/package.json +3 -3
- package/dist/templates/nuvler-default/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-default/package.json +2 -2
- package/dist/templates/starter/nuvler.theme.json +1 -1
- package/dist/templates/starter/package.json +2 -2
- package/dist/version.js +9 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -3
- package/preview-host/package.json +1 -1
- package/preview-host/src/main.tsx +31 -11
- package/preview-host/src/preview-path.d.mts +4 -0
- package/preview-host/src/preview-path.mjs +14 -0
- package/preview-host/src/public-preview-url.mjs +1 -1
- package/preview-host/vendor/theme-runtime/default-theme.tsx +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuvler-theme-nuvler-atelier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.3.1"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.1",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react": "^19.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
67
|
+
"@nuvler/theme-sdk": "^1.3.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/react": "^19.0.0",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.3.1"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.1",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
// This module and the bundled executable both live directly in dist/.
|
|
5
|
+
// Use package metadata so release bumps also update --version and new themes.
|
|
6
|
+
const packagePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../package.json");
|
|
7
|
+
const metadata = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
8
|
+
export const CLI_VERSION = metadata.version;
|
|
9
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,sEAAsE;AACtE,8EAA8E;AAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;AAClG,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAwB,CAAC;AACtF,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "CLI oficial para criação, validação, preview e empacotamento de temas Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nuvler/theme-schema": "^1.3.
|
|
24
|
-
"@nuvler/theme-sdk": "^1.3.
|
|
23
|
+
"@nuvler/theme-schema": "^1.3.0",
|
|
24
|
+
"@nuvler/theme-sdk": "^1.3.1",
|
|
25
25
|
"@vitejs/plugin-react": "^6.0.5",
|
|
26
26
|
"commander": "^15.0.0",
|
|
27
27
|
"react": "19.2.8",
|
|
@@ -11,6 +11,11 @@ import type {
|
|
|
11
11
|
import type { ThemePagination, ThemeProduct, ThemeRuntimeSdk } from "@nuvler/theme-sdk";
|
|
12
12
|
import ActiveTheme from "virtual:nuvler-active-theme";
|
|
13
13
|
import context from "virtual:nuvler-theme-context";
|
|
14
|
+
import { classifyPreviewPath } from "./preview-path.mjs";
|
|
15
|
+
|
|
16
|
+
class PreviewHttpError extends Error {
|
|
17
|
+
constructor(public status: number) { super(`HTTP ${status}`); }
|
|
18
|
+
}
|
|
14
19
|
|
|
15
20
|
function PreviewImage({ image, fallbackAlt, className }: ThemeImageProps) {
|
|
16
21
|
if (!image?.url) return <span className={`store-image-placeholder theme-image-placeholder ${className ?? ""}`} aria-hidden="true"><span>N</span></span>;
|
|
@@ -68,7 +73,7 @@ async function previewApi<T>(path: string): Promise<T> {
|
|
|
68
73
|
const response = await fetch(`/__nuvler-api/${path.replace(/^\/+/, "")}`, {
|
|
69
74
|
headers: { accept: "application/json" },
|
|
70
75
|
});
|
|
71
|
-
if (!response.ok) throw new
|
|
76
|
+
if (!response.ok) throw new PreviewHttpError(response.status);
|
|
72
77
|
return response.json() as Promise<T>;
|
|
73
78
|
}
|
|
74
79
|
|
|
@@ -93,6 +98,7 @@ function routeFromLocalData(url: URL): ThemeRoute | null {
|
|
|
93
98
|
function PreviewApp() {
|
|
94
99
|
const [route, setRoute] = useState<ThemeRoute>({ type: "loading", pathname: window.location.pathname });
|
|
95
100
|
const requestId = useRef(0);
|
|
101
|
+
const [routeError, setRouteError] = useState<string | null>(null);
|
|
96
102
|
|
|
97
103
|
useEffect(() => {
|
|
98
104
|
const favicon = document.querySelector<HTMLLinkElement>('link[rel~="icon"]');
|
|
@@ -101,26 +107,26 @@ function PreviewApp() {
|
|
|
101
107
|
|
|
102
108
|
const loadRoute = useCallback(async (url: URL) => {
|
|
103
109
|
const currentRequest = ++requestId.current;
|
|
110
|
+
setRouteError(null);
|
|
104
111
|
const localRoute = routeFromLocalData(url);
|
|
105
112
|
if (localRoute) { setRoute(localRoute); return; }
|
|
106
113
|
setRoute({ type: "loading", pathname: url.pathname });
|
|
107
114
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
const target = classifyPreviewPath(url.pathname);
|
|
116
|
+
if (target.type === "product") {
|
|
117
|
+
const slug = target.slug;
|
|
110
118
|
const product = normalizeProduct(await previewApi<unknown>(`products/${encodeURIComponent(slug)}`));
|
|
111
119
|
if (currentRequest === requestId.current) setRoute({ type: "product", product });
|
|
112
120
|
return;
|
|
113
121
|
}
|
|
114
|
-
if (
|
|
115
|
-
const slug =
|
|
122
|
+
if (target.type === "page") {
|
|
123
|
+
const slug = target.slug;
|
|
116
124
|
const page = await previewApi<{ title: string; slug: string; content: { schemaVersion: 1; time?: number; version?: string; blocks: Array<{ id?: string; type: string; data: Record<string, unknown> }> } }>(`pages/${encodeURIComponent(slug)}`);
|
|
117
125
|
if (currentRequest === requestId.current) setRoute({ type: "page", title: page.title, slug: page.slug, content: page.content });
|
|
118
126
|
return;
|
|
119
127
|
}
|
|
120
|
-
if (
|
|
121
|
-
const categoryPath =
|
|
122
|
-
? url.pathname.slice("/categoria/".length).split("/").filter(Boolean).map(decodeURIComponent)
|
|
123
|
-
: [];
|
|
128
|
+
if (target.type === "catalog") {
|
|
129
|
+
const categoryPath = target.categoryPath;
|
|
124
130
|
const params = new URLSearchParams();
|
|
125
131
|
const page = Math.max(1, Number(url.searchParams.get("pagina")) || 1);
|
|
126
132
|
const search = url.searchParams.get("busca")?.trim() || "";
|
|
@@ -139,8 +145,15 @@ function PreviewApp() {
|
|
|
139
145
|
return;
|
|
140
146
|
}
|
|
141
147
|
setRoute({ type: "not-found", pathname: url.pathname });
|
|
142
|
-
} catch {
|
|
143
|
-
if (currentRequest
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (currentRequest !== requestId.current) return;
|
|
150
|
+
if (error instanceof PreviewHttpError && error.status === 404) {
|
|
151
|
+
setRoute({ type: "not-found", pathname: url.pathname });
|
|
152
|
+
} else {
|
|
153
|
+
setRouteError(error instanceof PreviewHttpError
|
|
154
|
+
? `A API respondeu HTTP ${error.status}. Confira a conexão e a configuração do preview.`
|
|
155
|
+
: "Não foi possível carregar o conteúdo. Confira a conexão com a API.");
|
|
156
|
+
}
|
|
144
157
|
}
|
|
145
158
|
}, []);
|
|
146
159
|
|
|
@@ -199,6 +212,13 @@ function PreviewApp() {
|
|
|
199
212
|
},
|
|
200
213
|
}), [loadRoute]);
|
|
201
214
|
|
|
215
|
+
if (routeError) return <main role="alert" style={{ padding: "2rem" }}>
|
|
216
|
+
<h1>Não foi possível carregar esta página</h1>
|
|
217
|
+
<p>{routeError}</p>
|
|
218
|
+
<button onClick={() => void loadRoute(new URL(window.location.href))}>Tentar novamente</button>
|
|
219
|
+
<a href="/">Voltar ao início</a>
|
|
220
|
+
</main>;
|
|
221
|
+
|
|
202
222
|
return <>
|
|
203
223
|
<ActiveTheme adapters={adapters} context={context} route={route} sdk={sdk} />
|
|
204
224
|
<PlatformBrand routeKey={`${route.type}:${window.location.pathname}`} />
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function classifyPreviewPath(pathname) {
|
|
2
|
+
const segments = pathname.split("/").filter(Boolean).map(decodeURIComponent);
|
|
3
|
+
if (segments.length === 1 && segments[0] === "produtos") {
|
|
4
|
+
return { type: "catalog", categoryPath: [] };
|
|
5
|
+
}
|
|
6
|
+
if (segments[0] === "categoria" && segments.length > 1) {
|
|
7
|
+
return { type: "catalog", categoryPath: segments.slice(1) };
|
|
8
|
+
}
|
|
9
|
+
if (segments[0] === "produto" && segments.length === 2) {
|
|
10
|
+
return { type: "product", slug: segments[1] };
|
|
11
|
+
}
|
|
12
|
+
if (segments.length === 1) return { type: "page", slug: segments[0] };
|
|
13
|
+
return { type: "not-found" };
|
|
14
|
+
}
|
|
@@ -37,7 +37,7 @@ export function resolvePublicPreviewUrl(requestUrl, apiUrl, store) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const allowed = (
|
|
40
|
-
(segments[0]
|
|
40
|
+
(["products", "pages"].includes(segments[0]) && segments.length <= 2)
|
|
41
41
|
|| (segments.length === 1 && singleResourcePaths.has(segments[0] ?? ""))
|
|
42
42
|
);
|
|
43
43
|
if (!allowed) return null;
|
|
@@ -740,7 +740,7 @@ export function DefaultTheme({ context, adapters, route = { type: "home" }, sdk
|
|
|
740
740
|
const visible = context.home.content.sections.filter((section) => section.enabled).sort((a, b) => a.order - b.order);
|
|
741
741
|
const sections = visible.length ? visible : fallbackSections(context);
|
|
742
742
|
|
|
743
|
-
return <div className="store-shell nuvler-default-theme" data-theme-id="nuvler-default" data-theme-version="1.0.
|
|
743
|
+
return <div className="store-shell nuvler-default-theme" data-theme-id="nuvler-default" data-theme-version="1.0.2" style={style}>
|
|
744
744
|
<Header adapters={adapters} context={context} />
|
|
745
745
|
<div className="store-page"><RouteContent adapters={adapters} context={context} route={route} sdk={sdk} home={<main>{sections.map((section, index) => {
|
|
746
746
|
const Renderer = defaultSectionRegistry[section.type];
|