@blinkk/root 1.0.0-beta.17 → 1.0.0-beta.18
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/{chunk-WVRC46JG.js → chunk-DXD5LKU3.js} +18 -18
- package/dist/chunk-DXD5LKU3.js.map +1 -0
- package/dist/{chunk-LTSJAEBG.js → chunk-K72XPY7N.js} +2 -2
- package/dist/chunk-K72XPY7N.js.map +1 -0
- package/dist/{chunk-DTEQ2AIW.js → chunk-QKBMWK5B.js} +1 -1
- package/dist/chunk-QKBMWK5B.js.map +1 -0
- package/dist/{chunk-WTSNW7BB.js → chunk-WX2GLKRC.js} +1 -1
- package/dist/chunk-WX2GLKRC.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +117 -121
- package/dist/cli.js.map +1 -1
- package/dist/core.d.ts +11 -3
- package/dist/core.js +3 -2
- package/dist/core.js.map +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +2 -2
- package/dist/render.d.ts +1 -1
- package/dist/render.js +190 -190
- package/dist/render.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-DTEQ2AIW.js.map +0 -1
- package/dist/chunk-LTSJAEBG.js.map +0 -1
- package/dist/chunk-WTSNW7BB.js.map +0 -1
- package/dist/chunk-WVRC46JG.js.map +0 -1
- package/dist/{types-8310f09f.d.ts → types-d73469ff.d.ts} +29 -29
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
// src/utils/elements.ts
|
|
2
|
+
var ELEMENT_RE = /^[a-z][\w-]*-[\w-]*$/;
|
|
3
|
+
var HTML_ELEMENTS_REGEX = /<([a-z][\w-]*-[\w-]*)/g;
|
|
4
|
+
function isValidTagName(tagName) {
|
|
5
|
+
return ELEMENT_RE.test(tagName);
|
|
6
|
+
}
|
|
7
|
+
function parseTagNames(src) {
|
|
8
|
+
const tagNames = /* @__PURE__ */ new Set();
|
|
9
|
+
const matches = Array.from(src.matchAll(HTML_ELEMENTS_REGEX));
|
|
10
|
+
for (const match of matches) {
|
|
11
|
+
const tagName = match[1];
|
|
12
|
+
tagNames.add(tagName);
|
|
13
|
+
}
|
|
14
|
+
return Array.from(tagNames);
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
// src/render/html-minify.ts
|
|
2
18
|
import { createRequire } from "module";
|
|
3
19
|
var require2 = createRequire(import.meta.url);
|
|
@@ -17,22 +33,6 @@ async function htmlMinify(html, options) {
|
|
|
17
33
|
}
|
|
18
34
|
}
|
|
19
35
|
|
|
20
|
-
// src/utils/elements.ts
|
|
21
|
-
var ELEMENT_RE = /^[a-z][\w-]*-[\w-]*$/;
|
|
22
|
-
var HTML_ELEMENTS_REGEX = /<([a-z][\w-]*-[\w-]*)/g;
|
|
23
|
-
function isValidTagName(tagName) {
|
|
24
|
-
return ELEMENT_RE.test(tagName);
|
|
25
|
-
}
|
|
26
|
-
function parseTagNames(src) {
|
|
27
|
-
const tagNames = /* @__PURE__ */ new Set();
|
|
28
|
-
const matches = Array.from(src.matchAll(HTML_ELEMENTS_REGEX));
|
|
29
|
-
for (const match of matches) {
|
|
30
|
-
const tagName = match[1];
|
|
31
|
-
tagNames.add(tagName);
|
|
32
|
-
}
|
|
33
|
-
return Array.from(tagNames);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
36
|
// src/render/html-pretty.ts
|
|
37
37
|
import { createRequire as createRequire2 } from "module";
|
|
38
38
|
var require3 = createRequire2(import.meta.url);
|
|
@@ -53,9 +53,9 @@ async function htmlPretty(html, options) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export {
|
|
56
|
-
htmlMinify,
|
|
57
56
|
isValidTagName,
|
|
58
57
|
parseTagNames,
|
|
58
|
+
htmlMinify,
|
|
59
59
|
htmlPretty
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-DXD5LKU3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/elements.ts","../src/render/html-minify.ts","../src/render/html-pretty.ts"],"sourcesContent":["export const ELEMENT_RE = /^[a-z][\\w-]*-[\\w-]*$/;\nexport const HTML_ELEMENTS_REGEX = /<([a-z][\\w-]*-[\\w-]*)/g;\n\n/**\n * Returns true if the tagName is a valid custom element tag.\n */\nexport function isValidTagName(tagName: string) {\n return ELEMENT_RE.test(tagName);\n}\n\n/**\n * Returns a list of custom elements used in a src string (e.g. HTML, jsx, lit).\n * NOTE: the impl uses a simple regex, so tagNames used in comments and attr\n * values may be included.\n */\nexport function parseTagNames(src: string): string[] {\n const tagNames = new Set<string>();\n const matches = Array.from(src.matchAll(HTML_ELEMENTS_REGEX));\n for (const match of matches) {\n const tagName = match[1];\n tagNames.add(tagName);\n }\n return Array.from(tagNames);\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {Options} from 'html-minifier-terser';\n\nconst {minify} = require('html-minifier-terser');\n\nexport type HtmlMinifyOptions = Options;\n\nexport async function htmlMinify(\n html: string,\n options?: HtmlMinifyOptions\n): Promise<string> {\n const minifyOptions = options || {\n collapseWhitespace: true,\n removeComments: true,\n preserveLineBreaks: true,\n };\n try {\n const min = await minify(html, minifyOptions);\n return min.trimStart();\n } catch (e) {\n console.error('failed to minify html:', e);\n return html;\n }\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {HTMLBeautifyOptions} from 'js-beautify';\n\nconst beautify = require('js-beautify');\n\nexport type HtmlPrettyOptions = HTMLBeautifyOptions;\n\nexport async function htmlPretty(\n html: string,\n options?: HtmlPrettyOptions\n): Promise<string> {\n const prettyOptions = options || {\n indent_size: 0,\n end_with_newline: true,\n extra_liners: [],\n };\n try {\n const output = beautify.html(html, prettyOptions);\n return output.trimStart();\n } catch (e) {\n console.error('failed to pretty html:', e);\n return html;\n }\n}\n"],"mappings":";AAAO,IAAM,aAAa;AACnB,IAAM,sBAAsB;AAK5B,SAAS,eAAe,SAAiB;A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|
|
5
5
|
// src/node/load-config.ts
|
|
6
6
|
import path2 from "node:path";
|
|
@@ -147,4 +147,4 @@ export {
|
|
|
147
147
|
createViteServer,
|
|
148
148
|
viteSsrLoadModule
|
|
149
149
|
};
|
|
150
|
-
//# sourceMappingURL=chunk-
|
|
150
|
+
//# sourceMappingURL=chunk-K72XPY7N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/load-config.ts","../src/utils/fsutils.ts","../src/node/vite.ts"],"sourcesContent":["import path from 'node:path';\n\nimport {bundleRequire} from 'bundle-require';\n\nimport {RootConfig} from '../core/config';\nimport {fileExists} from '../utils/fsutils';\n\nexport interface ConfigOptions {\n command: string;\n}\n\nexport async function loadRootConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const configBundle = await bundleRequire({\n filepath: configPath,\n });\n let config = configBundle.mod.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n return Object.assign({}, config, {rootDir});\n}\n","import {promises as fs} from 'node:fs';\nimport path from 'node:path';\n\nimport fsExtra from 'fs-extra';\nimport glob from 'tiny-glob';\n\nexport function isJsFile(filename: string) {\n return !!filename.match(/\\.(j|t)sx?$/);\n}\n\nexport async function writeFile(filepath: string, content: string) {\n const dirPath = path.dirname(filepath);\n await makeDir(dirPath);\n await fs.writeFile(filepath, content);\n}\n\nexport async function makeDir(dirpath: string) {\n try {\n await fs.access(dirpath);\n } catch (e) {\n await fs.mkdir(dirpath, {recursive: true});\n }\n}\n\nexport async function copyDir(srcdir: string, dstdir: string) {\n if (!fsExtra.existsSync(srcdir)) {\n return;\n }\n fsExtra.copySync(srcdir, dstdir, {recursive: true, overwrite: true});\n}\n\n/**\n * Copies a glob of files from one directory to another.\n *\n * Example:\n *\n * ```\n * await copyGlob('*.css', 'src/styles', 'dist/html/styles');\n * ```\n */\nexport async function copyGlob(\n pattern: string,\n srcdir: string,\n dstdir: string\n) {\n const files = await glob(pattern, {cwd: srcdir});\n if (files.length > 0) {\n await makeDir(dstdir);\n }\n files.forEach((file) => {\n fsExtra.copySync(path.resolve(srcdir, file), path.resolve(dstdir, file));\n });\n}\n\nexport async function rmDir(dirpath: string) {\n await fs.rm(dirpath, {recursive: true, force: true});\n}\n\nexport async function loadJson<T = unknown>(filepath: string): Promise<T> {\n const content = await fs.readFile(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function isDirectory(dirpath: string) {\n return fs\n .stat(dirpath)\n .then((fsStat) => {\n return fsStat.isDirectory();\n })\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return false;\n }\n throw err;\n });\n}\n\nexport function fileExists(filepath: string): Promise<boolean> {\n return fs\n .access(filepath)\n .then(() => true)\n .catch(() => false);\n}\n\nexport async function directoryContains(\n dirpath: string,\n subpath: string\n): Promise<boolean> {\n const outer = await fs.realpath(dirpath);\n const inner = await fs.realpath(subpath);\n const rel = path.relative(outer, inner);\n return !rel.startsWith('..');\n}\n","import path from 'node:path';\n\nimport {createServer, ViteDevServer} from 'vite';\n\nimport {RootConfig} from '../core/config.js';\nimport {getVitePlugins} from '../core/plugin.js';\n\nexport interface CreateViteServerOptions {\n /** Override HMR settings. */\n hmr?: boolean;\n /** The port the server will run on. */\n port?: number;\n /** List of files to include in the optimizeDeps.include config. */\n optimizeDeps?: string[];\n}\n\n/**\n * Returns a vite dev server.\n */\nexport async function createViteServer(\n rootConfig: RootConfig,\n options?: CreateViteServerOptions\n): Promise<ViteDevServer> {\n const rootDir = rootConfig.rootDir;\n const viteConfig = rootConfig.vite || {};\n\n let hmrOptions = viteConfig.server?.hmr;\n if (options?.hmr === false) {\n hmrOptions = false;\n } else if (typeof hmrOptions === 'undefined' && options?.port) {\n // Automatically set the HMR port to `port + 10`. This allows multiple\n // root.js dev servers to run without conflicts.\n hmrOptions = {port: options.port + 10};\n }\n\n const viteServer = await createServer({\n ...viteConfig,\n mode: 'development',\n root: rootDir,\n publicDir: path.join(rootDir, 'public'),\n server: {\n ...(viteConfig.server || {}),\n middlewareMode: true,\n hmr: hmrOptions,\n },\n appType: 'custom',\n optimizeDeps: {\n ...(viteConfig.optimizeDeps || {}),\n include: [\n ...(options?.optimizeDeps || []),\n ...(viteConfig.optimizeDeps?.include || []),\n ],\n },\n ssr: {\n ...(viteConfig.ssr || {}),\n noExternal: ['@blinkk/root'],\n },\n esbuild: {\n ...(viteConfig.esbuild || {}),\n jsx: 'automatic',\n jsxImportSource: 'preact',\n },\n plugins: [\n ...(viteConfig.plugins || []),\n ...getVitePlugins(rootConfig.plugins || []),\n ],\n });\n return viteServer;\n}\n\n/**\n * Shortcut `viteServer.ssrLoadModule()` without starting an actual dev server.\n */\nexport async function viteSsrLoadModule(\n rootConfig: RootConfig,\n file: string\n): Promise<Record<string, any>> {\n const viteServer = await createViteServer(rootConfig, {hmr: false});\n const module = await viteServer.ssrLoadModule(file);\n await viteServer.close();\n return module;\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAU;AAEjB,SAAQ,qBAAoB;;;ACF5B,SAAQ,YAAY,UAAS;AAC7B,OAAO,UAAU;AAEjB,OAAO,aAAa;AACpB,OAAO,UAAU;AAEV,SAAS,SAAS,UAAkB;AACzC,SAAO,CAAC,CAAC,SAAS,MAAM,aAAa;AACvC;AAEA,eAAsB,UAAU,UAAkB,SAAiB;AACjE,QAAM,UAAU,KAAK,QAAQ,QAAQ;AACrC,QAAM,QAAQ,OAAO;AACrB,QAAM,GAAG,UAAU,UAAU,OAAO;AACtC;AAEA,eAAsB,QAAQ,SAAiB;AAC7C,MAAI;AACF,UAAM,GAAG,OAAO,OAAO;AAAA,EACzB,SAAS,GAAP;AACA,UAAM,GAAG,MAAM,SAAS,EAAC,WAAW,KAAI,CAAC;AAAA,EAC3C;AACF;AAkBA,eAAsB,SACpB,SACA,QACA,QACA;AACA,QAAM,QAAQ,MAAM,KAAK,S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WAAW,CAAC;AAAA,MAC3B,GAAG,eAAe,WAAW,WAAW,CAAC,CAAC;AAAA,IAC5C;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAKA,eAAsB,kBACpB,YACA,MAC8B;AAC9B,QAAM,aAAa,MAAM,iBAAiB,YAAY,EAAC,KAAK,MAAK,CAAC;AAClE,QAAM,SAAS,MAAM,WAAW,cAAc,IAAI;AAClD,QAAM,WAAW,MAAM;AACvB,SAAO;AACT;","names":["path","path","path","path"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/plugin.ts"],"sourcesContent":["import {PluginOption as VitePlugin} from 'vite';\n\nimport {RootConfig} from './config';\nimport {Server} from './types';\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type ConfigureServerHook = (\n server: Server,\n options: ConfigureServerOptions\n) => MaybePromise<void> | MaybePromise<() => void>;\n\nexport interface ConfigureServerOptions {\n type: 'dev' | 'preview' | 'prod';\n rootConfig: RootConfig;\n}\n\nexport interface Plugin {\n [key: string]: any;\n /** The name of the plugin. */\n name?: string;\n /**\n * Configures the root.js express server. Any middleware defined by the plugin\n * will be added to the server first. If a callback fn is returned, it will\n * be called after the root.js middlewares are added.\n */\n configureServer?: ConfigureServerHook;\n /**\n * Returns a list of deps to bundle for ssr. The files will be bundled and\n * output to `dist/server/`. The return value should be a map of\n * `{output filename => input filepath}`.\n *\n * E.g. a value of `{foo: 'path/to/bar.js'}` will output `dist/server/foo.js`.\n *\n * @experimental This config is subject to change to be incorporated into a\n * broader config option called \"ssr\" or \"ssrOptions\".\n */\n ssrInput?: () => {[entryAlias: string]: string};\n /** Adds vite plugins. */\n vitePlugins?: VitePlugin[];\n}\n\n/**\n * Runs the pre-hook configureServer method of every plugin, calls a callback\n * function, and then runs the configureServer's post-hook if provided. Plugins\n * provide a post-hook by returning a callback function from configureServer.\n */\nexport async function configureServerPlugins(\n server: Server,\n callback: () => Promise<void>,\n plugins: Plugin[],\n options: ConfigureServerOptions\n) {\n const postHooks: Array<() => void> = [];\n\n // Call the `configureServer()` method for each plugin.\n for (const plugin of plugins) {\n if (plugin.configureServer) {\n const postHook = await plugin.configureServer(server, options);\n if (postHook) {\n postHooks.push(postHook);\n }\n }\n }\n\n // Register any built-in middleware.\n callback();\n\n // Run any post hooks returned by `plugin.configureServer()`.\n for (const postHook of postHooks) {\n await postHook();\n }\n}\n\nexport function getVitePlugins(plugins: Plugin[]): VitePlugin[] {\n const vitePlugins: VitePlugin[] = [];\n for (const plugin of plugins) {\n if (plugin.vitePlugins) {\n vitePlugins.push(...plugin.vitePlugins);\n }\n }\n return vitePlugins;\n}\n"],"mappings":";AA+CA,eAAsB,uBACpB,QACA,UACA,SACA,SACA;AACA,QAAM,YAA+B,CAAC;AAGtC,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,iBAAiB;AAC1B,YAAM,WAAW,MAAM,OAAO,gBAAgB,QAAQ,OAAO;AAC7D,UAAI,UAAU;AACZ,kBAAU,KAAK,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAGA,WAAS;AAGT,aAAW,YAAY,WAAW;AAChC,UAAM,SAAS;AAAA,EACjB;AACF;AAEO,SAAS,eAAe,SAAiC;AAC9D,QAAM,cAA4B,CAAC;AACnC,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,aAAa;AACtB,kBAAY,KAAK,GAAG,OAAO,WAAW;AAAA,IACxC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/components/Html.tsx","../src/core/hooks/useI18nContext.ts","../src/core/hooks/useRequestContext.ts"],"sourcesContent":["import {ComponentChildren, FunctionalComponent, createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport interface HtmlContext {\n htmlAttrs: preact.JSX.HTMLAttributes<HTMLHtmlElement>;\n headAttrs: preact.JSX.HTMLAttributes<HTMLHeadElement>;\n headComponents: ComponentChildren[];\n bodyAttrs: preact.JSX.HTMLAttributes<HTMLBodyElement>;\n scriptDeps: Array<preact.JSX.HTMLAttributes<HTMLScriptElement>>;\n}\n\nexport const HTML_CONTEXT = createContext<HtmlContext | null>(null);\n\nexport type HtmlProps = preact.JSX.HTMLAttributes<HTMLHtmlElement> & {\n children?: ComponentChildren;\n};\n\n/**\n * The `<Html>` component can be used to update attrs in the `<html>` tag.\n *\n * Usage:\n *\n * ```tsx\n * <Html lang=\"en-US\">\n * <h1>Hello world</h1>\n * </Html>\n * ```\n */\nexport const Html: FunctionalComponent<HtmlProps> = ({children, ...attrs}) => {\n const context = useContext(HTML_CONTEXT);\n if (!context) {\n throw new Error(\n 'HTML_CONTEXT not found, double-check usage of the <Html> component'\n );\n }\n context.htmlAttrs = attrs;\n return <>{children}</>;\n};\n","import path from 'node:path';\n\nimport {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport const I18N_CONTEXT = createContext<I18nContext | null>(null);\n\nexport interface I18nContext {\n locale: string;\n translations: Record<string, string>;\n}\n\n/**\n * A hook that returns information about the current i18n context, including the\n * locale for the given route and a map of translations for that locale.\n */\nexport function useI18nContext() {\n const context = useContext(I18N_CONTEXT);\n if (!context) {\n throw new Error('I18N_CONTEXT not found');\n }\n return context;\n}\n\nexport function getTranslations(locale: string): Record<string, string> {\n const translations: Record<string, Record<string, string>> = {};\n const translationsFiles = import.meta.glob(['/translations/*.json'], {\n eager: true,\n }) as Record<string, {default?: Record<string, string>}>;\n Object.keys(translationsFiles).forEach((translationPath) => {\n const parts = path.parse(translationPath);\n const locale = parts.name;\n const module = translationsFiles[translationPath];\n if (module && module.default) {\n translations[locale] = module.default;\n }\n });\n return translations[locale] || {};\n}\n","import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nimport {Route} from '../types';\n\nexport interface RequestContext {\n /** The route file. */\n route: Route;\n /**\n * Route param values. E.g. for a route like `routes/blog/[slug].tsx`,\n * visiting `/blog/foo` will pass {slug: 'foo'} here.\n */\n routeParams: Record<string, string>;\n /** Props passed to the route's server component. */\n props: any;\n /** The current locale. */\n locale: string;\n /** Translations map for the current locale. */\n translations: Record<string, string>;\n}\n\nexport const REQUEST_CONTEXT = createContext<RequestContext | null>(null);\n\n/**\n * A hook that returns information about the current route.\n *\n * Usage:\n *\n * ```ts\n * const ctx = useRequestContext();\n * ctx.route.src;\n * // => 'routes/index.tsx'\n * ```\n */\nexport function useRequestContext() {\n const context = useContext(REQUEST_CONTEXT);\n if (!context) {\n throw new Error('REQUEST_CONTEXT not found');\n }\n return context;\n}\n"],"mappings":";AAAA,SAAgD,qBAAoB;AACpE,SAAQ,kBAAiB;AAmChB;AAzBF,IAAM,eAAe,cAAkC,IAAI;AAiB3D,IAAM,OAAuC,CAAC,EAAC,aAAa,MAAK,MAAM;AAC5E,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,UAAQ,YAAY;AACpB,SAAO;AAAA,IAAG;AAAA,GAAS;AACrB;;;ACrCA,OAAO,UAAU;AAEjB,SAAQ,iBAAAA,sBAAoB;AAC5B,SAAQ,cAAAC,mBAAiB;AAElB,IAAM,eAAeD,eAAkC,IAAI;AAW3D,SAAS,iBAAiB;AAC/B,QAAM,UAAUC,YAAW,YAAY;AACvC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,wBAAwB;AAAA,EAC1C;AACA,SAAO;AACT;AAEO,SAAS,gBAAgB,QAAwC;AACtE,QAAM,eAAuD,CAAC;AAC9D,QAAM,oBAAoB,YAAY,KAAK,CAAC,sBAAsB,GAAG;AAAA,IACnE,OAAO;AAAA,EACT,CAAC;AACD,SAAO,KAAK,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB;AAC1D,UAAM,QAAQ,KAAK,MAAM,eAAe;AACxC,UAAMC,UAAS,MAAM;AACrB,UAAM,SAAS,kBAAkB;AACjC,QAAI,UAAU,OAAO,SAAS;AAC5B,mBAAaA,WAAU,OAAO;AAAA,IAChC;AAAA,EACF,CAAC;AACD,SAAO,aAAa,WAAW,CAAC;AAClC;;;ACtCA,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAAC,mBAAiB;AAoBlB,IAAM,kBAAkBD,eAAqC,IAAI;AAajE,SAAS,oBAAoB;AAClC,QAAM,UAAUC,YAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,SAAO;AACT;","names":["createContext","useContext","locale","createContext","useContext"]}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
htmlPretty,
|
|
4
4
|
isValidTagName,
|
|
5
5
|
parseTagNames
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DXD5LKU3.js";
|
|
7
7
|
import {
|
|
8
8
|
copyGlob,
|
|
9
9
|
createViteServer,
|
|
@@ -16,22 +16,119 @@ import {
|
|
|
16
16
|
makeDir,
|
|
17
17
|
rmDir,
|
|
18
18
|
writeFile
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-K72XPY7N.js";
|
|
20
20
|
import {
|
|
21
21
|
configureServerPlugins,
|
|
22
22
|
getVitePlugins
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QKBMWK5B.js";
|
|
24
24
|
|
|
25
25
|
// src/cli/commands/build.ts
|
|
26
26
|
import path3 from "node:path";
|
|
27
27
|
import { fileURLToPath } from "node:url";
|
|
28
28
|
import fsExtra from "fs-extra";
|
|
29
|
+
import { dim, cyan } from "kleur/colors";
|
|
29
30
|
import glob2 from "tiny-glob";
|
|
30
31
|
import { build as viteBuild } from "vite";
|
|
31
32
|
|
|
32
|
-
// src/
|
|
33
|
+
// src/node/element-graph.ts
|
|
33
34
|
import fs from "node:fs";
|
|
34
35
|
import path from "node:path";
|
|
36
|
+
import glob from "tiny-glob";
|
|
37
|
+
import { searchForWorkspaceRoot } from "vite";
|
|
38
|
+
var ElementGraph = class {
|
|
39
|
+
constructor(sourceFiles) {
|
|
40
|
+
this.sourceFiles = {};
|
|
41
|
+
this.deps = {};
|
|
42
|
+
this.sourceFiles = sourceFiles;
|
|
43
|
+
}
|
|
44
|
+
toJson() {
|
|
45
|
+
for (const tagName in this.sourceFiles) {
|
|
46
|
+
this.deps[tagName] ??= this.parseDepsFromSource(tagName);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
sourceFiles: this.sourceFiles,
|
|
50
|
+
deps: this.deps
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static fromJson(data) {
|
|
54
|
+
const graph = new ElementGraph(data.sourceFiles);
|
|
55
|
+
graph.deps = data.deps;
|
|
56
|
+
return graph;
|
|
57
|
+
}
|
|
58
|
+
getDeps(tagName, visited) {
|
|
59
|
+
visited ??= /* @__PURE__ */ new Set();
|
|
60
|
+
if (visited.has(tagName)) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
visited.add(tagName);
|
|
64
|
+
this.deps[tagName] ??= this.parseDepsFromSource(tagName);
|
|
65
|
+
const deps = new Set(this.deps[tagName]);
|
|
66
|
+
for (const depTagName of this.deps[tagName]) {
|
|
67
|
+
for (const childDep of this.getDeps(depTagName, visited)) {
|
|
68
|
+
deps.add(childDep);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Array.from(deps);
|
|
72
|
+
}
|
|
73
|
+
parseDepsFromSource(tagName) {
|
|
74
|
+
const srcFile = this.sourceFiles[tagName];
|
|
75
|
+
if (!srcFile) {
|
|
76
|
+
throw new Error(`could not find file path for tagName <${tagName}>`);
|
|
77
|
+
}
|
|
78
|
+
const src = fs.readFileSync(srcFile.filePath, "utf-8");
|
|
79
|
+
const tagNames = parseTagNames(src);
|
|
80
|
+
const deps = /* @__PURE__ */ new Set();
|
|
81
|
+
for (const depTagName of tagNames) {
|
|
82
|
+
if (depTagName !== tagName && depTagName in this.sourceFiles) {
|
|
83
|
+
deps.add(depTagName);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return Array.from(deps);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
async function getElements(rootConfig) {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const rootDir = rootConfig.rootDir;
|
|
92
|
+
const workspaceRoot = searchForWorkspaceRoot(rootDir);
|
|
93
|
+
const elementsDirs = [path.join(rootDir, "elements")];
|
|
94
|
+
const elementsInclude = ((_a = rootConfig.elements) == null ? void 0 : _a.include) || [];
|
|
95
|
+
const excludePatterns = ((_b = rootConfig.elements) == null ? void 0 : _b.exclude) || [];
|
|
96
|
+
const excludeElement = (moduleId) => {
|
|
97
|
+
return excludePatterns.some((pattern) => Boolean(moduleId.match(pattern)));
|
|
98
|
+
};
|
|
99
|
+
for (const dirPath of elementsInclude) {
|
|
100
|
+
const elementsDir = path.resolve(rootDir, dirPath);
|
|
101
|
+
if (!directoryContains(rootDir, elementsDir)) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`the elements dir (${dirPath}) should be within the project's workspace (${workspaceRoot})`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
elementsDirs.push(elementsDir);
|
|
107
|
+
}
|
|
108
|
+
const elementFilePaths = {};
|
|
109
|
+
for (const dirPath of elementsDirs) {
|
|
110
|
+
if (await isDirectory(dirPath)) {
|
|
111
|
+
const files = await glob("**/*", { cwd: dirPath });
|
|
112
|
+
files.forEach((file) => {
|
|
113
|
+
const parts = path.parse(file);
|
|
114
|
+
if (isJsFile(parts.base) && isValidTagName(parts.name)) {
|
|
115
|
+
const tagName = parts.name;
|
|
116
|
+
const filePath = path.join(dirPath, file);
|
|
117
|
+
const relPath = path.relative(rootDir, filePath);
|
|
118
|
+
if (!excludeElement(relPath)) {
|
|
119
|
+
elementFilePaths[tagName] = { filePath, relPath };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const graph = new ElementGraph(elementFilePaths);
|
|
126
|
+
return graph;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/render/asset-map/build-asset-map.ts
|
|
130
|
+
import fs2 from "node:fs";
|
|
131
|
+
import path2 from "node:path";
|
|
35
132
|
var BuildAssetMap = class {
|
|
36
133
|
constructor(rootConfig) {
|
|
37
134
|
this.rootConfig = rootConfig;
|
|
@@ -101,12 +198,12 @@ var BuildAssetMap = class {
|
|
|
101
198
|
}
|
|
102
199
|
};
|
|
103
200
|
function realPathRelativeTo(rootDir, src) {
|
|
104
|
-
const fullPath =
|
|
105
|
-
if (!
|
|
201
|
+
const fullPath = path2.resolve(rootDir, src);
|
|
202
|
+
if (!fs2.existsSync(fullPath)) {
|
|
106
203
|
return src;
|
|
107
204
|
}
|
|
108
|
-
const realpath =
|
|
109
|
-
return
|
|
205
|
+
const realpath = fs2.realpathSync(path2.resolve(rootDir, src));
|
|
206
|
+
return path2.relative(rootDir, realpath);
|
|
110
207
|
}
|
|
111
208
|
var BuildAsset = class {
|
|
112
209
|
constructor(assetMap, assetData) {
|
|
@@ -182,105 +279,6 @@ var BuildAsset = class {
|
|
|
182
279
|
}
|
|
183
280
|
};
|
|
184
281
|
|
|
185
|
-
// src/cli/commands/build.ts
|
|
186
|
-
import { dim, cyan } from "kleur/colors";
|
|
187
|
-
|
|
188
|
-
// src/node/element-graph.ts
|
|
189
|
-
import fs2 from "node:fs";
|
|
190
|
-
import path2 from "node:path";
|
|
191
|
-
import { searchForWorkspaceRoot } from "vite";
|
|
192
|
-
import glob from "tiny-glob";
|
|
193
|
-
var ElementGraph = class {
|
|
194
|
-
constructor(sourceFiles) {
|
|
195
|
-
this.sourceFiles = {};
|
|
196
|
-
this.deps = {};
|
|
197
|
-
this.sourceFiles = sourceFiles;
|
|
198
|
-
}
|
|
199
|
-
toJson() {
|
|
200
|
-
for (const tagName in this.sourceFiles) {
|
|
201
|
-
this.deps[tagName] ??= this.parseDepsFromSource(tagName);
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
sourceFiles: this.sourceFiles,
|
|
205
|
-
deps: this.deps
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
static fromJson(data) {
|
|
209
|
-
const graph = new ElementGraph(data.sourceFiles);
|
|
210
|
-
graph.deps = data.deps;
|
|
211
|
-
return graph;
|
|
212
|
-
}
|
|
213
|
-
getDeps(tagName, visited) {
|
|
214
|
-
visited ??= /* @__PURE__ */ new Set();
|
|
215
|
-
if (visited.has(tagName)) {
|
|
216
|
-
return [];
|
|
217
|
-
}
|
|
218
|
-
visited.add(tagName);
|
|
219
|
-
this.deps[tagName] ??= this.parseDepsFromSource(tagName);
|
|
220
|
-
const deps = new Set(this.deps[tagName]);
|
|
221
|
-
for (const depTagName of this.deps[tagName]) {
|
|
222
|
-
for (const childDep of this.getDeps(depTagName, visited)) {
|
|
223
|
-
deps.add(childDep);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return Array.from(deps);
|
|
227
|
-
}
|
|
228
|
-
parseDepsFromSource(tagName) {
|
|
229
|
-
const srcFile = this.sourceFiles[tagName];
|
|
230
|
-
if (!srcFile) {
|
|
231
|
-
throw new Error(`could not find file path for tagName <${tagName}>`);
|
|
232
|
-
}
|
|
233
|
-
const src = fs2.readFileSync(srcFile.filePath, "utf-8");
|
|
234
|
-
const tagNames = parseTagNames(src);
|
|
235
|
-
const deps = /* @__PURE__ */ new Set();
|
|
236
|
-
for (const depTagName of tagNames) {
|
|
237
|
-
if (depTagName !== tagName && depTagName in this.sourceFiles) {
|
|
238
|
-
deps.add(depTagName);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
return Array.from(deps);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
async function getElements(rootConfig) {
|
|
245
|
-
var _a, _b;
|
|
246
|
-
const rootDir = rootConfig.rootDir;
|
|
247
|
-
const workspaceRoot = searchForWorkspaceRoot(rootDir);
|
|
248
|
-
const elementsDirs = [path2.join(rootDir, "elements")];
|
|
249
|
-
const elementsInclude = ((_a = rootConfig.elements) == null ? void 0 : _a.include) || [];
|
|
250
|
-
const excludePatterns = ((_b = rootConfig.elements) == null ? void 0 : _b.exclude) || [];
|
|
251
|
-
const excludeElement = (moduleId) => {
|
|
252
|
-
return excludePatterns.some((pattern) => Boolean(moduleId.match(pattern)));
|
|
253
|
-
};
|
|
254
|
-
for (const dirPath of elementsInclude) {
|
|
255
|
-
const elementsDir = path2.resolve(rootDir, dirPath);
|
|
256
|
-
if (!directoryContains(rootDir, elementsDir)) {
|
|
257
|
-
throw new Error(
|
|
258
|
-
`the elements dir (${dirPath}) should be within the project's workspace (${workspaceRoot})`
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
elementsDirs.push(elementsDir);
|
|
262
|
-
}
|
|
263
|
-
const elementFilePaths = {};
|
|
264
|
-
for (const dirPath of elementsDirs) {
|
|
265
|
-
if (await isDirectory(dirPath)) {
|
|
266
|
-
const files = await glob("**/*", { cwd: dirPath });
|
|
267
|
-
files.forEach((file) => {
|
|
268
|
-
const parts = path2.parse(file);
|
|
269
|
-
if (isJsFile(parts.base) && isValidTagName(parts.name)) {
|
|
270
|
-
const tagName = parts.name;
|
|
271
|
-
const filePath = path2.join(dirPath, file);
|
|
272
|
-
const relPath = path2.relative(rootDir, filePath);
|
|
273
|
-
if (!excludeElement(relPath)) {
|
|
274
|
-
elementFilePaths[tagName] = { filePath, relPath };
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const graph = new ElementGraph(elementFilePaths);
|
|
281
|
-
return graph;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
282
|
// src/cli/commands/build.ts
|
|
285
283
|
var __dirname = path3.dirname(fileURLToPath(import.meta.url));
|
|
286
284
|
async function build(rootProjectDir, options) {
|
|
@@ -586,6 +584,16 @@ function printFileOutput(fileSize2, outputDir, outputFile) {
|
|
|
586
584
|
import path5 from "node:path";
|
|
587
585
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
588
586
|
import { default as express } from "express";
|
|
587
|
+
import { dim as dim2 } from "kleur/colors";
|
|
588
|
+
import glob3 from "tiny-glob";
|
|
589
|
+
|
|
590
|
+
// src/core/middleware.ts
|
|
591
|
+
function rootProjectMiddleware(options) {
|
|
592
|
+
return (req, _, next) => {
|
|
593
|
+
req.rootConfig = options.rootConfig;
|
|
594
|
+
next();
|
|
595
|
+
};
|
|
596
|
+
}
|
|
589
597
|
|
|
590
598
|
// src/render/asset-map/dev-asset-map.ts
|
|
591
599
|
import path4 from "node:path";
|
|
@@ -710,17 +718,6 @@ var DevServerAsset = class {
|
|
|
710
718
|
}
|
|
711
719
|
};
|
|
712
720
|
|
|
713
|
-
// src/cli/commands/dev.ts
|
|
714
|
-
import { dim as dim2 } from "kleur/colors";
|
|
715
|
-
|
|
716
|
-
// src/core/middleware.ts
|
|
717
|
-
function rootProjectMiddleware(options) {
|
|
718
|
-
return (req, _, next) => {
|
|
719
|
-
req.rootConfig = options.rootConfig;
|
|
720
|
-
next();
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
|
|
724
721
|
// src/utils/ports.ts
|
|
725
722
|
import { createServer } from "node:net";
|
|
726
723
|
function isPortOpen(port) {
|
|
@@ -759,7 +756,6 @@ async function findOpenPort(min, max) {
|
|
|
759
756
|
}
|
|
760
757
|
|
|
761
758
|
// src/cli/commands/dev.ts
|
|
762
|
-
import glob3 from "tiny-glob";
|
|
763
759
|
var __dirname2 = path5.dirname(fileURLToPath2(import.meta.url));
|
|
764
760
|
async function dev(rootProjectDir, options) {
|
|
765
761
|
process.env.NODE_ENV = "development";
|
|
@@ -891,10 +887,10 @@ function rootDevServer500Middleware() {
|
|
|
891
887
|
|
|
892
888
|
// src/cli/commands/preview.ts
|
|
893
889
|
import path6 from "node:path";
|
|
890
|
+
import compression from "compression";
|
|
894
891
|
import { default as express2 } from "express";
|
|
895
892
|
import { dim as dim3 } from "kleur/colors";
|
|
896
893
|
import sirv from "sirv";
|
|
897
|
-
import compression from "compression";
|
|
898
894
|
async function preview(rootProjectDir, options) {
|
|
899
895
|
process.env.NODE_ENV = "development";
|
|
900
896
|
const rootDir = path6.resolve(rootProjectDir || process.cwd());
|
|
@@ -1018,10 +1014,10 @@ function rootPreviewServer500Middleware() {
|
|
|
1018
1014
|
|
|
1019
1015
|
// src/cli/commands/start.ts
|
|
1020
1016
|
import path7 from "node:path";
|
|
1017
|
+
import compression2 from "compression";
|
|
1021
1018
|
import { default as express3 } from "express";
|
|
1022
1019
|
import { dim as dim4 } from "kleur/colors";
|
|
1023
1020
|
import sirv2 from "sirv";
|
|
1024
|
-
import compression2 from "compression";
|
|
1025
1021
|
async function start(rootProjectDir, options) {
|
|
1026
1022
|
process.env.NODE_ENV = "production";
|
|
1027
1023
|
const rootDir = path7.resolve(rootProjectDir || process.cwd());
|