@react-native-ohos/react-native-background-timer 2.4.2-rc.1 → 2.5.0-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 (60) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/COMMITTERS.md +0 -4
  3. package/OAT.xml +3 -1
  4. package/README.md +1 -1
  5. package/example/.eslintrc +18 -0
  6. package/example/.node-version +6 -0
  7. package/example/.prettierrc.js +12 -0
  8. package/example/.watchmanconfig +6 -0
  9. package/example/app.json +4 -0
  10. package/example/babel.config.js +10 -0
  11. package/example/contexts.ts +8 -0
  12. package/example/harmony/AppScope/app.json5 +10 -0
  13. package/example/harmony/AppScope/resources/base/element/string.json +8 -0
  14. package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  15. package/example/harmony/build-profile.template.json5 +40 -0
  16. package/example/harmony/codelinter.json +32 -0
  17. package/example/harmony/entry/build-profile.json5 +19 -0
  18. package/example/harmony/entry/hvigorfile.ts +9 -0
  19. package/example/harmony/entry/oh-package.json5 +11 -0
  20. package/example/harmony/entry/src/main/cpp/CMakeLists.txt +34 -0
  21. package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +19 -0
  22. package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +15 -0
  23. package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
  24. package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
  25. package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +19 -0
  26. package/example/harmony/entry/src/main/ets/pages/Index.ets +118 -0
  27. package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
  28. package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +43 -0
  29. package/example/harmony/entry/src/main/module.json5 +52 -0
  30. package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
  31. package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
  32. package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
  33. package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  34. package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
  35. package/example/harmony/hvigor/hvigor-config.json5 +21 -0
  36. package/example/harmony/hvigorfile.ts +8 -0
  37. package/example/harmony/oh-package.json5 +12 -0
  38. package/example/index.js +10 -0
  39. package/example/jest.config.js +10 -0
  40. package/example/metro.config.js +29 -0
  41. package/example/package.json +66 -0
  42. package/example/react-native.config.js +10 -0
  43. package/example/src/BackgroundTimerDemo.tsx +166 -0
  44. package/harmony/background_timer/hvigorfile.ts +6 -6
  45. package/harmony/background_timer/oh-package.json5 +10 -10
  46. package/harmony/background_timer/src/main/cpp/CMakeLists.txt +13 -13
  47. package/harmony/background_timer/src/main/cpp/generated/RNOH/generated/turbo_modules/BackgroundTimerTurboModule.cpp +21 -21
  48. package/harmony/background_timer/src/main/cpp/generated/RNOH/generated/turbo_modules/BackgroundTimerTurboModule.h +16 -16
  49. package/harmony/background_timer/src/main/ets/generated/components/ts.ts +5 -5
  50. package/harmony/background_timer/src/main/ets/generated/index.ets +5 -5
  51. package/harmony/background_timer/src/main/ets/generated/ts.ts +6 -6
  52. package/harmony/background_timer/src/main/ets/generated/turboModules/BackgroundTimerTurboModule.ts +18 -18
  53. package/harmony/background_timer/src/main/ets/generated/turboModules/ts.ts +5 -5
  54. package/harmony/background_timer/src/main/resources/base/element/string.json +8 -8
  55. package/harmony/background_timer/src/main/resources/en_US/element/string.json +8 -8
  56. package/harmony/background_timer/src/main/resources/zh_CN/element/string.json +8 -8
  57. package/harmony/background_timer.har +0 -0
  58. package/index.js +111 -111
  59. package/package.json +6 -8
  60. package/react-native-background-timer.podspec +0 -24
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
Binary file
package/index.js CHANGED
@@ -1,111 +1,111 @@
1
- import {
2
- DeviceEventEmitter,
3
- NativeAppEventEmitter,
4
- NativeEventEmitter,
5
- NativeModules,
6
- Platform,
7
- TurboModuleRegistry,
8
- } from 'react-native';
9
-
10
- const RNBackgroundTimer = TurboModuleRegistry
11
- ? TurboModuleRegistry.get('BackgroundTimerTurboModule')
12
- : NativeModules.BackgroundTimer;
13
- const Emitter = new NativeEventEmitter(RNBackgroundTimer);
14
-
15
- class BackgroundTimer {
16
- constructor() {
17
- this.uniqueId = 0;
18
- this.callbacks = {};
19
-
20
- Emitter.addListener('backgroundTimer.timeout', (id) => {
21
- if (this.callbacks[id]) {
22
- const callbackById = this.callbacks[id];
23
- const { callback } = callbackById;
24
- if (!this.callbacks[id].interval) {
25
- delete this.callbacks[id];
26
- } else {
27
- RNBackgroundTimer.setTimeout(id, this.callbacks[id].timeout);
28
- }
29
- callback();
30
- }
31
- });
32
- }
33
-
34
- // Original API
35
- start(delay = 0) {
36
- return RNBackgroundTimer.start(delay);
37
- }
38
-
39
- stop() {
40
- return RNBackgroundTimer.stop();
41
- }
42
-
43
- runBackgroundTimer(callback, delay) {
44
- const EventEmitter = Platform.select({
45
- ios: () => NativeAppEventEmitter,
46
- android: () => DeviceEventEmitter,
47
- harmony: () => DeviceEventEmitter,
48
- })();
49
- this.start(0);
50
- this.backgroundListener = EventEmitter.addListener(
51
- 'backgroundTimer',
52
- () => {
53
- this.backgroundListener.remove();
54
- this.backgroundClockMethod(callback, delay);
55
- },
56
- );
57
- }
58
-
59
- backgroundClockMethod(callback, delay) {
60
- this.backgroundTimer = this.setTimeout(() => {
61
- callback();
62
- this.backgroundClockMethod(callback, delay);
63
- }, delay);
64
- }
65
-
66
- stopBackgroundTimer() {
67
- this.stop();
68
- this.clearTimeout(this.backgroundTimer);
69
- }
70
-
71
- // New API, allowing for multiple timers
72
- setTimeout(callback, timeout) {
73
- this.uniqueId += 1;
74
- const timeoutId = this.uniqueId;
75
- this.callbacks[timeoutId] = {
76
- callback,
77
- interval: false,
78
- timeout,
79
- };
80
- RNBackgroundTimer.setTimeout(timeoutId, timeout);
81
- return timeoutId;
82
- }
83
-
84
- clearTimeout(timeoutId) {
85
- if (this.callbacks[timeoutId]) {
86
- delete this.callbacks[timeoutId];
87
- // RNBackgroundTimer.clearTimeout(timeoutId);
88
- }
89
- }
90
-
91
- setInterval(callback, timeout) {
92
- this.uniqueId += 1;
93
- const intervalId = this.uniqueId;
94
- this.callbacks[intervalId] = {
95
- callback,
96
- interval: true,
97
- timeout,
98
- };
99
- RNBackgroundTimer.setTimeout(intervalId, timeout);
100
- return intervalId;
101
- }
102
-
103
- clearInterval(intervalId) {
104
- if (this.callbacks[intervalId]) {
105
- delete this.callbacks[intervalId];
106
- // RNBackgroundTimer.clearTimeout(intervalId);
107
- }
108
- }
109
- }
110
-
111
- export default new BackgroundTimer();
1
+ import {
2
+ DeviceEventEmitter,
3
+ NativeAppEventEmitter,
4
+ NativeEventEmitter,
5
+ NativeModules,
6
+ Platform,
7
+ TurboModuleRegistry,
8
+ } from 'react-native';
9
+
10
+ const RNBackgroundTimer = TurboModuleRegistry
11
+ ? TurboModuleRegistry.get('BackgroundTimerTurboModule')
12
+ : NativeModules.BackgroundTimer;
13
+ const Emitter = new NativeEventEmitter(RNBackgroundTimer);
14
+
15
+ class BackgroundTimer {
16
+ constructor() {
17
+ this.uniqueId = 0;
18
+ this.callbacks = {};
19
+
20
+ Emitter.addListener('backgroundTimer.timeout', (id) => {
21
+ if (this.callbacks[id]) {
22
+ const callbackById = this.callbacks[id];
23
+ const { callback } = callbackById;
24
+ if (!this.callbacks[id].interval) {
25
+ delete this.callbacks[id];
26
+ } else {
27
+ RNBackgroundTimer.setTimeout(id, this.callbacks[id].timeout);
28
+ }
29
+ callback();
30
+ }
31
+ });
32
+ }
33
+
34
+ // Original API
35
+ start(delay = 0) {
36
+ return RNBackgroundTimer.start(delay);
37
+ }
38
+
39
+ stop() {
40
+ return RNBackgroundTimer.stop();
41
+ }
42
+
43
+ runBackgroundTimer(callback, delay) {
44
+ const EventEmitter = Platform.select({
45
+ ios: () => NativeAppEventEmitter,
46
+ android: () => DeviceEventEmitter,
47
+ harmony: () => DeviceEventEmitter,
48
+ })();
49
+ this.start(0);
50
+ this.backgroundListener = EventEmitter.addListener(
51
+ 'backgroundTimer',
52
+ () => {
53
+ this.backgroundListener.remove();
54
+ this.backgroundClockMethod(callback, delay);
55
+ },
56
+ );
57
+ }
58
+
59
+ backgroundClockMethod(callback, delay) {
60
+ this.backgroundTimer = this.setTimeout(() => {
61
+ callback();
62
+ this.backgroundClockMethod(callback, delay);
63
+ }, delay);
64
+ }
65
+
66
+ stopBackgroundTimer() {
67
+ this.stop();
68
+ this.clearTimeout(this.backgroundTimer);
69
+ }
70
+
71
+ // New API, allowing for multiple timers
72
+ setTimeout(callback, timeout) {
73
+ this.uniqueId += 1;
74
+ const timeoutId = this.uniqueId;
75
+ this.callbacks[timeoutId] = {
76
+ callback,
77
+ interval: false,
78
+ timeout,
79
+ };
80
+ RNBackgroundTimer.setTimeout(timeoutId, timeout);
81
+ return timeoutId;
82
+ }
83
+
84
+ clearTimeout(timeoutId) {
85
+ if (this.callbacks[timeoutId]) {
86
+ delete this.callbacks[timeoutId];
87
+ // RNBackgroundTimer.clearTimeout(timeoutId);
88
+ }
89
+ }
90
+
91
+ setInterval(callback, timeout) {
92
+ this.uniqueId += 1;
93
+ const intervalId = this.uniqueId;
94
+ this.callbacks[intervalId] = {
95
+ callback,
96
+ interval: true,
97
+ timeout,
98
+ };
99
+ RNBackgroundTimer.setTimeout(intervalId, timeout);
100
+ return intervalId;
101
+ }
102
+
103
+ clearInterval(intervalId) {
104
+ if (this.callbacks[intervalId]) {
105
+ delete this.callbacks[intervalId];
106
+ // RNBackgroundTimer.clearTimeout(intervalId);
107
+ }
108
+ }
109
+ }
110
+
111
+ export default new BackgroundTimer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-background-timer",
3
- "version": "2.4.2-rc.1",
3
+ "version": "2.5.0-rc.1",
4
4
  "description": "Emit event periodically (even when app is in the background)",
