scripting-cli 1.0.5 → 1.0.7
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/config/AppJsonPlugin.js +9 -9
- package/dist/config/webpack.config.js +5 -0
- package/dist/createScript.js +210 -0
- package/dist/index.js +6 -6
- package/dist/startDevServer.js +2 -2
- package/package.json +1 -1
- package/public/global.d.ts +256 -0
- package/public/scripting.d.ts +4223 -809
- package/src/config/AppJsonPlugin.ts +12 -10
- package/src/config/webpack.config.ts +4 -0
- package/src/createScript.ts +257 -0
- package/src/index.ts +6 -5
- package/src/startDevServer.ts +17 -22
- package/dist/createApp.js +0 -223
- package/src/createApp.ts +0 -282
|
@@ -22,28 +22,28 @@ class AppJsonPlugin {
|
|
|
22
22
|
// 确保所有资源已被插件添加到 compilation
|
|
23
23
|
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
24
24
|
}, (assets) => {
|
|
25
|
-
const
|
|
25
|
+
const scriptJson = {
|
|
26
26
|
name: '',
|
|
27
27
|
index: '',
|
|
28
28
|
hash: '',
|
|
29
29
|
assets: Object.keys(assets),
|
|
30
30
|
};
|
|
31
|
-
const indexJs =
|
|
31
|
+
const indexJs = scriptJson.assets.find(filePath => filePath.match(/\.js$/i) != null);
|
|
32
32
|
if (indexJs != null) {
|
|
33
33
|
const [appName, ...others] = indexJs.split('/');
|
|
34
34
|
const filePath = others[others.length - 1];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
scriptJson.name = appName;
|
|
36
|
+
scriptJson.index = filePath;
|
|
37
|
+
scriptJson.hash = filePath.replace('.js', '');
|
|
38
38
|
const indexJsSource = assets[indexJs];
|
|
39
|
-
|
|
40
|
-
...
|
|
39
|
+
scriptJson.assets = [
|
|
40
|
+
...scriptJson.assets.filter(e => e !== indexJs),
|
|
41
41
|
filePath,
|
|
42
42
|
];
|
|
43
43
|
compilation.deleteAsset(indexJs);
|
|
44
44
|
compilation.emitAsset(filePath, indexJsSource);
|
|
45
45
|
}
|
|
46
|
-
compilation.emitAsset('
|
|
46
|
+
compilation.emitAsset('script.json', new RawSource(JSON.stringify(scriptJson, null, 2)));
|
|
47
47
|
// const appMap: {
|
|
48
48
|
// [appName: string]: {
|
|
49
49
|
// appName: string
|
|
@@ -76,7 +76,7 @@ class AppJsonPlugin {
|
|
|
76
76
|
// })
|
|
77
77
|
// Object.entries(appMap).forEach(([appName, content]) => {
|
|
78
78
|
// compilation.emitAsset(
|
|
79
|
-
// appName + '/
|
|
79
|
+
// appName + '/script.json',
|
|
80
80
|
// new RawSource(JSON.stringify(content, null, 2))
|
|
81
81
|
// )
|
|
82
82
|
// })
|
|
@@ -7,6 +7,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
10
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
10
11
|
const AppJsonPlugin_1 = __importDefault(require("./AppJsonPlugin"));
|
|
11
12
|
function getConfig() {
|
|
12
13
|
const baseDir = process.cwd();
|
|
@@ -87,6 +88,10 @@ function getConfig() {
|
|
|
87
88
|
},
|
|
88
89
|
plugins: [
|
|
89
90
|
new AppJsonPlugin_1.default(),
|
|
91
|
+
new webpack_1.default.BannerPlugin({
|
|
92
|
+
banner: 'const Scripting = require("scripting");',
|
|
93
|
+
raw: true
|
|
94
|
+
}),
|
|
90
95
|
],
|
|
91
96
|
devtool: false,
|
|
92
97
|
externals: {
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createScript = void 0;
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
const node_child_process_1 = require("node:child_process");
|
|
19
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
20
|
+
const promises_1 = require("node:fs/promises");
|
|
21
|
+
function getScriptDir(scriptName) {
|
|
22
|
+
return node_path_1.default.join(process.cwd(), scriptName);
|
|
23
|
+
}
|
|
24
|
+
function createScriptDir(scriptName) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const appDir = getScriptDir(scriptName);
|
|
27
|
+
if (node_fs_1.default.existsSync(appDir)) {
|
|
28
|
+
throw new Error(`Directory "./${scriptName}" already exists.`);
|
|
29
|
+
}
|
|
30
|
+
// const dir = path.resolve(appDir, 'src/svgs')
|
|
31
|
+
const srcDir = node_path_1.default.resolve(appDir, 'src');
|
|
32
|
+
// const typesDir = path.resolve(appDir, 'types')
|
|
33
|
+
yield Promise.all([
|
|
34
|
+
(0, promises_1.mkdir)(srcDir, { recursive: true }),
|
|
35
|
+
// mkdir(typesDir, { recursive: true })
|
|
36
|
+
]);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function createEntryFile(scriptName) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
console.log(` > Creating ${scriptName}/src/index.tsx ...`);
|
|
42
|
+
const filePath = node_path_1.default.join(getScriptDir(scriptName), '/src/index.tsx');
|
|
43
|
+
yield (0, promises_1.writeFile)(filePath, `import { Column, CupertinoNavigationBar, CupertinoPageScaffold, Text, Container, useCupertinoColors, navigator, GestureDetector, Script, Center, CupertinoButton, } from 'scripting'
|
|
44
|
+
|
|
45
|
+
function App() {
|
|
46
|
+
const cupertinoColors = useCupertinoColors()
|
|
47
|
+
const backgroundColor = cupertinoColors.systemBackground
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<CupertinoPageScaffold
|
|
51
|
+
navigationBar={
|
|
52
|
+
<CupertinoNavigationBar
|
|
53
|
+
middle={
|
|
54
|
+
<Text>My Script</Text>
|
|
55
|
+
}
|
|
56
|
+
backgroundColor={backgroundColor}
|
|
57
|
+
/>
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<Center>
|
|
61
|
+
<Text
|
|
62
|
+
color={cupertinoColors.label}
|
|
63
|
+
>Welcome to Scripting!</Text>
|
|
64
|
+
</Center>
|
|
65
|
+
</CupertinoPageScaffold>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function run() {
|
|
70
|
+
const result = await navigator.push({
|
|
71
|
+
element: <App />
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
Script.exit(result)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
run()
|
|
78
|
+
`, 'utf-8');
|
|
79
|
+
console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/src/index.tsx`));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function createPackageJson(scriptName) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
console.log(` > Creating ${scriptName}/package.json ...`);
|
|
85
|
+
const filePath = node_path_1.default.join(getScriptDir(scriptName), 'package.json');
|
|
86
|
+
yield (0, promises_1.writeFile)(filePath, `{
|
|
87
|
+
"name": "${scriptName}",
|
|
88
|
+
"version": "0.0.1",
|
|
89
|
+
"private": true,
|
|
90
|
+
"scripts": {
|
|
91
|
+
"dev": "npx scripting-cli dev",
|
|
92
|
+
"build": "npx scripting-cli build"
|
|
93
|
+
}
|
|
94
|
+
}`, 'utf-8');
|
|
95
|
+
console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/package.json`));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function createReadme(scriptName) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
console.log(` > Creating ${scriptName}/README.md ...`);
|
|
101
|
+
const filePath = node_path_1.default.join(getScriptDir(scriptName), 'README.md');
|
|
102
|
+
yield (0, promises_1.writeFile)(filePath, `# ${scriptName} - A Scripting script
|
|
103
|
+
|
|
104
|
+
## Start dev server
|
|
105
|
+
|
|
106
|
+
\`npm run dev\`
|
|
107
|
+
|
|
108
|
+
## Build App
|
|
109
|
+
|
|
110
|
+
\`npm run build\`
|
|
111
|
+
`, 'utf-8');
|
|
112
|
+
console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/README.md`));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function createTSConfig(scriptName) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
console.log(` > Creating ${scriptName}/tsconfig.json ...`);
|
|
118
|
+
const filePath = node_path_1.default.join(getScriptDir(scriptName), 'tsconfig.json');
|
|
119
|
+
yield (0, promises_1.writeFile)(filePath, `{
|
|
120
|
+
"compilerOptions": {
|
|
121
|
+
"target": "ESNext",
|
|
122
|
+
"lib": [
|
|
123
|
+
"esnext"
|
|
124
|
+
],
|
|
125
|
+
"allowJs": true,
|
|
126
|
+
"strict": true,
|
|
127
|
+
"esModuleInterop": true,
|
|
128
|
+
"allowSyntheticDefaultImports": true,
|
|
129
|
+
"forceConsistentCasingInFileNames": true,
|
|
130
|
+
"noFallthroughCasesInSwitch": true,
|
|
131
|
+
"module": "CommonJS",
|
|
132
|
+
"resolveJsonModule": true,
|
|
133
|
+
"skipLibCheck": true,
|
|
134
|
+
"jsx": "react",
|
|
135
|
+
"jsxFactory": "createElement",
|
|
136
|
+
"baseUrl": "src",
|
|
137
|
+
// "typeRoots": ["./types"],
|
|
138
|
+
// "paths": {
|
|
139
|
+
// "@/*": [
|
|
140
|
+
// "src/*"
|
|
141
|
+
// ]
|
|
142
|
+
// }
|
|
143
|
+
},
|
|
144
|
+
"include": [
|
|
145
|
+
"src"
|
|
146
|
+
],
|
|
147
|
+
}`, 'utf-8');
|
|
148
|
+
console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/tsconfig.json`));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function copyAsset(scriptName, fileName) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
console.log(` > Creating ${scriptName}/src/${fileName}.d.ts ...`);
|
|
154
|
+
yield (0, promises_1.copyFile)(node_path_1.default.join(__dirname, `../public/${fileName}.d.ts`), node_path_1.default.join(getScriptDir(scriptName), `src/${fileName}.d.ts`));
|
|
155
|
+
console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/src/${fileName}.d.ts`));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function copyAssets(scriptName) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
yield copyAsset(scriptName, 'scripting');
|
|
161
|
+
yield copyAsset(scriptName, 'global');
|
|
162
|
+
yield copyAsset(scriptName, 'assets');
|
|
163
|
+
// console.log(` > Creating ${scriptName}/src/svgs/logo.svg ...`)
|
|
164
|
+
// await copyFile(
|
|
165
|
+
// path.join(__dirname, '../public/logo.svg'),
|
|
166
|
+
// path.join(getScriptDir(scriptName), 'src/svgs/logo.svg')
|
|
167
|
+
// )
|
|
168
|
+
// console.log(
|
|
169
|
+
// chalk.green(` ✔️ Created ${scriptName}/src/svgs/logo.svg`)
|
|
170
|
+
// )
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function createVSCodeSettings(scriptName) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const destDir = node_path_1.default.join(getScriptDir(scriptName), '.vscode');
|
|
176
|
+
if (!node_fs_1.default.existsSync(destDir)) {
|
|
177
|
+
yield (0, promises_1.mkdir)(destDir, { recursive: true });
|
|
178
|
+
}
|
|
179
|
+
yield (0, promises_1.copyFile)(node_path_1.default.join(__dirname, '../.vscode/settings.json'), node_path_1.default.join(destDir, 'settings.json'));
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function installDeps(scriptName) {
|
|
183
|
+
console.log(` > cd ${scriptName} && npm i -D ts-loader typescript file-loader`);
|
|
184
|
+
(0, node_child_process_1.execSync)(`cd ${scriptName} && npm i -D ts-loader typescript file-loader`);
|
|
185
|
+
console.log(chalk_1.default.green(` ✔️ Scripting script ${chalk_1.default.bold(scriptName)} is ready!`));
|
|
186
|
+
}
|
|
187
|
+
function createScript(scriptName) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
if (!/^[a-zA-Z]+[a-zA-Z0-9-_]+$/.test(scriptName)) {
|
|
190
|
+
console.log(chalk_1.default.red(`✖️ Invalid Scripting script name "${scriptName}"`));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
console.log(`Start creating ${scriptName} ...`);
|
|
194
|
+
try {
|
|
195
|
+
yield createScriptDir(scriptName);
|
|
196
|
+
yield createPackageJson(scriptName);
|
|
197
|
+
yield createTSConfig(scriptName);
|
|
198
|
+
yield createReadme(scriptName);
|
|
199
|
+
yield createEntryFile(scriptName);
|
|
200
|
+
yield copyAssets(scriptName);
|
|
201
|
+
yield createVSCodeSettings(scriptName);
|
|
202
|
+
installDeps(scriptName);
|
|
203
|
+
console.log(`All done! Run ${chalk_1.default.bold(chalk_1.default.green(`cd ${scriptName} && npm run dev`))} to start the dev server.`);
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
206
|
+
console.log(chalk_1.default.red(`✖️ Create script failed: ${e.message}`));
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
exports.createScript = createScript;
|
package/dist/index.js
CHANGED
|
@@ -6,18 +6,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const minimist_1 = __importDefault(require("minimist"));
|
|
8
8
|
const startDevServer_1 = require("./startDevServer");
|
|
9
|
-
|
|
10
|
-
const
|
|
9
|
+
// import { buildApp } from './build'
|
|
10
|
+
const createScript_1 = require("./createScript");
|
|
11
11
|
function run() {
|
|
12
12
|
const args = (0, minimist_1.default)(process.argv.slice(2));
|
|
13
13
|
if (args['create'] != null) {
|
|
14
|
-
(0,
|
|
14
|
+
(0, createScript_1.createScript)(args['create']);
|
|
15
15
|
}
|
|
16
16
|
else if (args._.includes('dev')) {
|
|
17
17
|
(0, startDevServer_1.startDevServer)();
|
|
18
18
|
}
|
|
19
|
-
else if (args._.includes('build')) {
|
|
20
|
-
|
|
21
|
-
}
|
|
19
|
+
// else if (args._.includes('build')) {
|
|
20
|
+
// buildApp()
|
|
21
|
+
// }
|
|
22
22
|
}
|
|
23
23
|
run();
|
package/dist/startDevServer.js
CHANGED
|
@@ -80,9 +80,9 @@ function startDevServer() {
|
|
|
80
80
|
if (isStarted) {
|
|
81
81
|
printDevServerAddress();
|
|
82
82
|
console.log(chalk_1.default.gray(` ~ Sent update event to ${connectedSockets.length} client(s)`));
|
|
83
|
-
const
|
|
83
|
+
const scriptJson = yield (0, promises_1.readFile)(node_path_1.default.resolve(process.cwd(), 'build/script.json'), 'utf-8');
|
|
84
84
|
for (const socket of connectedSockets) {
|
|
85
|
-
socket.emit('update',
|
|
85
|
+
socket.emit('update', scriptJson);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
else {
|
package/package.json
CHANGED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
|
|
3
|
+
const console: {
|
|
4
|
+
log: (...args: any[]) => void
|
|
5
|
+
error: (...args: any[]) => void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const setTimeout: (callback: () => void, timeout?: number) => number
|
|
9
|
+
const clearTimeout: (timerId: number) => void
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Add message event listener from main thread.
|
|
13
|
+
*
|
|
14
|
+
* (Only supports use in Worker)
|
|
15
|
+
*/
|
|
16
|
+
var onmessage: ((event: {
|
|
17
|
+
data: any
|
|
18
|
+
}) => void) | undefined
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Add error event listener.
|
|
22
|
+
*
|
|
23
|
+
* (Only supports use in Worker)
|
|
24
|
+
*/
|
|
25
|
+
var onerror: ((error: {
|
|
26
|
+
filename: string
|
|
27
|
+
message: string
|
|
28
|
+
stack?: string
|
|
29
|
+
}) => void) | undefined
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Post message to main thread.
|
|
33
|
+
*
|
|
34
|
+
* (Only supports use in Worker)
|
|
35
|
+
*/
|
|
36
|
+
const postMessage: (message: any) => void
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Close current thread.
|
|
40
|
+
*
|
|
41
|
+
* (Only supports use in Worker)
|
|
42
|
+
*/
|
|
43
|
+
const close: () => void
|
|
44
|
+
|
|
45
|
+
// /**
|
|
46
|
+
// * A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system.
|
|
47
|
+
// *
|
|
48
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
|
|
49
|
+
// */
|
|
50
|
+
// interface Blob {
|
|
51
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */
|
|
52
|
+
// readonly size: number
|
|
53
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */
|
|
54
|
+
// readonly type: string
|
|
55
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) */
|
|
56
|
+
// arrayBuffer(): Promise<ArrayBuffer>
|
|
57
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */
|
|
58
|
+
// slice(start?: number, end?: number, contentType?: string): Blob
|
|
59
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */
|
|
60
|
+
// text(): Promise<string>
|
|
61
|
+
// }
|
|
62
|
+
|
|
63
|
+
// declare var Blob: {
|
|
64
|
+
// prototype: Blob
|
|
65
|
+
// new(blobParts?: (string | ArrayBuffer | ArrayBufferView | Blob)[], options?: BlobPropertyBag): Blob
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// interface Body {
|
|
70
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
|
|
71
|
+
// readonly body: string | FormData | Blob | null
|
|
72
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
73
|
+
// arrayBuffer(): Promise<ArrayBuffer>
|
|
74
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
75
|
+
// blob(): Promise<Blob>
|
|
76
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
|
|
77
|
+
// formData(): Promise<FormData>
|
|
78
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
|
|
79
|
+
// json(): Promise<any>
|
|
80
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
|
|
81
|
+
// text(): Promise<string>
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
// interface ResponseInit {
|
|
85
|
+
// status?: number
|
|
86
|
+
// statusText?: string
|
|
87
|
+
// headers?: HeadersInit | Headers
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// interface RequestInit {
|
|
92
|
+
// method?: string
|
|
93
|
+
// headers?: HeadersInit | Headers
|
|
94
|
+
// body?: any
|
|
95
|
+
// mode?: RequestMode
|
|
96
|
+
// credentials?: RequestCredentials
|
|
97
|
+
// cache?: RequestCache
|
|
98
|
+
// redirect?: RequestRedirect
|
|
99
|
+
// referrer?: string
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
|
+
// interface Request {
|
|
103
|
+
// /**
|
|
104
|
+
// * Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
|
|
105
|
+
// *
|
|
106
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
|
|
107
|
+
// */
|
|
108
|
+
// readonly cache: RequestCache
|
|
109
|
+
// /**
|
|
110
|
+
// * Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.
|
|
111
|
+
// *
|
|
112
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/credentials)
|
|
113
|
+
// */
|
|
114
|
+
// readonly credentials: RequestCredentials
|
|
115
|
+
// /**
|
|
116
|
+
// * Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
|
|
117
|
+
// *
|
|
118
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
|
|
119
|
+
// */
|
|
120
|
+
// readonly headers: Headers
|
|
121
|
+
// /**
|
|
122
|
+
// * Returns request's HTTP method, which is "GET" by default.
|
|
123
|
+
// *
|
|
124
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
|
|
125
|
+
// */
|
|
126
|
+
// readonly method: string
|
|
127
|
+
// /**
|
|
128
|
+
// * Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.
|
|
129
|
+
// *
|
|
130
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/mode)
|
|
131
|
+
// */
|
|
132
|
+
// readonly mode: RequestMode
|
|
133
|
+
// /**
|
|
134
|
+
// * Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
|
|
135
|
+
// *
|
|
136
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
|
|
137
|
+
// */
|
|
138
|
+
// readonly redirect: RequestRedirect
|
|
139
|
+
// /**
|
|
140
|
+
// * Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made.
|
|
141
|
+
// *
|
|
142
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/referrer)
|
|
143
|
+
// */
|
|
144
|
+
// readonly referrer: string
|
|
145
|
+
// /**
|
|
146
|
+
// * Returns the URL of request as a string.
|
|
147
|
+
// *
|
|
148
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
|
|
149
|
+
// */
|
|
150
|
+
// readonly url: string
|
|
151
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
|
|
152
|
+
// clone(): Request
|
|
153
|
+
// }
|
|
154
|
+
|
|
155
|
+
// declare var Request: {
|
|
156
|
+
// prototype: Request
|
|
157
|
+
// new(input: string | Request, init?: RequestInit): Request
|
|
158
|
+
// }
|
|
159
|
+
|
|
160
|
+
// /**
|
|
161
|
+
// * Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".
|
|
162
|
+
// *
|
|
163
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
|
|
164
|
+
// */
|
|
165
|
+
// interface FormData {
|
|
166
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) */
|
|
167
|
+
// append(name: string, value: string | Blob): void
|
|
168
|
+
// append(name: string, value: string): void
|
|
169
|
+
// append(name: string, blobValue: Blob, filename?: string): void
|
|
170
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) */
|
|
171
|
+
// delete(name: string): void
|
|
172
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) */
|
|
173
|
+
// get(name: string): string | Blob | null
|
|
174
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) */
|
|
175
|
+
// getAll(name: string): (string | Blob | null)[]
|
|
176
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) */
|
|
177
|
+
// has(name: string): boolean
|
|
178
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) */
|
|
179
|
+
// set(name: string, value: string | Blob): void
|
|
180
|
+
// set(name: string, value: string): void
|
|
181
|
+
// set(name: string, blobValue: Blob, filename?: string): void
|
|
182
|
+
// forEach(callbackfn: (value: string | Blob, key: string, parent: FormData) => void, thisArg?: any): void
|
|
183
|
+
// }
|
|
184
|
+
|
|
185
|
+
// declare var FormData: {
|
|
186
|
+
// prototype: FormData
|
|
187
|
+
// new(): FormData
|
|
188
|
+
// }
|
|
189
|
+
|
|
190
|
+
// /**
|
|
191
|
+
// * This Fetch API interface represents the response to a request.
|
|
192
|
+
// *
|
|
193
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
|
|
194
|
+
// */
|
|
195
|
+
// interface Response extends Body {
|
|
196
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
|
|
197
|
+
// readonly headers: Headers
|
|
198
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
|
|
199
|
+
// readonly ok: boolean
|
|
200
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
|
|
201
|
+
// readonly status: number
|
|
202
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
|
|
203
|
+
// readonly statusText: string
|
|
204
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
|
|
205
|
+
// readonly url: string
|
|
206
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
|
|
207
|
+
// clone(): Response
|
|
208
|
+
// }
|
|
209
|
+
|
|
210
|
+
// declare var Response: {
|
|
211
|
+
// prototype: Response
|
|
212
|
+
// new(body?: Blob | null, init?: ResponseInit): Response
|
|
213
|
+
// }
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
// type HeadersInit = [string, string][] | Record<string, string> | Headers
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
// /**
|
|
220
|
+
// * This Fetch API interface allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing. A Headers object has an associated header list, which is initially empty and consists of zero or more name and value pairs. You can add to this using methods like append() (see Examples.) In all methods of this interface, header names are matched by case-insensitive byte sequence.
|
|
221
|
+
// *
|
|
222
|
+
// * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
|
|
223
|
+
// */
|
|
224
|
+
// interface Headers {
|
|
225
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) */
|
|
226
|
+
// append(name: string, value: string): void
|
|
227
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) */
|
|
228
|
+
// delete(name: string): void
|
|
229
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) */
|
|
230
|
+
// get(name: string): string | null
|
|
231
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) */
|
|
232
|
+
// has(name: string): boolean
|
|
233
|
+
// /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) */
|
|
234
|
+
// set(name: string, value: string): void
|
|
235
|
+
// forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void
|
|
236
|
+
|
|
237
|
+
// /** Returns an iterator allowing to go through all key/value pairs contained in this object. */
|
|
238
|
+
// entries(): IterableIterator<[string, string]>
|
|
239
|
+
// /** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
|
|
240
|
+
// keys(): IterableIterator<string>
|
|
241
|
+
// /** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
|
|
242
|
+
// values(): IterableIterator<string>
|
|
243
|
+
// }
|
|
244
|
+
|
|
245
|
+
// declare var Headers: {
|
|
246
|
+
// prototype: Headers
|
|
247
|
+
// new(init?: HeadersInit): Headers
|
|
248
|
+
// }
|
|
249
|
+
|
|
250
|
+
// declare function fetch(input: string | Request, init?: RequestInit & {
|
|
251
|
+
// debugLabel?: string
|
|
252
|
+
// }): Promise<Response>
|
|
253
|
+
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export { }
|