@akylas/nativescript-app-utils 2.2.4 → 2.2.6
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 +8 -0
- package/package.json +2 -2
- package/worker/BaseWorkerHandler.d.ts +2 -1
- package/worker/BaseWorkerHandler.js +32 -31
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.2.6](https://github.com/akylas/nativescript-app-utils/compare/v2.2.5...v2.2.6) (2025-02-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @akylas/nativescript-app-utils
|
|
9
|
+
|
|
10
|
+
## [2.2.5](https://github.com/akylas/nativescript-app-utils/compare/v2.2.4...v2.2.5) (2025-02-07)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @akylas/nativescript-app-utils
|
|
13
|
+
|
|
6
14
|
## [2.2.4](https://github.com/akylas/nativescript-app-utils/compare/v2.2.3...v2.2.4) (2025-02-07)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @akylas/nativescript-app-utils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akylas/nativescript-app-utils",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "Provides API for changing the styles of SystemUI (StatusBar, NavigationBar...) on iOS.",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@nativescript-community/ui-share-file": "1.3.3"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "8b4cfc5a0f21f84bda9b5894cb4580bd560ab59d"
|
|
70
70
|
}
|
|
@@ -3,7 +3,8 @@ import type { BaseWorker, WorkerEventType, WorkerPostEvent } from './BaseWorker'
|
|
|
3
3
|
import Queue from './queue';
|
|
4
4
|
export default abstract class BaseWorkerHandler<T extends BaseWorker> extends Observable {
|
|
5
5
|
private createWorker;
|
|
6
|
-
|
|
6
|
+
private startWorkerTimeout;
|
|
7
|
+
constructor(createWorker: () => Worker, startWorkerTimeout?: number);
|
|
7
8
|
worker: T;
|
|
8
9
|
messagePromises: {
|
|
9
10
|
[key: string]: {
|
|
@@ -3,9 +3,10 @@ import { Observable } from '@nativescript/core';
|
|
|
3
3
|
import { time } from '@nativescript/core/profiling';
|
|
4
4
|
import Queue from './queue';
|
|
5
5
|
export default class BaseWorkerHandler extends Observable {
|
|
6
|
-
constructor(createWorker) {
|
|
6
|
+
constructor(createWorker, startWorkerTimeout = 1000) {
|
|
7
7
|
super();
|
|
8
8
|
this.createWorker = createWorker;
|
|
9
|
+
this.startWorkerTimeout = startWorkerTimeout;
|
|
9
10
|
this.messagePromises = {};
|
|
10
11
|
this.queue = new Queue();
|
|
11
12
|
}
|
|
@@ -71,7 +72,7 @@ export default class BaseWorkerHandler extends Observable {
|
|
|
71
72
|
};
|
|
72
73
|
const timeoutTimer = setTimeout(() => {
|
|
73
74
|
reject(new Error('failed_to_start_worker'));
|
|
74
|
-
},
|
|
75
|
+
}, this.startWorkerTimeout);
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
this.worker.postMessage(data);
|
|
@@ -82,36 +83,36 @@ export default class BaseWorkerHandler extends Observable {
|
|
|
82
83
|
if (!isResponse && (id || timeout)) {
|
|
83
84
|
return new Promise(async (resolve, reject) => {
|
|
84
85
|
// const id = Date.now().valueOf();
|
|
85
|
-
id = id || time();
|
|
86
|
-
this.messagePromises[id] = this.messagePromises[id] || [];
|
|
87
|
-
let timeoutTimer;
|
|
88
|
-
if (timeout > 0) {
|
|
89
|
-
timeoutTimer = setTimeout(() => {
|
|
90
|
-
// we need to try catch because the simple fact of creating a new Error actually throws.
|
|
91
|
-
// so we will get an uncaughtException
|
|
92
|
-
try {
|
|
93
|
-
reject(new Error('timeout'));
|
|
94
|
-
}
|
|
95
|
-
catch { }
|
|
96
|
-
delete this.messagePromises[id];
|
|
97
|
-
}, timeout);
|
|
98
|
-
}
|
|
99
|
-
this.messagePromises[id].push({ reject, resolve, timeoutTimer });
|
|
100
|
-
const keys = Object.keys(nativeData);
|
|
101
|
-
const nativeDataKeysPrefix = Date.now() + '$$$';
|
|
102
|
-
keys.forEach((k) => {
|
|
103
|
-
setWorkerContextValue(nativeDataKeysPrefix + k, nativeData[k]._native || nativeData[k]);
|
|
104
|
-
});
|
|
105
|
-
const data = {
|
|
106
|
-
error: !!error ? JSON.stringify(error.toJSON() ? error.toJSON() : { message: error.toString(), ...error }) : undefined,
|
|
107
|
-
id,
|
|
108
|
-
nativeDataKeysPrefix,
|
|
109
|
-
messageData: !!messageData ? JSON.stringify(messageData) : undefined,
|
|
110
|
-
nativeData: keys.map((k) => nativeDataKeysPrefix + k),
|
|
111
|
-
type
|
|
112
|
-
};
|
|
113
|
-
// DEV_LOG && console.info('Sync', 'postMessage', JSON.stringify(data));
|
|
114
86
|
try {
|
|
87
|
+
id = id || time();
|
|
88
|
+
this.messagePromises[id] = this.messagePromises[id] || [];
|
|
89
|
+
let timeoutTimer;
|
|
90
|
+
if (timeout > 0) {
|
|
91
|
+
timeoutTimer = setTimeout(() => {
|
|
92
|
+
// we need to try catch because the simple fact of creating a new Error actually throws.
|
|
93
|
+
// so we will get an uncaughtException
|
|
94
|
+
try {
|
|
95
|
+
reject(new Error('timeout'));
|
|
96
|
+
}
|
|
97
|
+
catch { }
|
|
98
|
+
delete this.messagePromises[id];
|
|
99
|
+
}, timeout);
|
|
100
|
+
}
|
|
101
|
+
this.messagePromises[id].push({ reject, resolve, timeoutTimer });
|
|
102
|
+
const keys = nativeData ? Object.keys(nativeData) : [];
|
|
103
|
+
const nativeDataKeysPrefix = Date.now() + '$$$';
|
|
104
|
+
keys.forEach((k) => {
|
|
105
|
+
setWorkerContextValue(nativeDataKeysPrefix + k, nativeData[k]._native || nativeData[k]);
|
|
106
|
+
});
|
|
107
|
+
const data = {
|
|
108
|
+
error: !!error ? JSON.stringify(error.toJSON() ? error.toJSON() : { message: error.toString(), ...error }) : undefined,
|
|
109
|
+
id,
|
|
110
|
+
nativeDataKeysPrefix,
|
|
111
|
+
messageData: !!messageData ? JSON.stringify(messageData) : undefined,
|
|
112
|
+
nativeData: keys.map((k) => nativeDataKeysPrefix + k),
|
|
113
|
+
type
|
|
114
|
+
};
|
|
115
|
+
// DEV_LOG && console.info('Sync', 'postMessage', JSON.stringify(data));
|
|
115
116
|
await this.internalSendMessageToWorker(data);
|
|
116
117
|
}
|
|
117
118
|
catch (error) {
|