Files
orca/src/main/plugins/plugin-dev-watcher-ignore.ts
T
Neil fbe891ce8b fix(plugins): skip nested packages in dev folders and summarize blocked frame requests (#37300)
* fix(plugins): skip nested dev packages and count blocked frame requests

Dev folders and their watcher now skip .git, .orca and node_modules at any
depth, so a nested build/node_modules no longer trips the 2,000-file limit
or re-reviews the plugin; installs still hash everything but the root .git.

Requests a plugin frame makes off its own files (session-cancelled or
refused by its content policy) are counted per kind and origin and logged
every 5 s and on teardown, outside the 20-lines-per-10-s console budget:
[frame] blocked font-src https://unpkg.com (x48): plugin frames have no network

* fix(plugins): read current CSP refusal wording and bound blocked-request logging

- Electron 43 prints "Loading the font '…' violates …" (and Connecting to / Framing /
  Fetching content from); read it alongside the older "Refused to …" wording, name the
  unset directive from the fallback note, and treat fetch's repeat as an echo. An Electron
  test captures the bundled runtime's real messages.
- Keep at most 32 kind-and-origin counts and log at most 8 lines per flush, folding the
  rest into one overflow count line.
2026-11-02 04:21:03 +00:00

27 lines
1.1 KiB
TypeScript

import { basename, isAbsolute, relative, sep } from 'node:path'
import {
buildParcelWatcherIgnoreOptions,
type ParcelWatcherIgnoreOptions
} from '../ipc/filesystem/watchers/filesystem-watcher-ignore'
import { DEV_FOLDER_SKIPPED_DIRECTORIES } from './plugin-content-hash'
// Why these: the dev tree hash and plugin serving never read them, so their churn is not an edit.
const IGNORED_DEV_DIRECTORIES: readonly string[] = [...DEV_FOLDER_SKIPPED_DIRECTORIES]
const OS_JUNK_FILE_NAMES = new Set(['.DS_Store', 'Thumbs.db', 'desktop.ini'])
/** Native-side exclusions for a dev root's recursive subscription, at any depth. */
export function pluginDevWatchIgnoreOptions(): ParcelWatcherIgnoreOptions {
return buildParcelWatcherIgnoreOptions(IGNORED_DEV_DIRECTORIES)
}
export function isIgnoredPluginDevPath(root: string, path: string): boolean {
if (OS_JUNK_FILE_NAMES.has(basename(path))) {
return true
}
const fromRoot = relative(root, path)
if (!fromRoot || fromRoot.startsWith('..') || isAbsolute(fromRoot)) {
return false
}
return fromRoot.split(sep).some((segment) => IGNORED_DEV_DIRECTORIES.includes(segment))
}