Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@td-design/pont-engine

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@td-design/pont-engine - npm Package Compare versions

Comparing version 1.1.1 to 1.1.3

5

lib/compatible/scripts/base.js

@@ -18,2 +18,3 @@ "use strict";

const Config_1 = require("../Config");
const { getToken } = require('../../thirdParty/translation.js');
class OriginBaseReader {

@@ -41,3 +42,5 @@ constructor(config, report) {

chineseKeyCollect.sort((pre, next) => next.length - pre.length);
let result = yield Promise.all(chineseKeyCollect.map((text) => (0, translate_1.translate)(this.config.rootDir, text)));
// 统一请求翻译 token
let token = yield getToken();
let result = yield Promise.all(chineseKeyCollect.map((text) => (0, translate_1.translate)(this.config.rootDir, text, 0, token)));
// const normalizeRegStr = (str: string) => str.replace(/(\W)/g, '$1');

@@ -44,0 +47,0 @@ const toRegStr = (str) => str.replace(/(\W)/g, '\\$1');

4

lib/thirdParty/translation.js/index.d.ts

@@ -68,3 +68,3 @@ declare var http: any;

/** 翻译 */
declare const translate: (options: any) => Promise<unknown>;
declare const translate: (options: any, token: any) => Promise<unknown>;
/**

@@ -77,5 +77,5 @@ * 获取指定文本的网络语音地址

__proto__: any;
translate: (options: any) => Promise<unknown>;
translate: (options: any, token: any) => Promise<unknown>;
detect: (options: any) => Promise<any>;
audio: (options: any) => Promise<string>;
}>;

@@ -200,6 +200,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
for (var d = ''
.concat(String.fromCharCode(103))
.concat(String.fromCharCode(116))
.concat(String.fromCharCode(107)), h = (null !== r ? r : (r = window[d] || '') || '').split('.'), f = Number(h[0]) || 0, m = Number(h[1]) || 0, g = [], y = 0, v = 0; v < t.length; v++) {
for (var d = ''.concat(String.fromCharCode(103)).concat(String.fromCharCode(116)).concat(String.fromCharCode(107)), h = (null !== r ? r : (r = window[d] || '') || '').split('.'), f = Number(h[0]) || 0, m = Number(h[1]) || 0, g = [], y = 0, v = 0; v < t.length; v++) {
var _ = t.charCodeAt(v);

@@ -218,21 +215,6 @@ _ < 128

}
for (var b = f, w = ''
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(45))
.concat(String.fromCharCode(97)) +
''
.concat(String.fromCharCode(94))
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(54)), k = ''
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(45))
.concat(String.fromCharCode(51)) +
''
.concat(String.fromCharCode(94))
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(98)) +
''
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(45))
.concat(String.fromCharCode(102)), x = 0; x < g.length; x++)
for (var b = f, w = ''.concat(String.fromCharCode(43)).concat(String.fromCharCode(45)).concat(String.fromCharCode(97)) +
''.concat(String.fromCharCode(94)).concat(String.fromCharCode(43)).concat(String.fromCharCode(54)), k = ''.concat(String.fromCharCode(43)).concat(String.fromCharCode(45)).concat(String.fromCharCode(51)) +
''.concat(String.fromCharCode(94)).concat(String.fromCharCode(43)).concat(String.fromCharCode(98)) +
''.concat(String.fromCharCode(43)).concat(String.fromCharCode(45)).concat(String.fromCharCode(102)), x = 0; x < g.length; x++)
b = n((b += g[x]), w);

@@ -286,3 +268,3 @@ return ((b = n(b, k)),

/** 翻译 */
const translate = (options) => __awaiter(this, void 0, void 0, function* () {
const translate = (options, token) => __awaiter(this, void 0, void 0, function* () {
const modifiedOptions = typeof options === 'string' ? { text: options } : options;

@@ -302,3 +284,5 @@ let { from, to, text } = modifiedOptions || {};

const sign = getSign(text);
const token = yield getToken();
if (!token) {
token = yield getToken();
}
let params = {

@@ -354,2 +338,3 @@ from: customFromLang,

exports.baidu = index;
exports.getToken = getToken;
//# sourceMappingURL=index.js.map
/**
* @description 翻译中文名称
*/
export declare function translate(rootDir: any, text: string, engineIndex?: number): any;
export declare function translate(rootDir: any, text: string, engineIndex?: number, token?: string): any;
/** 翻译中文类名等 */
export declare function translateChinese(jsonString: string, rootDir: string): Promise<string>;

@@ -54,3 +54,3 @@ "use strict";

}
function translate(rootDir, text, engineIndex = 0) {
function translate(rootDir, text, engineIndex = 0, token = '') {
var _a;

@@ -71,3 +71,3 @@ return __awaiter(this, void 0, void 0, function* () {

try {
let res = yield engines[index].translate(text);
let res = yield engines[index].translate(text, token);
enKey = startCaseClassName(res.trans_result.data[0].dst);

@@ -79,3 +79,3 @@ assert.ok(enKey);

catch (err) {
return translate(rootDir, text, index + 1);
return translate(rootDir, text, index + 1, token);
}

@@ -82,0 +82,0 @@ });

{
"name": "@td-design/pont-engine",
"version": "1.1.1",
"version": "1.1.3",
"description": "pont swagger typescript API",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -9,2 +9,4 @@ import * as _ from 'lodash';

const { getToken } = require('../../thirdParty/translation.js');
export class OriginBaseReader {

@@ -33,3 +35,6 @@ constructor(protected config: DataSourceConfig, protected report: any) {}

let result = await Promise.all(chineseKeyCollect.map((text) => translate(this.config.rootDir, text)));
// 统一请求翻译 token
let token = await getToken();
let result = await Promise.all(chineseKeyCollect.map((text) => translate(this.config.rootDir, text, 0, token)));
// const normalizeRegStr = (str: string) => str.replace(/(\W)/g, '$1');

@@ -36,0 +41,0 @@ const toRegStr = (str) => str.replace(/(\W)/g, '\\$1');

@@ -101,4 +101,4 @@ var http = require('http');

var responseType = options.responseType || 'json';
return new Promise(function(resolve, reject) {
var req = (urlObj.protocol === 'https:' ? https.request : http.request)(httpOptions, function(res) {
return new Promise(function (resolve, reject) {
var req = (urlObj.protocol === 'https:' ? https.request : http.request)(httpOptions, function (res) {
// 内置的翻译接口都以 200 作为响应码,所以不是 200 的一律视为错误

@@ -111,6 +111,6 @@ if (res.statusCode !== 200) {

var rawData = '';
res.on('data', function(chunk) {
res.on('data', function (chunk) {
rawData += chunk;
});
res.on('end', function() {
res.on('end', function () {
// Node.js 端只支持 json,其余都作为 text 处理

@@ -129,7 +129,7 @@ if (responseType === 'json') {

});
req.on('timeout', function() {
req.on('timeout', function () {
req.abort();
reject(getError('NETWORK_TIMEOUT' /* NETWORK_TIMEOUT */, '查询超时'));
});
req.on('error', function(e) {
req.on('error', function (e) {
reject(getError('NETWORK_ERROR' /* NETWORK_ERROR */, e.message));

@@ -173,10 +173,10 @@ });

u,
(function(t) {
(function (t) {
if (Array.isArray(t)) return e(t);
})((o = s[c].split(''))) ||
(function(t) {
(function (t) {
if (('undefined' != typeof Symbol && null != t[Symbol.iterator]) || null != t['@@iterator'])
return Array.from(t);
})(o) ||
(function(t, n) {
(function (t, n) {
if (t) {

@@ -195,3 +195,3 @@ if ('string' == typeof t) return e(t, n);

})(o) ||
(function() {
(function () {
throw new TypeError(

@@ -211,6 +211,3 @@ 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'

for (
var d = ''
.concat(String.fromCharCode(103))
.concat(String.fromCharCode(116))
.concat(String.fromCharCode(107)),
var d = ''.concat(String.fromCharCode(103)).concat(String.fromCharCode(116)).concat(String.fromCharCode(107)),
h = (null !== r ? r : (r = window[d] || '') || '').split('.'),

@@ -241,23 +238,8 @@ f = Number(h[0]) || 0,

w =
''
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(45))
.concat(String.fromCharCode(97)) +
''
.concat(String.fromCharCode(94))
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(54)),
''.concat(String.fromCharCode(43)).concat(String.fromCharCode(45)).concat(String.fromCharCode(97)) +
''.concat(String.fromCharCode(94)).concat(String.fromCharCode(43)).concat(String.fromCharCode(54)),
k =
''
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(45))
.concat(String.fromCharCode(51)) +
''
.concat(String.fromCharCode(94))
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(98)) +
''
.concat(String.fromCharCode(43))
.concat(String.fromCharCode(45))
.concat(String.fromCharCode(102)),
''.concat(String.fromCharCode(43)).concat(String.fromCharCode(45)).concat(String.fromCharCode(51)) +
''.concat(String.fromCharCode(94)).concat(String.fromCharCode(43)).concat(String.fromCharCode(98)) +
''.concat(String.fromCharCode(43)).concat(String.fromCharCode(45)).concat(String.fromCharCode(102)),
x = 0;

@@ -292,3 +274,3 @@ x < g.length;

/** 识别语言种类 */
const detect = async options => {
const detect = async (options) => {
let iso689lang;

@@ -321,3 +303,3 @@ let query = (typeof options === 'string' ? options : options.text).slice(0, 73);

/** 翻译 */
const translate = async options => {
const translate = async (options, token) => {
const modifiedOptions = typeof options === 'string' ? { text: options } : options;

@@ -339,3 +321,5 @@ let { from, to, text } = modifiedOptions || {};

const sign = getSign(text);
const token = await getToken();
if (!token) {
token = await getToken();
}
let params = {

@@ -364,3 +348,3 @@ from: customFromLang,

*/
const audio = async options => {
const audio = async (options) => {
const modifiedOptions = typeof options === 'string' ? { text: options } : options;

@@ -395,1 +379,2 @@ let { text, from } = modifiedOptions;

exports.baidu = index;
exports.getToken = getToken;

@@ -52,3 +52,3 @@ /**

export async function translate(rootDir, text: string, engineIndex = 0) {
export async function translate(rootDir, text: string, engineIndex = 0, token = '') {
if (!dicPath[rootDir]) {

@@ -71,3 +71,3 @@ init(rootDir);

try {
let res = await engines[index].translate(text);
let res = await engines[index].translate(text, token);
enKey = startCaseClassName(res.trans_result.data[0].dst);

@@ -80,3 +80,3 @@

} catch (err) {
return translate(rootDir, text, index + 1);
return translate(rootDir, text, index + 1, token);
}

@@ -83,0 +83,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc