Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 43x 1x 1x 43x 43x 43x 43x 43x 43x 108x 108x | /**
* @file builtins.js
* @description The registry of components an application gets without
* declaring them.
*
* ## Why this is a registry rather than an import
*
* `AvenxApp` used to `import { VirtualList }` and register it in its
* constructor. That is one line, and it put `VirtualList`, the template
* renderer and the DOM patcher into every bundle ever built -- including the
* overwhelming majority of applications that never write `<VirtualList>`.
* Roughly 60 KB of source, reachable because of a registration nobody asked
* for.
*
* A built-in is now registered by importing a module whose only job is to
* register it, and the compiler adds that module to the graph when it sees the
* tag in a template. An application that uses the component pays for it; one
* that does not, does not.
*
* ## Deliberately tiny
*
* This module imports nothing, for the same reason
* {@link module:lib/core/renderer/stringRenderer} imports nothing: a default
* would make the thing it defaults to reachable, and the arrangement would
* achieve nothing.
* @module lib/core/runtime/builtins
*/
/**
* Built-in component classes by tag name.
* @type {Map<string, Function>}
*/
const builtins = new Map();
/**
* Registers a built-in component.
* @param {string} name - The PascalCase tag name.
* @param {Function} componentClass - The component class.
*/
export function registerBuiltin(name, componentClass) {
builtins.set(name, componentClass);
}
/**
* Every registered built-in, for an application to adopt at construction.
* @returns {Map<string, Function>} The registry.
*/
export function getBuiltins() {
return builtins;
}
|