@spcsn/taro-runtime 0.1.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +1 -153
  2. package/README.md +16 -39
  3. package/dist/bom/{URL.js → URL2.js} +3 -4
  4. package/dist/bom/URL2.js.map +1 -0
  5. package/dist/bom/document.d.ts +0 -1
  6. package/dist/bom/document.js +1 -55
  7. package/dist/bom/document.js.map +1 -1
  8. package/dist/bom/get-computed-style.js +8 -0
  9. package/dist/bom/get-computed-style.js.map +1 -0
  10. package/dist/bom/history.js +1 -2
  11. package/dist/bom/history.js.map +1 -1
  12. package/dist/bom/location.js +2 -3
  13. package/dist/bom/location.js.map +1 -1
  14. package/dist/bom/navigator.js +1 -2
  15. package/dist/bom/navigator.js.map +1 -1
  16. package/dist/bom/raf.d.ts +2 -2
  17. package/dist/bom/raf.js +2 -2
  18. package/dist/bom/raf.js.map +1 -1
  19. package/dist/bom/url-search-params.d.ts +14 -0
  20. package/dist/bom/{URLSearchParams.js → url-search-params.js} +12 -15
  21. package/dist/bom/url-search-params.js.map +1 -0
  22. package/dist/bom/{URL.d.ts → url.d.ts} +1 -0
  23. package/dist/bom/url.js +196 -0
  24. package/dist/bom/url.js.map +1 -0
  25. package/dist/bom/window.d.ts +3 -3
  26. package/dist/bom/window.js +2 -2
  27. package/dist/bom/window.js.map +1 -1
  28. package/dist/current.d.ts +3 -0
  29. package/dist/current.js +10 -1
  30. package/dist/current.js.map +1 -1
  31. package/dist/dom/anchor-element.js +1 -1
  32. package/dist/dom/class-list.js +2 -1
  33. package/dist/dom/class-list.js.map +1 -1
  34. package/dist/dom/document.js.map +1 -1
  35. package/dist/dom/element.js +7 -7
  36. package/dist/dom/element.js.map +1 -1
  37. package/dist/dom/event.d.ts +1 -1
  38. package/dist/dom/event.js +3 -13
  39. package/dist/dom/event.js.map +1 -1
  40. package/dist/dom/form.js +1 -1
  41. package/dist/dom/form.js.map +1 -1
  42. package/dist/dom/node.d.ts +4 -3
  43. package/dist/dom/node.js +14 -7
  44. package/dist/dom/node.js.map +1 -1
  45. package/dist/dom/root.js +2 -2
  46. package/dist/dom/root.js.map +1 -1
  47. package/dist/dom/{style_properties.js → style-properties.js} +2 -2
  48. package/dist/dom/{style_properties.js.map → style-properties.js.map} +1 -1
  49. package/dist/dom/style.js +1 -1
  50. package/dist/dom/style.js.map +1 -1
  51. package/dist/dom/text.d.ts +1 -1
  52. package/dist/dom/text.js.map +1 -1
  53. package/dist/dom/tree.js.map +1 -1
  54. package/dist/dsl/common.js +26 -47
  55. package/dist/dsl/common.js.map +1 -1
  56. package/dist/env.js +2 -2
  57. package/dist/env.js.map +1 -1
  58. package/dist/hydrate.js +1 -1
  59. package/dist/hydrate.js.map +1 -1
  60. package/dist/index.cjs.d.ts +4 -4
  61. package/dist/index.cjs.js +331 -708
  62. package/dist/index.cjs.js.map +1 -1
  63. package/dist/index.d.ts +4 -4
  64. package/dist/index.js +6 -6
  65. package/dist/next-tick.js +1 -6
  66. package/dist/next-tick.js.map +1 -1
  67. package/dist/perf.js +1 -1
  68. package/dist/perf.js.map +1 -1
  69. package/dist/polyfill/index.js +1 -6
  70. package/dist/polyfill/index.js.map +1 -1
  71. package/dist/runtime.esm.d.ts +4 -4
  72. package/dist/runtime.esm.js +330 -708
  73. package/dist/runtime.esm.js.map +1 -1
  74. package/dist/utils/index.js.map +1 -1
  75. package/package.json +16 -10
  76. package/dist/bom/URL.js.map +0 -1
  77. package/dist/bom/URLSearchParams.d.ts +0 -1
  78. package/dist/bom/URLSearchParams.js.map +0 -1
  79. package/dist/bom/getComputedStyle.js +0 -9
  80. package/dist/bom/getComputedStyle.js.map +0 -1
  81. package/dist/polyfill/intersection-observer.js +0 -494
  82. package/dist/polyfill/intersection-observer.js.map +0 -1
  83. /package/dist/bom/{getComputedStyle.d.ts → get-computed-style.d.ts} +0 -0
  84. /package/dist/dom/{node_types.d.ts → node-types.d.ts} +0 -0
  85. /package/dist/dom/{style_properties.d.ts → style-properties.d.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -2,16 +2,16 @@ import './dom-external';
2
2
  import env from './env';
3
3
  export { hooks } from '@spcsn/taro-shared';
4
4
  export { taroDocumentProvider as document } from './bom/document';
5
- export { taroGetComputedStyleProvider as getComputedStyle } from './bom/getComputedStyle';
5
+ export { taroGetComputedStyleProvider as getComputedStyle } from './bom/get-computed-style';
6
6
  export { History } from './bom/history';
7
7
  export { Location } from './bom/location';
8
8
  export { nav as navigator } from './bom/navigator';
9
9
  export { caf as cancelAnimationFrame, now, raf as requestAnimationFrame } from './bom/raf';
10
10
  export { parseUrl, TaroURLProvider as URL } from './bom/URL';
11
- export { URLSearchParams } from './bom/URLSearchParams';
11
+ export { URLSearchParams } from './bom/url-search-params';
12
12
  export { taroHistoryProvider as history, taroLocationProvider as location, taroWindowProvider as window, } from './bom/window';
13
13
  export { TaroElement } from './dom/element';
14
- export { createEvent, eventHandler, eventHandlerTTDom, TaroEvent } from './dom/event';
14
+ export { createEvent, eventHandler, TaroEvent } from './dom/event';
15
15
  export { FormElement } from './dom/form';
16
16
  export { TaroNode } from './dom/node';
17
17
  export { TaroRootElement } from './dom/root';
@@ -21,7 +21,7 @@ export { TaroText } from './dom/text';
21
21
  export { MutationObserver } from './dom-external/mutation-observer';
22
22
  export { env };
23
23
  export * from './constants';
24
- export { Current, getCurrentInstance } from './current';
24
+ export { Current, getCurrentInstance, setCurrentApp, whenAppReady } from './current';
25
25
  export { eventSource } from './dom/event-source';
26
26
  export { createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, } from './dsl/common';
27
27
  export * from './emitter/emitter';
package/dist/index.js CHANGED
@@ -3,11 +3,10 @@ import { MutationObserver } from "./dom-external/mutation-observer/index.js";
3
3
  import { debounce, throttle } from "./utils/lodash.js";
4
4
  import { Events, eventCenter } from "./emitter/emitter.js";
5
5
  import env from "./env.js";
6
- import { taroGetComputedStyleProvider } from "./bom/getComputedStyle.js";
6
+ import { taroGetComputedStyleProvider } from "./bom/get-computed-style.js";
7
7
  import { History } from "./bom/history.js";
8
- import { Current, getCurrentInstance } from "./current.js";
9
- import { URLSearchParams } from "./bom/URLSearchParams.js";
10
- import { TaroURLProvider, parseUrl } from "./bom/URL.js";
8
+ import { Current, getCurrentInstance, setCurrentApp, whenAppReady } from "./current.js";
9
+ import { URLSearchParams } from "./bom/url-search-params.js";
11
10
  import { Location } from "./bom/location.js";
12
11
  import { nav } from "./bom/navigator.js";
13
12
  import { _caf, _raf, now } from "./bom/raf.js";
@@ -20,15 +19,16 @@ import { TaroNode } from "./dom/node.js";
20
19
  import { Style } from "./dom/style.js";
21
20
  import { TaroElement } from "./dom/element.js";
22
21
  import { options } from "./options.js";
23
- import { TaroEvent, createEvent, eventHandler, eventHandlerTTDom } from "./dom/event.js";
22
+ import { TaroEvent, createEvent, eventHandler } from "./dom/event.js";
24
23
  import { FormElement } from "./dom/form.js";
25
24
  import { perf } from "./perf.js";
26
25
  import { TaroRootElement } from "./dom/root.js";
27
26
  import { TaroText } from "./dom/text.js";
27
+ import { TaroURLProvider, parseUrl } from "./bom/URL2.js";
28
28
  import { taroDocumentProvider } from "./bom/document.js";
29
29
  import { SVGElement } from "./dom/svg.js";
30
30
  import { createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify } from "./dsl/common.js";
31
31
  import { nextTick } from "./next-tick.js";
32
32
  import { handlePolyfill } from "./polyfill/index.js";
33
33
  import { hooks } from "@spcsn/taro-shared";
34
- export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, Events, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, TaroURLProvider as URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventHandlerTTDom, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hooks, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, taroWindowProvider as window };
34
+ export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, CLICK_VIEW, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, Events, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, TaroURLProvider as URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, taroDocumentProvider as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, taroGetComputedStyleProvider as getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, taroHistoryProvider as history, hooks, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBound, isText, taroLocationProvider as location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, setCurrentApp, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, whenAppReady, taroWindowProvider as window };
package/dist/next-tick.js CHANGED
@@ -20,12 +20,7 @@ const nextTick = (cb, ctx) => {
20
20
  */
21
21
  function next() {
22
22
  const pageElement = env.document.getElementById(path);
23
- if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) if (process.env.TARO_PLATFORM === "web") {
24
- var _pageElement$firstChi, _pageElement$firstChi2, _pageElement$firstChi3;
25
- (_pageElement$firstChi = (_pageElement$firstChi2 = pageElement.firstChild) === null || _pageElement$firstChi2 === void 0 || (_pageElement$firstChi3 = _pageElement$firstChi2["componentOnReady"]) === null || _pageElement$firstChi3 === void 0 ? void 0 : _pageElement$firstChi3.call(_pageElement$firstChi2).then(() => {
26
- timerFunc();
27
- })) !== null && _pageElement$firstChi !== void 0 || timerFunc();
28
- } else pageElement.enqueueUpdateCallback(cb, ctx);
23
+ if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) pageElement.enqueueUpdateCallback(cb, ctx);
29
24
  else if (Date.now() - beginTime > TIMEOUT) timerFunc();
