All files index.js

88.97% Statements 121/136
71.43% Branches 60/84
87.5% Functions 35/40
88.81% Lines 119/134
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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304    4x   4x   4x 4x 4x     5x     4x     22x     2x   4x 4x 60x 60x   4x               4x 3x   1x   4x             4x   4x       22x   4x     30x 4x 1x     30x 33x 33x       4x   1x 1x     2x 2x 2x     2x 2x   2x 2x 2x   2x 2x 2x   2x                     2x               34x 34x     25x 3x 3x 1x     2x       2x             2x 2x 2x 2x           22x 2x   20x     20x 1x     19x           4x 4x 4x   34x   4x   26x     6x     20x     30x     30x           9x     23x           4x                 1x     26x 26x     4x     4x                                   4x   4x 4x 21x 21x   4x 28x 28x   4x 2x     28x 28x 7x   21x 21x 21x       4x   4x 3x 3x 1x 2x 2x 2x     2x     8x 1x   7x 7x 1x   6x   4x                       4x               4x 4x 4x 4x 4x 4x    
'use strict';
 
Object.defineProperty(exports, '__esModule', { value: true });
 
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
 
var Reconciler = _interopDefault(require('react-reconciler'));
var scheduler = require('scheduler');
var runtime = require('@tarojs/runtime');
 
function isString(o) {
    return typeof o === 'string';
}
function isObject(o) {
    return o !== null && typeof o === 'object';
}
function isFunction(o) {
    return typeof o === 'function';
}
function isNumber(o) {
    return typeof o === 'number';
}
var EMPTY_ARR = [];
var noop = function () {
    var _ = [], len = arguments.length;
    while ( len-- ) _[ len ] = arguments[ len ];
 };
var reportIssue = '如有疑问,请提交 issue 至:https://github.com/nervjs/taro/issues';
/**
 * ensure takes a condition and throw a error if the condition fails,
 * like failure::ensure: https://docs.rs/failure/0.1.1/failure/macro.ensure.html
 * @param condition condition.
 * @param msg error message.
 */
function ensure(condition, msg) {
    if (condition) {
        return;
    }
    throw new Error(msg + '\n' + reportIssue);
}
var touchEvents = {
    bindTouchStart: '',
    bindTouchMove: '',
    bindTouchEnd: '',
    bindTouchCancel: '',
    bindLongTap: ''
};
var View = Object.assign({ 'hover-class': singleQuote('none'), 'hover-stop-propagation': 'false', 'hover-start-time': '50', 'hover-stay-time': '400', animation: '' }, touchEvents);
function singleQuote(s) {
    return ("'" + s + "'");
}
 
function isEventName(s) {
    return s[0] === 'o' && s[1] === 'n';
}
var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
function updateProps(dom, oldProps, newProps) {
    var i;
    for (i in oldProps) {
        if (!(i in newProps)) {
            setProperty(dom, i, null, oldProps[i]);
        }
    }
    for (i in newProps) {
        Eif (oldProps[i] !== newProps[i]) {
            setProperty(dom, i, newProps[i], oldProps[i]);
        }
    }
}
var listeners = new WeakMap();
function eventProxy(e) {
    var el = runtime.document.getElementById(e.currentTarget.id);
    listeners.get(el)[e.type](e);
}
function setEvent(dom, name, value, oldValue) {
    var isCapture = name.endsWith('Capture');
    var eventName = name.toLowerCase().slice(2);
    Iif (isCapture) {
        eventName = eventName.slice(0, -7);
    }
    Eif (eventName === 'click') {
        eventName = 'tap';
    }
    Eif (isFunction(value)) {
        Eif (!oldValue) {
            dom.addEventListener(eventName, eventProxy, isCapture);
        }
        var events = listeners.get(dom);
        Eif (!events) {
            listeners.set(dom, events = {});
        }
        events[eventName] = value;
    }
    else {
        dom.removeEventListener(eventName, eventProxy);
        var events$1 = listeners.get(dom);
        if (events$1) {
            delete events$1[eventName];
        }
    }
}
function setStyle(style, key, value) {
    style[key] =
        isNumber(value) && IS_NON_DIMENSIONAL.test(key) === false
            ? value + 'px'
            : value == null
                ? ''
                : value;
}
function setProperty(dom, name, value, oldValue) {
    name = name === 'className' ? 'class' : name;
    if (name === 'key' ||
        name === 'children' ||
        name === 'ref') ;
    else if (name === 'style') {
        var style = dom.style;
        if (isString(value)) {
            style.cssText = value;
        }
        else {
            Iif (isString(oldValue)) {
                style.cssText = '';
                oldValue = null;
            }
            Iif (isObject(oldValue)) {
                for (var i in oldValue) {
                    if (!(value && i in value)) {
                        setStyle(style, i, '');
                    }
                }
            }
            Eif (isObject(value)) {
                for (var i$1 in value) {
                    Eif (!oldValue || value[i$1] !== oldValue[i$1]) {
                        setStyle(style, i$1, value[i$1]);
                    }
                }
            }
        }
    }
    else if (isEventName(name)) {
        setEvent(dom, name, value, oldValue);
    }
    else Eif (!isFunction(value) &&
        name !== 'dangerouslySetInnerHTML' // TODO: 实现 innerHTML
    ) {
        if (value == null) {
            dom.removeAttribute(name);
        }
        else {
            dom.setAttribute(name, value);
        }
    }
}
 
