Files
orca/src/main/ipc/automatic-load-path-text.ts
T
NeilandClaude 5dd5294294 perf(orcad): keep the server bundle ASCII so V8 stores it at half the size (#31495)
* perf(orcad): keep the server bundle ASCII so V8 stores it one byte per character

129 non-ASCII characters in regex literals (and three in a String.raw plugin
template) made V8 hold the whole ~11 MB orcad-server.js source as a two-byte
string. Write them as \uXXXX escapes and fail the build if any return.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(orcad): keep license comments ASCII and name the module the guard trips on

esbuild gathers legal comments at the end of the bundle; escape that comment so
a dependency's license text cannot fail the ASCII guard, while licenses still
ship with the code. The guard now reports the offset and, from an unminified
rebuild, the module the character came from. A dark-switch build is covered.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-21 04:06:49 -07:00

48 lines
1.6 KiB
TypeScript

import { basename, sep } from 'node:path'
import { parseWslUncPath } from '../../shared/wsl-paths'
// Why the path flavour, not the OS: these are Windows path rules, and tests exercise them with
// path.win32 on any host.
function usesWindowsPaths(): boolean {
return sep === '\\'
}
const WINDOWS_RESERVED_DEVICE_STEM =
/^(?:con|prn|aux|nul|conin\$|conout\$|clock\$|com[0-9\u00B9\u00B2\u00B3]|lpt[0-9\u00B9\u00B2\u00B3])$/i
/**
* `NUL.png`, `com1 .jpg`, `Aux.`, `NUL:stream.png` name a Windows device, not a file, whatever the
* extension or alternate data stream (`:`).
*/
export function isWindowsReservedDeviceName(filePath: string): boolean {
if (!usesWindowsPaths()) {
return false
}
const stem =
basename(filePath)
.replace(/[. ]+$/, '')
.split(/[.:]/)[0] ?? ''
return WINDOWS_RESERVED_DEVICE_STEM.test(stem.replace(/ +$/, ''))
}
function toBackslashes(filePath: string): string {
return filePath.replace(/\//g, '\\')
}
/** A Windows device-namespace path (`\\?\`, `\\.\`), which can name devices and shares alike. */
export function isDeviceNamespacePath(filePath: string): boolean {
return usesWindowsPaths() && /^\\\\[?.]\\/.test(toBackslashes(filePath))
}
/**
* A network share (`\\host\share`). WSL paths are UNC in form but stay on this machine, so they
* are not network paths.
*/
export function isNetworkSharePath(filePath: string): boolean {
if (!usesWindowsPaths() || isDeviceNamespacePath(filePath)) {
return false
}
const normalized = toBackslashes(filePath)
return normalized.startsWith('\\\\') && parseWslUncPath(normalized) === null
}