uni-shared.cjs.js 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767
  1. 'use strict';
  2. var shared = require('@vue/shared');
  3. const BUILT_IN_TAG_NAMES = [
  4. 'ad',
  5. 'ad-content-page',
  6. 'ad-draw',
  7. 'audio',
  8. 'button',
  9. 'camera',
  10. 'canvas',
  11. 'checkbox',
  12. 'checkbox-group',
  13. 'cover-image',
  14. 'cover-view',
  15. 'editor',
  16. 'form',
  17. 'functional-page-navigator',
  18. 'icon',
  19. 'image',
  20. 'input',
  21. 'label',
  22. 'live-player',
  23. 'live-pusher',
  24. 'map',
  25. 'movable-area',
  26. 'movable-view',
  27. 'navigator',
  28. 'official-account',
  29. 'open-data',
  30. 'picker',
  31. 'picker-view',
  32. 'picker-view-column',
  33. 'progress',
  34. 'radio',
  35. 'radio-group',
  36. 'rich-text',
  37. 'scroll-view',
  38. 'slider',
  39. 'swiper',
  40. 'swiper-item',
  41. 'switch',
  42. 'text',
  43. 'textarea',
  44. 'video',
  45. 'view',
  46. 'web-view',
  47. ];
  48. const BUILT_IN_TAGS = BUILT_IN_TAG_NAMES.map((tag) => 'uni-' + tag);
  49. const TAGS = [
  50. 'app',
  51. 'layout',
  52. 'content',
  53. 'main',
  54. 'top-window',
  55. 'left-window',
  56. 'right-window',
  57. 'tabbar',
  58. 'page',
  59. 'page-head',
  60. 'page-wrapper',
  61. 'page-body',
  62. 'page-refresh',
  63. 'actionsheet',
  64. 'modal',
  65. 'toast',
  66. 'resize-sensor',
  67. 'shadow-root',
  68. ].map((tag) => 'uni-' + tag);
  69. const NVUE_BUILT_IN_TAGS = [
  70. 'svg',
  71. 'view',
  72. 'a',
  73. 'div',
  74. 'img',
  75. 'image',
  76. 'text',
  77. 'span',
  78. 'input',
  79. 'textarea',
  80. 'spinner',
  81. 'select',
  82. // slider 被自定义 u-slider 替代
  83. // 'slider',
  84. 'slider-neighbor',
  85. 'indicator',
  86. 'canvas',
  87. 'list',
  88. 'cell',
  89. 'header',
  90. 'loading',
  91. 'loading-indicator',
  92. 'refresh',
  93. 'scrollable',
  94. 'scroller',
  95. 'video',
  96. 'web',
  97. 'embed',
  98. 'tabbar',
  99. 'tabheader',
  100. 'datepicker',
  101. 'timepicker',
  102. 'marquee',
  103. 'countdown',
  104. 'dc-switch',
  105. 'waterfall',
  106. 'richtext',
  107. 'recycle-list',
  108. 'u-scalable',
  109. 'barcode',
  110. 'gcanvas',
  111. ];
  112. const UVUE_BUILT_IN_TAGS = [
  113. 'loading-indicator',
  114. 'list-view',
  115. 'list-item',
  116. 'swiper',
  117. 'swiper-item',
  118. 'rich-text',
  119. 'sticky-view',
  120. 'sticky-header',
  121. 'sticky-section',
  122. // 自定义
  123. 'uni-slider',
  124. // 原生实现
  125. 'button',
  126. ];
  127. const UVUE_WEB_BUILT_IN_TAGS = [
  128. 'list-view',
  129. 'list-item',
  130. 'sticky-section',
  131. 'sticky-header',
  132. 'cloud-db-element',
  133. ].map((tag) => 'uni-' + tag);
  134. const UVUE_IOS_BUILT_IN_TAGS = [
  135. 'scroll-view',
  136. 'web-view',
  137. 'slider',
  138. 'swiper',
  139. 'swiper-item',
  140. 'rich-text',
  141. 'button',
  142. 'list-view',
  143. 'list-item',
  144. 'switch',
  145. 'sticky-header',
  146. 'sticky-section',
  147. ];
  148. const NVUE_U_BUILT_IN_TAGS = [
  149. 'u-text',
  150. 'u-image',
  151. 'u-input',
  152. 'u-textarea',
  153. 'u-video',
  154. 'u-web-view',
  155. 'u-slider',
  156. 'u-ad',
  157. 'u-ad-draw',
  158. 'u-rich-text',
  159. ];
  160. const UNI_UI_CONFLICT_TAGS = ['list-item'].map((tag) => 'uni-' + tag);
  161. function isBuiltInComponent(tag) {
  162. if (UNI_UI_CONFLICT_TAGS.indexOf(tag) !== -1) {
  163. return false;
  164. }
  165. // h5 平台会被转换为 v-uni-
  166. const realTag = 'uni-' + tag.replace('v-uni-', '');
  167. // TODO 区分x和非x
  168. return (BUILT_IN_TAGS.indexOf(realTag) !== -1 ||
  169. UVUE_WEB_BUILT_IN_TAGS.indexOf(realTag) !== -1);
  170. }
  171. function isH5CustomElement(tag, isX = false) {
  172. if (isX && UVUE_WEB_BUILT_IN_TAGS.indexOf(tag) !== -1) {
  173. return true;
  174. }
  175. return TAGS.indexOf(tag) !== -1 || BUILT_IN_TAGS.indexOf(tag) !== -1;
  176. }
  177. function isUniXElement(name) {
  178. return /^I?Uni.*Element(?:Impl)?$/.test(name);
  179. }
  180. function isH5NativeTag(tag) {
  181. return (tag !== 'head' &&
  182. (shared.isHTMLTag(tag) || shared.isSVGTag(tag)) &&
  183. !isBuiltInComponent(tag));
  184. }
  185. function isAppNativeTag(tag) {
  186. return shared.isHTMLTag(tag) || shared.isSVGTag(tag) || isBuiltInComponent(tag);
  187. }
  188. const NVUE_CUSTOM_COMPONENTS = [
  189. 'ad',
  190. 'ad-draw',
  191. 'button',
  192. 'checkbox-group',
  193. 'checkbox',
  194. 'form',
  195. 'icon',
  196. 'label',
  197. 'movable-area',
  198. 'movable-view',
  199. 'navigator',
  200. 'picker',
  201. 'progress',
  202. 'radio-group',
  203. 'radio',
  204. 'rich-text',
  205. 'swiper-item',
  206. 'swiper',
  207. 'switch',
  208. 'slider',
  209. 'picker-view',
  210. 'picker-view-column',
  211. ];
  212. function isAppUVueNativeTag(tag) {
  213. // 前端实现的内置组件都会注册一个根组件
  214. if (tag.startsWith('uni-') && tag.endsWith('-element')) {
  215. return true;
  216. }
  217. if (UVUE_BUILT_IN_TAGS.includes(tag)) {
  218. return true;
  219. }
  220. if (NVUE_CUSTOM_COMPONENTS.includes(tag)) {
  221. return false;
  222. }
  223. if (isBuiltInComponent(tag)) {
  224. return true;
  225. }
  226. // u-text,u-video...
  227. if (NVUE_U_BUILT_IN_TAGS.includes(tag)) {
  228. return true;
  229. }
  230. return false;
  231. }
  232. function isAppNVueNativeTag(tag) {
  233. if (NVUE_BUILT_IN_TAGS.includes(tag)) {
  234. return true;
  235. }
  236. if (NVUE_CUSTOM_COMPONENTS.includes(tag)) {
  237. return false;
  238. }
  239. if (isBuiltInComponent(tag)) {
  240. return true;
  241. }
  242. // u-text,u-video...
  243. if (NVUE_U_BUILT_IN_TAGS.includes(tag)) {
  244. return true;
  245. }
  246. return false;
  247. }
  248. function isMiniProgramNativeTag(tag) {
  249. return isBuiltInComponent(tag);
  250. }
  251. function createIsCustomElement(tags = []) {
  252. return function isCustomElement(tag) {
  253. return tags.includes(tag);
  254. };
  255. }
  256. function isComponentTag(tag) {
  257. return tag[0].toLowerCase() + tag.slice(1) === 'component';
  258. }
  259. const COMPONENT_SELECTOR_PREFIX = 'uni-';
  260. const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX;
  261. const LINEFEED = '\n';
  262. const NAVBAR_HEIGHT = 44;
  263. const TABBAR_HEIGHT = 50;
  264. const ON_REACH_BOTTOM_DISTANCE = 50;
  265. const RESPONSIVE_MIN_WIDTH = 768;
  266. const UNI_STORAGE_LOCALE = 'UNI_LOCALE';
  267. // quickapp-webview 不能使用 default 作为插槽名称
  268. const SLOT_DEFAULT_NAME = 'd';
  269. const COMPONENT_NAME_PREFIX = 'VUni';
  270. const I18N_JSON_DELIMITERS = ['%', '%'];
  271. const PRIMARY_COLOR = '#007aff';
  272. const SELECTED_COLOR = '#0062cc'; // 选中的颜色,如选项卡默认的选中颜色
  273. const BACKGROUND_COLOR = '#f7f7f7'; // 背景色,如标题栏默认背景色
  274. const UNI_SSR = '__uniSSR';
  275. const UNI_SSR_TITLE = 'title';
  276. const UNI_SSR_STORE = 'store';
  277. const UNI_SSR_DATA = 'data';
  278. const UNI_SSR_GLOBAL_DATA = 'globalData';
  279. const SCHEME_RE = /^([a-z-]+:)?\/\//i;
  280. const DATA_RE = /^data:.*,.*/;
  281. const WEB_INVOKE_APPSERVICE = 'WEB_INVOKE_APPSERVICE';
  282. const WXS_PROTOCOL = 'wxs://';
  283. const JSON_PROTOCOL = 'json://';
  284. const WXS_MODULES = 'wxsModules';
  285. const RENDERJS_MODULES = 'renderjsModules';
  286. // lifecycle
  287. // App and Page
  288. const ON_SHOW = 'onShow';
  289. const ON_HIDE = 'onHide';
  290. //App
  291. const ON_LAUNCH = 'onLaunch';
  292. const ON_ERROR = 'onError';
  293. const ON_THEME_CHANGE = 'onThemeChange';
  294. const OFF_THEME_CHANGE = 'offThemeChange';
  295. const ON_KEYBOARD_HEIGHT_CHANGE = 'onKeyboardHeightChange';
  296. const ON_PAGE_NOT_FOUND = 'onPageNotFound';
  297. const ON_UNHANDLE_REJECTION = 'onUnhandledRejection';
  298. const ON_EXIT = 'onExit';
  299. //Page
  300. const ON_LOAD = 'onLoad';
  301. const ON_READY = 'onReady';
  302. const ON_UNLOAD = 'onUnload';
  303. // 百度特有
  304. const ON_INIT = 'onInit';
  305. // 微信特有
  306. const ON_SAVE_EXIT_STATE = 'onSaveExitState';
  307. const ON_RESIZE = 'onResize';
  308. const ON_BACK_PRESS = 'onBackPress';
  309. const ON_PAGE_SCROLL = 'onPageScroll';
  310. const ON_TAB_ITEM_TAP = 'onTabItemTap';
  311. const ON_REACH_BOTTOM = 'onReachBottom';
  312. const ON_PULL_DOWN_REFRESH = 'onPullDownRefresh';
  313. const ON_SHARE_TIMELINE = 'onShareTimeline';
  314. const ON_ADD_TO_FAVORITES = 'onAddToFavorites';
  315. const ON_SHARE_APP_MESSAGE = 'onShareAppMessage';
  316. // navigationBar
  317. const ON_NAVIGATION_BAR_BUTTON_TAP = 'onNavigationBarButtonTap';
  318. const ON_NAVIGATION_BAR_CHANGE = 'onNavigationBarChange';
  319. const ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED = 'onNavigationBarSearchInputClicked';
  320. const ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED = 'onNavigationBarSearchInputChanged';
  321. const ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED = 'onNavigationBarSearchInputConfirmed';
  322. const ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = 'onNavigationBarSearchInputFocusChanged';
  323. // framework
  324. const ON_APP_ENTER_FOREGROUND = 'onAppEnterForeground';
  325. const ON_APP_ENTER_BACKGROUND = 'onAppEnterBackground';
  326. const ON_WEB_INVOKE_APP_SERVICE = 'onWebInvokeAppService';
  327. const ON_WXS_INVOKE_CALL_METHOD = 'onWxsInvokeCallMethod';
  328. function isComponentInternalInstance(vm) {
  329. return !!vm.appContext;
  330. }
  331. function resolveComponentInstance(instance) {
  332. return (instance &&
  333. (isComponentInternalInstance(instance) ? instance.proxy : instance));
  334. }
  335. function resolveOwnerVm(vm) {
  336. if (!vm) {
  337. return;
  338. }
  339. let componentName = vm.type.name;
  340. while (componentName && isBuiltInComponent(shared.hyphenate(componentName))) {
  341. // ownerInstance 内置组件需要使用父 vm
  342. vm = vm.parent;
  343. componentName = vm.type.name;
  344. }
  345. return vm.proxy;
  346. }
  347. function isElement(el) {
  348. // Element
  349. return el.nodeType === 1;
  350. }
  351. function resolveOwnerEl(instance, multi = false) {
  352. const { vnode } = instance;
  353. if (isElement(vnode.el)) {
  354. return multi ? (vnode.el ? [vnode.el] : []) : vnode.el;
  355. }
  356. const { subTree } = instance;
  357. // ShapeFlags.ARRAY_CHILDREN = 1<<4
  358. if (subTree.shapeFlag & 16) {
  359. const elemVNodes = subTree.children.filter((vnode) => vnode.el && isElement(vnode.el));
  360. if (elemVNodes.length > 0) {
  361. if (multi) {
  362. return elemVNodes.map((node) => node.el);
  363. }
  364. return elemVNodes[0].el;
  365. }
  366. }
  367. return multi ? (vnode.el ? [vnode.el] : []) : vnode.el;
  368. }
  369. function dynamicSlotName(name) {
  370. return name === 'default' ? SLOT_DEFAULT_NAME : name;
  371. }
  372. const customizeRE = /:/g;
  373. function customizeEvent(str) {
  374. return shared.camelize(str.replace(customizeRE, '-'));
  375. }
  376. function normalizeStyle(value) {
  377. if (value instanceof Map) {
  378. const styleObject = {};
  379. value.forEach((value, key) => {
  380. styleObject[key] = value;
  381. });
  382. return shared.normalizeStyle(styleObject);
  383. }
  384. else if (shared.isArray(value)) {
  385. const res = {};
  386. for (let i = 0; i < value.length; i++) {
  387. const item = value[i];
  388. const normalized = shared.isString(item)
  389. ? shared.parseStringStyle(item)
  390. : normalizeStyle(item);
  391. if (normalized) {
  392. for (const key in normalized) {
  393. res[key] = normalized[key];
  394. }
  395. }
  396. }
  397. return res;
  398. }
  399. else {
  400. return shared.normalizeStyle(value);
  401. }
  402. }
  403. function normalizeClass(value) {
  404. let res = '';
  405. if (value instanceof Map) {
  406. value.forEach((value, key) => {
  407. if (value) {
  408. res += key + ' ';
  409. }
  410. });
  411. }
  412. else if (shared.isArray(value)) {
  413. for (let i = 0; i < value.length; i++) {
  414. const normalized = normalizeClass(value[i]);
  415. if (normalized) {
  416. res += normalized + ' ';
  417. }
  418. }
  419. }
  420. else {
  421. res = shared.normalizeClass(value);
  422. }
  423. return res.trim();
  424. }
  425. function normalizeProps(props) {
  426. if (!props)
  427. return null;
  428. let { class: klass, style } = props;
  429. if (klass && !shared.isString(klass)) {
  430. props.class = normalizeClass(klass);
  431. }
  432. if (style) {
  433. props.style = normalizeStyle(style);
  434. }
  435. return props;
  436. }
  437. let lastLogTime = 0;
  438. function formatLog(module, ...args) {
  439. const now = Date.now();
  440. const diff = lastLogTime ? now - lastLogTime : 0;
  441. lastLogTime = now;
  442. return `[${now}][${diff}ms][${module}]:${args
  443. .map((arg) => JSON.stringify(arg))
  444. .join(' ')}`;
  445. }
  446. function cache(fn) {
  447. const cache = Object.create(null);
  448. return (str) => {
  449. const hit = cache[str];
  450. return hit || (cache[str] = fn(str));
  451. };
  452. }
  453. function cacheStringFunction(fn) {
  454. return cache(fn);
  455. }
  456. function getLen(str = '') {
  457. return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
  458. }
  459. function hasLeadingSlash(str) {
  460. return str.indexOf('/') === 0;
  461. }
  462. function addLeadingSlash(str) {
  463. return hasLeadingSlash(str) ? str : '/' + str;
  464. }
  465. function removeLeadingSlash(str) {
  466. return hasLeadingSlash(str) ? str.slice(1) : str;
  467. }
  468. const invokeArrayFns = (fns, arg) => {
  469. let ret;
  470. for (let i = 0; i < fns.length; i++) {
  471. ret = fns[i](arg);
  472. }
  473. return ret;
  474. };
  475. function updateElementStyle(element, styles) {
  476. for (const attrName in styles) {
  477. element.style[attrName] = styles[attrName];
  478. }
  479. }
  480. function once(fn, ctx = null) {
  481. let res;
  482. return ((...args) => {
  483. if (fn) {
  484. res = fn.apply(ctx, args);
  485. fn = null;
  486. }
  487. return res;
  488. });
  489. }
  490. const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
  491. const _completeValue = (value) => (value > 9 ? value : '0' + value);
  492. function formatDateTime({ date = new Date(), mode = 'date' }) {
  493. if (mode === 'time') {
  494. return (_completeValue(date.getHours()) + ':' + _completeValue(date.getMinutes()));
  495. }
  496. else {
  497. return (date.getFullYear() +
  498. '-' +
  499. _completeValue(date.getMonth() + 1) +
  500. '-' +
  501. _completeValue(date.getDate()));
  502. }
  503. }
  504. function callOptions(options, data) {
  505. options = options || {};
  506. if (shared.isString(data)) {
  507. data = {
  508. errMsg: data,
  509. };
  510. }
  511. if (/:ok$/.test(data.errMsg)) {
  512. if (shared.isFunction(options.success)) {
  513. options.success(data);
  514. }
  515. }
  516. else {
  517. if (shared.isFunction(options.fail)) {
  518. options.fail(data);
  519. }
  520. }
  521. if (shared.isFunction(options.complete)) {
  522. options.complete(data);
  523. }
  524. }
  525. function getValueByDataPath(obj, path) {
  526. if (!shared.isString(path)) {
  527. return;
  528. }
  529. path = path.replace(/\[(\d+)\]/g, '.$1');
  530. const parts = path.split('.');
  531. let key = parts[0];
  532. if (!obj) {
  533. obj = {};
  534. }
  535. if (parts.length === 1) {
  536. return obj[key];
  537. }
  538. return getValueByDataPath(obj[key], parts.slice(1).join('.'));
  539. }
  540. function sortObject(obj) {
  541. let sortObj = {};
  542. if (shared.isPlainObject(obj)) {
  543. Object.keys(obj)
  544. .sort()
  545. .forEach((key) => {
  546. const _key = key;
  547. sortObj[_key] = obj[_key];
  548. });
  549. }
  550. return !Object.keys(sortObj) ? obj : sortObj;
  551. }
  552. function formatKey(key) {
  553. return shared.camelize(key.substring(5));
  554. }
  555. // question/139181,增加副作用,避免 initCustomDataset 在 build 下被 tree-shaking
  556. const initCustomDatasetOnce = /*#__PURE__*/ once(() => {
  557. const prototype = HTMLElement.prototype;
  558. const setAttribute = prototype.setAttribute;
  559. prototype.setAttribute = function (key, value) {
  560. if (key.startsWith('data-') && this.tagName.startsWith('UNI-')) {
  561. const dataset = this.__uniDataset ||
  562. (this.__uniDataset = {});
  563. dataset[formatKey(key)] = value;
  564. }
  565. setAttribute.call(this, key, value);
  566. };
  567. const removeAttribute = prototype.removeAttribute;
  568. prototype.removeAttribute = function (key) {
  569. if (this.__uniDataset &&
  570. key.startsWith('data-') &&
  571. this.tagName.startsWith('UNI-')) {
  572. delete this.__uniDataset[formatKey(key)];
  573. }
  574. removeAttribute.call(this, key);
  575. };
  576. });
  577. function getCustomDataset(el) {
  578. return shared.extend({}, el.dataset, el.__uniDataset);
  579. }
  580. const unitRE = new RegExp(`"[^"]+"|'[^']+'|url\\([^)]+\\)|(\\d*\\.?\\d+)[r|u]px`, 'g');
  581. function toFixed(number, precision) {
  582. const multiplier = Math.pow(10, precision + 1);
  583. const wholeNumber = Math.floor(number * multiplier);
  584. return (Math.round(wholeNumber / 10) * 10) / multiplier;
  585. }
  586. const defaultRpx2Unit = {
  587. unit: 'rem',
  588. unitRatio: 10 / 320,
  589. unitPrecision: 5,
  590. };
  591. const defaultMiniProgramRpx2Unit = {
  592. unit: 'rpx',
  593. unitRatio: 1,
  594. unitPrecision: 1,
  595. };
  596. const defaultNVueRpx2Unit = defaultMiniProgramRpx2Unit;
  597. function createRpx2Unit(unit, unitRatio, unitPrecision) {
  598. // ignore: rpxCalcIncludeWidth
  599. return (val) => val.replace(unitRE, (m, $1) => {
  600. if (!$1) {
  601. return m;
  602. }
  603. if (unitRatio === 1) {
  604. return `${$1}${unit}`;
  605. }
  606. const value = toFixed(parseFloat($1) * unitRatio, unitPrecision);
  607. return value === 0 ? '0' : `${value}${unit}`;
  608. });
  609. }
  610. function passive(passive) {
  611. return { passive };
  612. }
  613. function normalizeDataset(el) {
  614. // TODO
  615. return JSON.parse(JSON.stringify(el.dataset || {}));
  616. }
  617. function normalizeTarget(el) {
  618. const { id, offsetTop, offsetLeft } = el;
  619. return {
  620. id,
  621. dataset: getCustomDataset(el),
  622. offsetTop,
  623. offsetLeft,
  624. };
  625. }
  626. function addFont(family, source, desc) {
  627. const fonts = document.fonts;
  628. if (fonts) {
  629. const fontFace = new FontFace(family, source, desc);
  630. return fontFace.load().then(() => {
  631. fonts.add && fonts.add(fontFace);
  632. });
  633. }
  634. return new Promise((resolve) => {
  635. const style = document.createElement('style');
  636. const values = [];
  637. if (desc) {
  638. const { style, weight, stretch, unicodeRange, variant, featureSettings } = desc;
  639. style && values.push(`font-style:${style}`);
  640. weight && values.push(`font-weight:${weight}`);
  641. stretch && values.push(`font-stretch:${stretch}`);
  642. unicodeRange && values.push(`unicode-range:${unicodeRange}`);
  643. variant && values.push(`font-variant:${variant}`);
  644. featureSettings && values.push(`font-feature-settings:${featureSettings}`);
  645. }
  646. style.innerText = `@font-face{font-family:"${family}";src:${source};${values.join(';')}}`;
  647. document.head.appendChild(style);
  648. resolve();
  649. });
  650. }
  651. function scrollTo(scrollTop, duration, isH5) {
  652. if (shared.isString(scrollTop)) {
  653. const el = document.querySelector(scrollTop);
  654. if (el) {
  655. const { top } = el.getBoundingClientRect();
  656. scrollTop = top + window.pageYOffset;
  657. // 如果存在,减去 <uni-page-head> 高度
  658. const pageHeader = document.querySelector('uni-page-head');
  659. if (pageHeader) {
  660. scrollTop -= pageHeader.offsetHeight;
  661. }
  662. }
  663. }
  664. if (scrollTop < 0) {
  665. scrollTop = 0;
  666. }
  667. const documentElement = document.documentElement;
  668. const { clientHeight, scrollHeight } = documentElement;
  669. scrollTop = Math.min(scrollTop, scrollHeight - clientHeight);
  670. if (duration === 0) {
  671. // 部分浏览器(比如微信)中 scrollTop 的值需要通过 document.body 来控制
  672. documentElement.scrollTop = document.body.scrollTop = scrollTop;
  673. return;
  674. }
  675. if (window.scrollY === scrollTop) {
  676. return;
  677. }
  678. const scrollTo = (duration) => {
  679. if (duration <= 0) {
  680. window.scrollTo(0, scrollTop);
  681. return;
  682. }
  683. const distaince = scrollTop - window.scrollY;
  684. requestAnimationFrame(function () {
  685. window.scrollTo(0, window.scrollY + (distaince / duration) * 10);
  686. scrollTo(duration - 10);
  687. });
  688. };
  689. scrollTo(duration);
  690. }
  691. const encode = encodeURIComponent;
  692. function stringifyQuery(obj, encodeStr = encode) {
  693. const res = obj
  694. ? Object.keys(obj)
  695. .map((key) => {
  696. let val = obj[key];
  697. if (typeof val === undefined || val === null) {
  698. val = '';
  699. }
  700. else if (shared.isPlainObject(val)) {
  701. val = JSON.stringify(val);
  702. }
  703. return encodeStr(key) + '=' + encodeStr(val);
  704. })
  705. .filter((x) => x.length > 0)
  706. .join('&')
  707. : null;
  708. return res ? `?${res}` : '';
  709. }
  710. /**
  711. * Decode text using `decodeURIComponent`. Returns the original text if it
  712. * fails.
  713. *
  714. * @param text - string to decode
  715. * @returns decoded string
  716. */
  717. function decode(text) {
  718. try {
  719. return decodeURIComponent('' + text);
  720. }
  721. catch (err) { }
  722. return '' + text;
  723. }
  724. function decodedQuery(query = {}) {
  725. const decodedQuery = {};
  726. Object.keys(query).forEach((name) => {
  727. try {
  728. decodedQuery[name] = decode(query[name]);
  729. }
  730. catch (e) {
  731. decodedQuery[name] = query[name];
  732. }
  733. });
  734. return decodedQuery;
  735. }
  736. const PLUS_RE = /\+/g; // %2B
  737. /**
  738. * https://github.com/vuejs/vue-router-next/blob/master/src/query.ts
  739. * @internal
  740. *
  741. * @param search - search string to parse
  742. * @returns a query object
  743. */
  744. function parseQuery(search) {
  745. const query = {};
  746. // avoid creating an object with an empty key and empty value
  747. // because of split('&')
  748. if (search === '' || search === '?')
  749. return query;
  750. const hasLeadingIM = search[0] === '?';
  751. const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&');
  752. for (let i = 0; i < searchParams.length; ++i) {
  753. // pre decode the + into space
  754. const searchParam = searchParams[i].replace(PLUS_RE, ' ');
  755. // allow the = character
  756. let eqPos = searchParam.indexOf('=');
  757. let key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
  758. let value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
  759. if (key in query) {
  760. // an extra variable for ts types
  761. let currentValue = query[key];
  762. if (!shared.isArray(currentValue)) {
  763. currentValue = query[key] = [currentValue];
  764. }
  765. currentValue.push(value);
  766. }
  767. else {
  768. query[key] = value;
  769. }
  770. }
  771. return query;
  772. }
  773. function parseUrl(url) {
  774. const [path, querystring] = url.split('?', 2);
  775. return {
  776. path,
  777. query: parseQuery(querystring || ''),
  778. };
  779. }
  780. function parseNVueDataset(attr) {
  781. const dataset = {};
  782. if (attr) {
  783. Object.keys(attr).forEach((key) => {
  784. if (key.indexOf('data-') === 0) {
  785. dataset[key.replace('data-', '')] = attr[key];
  786. }
  787. });
  788. }
  789. return dataset;
  790. }
  791. function plusReady(callback) {
  792. if (!shared.isFunction(callback)) {
  793. return;
  794. }
  795. if (window.plus) {
  796. return callback();
  797. }
  798. document.addEventListener('plusready', callback);
  799. }
  800. class DOMException extends Error {
  801. constructor(message) {
  802. super(message);
  803. this.name = 'DOMException';
  804. }
  805. }
  806. function normalizeEventType(type, options) {
  807. if (options) {
  808. if (options.capture) {
  809. type += 'Capture';
  810. }
  811. if (options.once) {
  812. type += 'Once';
  813. }
  814. if (options.passive) {
  815. type += 'Passive';
  816. }
  817. }
  818. return `on${shared.capitalize(shared.camelize(type))}`;
  819. }
  820. class UniEvent {
  821. constructor(type, opts) {
  822. this.defaultPrevented = false;
  823. this.timeStamp = Date.now();
  824. this._stop = false;
  825. this._end = false;
  826. this.type = type;
  827. this.bubbles = !!opts.bubbles;
  828. this.cancelable = !!opts.cancelable;
  829. }
  830. preventDefault() {
  831. this.defaultPrevented = true;
  832. }
  833. stopImmediatePropagation() {
  834. this._end = this._stop = true;
  835. }
  836. stopPropagation() {
  837. this._stop = true;
  838. }
  839. }
  840. function createUniEvent(evt) {
  841. if (evt instanceof UniEvent) {
  842. return evt;
  843. }
  844. const [type] = parseEventName(evt.type);
  845. const uniEvent = new UniEvent(type, {
  846. bubbles: false,
  847. cancelable: false,
  848. });
  849. shared.extend(uniEvent, evt);
  850. return uniEvent;
  851. }
  852. class UniEventTarget {
  853. constructor() {
  854. this.listeners = Object.create(null);
  855. }
  856. dispatchEvent(evt) {
  857. const listeners = this.listeners[evt.type];
  858. if (!listeners) {
  859. if ((process.env.NODE_ENV !== 'production')) {
  860. console.error(formatLog('dispatchEvent', this.nodeId), evt.type, 'not found');
  861. }
  862. return false;
  863. }
  864. // 格式化事件类型
  865. const event = createUniEvent(evt);
  866. const len = listeners.length;
  867. for (let i = 0; i < len; i++) {
  868. listeners[i].call(this, event);
  869. if (event._end) {
  870. break;
  871. }
  872. }
  873. return event.cancelable && event.defaultPrevented;
  874. }
  875. addEventListener(type, listener, options) {
  876. type = normalizeEventType(type, options);
  877. (this.listeners[type] || (this.listeners[type] = [])).push(listener);
  878. }
  879. removeEventListener(type, callback, options) {
  880. type = normalizeEventType(type, options);
  881. const listeners = this.listeners[type];
  882. if (!listeners) {
  883. return;
  884. }
  885. const index = listeners.indexOf(callback);
  886. if (index > -1) {
  887. listeners.splice(index, 1);
  888. }
  889. }
  890. }
  891. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  892. function parseEventName(name) {
  893. let options;
  894. if (optionsModifierRE.test(name)) {
  895. options = {};
  896. let m;
  897. while ((m = name.match(optionsModifierRE))) {
  898. name = name.slice(0, name.length - m[0].length);
  899. options[m[0].toLowerCase()] = true;
  900. }
  901. }
  902. return [shared.hyphenate(name.slice(2)), options];
  903. }
  904. const EventModifierFlags = /*#__PURE__*/ (() => {
  905. return {
  906. stop: 1,
  907. prevent: 1 << 1,
  908. self: 1 << 2,
  909. };
  910. })();
  911. function encodeModifier(modifiers) {
  912. let flag = 0;
  913. if (modifiers.includes('stop')) {
  914. flag |= EventModifierFlags.stop;
  915. }
  916. if (modifiers.includes('prevent')) {
  917. flag |= EventModifierFlags.prevent;
  918. }
  919. if (modifiers.includes('self')) {
  920. flag |= EventModifierFlags.self;
  921. }
  922. return flag;
  923. }
  924. const NODE_TYPE_PAGE = 0;
  925. const NODE_TYPE_ELEMENT = 1;
  926. const NODE_TYPE_TEXT = 3;
  927. const NODE_TYPE_COMMENT = 8;
  928. function sibling(node, type) {
  929. const { parentNode } = node;
  930. if (!parentNode) {
  931. return null;
  932. }
  933. const { childNodes } = parentNode;
  934. return childNodes[childNodes.indexOf(node) + (type === 'n' ? 1 : -1)] || null;
  935. }
  936. function removeNode(node) {
  937. const { parentNode } = node;
  938. if (parentNode) {
  939. const { childNodes } = parentNode;
  940. const index = childNodes.indexOf(node);
  941. if (index > -1) {
  942. node.parentNode = null;
  943. childNodes.splice(index, 1);
  944. }
  945. }
  946. }
  947. function checkNodeId(node) {
  948. if (!node.nodeId && node.pageNode) {
  949. node.nodeId = node.pageNode.genId();
  950. }
  951. }
  952. // 为优化性能,各平台不使用proxy来实现node的操作拦截,而是直接通过pageNode定制
  953. class UniNode extends UniEventTarget {
  954. constructor(nodeType, nodeName, container) {
  955. super();
  956. this.pageNode = null;
  957. this.parentNode = null;
  958. this._text = null;
  959. if (container) {
  960. const { pageNode } = container;
  961. if (pageNode) {
  962. this.pageNode = pageNode;
  963. this.nodeId = pageNode.genId();
  964. !pageNode.isUnmounted && pageNode.onCreate(this, nodeName);
  965. }
  966. }
  967. this.nodeType = nodeType;
  968. this.nodeName = nodeName;
  969. this.childNodes = [];
  970. }
  971. get firstChild() {
  972. return this.childNodes[0] || null;
  973. }
  974. get lastChild() {
  975. const { childNodes } = this;
  976. const length = childNodes.length;
  977. return length ? childNodes[length - 1] : null;
  978. }
  979. get nextSibling() {
  980. return sibling(this, 'n');
  981. }
  982. get nodeValue() {
  983. return null;
  984. }
  985. set nodeValue(_val) { }
  986. get textContent() {
  987. return this._text || '';
  988. }
  989. set textContent(text) {
  990. this._text = text;
  991. if (this.pageNode && !this.pageNode.isUnmounted) {
  992. this.pageNode.onTextContent(this, text);
  993. }
  994. }
  995. get parentElement() {
  996. const { parentNode } = this;
  997. if (parentNode && parentNode.nodeType === NODE_TYPE_ELEMENT) {
  998. return parentNode;
  999. }
  1000. return null;
  1001. }
  1002. get previousSibling() {
  1003. return sibling(this, 'p');
  1004. }
  1005. appendChild(newChild) {
  1006. return this.insertBefore(newChild, null);
  1007. }
  1008. cloneNode(deep) {
  1009. const cloned = shared.extend(Object.create(Object.getPrototypeOf(this)), this);
  1010. const { attributes } = cloned;
  1011. if (attributes) {
  1012. cloned.attributes = shared.extend({}, attributes);
  1013. }
  1014. if (deep) {
  1015. cloned.childNodes = cloned.childNodes.map((childNode) => childNode.cloneNode(true));
  1016. }
  1017. return cloned;
  1018. }
  1019. insertBefore(newChild, refChild) {
  1020. // 先从现在的父节点移除(注意:不能触发onRemoveChild,否则会生成先remove该 id,再 insert)
  1021. removeNode(newChild);
  1022. newChild.pageNode = this.pageNode;
  1023. newChild.parentNode = this;
  1024. checkNodeId(newChild);
  1025. const { childNodes } = this;
  1026. if (refChild) {
  1027. const index = childNodes.indexOf(refChild);
  1028. if (index === -1) {
  1029. throw new DOMException(`Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`);
  1030. }
  1031. childNodes.splice(index, 0, newChild);
  1032. }
  1033. else {
  1034. childNodes.push(newChild);
  1035. }
  1036. return this.pageNode && !this.pageNode.isUnmounted
  1037. ? this.pageNode.onInsertBefore(this, newChild, refChild)
  1038. : newChild;
  1039. }
  1040. removeChild(oldChild) {
  1041. const { childNodes } = this;
  1042. const index = childNodes.indexOf(oldChild);
  1043. if (index === -1) {
  1044. throw new DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`);
  1045. }
  1046. oldChild.parentNode = null;
  1047. childNodes.splice(index, 1);
  1048. return this.pageNode && !this.pageNode.isUnmounted
  1049. ? this.pageNode.onRemoveChild(oldChild)
  1050. : oldChild;
  1051. }
  1052. }
  1053. const ATTR_CLASS = 'class';
  1054. const ATTR_STYLE = 'style';
  1055. const ATTR_INNER_HTML = 'innerHTML';
  1056. const ATTR_TEXT_CONTENT = 'textContent';
  1057. const ATTR_V_SHOW = '.vShow';
  1058. const ATTR_V_OWNER_ID = '.vOwnerId';
  1059. const ATTR_V_RENDERJS = '.vRenderjs';
  1060. const ATTR_CHANGE_PREFIX = 'change:';
  1061. class UniBaseNode extends UniNode {
  1062. constructor(nodeType, nodeName, container) {
  1063. super(nodeType, nodeName, container);
  1064. this.attributes = Object.create(null);
  1065. this.style = null;
  1066. this.vShow = null;
  1067. this._html = null;
  1068. }
  1069. get className() {
  1070. return (this.attributes[ATTR_CLASS] || '');
  1071. }
  1072. set className(val) {
  1073. this.setAttribute(ATTR_CLASS, val);
  1074. }
  1075. get innerHTML() {
  1076. return '';
  1077. }
  1078. set innerHTML(html) {
  1079. this._html = html;
  1080. }
  1081. addEventListener(type, listener, options) {
  1082. super.addEventListener(type, listener, options);
  1083. if (this.pageNode && !this.pageNode.isUnmounted) {
  1084. if (listener.wxsEvent) {
  1085. this.pageNode.onAddWxsEvent(this, normalizeEventType(type, options), listener.wxsEvent, encodeModifier(listener.modifiers || []));
  1086. }
  1087. else {
  1088. this.pageNode.onAddEvent(this, normalizeEventType(type, options), encodeModifier(listener.modifiers || []));
  1089. }
  1090. }
  1091. }
  1092. removeEventListener(type, callback, options) {
  1093. super.removeEventListener(type, callback, options);
  1094. if (this.pageNode && !this.pageNode.isUnmounted) {
  1095. this.pageNode.onRemoveEvent(this, normalizeEventType(type, options));
  1096. }
  1097. }
  1098. getAttribute(qualifiedName) {
  1099. if (qualifiedName === ATTR_STYLE) {
  1100. return this.style;
  1101. }
  1102. return this.attributes[qualifiedName];
  1103. }
  1104. removeAttribute(qualifiedName) {
  1105. if (qualifiedName == ATTR_STYLE) {
  1106. this.style = null;
  1107. }
  1108. else {
  1109. delete this.attributes[qualifiedName];
  1110. }
  1111. if (this.pageNode && !this.pageNode.isUnmounted) {
  1112. this.pageNode.onRemoveAttribute(this, qualifiedName);
  1113. }
  1114. }
  1115. setAttribute(qualifiedName, value) {
  1116. if (qualifiedName === ATTR_STYLE) {
  1117. this.style = value;
  1118. }
  1119. else {
  1120. this.attributes[qualifiedName] = value;
  1121. }
  1122. if (this.pageNode && !this.pageNode.isUnmounted) {
  1123. this.pageNode.onSetAttribute(this, qualifiedName, value);
  1124. }
  1125. }
  1126. toJSON({ attr, normalize, } = {}) {
  1127. const { attributes, style, listeners, _text } = this;
  1128. const res = {};
  1129. if (Object.keys(attributes).length) {
  1130. res.a = normalize ? normalize(attributes) : attributes;
  1131. }
  1132. const events = Object.keys(listeners);
  1133. if (events.length) {
  1134. let w = undefined;
  1135. const e = {};
  1136. events.forEach((name) => {
  1137. const handlers = listeners[name];
  1138. if (handlers.length) {
  1139. // 可能存在多个 handler 且不同 modifiers 吗?
  1140. const { wxsEvent, modifiers } = handlers[0];
  1141. const modifier = encodeModifier(modifiers || []);
  1142. if (!wxsEvent) {
  1143. e[name] = modifier;
  1144. }
  1145. else {
  1146. if (!w) {
  1147. w = {};
  1148. }
  1149. w[name] = [normalize ? normalize(wxsEvent) : wxsEvent, modifier];
  1150. }
  1151. }
  1152. });
  1153. res.e = normalize ? normalize(e, false) : e;
  1154. if (w) {
  1155. res.w = normalize ? normalize(w, false) : w;
  1156. }
  1157. }
  1158. if (style !== null) {
  1159. res.s = normalize ? normalize(style) : style;
  1160. }
  1161. if (!attr) {
  1162. res.i = this.nodeId;
  1163. res.n = this.nodeName;
  1164. }
  1165. if (_text !== null) {
  1166. res.t = normalize ? normalize(_text) : _text;
  1167. }
  1168. return res;
  1169. }
  1170. }
  1171. class UniCommentNode extends UniNode {
  1172. constructor(text, container) {
  1173. super(NODE_TYPE_COMMENT, '#comment', container);
  1174. this._text = (process.env.NODE_ENV !== 'production') ? text : '';
  1175. }
  1176. toJSON(opts = {}) {
  1177. // 暂时不传递 text 到 view 层,没啥意义,节省点数据量
  1178. return opts.attr
  1179. ? {}
  1180. : {
  1181. i: this.nodeId,
  1182. };
  1183. // return opts.attr
  1184. // ? { t: this._text as string }
  1185. // : {
  1186. // i: this.nodeId!,
  1187. // t: this._text as string,
  1188. // }
  1189. }
  1190. }
  1191. class UniElement extends UniBaseNode {
  1192. constructor(nodeName, container) {
  1193. super(NODE_TYPE_ELEMENT, nodeName.toUpperCase(), container);
  1194. this.tagName = this.nodeName;
  1195. }
  1196. }
  1197. class UniInputElement extends UniElement {
  1198. get value() {
  1199. return this.getAttribute('value');
  1200. }
  1201. set value(val) {
  1202. this.setAttribute('value', val);
  1203. }
  1204. }
  1205. class UniTextAreaElement extends UniInputElement {
  1206. }
  1207. class UniTextNode extends UniBaseNode {
  1208. constructor(text, container) {
  1209. super(NODE_TYPE_TEXT, '#text', container);
  1210. this._text = text;
  1211. }
  1212. get nodeValue() {
  1213. return this._text || '';
  1214. }
  1215. set nodeValue(text) {
  1216. this._text = text;
  1217. if (this.pageNode && !this.pageNode.isUnmounted) {
  1218. this.pageNode.onNodeValue(this, text);
  1219. }
  1220. }
  1221. }
  1222. const forcePatchProps = {
  1223. AD: ['data'],
  1224. 'AD-DRAW': ['data'],
  1225. 'LIVE-PLAYER': ['picture-in-picture-mode'],
  1226. MAP: [
  1227. 'markers',
  1228. 'polyline',
  1229. 'circles',
  1230. 'controls',
  1231. 'include-points',
  1232. 'polygons',
  1233. ],
  1234. PICKER: ['range', 'value'],
  1235. 'PICKER-VIEW': ['value'],
  1236. 'RICH-TEXT': ['nodes'],
  1237. VIDEO: ['danmu-list', 'header'],
  1238. 'WEB-VIEW': ['webview-styles'],
  1239. };
  1240. const forcePatchPropKeys = ['animation'];
  1241. const forcePatchProp = (el, key) => {
  1242. if (forcePatchPropKeys.indexOf(key) > -1) {
  1243. return true;
  1244. }
  1245. const keys = forcePatchProps[el.nodeName];
  1246. if (keys && keys.indexOf(key) > -1) {
  1247. return true;
  1248. }
  1249. return false;
  1250. };
  1251. const ACTION_TYPE_PAGE_CREATE = 1;
  1252. const ACTION_TYPE_PAGE_CREATED = 2;
  1253. const ACTION_TYPE_CREATE = 3;
  1254. const ACTION_TYPE_INSERT = 4;
  1255. const ACTION_TYPE_REMOVE = 5;
  1256. const ACTION_TYPE_SET_ATTRIBUTE = 6;
  1257. const ACTION_TYPE_REMOVE_ATTRIBUTE = 7;
  1258. const ACTION_TYPE_ADD_EVENT = 8;
  1259. const ACTION_TYPE_REMOVE_EVENT = 9;
  1260. const ACTION_TYPE_SET_TEXT = 10;
  1261. const ACTION_TYPE_ADD_WXS_EVENT = 12;
  1262. const ACTION_TYPE_PAGE_SCROLL = 15;
  1263. const ACTION_TYPE_EVENT = 20;
  1264. /**
  1265. * 需要手动传入 timer,主要是解决 App 平台的定制 timer
  1266. */
  1267. function debounce(fn, delay, { clearTimeout, setTimeout }) {
  1268. let timeout;
  1269. const newFn = function () {
  1270. clearTimeout(timeout);
  1271. const timerFn = () => fn.apply(this, arguments);
  1272. timeout = setTimeout(timerFn, delay);
  1273. };
  1274. newFn.cancel = function () {
  1275. clearTimeout(timeout);
  1276. };
  1277. return newFn;
  1278. }
  1279. class EventChannel {
  1280. constructor(id, events) {
  1281. this.id = id;
  1282. this.listener = {};
  1283. this.emitCache = [];
  1284. if (events) {
  1285. Object.keys(events).forEach((name) => {
  1286. this.on(name, events[name]);
  1287. });
  1288. }
  1289. }
  1290. emit(eventName, ...args) {
  1291. const fns = this.listener[eventName];
  1292. if (!fns) {
  1293. return this.emitCache.push({
  1294. eventName,
  1295. args,
  1296. });
  1297. }
  1298. fns.forEach((opt) => {
  1299. opt.fn.apply(opt.fn, args);
  1300. });
  1301. this.listener[eventName] = fns.filter((opt) => opt.type !== 'once');
  1302. }
  1303. on(eventName, fn) {
  1304. this._addListener(eventName, 'on', fn);
  1305. this._clearCache(eventName);
  1306. }
  1307. once(eventName, fn) {
  1308. this._addListener(eventName, 'once', fn);
  1309. this._clearCache(eventName);
  1310. }
  1311. off(eventName, fn) {
  1312. const fns = this.listener[eventName];
  1313. if (!fns) {
  1314. return;
  1315. }
  1316. if (fn) {
  1317. for (let i = 0; i < fns.length;) {
  1318. if (fns[i].fn === fn) {
  1319. fns.splice(i, 1);
  1320. i--;
  1321. }
  1322. i++;
  1323. }
  1324. }
  1325. else {
  1326. delete this.listener[eventName];
  1327. }
  1328. }
  1329. _clearCache(eventName) {
  1330. for (let index = 0; index < this.emitCache.length; index++) {
  1331. const cache = this.emitCache[index];
  1332. const _name = eventName
  1333. ? cache.eventName === eventName
  1334. ? eventName
  1335. : null
  1336. : cache.eventName;
  1337. if (!_name)
  1338. continue;
  1339. const location = this.emit.apply(this, [_name, ...cache.args]);
  1340. if (typeof location === 'number') {
  1341. this.emitCache.pop();
  1342. continue;
  1343. }
  1344. this.emitCache.splice(index, 1);
  1345. index--;
  1346. }
  1347. }
  1348. _addListener(eventName, type, fn) {
  1349. (this.listener[eventName] || (this.listener[eventName] = [])).push({
  1350. fn,
  1351. type,
  1352. });
  1353. }
  1354. }
  1355. const PAGE_HOOKS = [
  1356. ON_INIT,
  1357. ON_LOAD,
  1358. ON_SHOW,
  1359. ON_HIDE,
  1360. ON_UNLOAD,
  1361. ON_BACK_PRESS,
  1362. ON_PAGE_SCROLL,
  1363. ON_TAB_ITEM_TAP,
  1364. ON_REACH_BOTTOM,
  1365. ON_PULL_DOWN_REFRESH,
  1366. ON_SHARE_TIMELINE,
  1367. ON_SHARE_APP_MESSAGE,
  1368. ON_ADD_TO_FAVORITES,
  1369. ON_SAVE_EXIT_STATE,
  1370. ON_NAVIGATION_BAR_BUTTON_TAP,
  1371. ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED,
  1372. ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
  1373. ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
  1374. ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
  1375. ];
  1376. const PAGE_SYNC_HOOKS = [ON_LOAD, ON_SHOW];
  1377. function isRootImmediateHook(name) {
  1378. return PAGE_SYNC_HOOKS.indexOf(name) > -1;
  1379. }
  1380. function isRootHook(name) {
  1381. return PAGE_HOOKS.indexOf(name) > -1;
  1382. }
  1383. const UniLifecycleHooks = [
  1384. ON_SHOW,
  1385. ON_HIDE,
  1386. ON_LAUNCH,
  1387. ON_ERROR,
  1388. ON_THEME_CHANGE,
  1389. ON_PAGE_NOT_FOUND,
  1390. ON_UNHANDLE_REJECTION,
  1391. ON_EXIT,
  1392. ON_INIT,
  1393. ON_LOAD,
  1394. ON_READY,
  1395. ON_UNLOAD,
  1396. ON_RESIZE,
  1397. ON_BACK_PRESS,
  1398. ON_PAGE_SCROLL,
  1399. ON_TAB_ITEM_TAP,
  1400. ON_REACH_BOTTOM,
  1401. ON_PULL_DOWN_REFRESH,
  1402. ON_SHARE_TIMELINE,
  1403. ON_ADD_TO_FAVORITES,
  1404. ON_SHARE_APP_MESSAGE,
  1405. ON_SAVE_EXIT_STATE,
  1406. ON_NAVIGATION_BAR_BUTTON_TAP,
  1407. ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED,
  1408. ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
  1409. ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
  1410. ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
  1411. ];
  1412. const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = /*#__PURE__*/ (() => {
  1413. return {
  1414. onPageScroll: 1,
  1415. onShareAppMessage: 1 << 1,
  1416. onShareTimeline: 1 << 2,
  1417. };
  1418. })();
  1419. function isUniLifecycleHook(name, value, checkType = true) {
  1420. // 检查类型
  1421. if (checkType && !shared.isFunction(value)) {
  1422. return false;
  1423. }
  1424. if (UniLifecycleHooks.indexOf(name) > -1) {
  1425. // 已预定义
  1426. return true;
  1427. }
  1428. else if (name.indexOf('on') === 0) {
  1429. // 以 on 开头
  1430. return true;
  1431. }
  1432. return false;
  1433. }
  1434. let vueApp;
  1435. const createVueAppHooks = [];
  1436. /**
  1437. * 提供 createApp 的回调事件,方便三方插件接收 App 对象,处理挂靠全局 mixin 之类的逻辑
  1438. */
  1439. function onCreateVueApp(hook) {
  1440. // TODO 每个 nvue 页面都会触发
  1441. if (vueApp) {
  1442. return hook(vueApp);
  1443. }
  1444. createVueAppHooks.push(hook);
  1445. }
  1446. function invokeCreateVueAppHook(app) {
  1447. vueApp = app;
  1448. createVueAppHooks.forEach((hook) => hook(app));
  1449. }
  1450. const invokeCreateErrorHandler = once((app, createErrorHandler) => {
  1451. if (shared.isFunction(app._component.onError)) {
  1452. return createErrorHandler(app);
  1453. }
  1454. });
  1455. const E = function () {
  1456. // Keep this empty so it's easier to inherit from
  1457. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  1458. };
  1459. E.prototype = {
  1460. on: function (name, callback, ctx) {
  1461. var e = this.e || (this.e = {});
  1462. (e[name] || (e[name] = [])).push({
  1463. fn: callback,
  1464. ctx: ctx,
  1465. });
  1466. return this;
  1467. },
  1468. once: function (name, callback, ctx) {
  1469. var self = this;
  1470. function listener() {
  1471. self.off(name, listener);
  1472. callback.apply(ctx, arguments);
  1473. }
  1474. listener._ = callback;
  1475. return this.on(name, listener, ctx);
  1476. },
  1477. emit: function (name) {
  1478. var data = [].slice.call(arguments, 1);
  1479. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  1480. var i = 0;
  1481. var len = evtArr.length;
  1482. for (i; i < len; i++) {
  1483. evtArr[i].fn.apply(evtArr[i].ctx, data);
  1484. }
  1485. return this;
  1486. },
  1487. off: function (name, callback) {
  1488. var e = this.e || (this.e = {});
  1489. var evts = e[name];
  1490. var liveEvents = [];
  1491. if (evts && callback) {
  1492. for (var i = evts.length - 1; i >= 0; i--) {
  1493. if (evts[i].fn === callback || evts[i].fn._ === callback) {
  1494. evts.splice(i, 1);
  1495. break;
  1496. }
  1497. }
  1498. liveEvents = evts;
  1499. }
  1500. // Remove event from queue to prevent memory leak
  1501. // Suggested by https://github.com/lazd
  1502. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  1503. liveEvents.length ? (e[name] = liveEvents) : delete e[name];
  1504. return this;
  1505. },
  1506. };
  1507. var E$1 = E;
  1508. const borderStyles = {
  1509. black: 'rgba(0,0,0,0.4)',
  1510. white: 'rgba(255,255,255,0.4)',
  1511. };
  1512. function normalizeTabBarStyles(borderStyle) {
  1513. if (borderStyle && borderStyle in borderStyles) {
  1514. return borderStyles[borderStyle];
  1515. }
  1516. return borderStyle;
  1517. }
  1518. function normalizeTitleColor(titleColor) {
  1519. return titleColor === 'black' ? '#000000' : '#ffffff';
  1520. }
  1521. function normalizeStyles(pageStyle, themeConfig = {}, mode = 'light') {
  1522. const modeStyle = themeConfig[mode];
  1523. const styles = {};
  1524. if (!modeStyle) {
  1525. return pageStyle;
  1526. }
  1527. Object.keys(pageStyle).forEach((key) => {
  1528. let styleItem = pageStyle[key] // Object Array String
  1529. ;
  1530. styles[key] = (() => {
  1531. if (shared.isPlainObject(styleItem)) {
  1532. return normalizeStyles(styleItem, themeConfig, mode);
  1533. }
  1534. else if (shared.isArray(styleItem)) {
  1535. return styleItem.map((item) => shared.isPlainObject(item)
  1536. ? normalizeStyles(item, themeConfig, mode)
  1537. : item);
  1538. }
  1539. else if (shared.isString(styleItem) && styleItem.startsWith('@')) {
  1540. const _key = styleItem.replace('@', '');
  1541. let _styleItem = modeStyle[_key] || styleItem;
  1542. switch (key) {
  1543. case 'titleColor':
  1544. _styleItem = normalizeTitleColor(_styleItem);
  1545. break;
  1546. case 'borderStyle':
  1547. _styleItem = normalizeTabBarStyles(_styleItem);
  1548. break;
  1549. }
  1550. return _styleItem;
  1551. }
  1552. return styleItem;
  1553. })();
  1554. });
  1555. return styles;
  1556. }
  1557. function getEnvLocale() {
  1558. const { env } = process;
  1559. const lang = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE;
  1560. return (lang && lang.replace(/[.:].*/, '')) || 'en';
  1561. }
  1562. exports.ACTION_TYPE_ADD_EVENT = ACTION_TYPE_ADD_EVENT;
  1563. exports.ACTION_TYPE_ADD_WXS_EVENT = ACTION_TYPE_ADD_WXS_EVENT;
  1564. exports.ACTION_TYPE_CREATE = ACTION_TYPE_CREATE;
  1565. exports.ACTION_TYPE_EVENT = ACTION_TYPE_EVENT;
  1566. exports.ACTION_TYPE_INSERT = ACTION_TYPE_INSERT;
  1567. exports.ACTION_TYPE_PAGE_CREATE = ACTION_TYPE_PAGE_CREATE;
  1568. exports.ACTION_TYPE_PAGE_CREATED = ACTION_TYPE_PAGE_CREATED;
  1569. exports.ACTION_TYPE_PAGE_SCROLL = ACTION_TYPE_PAGE_SCROLL;
  1570. exports.ACTION_TYPE_REMOVE = ACTION_TYPE_REMOVE;
  1571. exports.ACTION_TYPE_REMOVE_ATTRIBUTE = ACTION_TYPE_REMOVE_ATTRIBUTE;
  1572. exports.ACTION_TYPE_REMOVE_EVENT = ACTION_TYPE_REMOVE_EVENT;
  1573. exports.ACTION_TYPE_SET_ATTRIBUTE = ACTION_TYPE_SET_ATTRIBUTE;
  1574. exports.ACTION_TYPE_SET_TEXT = ACTION_TYPE_SET_TEXT;
  1575. exports.ATTR_CHANGE_PREFIX = ATTR_CHANGE_PREFIX;
  1576. exports.ATTR_CLASS = ATTR_CLASS;
  1577. exports.ATTR_INNER_HTML = ATTR_INNER_HTML;
  1578. exports.ATTR_STYLE = ATTR_STYLE;
  1579. exports.ATTR_TEXT_CONTENT = ATTR_TEXT_CONTENT;
  1580. exports.ATTR_V_OWNER_ID = ATTR_V_OWNER_ID;
  1581. exports.ATTR_V_RENDERJS = ATTR_V_RENDERJS;
  1582. exports.ATTR_V_SHOW = ATTR_V_SHOW;
  1583. exports.BACKGROUND_COLOR = BACKGROUND_COLOR;
  1584. exports.BUILT_IN_TAGS = BUILT_IN_TAGS;
  1585. exports.BUILT_IN_TAG_NAMES = BUILT_IN_TAG_NAMES;
  1586. exports.COMPONENT_NAME_PREFIX = COMPONENT_NAME_PREFIX;
  1587. exports.COMPONENT_PREFIX = COMPONENT_PREFIX;
  1588. exports.COMPONENT_SELECTOR_PREFIX = COMPONENT_SELECTOR_PREFIX;
  1589. exports.DATA_RE = DATA_RE;
  1590. exports.Emitter = E$1;
  1591. exports.EventChannel = EventChannel;
  1592. exports.EventModifierFlags = EventModifierFlags;
  1593. exports.I18N_JSON_DELIMITERS = I18N_JSON_DELIMITERS;
  1594. exports.JSON_PROTOCOL = JSON_PROTOCOL;
  1595. exports.LINEFEED = LINEFEED;
  1596. exports.MINI_PROGRAM_PAGE_RUNTIME_HOOKS = MINI_PROGRAM_PAGE_RUNTIME_HOOKS;
  1597. exports.NAVBAR_HEIGHT = NAVBAR_HEIGHT;
  1598. exports.NODE_TYPE_COMMENT = NODE_TYPE_COMMENT;
  1599. exports.NODE_TYPE_ELEMENT = NODE_TYPE_ELEMENT;
  1600. exports.NODE_TYPE_PAGE = NODE_TYPE_PAGE;
  1601. exports.NODE_TYPE_TEXT = NODE_TYPE_TEXT;
  1602. exports.NVUE_BUILT_IN_TAGS = NVUE_BUILT_IN_TAGS;
  1603. exports.NVUE_U_BUILT_IN_TAGS = NVUE_U_BUILT_IN_TAGS;
  1604. exports.OFF_THEME_CHANGE = OFF_THEME_CHANGE;
  1605. exports.ON_ADD_TO_FAVORITES = ON_ADD_TO_FAVORITES;
  1606. exports.ON_APP_ENTER_BACKGROUND = ON_APP_ENTER_BACKGROUND;
  1607. exports.ON_APP_ENTER_FOREGROUND = ON_APP_ENTER_FOREGROUND;
  1608. exports.ON_BACK_PRESS = ON_BACK_PRESS;
  1609. exports.ON_ERROR = ON_ERROR;
  1610. exports.ON_EXIT = ON_EXIT;
  1611. exports.ON_HIDE = ON_HIDE;
  1612. exports.ON_INIT = ON_INIT;
  1613. exports.ON_KEYBOARD_HEIGHT_CHANGE = ON_KEYBOARD_HEIGHT_CHANGE;
  1614. exports.ON_LAUNCH = ON_LAUNCH;
  1615. exports.ON_LOAD = ON_LOAD;
  1616. exports.ON_NAVIGATION_BAR_BUTTON_TAP = ON_NAVIGATION_BAR_BUTTON_TAP;
  1617. exports.ON_NAVIGATION_BAR_CHANGE = ON_NAVIGATION_BAR_CHANGE;
  1618. exports.ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED = ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED;
  1619. exports.ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED = ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED;
  1620. exports.ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED = ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED;
  1621. exports.ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED;
  1622. exports.ON_PAGE_NOT_FOUND = ON_PAGE_NOT_FOUND;
  1623. exports.ON_PAGE_SCROLL = ON_PAGE_SCROLL;
  1624. exports.ON_PULL_DOWN_REFRESH = ON_PULL_DOWN_REFRESH;
  1625. exports.ON_REACH_BOTTOM = ON_REACH_BOTTOM;
  1626. exports.ON_REACH_BOTTOM_DISTANCE = ON_REACH_BOTTOM_DISTANCE;
  1627. exports.ON_READY = ON_READY;
  1628. exports.ON_RESIZE = ON_RESIZE;
  1629. exports.ON_SAVE_EXIT_STATE = ON_SAVE_EXIT_STATE;
  1630. exports.ON_SHARE_APP_MESSAGE = ON_SHARE_APP_MESSAGE;
  1631. exports.ON_SHARE_TIMELINE = ON_SHARE_TIMELINE;
  1632. exports.ON_SHOW = ON_SHOW;
  1633. exports.ON_TAB_ITEM_TAP = ON_TAB_ITEM_TAP;
  1634. exports.ON_THEME_CHANGE = ON_THEME_CHANGE;
  1635. exports.ON_UNHANDLE_REJECTION = ON_UNHANDLE_REJECTION;
  1636. exports.ON_UNLOAD = ON_UNLOAD;
  1637. exports.ON_WEB_INVOKE_APP_SERVICE = ON_WEB_INVOKE_APP_SERVICE;
  1638. exports.ON_WXS_INVOKE_CALL_METHOD = ON_WXS_INVOKE_CALL_METHOD;
  1639. exports.PLUS_RE = PLUS_RE;
  1640. exports.PRIMARY_COLOR = PRIMARY_COLOR;
  1641. exports.RENDERJS_MODULES = RENDERJS_MODULES;
  1642. exports.RESPONSIVE_MIN_WIDTH = RESPONSIVE_MIN_WIDTH;
  1643. exports.SCHEME_RE = SCHEME_RE;
  1644. exports.SELECTED_COLOR = SELECTED_COLOR;
  1645. exports.SLOT_DEFAULT_NAME = SLOT_DEFAULT_NAME;
  1646. exports.TABBAR_HEIGHT = TABBAR_HEIGHT;
  1647. exports.TAGS = TAGS;
  1648. exports.UNI_SSR = UNI_SSR;
  1649. exports.UNI_SSR_DATA = UNI_SSR_DATA;
  1650. exports.UNI_SSR_GLOBAL_DATA = UNI_SSR_GLOBAL_DATA;
  1651. exports.UNI_SSR_STORE = UNI_SSR_STORE;
  1652. exports.UNI_SSR_TITLE = UNI_SSR_TITLE;
  1653. exports.UNI_STORAGE_LOCALE = UNI_STORAGE_LOCALE;
  1654. exports.UNI_UI_CONFLICT_TAGS = UNI_UI_CONFLICT_TAGS;
  1655. exports.UVUE_BUILT_IN_TAGS = UVUE_BUILT_IN_TAGS;
  1656. exports.UVUE_IOS_BUILT_IN_TAGS = UVUE_IOS_BUILT_IN_TAGS;
  1657. exports.UVUE_WEB_BUILT_IN_TAGS = UVUE_WEB_BUILT_IN_TAGS;
  1658. exports.UniBaseNode = UniBaseNode;
  1659. exports.UniCommentNode = UniCommentNode;
  1660. exports.UniElement = UniElement;
  1661. exports.UniEvent = UniEvent;
  1662. exports.UniInputElement = UniInputElement;
  1663. exports.UniLifecycleHooks = UniLifecycleHooks;
  1664. exports.UniNode = UniNode;
  1665. exports.UniTextAreaElement = UniTextAreaElement;
  1666. exports.UniTextNode = UniTextNode;
  1667. exports.WEB_INVOKE_APPSERVICE = WEB_INVOKE_APPSERVICE;
  1668. exports.WXS_MODULES = WXS_MODULES;
  1669. exports.WXS_PROTOCOL = WXS_PROTOCOL;
  1670. exports.addFont = addFont;
  1671. exports.addLeadingSlash = addLeadingSlash;
  1672. exports.borderStyles = borderStyles;
  1673. exports.cache = cache;
  1674. exports.cacheStringFunction = cacheStringFunction;
  1675. exports.callOptions = callOptions;
  1676. exports.createIsCustomElement = createIsCustomElement;
  1677. exports.createRpx2Unit = createRpx2Unit;
  1678. exports.createUniEvent = createUniEvent;
  1679. exports.customizeEvent = customizeEvent;
  1680. exports.debounce = debounce;
  1681. exports.decode = decode;
  1682. exports.decodedQuery = decodedQuery;
  1683. exports.defaultMiniProgramRpx2Unit = defaultMiniProgramRpx2Unit;
  1684. exports.defaultNVueRpx2Unit = defaultNVueRpx2Unit;
  1685. exports.defaultRpx2Unit = defaultRpx2Unit;
  1686. exports.dynamicSlotName = dynamicSlotName;
  1687. exports.forcePatchProp = forcePatchProp;
  1688. exports.formatDateTime = formatDateTime;
  1689. exports.formatLog = formatLog;
  1690. exports.getCustomDataset = getCustomDataset;
  1691. exports.getEnvLocale = getEnvLocale;
  1692. exports.getLen = getLen;
  1693. exports.getValueByDataPath = getValueByDataPath;
  1694. exports.initCustomDatasetOnce = initCustomDatasetOnce;
  1695. exports.invokeArrayFns = invokeArrayFns;
  1696. exports.invokeCreateErrorHandler = invokeCreateErrorHandler;
  1697. exports.invokeCreateVueAppHook = invokeCreateVueAppHook;
  1698. exports.isAppNVueNativeTag = isAppNVueNativeTag;
  1699. exports.isAppNativeTag = isAppNativeTag;
  1700. exports.isAppUVueNativeTag = isAppUVueNativeTag;
  1701. exports.isBuiltInComponent = isBuiltInComponent;
  1702. exports.isComponentInternalInstance = isComponentInternalInstance;
  1703. exports.isComponentTag = isComponentTag;
  1704. exports.isH5CustomElement = isH5CustomElement;
  1705. exports.isH5NativeTag = isH5NativeTag;
  1706. exports.isMiniProgramNativeTag = isMiniProgramNativeTag;
  1707. exports.isRootHook = isRootHook;
  1708. exports.isRootImmediateHook = isRootImmediateHook;
  1709. exports.isUniLifecycleHook = isUniLifecycleHook;
  1710. exports.isUniXElement = isUniXElement;
  1711. exports.normalizeClass = normalizeClass;
  1712. exports.normalizeDataset = normalizeDataset;
  1713. exports.normalizeEventType = normalizeEventType;
  1714. exports.normalizeProps = normalizeProps;
  1715. exports.normalizeStyle = normalizeStyle;
  1716. exports.normalizeStyles = normalizeStyles;
  1717. exports.normalizeTabBarStyles = normalizeTabBarStyles;
  1718. exports.normalizeTarget = normalizeTarget;
  1719. exports.normalizeTitleColor = normalizeTitleColor;
  1720. exports.onCreateVueApp = onCreateVueApp;
  1721. exports.once = once;
  1722. exports.parseEventName = parseEventName;
  1723. exports.parseNVueDataset = parseNVueDataset;
  1724. exports.parseQuery = parseQuery;
  1725. exports.parseUrl = parseUrl;
  1726. exports.passive = passive;
  1727. exports.plusReady = plusReady;
  1728. exports.removeLeadingSlash = removeLeadingSlash;
  1729. exports.resolveComponentInstance = resolveComponentInstance;
  1730. exports.resolveOwnerEl = resolveOwnerEl;
  1731. exports.resolveOwnerVm = resolveOwnerVm;
  1732. exports.sanitise = sanitise;
  1733. exports.scrollTo = scrollTo;
  1734. exports.sortObject = sortObject;
  1735. exports.stringifyQuery = stringifyQuery;
  1736. exports.updateElementStyle = updateElementStyle;