#!/usr/bin/env node /* * Post-rebase web integrity checker. * * The upstream rebase has repeatedly produced *silent* runtime breakage that * `vue-cli-service build` does NOT fail on and that unit tests (which do not * mount full views) do not catch. Three classes of corruption have bitten us: * * 1. Lost/duplicated imports -> shorthand component/object references to an * identifier that was never imported/declared (e.g. `components: * { CustomDialog }` with no import). Throwing module factory makes * webpack cache a half-initialized module and vue-router silently renders * a blank page (no console error). * * 2. Dropped function-signature parameters / const bindings (e.g. a method * body that references `request`, `onTerminalFailure`, `retryCount`, * `retryWindowStartedAt`, `failCallback` after the merge deleted them * from the signature). Throws ReferenceError at call time. * * 3. Interleaved / half-converted Vue templates -> mismatched tags * (`` ... ``, `` ... ``) * and duplicated option keys (`computed:` twice) that silently clobber * each other. * * This script fails hard (exit 1) if any of those reappear, so a future * rebase cannot merge them in silently. Run via `npm run check:integrity` * (wired into CI and into scripts/westernization_rebase_check.sh). */ const fs = require('fs'); const path = require('path'); const acorn = require('acorn'); const { analyze } = require('eslint-scope'); const { parseComponent, compile } = require('vue-template-compiler'); const ROOT = path.resolve(__dirname, '..'); const SRC = path.join(ROOT, 'src'); // Browser/ES/Node globals that legitimately resolve outside module scope. const GLOBALS = new Set([ 'window', 'document', 'navigator', 'location', 'localStorage', 'sessionStorage', 'console', 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'requestAnimationFrame', 'cancelAnimationFrame', 'Promise', 'JSON', 'Math', 'Date', 'Array', 'Object', 'String', 'Number', 'Boolean', 'Symbol', 'Map', 'Set', 'WeakMap', 'WeakSet', 'Proxy', 'Reflect', 'Error', 'TypeError', 'RangeError', 'SyntaxError', 'EvalError', 'ReferenceError', 'URIError', 'RegExp', 'encodeURIComponent', 'decodeURIComponent', 'encodeURI', 'decodeURI', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'fetch', 'URL', 'URLSearchParams', 'Blob', 'File', 'FileReader', 'FormData', 'AbortController', 'AbortSignal', 'atob', 'btoa', 'Image', 'Audio', 'XMLHttpRequest', 'WebSocket', 'EventSource', 'MutationObserver', 'IntersectionObserver', 'ResizeObserver', 'performance', 'crypto', 'process', 'Function', 'alert', 'confirm', 'prompt', 'getComputedStyle', 'matchMedia', 'CSS', 'DOMParser', 'XMLSerializer', 'TextEncoder', 'TextDecoder', 'Uint8Array', 'Int8Array', 'Uint16Array', 'Int16Array', 'Uint32Array', 'Int32Array', 'Float32Array', 'Float64Array', 'Uint8ClampedArray', 'DataView', 'ArrayBuffer', 'Notification', 'caches', 'indexedDB', 'self', 'globalThis', 'structuredClone', 'queueMicrotask', 'Intl', 'eval', 'arguments', 'AudioContext', 'webkitAudioContext', 'Element', 'Node', 'HTMLElement', 'SVGElement', 'Event', 'CustomEvent', 'KeyboardEvent', 'MouseEvent', 'DOMException', 'devicePixelRatio', 'screen', 'history', 'Worker', 'IDBKeyRange', 'SpeechSynthesisUtterance', 'Range', 'Text', 'undefined', 'NaN', 'Infinity', 'global', 'module', 'require', 'exports', 'Buffer', '__dirname', '__filename', 'Response', 'Request', 'Headers', 'importScripts', // ServiceWorker scope (src/service-worker.js, injected by workbox) 'workbox', 'skipWaiting', 'clients', 'registration', 'serviceWorker', ]); // Vue SFC macros available inside