'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var shared = require('@vue/shared'); function passive(passive) { return { passive }; } function normalizeDataset(el) { // TODO return JSON.parse(JSON.stringify(el.dataset || {})); } function plusReady(callback) { if (typeof callback !== 'function') { return; } if (window.plus) { return callback(); } document.addEventListener('plusready', callback); } const BUILT_IN_TAGS = [ 'ad', 'audio', 'button', 'camera', 'canvas', 'checkbox', 'checkbox-group', 'cover-image', 'cover-view', 'editor', 'form', 'functional-page-navigator', 'icon', 'image', 'input', 'label', 'live-player', 'live-pusher', 'map', 'movable-area', 'movable-view', 'navigator', 'official-account', 'open-data', 'picker', 'picker-view', 'picker-view-column', 'progress', 'radio', 'radio-group', 'rich-text', 'scroll-view', 'slider', 'swiper', 'swiper-item', 'switch', 'text', 'textarea', 'video', 'view', 'web-view', ].map((tag) => 'uni-' + tag); const TAGS = [ 'app', 'layout', 'content', 'main', 'top-window', 'left-window', 'right-window', 'tabbar', 'page', 'page-head', 'page-wrapper', 'page-body', 'page-refresh', 'actionsheet', 'modal', 'toast', 'resize-sensor', 'shadow-root', ].map((tag) => 'uni-' + tag); function isBuiltInComponent(tag) { return BUILT_IN_TAGS.indexOf('uni-' + tag) !== -1; } function isCustomElement(tag) { return TAGS.indexOf(tag) !== -1 || BUILT_IN_TAGS.indexOf(tag) !== -1; } function isNativeTag(tag) { return (shared.isHTMLTag(tag) || shared.isSVGTag(tag)) && !isBuiltInComponent(tag); } const COMPONENT_SELECTOR_PREFIX = 'uni-'; const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX; function getLen(str = '') { return ('' + str).replace(/[^\x00-\xff]/g, '**').length; } function removeLeadingSlash(str) { return str.indexOf('/') === 0 ? str.substr(1) : str; } const invokeArrayFns = (fns, arg) => { let ret; for (let i = 0; i < fns.length; i++) { ret = fns[i](arg); } return ret; }; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { const res = obj ? Object.keys(obj) .map((key) => { let val = obj[key]; if (typeof val === undefined || val === null) { val = ''; } else if (shared.isPlainObject(val)) { val = JSON.stringify(val); } return encodeStr(key) + '=' + encodeStr(val); }) .filter((x) => x.length > 0) .join('&') : null; return res ? `?${res}` : ''; } /** * Decode text using `decodeURIComponent`. Returns the original text if it * fails. * * @param text - string to decode * @returns decoded string */ function decode(text) { try { return decodeURIComponent('' + text); } catch (err) { } return '' + text; } function decodedQuery(query = {}) { const decodedQuery = {}; Object.keys(query).forEach((name) => { try { decodedQuery[name] = decode(query[name]); } catch (e) { decodedQuery[name] = query[name]; } }); return decodedQuery; } const PLUS_RE = /\+/g; // %2B /** * https://github.com/vuejs/vue-router-next/blob/master/src/query.ts * @internal * * @param search - search string to parse * @returns a query object */ function parseQuery(search) { const query = {}; // avoid creating an object with an empty key and empty value // because of split('&') if (search === '' || search === '?') return query; const hasLeadingIM = search[0] === '?'; const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&'); for (let i = 0; i < searchParams.length; ++i) { // pre decode the + into space const searchParam = searchParams[i].replace(PLUS_RE, ' '); // allow the = character let eqPos = searchParam.indexOf('='); let key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos)); let value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1)); if (key in query) { // an extra variable for ts types let currentValue = query[key]; if (!Array.isArray(currentValue)) { currentValue = query[key] = [currentValue]; } currentValue.push(value); } else { query[key] = value; } } return query; } function debounce(fn, delay) { let timeout; const newFn = function () { clearTimeout(timeout); const timerFn = () => fn.apply(this, arguments); timeout = setTimeout(timerFn, delay); }; newFn.cancel = function () { clearTimeout(timeout); }; return newFn; } const NAVBAR_HEIGHT = 44; const TABBAR_HEIGHT = 50; const RESPONSIVE_MIN_WIDTH = 768; const COMPONENT_NAME_PREFIX = 'VUni'; const PRIMARY_COLOR = '#007aff'; exports.BUILT_IN_TAGS = BUILT_IN_TAGS; exports.COMPONENT_NAME_PREFIX = COMPONENT_NAME_PREFIX; exports.COMPONENT_PREFIX = COMPONENT_PREFIX; exports.COMPONENT_SELECTOR_PREFIX = COMPONENT_SELECTOR_PREFIX; exports.NAVBAR_HEIGHT = NAVBAR_HEIGHT; exports.PLUS_RE = PLUS_RE; exports.PRIMARY_COLOR = PRIMARY_COLOR; exports.RESPONSIVE_MIN_WIDTH = RESPONSIVE_MIN_WIDTH; exports.TABBAR_HEIGHT = TABBAR_HEIGHT; exports.TAGS = TAGS; exports.debounce = debounce; exports.decode = decode; exports.decodedQuery = decodedQuery; exports.getLen = getLen; exports.invokeArrayFns = invokeArrayFns; exports.isBuiltInComponent = isBuiltInComponent; exports.isCustomElement = isCustomElement; exports.isNativeTag = isNativeTag; exports.normalizeDataset = normalizeDataset; exports.parseQuery = parseQuery; exports.passive = passive; exports.plusReady = plusReady; exports.removeLeadingSlash = removeLeadingSlash; exports.stringifyQuery = stringifyQuery;