@tomsher/cms-theme-kit 0.1.0 → 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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/dev/static-server.ts","../../static-engine/src/engine/render/static-html-renderer.ts","../../static-engine/src/engine/storefront/static-html-theme.provider.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/static-engine/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","import { themeFileExtensions } from '@tomsher/cms-core/constants';\nimport { extractThemeStylesheets } from '@tomsher/cms-core/utils';\nimport { staticThemeFolderNames } from '@tomsher/cms-core/constants';\nimport type { StaticHtmlRenderResult, StaticHtmlRenderTheme } from '@tomsher/cms-core/types';\n\nconst stripStaticRoot = (path: string) => path.replace(new RegExp(`^${staticThemeFolderNames.root}/?`), '');\n\nconst normalizePosixPath = (path: string) => {\n const parts: string[] = [];\n for (const part of path.replace(/\\\\/g, '/').split('/')) {\n if (!part || part === '.') continue;\n if (part === '..') parts.pop();\n else parts.push(part);\n }\n return parts.join('/') || '.';\n};\nconst joinPosixPath = (...parts: string[]) => normalizePosixPath(parts.filter(Boolean).join('/'));\n\nconst dirnamePosixPath = (path: string) => {\n const normalized = path.replace(/\\\\/g, '/').replace(/\\/$/, '');\n const separatorIndex = normalized.lastIndexOf('/');\n return separatorIndex < 0 ? '.' : normalized.slice(0, separatorIndex) || '/';\n};\n\nconst basenamePosixPath = (path: string) => path.replace(/\\\\/g, '/').split('/').filter(Boolean).at(-1) || '';\n\nexport const renderStaticHtmlTheme = (theme: StaticHtmlRenderTheme): StaticHtmlRenderResult => {\n const pagePath = theme.templatePath;\n let documentHtml = theme.files[pagePath] || '';\n const pageDirectory = dirnamePosixPath(pagePath);\n\n const resolveReference = (reference: string) => {\n if (!reference || /^(?:[a-z]+:|\\/\\/|#)/i.test(reference)) return reference;\n const [pathname, suffix = ''] = reference.split(/(?=[?#])/, 2);\n const resolved = pathname.startsWith('/') ? pathname.replace(/^\\/+/, '') : joinPosixPath(stripStaticRoot(pageDirectory), pathname).replace(/^\\.\\//, '');\n const url = theme.assetUrls[`${staticThemeFolderNames.root}/${resolved}`] || theme.assetUrls[resolved] || Object.entries(theme.assetUrls).find(([assetPath]) => assetPath.endsWith(`/${basenamePosixPath(resolved)}`))?.[1];\n return url ? `${url}${suffix}` : reference;\n };\n\n const rewriteCss = (content: string, cssDirectory: string) => content.replace(/url\\(\\s*(['\"]?)(?!data:|https?:|blob:)([^'\")]+)\\1\\s*\\)/gi, (match, quote: string, ref: string) => {\n const target = ref.trim().startsWith('/') ? ref.trim().replace(/^\\/+/, '') : joinPosixPath(cssDirectory, ref.trim());\n const url = theme.assetUrls[`${staticThemeFolderNames.root}/${target}`] || theme.assetUrls[target] || Object.entries(theme.assetUrls).find(([assetPath]) => assetPath.endsWith(`/${basenamePosixPath(target)}`))?.[1];\n return url ? `url(${quote}${url}${quote})` : match;\n });\n\n documentHtml = documentHtml.replace(/<link\\b[^>]*\\brel=(['\"])stylesheet\\1[^>]*>/gi, (tag) => {\n const href = tag.match(/\\bhref=(['\"])(.*?)\\1/i)?.[2];\n if (!href || /^(?:[a-z]+:|\\/\\/|data:)/i.test(href)) return tag;\n const [hrefPath] = href.split(/[?#]/, 1);\n const cssPath = hrefPath.startsWith('/') ? hrefPath.replace(/^\\/+/, '') : joinPosixPath(pageDirectory, hrefPath);\n const css = theme.files[cssPath] || theme.files[`${staticThemeFolderNames.root}/${cssPath}`];\n if (!css) return tag;\n const media = tag.match(/\\bmedia=(['\"])(.*?)\\1/i)?.[2];\n return `<style${media ? ` media=\"${media}\"` : ''}>${rewriteCss(css, stripStaticRoot(dirnamePosixPath(cssPath)))}</style>`;\n });\n\n documentHtml = documentHtml.replace(/<style\\b([^>]*)>([\\s\\S]*?)<\\/style>/gi, (_tag, attributes: string, css: string) => `<style${attributes}>${rewriteCss(css, stripStaticRoot(pageDirectory))}</style>`);\n\n documentHtml = documentHtml.replace(/\\b(src|href|poster)=(['\"])(.*?)\\2/gi, (match, attr: string, quote: string, value: string) => {\n if (value.split(/[?#]/, 1)[0].toLowerCase().endsWith(themeFileExtensions.html) || /^(?:mailto:|tel:|javascript:|data:)/i.test(value)) return match;\n return `${attr}=${quote}${resolveReference(value)}${quote}`;\n });\n\n const head = documentHtml.match(/<head\\b[^>]*>([\\s\\S]*?)<\\/head>/i)?.[1] || '';\n const body = documentHtml.match(/<body\\b[^>]*>([\\s\\S]*?)<\\/body>/i)?.[1] || documentHtml.replace(/^[\\s\\S]*?<body\\b[^>]*>/i, '').replace(/<\\/body>[\\s\\S]*$/i, '');\n const title = head.match(/<title\\b[^>]*>([\\s\\S]*?)<\\/title>/i)?.[1]?.trim();\n const htmlAttributes = documentHtml.match(/<html\\b([^>]*)>/i)?.[1] || '';\n const languageCode = htmlAttributes.match(/\\blang\\s*=\\s*(['\"])(.*?)\\1/i)?.[2];\n const direction = htmlAttributes.match(/\\bdir\\s*=\\s*(['\"])(.*?)\\1/i)?.[2];\n const headExtras = head.replace(/<title\\b[^>]*>[\\s\\S]*?<\\/title>/gi, '');\n const scripts = head.match(/<script\\b[^>]*>[\\s\\S]*?<\\/script>/gi) || [];\n const extractedHead = extractThemeStylesheets(headExtras);\n \n return { html: `${extractedHead.html}${scripts.join('')}${body}`, stylesheets: extractedHead.stylesheets, documentHtml, documentTitle: title, languageCode, direction };\n};\n","import { staticThemeFolderNames, themeRenderModes } from '@tomsher/cms-core/constants';\nimport type { PreparedStorefrontTheme, RenderedThemeHtml, StorefrontBundle } from '@tomsher/cms-core/types';\nimport { getThemeAssetUrls } from '@tomsher/cms-core/utils';\nimport { renderStaticHtmlTheme } from '../render/static-html-renderer';\n\nexport interface StaticHtmlThemeProviderOptions {\n // Turns a stored file URL into the public URL the page should use (base URL, CDN, ...).\n resolveMediaUrl: (value: string) => string;\n}\n\nexport class StaticHtmlThemeProvider {\n readonly renderMode = themeRenderModes.static;\n\n constructor(private readonly options: StaticHtmlThemeProviderOptions) { }\n\n async render(theme: PreparedStorefrontTheme): Promise<RenderedThemeHtml> {\n return renderStaticHtmlTheme(theme);\n }\n\n getFallbackTemplatePath(_bundle: StorefrontBundle, _path: string): string | null { return null; }\n\n getNotFoundTemplatePath(_bundle: StorefrontBundle): string | null { return null; }\n\n prepare(bundle: StorefrontBundle, fallbackTemplatePath: string | null): PreparedStorefrontTheme | null {\n const files = Object.fromEntries((bundle.theme.files || []).map((file) => [file.filename, file.content || '']));\n const assetUrls = getThemeAssetUrls(bundle.theme.files || [], staticThemeFolderNames.root, this.options.resolveMediaUrl);\n const templatePath = bundle.theme.templatePath || fallbackTemplatePath;\n if (!templatePath || !files[templatePath]) return null;\n return { bundle, files, renderFiles: { ...files }, assetUrls, templatePath };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,gBAAgB;AAGlC,SAAS,MAAM,UAAU,SAAS,WAAW;;;ACE7C,IAAM,kBAAkB,CAAC,SAAiB,KAAK,QAAQ,IAAI,OAAO,IAAI,uBAAuB,IAAI,IAAI,GAAG,EAAE;AAE1G,IAAM,qBAAqB,CAAC,SAAiB;AACzC,QAAM,QAAkB,CAAC;AACzB,aAAW,QAAQ,KAAK,QAAQ,OAAO,GAAG,EAAE,MAAM,GAAG,GAAG;AACpD,QAAI,CAAC,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