swpp-backends 1.2.2 → 2.0.0
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/dist/DomBuilder.js +27 -0
- package/dist/FileAnalyzer.js +109 -128
- package/dist/ServiceWorkerBuilder.js +6 -2
- package/dist/SwppRules.js +60 -73
- package/dist/UpdateJsonBuilder.js +51 -57
- package/dist/Utils.js +39 -12
- package/dist/Variant.js +111 -0
- package/dist/VersionAnalyzer.js +13 -17
- package/dist/index.js +11 -7
- package/package.json +1 -1
- package/types/DomBuilder.d.ts +6 -0
- package/types/FileAnalyzer.d.ts +12 -37
- package/types/SwppConfig.d.ts +4 -0
- package/types/SwppRules.d.ts +5 -11
- package/types/UpdateJsonBuilder.d.ts +9 -16
- package/types/Utils.d.ts +3 -2
- package/types/Variant.d.ts +58 -0
- package/types/VersionAnalyzer.d.ts +2 -4
- package/types/index.d.ts +13 -6
package/types/Utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Response } from 'node-fetch';
|
|
1
2
|
export declare function error(type: string, message: string): void;
|
|
2
3
|
export declare function warn(type: string, message: string): void;
|
|
3
4
|
export interface EjectCache {
|
|
@@ -32,7 +33,7 @@ export declare function getSource(obj: any, typeChecker?: ((name: string) => boo
|
|
|
32
33
|
*
|
|
33
34
|
* **调用该函数前必须调用过 [loadRules]**
|
|
34
35
|
*/
|
|
35
|
-
export declare function fetchFile(link: string): Promise<
|
|
36
|
+
export declare function fetchFile(link: string): Promise<Response>;
|
|
36
37
|
/**
|
|
37
38
|
* 替换编译期的 URL(CDN 竞速)
|
|
38
39
|
*
|
|
@@ -40,4 +41,4 @@ export declare function fetchFile(link: string): Promise<import("node-fetch").Re
|
|
|
40
41
|
*/
|
|
41
42
|
export declare function replaceDevRequest(link: string): string[] | string;
|
|
42
43
|
/** 深度冻结一个对象,这将使得无法修改对象中的任何值,也无法添加新的值 */
|
|
43
|
-
export declare function deepFreeze(obj:
|
|
44
|
+
export declare function deepFreeze<T>(obj: T): T;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { VersionJson, VersionMap } from './FileAnalyzer';
|
|
2
|
+
import { SwppRules } from './SwppRules';
|
|
3
|
+
import { UpdateJson } from './UpdateJsonBuilder';
|
|
4
|
+
import { AnalyzeResult } from './VersionAnalyzer';
|
|
5
|
+
/** 创建一个变量 */
|
|
6
|
+
export declare function writeVariant<T>(key: string, value: T): T;
|
|
7
|
+
/** 读取一个变量 */
|
|
8
|
+
export declare function readVariant(key: string): any;
|
|
9
|
+
/** 移除一个变量 */
|
|
10
|
+
export declare function deleteVariant(key: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* 读取最后一次构建的 rules
|
|
13
|
+
*
|
|
14
|
+
* **执行该函数前必须调用过 [loadRules]**
|
|
15
|
+
*/
|
|
16
|
+
export declare function readRules(): SwppRules;
|
|
17
|
+
/**
|
|
18
|
+
* 读取最后一次加载的 version json
|
|
19
|
+
*
|
|
20
|
+
* + **执行该函数前必须调用过 [loadRules]**
|
|
21
|
+
* + **调用该函数前必须调用过 [loadCacheJson]**
|
|
22
|
+
*/
|
|
23
|
+
export declare function readOldVersionJson(): VersionJson | null;
|
|
24
|
+
/**
|
|
25
|
+
* 读取最后一次构建的 VersionJson
|
|
26
|
+
*
|
|
27
|
+
* + **执行该函数前必须调用过 [loadRules]**
|
|
28
|
+
* + **调用该函数前必须调用过 [loadCacheJson]**
|
|
29
|
+
* + **执行该函数前必须调用过 [buildVersionJson]**
|
|
30
|
+
* + **执行该函数前必须调用过 [calcEjectValues]**
|
|
31
|
+
*/
|
|
32
|
+
export declare function readNewVersionJson(): VersionJson;
|
|
33
|
+
/**
|
|
34
|
+
* 读取新旧版本文件合并后的版本地图
|
|
35
|
+
*
|
|
36
|
+
* + **执行该函数前必须调用过 [loadRules]**
|
|
37
|
+
* + **调用该函数前必须调用过 [loadCacheJson]**
|
|
38
|
+
* + **执行该函数前必须调用过 [buildVersionJson]**
|
|
39
|
+
* + **执行该函数前必须调用过 [calcEjectValues]**
|
|
40
|
+
*/
|
|
41
|
+
export declare function readMergeVersionMap(): VersionMap;
|
|
42
|
+
/**
|
|
43
|
+
* 读取最后一次加载的版本文件
|
|
44
|
+
*
|
|
45
|
+
* + **调用该函数前必须调用过 [loadRules]**
|
|
46
|
+
* + **调用该函数前必须调用过 [loadUpdateJson]**
|
|
47
|
+
*/
|
|
48
|
+
export declare function readUpdateJson(): UpdateJson | null;
|
|
49
|
+
/**
|
|
50
|
+
* 读取分析结果
|
|
51
|
+
*
|
|
52
|
+
* + **执行该函数前必须调用过 [loadRules]**
|
|
53
|
+
* + **调用该函数前必须调用过 [loadCacheJson]**
|
|
54
|
+
* + **调用该函数前必须调用过 [analyze]**
|
|
55
|
+
*/
|
|
56
|
+
export declare function readAnalyzeResult(): AnalyzeResult;
|
|
57
|
+
/** 读取一个事件 */
|
|
58
|
+
export declare function readEvent<T>(key: string): T;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { VersionJson } from './FileAnalyzer';
|
|
2
1
|
/**
|
|
3
2
|
* 分析两个版本信息的不同
|
|
4
3
|
*
|
|
5
4
|
* + **执行该函数前必须调用过 [loadRules]**
|
|
6
5
|
* + **调用该函数前必须调用过 [loadCacheJson]**
|
|
7
|
-
*
|
|
8
|
-
* @param version 新的版本信息
|
|
6
|
+
* + **调用该函数前必须调用过 [buildVersionJson]**
|
|
9
7
|
*/
|
|
10
|
-
export declare function
|
|
8
|
+
export declare function analyzeVersion(): AnalyzeResult;
|
|
11
9
|
/** 手动添加一个要刷新的 URL */
|
|
12
10
|
export declare function refreshUrl(url: string): void;
|
|
13
11
|
export interface AnalyzeResult {
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { readEjectData, getSource, fetchFile, replaceDevRequest, calcEjectValues, deepFreeze } from './Utils';
|
|
2
|
-
import { isExclude, isStable, loadVersionJson,
|
|
2
|
+
import { isExclude, isStable, loadVersionJson, buildVersionJson, eachAllLinkInUrl, findCache, findFileHandler, replaceRequest, submitCacheInfo, submitExternalUrl, registryFileHandler } from './FileAnalyzer';
|
|
3
3
|
import { buildServiceWorker } from './ServiceWorkerBuilder';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { loadRules, addRulesMapEvent } from './SwppRules';
|
|
5
|
+
import { loadUpdateJson, submitChange, getShorthand, buildUpdateJson } from './UpdateJsonBuilder';
|
|
6
|
+
import { readMergeVersionMap, readNewVersionJson, readOldVersionJson, readRules, readUpdateJson, readAnalyzeResult, writeVariant, readVariant, deleteVariant } from './Variant';
|
|
7
|
+
import { refreshUrl, analyzeVersion } from './VersionAnalyzer';
|
|
8
|
+
import { buildDomJs } from './DomBuilder';
|
|
7
9
|
declare const _default: {
|
|
8
10
|
version: string;
|
|
9
11
|
cache: {
|
|
@@ -13,13 +15,15 @@ declare const _default: {
|
|
|
13
15
|
readMergeVersionMap: typeof readMergeVersionMap;
|
|
14
16
|
readOldVersionJson: typeof readOldVersionJson;
|
|
15
17
|
readNewVersionJson: typeof readNewVersionJson;
|
|
18
|
+
readAnalyzeResult: typeof readAnalyzeResult;
|
|
16
19
|
};
|
|
17
20
|
builder: {
|
|
18
21
|
buildServiceWorker: typeof buildServiceWorker;
|
|
22
|
+
buildDomJs: typeof buildDomJs;
|
|
19
23
|
buildVersionJson: typeof buildVersionJson;
|
|
20
|
-
|
|
24
|
+
buildUpdateJson: typeof buildUpdateJson;
|
|
21
25
|
calcEjectValues: typeof calcEjectValues;
|
|
22
|
-
|
|
26
|
+
analyzeVersion: typeof analyzeVersion;
|
|
23
27
|
};
|
|
24
28
|
loader: {
|
|
25
29
|
loadRules: typeof loadRules;
|
|
@@ -46,6 +50,9 @@ declare const _default: {
|
|
|
46
50
|
findFileHandler: typeof findFileHandler;
|
|
47
51
|
eachAllLinkInUrl: typeof eachAllLinkInUrl;
|
|
48
52
|
deepFreeze: typeof deepFreeze;
|
|
53
|
+
writeVariant: typeof writeVariant;
|
|
54
|
+
readVariant: typeof readVariant;
|
|
55
|
+
deleteVariant: typeof deleteVariant;
|
|
49
56
|
};
|
|
50
57
|
};
|
|
51
58
|
export default _default;
|