@blinkk/root 3.0.1-alpha.0 → 3.0.1-alpha.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.
- package/dist/chunk-PVBPP5LN.js +854 -0
- package/dist/chunk-PVBPP5LN.js.map +1 -0
- package/dist/{chunk-G7OKXRD3.js → chunk-RRJ3JKJD.js} +40 -13
- package/dist/chunk-RRJ3JKJD.js.map +1 -0
- package/dist/{chunk-6FDF3DXT.js → chunk-XSNCF7WU.js} +1 -1
- package/dist/chunk-XSNCF7WU.js.map +1 -0
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +3 -3
- package/dist/core.d.ts +4 -4
- package/dist/core.js +7 -1
- package/dist/core.js.map +1 -1
- package/dist/functions.js +3 -3
- package/dist/middleware.d.ts +4 -4
- package/dist/node.d.ts +36 -4
- package/dist/node.js +6 -2
- package/dist/render.d.ts +3 -3
- package/dist/render.js +42 -7
- package/dist/render.js.map +1 -1
- package/dist/{types-BstdV3Rj.d.ts → types-Cksf99CK.d.ts} +71 -2
- package/package.json +1 -1
- package/dist/chunk-6FDF3DXT.js.map +0 -1
- package/dist/chunk-EBE4O463.js +0 -417
- package/dist/chunk-EBE4O463.js.map +0 -1
- package/dist/chunk-G7OKXRD3.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/monorepo.ts","../src/utils/fsutils.ts","../src/node/load-config.ts","../src/node/pod-collector.ts","../src/node/vite.ts","../src/node/pods-vite-plugin.ts","../src/node/vite-plugin-root-jsx-virtual.ts"],"sourcesContent":["import path from 'node:path';\nimport {getWorkspaces, getWorkspaceRoot, PackageInfo} from 'workspace-tools';\nimport {fileExistsSync, loadJsonSync} from '../utils/fsutils.js';\n\ninterface WorkspacePackage {\n name: string;\n path: string;\n packageJson: PackageInfo;\n}\n\nexport function loadPackageJson(filepath: string): PackageInfo | null {\n if (!fileExistsSync(filepath)) {\n return null;\n }\n return loadJsonSync(filepath);\n}\n\n/**\n * Returns a map of all packages in the monorepo and the corresponding\n * package.json path.\n */\nfunction getMonorepoPackages(\n rootDir: string\n): Record<string, WorkspacePackage> {\n const monorepoRoot = getWorkspaceRoot(rootDir);\n if (!monorepoRoot) {\n return {};\n }\n\n const workspaces = getWorkspaces(monorepoRoot);\n const packages: Record<string, WorkspacePackage> = {};\n workspaces.forEach((workspaceInfo) => {\n packages[workspaceInfo.name] = workspaceInfo;\n });\n return packages;\n}\n\n/**\n * Returns the top-level monorepo package's deps, if any.\n */\nexport function getMonorepoPackageDeps(\n rootDir: string\n): Record<string, string> {\n const monorepoRoot = getWorkspaceRoot(rootDir);\n if (!monorepoRoot) {\n return {};\n }\n\n const packageJsonPath = path.join(monorepoRoot, 'package.json');\n const packageJson = loadPackageJson(packageJsonPath);\n return packageJson?.dependencies || {};\n}\n\n/**\n * Flattens package.json deps from the root project dir, taking into account any\n * deps from the monorepo root as well as any `workspace:` deps from within the\n * monorepo.\n */\nexport function flattenPackageDepsFromMonorepo(\n rootDir: string,\n options?: {ignore?: Set<string>}\n): Record<string, string> {\n const packageJsonPath = path.resolve(rootDir, 'package.json');\n const packageJson = loadPackageJson(packageJsonPath);\n const monorepoDeps = getMonorepoPackageDeps(rootDir);\n\n // Flatten `peerDependencies` and `dependencies`.\n const projectDeps = {\n ...packageJson?.peerDependencies,\n ...packageJson?.dependencies,\n };\n\n const allDeps: Record<string, string> = {};\n const workspacePackages = getMonorepoPackages(rootDir);\n const ignore = options?.ignore || new Set();\n Object.entries(projectDeps).forEach(([depName, depVersion]) => {\n if (\n depName.startsWith('@blinkk/root') &&\n depVersion.startsWith('workspace:')\n ) {\n const packageInfo = workspacePackages[depName];\n if (packageInfo) {\n allDeps[depName] = packageInfo.packageJson.version;\n }\n } else if (depVersion.startsWith('workspace:')) {\n // For internal packages within the workspace, recursively collect the\n // deps from those packages.\n if (ignore.has(depName)) {\n return;\n }\n ignore.add(depName);\n const packageInfo = workspacePackages[depName];\n if (packageInfo) {\n const workspacePackageDir = packageInfo.path;\n const deps = flattenPackageDepsFromMonorepo(workspacePackageDir, {\n ignore: ignore,\n });\n for (const key in deps) {\n const currentValue = allDeps[key];\n if (\n deps[key] &&\n deps[key] !== '*' &&\n (!currentValue || currentValue === '*')\n ) {\n allDeps[key] = deps[key];\n }\n }\n }\n } else if (depVersion === '*' && monorepoDeps[depName]) {\n // For any dependencies using a wildcard version `*`, if the top-level\n // package.json has the depdenency defined, overwrite the version.\n allDeps[depName] = monorepoDeps[depName];\n } else {\n allDeps[depName] = depVersion;\n }\n });\n return sortDeps(allDeps);\n}\n\nfunction sortDeps(deps: Record<string, string>): Record<string, string> {\n const keys = Object.keys(deps).sort();\n const sortedDeps: Record<string, string> = {};\n for (const key of keys) {\n sortedDeps[key] = deps[key];\n }\n return sortedDeps;\n}\n","import 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.promises.writeFile(filepath, content);\n}\n\nexport async function makeDir(dirpath: string) {\n try {\n await fs.promises.access(dirpath);\n } catch (e) {\n await fs.promises.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, {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.promises.rm(dirpath, {recursive: true, force: true});\n}\n\nexport async function loadJson<T = unknown>(filepath: string): Promise<T> {\n const content = await fs.promises.readFile(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport function loadJsonSync<T = unknown>(filepath: string): T {\n const content = fs.readFileSync(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function writeJson(filepath: string, data: any) {\n const content = JSON.stringify(data, null, 2);\n await writeFile(filepath, content);\n}\n\nexport async function isDirectory(dirpath: string) {\n return fs.promises\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.promises\n .access(filepath)\n .then(() => true)\n .catch(() => false);\n}\n\nexport function fileExistsSync(filepath: string): boolean {\n try {\n fs.accessSync(filepath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function dirExists(dirpath: string): Promise<boolean> {\n try {\n const stat = await fs.promises.stat(dirpath);\n return stat.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n return false;\n }\n throw error;\n }\n}\n\nexport async function directoryContains(\n dirpath: string,\n subpath: string\n): Promise<boolean> {\n const outer = await fs.promises.realpath(dirpath);\n const inner = await fs.promises.realpath(subpath);\n const rel = path.relative(outer, inner);\n return !rel.startsWith('..');\n}\n\nexport async function listFilesRecursive(dirPath: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await fs.promises.readdir(dirPath, {withFileTypes: true});\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n if (entry.isDirectory()) {\n const subFiles = await listFilesRecursive(fullPath);\n files.push(...subFiles);\n } else {\n files.push(fullPath);\n }\n }\n return files;\n}\n","import path from 'node:path';\nimport {bundleRequire} from 'bundle-require';\nimport {build, Plugin as EsbuildPlugin} from 'esbuild';\nimport {RootConfig} from '../core/config.js';\nimport {fileExists} from '../utils/fsutils.js';\nimport {flattenPackageDepsFromMonorepo} from './monorepo.js';\n\nexport interface ConfigOptions {\n command: string;\n}\n\nexport async function loadRootConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const {rootConfig} = await loadRootConfigWithDeps(rootDir, options);\n return rootConfig;\n}\n\nexport async function loadRootConfigWithDeps(\n rootDir: string,\n options: ConfigOptions\n): Promise<{rootConfig: RootConfig; dependencies: string[]}> {\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 esbuildOptions: {plugins: [esbuildExternalsPlugin({rootDir})]},\n });\n let config = configBundle.mod.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n const rootConfig = Object.assign({}, config, {rootDir});\n validateRootconfig(rootConfig);\n return {rootConfig, dependencies: configBundle.dependencies};\n}\n\nfunction validateRootconfig(rootConfig: RootConfig) {\n // Update vite legacy config options.\n const scss: any = rootConfig.vite?.css?.preprocessorOptions?.scss;\n if (scss?.includePaths) {\n console.warn(\n '[deprecation warning] root.config.ts: vite.css.preprocessorOptions.scss.includePaths is deprecated. rename \"includePaths\" -> \"loadPaths\"'\n );\n scss.loadPaths = scss.includePaths;\n }\n}\n\n/**\n * Compiles a root.config.ts file to root.config.js.\n */\nexport async function bundleRootConfig(rootDir: string, outPath: string) {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const configExists = await fileExists(configPath);\n if (!configExists) {\n throw new Error(`${configPath} does not exist`);\n }\n await build({\n entryPoints: [configPath],\n bundle: true,\n minify: true,\n platform: 'node',\n outfile: outPath,\n sourcemap: 'inline',\n metafile: true,\n format: 'esm',\n plugins: [esbuildExternalsPlugin({rootDir})],\n });\n}\n\n/**\n * Loads a pre-bundled config file from dist/root.config.js.\n */\nexport async function loadBundledConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const configPath = path.resolve(rootDir, 'dist/root.config.js');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const module = await import(configPath);\n let config = module.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n return Object.assign({}, config, {rootDir});\n}\n\n/**\n * Externalizes node_modules deps from the package and any dependent packages\n * from the monorepo.\n */\nfunction esbuildExternalsPlugin(options: {rootDir: string}): EsbuildPlugin {\n const rootDir = options.rootDir;\n const allDeps = flattenPackageDepsFromMonorepo(rootDir);\n\n function getPackageName(id: string): string {\n const segments = id.split('/');\n if (segments.length > 1) {\n // Check if package is an org path like `@blinkk/root`.\n if (segments[0].startsWith('@') && segments[0].length > 1) {\n return `${segments[0]}/${segments[1]}`;\n }\n // For imports like `my-package/subpackage`, return `my-package`.\n return segments[0];\n }\n return id;\n }\n\n return {\n name: 'root-externals-plugin',\n setup(build) {\n build.onResolve({filter: /.*/}, (args) => {\n const id = args.path;\n if (id[0] !== '.' && !id.startsWith('@/')) {\n const packageName = getPackageName(id);\n if (packageName in allDeps) {\n return {\n external: true,\n };\n }\n }\n return null;\n });\n },\n };\n}\n","import path from 'node:path';\nimport glob from 'tiny-glob';\nimport {RootConfig} from '../core/config.js';\nimport {Pod, PodConfig} from '../core/pod.js';\nimport {Plugin} from '../core/plugin.js';\nimport {isDirectory, isJsFile} from '../utils/fsutils.js';\n\nexport interface ResolvedPodRoute {\n filePath: string;\n relPath: string;\n routePath: string;\n}\n\nexport interface ResolvedPodCollection {\n filePath: string;\n relPath: string;\n id: string;\n}\n\nexport interface ResolvedPod {\n name: string;\n enabled: boolean;\n mount: string;\n priority: number;\n routesDir?: string;\n elementsDirs: string[];\n bundlesDir?: string;\n collectionsDir?: string;\n translationsDir?: string;\n routeFiles: ResolvedPodRoute[];\n bundleFiles: string[];\n collectionFiles: ResolvedPodCollection[];\n translationFiles: Array<{locale: string; filePath: string}>;\n config: PodConfig;\n}\n\nlet cachedPods: ResolvedPod[] | null = null;\n\nexport function invalidatePodCache() {\n cachedPods = null;\n}\n\nexport async function collectPods(rootConfig: RootConfig): Promise<ResolvedPod[]> {\n if (cachedPods) {\n return cachedPods;\n }\n\n const plugins = rootConfig.plugins || [];\n const userPodConfigs = rootConfig.pods || {};\n\n const rawPods = await resolvePluginPods(plugins, rootConfig);\n const resolved: ResolvedPod[] = [];\n\n const seenNames = new Set<string>();\n for (const pod of rawPods) {\n if (seenNames.has(pod.name)) {\n throw new Error(\n `Duplicate pod name: \"${pod.name}\". Each pod must have a unique name.`\n );\n }\n seenNames.add(pod.name);\n\n const userConfig = userPodConfigs[pod.name] || {};\n if (userConfig.enabled === false) {\n continue;\n }\n\n const resolvedPod = await resolvePod(pod, userConfig, rootConfig);\n resolved.push(resolvedPod);\n }\n\n validateCollectionIds(resolved, rootConfig);\n\n cachedPods = resolved;\n return resolved;\n}\n\nasync function resolvePluginPods(\n plugins: Plugin[],\n rootConfig: RootConfig\n): Promise<Pod[]> {\n const pods: Pod[] = [];\n for (const plugin of plugins) {\n if (!plugin.pod) {\n continue;\n }\n if (typeof plugin.pod === 'function') {\n const result = await plugin.pod({rootConfig});\n pods.push(result);\n } else if (Array.isArray(plugin.pod)) {\n pods.push(...plugin.pod);\n } else {\n pods.push(plugin.pod);\n }\n }\n return pods;\n}\n\nasync function resolvePod(\n pod: Pod,\n userConfig: PodConfig,\n rootConfig: RootConfig\n): Promise<ResolvedPod> {\n const mount = normalizeMountPath(userConfig.mount ?? pod.mount ?? '/');\n const priority = userConfig.priority ?? pod.priority ?? 0;\n\n const routeFiles = pod.routesDir\n ? await scanRouteFiles(pod.routesDir, mount, userConfig, rootConfig)\n : [];\n\n const bundleFiles = pod.bundlesDir\n ? await scanBundleFiles(pod.bundlesDir)\n : [];\n\n const collectionFiles = pod.collectionsDir\n ? await scanCollectionFiles(pod.collectionsDir, userConfig)\n : [];\n\n const translationFiles = pod.translationsDir\n ? await scanTranslationFiles(pod.translationsDir)\n : [];\n\n return {\n name: pod.name,\n enabled: true,\n mount,\n priority,\n routesDir: pod.routesDir,\n elementsDirs: pod.elementsDirs || [],\n bundlesDir: pod.bundlesDir,\n collectionsDir: pod.collectionsDir,\n translationsDir: pod.translationsDir,\n routeFiles,\n bundleFiles,\n collectionFiles,\n translationFiles,\n config: userConfig,\n };\n}\n\nasync function scanRouteFiles(\n routesDir: string,\n mount: string,\n userConfig: PodConfig,\n rootConfig: RootConfig\n): Promise<ResolvedPodRoute[]> {\n if (!(await isDirectory(routesDir))) {\n return [];\n }\n\n const files = await glob('**/*', {cwd: routesDir});\n const routes: ResolvedPodRoute[] = [];\n const excludePatterns = userConfig.routes?.exclude || [];\n\n for (const file of files) {\n const parts = path.parse(file);\n if (parts.name.startsWith('_') || !isJsFile(parts.base)) {\n continue;\n }\n\n if (shouldExclude(file, excludePatterns)) {\n continue;\n }\n\n const filePath = path.join(routesDir, file);\n let relativeRoutePath = '/' + file.replace(/\\\\/g, '/');\n const routeParts = path.parse(relativeRoutePath);\n if (routeParts.name === 'index') {\n relativeRoutePath = routeParts.dir;\n } else {\n relativeRoutePath = path.join(routeParts.dir, routeParts.name);\n }\n relativeRoutePath = relativeRoutePath.replace(/\\\\/g, '/');\n\n const routePath = normalizeRoutePath(mount, relativeRoutePath, rootConfig);\n\n routes.push({filePath, relPath: file, routePath});\n }\n\n return routes;\n}\n\nasync function scanBundleFiles(bundlesDir: string): Promise<string[]> {\n if (!(await isDirectory(bundlesDir))) {\n return [];\n }\n const files = await glob('*', {cwd: bundlesDir});\n return files\n .filter((file) => isJsFile(path.parse(file).base))\n .map((file) => path.join(bundlesDir, file));\n}\n\nasync function scanCollectionFiles(\n collectionsDir: string,\n userConfig: PodConfig\n): Promise<ResolvedPodCollection[]> {\n if (!(await isDirectory(collectionsDir))) {\n return [];\n }\n const files = await glob('**/*.schema.ts', {cwd: collectionsDir});\n const excludeIds = new Set(userConfig.collections?.exclude || []);\n const renameMap = userConfig.collections?.rename || {};\n const collections: ResolvedPodCollection[] = [];\n\n for (const file of files) {\n const parts = path.parse(file);\n const rawId = parts.name.replace('.schema', '');\n if (excludeIds.has(rawId)) {\n continue;\n }\n const id = renameMap[rawId] || rawId;\n collections.push({\n filePath: path.join(collectionsDir, file),\n relPath: file,\n id,\n });\n }\n\n return collections;\n}\n\nasync function scanTranslationFiles(\n translationsDir: string\n): Promise<Array<{locale: string; filePath: string}>> {\n if (!(await isDirectory(translationsDir))) {\n return [];\n }\n const files = await glob('*.json', {cwd: translationsDir});\n return files.map((file) => ({\n locale: path.parse(file).name,\n filePath: path.join(translationsDir, file),\n }));\n}\n\nfunction validateCollectionIds(\n pods: ResolvedPod[],\n rootConfig: RootConfig\n) {\n const seenIds = new Map<string, string>();\n\n for (const pod of pods) {\n for (const col of pod.collectionFiles) {\n const existing = seenIds.get(col.id);\n if (existing) {\n throw new Error(\n `Collection \"${col.id}\" is defined by both \"${existing}\" and ` +\n `\"${pod.name}\". Use rootConfig.pods['${pod.name}'].collections.rename ` +\n `to disambiguate.`\n );\n }\n seenIds.set(col.id, pod.name);\n }\n }\n}\n\nfunction normalizeMountPath(mount: string): string {\n if (!mount.startsWith('/')) {\n mount = '/' + mount;\n }\n if (mount.endsWith('/') && mount.length > 1) {\n mount = mount.slice(0, -1);\n }\n return mount;\n}\n\nfunction normalizeRoutePath(\n mount: string,\n relativeRoutePath: string,\n rootConfig: RootConfig\n): string {\n const basePath = rootConfig.base || '/';\n let fullPath: string;\n if (mount === '/') {\n fullPath = relativeRoutePath || '/';\n } else {\n fullPath = mount + (relativeRoutePath || '');\n }\n\n if (basePath !== '/') {\n const base = basePath.replace(/^\\/|\\/$/g, '');\n fullPath = `/${base}${fullPath}`;\n }\n\n // Collapse multiple slashes.\n fullPath = fullPath.replace(/\\/+/g, '/');\n if (!fullPath.startsWith('/')) {\n fullPath = '/' + fullPath;\n }\n return fullPath || '/';\n}\n\nfunction shouldExclude(\n filePath: string,\n patterns: (string | RegExp)[]\n): boolean {\n for (const pattern of patterns) {\n if (typeof pattern === 'string') {\n if (filePath.includes(pattern)) {\n return true;\n }\n } else {\n if (pattern.test(filePath)) {\n return true;\n }\n }\n }\n return false;\n}\n","import {createServer, ViteDevServer} from 'vite';\nimport type {Plugin, EnvironmentModuleNode} from 'vite';\nimport {RootConfig} from '../core/config.js';\nimport {getVitePlugins} from '../core/plugin.js';\nimport {rootPodsVitePlugin} from './pods-vite-plugin.js';\nimport {preactToRootJsxPlugin} from './vite-plugin-root-jsx-virtual.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 is disabled from the vite dev server since it's handled by the\n // root dev server directly, which allows user middlewares to override\n // files in the public dir.\n publicDir: false,\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 extensions: [...(viteConfig.optimizeDeps?.extensions || []), '.tsx'],\n },\n ssr: {\n ...(viteConfig.ssr || {}),\n noExternal: ['@blinkk/root', '@blinkk/root-cms/richtext', /^virtual:/],\n },\n plugins: [\n rootPodsVitePlugin(rootConfig),\n hmrSSRReload(),\n preactToRootJsxPlugin({useRootJsx: !!rootConfig.jsxRenderer?.mode}),\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<T = Record<string, any>>(\n rootConfig: RootConfig,\n file: string\n): Promise<T> {\n const viteServer = await createViteServer(rootConfig, {hmr: false});\n const module = await viteServer.ssrLoadModule(file);\n await viteServer.close();\n return module as T;\n}\n\n/**\n * Vite plugin to reload the page when SSR modules change.\n * https://github.com/vitejs/vite/issues/19114\n */\nfunction hmrSSRReload(): Plugin {\n return {\n name: 'hmr-ssr-reload',\n enforce: 'post',\n hotUpdate: {\n order: 'post',\n handler({modules, server, timestamp}) {\n if (this.environment.name !== 'ssr') {\n return;\n }\n\n let hasSsrOnlyModules = false;\n const invalidatedModules = new Set<EnvironmentModuleNode>();\n for (const mod of modules) {\n if (mod.id === null) {\n continue;\n }\n const clientModule =\n server.environments.client.moduleGraph.getModuleById(mod.id);\n if (clientModule) {\n continue;\n }\n\n hasSsrOnlyModules = true;\n this.environment.moduleGraph.invalidateModule(\n mod,\n invalidatedModules,\n timestamp,\n true\n );\n }\n\n if (hasSsrOnlyModules) {\n server.ws.send({type: 'full-reload'});\n return [];\n }\n\n return;\n },\n },\n };\n}\n","import path from 'node:path';\nimport type {Plugin as VitePlugin} from 'vite';\nimport glob from 'tiny-glob';\nimport {RootConfig} from '../core/config.js';\nimport {isDirectory, isJsFile} from '../utils/fsutils.js';\nimport {collectPods, invalidatePodCache, ResolvedPod} from './pod-collector.js';\n\nexport const VIRTUAL_ROUTES_ID = 'virtual:root/routes';\nexport const VIRTUAL_SCHEMAS_ID = 'virtual:root/schemas';\nexport const VIRTUAL_TRANSLATIONS_ID = 'virtual:root/translations';\n\nconst RESOLVED_VIRTUAL_ROUTES = '\\0' + VIRTUAL_ROUTES_ID;\nconst RESOLVED_VIRTUAL_SCHEMAS = '\\0' + VIRTUAL_SCHEMAS_ID;\nconst RESOLVED_VIRTUAL_TRANSLATIONS = '\\0' + VIRTUAL_TRANSLATIONS_ID;\n\nexport function rootPodsVitePlugin(rootConfig: RootConfig): VitePlugin {\n let podsPromise: Promise<ResolvedPod[]> | null = null;\n\n const getPods = () => {\n if (!podsPromise) {\n podsPromise = collectPods(rootConfig);\n }\n return podsPromise;\n };\n\n return {\n name: 'root:pods',\n enforce: 'pre',\n\n resolveId(id) {\n if (id === VIRTUAL_ROUTES_ID) return RESOLVED_VIRTUAL_ROUTES;\n if (id === VIRTUAL_SCHEMAS_ID) return RESOLVED_VIRTUAL_SCHEMAS;\n if (id === VIRTUAL_TRANSLATIONS_ID) return RESOLVED_VIRTUAL_TRANSLATIONS;\n return null;\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_ROUTES) {\n return buildRoutesModule(rootConfig, await getPods());\n }\n if (id === RESOLVED_VIRTUAL_SCHEMAS) {\n return buildSchemasModule(rootConfig, await getPods());\n }\n if (id === RESOLVED_VIRTUAL_TRANSLATIONS) {\n return buildTranslationsModule(rootConfig, await getPods());\n }\n return null;\n },\n\n configureServer(server) {\n const watchDirs: string[] = [];\n getPods().then((pods) => {\n for (const pod of pods) {\n if (pod.routesDir) watchDirs.push(pod.routesDir);\n if (pod.collectionsDir) watchDirs.push(pod.collectionsDir);\n if (pod.translationsDir) watchDirs.push(pod.translationsDir);\n if (pod.bundlesDir) watchDirs.push(pod.bundlesDir);\n for (const dir of pod.elementsDirs) {\n watchDirs.push(dir);\n }\n }\n for (const dir of watchDirs) {\n server.watcher.add(dir);\n }\n });\n\n const invalidateVirtualModules = () => {\n invalidatePodCache();\n podsPromise = null;\n const mods = [\n RESOLVED_VIRTUAL_ROUTES,\n RESOLVED_VIRTUAL_SCHEMAS,\n RESOLVED_VIRTUAL_TRANSLATIONS,\n ];\n for (const modId of mods) {\n const mod = server.moduleGraph.getModuleById(modId);\n if (mod) {\n server.moduleGraph.invalidateModule(mod);\n }\n }\n server.ws.send({type: 'full-reload'});\n };\n\n server.watcher.on('add', (filePath) => {\n if (isInPodDir(filePath, watchDirs)) {\n invalidateVirtualModules();\n }\n });\n server.watcher.on('unlink', (filePath) => {\n if (isInPodDir(filePath, watchDirs)) {\n invalidateVirtualModules();\n }\n });\n },\n };\n}\n\nfunction isInPodDir(filePath: string, watchDirs: string[]): boolean {\n for (const dir of watchDirs) {\n if (filePath.startsWith(dir)) {\n return true;\n }\n }\n return false;\n}\n\nasync function buildRoutesModule(\n rootConfig: RootConfig,\n pods: ResolvedPod[]\n): Promise<string> {\n const rootDir = rootConfig.rootDir;\n const imports: string[] = [];\n const userEntries: string[] = [];\n const podEntries: string[] = [];\n let idx = 0;\n\n // User project routes.\n const routesDir = path.join(rootDir, 'routes');\n if (await isDirectory(routesDir)) {\n const files = await glob('**/*', {cwd: routesDir});\n for (const file of files) {\n const parts = path.parse(file);\n if (parts.name.startsWith('_') || !isJsFile(parts.base)) {\n continue;\n }\n const modulePath = `/routes/${file.replace(/\\\\/g, '/')}`;\n const varName = `_r${idx++}`;\n imports.push(`import * as ${varName} from '${modulePath}';`);\n userEntries.push(` '${modulePath}': ${varName},`);\n }\n }\n\n // Pod routes.\n for (const pod of pods) {\n for (const route of pod.routeFiles) {\n const varName = `_r${idx++}`;\n imports.push(`import * as ${varName} from '${route.filePath}';`);\n podEntries.push(\n ` '${route.filePath}': {module: ${varName}, podName: ${JSON.stringify(pod.name)}, routePath: ${JSON.stringify(route.routePath)}, src: ${JSON.stringify(`pod/${pod.name}/${route.relPath}`)}},`\n );\n }\n }\n\n return [\n ...imports,\n '',\n 'export const ROUTE_MODULES = {',\n ...userEntries,\n '};',\n '',\n 'export const POD_ROUTE_MODULES = {',\n ...podEntries,\n '};',\n ].join('\\n');\n}\n\nasync function buildSchemasModule(\n rootConfig: RootConfig,\n pods: ResolvedPod[]\n): Promise<string> {\n const rootDir = rootConfig.rootDir;\n const imports: string[] = [];\n const entries: string[] = [];\n let idx = 0;\n\n // User project collections — these win over pod collections.\n const userCollectionIds = new Set<string>();\n const collectionsDir = path.join(rootDir, 'collections');\n if (await isDirectory(collectionsDir)) {\n const files = await glob('**/*.schema.ts', {cwd: collectionsDir});\n for (const file of files) {\n const parts = path.parse(file);\n const id = parts.name.replace('.schema', '');\n userCollectionIds.add(id);\n const modulePath = `/collections/${file.replace(/\\\\/g, '/')}`;\n const varName = `_s${idx++}`;\n imports.push(`import * as ${varName} from '${modulePath}';`);\n entries.push(` '${modulePath}': ${varName},`);\n }\n }\n\n // Also scan root-level schema files that match the existing patterns\n // (e.g. /templates/**/*.schema.ts), excluding known non-collection dirs.\n const rootSchemaFiles = await scanRootSchemaFiles(rootDir);\n for (const file of rootSchemaFiles) {\n const modulePath = `/${file.replace(/\\\\/g, '/')}`;\n // Skip if already in collections.\n if (modulePath.startsWith('/collections/')) continue;\n const varName = `_s${idx++}`;\n imports.push(`import * as ${varName} from '${modulePath}';`);\n entries.push(` '${modulePath}': ${varName},`);\n }\n\n // Pod collections — user project wins on id collision.\n for (const pod of pods) {\n for (const col of pod.collectionFiles) {\n if (userCollectionIds.has(col.id)) {\n continue;\n }\n const varName = `_s${idx++}`;\n imports.push(`import * as ${varName} from '${col.filePath}';`);\n const key = `/collections/${col.id}.schema.ts`;\n entries.push(` '${key}': ${varName},`);\n }\n }\n\n return [\n ...imports,\n '',\n 'export const SCHEMA_MODULES = {',\n ...entries,\n '};',\n ].join('\\n');\n}\n\nasync function scanRootSchemaFiles(rootDir: string): Promise<string[]> {\n const excludeDirs = ['appengine', 'functions', 'gae', 'node_modules', 'dist'];\n let files: string[];\n try {\n files = await glob('**/*.schema.ts', {cwd: rootDir});\n } catch {\n return [];\n }\n return files.filter((file) => {\n const normalized = file.replace(/\\\\/g, '/');\n return !excludeDirs.some((dir) => normalized.startsWith(dir + '/'));\n });\n}\n\nasync function buildTranslationsModule(\n rootConfig: RootConfig,\n pods: ResolvedPod[]\n): Promise<string> {\n const rootDir = rootConfig.rootDir;\n const imports: string[] = [];\n const entries: string[] = [];\n let idx = 0;\n\n // User translations take precedence.\n const userLocales = new Set<string>();\n const translationsDir = path.join(rootDir, 'translations');\n if (await isDirectory(translationsDir)) {\n const files = await glob('*.json', {cwd: translationsDir});\n for (const file of files) {\n const locale = path.parse(file).name;\n userLocales.add(locale);\n const modulePath = `/translations/${file}`;\n const varName = `_t${idx++}`;\n imports.push(`import ${varName} from '${modulePath}';`);\n entries.push(` '${modulePath}': {default: ${varName}},`);\n }\n }\n\n // Pod translations.\n for (const pod of pods) {\n for (const t of pod.translationFiles) {\n const varName = `_t${idx++}`;\n imports.push(`import ${varName} from '${t.filePath}';`);\n // Use a synthetic key that includes the pod name for merging.\n const key = `/translations/pod:${pod.name}:${t.locale}.json`;\n entries.push(` '${key}': {default: ${varName}},`);\n }\n }\n\n return [\n ...imports,\n '',\n 'export const TRANSLATION_MODULES = {',\n ...entries,\n '};',\n ].join('\\n');\n}\n","import type {Plugin} from 'vite';\n\nexport interface PreactToRootJsxPluginOptions {\n /** Whether Root's JSX renderer mode is enabled. */\n useRootJsx?: boolean;\n}\n\n/**\n * Vite plugin that aliases `preact` imports to `@blinkk/root/jsx` in the SSR\n * environment only.\n *\n * When `jsxRenderer.mode` is configured, the project uses Root's built-in JSX\n * runtime instead of Preact for server-side rendering. This plugin redirects\n * `preact` imports (`preact`, `preact/hooks`, `preact/jsx-runtime`, etc.) to\n * Root's JSX package, but only in the SSR environment. Client-side code (e.g.\n * islands that depend on real Preact for hydration) is left untouched.\n */\nexport function preactToRootJsxPlugin(\n options?: PreactToRootJsxPluginOptions\n): Plugin {\n const useRootJsx = options?.useRootJsx ?? false;\n\n /**\n * Preact import specifiers to redirect in SSR when `jsxRenderer.mode` is\n * enabled.\n */\n const SSR_REDIRECTS: Record<string, string> = {\n preact: '@blinkk/root/jsx',\n 'preact/hooks': '@blinkk/root/jsx',\n 'preact/jsx-runtime': '@blinkk/root/jsx/jsx-runtime',\n 'preact/jsx-dev-runtime': '@blinkk/root/jsx/jsx-dev-runtime',\n };\n\n return {\n name: 'root:preact-to-jsx',\n async resolveId(id, importer, resolveOptions) {\n if (!useRootJsx) {\n return null;\n }\n\n const ssrTarget = SSR_REDIRECTS[id];\n if (!ssrTarget) {\n return null;\n }\n\n // Only rewrite in the SSR environment. Client-side code (islands)\n // continues to use the real Preact package.\n const isSSR = this.environment?.name === 'ssr';\n if (!isSSR) {\n return null;\n }\n\n const resolved = await this.resolve(ssrTarget, importer, {\n ...resolveOptions,\n skipSelf: true,\n });\n return resolved;\n },\n };\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAU;AACjB,SAAQ,eAAe,wBAAoC;;;ACD3D,OAAO,QAAQ;AACf,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,SAAS,UAAU,UAAU,OAAO;AAC/C;AAEA,eAAsB,QAAQ,SAAiB;AAC7C,MAAI;AACF,UAAM,GAAG,SAAS,OAAO,OAAO;AAAA,EAClC,SAAS,GAAG;AACV,UAAM,GAAG,SAAS,MAAM,SAAS,EAAC,WAAW,KAAI,CAAC;AAAA,EACpD;AACF;AAEA,eAAsB,QAAQ,QAAgB,QAAgB;AAC5D,MAAI,CAAC,QAAQ,WAAW,MAAM,GAAG;AAC/B;AAAA,EACF;AACA,UAAQ,SAAS,QAAQ,QAAQ,EAAC,WAAW,KAAI,CAAC;AACpD;AAWA,eAAsB,SACpB,SACA,QACA,QACA;AACA,QAAM,QAAQ,MAAM,KAAK,SAAS,EAAC,KAAK,OAAM,CAAC;AAC/C,MAAI,MAAM,SAAS,GAAG;AACpB,UAAM,QAAQ,MAAM;AAAA,EACtB;AACA,QAAM,QAAQ,CAAC,SAAS;AACtB,YAAQ,SAAS,KAAK,QAAQ,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ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YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAEA,YAAI,mBAAmB;AACrB,iBAAO,GAAG,KAAK,EAAC,MAAM,cAAa,CAAC;AACpC,iBAAO,CAAC;AAAA,QACV;AAEA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["path","path","path","path","build","path","glob","glob","path","path","glob","path","glob"]}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from "./chunk-JCRXBB26.js";
|
|
14
14
|
import {
|
|
15
15
|
bundleRootConfig,
|
|
16
|
+
collectPods,
|
|
16
17
|
copyDir,
|
|
17
18
|
copyGlob,
|
|
18
19
|
createViteServer,
|
|
@@ -29,13 +30,14 @@ import {
|
|
|
29
30
|
makeDir,
|
|
30
31
|
preactToRootJsxPlugin,
|
|
31
32
|
rmDir,
|
|
33
|
+
rootPodsVitePlugin,
|
|
32
34
|
writeFile,
|
|
33
35
|
writeJson
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-PVBPP5LN.js";
|
|
35
37
|
import {
|
|
36
38
|
configureServerPlugins,
|
|
37
39
|
getVitePlugins
|
|
38
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-XSNCF7WU.js";
|
|
39
41
|
|
|
40
42
|
// src/cli/cli.ts
|
|
41
43
|
import { Command, InvalidArgumentError } from "commander";
|
|
@@ -114,9 +116,9 @@ var ElementGraph = class _ElementGraph {
|
|
|
114
116
|
return Array.from(deps);
|
|
115
117
|
}
|
|
116
118
|
};
|
|
117
|
-
async function getElements(rootConfig) {
|
|
119
|
+
async function getElements(rootConfig, pods) {
|
|
118
120
|
const rootDir = rootConfig.rootDir;
|
|
119
|
-
const elementsDirs = getElementsDirs(rootConfig);
|
|
121
|
+
const elementsDirs = getElementsDirs(rootConfig, pods);
|
|
120
122
|
const excludePatterns = rootConfig.elements?.exclude || [];
|
|
121
123
|
const excludeElement = (moduleId) => {
|
|
122
124
|
return excludePatterns.some((pattern) => Boolean(moduleId.match(pattern)));
|
|
@@ -141,7 +143,7 @@ async function getElements(rootConfig) {
|
|
|
141
143
|
const graph = new ElementGraph(elementFilePaths);
|
|
142
144
|
return graph;
|
|
143
145
|
}
|
|
144
|
-
function getElementsDirs(rootConfig) {
|
|
146
|
+
function getElementsDirs(rootConfig, pods) {
|
|
145
147
|
const rootDir = rootConfig.rootDir;
|
|
146
148
|
const workspaceRoot = searchForWorkspaceRoot(rootDir);
|
|
147
149
|
const elementsDirs = [path.join(rootDir, "elements")];
|
|
@@ -155,6 +157,13 @@ function getElementsDirs(rootConfig) {
|
|
|
155
157
|
}
|
|
156
158
|
elementsDirs.push(elementsDir);
|
|
157
159
|
}
|
|
160
|
+
if (pods) {
|
|
161
|
+
for (const pod of pods) {
|
|
162
|
+
for (const dir of pod.elementsDirs) {
|
|
163
|
+
elementsDirs.push(dir);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
158
167
|
return elementsDirs;
|
|
159
168
|
}
|
|
160
169
|
|
|
@@ -353,6 +362,7 @@ async function build(rootProjectDir, options) {
|
|
|
353
362
|
console.log();
|
|
354
363
|
await rmDir(distDir);
|
|
355
364
|
await makeDir(distDir);
|
|
365
|
+
const pods = await collectPods(rootConfig);
|
|
356
366
|
const routeFiles = [];
|
|
357
367
|
if (await isDirectory(path3.join(rootDir, "routes"))) {
|
|
358
368
|
const pageFiles = await glob2("routes/**/*", { cwd: rootDir });
|
|
@@ -363,7 +373,12 @@ async function build(rootProjectDir, options) {
|
|
|
363
373
|
}
|
|
364
374
|
});
|
|
365
375
|
}
|
|
366
|
-
const
|
|
376
|
+
for (const pod of pods) {
|
|
377
|
+
for (const route of pod.routeFiles) {
|
|
378
|
+
routeFiles.push(route.filePath);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const elementGraph = await getElements(rootConfig, pods);
|
|
367
382
|
const elements = Object.values(elementGraph.sourceFiles).map((sourceFile) => {
|
|
368
383
|
return sourceFile.filePath;
|
|
369
384
|
});
|
|
@@ -377,6 +392,11 @@ async function build(rootProjectDir, options) {
|
|
|
377
392
|
}
|
|
378
393
|
});
|
|
379
394
|
}
|
|
395
|
+
for (const pod of pods) {
|
|
396
|
+
for (const bundleFile of pod.bundleFiles) {
|
|
397
|
+
bundleScripts.push(bundleFile);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
380
400
|
const rootPlugins = rootConfig.plugins || [];
|
|
381
401
|
const viteConfig = rootConfig.vite || {};
|
|
382
402
|
for (const plugin of rootPlugins) {
|
|
@@ -385,7 +405,8 @@ async function build(rootProjectDir, options) {
|
|
|
385
405
|
}
|
|
386
406
|
}
|
|
387
407
|
const vitePlugins = [
|
|
388
|
-
|
|
408
|
+
preactToRootJsxPlugin({ useRootJsx: !!rootConfig.jsxRenderer?.mode }),
|
|
409
|
+
rootPodsVitePlugin(rootConfig),
|
|
389
410
|
...viteConfig.plugins || [],
|
|
390
411
|
...getVitePlugins(rootPlugins)
|
|
391
412
|
];
|
|
@@ -440,7 +461,7 @@ async function build(rootProjectDir, options) {
|
|
|
440
461
|
ssr: {
|
|
441
462
|
...viteConfig.ssr,
|
|
442
463
|
target: "node",
|
|
443
|
-
noExternal: ["@blinkk/root", ...noExternal]
|
|
464
|
+
noExternal: ["@blinkk/root", /^virtual:/, ...noExternal]
|
|
444
465
|
}
|
|
445
466
|
});
|
|
446
467
|
await viteBuild({
|
|
@@ -1419,7 +1440,8 @@ async function createDevServer(options) {
|
|
|
1419
1440
|
async function createViteMiddleware(options) {
|
|
1420
1441
|
const rootConfig = options.rootConfig;
|
|
1421
1442
|
const rootDir = rootConfig.rootDir;
|
|
1422
|
-
|
|
1443
|
+
const pods = await collectPods(rootConfig);
|
|
1444
|
+
let elementGraph = await getElements(rootConfig, pods);
|
|
1423
1445
|
const elements = Object.values(elementGraph.sourceFiles).map((sourceFile) => {
|
|
1424
1446
|
return sourceFile.relPath;
|
|
1425
1447
|
});
|
|
@@ -1433,6 +1455,11 @@ async function createViteMiddleware(options) {
|
|
|
1433
1455
|
}
|
|
1434
1456
|
});
|
|
1435
1457
|
}
|
|
1458
|
+
for (const pod of pods) {
|
|
1459
|
+
for (const bundleFile of pod.bundleFiles) {
|
|
1460
|
+
bundleScripts.push(bundleFile);
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1436
1463
|
const optimizeDeps = [...elements, ...bundleScripts];
|
|
1437
1464
|
const viteServer = await createViteServer(rootConfig, {
|
|
1438
1465
|
port: options.port,
|
|
@@ -1440,18 +1467,18 @@ async function createViteMiddleware(options) {
|
|
|
1440
1467
|
});
|
|
1441
1468
|
function isInElementsDir(changedFilePath) {
|
|
1442
1469
|
const filePath = path7.resolve(changedFilePath);
|
|
1443
|
-
const elementsDirs = getElementsDirs(rootConfig);
|
|
1470
|
+
const elementsDirs = getElementsDirs(rootConfig, pods);
|
|
1444
1471
|
return elementsDirs.some((dirPath) => filePath.startsWith(dirPath));
|
|
1445
1472
|
}
|
|
1446
1473
|
viteServer.watcher.on("add", async (filePath) => {
|
|
1447
1474
|
if (isInElementsDir(filePath)) {
|
|
1448
|
-
elementGraph = await getElements(rootConfig);
|
|
1475
|
+
elementGraph = await getElements(rootConfig, pods);
|
|
1449
1476
|
console.log(`element added: ${filePath}`);
|
|
1450
1477
|
}
|
|
1451
1478
|
});
|
|
1452
1479
|
viteServer.watcher.on("unlink", async (filePath) => {
|
|
1453
1480
|
if (isInElementsDir(filePath)) {
|
|
1454
|
-
elementGraph = await getElements(rootConfig);
|
|
1481
|
+
elementGraph = await getElements(rootConfig, pods);
|
|
1455
1482
|
console.log(`element deleted: ${filePath}`);
|
|
1456
1483
|
}
|
|
1457
1484
|
});
|
|
@@ -2105,4 +2132,4 @@ export {
|
|
|
2105
2132
|
createProdServer,
|
|
2106
2133
|
CliRunner
|
|
2107
2134
|
};
|
|
2108
|
-
//# sourceMappingURL=chunk-
|
|
2135
|
+
//# sourceMappingURL=chunk-RRJ3JKJD.js.map
|