@howuse/feedback 0.3.0 → 0.5.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.
- package/dist/index.cjs +25 -10
- package/dist/index.d.ts +6 -2
- package/dist/index.mjs +25 -10
- package/dist/native/index.d.ts +2 -1
- package/dist/types.d.ts +15 -0
- package/native/howuse_feedback.dll +0 -0
- package/native/howuse_feedback.h +1 -0
- package/native/libhowuse_feedback.dylib +0 -0
- package/native/libhowuse_feedback.h +1 -0
- package/native/libhowuse_feedback_arm64.dylib +0 -0
- package/native/libhowuse_feedback_arm64.h +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,18 +22,15 @@ function tryLoadNativeLibrary() {
|
|
|
22
22
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
23
23
|
}
|
|
24
24
|
let libPath = path.join(packageRoot, "native", libName);
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
libPath = asarPath;
|
|
30
|
-
} else {
|
|
31
|
-
throw new Error(`Native library asarPath not found: ${asarPath}. Please run 'npm run build:native' first.`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
throw new Error(`Native library not found: ${libPath}. Please run 'npm run build:native' first.`);
|
|
25
|
+
if (libPath.includes(".asar")) {
|
|
26
|
+
const asarPath = libPath.replace(".asar", ".asar.unpacked");
|
|
27
|
+
if (fs.existsSync(asarPath)) {
|
|
28
|
+
libPath = asarPath;
|
|
35
29
|
}
|
|
36
30
|
}
|
|
31
|
+
if (!fs.existsSync(libPath)) {
|
|
32
|
+
throw new Error(`Native library not found: ${libPath}. Please run 'npm run build:native' first.`);
|
|
33
|
+
}
|
|
37
34
|
try {
|
|
38
35
|
return koffi.load(libPath);
|
|
39
36
|
} catch (error) {
|
|
@@ -46,6 +43,7 @@ function createNativeClient() {
|
|
|
46
43
|
const SubmitFeedback = lib.func("SubmitFeedback", "str", ["str"]);
|
|
47
44
|
const Activate = lib.func("Activate", "str", ["str"]);
|
|
48
45
|
const CheckActivation = lib.func("CheckActivation", "str", ["str"]);
|
|
46
|
+
const StoreData = lib.func("StoreData", "str", ["str"]);
|
|
49
47
|
return {
|
|
50
48
|
async initClient(options) {
|
|
51
49
|
const json = JSON.stringify(options);
|
|
@@ -66,6 +64,11 @@ function createNativeClient() {
|
|
|
66
64
|
const json = JSON.stringify({ softwareId });
|
|
67
65
|
const result = CheckActivation(json);
|
|
68
66
|
return JSON.parse(result);
|
|
67
|
+
},
|
|
68
|
+
async storeData(payload) {
|
|
69
|
+
const json = JSON.stringify(payload);
|
|
70
|
+
const result = StoreData(json);
|
|
71
|
+
return JSON.parse(result);
|
|
69
72
|
}
|
|
70
73
|
};
|
|
71
74
|
}
|
|
@@ -134,6 +137,18 @@ class FeedbackClient {
|
|
|
134
137
|
};
|
|
135
138
|
}
|
|
136
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* 存储数据
|
|
142
|
+
*/
|
|
143
|
+
async storeData(data) {
|
|
144
|
+
if (!this.enabled) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: "sdk_disabled"
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return this.nativeClient.storeData(data);
|
|
151
|
+
}
|
|
137
152
|
}
|
|
138
153
|
async function initFeedbackClient(options) {
|
|
139
154
|
if (!options.baseUrl || !options.softwareId || !options.version || !options.machineCodePath) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NativeClient } from './native';
|
|
2
|
-
import type { InitOptions, FeedbackPayload, FeedbackResult, ActivationRequest, ActivationResult, ActivationCheckResponse } from './types';
|
|
2
|
+
import type { InitOptions, FeedbackPayload, FeedbackResult, ActivationRequest, ActivationResult, ActivationCheckResponse, DataStorePayload, DataStoreResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* FeedbackClient 类
|
|
5
5
|
*/
|
|
@@ -23,6 +23,10 @@ export declare class FeedbackClient {
|
|
|
23
23
|
* 检查激活状态(机器码在内部自动使用)
|
|
24
24
|
*/
|
|
25
25
|
check(): Promise<ActivationCheckResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* 存储数据
|
|
28
|
+
*/
|
|
29
|
+
storeData(data: DataStorePayload): Promise<DataStoreResult>;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* 初始化 Feedback 客户端
|
|
@@ -30,4 +34,4 @@ export declare class FeedbackClient {
|
|
|
30
34
|
* @returns Promise<FeedbackClient>
|
|
31
35
|
*/
|
|
32
36
|
export declare function initFeedbackClient(options: InitOptions): Promise<FeedbackClient>;
|
|
33
|
-
export type { InitOptions, InitResult, FeedbackPayload, FeedbackResult, ActivationRequest, ActivationResult, ActivationCheckRequest, ActivationCheckResponse, } from './types';
|
|
37
|
+
export type { InitOptions, InitResult, FeedbackPayload, FeedbackResult, ActivationRequest, ActivationResult, ActivationCheckRequest, ActivationCheckResponse, DataStorePayload, DataStoreResult, } from './types';
|
package/dist/index.mjs
CHANGED
|
@@ -20,18 +20,15 @@ function tryLoadNativeLibrary() {
|
|
|
20
20
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
21
21
|
}
|
|
22
22
|
let libPath = path.join(packageRoot, "native", libName);
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
libPath = asarPath;
|
|
28
|
-
} else {
|
|
29
|
-
throw new Error(`Native library asarPath not found: ${asarPath}. Please run 'npm run build:native' first.`);
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
throw new Error(`Native library not found: ${libPath}. Please run 'npm run build:native' first.`);
|
|
23
|
+
if (libPath.includes(".asar")) {
|
|
24
|
+
const asarPath = libPath.replace(".asar", ".asar.unpacked");
|
|
25
|
+
if (fs.existsSync(asarPath)) {
|
|
26
|
+
libPath = asarPath;
|
|
33
27
|
}
|
|
34
28
|
}
|
|
29
|
+
if (!fs.existsSync(libPath)) {
|
|
30
|
+
throw new Error(`Native library not found: ${libPath}. Please run 'npm run build:native' first.`);
|
|
31
|
+
}
|
|
35
32
|
try {
|
|
36
33
|
return koffi.load(libPath);
|
|
37
34
|
} catch (error) {
|
|
@@ -44,6 +41,7 @@ function createNativeClient() {
|
|
|
44
41
|
const SubmitFeedback = lib.func("SubmitFeedback", "str", ["str"]);
|
|
45
42
|
const Activate = lib.func("Activate", "str", ["str"]);
|
|
46
43
|
const CheckActivation = lib.func("CheckActivation", "str", ["str"]);
|
|
44
|
+
const StoreData = lib.func("StoreData", "str", ["str"]);
|
|
47
45
|
return {
|
|
48
46
|
async initClient(options) {
|
|
49
47
|
const json = JSON.stringify(options);
|
|
@@ -64,6 +62,11 @@ function createNativeClient() {
|
|
|
64
62
|
const json = JSON.stringify({ softwareId });
|
|
65
63
|
const result = CheckActivation(json);
|
|
66
64
|
return JSON.parse(result);
|
|
65
|
+
},
|
|
66
|
+
async storeData(payload) {
|
|
67
|
+
const json = JSON.stringify(payload);
|
|
68
|
+
const result = StoreData(json);
|
|
69
|
+
return JSON.parse(result);
|
|
67
70
|
}
|
|
68
71
|
};
|
|
69
72
|
}
|
|
@@ -132,6 +135,18 @@ class FeedbackClient {
|
|
|
132
135
|
};
|
|
133
136
|
}
|
|
134
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* 存储数据
|
|
140
|
+
*/
|
|
141
|
+
async storeData(data) {
|
|
142
|
+
if (!this.enabled) {
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: "sdk_disabled"
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return this.nativeClient.storeData(data);
|
|
149
|
+
}
|
|
135
150
|
}
|
|
136
151
|
async function initFeedbackClient(options) {
|
|
137
152
|
if (!options.baseUrl || !options.softwareId || !options.version || !options.machineCodePath) {
|
package/dist/native/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InitOptions, InitResult, FeedbackPayload, FeedbackResult, ActivationRequest, ActivationResult, ActivationCheckRequest, ActivationCheckResponse } from '../types';
|
|
1
|
+
import type { InitOptions, InitResult, FeedbackPayload, FeedbackResult, ActivationRequest, ActivationResult, ActivationCheckRequest, ActivationCheckResponse, DataStorePayload, DataStoreResult } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Native 客户端接口
|
|
4
4
|
*/
|
|
@@ -7,6 +7,7 @@ export interface NativeClient {
|
|
|
7
7
|
submitFeedback(payload: FeedbackPayload, softwareId: number): Promise<FeedbackResult>;
|
|
8
8
|
activate(request: ActivationRequest, softwareId: number): Promise<ActivationResult>;
|
|
9
9
|
checkActivation(request: ActivationCheckRequest, softwareId: number): Promise<ActivationCheckResponse>;
|
|
10
|
+
storeData(payload: DataStorePayload): Promise<DataStoreResult>;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* 创建 Native 客户端
|
package/dist/types.d.ts
CHANGED
|
@@ -103,3 +103,18 @@ export interface ActivationCheckResponse {
|
|
|
103
103
|
/** 错误原因 */
|
|
104
104
|
reason?: string;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* 数据存储请求
|
|
108
|
+
*/
|
|
109
|
+
export interface DataStorePayload {
|
|
110
|
+
/** 数据内容 */
|
|
111
|
+
data: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 数据存储响应
|
|
115
|
+
*/
|
|
116
|
+
export interface DataStoreResult {
|
|
117
|
+
success: boolean;
|
|
118
|
+
id?: number;
|
|
119
|
+
error?: string;
|
|
120
|
+
}
|
|
Binary file
|
package/native/howuse_feedback.h
CHANGED
|
@@ -83,6 +83,7 @@ extern __declspec(dllexport) char* InitClient(char* jsonOptions);
|
|
|
83
83
|
extern __declspec(dllexport) char* SubmitFeedback(char* jsonPayload);
|
|
84
84
|
extern __declspec(dllexport) char* Activate(char* jsonRequest);
|
|
85
85
|
extern __declspec(dllexport) char* CheckActivation(char* jsonRequest);
|
|
86
|
+
extern __declspec(dllexport) char* StoreData(char* jsonPayload);
|
|
86
87
|
extern __declspec(dllexport) void FreeString(char* ptr);
|
|
87
88
|
|
|
88
89
|
#ifdef __cplusplus
|
|
Binary file
|
|
@@ -83,6 +83,7 @@ extern char* InitClient(char* jsonOptions);
|
|
|
83
83
|
extern char* SubmitFeedback(char* jsonPayload);
|
|
84
84
|
extern char* Activate(char* jsonRequest);
|
|
85
85
|
extern char* CheckActivation(char* jsonRequest);
|
|
86
|
+
extern char* StoreData(char* jsonPayload);
|
|
86
87
|
extern void FreeString(char* ptr);
|
|
87
88
|
|
|
88
89
|
#ifdef __cplusplus
|
|
Binary file
|
|
@@ -83,6 +83,7 @@ extern char* InitClient(char* jsonOptions);
|
|
|
83
83
|
extern char* SubmitFeedback(char* jsonPayload);
|
|
84
84
|
extern char* Activate(char* jsonRequest);
|
|
85
85
|
extern char* CheckActivation(char* jsonRequest);
|
|
86
|
+
extern char* StoreData(char* jsonPayload);
|
|
86
87
|
extern void FreeString(char* ptr);
|
|
87
88
|
|
|
88
89
|
#ifdef __cplusplus
|