shared.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. /**
  2. * @private
  3. */
  4. export declare const camelize: (str: string) => string;
  5. /**
  6. * @private
  7. */
  8. export declare const capitalize: (str: string) => string;
  9. export declare const def: (obj: object, key: string | symbol, value: any) => void;
  10. export declare const EMPTY_ARR: readonly never[];
  11. export declare const EMPTY_OBJ: {
  12. readonly [key: string]: any;
  13. };
  14. export declare function escapeHtml(string: unknown): string;
  15. export declare function escapeHtmlComment(src: string): string;
  16. export declare const extend: {
  17. <T extends {}, U>(target: T, source: U): T & U;
  18. <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
  19. <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
  20. (target: object, ...sources: any[]): any;
  21. };
  22. export declare function generateCodeFrame(source: string, start?: number, end?: number): string;
  23. export declare function genPropsAccessExp(name: string): string;
  24. export declare const getGlobalThis: () => any;
  25. export declare const hasChanged: (value: any, oldValue: any) => boolean;
  26. export declare const hasOwn: (val: object, key: string | symbol) => key is never;
  27. /**
  28. * @private
  29. */
  30. export declare const hyphenate: (str: string) => string;
  31. export declare type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
  32. /**
  33. * Boolean attributes should be included if the value is truthy or ''.
  34. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  35. */
  36. export declare function includeBooleanAttr(value: unknown): boolean;
  37. export declare const invokeArrayFns: (fns: Function[], arg?: any) => void;
  38. export declare const isArray: (arg: any) => arg is any[];
  39. /**
  40. * The full list is needed during SSR to produce the correct initial markup.
  41. */
  42. export declare const isBooleanAttr: (key: string) => boolean;
  43. export declare const isBuiltInDirective: (key: string) => boolean;
  44. export declare const isDate: (val: unknown) => val is Date;
  45. export declare const isFunction: (val: unknown) => val is Function;
  46. export declare const isGloballyWhitelisted: (key: string) => boolean;
  47. /**
  48. * Compiler only.
  49. * Do NOT use in runtime code paths unless behind `__DEV__` flag.
  50. */
  51. export declare const isHTMLTag: (key: string) => boolean;
  52. export declare const isIntegerKey: (key: unknown) => boolean;
  53. /**
  54. * Known attributes, this is used for stringification of runtime static nodes
  55. * so that we don't stringify bindings that cannot be set from HTML.
  56. * Don't also forget to allow `data-*` and `aria-*`!
  57. * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
  58. */
  59. export declare const isKnownHtmlAttr: (key: string) => boolean;
  60. /**
  61. * Generated from https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
  62. */
  63. export declare const isKnownSvgAttr: (key: string) => boolean;
  64. export declare const isMap: (val: unknown) => val is Map<any, any>;
  65. export declare const isModelListener: (key: string) => boolean;
  66. export declare const isObject: (val: unknown) => val is Record<any, any>;
  67. export declare const isOn: (key: string) => boolean;
  68. export declare const isPlainObject: (val: unknown) => val is object;
  69. export declare const isPromise: <T = any>(val: unknown) => val is Promise<T>;
  70. export declare const isReservedProp: (key: string) => boolean;
  71. export declare const isSet: (val: unknown) => val is Set<any>;
  72. export declare const isSpecialBooleanAttr: (key: string) => boolean;
  73. export declare function isSSRSafeAttrName(name: string): boolean;
  74. export declare const isString: (val: unknown) => val is string;
  75. /**
  76. * Compiler only.
  77. * Do NOT use in runtime code paths unless behind `__DEV__` flag.
  78. */
  79. export declare const isSVGTag: (key: string) => boolean;
  80. export declare const isSymbol: (val: unknown) => val is symbol;
  81. /**
  82. * Compiler only.
  83. * Do NOT use in runtime code paths unless behind `__DEV__` flag.
  84. */
  85. export declare const isVoidTag: (key: string) => boolean;
  86. export declare function looseEqual(a: any, b: any): boolean;
  87. export declare function looseIndexOf(arr: any[], val: any): number;
  88. export declare type LooseRequired<T> = {
  89. [P in keyof (T & Required<T>)]: T[P];
  90. };
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. * IMPORTANT: all calls of this function must be prefixed with
  95. * \/\*#\_\_PURE\_\_\*\/
  96. * So that rollup can tree-shake them if necessary.
  97. */
  98. export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => boolean;
  99. /**
  100. * Always return false.
  101. */
  102. export declare const NO: () => boolean;
  103. export declare const NOOP: () => void;
  104. export declare function normalizeClass(value: unknown): string;
  105. export declare type NormalizedStyle = Record<string, string | number>;
  106. export declare function normalizeProps(props: Record<string, any> | null): Record<string, any> | null;
  107. export declare function normalizeStyle(value: unknown): NormalizedStyle | string | undefined;
  108. export declare const objectToString: () => string;
  109. export declare function parseStringStyle(cssText: string): NormalizedStyle;
  110. /**
  111. * dev only flag -> name mapping
  112. */
  113. export declare const PatchFlagNames: {
  114. [x: number]: string;
  115. };
  116. /**
  117. * Patch flags are optimization hints generated by the compiler.
  118. * when a block with dynamicChildren is encountered during diff, the algorithm
  119. * enters "optimized mode". In this mode, we know that the vdom is produced by
  120. * a render function generated by the compiler, so the algorithm only needs to
  121. * handle updates explicitly marked by these patch flags.
  122. *
  123. * Patch flags can be combined using the | bitwise operator and can be checked
  124. * using the & operator, e.g.
  125. *
  126. * ```js
  127. * const flag = TEXT | CLASS
  128. * if (flag & TEXT) { ... }
  129. * ```
  130. *
  131. * Check the `patchElement` function in '../../runtime-core/src/renderer.ts' to see how the
  132. * flags are handled during diff.
  133. */
  134. export declare const enum PatchFlags {
  135. /**
  136. * Indicates an element with dynamic textContent (children fast path)
  137. */
  138. TEXT = 1,
  139. /**
  140. * Indicates an element with dynamic class binding.
  141. */
  142. CLASS = 2,
  143. /**
  144. * Indicates an element with dynamic style
  145. * The compiler pre-compiles static string styles into static objects
  146. * + detects and hoists inline static objects
  147. * e.g. `style="color: red"` and `:style="{ color: 'red' }"` both get hoisted
  148. * as:
  149. * ```js
  150. * const style = { color: 'red' }
  151. * render() { return e('div', { style }) }
  152. * ```
  153. */
  154. STYLE = 4,
  155. /**
  156. * Indicates an element that has non-class/style dynamic props.
  157. * Can also be on a component that has any dynamic props (includes
  158. * class/style). when this flag is present, the vnode also has a dynamicProps
  159. * array that contains the keys of the props that may change so the runtime
  160. * can diff them faster (without having to worry about removed props)
  161. */
  162. PROPS = 8,
  163. /**
  164. * Indicates an element with props with dynamic keys. When keys change, a full
  165. * diff is always needed to remove the old key. This flag is mutually
  166. * exclusive with CLASS, STYLE and PROPS.
  167. */
  168. FULL_PROPS = 16,
  169. /**
  170. * Indicates an element with event listeners (which need to be attached
  171. * during hydration)
  172. */
  173. HYDRATE_EVENTS = 32,
  174. /**
  175. * Indicates a fragment whose children order doesn't change.
  176. */
  177. STABLE_FRAGMENT = 64,
  178. /**
  179. * Indicates a fragment with keyed or partially keyed children
  180. */
  181. KEYED_FRAGMENT = 128,
  182. /**
  183. * Indicates a fragment with unkeyed children.
  184. */
  185. UNKEYED_FRAGMENT = 256,
  186. /**
  187. * Indicates an element that only needs non-props patching, e.g. ref or
  188. * directives (onVnodeXXX hooks). since every patched vnode checks for refs
  189. * and onVnodeXXX hooks, it simply marks the vnode so that a parent block
  190. * will track it.
  191. */
  192. NEED_PATCH = 512,
  193. /**
  194. * Indicates a component with dynamic slots (e.g. slot that references a v-for
  195. * iterated value, or dynamic slot names).
  196. * Components with this flag are always force updated.
  197. */
  198. DYNAMIC_SLOTS = 1024,
  199. /**
  200. * Indicates a fragment that was created only because the user has placed
  201. * comments at the root level of a template. This is a dev-only flag since
  202. * comments are stripped in production.
  203. */
  204. DEV_ROOT_FRAGMENT = 2048,
  205. /**
  206. * SPECIAL FLAGS -------------------------------------------------------------
  207. * Special flags are negative integers. They are never matched against using
  208. * bitwise operators (bitwise matching should only happen in branches where
  209. * patchFlag > 0), and are mutually exclusive. When checking for a special
  210. * flag, simply check patchFlag === FLAG.
  211. */
  212. /**
  213. * Indicates a hoisted static vnode. This is a hint for hydration to skip
  214. * the entire sub tree since static content never needs to be updated.
  215. */
  216. HOISTED = -1,
  217. /**
  218. * A special flag that indicates that the diffing algorithm should bail out
  219. * of optimized mode. For example, on block fragments created by renderSlot()
  220. * when encountering non-compiler generated slots (i.e. manually written
  221. * render functions, which should always be fully diffed)
  222. * OR manually cloneVNodes
  223. */
  224. BAIL = -2
  225. }
  226. export declare const propsToAttrMap: Record<string, string | undefined>;
  227. export declare const remove: <T>(arr: T[], el: T) => void;
  228. export declare const enum ShapeFlags {
  229. ELEMENT = 1,
  230. FUNCTIONAL_COMPONENT = 2,
  231. STATEFUL_COMPONENT = 4,
  232. TEXT_CHILDREN = 8,
  233. ARRAY_CHILDREN = 16,
  234. SLOTS_CHILDREN = 32,
  235. TELEPORT = 64,
  236. SUSPENSE = 128,
  237. COMPONENT_SHOULD_KEEP_ALIVE = 256,
  238. COMPONENT_KEPT_ALIVE = 512,
  239. COMPONENT = 6
  240. }
  241. export declare const enum SlotFlags {
  242. /**
  243. * Stable slots that only reference slot props or context state. The slot
  244. * can fully capture its own dependencies so when passed down the parent won't
  245. * need to force the child to update.
  246. */
  247. STABLE = 1,
  248. /**
  249. * Slots that reference scope variables (v-for or an outer slot prop), or
  250. * has conditional structure (v-if, v-for). The parent will need to force
  251. * the child to update because the slot does not fully capture its dependencies.
  252. */
  253. DYNAMIC = 2,
  254. /**
  255. * `<slot/>` being forwarded into a child component. Whether the parent needs
  256. * to update the child is dependent on what kind of slots the parent itself
  257. * received. This has to be refined at runtime, when the child's vnode
  258. * is being created (in `normalizeChildren`)
  259. */
  260. FORWARDED = 3
  261. }
  262. /**
  263. * Dev only
  264. */
  265. export declare const slotFlagsText: {
  266. 1: string;
  267. 2: string;
  268. 3: string;
  269. };
  270. export declare function stringifyStyle(styles: NormalizedStyle | string | undefined): string;
  271. /**
  272. * For converting {{ interpolation }} values to displayed strings.
  273. * @private
  274. */
  275. export declare const toDisplayString: (val: unknown) => string;
  276. /**
  277. * @private
  278. */
  279. export declare const toHandlerKey: (str: string) => string;
  280. export declare const toNumber: (val: any) => any;
  281. export declare const toRawType: (value: unknown) => string;
  282. export declare const toTypeString: (value: unknown) => string;
  283. export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
  284. export { }