@certd/lib-huawei 1.21.2
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/.eslintrc +23 -0
- package/.prettierrc +3 -0
- package/README.md +16 -0
- package/dist/bundle.js +1 -0
- package/dist/d/index.d.ts +2 -0
- package/fix-esm-import-paths.js +96 -0
- package/package.json +20 -0
- package/rollup.config.js +36 -0
- package/stats.html +6177 -0
- package/tsconfig.json +41 -0
package/.eslintrc
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@typescript-eslint"
|
|
5
|
+
],
|
|
6
|
+
"extends": [
|
|
7
|
+
"plugin:@typescript-eslint/recommended",
|
|
8
|
+
"plugin:prettier/recommended",
|
|
9
|
+
"prettier"
|
|
10
|
+
],
|
|
11
|
+
"env": {
|
|
12
|
+
"mocha": true
|
|
13
|
+
},
|
|
14
|
+
"rules": {
|
|
15
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
16
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
17
|
+
"@typescript-eslint/ban-ts-ignore": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
20
|
+
// "no-unused-expressions": "off",
|
|
21
|
+
"max-len": [0, 160, 2, { "ignoreUrls": true }]
|
|
22
|
+
}
|
|
23
|
+
}
|
package/.prettierrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Vue 3 + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
|
4
|
+
|
|
5
|
+
## Recommended IDE Setup
|
|
6
|
+
|
|
7
|
+
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
|
|
8
|
+
|
|
9
|
+
## Type Support For `.vue` Imports in TS
|
|
10
|
+
|
|
11
|
+
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
|
|
12
|
+
|
|
13
|
+
1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
|
|
14
|
+
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
|
|
15
|
+
|
|
16
|
+
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|
package/dist/bundle.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("crypto"),e=require("axios");function s(e){return t.createHash("SHA256").update(e).digest().toString("hex")}const n="SDK-HMAC-SHA256",r="X-Sdk-Date",o=new Array(256);for(let t=0;t<256;++t)o[t]="%"+((t<16?"0":"")+t.toString(16)).toUpperCase();const i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0];function c(t){"string"!=typeof t&&("object"==typeof t?t=String(t):t+="");let e="",s=0;for(let n=0;n<t.length;++n){let r=t.charCodeAt(n);if(r<128){if(1===i[r])continue;s<n&&(e+=t.slice(s,n)),s=n+1,e+=o[r];continue}if(s<n&&(e+=t.slice(s,n)),r<2048){s=n+1,e+=o[192|r>>6]+o[128|63&r];continue}if(r<55296||r>=57344){s=n+1,e+=o[224|r>>12]+o[128|r>>6&63]+o[128|63&r];continue}if(++n,n>=t.length)throw new Error("ERR_INVALID_URI");s=n+1,r=65536+((1023&r)<<10|1023&t.charCodeAt(n)),e+=o[240|r>>18]+o[128|r>>12&63]+o[128|r>>6&63]+o[128|63&r]}return 0===s?t:s<t.length?e+t.slice(s):e}function u(t,e){for(const s in t.headers)if(s.toLowerCase()===e.toLowerCase())return t.headers[s];return null}function h(t,e){let n=u(t,"x-sdk-content-sha256");if(null===n){const e=function(t){return t.body}(t);n=s(e)}return t.method+"\n"+function(t){const e=t.uri.split("/"),s=[];for(const t in e){const n=e[t];s.push(c(n))}let n=s.join("/");"/"!==n[n.length-1]&&(n+="/");return n}(t)+"\n"+a(t)+"\n"+function(t,e){const s={};for(const e in t.headers)s[e.toLowerCase()]=t.headers[e];const n=[];for(const t in e){const r=s[e[t]];n.push(e[t]+":"+r.trim())}return n.join("\n")+"\n"}(t,e)+"\n"+e.join(";")+"\n"+n}function a(t){const e=[];for(const s in t.query)e.push(s);e.sort();const s=[];for(const n in e){const r=c(e[n]),o=t.query[e[n]];if(Array.isArray(o)){o.sort();for(const t in o)s.push(r+"="+c(o[t]))}else s.push(r+"="+c(o))}return s.join("&")}function d(e,s){return n=s,r=e,t.createHmac("SHA256",n).update(r).digest().toString("hex");var n,r}function f(t){return t>=10?""+t:"0"+t}class l{method="";host="";uri="";query={};headers={};body="";constructor(t,e,s,n){if(this.method=void 0===t?"":t,void 0===e)this.host="",this.uri="",this.query={};else{let t,s;this.query={};let n=e.indexOf("://");if(-1!==n&&(e=e.substr(n+3)),n=e.indexOf("?"),-1!==n){const t=e.substr(n+1);e=e.substr(0,n);const s=t.split("&");for(const t in s){const e=s[t],n=e.indexOf("=");let r,o;n>=0?(r=e.substr(0,n),o=e.substr(n+1)):(r=e,o=""),""!==r&&(r=decodeURI(r),o=decodeURI(o),void 0===this.query[r]?this.query[r]=[o]:this.query[r].push(o))}}n=e.indexOf("/"),-1===n?(t=e,s="/"):(t=e.substr(0,n),s=e.substr(n)),this.host=t,this.uri=decodeURI(s)}this.headers=void 0===s?{}:s,this.body=void 0===n?"":n}}class y{Key="";Secret="";constructor(t,e){this.Key=t,this.Secret=e}Sign(t){let e=u(t,r);null===e&&(e=function(){const t=new Date;return""+t.getUTCFullYear()+f(t.getUTCMonth()+1)+f(t.getUTCDate())+"T"+f(t.getUTCHours())+f(t.getUTCMinutes())+f(t.getUTCSeconds())+"Z"}(),t.headers[r]=e),"PUT"!==t.method&&"PATCH"!==t.method&&"POST"!==t.method&&(t.body="");let o=a(t);""!==o&&(o="?"+o);const i={hostname:t.host,path:encodeURI(t.uri)+o,method:t.method,headers:t.headers};null===u(t,"host")&&(t.headers.host=t.host);const c=function(t){const e=[];for(const s in t.headers)e.push(s.toLowerCase());return e.sort(),e}(t),l=function(t,e){const r=s(t);return n+"\n"+e+"\n"+r}(h(t,c),e),y=d(l,this.Secret);return i.headers.Authorization=function(t,e,s){return n+" Access="+e+", SignedHeaders="+s.join(";")+", Signature="+t}(y,this.Key,c),i}}exports.HuaweiYunClient=class{access;constructor(t,e){this.access=t}async request(t){const s=new y(this.access.accessKeyId,this.access.accessKeySecret);let n;t.data&&(n=JSON.stringify(t.data));const r=new l(t.method,t.url,t.headers,n);r.headers={"Content-Type":"application/json"};const o=s.Sign(r);try{return(await e.request({url:t.url,method:t.method,headers:o.headers,data:n})).data}catch(t){this.logger.error("华为云接口请求出错:",t?.response?.data);const e=new Error(t?.response?.data.message);throw e.code=t?.response?.code,e}}};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
// https://gist.github.com/lovasoa/8691344
|
|
5
|
+
async function* walk(dir) {
|
|
6
|
+
for await (const d of await fs.promises.opendir(dir)) {
|
|
7
|
+
const entry = path.join(dir, d.name);
|
|
8
|
+
if (d.isDirectory()) {
|
|
9
|
+
yield* walk(entry);
|
|
10
|
+
} else if (d.isFile()) {
|
|
11
|
+
yield entry;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function resolveImportPath(sourceFile, importPath, options) {
|
|
17
|
+
const sourceFileAbs = path.resolve(process.cwd(), sourceFile);
|
|
18
|
+
const root = path.dirname(sourceFileAbs);
|
|
19
|
+
const { moduleFilter = defaultModuleFilter } = options;
|
|
20
|
+
|
|
21
|
+
if (moduleFilter(importPath)) {
|
|
22
|
+
const importPathAbs = path.resolve(root, importPath);
|
|
23
|
+
let possiblePath = [path.resolve(importPathAbs, "./index.ts"), path.resolve(importPathAbs, "./index.js"), importPathAbs + ".ts", importPathAbs + ".js"];
|
|
24
|
+
|
|
25
|
+
if (possiblePath.length) {
|
|
26
|
+
for (let i = 0; i < possiblePath.length; i++) {
|
|
27
|
+
let entry = possiblePath[i];
|
|
28
|
+
if (fs.existsSync(entry)) {
|
|
29
|
+
const resolved = path.relative(root, entry.replace(/\.ts$/, ".js"));
|
|
30
|
+
|
|
31
|
+
if (!resolved.startsWith(".")) {
|
|
32
|
+
return "./" + resolved;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return resolved;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function replace(filePath, outFilePath, options) {
|
|
45
|
+
const code = fs.readFileSync(filePath).toString();
|
|
46
|
+
const newCode = code.replace(/(import|export) (.+?) from ('[^\n']+'|"[^\n"]+");/gs, function (found, action, imported, from) {
|
|
47
|
+
const importPath = from.slice(1, -1);
|
|
48
|
+
let resolvedPath = resolveImportPath(filePath, importPath, options);
|
|
49
|
+
|
|
50
|
+
if (resolvedPath) {
|
|
51
|
+
resolvedPath = resolvedPath.replaceAll("\\", "/");
|
|
52
|
+
console.log("\t", importPath, resolvedPath);
|
|
53
|
+
return `${action} ${imported} from "${resolvedPath}";`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return found;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (code !== newCode) {
|
|
60
|
+
fs.writeFileSync(outFilePath, newCode);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Then, use it with a simple async for loop
|
|
65
|
+
async function run(srcDir, options = defaultOptions) {
|
|
66
|
+
const { sourceFileFilter = defaultSourceFileFilter } = options;
|
|
67
|
+
|
|
68
|
+
for await (const entry of walk(srcDir)) {
|
|
69
|
+
if (sourceFileFilter(entry)) {
|
|
70
|
+
console.log(entry);
|
|
71
|
+
replace(entry, entry, options);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const defaultSourceFileFilter = function (sourceFilePath) {
|
|
77
|
+
return /\.(js|ts)$/.test(sourceFilePath) && !/node_modules/.test(sourceFilePath);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const defaultModuleFilter = function (importedModule) {
|
|
81
|
+
return !path.isAbsolute(importedModule) && !importedModule.startsWith("@") && !importedModule.endsWith(".js");
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const defaultOptions = {
|
|
85
|
+
sourceFileFilter: defaultSourceFileFilter,
|
|
86
|
+
moduleFilter: defaultModuleFilter,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Switch this to test on one file or directly run on a directory.
|
|
90
|
+
const DEBUG = false;
|
|
91
|
+
|
|
92
|
+
if (DEBUG) {
|
|
93
|
+
replace("./src/index.ts", "./out.ts", defaultOptions);
|
|
94
|
+
} else {
|
|
95
|
+
await run("./src/", defaultOptions);
|
|
96
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@certd/lib-huawei",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.21.2",
|
|
5
|
+
"main": "./dist/bundle.js",
|
|
6
|
+
"module": "./dist/bundle.js",
|
|
7
|
+
"types": "./dist/d/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"build": "rollup -c ",
|
|
11
|
+
"build2": "vue-tsc --noEmit && vite build",
|
|
12
|
+
"preview": "vite preview"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@certd/pipeline": "1.21.0",
|
|
16
|
+
"axios": "^1.7.2",
|
|
17
|
+
"rollup": "^3.7.4"
|
|
18
|
+
},
|
|
19
|
+
"gitHead": "a31f1c7f5e71fa946de9bf0283e11d6ce049b3e9"
|
|
20
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const resolve = require("@rollup/plugin-node-resolve");
|
|
2
|
+
const commonjs = require("@rollup/plugin-commonjs");
|
|
3
|
+
//const Typescript = require("rollup-plugin-typescript2");
|
|
4
|
+
const Typescript = require("@rollup/plugin-typescript");
|
|
5
|
+
const json = require("@rollup/plugin-json");
|
|
6
|
+
const terser = require("@rollup/plugin-terser");
|
|
7
|
+
module.exports = {
|
|
8
|
+
input: "src/index.ts",
|
|
9
|
+
output: {
|
|
10
|
+
file: "dist/bundle.js",
|
|
11
|
+
format: "cjs",
|
|
12
|
+
},
|
|
13
|
+
plugins: [
|
|
14
|
+
// 解析第三方依赖
|
|
15
|
+
resolve(),
|
|
16
|
+
// 识别 commonjs 模式第三方依赖
|
|
17
|
+
commonjs({
|
|
18
|
+
// dynamicRequireRoot: "../../../../",
|
|
19
|
+
// dynamicRequireTargets: [
|
|
20
|
+
// // include using a glob pattern (either a string or an array of strings)
|
|
21
|
+
// "../../../../**/shelljs/src/*",
|
|
22
|
+
// ],
|
|
23
|
+
}),
|
|
24
|
+
Typescript({
|
|
25
|
+
target: "esnext",
|
|
26
|
+
rootDir: "src",
|
|
27
|
+
declaration: true,
|
|
28
|
+
declarationDir: "dist/d",
|
|
29
|
+
exclude: ["./node_modules/**", "./src/**/*.vue"],
|
|
30
|
+
allowSyntheticDefaultImports: true,
|
|
31
|
+
}),
|
|
32
|
+
json(),
|
|
33
|
+
terser(),
|
|
34
|
+
],
|
|
35
|
+
external: ["vue", "lodash-es", "dayjs", "log4js", "@midwayjs/core", "@certd/pipeline", "axios"],
|
|
36
|
+
};
|