mol_plot_all 1.2.845 → 1.2.847
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/node.audit.js +1 -1
- package/node.deps.json +1 -1
- package/node.js +7 -5
- package/node.js.map +1 -1
- package/node.mjs +7 -5
- package/node.test.js +46 -347
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.audit.js +1 -1
- package/web.deps.json +1 -1
- package/web.js +3 -1
- package/web.js.map +1 -1
- package/web.mjs +3 -1
- package/web.test.js +34 -164
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
|
@@ -1137,7 +1137,7 @@ var $;
|
|
|
1137
1137
|
};
|
|
1138
1138
|
}
|
|
1139
1139
|
error(message, Class = Error) {
|
|
1140
|
-
return new Class(`${message}${this}`);
|
|
1140
|
+
return new Class(`${message} (${this})`);
|
|
1141
1141
|
}
|
|
1142
1142
|
span(row, col, length) {
|
|
1143
1143
|
return new $mol_span(this.uri, this.source, row, col, length);
|
|
@@ -1152,11 +1152,11 @@ var $;
|
|
|
1152
1152
|
if (end < 0)
|
|
1153
1153
|
end += len;
|
|
1154
1154
|
if (begin < 0 || begin > len)
|
|
1155
|
-
this.$.$mol_fail(`Begin value '${begin}' out of range
|
|
1155
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1156
1156
|
if (end < 0 || end > len)
|
|
1157
|
-
this.$.$mol_fail(`End value '${end}' out of range
|
|
1157
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1158
1158
|
if (end < begin)
|
|
1159
|
-
this.$.$mol_fail(`End value '${end}' can't be less than begin value
|
|
1159
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1160
1160
|
return this.span(this.row, this.col + begin, end - begin);
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
@@ -2203,7 +2203,9 @@ var $;
|
|
|
2203
2203
|
var $;
|
|
2204
2204
|
(function ($) {
|
|
2205
2205
|
function $mol_wire_solid() {
|
|
2206
|
-
|
|
2206
|
+
let current = $mol_wire_auto();
|
|
2207
|
+
if (current.temp)
|
|
2208
|
+
current = current.host;
|
|
2207
2209
|
if (current.reap !== nothing) {
|
|
2208
2210
|
current?.sub_on(sub, sub.data.length);
|
|
2209
2211
|
}
|
package/node.test.js
CHANGED
|
@@ -1129,7 +1129,7 @@ var $;
|
|
|
1129
1129
|
};
|
|
1130
1130
|
}
|
|
1131
1131
|
error(message, Class = Error) {
|
|
1132
|
-
return new Class(`${message}${this}`);
|
|
1132
|
+
return new Class(`${message} (${this})`);
|
|
1133
1133
|
}
|
|
1134
1134
|
span(row, col, length) {
|
|
1135
1135
|
return new $mol_span(this.uri, this.source, row, col, length);
|
|
@@ -1144,11 +1144,11 @@ var $;
|
|
|
1144
1144
|
if (end < 0)
|
|
1145
1145
|
end += len;
|
|
1146
1146
|
if (begin < 0 || begin > len)
|
|
1147
|
-
this.$.$mol_fail(`Begin value '${begin}' out of range
|
|
1147
|
+
this.$.$mol_fail(this.error(`Begin value '${begin}' out of range`, RangeError));
|
|
1148
1148
|
if (end < 0 || end > len)
|
|
1149
|
-
this.$.$mol_fail(`End value '${end}' out of range
|
|
1149
|
+
this.$.$mol_fail(this.error(`End value '${end}' out of range`, RangeError));
|
|
1150
1150
|
if (end < begin)
|
|
1151
|
-
this.$.$mol_fail(`End value '${end}' can't be less than begin value
|
|
1151
|
+
this.$.$mol_fail(this.error(`End value '${end}' can't be less than begin value`, RangeError));
|
|
1152
1152
|
return this.span(this.row, this.col + begin, end - begin);
|
|
1153
1153
|
}
|
|
1154
1154
|
}
|
|
@@ -2195,7 +2195,9 @@ var $;
|
|
|
2195
2195
|
var $;
|
|
2196
2196
|
(function ($) {
|
|
2197
2197
|
function $mol_wire_solid() {
|
|
2198
|
-
|
|
2198
|
+
let current = $mol_wire_auto();
|
|
2199
|
+
if (current.temp)
|
|
2200
|
+
current = current.host;
|
|
2199
2201
|
if (current.reap !== nothing) {
|
|
2200
2202
|
current?.sub_on(sub, sub.data.length);
|
|
2201
2203
|
}
|
|
@@ -7070,17 +7072,6 @@ var $;
|
|
|
7070
7072
|
;
|
|
7071
7073
|
"use strict";
|
|
7072
7074
|
var $;
|
|
7073
|
-
(function ($) {
|
|
7074
|
-
function $mol_dom_serialize(node) {
|
|
7075
|
-
const serializer = new $mol_dom_context.XMLSerializer;
|
|
7076
|
-
return serializer.serializeToString(node);
|
|
7077
|
-
}
|
|
7078
|
-
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
7079
|
-
})($ || ($ = {}));
|
|
7080
|
-
//mol/dom/serialize/serialize.ts
|
|
7081
|
-
;
|
|
7082
|
-
"use strict";
|
|
7083
|
-
var $;
|
|
7084
7075
|
(function ($) {
|
|
7085
7076
|
function $mol_assert_ok(value) {
|
|
7086
7077
|
if (value)
|
|
@@ -7101,14 +7092,12 @@ var $;
|
|
|
7101
7092
|
handler();
|
|
7102
7093
|
}
|
|
7103
7094
|
catch (error) {
|
|
7104
|
-
if (!ErrorRight)
|
|
7105
|
-
return error;
|
|
7106
7095
|
$.$mol_fail = fail;
|
|
7107
7096
|
if (typeof ErrorRight === 'string') {
|
|
7108
7097
|
$mol_assert_equal(error.message, ErrorRight);
|
|
7109
7098
|
}
|
|
7110
7099
|
else {
|
|
7111
|
-
$
|
|
7100
|
+
$mol_assert_equal(error instanceof ErrorRight, true);
|
|
7112
7101
|
}
|
|
7113
7102
|
return error;
|
|
7114
7103
|
}
|
|
@@ -7118,58 +7107,47 @@ var $;
|
|
|
7118
7107
|
$mol_fail(new Error('Not failed'));
|
|
7119
7108
|
}
|
|
7120
7109
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
7121
|
-
function $
|
|
7122
|
-
|
|
7123
|
-
for (let j = 0; j < args.length; ++j) {
|
|
7124
|
-
if (i === j)
|
|
7125
|
-
continue;
|
|
7126
|
-
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
7127
|
-
continue;
|
|
7128
|
-
if (args[i] !== args[j])
|
|
7129
|
-
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
7130
|
-
}
|
|
7131
|
-
}
|
|
7110
|
+
function $mol_assert_like(...args) {
|
|
7111
|
+
$mol_assert_equal(...args);
|
|
7132
7112
|
}
|
|
7133
|
-
$.$
|
|
7113
|
+
$.$mol_assert_like = $mol_assert_like;
|
|
7134
7114
|
function $mol_assert_unique(...args) {
|
|
7135
7115
|
for (let i = 0; i < args.length; ++i) {
|
|
7136
7116
|
for (let j = 0; j < args.length; ++j) {
|
|
7137
7117
|
if (i === j)
|
|
7138
7118
|
continue;
|
|
7139
|
-
if (
|
|
7140
|
-
|
|
7141
|
-
}
|
|
7119
|
+
if (!$mol_compare_deep(args[i], args[j]))
|
|
7120
|
+
continue;
|
|
7121
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
7142
7122
|
}
|
|
7143
7123
|
}
|
|
7144
7124
|
}
|
|
7145
7125
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
7146
|
-
function $
|
|
7147
|
-
for (let
|
|
7148
|
-
if (
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
return val;
|
|
7154
|
-
if ('outerHTML' in val)
|
|
7155
|
-
return val.outerHTML;
|
|
7156
|
-
try {
|
|
7157
|
-
return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
|
|
7158
|
-
}
|
|
7159
|
-
catch (error) {
|
|
7160
|
-
console.error(error);
|
|
7161
|
-
return val;
|
|
7162
|
-
}
|
|
7163
|
-
};
|
|
7164
|
-
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
7165
|
-
}
|
|
7126
|
+
function $mol_assert_equal(...args) {
|
|
7127
|
+
for (let i = 1; i < args.length; ++i) {
|
|
7128
|
+
if ($mol_compare_deep(args[0], args[i]))
|
|
7129
|
+
continue;
|
|
7130
|
+
if (args[0] instanceof $mol_dom_context.Element && args[i] instanceof $mol_dom_context.Element && args[0].outerHTML === args[i].outerHTML)
|
|
7131
|
+
continue;
|
|
7132
|
+
return $mol_fail(new Error(`args[0] ≠ args[${i}]\n${print(args[0])}\n---\n${print(args[i])}`));
|
|
7166
7133
|
}
|
|
7167
7134
|
}
|
|
7168
|
-
$.$
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7135
|
+
$.$mol_assert_equal = $mol_assert_equal;
|
|
7136
|
+
const print = (val) => {
|
|
7137
|
+
if (!val)
|
|
7138
|
+
return val;
|
|
7139
|
+
if (typeof val !== 'object')
|
|
7140
|
+
return val;
|
|
7141
|
+
if ('outerHTML' in val)
|
|
7142
|
+
return val.outerHTML;
|
|
7143
|
+
try {
|
|
7144
|
+
return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
|
|
7145
|
+
}
|
|
7146
|
+
catch (error) {
|
|
7147
|
+
console.error(error);
|
|
7148
|
+
return val;
|
|
7149
|
+
}
|
|
7150
|
+
};
|
|
7173
7151
|
})($ || ($ = {}));
|
|
7174
7152
|
//mol/assert/assert.ts
|
|
7175
7153
|
;
|
|
@@ -7190,10 +7168,10 @@ var $;
|
|
|
7190
7168
|
$mol_assert_equal(2, 2, 2);
|
|
7191
7169
|
},
|
|
7192
7170
|
'two must be unique'() {
|
|
7193
|
-
$mol_assert_unique([
|
|
7171
|
+
$mol_assert_unique([2], [3]);
|
|
7194
7172
|
},
|
|
7195
7173
|
'three must be unique'() {
|
|
7196
|
-
$mol_assert_unique([
|
|
7174
|
+
$mol_assert_unique([1], [2], [3]);
|
|
7197
7175
|
},
|
|
7198
7176
|
'two must be alike'() {
|
|
7199
7177
|
$mol_assert_like([3], [3]);
|
|
@@ -7966,7 +7944,7 @@ var $;
|
|
|
7966
7944
|
], App, "result", null);
|
|
7967
7945
|
$mol_assert_equal(App.result(), 1);
|
|
7968
7946
|
App.condition(true);
|
|
7969
|
-
$mol_assert_fail(() => App.result());
|
|
7947
|
+
$mol_assert_fail(() => App.result(), 'test error');
|
|
7970
7948
|
App.condition(false);
|
|
7971
7949
|
$mol_assert_equal(App.result(), 1);
|
|
7972
7950
|
},
|
|
@@ -8905,14 +8883,14 @@ var $;
|
|
|
8905
8883
|
},
|
|
8906
8884
|
'slice span - out of range'($) {
|
|
8907
8885
|
const span = new $mol_span('test.ts', '', 1, 3, 5);
|
|
8908
|
-
$mol_assert_fail(() => span.slice(-1, 3));
|
|
8909
|
-
$mol_assert_fail(() => span.slice(1, 6));
|
|
8910
|
-
$mol_assert_fail(() => span.slice(1, 10));
|
|
8886
|
+
$mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
|
|
8887
|
+
$mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
|
|
8888
|
+
$mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
|
|
8911
8889
|
},
|
|
8912
8890
|
'error handling'($) {
|
|
8913
8891
|
const span = new $mol_span('test.ts', '', 1, 3, 4);
|
|
8914
|
-
const error = span.error('Some error
|
|
8915
|
-
$mol_assert_equal(error.message, 'Some error
|
|
8892
|
+
const error = span.error('Some error');
|
|
8893
|
+
$mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
|
|
8916
8894
|
}
|
|
8917
8895
|
});
|
|
8918
8896
|
})($ || ($ = {}));
|
|
@@ -9465,7 +9443,7 @@ var $;
|
|
|
9465
9443
|
native.persist().then(actual => {
|
|
9466
9444
|
setTimeout(() => this.persisted(actual, 'cache'), 5000);
|
|
9467
9445
|
if (actual)
|
|
9468
|
-
this.$.$
|
|
9446
|
+
this.$.$mol_log3_done({ place: `$mol_storage`, message: `Persist: Yes` });
|
|
9469
9447
|
else
|
|
9470
9448
|
this.$.$mol_log3_fail({ place: `$mol_storage`, message: `Persist: No` });
|
|
9471
9449
|
});
|
|
@@ -9987,279 +9965,6 @@ var $;
|
|
|
9987
9965
|
//mol/file/file.node.ts
|
|
9988
9966
|
;
|
|
9989
9967
|
"use strict";
|
|
9990
|
-
//hyoo/hyoo.ts
|
|
9991
|
-
;
|
|
9992
|
-
"use strict";
|
|
9993
|
-
var $;
|
|
9994
|
-
(function ($) {
|
|
9995
|
-
$.$mol_action = $mol_wire_method;
|
|
9996
|
-
})($ || ($ = {}));
|
|
9997
|
-
//mol/action/action.ts
|
|
9998
|
-
;
|
|
9999
|
-
"use strict";
|
|
10000
|
-
var $;
|
|
10001
|
-
(function ($) {
|
|
10002
|
-
function $mol_dom_parse(text, type = 'application/xhtml+xml') {
|
|
10003
|
-
const parser = new $mol_dom_context.DOMParser();
|
|
10004
|
-
const doc = parser.parseFromString(text, type);
|
|
10005
|
-
const error = doc.getElementsByTagName('parsererror');
|
|
10006
|
-
if (error.length)
|
|
10007
|
-
throw new Error(error[0].textContent);
|
|
10008
|
-
return doc;
|
|
10009
|
-
}
|
|
10010
|
-
$.$mol_dom_parse = $mol_dom_parse;
|
|
10011
|
-
})($ || ($ = {}));
|
|
10012
|
-
//mol/dom/parse/parse.ts
|
|
10013
|
-
;
|
|
10014
|
-
"use strict";
|
|
10015
|
-
var $;
|
|
10016
|
-
(function ($) {
|
|
10017
|
-
class $mol_fetch_response extends $mol_object2 {
|
|
10018
|
-
native;
|
|
10019
|
-
constructor(native) {
|
|
10020
|
-
super();
|
|
10021
|
-
this.native = native;
|
|
10022
|
-
}
|
|
10023
|
-
status() {
|
|
10024
|
-
const types = ['unknown', 'inform', 'success', 'redirect', 'wrong', 'failed'];
|
|
10025
|
-
return types[Math.floor(this.native.status / 100)];
|
|
10026
|
-
}
|
|
10027
|
-
code() {
|
|
10028
|
-
return this.native.status;
|
|
10029
|
-
}
|
|
10030
|
-
message() {
|
|
10031
|
-
return this.native.statusText || `HTTP Error ${this.code()}`;
|
|
10032
|
-
}
|
|
10033
|
-
headers() {
|
|
10034
|
-
return this.native.headers;
|
|
10035
|
-
}
|
|
10036
|
-
mime() {
|
|
10037
|
-
return this.headers().get('content-type');
|
|
10038
|
-
}
|
|
10039
|
-
stream() {
|
|
10040
|
-
return this.native.body;
|
|
10041
|
-
}
|
|
10042
|
-
text() {
|
|
10043
|
-
const buffer = this.buffer();
|
|
10044
|
-
const native = this.native;
|
|
10045
|
-
const mime = native.headers.get('content-type') || '';
|
|
10046
|
-
const [, charset] = /charset=(.*)/.exec(mime) || [, 'utf-8'];
|
|
10047
|
-
const decoder = new TextDecoder(charset);
|
|
10048
|
-
return decoder.decode(buffer);
|
|
10049
|
-
}
|
|
10050
|
-
json() {
|
|
10051
|
-
return $mol_wire_sync(this.native).json();
|
|
10052
|
-
}
|
|
10053
|
-
buffer() {
|
|
10054
|
-
return $mol_wire_sync(this.native).arrayBuffer();
|
|
10055
|
-
}
|
|
10056
|
-
xml() {
|
|
10057
|
-
return $mol_dom_parse(this.text(), 'application/xml');
|
|
10058
|
-
}
|
|
10059
|
-
xhtml() {
|
|
10060
|
-
return $mol_dom_parse(this.text(), 'application/xhtml+xml');
|
|
10061
|
-
}
|
|
10062
|
-
html() {
|
|
10063
|
-
return $mol_dom_parse(this.text(), 'text/html');
|
|
10064
|
-
}
|
|
10065
|
-
}
|
|
10066
|
-
__decorate([
|
|
10067
|
-
$mol_action
|
|
10068
|
-
], $mol_fetch_response.prototype, "stream", null);
|
|
10069
|
-
__decorate([
|
|
10070
|
-
$mol_action
|
|
10071
|
-
], $mol_fetch_response.prototype, "text", null);
|
|
10072
|
-
__decorate([
|
|
10073
|
-
$mol_action
|
|
10074
|
-
], $mol_fetch_response.prototype, "buffer", null);
|
|
10075
|
-
__decorate([
|
|
10076
|
-
$mol_action
|
|
10077
|
-
], $mol_fetch_response.prototype, "xml", null);
|
|
10078
|
-
__decorate([
|
|
10079
|
-
$mol_action
|
|
10080
|
-
], $mol_fetch_response.prototype, "xhtml", null);
|
|
10081
|
-
__decorate([
|
|
10082
|
-
$mol_action
|
|
10083
|
-
], $mol_fetch_response.prototype, "html", null);
|
|
10084
|
-
$.$mol_fetch_response = $mol_fetch_response;
|
|
10085
|
-
class $mol_fetch extends $mol_object2 {
|
|
10086
|
-
static request(input, init = {}) {
|
|
10087
|
-
const native = globalThis.fetch ?? $node['undici'].fetch;
|
|
10088
|
-
const controller = new AbortController();
|
|
10089
|
-
let done = false;
|
|
10090
|
-
const promise = native(input, {
|
|
10091
|
-
...init,
|
|
10092
|
-
signal: controller.signal,
|
|
10093
|
-
}).finally(() => {
|
|
10094
|
-
done = true;
|
|
10095
|
-
});
|
|
10096
|
-
return Object.assign(promise, {
|
|
10097
|
-
destructor: () => {
|
|
10098
|
-
if (!done && !controller.signal.aborted)
|
|
10099
|
-
controller.abort();
|
|
10100
|
-
},
|
|
10101
|
-
});
|
|
10102
|
-
}
|
|
10103
|
-
static response(input, init) {
|
|
10104
|
-
return new $mol_fetch_response($mol_wire_sync(this).request(input, init));
|
|
10105
|
-
}
|
|
10106
|
-
static success(input, init) {
|
|
10107
|
-
const response = this.response(input, init);
|
|
10108
|
-
if (response.status() === 'success')
|
|
10109
|
-
return response;
|
|
10110
|
-
throw new Error(response.message());
|
|
10111
|
-
}
|
|
10112
|
-
static stream(input, init) {
|
|
10113
|
-
return this.success(input, init).stream();
|
|
10114
|
-
}
|
|
10115
|
-
static text(input, init) {
|
|
10116
|
-
return this.success(input, init).text();
|
|
10117
|
-
}
|
|
10118
|
-
static json(input, init) {
|
|
10119
|
-
return this.success(input, init).json();
|
|
10120
|
-
}
|
|
10121
|
-
static buffer(input, init) {
|
|
10122
|
-
return this.success(input, init).buffer();
|
|
10123
|
-
}
|
|
10124
|
-
static xml(input, init) {
|
|
10125
|
-
return this.success(input, init).xml();
|
|
10126
|
-
}
|
|
10127
|
-
static xhtml(input, init) {
|
|
10128
|
-
return this.success(input, init).xhtml();
|
|
10129
|
-
}
|
|
10130
|
-
static html(input, init) {
|
|
10131
|
-
return this.success(input, init).html();
|
|
10132
|
-
}
|
|
10133
|
-
}
|
|
10134
|
-
__decorate([
|
|
10135
|
-
$mol_action
|
|
10136
|
-
], $mol_fetch, "response", null);
|
|
10137
|
-
__decorate([
|
|
10138
|
-
$mol_action
|
|
10139
|
-
], $mol_fetch, "success", null);
|
|
10140
|
-
__decorate([
|
|
10141
|
-
$mol_action
|
|
10142
|
-
], $mol_fetch, "stream", null);
|
|
10143
|
-
__decorate([
|
|
10144
|
-
$mol_action
|
|
10145
|
-
], $mol_fetch, "text", null);
|
|
10146
|
-
__decorate([
|
|
10147
|
-
$mol_action
|
|
10148
|
-
], $mol_fetch, "json", null);
|
|
10149
|
-
__decorate([
|
|
10150
|
-
$mol_action
|
|
10151
|
-
], $mol_fetch, "buffer", null);
|
|
10152
|
-
__decorate([
|
|
10153
|
-
$mol_action
|
|
10154
|
-
], $mol_fetch, "xml", null);
|
|
10155
|
-
__decorate([
|
|
10156
|
-
$mol_action
|
|
10157
|
-
], $mol_fetch, "xhtml", null);
|
|
10158
|
-
__decorate([
|
|
10159
|
-
$mol_action
|
|
10160
|
-
], $mol_fetch, "html", null);
|
|
10161
|
-
$.$mol_fetch = $mol_fetch;
|
|
10162
|
-
})($ || ($ = {}));
|
|
10163
|
-
//mol/fetch/fetch.ts
|
|
10164
|
-
;
|
|
10165
|
-
"use strict";
|
|
10166
|
-
var $;
|
|
10167
|
-
(function ($) {
|
|
10168
|
-
function $mol_huggingface_run(space, method, ...data) {
|
|
10169
|
-
while (true) {
|
|
10170
|
-
try {
|
|
10171
|
-
if (typeof method === 'number') {
|
|
10172
|
-
return $mol_wire_sync(this).$mol_huggingface_ws(space, method, ...data);
|
|
10173
|
-
}
|
|
10174
|
-
else {
|
|
10175
|
-
return this.$mol_huggingface_rest(space, method, ...data);
|
|
10176
|
-
}
|
|
10177
|
-
}
|
|
10178
|
-
catch (error) {
|
|
10179
|
-
if ($mol_promise_like(error))
|
|
10180
|
-
$mol_fail_hidden(error);
|
|
10181
|
-
if (error instanceof Error && error.message === `Queue full`) {
|
|
10182
|
-
$mol_fail_log(error);
|
|
10183
|
-
continue;
|
|
10184
|
-
}
|
|
10185
|
-
$mol_fail_hidden(error);
|
|
10186
|
-
}
|
|
10187
|
-
}
|
|
10188
|
-
}
|
|
10189
|
-
$.$mol_huggingface_run = $mol_huggingface_run;
|
|
10190
|
-
function $mol_huggingface_rest(space, method, ...data) {
|
|
10191
|
-
const uri = `https://${space}.hf.space/run/${method}`;
|
|
10192
|
-
const response = $mol_fetch.json(uri, {
|
|
10193
|
-
method: 'post',
|
|
10194
|
-
headers: { "Content-Type": "application/json" },
|
|
10195
|
-
body: JSON.stringify({ data }),
|
|
10196
|
-
});
|
|
10197
|
-
if ('error' in response) {
|
|
10198
|
-
$mol_fail(new Error(response.error ?? 'Unknown API error'));
|
|
10199
|
-
}
|
|
10200
|
-
return response.data;
|
|
10201
|
-
}
|
|
10202
|
-
$.$mol_huggingface_rest = $mol_huggingface_rest;
|
|
10203
|
-
function $mol_huggingface_ws(space, fn_index, ...data) {
|
|
10204
|
-
const session_hash = $mol_guid();
|
|
10205
|
-
const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
|
|
10206
|
-
const promise = new Promise((done, fail) => {
|
|
10207
|
-
socket.onclose = event => {
|
|
10208
|
-
if (event.reason)
|
|
10209
|
-
fail(new Error(event.reason));
|
|
10210
|
-
};
|
|
10211
|
-
socket.onerror = event => {
|
|
10212
|
-
fail(new Error(`Socket error`));
|
|
10213
|
-
};
|
|
10214
|
-
socket.onmessage = event => {
|
|
10215
|
-
const message = JSON.parse(event.data);
|
|
10216
|
-
switch (message.msg) {
|
|
10217
|
-
case 'send_hash':
|
|
10218
|
-
return socket.send(JSON.stringify({ session_hash, fn_index }));
|
|
10219
|
-
case 'estimation': return;
|
|
10220
|
-
case 'queue_full':
|
|
10221
|
-
fail(new Error(`Queue full`));
|
|
10222
|
-
case 'send_data':
|
|
10223
|
-
return socket.send(JSON.stringify({ session_hash, fn_index, data }));
|
|
10224
|
-
case 'process_starts': return;
|
|
10225
|
-
case 'process_completed':
|
|
10226
|
-
if (message.success) {
|
|
10227
|
-
return done(message.output.data);
|
|
10228
|
-
}
|
|
10229
|
-
else {
|
|
10230
|
-
return fail(new Error(message.output.error ?? `Unknown API error`));
|
|
10231
|
-
}
|
|
10232
|
-
default:
|
|
10233
|
-
return fail(new Error(`Unknown message type: ${message.msg}`));
|
|
10234
|
-
}
|
|
10235
|
-
};
|
|
10236
|
-
});
|
|
10237
|
-
return Object.assign(promise, {
|
|
10238
|
-
destructor: () => socket.close()
|
|
10239
|
-
});
|
|
10240
|
-
}
|
|
10241
|
-
$.$mol_huggingface_ws = $mol_huggingface_ws;
|
|
10242
|
-
})($ || ($ = {}));
|
|
10243
|
-
//mol/huggingface/huggingface.ts
|
|
10244
|
-
;
|
|
10245
|
-
"use strict";
|
|
10246
|
-
var $;
|
|
10247
|
-
(function ($) {
|
|
10248
|
-
function $hyoo_lingua_translate(lang, text) {
|
|
10249
|
-
if (!text.trim())
|
|
10250
|
-
return '';
|
|
10251
|
-
const cache_key = `$hyoo_lingua_translate(${JSON.stringify(lang)},${JSON.stringify(text)})`;
|
|
10252
|
-
const cached = this.$mol_state_local.value(cache_key);
|
|
10253
|
-
if (cached)
|
|
10254
|
-
return String(cached);
|
|
10255
|
-
const translated = this.$mol_huggingface_run('hyoo-translate', 0, lang, text)[0];
|
|
10256
|
-
return this.$mol_state_local.value(cache_key, translated);
|
|
10257
|
-
}
|
|
10258
|
-
$.$hyoo_lingua_translate = $hyoo_lingua_translate;
|
|
10259
|
-
})($ || ($ = {}));
|
|
10260
|
-
//hyoo/lingua/translate/translate.ts
|
|
10261
|
-
;
|
|
10262
|
-
"use strict";
|
|
10263
9968
|
var $;
|
|
10264
9969
|
(function ($) {
|
|
10265
9970
|
class $mol_locale extends $mol_object {
|
|
@@ -10296,12 +10001,6 @@ var $;
|
|
|
10296
10001
|
const en = this.texts('en')[key];
|
|
10297
10002
|
if (!en)
|
|
10298
10003
|
return key;
|
|
10299
|
-
try {
|
|
10300
|
-
return $mol_wire_sync($hyoo_lingua_translate).call(this.$, lang, en);
|
|
10301
|
-
}
|
|
10302
|
-
catch (error) {
|
|
10303
|
-
$mol_fail_log(error);
|
|
10304
|
-
}
|
|
10305
10004
|
return en;
|
|
10306
10005
|
}
|
|
10307
10006
|
static warn(key) {
|