@react-native-ohos/slider 4.4.4-rc.1 → 5.1.2-rc.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 (96) hide show
  1. package/.github/Examples/Slider-Android-Example.gif +0 -0
  2. package/.github/Examples/Slider-Web-Example.gif +0 -0
  3. package/.github/Examples/Slider-Windows-Example.gif +0 -0
  4. package/.github/Examples/Slider-iOS-Example.gif +0 -0
  5. package/.github/ISSUE_TEMPLATE/BUG_REPORT.md +38 -0
  6. package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +14 -0
  7. package/.github/ISSUE_TEMPLATE/QUESTION.md +9 -0
  8. package/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  9. package/.github/workflows/ReactNativeSlider-CI.yml +231 -0
  10. package/CHANGELOG.md +184 -0
  11. package/COMMITTERS.md +6 -0
  12. package/LICENSE +9 -0
  13. package/OAT.xml +73 -0
  14. package/README.OpenSource +11 -0
  15. package/README.md +13 -0
  16. package/babel.config.json +1 -1
  17. package/dist/RNCSliderNativeComponent.js +1 -1
  18. package/dist/Slider.js +1 -1
  19. package/dist/components/StepNumber.js +1 -0
  20. package/dist/components/StepsIndicator.js +1 -0
  21. package/dist/components/TrackMark.js +1 -0
  22. package/dist/utils/constants.js +1 -0
  23. package/dist/utils/styles.js +1 -0
  24. package/example/.eslintrc +19 -0
  25. package/example/.node-version +6 -0
  26. package/example/.prettierrc.js +7 -0
  27. package/example/.watchmanconfig +6 -0
  28. package/example/app.json +4 -0
  29. package/example/babel.config.js +9 -0
  30. package/example/contexts.ts +9 -0
  31. package/example/harmony/AppScope/app.json5 +10 -0
  32. package/example/harmony/AppScope/resources/base/element/string.json +8 -0
  33. package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  34. package/example/harmony/build-profile.template.json5 +36 -0
  35. package/example/harmony/codelinter.json +32 -0
  36. package/example/harmony/entry/build-profile.json5 +22 -0
  37. package/example/harmony/entry/hvigorfile.ts +8 -0
  38. package/example/harmony/entry/oh-package.json5 +11 -0
  39. package/example/harmony/entry/src/main/cpp/CMakeLists.txt +41 -0
  40. package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +17 -0
  41. package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +13 -0
  42. package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
  43. package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
  44. package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +27 -0
  45. package/example/harmony/entry/src/main/ets/pages/Index.ets +125 -0
  46. package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
  47. package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +44 -0
  48. package/example/harmony/entry/src/main/module.json5 +52 -0
  49. package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
  50. package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
  51. package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
  52. package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  53. package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
  54. package/example/harmony/format.ps1 +18 -0
  55. package/example/harmony/hvigor/hvigor-config.json5 +21 -0
  56. package/example/harmony/hvigorfile.ts +9 -0
  57. package/example/harmony/oh-package.json5 +12 -0
  58. package/example/index.js +11 -0
  59. package/example/jest.config.js +11 -0
  60. package/example/metro.config.js +30 -0
  61. package/example/package.json +58 -0
  62. package/example/react-native.config.js +11 -0
  63. package/example/scripts/create-build-profile.js +46 -0
  64. package/example/src/index.tsx +22 -0
  65. package/example/tsconfig.json +20 -0
  66. package/harmony/slider/OAT.xml +42 -0
  67. package/harmony/slider/README.OpenSource +1 -1
  68. package/harmony/slider/index.ets +1 -2
  69. package/harmony/slider/oh-package.json5 +2 -2
  70. package/harmony/slider/src/main/cpp/ComponentDescriptor.h +2 -4
  71. package/harmony/slider/src/main/cpp/EventEmitters.cpp +13 -13
  72. package/harmony/slider/src/main/cpp/EventEmitters.h +15 -9
  73. package/harmony/slider/src/main/cpp/Props.cpp +9 -5
  74. package/harmony/slider/src/main/cpp/Props.h +15 -10
  75. package/harmony/slider/src/main/cpp/ShadowNodes.cpp +1 -1
  76. package/harmony/slider/src/main/cpp/ShadowNodes.h +6 -6
  77. package/harmony/slider/src/main/cpp/SliderEventEmiRequestHandler.h +28 -31
  78. package/harmony/slider/src/main/cpp/SliderJSIBinder.h +8 -12
  79. package/harmony/slider/src/main/cpp/SliderNapiBinder.h +2 -6
  80. package/harmony/slider/src/main/cpp/SliderPackage.h +6 -12
  81. package/harmony/slider.har +0 -0
  82. package/package.json +39 -25
  83. package/react-native.config.js +11 -0
  84. package/src/RNCSliderNativeComponent.ts +14 -9
  85. package/src/Slider.tsx +135 -74
  86. package/src/components/StepNumber.tsx +23 -0
  87. package/src/components/StepsIndicator.tsx +89 -0
  88. package/src/components/TrackMark.tsx +59 -0
  89. package/src/index.ts +7 -1
  90. package/src/utils/constants.ts +17 -0
  91. package/src/utils/styles.ts +61 -0
  92. package/tsconfig.json +3 -2
  93. package/typings/index.d.ts +35 -1
  94. package/.eslintrc.json +0 -20
  95. package/.flowconfig +0 -66
  96. package/harmony/slider/src/main/ets/SliderPackage.ets +0 -34
