extend.ts — vue Source File
Architecture documentation for extend.ts, a typescript file in the vue codebase. 9 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 295edfdd_f910_fae9_5ece_4985c36859c4["extend.ts"] 079339bc_f0ce_0fd0_3d1b_26a2dc073616["state.ts"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> 079339bc_f0ce_0fd0_3d1b_26a2dc073616 743f92db_5862_0bb2_3ad1_47ccd2ae1c10["defineComputed"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> 743f92db_5862_0bb2_3ad1_47ccd2ae1c10 fad58ec8_df0b_6b38_de80_539f1b7ee0f3["proxy"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> fad58ec8_df0b_6b38_de80_539f1b7ee0f3 76672dd6_4e87_4468_a48b_f4da793fd211["index.ts"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> 76672dd6_4e87_4468_a48b_f4da793fd211 82e2e746_8f28_fbf0_8cf7_69eca6423e4a["create-component.ts"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> 82e2e746_8f28_fbf0_8cf7_69eca6423e4a 07237020_2f32_55be_02ad_e77197985632["getComponentName"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> 07237020_2f32_55be_02ad_e77197985632 ab8fc425_80ef_461f_288a_985447c26d02["constants"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> ab8fc425_80ef_461f_288a_985447c26d02 64c87498_c46a_6944_ab9d_8e45519852a8["component"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> 64c87498_c46a_6944_ab9d_8e45519852a8 e113c728_56e1_b7c8_935f_f89af3e6c5fc["global-api"] 295edfdd_f910_fae9_5ece_4985c36859c4 --> e113c728_56e1_b7c8_935f_f89af3e6c5fc 65cf792e_a676_cf99_19ca_1e38df384bdc["index.ts"] 65cf792e_a676_cf99_19ca_1e38df384bdc --> 295edfdd_f910_fae9_5ece_4985c36859c4 style 295edfdd_f910_fae9_5ece_4985c36859c4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { ASSET_TYPES } from 'shared/constants'
import type { Component } from 'types/component'
import type { GlobalAPI } from 'types/global-api'
import { defineComputed, proxy } from '../instance/state'
import { extend, mergeOptions, validateComponentName } from '../util/index'
import { getComponentName } from '../vdom/create-component'
export function initExtend(Vue: GlobalAPI) {
/**
* Each instance constructor, including Vue, has a unique
* cid. This enables us to create wrapped "child
* constructors" for prototypal inheritance and cache them.
*/
Vue.cid = 0
let cid = 1
/**
* Class inheritance
*/
Vue.extend = function (extendOptions: any): typeof Component {
extendOptions = extendOptions || {}
const Super = this
const SuperId = Super.cid
const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {})
if (cachedCtors[SuperId]) {
return cachedCtors[SuperId]
}
const name =
getComponentName(extendOptions) || getComponentName(Super.options)
if (__DEV__ && name) {
validateComponentName(name)
}
const Sub = function VueComponent(this: any, options: any) {
this._init(options)
} as unknown as typeof Component
Sub.prototype = Object.create(Super.prototype)
Sub.prototype.constructor = Sub
Sub.cid = cid++
Sub.options = mergeOptions(Super.options, extendOptions)
Sub['super'] = Super
// For props and computed properties, we define the proxy getters on
// the Vue instances at extension time, on the extended prototype. This
// avoids Object.defineProperty calls for each instance created.
if (Sub.options.props) {
initProps(Sub)
}
if (Sub.options.computed) {
initComputed(Sub)
}
// allow further extension/mixin/plugin usage
Sub.extend = Super.extend
Sub.mixin = Super.mixin
Sub.use = Super.use
// create asset registers, so extended classes
// can have their private assets too.
ASSET_TYPES.forEach(function (type) {
Sub[type] = Super[type]
})
// enable recursive self-lookup
if (name) {
Sub.options.components[name] = Sub
}
// keep a reference to the super options at extension time.
// later at instantiation we can check if Super's options have
// been updated.
Sub.superOptions = Super.options
Sub.extendOptions = extendOptions
Sub.sealedOptions = extend({}, Sub.options)
// cache constructor
cachedCtors[SuperId] = Sub
return Sub
}
}
function initProps(Comp: typeof Component) {
const props = Comp.options.props
for (const key in props) {
proxy(Comp.prototype, `_props`, key)
}
}
function initComputed(Comp: typeof Component) {
const computed = Comp.options.computed
for (const key in computed) {
defineComputed(Comp.prototype, key, computed[key])
}
}
Domain
Subdomains
Functions
Dependencies
- component
- constants
- create-component.ts
- defineComputed
- getComponentName
- global-api
- index.ts
- proxy
- state.ts
Imported By
Source
Frequently Asked Questions
What does extend.ts do?
extend.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, GlobalAPI subdomain.
What functions are defined in extend.ts?
extend.ts defines 3 function(s): initComputed, initExtend, initProps.
What does extend.ts depend on?
extend.ts imports 9 module(s): component, constants, create-component.ts, defineComputed, getComponentName, global-api, index.ts, proxy, and 1 more.
What files import extend.ts?
extend.ts is imported by 1 file(s): index.ts.
Where is extend.ts in the architecture?
extend.ts is located at src/core/global-api/extend.ts (domain: VueCore, subdomain: GlobalAPI, directory: src/core/global-api).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free