@mionjs/devtools 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +4 -4
  2. package/dist/core/apply-edits.d.ts +1 -1
  3. package/dist/core/apply-edits.js +2 -3
  4. package/dist/core/apply-edits.js.map +1 -1
  5. package/dist/core/bundledApiStub.js.map +1 -1
  6. package/dist/core/devReporter.js.map +1 -1
  7. package/dist/core/diagnosticCatalog.js.map +1 -1
  8. package/dist/core/downgradeErrors.js.map +1 -1
  9. package/dist/core/edit-buffer.d.ts +0 -2
  10. package/dist/core/edit-buffer.js +1 -8
  11. package/dist/core/edit-buffer.js.map +1 -1
  12. package/dist/core/go-generated/diagnosticCatalog.generated.js +6 -1
  13. package/dist/core/go-generated/diagnosticCatalog.generated.js.map +1 -1
  14. package/dist/core/go-generated/reflectionKind.generated.js.map +1 -1
  15. package/dist/core/go-generated/runtypes-constants.generated.d.ts +1 -1
  16. package/dist/core/go-generated/runtypes-constants.generated.js +1 -1
  17. package/dist/core/go-generated/runtypes-constants.generated.js.map +1 -1
  18. package/dist/core/go-generated/tsconfig-plugin-keys.generated.d.ts +1 -1
  19. package/dist/core/go-generated/tsconfig-plugin-keys.generated.js +1 -0
  20. package/dist/core/go-generated/tsconfig-plugin-keys.generated.js.map +1 -1
  21. package/dist/core/groupedLog.js.map +1 -1
  22. package/dist/core/levels.js.map +1 -1
  23. package/dist/core/markerImports.js.map +1 -1
  24. package/dist/core/option-guards.js.map +1 -1
  25. package/dist/core/plugin-option-keys.js +1 -0
  26. package/dist/core/plugin-option-keys.js.map +1 -1
  27. package/dist/core/protocol.d.ts +2 -0
  28. package/dist/core/protocol.js.map +1 -1
  29. package/dist/core/resolver-client.d.ts +4 -0
  30. package/dist/core/resolver-client.js +26 -4
  31. package/dist/core/resolver-client.js.map +1 -1
  32. package/dist/core/scan-batcher.js.map +1 -1
  33. package/dist/core/surface.js.map +1 -1
  34. package/dist/core/type-deps.js.map +1 -1
  35. package/dist/core/types.d.ts +8 -0
  36. package/dist/core/types.js.map +1 -1
  37. package/dist/core/typescript-floor.js.map +1 -1
  38. package/dist/core/unplugin.d.ts +1 -0
  39. package/dist/core/unplugin.js +63 -10
  40. package/dist/core/unplugin.js.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/lint/diagnosticRouting.js.map +1 -1
  43. package/dist/lint/index.js.map +1 -1
  44. package/dist/lint/lint-worker.js +11 -6
  45. package/dist/lint/lint-worker.js.map +1 -1
  46. package/dist/lint/prefilter.js.map +1 -1
  47. package/dist/lint/session-protocol.js.map +1 -1
  48. package/dist/lint/session.js.map +1 -1
  49. package/dist/lint/spawn-shim.js.map +1 -1
  50. package/dist/lint/vueSfc.d.ts +9 -0
  51. package/dist/lint/vueSfc.js +112 -0
  52. package/dist/lint/vueSfc.js.map +1 -0
  53. package/dist/options.js.map +1 -1
  54. package/dist/runtypes/bun.js.map +1 -1
  55. package/dist/runtypes/esbuild.js.map +1 -1
  56. package/dist/runtypes/next/broker.js +13 -13
  57. package/dist/runtypes/next/broker.js.map +1 -1
  58. package/dist/runtypes/next/index.d.ts +0 -1
  59. package/dist/runtypes/next/index.js +2 -0
  60. package/dist/runtypes/next/index.js.map +1 -1
  61. package/dist/runtypes/next/loader.js.map +1 -1
  62. package/dist/runtypes/next/wire.js.map +1 -1
  63. package/dist/runtypes/rolldown.js.map +1 -1
  64. package/dist/runtypes/rollup.js.map +1 -1
  65. package/dist/runtypes/rspack.js.map +1 -1
  66. package/dist/runtypes/vite.js.map +1 -1
  67. package/dist/runtypes/webpack.js.map +1 -1
  68. package/dist/vite/buildEntries.js +14 -11
  69. package/dist/vite/buildEntries.js.map +1 -1
  70. package/dist/vite/index.d.ts +0 -1
  71. package/dist/vite/index.js +0 -1
  72. package/dist/vite/index.js.map +1 -1
  73. package/dist/vite/middlewareMode.d.ts +3 -2
  74. package/dist/vite/middlewareMode.js +73 -59
  75. package/dist/vite/middlewareMode.js.map +1 -1
  76. package/dist/vite/mionVitePlugin.d.ts +0 -1
  77. package/dist/vite/mionVitePlugin.js +28 -8
  78. package/dist/vite/mionVitePlugin.js.map +1 -1
  79. package/dist/vite/nodeWebBridge.js.map +1 -1
  80. package/dist/vite/sfcTransform.d.ts +1 -0
  81. package/dist/vite/sfcTransform.js +17 -7
  82. package/dist/vite/sfcTransform.js.map +1 -1
  83. package/package.json +8 -13
  84. package/dist/next/index.d.ts +0 -11
  85. package/dist/next/index.js +0 -17
  86. package/dist/next/index.js.map +0 -1
  87. package/dist/vite/cjsPackageJsonPlugin.d.ts +0 -3
  88. package/dist/vite/cjsPackageJsonPlugin.js +0 -12
  89. package/dist/vite/cjsPackageJsonPlugin.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAE,IAAI,EAAE,sBAAsB,EAAoB,MAAM,4BAA4B,CAAC;AACzG,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,cAAc,EAAE,aAAa,EAA0B,MAAM,cAAc,CAAC;AAKpF,MAAM,cAAc,EAAE,CAAC;AAkBvB,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;AAGtD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;AAErC,SAAS,QAAQ,CAAC,OAAe;IAC/B,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IACpC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,CAAC,IAAI,CAAC,OAAO,CAA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AAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACnD,CAAC;AAGlC,MAAM,MAAM,GAAG,EAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAA6B,EAAC,CAAC;AAErE,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG;IAC9B,OAAO,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC;IACvB,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;CACzF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;AAEtC,eAAe,MAAM,CAAC","sourcesContent":["// ONE module is both an OXlint JS plugin (the primary target) and an ESLint v9 flat-config plugin, so every rule\n// uses plain `create` and no oxlint-only lifecycle. The four `mion/<level>` rules are pure transport over ONE\n// resolver pass per file, split by level in diagnosticRouting.ts; rules take no options.\n\nimport {createRequire} from 'node:module';\nimport {isDowngraded, NONE, resolveDowngradeErrors, type DowngradeSet} from '../core/downgradeErrors.ts';\nimport {anchoredIn, routeDiagnostic, RULE_SPECS, type RuleName} from './diagnosticRouting.ts';\nimport {needsResolverPass} from './prefilter.ts';\nimport {LINT_SETTING_KEYS} from './session-protocol.ts';\nimport {prewarmSession, sharedSession, type LintSessionOptions} from './session.ts';\n\n// Hold the plugin load until the session's launcher child exists: a host that embeds the Rust linter in-process\n// (oxlint) reserves tens of GB of address space once linting starts, after which the resolver child can no\n// longer be forked on Linux. MION_LINT_PRESPAWN=0 opts out.\nawait prewarmSession();\n\n// The subset of the rule context OXlint and ESLint both provide, typed locally so the plugin depends on\n// neither host's types.\ninterface RuleContext {\n physicalFilename?: string;\n filename?: string;\n sourceCode: {text: string};\n settings?: Record<string, unknown>;\n report(descriptor: {message: string; loc: {start: {line: number; column: number}; end?: {line: number; column: number}}}): void;\n}\n\ninterface RuleModule {\n meta: {type: 'problem'; docs: {description: string}};\n create(context: RuleContext): Record<string, unknown>;\n}\n\n// An engine failure reports once per file, by the first enabled rule to lint it: a config may turn any rule off.\nconst engineErrorClaims = new Map<string, RuleName>();\n\n// A config mistake warns once per run on stderr, not as a report on an arbitrary linted file.\nconst warnedKeys = new Set<string>();\n\nfunction warnOnce(message: string): void {\n if (warnedKeys.has(message)) return;\n warnedKeys.add(message);\n console.warn(message);\n}\n\nfunction warnUnknownSettings(bag: Record<string, unknown>): void {\n for (const key of Object.keys(bag)) {\n if ((LINT_SETTING_KEYS as string[]).includes(key)) continue;\n warnOnce(`[mion] ignoring unknown lint setting 'settings.mion.${key}' (supported: ${LINT_SETTING_KEYS.join(', ')})`);\n }\n}\n\n// A bad tsconfig `downgradeErrors` value only warns here; the build fails on it.\nfunction lintDowngrade(value: string[] | undefined): DowngradeSet {\n try {\n return resolveDowngradeErrors(value);\n } catch (error) {\n warnOnce(error instanceof Error ? error.message : String(error));\n return NONE;\n }\n}\n\n// An unknown key warns: a silently dropped key reads as working. Exported for the transparency regression test.\nexport function sessionOptions(settings: Record<string, unknown> | undefined): LintSessionOptions {\n const raw = settings?.['mion'];\n if (!raw || typeof raw !== 'object') return {};\n const bag = raw as Record<string, unknown>;\n warnUnknownSettings(bag);\n const options: LintSessionOptions = {};\n if (typeof bag['timeoutMs'] === 'number') options.timeoutMs = bag['timeoutMs'];\n if (typeof bag['tsconfig'] === 'string') options.tsconfig = bag['tsconfig'];\n if (typeof bag['binary'] === 'string') options.binary = bag['binary'];\n if (bag['markers'] && typeof bag['markers'] === 'object') {\n options.markers = bag['markers'] as LintSessionOptions['markers'];\n }\n return options;\n}\n\n// The shared session memoizes the file's resolver pass, so the four level rules cost one.\nfunction diagnosticRule(ruleName: RuleName, description: string): RuleModule {\n return {\n meta: {type: 'problem', docs: {description}},\n create(context: RuleContext) {\n const text = context.sourceCode.text;\n // The pre-filter follows imports: it needs the marker settings and the file path.\n const options = sessionOptions(context.settings);\n const file = context.physicalFilename ?? context.filename ?? '';\n // Skip unnamed/virtual buffers: the resolver needs a real path to relativize and to read imports from disk.\n if (!file || file.startsWith('<')) return {};\n if (!needsResolverPass(text, file, options.markers)) return {};\n const session = sharedSession();\n if (!engineErrorClaims.has(file)) engineErrorClaims.set(file, ruleName);\n return {\n Program: () => {\n const outcome = session.lintFileSync(file, text, options);\n if ('engineError' in outcome) {\n // Never silently dropped; reported by the rule that claimed the file.\n if (engineErrorClaims.get(file) === ruleName)\n context.report({message: `[mion] ${outcome.engineError}`, loc: {start: {line: 1, column: 0}}});\n return;\n }\n const downgrade = lintDowngrade(outcome.downgradeErrors);\n for (const diagnostic of outcome.diagnostics) {\n if (!anchoredIn(diagnostic, file)) continue;\n const report = routeDiagnostic(isDowngraded(downgrade, diagnostic) ? {...diagnostic, downgraded: true} : diagnostic);\n if (report.ruleName !== ruleName) continue;\n context.report({message: report.message, loc: report.loc});\n }\n },\n };\n },\n };\n}\n\nconst packageVersion = (createRequire(import.meta.url)('../../package.json') as {version: string}).version;\n\nexport const meta = {name: 'mion', version: packageVersion};\n\nexport const rules = Object.fromEntries(\n RULE_SPECS.map((spec) => [spec.name, diagnosticRule(spec.name, spec.description)])\n) as Record<RuleName, RuleModule>;\n\n// oxlint reads its own preset, oxlint-recommended.json, and takes only `meta` + `rules` off this export.\nconst plugin = {meta, rules, configs: {} as Record<string, unknown>};\n\nplugin.configs['recommended'] = {\n plugins: {mion: plugin},\n rules: Object.fromEntries(RULE_SPECS.map((spec) => [`mion/${spec.name}`, spec.default])),\n};\n\nexport const configs = plugin.configs;\n\nexport default plugin;\n"]}
