brumate 0.4.0 → 0.4.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/{boot-DLlRmD9z.d.ts → boot-SCWYwuUd.d.ts} +2 -2
- package/dist/cli.js +2 -2
- package/dist/{client-BvDsC6Qr.js → client-BBtVTOIt.js} +71 -28
- package/dist/client-BBtVTOIt.js.map +1 -0
- package/dist/{client-DBwL2wKQ.d.ts → client-Cs3o4key.d.ts} +3 -3
- package/dist/{defer-CKWZLv2K.js → defer-BLJjxqVc.js} +2 -2
- package/dist/{defer-CKWZLv2K.js.map → defer-BLJjxqVc.js.map} +1 -1
- package/dist/{devtools-4uTPwR_v.js → devtools-DTpsVFbn.js} +4 -4
- package/dist/{devtools-4uTPwR_v.js.map → devtools-DTpsVFbn.js.map} +1 -1
- package/dist/{devtools-panel-Be9pxYgv.js → devtools-panel-C1Dfv6nq.js} +2 -2
- package/dist/{devtools-panel-Be9pxYgv.js.map → devtools-panel-C1Dfv6nq.js.map} +1 -1
- package/dist/{files-WW4RlajL.js → files-DZIiMDnS.js} +2 -2
- package/dist/{files-WW4RlajL.js.map → files-DZIiMDnS.js.map} +1 -1
- package/dist/{html-BtKRyi7g.js → html-DS9B1H-M.js} +10 -4
- package/dist/html-DS9B1H-M.js.map +1 -0
- package/dist/{html-Bw9Qwu6F.d.ts → html-Gggepsf-.d.ts} +4 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/{inspect-Y6y4uNZp.js → inspect-DomFHy5O.js} +67 -5
- package/dist/inspect-DomFHy5O.js.map +1 -0
- package/dist/{loader-BjKGJzLN.js → loader-D62komKu.js} +2 -2
- package/dist/{loader-BjKGJzLN.js.map → loader-D62komKu.js.map} +1 -1
- package/dist/{produce-B7X9ori9.js → produce-BNIpmZq2.js} +4 -3
- package/dist/produce-BNIpmZq2.js.map +1 -0
- package/dist/{produce-DIgHBVwL.d.ts → produce-CRfouraC.d.ts} +6 -1
- package/dist/{rpc-Q-XkLwFh.js → rpc-BTMb8jap.js} +3 -3
- package/dist/{rpc-Q-XkLwFh.js.map → rpc-BTMb8jap.js.map} +1 -1
- package/dist/runtime/client.d.ts +3 -3
- package/dist/runtime/client.js +3 -3
- package/dist/runtime/devtools.d.ts +2 -2
- package/dist/runtime/devtools.js +1 -1
- package/dist/runtime/hot.d.ts +1 -1
- package/dist/runtime/html.d.ts +2 -2
- package/dist/runtime/html.js +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 +3 -3
- 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-DjyOVJtJ.js → server-BTtsQFFw.js} +47 -11
- package/dist/server-BTtsQFFw.js.map +1 -0
- package/dist/{server-BvPIg9pT.d.ts → server-CYw15Dsg.d.ts} +22 -3
- package/dist/{static-loader-BZR17hSw.js → static-loader-C_GYIFtt.js} +4 -3
- package/dist/{static-loader-BZR17hSw.js.map → static-loader-C_GYIFtt.js.map} +1 -1
- package/dist/{static-loader-BGgdp_Y5.d.ts → static-loader-DVuLmXeu.d.ts} +2 -2
- package/dist/{stream-BP5AVmg5.js → stream-r4V5zBKm.js} +4 -4
- package/dist/stream-r4V5zBKm.js.map +1 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +72 -12
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/client-BvDsC6Qr.js.map +0 -1
- package/dist/html-BtKRyi7g.js.map +0 -1
- package/dist/inspect-Y6y4uNZp.js.map +0 -1
- package/dist/produce-B7X9ori9.js.map +0 -1
- package/dist/server-DjyOVJtJ.js.map +0 -1
- package/dist/stream-BP5AVmg5.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as functionId } from "./inspect-
|
|
1
|
+
import { _ as functionId } from "./inspect-DomFHy5O.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-DZIiMDnS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-WW4RlajL.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,IA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,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-DZIiMDnS.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,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AAM,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,5 +1,6 @@
|
|
|
1
1
|
//#region src/runtime/html.ts
|
|
2
2
|
const RAW = Symbol.for("brumate.raw");
|
|
3
|
+
const INTERNAL = Symbol.for("brumate.internal");
|
|
3
4
|
var RawHTML = class {
|
|
4
5
|
[RAW];
|
|
5
6
|
constructor(html) {
|
|
@@ -195,19 +196,24 @@ var Internal = class {
|
|
|
195
196
|
this.value = value;
|
|
196
197
|
}
|
|
197
198
|
};
|
|
199
|
+
Internal.prototype[INTERNAL] = true;
|
|
200
|
+
/** True for an `Internal`, also one that another copy of the runtime made. */
|
|
201
|
+
function isInternal(value) {
|
|
202
|
+
return typeof value === "object" && value !== null && INTERNAL in value;
|
|
203
|
+
}
|
|
198
204
|
/** Wraps the value of an attribute that brumate writes. See `Internal`. */
|
|
199
205
|
function internal(value) {
|
|
200
206
|
return new Internal(value);
|
|
201
207
|
}
|
|
202
208
|
/** The value of an attribute of an object, or undefined for a `b-` attribute from outside. */
|
|
203
209
|
function ownValue(name, value) {
|
|
204
|
-
if (value
|
|
210
|
+
if (isInternal(value)) return value.value;
|
|
205
211
|
return name.startsWith("b-") ? void 0 : value;
|
|
206
212
|
}
|
|
207
213
|
function mergeAttributes(parts, variables) {
|
|
208
214
|
const result = {};
|
|
209
215
|
for (const part of parts) for (const [name, value] of Object.entries(part ?? {})) {
|
|
210
|
-
if (name.startsWith("b-") && !(value
|
|
216
|
+
if (name.startsWith("b-") && !isInternal(value)) continue;
|
|
211
217
|
result[name] = name === "class" && result.class !== void 0 && value !== void 0 ? [result.class, value] : value;
|
|
212
218
|
}
|
|
213
219
|
if (variables) result.style = vars(variables, result.style);
|
|
@@ -300,6 +306,6 @@ function actionAttributes(prefix, name, id, method, result, build, key) {
|
|
|
300
306
|
return ` ${name}="${escapeAttribute(`${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ""}`)}"${methodText}`;
|
|
301
307
|
}
|
|
302
308
|
//#endregion
|
|
303
|
-
export {
|
|
309
|
+
export { spread as C, vars as E, rawHTML as S, textValue as T, mergeAttributes as _, attribute as a, ownValue as b, classAttribute as c, escapeAttribute as d, handlerEntry as f, isRaw as g, isInternal as h, affix as i, classValue as l, internal as m, VOID_ELEMENTS as n, attributeText as o, insertValue as p, actionAttributes as r, bindEntry as s, Internal as t, escape as u, onAttribute as v, styleElement as w, raw as x, onValue as y };
|
|
304
310
|
|
|
305
|
-
//# sourceMappingURL=html-
|
|
311
|
+
//# sourceMappingURL=html-DS9B1H-M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-DS9B1H-M.js","names":[],"sources":["../src/runtime/html.ts"],"sourcesContent":["// HTML string helpers that the server and the client both use.\n\nconst RAW: unique symbol = Symbol.for('brumate.raw');\nconst INTERNAL: unique symbol = Symbol.for('brumate.internal');\n\n/** HTML that is inserted as it is, such as the output of a template. */\nexport interface Raw {\n [RAW]: string;\n}\n\n// A class, not an object literal, so serializers can skip their test for raw HTML on plain objects.\nclass RawHTML implements Raw {\n readonly [RAW]: string;\n\n constructor(html: string) {\n this[RAW] = html;\n }\n}\n\nexport function raw(html: string): Raw {\n return new RawHTML(html);\n}\n\nexport function isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && RAW in value;\n}\n\nexport function rawHTML(value: Raw): string {\n return value[RAW];\n}\n\nconst ESCAPES: Record<string, string> = { '&': '&', '<': '<', '>': '>', '\"': '"' };\n\nfunction toEscape(char: string): string {\n return ESCAPES[char]!;\n}\n\n// Most text has nothing to escape, so a test without the global flag skips the replace.\nexport function escape(value: string): string {\n return /[&<>]/.test(value) ? value.replace(/[&<>]/g, toEscape) : value;\n}\n\nexport function escapeAttribute(value: string): string {\n return /[&<\"]/.test(value) ? value.replace(/[&<\"]/g, toEscape) : value;\n}\n\n/** True for a promise, or any object with a `then` function, as the server awaits it. */\nfunction isThenable(value: unknown): boolean {\n return (\n value !== null &&\n (typeof value === 'object' || typeof value === 'function') &&\n typeof (value as PromiseLike<unknown>).then === 'function'\n );\n}\n\n/** Renders a value inserted in markup. A promise is not awaited: it renders empty. */\nexport function insertValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n // A memo of a promise that is still loading: empty until its value lands.\n if (value === null || value === undefined || typeof value === 'boolean' || isThenable(value)) {\n return '';\n }\n if (Array.isArray(value)) {\n let result = '';\n for (const item of value) {\n result += insertValue(item);\n }\n return result;\n }\n return escape(String(value));\n}\n\n/**\n * Renders a value as the text of an element whose content is text, such as\n * a `<textarea>`, as `insertValue` does but without escaping.\n */\nexport function textValue(value: unknown): string {\n if (isRaw(value)) {\n return value[RAW];\n }\n if (value === null || value === undefined || typeof value === 'boolean' || isThenable(value)) {\n return '';\n }\n if (Array.isArray(value)) {\n let result = '';\n for (const item of value) {\n result += textValue(item);\n }\n return result;\n }\n return String(value);\n}\n\nfunction toKebabCase(name: string): string {\n return name.startsWith('--') ? name : name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\nexport function classValue(value: unknown): string {\n if (typeof value !== 'object' || value === null) {\n return value ? String(value) : '';\n }\n let text = '';\n if (Array.isArray(value)) {\n for (const item of value) {\n const part = classValue(item);\n if (part !== '') {\n text = text === '' ? part : `${text} ${part}`;\n }\n }\n return text;\n }\n // An empty name still adds a space between its neighbours, as in a join.\n let first = true;\n for (const name in value) {\n if (Object.hasOwn(value, name) && (value as Record<string, unknown>)[name]) {\n text = first ? name : `${text} ${name}`;\n first = false;\n }\n }\n return text;\n}\n\n/**\n * Renders a `class` attribute from classes that each have a space before\n * them, which the compiler builds from a literal class value. The classes\n * are escaped already. No class renders nothing.\n */\nexport function classAttribute(classes: string): string {\n return classes === '' ? '' : ` class=\"${classes.slice(1)}\"`;\n}\n\nfunction styleValue(value: unknown): string {\n if (typeof value === 'object' && value !== null) {\n const declarations: string[] = [];\n for (const [name, item] of Object.entries(value)) {\n if (item !== null && item !== undefined && item !== false) {\n declarations.push(`${toKebabCase(name)}:${String(item)}`);\n }\n }\n return declarations.join(';');\n }\n return String(value);\n}\n\n/** The brand of a binding of `$bind`, under the key of the registry. See `Binding`. */\nconst BOUND = Symbol.for('brumate.binding');\n\n/** The words of an attribute that says `true` or `false` in its value. */\nconst TRUE_FALSE = ['true', 'false'] as const;\n\n/**\n * Attributes whose two states are words in the value, not whether the\n * attribute is there, by their words for `true` and `false`. A missing\n * attribute means a third state, such as the default of the element, so\n * `false` must not remove it. `aria-*` and `data-*` are such attributes too.\n */\nconst SWITCHES = new Map<string, readonly [string, string]>([\n ['contenteditable', TRUE_FALSE],\n ['draggable', TRUE_FALSE],\n ['spellcheck', TRUE_FALSE],\n ['writingsuggestions', TRUE_FALSE],\n // SVG.\n ['focusable', TRUE_FALSE],\n ['translate', ['yes', 'no']],\n ['autocomplete', ['on', 'off']],\n ['autocorrect', ['on', 'off']],\n]);\n\n/** The words of `true` and `false` for an attribute that says them in its value, or undefined. */\nfunction switchWords(name: string): readonly [string, string] | undefined {\n const lower = name.toLowerCase();\n if (lower.startsWith('aria-') || lower.startsWith('data-')) {\n return TRUE_FALSE;\n }\n return SWITCHES.get(lower);\n}\n\n/**\n * Returns the text of an attribute, or undefined if the attribute is not\n * rendered.\n *\n * - `null` and `undefined` leave the attribute out.\n * - For an attribute whose value says its state, such as `aria-expanded`,\n * `draggable` or `translate`, `true` and `false` render as its words:\n * `\"true\"` and `\"false\"`, or `\"yes\"` and `\"no\"`, or `\"on\"` and `\"off\"`.\n * - For other attributes, such as `disabled`, `true` renders the attribute\n * without a value, and `false` leaves it out.\n */\nexport function attributeText(name: string, value: unknown): string | undefined {\n // `value=$bind(name)` on an element renders the value of the name.\n if (typeof value === 'object' && value !== null && BOUND in value) {\n // A `ref` is no attribute: the element goes to its signal.\n if (name === 'ref') {\n return undefined;\n }\n value = (value as unknown as { value: unknown }).value;\n }\n // A promise is a memo that is still loading: the attribute is absent until its value lands.\n if (value === null || value === undefined || typeof value === 'function' || isThenable(value)) {\n return undefined;\n }\n if (typeof value === 'boolean') {\n const words = switchWords(name);\n if (words) {\n return value ? words[0] : words[1];\n }\n return value ? '' : undefined;\n }\n if (name === 'class') {\n const text = classValue(value);\n return text === '' ? undefined : text;\n }\n return name === 'style' ? styleValue(value) : String(value);\n}\n\n/**\n * A name that HTML reads as one attribute. A spread takes its names from\n * data, so a name with a space, a quote, `>`, `/` or `=` could write other\n * attributes or markup.\n */\n// oxlint-disable-next-line no-control-regex -- HTML reads no control character in a name.\nconst ATTRIBUTE_NAME = /^[^\\s\"'>/=\\x00-\\x1f\\x7f]+$/;\n\n/** Renders one attribute, with a leading space. A name that is not one attribute renders nothing. */\nexport function attribute(name: string, value: unknown): string {\n const text = attributeText(name, value);\n if (text === undefined || !ATTRIBUTE_NAME.test(name)) {\n return '';\n }\n return value === true && text === '' ? ` ${name}` : ` ${name}=\"${escapeAttribute(text)}\"`;\n}\n\n/**\n * Returns the value of a style variable with text around it, such as `12px`\n * for `${size}px`. A value that sets no variable stays as it is.\n */\nexport function affix(prefix: string, value: unknown, suffix: string): unknown {\n return value === null || value === undefined || value === false\n ? value\n : `${prefix}${String(value)}${suffix}`;\n}\n\n/** Returns a style with custom properties before an element's own style. */\nexport function vars(variables: Record<string, unknown>, own: unknown): string {\n const parts: string[] = [];\n for (const [name, value] of Object.entries(variables)) {\n if (value !== null && value !== undefined && value !== false) {\n parts.push(`${name}:${String(value)}`);\n }\n }\n const rest = own === null || own === undefined || own === false ? '' : styleValue(own);\n if (rest) {\n parts.push(rest);\n }\n return parts.join(';');\n}\n\n/** Returns a `<style>` element for a component's stylesheet. */\nexport function styleElement(id: string, css: string): string {\n return `<style b-style=\"${escapeAttribute(id)}\">${css.replace(/<\\/style/gi, '<\\\\/style')}</style>`;\n}\n\n/**\n * Merges the attributes of an element that has spreads, in their order: a\n * later value wins, except `class`, whose values all apply.\n */\n/**\n * A value of an attribute that brumate writes, such as the `b-on` of a dynamic tag, which the\n * compiler wraps. An object of attributes, such as a spread, writes a `b-` attribute only with\n * one, so data from outside the app cannot name handlers or scopes.\n */\nexport class Internal {\n readonly value: unknown;\n\n constructor(value: unknown) {\n this.value = value;\n }\n}\n\n// The brand sits on the prototype, so an instance does not carry a field for it.\n(Internal.prototype as unknown as Record<symbol, boolean>)[INTERNAL] = true;\n\n/** True for an `Internal`, also one that another copy of the runtime made. */\nexport function isInternal(value: unknown): value is Internal {\n return typeof value === 'object' && value !== null && INTERNAL in value;\n}\n\n/** Wraps the value of an attribute that brumate writes. See `Internal`. */\nexport function internal(value: unknown): Internal {\n return new Internal(value);\n}\n\n/** The value of an attribute of an object, or undefined for a `b-` attribute from outside. */\nexport function ownValue(name: string, value: unknown): unknown {\n if (isInternal(value)) {\n return value.value;\n }\n return name.startsWith('b-') ? undefined : value;\n}\n\nexport function mergeAttributes(\n parts: Record<string, unknown>[],\n variables?: Record<string, unknown>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const part of parts) {\n for (const [name, value] of Object.entries(part ?? {})) {\n // A `b-` attribute from outside the app does not take the place of brumate's own.\n if (name.startsWith('b-') && !isInternal(value)) {\n continue;\n }\n result[name] =\n name === 'class' && result.class !== undefined && value !== undefined\n ? [result.class, value]\n : value;\n }\n }\n // The style variables of the component come before the style that won, whoever gave it.\n if (variables) {\n result.style = vars(variables, result.style);\n }\n return result;\n}\n\n/**\n * The `b-on` entry of a handler that a spread passes on, such as\n * `click:prevent=Parent#h1@3`: its event, the modifiers of its wrappers, its\n * client function and the scope it runs in. A handler that `$handler` made\n * has its arguments after another `@`, encoded so that they hold no space.\n */\nexport function handlerEntry(\n name: string,\n ref: string,\n scope: number | string,\n modifiers: readonly string[] = [],\n args?: unknown[],\n): string {\n const bound = args === undefined ? '' : `@${encodeURIComponent(JSON.stringify(args))}`;\n return `${[name.slice(2).toLowerCase(), ...modifiers].join(':')}=${ref}@${scope}${bound}`;\n}\n\n/**\n * The `b-on` entry of a binding that a spread puts on `value` or `checked`\n * of an element. It names the scope of the slot, or of the setter of\n * `$bind(name, fn)`, after `@`. A box writes on `change`.\n */\nexport function bindEntry(\n name: string,\n ref: { scope: number | string; slot: number },\n setter?: { ref: string; scope: number | string },\n): string {\n const event = name === 'checked' ? 'change' : 'input';\n return setter\n ? `${event}=$set:${setter.ref}@${setter.scope}`\n : `${event}=$bind#0.${ref.slot}@${ref.scope}`;\n}\n\n/**\n * The `b-on` attribute of an element with spreads: the bindings of its\n * spreads, so its handlers read the new value, then its own handlers, then\n * those of its spreads.\n */\nexport function onAttribute(on: string[], own: string): string {\n const value = onValue(on, own);\n return value ? ` b-on=\"${escapeAttribute(value)}\"` : '';\n}\n\n/** The value of `b-on`, in the order of `onAttribute`. */\nexport function onValue(on: string[], own: string): string {\n const bindings: string[] = [];\n const rest: string[] = [];\n for (const entry of on) {\n if (/=\\$(bind#|set:)/.test(entry)) {\n bindings.push(entry);\n } else {\n rest.push(entry);\n }\n }\n const parts: string[] = [];\n for (const part of [...bindings, own, ...rest]) {\n if (part) {\n parts.push(part);\n }\n }\n return parts.join(' ');\n}\n\n/** Renders an object of attributes. */\nexport function spread(attributes: Record<string, unknown>, names = false): string {\n let result = '';\n const written: string[] = [];\n for (const [name, value] of Object.entries(attributes)) {\n if (name !== 'children' && !/^on[A-Z]/.test(name)) {\n const text = attribute(name, ownValue(name, value));\n if (text) {\n result += text;\n written.push(name);\n }\n }\n }\n // `b-s` names the attributes of a spread that changes in the browser. Its first update there\n // removes only those, so a spread that wrote none still writes it, empty.\n return names ? `${result} b-s=\"${written.join(' ')}\"` : result;\n}\n\nexport const VOID_ELEMENTS: Set<string> = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/**\n * Renders the attributes of a form that posts to a server function, such as\n * ` action=\"/_brumate/App_1abc%23save\" method=\"post\"`. `method` is the name of\n * the method attribute to add, if the element has none. `build` is the ID\n * of the build of the page, which the URL carries as `__build`, so the\n * server can tell a post from before a deploy without scripts.\n */\nexport function actionAttributes(\n prefix: string,\n name: string,\n id: string,\n method?: string,\n result?: string,\n build?: string,\n key?: string,\n): string {\n const methodText = method ? ` ${method}=\"post\"` : '';\n // The key of a form of a function that `idempotent` made, so a second post gets the first result.\n const params: string[] = [];\n if (build !== undefined) {\n params.push(`__build=${encodeURIComponent(build)}`);\n }\n if (key !== undefined) {\n params.push(`__key=${key}`);\n }\n const query = params.join('&');\n if (result !== undefined) {\n // The form posts to its page, which renders with the result. With the\n // loader, the result is written into the `$action` at `result` instead.\n const url = `?__action=${encodeURIComponent(id)}${query ? `&${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText} b-action=\"${escapeAttribute(id)}\" b-result=\"${escapeAttribute(result)}\"`;\n }\n const url = `${prefix}/${encodeURIComponent(id)}${query ? `?${query}` : ''}`;\n return ` ${name}=\"${escapeAttribute(url)}\"${methodText}`;\n}\n"],"mappings":";AAEA,MAAM,MAAqB,OAAO,IAAI,aAAa;AACnD,MA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62
|
+
/** True for an `Internal`, also one that another copy of the runtime made. */
|
|
63
|
+
declare function isInternal(value: unknown): value is Internal;
|
|
62
64
|
/** Wraps the value of an attribute that brumate writes. See `Internal`. */
|
|
63
65
|
declare function internal(value: unknown): Internal;
|
|
64
66
|
/** The value of an attribute of an object, or undefined for a `b-` attribute from outside. */
|
|
@@ -103,5 +105,5 @@ declare const VOID_ELEMENTS: Set<string>;
|
|
|
103
105
|
*/
|
|
104
106
|
declare function actionAttributes(prefix: string, name: string, id: string, method?: string, result?: string, build?: string, key?: string): string;
|
|
105
107
|
//#endregion
|
|
106
|
-
export {
|
|
107
|
-
//# sourceMappingURL=html-
|
|
108
|
+
export { rawHTML as C, vars as D, textValue as E, raw as S, styleElement as T, isRaw as _, affix as a, onValue as b, bindEntry as c, escape as d, escapeAttribute as f, isInternal as g, internal as h, actionAttributes as i, classAttribute as l, insertValue as m, Raw as n, attribute as o, handlerEntry as p, VOID_ELEMENTS as r, attributeText as s, Internal as t, classValue as u, mergeAttributes as v, spread as w, ownValue as x, onAttribute as y };
|
|
109
|
+
//# sourceMappingURL=html-Gggepsf-.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1665,6 +1665,8 @@ interface Site {
|
|
|
1665
1665
|
* values that the site depends on.
|
|
1666
1666
|
*/
|
|
1667
1667
|
trackedCalls: Set<Declaration>;
|
|
1668
|
+
/** True when the site calls through a context value or a prop, outside `$untrack`. */
|
|
1669
|
+
opaqueCalls?: boolean;
|
|
1668
1670
|
/** The declaration that a function or memo site belongs to. */
|
|
1669
1671
|
declaration?: Declaration;
|
|
1670
1672
|
/** The element, component or listener of an attribute or event site. */
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as analyzeProject, B as getLocation, D as unmarked, F as resolveRelative, G as isWithin, H as findError, I as summarize, K as lookup, L as parse, R as buildGraph, 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 resolveRelative, G as isWithin, H as findError, I as summarize, K as lookup, L as parse, R as buildGraph, 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-DomFHy5O.js";
|
|
2
2
|
//#region src/print.ts
|
|
3
3
|
function at(source, range) {
|
|
4
4
|
const { line, column } = getLocation(source, range.start);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as paragraphComponents, t as checkNesting } from "./nesting-DA5vJw9X.js";
|
|
2
2
|
import { t as KEY_NAMES } from "./events-LgLdp1R7.js";
|
|
3
|
-
import { p as insertValue } from "./html-
|
|
3
|
+
import { p as insertValue } from "./html-DS9B1H-M.js";
|
|
4
4
|
import { parseSync } from "oxc-parser";
|
|
5
5
|
import { parse } from "postcss";
|
|
6
6
|
import selectorParser from "postcss-selector-parser";
|
|
@@ -1524,6 +1524,14 @@ var Resolver = class {
|
|
|
1524
1524
|
if (target?.kind === "server-function") target.refreshed = true;
|
|
1525
1525
|
}
|
|
1526
1526
|
if (node.callee.type === "MemberExpression" && !node.callee.computed && node.callee.property.type === "Identifier" && MUTATORS.has(node.callee.property.name)) this.checkMutation(node.callee.object, node);
|
|
1527
|
+
if (this.untracked === 0) {
|
|
1528
|
+
let root = node.callee;
|
|
1529
|
+
while (root.type === "MemberExpression" || root.type === "TSNonNullExpression" || root.type === "ChainExpression") root = root.type === "MemberExpression" ? root.object : root.expression;
|
|
1530
|
+
if (root.type === "Identifier" && !this.isLocal(root.name)) {
|
|
1531
|
+
const target = lookup(this.site.scope, root.name);
|
|
1532
|
+
if (target?.kind === "context" || target?.kind === "prop" || target?.kind === "props-rest") this.site.opaqueCalls = true;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1527
1535
|
const name = node.callee.type === "Identifier" ? node.callee.name : void 0;
|
|
1528
1536
|
if (name && !this.isLocal(name) && !lookup(this.site.scope, name)) {
|
|
1529
1537
|
if (name === "$untrack") {
|
|
@@ -2138,10 +2146,29 @@ function isPropValue(site) {
|
|
|
2138
2146
|
function isTemplateValue(site) {
|
|
2139
2147
|
return site.node.type === "Identifier" && lookup(site.scope, site.node.name)?.kind === "template";
|
|
2140
2148
|
}
|
|
2149
|
+
function writes(site, seen = /* @__PURE__ */ new Set()) {
|
|
2150
|
+
if (seen.has(site)) return false;
|
|
2151
|
+
seen.add(site);
|
|
2152
|
+
if (site.opaqueCalls) return true;
|
|
2153
|
+
for (const write of site.writes) if (write.tracked) return true;
|
|
2154
|
+
for (const callee of site.trackedCalls) if (callee.site && writes(callee.site, seen)) return true;
|
|
2155
|
+
return false;
|
|
2156
|
+
}
|
|
2157
|
+
/** True for a function prop of a component that only reads values and is not an event. */
|
|
2158
|
+
function isDerivation(site) {
|
|
2159
|
+
const owner = site.owner;
|
|
2160
|
+
if (owner?.kind !== "component" || writes(site)) return false;
|
|
2161
|
+
for (const attribute of owner.attributes) if (attribute.kind === "value" && attribute.value.ast === site.node) return true;
|
|
2162
|
+
return false;
|
|
2163
|
+
}
|
|
2141
2164
|
function isFunctionValue(site) {
|
|
2142
2165
|
let node = site.node;
|
|
2143
2166
|
for (;;) {
|
|
2144
2167
|
while (node.type === "ParenthesizedExpression") node = node.expression;
|
|
2168
|
+
if (node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "$untrack" && !lookup(site.scope, node.callee.name) && node.arguments[0]) {
|
|
2169
|
+
node = node.arguments[0];
|
|
2170
|
+
continue;
|
|
2171
|
+
}
|
|
2145
2172
|
if (node.type !== "CallExpression" || node.callee.type !== "Identifier" || lookup(site.scope, node.callee.name)?.imported?.source !== "brumate/events" || !node.arguments[0]) break;
|
|
2146
2173
|
node = node.arguments[0];
|
|
2147
2174
|
}
|
|
@@ -2224,7 +2251,7 @@ function buildGraph(model, options = {}) {
|
|
|
2224
2251
|
return result;
|
|
2225
2252
|
}
|
|
2226
2253
|
for (const [site, node] of siteNodes) {
|
|
2227
|
-
if (site.kind === "prop" && isFunctionValue(site)) continue;
|
|
2254
|
+
if (site.kind === "prop" && isFunctionValue(site) && !isDerivation(site)) continue;
|
|
2228
2255
|
for (const declaration of dependencies(site)) addEdge(declarationNodes.get(declaration), node);
|
|
2229
2256
|
}
|
|
2230
2257
|
for (const [site, node] of siteNodes) {
|
|
@@ -7631,6 +7658,19 @@ var Emitter = class {
|
|
|
7631
7658
|
const parent = instanceScope(this.plan, scope.parent);
|
|
7632
7659
|
this.line(`const ${this.scopeVar(scope)} = ${this.helper("scope")}(${scope.id}, ${this.scopeVar(parent)});`);
|
|
7633
7660
|
}
|
|
7661
|
+
/** On the server, records the bound props before the markup, for `refKey`. */
|
|
7662
|
+
emitBound(scope) {
|
|
7663
|
+
if (this.options.mode !== "server") return;
|
|
7664
|
+
const bindable = this.bindableProps(scope);
|
|
7665
|
+
if (bindable.length > 0) this.line(`$$ctx.bound(${this.scopeVar(scope)}, $$props, { ${bindable.join(", ")} });`);
|
|
7666
|
+
}
|
|
7667
|
+
/** The props that the component writes, as `"key": slot` entries. */
|
|
7668
|
+
bindableProps(scope) {
|
|
7669
|
+
const bindable = [];
|
|
7670
|
+
const slots = this.plan.scopes.get(scope)?.slots ?? [];
|
|
7671
|
+
for (const [index, slot] of slots.entries()) if (slot.kind === "prop" && slot.writable && slot.propKey !== void 0) bindable.push(`${JSON.stringify(slot.propKey)}: ${index}`);
|
|
7672
|
+
return bindable;
|
|
7673
|
+
}
|
|
7634
7674
|
emitSlots(scope) {
|
|
7635
7675
|
const slots = this.plan.scopes.get(scope)?.slots ?? [];
|
|
7636
7676
|
if (slots.length > 0) {
|
|
@@ -7644,8 +7684,7 @@ var Emitter = class {
|
|
|
7644
7684
|
this.line(`${this.helper("slots")}(${this.scopeVar(scope)}, [${values.join(", ")}]${names});`);
|
|
7645
7685
|
}
|
|
7646
7686
|
if (scope.kind === "component") {
|
|
7647
|
-
const bindable =
|
|
7648
|
-
for (const [index, slot] of slots.entries()) if (slot.kind === "prop" && slot.writable && slot.propKey !== void 0) bindable.push(`${JSON.stringify(slot.propKey)}: ${index}`);
|
|
7687
|
+
const bindable = this.bindableProps(scope);
|
|
7649
7688
|
if (bindable.length > 0) this.line(`${this.helper("bindings")}(${this.scopeVar(scope)}, $$props, { ${bindable.join(", ")} });`);
|
|
7650
7689
|
}
|
|
7651
7690
|
}
|
|
@@ -7827,10 +7866,29 @@ var Emitter = class {
|
|
|
7827
7866
|
this.html(" b-near=\"");
|
|
7828
7867
|
this.code(anchor.scope);
|
|
7829
7868
|
this.html(`:${near}"`);
|
|
7869
|
+
} else if (site.trigger === "visible" && this.options.mode === "server") {
|
|
7870
|
+
const forwarded = this.forwardedSignal(site, scope);
|
|
7871
|
+
if (forwarded) this.code(`$$ctx.near(${anchor.scope}, ${slotIndex(this.plan, forwarded)})`);
|
|
7830
7872
|
}
|
|
7831
7873
|
this.html("></template>");
|
|
7832
7874
|
}
|
|
7833
7875
|
}
|
|
7876
|
+
/** The code of the `b-r` attribute of an element that has `ref=$bind(name)` with a prop. */
|
|
7877
|
+
forwardedRef(node) {
|
|
7878
|
+
if (this.options.mode !== "server") return;
|
|
7879
|
+
for (const attribute of node.attributes) {
|
|
7880
|
+
const declaration = attribute.kind === "ref" ? this.refTargets.get(attribute) : void 0;
|
|
7881
|
+
if (declaration?.kind === "prop") return `$$ctx.refKey(${this.scopeVar(instanceScope(this.plan, declaration.scope))}, ${slotIndex(this.plan, declaration)})`;
|
|
7882
|
+
}
|
|
7883
|
+
}
|
|
7884
|
+
/** The signal of `scope` that a site reads, which a component may forward its element to. */
|
|
7885
|
+
forwardedSignal(site, scope) {
|
|
7886
|
+
for (const read of site.reads) {
|
|
7887
|
+
const declaration = read.declaration;
|
|
7888
|
+
if (declaration.scope !== scope || declaration.kind !== "signal") continue;
|
|
7889
|
+
for (const binding of this.plan.graph.model.bindings) if (binding.declaration === declaration && !binding.setter) return declaration;
|
|
7890
|
+
}
|
|
7891
|
+
}
|
|
7834
7892
|
/** The anchor of the first element of `scope` that a site reads through `ref`. */
|
|
7835
7893
|
refElement(site, scope) {
|
|
7836
7894
|
for (const read of site.reads) for (const ref of read.declaration.refs) {
|
|
@@ -7846,6 +7904,7 @@ var Emitter = class {
|
|
|
7846
7904
|
else this.code(`${this.helper("style")}(${JSON.stringify(this.plan.id)}, $$css)`);
|
|
7847
7905
|
}
|
|
7848
7906
|
this.emitStatements(setup, component);
|
|
7907
|
+
this.emitBound(component);
|
|
7849
7908
|
for (const template of this.file.templates) this.emitTemplate(template);
|
|
7850
7909
|
this.emitClientAnchors(component);
|
|
7851
7910
|
this.emitNodes(this.file.children, component);
|
|
@@ -8187,6 +8246,8 @@ var Emitter = class {
|
|
|
8187
8246
|
this.code(anchor.scope);
|
|
8188
8247
|
this.html(`:${anchor.index}"`);
|
|
8189
8248
|
}
|
|
8249
|
+
const forwarded = this.forwardedRef(node);
|
|
8250
|
+
if (forwarded) this.code(forwarded);
|
|
8190
8251
|
if (pageTitle) this.html(" b-t");
|
|
8191
8252
|
if (spreadHandlers) this.code(`$$b.onAttribute(${spreadHandlers}, ${JSON.stringify(events.join(" "))})`);
|
|
8192
8253
|
else if (events.length > 0) this.html(` b-on="${events.join(" ")}"`);
|
|
@@ -9927,6 +9988,7 @@ var ClientGenerator = class {
|
|
|
9927
9988
|
}
|
|
9928
9989
|
const updates = [];
|
|
9929
9990
|
for (const site of this.plan.clientSites) if (!this.plan.symbols.has(site) && site.kind !== "function" && site.kind !== "server-function") updates.push(site);
|
|
9991
|
+
for (const node of this.plan.graph.nodes) if (node.kind === "binding" && node.site.kind === "prop" && this.plan.symbols.has(node.site) && this.plan.graph.live.has(node)) updates.push(node.site);
|
|
9930
9992
|
for (const scope of this.renderedScopes()) for (const site of this.model.sites) if (isWithin(site.scope, scope) && !DEFERRED_SITES.has(site.kind)) updates.push(site);
|
|
9931
9993
|
for (const site of this.childrenSites()) updates.push(site);
|
|
9932
9994
|
this.reach.set("update", this.closure(updates));
|
|
@@ -11412,4 +11474,4 @@ function inspect(source, options = {}) {
|
|
|
11412
11474
|
//#endregion
|
|
11413
11475
|
export { analyzeProject as A, getLocation as B, isReactiveModule as C, unmarked as D, originalPosition as E, resolveRelative as F, isWithin as G, findError as H, summarize as I, walk as J, lookup as K, parse$1 as L, forEachNode as M, importSource as N, entryClasses as O, importedComponents as P, buildGraph as R, sharedSites as S, builtin as T, analyze$1 as U, errorLink as V, getPatternNames as W, functionId as _, scopeLabel as a, SHARED_QUERY as b, DEFAULT_MERGE as c, generateServer as d, instanceScope as f, createPlan as g, clientState as h, report as i, analyzeProjectProps as j, refreshedNames as k, generateClient as l, blockBodies as m, formatReport as n, CompileError as o, slotIndex as p, resolveMacros as q, inspect as r, compile as s, anchorLabel as t, generateRender as u, getComponentName as v, resolveFromDisk as w, generateShared as x, hash as y, BrumateError as z };
|
|
11414
11476
|
|
|
11415
|
-
//# sourceMappingURL=inspect-
|
|
11477
|
+
//# sourceMappingURL=inspect-DomFHy5O.js.map
|