diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b150bb169e..92155c0be89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## Unreleased + +* Add all global objects / functions ([#3805](https://github.com/sveltejs/svelte/issue/3805), [#7223](https://github.com/sveltejs/svelte/issue/7223), [#7240](https://github.com/sveltejs/svelte/issue/7240)) + ## 3.50.0 * Add a11y warnings: diff --git a/scripts/globals-extractor.mjs b/scripts/globals-extractor.mjs new file mode 100644 index 00000000000..1c4274a0245 --- /dev/null +++ b/scripts/globals-extractor.mjs @@ -0,0 +1,91 @@ +/** ---------------------------------------------------------------------- +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 GLOBAL_TS_PATH = './src/compiler/utils/globals.ts'; + +// 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. +const SPECIALS = ['global', 'globalThis', 'InternalError', 'process', 'undefined']; + +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_functions_and_references = (name, data) => { + const functions = []; + const references = []; + data.split('\n').forEach(line => { + const trimmed = line.trim(); + const split = trimmed.replace(/[\s+]/, ' ').split(' '); + if (split[0] === 'declare' && split[1] !== 'type') { + functions.push(extract_name(split[2])); + } else if (trimmed.startsWith('/// new Promise((resolve, reject) => { + http.get(url, (res) => { + let body = ''; + res.setEncoding('utf8'); + res.on('data', (chunk) => body += chunk); + res.on('end', () => resolve(body)); + }).on('error', (e) => { + console.error(e.message); + reject(e); + }); +}); + +const fetched_names = new Set(); +const get_functions = async (name) => { + const res = []; + if (fetched_names.has(name)) return res; + fetched_names.add(name); + const body = await do_get(get_url(name)); + const { functions, references } = extract_functions_and_references(name, 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')} +]); +`; +}; + +const get_exists_globals = () => { + const regexp = /^\s*["'](.+)["'],?\s*$/; + return fs.readFileSync(GLOBAL_TS_PATH, 'utf8') + .split('\n') + .filter(line => line.match(regexp)) + .map(line => line.match(regexp)[1]); +}; + +(async () => { + const globals = get_exists_globals(); + const new_globals = await get_functions('es2021.full'); + globals.forEach((g) => new_globals.push(g)); + SPECIALS.forEach((g) => new_globals.push(g)); + fs.writeFileSync(GLOBAL_TS_PATH, build_output(new_globals)); +})(); diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 63c62a256a3..2f8874de7ac 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 00000000000..ee43af3b914 --- /dev/null +++ b/src/compiler/utils/globals.ts @@ -0,0 +1,840 @@ +/** ---------------------------------------------------------------------- +This file is automatically generated by `scripts/globals-extractor.mjs`. +Generated At: 2022-09-03T15:22:37.415Z +---------------------------------------------------------------------- */ + +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', + 'CanvasCaptureMediaStreamTrack', + 'CanvasGradient', + 'CanvasPattern', + 'CanvasRenderingContext2D', + 'ChannelMergerNode', + 'ChannelSplitterNode', + 'CharacterData', + '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', + 'ElementInternals', + 'Enumerator', + 'Error', + 'ErrorEvent', + 'EvalError', + 'Event', + 'EventCounts', + 'EventSource', + 'EventTarget', + 'External', + 'File', + 'FileList', + 'FileReader', + 'FileSystem', + 'FileSystemDirectoryEntry', + 'FileSystemDirectoryHandle', + 'FileSystemDirectoryReader', + 'FileSystemEntry', + 'FileSystemFileEntry', + 'FileSystemFileHandle', + 'FileSystemHandle', + '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', + 'HTMLDialogElement', + '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', + 'InputDeviceInfo', + 'InputEvent', + 'Int16Array', + 'Int32Array', + 'Int8Array', + 'InternalError', + 'IntersectionObserver', + 'IntersectionObserverEntry', + 'Intl', + 'JSON', + 'KeyboardEvent', + 'KeyframeEffect', + 'Location', + 'Lock', + 'LockManager', + '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', + 'MimeType', + 'MimeTypeArray', + 'MouseEvent', + 'MutationEvent', + 'MutationObserver', + 'MutationRecord', + 'NaN', + 'NamedNodeMap', + 'NavigationPreloadManager', + 'Navigator', + 'NetworkInformation', + 'Node', + 'NodeFilter', + 'NodeIterator', + 'NodeList', + 'Notification', + 'Number', + 'Object', + 'OfflineAudioCompletionEvent', + 'OfflineAudioContext', + 'Option', + 'OscillatorNode', + 'OverconstrainedError', + 'PageTransitionEvent', + 'PannerNode', + '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', + 'PromiseRejectionEvent', + 'Proxy', + 'PublicKeyCredential', + 'PushManager', + 'PushSubscription', + 'PushSubscriptionOptions', + 'RTCCertificate', + 'RTCDTMFSender', + 'RTCDTMFToneChangeEvent', + 'RTCDataChannel', + 'RTCDataChannelEvent', + 'RTCDtlsTransport', + 'RTCEncodedAudioFrame', + 'RTCEncodedVideoFrame', + 'RTCError', + 'RTCErrorEvent', + 'RTCIceCandidate', + 'RTCIceTransport', + 'RTCPeerConnection', + 'RTCPeerConnectionIceErrorEvent', + 'RTCPeerConnectionIceEvent', + 'RTCRtpReceiver', + 'RTCRtpSender', + 'RTCRtpTransceiver', + 'RTCSctpTransport', + 'RTCSessionDescription', + 'RTCStatsReport', + 'RTCTrackEvent', + 'RadioNodeList', + 'Range', + 'RangeError', + 'ReadableByteStreamController', + 'ReadableStream', + 'ReadableStreamBYOBReader', + 'ReadableStreamBYOBRequest', + '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', + 'VideoColorSpace', + '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', + 'clientInformation', + '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', + 'onsecuritypolicyviolation', + 'onseeked', + 'onseeking', + 'onselect', + 'onselectionchange', + 'onselectstart', + 'onslotchange', + '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', + 'reportError', + 'requestAnimationFrame', + 'requestIdleCallback', + 'resizeBy', + 'resizeTo', + 'screen', + 'screenLeft', + 'screenTop', + 'screenX', + 'screenY', + 'scroll', + 'scrollBy', + 'scrollTo', + 'scrollX', + 'scrollY', + 'scrollbars', + 'self', + 'sessionStorage', + 'setInterval', + 'setTimeout', + 'speechSynthesis', + 'status', + 'statusbar', + 'stop', + 'structuredClone', + 'toString', + 'toolbar', + 'top', + 'undefined', + 'unescape', + 'visualViewport', + 'webkitURL', + 'window' +]); diff --git a/src/compiler/utils/names.ts b/src/compiler/utils/names.ts index e091edb19eb..9d5b78fcebc 100644 --- a/src/compiler/utils/names.ts +++ b/src/compiler/utils/names.ts @@ -1,71 +1,6 @@ import { isIdentifierStart, isIdentifierChar } from 'acorn'; import full_char_code_at from './full_char_code_at'; -export const globals = new Set([ - 'alert', - 'Array', - 'BigInt', - 'Boolean', - 'clearInterval', - 'clearTimeout', - 'confirm', - 'console', - 'Date', - 'decodeURI', - 'decodeURIComponent', - 'document', - 'Element', - 'encodeURI', - 'encodeURIComponent', - 'Error', - 'EvalError', - 'Event', - 'EventSource', - 'fetch', - 'FormData', - 'global', - 'globalThis', - 'history', - 'HTMLElement', - 'Infinity', - 'InternalError', - 'Intl', - 'isFinite', - 'isNaN', - 'JSON', - 'localStorage', - 'location', - 'Map', - 'Math', - 'NaN', - 'navigator', - 'Node', - 'Number', - 'Object', - 'parseFloat', - 'parseInt', - 'process', - 'Promise', - 'prompt', - 'RangeError', - 'ReferenceError', - 'RegExp', - 'sessionStorage', - 'Set', - 'setInterval', - 'setTimeout', - 'String', - 'SVGElement', - 'Symbol', - 'SyntaxError', - 'TypeError', - 'undefined', - 'URIError', - 'URL', - 'URLSearchParams', - 'window' -]); - export const reserved = new Set([ 'arguments', 'await',