Home / File/ reactive.ts — vue Source File

reactive.ts — vue Source File

Architecture documentation for reactive.ts, a typescript file in the vue codebase. 6 imports, 5 dependents.

File typescript CompilerSFC ScriptAnalyzer 6 imports 5 dependents 10 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  abfe3078_bfec_252c_2107_7cdf0dd06f08["reactive.ts"]
  ada43310_8d32_ee2a_f18b_1e24fd4f8a1d["ref.ts"]
  abfe3078_bfec_252c_2107_7cdf0dd06f08 --> ada43310_8d32_ee2a_f18b_1e24fd4f8a1d
  b2dbf772_f39b_f942_7a94_3bc9c73b0a11["Ref"]
  abfe3078_bfec_252c_2107_7cdf0dd06f08 --> b2dbf772_f39b_f942_7a94_3bc9c73b0a11
  00ff1060_42c6_7a4a_3eb1_52c6fa7a39ad["UnwrapRefSimple"]
  abfe3078_bfec_252c_2107_7cdf0dd06f08 --> 00ff1060_42c6_7a4a_3eb1_52c6fa7a39ad
  1e22895d_5330_013d_cf7e_5e171013ae0b["RawSymbol"]
  abfe3078_bfec_252c_2107_7cdf0dd06f08 --> 1e22895d_5330_013d_cf7e_5e171013ae0b
  cf1af910_0651_68a5_bdd0_87db5433e4bf["observer"]
  abfe3078_bfec_252c_2107_7cdf0dd06f08 --> cf1af910_0651_68a5_bdd0_87db5433e4bf
  8a5fb776_a8f4_ce8a_8549_67af07f2e1e9["util"]
  abfe3078_bfec_252c_2107_7cdf0dd06f08 --> 8a5fb776_a8f4_ce8a_8549_67af07f2e1e9
  4ad51b1f_61ec_31ba_dbb7_667d6a0a8c85["apiSetup.ts"]
  4ad51b1f_61ec_31ba_dbb7_667d6a0a8c85 --> abfe3078_bfec_252c_2107_7cdf0dd06f08
  38aa88fe_678d_7728_4258_240bdb85b32b["apiWatch.ts"]
  38aa88fe_678d_7728_4258_240bdb85b32b --> abfe3078_bfec_252c_2107_7cdf0dd06f08
  50bb6353_35b0_d08f_72d3_b5e73e75dfee["computed.ts"]
  50bb6353_35b0_d08f_72d3_b5e73e75dfee --> abfe3078_bfec_252c_2107_7cdf0dd06f08
  0c0a6db0_d081_921f_5fe2_f51407664b15["readonly.ts"]
  0c0a6db0_d081_921f_5fe2_f51407664b15 --> abfe3078_bfec_252c_2107_7cdf0dd06f08
  ada43310_8d32_ee2a_f18b_1e24fd4f8a1d["ref.ts"]
  ada43310_8d32_ee2a_f18b_1e24fd4f8a1d --> abfe3078_bfec_252c_2107_7cdf0dd06f08
  style abfe3078_bfec_252c_2107_7cdf0dd06f08 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { observe, Observer } from 'core/observer'
import {
  def,
  isArray,
  isPrimitive,
  warn,
  toRawType,
  isServerRendering
} from 'core/util'
import type { Ref, UnwrapRefSimple, RawSymbol } from './ref'

export const enum ReactiveFlags {
  SKIP = '__v_skip',
  IS_READONLY = '__v_isReadonly',
  IS_SHALLOW = '__v_isShallow',
  RAW = '__v_raw'
}

export interface Target {
  __ob__?: Observer
  [ReactiveFlags.SKIP]?: boolean
  [ReactiveFlags.IS_READONLY]?: boolean
  [ReactiveFlags.IS_SHALLOW]?: boolean
  [ReactiveFlags.RAW]?: any
}

// only unwrap nested ref
export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>

export function reactive<T extends object>(target: T): UnwrapNestedRefs<T>
export function reactive(target: object) {
  makeReactive(target, false)
  return target
}

export declare const ShallowReactiveMarker: unique symbol

export type ShallowReactive<T> = T & { [ShallowReactiveMarker]?: true }

/**
 * Return a shallowly-reactive copy of the original object, where only the root
 * level properties are reactive. It also does not auto-unwrap refs (even at the
 * root level).
 */
export function shallowReactive<T extends object>(
  target: T
): ShallowReactive<T> {
  makeReactive(target, true)
  def(target, ReactiveFlags.IS_SHALLOW, true)
  return target
}

function makeReactive(target: any, shallow: boolean) {
  // if trying to observe a readonly proxy, return the readonly version.
  if (!isReadonly(target)) {
    if (__DEV__) {
      if (isArray(target)) {
        warn(
          `Avoid using Array as root value for ${
            shallow ? `shallowReactive()` : `reactive()`
// ... (78 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does reactive.ts do?
reactive.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, ScriptAnalyzer subdomain.
What functions are defined in reactive.ts?
reactive.ts defines 10 function(s): isCollectionType, isProxy, isReactive, isReadonly, isShallow, makeReactive, markRaw, reactive, shallowReactive, toRaw.
What does reactive.ts depend on?
reactive.ts imports 6 module(s): RawSymbol, Ref, UnwrapRefSimple, observer, ref.ts, util.
What files import reactive.ts?
reactive.ts is imported by 5 file(s): apiSetup.ts, apiWatch.ts, computed.ts, readonly.ts, ref.ts.
Where is reactive.ts in the architecture?
reactive.ts is located at src/v3/reactivity/reactive.ts (domain: CompilerSFC, subdomain: ScriptAnalyzer, directory: src/v3/reactivity).

Analyze Your Own Codebase

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

Try Supermodel Free