30
25
  else setTimeout(() => next(), 20);
31
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"next-tick.js","names":[],"sources":["../src/next-tick.ts"],"sourcesContent":["import { Current } from './current';\nimport { TaroRootElement } from './dom/root';\nimport env from './env';\n\nimport type { TFunc } from './interface';\n\nconst TIMEOUT = 100;\n\nexport const nextTick = (cb: TFunc, ctx?: Record<string, any>) => {\n const beginTime = Date.now();\n const router = Current.router;\n\n const timerFunc = () => {\n setTimeout(function () {\n ctx ? cb.call(ctx) : cb();\n }, 1);\n };\n\n if (router === null) return timerFunc();\n\n const path = router.$taroPath;\n\n /**\n * 三种情况\n * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms\n * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车\n * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。\n */\n function next() {\n const pageElement: TaroRootElement | null = env.document.getElementById<TaroRootElement>(path);\n if (pageElement?.pendingUpdate) {\n if (process.env.TARO_PLATFORM === 'web') {\n // eslint-disable-next-line dot-notation\n pageElement.firstChild?.['componentOnReady']?.().then(() => {\n timerFunc();\n }) ?? timerFunc();\n } else {\n pageElement.enqueueUpdateCallback(cb, ctx);\n }\n } else if (Date.now() - beginTime > TIMEOUT) {\n timerFunc();\n } else {\n setTimeout(() => next(), 20);\n }\n }\n\n next();\n};\n"],"mappings":";;;AAMA,MAAM,UAAU;AAEhB,MAAa,YAAY,IAAW,QAA8B;CAChE,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,SAAS,QAAQ;CAEvB,MAAM,kBAAkB;EACtB,WAAW,WAAY;GACrB,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG;EAC1B,GAAG,CAAC;CACN;CAEA,IAAI,WAAW,MAAM,OAAO,UAAU;CAEtC,MAAM,OAAO,OAAO;;;;;;;CAQpB,SAAS,OAAO;EACd,MAAM,cAAsC,IAAI,SAAS,eAAgC,IAAI;EAC7F,IAAA,gBAAA,QAAA,gBAAA,KAAA,IAAA,KAAA,IAAI,YAAa,eACf,IAAI,QAAQ,IAAI,kBAAkB,OAAO;;GAEvC,CAAA,yBAAA,yBAAA,YAAY,gBAAA,QAAA,2BAAA,KAAA,MAAA,yBAAA,uBAAa,yBAAA,QAAA,2BAAA,KAAA,IAAA,KAAA,IAAA,uBAAA,KAAA,sBAAsB,EAAE,WAAW;IAC1D,UAAU;GACZ,CAAC,OAAA,QAAA,0BAAA,KAAA,KAAK,UAAU;EAClB,OACE,YAAY,sBAAsB,IAAI,GAAG;OAEtC,IAAI,KAAK,IAAI,IAAI,YAAY,SAClC,UAAU;OAEV,iBAAiB,KAAK,GAAG,EAAE;CAE/B;CAEA,KAAK;AACP"}
1
+ {"version":3,"file":"next-tick.js","names":[],"sources":["../src/next-tick.ts"],"sourcesContent":["import { Current } from './current';\nimport { TaroRootElement } from './dom/root';\nimport env from './env';\n\nimport type { TFunc } from './interface';\n\nconst TIMEOUT = 100;\n\nexport const nextTick = (cb: TFunc, ctx?: Record<string, any>) => {\n const beginTime = Date.now();\n const router = Current.router;\n\n const timerFunc = () => {\n setTimeout(function () {\n ctx ? cb.call(ctx) : cb();\n }, 1);\n };\n\n if (router === null) return timerFunc();\n\n const path = router.$taroPath;\n\n /**\n * 三种情况\n * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms\n * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车\n * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。\n */\n function next() {\n const pageElement: TaroRootElement | null = env.document.getElementById<TaroRootElement>(path);\n if (pageElement?.pendingUpdate) {\n pageElement.enqueueUpdateCallback(cb, ctx);\n } else if (Date.now() - beginTime > TIMEOUT) {\n timerFunc();\n } else {\n setTimeout(() => next(), 20);\n }\n }\n\n next();\n};\n"],"mappings":";;;AAMA,MAAM,UAAU;AAEhB,MAAa,YAAY,IAAW,QAA8B;CAChE,MAAM,YAAY,KAAK,IAAI;CAC3B,MAAM,SAAS,QAAQ;CAEvB,MAAM,kBAAkB;EACtB,WAAW,WAAY;GACrB,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG;EAC1B,GAAG,CAAC;CACN;CAEA,IAAI,WAAW,MAAM,OAAO,UAAU;CAEtC,MAAM,OAAO,OAAO;;;;;;;CAQpB,SAAS,OAAO;EACd,MAAM,cAAsC,IAAI,SAAS,eAAgC,IAAI;EAC7F,IAAA,gBAAA,QAAA,gBAAA,KAAA,IAAA,KAAA,IAAI,YAAa,eACf,YAAY,sBAAsB,IAAI,GAAG;OACpC,IAAI,KAAK,IAAI,IAAI,YAAY,SAClC,UAAU;OAEV,iBAAiB,KAAK,GAAG,EAAE;CAE/B;CAEA,KAAK;AACP"}
package/dist/perf.js CHANGED
@@ -19,7 +19,7 @@ var Performance = class {
19
19
  if (!(prev >= 0)) return;
20
20
  this.recorder.delete(id);
21
21
  const time = now - prev;
22
- console.log(`${id} 时长: ${time}ms 开始时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, prev)} 结束时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, now)}`);
22
+ process.stdout.write(`${id} 时长: ${time}ms 开始时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, prev)} 结束时间:${_assertClassBrand(_Performance_brand, this, _parseTime).call(this, now)}\n`);
23
23
  }