package/dist/Slider.js CHANGED
@@ -1 +1 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _index=_interopRequireDefault(require("./index"));var _excluded=["onValueChange","onSlidingStart","onSlidingComplete","onAccessibilityAction"];var _this=this,_jsxFileName="D:\\fxxcode\\newThird\\rntpc_react-native-slider\\package\\src\\Slider.tsx";var LIMIT_MIN_VALUE=Number.MIN_SAFE_INTEGER;var LIMIT_MAX_VALUE=Number.MAX_SAFE_INTEGER;var SliderComponent=function SliderComponent(props,forwardedRef){var _props$accessibilityS;var style=_reactNative.StyleSheet.compose(props.style,styles.slider);var onValueChange=props.onValueChange,onSlidingStart=props.onSlidingStart,onSlidingComplete=props.onSlidingComplete,onAccessibilityAction=props.onAccessibilityAction,localProps=(0,_objectWithoutProperties2.default)(props,_excluded);var onValueChangeEvent=onValueChange?function(event){onValueChange(event.nativeEvent.value);}:null;var _disabled=typeof props.disabled==='boolean'?props.disabled:((_props$accessibilityS=props.accessibilityState)==null?void 0:_props$accessibilityS.disabled)===true;var _accessibilityState=typeof props.disabled==='boolean'?Object.assign({},props.accessibilityState,{disabled:props.disabled}):props.accessibilityState;var onSlidingStartEvent=onSlidingStart?function(event){onSlidingStart(event.nativeEvent.value);}:null;var onSlidingCompleteEvent=onSlidingComplete?function(event){onSlidingComplete(event.nativeEvent.value);}:null;var onAccessibilityActionEvent=onAccessibilityAction?function(event){onAccessibilityAction(event);}:null;var value=Number.isNaN(props.value)||!props.value?undefined:props.value;var lowerLimit=!!localProps.lowerLimit||localProps.lowerLimit===0?localProps.lowerLimit:LIMIT_MIN_VALUE;var upperLimit=!!localProps.upperLimit||localProps.upperLimit===0?localProps.upperLimit:LIMIT_MAX_VALUE;return _react.default.createElement(_index.default,(0,_extends2.default)({},localProps,{value:value,lowerLimit:lowerLimit,upperLimit:upperLimit,accessibilityState:_accessibilityState,thumbImage:_reactNative.Platform.OS==='web'?props.thumbImage:props.thumbImage?_reactNative.Image.resolveAssetSource(props.thumbImage):undefined,ref:forwardedRef,style:style,onChange:onValueChangeEvent,onRNCSliderSlidingStart:onSlidingStartEvent,onRNCSliderSlidingComplete:onSlidingCompleteEvent,onRNCSliderValueChange:onValueChangeEvent,disabled:_disabled,onStartShouldSetResponder:function onStartShouldSetResponder(){return true;},onResponderTerminationRequest:function onResponderTerminationRequest(){return false;},onRNCSliderAccessibilityAction:onAccessibilityActionEvent,__self:_this,__source:{fileName:_jsxFileName,lineNumber:251,columnNumber:5}}));};var SliderWithRef=_react.default.forwardRef(SliderComponent);SliderWithRef.defaultProps={value:0,minimumValue:0,maximumValue:1,step:0,inverted:false,tapToSeek:false,lowerLimit:LIMIT_MIN_VALUE,upperLimit:LIMIT_MAX_VALUE};var styles=_reactNative.StyleSheet.create(_reactNative.Platform.OS==='ios'||_reactNative.Platform.OS==='harmony'?{slider:{height:40}}:{slider:{}});var _default=exports.default=SliderWithRef;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _index=_interopRequireDefault(require("./index"));var _StepsIndicator=require("./components/StepsIndicator");var _styles=require("./utils/styles");var _constants=require("./utils/constants");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["onValueChange","onSlidingStart","onSlidingComplete","onAccessibilityAction","value","minimumValue","maximumValue","step","inverted","tapToSeek","lowerLimit","upperLimit"];var _this=this,_jsxFileName="E:\\tempcode\\rntpc_react-native-slider\\src\\Slider.tsx";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t in e)"default"!==_t&&{}.hasOwnProperty.call(e,_t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t))&&(i.get||i.set)?o(f,_t,i):f[_t]=e[_t]);return f;})(e,t);}var SliderComponent=function SliderComponent(_ref,forwardedRef){var _ref2,_props$accessibilityS;var onValueChange=_ref.onValueChange,onSlidingStart=_ref.onSlidingStart,onSlidingComplete=_ref.onSlidingComplete,onAccessibilityAction=_ref.onAccessibilityAction,_ref$value=_ref.value,value=_ref$value===void 0?_constants.constants.SLIDER_DEFAULT_INITIAL_VALUE:_ref$value,_ref$minimumValue=_ref.minimumValue,minimumValue=_ref$minimumValue===void 0?0:_ref$minimumValue,_ref$maximumValue=_ref.maximumValue,maximumValue=_ref$maximumValue===void 0?1:_ref$maximumValue,_ref$step=_ref.step,step=_ref$step===void 0?0:_ref$step,_ref$inverted=_ref.inverted,inverted=_ref$inverted===void 0?false:_ref$inverted,_ref$tapToSeek=_ref.tapToSeek,tapToSeek=_ref$tapToSeek===void 0?false:_ref$tapToSeek,_ref$lowerLimit=_ref.lowerLimit,lowerLimit=_ref$lowerLimit===void 0?_reactNative.Platform.select({web:minimumValue,default:_constants.constants.LIMIT_MIN_VALUE}):_ref$lowerLimit,_ref$upperLimit=_ref.upperLimit,upperLimit=_ref$upperLimit===void 0?_reactNative.Platform.select({web:maximumValue,default:_constants.constants.LIMIT_MAX_VALUE}):_ref$upperLimit,props=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _useState=(0,_react.useState)((_ref2=value!=null?value:minimumValue)!=null?_ref2:_constants.constants.SLIDER_DEFAULT_INITIAL_VALUE),_useState2=(0,_slicedToArray2.default)(_useState,2),currentValue=_useState2[0],setCurrentValue=_useState2[1];var _useState3=(0,_react.useState)(0),_useState4=(0,_slicedToArray2.default)(_useState3,2),width=_useState4[0],setWidth=_useState4[1];var stepResolution=step?step:_constants.constants.DEFAULT_STEP_RESOLUTION;var defaultStep=(maximumValue-minimumValue)/stepResolution;var stepLength=step||defaultStep;var options=Array.from({length:(step?defaultStep:stepResolution)+1},function(_,index){return minimumValue+index*stepLength;});var defaultStyle=_reactNative.Platform.OS==='ios'||_reactNative.Platform.OS==='harmony'?_styles.styles.defaultSlideriOS:_styles.styles.defaultSlider;var sliderStyle={zIndex:1,width:width};var style=[defaultStyle,props.style];var onValueChangeEvent=function onValueChangeEvent(event){onValueChange&&onValueChange(event.nativeEvent.value);setCurrentValue(event.nativeEvent.value);};var _disabled=typeof props.disabled==='boolean'?props.disabled:((_props$accessibilityS=props.accessibilityState)==null?void 0:_props$accessibilityS.disabled)===true;var _accessibilityState=typeof props.disabled==='boolean'?Object.assign({},props.accessibilityState,{disabled:props.disabled}):props.accessibilityState;var onSlidingStartEvent=onSlidingStart?function(event){onSlidingStart(event.nativeEvent.value);}:null;var onSlidingCompleteEvent=onSlidingComplete?function(event){onSlidingComplete(event.nativeEvent.value);}:null;var onAccessibilityActionEvent=onAccessibilityAction?function(event){onAccessibilityAction(event);}:null;var passedValue=Number.isNaN(value)||!value?undefined:value;(0,_react.useEffect)(function(){if(lowerLimit>=upperLimit){console.warn('Invalid configuration: lower limit is supposed to be smaller than upper limit');}},[lowerLimit,upperLimit]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{onLayout:function onLayout(event){setWidth(event.nativeEvent.layout.width);},style:[style,{justifyContent:'center'}],children:[props.StepMarker||!!props.renderStepNumber?(0,_jsxRuntime.jsx)(_StepsIndicator.StepsIndicator,{options:options,sliderWidth:width,currentValue:currentValue,renderStepNumber:props.renderStepNumber,thumbImage:props.thumbImage,StepMarker:props.StepMarker,isLTR:inverted}):null,(0,_jsxRuntime.jsx)(_index.default,Object.assign({},props,{minimumValue:minimumValue,maximumValue:maximumValue,step:step,inverted:inverted,tapToSeek:tapToSeek,value:passedValue,lowerLimit:lowerLimit,upperLimit:upperLimit,accessibilityState:_accessibilityState,thumbImage:_reactNative.Platform.OS==='web'?props.thumbImage:props.StepMarker||!props.thumbImage?undefined:_reactNative.Image.resolveAssetSource(props.thumbImage),ref:forwardedRef,style:[sliderStyle,defaultStyle,{alignContent:'center',alignItems:'center'}],onChange:onValueChangeEvent,onRNCSliderSlidingStart:onSlidingStartEvent,onRNCSliderSlidingComplete:onSlidingCompleteEvent,onRNCSliderValueChange:onValueChangeEvent,disabled:_disabled,onStartShouldSetResponder:function onStartShouldSetResponder(){return true;},onResponderTerminationRequest:function onResponderTerminationRequest(){return false;},onRNCSliderAccessibilityAction:onAccessibilityActionEvent,thumbTintColor:props.thumbImage&&!!props.StepMarker?'transparent':props.thumbTintColor}))]});};var SliderWithRef=_react.default.forwardRef(SliderComponent);var _default=exports.default=SliderWithRef;
@@ -0,0 +1 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.StepNumber=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _styles=require("../utils/styles");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="E:\\tempcode\\rntpc_react-native-slider\\src\\components\\StepNumber.tsx";var StepNumber=exports.StepNumber=function StepNumber(_ref){var i=_ref.i,style=_ref.style;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:_styles.styles.stepNumber,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:style,children:i})});};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.StepsIndicator=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _StepNumber=require("./StepNumber");var _TrackMark=require("./TrackMark");var _styles=require("../utils/styles");var _constants=require("../utils/constants");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="E:\\tempcode\\rntpc_react-native-slider\\src\\components\\StepsIndicator.tsx";function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(var _t in e)"default"!==_t&&{}.hasOwnProperty.call(e,_t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,_t))&&(i.get||i.set)?o(f,_t,i):f[_t]=e[_t]);return f;})(e,t);}var StepsIndicator=exports.StepsIndicator=function StepsIndicator(_ref){var options=_ref.options,sliderWidth=_ref.sliderWidth,currentValue=_ref.currentValue,StepMarker=_ref.StepMarker,renderStepNumber=_ref.renderStepNumber,thumbImage=_ref.thumbImage,isLTR=_ref.isLTR;var stepNumberFontStyle=(0,_react.useMemo)(function(){return{fontSize:options.length>9?_constants.constants.STEP_NUMBER_TEXT_FONT_SMALL:_constants.constants.STEP_NUMBER_TEXT_FONT_BIG};},[options.length]);var values=isLTR?options.reverse():options;var renderStepIndicator=(0,_react.useCallback)(function(i,index){return(0,_jsxRuntime.jsx)(_react.Fragment,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_styles.styles.stepIndicatorElement,children:[(0,_jsxRuntime.jsx)(_TrackMark.SliderTrackMark,{isTrue:currentValue===i,index:i,thumbImage:thumbImage,StepMarker:StepMarker,currentValue:currentValue,min:options[0],max:options[options.length-1]},`${index}-SliderTrackMark`),renderStepNumber?(0,_jsxRuntime.jsx)(_StepNumber.StepNumber,{i:i,style:stepNumberFontStyle},`${index}th-step`):null]},`${index}-View`)},index);},[currentValue,StepMarker,options,thumbImage,renderStepNumber,stepNumberFontStyle]);return(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_styles.styles.stepsIndicator,{marginHorizontal:sliderWidth*_constants.constants.MARGIN_HORIZONTAL_PADDING}],children:values.map(function(i,index){return renderStepIndicator(i,index);})});};
@@ -0,0 +1 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.SliderTrackMark=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _styles=require("../utils/styles");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="E:\\tempcode\\rntpc_react-native-slider\\src\\components\\TrackMark.tsx";var SliderTrackMark=exports.SliderTrackMark=function SliderTrackMark(_ref){var isTrue=_ref.isTrue,index=_ref.index,thumbImage=_ref.thumbImage,StepMarker=_ref.StepMarker,currentValue=_ref.currentValue,min=_ref.min,max=_ref.max;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_styles.styles.trackMarkContainer,children:[StepMarker?(0,_jsxRuntime.jsx)(StepMarker,{stepMarked:isTrue,index:index,currentValue:currentValue,min:min,max:max}):null,thumbImage&&isTrue?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_styles.styles.thumbImageContainer,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:thumbImage,style:_styles.styles.thumbImage})}):null]});};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.constants=void 0;var _reactNative=require("react-native");var constants=exports.constants={SLIDER_DEFAULT_INITIAL_VALUE:0,MARGIN_HORIZONTAL_PADDING:0.05,STEP_NUMBER_TEXT_FONT_SMALL:8,STEP_NUMBER_TEXT_FONT_BIG:12,LIMIT_MIN_VALUE:Number.MIN_SAFE_INTEGER,LIMIT_MAX_VALUE:Number.MAX_SAFE_INTEGER,DEFAULT_STEP_RESOLUTION:_reactNative.Platform.OS==='android'?128:1000};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.styles=void 0;var _reactNative=require("react-native");var styles=exports.styles=_reactNative.StyleSheet.create({stepNumber:{marginTop:20,alignItems:'center',position:'absolute'},sliderMainContainer:{zIndex:1,width:'100%'},defaultSlideriOS:{height:40},defaultSlider:{},stepsIndicator:{flex:1,flexDirection:'row',justifyContent:'space-between',top:_reactNative.Platform.OS==='ios'?10:0,zIndex:2},trackMarkContainer:{alignItems:'center',alignContent:'center',alignSelf:'center',justifyContent:'center',position:'absolute',zIndex:3},thumbImageContainer:{position:'absolute',zIndex:3,justifyContent:'center',alignItems:'center',alignContent:'center'},thumbImage:{alignContent:'center',alignItems:'center',position:'absolute'},stepIndicatorElement:{alignItems:'center',alignContent:'center'},defaultIndicatorMarked:{height:20,width:5,backgroundColor:'#CCCCCC'},defaultIndicatorIdle:{height:10,width:2,backgroundColor:'#C0C0C0'}});
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ {
8
+ "extends": "@react-native",
9
+ "rules": {
10
+ "react-native/no-inline-styles": "off",
11
+ "react/no-unstable-nested-components": "off",
12
+ "react/react-in-jsx-scope": "off",
13
+ "@typescript-eslint/no-unused-vars": "warn",
14
+ "react-hooks/exhaustive-deps": "off",
15
+ "radix": "off",
16
+ "prettier/prettier": "warn",
17
+ "max-lines": "off"
18
+ }
19
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+ 18
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ arrowParens: 'avoid',
3
+ bracketSameLine: true,
4
+ bracketSpacing: true,
5
+ singleQuote: true,
6
+ trailingComma: 'all',
7
+ };
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+ {}
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "app_name",
3
+ "displayName": "tester"
4
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ module.exports = {
8
+ presets: ['module:@react-native/babel-preset']
9
+ };
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import React from 'react';
8
+
9
+ export const AppParamsContext = React.createContext(undefined);
@@ -0,0 +1,10 @@
1
+ {
2
+ "app": {
3
+ "bundleName": "com.harmony.wechat.lib.demo",
4
+ "vendor": "example",
5
+ "versionCode": 1000000,
6
+ "versionName": "1.0.0",
7
+ "icon": "$media:app_icon",
8
+ "label": "$string:app_name"
9
+ }
10
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "app_name",
5
+ "value": "RN Tester"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "app": {
3
+ "products": [
4
+ {
5
+ "name": 'default',
6
+ "signingConfig": 'default',
7
+ "compileSdkVersion": '5.0.1(13)',
8
+ "compatibleSdkVersion": '5.0.0(12)',
9
+ "runtimeOS": 'HarmonyOS'
10
+ },
11
+ ],
12
+ "buildModeSet": [
13
+ {
14
+ "name": 'debug',
15
+ },
16
+ {
17
+ "name": 'release',
18
+ },
19
+ ],
20
+ "signingConfigs": []
21
+ },
22
+ "modules": [
23
+ {
24
+ "name": 'entry',
25
+ "srcPath": './entry',
26
+ "targets": [
27
+ {
28
+ "name": 'default',
29
+ "applyToProducts": [
30
+ 'default'
31
+ ],
32
+ },
33
+ ],
34
+ }
35
+ ],
36
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "files": ["**/*.ts", "**/*.ets"],
3
+ "ignore": [
4
+ "**/ohosTest/**/*",
5
+ "**/node_modules/**/*",
6
+ "**/hvigorfile.ts",
7
+ "**/node_modules/**/*",
8
+ "**/oh_modules/**/*",
9
+ "**/build/**/*",
10
+ "**/.preview/**/*"
11
+ ],
12
+ "plugins": ["@typescript-eslint"],
13
+ "ruleSet": [],
14
+ "rules": {
15
+ "@typescript-eslint/await-thenable": "warn",
16
+ "@typescript-eslint/consistent-type-imports": "warn",
17
+ "@typescript-eslint/explicit-function-return-type": "warn",
18
+ "@typescript-eslint/explicit-module-boundary-types": "warn",
19
+ "@typescript-eslint/no-dynamic-delete": "warn",
20
+ "@typescript-eslint/no-explicit-any": "warn",
21
+ "@typescript-eslint/no-for-in-array": "warn",
22
+ "@typescript-eslint/no-this-alias": "warn",
23
+ "@typescript-eslint/no-unnecessary-type-constraint": "warn",
24
+ "@typescript-eslint/no-unsafe-argument": "warn",
25
+ "@typescript-eslint/no-unsafe-assignment": "warn",
26
+ "@typescript-eslint/no-unsafe-call": "warn",
27
+ "@typescript-eslint/no-unsafe-member-access": "warn",
28
+ "@typescript-eslint/no-unsafe-return": "warn",
29
+ "@typescript-eslint/prefer-literal-enum-member": "warn"
30
+ },
31
+ "overrides": []
32
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "apiType": 'stageMode',
3
+ "buildOption": {
4
+ "externalNativeOptions": {
5
+ "path": "./src/main/cpp/CMakeLists.txt",
6
+ "arguments": "",
7
+ "cppFlags": "-s",
8
+ "abiFilters": [
9
+ "arm64-v8a",
10
+ "x86_64"
11
+ ]
12
+ },
13
+ },
14
+ "targets": [
15
+ {
16
+ "name": "default",
17
+ },
18
+ {
19
+ "name": "ohosTest",
20
+ }
21
+ ]
22
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
8
+ export { hapTasks } from '@ohos/hvigor-ohos-plugin';
@@ -0,0 +1,11 @@
1
+ {
2
+ "license": "ISC",
3
+ "devDependencies": {},
4
+ "name": "entry",
5
+ "description": "example description",
6
+ "version": "1.0.0",
7
+ "dependencies": {
8
+ "@rnoh/react-native-openharmony": "file:../../node_modules/react-native-harmony/harmony/react_native_openharmony.har",
9
+ "@react-native-ohos/slider": "file:../../../harmony/slider.har"
10
+ }
11
+ }
@@ -0,0 +1,41 @@
1
+ project(rnapp)
2
+ cmake_minimum_required(VERSION 3.4.1)
3
+ set(CMAKE_SKIP_BUILD_RPATH TRUE)
4
+ set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
5
+ set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
6
+ set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
7
+ set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
8
+ set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
9
+ set(LOG_VERBOSITY_LEVEL 1)
10
+ set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
11
+ set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
12
+ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
13
+
14
+ set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
15
+ add_compile_definitions(WITH_HITRACE_SYSTRACE)
16
+
17
+ # (VM) Define a variable and assign it to the current module's cpp directory
18
+ set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
19
+
20
+ # Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here
21
+ include_directories(${NATIVERENDER_ROOT_PATH}
22
+ ${NATIVERENDER_ROOT_PATH}/include)
23
+
24
+ add_subdirectory("${RNOH_CPP_DIR}" ./rn)
25
+
26
+ # RNOH_BEGIN: manual_package_linking_1
27
+ add_subdirectory("${OH_MODULES}/@react-native-ohos/slider/src/main/cpp" ./slider)
28
+ # RNOH_END: manual_package_linking_1
29
+
30
+ file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
31
+
32
+ add_library(rnoh_app SHARED
33
+ ${GENERATED_CPP_FILES}
34
+ "./PackageProvider.cpp"
35
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
36
+ )
37
+ target_link_libraries(rnoh_app PUBLIC rnoh)
38
+
39
+ # RNOH_BEGIN: manual_package_linking_2
40
+ target_link_libraries(rnoh_app PUBLIC rnoh_slider)
41
+ # RNOH_END: manual_package_linking_2
@@ -0,0 +1,17 @@
1
+ // Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
2
+ // Use of this source code is governed by a MIT license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #include "RNOH/PackageProvider.h"
6
+ #include "generated/RNOHGeneratedPackage.h"
7
+ #include "SliderPackage.h"
8
+
9
+ using namespace rnoh;
10
+
11
+ std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx)
12
+ {
13
+ return {
14
+ std::make_shared<RNOHGeneratedPackage>(ctx), // generated by codegen v1
15
+ std::make_shared<SliderPackage>(ctx)
16
+ };
17
+ }
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+
8
+ import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
9
+
10
+ export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
11
+ return [
12
+ ];
13
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import {RNAbility} from '@rnoh/react-native-openharmony';
8
+ import { AbilityConstant, Want } from '@kit.AbilityKit';
9
+
10
+ export default class EntryAbility extends RNAbility {
11
+
12
+ onCreate(want: Want) {
13
+ super.onCreate(want)
14
+ this.handleWeChatCallIfNeed(want)
15
+ }
16
+
17
+ getPagePath() {
18
+ return 'pages/Index';
19
+ }
20
+
21
+ onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void {
22
+ this.handleWeChatCallIfNeed(want)
23
+ }
24
+
25
+ private handleWeChatCallIfNeed(want: Want) {
26
+ }
27
+ }
@@ -0,0 +1,125 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import {
8
+ AnyJSBundleProvider,
9
+ ComponentBuilderContext,
10
+ FileJSBundleProvider,
11
+ MetroJSBundleProvider,
12
+ ResourceJSBundleProvider,
13
+ RNApp,
14
+ RNOHErrorDialog,
15
+ RNOHLogger,
16
+ TraceJSBundleProviderDecorator,
17
+ RNOHCoreContext
18
+ } from '@rnoh/react-native-openharmony';
19
+ import font from '@ohos.font';
20
+ import { createRNPackages } from '../RNPackagesFactory';
21
+ import { RNCSlider, SLIDER_TYPE } from "@react-native-ohos/slider"
22
+ const arkTsComponentNames: Array<string> = [
23
+ SLIDER_TYPE
24
+ ];
25
+
26
+ @Builder
27
+ export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
28
+ // There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided.
29
+ Stack() {
30
+ if (ctx.componentName === SLIDER_TYPE) {
31
+ RNCSlider({
32
+ ctx: ctx.rnComponentContext,
33
+ tag: ctx.tag,
34
+ })
35
+ }
36
+ }
37
+ .position({ x: 0, y: 0 })
38
+
39
+ }
40
+
41
+ const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)
42
+
43
+ /**
44
+ * If you want to use custom fonts, you need to register them here.
45
+ * We should support react-native-asset to handle registering fonts automatically.
46
+ */
47
+ const fonts: font.FontOptions[] = [
48
+ {
49
+ familyName: 'Pacifico-Regular',
50
+ familySrc: '/assets/fonts/Pacifico-Regular.ttf'
51
+ },
52
+ {
53
+ familyName: 'StintUltraCondensed-Regular',
54
+ familySrc: '/assets/fonts/StintUltraCondensed-Regular.ttf'
55
+ }
56
+ ]
57
+
58
+ @Entry
59
+ @Component
60
+ struct Index {
61
+ @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
62
+ @State shouldShow: boolean = false
63
+ private logger!: RNOHLogger
64
+ bundlePath: string = 'bunlde.harmony.js'
65
+ @State hasBundle: boolean = false
66
+
67
+ aboutToAppear() {
68
+ this.logger = this.rnohCoreContext!.logger.clone("Index")
69
+ const stopTracing = this.logger.clone("aboutToAppear").startTracing()
70
+ for (const customFont of fonts) {
71
+ font.registerFont(customFont)
72
+ }
73
+
74
+ this.shouldShow = true
75
+ stopTracing()
76
+ }
77
+
78
+ onBackPress(): boolean | undefined {
79
+ // NOTE: this is required since `Ability`'s `onBackPressed` function always
80
+ // terminates or puts the app in the background, but we want Ark to ignore it completely
81
+ // when handled by RN
82
+ this.rnohCoreContext!.dispatchBackPress()
83
+ return true
84
+ }
85
+
86
+ build() {
87
+ Column() {
88
+ if (this.rnohCoreContext && this.shouldShow) {
89
+ if (this.rnohCoreContext?.isDebugModeEnabled) {
90
+ RNOHErrorDialog({ ctx: this.rnohCoreContext })
91
+ }
92
+ RNApp({
93
+ rnInstanceConfig: {
94
+ createRNPackages,
95
+ enableNDKTextMeasuring: true,
96
+ enableBackgroundExecutor: false,
97
+ enableCAPIArchitecture: true,
98
+ arkTsComponentNames: arkTsComponentNames,
99
+ },
100
+ initialProps: { "foo": "bar" } as Record<string, string>,
101
+ appKey: "app_name",
102
+ wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
103
+ onSetUp: (rnInstance) => {
104
+ rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
105
+ },
106
+ jsBundleProvider: new TraceJSBundleProviderDecorator(
107
+ new AnyJSBundleProvider([
108
+ new MetroJSBundleProvider(),
109
+ // NOTE: to load the bundle from file, place it in
110
+ // `/data/app/el2/100/base/com.rnoh.tester/files/bundle.harmony.js`
111
+ // on your device. The path mismatch is due to app sandboxing on HarmonyOS
112
+ new FileJSBundleProvider('/data/storage/el2/base/files/bundle.harmony.js'),
113
+ // new FileJSBundleProvider(context.filesDir + '/' + this.bundlePath),
114
+ new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
115
+ new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
116
+ ]),
117
+ this.rnohCoreContext.logger),
118
+ })
119
+ }
120
+ Text("1233333333122 1212323")
121
+ }
122
+ .height('100%')
123
+ .width('100%')
124
+ }
125
+ }
@@ -0,0 +1,135 @@
1
+ /*
2
+ * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+ import { RNInstance, JSBundleProvider, RNAbility, RNSurface } from '@rnoh/react-native-openharmony'
7
+ import { CustomComponentBuilder } from "@rnoh/react-native-openharmony/src/main/ets/RNOHCorePackage"
8
+ import { SurfaceConfig2 } from '@rnoh/react-native-openharmony/src/main/ets/RNSurface'
9
+
10
+
11
+ @Component
12
+ export struct SurfaceDeadlockTest {
13
+ public jsBundleProvider: JSBundleProvider | undefined = undefined
14
+ public appKeys: string[] = []
15
+ public numberOfIterations: number = 1
16
+ @BuilderParam public buildCustomComponent!: CustomComponentBuilder
17
+ // -------------------------------------------------------------------------------------------------------------------
18
+ @StorageLink('RNAbility') private rnAbility: RNAbility = {} as RNAbility
19
+ private rnInstance!: RNInstance
20
+ @State private shouldShow: boolean = false
21
+ private shouldDestroyRNInstance: boolean = false
22
+ private cleanUpCallbacks: (() => void)[] = []
23
+
24
+ aboutToAppear() {
25
+ this.getOrCreateRNInstance().then(rnInstance => {
26
+ this.rnInstance = rnInstance
27
+ const jsBundleExecutionStatus = this.rnInstance.getBundleExecutionStatus(this.jsBundleProvider?.getURL())
28
+ if (this.jsBundleProvider && jsBundleExecutionStatus === undefined) {
29
+ this.rnInstance.runJSBundle(this.jsBundleProvider).then(() => {
30
+ this.shouldShow = true
31
+ })
32
+ return;
33
+ }
34
+ }).catch((reason: string | Error) => {
35
+ if (typeof reason === "string")
36
+ this.rnAbility.getLogger().error(reason)
37
+ else if (reason instanceof Error) {
38
+ this.rnAbility.getLogger().error(reason.message)
39
+ } else {
40
+ this.rnAbility.getLogger().error("Fatal exception")
41
+ }
42
+ })
43
+ }
44
+
45
+ aboutToDisappear() {
46
+ if (this.shouldDestroyRNInstance)
47
+ this.rnAbility.destroyAndUnregisterRNInstance(this.rnInstance)
48
+ this.cleanUpCallbacks.forEach(cleanUp => cleanUp())
49
+ }
50
+
51
+ private getOrCreateRNInstance(): Promise<RNInstance> {
52
+ return this.rnAbility.createAndRegisterRNInstance({ createRNPackages: () => [] })
53
+ }
54
+
55
+ build() {
56
+ Stack() {
57
+ if (this.shouldShow) {
58
+ ForEach(this.appKeys, (appKey: string, idx) => {
59
+ Stack() {
60
+ Blinker({
61
+ minDelayInMs: 1000,
62
+ maxDelayInMs: 2000,
63
+ blinksCount: this.numberOfIterations,
64
+ randomnessPrecisionInMs: 500
65
+ }) {
66
+ RNSurface({
67
+ ctx: this.rnAbility.createRNOHContext({ rnInstance: this.rnInstance }),
68
+ surfaceConfig: {
69
+ initialProps: {},
70
+ appKey: appKey,
71
+ } as SurfaceConfig2,
72
+ buildCustomComponent: this.buildCustomComponent,
73
+ })
74
+ }
75
+ }.height(`${100 / this.appKeys.length}%`)
76
+ .position({ x: 0, y: `${(idx / this.appKeys.length) * 100}%` })
77
+ })
78
+ }
79
+ }.width("100%")
80
+ .height("100%")
81
+ }
82
+ }
83
+
84
+
85
+ @Component
86
+ struct Blinker {
87
+ public minDelayInMs: number = 0
88
+ public maxDelayInMs: number = 1000
89
+ public blinksCount: number = 0
90
+ public randomnessPrecisionInMs: number = 250
91
+ @BuilderParam public renderChildren: () => void
92
+ private currentBlinksCount = 0
93
+ @State private isVisible: boolean = false
94
+ private timeout: number = 0
95
+
96
+ aboutToAppear() {
97
+ this.blink(this.minDelayInMs)
98
+ }
99
+
100
+ aboutToDisappear() {
101
+ clearTimeout(this.timeout)
102
+ }
103
+
104
+ private blink(ms: number) {
105
+ this.isVisible = !this.isVisible
106
+ this.currentBlinksCount += 1
107
+ if (this.currentBlinksCount >= this.blinksCount) {
108
+ if (this.timeout) {
109
+ clearTimeout(this.timeout)
110
+ }
111
+ this.isVisible = true
112
+ return;
113
+ }
114
+ this.timeout = setTimeout(() => {
115
+ this.blink(this.getNextDelay())
116
+ }, ms)
117
+ }
118
+
119
+ private getNextDelay(): number {
120
+ return ((Math.floor(Math.random() * (Number.MAX_VALUE / this.randomnessPrecisionInMs)) * this.randomnessPrecisionInMs) % this.maxDelayInMs) + this.minDelayInMs
121
+ }
122
+
123
+ build() {
124
+ Stack() {
125
+ if (this.isVisible) {
126
+ this.renderChildren()
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+
133
+
134
+
135
+