@ywfe/fe-tools 1.2.1-beta.24 → 1.2.1-beta.26
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/JSON2String.ts +6 -3
- package/index.ts +0 -1
- package/lib/JSON2String.d.ts +3 -1
- package/lib/index.d.ts +0 -1
- package/lib/ywfe-tools.cjs +11 -38
- package/lib/ywfe-tools.cjs.map +1 -1
- package/lib/ywfe-tools.esm.js +12 -38
- package/lib/ywfe-tools.esm.js.map +1 -1
- package/lib/ywfe-tools.umd.js +2 -2
- package/lib/ywfe-tools.umd.js.map +1 -1
- package/package.json +1 -1
- package/request.ts +6 -6
- package/lib/userInputToJson.d.ts +0 -8
- package/userInputToJson.ts +0 -24
package/JSON2String.ts
CHANGED
@@ -4,11 +4,14 @@ interface Input {
|
|
4
4
|
// Ctrl-S保存代码
|
5
5
|
function JSON2String({input}: { input: Input }){
|
6
6
|
const { data } = input;
|
7
|
+
const result:{content: string} = {content:''};
|
7
8
|
try {
|
8
|
-
const str = JSON.stringify(data)
|
9
|
-
|
9
|
+
const str = JSON.stringify(data);
|
10
|
+
result.content = '```json' + str + 'json```';
|
11
|
+
return result;
|
10
12
|
} catch (error) {
|
11
|
-
|
13
|
+
result.content = '```json' + '{}' + 'json```';
|
14
|
+
return result;
|
12
15
|
}
|
13
16
|
}
|
14
17
|
export default JSON2String
|
package/index.ts
CHANGED
package/lib/JSON2String.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/ywfe-tools.cjs
CHANGED
@@ -8723,12 +8723,12 @@ function request(_a) {
|
|
8723
8723
|
return basePathMap.get(env);
|
8724
8724
|
};
|
8725
8725
|
isValidURL = function (url) {
|
8726
|
-
var pattern = new RegExp("^(https
|
8727
|
-
"((([a-z
|
8728
|
-
"((
|
8729
|
-
"(
|
8730
|
-
"(
|
8731
|
-
"(
|
8726
|
+
var pattern = new RegExp("^(https?:\/\/)?" + // protocol
|
8727
|
+
"((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|" + // domain name
|
8728
|
+
"((\d{1,3}\.){3}\d{1,3}))" + // OR ip (v4) address
|
8729
|
+
"(\:\d+)?(\/[-a-z\d%_.~+]*)*" + // port and path
|
8730
|
+
"(\?[;&a-z\d%_.~+=-]*)?" + // query string
|
8731
|
+
"(\#[-a-z\d_]*)?$", "i"); // fragment locator
|
8732
8732
|
return !!pattern.test(url);
|
8733
8733
|
};
|
8734
8734
|
prefix = getBasePath();
|
@@ -8762,49 +8762,22 @@ function request(_a) {
|
|
8762
8762
|
});
|
8763
8763
|
}
|
8764
8764
|
|
8765
|
-
function userInputToJson(_a) {
|
8766
|
-
return __awaiter(this, arguments, void 0, function (_b) {
|
8767
|
-
var res, result;
|
8768
|
-
var input = _b.input;
|
8769
|
-
return __generator(this, function (_c) {
|
8770
|
-
switch (_c.label) {
|
8771
|
-
case 0:
|
8772
|
-
console.log("input", input);
|
8773
|
-
return [4 /*yield*/, request({
|
8774
|
-
input: {
|
8775
|
-
url: "https://fc-typechat.ywwl.com/userInputToJson",
|
8776
|
-
method: "GET",
|
8777
|
-
params: input,
|
8778
|
-
},
|
8779
|
-
})];
|
8780
|
-
case 1:
|
8781
|
-
res = _c.sent();
|
8782
|
-
if (res.success) {
|
8783
|
-
result = res.data;
|
8784
|
-
return [2 /*return*/, result.success ? result.data : result];
|
8785
|
-
}
|
8786
|
-
else {
|
8787
|
-
return [2 /*return*/, res.success ? res.data : res];
|
8788
|
-
}
|
8789
|
-
}
|
8790
|
-
});
|
8791
|
-
});
|
8792
|
-
}
|
8793
|
-
|
8794
8765
|
// Ctrl-S保存代码
|
8795
8766
|
function JSON2String(_a) {
|
8796
8767
|
var input = _a.input;
|
8797
8768
|
var data = input.data;
|
8769
|
+
var result = { content: '' };
|
8798
8770
|
try {
|
8799
8771
|
var str = JSON.stringify(data);
|
8800
|
-
|
8772
|
+
result.content = '```json' + str + 'json```';
|
8773
|
+
return result;
|
8801
8774
|
}
|
8802
8775
|
catch (error) {
|
8803
|
-
|
8776
|
+
result.content = '```json' + '{}' + 'json```';
|
8777
|
+
return result;
|
8804
8778
|
}
|
8805
8779
|
}
|
8806
8780
|
|
8807
8781
|
exports.JSON2String = JSON2String;
|
8808
8782
|
exports.request = request;
|
8809
|
-
exports.userInputToJson = userInputToJson;
|
8810
8783
|
//# sourceMappingURL=ywfe-tools.cjs.map
|