24
24
  delayStop(id, delay = 500) {
25
25
  if (!options.debug) return;
package/dist/perf.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"perf.js","names":[],"sources":["../src/perf.ts"],"sourcesContent":["import { options } from './options';\nimport { debounce } from './utils';\n\nimport type { TFunc } from './interface';\n\nclass Performance {\n private recorder = new Map<string, number>();\n\n public start(id: string) {\n if (!options.debug) {\n return;\n }\n this.recorder.set(id, Date.now());\n }\n\n public stop(id: string, now = Date.now()) {\n if (!options.debug) {\n return;\n }\n const prev = this.recorder.get(id)!;\n if (!(prev >= 0)) return;\n\n this.recorder.delete(id);\n const time = now - prev;\n // eslint-disable-next-line no-console\n console.log(`${id} 时长: ${time}ms 开始时间:${this.#parseTime(prev)} 结束时间:${this.#parseTime(now)}`);\n }\n\n public delayStop(id: string, delay = 500) {\n if (!options.debug) {\n return;\n }\n\n return debounce((now = Date.now(), cb?: TFunc) => {\n this.stop(id, now);\n cb?.();\n }, delay);\n }\n\n #parseTime(time: number) {\n const d = new Date(time);\n return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, '0')}`;\n }\n}\n\nexport const perf = new Performance();\n"],"mappings":";;;;;;AAKA,IAAM,cAAN,MAAkB;;;EAChB,KAAQ,2BAAW,IAAI,IAAoB;;CAE3C,MAAa,IAAY;EACvB,IAAI,CAAC,QAAQ,OACX;EAEF,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC;CAClC;CAEA,KAAY,IAAY,MAAM,KAAK,IAAI,GAAG;EACxC,IAAI,CAAC,QAAQ,OACX;EAEF,MAAM,OAAO,KAAK,SAAS,IAAI,EAAE;EACjC,IAAI,EAAE,QAAQ,IAAI;EAElB,KAAK,SAAS,OAAO,EAAE;EACvB,MAAM,OAAO,MAAM;EAEnB,QAAQ,IAAI,GAAG,GAAG,OAAO,KAAK,UAAA,kBAAA,oBAAU,MAAA,UAAA,EAAA,KAAA,MAAgB,IAAI,EAAE,QAAA,kBAAA,oBAAQ,MAAA,UAAA,EAAA,KAAA,MAAgB,GAAG,GAAG;CAC9F;CAEA,UAAiB,IAAY,QAAQ,KAAK;EACxC,IAAI,CAAC,QAAQ,OACX;EAGF,OAAO,UAAU,MAAM,KAAK,IAAI,GAAG,OAAe;GAChD,KAAK,KAAK,IAAI,GAAG;GACjB,OAAA,QAAA,OAAA,KAAA,KAAA,GAAK;EACP,GAAG,KAAK;CACV;AAMF;AAJE,SAAA,WAAW,MAAc;CACvB,MAAM,IAAI,IAAI,KAAK,IAAI;CACvB,OAAO,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,gBAAgB,IAAI,SAAS,GAAG,GAAG;AACxG;AAGF,MAAa,OAAO,IAAI,YAAY"}
1
+ {"version":3,"file":"perf.js","names":[],"sources":["../src/perf.ts"],"sourcesContent":["import { options } from './options';\nimport { debounce } from './utils';\n\nimport type { TFunc } from './interface';\n\nclass Performance {\n private recorder = new Map<string, number>();\n\n public start(id: string) {\n if (!options.debug) {\n return;\n }\n this.recorder.set(id, Date.now());\n }\n\n public stop(id: string, now = Date.now()) {\n if (!options.debug) {\n return;\n }\n const prev = this.recorder.get(id)!;\n if (!(prev >= 0)) return;\n\n this.recorder.delete(id);\n const time = now - prev;\n process.stdout.write(\n `${id} 时长: ${time}ms 开始时间:${this.#parseTime(prev)} 结束时间:${this.#parseTime(now)}\\n`,\n );\n }\n\n public delayStop(id: string, delay = 500) {\n if (!options.debug) {\n return;\n }\n\n return debounce((now = Date.now(), cb?: TFunc) => {\n this.stop(id, now);\n cb?.();\n }, delay);\n }\n\n #parseTime(time: number) {\n const d = new Date(time);\n return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, '0')}`;\n }\n}\n\nexport const perf = new Performance();\n"],"mappings":";;;;;;AAKA,IAAM,cAAN,MAAkB;;;EAChB,KAAQ,2BAAW,IAAI,IAAoB;;CAE3C,MAAa,IAAY;EACvB,IAAI,CAAC,QAAQ,OACX;EAEF,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC;CAClC;CAEA,KAAY,IAAY,MAAM,KAAK,IAAI,GAAG;EACxC,IAAI,CAAC,QAAQ,OACX;EAEF,MAAM,OAAO,KAAK,SAAS,IAAI,EAAE;EACjC,IAAI,EAAE,QAAQ,IAAI;EAElB,KAAK,SAAS,OAAO,EAAE;EACvB,MAAM,OAAO,MAAM;EACnB,QAAQ,OAAO,MACb,GAAG,GAAG,OAAO,KAAK,UAAA,kBAAA,oBAAU,MAAA,UAAA,EAAA,KAAA,MAAgB,IAAI,EAAE,QAAA,kBAAA,oBAAQ,MAAA,UAAA,EAAA,KAAA,MAAgB,GAAG,EAAE,GACjF;CACF;CAEA,UAAiB,IAAY,QAAQ,KAAK;EACxC,IAAI,CAAC,QAAQ,OACX;EAGF,OAAO,UAAU,MAAM,KAAK,IAAI,GAAG,OAAe;GAChD,KAAK,KAAK,IAAI,GAAG;GACjB,OAAA,QAAA,OAAA,KAAA,KAAA,GAAK;EACP,GAAG,KAAK;CACV;AAMF;AAJE,SAAA,WAAW,MAAc;CACvB,MAAM,IAAI,IAAI,KAAK,IAAI;CACvB,OAAO,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,gBAAgB,IAAI,SAAS,GAAG,GAAG;AACxG;AAGF,MAAa,OAAO,IAAI,YAAY"}
@@ -1,7 +1,5 @@
1
1
  import { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from "./array.js";
2
- import { handleIntersectionObserverPolyfill } from "./intersection-observer.js";
3
2
  import { handleObjectAssignPolyfill, handleObjectDefinePropertyPolyfill, handleObjectEntriesPolyfill } from "./object.js";
4
- import { isObject } from "@spcsn/taro-shared";
5
3
  //#region src/polyfill/index.ts
6
4
  function handlePolyfill() {
7
5
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Object" || process.env.SUPPORT_TARO_POLYFILL === "Object.assign") handleObjectAssignPolyfill();
@@ -9,11 +7,8 @@ function handlePolyfill() {
9
7
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Object" || process.env.SUPPORT_TARO_POLYFILL === "Object.defineProperty") handleObjectDefinePropertyPolyfill();
10
8
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Array" || process.env.SUPPORT_TARO_POLYFILL === "Array.find") handleArrayFindPolyfill();
11
9
  if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "Array" || process.env.SUPPORT_TARO_POLYFILL === "Array.includes") handleArrayIncludesPolyfill();
12
- if (process.env.TARO_PLATFORM === "web" && isObject(window)) {
13
- if (process.env.SUPPORT_TARO_POLYFILL === "enabled" || process.env.SUPPORT_TARO_POLYFILL === "IntersectionObserver") handleIntersectionObserverPolyfill();
14
- }
15
10
  }
16
- if (process.env.SUPPORT_TARO_POLYFILL !== "disabled" && process.env.TARO_PLATFORM !== "web") handlePolyfill();
11
+ if (process.env.SUPPORT_TARO_POLYFILL !== "disabled") handlePolyfill();
17
12
  //#endregion
18
13
  export { handlePolyfill };
19
14
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/polyfill/index.ts"],"sourcesContent":["import { isObject } from '@spcsn/taro-shared'\n\nimport { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array'\nimport { handleIntersectionObserverPolyfill } from './intersection-observer'\nimport { handleObjectAssignPolyfill, handleObjectDefinePropertyPolyfill, handleObjectEntriesPolyfill } from './object'\n\nfunction handlePolyfill () {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {\n handleObjectAssignPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {\n handleObjectEntriesPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {\n handleObjectDefinePropertyPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {\n handleArrayFindPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {\n handleArrayIncludesPolyfill()\n }\n // Exit early if we're not running in a browser.\n if (process.env.TARO_PLATFORM === 'web' && isObject(window)) {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {\n handleIntersectionObserverPolyfill()\n }\n }\n}\n\nif (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== 'web') {\n handlePolyfill()\n}\n\nexport { handlePolyfill }\n\n"],"mappings":";;;;;AAMA,SAAS,iBAAkB;CACzB,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,YAAY,QAAQ,IAAI,0BAA0B,iBAC7I,2BAA2B;CAE7B,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,YAAY,QAAQ,IAAI,0BAA0B,kBAC7I,4BAA4B;CAE9B,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,YAAY,QAAQ,IAAI,0BAA0B,yBAC7I,mCAAmC;CAErC,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,WAAW,QAAQ,IAAI,0BAA0B,cAC5I,wBAAwB;CAE1B,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,WAAW,QAAQ,IAAI,0BAA0B,kBAC5I,4BAA4B;CAG9B,IAAI,QAAQ,IAAI,kBAAkB,SAAS,SAAS,MAAM;MACpD,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,wBAC3F,mCAAmC;CAAA;AAGzC;AAEA,IAAI,QAAQ,IAAI,0BAA0B,cAAc,QAAQ,IAAI,kBAAkB,OACpF,eAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/polyfill/index.ts"],"sourcesContent":["import { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array'\nimport { handleObjectAssignPolyfill, handleObjectDefinePropertyPolyfill, handleObjectEntriesPolyfill } from './object'\n\nfunction handlePolyfill () {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {\n handleObjectAssignPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {\n handleObjectEntriesPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {\n handleObjectDefinePropertyPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {\n handleArrayFindPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {\n handleArrayIncludesPolyfill()\n }\n}\n\nif (process.env.SUPPORT_TARO_POLYFILL !== 'disabled') {\n handlePolyfill()\n}\n\nexport { handlePolyfill }\n\n"],"mappings":";;;AAGA,SAAS,iBAAkB;CACzB,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,YAAY,QAAQ,IAAI,0BAA0B,iBAC7I,2BAA2B;CAE7B,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,YAAY,QAAQ,IAAI,0BAA0B,kBAC7I,4BAA4B;CAE9B,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,YAAY,QAAQ,IAAI,0BAA0B,yBAC7I,mCAAmC;CAErC,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,WAAW,QAAQ,IAAI,0BAA0B,cAC5I,wBAAwB;CAE1B,IAAI,QAAQ,IAAI,0BAA0B,aAAa,QAAQ,IAAI,0BAA0B,WAAW,QAAQ,IAAI,0BAA0B,kBAC5I,4BAA4B;AAEhC;AAEA,IAAI,QAAQ,IAAI,0BAA0B,YACxC,eAAe"}
@@ -2,16 +2,16 @@ import './dom-external';
2
2
  import env from './env';
3
3
  export { hooks } from '@spcsn/taro-shared';
4
4
  export { taroDocumentProvider as document } from './bom/document';
5
- export { taroGetComputedStyleProvider as getComputedStyle } from './bom/getComputedStyle';
5
+ export { taroGetComputedStyleProvider as getComputedStyle } from './bom/get-computed-style';
6
6
  export { History } from './bom/history';
7
7
  export { Location } from './bom/location';
8
8
  export { nav as navigator } from './bom/navigator';
9
9
  export { caf as cancelAnimationFrame, now, raf as requestAnimationFrame } from './bom/raf';
10
10
  export { parseUrl, TaroURLProvider as URL } from './bom/URL';
11
- export { URLSearchParams } from './bom/URLSearchParams';
11
+ export { URLSearchParams } from './bom/url-search-params';
12
12
  export { taroHistoryProvider as history, taroLocationProvider as location, taroWindowProvider as window, } from './bom/window';
13
13
  export { TaroElement } from './dom/element';
14
- export { createEvent, eventHandler, eventHandlerTTDom, TaroEvent } from './dom/event';
14
+ export { createEvent, eventHandler, TaroEvent } from './dom/event';
15
15
  export { FormElement } from './dom/form';
16
16
  export { TaroNode } from './dom/node';
17
17
  export { TaroRootElement } from './dom/root';
@@ -21,7 +21,7 @@ export { TaroText } from './dom/text';
21
21
  export { MutationObserver } from './dom-external/mutation-observer';
22
22
  export { env };
23
23
  export * from './constants';
24
- export { Current, getCurrentInstance } from './current';
24
+ export { Current, getCurrentInstance, setCurrentApp, whenAppReady } from './current';
25
25
  export { eventSource } from './dom/event-source';
26
26
  export { createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, } from './dsl/common';
27
27
  export * from './emitter/emitter';