@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.3

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 (77) hide show
  1. package/dist/apis/device/memory.ts +10 -3
  2. package/dist/apis/index.ts +2 -0
  3. package/dist/apis/media/video/VideoContext.ts +56 -7
  4. package/dist/apis/media/video/index.ts +3 -2
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/wxml/index.ts +2 -0
  8. package/dist/components-harmony-ets/button.ets +26 -40
  9. package/dist/components-harmony-ets/checkbox.ets +70 -99
  10. package/dist/components-harmony-ets/form.ets +29 -42
  11. package/dist/components-harmony-ets/icon.ets +6 -34
  12. package/dist/components-harmony-ets/image.ets +2 -32
  13. package/dist/components-harmony-ets/innerHtml.ets +2 -2
  14. package/dist/components-harmony-ets/input.ets +7 -27
  15. package/dist/components-harmony-ets/label.ets +40 -47
  16. package/dist/components-harmony-ets/picker.ets +66 -73
  17. package/dist/components-harmony-ets/radio.ets +72 -101
  18. package/dist/components-harmony-ets/richText.ets +4 -36
  19. package/dist/components-harmony-ets/scrollView.ets +34 -74
  20. package/dist/components-harmony-ets/slider.ets +9 -34
  21. package/dist/components-harmony-ets/style.ets +154 -0
  22. package/dist/components-harmony-ets/swiper.ets +4 -34
  23. package/dist/components-harmony-ets/switch.ets +43 -56
  24. package/dist/components-harmony-ets/text.ets +7 -34
  25. package/dist/components-harmony-ets/textArea.ets +8 -28
  26. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  27. package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
  28. package/dist/components-harmony-ets/utils/helper.ets +2 -2
  29. package/dist/components-harmony-ets/utils/styles.ets +58 -20
  30. package/dist/components-harmony-ets/video.ets +4 -34
  31. package/dist/components-harmony-ets/view.ets +25 -67
  32. package/dist/components-harmony-ets/webView.ets +50 -0
  33. package/dist/index.js +103 -5
  34. package/dist/index.js.map +1 -1
  35. package/dist/runtime-ets/bom/window.ts +2 -2
  36. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
  37. package/dist/runtime-ets/dom/document.ts +21 -4
  38. package/dist/runtime-ets/dom/element/element.ts +1 -0
  39. package/dist/runtime-ets/dom/element/form.ts +11 -2
  40. package/dist/runtime-ets/dom/element/index.ts +4 -1
  41. package/dist/runtime-ets/dom/element/normal.ts +1 -0
  42. package/dist/runtime-ets/dom/element/webView.ts +61 -0
  43. package/dist/runtime-ets/dom/node.ts +29 -16
  44. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
  45. package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
  46. package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
  47. package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
  48. package/dist/runtime-ets/index.ts +1 -2
  49. package/dist/runtime-ets/interface/event.ts +2 -1
  50. package/dist/runtime-ets/utils/index.ts +6 -1
  51. package/dist/runtime-ets/utils/info.ts +3 -1
  52. package/dist/runtime-framework/react/app.ts +12 -22
  53. package/dist/runtime-framework/react/hooks.ts +3 -3
  54. package/dist/runtime-framework/react/index.ts +1 -0
  55. package/dist/runtime-framework/react/native-page.ts +344 -0
  56. package/dist/runtime-framework/react/page.ts +2 -2
  57. package/dist/runtime-framework/solid/hooks.ts +3 -3
  58. package/dist/runtime-utils.js +76 -20
  59. package/dist/runtime-utils.js.map +1 -1
  60. package/dist/runtime.js +76 -20
  61. package/dist/runtime.js.map +1 -1
  62. package/package.json +12 -11
  63. package/static/media/cancel.svg +1 -0
  64. package/static/media/circle.svg +1 -0
  65. package/static/media/clear.svg +1 -0
  66. package/static/media/download.svg +1 -0
  67. package/static/media/info.svg +1 -0
  68. package/static/media/info_circle.svg +1 -0
  69. package/static/media/search.svg +1 -0
  70. package/static/media/success.svg +1 -0
  71. package/static/media/success_no_circle.svg +1 -0
  72. package/static/media/taro_arrow_left.svg +1 -0
  73. package/static/media/taro_home.svg +1 -0
  74. package/static/media/waiting.svg +1 -0
  75. package/static/media/warn.svg +1 -0
  76. package/types/runtime.d.ts +2 -0
  77. package/dist/runtime-ets/utils/bind.ts +0 -24