@@ -7,6 +7,8 @@ import { getExePath } from '@mionjs/bin-compiler';
7
7
  import { Family, Level, Severity } from "../core/protocol.js";
8
8
  import { buildResolverArgs, ResolverClient, ResolverStreamClient } from "../core/resolver-client.js";
9
9
  import { LINT_RESOLVER_OPTIONS, WAKE_INDEX, } from "./session-protocol.js";
10
+ import { anchoredIn } from "./diagnosticRouting.js";
11
+ import { vueLintSource } from "./vueSfc.js";
10
12
  const data = workerData;
11
13
  const requests = data.port;
12
14
  const signal = data.signal;
@@ -56,21 +58,24 @@ const connectionLostPattern = /resolver exited|spawn failed|resolver is closed/;
56
58
  async function lintOne(request) {
57
59
  for (let attempt = 0;; attempt++) {
58
60
  let stage = 'connect';
61
+ let scanned = request.file;
59
62
  try {
60
63
  const resolver = await ensureConnection(request.tsconfig ?? '', request.binary ?? '');
61
64
  stage = 'scan';
62
- const rel = path.relative(process.cwd(), request.file) || request.file;
63
- await resolver.setSources({ [rel]: request.text });
65
+ const vue = request.file.endsWith('.vue') ? vueLintSource(request.file, request.text) : undefined;
66
+ scanned = vue?.virtualFile ?? request.file;
67
+ const rel = path.relative(process.cwd(), scanned) || scanned;
68
+ await resolver.setSources({ [rel]: vue?.text ?? request.text });
64
69
  const result = await resolver.scanFiles([rel], { checkEnrich: true, checkRouterRules: true, includeRtDiagnostics: true });
65
- const diagnostics = (result.diagnostics ?? []);
70
+ let diagnostics = (result.diagnostics ?? []);
71
+ if (vue)
72
+ diagnostics = diagnostics.flatMap((diagnostic) => anchoredIn(diagnostic, scanned) ? (vue.toVue(diagnostic) ?? []) : [diagnostic]);
66
73
  return { seq: request.seq, diagnostics, downgradeErrors: result.downgradeErrors };
67
74
  }
68
75
  catch (error) {
69
76
  const message = error instanceof Error ? error.message : String(error);
70
77
  if (stage === 'scan' && message.includes('source file not in program:')) {
71
- return /\.(?:[cm]?js|jsx)$/i.test(request.file)
72
- ? { seq: request.seq, diagnostics: [] }
73
- : { seq: request.seq, error: message };
78
+ return /\.(?:[cm]?js|jsx)$/i.test(scanned) ? { seq: request.seq, diagnostics: [] } : { seq: request.seq, error: message };
74
79
  }
75
80
  if (message.includes('config-tsconfig-not-loaded')) {
76
81
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"lint-worker.js","sourceRoot":"","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AC,CAAC,CAAC;AAGH,UAAU,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,OAA0B,EAAE,EAAE;IACvD,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,UAAU,EAAE,KAAK,EAAE,CAAC;QACpB,UAAU,GAAG,IAAI,CAAC;QAClB,IAAI,EAAE,IAAI,EAAE,CAAC;QACb,IAAI,GAAG,IAAI,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["// Worker-thread half of the lint session's sync bridge (see session.ts): the Promise-based resolver work lives\n// here, behind the rule thread's Atomics.wait. The worker owns ONE long-lived resolver connection for the whole\n// run, so the tsgo Program machinery is amortised across files, and at PLUGIN LOAD it pre-spawns the generic\n// launcher (spawn-shim.ts) while the host process is still small enough to fork, handing it the real binary and\n// argv on the first request. Per request it mirrors the unplugin's HMR pivot: push the file's buffer text\n// (`setSources`, an inferred Program rooted at the file, its imports read from disk through the overlay FS),\n// then `scanFiles` with checkEnrich + checkRouterRules + includeRtDiagnostics, so ONE pass returns what a build\n// reports plus the two checks only lint runs.\n\nimport {spawn, type ChildProcess} from 'node:child_process';\nimport {existsSync} from 'node:fs';\nimport path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {parentPort, workerData} from 'node:worker_threads';\nimport {getExePath} from '@mionjs/bin-compiler';\nimport {Family, Level, Severity, type Diagnostic} from '../core/protocol.ts';\nimport {buildResolverArgs, ResolverClient, ResolverStreamClient, type ResolverConnection} from '../core/resolver-client.ts';\nimport {\n LINT_RESOLVER_OPTIONS,\n WAKE_INDEX,\n type LintWorkerData,\n type LintWorkerRequest,\n type LintWorkerResponse,\n} from './session-protocol.ts';\nimport {anchoredIn} from './diagnosticRouting.ts';\nimport {vueLintSource} from './vueSfc.ts';\n\nconst data = workerData as LintWorkerData;\nconst requests = data.port;\nconst signal = data.signal;\n\n// Pre-spawn the launcher NOW, while forking is still possible; the session awaits the shimReady signal below\n// before the plugin finishes loading. On failure (or opt-out) the direct spawn path serves small hosts.\nlet shim: ChildProcess | null = null;\nif (process.env.MION_LINT_PRESPAWN !== '0') {\n try {\n shim = spawn(process.execPath, [fileURLToPath(new URL('./spawn-shim.js', import.meta.url))], {\n stdio: ['pipe', 'pipe', 'inherit'],\n });\n shim.on('error', () => {\n shim = null;\n });\n // Unref the child AND its pipes (net.Sockets at runtime) or an idle shim keeps the worker's loop alive.\n shim.unref();\n (shim.stdin as unknown as {unref?: () => void}).unref?.();\n (shim.stdout as unknown as {unref?: () => void}).unref?.();\n } catch {\n shim = null;\n }\n}\nparentPort?.postMessage({shimReady: true});\n\nlet connection: ResolverConnection | null = null;\n\n// resolveConfiguredBinary checks the path up front so a typo reports as a config mistake naming the setting, not\n// an opaque spawn failure. Never falls back to another binary, whose version would key caches differently.\nfunction resolveConfiguredBinary(binary: string): string {\n const resolved = path.resolve(binary);\n if (!existsSync(resolved)) {\n throw new Error(`settings.mion.binary=${binary} does not exist (resolved to ${resolved})`);\n }\n return resolved;\n}\n\n// The connection is long-lived, so the first request's tsconfig and binary fix the options for every later file.\nasync function ensureConnection(tsconfig: string, binary: string): Promise<ResolverConnection> {\n if (connection) return connection;\n // getExePath honours MION_BIN.\n // An unset tsconfig is discovered as tsc does, with its FULL options, so lint type-checks like the build.\n // Single-threaded: one file at a time, and a light child keeps editor/CI hosts under process and memory limits.\n const binaryPath = binary ? resolveConfiguredBinary(binary) : getExePath();\n const args = buildResolverArgs(process.cwd(), tsconfig, LINT_RESOLVER_OPTIONS);\n if (shim?.stdin && shim.stdout && shim.exitCode === null) {\n const launcher = shim;\n launcher.stdin!.write(JSON.stringify({exec: binaryPath, args}) + '\\n');\n const stream = new ResolverStreamClient(launcher.stdin!, launcher.stdout!, () => launcher.kill());\n launcher.on('exit', () => stream.markClosed('resolver exited'));\n connection = stream;\n return connection;\n }\n connection = new ResolverClient(binaryPath, process.cwd(), tsconfig, LINT_RESOLVER_OPTIONS);\n return connection;\n}\n\n// The transport's own connection-death strings, not a per-file op error the resolver answered with.\nconst connectionLostPattern = /resolver exited|spawn failed|resolver is closed/;\n\nasync function lintOne(request: LintWorkerRequest): Promise<LintWorkerResponse> {\n // Retry once to recover transient failures; the fallback can also fail.\n for (let attempt = 0; ; attempt++) {\n let stage: 'connect' | 'scan' = 'connect';\n let scanned = request.file;\n try {\n const resolver = await ensureConnection(request.tsconfig ?? '', request.binary ?? '');\n stage = 'scan';\n const vue = request.file.endsWith('.vue') ? vueLintSource(request.file, request.text) : undefined;\n scanned = vue?.virtualFile ?? request.file;\n const rel = path.relative(process.cwd(), scanned) || scanned;\n await resolver.setSources({[rel]: vue?.text ?? request.text});\n const result = await resolver.scanFiles([rel], {checkEnrich: true, checkRouterRules: true, includeRtDiagnostics: true});\n // The resolver runs the JS engine for format-* verdicts; the worker must not recheck them.\n let diagnostics = (result.diagnostics ?? []) as Diagnostic[];\n if (vue)\n diagnostics = diagnostics.flatMap((diagnostic) =>\n anchoredIn(diagnostic, scanned) ? (vue.toVue(diagnostic) ?? []) : [diagnostic]\n );\n return {seq: request.seq, diagnostics, downgradeErrors: result.downgradeErrors};\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n // The import gate can admit JavaScript excluded by allowJs.\n if (stage === 'scan' && message.includes('source file not in program:')) {\n return /\\.(?:[cm]?js|jsx)$/i.test(scanned) ? {seq: request.seq, diagnostics: []} : {seq: request.seq, error: message};\n }\n // Config failures are deterministic, so keep the connection: setSources reparses the config on the next lint.\n if (message.includes('config-tsconfig-not-loaded')) {\n return {\n seq: request.seq,\n diagnostics: [\n {\n code: 'config-tsconfig-not-loaded',\n family: Family.Marker,\n severity: Severity.Error,\n level: Level.Error,\n args: [message.replace(/^.*config-tsconfig-not-loaded\\s*/, '')],\n site: {filePath: request.file, startLine: 1, startCol: 1},\n },\n ],\n };\n }\n connection?.close();\n connection = null;\n if (attempt === 0) {\n await new Promise((resolve) => setTimeout(resolve, 250));\n continue;\n }\n return {seq: request.seq, error: message, fatal: stage === 'connect' || connectionLostPattern.test(message)};\n }\n }\n}\n\nrequests.on('message', (request: LintWorkerRequest) => {\n void lintOne(request).then((response) => {\n requests.postMessage(response);\n // Wake the rule thread AFTER the response is queued on the port.\n Atomics.store(signal, WAKE_INDEX, response.seq);\n Atomics.notify(signal, WAKE_INDEX);\n });\n});\n\n// Close the child so the Go process exits promptly.\nparentPort?.on('message', (message: {close?: boolean}) => {\n if (message?.close) {\n connection?.close();\n connection = null;\n shim?.kill();\n shim = null;\n process.exit(0);\n }\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prefilter.js","sourceRoot":"","sources":["../../src/lint/prefilter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAE,cAAc,EAAC,MAAM,sDAAsD,CAAC;AAC/H,OAAO,EAAC,qBAAqB,EAAE,kBAAkB,EAAyB,MAAM,0BAA0B,CAAC;AAG3G,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,IAAa,EAAE,OAA2B;IAC7F,OAAO,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAGD,MAAM,4BAA4B,GAAG,IAAI,MAAM,CAC7C,gFAAgF,kBAAkB,IAAI,cAAc,WAAW,EAC/H,GAAG,CACJ,CAAC;AAKF,MAAM,UAAU,uBAAuB,CAAC,IAAY;IAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzF,CAAC;AAOD,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC;AACzF,MAAM,uBAAuB,GAAG,IAAI,MAAM,CAAC,0BAA0B,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CA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// produce no diagnostic, so the rules skip it, the common case for most files in a lint run.\n\nimport {FRIENDLY_TEXT_NAME, MARKER_COMMENT_PREFIX, MOCK_DATA_NAME} from '../core/go-generated/runtypes-constants.generated.ts';\nimport {mayHoldDrizzleSchemas, mayHoldMarkerCalls, type MarkerGateOptions} from '../core/markerImports.ts';\n\n// Gates the compiler-diagnostics pass with the build fallback's own gate, so lint and build admit the same files.\nexport function referencesMarkerModule(text: string, file?: string, markers?: MarkerGateOptions): boolean {\n return mayHoldMarkerCalls(text, file, markers);\n}\n\n// Mirrors the Go guard's const-annotation probe without masking comments: a comment-only match costs one round trip.\nconst enrichConstAnnotationPattern = new RegExp(\n `^[ \\\\t]*(?:export[ \\\\t]+)?const[ \\\\t]+[A-Za-z_$][A-Za-z0-9_$]*[ \\\\t]*:\\\\s*(?:${FRIENDLY_TEXT_NAME}|${MOCK_DATA_NAME})[ \\\\t]*<`,\n 'm'\n);\n\n// looksLikeEnrichmentFile admits enrichment files, the JS twin of the authoritative Go-side\n// mirror.IsEnrichmentFile guard: a reconcile marker in its EMIT form, or the DSL-annotated const declaration.\n// A file merely mentioning the tags or types in strings, prose or parameter annotations never matches.\nexport function looksLikeEnrichmentFile(text: string): boolean {\n return text.includes(MARKER_COMMENT_PREFIX) || enrichConstAnnotationPattern.test(text);\n}\n\n// ROUTER_MODULE and ROUTER_HELPERS admit route files: a route file need not import the marker package\n// at all, so without this it would never reach the resolver. The helper names are matched WITH their opening\n// paren because the router is often imported from a relative module (`import {mion} from './mion.ts'`) and the\n// file then names the package nowhere. Permissive on purpose: one round trip on a file that merely spells\n// `route(`, and the Go side stays authoritative about what is really a route.\nconst ROUTER_MODULE = '@mionjs/router';\nconst ROUTER_HELPERS = ['route', 'query', 'mutation', 'middleware', 'headersMiddleware'];\nconst routerHelperCallPattern = new RegExp(`(?:^|[^A-Za-z0-9_$])(?:${ROUTER_HELPERS.join('|')})\\\\s*\\\\(`);\n\nexport function referencesRouter(text: string): boolean {\n if (text.includes(`'${ROUTER_MODULE}`) || text.includes(`\"${ROUTER_MODULE}`)) return true;\n if (text.includes('@mion:')) return true; // the JSDoc handler tags\n return routerHelperCallPattern.test(text);\n}\n\n// unsafePropertyNamePattern gates the data-proto-property-dropped check, which reports a DECLARATION in any interface,\n// type literal or class, so it must admit files that import nothing of ours: it covers types no route reaches\n// yet. `__proto__` is matched anywhere, being rare enough that a stray mention costs one round trip.\nconst unsafePropertyNamePattern = /__proto__/;\n\nexport function declaresUnsafePropertyName(text: string): boolean {\n return unsafePropertyNamePattern.test(text);\n}\n\n// One pass per file serves every rule, so a file goes over the wire when any family could report on it.\nexport function needsResolverPass(text: string, file?: string, markers?: MarkerGateOptions): boolean {\n return (\n referencesMarkerModule(text, file, markers) ||\n looksLikeEnrichmentFile(text) ||\n referencesRouter(text) ||\n declaresUnsafePropertyName(text) ||\n mayHoldDrizzleSchemas(text)\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"session-protocol.js","sourceRoot":"","sources":["../../src/lint/session-protocol.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAuB5B,MAAM,sBAAsB,GAAG,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAG3F,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAiC,CAAC;AAoBrG,MAAM,6BAA6B,GAAG,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAGrG,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAgC,CAAC;AAclH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,OAAO;CACmB,CAAC"}
1
+ {"version":3,"file":"session-protocol.js","sourceRoot":"","sources":["../../src/lint/session-protocol.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAuB5B,MAAM,sBAAsB,GAAG,EAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAG3F,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAiC,CAAC;AAoBrG,MAAM,6BAA6B,GAAG,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAGrG,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAgC,CAAC;AAclH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,OAAO;CACmB,CAAC","sourcesContent":["// Shapes shared by session.ts (rule thread) and lint-worker.ts; dependency-free so both halves import one contract.\n\nimport type {MessagePort} from 'node:worker_threads';\nimport type {Diagnostic} from '../core/protocol.ts';\nimport type {ResolverClientOptions} from '../core/resolver-client.ts';\n\n// WAKE_INDEX is the slot the worker stores the completed seq into and notifies; the rule thread Atomics.waits on it.\nexport const WAKE_INDEX = 0;\n\n// No working directory among the knobs: the session runs in process.cwd(), where the linter runs.\nexport interface LintSessionOptions {\n // Per-file wait budget before the engine is reported unavailable; the 60s default covers the first file's\n // child spawn + Program build.\n timeoutMs?: number;\n // Project tsconfig (relative to process.cwd(), or absolute) the resolver reads for its resolution-affecting\n // options (customConditions / paths / baseUrl), so lint-time resolution matches the build. Unset, the Go\n // side searches upward from cwd exactly as tsc does.\n tsconfig?: string;\n // Resolver binary to run. Unset (the normal case) resolves through @mionjs/bin-compiler's getExePath(), which\n // honours MION_BIN, so precedence is this setting > MION_BIN > the installed platform package. A configured\n // path that is not there fails loudly rather than falling back: another binary keys caches on another version.\n binary?: string;\n // Which packages may declare the marker types, mirroring the tsconfig `markers` key. Here for ONE reason: the\n // text pre-filter matches import specifiers, so a project whose markers come from its own package would have\n // those files skipped before the resolver saw them. Set it to whatever the tsconfig `markers` block says.\n markers?: {packages?: string[]; checkPackage?: boolean};\n}\n\n// sessionOptions() (index.ts) warns once on any other key, so none is a silent no-op. `satisfies` keeps this\n// exhaustive, like PLUGIN_OPTION_KEYS in core/plugin-option-keys.ts.\nconst LINT_SETTING_KEY_TABLE = {timeoutMs: true, tsconfig: true, binary: true, markers: true} satisfies Record<\n keyof LintSessionOptions,\n true\n>;\n\nexport const LINT_SETTING_KEYS = Object.keys(LINT_SETTING_KEY_TABLE) as (keyof LintSessionOptions)[];\n\nexport interface LintWorkerData {\n port: MessagePort;\n signal: Int32Array;\n}\n\nexport interface LintWorkerRequest {\n seq: number;\n file: string;\n text: string;\n // Project tsconfig for the worker's resolver connection. Read once, on the first request that opens the\n // long-lived connection; the connection is fixed for the run, so later requests' values are ignored.\n tsconfig?: string;\n // Resolver binary, same one-shot rule as tsconfig: the first request's value opens the connection.\n binary?: string;\n}\n\n// The exact field set roundTrip() posts; session.test.ts asserts the posted message against it.\n// markers never rides here: marker packages are resolver spawn config read from the tsconfig.\nconst LINT_WORKER_REQUEST_KEY_TABLE = {seq: true, file: true, text: true, tsconfig: true, binary: true} satisfies Record<\n keyof LintWorkerRequest,\n true\n>;\n\nexport const LINT_WORKER_REQUEST_KEYS = Object.keys(LINT_WORKER_REQUEST_KEY_TABLE) as (keyof LintWorkerRequest)[];\n\nexport interface LintWorkerResponse {\n seq: number;\n diagnostics?: Diagnostic[];\n // The tsconfig `downgradeErrors` echo, so the editor shows a lowered code as the build does.\n downgradeErrors?: string[];\n error?: string;\n // fatal marks a CONNECTION-level failure (binary missing, child died), not a per-file op error: the session\n // goes sticky-dead on it so later files answer instantly instead of re-paying the failure.\n fatal?: boolean;\n}\n\n// Routes fetched: lint scans one file, and the bundled-API and metadata-fetching checks need the whole program\nexport const LINT_RESOLVER_OPTIONS = {\n serverMode: true,\n singleThreaded: true,\n clientRoutes: 'fetch',\n} as const satisfies ResolverClientOptions;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/lint/session.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAE,MAAM,EAAmB,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAC,UAAU,EAA2E,MAAM,uBAAuB,CAAC;AAO3H,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,OAAO,WAAW;IACd,MAAM,GAAkB,IAAI,CAAC;IAC7B,WAAW,GAAuB,IAAI,CAAC;IACvC,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,GAAG,GAAG,CAAC,CAAC;IACC,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEhD,IAAI,GAAkB,IAAI,CAAC;IAInC,KAAK;QACH,IAAI,MAAc,CAAC;QACnB,IAAI,CAAC;YACH,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,MAAM,GAAG,IAAI,CAAC,MAAO,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,O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AM,OAAO,GAAG,IAAI,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7D,IAAI,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAAE,OAAO,OAAO,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,gCAAgC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxE,IAAI,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,IAAI,KAAK,CAAC,wGAAwG,CAAC,CAAC;AAC5H,CAAC;AAGD,IAAI,MAAM,GAAuB,IAAI,CAAC;AAEtC,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC,MAAM;QAAE,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC;AAChB,CAAC;AAID,MAAM,UAAU,cAAc;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IACrE,OAAO,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC;AACjC,CAAC;AAGD,MAAM,UAAU,kBAAkB;IAChC,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC","sourcesContent":["// Rule-thread half of the lint session: lint rule visitors are synchronous, so the rule thread posts to the\n// worker (lint-worker.ts) and BLOCKS on a SharedArrayBuffer until the response is queued, the sync-over-async\n// pattern hand-rolled so the plugin adds no dependencies. One session serves the whole run, memoized per\n// (file, text hash) so the several rules sharing a file's single resolver pass pay once and unchanged files\n// replay instantly in a long-lived host (the oxlint LSP). The worker starts at PLUGIN LOAD (prewarmSession,\n// called from index.ts) to pre-spawn the resolver launcher while the host is still small enough to fork;\n// MION_LINT_PRESPAWN=0 opts out of both the prewarm and the shim.\n\nimport {createHash} from 'node:crypto';\nimport {existsSync} from 'node:fs';\nimport {fileURLToPath} from 'node:url';\nimport {MessageChannel, receiveMessageOnPort, Worker, type MessagePort} from 'node:worker_threads';\nimport type {Diagnostic} from '../core/protocol.ts';\nimport {WAKE_INDEX, type LintSessionOptions, type LintWorkerRequest, type LintWorkerResponse} from './session-protocol.ts';\n\nexport type {LintSessionOptions} from './session-protocol.ts';\n\n// LintOutcome is one file's result: the wire diagnostics, or the reason the engine could not answer.\nexport type LintOutcome = {diagnostics: Diagnostic[]; downgradeErrors?: string[]} | {engineError: string};\n\nconst DEFAULT_TIMEOUT_MS = 60_000;\nconst CACHE_CAP = 256;\n\nexport class LintSession {\n private worker: Worker | null = null;\n private requestPort: MessagePort | null = null;\n private signal = new Int32Array(new SharedArrayBuffer(4));\n private seq = 0;\n private readonly cache = new Map<string, LintOutcome>();\n // Sticky engine failure: once the bridge is known-broken, later files reuse the reason instead of re-paying it.\n private dead: string | null = null;\n\n // start resolves once the worker signals shimReady; the plugin entry awaits it at load so the launcher fork\n // precedes the host's memory ramp. Never rejects: on worker failure or grace timeout it surfaces per file.\n start(): Promise<void> {\n let worker: Worker;\n try {\n this.ensureWorker();\n worker = this.worker!;\n } catch (error) {\n this.dead = error instanceof Error ? error.message : String(error);\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n const timer = setTimeout(resolve, 2000);\n timer.unref?.();\n worker.once('message', () => {\n clearTimeout(timer);\n resolve();\n });\n worker.once('error', (error) => {\n this.dead = `lint worker failed: ${error instanceof Error ? error.message : String(error)}`;\n clearTimeout(timer);\n resolve();\n });\n });\n }\n\n // lintFileSync runs one file's single resolver pass and returns every family's diagnostics; the caller routes\n // them. The working directory is always process.cwd(); tsconfig and binary only apply on the run's FIRST file,\n // which is when the worker opens its long-lived connection.\n lintFileSync(file: string, text: string, options: LintSessionOptions = {}): LintOutcome {\n const key = `${file} ${createHash('sha1').update(text).digest('base64')}`;\n const cached = this.cache.get(key);\n if (cached) return cached;\n const outcome = this.dead ? {engineError: this.dead} : this.roundTrip(file, text, options);\n this.remember(key, outcome);\n return outcome;\n }\n\n private remember(key: string, outcome: LintOutcome): void {\n if (this.cache.size >= CACHE_CAP) {\n const oldest = this.cache.keys().next().value;\n if (oldest !== undefined) this.cache.delete(oldest);\n }\n this.cache.set(key, outcome);\n }\n\n private roundTrip(file: string, text: string, options: LintSessionOptions): LintOutcome {\n let port: MessagePort;\n try {\n port = this.ensureWorker();\n } catch (error) {\n this.dead = error instanceof Error ? error.message : String(error);\n return {engineError: this.dead};\n }\n\n const seq = ++this.seq;\n // Forward ONLY an explicit tsconfig (strict: the daemon fails the op when it is missing or broken). Unset,\n // the Go side searches upward from cwd exactly as tsc does, so this side carries no config logic.\n port.postMessage({\n seq,\n file,\n text,\n tsconfig: options.tsconfig ?? '',\n binary: options.binary ?? '',\n } satisfies LintWorkerRequest);\n\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const deadline = Date.now() + timeoutMs;\n // The worker posts the response BEFORE notifying, so once the signal reaches seq the message is queued.\n for (;;) {\n const current = Atomics.load(this.signal, WAKE_INDEX);\n if (current >= seq) break;\n const remaining = deadline - Date.now();\n if (remaining <= 0 || Atomics.wait(this.signal, WAKE_INDEX, current, remaining) === 'timed-out') {\n this.dead = `resolver did not answer within ${timeoutMs}ms (file: ${file})`;\n return {engineError: this.dead};\n }\n }\n\n // Requests are strictly sequential, so the next message is ours; the loop guards a stale leftover anyway.\n for (;;) {\n const received = receiveMessageOnPort(port) as {message: LintWorkerResponse} | undefined;\n if (!received) {\n this.dead = `resolver signalled seq ${seq} but no response message arrived`;\n return {engineError: this.dead};\n }\n if (received.message.seq !== seq) continue;\n if (received.message.error) {\n const engineError = `resolver failed: ${received.message.error}`;\n // Connection-level failures stick so later files answer instantly; per-file op errors don't.\n if (received.message.fatal) this.dead = engineError;\n return {engineError};\n }\n const {diagnostics = [], downgradeErrors} = received.message;\n return {diagnostics, downgradeErrors};\n }\n }\n\n private ensureWorker(): MessagePort {\n if (this.requestPort) return this.requestPort;\n const {port1, port2} = new MessageChannel();\n this.worker = new Worker(resolveWorkerURL(), {\n name: 'runtypes-lint-resolver',\n workerData: {port: port2, signal: this.signal},\n transferList: [port2],\n });\n // The worker must never keep the host alive; on host exit its resolver child reads EOF and exits too.\n this.worker.unref();\n this.requestPort = port1;\n return port1;\n }\n\n // dispose tears the bridge down (tests; hosts rely on process exit).\n dispose(): void {\n this.worker?.postMessage({close: true});\n void this.worker?.terminate();\n this.worker = null;\n this.requestPort = null;\n this.cache.clear();\n this.dead = null;\n }\n}\n\n// resolveWorkerURL finds the worker ENTRY FILE: a worker thread loads it through plain Node, never vite's\n// transform, so running from src falls back to the built dist twin (the repo's stale-build check keeps it fresh).\nfunction resolveWorkerURL(): URL {\n const sibling = new URL('./lint-worker.js', import.meta.url);\n if (existsSync(fileURLToPath(sibling))) return sibling;\n const dist = new URL('../../dist/lint/lint-worker.js', import.meta.url);\n if (existsSync(fileURLToPath(dist))) return dist;\n throw new Error('[mion] lint worker not found — build @mionjs/devtools first (pnpm --filter @mionjs/devtools run build)');\n}\n\n// sharedSession returns the module-level session every rule shares.\nlet shared: LintSession | null = null;\n\nexport function sharedSession(): LintSession {\n if (!shared) shared = new LintSession();\n return shared;\n}\n\n// prewarmSession starts the shared worker at plugin load so the launcher forks while the host is still small;\n// the plugin entry top-level-awaits it. MION_LINT_PRESPAWN=0 starts the session on the first linted file instead.\nexport function prewarmSession(): Promise<void> {\n if (process.env.MION_LINT_PRESPAWN === '0') return Promise.resolve();\n return sharedSession().start();\n}\n\n// resetSharedSession disposes the shared session (tests only).\nexport function resetSharedSession(): void {\n shared?.dispose();\n shared = null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"spawn-shim.js","sourceRoot":"","sources":["../../src/lint/spawn-shim.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEzC,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,C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AC,OAAO,EAAE,CAAC,CAAC;QACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACjC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["// The lint session's early fork, started at PLUGIN LOAD while the host process is still small: a host that\n// runs the Rust linter in-process (oxlint) reserves tens of GB of address space once linting starts, after\n// which fork() fails with ENOMEM on Linux, so the resolver can never be spawned lazily. Protocol: ONE\n// newline-terminated JSON control line on stdin, `{\"exec\": \"<binary>\", \"args\": [...]}`, names the target to\n// spawn with inherited stdio, so responses flow straight to the session; later stdin bytes are forwarded to\n// it and its exit is mirrored. EOF before that line: the session went away, exit.\n\nimport {spawn} from 'node:child_process';\n\nlet buffer = Buffer.alloc(0);\n\nfunction onData(chunk: Buffer): void {\n buffer = Buffer.concat([buffer, chunk]);\n const newline = buffer.indexOf(0x0a);\n if (newline < 0) return;\n process.stdin.off('data', onData);\n\n const control = JSON.parse(buffer.subarray(0, newline).toString('utf8')) as {exec: string; args: string[]};\n const rest = buffer.subarray(newline + 1);\n const child = spawn(control.exec, control.args, {stdio: ['pipe', 'inherit', 'inherit']});\n child.on('error', (error) => {\n console.error(`[mion] spawn-shim could not start ${control.exec}: ${error.message}`);\n process.exit(1);\n });\n child.on('exit', (code) => process.exit(code ?? 0));\n // Bytes that arrived behind the control line must not be lost.\n if (rest.length > 0) child.stdin.write(rest);\n process.stdin.pipe(child.stdin);\n}\n\nprocess.stdin.on('data', onData);\nprocess.stdin.on('end', () => process.exit(0));\n"]}
@@ -0,0 +1,9 @@
1
+ import type { Diagnostic } from '../core/protocol.ts';
2
+ interface VueLintSource {
3
+ virtualFile: string;
4
+ text: string;
5
+ toVue(diagnostic: Diagnostic): Diagnostic | undefined;
6
+ }
7
+ export declare function vueLintSource(file: string, text: string, readFile?: (file: string) => string): VueLintSource;
8
+ export {};
9
+ //# sourceMappingURL=vueSfc.d.ts.map
@@ -0,0 +1,112 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import path from 'node:path';
4
+ export function vueLintSource(file, text, readFile = readDisk) {
5
+ const onDisk = readFile(file);
6
+ const diskBlocks = onDisk ? scriptBlocks(onDisk, file) : [];
7
+ const diskVirtual = virtualPath(file, diskBlocks);
8
+ for (const block of diskBlocks) {
9
+ const content = onDisk.slice(block.loc.start.offset, block.loc.end.offset);
10
+ const offset = content.indexOf(text);
11
+ if (!text.trim() || offset < 0 || content.slice(0, offset).trim() || content.slice(offset + text.length).trim())
12
+ continue;
13
+ const start = block.loc.start.offset + offset;
14
+ const range = { start: lineCol(onDisk, start), end: lineCol(onDisk, start + text.length) };
15
+ return {
16
+ virtualFile: diskVirtual,
17
+ text: scriptsOnly(onDisk, diskBlocks),
18
+ toVue: (diagnostic) => remap(diagnostic, diskVirtual, file, range),
19
+ };
20
+ }
21
+ if (/<script\b/i.test(text)) {
22
+ const blocks = scriptBlocks(text, file);
23
+ const virtualFile = virtualPath(file, blocks);
24
+ return { virtualFile, text: scriptsOnly(text, blocks), toVue: (diagnostic) => remap(diagnostic, virtualFile, file) };
25
+ }
26
+ return {
27
+ virtualFile: diskVirtual,
28
+ text,
29
+ toVue: diskBlocks.length > 1 ? () => undefined : (diagnostic) => remap(diagnostic, diskVirtual, file),
30
+ };
31
+ }
32
+ function readDisk(file) {
33
+ try {
34
+ return readFileSync(file, 'utf8');
35
+ }
36
+ catch {
37
+ return '';
38
+ }
39
+ }
40
+ function sfcCompiler(file) {
41
+ for (const from of [file, path.join(process.cwd(), 'index.js')]) {
42
+ try {
43
+ return createRequire(from)('vue/compiler-sfc');
44
+ }
45
+ catch {
46
+ }
47
+ }
48
+ throw new Error(`vue/compiler-sfc is not resolvable from ${file}, so its <script> code cannot be linted`);
49
+ }
50
+ function scriptBlocks(sfc, file) {
51
+ const { descriptor } = sfcCompiler(file).parse(sfc, { filename: file });
52
+ return [descriptor.script, descriptor.scriptSetup]
53
+ .filter((block) => !!block && !block.src)
54
+ .sort((first, second) => first.loc.start.offset - second.loc.start.offset);
55
+ }
56
+ function virtualPath(file, blocks) {
57
+ if (!blocks.length)
58
+ return `${file}.ts`;
59
+ return `${file}.${blocks.find((block) => block.lang)?.lang ?? 'js'}`;
60
+ }
61
+ function scriptsOnly(sfc, blocks) {
62
+ let out = '';
63
+ let cursor = 0;
64
+ for (const block of blocks) {
65
+ out += blank(sfc.slice(cursor, block.loc.start.offset)) + sfc.slice(block.loc.start.offset, block.loc.end.offset);
66
+ cursor = block.loc.end.offset;
67
+ }
68
+ return out + blank(sfc.slice(cursor));
69
+ }
70
+ function blank(markup) {
71
+ return markup.replace(/[^\r\n]/g, ' ');
72
+ }
73
+ function lineCol(text, offset) {
74
+ const before = text.slice(0, offset);
75
+ const lineStart = before.lastIndexOf('\n') + 1;
76
+ return { line: before.split('\n').length, col: Buffer.byteLength(before.slice(lineStart)) + 1 };
77
+ }
78
+ function remap(diagnostic, virtualFile, file, range) {
79
+ const inModule = (site) => path.resolve(site.filePath) === path.resolve(virtualFile);
80
+ const site = range ? shift(diagnostic.site, range.start, range.end) : diagnostic.site;
81
+ if (!site)
82
+ return undefined;
83
+ const related = diagnostic.related?.flatMap((entry) => {
84
+ if (!inModule(entry))
85
+ return [entry];
86
+ const moved = range ? shift(entry, range.start, range.end) : entry;
87
+ return moved ? [{ ...entry, ...moved, filePath: file }] : [];
88
+ });
89
+ return { ...diagnostic, site: { ...site, filePath: file }, related };
90
+ }
91
+ function shift(site, start, end) {
92
+ if (!within({ line: site.startLine, col: site.startCol }, start, end))
93
+ return undefined;
94
+ const moved = { ...site, ...relative(site.startLine, site.startCol, start) };
95
+ delete moved.endLine;
96
+ delete moved.endCol;
97
+ if (site.endLine && site.endCol && within({ line: site.endLine, col: site.endCol }, start, { ...end, col: end.col + 1 })) {
98
+ const relEnd = relative(site.endLine, site.endCol, start);
99
+ moved.endLine = relEnd.startLine;
100
+ moved.endCol = relEnd.startCol;
101
+ }
102
+ return moved;
103
+ }
104
+ function within(position, start, end) {
105
+ const afterStart = position.line > start.line || (position.line === start.line && position.col >= start.col);
106
+ const beforeEnd = position.line < end.line || (position.line === end.line && position.col < end.col);
107
+ return afterStart && beforeEnd;
108
+ }
109
+ function relative(line, col, start) {
110
+ return { startLine: line - start.line + 1, startCol: line === start.line ? col - start.col + 1 : col };
111
+ }
112
+ //# sourceMappingURL=vueSfc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vueSfc.js","sourceRoot":"","sources":["../../src/lint/vueSfc.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAyB7B,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY,EAAE,WAAqC,QAAQ;IACrG,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,UAAU,CAA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,UAAU,GAAG,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7G,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACrG,OAAO,UAAU,IAAI,SAAS,CAAC;AACjC,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,GAAW,EAAE,KAAe;IAC1D,OAAO,EAAC,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAC,CAAC;AACvG,CAAC","sourcesContent":["// tsgo cannot read a Vue SFC, so lint scans its <script> code under the build's virtual `Comp.vue.<lang>` path\n// (vite/sfcTransform.ts) and maps findings back. ESLint passes the whole SFC; oxlint passes one <script> block's\n// text and rejects a report outside it.\n\nimport {readFileSync} from 'node:fs';\nimport {createRequire} from 'node:module';\nimport path from 'node:path';\nimport type {Diagnostic, DiagnosticSite} from '../core/protocol.ts';\n\n/** Subset of @vue/compiler-sfc, the parser the build's SFC pass also uses. */\ninterface SfcBlock {\n lang?: string;\n src?: string;\n loc: {start: {offset: number}; end: {offset: number}};\n}\ninterface SfcCompiler {\n parse(source: string, options?: {filename?: string}): {descriptor: {script: SfcBlock | null; scriptSetup: SfcBlock | null}};\n}\n\ninterface Position {\n line: number;\n col: number;\n}\n\ninterface VueLintSource {\n virtualFile: string;\n text: string;\n /** Undefined when the finding lies outside the `.vue` file's (or oxlint block's) own lines. */\n toVue(diagnostic: Diagnostic): Diagnostic | undefined;\n}\n\nexport function vueLintSource(file: string, text: string, readFile: (file: string) => string = readDisk): VueLintSource {\n const onDisk = readFile(file);\n const diskBlocks = onDisk ? scriptBlocks(onDisk, file) : [];\n const diskVirtual = virtualPath(file, diskBlocks);\n // An oxlint block: its text is one block of the saved file, so the whole file gives the module.\n for (const block of diskBlocks) {\n const content = onDisk.slice(block.loc.start.offset, block.loc.end.offset);\n const offset = content.indexOf(text);\n if (!text.trim() || offset < 0 || content.slice(0, offset).trim() || content.slice(offset + text.length).trim()) continue;\n const start = block.loc.start.offset + offset;\n const range = {start: lineCol(onDisk, start), end: lineCol(onDisk, start + text.length)};\n return {\n virtualFile: diskVirtual,\n text: scriptsOnly(onDisk, diskBlocks),\n toVue: (diagnostic) => remap(diagnostic, diskVirtual, file, range),\n };\n }\n // The whole SFC (ESLint): blanking everything but script code keeps every line and column where it was.\n if (/<script\\b/i.test(text)) {\n const blocks = scriptBlocks(text, file);\n const virtualFile = virtualPath(file, blocks);\n return {virtualFile, text: scriptsOnly(text, blocks), toVue: (diagnostic) => remap(diagnostic, virtualFile, file)};\n }\n // An oxlint block edited since the save: beside another block it lacks that block's types, so it reports nothing.\n return {\n virtualFile: diskVirtual,\n text,\n toVue: diskBlocks.length > 1 ? () => undefined : (diagnostic) => remap(diagnostic, diskVirtual, file),\n };\n}\n\nfunction readDisk(file: string): string {\n try {\n return readFileSync(file, 'utf8');\n } catch {\n return '';\n }\n}\n\n// The project's own compiler, as the build's SFC pass borrows it, so lint reads exactly the blocks the build does.\nfunction sfcCompiler(file: string): SfcCompiler {\n for (const from of [file, path.join(process.cwd(), 'index.js')]) {\n try {\n return createRequire(from)('vue/compiler-sfc') as SfcCompiler;\n } catch {\n // try the next location\n }\n }\n throw new Error(`vue/compiler-sfc is not resolvable from ${file}, so its <script> code cannot be linted`);\n}\n\n// A `src` block is a real file the program already holds.\nfunction scriptBlocks(sfc: string, file: string): SfcBlock[] {\n const {descriptor} = sfcCompiler(file).parse(sfc, {filename: file});\n return [descriptor.script, descriptor.scriptSetup]\n .filter((block): block is SfcBlock => !!block && !block.src)\n .sort((first, second) => first.loc.start.offset - second.loc.start.offset);\n}\n\n// Mirrors vite/sfcTransform.ts so relative imports resolve; no saved block falls back to `.ts`, which also parses JavaScript.\nfunction virtualPath(file: string, blocks: SfcBlock[]): string {\n if (!blocks.length) return `${file}.ts`;\n return `${file}.${blocks.find((block) => block.lang)?.lang ?? 'js'}`;\n}\n\nfunction scriptsOnly(sfc: string, blocks: SfcBlock[]): string {\n let out = '';\n let cursor = 0;\n for (const block of blocks) {\n out += blank(sfc.slice(cursor, block.loc.start.offset)) + sfc.slice(block.loc.start.offset, block.loc.end.offset);\n cursor = block.loc.end.offset;\n }\n return out + blank(sfc.slice(cursor));\n}\n\nfunction blank(markup: string): string {\n return markup.replace(/[^\\r\\n]/g, ' ');\n}\n\n// 1-based line and UTF-8 byte column, the way the resolver counts diagnostic sites.\nfunction lineCol(text: string, offset: number): Position {\n const before = text.slice(0, offset);\n const lineStart = before.lastIndexOf('\\n') + 1;\n return {line: before.split('\\n').length, col: Buffer.byteLength(before.slice(lineStart)) + 1};\n}\n\n// Only sites in the virtual module move onto the `.vue` file; a related site in an imported file keeps its path.\nfunction remap(\n diagnostic: Diagnostic,\n virtualFile: string,\n file: string,\n range?: {start: Position; end: Position}\n): Diagnostic | undefined {\n const inModule = (site: DiagnosticSite): boolean => path.resolve(site.filePath) === path.resolve(virtualFile);\n const site = range ? shift(diagnostic.site, range.start, range.end) : diagnostic.site;\n if (!site) return undefined;\n const related = diagnostic.related?.flatMap((entry) => {\n if (!inModule(entry)) return [entry];\n const moved = range ? shift(entry, range.start, range.end) : entry;\n return moved ? [{...entry, ...moved, filePath: file}] : [];\n });\n return {...diagnostic, site: {...site, filePath: file}, related};\n}\n\nfunction shift(site: DiagnosticSite, start: Position, end: Position): DiagnosticSite | undefined {\n if (!within({line: site.startLine, col: site.startCol}, start, end)) return undefined;\n const moved: DiagnosticSite = {...site, ...relative(site.startLine, site.startCol, start)};\n delete moved.endLine;\n delete moved.endCol;\n if (site.endLine && site.endCol && within({line: site.endLine, col: site.endCol}, start, {...end, col: end.col + 1})) {\n const relEnd = relative(site.endLine, site.endCol, start);\n moved.endLine = relEnd.startLine;\n moved.endCol = relEnd.startCol;\n }\n return moved;\n}\n\nfunction within(position: Position, start: Position, end: Position): boolean {\n const afterStart = position.line > start.line || (position.line === start.line && position.col >= start.col);\n const beforeEnd = position.line < end.line || (position.line === end.line && position.col < end.col);\n return afterStart && beforeEnd;\n}\n\nfunction relative(line: number, col: number, start: Position): Pick<DiagnosticSite, 'startLine' | 'startCol'> {\n return {startLine: line - start.line + 1, startCol: line === start.line ? col - start.col + 1 : col};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAC,sBAAsB,EAAC,MAAM,qDAAqD,CAAC;AAuE3F,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAeD,MAAM,UAAU,iBAAiB,CAAC,UAA6B,EAAE;IAC/D,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IAElC,IAAK,EAAE,CAAC,QAAmB,KAAK,WAAW,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,+FAA+F;YAC7F,8FAA8F;YAC9F,iCAAiC,CACpC,CAAC;IACJ,CAAC;IACD,IAAK,EAAE,CAAC,UAAqB,KAAK,sBAAsB,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,uGAAuG;YACrG,6FAA6F,CAChG,CAAC;IACJ,CAAC;IACD,uBAAuB,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,MAAM,EAAE,eAA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AAC;IACD,uBAAuB,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC;QAClC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,YAAY,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM;QACpC,MAAM,EAAE,EAAE,CAAC,MAAM;QACjB,QAAQ,EAAE,EAAE,CAAC,QAAQ;QACrB,UAAU,EAAE,EAAE,CAAC,UAAU;QACzB,UAAU,EAAE,EAAE,CAAC,UAAU;QACzB,aAAa,EAAE,EAAE,CAAC,aAAa;QAI/B,eAAe,EAAE,EAAE,CAAC,eAAe;QAEnC,MAAM,EAAE,EAAE,CAAC,MAAM;QAEjB,QAAQ,EAAE,EAAE,CAAC,QAAQ;QACrB,kBAAkB,EAAE,EAAE,CAAC,kBAAkB;QACzC,oBAAoB,EAAE,EAAE,CAAC,oBAAoB;QAC7C,YAAY,EAAE,EAAE,CAAC,oBAAoB;QACrC,SAAS,EAAE,EAAE,CAAC,SAAS;KACxB,CAAC;AACJ,CAAC","sourcesContent":["/* ########\n * 2026 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ######## */\n\n// Host hooks (Vue SFC pass, middleware mode, module-graph invalidation) stay in the vite preset, not here.\n\nimport {type PluginOptions as TsRuntypesPluginOptions} from './core/unplugin.ts';\nimport {assertValidClientRoutes} from './core/option-guards.ts';\nimport {MODULE_MODE_ALL_SINGLE} from './core/go-generated/runtypes-constants.generated.ts';\n\n/** Options for the mion powered type transformation. */\nexport interface MionRunTypesOptions {\n /** Explicit path to the mion resolver binary; unset, @mionjs/bin-compiler getExePath() takes MION_BIN, then\n * the published platform binary. MION_BIN also covers the ESLint lane, so prefer it when both must match. */\n binary?: string;\n /** RunTypes generated-output root: gitignored modules under `<genDir>/types/`, committed enrichment under\n * `<genDir>/enriched/`. */\n genDir?: string;\n /** What generated fn entries ship: 'code' (default) | 'both' | 'ts' ('both' as typed `.ts` modules).\n *\n * ⚠️ EDGE TARGETS MUST USE 'both'. 'code' ships only the compiled fn's source string, which\n * @mionjs/run-types turns into a function with `new Function` on first use; workerd, Vercel Edge and any CSP\n * without 'unsafe-eval' refuse that, so initRoutes dies on the first route with \"Code generation from\n * strings disallowed for this context\". 'both' emits the live factory ALONGSIDE the string, so nothing is\n * compiled at runtime and the string is still there for the fetch-metadata middleware to serialize to clients.\n * It costs bundle size, roughly +30% raw and +15% gzipped.\n *\n * RunTypes' third mode, 'functions', omits `code` and throws here at config time: mion's client story is\n * serializing compiled fns to the browser as strings, so an entry with no body cannot cross the wire.\n * Guaranteeing `code` is what lets `MionTypeFn` type it as required (packages/core/src/types/general.types.ts). */\n emitMode?: 'code' | 'both' | 'ts';\n /** Cache-module grouping, see the runtypes core docs; 'allSingle' throws: one module would carry both sides. */\n moduleMode?: Exclude<TsRuntypesPluginOptions['moduleMode'], typeof MODULE_MODE_ALL_SINGLE>;\n inlineMode?: TsRuntypesPluginOptions['inlineMode'];\n transformMode?: TsRuntypesPluginOptions['transformMode'];\n /** Diagnostic codes to report as warnings instead of halting the build, or `'*'` for all of them. Strict by\n * default: the RunTypes adapter is scanner-clean, so strict mode is safe monorepo-wide. */\n downgradeErrors?: TsRuntypesPluginOptions['downgradeErrors'];\n /** `'all'` also prints Info findings (a skipped method, a validator on `any`), hidden by default; never changes what stops the build. */\n levels?: TsRuntypesPluginOptions['levels'];\n /** `'lines'` prints one line per finding; the default `'grouped'` prints each message once with its sites. */\n logStyle?: TsRuntypesPluginOptions['logStyle'];\n /** How many mockSamples to generate for a TypeFormat pattern that declares none. Declared mockSamples always\n * win over generation, and a pattern the generator cannot handle (usually lookarounds) fails the build with\n * format-sample-generation-failed, asking for explicit mockSamples. */\n patternSampleCount?: TsRuntypesPluginOptions['patternSampleCount'];\n /** How many times to retry sample generation before failing with format-sample-generation-failed; the total budget is\n * `patternSampleCount * patternSampleRetries`. Raise it for constrained patterns whose draws often miss. */\n patternSampleRetries?: TsRuntypesPluginOptions['patternSampleRetries'];\n /** Derive every route's request size limit from its types (default true): the compiler emits the largest\n * JSON a bounded type allows and the router refuses anything past it. `false` turns the feature off, so every\n * route takes its own `maxBodySize` or the platform adapter's number. Maps onto the resolver's\n * `jsonMaxBytes` option (also settable in tsconfig). */\n derivedPayloadLimits?: boolean;\n /** JS runtime for the pattern-checking sidecar; node and bun are found on PATH, so set this (or\n * `MION_JS_RUNTIME`) only for another runtime. With no runtime the build fails closed with format-no-js-runtime. */\n jsRuntime?: TsRuntypesPluginOptions['jsRuntime'];\n /** Transform typed mion code inside Vue SFC `<script>` blocks (default true), the script being registered\n * under a virtual path next to the .vue file and injected before @vitejs/plugin-vue compiles it (see\n * vite/sfcTransform.ts). Off, a marker call inside an SFC gets no compiled fns and fails at runtime. */\n sfc?: boolean;\n}\n\n/** How the client gets each route's metadata and compiled functions. */\nexport interface MionClientOptions {\n /** 'bundle' (default) bundles every called route; an unseen one is fetched only with client `useFetchMetadata`.\n * 'fetch' gets every route from the server on first use: needs `useFetchMetadata` and server `mionFetchMetadata`. */\n routes?: TsRuntypesPluginOptions['clientRoutes'];\n}\n\n/** Resolves the mion resolver binary: explicit option, else @mionjs/bin-compiler getExePath(), which honours\n * MION_BIN and then the published platform package.\n *\n * mion reads NO env var of its own: MION_BIN covers the transform lane and the ESLint lane, which run in\n * SEPARATE processes, so a mion-side variable could never make the two agree.\n *\n * ⚠️ No sibling-checkout fallback: the binary VERSION is folded into every typeId, so a locally built binary at\n * another version silently produces caches that diverge from CI/user installs (the `<typeId>` half of every\n * `<fnHash>_<typeId>` key stops matching). The same caution applies to MION_BIN. */\nexport function resolveRtBinary(explicit?: string): string | undefined {\n return explicit; // otherwise @mionjs/bin-compiler getExePath() takes over (MION_BIN → platform binary)\n}\n\nexport interface MionPresetOptions {\n /** The ONE client + server tsconfig (absolute or vite-root-relative); unset, tsc's upward `tsconfig.json` search. */\n tsConfig?: string;\n client?: MionClientOptions;\n runTypes?: MionRunTypesOptions;\n}\n\n/** Host hooks (`onSiteFilesChanged`, `onGenerate`) are NOT set here: the vite preset adds them. */\nexport function toRunTypesOptions(options: MionPresetOptions = {}): TsRuntypesPluginOptions {\n const rt = options.runTypes ?? {};\n // The type says 'code' | 'both' | 'ts', but configs are plain JS/JSON often written by hand.\n if ((rt.emitMode as string) === 'functions') {\n throw new Error(\n `[mion] emitMode: 'functions' is not supported. mion serializes compiled fns to the client as ` +\n `code strings, and 'functions' omits the code, so every client would fail on first validate. ` +\n `Use 'code' (default) or 'both'.`\n );\n }\n if ((rt.moduleMode as string) === MODULE_MODE_ALL_SINGLE) {\n throw new Error(\n `[mion] moduleMode: 'allSingle' is not supported. It puts every type of the program in one module per ` +\n `family, so the client bundle would carry the server's types. Use 'default' or 'allModules'.`\n );\n }\n assertValidClientRoutes(options.client?.routes);\n // Project `references` in the tsconfig are fine: the resolver drops them when building its scan program.\n return {\n binary: resolveRtBinary(rt.binary),\n tsconfig: options.tsConfig,\n clientRoutes: options.client?.routes,\n genDir: rt.genDir,\n emitMode: rt.emitMode,\n moduleMode: rt.moduleMode,\n inlineMode: rt.inlineMode,\n transformMode: rt.transformMode,\n // Strict by default: Error-severity mion diagnostics halt the build, the documented contract. Passed\n // through UNDEFINED when unset, never defaulted, so a tsconfig-only `downgradeErrors` still reaches the\n // host: the echo can only win over an absent option.\n downgradeErrors: rt.downgradeErrors,\n // Undefined when unset, like downgradeErrors, so a tsconfig-only `levels` still reaches the host.\n levels: rt.levels,\n // Undefined when unset, so a tsconfig-only `logStyle` still reaches the host.\n logStyle: rt.logStyle,\n patternSampleCount: rt.patternSampleCount,\n patternSampleRetries: rt.patternSampleRetries,\n jsonMaxBytes: rt.derivedPayloadLimits,\n jsRuntime: rt.jsRuntime,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bun.js","sourceRoot":"","sources":["../../src/runtypes/bun.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,QAAQ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AC,CAAC;YAE3B,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,WAAW,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YAED,IAAI,CAAC;gBACH,KAAK,MAAM,QAAQ,IAAI,cAAc;oBAAE,MAAM,QAAQ,EAAE,CAAC;YAC1D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,YAAY,GAAG,KAAK,CAAC;YACvB,CAAC;oBAAS,CAAC;gBACT,WAAW,EAAE,CAAC;YAChB,CAAC;YAGD,KAAK,YAAY,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,eAAe,iBAAiB,CAAC","sourcesContent":["// One plugin for BOTH Bun hosts: `Bun.build({plugins})`, which unplugin supports unaided, and `Bun.plugin()`\n// from a `--preload` module, which it does not. The runtime host is a SUBSET and needs three gaps bridged,\n// marked below: it has no `onStart`/`onEnd`, its `onLoad` throws unless it returns an object, and\n// `Bun.plugin()` does not await an async `setup`, so a load racing startup would silently transform nothing\n// (no throw, no warning: it surfaces later as a missing-type error from whatever consumes the markers).\n\nimport {unplugin, PLUGIN_NAME, type Options} from '../core/unplugin.ts';\n\nexport * from '../core/unplugin.ts';\n\n// Bun's plugin types are declared by `bun-types`, deliberately NOT a dependency: this package is published and\n// will not pull Bun's globals into every consumer's typecheck. The structural minimum the adapter touches.\n\nexport interface BunOnLoadResult {\n contents: string;\n loader?: string;\n}\n\n/** `onStart`/`onEnd` are optional because the RUNTIME host omits them entirely — that is gap 1. */\nexport interface BunBuildContext {\n onLoad: (constraints: unknown, callback: (args: BunOnLoadArgs) => unknown) => void;\n onResolve?: (constraints: unknown, callback: (args: unknown) => unknown) => void;\n onStart?: (callback: () => unknown) => void;\n onEnd?: (callback: () => unknown) => void;\n [key: string]: unknown;\n}\n\nexport interface BunOnLoadArgs {\n path: string;\n loader?: string;\n [key: string]: unknown;\n}\n\nexport interface BunPluginLike {\n name: string;\n setup: (build: BunBuildContext) => unknown;\n}\n\n/** Bun's own file reader, for the gap-2 passthrough read; this only ever runs inside a Bun process. */\ndeclare const Bun: {file: (path: string) => {text: () => Promise<string>}};\n\n// Bun infers a loader from the extension on a plain read, but the runtime host wants one named explicitly.\nfunction passthroughLoader(args: BunOnLoadArgs): string {\n if (typeof args.loader === 'string' && args.loader !== '') return args.loader;\n if (args.path.endsWith('.tsx')) return 'tsx';\n if (args.path.endsWith('.jsx')) return 'jsx';\n if (/\\.[mc]?js$/.test(args.path)) return 'js';\n return 'ts';\n}\n\n/**\n * The RunTypes Bun plugin. Pass it to `Bun.build({plugins: [...]})` or to\n * `Bun.plugin()` from a `--preload` module (see `bunfig.toml`'s `preload`).\n *\n * ```ts\n * // rt-preload.ts, referenced from bunfig.toml `preload`\n * import {plugin} from 'bun';\n * import runtypes from '@mionjs/devtools/runtypes/bun';\n * plugin(runtypes({tsconfig: './tsconfig.json'}));\n * ```\n */\nexport function runtypesBunPlugin(options?: Options): BunPluginLike {\n return {\n name: PLUGIN_NAME,\n async setup(build: BunBuildContext) {\n // Decided HERE, not at construction, because the inner plugin's options depend on it.\n const runtimeHost = typeof build.onStart !== 'function';\n\n // `detachResolver` unrefs the resolver child: right for the runtime loader, which never gets a buildEnd to\n // close it, WRONG for Bun.build, where a pending resolver response can be the build's only live handle.\n const built = unplugin.bun(runtimeHost ? ({...options, detachResolver: true} as Options) : options) as unknown;\n // unplugin returns one plugin for a single-plugin factory, but its type allows an array.\n const inner = (Array.isArray(built) ? built[0] : built) as BunPluginLike;\n\n // Gap 1 — capture what unplugin registers, to drive it below; the BUNDLER host has both hooks and is left\n // alone, so Bun.build keeps its own ordering.\n const startCallbacks: Array<() => unknown> = [];\n const endCallbacks: Array<() => unknown> = [];\n if (runtimeHost) {\n build.onStart = (callback) => void startCallbacks.push(callback);\n build.onEnd = (callback) => void endCallbacks.push(callback);\n }\n\n // Gap 3 — every load waits on this: the captured buildStart callbacks having finished (resolver up, cache\n // modules on disk), or nothing on the bundler host, which sequences onStart before onLoad itself.\n let signalReady: () => void = () => {};\n const ready = new Promise<void>((resolve) => {\n signalReady = resolve;\n });\n // A startup FAILURE must not hang every import behind a promise that never settles; rethrown from the load\n // that hits it, where Bun can attribute the error to a real file.\n let startupError: unknown;\n\n // Gap 2 + gap 3 — wrap onLoad before `setup` registers any.\n const registerLoad = build.onLoad.bind(build);\n build.onLoad = (constraints, callback) =>\n registerLoad(constraints, async (args: BunOnLoadArgs) => {\n await ready;\n if (startupError !== undefined) throw startupError;\n const result = await callback(args);\n if (result && typeof result === 'object') return result;\n // Gap 2 — no rewrite for this file, and undefined would throw, so hand back the source to transpile.\n return {contents: await Bun.file(args.path).text(), loader: passthroughLoader(args)};\n });\n\n await inner.setup?.(build);\n\n if (!runtimeHost) {\n signalReady();\n return;\n }\n // Drive the captured buildStart, THEN open the gate.\n try {\n for (const callback of startCallbacks) await callback();\n } catch (error) {\n startupError = error;\n } finally {\n signalReady();\n }\n // buildEnd has no runtime-host trigger, the process exiting is the teardown; referenced so a future host\n // that grows an onEnd can run them.\n void endCallbacks;\n },\n };\n}\n\nexport default runtypesBunPlugin;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../src/runtypes/esbuild.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C,cAAc,qBAAqB,CAAC;AACpC,eAAe,QAAQ,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../src/runtypes/esbuild.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C,cAAc,qBAAqB,CAAC;AACpC,eAAe,QAAQ,CAAC,OAAO,CAAC","sourcesContent":["// esbuild has no transform phase, so unplugin emulates it via onLoad and this entry loads every matched module.\nimport {unplugin} from '../core/unplugin.ts';\n\nexport * from '../core/unplugin.ts';\nexport default unplugin.esbuild;\n"]}
@@ -93,7 +93,7 @@ export async function startBroker(root, options = {}) {
93
93
  debug(`buildStart done, ${countGenerated()} generated modules`);
94
94
  refreshStamp(true);
95
95
  startWatching();
96
- void writeArtifact();
96
+ return writeArtifact();
97
97
  })
98
98
  .catch((error) => {
99
99
  startupError = error;
@@ -109,19 +109,17 @@ export async function startBroker(root, options = {}) {
109
109
  }
110
110
  }
111
111
  function generatedListing() {
112
+ let names;
113
+ try {
114
+ names = fs.readdirSync(path.join(genDirAbs, 'types'), { recursive: true });
115
+ }
116
+ catch {
117
+ return [];
118
+ }
112
119
  const listing = [];
113
- for (const half of ['types', 'rpc']) {
114
- let names;
115
- try {
116
- names = fs.readdirSync(path.join(genDirAbs, half), { recursive: true });
117
- }
118
- catch {
119
- continue;
120
- }
121
- for (const name of names) {
122
- const entry = `${half}/${name.split(path.sep).join('/')}`;
123
- listing.push(entry.startsWith(FILE_MODULE_PREFIX) && isModuleFile(entry) ? `${entry}#${contentHash(entry)}` : entry);
124
- }
120
+ for (const name of names) {
121
+ const entry = `types/${name.split(path.sep).join('/')}`;
122
+ listing.push(entry.startsWith(FILE_MODULE_PREFIX) && isModuleFile(entry) ? `${entry}#${contentHash(entry)}` : entry);
125
123
  }
126
124
  return listing.sort();
127
125
  }
@@ -288,7 +286,9 @@ export async function startBroker(root, options = {}) {
288
286
  if (flushTimer)
289
287
  clearTimeout(flushTimer);
290
288
  await new Promise((resolve) => server.close(() => resolve()));
289
+ await Promise.all([ready, chain, hotUpdate]);
291
290
  await unlinkQuietly(socketPath);
291
+ process.off('exit', cleanup);
292
292
  built.buildEnd?.call(context);
293
293
  },
294
294
  };
@@ -1 +1 @@
1
- {"version":3,"file":"broker.js","sourceRoot":"","sources":["../../../src/runtypes/next/broker.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,UAAU,EAA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QAAQ,KAAK,OAAO;QAAE,OAAO;IACzC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;AACH,CAAC","sourcesContent":["// ONE resolver and ONE whole-program buildStart per `next build` / `next dev`, shared by every Turbopack\n// loader worker. Turbopack runs loaders in a POOL OF NODE WORKER PROCESSES, so a loader that started the\n// resolver itself would start one per worker and pay for that many whole-program tsgo builds; `next.config`\n// runs before any worker exists, so it hosts the real buildStart and workers ask it for one file at a time.\n// ELECTION is by ATOMIC SOCKET BIND, not a flag, because `next.config` is evaluated more than once (observed:\n// twice per build, in the same process) and nothing promises that stays true: first bind owns the resolver,\n// a later caller sees EADDRINUSE and becomes a client. READINESS: connections are accepted IMMEDIATELY,\n// before buildStart finishes, and each request waits on a promise; attaching the handler afterwards silently\n// DROPS a connection that arrived during startup (an EventEmitter discards events with no listener) and the\n// worker hangs forever. Same gate as gap 3 in ../bun.ts.\nimport fs from 'node:fs';\nimport net from 'node:net';\nimport os from 'node:os';\nimport path from 'node:path';\nimport {createHash} from 'node:crypto';\nimport type {UnpluginContextMeta} from 'unplugin';\nimport {unplugin, type PluginOptions} from '../../core/unplugin.ts';\nimport {createLineReader, type BrokerReply, type BrokerRequest} from './wire.ts';\nimport {RUNTYPES_FILE_MODULE_DIR} from '../../core/go-generated/runtypes-constants.generated.ts';\n\n// The check is a cheap readdir, but on a large project it would still run once per file without a throttle.\nconst STAMP_THROTTLE_MS = 100;\nconst FILE_MODULE_PREFIX = `types/${RUNTYPES_FILE_MODULE_DIR}/`;\n\n// How long an edit may settle before absorbing it: several files saved at once (a formatter) are ONE batch.\nconst WATCH_DEBOUNCE_MS = 30;\n\n// The Next lane has no plugin log of its own, so without this trace a misbehaving dev loop is completely opaque.\nconst debugEnabled = process.env.MION_NEXT_DEBUG === '1';\nfunction debug(message: string): void {\n if (debugEnabled) console.error(`[@mionjs/devtools:next] ${message}`);\n}\n\n// Next sets NODE_ENV before it loads the config, so the config process (where the broker starts) reads the lane.\nexport function isNextDev(): boolean {\n return process.env.NODE_ENV === 'development';\n}\n\n// The Next-only knobs live here, not in PluginOptions, so core/plugin-option-keys.ts and its parity test stay put.\nexport interface NextOptions extends PluginOptions {\n // Set it only to keep two projects that share a root from sharing one resolver.\n socketPath?: string;\n // Next's distDir, as withRunTypes derives it. Nothing reads the copy: a Next app is never installed as a package.\n // Best effort, no post-build hook: written after buildStart and on the first loader request (Turbopack empties it).\n artifactDir?: string;\n}\n\nexport interface BrokerHandle {\n /** True when THIS caller won the election and owns the resolver. */\n owner: boolean;\n socketPath: string;\n /** Releases the socket and the resolver. A no-op for a non-owner. */\n close: () => Promise<void>;\n}\n\n// socketPathFor derives the endpoint for ONE Next invocation. The process id in the key is a CORRECTNESS\n// requirement: keyed on the project root alone the socket is a global rendezvous any process evaluating\n// next.config can claim, including Next's detached telemetry flush, which outlives the dev server and gets\n// reparented to init, so a later `next dev` joins THAT resolver and every file comes back \"source file not in\n// program\" from a Program belonging to a finished build, silently. Per-pid makes a stale owner unreachable\n// instead of authoritative; workers never derive this path, next.config bakes it into the loader options.\n// On POSIX it lives in the temp dir because a unix socket path is capped near 104 bytes and a deep project\n// path spends that on its own; Windows has no such limit and no unix sockets, so it gets a named pipe.\nexport function socketPathFor(root: string, pid: number = process.pid): string {\n const digest = createHash('sha256').update(path.resolve(root)).digest('hex').slice(0, 12);\n if (process.platform === 'win32') return `\\\\\\\\.\\\\pipe\\\\mion-next-${digest}-${pid}`;\n return path.join(os.tmpdir(), `mion-next-${digest}-${pid}.sock`);\n}\n\n// Next's detached telemetry flush loads next.config too, and a resolver started there never serves a loader\n// and lingers after the build. Per-pid sockets stop it poisoning anything; this stops it existing.\nexport function ownsBroker(): boolean {\n return !/detached-flush|telemetry/.test(process.argv[1] ?? '');\n}\n\n/** Starts or joins the broker for `root`: exactly one caller wins the election and the rest no-op. */\nexport async function startBroker(root: string, options: NextOptions = {}): Promise<BrokerHandle> {\n const rootAbs = path.resolve(root);\n const socketPath = options.socketPath ?? socketPathFor(rootAbs);\n\n // Set after buildStart, never defaulted: a default would beat the tsconfig or inferred genDir the enrich CLI uses.\n let genDirAbs = '';\n let stampPath = '';\n\n const server = net.createServer();\n const listening = await new Promise<boolean>((resolve, reject) => {\n server.once('error', (error: NodeJS.ErrnoException) => {\n if (error.code === 'EADDRINUSE') return resolve(false);\n if (error.code === 'ECONNREFUSED' || error.code === 'ENOENT') return resolve(false);\n reject(error);\n });\n server.listen(socketPath, () => resolve(true));\n });\n\n // Someone else owns it, or a killed build left a stale socket file: if nothing answers, take the address over.\n if (!listening) {\n if (await isLive(socketPath)) return {owner: false, socketPath, close: async () => {}};\n await unlinkQuietly(socketPath);\n return startBroker(rootAbs, options);\n }\n\n const {socketPath: _socketPath, ...pluginOptions} = options;\n const rawPlugin = unplugin.raw(\n {\n ...pluginOptions,\n cwd: rootAbs,\n // No bundler config here to read the lane from: under `next dev` a RuntimeError reports without halting\n // (see PluginOptions.devServer), under `next build` it halts.\n devServer: pluginOptions.devServer ?? isNextDev(),\n // No host gives this broker a buildEnd, so the resolver child must never be the handle keeping Next alive.\n detachResolver: true,\n },\n // Called with no host, so the cast records that the compiler-bearing meta a real webpack host would pass\n // deliberately does not exist here. (With rollup absent from node_modules the meta type collapses to any\n // and enforces nothing.)\n {framework: 'webpack', versions: {}} as UnpluginContextMeta\n );\n // A single-plugin factory returns one plugin, but unplugin's type allows an array.\n const built = (Array.isArray(rawPlugin) ? rawPlugin[0] : rawPlugin) as {\n buildStart?: (this: unknown) => unknown;\n buildEnd?: (this: unknown) => unknown;\n transform?: (this: unknown, code: string, id: string) => unknown;\n rtHotUpdate?: (ctx: unknown, updates: {file: string; content?: string}[]) => Promise<void>;\n rtWritePureFnArtifact?: (dir: string) => Promise<void>;\n rtGenDir?: () => string;\n };\n const writeArtifact = async (): Promise<void> => {\n if (!options.artifactDir) return;\n await built.rtWritePureFnArtifact?.(options.artifactDir).catch((error) => debug(`artifact write failed: ${String(error)}`));\n };\n let artifactWrittenOnRequest = false;\n\n // A warning raised while rewriting one file goes back to that file's loader so Turbopack can attribute it;\n // one raised outside a request (the whole-program buildStart) has no loader to own it and goes to stderr.\n let collecting: string[] | null = null;\n // The shared transform hook declares type dependencies through `addWatchFile` (unplugin's universal shape),\n // so the broker collects them here rather than reaching into the plugin: no Next-specific plumbing in the leaf.\n let collectingDeps: string[] | null = null;\n const context = {\n warn: (message: unknown) => {\n const text = String(message);\n if (collecting) collecting.push(text);\n else console.warn(`[@mionjs/devtools] ${text}`);\n },\n error: (error: unknown) => {\n throw error instanceof Error ? error : new Error(String(error));\n },\n addWatchFile: (file: unknown) => {\n if (collectingDeps && typeof file === 'string') collectingDeps.push(file);\n },\n };\n\n let startupError: unknown;\n const ready = (async () => {\n await built.buildStart?.call(context);\n genDirAbs = built.rtGenDir?.() ?? '';\n if (!genDirAbs) throw new Error('@mionjs/devtools: the resolver did not report its output directory (genDir)');\n stampPath = path.join(genDirAbs, 'types', '.rt-stamp');\n debug(`genDir ${genDirAbs}`);\n })()\n .then(() => {\n debug(`buildStart done, ${countGenerated()} generated modules`);\n refreshStamp(true);\n startWatching();\n // Returned so close() waits for it and the first request's own write never overlaps it.\n return writeArtifact();\n })\n .catch((error) => {\n startupError = error;\n });\n\n // ── invalidation stamp ────────────────────────────────────────────────────\n // Turbopack cannot see types from OTHER files: `TransformResult.typeDeps` names them, the stamp is the fallback.\n // Every rewritten file declares the stamp, a hash of the generated listing: a type change re-runs them all.\n // Bounded: only files with marker sites are rewritten, a few ms each.\n // `.ts` under emitMode 'ts', `.js` otherwise.\n const isModuleFile = (name: string): boolean => name.endsWith('.js') || name.endsWith('.ts');\n\n function countGenerated(): number {\n try {\n const names = fs.readdirSync(path.join(genDirAbs, 'types'), {recursive: true}) as string[];\n return names.filter(isModuleFile).length;\n } catch {\n return -1;\n }\n }\n\n /** A `types/rt/` module keeps its name when its types change, so its entry adds a content hash. */\n function generatedListing(): string[] {\n let names: string[];\n try {\n names = fs.readdirSync(path.join(genDirAbs, 'types'), {recursive: true}) as string[];\n } catch {\n return []; // not generated yet\n }\n const listing: string[] = [];\n for (const name of names) {\n // Recursive readdir joins with the OS separator; the prefix test and the stamp want '/'.\n const entry = `types/${name.split(path.sep).join('/')}`;\n listing.push(entry.startsWith(FILE_MODULE_PREFIX) && isModuleFile(entry) ? `${entry}#${contentHash(entry)}` : entry);\n }\n return listing.sort();\n }\n\n // The stamp refreshes after every transform, so a module is re-read only once its stat moved.\n const hashByEntry = new Map<string, {stat: string; hash: string}>();\n function contentHash(entry: string): string {\n const file = path.join(genDirAbs, entry);\n try {\n const {mtimeNs, size} = fs.statSync(file, {bigint: true});\n const stat = `${mtimeNs}:${size}`;\n const cached = hashByEntry.get(entry);\n if (cached?.stat === stat) return cached.hash;\n const hash = createHash('sha256').update(fs.readFileSync(file)).digest('hex').slice(0, 16);\n hashByEntry.set(entry, {stat, hash});\n return hash;\n } catch {\n return '';\n }\n }\n\n let lastStamp = '';\n let lastStampAt = 0;\n function refreshStamp(force = false): void {\n const now = Date.now();\n if (!force && now - lastStampAt < STAMP_THROTTLE_MS) return;\n lastStampAt = now;\n const listing = generatedListing();\n if (listing.length === 0) return; // nothing generated yet\n const digest = createHash('sha256').update(listing.join('\\n')).digest('hex').slice(0, 16);\n if (digest === lastStamp) return;\n debug(`stamp ${lastStamp || '(none)'} -> ${digest} (${listing.length} entries)`);\n lastStamp = digest;\n try {\n fs.writeFileSync(stampPath, `${digest}\\n`);\n } catch {\n // A stamp we cannot write only costs invalidation precision, never the build.\n }\n }\n\n // ── watching for edits ────────────────────────────────────────────────────\n // Turbopack gives a loader no update callback, so the only other signal an edit happened is the loader being\n // re-run, by which time Turbopack is already resolving imports. Absorbing edits one loader call at a time\n // regenerates the module set once PER FILE, and a file resolved during one of those rewrites fails with\n // \"can't resolve <hash>.js\" for a module that exists moments later (observed, before the watcher existed).\n // So the broker watches the sources itself and absorbs a whole edit as ONE batch, ahead of any loader re-run:\n // the same order Vite's handleHotUpdate gets for free, via the same shared leaf.\n let watcher: fs.FSWatcher | null = null;\n const dirtyFiles = new Set<string>();\n let flushTimer: NodeJS.Timeout | null = null;\n // Serialises watcher-driven updates against transforms: a transform must never read a half-regenerated tree.\n let hotUpdate: Promise<void> = Promise.resolve();\n\n function scheduleFlush(): void {\n if (flushTimer) clearTimeout(flushTimer);\n flushTimer = setTimeout(flushDirty, WATCH_DEBOUNCE_MS);\n flushTimer.unref?.();\n }\n\n function flushDirty(): void {\n if (dirtyFiles.size === 0) return;\n const batch = [...dirtyFiles];\n dirtyFiles.clear();\n const work = async () => {\n await ready;\n const read = await Promise.all(\n batch.map(async (file) => ({file, content: await fs.promises.readFile(file, 'utf8').catch(() => undefined)}))\n );\n const updates = read.filter((update) => update.content !== undefined);\n if (updates.length === 0) return;\n debug(`absorbing ${updates.length} edited file(s): ${updates.map((u) => path.relative(rootAbs, u.file)).join(', ')}`);\n await built.rtHotUpdate?.(context, updates);\n debug(`generated modules now: ${countGenerated()}`);\n refreshStamp(true);\n };\n hotUpdate = hotUpdate.then(work).catch(() => {\n // A failed absorb must not wedge the dev loop; the next edit retries.\n });\n }\n\n function startWatching(): void {\n if (watcher) return;\n try {\n watcher = fs.watch(rootAbs, {recursive: true}, (_event, name) => {\n if (!name) return;\n const file = path.join(rootAbs, name.toString());\n // Ignore our own output and anything that cannot carry a marker site.\n if (file.startsWith(genDirAbs)) return;\n if (file.includes(`${path.sep}node_modules${path.sep}`) || file.includes(`${path.sep}.next${path.sep}`)) return;\n if (!/\\.[mc]?[jt]sx?$/.test(file)) return;\n debug(`watch: ${path.relative(rootAbs, file)}`);\n dirtyFiles.add(file);\n scheduleFlush();\n });\n watcher.unref?.();\n } catch {\n // Recursive watch is unsupported on some platforms, so the dev loop degrades to per-file absorption.\n }\n }\n\n // The resolver answers strictly FIFO and carries no request ids, so every worker's requests share one chain.\n // Transforms are ~2ms, so serialising them costs far less than the duplicated startup would.\n let chain: Promise<void> = Promise.resolve();\n\n server.on('connection', (socket) => {\n socket.on('error', () => {});\n socket.on(\n 'data',\n createLineReader((line) => {\n let request: BrokerRequest;\n try {\n request = JSON.parse(line) as BrokerRequest;\n } catch {\n return;\n }\n chain = chain.then(() => handle(request, socket));\n })\n );\n });\n\n async function handle(request: BrokerRequest, socket: net.Socket): Promise<void> {\n const warnings: string[] = [];\n let reply: BrokerReply;\n try {\n await ready;\n if (startupError) throw startupError;\n if (!artifactWrittenOnRequest) {\n artifactWrittenOnRequest = true;\n await writeArtifact();\n }\n // Never rewrite against a tree a watcher-driven regenerate is mid-way through writing.\n await hotUpdate;\n collecting = warnings;\n const deps: string[] = [];\n collectingDeps = deps;\n const result = (await built.transform?.call(context, request.code, request.file)) as\n | {code?: string; map?: unknown}\n | null\n | undefined;\n collecting = null;\n collectingDeps = null;\n // Forced: the reply hands the loader this stamp, so it must reflect THIS transform's output.\n // The fs-watcher throttle left a back-to-back second reply on a stale stamp (\"moves the invalidation stamp\" test).\n refreshStamp(true);\n reply = {\n id: request.id,\n ok: true,\n ...(result && typeof result.code === 'string' ? {code: result.code, map: result.map} : {}),\n ...(warnings.length ? {warnings} : {}),\n ...(deps.length ? {typeDeps: [...new Set(deps)].sort()} : {}),\n // Empty typeDeps means unknown; always send the stamp to prevent stale rewrites (./AGENTS.md, 7).\n stamp: stampPath,\n };\n } catch (error) {\n collecting = null;\n collectingDeps = null;\n reply = {\n id: request.id,\n ok: false,\n error: String((error as Error)?.stack ?? error),\n ...(warnings.length ? {warnings} : {}),\n };\n }\n if (!socket.destroyed) socket.write(`${JSON.stringify(reply)}\\n`);\n }\n\n // The broker lives inside the Next process and must never be the reason it stays alive. No idle timeout on\n // purpose: closing the resolver mid-session makes the next edit pay for a cold start.\n server.unref();\n // A leftover socket file is inert, per-pid keying means nothing dials it again, but still litter.\n const cleanup = () => {\n try {\n if (process.platform !== 'win32') fs.unlinkSync(socketPath);\n } catch {\n // already gone\n }\n };\n process.once('exit', cleanup);\n\n return {\n owner: true,\n socketPath,\n close: async () => {\n watcher?.close();\n if (flushTimer) clearTimeout(flushTimer);\n await new Promise<void>((resolve) => server.close(() => resolve()));\n // In-flight work still writes into the project; a caller deleting it after close() hit ENOTEMPTY. None rejects.\n await Promise.all([ready, chain, hotUpdate]);\n await unlinkQuietly(socketPath);\n process.off('exit', cleanup);\n built.buildEnd?.call(context);\n },\n };\n}\n\n// isLive distinguishes a serving broker from a socket file left behind by a killed build.\nfunction isLive(socketPath: string): Promise<boolean> {\n return new Promise((resolve) => {\n const probe = net.connect(socketPath);\n const settle = (live: boolean) => {\n probe.destroy();\n resolve(live);\n };\n probe.once('connect', () => settle(true));\n probe.once('error', () => settle(false));\n });\n}\n\nasync function unlinkQuietly(target: string): Promise<void> {\n if (process.platform === 'win32') return; // named pipes are not files\n try {\n await fs.promises.unlink(target);\n } catch {\n // already gone\n }\n}\n"]}