@pisell/core 1.0.8 → 1.0.9

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/es/cmd/index.js DELETED
@@ -1,91 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- import socket from "../socket";
9
- import { CMDCoreEnum } from "./const";
10
- var CMD = /*#__PURE__*/function () {
11
- function CMD(app, options) {
12
- _classCallCheck(this, CMD);
13
- _defineProperty(this, "app", void 0);
14
- _defineProperty(this, "options", void 0);
15
- this.app = app;
16
- this.options = options;
17
- }
18
- _createClass(CMD, [{
19
- key: "init",
20
- value: function init() {
21
- var _this$options,
22
- _this$options2,
23
- _this = this;
24
- if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.socketUrl)) {
25
- return;
26
- }
27
- var cmdSocket = socket.create((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.socketUrl, {
28
- autoConnect: false,
29
- // 自动连接
30
- reconnection: true,
31
- // 启用断线重连
32
- heartbeat: true,
33
- // 启用心跳检测
34
- heartbeatInterval: 30000,
35
- // 心跳间隔(毫秒)
36
- heartbeatTimeout: 50000 // 请求超时时间(毫秒)
37
- }, "front_cmd" // Socket标识键
38
- );
39
- cmdSocket.on("connect", function (res) {
40
- _this.app.pubsub.publish(CMDCoreEnum.CMD_CONNECT, res);
41
- _this.app.logger.addLog({
42
- type: "info",
43
- title: "cmdSocket连接成功",
44
- metadata: res
45
- });
46
- });
47
- cmdSocket.on("disconnect", function (res) {
48
- _this.app.pubsub.publish(CMDCoreEnum.CMD_DISCONNECT, res);
49
- _this.app.logger.addLog({
50
- type: "info",
51
- title: "cmdSocket连接断开",
52
- metadata: res
53
- });
54
- });
55
- cmdSocket.on("reconnect", function (res) {
56
- _this.app.pubsub.publish(CMDCoreEnum.CMD_RECONNECT, res);
57
- _this.app.logger.addLog({
58
- type: "info",
59
- title: "cmdSocket重连",
60
- metadata: res
61
- });
62
- });
63
- cmdSocket.on("message", function (res) {
64
- _this.app.pubsub.publish(CMDCoreEnum.CMD_MESSAGE, res);
65
- _this.app.logger.addLog({
66
- type: "info",
67
- title: "cmdSocket收到消息",
68
- metadata: res
69
- });
70
- });
71
- cmdSocket.on("error", function (res) {
72
- _this.app.pubsub.publish(CMDCoreEnum.CMD_ERROR, res);
73
- _this.app.logger.addLog({
74
- type: "info",
75
- title: "cmdSocket连接错误",
76
- metadata: res
77
- });
78
- });
79
- cmdSocket.connect().catch(function (error) {
80
- _this.app.logger.addLog({
81
- type: "info",
82
- title: "cmdSocket连接失败",
83
- metadata: error
84
- });
85
- });
86
- }
87
- }]);
88
- return CMD;
89
- }();
90
- export { CMDCoreEnum };
91
- export default CMD;
package/es/cmd/type.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export interface CDMItem {
2
- key: string;
3
- code: string;
4
- [key: string]: any;
5
- }
package/es/cmd/type.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import { S3ClientConfig, PutObjectCommandInput } from '@aws-sdk/client-s3';
2
- import App from '../app';
3
- export interface AWSOptions extends S3ClientConfig {
4
- s3Config: S3ClientConfig;
5
- bucketName?: string;
6
- }
7
- export interface UploadParams extends PutObjectCommandInput {
8
- }
9
- declare class AWS {
10
- private s3Client?;
11
- private app;
12
- private config?;
13
- constructor(app: App, options?: AWSOptions);
14
- upload(params: UploadParams): Promise<any>;
15
- }
16
- export default AWS;
package/lib/aws/index.js DELETED
@@ -1,67 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/aws/index.ts
20
- var aws_exports = {};
21
- __export(aws_exports, {
22
- default: () => aws_default
23
- });
24
- module.exports = __toCommonJS(aws_exports);
25
- var import_client_s3 = require("@aws-sdk/client-s3");
26
- var defaultUploadParams = {
27
- Bucket: "",
28
- Key: "",
29
- ContentType: "application/json",
30
- ContentDisposition: "inline",
31
- ACL: "public-read"
32
- // 设置ACL权限为公共读取
33
- };
34
- var AWS = class {
35
- s3Client;
36
- app;
37
- config;
38
- constructor(app, options) {
39
- this.app = app;
40
- if (options) {
41
- const clientConfig = {
42
- ...options.s3Config
43
- };
44
- this.s3Client = new import_client_s3.S3Client(clientConfig);
45
- this.config = options;
46
- }
47
- }
48
- async upload(params) {
49
- var _a, _b;
50
- try {
51
- const _params = {
52
- ...defaultUploadParams,
53
- ...params,
54
- Bucket: params.Bucket || ((_a = this.config) == null ? void 0 : _a.bucketName)
55
- };
56
- console.log(`上传参数`, _params);
57
- const command = new import_client_s3.PutObjectCommand(_params);
58
- const response = await ((_b = this.s3Client) == null ? void 0 : _b.send(command));
59
- console.log(`上传成功`);
60
- return response;
61
- } catch (err) {
62
- console.error(`上传失败`, err);
63
- throw err;
64
- }
65
- }
66
- };
67
- var aws_default = AWS;
@@ -1,11 +0,0 @@
1
- export declare enum CMDCoreEnum {
2
- CMD_CONNECT,
3
- CMD_DISCONNECT,
4
- CMD_RECONNECT,
5
- CMD_MESSAGE,
6
- CMD_ERROR
7
- }
8
- declare const _default: {
9
- CMDCoreEnum: typeof CMDCoreEnum;
10
- };
11
- export default _default;
package/lib/cmd/const.js DELETED
@@ -1,39 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/cmd/const.ts
20
- var const_exports = {};
21
- __export(const_exports, {
22
- CMDCoreEnum: () => CMDCoreEnum,
23
- default: () => const_default
24
- });
25
- module.exports = __toCommonJS(const_exports);
26
- var prefix = "cmd";
27
- var CMDCoreEnum = ((CMDCoreEnum2) => {
28
- CMDCoreEnum2["CMD_CONNECT"] = `${prefix}.connect`;
29
- CMDCoreEnum2["CMD_DISCONNECT"] = `${prefix}.disconnect`;
30
- CMDCoreEnum2["CMD_RECONNECT"] = `${prefix}.reconnect`;
31
- CMDCoreEnum2["CMD_MESSAGE"] = `${prefix}.message`;
32
- CMDCoreEnum2["CMD_ERROR"] = `${prefix}.error`;
33
- return CMDCoreEnum2;
34
- })(CMDCoreEnum || {});
35
- var const_default = { CMDCoreEnum };
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- CMDCoreEnum
39
- });
@@ -1,13 +0,0 @@
1
- import App from "../app";
2
- import { CMDCoreEnum } from "./const";
3
- export interface CMDOptions {
4
- socketUrl?: string;
5
- }
6
- declare class CMD {
7
- private app;
8
- private options?;
9
- constructor(app: App, options?: CMDOptions);
10
- init(): void;
11
- }
12
- export { CMDCoreEnum };
13
- export default CMD;
package/lib/cmd/index.js DELETED
@@ -1,96 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/cmd/index.ts
30
- var cmd_exports = {};
31
- __export(cmd_exports, {
32
- CMDCoreEnum: () => import_const.CMDCoreEnum,
33
- default: () => cmd_default
34
- });
35
- module.exports = __toCommonJS(cmd_exports);
36
- var import_socket = __toESM(require("../socket"));
37
- var import_const = require("./const");
38
- var CMD = class {
39
- app;
40
- options;
41
- constructor(app, options) {
42
- this.app = app;
43
- this.options = options;
44
- }
45
- init() {
46
- var _a, _b;
47
- if (!((_a = this.options) == null ? void 0 : _a.socketUrl)) {
48
- return;
49
- }
50
- const cmdSocket = import_socket.default.create(
51
- (_b = this.options) == null ? void 0 : _b.socketUrl,
52
- {
53
- autoConnect: false,
54
- // 自动连接
55
- reconnection: true,
56
- // 启用断线重连
57
- heartbeat: true,
58
- // 启用心跳检测
59
- heartbeatInterval: 3e4,
60
- // 心跳间隔(毫秒)
61
- heartbeatTimeout: 5e4
62
- // 请求超时时间(毫秒)
63
- },
64
- "front_cmd"
65
- // Socket标识键
66
- );
67
- cmdSocket.on("connect", (res) => {
68
- this.app.pubsub.publish(import_const.CMDCoreEnum.CMD_CONNECT, res);
69
- this.app.logger.addLog({ type: "info", title: "cmdSocket连接成功", metadata: res });
70
- });
71
- cmdSocket.on("disconnect", (res) => {
72
- this.app.pubsub.publish(import_const.CMDCoreEnum.CMD_DISCONNECT, res);
73
- this.app.logger.addLog({ type: "info", title: "cmdSocket连接断开", metadata: res });
74
- });
75
- cmdSocket.on("reconnect", (res) => {
76
- this.app.pubsub.publish(import_const.CMDCoreEnum.CMD_RECONNECT, res);
77
- this.app.logger.addLog({ type: "info", title: "cmdSocket重连", metadata: res });
78
- });
79
- cmdSocket.on("message", (res) => {
80
- this.app.pubsub.publish(import_const.CMDCoreEnum.CMD_MESSAGE, res);
81
- this.app.logger.addLog({ type: "info", title: "cmdSocket收到消息", metadata: res });
82
- });
83
- cmdSocket.on("error", (res) => {
84
- this.app.pubsub.publish(import_const.CMDCoreEnum.CMD_ERROR, res);
85
- this.app.logger.addLog({ type: "info", title: "cmdSocket连接错误", metadata: res });
86
- });
87
- cmdSocket.connect().catch((error) => {
88
- this.app.logger.addLog({ type: "info", title: "cmdSocket连接失败", metadata: error });
89
- });
90
- }
91
- };
92
- var cmd_default = CMD;
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- CMDCoreEnum
96
- });
package/lib/cmd/type.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export interface CDMItem {
2
- key: string;
3
- code: string;
4
- [key: string]: any;
5
- }
package/lib/cmd/type.js DELETED
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
-
15
- // src/cmd/type.ts
16
- var type_exports = {};
17
- module.exports = __toCommonJS(type_exports);