-
Notifications
You must be signed in to change notification settings - Fork 324
Expand file tree
/
Copy pathstruct.ts
More file actions
117 lines (103 loc) · 2.54 KB
/
struct.ts
File metadata and controls
117 lines (103 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import type { Script } from "@App/app/repo/scripts";
import type { Subscribe } from "@App/app/repo/subscribe";
export type ResourceMeta = {
name: string;
url: string;
ts: number;
mimetype?: string;
};
export type ResourceBackup = {
meta: ResourceMeta;
// text数据
source?: string;
// 二进制数据
base64: string;
};
export type ValueStorage = {
data: { [key: string]: any };
ts: number;
};
export type ScriptOptions = {
check_for_updates: boolean;
comment: string | null;
compat_foreach: boolean;
compat_metadata: boolean;
compat_prototypes: boolean;
compat_wrappedjsobject: boolean;
compatopts_for_requires: boolean;
noframes: boolean | null;
override: {
merge_connects: boolean;
merge_excludes: boolean;
merge_includes: boolean;
merge_matches: boolean;
orig_connects: Array<string>;
orig_excludes: Array<string>;
orig_includes: Array<string>;
orig_matches: Array<string>;
orig_noframes: boolean | null;
orig_run_at: string;
use_blockers: Array<string>;
use_connects: Array<string>;
use_excludes: Array<string>;
use_includes: Array<string>;
use_matches: Array<string>;
};
run_at: string | null;
};
export type ScriptMeta = {
name: string;
uuid: string; // 此uuid是对tm的兼容处理
sc_uuid: string; // 脚本猫uuid
modified: number;
file_url: string;
subscribe_url?: string;
};
export type ScriptOptionsFile = {
options: ScriptOptions;
settings: { enabled: boolean; position: number };
meta: ScriptMeta;
};
export type ScriptBackupData = {
code: string;
options?: ScriptOptionsFile;
storage: ValueStorage;
requires: ResourceBackup[];
requiresCss: ResourceBackup[];
resources: ResourceBackup[];
// 为了兼容暴力猴而设置的字段
enabled?: boolean;
lastModificationDate?: number;
};
export type ScriptData = ScriptBackupData & {
script?: { script: Script; oldScript?: Script };
install: boolean;
error?: string;
};
export type SubscribeData = SubscribeBackupData & {
subscribe?: Subscribe;
install: boolean;
};
export type SubscribeScript = {
uuid: string;
url: string;
};
export type SubscribeMeta = {
name: string;
modified: number;
url: string;
};
export type SubscribeOptionsFile = {
settings: { enabled: boolean };
scripts: Record<string, SubscribeScript>;
meta: SubscribeMeta;
};
export type SubscribeBackupData = {
source: string;
options?: SubscribeOptionsFile;
lastModificationDate?: number;
};
export type BackupData = {
script: ScriptBackupData[];
subscribe: SubscribeBackupData[];
};