package/dist/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined, queryToJson, PLATFORM_TYPE, singleQuote, internalComponents, mergeReconciler, mergeInternalComponents } from '@tarojs/shared';
2
2
  import _display from '@ohos.display';
3
- import { Current, window, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME, hooks } from '@tarojs/runtime';
3
+ import { Current, window, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime';
4
4
  import { eventCenter, Events, History } from '@tarojs/runtime/dist/runtime.esm';
5
5
  import deviceInfo from '@ohos.deviceInfo';
6
6
  import i18n from '@ohos.i18n';
@@ -509,7 +509,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
509
509
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
510
510
  PERFORMANCE OF THIS SOFTWARE.
511
511
  ***************************************************************************** */
512
- /* global Reflect, Promise */
512
+ /* global Reflect, Promise, SuppressedError, Symbol */
513
513
 
514
514
 
515
515
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -520,7 +520,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
520
520
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
521
521
  step((generator = generator.apply(thisArg, _arguments || [])).next());
522
522
  });
523
- }
523
+ }
524
+
525
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
526
+ var e = new Error(message);
527
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
528
+ };
524
529
 
525
530
  // 电量
526
531
  const getBatteryInfoSync = () => ({
@@ -731,8 +736,14 @@ const hideKeyboard = function (options) {
731
736
  };
732
737
  const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange');
733
738
 
734
- const onMemoryWarning = temporarilyNotSupport('onMemoryWarning');
735
- const offMemoryWarning = temporarilyNotSupport('offMemoryWarning');
739
+ const onMemoryWarning = (listener) => {
740
+ hooks.tap('getMemoryLevel', (res) => {
741
+ listener(res);
742
+ });
743
+ };
744
+ const offMemoryWarning = (listener) => {
745
+ hooks.off('getMemoryLevel', listener);
746
+ };
736
747
 
737
748
  const stopDeviceMotionListening = temporarilyNotSupport('stopDeviceMotionListening');
738
749
  const startDeviceMotionListening = temporarilyNotSupport('startDeviceMotionListening');
@@ -2306,21 +2317,51 @@ const stopRecord = /* @__PURE__ */ temporarilyNotSupport('stopRecord');
2306
2317
  const startRecord = /* @__PURE__ */ temporarilyNotSupport('startRecord');
2307
2318
  const getRecorderManager = /* @__PURE__ */ temporarilyNotSupport('getRecorderManager');
2308
2319
 
2320
+ // @ts-nocheck
2309
2321
  class VideoContext {
2310
- constructor() {
2322
+ constructor(id) {
2323
+ this.requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback');
2311
2324
  this.exitBackgroundPlayback = temporarilyNotSupport('VideoContext.exitBackgroundPlayback');
2312
- this.exitFullScreen = temporarilyNotSupport('VideoContext.exitFullScreen');
2313
2325
  this.exitPictureInPicture = temporarilyNotSupport('VideoContext.exitPictureInPicture');
2314
2326
  this.hideStatusBar = temporarilyNotSupport('VideoContext.hideStatusBar');
2315
- this.pause = temporarilyNotSupport('VideoContext.pause');
2316
- this.play = temporarilyNotSupport('VideoContext.play');
2317
2327
  this.playbackRate = temporarilyNotSupport('VideoContext.playbackRate');
2318
- this.requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback');
2319
- this.requestFullScreen = temporarilyNotSupport('VideoContext.requestFullScreen');
2320
- this.seek = temporarilyNotSupport('VideoContext.seek');
2321
2328
  this.sendDanmu = temporarilyNotSupport('VideoContext.sendDanmu');
2322
2329
  this.showStatusBar = temporarilyNotSupport('VideoContext.showStatusBar');
2323
- this.stop = temporarilyNotSupport('VideoContext.stop');
2330
+ this.id = id;
2331
+ this.video = document$1.getElementById(id);
2332
+ if (this.video) {
2333
+ this.controller = this.video.controller;
2334
+ }
2335
+ }
2336
+ play() {
2337
+ if (!this.controller)
2338
+ return;
2339
+ this.controller.play();
2340
+ }
2341
+ pause() {
2342
+ if (!this.controller)
2343
+ return;
2344
+ this.controller.pause();
2345
+ }
2346
+ stop() {
2347
+ if (!this.controller)
2348
+ return;
2349
+ this.controller.stop();
2350
+ }
2351
+ seek(position) {
2352
+ if (!this.controller)
2353
+ return;
2354
+ this.controller.setCurrentTime(position);
2355
+ }
2356
+ requestFullScreen() {
2357
+ if (!this.controller)
2358
+ return;
2359
+ this.controller.requestFullscreen(true);
2360
+ }
2361
+ exitFullScreen() {
2362
+ if (!this.controller)
2363
+ return;
2364
+ this.controller.exitFullscreen();
2324
2365
  }
2325
2366
  }
2326
2367
 
@@ -2349,8 +2390,8 @@ class VideoContext {
2349
2390
  const saveVideoToPhotosAlbumSchema = {
2350
2391
  filePath: 'String'
2351
2392
  };
2352
- const createVideoContext = () => {
2353
- return new VideoContext();
2393
+ const createVideoContext = (id, _) => {
2394
+ return new VideoContext(id);
2354
2395
  };
2355
2396
  // TODO: 1.返回属性补全
2356
2397
  // TODO: 2.只支持从相册选择,补充摄像头拍摄功能,需要HarmonyOS提供选择组件
@@ -2570,10 +2611,10 @@ const request = function (options) {
2570
2611
  header['Content-Type'] = 'application/json';
2571
2612
  }
2572
2613
  // 检查 Header 是否有 Referer
2573
- if (isUndefined(header.Referer)) {
2574
- const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' };
2575
- callAsyncFail(reject, error, options);
2576
- }
2614
+ // if (isUndefined(header.Referer)) {
2615
+ // const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
2616
+ // callAsyncFail(reject, error, options)
2617
+ // }
2577
2618
  // 检查 method 是否正确
2578
2619
  if (method) {
2579
2620
  if (!METHOD.includes(method)) {
@@ -3019,6 +3060,19 @@ function parseURL(raw = '') {
3019
3060
  const [urlStr, queryStr = ''] = raw.split('?');
3020
3061
  const query = queryToJson(queryStr);
3021
3062
  let url = urlStr.replace(/^\//, '');
3063
+ // 处理相对路径
3064
+ if (url.indexOf('.') === 0) {
3065
+ const page = router.getState();
3066
+ const parts = page.path.split('/');
3067
+ parts.pop();
3068
+ url.split('/').forEach((item) => {
3069
+ if (item === '.') {
3070
+ return;
3071
+ }
3072
+ item === '..' ? parts.pop() : parts.push(item);
3073
+ });
3074
+ url = parts.join('/');
3075
+ }
3022
3076
  if (isTabPage(url)) {
3023
3077
  query.$page = url;
3024
3078
  url = TARO_TABBAR_PAGE_PATH;
@@ -4239,6 +4293,7 @@ var apis = /*#__PURE__*/Object.freeze({
4239
4293
  ENV_TYPE: ENV_TYPE,
4240
4294
  Events: Events,
4241
4295
  History: History,
4296
+ IntersectionObserver: IntersectionObserver,
4242
4297
  addCard: addCard,
4243
4298
  addFileToFavorites: addFileToFavorites,
4244
4299
  addPhoneCalendar: addPhoneCalendar,
@@ -4628,7 +4683,7 @@ var apis = /*#__PURE__*/Object.freeze({
4628
4683
  writeBLECharacteristicValue: writeBLECharacteristicValue
4629
4684
  });
4630
4685
 
4631
- Object.assign({}, apis);
4686
+ const taro = Object.assign({}, apis);
4632
4687
  const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
4633
4688
  function initNativeApi(taro) {
4634
4689
  Current.taro = taro;
@@ -4692,6 +4747,7 @@ function getAppInfo() {
4692
4747
  designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
4693
4748
  };
4694
4749
  }
4750
+ initNativeApi(taro);
4695
4751
 
4696
4752
  const components = {
4697
4753
  Checkbox: {