@tinywork/glass 0.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.
@@ -0,0 +1,33 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 16
18
+ - run: npm ci
19
+
20
+ publish-npm:
21
+ needs: build
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - uses: actions/setup-node@v3
26
+ with:
27
+ node-version: 16
28
+ registry-url: https://registry.npmjs.org/
29
+ scope: '@tinywork'
30
+ - run: npm ci
31
+ - run: npm publish --access public
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -0,0 +1,5 @@
1
+ // 参考 https://commitlint.js.org/#/
2
+
3
+ module.exports = {
4
+ extends: ['@commitlint/config-conventional'],
5
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@tinywork/glass",
3
+ "version": "0.0.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "types": "src/index.ts",
7
+ "scripts": {
8
+ "build": "rm -rf ./dist && tsc",
9
+ "release": "standard-version"
10
+ },
11
+ "author": "",
12
+ "license": "ISC",
13
+ "peerDependencies": {
14
+ "electron": "^21.0.0"
15
+ },
16
+ "dependencies": {
17
+ "axios": "^1.2.2"
18
+ },
19
+ "devDependencies": {
20
+ "@commitlint/cli": "^17.5.1",
21
+ "@commitlint/config-conventional": "^17.4.4",
22
+ "standard-version": "^9.5.0",
23
+ "typescript": "^4.9.4"
24
+ },
25
+ "engines": {
26
+ "npm": ">=8.0.0",
27
+ "node": ">=16.16.0"
28
+ },
29
+ "standard-version": {
30
+ "scripts": {
31
+ "posttag": "git push --follow-tags origin master"
32
+ },
33
+ "changelogHeader": "# Changelog\n"
34
+ }
35
+ }
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import http from 'node:http';
4
+ import https from 'node:https';
5
+ import axios from 'axios';
6
+
7
+ export type DevtoolsContext = {
8
+ getItem?: <T>(key: string) => Promise<T>;
9
+ setItem?: <T>(key: string, value: T) => Promise<void>;
10
+ onItemChange?: <T>(key: string, cb: (params: { key: string; value: T }) => void) => void;
11
+ };
12
+
13
+ export interface IDevtoolsExtension {
14
+ install?(context: DevtoolsContext): void | Promise<void>;
15
+ activate?(context: DevtoolsContext): void | Promise<void>;
16
+ /** 要修改url时,直接在params.url = new URL方式修改 */
17
+ onRequest?(
18
+ context: DevtoolsContext,
19
+ params: {
20
+ url: URL;
21
+ req: http.IncomingMessage;
22
+ res: http.ServerResponse;
23
+ }
24
+ ): void | Promise<void>;
25
+ onResponse?(
26
+ context: DevtoolsContext,
27
+ params: {
28
+ url: URL;
29
+ req: http.IncomingMessage;
30
+ res: http.ServerResponse;
31
+ }
32
+ ): void | Promise<void>;
33
+ deactivate?(context: DevtoolsContext): void | Promise<void>;
34
+ uninstall?(context: DevtoolsContext): void | Promise<void>;
35
+ }
36
+
37
+ export { fs, path, http, https, axios };
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "target": "es2020",
5
+ "outDir": "dist",
6
+ "lib": ["esnext", "DOM"],
7
+ "sourceMap": false,
8
+ "baseUrl": ".",
9
+ "allowSyntheticDefaultImports": true,
10
+ "moduleResolution": "node",
11
+ "forceConsistentCasingInFileNames": true,
12
+ "noImplicitReturns": true,
13
+ "suppressImplicitAnyIndexErrors": true,
14
+ "noUnusedLocals": true,
15
+ "noEmit": false,
16
+ "allowJs": false
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "electron"]
20
+ }