ropegeo-common 1.20.0 → 1.20.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.
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { PagePreview } from './pagePreview';
|
|
2
|
+
import { DownloadJob } from '../../download/downloadJob';
|
|
3
|
+
import type { DownloadJobConfig } from '../../download/types';
|
|
2
4
|
export declare class OfflinePagePreview extends PagePreview {
|
|
3
5
|
readonly fetchType: "offline";
|
|
4
6
|
downloadedImagePath: string | null;
|
|
5
7
|
constructor(id: string, source: import('../pageDataSource').PageDataSource, downloadedImagePath: string | null, rating: number | null, ratingCount: number | null, title: string, regions: string[], aka: string[], difficultyRating: import('../difficulty/difficultyRating').DifficultyRating, mapData: string | null, externalLink: string | null, permit: import('../permitStatus').PermitStatus | null);
|
|
8
|
+
/**
|
|
9
|
+
* Re-downloads the page bundle by id/source (fetch-page-json path). Offline previews carry no
|
|
10
|
+
* `downloadFolder`, so this always uses the page-JSON fetch phase. Enables re-downloading a saved
|
|
11
|
+
* page whose bundle was removed (its preview stays offline while `downloadedPageViewPath` is null).
|
|
12
|
+
*/
|
|
13
|
+
toDownloadJob(config: DownloadJobConfig): DownloadJob;
|
|
6
14
|
static fromResult(result: unknown): OfflinePagePreview;
|
|
7
15
|
}
|
|
8
16
|
//# sourceMappingURL=offlinePagePreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offlinePagePreview.d.ts","sourceRoot":"","sources":["../../../src/models/previews/offlinePagePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA6B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"offlinePagePreview.d.ts","sourceRoot":"","sources":["../../../src/models/previews/offlinePagePreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA6B,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAS9D,qBAAa,kBAAmB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,SAAS,EAAG,SAAS,CAAU;IACxC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;gBAG/B,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,OAAO,mBAAmB,EAAE,cAAc,EAClD,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,GAAG,EAAE,MAAM,EAAE,EACb,gBAAgB,EAAE,OAAO,gCAAgC,EAAE,gBAAgB,EAC3E,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,MAAM,EAAE,OAAO,iBAAiB,EAAE,YAAY,GAAG,IAAI;IAkBzD;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,WAAW;IAyBrD,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,kBAAkB;CAUzD"}
|
|
@@ -2,12 +2,47 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OfflinePagePreview = void 0;
|
|
4
4
|
const pagePreview_1 = require("./pagePreview");
|
|
5
|
+
const downloadJob_1 = require("../../download/downloadJob");
|
|
6
|
+
const downloadPhase_1 = require("../../download/downloadPhase");
|
|
7
|
+
const downloadPhaseTitles_1 = require("../../download/helpers/downloadPhaseTitles");
|
|
8
|
+
const downloadDependencyKeys_1 = require("../../download/dependencies/downloadDependencyKeys");
|
|
9
|
+
const fetchPageJsonTaskDependency_1 = require("../../download/dependencies/fetchPageJsonTaskDependency");
|
|
10
|
+
const fetchPageJsonTask_1 = require("../../download/tasks/fetchPageJsonTask");
|
|
11
|
+
const pageDataSource_1 = require("../pageDataSource");
|
|
12
|
+
const pageViewType_1 = require("../pageViews/pageViewType");
|
|
5
13
|
class OfflinePagePreview extends pagePreview_1.PagePreview {
|
|
6
14
|
constructor(id, source, downloadedImagePath, rating, ratingCount, title, regions, aka, difficultyRating, mapData, externalLink, permit) {
|
|
7
15
|
super(id, source, rating, ratingCount, title, regions, aka, difficultyRating, mapData, externalLink, permit);
|
|
8
16
|
this.fetchType = 'offline';
|
|
9
17
|
this.downloadedImagePath = downloadedImagePath;
|
|
10
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Re-downloads the page bundle by id/source (fetch-page-json path). Offline previews carry no
|
|
21
|
+
* `downloadFolder`, so this always uses the page-JSON fetch phase. Enables re-downloading a saved
|
|
22
|
+
* page whose bundle was removed (its preview stays offline while `downloadedPageViewPath` is null).
|
|
23
|
+
*/
|
|
24
|
+
toDownloadJob(config) {
|
|
25
|
+
const pageViewType = this.source === pageDataSource_1.PageDataSource.Ropewiki
|
|
26
|
+
? pageViewType_1.PageViewType.Ropewiki
|
|
27
|
+
: null;
|
|
28
|
+
if (pageViewType == null) {
|
|
29
|
+
throw new Error(`Unsupported page preview source "${String(this.source)}"`);
|
|
30
|
+
}
|
|
31
|
+
const fetchPageTask = new fetchPageJsonTask_1.FetchPageJsonTask();
|
|
32
|
+
const fetchPagePhase = new downloadPhase_1.DownloadPhase({
|
|
33
|
+
title: (0, downloadPhaseTitles_1.titleForPhase)([fetchPageTask]),
|
|
34
|
+
tasks: [fetchPageTask],
|
|
35
|
+
});
|
|
36
|
+
return new downloadJob_1.DownloadJob({
|
|
37
|
+
pageId: this.id,
|
|
38
|
+
pageViewType,
|
|
39
|
+
config,
|
|
40
|
+
phases: [(0, downloadPhaseTitles_1.buildDeleteStoredPagePhase)(), fetchPagePhase],
|
|
41
|
+
taskDependencies: {
|
|
42
|
+
[downloadDependencyKeys_1.DownloadDependencyKeys.FetchPageJson]: fetchPageJsonTaskDependency_1.FetchPageJsonTaskDependency.fromPreview(this, config),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
11
46
|
static fromResult(result) {
|
|
12
47
|
if (result == null || typeof result !== 'object') {
|
|
13
48
|
throw new Error('OfflinePagePreview result must be an object');
|