brumate 0.4.4 → 0.5.0
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/{boot-D3NjfyUX.d.ts → boot-Difa0qdg.d.ts} +2 -8
- package/dist/cli.js +2 -2
- package/dist/{client-DNva05jp.d.ts → client-DvsU9qxG.d.ts} +107 -23
- package/dist/{client-iZ9a1Nut.js → client-glvRglTB.js} +990 -369
- package/dist/client-glvRglTB.js.map +1 -0
- package/dist/{defer-DP7dMS2y.js → defer-CNYYG-A5.js} +2 -2
- package/dist/{defer-DP7dMS2y.js.map → defer-CNYYG-A5.js.map} +1 -1
- package/dist/{devtools-BJB_MMeL.js → devtools-D8EioKXs.js} +4 -4
- package/dist/{devtools-BJB_MMeL.js.map → devtools-D8EioKXs.js.map} +1 -1
- package/dist/{devtools-panel-CUV6A4ZE.js → devtools-panel-BKmBqkau.js} +2 -2
- package/dist/{devtools-panel-CUV6A4ZE.js.map → devtools-panel-BKmBqkau.js.map} +1 -1
- package/dist/{features-CHY5Ekku.js → features-D5kLyihb.js} +19 -2
- package/dist/features-D5kLyihb.js.map +1 -0
- package/dist/{files-BZRjz9Mx.js → files-ClQJlDcB.js} +2 -2
- package/dist/{files-BZRjz9Mx.js.map → files-ClQJlDcB.js.map} +1 -1
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -1
- package/dist/{inspect-BLOdfj7o.js → inspect-B8i6R3mZ.js} +876 -132
- package/dist/inspect-B8i6R3mZ.js.map +1 -0
- package/dist/{loader-CheV6t0N.js → loader-DB0i9MwD.js} +4 -4
- package/dist/{loader-CheV6t0N.js.map → loader-DB0i9MwD.js.map} +1 -1
- package/dist/{navigate-CfOr-TRF.js → navigate-BcV1qkkx.js} +2 -2
- package/dist/navigate-BcV1qkkx.js.map +1 -0
- package/dist/{produce-DS-dQaUX.js → produce-Cq6KKi7b.js} +2 -2
- package/dist/{produce-DS-dQaUX.js.map → produce-Cq6KKi7b.js.map} +1 -1
- package/dist/{rpc-DvTwGfL_.js → rpc-BHlxmeWe.js} +5 -5
- package/dist/rpc-BHlxmeWe.js.map +1 -0
- package/dist/runtime/bundles.d.ts +9 -0
- package/dist/runtime/bundles.js +60 -0
- package/dist/runtime/bundles.js.map +1 -0
- package/dist/runtime/client.d.ts +2 -2
- package/dist/runtime/client.js +3 -3
- package/dist/runtime/devtools.d.ts +1 -1
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/loader.d.ts +2 -2
- package/dist/runtime/loader.js +2 -2
- package/dist/runtime/server.d.ts +3 -3
- package/dist/runtime/server.js +4 -4
- package/dist/runtime/static-loader.d.ts +2 -2
- package/dist/runtime/static-loader.js +1 -1
- package/dist/runtime/testing.d.ts +2 -2
- package/dist/runtime/testing.js +2 -2
- package/dist/{server-BXMH3Z9T.d.ts → server-CAwIqrXl.d.ts} +44 -5
- package/dist/{server-O_rC-RRL.js → server-Doy5HR7r.js} +106 -17
- package/dist/server-Doy5HR7r.js.map +1 -0
- package/dist/{static-loader-BiUaZaag.d.ts → static-loader-9Nc1GvF0.d.ts} +2 -2
- package/dist/{static-loader-BLJYvTKc.js → static-loader-D0ARlMxM.js} +3 -26
- package/dist/static-loader-D0ARlMxM.js.map +1 -0
- package/dist/{stream-JGRPr7u5.js → stream-BdhzvPQO.js} +2 -2
- package/dist/{stream-JGRPr7u5.js.map → stream-BdhzvPQO.js.map} +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +129 -51
- package/dist/vite.js.map +1 -1
- package/package.json +5 -1
- package/skills/brumate/references/errors.md +19 -5
- package/dist/client-iZ9a1Nut.js.map +0 -1
- package/dist/features-CHY5Ekku.js.map +0 -1
- package/dist/inspect-BLOdfj7o.js.map +0 -1
- package/dist/navigate-CfOr-TRF.js.map +0 -1
- package/dist/rpc-DvTwGfL_.js.map +0 -1
- package/dist/server-O_rC-RRL.js.map +0 -1
- package/dist/static-loader-BLJYvTKc.js.map +0 -1
|
@@ -24,7 +24,24 @@ const HAS_ACTIONS = typeof __BRUMATE_HAS_ACTIONS__ === "undefined" || __BRUMATE_
|
|
|
24
24
|
* indexes each insert at once, and HTML holds no places for clones.
|
|
25
25
|
*/
|
|
26
26
|
const HAS_CLIENT_HTML = typeof __BRUMATE_HAS_CLIENT_HTML__ === "undefined" || __BRUMATE_HAS_CLIENT_HTML__;
|
|
27
|
+
/** `#try` blocks, whose `#catch` the browser renders. */
|
|
28
|
+
const HAS_TRIES = typeof __BRUMATE_HAS_TRIES__ === "undefined" || __BRUMATE_HAS_TRIES__;
|
|
29
|
+
/** Fields of an element `$bind`, which the core reads when the user typed before it loaded. */
|
|
30
|
+
const HAS_FIELDS = typeof __BRUMATE_HAS_FIELDS__ === "undefined" || __BRUMATE_HAS_FIELDS__;
|
|
31
|
+
/** `#for` lists with `window`. */
|
|
32
|
+
const HAS_WINDOWS = typeof __BRUMATE_HAS_WINDOWS__ === "undefined" || __BRUMATE_HAS_WINDOWS__;
|
|
33
|
+
/** Dynamic tags, which can name a component and pass it props. */
|
|
34
|
+
const HAS_DYNAMIC = typeof __BRUMATE_HAS_DYNAMIC__ === "undefined" || __BRUMATE_HAS_DYNAMIC__;
|
|
35
|
+
/** `$route` and `$navigation`, which the runtime provides. */
|
|
36
|
+
const HAS_ROUTES = typeof __BRUMATE_HAS_ROUTES__ === "undefined" || __BRUMATE_HAS_ROUTES__;
|
|
37
|
+
/** `#loading` blocks that the browser renders, which show their fallback while memos load. */
|
|
38
|
+
const HAS_LOADING = typeof __BRUMATE_HAS_LOADING__ === "undefined" || __BRUMATE_HAS_LOADING__;
|
|
39
|
+
/**
|
|
40
|
+
* A browser render that waits at `await $memo`. A block outside every `#loading` then keeps what
|
|
41
|
+
* it shows until the waits of its new body settle, as the server holds the page.
|
|
42
|
+
*/
|
|
43
|
+
const HAS_ROOT_WAIT = typeof __BRUMATE_HAS_ROOT_WAIT__ === "undefined" || __BRUMATE_HAS_ROOT_WAIT__;
|
|
27
44
|
//#endregion
|
|
28
|
-
export { HAS_CLIENT_HTML as a,
|
|
45
|
+
export { HAS_CLIENT_HTML as a, HAS_LATE_MARKUP as c, HAS_ROOT_WAIT as d, HAS_ROUTES as f, HAS_WINDOWS as g, HAS_TRIES as h, HAS_CHILDREN as i, HAS_LISTENERS as l, HAS_TITLES as m, HAS_BINDINGS as n, HAS_DYNAMIC as o, HAS_TEMPLATES as p, HAS_BLOCKS as r, HAS_FIELDS as s, HAS_ACTIONS as t, HAS_LOADING as u };
|
|
29
46
|
|
|
30
|
-
//# sourceMappingURL=features-
|
|
47
|
+
//# sourceMappingURL=features-D5kLyihb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features-D5kLyihb.js","names":[],"sources":["../src/runtime/features.ts"],"sourcesContent":["// The features of the core that a build uses. Each is on, unless the build names it. The Vite\n// plugin names them in the client build of an app, and turns off the features that none of its\n// components use, so the bundler leaves out their code. They are globals that the plugin\n// replaces, so the build of this package does not fold them.\n\ndeclare const __BRUMATE_HAS_CHILDREN__: boolean | undefined;\ndeclare const __BRUMATE_HAS_TEMPLATES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_TITLES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_BINDINGS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_LATE_MARKUP__: boolean | undefined;\ndeclare const __BRUMATE_HAS_BLOCKS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_LISTENERS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_ACTIONS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_CLIENT_HTML__: boolean | undefined;\ndeclare const __BRUMATE_HAS_TRIES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_FIELDS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_WINDOWS__: boolean | undefined;\ndeclare const __BRUMATE_HAS_DYNAMIC__: boolean | undefined;\ndeclare const __BRUMATE_HAS_ROUTES__: boolean | undefined;\ndeclare const __BRUMATE_HAS_LOADING__: boolean | undefined;\ndeclare const __BRUMATE_HAS_ROOT_WAIT__: boolean | undefined;\n\n/** Children that the browser renders with an export of their own, each time they are inserted. */\nexport const HAS_CHILDREN: boolean =\n typeof __BRUMATE_HAS_CHILDREN__ === 'undefined' || __BRUMATE_HAS_CHILDREN__;\n\n/** `#template` values that the browser calls, such as a template that a prop holds. */\nexport const HAS_TEMPLATES: boolean =\n typeof __BRUMATE_HAS_TEMPLATES__ === 'undefined' || __BRUMATE_HAS_TEMPLATES__;\n\n/** `<title>` elements in markup, which set the title of the page. */\nexport const HAS_TITLES: boolean =\n typeof __BRUMATE_HAS_TITLES__ === 'undefined' || __BRUMATE_HAS_TITLES__;\n\n/** `$bind` that a component passes to another, which the page state can hold. */\nexport const HAS_BINDINGS: boolean =\n typeof __BRUMATE_HAS_BINDINGS__ === 'undefined' || __BRUMATE_HAS_BINDINGS__;\n\n/**\n * Markup that comes into the page after it loads, from others than the core: the bodies of\n * `#loading` and `#defer`, the items of a list that streams, and the pages of client navigation.\n * Without it, the core finds every marker in the markup that it reads or inserts itself.\n */\nexport const HAS_LATE_MARKUP: boolean =\n typeof __BRUMATE_HAS_LATE_MARKUP__ === 'undefined' || __BRUMATE_HAS_LATE_MARKUP__;\n\n/** `$client` callbacks and `#defer` blocks, which start on a trigger. */\nexport const HAS_BLOCKS: boolean =\n typeof __BRUMATE_HAS_BLOCKS__ === 'undefined' || __BRUMATE_HAS_BLOCKS__;\n\n/** Handlers of the window or the document. */\nexport const HAS_LISTENERS: boolean =\n typeof __BRUMATE_HAS_LISTENERS__ === 'undefined' || __BRUMATE_HAS_LISTENERS__;\n\n/** Forms of an `$action`, which send their data with `fetch`. */\nexport const HAS_ACTIONS: boolean =\n typeof __BRUMATE_HAS_ACTIONS__ === 'undefined' || __BRUMATE_HAS_ACTIONS__;\n\n/**\n * Markup that the browser renders as HTML, not as a clone of a template. Without it, the core\n * indexes each insert at once, and HTML holds no places for clones.\n */\nexport const HAS_CLIENT_HTML: boolean =\n typeof __BRUMATE_HAS_CLIENT_HTML__ === 'undefined' || __BRUMATE_HAS_CLIENT_HTML__;\n\n/** `#try` blocks, whose `#catch` the browser renders. */\nexport const HAS_TRIES: boolean =\n typeof __BRUMATE_HAS_TRIES__ === 'undefined' || __BRUMATE_HAS_TRIES__;\n\n/** Fields of an element `$bind`, which the core reads when the user typed before it loaded. */\nexport const HAS_FIELDS: boolean =\n typeof __BRUMATE_HAS_FIELDS__ === 'undefined' || __BRUMATE_HAS_FIELDS__;\n\n/** `#for` lists with `window`. */\nexport const HAS_WINDOWS: boolean =\n typeof __BRUMATE_HAS_WINDOWS__ === 'undefined' || __BRUMATE_HAS_WINDOWS__;\n\n/** Dynamic tags, which can name a component and pass it props. */\nexport const HAS_DYNAMIC: boolean =\n typeof __BRUMATE_HAS_DYNAMIC__ === 'undefined' || __BRUMATE_HAS_DYNAMIC__;\n\n/** `$route` and `$navigation`, which the runtime provides. */\nexport const HAS_ROUTES: boolean =\n typeof __BRUMATE_HAS_ROUTES__ === 'undefined' || __BRUMATE_HAS_ROUTES__;\n\n/** `#loading` blocks that the browser renders, which show their fallback while memos load. */\nexport const HAS_LOADING: boolean =\n typeof __BRUMATE_HAS_LOADING__ === 'undefined' || __BRUMATE_HAS_LOADING__;\n\n/**\n * A browser render that waits at `await $memo`. A block outside every `#loading` then keeps what\n * it shows until the waits of its new body settle, as the server holds the page.\n */\nexport const HAS_ROOT_WAIT: boolean =\n typeof __BRUMATE_HAS_ROOT_WAIT__ === 'undefined' || __BRUMATE_HAS_ROOT_WAIT__;\n"],"mappings":";;AAuBA,MAAa,eACX,OAAO,6BAA6B,eAAe;;AAGrD,MAAa,gBACX,OAAO,8BAA8B,eAAe;;AAGtD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,eACX,OAAO,6BAA6B,eAAe;;;;;;AAOrD,MAAa,kBACX,OAAO,gCAAgC,eAAe;;AAGxD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,gBACX,OAAO,8BAA8B,eAAe;;AAGtD,MAAa,cACX,OAAO,4BAA4B,eAAe;;;;;AAMpD,MAAa,kBACX,OAAO,gCAAgC,eAAe;;AAGxD,MAAa,YACX,OAAO,0BAA0B,eAAe;;AAGlD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,cACX,OAAO,4BAA4B,eAAe;;AAGpD,MAAa,cACX,OAAO,4BAA4B,eAAe;;AAGpD,MAAa,aACX,OAAO,2BAA2B,eAAe;;AAGnD,MAAa,cACX,OAAO,4BAA4B,eAAe;;;;;AAMpD,MAAa,gBACX,OAAO,8BAA8B,eAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as functionId } from "./inspect-
|
|
1
|
+
import { _ as functionId } from "./inspect-B8i6R3mZ.js";
|
|
2
2
|
import { parseSync } from "oxc-parser";
|
|
3
3
|
import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
4
4
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
@@ -503,4 +503,4 @@ async function collectSources(root, paths) {
|
|
|
503
503
|
//#endregion
|
|
504
504
|
export { reachableFiles as _, findServerFiles as a, hasServerMiddleware as c, serverExports as d, serverModule as f, packageFileName as g, findPackages as h, findScripts as i, hasUseServer as l, findPackage as m, defaultExclude as n, findPackageServerFile as o, serverStubs as p, findFiles as r, findServerImport as s, collectSources as t, isScriptFile as u, resolveComponentPackage as v };
|
|
505
505
|
|
|
506
|
-
//# sourceMappingURL=files-
|
|
506
|
+
//# sourceMappingURL=files-ClQJlDcB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-BZRjz9Mx.js","names":[],"sources":["../src/packages.ts","../src/server-files.ts","../src/files.ts"],"sourcesContent":["// Packages of components. A dependency of the app whose package.json has a\n// `brumate` field ships `.brm` files, `.brm.ts` modules and `'use server'`\n// files as source, and the plugin of the app compiles them with its own files.\n\nimport { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';\nimport path from 'node:path';\n\n/** A dependency of the app that ships `.brm` files. */\nexport interface BrumatePackage {\n /** The name of the package, such as `@acme/ui`. */\n name: string;\n version: string;\n /** The real path of the directory of the package, with forward slashes. */\n root: string;\n /** The directories to search for files, as absolute paths with forward slashes. */\n directories: string[];\n /**\n * The prefix of the names of its files, which their IDs come from: the\n * name of the package, and its version when the app has two versions.\n */\n prefix: string;\n /** True when the package is not inside `node_modules`, such as a workspace package. */\n linked: boolean;\n}\n\ninterface PackageJson {\n name?: string;\n version?: string;\n brumate?: unknown;\n exports?: unknown;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\nfunction readJson(file: string): PackageJson | undefined {\n try {\n return JSON.parse(readFileSync(file, 'utf8')) as PackageJson;\n } catch {\n return undefined;\n }\n}\n\n/** The real directory of a package that code in `from` can import, or undefined. */\nexport function findPackageDirectory(name: string, from: string): string | undefined {\n for (let directory = from; ; directory = path.dirname(directory)) {\n const candidate = path.join(directory, 'node_modules', name);\n if (existsSync(path.join(candidate, 'package.json'))) {\n return toPosix(realpathSync(candidate));\n }\n if (path.dirname(directory) === directory) {\n return undefined;\n }\n }\n}\n\n/** The directory of the nearest package.json at or above a directory. */\nfunction packageRoot(directory: string): string | undefined {\n for (let current = directory; ; current = path.dirname(current)) {\n if (existsSync(path.join(current, 'package.json'))) {\n return current;\n }\n if (path.dirname(current) === current) {\n return undefined;\n }\n }\n}\n\n/** The version of the `brumate` field that this version of brumate reads. */\nexport const PACKAGE_FORMAT = 1;\n\n/** The directories that the `brumate` field names, or undefined when the package does not opt in. */\nfunction readDirectories(root: string, field: unknown, name: string): string[] | undefined {\n if (field === true) {\n return [root];\n }\n if (typeof field === 'object' && field !== null) {\n const { dir, version = PACKAGE_FORMAT } = field as {\n dir?: string | string[];\n version?: number;\n };\n if (version !== PACKAGE_FORMAT) {\n throw new Error(\n `The package ${name} has \"brumate\": { \"version\": ${version} }, but this version of brumate reads version ${PACKAGE_FORMAT}. Install a version of ${name} or of brumate that matches.`,\n );\n }\n if (dir === undefined) {\n return [root];\n }\n const directories: string[] = [];\n for (const item of Array.isArray(dir) ? dir : [dir]) {\n directories.push(toPosix(path.resolve(root, item)));\n }\n return directories;\n }\n return undefined;\n}\n\n/**\n * Finds the dependencies of the app at `root` that ship `.brm` files, and\n * theirs. The app's dependencies come from its package.json: `dependencies`,\n * `devDependencies`, `optionalDependencies` and `peerDependencies`. A package\n * opts in with `\"brumate\": true`, or `\"brumate\": { \"dir\": \"src\" }` to search\n * only that directory. Symbolic links, such as those of pnpm, resolve to the\n * real directory.\n */\nexport function findPackages(root: string): BrumatePackage[] {\n const app = packageRoot(path.resolve(root));\n if (!app) {\n return [];\n }\n const found = new Map<string, Omit<BrumatePackage, 'prefix'>>();\n function visit(directory: string, json: PackageJson, own: boolean): void {\n const names = new Set([\n ...Object.keys(json.dependencies ?? {}),\n ...Object.keys(json.optionalDependencies ?? {}),\n ...Object.keys(json.peerDependencies ?? {}),\n // The dev dependencies of a package are its own tools, not part of what it ships.\n ...(own ? Object.keys(json.devDependencies ?? {}) : []),\n ]);\n for (const name of [...names].toSorted()) {\n const real = findPackageDirectory(name, directory);\n if (!real || found.has(real)) {\n continue;\n }\n const dependency = readJson(`${real}/package.json`);\n const directories = dependency && readDirectories(real, dependency.brumate, name);\n if (!dependency || !directories) {\n continue;\n }\n found.set(real, {\n name: dependency.name ?? name,\n version: dependency.version ?? '0.0.0',\n root: real,\n directories,\n linked: !real.includes('/node_modules/'),\n });\n visit(real, dependency, false);\n }\n }\n visit(app, readJson(path.join(app, 'package.json')) ?? {}, true);\n const list = [...found.values()];\n // Two versions of one package get IDs apart. Copies of one version share theirs, as their files are the same.\n const versions = new Map<string, Set<string>>();\n for (const item of list) {\n versions.set(item.name, (versions.get(item.name) ?? new Set()).add(item.version));\n }\n const result: BrumatePackage[] = [];\n for (const item of list) {\n result.push(\n Object.assign(item, {\n prefix: versions.get(item.name)!.size > 1 ? `${item.name}@${item.version}` : item.name,\n }),\n );\n }\n return result;\n}\n\n/** The package that a file belongs to, or undefined for a file of the app. */\nexport function findPackage(packages: BrumatePackage[], file: string): BrumatePackage | undefined {\n for (const item of packages) {\n if (file.startsWith(`${item.root}/`)) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * The name of a file of a package, which its IDs come from: the prefix of\n * the package and the path of the file in it, such as `@acme/ui/src/Button.brm`.\n * It is the same wherever the package is installed.\n */\nexport function packageFileName(item: BrumatePackage, file: string): string {\n return `${item.prefix}/${file.slice(item.root.length + 1)}`;\n}\n\n/** The name and the subpath of a bare specifier, such as `@acme/ui` and `./Button.brm`. */\nexport function splitSpecifier(specifier: string): { name: string; subpath: string } | undefined {\n if (specifier.startsWith('.') || specifier.startsWith('/') || /^[a-z]+:/i.test(specifier)) {\n return undefined;\n }\n const parts = specifier.split('/');\n const count = specifier.startsWith('@') ? 2 : 1;\n if (parts.length < count) {\n return undefined;\n }\n for (const part of parts.slice(0, count)) {\n if (part === '') {\n return undefined;\n }\n }\n const rest = parts.slice(count).join('/');\n return { name: parts.slice(0, count).join('/'), subpath: rest ? `./${rest}` : '.' };\n}\n\n/** The conditions of `exports` that a `.brm` file or a source module can be under. */\nconst CONDITIONS = new Set(['brumate', 'import', 'module', 'node', 'browser', 'default']);\n\nfunction resolveTarget(target: unknown, star: string): string | undefined {\n if (typeof target === 'string') {\n return target.replaceAll('*', star);\n }\n if (Array.isArray(target)) {\n for (const item of target) {\n const result = resolveTarget(item, star);\n if (result) {\n return result;\n }\n }\n return undefined;\n }\n if (typeof target === 'object' && target !== null) {\n for (const [condition, value] of Object.entries(target)) {\n if (CONDITIONS.has(condition)) {\n const result = resolveTarget(value, star);\n if (result) {\n return result;\n }\n }\n }\n }\n return undefined;\n}\n\n/** Resolves a subpath through the `exports` of a package.json, or undefined if it does not export it. */\nexport function resolveExports(exports: unknown, subpath: string): string | undefined {\n let hasSubpaths = false;\n if (typeof exports === 'object' && exports !== null && !Array.isArray(exports)) {\n for (const key of Object.keys(exports)) {\n if (key.startsWith('.')) {\n hasSubpaths = true;\n break;\n }\n }\n }\n const map = hasSubpaths ? (exports as Record<string, unknown>) : { '.': exports };\n if (subpath in map) {\n return resolveTarget(map[subpath], '');\n }\n // The pattern with the longest prefix wins, as in Node.\n let best: { key: string; star: string } | undefined;\n for (const key of Object.keys(map)) {\n const index = key.indexOf('*');\n if (index === -1) {\n continue;\n }\n const before = key.slice(0, index);\n const after = key.slice(index + 1);\n if (\n subpath.startsWith(before) &&\n subpath.endsWith(after) &&\n subpath.length >= key.length - 1 &&\n (!best || before.length > best.key.indexOf('*'))\n ) {\n best = { key, star: subpath.slice(before.length, subpath.length - after.length) };\n }\n }\n return best && resolveTarget(map[best.key], best.star);\n}\n\n/**\n * Resolves a bare specifier, such as `@acme/ui/Button.brm`, to the real path\n * of the file, through the `exports` of the package. Returns undefined when\n * it is not a bare specifier or names no file.\n */\nexport function resolvePackageImport(specifier: string, importer: string): string | undefined {\n const split = splitSpecifier(specifier);\n if (!split) {\n return undefined;\n }\n const directory = findPackageDirectory(split.name, path.dirname(importer));\n if (!directory) {\n return undefined;\n }\n const json = readJson(`${directory}/package.json`);\n const target =\n json?.exports === undefined ? split.subpath : resolveExports(json.exports, split.subpath);\n if (!target) {\n return undefined;\n }\n const file = path.resolve(directory, target);\n return existsSync(file) ? toPosix(realpathSync(file)) : undefined;\n}\n\n/**\n * Resolves a bare specifier like `resolvePackageImport`, but only for a\n * package of components in the list. Returns undefined for any other package.\n */\nexport function resolveComponentPackage(\n packages: BrumatePackage[],\n specifier: string,\n importer: string,\n): string | undefined {\n const name = splitSpecifier(specifier)?.name;\n for (const item of packages) {\n if (item.name === name) {\n return resolvePackageImport(specifier, importer);\n }\n }\n return undefined;\n}\n\n/** The specifiers that a file imports or exports from, found by a pattern, so it can only find more. */\nexport function importSpecifiers(source: string): string[] {\n const result: string[] = [];\n for (const match of source.matchAll(/(?:\\bfrom|\\bimport\\s*\\(?)\\s*(['\"])([^'\"\\n]+)\\1/g)) {\n result.push(match[2]!);\n }\n return result;\n}\n\n/** The extensions that an import without one can name. */\nconst EXTENSIONS = ['', '.ts', '.tsx', '.js', '.mjs', '/index.ts', '/index.js'];\n\n/**\n * The files of packages that the app reaches: the files of packages that\n * files of the app import, and the files of packages that those import, and\n * so on. Only these become server functions of the app.\n */\nexport function reachableFiles(\n packages: BrumatePackage[],\n appFiles: string[],\n read: (file: string) => string | undefined,\n): Set<string> {\n const reached = new Set<string>();\n const names = new Set<string>();\n for (const item of packages) {\n names.add(item.name);\n }\n const pending: string[] = [];\n function add(file: string | undefined): void {\n if (file && !reached.has(file) && findPackage(packages, file)) {\n reached.add(file);\n pending.push(file);\n }\n }\n function resolve(specifier: string, importer: string): string | undefined {\n if (specifier.startsWith('.')) {\n const stem = path.resolve(path.dirname(importer), specifier.split('?')[0]!);\n for (const extension of EXTENSIONS) {\n const candidate = stem + extension;\n if (statSync(candidate, { throwIfNoEntry: false })?.isFile()) {\n return toPosix(realpathSync(candidate));\n }\n }\n return undefined;\n }\n const name = splitSpecifier(specifier)?.name;\n return name && names.has(name)\n ? resolvePackageImport(specifier.split('?')[0]!, importer)\n : undefined;\n }\n function visit(file: string, own: boolean): void {\n const source = read(file);\n if (source === undefined) {\n return;\n }\n for (const specifier of importSpecifiers(source)) {\n // A file of the app reaches a package only by its name.\n if (own && specifier.startsWith('.')) {\n continue;\n }\n try {\n add(resolve(specifier, file));\n } catch {\n // A path that is not a file, such as a directory, reaches nothing.\n }\n }\n }\n for (const file of appFiles) {\n visit(file, true);\n }\n while (pending.length > 0) {\n visit(pending.pop()!, false);\n }\n return reached;\n}\n","// Files of server functions. A `.ts` or `.js` file whose first statement is\n// `'use server'` holds functions that only run on the server. Its exports are\n// server functions: the browser gets a stub for each one, which calls the\n// server, and the code of the file never ships.\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { parseSync } from 'oxc-parser';\nimport type { BrumatePackage } from './packages.ts';\nimport { resolveComponentPackage } from './packages.ts';\nimport { functionId } from './plan.ts';\n\n/** The import of the stubs, which call server functions with `rpc` of the core. */\nconst CLIENT = 'brumate/client';\n\n/** True for a file whose first statement is `'use server'`, after comments. */\nexport function hasUseServer(source: string): boolean {\n return /^(?:\\s|\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/)*(['\"])use server\\1/.test(source);\n}\n\n/** True for a path that can be a file of server functions. */\nexport function isScriptFile(path: string): boolean {\n return (\n /\\.[cm]?[jt]sx?$/.test(path) && !path.endsWith('.d.ts') && !/\\.brm\\.[cm]?[jt]s$/.test(path)\n );\n}\n\n/** True for a function expression or an arrow. */\ntype Program = ReturnType<typeof parseSync>['program'];\ntype Node = Program['body'][number] | { type: string; callee?: unknown } | null | undefined;\n\n/**\n * Tells a value that the file exports as a function: a function expression,\n * or a call of `cached` or `idempotent` of `brumate/server`, which return a function.\n */\nfunction functionTest(program: Program): (node: Node) => boolean {\n const wrappers = new Set<string>();\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration' && statement.source.value === 'brumate/server') {\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported.type === 'Identifier' &&\n (specifier.imported.name === 'cached' || specifier.imported.name === 'idempotent')\n ) {\n wrappers.add(specifier.local.name);\n }\n }\n }\n }\n return (node) => {\n if (node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression') {\n return true;\n }\n const callee =\n node?.type === 'CallExpression'\n ? (node.callee as { type: string; name?: string })\n : undefined;\n return callee?.type === 'Identifier' && wrappers.has(callee.name!);\n };\n}\n\n/**\n * The names of the functions that a file of server functions exports.\n * Throws for an export that is not a function, because the browser can only\n * call a server function through its stub.\n */\nexport function serverExports(source: string, filename: string): string[] {\n const { program, errors } = parseSync(filename, source, { lang: 'ts' });\n if (errors[0]) {\n throw new Error(`${errors[0].message} (${filename})`);\n }\n const functions = new Set<string>();\n const values = new Set<string>();\n const local = new Map<string, 'function' | 'value'>();\n const isFunction = functionTest(program);\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n local.set(declaration.id.name, 'function');\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n local.set(declarator.id.name, isFunction(declarator.init) ? 'function' : 'value');\n }\n }\n }\n }\n for (const statement of program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n const value = statement.declaration;\n if (value.type === 'FunctionDeclaration' || isFunction(value)) {\n functions.add('default');\n } else {\n values.add('default');\n }\n } else if (statement.type === 'ExportNamedDeclaration') {\n if (statement.exportKind === 'type') {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n functions.add(declaration.id.name);\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n (isFunction(declarator.init) ? functions : values).add(declarator.id.name);\n }\n }\n } else if (declaration && !declaration.type.startsWith('TS')) {\n values.add('a class');\n }\n for (const specifier of statement.specifiers) {\n if (specifier.exportKind === 'type') {\n continue;\n }\n const name =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const from = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n (local.get(from) === 'function' && !statement.source ? functions : values).add(name);\n }\n } else if (statement.type === 'ExportAllDeclaration') {\n values.add('*');\n }\n }\n if (values.size > 0) {\n throw new Error(\n `A 'use server' file exports only functions, because the browser calls them on the server. ${[...values].join(', ')} of ${filename} is not one`,\n );\n }\n // The middleware of the file runs before its functions. The browser cannot call it.\n functions.delete(MIDDLEWARE);\n return [...functions];\n}\n\n/** The export of a file of server functions that runs before each of them. */\nexport const MIDDLEWARE = 'middleware';\n\n/** True if a file of server functions exports `middleware`. */\nexport function hasServerMiddleware(source: string, filename: string): boolean {\n const { program } = parseSync(filename, source, { lang: 'ts' });\n for (const statement of program.body) {\n if (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id?.name === MIDDLEWARE) {\n return true;\n }\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && declarator.id.name === MIDDLEWARE) {\n return true;\n }\n }\n }\n for (const specifier of statement.specifiers) {\n const name =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (specifier.exportKind !== 'type' && name === MIDDLEWARE) {\n return true;\n }\n }\n }\n return false;\n}\n\n/** The module that the browser gets in place of a file of server functions. */\nexport function serverStubs(\n source: string,\n filename: string,\n id: string,\n hideNames = false,\n): string {\n const lines = [`import { rpc } from ${JSON.stringify(CLIENT)};`];\n for (const name of serverExports(source, filename)) {\n const call = `(...args) => rpc(${JSON.stringify(functionId(id, name, hideNames))}, args)`;\n lines.push(name === 'default' ? `export default ${call};` : `export const ${name} = ${call};`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/**\n * The module that the server runs for a file of server functions: the file,\n * with each exported function wrapped, so its calls while a page renders\n * share a result when their arguments are the same. Offsets stay the same.\n */\nexport function serverModule(source: string, filename: string, id: string): string {\n const { program } = parseSync(filename, source, { lang: 'ts' });\n const isFunction = functionTest(program);\n // Local names of exported functions, with the name that each is exported as.\n const wrapped = new Map<string, string>();\n const declarations = new Map<string, 'function' | 'const'>();\n let code = source;\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n declarations.set(declaration.id.name, 'function');\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && isFunction(declarator.init)) {\n declarations.set(declarator.id.name, 'const');\n }\n }\n }\n }\n function makeLet(declaration: { start: number; kind: string }): void {\n // `const` becomes `let `, so the function can be wrapped and offsets stay the same.\n if (declaration.kind === 'const') {\n code = `${code.slice(0, declaration.start)}let ${code.slice(declaration.start + 5)}`;\n }\n }\n for (const statement of program.body) {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n statement.source ||\n statement.exportKind === 'type'\n ) {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n wrapped.set(declaration.id.name, declaration.id.name);\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && isFunction(declarator.init)) {\n wrapped.set(declarator.id.name, declarator.id.name);\n makeLet(declaration);\n }\n }\n }\n for (const specifier of statement.specifiers) {\n const local = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (declarations.has(local)) {\n wrapped.set(local, exported);\n }\n }\n }\n // A `const` arrow that `export { name }` exports is declared with `let` too.\n for (const statement of program.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n if (declarator.id.type === 'Identifier' && wrapped.has(declarator.id.name)) {\n makeLet(statement);\n }\n }\n }\n }\n if (wrapped.size === 0) {\n return source;\n }\n const lines = [\"import { dedupe as __brumateDedupe } from 'brumate/server';\"];\n for (const [local, exported] of wrapped) {\n lines.push(`${local} = __brumateDedupe(${local}, ${JSON.stringify(`${id}#${exported}`)});`);\n }\n return `${code}\\n${lines.join('\\n')}\\n`;\n}\n\n/**\n * The file of a relative import that holds server functions, such as `./issues` for `issues.ts`\n * with `'use server'` first, or undefined. A package specifier is not looked up.\n */\nexport function findServerImport(importer: string, specifier: string): string | undefined {\n if (!specifier.startsWith('.')) {\n return undefined;\n }\n const stem = path.resolve(path.dirname(importer), specifier);\n const candidates = [stem];\n for (const extension of ['.ts', '.tsx', '.js', '.mjs']) {\n candidates.push(stem + extension);\n }\n for (const candidate of candidates) {\n if (\n isScriptFile(candidate) &&\n existsSync(candidate) &&\n hasUseServer(readFileSync(candidate, 'utf8'))\n ) {\n return candidate;\n }\n }\n return undefined;\n}\n\n/**\n * The file of server functions that a package of components exports under a\n * bare specifier, or undefined.\n */\nexport function findPackageServerFile(\n packages: BrumatePackage[],\n importer: string,\n specifier: string,\n): string | undefined {\n const file = resolveComponentPackage(packages, specifier, importer);\n return file && isScriptFile(file) && hasUseServer(readFileSync(file, 'utf8')) ? file : undefined;\n}\n","import { readFile, readdir, stat } from 'node:fs/promises';\nimport path from 'node:path';\nimport { hasUseServer, isScriptFile } from './server-files.ts';\n\n/** Skips `node_modules`, `dist` and hidden directories when looking for `.brm` files. */\nexport function defaultExclude(directory: string): boolean {\n return directory === 'node_modules' || directory === 'dist' || directory.startsWith('.');\n}\n\n/** Finds every `.brm` file under a directory, as absolute paths with forward slashes. */\nexport async function findFiles(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n const directories: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n directories.push(visit(file));\n }\n } else if (entry.name.endsWith('.brm')) {\n result.push(file.split(path.sep).join('/'));\n }\n }\n await Promise.all(directories);\n }\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Finds every file of server functions under a directory: a script whose\n * first statement is `'use server'`.\n */\nexport async function findServerFiles(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n const pending: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n pending.push(visit(file));\n }\n } else if (isScriptFile(entry.name)) {\n pending.push(\n readFile(file, 'utf8').then((source) => {\n if (hasUseServer(source)) {\n result.push(file.split(path.sep).join('/'));\n }\n }),\n );\n }\n }\n await Promise.all(pending);\n }\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Finds every script under a directory, such as `.ts` and `.brm.ts` files, as\n * absolute paths with forward slashes, without reading them.\n */\nexport async function findScripts(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n const directories: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n directories.push(visit(file));\n }\n } else if (/\\.[cm]?[jt]sx?$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {\n result.push(file.split(path.sep).join('/'));\n }\n }\n await Promise.all(directories);\n }\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Reads every `.brm` file under a root, and finds the files that the paths\n * name: a file, or the files under a directory. Without paths, the targets are\n * the whole project. A file outside the root is read too. A path that does not\n * exist throws.\n */\nexport async function collectSources(\n root: string,\n paths: string[],\n): Promise<{ sources: Map<string, string>; targets: string[] }> {\n const project = await findFiles(root, defaultExclude);\n const sources = new Map<string, string>();\n const reads: Promise<string>[] = [];\n for (const file of project) {\n reads.push(readFile(file, 'utf8'));\n }\n const texts = await Promise.all(reads);\n for (const [index, file] of project.entries()) {\n sources.set(file, texts[index]!);\n }\n\n const targets: string[] = paths.length === 0 ? [...project] : [];\n const lookups: Promise<string[]>[] = [];\n for (const target of paths) {\n const absolute = path.resolve(root, target);\n lookups.push(\n stat(absolute).then((info) =>\n info.isDirectory()\n ? findFiles(absolute, defaultExclude)\n : [absolute.split(path.sep).join('/')],\n ),\n );\n }\n for (const found of await Promise.all(lookups)) {\n targets.push(...found);\n }\n const extra: string[] = [];\n const extraReads: Promise<string>[] = [];\n for (const file of targets) {\n if (!sources.has(file)) {\n extra.push(file);\n extraReads.push(readFile(file, 'utf8'));\n }\n }\n const extraTexts = await Promise.all(extraReads);\n for (const [index, file] of extra.entries()) {\n sources.set(file, extraTexts[index]!);\n }\n return { sources, targets };\n}\n"],"mappings":";;;;;;AAoCA,SAAS,QAAQ,MAAsB;CACrC,OAAO,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;AACtC;AAEA,SAAS,SAAS,MAAuC;CACvD,IAAI;EACF,OAAO,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;CAC9C,QAAQ;EACN;CACF;AACF;;AAGA,SAAgB,qBAAqB,MAAc,MAAkC;CACnF,KAAK,IAAI,YAAY,OAAQ,YAAY,KAAK,QAAQ,SAAS,GAAG;EAChE,MAAM,YAAY,KAAK,KAAK,WAAW,gBAAgB,IAAI;EAC3D,IAAI,WAAW,KAAK,KAAK,WAAW,cAAc,CAAC,GACjD,OAAO,QAAQ,aAAa,SAAS,CAAC;EAExC,IAAI,KAAK,QAAQ,SAAS,MAAM,WAC9B;CAEJ;AACF;;AAGA,SAAS,YAAY,WAAuC;CAC1D,KAAK,IAAI,UAAU,YAAa,UAAU,KAAK,QAAQ,OAAO,GAAG;EAC/D,IAAI,WAAW,KAAK,KAAK,SAAS,cAAc,CAAC,GAC/C,OAAO;EAET,IAAI,KAAK,QAAQ,OAAO,MAAM,SAC5B;CAEJ;AACF;;AAMA,SAAS,gBAAgB,MAAc,OAAgB,MAAoC;CACzF,IAAI,UAAU,MACZ,OAAO,CAAC,IAAI;CAEd,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,EAAE,KAAK,UAAA,MAA6B;EAI1C,IAAI,YAAA,GACF,MAAM,IAAI,MACR,eAAe,KAAK,+BAA+B,QAAQ,wEAAwF,KAAK,6BAC1J;EAEF,IAAI,QAAQ,KAAA,GACV,OAAO,CAAC,IAAI;EAEd,MAAM,cAAwB,CAAC;EAC/B,KAAK,MAAM,QAAQ,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,GAAG,GAChD,YAAY,KAAK,Q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,MAAM,cAAc;CACpD,MAAM,0BAAU,IAAI,IAAoB;CACxC,MAAM,QAA2B,CAAC;CAClC,KAAK,MAAM,QAAQ,SACjB,MAAM,KAAK,SAAS,MAAM,MAAM,CAAC;CAEnC,MAAM,QAAQ,MAAM,QAAQ,IAAI,KAAK;CACrC,KAAK,MAAM,CAAC,OAAO,SAAS,QAAQ,QAAQ,GAC1C,QAAQ,IAAI,MAAM,MAAM,MAAO;CAGjC,MAAM,UAAoB,MAAM,WAAW,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC;CAC/D,MAAM,UAA+B,CAAC;CACtC,KAAK,MAAM,UAAU,OAAO;EAC1B,MAAM,WAAW,KAAK,QAAQ,MAAM,MAAM;EAC1C,QAAQ,KACN,KAAK,QAAQ,CAAC,CAAC,MAAM,SACnB,KAAK,YAAY,IACb,UAAU,UAAU,cAAc,IAClC,CAAC,SAAS,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CACzC,CACF;CACF;CACA,KAAK,MAAM,SAAS,MAAM,QAAQ,IAAI,OAAO,GAC3C,QAAQ,KAAK,GAAG,KAAK;CAEvB,MAAM,QAAkB,CAAC;CACzB,MAAM,aAAgC,CAAC;CACvC,KAAK,MAAM,QAAQ,SACjB,IAAI,CAAC,QAAQ,IAAI,IAAI,GAAG;EACtB,MAAM,KAAK,IAAI;EACf,WAAW,KAAK,SAAS,MAAM,MAAM,CAAC;CACxC;CAEF,MAAM,aAAa,MAAM,QAAQ,IAAI,UAAU;CAC/C,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GACxC,QAAQ,IAAI,MAAM,WAAW,MAAO;CAEtC,OAAO;EAAE;EAAS;CAAQ;AAC5B"}
|
|
1
|
+
{"version":3,"file":"files-ClQJlDcB.js","names":[],"sources":["../src/packages.ts","../src/server-files.ts","../src/files.ts"],"sourcesContent":["// Packages of components. A dependency of the app whose package.json has a\n// `brumate` field ships `.brm` files, `.brm.ts` modules and `'use server'`\n// files as source, and the plugin of the app compiles them with its own files.\n\nimport { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';\nimport path from 'node:path';\n\n/** A dependency of the app that ships `.brm` files. */\nexport interface BrumatePackage {\n /** The name of the package, such as `@acme/ui`. */\n name: string;\n version: string;\n /** The real path of the directory of the package, with forward slashes. */\n root: string;\n /** The directories to search for files, as absolute paths with forward slashes. */\n directories: string[];\n /**\n * The prefix of the names of its files, which their IDs come from: the\n * name of the package, and its version when the app has two versions.\n */\n prefix: string;\n /** True when the package is not inside `node_modules`, such as a workspace package. */\n linked: boolean;\n}\n\ninterface PackageJson {\n name?: string;\n version?: string;\n brumate?: unknown;\n exports?: unknown;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\nfunction toPosix(file: string): string {\n return file.split(path.sep).join('/');\n}\n\nfunction readJson(file: string): PackageJson | undefined {\n try {\n return JSON.parse(readFileSync(file, 'utf8')) as PackageJson;\n } catch {\n return undefined;\n }\n}\n\n/** The real directory of a package that code in `from` can import, or undefined. */\nexport function findPackageDirectory(name: string, from: string): string | undefined {\n for (let directory = from; ; directory = path.dirname(directory)) {\n const candidate = path.join(directory, 'node_modules', name);\n if (existsSync(path.join(candidate, 'package.json'))) {\n return toPosix(realpathSync(candidate));\n }\n if (path.dirname(directory) === directory) {\n return undefined;\n }\n }\n}\n\n/** The directory of the nearest package.json at or above a directory. */\nfunction packageRoot(directory: string): string | undefined {\n for (let current = directory; ; current = path.dirname(current)) {\n if (existsSync(path.join(current, 'package.json'))) {\n return current;\n }\n if (path.dirname(current) === current) {\n return undefined;\n }\n }\n}\n\n/** The version of the `brumate` field that this version of brumate reads. */\nexport const PACKAGE_FORMAT = 1;\n\n/** The directories that the `brumate` field names, or undefined when the package does not opt in. */\nfunction readDirectories(root: string, field: unknown, name: string): string[] | undefined {\n if (field === true) {\n return [root];\n }\n if (typeof field === 'object' && field !== null) {\n const { dir, version = PACKAGE_FORMAT } = field as {\n dir?: string | string[];\n version?: number;\n };\n if (version !== PACKAGE_FORMAT) {\n throw new Error(\n `The package ${name} has \"brumate\": { \"version\": ${version} }, but this version of brumate reads version ${PACKAGE_FORMAT}. Install a version of ${name} or of brumate that matches.`,\n );\n }\n if (dir === undefined) {\n return [root];\n }\n const directories: string[] = [];\n for (const item of Array.isArray(dir) ? dir : [dir]) {\n directories.push(toPosix(path.resolve(root, item)));\n }\n return directories;\n }\n return undefined;\n}\n\n/**\n * Finds the dependencies of the app at `root` that ship `.brm` files, and\n * theirs. The app's dependencies come from its package.json: `dependencies`,\n * `devDependencies`, `optionalDependencies` and `peerDependencies`. A package\n * opts in with `\"brumate\": true`, or `\"brumate\": { \"dir\": \"src\" }` to search\n * only that directory. Symbolic links, such as those of pnpm, resolve to the\n * real directory.\n */\nexport function findPackages(root: string): BrumatePackage[] {\n const app = packageRoot(path.resolve(root));\n if (!app) {\n return [];\n }\n const found = new Map<string, Omit<BrumatePackage, 'prefix'>>();\n function visit(directory: string, json: PackageJson, own: boolean): void {\n const names = new Set([\n ...Object.keys(json.dependencies ?? {}),\n ...Object.keys(json.optionalDependencies ?? {}),\n ...Object.keys(json.peerDependencies ?? {}),\n // The dev dependencies of a package are its own tools, not part of what it ships.\n ...(own ? Object.keys(json.devDependencies ?? {}) : []),\n ]);\n for (const name of [...names].toSorted()) {\n const real = findPackageDirectory(name, directory);\n if (!real || found.has(real)) {\n continue;\n }\n const dependency = readJson(`${real}/package.json`);\n const directories = dependency && readDirectories(real, dependency.brumate, name);\n if (!dependency || !directories) {\n continue;\n }\n found.set(real, {\n name: dependency.name ?? name,\n version: dependency.version ?? '0.0.0',\n root: real,\n directories,\n linked: !real.includes('/node_modules/'),\n });\n visit(real, dependency, false);\n }\n }\n visit(app, readJson(path.join(app, 'package.json')) ?? {}, true);\n const list = [...found.values()];\n // Two versions of one package get IDs apart. Copies of one version share theirs, as their files are the same.\n const versions = new Map<string, Set<string>>();\n for (const item of list) {\n versions.set(item.name, (versions.get(item.name) ?? new Set()).add(item.version));\n }\n const result: BrumatePackage[] = [];\n for (const item of list) {\n result.push(\n Object.assign(item, {\n prefix: versions.get(item.name)!.size > 1 ? `${item.name}@${item.version}` : item.name,\n }),\n );\n }\n return result;\n}\n\n/** The package that a file belongs to, or undefined for a file of the app. */\nexport function findPackage(packages: BrumatePackage[], file: string): BrumatePackage | undefined {\n for (const item of packages) {\n if (file.startsWith(`${item.root}/`)) {\n return item;\n }\n }\n return undefined;\n}\n\n/**\n * The name of a file of a package, which its IDs come from: the prefix of\n * the package and the path of the file in it, such as `@acme/ui/src/Button.brm`.\n * It is the same wherever the package is installed.\n */\nexport function packageFileName(item: BrumatePackage, file: string): string {\n return `${item.prefix}/${file.slice(item.root.length + 1)}`;\n}\n\n/** The name and the subpath of a bare specifier, such as `@acme/ui` and `./Button.brm`. */\nexport function splitSpecifier(specifier: string): { name: string; subpath: string } | undefined {\n if (specifier.startsWith('.') || specifier.startsWith('/') || /^[a-z]+:/i.test(specifier)) {\n return undefined;\n }\n const parts = specifier.split('/');\n const count = specifier.startsWith('@') ? 2 : 1;\n if (parts.length < count) {\n return undefined;\n }\n for (const part of parts.slice(0, count)) {\n if (part === '') {\n return undefined;\n }\n }\n const rest = parts.slice(count).join('/');\n return { name: parts.slice(0, count).join('/'), subpath: rest ? `./${rest}` : '.' };\n}\n\n/** The conditions of `exports` that a `.brm` file or a source module can be under. */\nconst CONDITIONS = new Set(['brumate', 'import', 'module', 'node', 'browser', 'default']);\n\nfunction resolveTarget(target: unknown, star: string): string | undefined {\n if (typeof target === 'string') {\n return target.replaceAll('*', star);\n }\n if (Array.isArray(target)) {\n for (const item of target) {\n const result = resolveTarget(item, star);\n if (result) {\n return result;\n }\n }\n return undefined;\n }\n if (typeof target === 'object' && target !== null) {\n for (const [condition, value] of Object.entries(target)) {\n if (CONDITIONS.has(condition)) {\n const result = resolveTarget(value, star);\n if (result) {\n return result;\n }\n }\n }\n }\n return undefined;\n}\n\n/** Resolves a subpath through the `exports` of a package.json, or undefined if it does not export it. */\nexport function resolveExports(exports: unknown, subpath: string): string | undefined {\n let hasSubpaths = false;\n if (typeof exports === 'object' && exports !== null && !Array.isArray(exports)) {\n for (const key of Object.keys(exports)) {\n if (key.startsWith('.')) {\n hasSubpaths = true;\n break;\n }\n }\n }\n const map = hasSubpaths ? (exports as Record<string, unknown>) : { '.': exports };\n if (subpath in map) {\n return resolveTarget(map[subpath], '');\n }\n // The pattern with the longest prefix wins, as in Node.\n let best: { key: string; star: string } | undefined;\n for (const key of Object.keys(map)) {\n const index = key.indexOf('*');\n if (index === -1) {\n continue;\n }\n const before = key.slice(0, index);\n const after = key.slice(index + 1);\n if (\n subpath.startsWith(before) &&\n subpath.endsWith(after) &&\n subpath.length >= key.length - 1 &&\n (!best || before.length > best.key.indexOf('*'))\n ) {\n best = { key, star: subpath.slice(before.length, subpath.length - after.length) };\n }\n }\n return best && resolveTarget(map[best.key], best.star);\n}\n\n/**\n * Resolves a bare specifier, such as `@acme/ui/Button.brm`, to the real path\n * of the file, through the `exports` of the package. Returns undefined when\n * it is not a bare specifier or names no file.\n */\nexport function resolvePackageImport(specifier: string, importer: string): string | undefined {\n const split = splitSpecifier(specifier);\n if (!split) {\n return undefined;\n }\n const directory = findPackageDirectory(split.name, path.dirname(importer));\n if (!directory) {\n return undefined;\n }\n const json = readJson(`${directory}/package.json`);\n const target =\n json?.exports === undefined ? split.subpath : resolveExports(json.exports, split.subpath);\n if (!target) {\n return undefined;\n }\n const file = path.resolve(directory, target);\n return existsSync(file) ? toPosix(realpathSync(file)) : undefined;\n}\n\n/**\n * Resolves a bare specifier like `resolvePackageImport`, but only for a\n * package of components in the list. Returns undefined for any other package.\n */\nexport function resolveComponentPackage(\n packages: BrumatePackage[],\n specifier: string,\n importer: string,\n): string | undefined {\n const name = splitSpecifier(specifier)?.name;\n for (const item of packages) {\n if (item.name === name) {\n return resolvePackageImport(specifier, importer);\n }\n }\n return undefined;\n}\n\n/** The specifiers that a file imports or exports from, found by a pattern, so it can only find more. */\nexport function importSpecifiers(source: string): string[] {\n const result: string[] = [];\n for (const match of source.matchAll(/(?:\\bfrom|\\bimport\\s*\\(?)\\s*(['\"])([^'\"\\n]+)\\1/g)) {\n result.push(match[2]!);\n }\n return result;\n}\n\n/** The extensions that an import without one can name. */\nconst EXTENSIONS = ['', '.ts', '.tsx', '.js', '.mjs', '/index.ts', '/index.js'];\n\n/**\n * The files of packages that the app reaches: the files of packages that\n * files of the app import, and the files of packages that those import, and\n * so on. Only these become server functions of the app.\n */\nexport function reachableFiles(\n packages: BrumatePackage[],\n appFiles: string[],\n read: (file: string) => string | undefined,\n): Set<string> {\n const reached = new Set<string>();\n const names = new Set<string>();\n for (const item of packages) {\n names.add(item.name);\n }\n const pending: string[] = [];\n function add(file: string | undefined): void {\n if (file && !reached.has(file) && findPackage(packages, file)) {\n reached.add(file);\n pending.push(file);\n }\n }\n function resolve(specifier: string, importer: string): string | undefined {\n if (specifier.startsWith('.')) {\n const stem = path.resolve(path.dirname(importer), specifier.split('?')[0]!);\n for (const extension of EXTENSIONS) {\n const candidate = stem + extension;\n if (statSync(candidate, { throwIfNoEntry: false })?.isFile()) {\n return toPosix(realpathSync(candidate));\n }\n }\n return undefined;\n }\n const name = splitSpecifier(specifier)?.name;\n return name && names.has(name)\n ? resolvePackageImport(specifier.split('?')[0]!, importer)\n : undefined;\n }\n function visit(file: string, own: boolean): void {\n const source = read(file);\n if (source === undefined) {\n return;\n }\n for (const specifier of importSpecifiers(source)) {\n // A file of the app reaches a package only by its name.\n if (own && specifier.startsWith('.')) {\n continue;\n }\n try {\n add(resolve(specifier, file));\n } catch {\n // A path that is not a file, such as a directory, reaches nothing.\n }\n }\n }\n for (const file of appFiles) {\n visit(file, true);\n }\n while (pending.length > 0) {\n visit(pending.pop()!, false);\n }\n return reached;\n}\n","// Files of server functions. A `.ts` or `.js` file whose first statement is\n// `'use server'` holds functions that only run on the server. Its exports are\n// server functions: the browser gets a stub for each one, which calls the\n// server, and the code of the file never ships.\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { parseSync } from 'oxc-parser';\nimport type { BrumatePackage } from './packages.ts';\nimport { resolveComponentPackage } from './packages.ts';\nimport { functionId } from './plan.ts';\n\n/** The import of the stubs, which call server functions with `rpc` of the core. */\nconst CLIENT = 'brumate/client';\n\n/** True for a file whose first statement is `'use server'`, after comments. */\nexport function hasUseServer(source: string): boolean {\n return /^(?:\\s|\\/\\/[^\\n]*\\n|\\/\\*[\\s\\S]*?\\*\\/)*(['\"])use server\\1/.test(source);\n}\n\n/** True for a path that can be a file of server functions. */\nexport function isScriptFile(path: string): boolean {\n return (\n /\\.[cm]?[jt]sx?$/.test(path) && !path.endsWith('.d.ts') && !/\\.brm\\.[cm]?[jt]s$/.test(path)\n );\n}\n\n/** True for a function expression or an arrow. */\ntype Program = ReturnType<typeof parseSync>['program'];\ntype Node = Program['body'][number] | { type: string; callee?: unknown } | null | undefined;\n\n/**\n * Tells a value that the file exports as a function: a function expression,\n * or a call of `cached` or `idempotent` of `brumate/server`, which return a function.\n */\nfunction functionTest(program: Program): (node: Node) => boolean {\n const wrappers = new Set<string>();\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration' && statement.source.value === 'brumate/server') {\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported.type === 'Identifier' &&\n (specifier.imported.name === 'cached' || specifier.imported.name === 'idempotent')\n ) {\n wrappers.add(specifier.local.name);\n }\n }\n }\n }\n return (node) => {\n if (node?.type === 'ArrowFunctionExpression' || node?.type === 'FunctionExpression') {\n return true;\n }\n const callee =\n node?.type === 'CallExpression'\n ? (node.callee as { type: string; name?: string })\n : undefined;\n return callee?.type === 'Identifier' && wrappers.has(callee.name!);\n };\n}\n\n/**\n * The names of the functions that a file of server functions exports.\n * Throws for an export that is not a function, because the browser can only\n * call a server function through its stub.\n */\nexport function serverExports(source: string, filename: string): string[] {\n const { program, errors } = parseSync(filename, source, { lang: 'ts' });\n if (errors[0]) {\n throw new Error(`${errors[0].message} (${filename})`);\n }\n const functions = new Set<string>();\n const values = new Set<string>();\n const local = new Map<string, 'function' | 'value'>();\n const isFunction = functionTest(program);\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n local.set(declaration.id.name, 'function');\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n local.set(declarator.id.name, isFunction(declarator.init) ? 'function' : 'value');\n }\n }\n }\n }\n for (const statement of program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n const value = statement.declaration;\n if (value.type === 'FunctionDeclaration' || isFunction(value)) {\n functions.add('default');\n } else {\n values.add('default');\n }\n } else if (statement.type === 'ExportNamedDeclaration') {\n if (statement.exportKind === 'type') {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n functions.add(declaration.id.name);\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n (isFunction(declarator.init) ? functions : values).add(declarator.id.name);\n }\n }\n } else if (declaration && !declaration.type.startsWith('TS')) {\n values.add('a class');\n }\n for (const specifier of statement.specifiers) {\n if (specifier.exportKind === 'type') {\n continue;\n }\n const name =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n const from = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n (local.get(from) === 'function' && !statement.source ? functions : values).add(name);\n }\n } else if (statement.type === 'ExportAllDeclaration') {\n values.add('*');\n }\n }\n if (values.size > 0) {\n throw new Error(\n `A 'use server' file exports only functions, because the browser calls them on the server. ${[...values].join(', ')} of ${filename} is not one`,\n );\n }\n // The middleware of the file runs before its functions. The browser cannot call it.\n functions.delete(MIDDLEWARE);\n return [...functions];\n}\n\n/** The export of a file of server functions that runs before each of them. */\nexport const MIDDLEWARE = 'middleware';\n\n/** True if a file of server functions exports `middleware`. */\nexport function hasServerMiddleware(source: string, filename: string): boolean {\n const { program } = parseSync(filename, source, { lang: 'ts' });\n for (const statement of program.body) {\n if (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id?.name === MIDDLEWARE) {\n return true;\n }\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && declarator.id.name === MIDDLEWARE) {\n return true;\n }\n }\n }\n for (const specifier of statement.specifiers) {\n const name =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (specifier.exportKind !== 'type' && name === MIDDLEWARE) {\n return true;\n }\n }\n }\n return false;\n}\n\n/** The module that the browser gets in place of a file of server functions. */\nexport function serverStubs(\n source: string,\n filename: string,\n id: string,\n hideNames = false,\n): string {\n const lines = [`import { rpc } from ${JSON.stringify(CLIENT)};`];\n for (const name of serverExports(source, filename)) {\n const call = `(...args) => rpc(${JSON.stringify(functionId(id, name, hideNames))}, args)`;\n lines.push(name === 'default' ? `export default ${call};` : `export const ${name} = ${call};`);\n }\n return `${lines.join('\\n')}\\n`;\n}\n\n/**\n * The module that the server runs for a file of server functions: the file,\n * with each exported function wrapped, so its calls while a page renders\n * share a result when their arguments are the same. Offsets stay the same.\n */\nexport function serverModule(source: string, filename: string, id: string): string {\n const { program } = parseSync(filename, source, { lang: 'ts' });\n const isFunction = functionTest(program);\n // Local names of exported functions, with the name that each is exported as.\n const wrapped = new Map<string, string>();\n const declarations = new Map<string, 'function' | 'const'>();\n let code = source;\n for (const statement of program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n declarations.set(declaration.id.name, 'function');\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && isFunction(declarator.init)) {\n declarations.set(declarator.id.name, 'const');\n }\n }\n }\n }\n function makeLet(declaration: { start: number; kind: string }): void {\n // `const` becomes `let `, so the function can be wrapped and offsets stay the same.\n if (declaration.kind === 'const') {\n code = `${code.slice(0, declaration.start)}let ${code.slice(declaration.start + 5)}`;\n }\n }\n for (const statement of program.body) {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n statement.source ||\n statement.exportKind === 'type'\n ) {\n continue;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'FunctionDeclaration' && declaration.id) {\n wrapped.set(declaration.id.name, declaration.id.name);\n } else if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier' && isFunction(declarator.init)) {\n wrapped.set(declarator.id.name, declarator.id.name);\n makeLet(declaration);\n }\n }\n }\n for (const specifier of statement.specifiers) {\n const local = specifier.local.type === 'Identifier' ? specifier.local.name : '';\n const exported =\n specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value;\n if (declarations.has(local)) {\n wrapped.set(local, exported);\n }\n }\n }\n // A `const` arrow that `export { name }` exports is declared with `let` too.\n for (const statement of program.body) {\n if (statement.type === 'VariableDeclaration') {\n for (const declarator of statement.declarations) {\n if (declarator.id.type === 'Identifier' && wrapped.has(declarator.id.name)) {\n makeLet(statement);\n }\n }\n }\n }\n if (wrapped.size === 0) {\n return source;\n }\n const lines = [\"import { dedupe as __brumateDedupe } from 'brumate/server';\"];\n for (const [local, exported] of wrapped) {\n lines.push(`${local} = __brumateDedupe(${local}, ${JSON.stringify(`${id}#${exported}`)});`);\n }\n return `${code}\\n${lines.join('\\n')}\\n`;\n}\n\n/**\n * The file of a relative import that holds server functions, such as `./issues` for `issues.ts`\n * with `'use server'` first, or undefined. A package specifier is not looked up.\n */\nexport function findServerImport(importer: string, specifier: string): string | undefined {\n if (!specifier.startsWith('.')) {\n return undefined;\n }\n const stem = path.resolve(path.dirname(importer), specifier);\n const candidates = [stem];\n for (const extension of ['.ts', '.tsx', '.js', '.mjs']) {\n candidates.push(stem + extension);\n }\n for (const candidate of candidates) {\n if (\n isScriptFile(candidate) &&\n existsSync(candidate) &&\n hasUseServer(readFileSync(candidate, 'utf8'))\n ) {\n return candidate;\n }\n }\n return undefined;\n}\n\n/**\n * The file of server functions that a package of components exports under a\n * bare specifier, or undefined.\n */\nexport function findPackageServerFile(\n packages: BrumatePackage[],\n importer: string,\n specifier: string,\n): string | undefined {\n const file = resolveComponentPackage(packages, specifier, importer);\n return file && isScriptFile(file) && hasUseServer(readFileSync(file, 'utf8')) ? file : undefined;\n}\n","import { readFile, readdir, stat } from 'node:fs/promises';\nimport path from 'node:path';\nimport { hasUseServer, isScriptFile } from './server-files.ts';\n\n/** Skips `node_modules`, `dist` and hidden directories when looking for `.brm` files. */\nexport function defaultExclude(directory: string): boolean {\n return directory === 'node_modules' || directory === 'dist' || directory.startsWith('.');\n}\n\n/** Finds every `.brm` file under a directory, as absolute paths with forward slashes. */\nexport async function findFiles(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n const directories: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n directories.push(visit(file));\n }\n } else if (entry.name.endsWith('.brm')) {\n result.push(file.split(path.sep).join('/'));\n }\n }\n await Promise.all(directories);\n }\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Finds every file of server functions under a directory: a script whose\n * first statement is `'use server'`.\n */\nexport async function findServerFiles(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n const pending: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n pending.push(visit(file));\n }\n } else if (isScriptFile(entry.name)) {\n pending.push(\n readFile(file, 'utf8').then((source) => {\n if (hasUseServer(source)) {\n result.push(file.split(path.sep).join('/'));\n }\n }),\n );\n }\n }\n await Promise.all(pending);\n }\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Finds every script under a directory, such as `.ts` and `.brm.ts` files, as\n * absolute paths with forward slashes, without reading them.\n */\nexport async function findScripts(\n root: string,\n exclude: (directory: string) => boolean,\n): Promise<string[]> {\n const result: string[] = [];\n async function visit(directory: string): Promise<void> {\n const directories: Promise<void>[] = [];\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const file = path.join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!exclude(entry.name)) {\n directories.push(visit(file));\n }\n } else if (/\\.[cm]?[jt]sx?$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {\n result.push(file.split(path.sep).join('/'));\n }\n }\n await Promise.all(directories);\n }\n await visit(root);\n return result.toSorted();\n}\n\n/**\n * Reads every `.brm` file under a root, and finds the files that the paths\n * name: a file, or the files under a directory. Without paths, the targets are\n * the whole project. A file outside the root is read too. A path that does not\n * exist throws.\n */\nexport async function collectSources(\n root: string,\n paths: string[],\n): Promise<{ sources: Map<string, string>; targets: string[] }> {\n const project = await findFiles(root, defaultExclude);\n const sources = new Map<string, string>();\n const reads: Promise<string>[] = [];\n for (const file of project) {\n reads.push(readFile(file, 'utf8'));\n }\n const texts = await Promise.all(reads);\n for (const [index, file] of project.entries()) {\n sources.set(file, texts[index]!);\n }\n\n const targets: string[] = paths.length === 0 ? [...project] : [];\n const lookups: Promise<string[]>[] = [];\n for (const target of paths) {\n const absolute = path.resolve(root, target);\n lookups.push(\n stat(absolute).then((info) =>\n info.isDirectory()\n ? findFiles(absolute, defaultExclude)\n : [absolute.split(path.sep).join('/')],\n ),\n );\n }\n for (const found of await Promise.all(lookups)) {\n targets.push(...found);\n }\n const extra: string[] = [];\n const extraReads: Promise<string>[] = [];\n for (const file of targets) {\n if (!sources.has(file)) {\n extra.push(file);\n extraReads.push(readFile(file, 'utf8'));\n }\n }\n const extraTexts = await Promise.all(extraReads);\n for (const [index, file] of extra.entries()) {\n sources.set(file, extraTexts[index]!);\n }\n return { sources, targets };\n}\n"],"mappings":";;;;;;AAoCA,SAAS,QAAQ,MAAsB;CACrC,OAAO,KAAK,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;AACtC;AAEA,SAAS,SAAS,MAAuC;CACvD,IAAI;EACF,OAAO,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;CAC9C,QAAQ;EACN;CACF;AACF;;AAGA,SAAgB,qBAAqB,MAAc,MAAkC;CACnF,KAAK,IAAI,YAAY,OAAQ,YAAY,KAAK,QAAQ,SAAS,GAAG;EAChE,MAAM,YAAY,KAAK,KAAK,WAAW,gBAAgB,IAAI;EAC3D,IAAI,WAAW,KAAK,KAAK,WAAW,cAAc,CAAC,GACjD,OAAO,QAAQ,aAAa,SAAS,CAAC;EAExC,IAAI,KAAK,QAAQ,SAAS,MAAM,WAC9B;CAEJ;AACF;;AAGA,SAAS,YAAY,WAAuC;CAC1D,KAAK,IAAI,UAAU,YAAa,UAAU,KAAK,QAAQ,OAAO,GAAG;EAC/D,IAAI,WAAW,KAAK,KAAK,SAAS,cAAc,CAAC,GAC/C,OAAO;EAET,IAAI,KAAK,QAAQ,OAAO,MAAM,SAC5B;CAEJ;AACF;;AAMA,SAAS,gBAAgB,MAAc,OAAgB,MAAoC;CACzF,IAAI,UAAU,MACZ,OAAO,CAAC,IAAI;CAEd,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,EAAE,KAAK,UAAA,MAA6B;EAI1C,IAAI,YAAA,GACF,MAAM,IAAI,MACR,eAAe,KAAK,+BAA+B,QAAQ,wEAAwF,KAAK,6BAC1J;EAEF,IAAI,QAAQ,KAAA,GACV,OAAO,CAAC,IAAI;EAEd,MAAM,cAAwB,CAAC;EAC/B,KAAK,MAAM,QAA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
2067
2067
|
*/
|
|
2068
2068
|
parts: Record<string, string>;
|
|
2069
|
-
/** The parts that the entry loads for each part name, its own first. See `ClientOutput`. */
|
|
2070
|
-
loaders: Record<string, string[]>;
|
|
2071
2069
|
/** The ID, the props map and the update tables of the client entry, without code. */
|
|
2072
2070
|
table: string;
|
|
2073
2071
|
/** False when nothing of the component runs in the browser, so it needs no client module. */
|
|
@@ -2163,7 +2161,7 @@ interface SharedContext {
|
|
|
2163
2161
|
//#endregion
|
|
2164
2162
|
//#region src/codegen/client.d.ts
|
|
2165
2163
|
interface ClientOutput {
|
|
2166
|
-
/** The entry module: the component ID, its props, its update table
|
|
2164
|
+
/** The entry module: the component ID, its props, and its update table. */
|
|
2167
2165
|
code: string;
|
|
2168
2166
|
/**
|
|
2169
2167
|
* The parts, by name. `h<n>` and `c<n>` parts hold one client root each,
|
|
@@ -2173,11 +2171,6 @@ interface ClientOutput {
|
|
|
2173
2171
|
parts: Record<string, string>;
|
|
2174
2172
|
/** The ID, the props map, the update table and the refresh table: what the page depends on. */
|
|
2175
2173
|
table: string;
|
|
2176
|
-
/**
|
|
2177
|
-
* The parts that each export part loads, by name: its own first, then the
|
|
2178
|
-
* ones it starts loading with it. Empty when the entry holds the code.
|
|
2179
|
-
*/
|
|
2180
|
-
loaders: Record<string, string[]>;
|
|
2181
2174
|
/** False when nothing of the component runs in the browser. */
|
|
2182
2175
|
clientCode: boolean;
|
|
2183
2176
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as analyzeProject, B as getLocation, D as unmarked, F as summarize, G as isWithin, H as findError, I as parse, K as lookup, L as buildGraph, P as resolveRelative, S as sharedSites, U as analyze, V as errorLink, W as getPatternNames, b as SHARED_QUERY, d as generateServer$1, g as createPlan, h as clientState, i as report, j as analyzeProjectProps, l as generateClient$1, m as blockBodies, n as formatReport, o as CompileError, r as inspect, s as compile, u as generateRender$1, v as getComponentName, x as generateShared, z as BrumateError } from "./inspect-
|
|
1
|
+
import { A as analyzeProject, B as getLocation, D as unmarked, F as summarize, G as isWithin, H as findError, I as parse, K as lookup, L as buildGraph, P as resolveRelative, S as sharedSites, U as analyze, V as errorLink, W as getPatternNames, b as SHARED_QUERY, d as generateServer$1, g as createPlan, h as clientState, i as report, j as analyzeProjectProps, l as generateClient$1, m as blockBodies, n as formatReport, o as CompileError, r as inspect, s as compile, u as generateRender$1, v as getComponentName, x as generateShared, z as BrumateError } from "./inspect-B8i6R3mZ.js";
|
|
2
2
|
//#region src/print.ts
|
|
3
3
|
function at(source, range) {
|
|
4
4
|
const { line, column } = getLocation(source, range.start);
|