# All files / lib/util types.js

100% Statements 263/263
100% Branches 1/1
100% Functions 0/0
100% Lines 263/263

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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    2642x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
     /**
     * @enum {number}
     */
    export const NODE_TYPE = {
      ELEMENT: 1,
      ATTR: 2,
      TEXT: 3,
      COMMENT: 8,
      FRAGMENT: 11,
    };

    /**
     * @enum {any}
     */
    export const EMPTY = {
      STR: '',
      NUM: 1,
      OBJ: /** @type {any} */ ({}),
      ARR: [],
      MAP: new Map(),
      SET: new Set(),
      DOM: /** @type {HTMLElement} */ ({}),
    };

    /**
     * @enum {number}
     */
    export const PATCH_TYPE = {
      SET_ATTRIBUTE: 0,
      REMOVE_ATTRIBUTE: 1,
      NODE_VALUE: 2,
      INSERT_BEFORE: 3,
      REPLACE_CHILD: 4,
      REMOVE_CHILD: 5,
    };

    /**
     * @typedef {TransitionStateName[]} TransitionStateNames
     * @type {TransitionStateNames}
     */
    export const TransitionStateNames = [
      'attached',
      'detached',
      'replaced',
      'attributeChanged',
      'textChanged',
    ];

    /**
     * Creates a mapping of TransitionState
     *
     * @typedef {Map<TransitionStateName, Set<Function>>} TransitionCache
     */
    export const TransitionCache = new Map([
      ['attached', new Set()],
      ['detached', new Set()],
      ['replaced', new Set()],
      ['attributeChanged', new Set()],
      ['textChanged', new Set()],
    ]);

    /**
     * Associates active transaction mount with state.
     *
     * @typedef {Map<Mount, TransactionState>} StateCache
     */
    export const StateCache = new Map();

    /**
     * Associates a VTree with a distinctive DOM Node.
     *
     * @typedef {Map<VTree, ValidNode>} NodeCache
     */
    export const NodeCache = new Map();

    /**
     * Stores middleware functions/objects which hook into the render flow.
     *
     * @typedef {Set<Function>} MiddlewareCache
     */
    export const MiddlewareCache = new Set();

    /**
     * @typedef {Set<Function>} CreateTreeHookCache
     */
    export const CreateTreeHookCache = new Set();

    /**
     * @typedef {(vTree: VTree) => ValidNode | void} CreateNodeHookCallback
     * @typedef {Set<CreateNodeHookCallback>} CreateNodeHookCache
     */
    export const CreateNodeHookCache = new Set();

    /**
     * @typedef {Set<Function>} SyncTreeHookCache
     */
    export const SyncTreeHookCache = new Set();

    /**
     * @typedef {Set<Function>} ReleaseHookCache
     */
    export const ReleaseHookCache = new Set();

    /**
     * @typedef {Set<Function>} ParseHookCache
     */
    export const ParseHookCache = new Set();

    /**
     * @typedef {'attached' | 'detached' | 'replaced' | 'attributeChanged' | 'textChanged'} TransitionStateName
     */
    export const TransitionStateName = EMPTY.OBJ;

    /**
     * @typedef {{ [key: string]: any }} VTreeAttributes
     *
     */
    export const VTreeAttributes = EMPTY.OBJ;

    /**
     * @typedef {Object} VTree
     *
     * @property {any} rawNodeName - unaltered extracted nodeName
     * @property {string} nodeName - lowercased, string, nodeName
     * @property {string} nodeValue - defines the text value associated
     * @property {number} nodeType - the type of Node this is representing
     * @property {string} key - A unique identifier for the children
     * @property {VTree[]} childNodes - Any nested elements
     * @property {VTreeAttributes} attributes - Any key/val attributes for the Node
     */
    export const VTree = EMPTY.OBJ;

    /**
     * @typedef {Object} VTreeLike

     * @property {any=} rawNodeName - unaltered extracted nodeName
     * @property {string=} nodeName - lowercased, string, nodeName, only required value
     * @property {string=} elementName - lowercased, string, elementName
     * @property {string=} nodeValue - defines the text value associated
     * @property {number=} nodeType - the type of Node this is representing
     * @property {string=} key - A unique identifier for the children
     * @property {VTreeLike[]=} childNodes - Any nested elements
     * @property {VTreeLike[]=} children - Any nested elements
     * @property {any=} attributes - Any key/val attributes for the Node
     */
    export const VTreeLike = EMPTY.OBJ;

    /**
     * @typedef {HTMLElement | ChildNode | Element | Text | Comment | DocumentFragment | Function | string | string[] | VTree | VTree[] | VTreeLike | VTreeLike[]} ValidInput
     */
    export const ValidInput = EMPTY.OBJ;

    /**
     * @typedef {Element | HTMLElement | Text | DocumentFragment | ChildNode} ValidNode
     */
    export const ValidNode = EMPTY.OBJ;

    /**
     * @typedef {ValidNode | VTree | VTree[] | VTreeLike | VTreeLike[]} Mount
     */
    export const Mount = EMPTY.OBJ;

    /**
     * @typedef {Object} Middleware
     *
     * @property {string=} displayName
     * @property {Function=} subscribe
     * @property {Function=} unsubscribe
     * @property {Function=} createTreeHook
     * @property {CreateNodeHookCallback=} createNodeHook
     * @property {Function=} syncTreeHook
     * @property {Function=} releaseHook
     * @property {Function=} parseHook
     */
    export const Middleware = EMPTY.OBJ;

    /**
     * @typedef {Object} ParserConfig
     *
     * @property {Boolean=} strict - Should the parser operate in strict mode
     * @property {Boolean=} trim - Trim surrounding whitespace nodes
     * @property {string[]=} rawElements - Set of raw element tagNames, empty is all
     * @property {string[]=} selfClosingElements - Set of self closing element tagNames, empty is all
     */
    export const ParserConfig = EMPTY.OBJ;

     /**
     * @typedef {Object} TransactionConfig
     *
     * @property {Boolean=} inner - to diff children or root
     * @property {Boolean=} executeScripts - to execute scripts or not
     * @property {Function[]=} tasks - to override tasks
     * @property {ParserConfig=} parser - override parser options
     */
    export const TransactionConfig = EMPTY.OBJ;

    /**
     * @typedef {Object} GlobalConfig
     *
     * @property {string=} NODE_ENV - To set the runtime execution mode
     * @property {Boolean=} collectMetrics - to collect performance metrics, defaults to false
     */
    export const GlobalConfig = EMPTY.OBJ;

    /**
     * @typedef {TransactionConfig & GlobalConfig & { [key: string]: unknown }} Config
     */
    export const Config = {};

    /**
     * @typedef {Object} Supplemental
     *
     * @property {{ [key: string]: any }} tags
     * @property {{ [key: string]: any }} attributes
     * @property {{ [key: string]: any }} children
     */
    export const Supplemental = EMPTY.OBJ;

    /**
     * @typedef {Object} TransactionState
     *
     * @property {Function} measure
     * @property {Set<VTree>} svgElements
     * @property {Map<VTree, string | undefined>} scriptsToExecute
     * @property {VTree=} oldTree
     * @property {Boolean=} isRendering
     * @property {Boolean=} isDirty
     * @property {MutationObserver=} mutationObserver
     * @property {import('../transaction').default} activeTransaction
     * @property {import('../transaction').default=} nextTransaction
     * @property {Document=} ownerDocument
    */
    export const TransactionState = EMPTY.OBJ;

    /**
     * @typedef {Object} Internals
     *
     * @property {string=} VERSION
     * @property {GlobalConfig=} globalConfig
     * @property {Function} decodeEntities
     * @property {Function} escape
     * @property {Function} makeMeasure
     * @property {any} memory
     * @property {any} Pool
     * @property {any} process
     * @property {{ [key: string]: any }} PATCH_TYPE
     * @property {Function=} parse
     * @property {Function} createNode
     * @property {Function} syncTree
     * @property {unknown} Transaction
     * @property {Function[]} defaultTasks
     * @property {{ [key: string]: any }} tasks
     * @property {StateCache} StateCache
     * @property {NodeCache} NodeCache
     * @property {TransitionCache} TransitionCache
     * @property {MiddlewareCache} MiddlewareCache
     * @property {CreateTreeHookCache} CreateTreeHookCache
     * @property {CreateNodeHookCache} CreateNodeHookCache
     * @property {SyncTreeHookCache} SyncTreeHookCache
     * @property {ReleaseHookCache} ReleaseHookCache
     * @property {ParseHookCache} ParseHookCache
     */
    export const Internals = EMPTY.OBJ;