/* eslint-disable @typescript-eslint/indent */
var scheduleDeferredCallback = scheduler.unstable_scheduleCallback;
var cancelDeferredCallback = scheduler.unstable_cancelCallback;
var now = scheduler.unstable_now;
function returnFalse() {
    return false;
}
var hostConfig = {
    createInstance: function createInstance(type) {
        return runtime.document.createElement(type);
    },
    createTextInstance: function createTextInstance(text) {
        return runtime.document.createTextNode(text);
    },
    getPublicInstance: function getPublicInstance(inst) {
        return inst;
    },
    getRootHostContext: function getRootHostContext() {
        return {};
    },
    getChildHostContext: function getChildHostContext() {
        return {};
    },
    appendChild: function appendChild(parent, child) {
        parent.appendChild(child);
    },
    appendInitialChild: function appendInitialChild(parent, child) {
        parent.appendChild(child);
    },
    appendChildToContainer: function appendChildToContainer(parent, child) {
        parent.appendChild(child);
    },
    removeChild: function removeChild(parent, child) {
        parent.removeChild(child);
    },
    removeChildFromContainer: function removeChildFromContainer(parent, child) {
        parent.removeChild(child);
    },
    insertBefore: function insertBefore(parent, child, refChild) {
        parent.insertBefore(child, refChild);
    },
    insertInContainerBefore: function insertInContainerBefore(parent, child, refChild) {
        parent.insertBefore(child, refChild);
    },
    commitTextUpdate: function commitTextUpdate(textInst, _, newText) {
        textInst.nodeValue = newText;
    },
    finalizeInitialChildren: function finalizeInitialChildren(dom, _, props) {
        updateProps(dom, {}, props);
        return false;
    },
    prepareUpdate: function prepareUpdate() {
        return EMPTY_ARR;
    },
    commitUpdate: function commitUpdate(dom, _payload, _type, oldProps, newProps) {
        updateProps(dom, oldProps, newProps);
    },
    shouldSetTextContent: returnFalse,
    shouldDeprioritizeSubtree: returnFalse,
    prepareForCommit: noop,
    resetAfterCommit: noop,
    commitMount: noop,
    now: now,
    scheduleDeferredCallback: scheduleDeferredCallback,
    cancelDeferredCallback: cancelDeferredCallback,
    clearTimeout: clearTimeout,
    setTimeout: setTimeout,
    noTimeout: -1,
    supportsMutation: true,
    supportsPersistence: false,
    isPrimaryRenderer: true,
    supportsHydration: false
};
var TaroReconciler = Reconciler(hostConfig);
 
var ContainerMap = new WeakMap();
var Root = function Root(renderer, domContainer) {
    this.renderer = renderer;
    this.internalRoot = renderer.createContainer(domContainer, false, false);
};
Root.prototype.render = function render (children, cb) {
    this.renderer.updateContainer(children, this.internalRoot, null, cb);
    return this.renderer.getPublicRootInstance(this.internalRoot);
};
Root.prototype.unmount = function unmount (cb) {
    this.renderer.updateContainer(null, this.internalRoot, null, cb);
};
function render(element, domContainer, cb) {
    var oldRoot = ContainerMap.get(domContainer);
    if (oldRoot != null) {
        return oldRoot.render(element, cb);
    }
    var root = new Root(TaroReconciler, domContainer);
    ContainerMap.set(domContainer, root);
    return root.render(element, cb);
}
 
/* eslint-disable @typescript-eslint/no-unused-vars */
var unstable_batchedUpdates = TaroReconciler.batchedUpdates;
function unmountComponentAtNode(dom) {
    ensure(dom && [1, 8, 9, 11].includes(dom.nodeType), 'unmountComponentAtNode(...): Target container is not a DOM element.');
    var root = ContainerMap.get(dom);
    if (!root)
        { return false; }
    unstable_batchedUpdates(function () {
        root.unmount(function () {
            ContainerMap.delete(dom);
        });
    });
    return true;
}
function findDOMNode(comp) {
    if (comp == null) {
        return null;
    }
    var nodeType = comp.nodeType;
    if (nodeType === 1 || nodeType === 3) {
        return comp;
    }
    return TaroReconciler.findHostInstance(comp);
}
var portalType = typeof Symbol === 'function' && Symbol.for
    ? Symbol.for('react.portal')
    : 0xeaca;
function createPortal(children, containerInfo, key) {
    return {
        $$typeof: portalType,
        key: key == null ? null : String(key),
        children: children,
        containerInfo: containerInfo,
        implementation: null
    };
}
var index = {
    render: render,
    unstable_batchedUpdates: unstable_batchedUpdates,
    unmountComponentAtNode: unmountComponentAtNode,
    findDOMNode: findDOMNode,
    createPortal: createPortal
};
 
exports.createPortal = createPortal;
exports.default = index;
exports.findDOMNode = findDOMNode;
exports.render = render;
exports.unmountComponentAtNode = unmountComponentAtNode;
exports.unstable_batchedUpdates = unstable_batchedUpdates;
//# sourceMappingURL=index.js.map