mol_dump_lib 0.0.180 → 0.0.181

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/web.js CHANGED
@@ -5183,106 +5183,6 @@ var $;
5183
5183
  //mol/file/file.web.ts
5184
5184
  ;
5185
5185
  "use strict";
5186
- //hyoo/hyoo.ts
5187
- ;
5188
- "use strict";
5189
- var $;
5190
- (function ($) {
5191
- function $mol_huggingface_run(space, method, ...data) {
5192
- while (true) {
5193
- try {
5194
- if (typeof method === 'number') {
5195
- return $mol_wire_sync(this).$mol_huggingface_ws(space, method, ...data);
5196
- }
5197
- else {
5198
- return this.$mol_huggingface_rest(space, method, ...data);
5199
- }
5200
- }
5201
- catch (error) {
5202
- if ($mol_promise_like(error))
5203
- $mol_fail_hidden(error);
5204
- if (error instanceof Error && error.message === `Queue full`) {
5205
- $mol_fail_log(error);
5206
- continue;
5207
- }
5208
- $mol_fail_hidden(error);
5209
- }
5210
- }
5211
- }
5212
- $.$mol_huggingface_run = $mol_huggingface_run;
5213
- function $mol_huggingface_rest(space, method, ...data) {
5214
- const uri = `https://${space}.hf.space/run/${method}`;
5215
- const response = $mol_fetch.json(uri, {
5216
- method: 'post',
5217
- headers: { "Content-Type": "application/json" },
5218
- body: JSON.stringify({ data }),
5219
- });
5220
- if ('error' in response) {
5221
- $mol_fail(new Error(response.error ?? 'Unknown API error'));
5222
- }
5223
- return response.data;
5224
- }
5225
- $.$mol_huggingface_rest = $mol_huggingface_rest;
5226
- function $mol_huggingface_ws(space, fn_index, ...data) {
5227
- const session_hash = $mol_guid();
5228
- const socket = new WebSocket(`wss://${space}.hf.space/queue/join`);
5229
- const promise = new Promise((done, fail) => {
5230
- socket.onclose = event => {
5231
- if (event.reason)
5232
- fail(new Error(event.reason));
5233
- };
5234
- socket.onerror = event => {
5235
- fail(new Error(`Socket error`));
5236
- };
5237
- socket.onmessage = event => {
5238
- const message = JSON.parse(event.data);
5239
- switch (message.msg) {
5240
- case 'send_hash':
5241
- return socket.send(JSON.stringify({ session_hash, fn_index }));
5242
- case 'estimation': return;
5243
- case 'queue_full':
5244
- fail(new Error(`Queue full`));
5245
- case 'send_data':
5246
- return socket.send(JSON.stringify({ session_hash, fn_index, data }));
5247
- case 'process_starts': return;
5248
- case 'process_completed':
5249
- if (message.success) {
5250
- return done(message.output.data);
5251
- }
5252
- else {
5253
- return fail(new Error(message.output.error ?? `Unknown API error`));
5254
- }
5255
- default:
5256
- return fail(new Error(`Unknown message type: ${message.msg}`));
5257
- }
5258
- };
5259
- });
5260
- return Object.assign(promise, {
5261
- destructor: () => socket.close()
5262
- });
5263
- }
5264
- $.$mol_huggingface_ws = $mol_huggingface_ws;
5265
- })($ || ($ = {}));
5266
- //mol/huggingface/huggingface.ts
5267
- ;
5268
- "use strict";
5269
- var $;
5270
- (function ($) {
5271
- function $hyoo_lingua_translate(lang, text) {
5272
- if (!text.trim())
5273
- return '';
5274
- const cache_key = `$hyoo_lingua_translate(${JSON.stringify(lang)},${JSON.stringify(text)})`;
5275
- const cached = this.$mol_state_local.value(cache_key);
5276
- if (cached)
5277
- return String(cached);
5278
- const translated = this.$mol_huggingface_run('hyoo-translate', 0, lang, text)[0];
5279
- return this.$mol_state_local.value(cache_key, translated);
5280
- }
5281
- $.$hyoo_lingua_translate = $hyoo_lingua_translate;
5282
- })($ || ($ = {}));
5283
- //hyoo/lingua/translate/translate.ts
5284
- ;
5285
- "use strict";
5286
5186
  var $;
5287
5187
  (function ($) {
5288
5188
  class $mol_locale extends $mol_object {
@@ -5319,12 +5219,6 @@ var $;
5319
5219
  const en = this.texts('en')[key];
5320
5220
  if (!en)
5321
5221
  return key;
5322
- try {
5323
- return $mol_wire_sync($hyoo_lingua_translate).call(this.$, lang, en);
5324
- }
5325
- catch (error) {
5326
- $mol_fail_log(error);
5327
- }
5328
5222
  return en;
5329
5223
  }
5330
5224
  static warn(key) {