@spcsn/taro-runtime 0.1.1 → 1.0.0

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 (110) hide show
  1. package/README.md +16 -39
  2. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js +7 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/checkPrivateRedeclaration.js +6 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js +7 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js +7 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/defineProperty.js +12 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js +25 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPrimitive.js +14 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPropertyKey.js +9 -0
  12. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/typeof.js +11 -0
  13. package/dist/bom/{URL.js → URL2.js} +39 -30
  14. package/dist/bom/URL2.js.map +1 -0
  15. package/dist/bom/document.d.ts +0 -1
  16. package/dist/bom/document.js +1 -54
  17. package/dist/bom/document.js.map +1 -1
  18. package/dist/bom/get-computed-style.js +8 -0
  19. package/dist/bom/get-computed-style.js.map +1 -0
  20. package/dist/bom/history.d.ts +1 -5
  21. package/dist/bom/history.js +53 -40
  22. package/dist/bom/history.js.map +1 -1
  23. package/dist/bom/location.d.ts +1 -11
  24. package/dist/bom/location.js +103 -93
  25. package/dist/bom/location.js.map +1 -1
  26. package/dist/bom/navigator.js +1 -2
  27. package/dist/bom/navigator.js.map +1 -1
  28. package/dist/bom/raf.d.ts +2 -2
  29. package/dist/bom/raf.js +2 -2
  30. package/dist/bom/raf.js.map +1 -1
  31. package/dist/bom/url-search-params.d.ts +14 -0
  32. package/dist/bom/{URLSearchParams.js → url-search-params.js} +26 -25
  33. package/dist/bom/url-search-params.js.map +1 -0
  34. package/dist/bom/{URL.d.ts → url.d.ts} +2 -6
  35. package/dist/bom/url.js +196 -0
  36. package/dist/bom/url.js.map +1 -0
  37. package/dist/bom/window.d.ts +3 -3
  38. package/dist/bom/window.js +3 -3
  39. package/dist/bom/window.js.map +1 -1
  40. package/dist/current.d.ts +3 -0
  41. package/dist/current.js +10 -1
  42. package/dist/current.js.map +1 -1
  43. package/dist/dom/anchor-element.js +17 -9
  44. package/dist/dom/anchor-element.js.map +1 -1
  45. package/dist/dom/class-list.js +2 -1
  46. package/dist/dom/class-list.js.map +1 -1
  47. package/dist/dom/document.js.map +1 -1
  48. package/dist/dom/element.js +9 -8
  49. package/dist/dom/element.js.map +1 -1
  50. package/dist/dom/event-target.js +2 -4
  51. package/dist/dom/event-target.js.map +1 -1
  52. package/dist/dom/event.d.ts +1 -1
  53. package/dist/dom/event.js +19 -28
  54. package/dist/dom/event.js.map +1 -1
  55. package/dist/dom/form.js +3 -2
  56. package/dist/dom/form.js.map +1 -1
  57. package/dist/dom/node.d.ts +4 -3
  58. package/dist/dom/node.js +23 -13
  59. package/dist/dom/node.js.map +1 -1
  60. package/dist/dom/root.js +4 -6
  61. package/dist/dom/root.js.map +1 -1
  62. package/dist/dom/{style_properties.js → style-properties.js} +2 -2
  63. package/dist/dom/{style_properties.js.map → style-properties.js.map} +1 -1
  64. package/dist/dom/style.js +1 -1
  65. package/dist/dom/style.js.map +1 -1
  66. package/dist/dom/text.d.ts +1 -1
  67. package/dist/dom/text.js.map +1 -1
  68. package/dist/dom/transfer.js.map +1 -1
  69. package/dist/dom/tree.js +1 -1
  70. package/dist/dom/tree.js.map +1 -1
  71. package/dist/dom-external/mutation-observer/implements.js +1 -1
  72. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  73. package/dist/dsl/common.js +45 -63
  74. package/dist/dsl/common.js.map +1 -1
  75. package/dist/env.js +2 -2
  76. package/dist/env.js.map +1 -1
  77. package/dist/hydrate.js +11 -8
  78. package/dist/hydrate.js.map +1 -1
  79. package/dist/index.cjs.d.ts +4 -4
  80. package/dist/index.cjs.js +670 -911
  81. package/dist/index.cjs.js.map +1 -1
  82. package/dist/index.d.ts +4 -4
  83. package/dist/index.js +6 -6
  84. package/dist/next-tick.js +1 -4
  85. package/dist/next-tick.js.map +1 -1
  86. package/dist/perf.d.ts +1 -1
  87. package/dist/perf.js +10 -6
  88. package/dist/perf.js.map +1 -1
  89. package/dist/polyfill/index.js +1 -6
  90. package/dist/polyfill/index.js.map +1 -1
  91. package/dist/runtime.esm.d.ts +4 -4
  92. package/dist/runtime.esm.js +669 -911
  93. package/dist/runtime.esm.js.map +1 -1
  94. package/dist/utils/cache.js.map +1 -1
  95. package/dist/utils/index.js +9 -6
  96. package/dist/utils/index.js.map +1 -1
  97. package/dist/utils/router.js +2 -1
  98. package/dist/utils/router.js.map +1 -1
  99. package/package.json +26 -20
  100. package/LICENSE +0 -174
  101. package/dist/bom/URL.js.map +0 -1
  102. package/dist/bom/URLSearchParams.d.ts +0 -1
  103. package/dist/bom/URLSearchParams.js.map +0 -1
  104. package/dist/bom/getComputedStyle.js +0 -9
  105. package/dist/bom/getComputedStyle.js.map +0 -1
  106. package/dist/polyfill/intersection-observer.js +0 -494
  107. package/dist/polyfill/intersection-observer.js.map +0 -1
  108. /package/dist/bom/{getComputedStyle.d.ts → get-computed-style.d.ts} +0 -0
  109. /package/dist/dom/{node_types.d.ts → node-types.d.ts} +0 -0
  110. /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,10 +20,7 @@ const nextTick = (cb, ctx) => {
20
20
  */
21
21
  function next() {
22
22
  const pageElement = env.document.getElementById(path);
23
- if (pageElement?.pendingUpdate) if (process.env.TARO_PLATFORM === "web") pageElement.firstChild?.["componentOnReady"]?.().then(() => {
24
- timerFunc();
25
- }) ?? timerFunc();
26
- else pageElement.enqueueUpdateCallback(cb, ctx);
23
+ if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) pageElement.enqueueUpdateCallback(cb, ctx);
27
24
  else if (Date.now() - beginTime > TIMEOUT) timerFunc();
28
25
  else setTimeout(() => next(), 20);
29
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,IAAI,aAAa,eACf,IAAI,QAAQ,IAAI,kBAAkB,OAEhC,YAAY,aAAa,sBAAsB,EAAE,WAAW;GAC1D,UAAU;EACZ,CAAC,KAAK,UAAU;OAEhB,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.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  declare class Performance {
2
+ #private;
2
3
  private recorder;
3
4
  start(id: string): void;
4
5
  stop(id: string, now?: number): void;
5
6
  delayStop(id: string, delay?: number): ((...args: any[]) => void) | undefined;
6
- private parseTime;
7
7
  }
8
8
  export declare const perf: Performance;
9
9
  export {};
package/dist/perf.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import { debounce } from "./utils/lodash.js";
2
+ import { _classPrivateMethodInitSpec } from "./_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js";
3
+ import { _assertClassBrand } from "./_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js";
2
4
  import { options } from "./options.js";
3
5
  //#region src/perf.ts
6
+ var _Performance_brand = /* @__PURE__ */ new WeakSet();
4
7
  var Performance = class {
5
8
  constructor() {
9
+ _classPrivateMethodInitSpec(this, _Performance_brand);
6
10
  this.recorder = /* @__PURE__ */ new Map();
7
11
  }
8
12
  start(id) {
@@ -15,20 +19,20 @@ var Performance = class {
15
19
  if (!(prev >= 0)) return;
16
20
  this.recorder.delete(id);
17
21
  const time = now - prev;
18
- console.log(`${id} 时长: ${time}ms 开始时间:${this.parseTime(prev)} 结束时间:${this.parseTime(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`);
19
23
  }
20
24
  delayStop(id, delay = 500) {
21
25
  if (!options.debug) return;
22
26
  return debounce((now = Date.now(), cb) => {
23
27
  this.stop(id, now);
24
- cb?.();
28
+ cb === null || cb === void 0 || cb();
25
29
  }, delay);
26
30
  }
27
- parseTime(time) {
28
- const d = new Date(time);
29
- return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
30
- }
31
31
  };
32
+ function _parseTime(time) {
33
+ const d = new Date(time);
34
+ return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, "0")}`;
35
+ }
32
36
  const perf = new Performance();
33
37
  //#endregion
34
38
  export { perf };
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 private 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;;kCACG,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,UAAU,KAAK,UAAU,IAAI,EAAE,QAAQ,KAAK,UAAU,GAAG,GAAG;CAC5F;CAEA,UAAiB,IAAY,QAAQ,KAAK;EACxC,IAAI,CAAC,QAAQ,OACX;EAGF,OAAO,UAAU,MAAM,KAAK,IAAI,GAAG,OAAe;GAChD,KAAK,KAAK,IAAI,GAAG;GACjB,KAAK;EACP,GAAG,KAAK;CACV;CAEA,UAAkB,MAAc;EAC9B,MAAM,IAAI,IAAI,KAAK,IAAI;EACvB,OAAO,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,gBAAgB,IAAI,SAAS,GAAG,GAAG;CACxG;AACF;AAEA,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';