@tomsher/cms-theme-kit 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ liquidThemeAllowedDirectories,
4
+ sha256Hex
5
+ } from "./chunk-TN3DQWJE.js";
6
+
7
+ // src/lib/theme-files.ts
8
+ import { readdir, readFile } from "fs/promises";
9
+ import { join, relative, sep } from "path";
10
+ var textExtensions = [".liquid", ".html", ".json", ".css", ".js", ".svg", ".txt"];
11
+ var isPushablePath = (relativePath) => {
12
+ const segments = relativePath.split("/");
13
+ if (segments.length < 2) {
14
+ return false;
15
+ }
16
+ if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
17
+ return false;
18
+ }
19
+ return liquidThemeAllowedDirectories.includes(segments[0]);
20
+ };
21
+ var isTextPath = (relativePath) => {
22
+ const lower = relativePath.toLowerCase();
23
+ return textExtensions.some((extension) => lower.endsWith(extension));
24
+ };
25
+ var readLocalTheme = async (rootDir) => {
26
+ const entries = await readdir(rootDir, { recursive: true, withFileTypes: true });
27
+ const files = [];
28
+ for (const entry of entries) {
29
+ if (!entry.isFile()) {
30
+ continue;
31
+ }
32
+ const absolutePath = join(entry.parentPath, entry.name);
33
+ const path = relative(rootDir, absolutePath).split(sep).join("/");
34
+ if (!isPushablePath(path)) {
35
+ continue;
36
+ }
37
+ const bytes = await readFile(absolutePath);
38
+ files.push({ path, bytes, hash: sha256Hex(bytes) });
39
+ }
40
+ return files.sort((a, b) => a.path.localeCompare(b.path));
41
+ };
42
+ var toHashMap = (files) => {
43
+ const hashes = {};
44
+ for (const file of files) {
45
+ hashes[file.path] = file.hash;
46
+ }
47
+ return hashes;
48
+ };
49
+
50
+ export {
51
+ isPushablePath,
52
+ isTextPath,
53
+ readLocalTheme,
54
+ toHashMap
55
+ };
56
+ //# sourceMappingURL=chunk-YAYCHT4W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/theme-files.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises';\nimport { join, relative, sep } from 'node:path';\nimport { liquidThemeAllowedDirectories } from '@tomsher/cms-core/constants';\nimport { sha256Hex } from './hash';\n\n// Extensions that can travel as UTF-8 text through the files/batch endpoint.\nconst textExtensions = ['.liquid', '.html', '.json', '.css', '.js', '.svg', '.txt'];\n\nexport interface LocalFile {\n path: string;\n bytes: Uint8Array;\n hash: string;\n}\n\nexport const isPushablePath = (relativePath: string): boolean => {\n const segments = relativePath.split('/');\n\n if (segments.length < 2) {\n return false;\n }\n\n if (segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {\n return false;\n }\n\n return (liquidThemeAllowedDirectories as readonly string[]).includes(segments[0]);\n};\n\nexport const isTextPath = (relativePath: string): boolean => {\n const lower = relativePath.toLowerCase();\n return textExtensions.some((extension) => lower.endsWith(extension));\n};\n\n// manifest.json, data/, files/ and the metadata folder are never inside a pushable directory, so they are skipped here.\nexport const readLocalTheme = async (rootDir: string): Promise<LocalFile[]> => {\n const entries = await readdir(rootDir, { recursive: true, withFileTypes: true });\n const files: LocalFile[] = [];\n\n for (const entry of entries) {\n if (!entry.isFile()) {\n continue;\n }\n\n const absolutePath = join(entry.parentPath, entry.name);\n const path = relative(rootDir, absolutePath).split(sep).join('/');\n\n if (!isPushablePath(path)) {\n continue;\n }\n\n const bytes = await readFile(absolutePath);\n files.push({ path, bytes, hash: sha256Hex(bytes) });\n }\n\n return files.sort((a, b) => a.path.localeCompare(b.path));\n};\n\nexport const toHashMap = (files: LocalFile[]): Record<string, string> => {\n const hashes: Record<string, string> = {};\n\n for (const file of files) {\n hashes[file.path] = file.hash;\n }\n\n return hashes;\n};\n"],"mappings":";;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAClC,SAAS,MAAM,UAAU,WAAW;AAKpC,IAAM,iBAAiB,CAAC,WAAW,SAAS,SAAS,QAAQ,OAAO,QAAQ,MAAM;AAQ3E,I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5
+ createLiveDataSource,
6
+ normalizePreviewData
7
+ } from "./chunk-EUR46QER.js";
8
+ import "./chunk-WSX3MAFK.js";
9
+ import "./chunk-TN3DQWJE.js";
10
+ export {
11
+ buildPreviewRequest,
12
+ createFixturesDataSource,
13
+ createLiveDataSource,
14
+ normalizePreviewData
15
+ };
16
+ //# sourceMappingURL=data-source-63RC4O5W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ closeServer,
4
+ createLiquidFilters,
5
+ createReloadHub,
6
+ createRouteServer,
7
+ linkListHtml,
8
+ listenOnLocalhost,
9
+ notFoundHtml,
10
+ renderErrorPage,
11
+ renderLiquidThemeBundle,
12
+ safeDecode,
13
+ sendHtml,
14
+ sendResponse,
15
+ serveFile
16
+ } from "./chunk-WTBGO3HG.js";
17
+ import {
18
+ isTextPath,
19
+ readLocalTheme
20
+ } from "./chunk-YAYCHT4W.js";
21
+ import {
22
+ buildPreviewRequest
23
+ } from "./chunk-EUR46QER.js";
24
+ import {
25
+ applyThemeCustomizerLocaleOverrides,
26
+ ensureThemeStylesheetsBeforeContent,
27
+ getThemeAssetUrls,
28
+ resolveThemeMediaUrl,
29
+ rewriteLiquidThemeAssetBuffers
30
+ } from "./chunk-WSX3MAFK.js";
31
+ import {
32
+ defaultLanguageCode,
33
+ liquidThemeFolderNames
34
+ } from "./chunk-TN3DQWJE.js";
35
+
36
+ // src/lib/dev/server.ts
37
+ import { join, resolve } from "path";
38
+
39
+ // src/lib/dev/render-page.ts
40
+ var buildLocalization = (languageCode, countryCode) => {
41
+ return {
42
+ country: countryCode ? { name: countryCode, countryCode } : void 0,
43
+ language: { languageCode, languageName: languageCode },
44
+ availableCountries: [],
45
+ availableLanguages: []
46
+ };
47
+ };
48
+ var buildPageContext = (data) => {
49
+ if (!data.page) {
50
+ return {};
51
+ }
52
+ const entry = data.page.entry ?? {};
53
+ return {
54
+ page: { ...entry, entity: data.page.entity, type: data.page.type },
55
+ collection: data.collection
56
+ };
57
+ };
58
+ var renderThemePage = async (options) => {
59
+ const { buffers, assetPaths, templatePath, data, languageCode, countryCode, assetOrigin } = options;
60
+ const localizedBuffers = applyThemeCustomizerLocaleOverrides(buffers, languageCode, defaultLanguageCode);
61
+ const assetFiles = assetPaths.map((path) => ({ path, fileUrl: `${assetOrigin}/${path}` }));
62
+ const themeAssetUrls = getThemeAssetUrls(assetFiles, liquidThemeFolderNames.assets, resolveThemeMediaUrl);
63
+ const previewBuffers = rewriteLiquidThemeAssetBuffers(localizedBuffers, themeAssetUrls);
64
+ const localization = buildLocalization(languageCode, countryCode);
65
+ const customFilters = createLiquidFilters({ fileBuffers: localizedBuffers, activeLocale: languageCode, localization });
66
+ const { entities: entityQueries } = buildPreviewRequest(buffers, templatePath);
67
+ const renderedHtml = await renderLiquidThemeBundle(previewBuffers, {
68
+ customFilters,
69
+ themeAssetUrls,
70
+ templatePath,
71
+ context: {
72
+ entities: data.entities,
73
+ contentCollections: data.contentCollections,
74
+ entityQueries,
75
+ linkTargets: {},
76
+ contentLoading: false,
77
+ localization,
78
+ ...buildPageContext(data)
79
+ }
80
+ });
81
+ return ensureThemeStylesheetsBeforeContent(renderedHtml);
82
+ };
83
+
84
+ // src/lib/dev/server.ts
85
+ var readThemeSnapshot = async (themeDir) => {
86
+ const files = await readLocalTheme(themeDir);
87
+ const buffers = {};
88
+ const assetPaths = [];
89
+ for (const file of files) {
90
+ if (file.path.startsWith("assets/")) {
91
+ assetPaths.push(file.path);
92
+ }
93
+ if (isTextPath(file.path)) {
94
+ buffers[file.path] = new TextDecoder().decode(file.bytes);
95
+ }
96
+ }
97
+ return { buffers, assetPaths };
98
+ };
99
+ var startDevServer = async (options) => {
100
+ const themeDir = resolve(options.themeDir);
101
+ const assetsDir = join(themeDir, "assets");
102
+ const reload = createReloadHub();
103
+ let snapshot = await readThemeSnapshot(themeDir);
104
+ const renderTemplate = async (response, templatePath, assetOrigin) => {
105
+ if (snapshot.buffers[templatePath] === void 0) {
106
+ sendHtml(response, 404, notFoundHtml(`${templatePath} does not exist. See /__templates.`));
107
+ return;
108
+ }
109
+ try {
110
+ const data = await options.dataSource.load({ templatePath, buffers: snapshot.buffers });
111
+ const html = await renderThemePage({
112
+ buffers: snapshot.buffers,
113
+ assetPaths: snapshot.assetPaths,
114
+ templatePath,
115
+ data,
116
+ languageCode: options.languageCode,
117
+ countryCode: options.countryCode,
118
+ assetOrigin
119
+ });
120
+ sendHtml(response, 200, html);
121
+ } catch (error) {
122
+ sendHtml(response, 500, renderErrorPage(error));
123
+ }
124
+ };
125
+ const route = async (request, response) => {
126
+ if (request.method !== "GET") {
127
+ sendResponse(response, 405, { "Content-Type": "text/plain; charset=utf-8", Allow: "GET" }, "Method not allowed");
128
+ return;
129
+ }
130
+ const pathname = new URL(request.url ?? "/", "http://localhost").pathname;
131
+ const address2 = server.address();
132
+ const assetOrigin = `http://localhost:${address2.port}`;
133
+ if (pathname === "/__events") {
134
+ reload.open(request, response);
135
+ return;
136
+ }
137
+ if (pathname === "/__templates") {
138
+ const templatePaths = Object.keys(snapshot.buffers).filter((path) => /^templates\/[^/]+\.json$/.test(path)).sort();
139
+ const links = templatePaths.map((path) => ({ href: `/t/${encodeURI(path)}`, label: path }));
140
+ sendHtml(response, 200, linkListHtml("Templates", links));
141
+ return;
142
+ }
143
+ if (pathname.startsWith("/assets/")) {
144
+ await serveFile(response, assetsDir, pathname.slice("/assets/".length));
145
+ return;
146
+ }
147
+ if (pathname === "/") {
148
+ await renderTemplate(response, options.templatePath, assetOrigin);
149
+ return;
150
+ }
151
+ if (pathname.startsWith("/t/")) {
152
+ const templatePath = safeDecode(pathname.slice("/t/".length));
153
+ if (templatePath === null) {
154
+ sendHtml(response, 400, notFoundHtml("Malformed template path."));
155
+ return;
156
+ }
157
+ await renderTemplate(response, templatePath, assetOrigin);
158
+ return;
159
+ }
160
+ sendHtml(response, 404, notFoundHtml(`No route for ${pathname}.`));
161
+ };
162
+ const server = createRouteServer(route);
163
+ await listenOnLocalhost(server, options.port);
164
+ const address = server.address();
165
+ return {
166
+ url: `http://localhost:${address.port}`,
167
+ notifyChanged: async () => {
168
+ snapshot = await readThemeSnapshot(themeDir);
169
+ reload.broadcast();
170
+ },
171
+ close: () => closeServer(server, reload)
172
+ };
173
+ };
174
+ export {
175
+ startDevServer
176
+ };
177
+ //# sourceMappingURL=server-GITJIQTE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/dev/server.ts","../src/lib/dev/render-page.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport { join, resolve } from 'node:path';\nimport { isTextPath, readLocalTheme } from '../theme-files';\nimport type { DataSource } from './data-source';\nimport { renderThemePage } from './render-page';\nimport { closeServer, createReloadHub, createRouteServer, linkListHtml, listenOnLocalhost, notFoundHtml, renderErrorPage, safeDecode, sendHtml, sendResponse, serveFile } from './server-shared';\n\nexport interface DevServerOptions {\n themeDir: string;\n port: number;\n templatePath: string;\n languageCode: string;\n countryCode?: string;\n dataSource: DataSource;\n}\n\nexport interface DevServer {\n url: string;\n notifyChanged: () => Promise<void>;\n close: () => Promise<void>;\n}\n\ninterface ThemeSnapshot {\n buffers: Record<string, string>;\n assetPaths: string[];\n}\n\nconst readThemeSnapshot = async (themeDir: string): Promise<ThemeSnapshot> => {\n const files = await readLocalTheme(themeDir);\n const buffers: Record<string, string> = {};\n const assetPaths: string[] = [];\n\n for (const file of files) {\n if (file.path.startsWith('assets/')) {\n assetPaths.push(file.path);\n }\n\n if (isTextPath(file.path)) {\n buffers[file.path] = new TextDecoder().decode(file.bytes);\n }\n }\n\n return { buffers, assetPaths };\n};\n\n// Dev server for one theme folder. The theme is read at start and again on each notifyChanged call.\nexport const startDevServer = async (options: DevServerOptions): Promise<DevServer> => {\n const themeDir = resolve(options.themeDir);\n const assetsDir = join(themeDir, 'assets');\n const reload = createReloadHub();\n let snapshot = await readThemeSnapshot(themeDir);\n\n const renderTemplate = async (response: ServerResponse, templatePath: string, assetOrigin: string): Promise<void> => {\n if (snapshot.buffers[templatePath] === undefined) {\n sendHtml(response, 404, notFoundHtml(`${templatePath} does not exist. See /__templates.`));\n return;\n }\n\n try {\n const data = await options.dataSource.load({ templatePath, buffers: snapshot.buffers });\n const html = await renderThemePage({\n buffers: snapshot.buffers,\n assetPaths: snapshot.assetPaths,\n templatePath,\n data,\n languageCode: options.languageCode,\n countryCode: options.countryCode,\n assetOrigin,\n });\n sendHtml(response, 200, html);\n } catch (error) {\n sendHtml(response, 500, renderErrorPage(error));\n }\n };\n\n const route = async (request: IncomingMessage, response: ServerResponse): Promise<void> => {\n if (request.method !== 'GET') {\n sendResponse(response, 405, { 'Content-Type': 'text/plain; charset=utf-8', Allow: 'GET' }, 'Method not allowed');\n return;\n }\n\n const pathname = new URL(request.url ?? '/', 'http://localhost').pathname;\n const address = server.address() as AddressInfo;\n const assetOrigin = `http://localhost:${address.port}`;\n\n if (pathname === '/__events') {\n reload.open(request, response);\n return;\n }\n\n if (pathname === '/__templates') {\n const templatePaths = Object.keys(snapshot.buffers)\n .filter((path) => /^templates\\/[^/]+\\.json$/.test(path))\n .sort();\n const links = templatePaths.map((path) => ({ href: `/t/${encodeURI(path)}`, label: path }));\n sendHtml(response, 200, linkListHtml('Templates', links));\n return;\n }\n\n if (pathname.startsWith('/assets/')) {\n await serveFile(response, assetsDir, pathname.slice('/assets/'.length));\n return;\n }\n\n if (pathname === '/') {\n await renderTemplate(response, options.templatePath, assetOrigin);\n return;\n }\n\n if (pathname.startsWith('/t/')) {\n const templatePath = safeDecode(pathname.slice('/t/'.length));\n\n if (templatePath === null) {\n sendHtml(response, 400, notFoundHtml('Malformed template path.'));\n return;\n }\n\n await renderTemplate(response, templatePath, assetOrigin);\n return;\n }\n\n sendHtml(response, 404, notFoundHtml(`No route for ${pathname}.`));\n };\n\n const server = createRouteServer(route);\n\n await listenOnLocalhost(server, options.port);\n\n const address = server.address() as AddressInfo;\n\n return {\n url: `http://localhost:${address.port}`,\n notifyChanged: async () => {\n snapshot = await readThemeSnapshot(themeDir);\n reload.broadcast();\n },\n close: () => closeServer(server, reload),\n };\n};\n","import { getThemeAssetUrls } from '@tomsher/cms-core/utils';\nimport { resolveThemeMediaUrl } from '@tomsher/cms-theme-engines/utils';\nimport { applyThemeCustomizerLocaleOverrides } from '@tomsher/cms-theme-engines/utils';\nimport { createLiquidFilters } from '@tomsher/cms-theme-engines/engine';\nimport { defaultLanguageCode } from '@tomsher/cms-core/constants';\nimport { ensureThemeStylesheetsBeforeContent, rewriteLiquidThemeAssetBuffers } from '@tomsher/cms-core/utils';\nimport { liquidThemeFolderNames } from '@tomsher/cms-core/constants';\nimport { renderLiquidThemeBundle } from '@tomsher/cms-theme-engines/engine';\nimport type { StorefrontLocalization } from '@tomsher/cms-core/types';\nimport { buildPreviewRequest, type PreviewData } from './data-source';\n\nexport interface RenderPageOptions {\n buffers: Record<string, string>;\n assetPaths: string[];\n templatePath: string;\n data: PreviewData;\n languageCode: string;\n countryCode?: string;\n assetOrigin: string;\n}\n\nconst buildLocalization = (languageCode: string, countryCode?: string): StorefrontLocalization => {\n return {\n country: countryCode ? { name: countryCode, countryCode } : undefined,\n language: { languageCode, languageName: languageCode },\n availableCountries: [],\n availableLanguages: [],\n };\n};\n\n// Same page context shape as useThemeVisualBuilderPreview.\nconst buildPageContext = (data: PreviewData): Record<string, unknown> => {\n if (!data.page) {\n return {};\n }\n\n const entry = (data.page.entry as Record<string, unknown> | undefined) ?? {};\n\n return {\n page: { ...entry, entity: data.page.entity, type: data.page.type },\n collection: data.collection,\n };\n};\n\n// Renders one template the way the admin editor preview does. Throws on render failure.\nexport const renderThemePage = async (options: RenderPageOptions): Promise<string> => {\n const { buffers, assetPaths, templatePath, data, languageCode, countryCode, assetOrigin } = options;\n const localizedBuffers = applyThemeCustomizerLocaleOverrides(buffers, languageCode, defaultLanguageCode);\n const assetFiles = assetPaths.map((path) => ({ path, fileUrl: `${assetOrigin}/${path}` }));\n const themeAssetUrls = getThemeAssetUrls(assetFiles, liquidThemeFolderNames.assets, resolveThemeMediaUrl);\n const previewBuffers = rewriteLiquidThemeAssetBuffers(localizedBuffers, themeAssetUrls);\n const localization = buildLocalization(languageCode, countryCode);\n const customFilters = createLiquidFilters({ fileBuffers: localizedBuffers, activeLocale: languageCode, localization });\n const { entities: entityQueries } = buildPreviewRequest(buffers, templatePath);\n const renderedHtml = await renderLiquidThemeBundle(previewBuffers, {\n customFilters,\n themeAssetUrls,\n templatePath,\n context: {\n entities: data.entities,\n contentCollections: data.contentCollections,\n entityQueries,\n linkTargets: {},\n contentLoading: false,\n localization,\n ...buildPageContext(data),\n },\n });\n\n return ensureThemeStylesheetsBeforeContent(renderedHtml);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,MAAM,eAAe;;;ACmB9B,IAAM,oBAAoB,CAAC,cAAsB,gBAAiD;AAC9F,SAAO;AAAA,IACH,SAAS,cAAc,EAAE,MAAM,aAAa,YAAY,IAAI;AAAA,IAC5D,UAAU,EAAE,cAAc,cAAc,aAAa;AAAA,IACrD,oBAAoB,CAAC;AAAA,IACrB,oBAAoB,CAAC;AAAA,EACzB;AACJ;AAGA,IAAM,mBAAmB,CAAC,SAA+C;AACrE,MAAI,CAAC,KAAK,MAAM;AACZ,WAAO,CAAC;AAAA,EACZ;AAEA,QAAM,QAAS,KAAK,KAAK,SAAiD,CAAC;AAE3E,SAAO;AAAA,IACH,MAAM,EAAE,GAAG,OAAO,QAAQ,KAAK,KAAK,QAAQ,MAAM,KAAK,KAAK,KAAK;AAAA,IACjE,YAAY,KAAK;AAAA,EACrB;AACJ;AAGO,IAAM,kBAAkB,OAAO,YAAgD;AAClF,QAAM,EAAE,SAAS,YAAY,cAAc,MAAM,cAAc,aAAa,YAAY,IAAI;AAC5F,QAAM,mBAAmB,oCAAoC,SAAS,cAAc,mBAAm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AAK,aAAa,aAAa,KAAK,CAAC;AACxD;AAAA,IACJ;AAEA,QAAI,SAAS,WAAW,UAAU,GAAG;AACjC,YAAM,UAAU,UAAU,WAAW,SAAS,MAAM,WAAW,MAAM,CAAC;AACtE;AAAA,IACJ;AAEA,QAAI,aAAa,KAAK;AAClB,YAAM,eAAe,UAAU,QAAQ,cAAc,WAAW;AAChE;AAAA,IACJ;AAEA,QAAI,SAAS,WAAW,KAAK,GAAG;AAC5B,YAAM,eAAe,WAAW,SAAS,MAAM,MAAM,MAAM,CAAC;AAE5D,UAAI,iBAAiB,MAAM;AACvB,iBAAS,UAAU,KAAK,aAAa,0BAA0B,CAAC;AAChE;AAAA,MACJ;AAEA,YAAM,eAAe,UAAU,cAAc,WAAW;AACxD;AAAA,IACJ;AAEA,aAAS,UAAU,KAAK,aAAa,gBAAgB,QAAQ,GAAG,CAAC;AAAA,EACrE;AAEA,QAAM,SAAS,kBAAkB,KAAK;AAEtC,QAAM,kBAAkB,QAAQ,QAAQ,IAAI;AAE5C,QAAM,UAAU,OAAO,QAAQ;AAE/B,SAAO;AAAA,IACH,KAAK,oBAAoB,QAAQ,IAAI;AAAA,IACrC,eAAe,YAAY;AACvB,iBAAW,MAAM,kBAAkB,QAAQ;AAC3C,aAAO,UAAU;AAAA,IACrB;AAAA,IACA,OAAO,MAAM,YAAY,QAAQ,MAAM;AAAA,EAC3C;AACJ;","names":["address"]}
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ closeServer,
4
+ createReloadHub,
5
+ createRouteServer,
6
+ linkListHtml,
7
+ listenOnLocalhost,
8
+ notFoundHtml,
9
+ renderErrorPage,
10
+ renderStaticHtmlTheme,
11
+ safeDecode,
12
+ sendHtml,
13
+ sendResponse,
14
+ serveFile
15
+ } from "./chunk-WTBGO3HG.js";
16
+ import {
17
+ isTextPath
18
+ } from "./chunk-YAYCHT4W.js";
19
+ import "./chunk-WSX3MAFK.js";
20
+ import {
21
+ CliError,
22
+ staticThemeFolderNames,
23
+ staticThemeHomePath,
24
+ themeFileExtensions
25
+ } from "./chunk-TN3DQWJE.js";
26
+
27
+ // src/lib/dev/static-server.ts
28
+ import { readdir, readFile } from "fs/promises";
29
+ import { join, relative, resolve, sep } from "path";
30
+ var staticRootPrefix = `${staticThemeFolderNames.root}/`;
31
+ var staticFilesPrefix = "/static-files/";
32
+ var htmlExtension = themeFileExtensions.html;
33
+ var readStaticSnapshot = async (themeDir) => {
34
+ const staticDir = join(themeDir, staticThemeFolderNames.root);
35
+ const entries = await readdir(staticDir, { recursive: true, withFileTypes: true }).catch((error) => {
36
+ if (error.code === "ENOENT") {
37
+ throw new CliError(`No ${staticThemeFolderNames.root}/ folder in ${themeDir}. Pass --mode liquid for a liquid theme.`);
38
+ }
39
+ throw error;
40
+ });
41
+ const files = {};
42
+ const assetUrls = {};
43
+ for (const entry of entries) {
44
+ if (!entry.isFile()) {
45
+ continue;
46
+ }
47
+ const absolutePath = join(entry.parentPath, entry.name);
48
+ const path = relative(themeDir, absolutePath).split(sep).join("/");
49
+ const relativePath = path.slice(staticRootPrefix.length);
50
+ if (!path.toLowerCase().endsWith(htmlExtension)) {
51
+ assetUrls[path] = `${staticFilesPrefix}${relativePath.split("/").map(encodeURIComponent).join("/")}`;
52
+ }
53
+ if (isTextPath(path)) {
54
+ files[path] = new TextDecoder().decode(await readFile(absolutePath));
55
+ }
56
+ }
57
+ return { files, assetUrls };
58
+ };
59
+ var pageCandidates = (route) => {
60
+ const name = route.replace(/\/+$/, "");
61
+ if (name === "") {
62
+ return [staticThemeHomePath];
63
+ }
64
+ if (name.endsWith(htmlExtension)) {
65
+ return [`${staticRootPrefix}${name}`];
66
+ }
67
+ return [`${staticRootPrefix}${name}${htmlExtension}`, `${staticRootPrefix}${name}/index${htmlExtension}`];
68
+ };
69
+ var routeOfPage = (path) => {
70
+ const name = path.slice(staticRootPrefix.length, -htmlExtension.length);
71
+ return name === "index" ? "/" : `/${name.replace(/\/index$/, "")}`;
72
+ };
73
+ var startStaticDevServer = async (options) => {
74
+ const themeDir = resolve(options.themeDir);
75
+ const staticDir = join(themeDir, staticThemeFolderNames.root);
76
+ const reload = createReloadHub();
77
+ let snapshot = await readStaticSnapshot(themeDir);
78
+ const renderPage = (response, pathname, route) => {
79
+ const templatePath = pageCandidates(route).find((candidate) => snapshot.files[candidate] !== void 0);
80
+ if (templatePath === void 0) {
81
+ sendHtml(response, 404, notFoundHtml(`No page for ${pathname}. See /__templates.`));
82
+ return;
83
+ }
84
+ try {
85
+ const { documentHtml } = renderStaticHtmlTheme({ templatePath, files: snapshot.files, assetUrls: snapshot.assetUrls });
86
+ sendHtml(response, 200, documentHtml ?? "");
87
+ } catch (error) {
88
+ sendHtml(response, 500, renderErrorPage(error));
89
+ }
90
+ };
91
+ const handleRequest = async (request, response) => {
92
+ if (request.method !== "GET") {
93
+ sendResponse(response, 405, { "Content-Type": "text/plain; charset=utf-8", Allow: "GET" }, "Method not allowed");
94
+ return;
95
+ }
96
+ const pathname = new URL(request.url ?? "/", "http://localhost").pathname;
97
+ if (pathname === "/__events") {
98
+ reload.open(request, response);
99
+ return;
100
+ }
101
+ if (pathname === "/__templates") {
102
+ const links = Object.keys(snapshot.files).filter((path) => path.toLowerCase().endsWith(htmlExtension)).sort().map((path) => ({ href: encodeURI(routeOfPage(path)), label: path }));
103
+ sendHtml(response, 200, linkListHtml("Pages", links));
104
+ return;
105
+ }
106
+ if (pathname.startsWith(staticFilesPrefix)) {
107
+ await serveFile(response, staticDir, pathname.slice(staticFilesPrefix.length));
108
+ return;
109
+ }
110
+ const routePath = safeDecode(pathname.slice(1));
111
+ if (routePath === null) {
112
+ sendHtml(response, 400, notFoundHtml("Malformed page path."));
113
+ return;
114
+ }
115
+ renderPage(response, pathname, routePath);
116
+ };
117
+ const server = createRouteServer(handleRequest);
118
+ await listenOnLocalhost(server, options.port);
119
+ const address = server.address();
120
+ return {
121
+ url: `http://localhost:${address.port}`,
122
+ notifyChanged: async () => {
123
+ snapshot = await readStaticSnapshot(themeDir);
124
+ reload.broadcast();
125
+ },
126
+ close: () => closeServer(server, reload)
127
+ };
128
+ };
129
+ export {
130
+ startStaticDevServer
131
+ };
132
+ //# sourceMappingURL=static-server-WWP7CW4C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/dev/static-server.ts"],"sourcesContent":["import { readdir, readFile } from 'node:fs/promises';\nimport type { IncomingMessage, ServerResponse } from 'node:http';\nimport type { AddressInfo } from 'node:net';\nimport { join, relative, resolve, sep } from 'node:path';\nimport { staticThemeFolderNames, staticThemeHomePath, themeFileExtensions } from '@tomsher/cms-core/constants';\nimport { renderStaticHtmlTheme } from '@tomsher/cms-theme-engines/engine';\nimport { CliError } from '../errors';\nimport { isTextPath } from '../theme-files';\nimport type { DevServer } from './server';\nimport { closeServer, createReloadHub, createRouteServer, linkListHtml, listenOnLocalhost, notFoundHtml, renderErrorPage, safeDecode, sendHtml, sendResponse, serveFile } from './server-shared';\n\nexport interface StaticDevServerOptions {\n themeDir: string;\n port: number;\n}\n\ninterface StaticSnapshot {\n files: Record<string, string>;\n assetUrls: Record<string, string>;\n}\n\nconst staticRootPrefix = `${staticThemeFolderNames.root}/`;\nconst staticFilesPrefix = '/static-files/';\nconst htmlExtension = themeFileExtensions.html;\n\n// Text files are renderer sources. Every non-HTML file gets a local URL that the dev server serves from disk.\nconst readStaticSnapshot = async (themeDir: string): Promise<StaticSnapshot> => {\n const staticDir = join(themeDir, staticThemeFolderNames.root);\n const entries = await readdir(staticDir, { recursive: true, withFileTypes: true }).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') {\n throw new CliError(`No ${staticThemeFolderNames.root}/ folder in ${themeDir}. Pass --mode liquid for a liquid theme.`);\n }\n\n throw error;\n });\n const files: Record<string, string> = {};\n const assetUrls: Record<string, string> = {};\n\n for (const entry of entries) {\n if (!entry.isFile()) {\n continue;\n }\n\n const absolutePath = join(entry.parentPath, entry.name);\n const path = relative(themeDir, absolutePath).split(sep).join('/');\n const relativePath = path.slice(staticRootPrefix.length);\n\n if (!path.toLowerCase().endsWith(htmlExtension)) {\n assetUrls[path] = `${staticFilesPrefix}${relativePath.split('/').map(encodeURIComponent).join('/')}`;\n }\n\n if (isTextPath(path)) {\n files[path] = new TextDecoder().decode(await readFile(absolutePath));\n }\n }\n\n return { files, assetUrls };\n};\n\n// Lookup order for a route: static/<route>.html, then static/<route>/index.html. The route \"\" is the home page.\nconst pageCandidates = (route: string): string[] => {\n const name = route.replace(/\\/+$/, '');\n\n if (name === '') {\n return [staticThemeHomePath];\n }\n\n if (name.endsWith(htmlExtension)) {\n return [`${staticRootPrefix}${name}`];\n }\n\n return [`${staticRootPrefix}${name}${htmlExtension}`, `${staticRootPrefix}${name}/index${htmlExtension}`];\n};\n\n// static/docs/index.html is served at /docs and static/index.html at /.\nconst routeOfPage = (path: string): string => {\n const name = path.slice(staticRootPrefix.length, -htmlExtension.length);\n\n return name === 'index' ? '/' : `/${name.replace(/\\/index$/, '')}`;\n};\n\n// Dev server for a static theme folder (static/ holds the pages and their assets). Files are re-read on each notifyChanged call.\nexport const startStaticDevServer = async (options: StaticDevServerOptions): Promise<DevServer> => {\n const themeDir = resolve(options.themeDir);\n const staticDir = join(themeDir, staticThemeFolderNames.root);\n const reload = createReloadHub();\n let snapshot = await readStaticSnapshot(themeDir);\n\n const renderPage = (response: ServerResponse, pathname: string, route: string): void => {\n const templatePath = pageCandidates(route).find((candidate) => snapshot.files[candidate] !== undefined);\n\n if (templatePath === undefined) {\n sendHtml(response, 404, notFoundHtml(`No page for ${pathname}. See /__templates.`));\n return;\n }\n\n try {\n const { documentHtml } = renderStaticHtmlTheme({ templatePath, files: snapshot.files, assetUrls: snapshot.assetUrls });\n sendHtml(response, 200, documentHtml ?? '');\n } catch (error) {\n sendHtml(response, 500, renderErrorPage(error));\n }\n };\n\n const handleRequest = async (request: IncomingMessage, response: ServerResponse): Promise<void> => {\n if (request.method !== 'GET') {\n sendResponse(response, 405, { 'Content-Type': 'text/plain; charset=utf-8', Allow: 'GET' }, 'Method not allowed');\n return;\n }\n\n const pathname = new URL(request.url ?? '/', 'http://localhost').pathname;\n\n if (pathname === '/__events') {\n reload.open(request, response);\n return;\n }\n\n if (pathname === '/__templates') {\n const links = Object.keys(snapshot.files)\n .filter((path) => path.toLowerCase().endsWith(htmlExtension))\n .sort()\n .map((path) => ({ href: encodeURI(routeOfPage(path)), label: path }));\n sendHtml(response, 200, linkListHtml('Pages', links));\n return;\n }\n\n if (pathname.startsWith(staticFilesPrefix)) {\n await serveFile(response, staticDir, pathname.slice(staticFilesPrefix.length));\n return;\n }\n\n const routePath = safeDecode(pathname.slice(1));\n\n if (routePath === null) {\n sendHtml(response, 400, notFoundHtml('Malformed page path.'));\n return;\n }\n\n renderPage(response, pathname, routePath);\n };\n\n const server = createRouteServer(handleRequest);\n\n await listenOnLocalhost(server, options.port);\n\n const address = server.address() as AddressInfo;\n\n return {\n url: `http://localhost:${address.port}`,\n notifyChanged: async () => {\n snapshot = await readStaticSnapshot(themeDir);\n reload.broadcast();\n },\n close: () => closeServer(server, reload),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAGlC,SAAS,MAAM,UAAU,SAAS,WAAW;AAkB7C,IAAM,mBAAmB,GAAG,uBAAuB,IAAI;AACvD,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB,oBAAoB;AAG1C,IAAM,qBAAqB,OAAO,aAA8C;AAC5E,QAAM,YAAY,KAAK,UAAU,uBAAuB,IAAI;AAC5D,QAAM,UAAU,MAAM,QAAQ,WAAW,EAAE,WAAW,MAAM,eAAe,KAAK,CAAC,EAAE,MAAM,CAAC,UAAiC;AACvH,QAAI,MAAM,SAAS,UAAU;AACzB,YAAM,IAAI,SAAS,MAAM,uBAAuB,IAAI,eAAe,QAAQ,0CAA0C;AAAA,IACzH;AAEA,UAAM;AAAA,EACV,CAAC;AACD,QAAM,QAAgC,CAAC;AACvC,QAA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AAM,kBAAkB,MAAM,CAAC;AAC7E;AAAA,IACJ;AAEA,UAAM,YAAY,WAAW,SAAS,MAAM,CAAC,CAAC;AAE9C,QAAI,cAAc,MAAM;AACpB,eAAS,UAAU,KAAK,aAAa,sBAAsB,CAAC;AAC5D;AAAA,IACJ;AAEA,eAAW,UAAU,UAAU,SAAS;AAAA,EAC5C;AAEA,QAAM,SAAS,kBAAkB,aAAa;AAE9C,QAAM,kBAAkB,QAAQ,QAAQ,IAAI;AAE5C,QAAM,UAAU,OAAO,QAAQ;AAE/B,SAAO;AAAA,IACH,KAAK,oBAAoB,QAAQ,IAAI;AAAA,IACrC,eAAe,YAAY;AACvB,iBAAW,MAAM,mBAAmB,QAAQ;AAC5C,aAAO,UAAU;AAAA,IACrB;AAAA,IACA,OAAO,MAAM,YAAY,QAAQ,MAAM;AAAA,EAC3C;AACJ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
- "name": "@tomsher/cms-theme-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@tomsher/cms-theme-kit",
3
+ "version": "0.1.1",
4
+ "description": "Pull a theme from a Tomsher CMS, edit it locally and push it back as a draft.",
5
+ "type": "module",
6
+ "bin": {
7
+ "cms-theme-kit": "dist/bin.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "engines": {
13
+ "node": ">=22"
14
+ },
15
+ "scripts": {
16
+ "build": "tsup",
17
+ "test": "vitest run",
18
+ "prepublishOnly": "npm run build && npm test"
19
+ },
20
+ "dependencies": {
21
+ "fflate": "^0.8.2",
22
+ "sanitize-html": "^2.18.0"
23
+ },
24
+ "devDependencies": {
25
+ "@tomsher/cms-core": "0.1.0",
26
+ "@tomsher/cms-theme-engines": "0.1.0",
27
+ "@types/node": "^22.10.0",
28
+ "tsup": "^8.5.0",
29
+ "typescript": "^5.9.3",
30
+ "vitest": "^4.1.11"
31
+ },
32
+ "license": "UNLICENSED",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.