Home / File/ proxy.ts — vue Source File

proxy.ts — vue Source File

Architecture documentation for proxy.ts, a typescript file in the vue codebase. 2 imports, 1 dependents.

File typescript VueCore Instance 2 imports 1 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  581d7f4f_49fe_9174_eacc_5863a2fab073["proxy.ts"]
  76672dd6_4e87_4468_a48b_f4da793fd211["index.ts"]
  581d7f4f_49fe_9174_eacc_5863a2fab073 --> 76672dd6_4e87_4468_a48b_f4da793fd211
  a9349ba5_bc74_f03e_b748_41eb2dcc87a9["config"]
  581d7f4f_49fe_9174_eacc_5863a2fab073 --> a9349ba5_bc74_f03e_b748_41eb2dcc87a9
  ae790ceb_073b_1bcf_331c_af2d587c1ad6["init.ts"]
  ae790ceb_073b_1bcf_331c_af2d587c1ad6 --> 581d7f4f_49fe_9174_eacc_5863a2fab073
  style 581d7f4f_49fe_9174_eacc_5863a2fab073 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/* not type checking this file because flow doesn't play well with Proxy */

import config from 'core/config'
import { warn, makeMap, isNative } from '../util/index'

let initProxy

if (__DEV__) {
  const allowedGlobals = makeMap(
    'Infinity,undefined,NaN,isFinite,isNaN,' +
      'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
      'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
      'require' // for Webpack/Browserify
  )

  const warnNonPresent = (target, key) => {
    warn(
      `Property or method "${key}" is not defined on the instance but ` +
        'referenced during render. Make sure that this property is reactive, ' +
        'either in the data option, or for class-based components, by ' +
        'initializing the property. ' +
        'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
      target
    )
  }

  const warnReservedPrefix = (target, key) => {
    warn(
      `Property "${key}" must be accessed with "$data.${key}" because ` +
        'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
        'prevent conflicts with Vue internals. ' +
        'See: https://v2.vuejs.org/v2/api/#data',
      target
    )
  }

  const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy)

  if (hasProxy) {
    const isBuiltInModifier = makeMap(
      'stop,prevent,self,ctrl,shift,alt,meta,exact'
    )
    config.keyCodes = new Proxy(config.keyCodes, {
      set(target, key: string, value) {
        if (isBuiltInModifier(key)) {
          warn(
            `Avoid overwriting built-in modifier in config.keyCodes: .${key}`
          )
          return false
        } else {
          target[key] = value
          return true
        }
      }
    })
  }

  const hasHandler = {
    has(target, key) {
      const has = key in target
      const isAllowed =
        allowedGlobals(key) ||
        (typeof key === 'string' &&
          key.charAt(0) === '_' &&
          !(key in target.$data))
      if (!has && !isAllowed) {
        if (key in target.$data) warnReservedPrefix(target, key)
        else warnNonPresent(target, key)
      }
      return has || !isAllowed
    }
  }

  const getHandler = {
    get(target, key) {
      if (typeof key === 'string' && !(key in target)) {
        if (key in target.$data) warnReservedPrefix(target, key)
        else warnNonPresent(target, key)
      }
      return target[key]
    }
  }

  initProxy = function initProxy(vm) {
    if (hasProxy) {
      // determine which proxy handler to use
      const options = vm.$options
      const handlers =
        options.render && options.render._withStripped ? getHandler : hasHandler
      vm._renderProxy = new Proxy(vm, handlers)
    } else {
      vm._renderProxy = vm
    }
  }
}

export { initProxy }

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does proxy.ts do?
proxy.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, Instance subdomain.
What functions are defined in proxy.ts?
proxy.ts defines 5 function(s): getHandler.get, hasHandler.has, initProxy, warnNonPresent, warnReservedPrefix.
What does proxy.ts depend on?
proxy.ts imports 2 module(s): config, index.ts.
What files import proxy.ts?
proxy.ts is imported by 1 file(s): init.ts.
Where is proxy.ts in the architecture?
proxy.ts is located at src/core/instance/proxy.ts (domain: VueCore, subdomain: Instance, directory: src/core/instance).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free