@yxw007/translate 0.0.2 → 0.0.3
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/browser/index.cjs +39 -17
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.min.cjs +1 -1
- package/dist/browser/index.min.cjs.map +1 -1
- package/dist/browser/index.umd.js +39 -17
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/browser/index.umd.min.js +1 -1
- package/dist/browser/index.umd.min.js.map +1 -1
- package/dist/node/index.cjs +108 -51
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +108 -51
- package/dist/node/index.js.map +1 -1
- package/dist/package.json +5 -3
- package/package.json +5 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// translate v0.0.
|
|
1
|
+
// translate v0.0.3 Copyright (c) 2024 Potter<aa4790139@gmail.com> and contributors
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -729,16 +729,6 @@
|
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
const endpoint = evaluateRules(rules, { endpointParams, logger, referenceRecord: {} });
|
|
732
|
-
if (options.endpointParams?.Endpoint) {
|
|
733
|
-
try {
|
|
734
|
-
const givenEndpoint = new URL(options.endpointParams.Endpoint);
|
|
735
|
-
const { protocol, port } = givenEndpoint;
|
|
736
|
-
endpoint.url.protocol = protocol;
|
|
737
|
-
endpoint.url.port = port;
|
|
738
|
-
}
|
|
739
|
-
catch (e) {
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
732
|
options.logger?.debug?.(`${debugId} Resolved endpoint: ${toDebugString(endpoint)}`);
|
|
743
733
|
return endpoint;
|
|
744
734
|
};
|
|
@@ -1359,7 +1349,13 @@
|
|
|
1359
1349
|
|
|
1360
1350
|
const getEndpointFromInstructions = async (commandInput, instructionsSupplier, clientConfig, context) => {
|
|
1361
1351
|
if (!clientConfig.endpoint) {
|
|
1362
|
-
|
|
1352
|
+
let endpointFromConfig;
|
|
1353
|
+
if (clientConfig.serviceConfiguredEndpoint) {
|
|
1354
|
+
endpointFromConfig = await clientConfig.serviceConfiguredEndpoint();
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
endpointFromConfig = await getEndpointFromConfig(clientConfig.serviceId);
|
|
1358
|
+
}
|
|
1363
1359
|
if (endpointFromConfig) {
|
|
1364
1360
|
clientConfig.endpoint = () => Promise.resolve(toEndpointV1(endpointFromConfig));
|
|
1365
1361
|
}
|
|
@@ -1513,7 +1509,7 @@
|
|
|
1513
1509
|
const { endpoint } = input;
|
|
1514
1510
|
const customEndpointProvider = endpoint != null ? async () => toEndpointV1(await normalizeProvider$1(endpoint)()) : undefined;
|
|
1515
1511
|
const isCustomEndpoint = !!endpoint;
|
|
1516
|
-
|
|
1512
|
+
const resolvedConfig = {
|
|
1517
1513
|
...input,
|
|
1518
1514
|
endpoint: customEndpointProvider,
|
|
1519
1515
|
tls,
|
|
@@ -1521,6 +1517,14 @@
|
|
|
1521
1517
|
useDualstackEndpoint: normalizeProvider$1(input.useDualstackEndpoint ?? false),
|
|
1522
1518
|
useFipsEndpoint: normalizeProvider$1(input.useFipsEndpoint ?? false),
|
|
1523
1519
|
};
|
|
1520
|
+
let configuredEndpointPromise = undefined;
|
|
1521
|
+
resolvedConfig.serviceConfiguredEndpoint = async () => {
|
|
1522
|
+
if (input.serviceId && !configuredEndpointPromise) {
|
|
1523
|
+
configuredEndpointPromise = getEndpointFromConfig(input.serviceId);
|
|
1524
|
+
}
|
|
1525
|
+
return configuredEndpointPromise;
|
|
1526
|
+
};
|
|
1527
|
+
return resolvedConfig;
|
|
1524
1528
|
};
|
|
1525
1529
|
|
|
1526
1530
|
const httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
|
|
@@ -2212,13 +2216,31 @@
|
|
|
2212
2216
|
|
|
2213
2217
|
class Client {
|
|
2214
2218
|
constructor(config) {
|
|
2215
|
-
this.middlewareStack = constructStack();
|
|
2216
2219
|
this.config = config;
|
|
2220
|
+
this.middlewareStack = constructStack();
|
|
2217
2221
|
}
|
|
2218
2222
|
send(command, optionsOrCb, cb) {
|
|
2219
2223
|
const options = typeof optionsOrCb !== "function" ? optionsOrCb : undefined;
|
|
2220
2224
|
const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
|
|
2221
|
-
const
|
|
2225
|
+
const useHandlerCache = options === undefined && this.config.cacheMiddleware === true;
|
|
2226
|
+
let handler;
|
|
2227
|
+
if (useHandlerCache) {
|
|
2228
|
+
if (!this.handlers) {
|
|
2229
|
+
this.handlers = new WeakMap();
|
|
2230
|
+
}
|
|
2231
|
+
const handlers = this.handlers;
|
|
2232
|
+
if (handlers.has(command.constructor)) {
|
|
2233
|
+
handler = handlers.get(command.constructor);
|
|
2234
|
+
}
|
|
2235
|
+
else {
|
|
2236
|
+
handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
|
|
2237
|
+
handlers.set(command.constructor, handler);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
else {
|
|
2241
|
+
delete this.handlers;
|
|
2242
|
+
handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
|
|
2243
|
+
}
|
|
2222
2244
|
if (callback) {
|
|
2223
2245
|
handler(command)
|
|
2224
2246
|
.then((result) => callback(null, result.output), (err) => callback(err))
|
|
@@ -2229,8 +2251,8 @@
|
|
|
2229
2251
|
}
|
|
2230
2252
|
}
|
|
2231
2253
|
destroy() {
|
|
2232
|
-
|
|
2233
|
-
|
|
2254
|
+
this.config?.requestHandler?.destroy?.();
|
|
2255
|
+
delete this.handlers;
|
|
2234
2256
|
}
|
|
2235
2257
|
}
|
|
2236
2258
|
|