Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compiler-core): support Symbol in template #9069

Merged
merged 10 commits into from
May 27, 2024
40 changes: 36 additions & 4 deletions packages/shared/src/globalsAllowList.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
import { makeMap } from './makeMap'

const GLOBALS_ALLOWED =
'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console'
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
const GLOBAL_SIMPLE_VALUE = 'globalThis,Infinity,NaN,undefined'
const FUNCTION =
'eval,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent'
const FUNDAMENTAL = 'Object,Function,Boolean,Symbol'
const ERROR =
'Error,AggregateError,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError'
const NUMBER_AND_DATES = 'Math,BigInt,Number,Date'
const TEXT = 'String,RegExp'
const INDEXED_COLLECTIONS =
'Array,Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,BigInt64Array,BigUint64Array,Float32Array,Float64Array'
const KEYED_COLLECTIONS = 'Map,Set,WeakMap,WeakSet'
const STRUCTURED_DATA = 'ArrayBuffer,SharedArrayBuffer,DataView,Atomics,JSON'
const MANAGING_MEMORY = 'WeakRef,FinalizationRegistry'
const CONTROL_ABSTRACTION_OBJECTS =
'Iterator,AsyncIterator,Promise,GeneratorFunction,AsyncGeneratorFunction,Generator,AsyncGenerator,AsyncFunction'
const REFLECTION = 'Reflect,Proxy'
const INTERNATIONALIZATION = 'Intl'
const OTHER_GLOBALS_ALLOWED = 'console'
sxzz marked this conversation as resolved.
Show resolved Hide resolved

const GLOBALS_ALLOWED = [
GLOBAL_SIMPLE_VALUE,
FUNCTION,
FUNDAMENTAL,
ERROR,
NUMBER_AND_DATES,
TEXT,
INDEXED_COLLECTIONS,
KEYED_COLLECTIONS,
STRUCTURED_DATA,
MANAGING_MEMORY,
CONTROL_ABSTRACTION_OBJECTS,
REFLECTION,
INTERNATIONALIZATION,
OTHER_GLOBALS_ALLOWED
].join(',')

export const isGloballyAllowed = /*#__PURE__*/ makeMap(GLOBALS_ALLOWED)
sxzz marked this conversation as resolved.
Show resolved Hide resolved

Expand Down