diff --git a/scripts/globals-extractor.mjs b/scripts/globals-extractor.mjs index 80f5277f37..c479418aad 100644 --- a/scripts/globals-extractor.mjs +++ b/scripts/globals-extractor.mjs @@ -1,27 +1,30 @@ /** ---------------------------------------------------------------------- -This script gets a list of global objects/interfaces of browser. +This script gets a list of global objects/functions of browser. This process is simple for now, so it is handled without AST parser. +Please run `node scripts/globals-extractor.mjs` at the project root. + see: https://github.com/microsoft/TypeScript/tree/main/lib ---------------------------------------------------------------------- */ import http from 'https'; +import fs from 'fs'; const get_url = (name) => `https://raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.${name}.d.ts`; const extract_name = (split) => split.match(/^[a-zA-Z0-9_$]+/)[0]; -const extract_interfaces_and_references = (data) => { - const interfaces = []; +const extract_functions_and_references = (data) => { + const functions = []; const references = []; data.split('\n').forEach(line => { const trimmed = line.trim(); const split = trimmed.replace(/[\s+]/, ' ').split(' '); - if (split[0] === 'declare') interfaces.push(extract_name(split[2])); + if (split[0] === 'declare') functions.push(extract_name(split[2])); else if (trimmed.startsWith('/// new Promise((resolve, reject) => { @@ -36,20 +39,34 @@ const do_get = (url) => new Promise((resolve, reject) => { }); }); -const get_interfaces = async (name) => { +const get_functions = async (name) => { const res = []; const body = await do_get(get_url(name)); - const { interfaces, references } = extract_interfaces_and_references(body); - res.push(...interfaces); - const chile_interfaces = await Promise.all(references.map(get_interfaces)); - chile_interfaces.forEach(i => res.push(...i)); + const { functions, references } = extract_functions_and_references(body); + res.push(...functions); + const chile_functions = await Promise.all(references.map(get_functions)); + chile_functions.forEach(i => res.push(...i)); return res; }; +const build_output = (functions) => { + const sorted = Array.from(new Set(functions.sort())); + return ` +/** ---------------------------------------------------------------------- +This file is automatically generated by \`scripts/globals-extractor.mjs\`. +Generated At: ${new Date().toISOString()} +---------------------------------------------------------------------- */ + +export default new Set([ +${sorted.map((i) => `\t'${i}'`).join(',\n')} +]); +`.substring(1); +}; + (async () => { - const interfaces = await get_interfaces('es2021.full'); - // MEMO: add additional objects/interfaces which existed in `src/compiler/utils/names.ts` + const functions = await get_functions('es2021.full'); + // MEMO: add additional objects/functions which existed in `src/compiler/utils/names.ts` // before this script was introduced but could not be retrieved by this process. - interfaces.push(...['global', 'globalThis', 'InternalError', 'process', 'undefined']); - new Set(interfaces.sort()).forEach((i) => console.log(`'${i}',`)); + functions.push(...['global', 'globalThis', 'InternalError', 'process', 'undefined']); + fs.writeFileSync('src/compiler/utils/globals.ts', build_output(functions)); })(); diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 63c62a256a..2f8874de7a 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -1,7 +1,8 @@ import { walk } from 'estree-walker'; import { getLocator } from 'locate-character'; import Stats from '../Stats'; -import { globals, reserved, is_valid } from '../utils/names'; +import { reserved, is_valid } from '../utils/names'; +import globals from '../utils/globals'; import { namespaces, valid_namespaces } from '../utils/namespaces'; import create_module from './create_module'; import { diff --git a/src/compiler/utils/globals.ts b/src/compiler/utils/globals.ts new file mode 100644 index 0000000000..9406aee71d --- /dev/null +++ b/src/compiler/utils/globals.ts @@ -0,0 +1,821 @@ +/** ---------------------------------------------------------------------- +This file is automatically generated by `scripts/globals-extractor.mjs`. +Generated At: 2022-08-14T09:54:06.940Z +---------------------------------------------------------------------- */ + +export default new Set([ + 'AbortController', + 'AbortSignal', + 'AbstractRange', + 'ActiveXObject', + 'AggregateError', + 'AnalyserNode', + 'Animation', + 'AnimationEffect', + 'AnimationEvent', + 'AnimationPlaybackEvent', + 'AnimationTimeline', + 'Array', + 'ArrayBuffer', + 'Atomics', + 'Attr', + 'Audio', + 'AudioBuffer', + 'AudioBufferSourceNode', + 'AudioContext', + 'AudioDestinationNode', + 'AudioListener', + 'AudioNode', + 'AudioParam', + 'AudioParamMap', + 'AudioProcessingEvent', + 'AudioScheduledSourceNode', + 'AudioWorklet', + 'AudioWorkletNode', + 'AuthenticatorAssertionResponse', + 'AuthenticatorAttestationResponse', + 'AuthenticatorResponse', + 'BarProp', + 'BaseAudioContext', + 'BeforeUnloadEvent', + 'BigInt', + 'BigInt64Array', + 'BigUint64Array', + 'BiquadFilterNode', + 'Blob', + 'BlobEvent', + 'Boolean', + 'BroadcastChannel', + 'ByteLengthQueuingStrategy', + 'CDATASection', + 'CSS', + 'CSSAnimation', + 'CSSConditionRule', + 'CSSCounterStyleRule', + 'CSSFontFaceRule', + 'CSSGroupingRule', + 'CSSImportRule', + 'CSSKeyframeRule', + 'CSSKeyframesRule', + 'CSSMediaRule', + 'CSSNamespaceRule', + 'CSSPageRule', + 'CSSRule', + 'CSSRuleList', + 'CSSStyleDeclaration', + 'CSSStyleRule', + 'CSSStyleSheet', + 'CSSSupportsRule', + 'CSSTransition', + 'Cache', + 'CacheStorage', + 'CanvasGradient', + 'CanvasPattern', + 'CanvasRenderingContext2D', + 'ChannelMergerNode', + 'ChannelSplitterNode', + 'CharacterData', + 'ClassDecorator', + 'ClientRect', + 'Clipboard', + 'ClipboardEvent', + 'ClipboardItem', + 'CloseEvent', + 'Comment', + 'CompositionEvent', + 'ConstantSourceNode', + 'ConvolverNode', + 'CountQueuingStrategy', + 'Credential', + 'CredentialsContainer', + 'Crypto', + 'CryptoKey', + 'CustomElementRegistry', + 'CustomEvent', + 'DOMException', + 'DOMImplementation', + 'DOMMatrix', + 'DOMMatrixReadOnly', + 'DOMParser', + 'DOMPoint', + 'DOMPointReadOnly', + 'DOMQuad', + 'DOMRect', + 'DOMRectList', + 'DOMRectReadOnly', + 'DOMStringList', + 'DOMStringMap', + 'DOMTokenList', + 'DataTransfer', + 'DataTransferItem', + 'DataTransferItemList', + 'DataView', + 'Date', + 'DelayNode', + 'DeviceMotionEvent', + 'DeviceOrientationEvent', + 'Document', + 'DocumentFragment', + 'DocumentTimeline', + 'DocumentType', + 'DragEvent', + 'DynamicsCompressorNode', + 'Element', + 'Enumerator', + 'Error', + 'ErrorEvent', + 'EvalError', + 'Event', + 'EventSource', + 'EventTarget', + 'External', + 'File', + 'FileList', + 'FileReader', + 'FileSystem', + 'FileSystemDirectoryEntry', + 'FileSystemDirectoryReader', + 'FileSystemEntry', + 'FileSystemFileEntry', + 'FinalizationRegistry', + 'Float32Array', + 'Float64Array', + 'FocusEvent', + 'FontFace', + 'FontFaceSet', + 'FontFaceSetLoadEvent', + 'FormData', + 'FormDataEvent', + 'Function', + 'GainNode', + 'Gamepad', + 'GamepadButton', + 'GamepadEvent', + 'GamepadHapticActuator', + 'Geolocation', + 'GeolocationCoordinates', + 'GeolocationPosition', + 'GeolocationPositionError', + 'HTMLAllCollection', + 'HTMLAnchorElement', + 'HTMLAreaElement', + 'HTMLAudioElement', + 'HTMLBRElement', + 'HTMLBaseElement', + 'HTMLBodyElement', + 'HTMLButtonElement', + 'HTMLCanvasElement', + 'HTMLCollection', + 'HTMLDListElement', + 'HTMLDataElement', + 'HTMLDataListElement', + 'HTMLDetailsElement', + 'HTMLDirectoryElement', + 'HTMLDivElement', + 'HTMLDocument', + 'HTMLElement', + 'HTMLEmbedElement', + 'HTMLFieldSetElement', + 'HTMLFontElement', + 'HTMLFormControlsCollection', + 'HTMLFormElement', + 'HTMLFrameElement', + 'HTMLFrameSetElement', + 'HTMLHRElement', + 'HTMLHeadElement', + 'HTMLHeadingElement', + 'HTMLHtmlElement', + 'HTMLIFrameElement', + 'HTMLImageElement', + 'HTMLInputElement', + 'HTMLLIElement', + 'HTMLLabelElement', + 'HTMLLegendElement', + 'HTMLLinkElement', + 'HTMLMapElement', + 'HTMLMarqueeElement', + 'HTMLMediaElement', + 'HTMLMenuElement', + 'HTMLMetaElement', + 'HTMLMeterElement', + 'HTMLModElement', + 'HTMLOListElement', + 'HTMLObjectElement', + 'HTMLOptGroupElement', + 'HTMLOptionElement', + 'HTMLOptionsCollection', + 'HTMLOutputElement', + 'HTMLParagraphElement', + 'HTMLParamElement', + 'HTMLPictureElement', + 'HTMLPreElement', + 'HTMLProgressElement', + 'HTMLQuoteElement', + 'HTMLScriptElement', + 'HTMLSelectElement', + 'HTMLSlotElement', + 'HTMLSourceElement', + 'HTMLSpanElement', + 'HTMLStyleElement', + 'HTMLTableCaptionElement', + 'HTMLTableCellElement', + 'HTMLTableColElement', + 'HTMLTableElement', + 'HTMLTableRowElement', + 'HTMLTableSectionElement', + 'HTMLTemplateElement', + 'HTMLTextAreaElement', + 'HTMLTimeElement', + 'HTMLTitleElement', + 'HTMLTrackElement', + 'HTMLUListElement', + 'HTMLUnknownElement', + 'HTMLVideoElement', + 'HashChangeEvent', + 'Headers', + 'History', + 'IDBCursor', + 'IDBCursorWithValue', + 'IDBDatabase', + 'IDBFactory', + 'IDBIndex', + 'IDBKeyRange', + 'IDBObjectStore', + 'IDBOpenDBRequest', + 'IDBRequest', + 'IDBTransaction', + 'IDBVersionChangeEvent', + 'IIRFilterNode', + 'IdleDeadline', + 'Image', + 'ImageBitmap', + 'ImageBitmapRenderingContext', + 'ImageData', + 'Infinity', + 'InputEvent', + 'Int16Array', + 'Int32Array', + 'Int8Array', + 'InternalError', + 'IntersectionObserver', + 'IntersectionObserverEntry', + 'Intl', + 'JSON', + 'KeyboardEvent', + 'KeyframeEffect', + 'Location', + 'Map', + 'Math', + 'MathMLElement', + 'MediaCapabilities', + 'MediaDeviceInfo', + 'MediaDevices', + 'MediaElementAudioSourceNode', + 'MediaEncryptedEvent', + 'MediaError', + 'MediaKeyMessageEvent', + 'MediaKeySession', + 'MediaKeyStatusMap', + 'MediaKeySystemAccess', + 'MediaKeys', + 'MediaList', + 'MediaMetadata', + 'MediaQueryList', + 'MediaQueryListEvent', + 'MediaRecorder', + 'MediaRecorderErrorEvent', + 'MediaSession', + 'MediaSource', + 'MediaStream', + 'MediaStreamAudioDestinationNode', + 'MediaStreamAudioSourceNode', + 'MediaStreamTrack', + 'MediaStreamTrackEvent', + 'MessageChannel', + 'MessageEvent', + 'MessagePort', + 'MethodDecorator', + 'MimeType', + 'MimeTypeArray', + 'MouseEvent', + 'MutationEvent', + 'MutationObserver', + 'MutationRecord', + 'NaN', + 'NamedNodeMap', + 'Navigator', + 'NetworkInformation', + 'Node', + 'NodeFilter', + 'NodeIterator', + 'NodeList', + 'Notification', + 'Number', + 'Object', + 'OfflineAudioCompletionEvent', + 'OfflineAudioContext', + 'Option', + 'OscillatorNode', + 'OverconstrainedError', + 'PageTransitionEvent', + 'PannerNode', + 'ParameterDecorator', + 'Path2D', + 'PaymentAddress', + 'PaymentMethodChangeEvent', + 'PaymentRequest', + 'PaymentRequestUpdateEvent', + 'PaymentResponse', + 'Performance', + 'PerformanceEntry', + 'PerformanceEventTiming', + 'PerformanceMark', + 'PerformanceMeasure', + 'PerformanceNavigation', + 'PerformanceNavigationTiming', + 'PerformanceObserver', + 'PerformanceObserverEntryList', + 'PerformancePaintTiming', + 'PerformanceResourceTiming', + 'PerformanceServerTiming', + 'PerformanceTiming', + 'PeriodicWave', + 'PermissionStatus', + 'Permissions', + 'PictureInPictureWindow', + 'Plugin', + 'PluginArray', + 'PointerEvent', + 'PopStateEvent', + 'ProcessingInstruction', + 'ProgressEvent', + 'Promise', + 'PromiseConstructorLike', + 'PromiseRejectionEvent', + 'PropertyDecorator', + 'PropertyKey', + 'Proxy', + 'PublicKeyCredential', + 'PushManager', + 'PushSubscription', + 'PushSubscriptionOptions', + 'RTCCertificate', + 'RTCDTMFSender', + 'RTCDTMFToneChangeEvent', + 'RTCDataChannel', + 'RTCDataChannelEvent', + 'RTCDtlsTransport', + 'RTCIceCandidate', + 'RTCIceTransport', + 'RTCPeerConnection', + 'RTCPeerConnectionIceErrorEvent', + 'RTCPeerConnectionIceEvent', + 'RTCRtpReceiver', + 'RTCRtpSender', + 'RTCRtpTransceiver', + 'RTCSessionDescription', + 'RTCStatsReport', + 'RTCTrackEvent', + 'RadioNodeList', + 'Range', + 'RangeError', + 'ReadableStream', + 'ReadableStreamDefaultController', + 'ReadableStreamDefaultReader', + 'ReferenceError', + 'Reflect', + 'RegExp', + 'RemotePlayback', + 'Request', + 'ResizeObserver', + 'ResizeObserverEntry', + 'ResizeObserverSize', + 'Response', + 'SVGAElement', + 'SVGAngle', + 'SVGAnimateElement', + 'SVGAnimateMotionElement', + 'SVGAnimateTransformElement', + 'SVGAnimatedAngle', + 'SVGAnimatedBoolean', + 'SVGAnimatedEnumeration', + 'SVGAnimatedInteger', + 'SVGAnimatedLength', + 'SVGAnimatedLengthList', + 'SVGAnimatedNumber', + 'SVGAnimatedNumberList', + 'SVGAnimatedPreserveAspectRatio', + 'SVGAnimatedRect', + 'SVGAnimatedString', + 'SVGAnimatedTransformList', + 'SVGAnimationElement', + 'SVGCircleElement', + 'SVGClipPathElement', + 'SVGComponentTransferFunctionElement', + 'SVGCursorElement', + 'SVGDefsElement', + 'SVGDescElement', + 'SVGElement', + 'SVGEllipseElement', + 'SVGFEBlendElement', + 'SVGFEColorMatrixElement', + 'SVGFEComponentTransferElement', + 'SVGFECompositeElement', + 'SVGFEConvolveMatrixElement', + 'SVGFEDiffuseLightingElement', + 'SVGFEDisplacementMapElement', + 'SVGFEDistantLightElement', + 'SVGFEDropShadowElement', + 'SVGFEFloodElement', + 'SVGFEFuncAElement', + 'SVGFEFuncBElement', + 'SVGFEFuncGElement', + 'SVGFEFuncRElement', + 'SVGFEGaussianBlurElement', + 'SVGFEImageElement', + 'SVGFEMergeElement', + 'SVGFEMergeNodeElement', + 'SVGFEMorphologyElement', + 'SVGFEOffsetElement', + 'SVGFEPointLightElement', + 'SVGFESpecularLightingElement', + 'SVGFESpotLightElement', + 'SVGFETileElement', + 'SVGFETurbulenceElement', + 'SVGFilterElement', + 'SVGForeignObjectElement', + 'SVGGElement', + 'SVGGeometryElement', + 'SVGGradientElement', + 'SVGGraphicsElement', + 'SVGImageElement', + 'SVGLength', + 'SVGLengthList', + 'SVGLineElement', + 'SVGLinearGradientElement', + 'SVGMPathElement', + 'SVGMarkerElement', + 'SVGMaskElement', + 'SVGMatrix', + 'SVGMetadataElement', + 'SVGNumber', + 'SVGNumberList', + 'SVGPathElement', + 'SVGPatternElement', + 'SVGPoint', + 'SVGPointList', + 'SVGPolygonElement', + 'SVGPolylineElement', + 'SVGPreserveAspectRatio', + 'SVGRadialGradientElement', + 'SVGRect', + 'SVGRectElement', + 'SVGSVGElement', + 'SVGScriptElement', + 'SVGSetElement', + 'SVGStopElement', + 'SVGStringList', + 'SVGStyleElement', + 'SVGSwitchElement', + 'SVGSymbolElement', + 'SVGTSpanElement', + 'SVGTextContentElement', + 'SVGTextElement', + 'SVGTextPathElement', + 'SVGTextPositioningElement', + 'SVGTitleElement', + 'SVGTransform', + 'SVGTransformList', + 'SVGUnitTypes', + 'SVGUseElement', + 'SVGViewElement', + 'SafeArray', + 'Screen', + 'ScreenOrientation', + 'ScriptProcessorNode', + 'SecurityPolicyViolationEvent', + 'Selection', + 'ServiceWorker', + 'ServiceWorkerContainer', + 'ServiceWorkerRegistration', + 'Set', + 'ShadowRoot', + 'SharedArrayBuffer', + 'SharedWorker', + 'SourceBuffer', + 'SourceBufferList', + 'SpeechRecognitionAlternative', + 'SpeechRecognitionErrorEvent', + 'SpeechRecognitionResult', + 'SpeechRecognitionResultList', + 'SpeechSynthesis', + 'SpeechSynthesisErrorEvent', + 'SpeechSynthesisEvent', + 'SpeechSynthesisUtterance', + 'SpeechSynthesisVoice', + 'StaticRange', + 'StereoPannerNode', + 'Storage', + 'StorageEvent', + 'StorageManager', + 'String', + 'StyleMedia', + 'StyleSheet', + 'StyleSheetList', + 'SubmitEvent', + 'SubtleCrypto', + 'Symbol', + 'SyntaxError', + 'Text', + 'TextDecoder', + 'TextDecoderStream', + 'TextEncoder', + 'TextEncoderStream', + 'TextMetrics', + 'TextTrack', + 'TextTrackCue', + 'TextTrackCueList', + 'TextTrackList', + 'TimeRanges', + 'Touch', + 'TouchEvent', + 'TouchList', + 'TrackEvent', + 'TransformStream', + 'TransformStreamDefaultController', + 'TransitionEvent', + 'TreeWalker', + 'TypeError', + 'UIEvent', + 'URIError', + 'URL', + 'URLSearchParams', + 'Uint16Array', + 'Uint32Array', + 'Uint8Array', + 'Uint8ClampedArray', + 'VBArray', + 'VTTCue', + 'VTTRegion', + 'ValidityState', + 'VarDate', + 'VideoPlaybackQuality', + 'VisualViewport', + 'WSH', + 'WScript', + 'WaveShaperNode', + 'WeakMap', + 'WeakRef', + 'WeakSet', + 'WebAssembly', + 'WebGL2RenderingContext', + 'WebGLActiveInfo', + 'WebGLBuffer', + 'WebGLContextEvent', + 'WebGLFramebuffer', + 'WebGLProgram', + 'WebGLQuery', + 'WebGLRenderbuffer', + 'WebGLRenderingContext', + 'WebGLSampler', + 'WebGLShader', + 'WebGLShaderPrecisionFormat', + 'WebGLSync', + 'WebGLTexture', + 'WebGLTransformFeedback', + 'WebGLUniformLocation', + 'WebGLVertexArrayObject', + 'WebKitCSSMatrix', + 'WebSocket', + 'WheelEvent', + 'Window', + 'Worker', + 'Worklet', + 'WritableStream', + 'WritableStreamDefaultController', + 'WritableStreamDefaultWriter', + 'XMLDocument', + 'XMLHttpRequest', + 'XMLHttpRequestEventTarget', + 'XMLHttpRequestUpload', + 'XMLSerializer', + 'XPathEvaluator', + 'XPathExpression', + 'XPathResult', + 'XSLTProcessor', + 'addEventListener', + 'alert', + 'atob', + 'blur', + 'btoa', + 'caches', + 'cancelAnimationFrame', + 'cancelIdleCallback', + 'captureEvents', + 'clearInterval', + 'clearTimeout', + 'close', + 'closed', + 'confirm', + 'console', + 'createImageBitmap', + 'crossOriginIsolated', + 'crypto', + 'customElements', + 'decodeURI', + 'decodeURIComponent', + 'devicePixelRatio', + 'dispatchEvent', + 'document', + 'encodeURI', + 'encodeURIComponent', + 'escape', + 'eval', + 'event', + 'external', + 'fetch', + 'focus', + 'frameElement', + 'frames', + 'getComputedStyle', + 'getSelection', + 'global', + 'globalThis', + 'history', + 'importScripts', + 'indexedDB', + 'innerHeight', + 'innerWidth', + 'isFinite', + 'isNaN', + 'isSecureContext', + 'length', + 'localStorage', + 'location', + 'locationbar', + 'matchMedia', + 'menubar', + 'moveBy', + 'moveTo', + 'name', + 'navigator', + 'onabort', + 'onafterprint', + 'onanimationcancel', + 'onanimationend', + 'onanimationiteration', + 'onanimationstart', + 'onauxclick', + 'onbeforeprint', + 'onbeforeunload', + 'onblur', + 'oncanplay', + 'oncanplaythrough', + 'onchange', + 'onclick', + 'onclose', + 'oncontextmenu', + 'oncuechange', + 'ondblclick', + 'ondevicemotion', + 'ondeviceorientation', + 'ondrag', + 'ondragend', + 'ondragenter', + 'ondragleave', + 'ondragover', + 'ondragstart', + 'ondrop', + 'ondurationchange', + 'onemptied', + 'onended', + 'onerror', + 'onfocus', + 'onformdata', + 'ongamepadconnected', + 'ongamepaddisconnected', + 'ongotpointercapture', + 'onhashchange', + 'oninput', + 'oninvalid', + 'onkeydown', + 'onkeypress', + 'onkeyup', + 'onlanguagechange', + 'onload', + 'onloadeddata', + 'onloadedmetadata', + 'onloadstart', + 'onlostpointercapture', + 'onmessage', + 'onmessageerror', + 'onmousedown', + 'onmouseenter', + 'onmouseleave', + 'onmousemove', + 'onmouseout', + 'onmouseover', + 'onmouseup', + 'onoffline', + 'ononline', + 'onorientationchange', + 'onpagehide', + 'onpageshow', + 'onpause', + 'onplay', + 'onplaying', + 'onpointercancel', + 'onpointerdown', + 'onpointerenter', + 'onpointerleave', + 'onpointermove', + 'onpointerout', + 'onpointerover', + 'onpointerup', + 'onpopstate', + 'onprogress', + 'onratechange', + 'onrejectionhandled', + 'onreset', + 'onresize', + 'onscroll', + 'onseeked', + 'onseeking', + 'onselect', + 'onselectionchange', + 'onselectstart', + 'onstalled', + 'onstorage', + 'onsubmit', + 'onsuspend', + 'ontimeupdate', + 'ontoggle', + 'ontouchcancel', + 'ontouchend', + 'ontouchmove', + 'ontouchstart', + 'ontransitioncancel', + 'ontransitionend', + 'ontransitionrun', + 'ontransitionstart', + 'onunhandledrejection', + 'onunload', + 'onvolumechange', + 'onwaiting', + 'onwebkitanimationend', + 'onwebkitanimationiteration', + 'onwebkitanimationstart', + 'onwebkittransitionend', + 'onwheel', + 'open', + 'opener', + 'orientation', + 'origin', + 'outerHeight', + 'outerWidth', + 'pageXOffset', + 'pageYOffset', + 'parent', + 'parseFloat', + 'parseInt', + 'performance', + 'personalbar', + 'postMessage', + 'print', + 'process', + 'prompt', + 'queueMicrotask', + 'releaseEvents', + 'removeEventListener', + 'requestAnimationFrame', + 'requestIdleCallback', + 'resizeBy', + 'resizeTo', + 'screen', + 'screenLeft', + 'screenTop', + 'screenX', + 'screenY', + 'scroll', + 'scrollBy', + 'scrollTo', + 'scrollX', + 'scrollY', + 'scrollbars', + 'self', + 'sessionStorage', + 'setInterval', + 'setTimeout', + 'speechSynthesis', + 'status', + 'statusbar', + 'stop', + 'toString', + 'toolbar', + 'top', + 'undefined', + 'unescape', + 'visualViewport', + 'webkitURL', + 'window' +]); diff --git a/src/compiler/utils/names.ts b/src/compiler/utils/names.ts index 52e09edf32..9d5b78fceb 100644 --- a/src/compiler/utils/names.ts +++ b/src/compiler/utils/names.ts @@ -1,823 +1,6 @@ import { isIdentifierStart, isIdentifierChar } from 'acorn'; import full_char_code_at from './full_char_code_at'; -export const globals = new Set([ - 'AbortController', - 'AbortSignal', - 'AbstractRange', - 'ActiveXObject', - 'AggregateError', - 'AnalyserNode', - 'Animation', - 'AnimationEffect', - 'AnimationEvent', - 'AnimationPlaybackEvent', - 'AnimationTimeline', - 'Array', - 'ArrayBuffer', - 'Atomics', - 'Attr', - 'Audio', - 'AudioBuffer', - 'AudioBufferSourceNode', - 'AudioContext', - 'AudioDestinationNode', - 'AudioListener', - 'AudioNode', - 'AudioParam', - 'AudioParamMap', - 'AudioProcessingEvent', - 'AudioScheduledSourceNode', - 'AudioWorklet', - 'AudioWorkletNode', - 'AuthenticatorAssertionResponse', - 'AuthenticatorAttestationResponse', - 'AuthenticatorResponse', - 'BarProp', - 'BaseAudioContext', - 'BeforeUnloadEvent', - 'BigInt', - 'BigInt64Array', - 'BigUint64Array', - 'BiquadFilterNode', - 'Blob', - 'BlobEvent', - 'Boolean', - 'BroadcastChannel', - 'ByteLengthQueuingStrategy', - 'CDATASection', - 'CSS', - 'CSSAnimation', - 'CSSConditionRule', - 'CSSCounterStyleRule', - 'CSSFontFaceRule', - 'CSSGroupingRule', - 'CSSImportRule', - 'CSSKeyframeRule', - 'CSSKeyframesRule', - 'CSSMediaRule', - 'CSSNamespaceRule', - 'CSSPageRule', - 'CSSRule', - 'CSSRuleList', - 'CSSStyleDeclaration', - 'CSSStyleRule', - 'CSSStyleSheet', - 'CSSSupportsRule', - 'CSSTransition', - 'Cache', - 'CacheStorage', - 'CanvasGradient', - 'CanvasPattern', - 'CanvasRenderingContext2D', - 'ChannelMergerNode', - 'ChannelSplitterNode', - 'CharacterData', - 'ClassDecorator', - 'ClientRect', - 'Clipboard', - 'ClipboardEvent', - 'ClipboardItem', - 'CloseEvent', - 'Comment', - 'CompositionEvent', - 'ConstantSourceNode', - 'ConvolverNode', - 'CountQueuingStrategy', - 'Credential', - 'CredentialsContainer', - 'Crypto', - 'CryptoKey', - 'CustomElementRegistry', - 'CustomEvent', - 'DOMException', - 'DOMImplementation', - 'DOMMatrix', - 'DOMMatrixReadOnly', - 'DOMParser', - 'DOMPoint', - 'DOMPointReadOnly', - 'DOMQuad', - 'DOMRect', - 'DOMRectList', - 'DOMRectReadOnly', - 'DOMStringList', - 'DOMStringMap', - 'DOMTokenList', - 'DataTransfer', - 'DataTransferItem', - 'DataTransferItemList', - 'DataView', - 'Date', - 'DelayNode', - 'DeviceMotionEvent', - 'DeviceOrientationEvent', - 'Document', - 'DocumentFragment', - 'DocumentTimeline', - 'DocumentType', - 'DragEvent', - 'DynamicsCompressorNode', - 'Element', - 'Enumerator', - 'Error', - 'ErrorEvent', - 'EvalError', - 'Event', - 'EventSource', - 'EventTarget', - 'External', - 'File', - 'FileList', - 'FileReader', - 'FileSystem', - 'FileSystemDirectoryEntry', - 'FileSystemDirectoryReader', - 'FileSystemEntry', - 'FileSystemFileEntry', - 'FinalizationRegistry', - 'Float32Array', - 'Float64Array', - 'FocusEvent', - 'FontFace', - 'FontFaceSet', - 'FontFaceSetLoadEvent', - 'FormData', - 'FormDataEvent', - 'Function', - 'GainNode', - 'Gamepad', - 'GamepadButton', - 'GamepadEvent', - 'GamepadHapticActuator', - 'Geolocation', - 'GeolocationCoordinates', - 'GeolocationPosition', - 'GeolocationPositionError', - 'HTMLAllCollection', - 'HTMLAnchorElement', - 'HTMLAreaElement', - 'HTMLAudioElement', - 'HTMLBRElement', - 'HTMLBaseElement', - 'HTMLBodyElement', - 'HTMLButtonElement', - 'HTMLCanvasElement', - 'HTMLCollection', - 'HTMLDListElement', - 'HTMLDataElement', - 'HTMLDataListElement', - 'HTMLDetailsElement', - 'HTMLDirectoryElement', - 'HTMLDivElement', - 'HTMLDocument', - 'HTMLElement', - 'HTMLEmbedElement', - 'HTMLFieldSetElement', - 'HTMLFontElement', - 'HTMLFormControlsCollection', - 'HTMLFormElement', - 'HTMLFrameElement', - 'HTMLFrameSetElement', - 'HTMLHRElement', - 'HTMLHeadElement', - 'HTMLHeadingElement', - 'HTMLHtmlElement', - 'HTMLIFrameElement', - 'HTMLImageElement', - 'HTMLInputElement', - 'HTMLLIElement', - 'HTMLLabelElement', - 'HTMLLegendElement', - 'HTMLLinkElement', - 'HTMLMapElement', - 'HTMLMarqueeElement', - 'HTMLMediaElement', - 'HTMLMenuElement', - 'HTMLMetaElement', - 'HTMLMeterElement', - 'HTMLModElement', - 'HTMLOListElement', - 'HTMLObjectElement', - 'HTMLOptGroupElement', - 'HTMLOptionElement', - 'HTMLOptionsCollection', - 'HTMLOutputElement', - 'HTMLParagraphElement', - 'HTMLParamElement', - 'HTMLPictureElement', - 'HTMLPreElement', - 'HTMLProgressElement', - 'HTMLQuoteElement', - 'HTMLScriptElement', - 'HTMLSelectElement', - 'HTMLSlotElement', - 'HTMLSourceElement', - 'HTMLSpanElement', - 'HTMLStyleElement', - 'HTMLTableCaptionElement', - 'HTMLTableCellElement', - 'HTMLTableColElement', - 'HTMLTableElement', - 'HTMLTableRowElement', - 'HTMLTableSectionElement', - 'HTMLTemplateElement', - 'HTMLTextAreaElement', - 'HTMLTimeElement', - 'HTMLTitleElement', - 'HTMLTrackElement', - 'HTMLUListElement', - 'HTMLUnknownElement', - 'HTMLVideoElement', - 'HashChangeEvent', - 'Headers', - 'History', - 'IDBCursor', - 'IDBCursorWithValue', - 'IDBDatabase', - 'IDBFactory', - 'IDBIndex', - 'IDBKeyRange', - 'IDBObjectStore', - 'IDBOpenDBRequest', - 'IDBRequest', - 'IDBTransaction', - 'IDBVersionChangeEvent', - 'IIRFilterNode', - 'IdleDeadline', - 'Image', - 'ImageBitmap', - 'ImageBitmapRenderingContext', - 'ImageData', - 'Infinity', - 'InputEvent', - 'Int16Array', - 'Int32Array', - 'Int8Array', - 'InternalError', - 'IntersectionObserver', - 'IntersectionObserverEntry', - 'Intl', - 'JSON', - 'KeyboardEvent', - 'KeyframeEffect', - 'Location', - 'Map', - 'Math', - 'MathMLElement', - 'MediaCapabilities', - 'MediaDeviceInfo', - 'MediaDevices', - 'MediaElementAudioSourceNode', - 'MediaEncryptedEvent', - 'MediaError', - 'MediaKeyMessageEvent', - 'MediaKeySession', - 'MediaKeyStatusMap', - 'MediaKeySystemAccess', - 'MediaKeys', - 'MediaList', - 'MediaMetadata', - 'MediaQueryList', - 'MediaQueryListEvent', - 'MediaRecorder', - 'MediaRecorderErrorEvent', - 'MediaSession', - 'MediaSource', - 'MediaStream', - 'MediaStreamAudioDestinationNode', - 'MediaStreamAudioSourceNode', - 'MediaStreamTrack', - 'MediaStreamTrackEvent', - 'MessageChannel', - 'MessageEvent', - 'MessagePort', - 'MethodDecorator', - 'MimeType', - 'MimeTypeArray', - 'MouseEvent', - 'MutationEvent', - 'MutationObserver', - 'MutationRecord', - 'NaN', - 'NamedNodeMap', - 'Navigator', - 'NetworkInformation', - 'Node', - 'NodeFilter', - 'NodeIterator', - 'NodeList', - 'Notification', - 'Number', - 'Object', - 'OfflineAudioCompletionEvent', - 'OfflineAudioContext', - 'Option', - 'OscillatorNode', - 'OverconstrainedError', - 'PageTransitionEvent', - 'PannerNode', - 'ParameterDecorator', - 'Path2D', - 'PaymentAddress', - 'PaymentMethodChangeEvent', - 'PaymentRequest', - 'PaymentRequestUpdateEvent', - 'PaymentResponse', - 'Performance', - 'PerformanceEntry', - 'PerformanceEventTiming', - 'PerformanceMark', - 'PerformanceMeasure', - 'PerformanceNavigation', - 'PerformanceNavigationTiming', - 'PerformanceObserver', - 'PerformanceObserverEntryList', - 'PerformancePaintTiming', - 'PerformanceResourceTiming', - 'PerformanceServerTiming', - 'PerformanceTiming', - 'PeriodicWave', - 'PermissionStatus', - 'Permissions', - 'PictureInPictureWindow', - 'Plugin', - 'PluginArray', - 'PointerEvent', - 'PopStateEvent', - 'ProcessingInstruction', - 'ProgressEvent', - 'Promise', - 'PromiseConstructorLike', - 'PromiseRejectionEvent', - 'PropertyDecorator', - 'PropertyKey', - 'Proxy', - 'PublicKeyCredential', - 'PushManager', - 'PushSubscription', - 'PushSubscriptionOptions', - 'RTCCertificate', - 'RTCDTMFSender', - 'RTCDTMFToneChangeEvent', - 'RTCDataChannel', - 'RTCDataChannelEvent', - 'RTCDtlsTransport', - 'RTCIceCandidate', - 'RTCIceTransport', - 'RTCPeerConnection', - 'RTCPeerConnectionIceErrorEvent', - 'RTCPeerConnectionIceEvent', - 'RTCRtpReceiver', - 'RTCRtpSender', - 'RTCRtpTransceiver', - 'RTCSessionDescription', - 'RTCStatsReport', - 'RTCTrackEvent', - 'RadioNodeList', - 'Range', - 'RangeError', - 'ReadableStream', - 'ReadableStreamDefaultController', - 'ReadableStreamDefaultReader', - 'ReferenceError', - 'Reflect', - 'RegExp', - 'RemotePlayback', - 'Request', - 'ResizeObserver', - 'ResizeObserverEntry', - 'ResizeObserverSize', - 'Response', - 'SVGAElement', - 'SVGAngle', - 'SVGAnimateElement', - 'SVGAnimateMotionElement', - 'SVGAnimateTransformElement', - 'SVGAnimatedAngle', - 'SVGAnimatedBoolean', - 'SVGAnimatedEnumeration', - 'SVGAnimatedInteger', - 'SVGAnimatedLength', - 'SVGAnimatedLengthList', - 'SVGAnimatedNumber', - 'SVGAnimatedNumberList', - 'SVGAnimatedPreserveAspectRatio', - 'SVGAnimatedRect', - 'SVGAnimatedString', - 'SVGAnimatedTransformList', - 'SVGAnimationElement', - 'SVGCircleElement', - 'SVGClipPathElement', - 'SVGComponentTransferFunctionElement', - 'SVGCursorElement', - 'SVGDefsElement', - 'SVGDescElement', - 'SVGElement', - 'SVGEllipseElement', - 'SVGFEBlendElement', - 'SVGFEColorMatrixElement', - 'SVGFEComponentTransferElement', - 'SVGFECompositeElement', - 'SVGFEConvolveMatrixElement', - 'SVGFEDiffuseLightingElement', - 'SVGFEDisplacementMapElement', - 'SVGFEDistantLightElement', - 'SVGFEDropShadowElement', - 'SVGFEFloodElement', - 'SVGFEFuncAElement', - 'SVGFEFuncBElement', - 'SVGFEFuncGElement', - 'SVGFEFuncRElement', - 'SVGFEGaussianBlurElement', - 'SVGFEImageElement', - 'SVGFEMergeElement', - 'SVGFEMergeNodeElement', - 'SVGFEMorphologyElement', - 'SVGFEOffsetElement', - 'SVGFEPointLightElement', - 'SVGFESpecularLightingElement', - 'SVGFESpotLightElement', - 'SVGFETileElement', - 'SVGFETurbulenceElement', - 'SVGFilterElement', - 'SVGForeignObjectElement', - 'SVGGElement', - 'SVGGeometryElement', - 'SVGGradientElement', - 'SVGGraphicsElement', - 'SVGImageElement', - 'SVGLength', - 'SVGLengthList', - 'SVGLineElement', - 'SVGLinearGradientElement', - 'SVGMPathElement', - 'SVGMarkerElement', - 'SVGMaskElement', - 'SVGMatrix', - 'SVGMetadataElement', - 'SVGNumber', - 'SVGNumberList', - 'SVGPathElement', - 'SVGPatternElement', - 'SVGPoint', - 'SVGPointList', - 'SVGPolygonElement', - 'SVGPolylineElement', - 'SVGPreserveAspectRatio', - 'SVGRadialGradientElement', - 'SVGRect', - 'SVGRectElement', - 'SVGSVGElement', - 'SVGScriptElement', - 'SVGSetElement', - 'SVGStopElement', - 'SVGStringList', - 'SVGStyleElement', - 'SVGSwitchElement', - 'SVGSymbolElement', - 'SVGTSpanElement', - 'SVGTextContentElement', - 'SVGTextElement', - 'SVGTextPathElement', - 'SVGTextPositioningElement', - 'SVGTitleElement', - 'SVGTransform', - 'SVGTransformList', - 'SVGUnitTypes', - 'SVGUseElement', - 'SVGViewElement', - 'SafeArray', - 'Screen', - 'ScreenOrientation', - 'ScriptProcessorNode', - 'SecurityPolicyViolationEvent', - 'Selection', - 'ServiceWorker', - 'ServiceWorkerContainer', - 'ServiceWorkerRegistration', - 'Set', - 'ShadowRoot', - 'SharedArrayBuffer', - 'SharedWorker', - 'SourceBuffer', - 'SourceBufferList', - 'SpeechRecognitionAlternative', - 'SpeechRecognitionErrorEvent', - 'SpeechRecognitionResult', - 'SpeechRecognitionResultList', - 'SpeechSynthesis', - 'SpeechSynthesisErrorEvent', - 'SpeechSynthesisEvent', - 'SpeechSynthesisUtterance', - 'SpeechSynthesisVoice', - 'StaticRange', - 'StereoPannerNode', - 'Storage', - 'StorageEvent', - 'StorageManager', - 'String', - 'StyleMedia', - 'StyleSheet', - 'StyleSheetList', - 'SubmitEvent', - 'SubtleCrypto', - 'Symbol', - 'SyntaxError', - 'Text', - 'TextDecoder', - 'TextDecoderStream', - 'TextEncoder', - 'TextEncoderStream', - 'TextMetrics', - 'TextTrack', - 'TextTrackCue', - 'TextTrackCueList', - 'TextTrackList', - 'TimeRanges', - 'Touch', - 'TouchEvent', - 'TouchList', - 'TrackEvent', - 'TransformStream', - 'TransformStreamDefaultController', - 'TransitionEvent', - 'TreeWalker', - 'TypeError', - 'UIEvent', - 'URIError', - 'URL', - 'URLSearchParams', - 'Uint16Array', - 'Uint32Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'VBArray', - 'VTTCue', - 'VTTRegion', - 'ValidityState', - 'VarDate', - 'VideoPlaybackQuality', - 'VisualViewport', - 'WSH', - 'WScript', - 'WaveShaperNode', - 'WeakMap', - 'WeakRef', - 'WeakSet', - 'WebAssembly', - 'WebGL2RenderingContext', - 'WebGLActiveInfo', - 'WebGLBuffer', - 'WebGLContextEvent', - 'WebGLFramebuffer', - 'WebGLProgram', - 'WebGLQuery', - 'WebGLRenderbuffer', - 'WebGLRenderingContext', - 'WebGLSampler', - 'WebGLShader', - 'WebGLShaderPrecisionFormat', - 'WebGLSync', - 'WebGLTexture', - 'WebGLTransformFeedback', - 'WebGLUniformLocation', - 'WebGLVertexArrayObject', - 'WebKitCSSMatrix', - 'WebSocket', - 'WheelEvent', - 'Window', - 'Worker', - 'Worklet', - 'WritableStream', - 'WritableStreamDefaultController', - 'WritableStreamDefaultWriter', - 'XMLDocument', - 'XMLHttpRequest', - 'XMLHttpRequestEventTarget', - 'XMLHttpRequestUpload', - 'XMLSerializer', - 'XPathEvaluator', - 'XPathExpression', - 'XPathResult', - 'XSLTProcessor', - 'addEventListener', - 'alert', - 'atob', - 'blur', - 'btoa', - 'caches', - 'cancelAnimationFrame', - 'cancelIdleCallback', - 'captureEvents', - 'clearInterval', - 'clearTimeout', - 'close', - 'closed', - 'confirm', - 'console', - 'createImageBitmap', - 'crossOriginIsolated', - 'crypto', - 'customElements', - 'decodeURI', - 'decodeURIComponent', - 'devicePixelRatio', - 'dispatchEvent', - 'document', - 'encodeURI', - 'encodeURIComponent', - 'escape', - 'eval', - 'event', - 'external', - 'fetch', - 'focus', - 'frameElement', - 'frames', - 'getComputedStyle', - 'getSelection', - 'global', - 'globalThis', - 'history', - 'importScripts', - 'indexedDB', - 'innerHeight', - 'innerWidth', - 'isFinite', - 'isNaN', - 'isSecureContext', - 'length', - 'localStorage', - 'location', - 'locationbar', - 'matchMedia', - 'menubar', - 'moveBy', - 'moveTo', - 'name', - 'navigator', - 'onabort', - 'onafterprint', - 'onanimationcancel', - 'onanimationend', - 'onanimationiteration', - 'onanimationstart', - 'onauxclick', - 'onbeforeprint', - 'onbeforeunload', - 'onblur', - 'oncanplay', - 'oncanplaythrough', - 'onchange', - 'onclick', - 'onclose', - 'oncontextmenu', - 'oncuechange', - 'ondblclick', - 'ondevicemotion', - 'ondeviceorientation', - 'ondrag', - 'ondragend', - 'ondragenter', - 'ondragleave', - 'ondragover', - 'ondragstart', - 'ondrop', - 'ondurationchange', - 'onemptied', - 'onended', - 'onerror', - 'onfocus', - 'onformdata', - 'ongamepadconnected', - 'ongamepaddisconnected', - 'ongotpointercapture', - 'onhashchange', - 'oninput', - 'oninvalid', - 'onkeydown', - 'onkeypress', - 'onkeyup', - 'onlanguagechange', - 'onload', - 'onloadeddata', - 'onloadedmetadata', - 'onloadstart', - 'onlostpointercapture', - 'onmessage', - 'onmessageerror', - 'onmousedown', - 'onmouseenter', - 'onmouseleave', - 'onmousemove', - 'onmouseout', - 'onmouseover', - 'onmouseup', - 'onoffline', - 'ononline', - 'onorientationchange', - 'onpagehide', - 'onpageshow', - 'onpause', - 'onplay', - 'onplaying', - 'onpointercancel', - 'onpointerdown', - 'onpointerenter', - 'onpointerleave', - 'onpointermove', - 'onpointerout', - 'onpointerover', - 'onpointerup', - 'onpopstate', - 'onprogress', - 'onratechange', - 'onrejectionhandled', - 'onreset', - 'onresize', - 'onscroll', - 'onseeked', - 'onseeking', - 'onselect', - 'onselectionchange', - 'onselectstart', - 'onstalled', - 'onstorage', - 'onsubmit', - 'onsuspend', - 'ontimeupdate', - 'ontoggle', - 'ontouchcancel', - 'ontouchend', - 'ontouchmove', - 'ontouchstart', - 'ontransitioncancel', - 'ontransitionend', - 'ontransitionrun', - 'ontransitionstart', - 'onunhandledrejection', - 'onunload', - 'onvolumechange', - 'onwaiting', - 'onwebkitanimationend', - 'onwebkitanimationiteration', - 'onwebkitanimationstart', - 'onwebkittransitionend', - 'onwheel', - 'open', - 'opener', - 'orientation', - 'origin', - 'outerHeight', - 'outerWidth', - 'pageXOffset', - 'pageYOffset', - 'parent', - 'parseFloat', - 'parseInt', - 'performance', - 'personalbar', - 'postMessage', - 'print', - 'process', - 'prompt', - 'queueMicrotask', - 'releaseEvents', - 'removeEventListener', - 'requestAnimationFrame', - 'requestIdleCallback', - 'resizeBy', - 'resizeTo', - 'screen', - 'screenLeft', - 'screenTop', - 'screenX', - 'screenY', - 'scroll', - 'scrollBy', - 'scrollTo', - 'scrollX', - 'scrollY', - 'scrollbars', - 'self', - 'sessionStorage', - 'setInterval', - 'setTimeout', - 'speechSynthesis', - 'status', - 'statusbar', - 'stop', - 'toString', - 'toolbar', - 'top', - 'undefined', - 'unescape', - 'visualViewport', - 'webkitURL', - 'window' -]); - export const reserved = new Set([ 'arguments', 'await',