@react-native-ohos/react-native-background-timer 2.4.2-rc.1 → 2.4.2-rc.4
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.
- package/CHANGELOG.md +0 -0
- package/COMMITTERS.md +1 -5
- package/OAT.xml +3 -1
- package/README.md +1 -1
- package/example/.eslintrc +18 -0
- package/example/.node-version +6 -0
- package/example/.prettierrc.js +12 -0
- package/example/.watchmanconfig +6 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +10 -0
- package/example/contexts.ts +8 -0
- package/example/harmony/AppScope/app.json5 +10 -0
- package/example/harmony/AppScope/resources/base/element/string.json +8 -0
- package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/example/harmony/build-profile.template.json5 +40 -0
- package/example/harmony/codelinter.json +32 -0
- package/example/harmony/entry/build-profile.json5 +19 -0
- package/example/harmony/entry/hvigorfile.ts +9 -0
- package/example/harmony/entry/oh-package.json5 +11 -0
- package/example/harmony/entry/src/main/cpp/CMakeLists.txt +34 -0
- package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +19 -0
- package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +15 -0
- package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
- package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
- package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +19 -0
- package/example/harmony/entry/src/main/ets/pages/Index.ets +118 -0
- package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
- package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +43 -0
- package/example/harmony/entry/src/main/module.json5 +52 -0
- package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
- package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
- package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
- package/example/harmony/hvigor/hvigor-config.json5 +21 -0
- package/example/harmony/hvigorfile.ts +8 -0
- package/example/harmony/oh-package.json5 +12 -0
- package/example/index.js +10 -0
- package/example/jest.config.js +10 -0
- package/example/metro.config.js +29 -0
- package/example/package.json +66 -0
- package/example/react-native.config.js +10 -0
- package/example/src/BackgroundTimerDemo.tsx +166 -0
- package/harmony/background_timer/Index.ets +3 -1
- package/harmony/background_timer/hvigorfile.ts +6 -6
- package/harmony/background_timer/oh-package.json5 +10 -10
- package/harmony/background_timer/src/main/cpp/CMakeLists.txt +13 -13
- package/harmony/background_timer/src/main/cpp/generated/RNOH/generated/turbo_modules/BackgroundTimerTurboModule.cpp +21 -21
- package/harmony/background_timer/src/main/cpp/generated/RNOH/generated/turbo_modules/BackgroundTimerTurboModule.h +16 -16
- package/harmony/background_timer/src/main/ets/{BackgroundTimerPackage.ts → BackgroundTimerPackage.ets} +2 -1
- package/harmony/background_timer/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/background_timer/src/main/ets/generated/index.ets +5 -5
- package/harmony/background_timer/src/main/ets/generated/ts.ts +6 -6
- package/harmony/background_timer/src/main/ets/generated/turboModules/BackgroundTimerTurboModule.ts +18 -18
- package/harmony/background_timer/src/main/ets/generated/turboModules/ts.ts +5 -5
- package/harmony/background_timer/src/main/resources/base/element/string.json +8 -8
- package/harmony/background_timer/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/background_timer/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/background_timer.har +0 -0
- package/index.js +111 -111
- package/package.json +13 -8
- package/react-native-background-timer.podspec +0 -24
- /package/harmony/background_timer/src/main/cpp/{ReactNativeOhosReactNativeBackgroundTimerPackage.h → BackgroundTimerPackage.h} +0 -0
- /package/harmony/background_timer/src/main/ets/{ts.ts → ts.ets} +0 -0
- /package/harmony/background_timer/{ts.ts → ts.ets} +0 -0
package/harmony/background_timer/src/main/ets/generated/turboModules/BackgroundTimerTurboModule.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
-
|
|
7
|
-
export namespace BackgroundTimerTurboModule {
|
|
8
|
-
export const NAME = 'BackgroundTimerTurboModule' as const
|
|
9
|
-
|
|
10
|
-
export interface Spec {
|
|
11
|
-
start(delay: number): void;
|
|
12
|
-
|
|
13
|
-
stop(): void;
|
|
14
|
-
|
|
15
|
-
setTimeout(timeoutId: number, timeout: number): void;
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
+
|
|
7
|
+
export namespace BackgroundTimerTurboModule {
|
|
8
|
+
export const NAME = 'BackgroundTimerTurboModule' as const
|
|
9
|
+
|
|
10
|
+
export interface Spec {
|
|
11
|
+
start(delay: number): void;
|
|
12
|
+
|
|
13
|
+
stop(): void;
|
|
14
|
+
|
|
15
|
+
setTimeout(timeoutId: number, timeout: number): void;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from "./BackgroundTimerTurboModule"
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from "./BackgroundTimerTurboModule"
|
|
@@ -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.
|
|
3
|
+
"version": "2.4.2-rc.4",
|
|
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://
|
|
21
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-background-timer.git"
|
|
22
22
|
},
|
|
23
23
|
"author": "David Ocetnik",
|
|
24
24
|
"license": "MIT",
|
|
@@ -55,11 +55,16 @@
|
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
57
|
"harmony": {
|
|
58
|
-
"alias": "react-native-background-timer"
|
|
58
|
+
"alias": "react-native-background-timer",
|
|
59
|
+
"autolinking": {
|
|
60
|
+
"etsPackageClassName":"BackgroundTimerPackage",
|
|
61
|
+
"cppPackageClassName":"BackgroundTimerPackage",
|
|
62
|
+
"cmakeLibraryTargetName": "rnoh_background_timer",
|
|
63
|
+
"ohPackageName": "@react-native-ohos/react-native-background-timer"
|
|
64
|
+
}
|
|
59
65
|
},
|
|
60
66
|
"publishConfig": {
|
|
61
|
-
"registry": "https://registry.npmjs.
|
|
62
|
-
|
|
67
|
+
"registry": "https://registry.npmjs.org/",
|
|
68
|
+
"access": "public"
|
|
63
69
|
}
|
|
64
|
-
|
|
65
|
-
}
|
|
70
|
+
}
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|