5
5
  "keywords": [
6
6
  "react-native",
@@ -12,13 +12,13 @@
12
12
  "main": "index.js",
13
13
  "scripts": {
14
14
  "eslint": "eslint *.js",
15
- "eslint:fix": "yarn eslint --fix",
15
+ "eslint:fix": "yarn eslint --fix",
16
16
  "test": "echo \"Error: no test specified\" && exit 1",
17
17
  "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-background-timer --cpp-output-path ./harmony/background_timer/src/main/cpp/generated --ets-output-path ./harmony/background_timer/src/main/ets/generated --turbo-modules-spec-paths ./src/RNBackgroundTimerSpec.ts"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
21
- "url": "https://gitee.com/openharmony-sig/rntpc_react-native-background-timer.git"
21
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-background-timer.git"
22
22
  },
23
23
  "author": "David Ocetnik",
24
24
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "prettier": "^2.1.2",
41
41
  "react": "16.13.1",
42
42
  "react-native": "^0.63.3",
43
- "react-native-harmony": "npm:@react-native-oh/react-native-harmony@^0.72.38",
43
+ "react-native-harmony": "npm:@react-native-oh/react-native-harmony@^0.77.17",
44
44
  "react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@^0.0.27"
45
45
  },
46
46
  "husky": {
@@ -58,8 +58,6 @@
58
58
  "alias": "react-native-background-timer"
59
59
  },
60
60
  "publishConfig": {
61
- "registry": "https://registry.npmjs.com/",
62
- "access": "public"
61
+ "access": "public"
63
62
  }
64
-
65
- }
63
+ }
@@ -1,24 +0,0 @@
1
- require 'json'
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
-
5
- Pod::Spec.new do |s|
6
-
7
- s.name = package['name']
8
- s.version = package['version']
9
- s.summary = package['description']
10
- s.homepage = package['repository']['url']
11
- s.license = package['license']
12
- s.author = package['author']
13
- s.source = { :git => s.homepage, :tag => 'v#{s.version}' }
14
-
15
- s.requires_arc = true
16
- s.ios.deployment_target = '8.0'
17
- s.tvos.deployment_target = '9.0'
18
-
19
- s.preserve_paths = 'README.md', 'package.json', 'index.js'
20
- s.source_files = 'ios/*.{h,m}'
21
-
22
- s.dependency 'React-Core'
23
-
24
- end