incyclist-services 1.9.37 → 1.9.39
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/lib/cjs/routes/base/parsers/epm.js +15 -20
- package/lib/cjs/utils/fileurl.js +3 -2
- package/lib/cjs/video/resolvePlaybackUrl.js +10 -2
- package/lib/esm/routes/base/parsers/epm.js +15 -20
- package/lib/esm/utils/fileurl.js +1 -1
- package/lib/esm/video/resolvePlaybackUrl.js +10 -2
- package/lib/types/utils/fileurl.d.ts +1 -0
- package/package.json +2 -2
|
@@ -167,31 +167,26 @@ class EPMParser extends xml_1.XMLParser {
|
|
|
167
167
|
point.elevation = prevElevation + gainToPoint;
|
|
168
168
|
}
|
|
169
169
|
addVideoSpeed(route) {
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
const mappings = route.video.mappings;
|
|
171
|
+
const lastMapping = mappings.at(-1);
|
|
172
172
|
let videoIdx = 0;
|
|
173
173
|
route.points.forEach((p, idx) => {
|
|
174
174
|
if (idx === 0) {
|
|
175
|
-
p.videoSpeed =
|
|
176
|
-
p.videoTime =
|
|
177
|
-
|
|
178
|
-
prevTime = p.videoTime;
|
|
175
|
+
p.videoSpeed = mappings[0].videoSpeed;
|
|
176
|
+
p.videoTime = mappings[0].time;
|
|
177
|
+
return;
|
|
179
178
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
videoIdx++;
|
|
187
|
-
if (videoIdx < route.video.mappings.length) {
|
|
188
|
-
p.videoSpeed = route.video.mappings[videoIdx].videoSpeed;
|
|
189
|
-
const v = p.videoSpeed / 3.6;
|
|
190
|
-
p.videoTime = route.video.mappings[videoIdx].time - (route.video.mappings[videoIdx].distance - p.routeDistance) / v;
|
|
191
|
-
prevSpeed = p.videoSpeed;
|
|
192
|
-
prevTime = p.videoTime;
|
|
193
|
-
}
|
|
179
|
+
while (videoIdx < mappings.length && p.routeDistance > mappings[videoIdx].distance)
|
|
180
|
+
videoIdx++;
|
|
181
|
+
if (videoIdx >= mappings.length) {
|
|
182
|
+
p.videoSpeed = lastMapping.videoSpeed;
|
|
183
|
+
p.videoTime = lastMapping.time;
|
|
184
|
+
return;
|
|
194
185
|
}
|
|
186
|
+
const mapping = mappings[videoIdx];
|
|
187
|
+
p.videoSpeed = mapping.videoSpeed;
|
|
188
|
+
const v = p.videoSpeed / 3.6;
|
|
189
|
+
p.videoTime = mapping.time - (mapping.distance - p.routeDistance) / v;
|
|
195
190
|
});
|
|
196
191
|
}
|
|
197
192
|
parseEpp(data, route) {
|
package/lib/cjs/utils/fileurl.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeFileUrl = void 0;
|
|
3
|
+
exports.isWindows = exports.normalizeFileUrl = void 0;
|
|
4
4
|
const api_1 = require("../api");
|
|
5
5
|
const normalizeFileUrl = (url) => {
|
|
6
|
-
if (!isWindows())
|
|
6
|
+
if (!(0, exports.isWindows)())
|
|
7
7
|
return url;
|
|
8
8
|
return url?.replace(/^(file|video):\/\/+(?=[A-Za-z]:(?:[\\/%]|$))/, '$1:///');
|
|
9
9
|
};
|
|
10
10
|
exports.normalizeFileUrl = normalizeFileUrl;
|
|
11
11
|
const isWindows = () => (0, api_1.getBindings)().appInfo?.getOS?.()?.platform === 'win32';
|
|
12
|
+
exports.isWindows = isWindows;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolvePlaybackUrl = void 0;
|
|
4
|
+
const fileurl_1 = require("../utils/fileurl");
|
|
4
5
|
const resolvePlaybackUrl = (url) => {
|
|
5
6
|
if (!url)
|
|
6
7
|
return undefined;
|
|
@@ -9,13 +10,20 @@ const resolvePlaybackUrl = (url) => {
|
|
|
9
10
|
if (fileName.startsWith('incyclist:'))
|
|
10
11
|
fileName = fileName.replace('incyclist:', 'file:');
|
|
11
12
|
if (fileName.startsWith('video:') && !lc.endsWith('.avi'))
|
|
12
|
-
return fileName.replace('video:', 'file:');
|
|
13
|
+
return restoreWindowsSeparators(fileName.replace('video:', 'file:'));
|
|
13
14
|
if (fileName.startsWith('video:') && lc.endsWith('.avi'))
|
|
14
15
|
return fileName;
|
|
15
|
-
if (fileName.startsWith('file:')
|
|
16
|
+
if (fileName.startsWith('file:'))
|
|
17
|
+
return restoreWindowsSeparators(fileName);
|
|
18
|
+
if (fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
|
|
16
19
|
return fileName;
|
|
17
20
|
if (fileName.startsWith('content:'))
|
|
18
21
|
return fileName;
|
|
19
22
|
return `./${fileName}`;
|
|
20
23
|
};
|
|
21
24
|
exports.resolvePlaybackUrl = resolvePlaybackUrl;
|
|
25
|
+
const restoreWindowsSeparators = (url) => {
|
|
26
|
+
if (!(0, fileurl_1.isWindows)() || !/^file:\/\/\/[A-Za-z]:/.test(url))
|
|
27
|
+
return url;
|
|
28
|
+
return url.replace(/%5C/gi, '\\');
|
|
29
|
+
};
|
|
@@ -164,31 +164,26 @@ export class EPMParser extends XMLParser {
|
|
|
164
164
|
point.elevation = prevElevation + gainToPoint;
|
|
165
165
|
}
|
|
166
166
|
addVideoSpeed(route) {
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
const mappings = route.video.mappings;
|
|
168
|
+
const lastMapping = mappings.at(-1);
|
|
169
169
|
let videoIdx = 0;
|
|
170
170
|
route.points.forEach((p, idx) => {
|
|
171
171
|
if (idx === 0) {
|
|
172
|
-
p.videoSpeed =
|
|
173
|
-
p.videoTime =
|
|
174
|
-
|
|
175
|
-
prevTime = p.videoTime;
|
|
172
|
+
p.videoSpeed = mappings[0].videoSpeed;
|
|
173
|
+
p.videoTime = mappings[0].time;
|
|
174
|
+
return;
|
|
176
175
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
videoIdx++;
|
|
184
|
-
if (videoIdx < route.video.mappings.length) {
|
|
185
|
-
p.videoSpeed = route.video.mappings[videoIdx].videoSpeed;
|
|
186
|
-
const v = p.videoSpeed / 3.6;
|
|
187
|
-
p.videoTime = route.video.mappings[videoIdx].time - (route.video.mappings[videoIdx].distance - p.routeDistance) / v;
|
|
188
|
-
prevSpeed = p.videoSpeed;
|
|
189
|
-
prevTime = p.videoTime;
|
|
190
|
-
}
|
|
176
|
+
while (videoIdx < mappings.length && p.routeDistance > mappings[videoIdx].distance)
|
|
177
|
+
videoIdx++;
|
|
178
|
+
if (videoIdx >= mappings.length) {
|
|
179
|
+
p.videoSpeed = lastMapping.videoSpeed;
|
|
180
|
+
p.videoTime = lastMapping.time;
|
|
181
|
+
return;
|
|
191
182
|
}
|
|
183
|
+
const mapping = mappings[videoIdx];
|
|
184
|
+
p.videoSpeed = mapping.videoSpeed;
|
|
185
|
+
const v = p.videoSpeed / 3.6;
|
|
186
|
+
p.videoTime = mapping.time - (mapping.distance - p.routeDistance) / v;
|
|
192
187
|
});
|
|
193
188
|
}
|
|
194
189
|
parseEpp(data, route) {
|
package/lib/esm/utils/fileurl.js
CHANGED
|
@@ -4,4 +4,4 @@ export const normalizeFileUrl = (url) => {
|
|
|
4
4
|
return url;
|
|
5
5
|
return url?.replace(/^(file|video):\/\/+(?=[A-Za-z]:(?:[\\/%]|$))/, '$1:///');
|
|
6
6
|
};
|
|
7
|
-
const isWindows = () => getBindings().appInfo?.getOS?.()?.platform === 'win32';
|
|
7
|
+
export const isWindows = () => getBindings().appInfo?.getOS?.()?.platform === 'win32';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isWindows } from '../utils/fileurl';
|
|
1
2
|
export const resolvePlaybackUrl = (url) => {
|
|
2
3
|
if (!url)
|
|
3
4
|
return undefined;
|
|
@@ -6,12 +7,19 @@ export const resolvePlaybackUrl = (url) => {
|
|
|
6
7
|
if (fileName.startsWith('incyclist:'))
|
|
7
8
|
fileName = fileName.replace('incyclist:', 'file:');
|
|
8
9
|
if (fileName.startsWith('video:') && !lc.endsWith('.avi'))
|
|
9
|
-
return fileName.replace('video:', 'file:');
|
|
10
|
+
return restoreWindowsSeparators(fileName.replace('video:', 'file:'));
|
|
10
11
|
if (fileName.startsWith('video:') && lc.endsWith('.avi'))
|
|
11
12
|
return fileName;
|
|
12
|
-
if (fileName.startsWith('file:')
|
|
13
|
+
if (fileName.startsWith('file:'))
|
|
14
|
+
return restoreWindowsSeparators(fileName);
|
|
15
|
+
if (fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
|
|
13
16
|
return fileName;
|
|
14
17
|
if (fileName.startsWith('content:'))
|
|
15
18
|
return fileName;
|
|
16
19
|
return `./${fileName}`;
|
|
17
20
|
};
|
|
21
|
+
const restoreWindowsSeparators = (url) => {
|
|
22
|
+
if (!isWindows() || !/^file:\/\/\/[A-Za-z]:/.test(url))
|
|
23
|
+
return url;
|
|
24
|
+
return url.replace(/%5C/gi, '\\');
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.39",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.27"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@garmin/fitsdk": "^21.222.0",
|
|
9
9
|
"axios": "^1.21.1",
|
|
10
|
-
"incyclist-devices": "^3.0.
|
|
10
|
+
"incyclist-devices": "^3.0.52",
|
|
11
11
|
"promise.any": "^2.0.6",
|
|
12
12
|
"semver": "^7.8.6",
|
|
13
13
|
"tcx-builder": "^1.1.1",
|