mol_plot_all 1.2.845 → 1.2.846

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.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 ${this}`);
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 ${this}`);
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 ${this}`);
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
  }
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 ${this}`);
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 ${this}`);
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 ${this}`);
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
  }
@@ -7070,17 +7070,6 @@ var $;
7070
7070
  ;
7071
7071
  "use strict";
7072
7072
  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
7073
  (function ($) {
7085
7074
  function $mol_assert_ok(value) {
7086
7075
  if (value)
@@ -7101,14 +7090,12 @@ var $;
7101
7090
  handler();
7102
7091
  }
7103
7092
  catch (error) {
7104
- if (!ErrorRight)
7105
- return error;
7106
7093
  $.$mol_fail = fail;
7107
7094
  if (typeof ErrorRight === 'string') {
7108
7095
  $mol_assert_equal(error.message, ErrorRight);
7109
7096
  }
7110
7097
  else {
7111
- $mol_assert_ok(error instanceof ErrorRight);
7098
+ $mol_assert_equal(error instanceof ErrorRight, true);
7112
7099
  }
7113
7100
  return error;
7114
7101
  }
@@ -7118,58 +7105,47 @@ var $;
7118
7105
  $mol_fail(new Error('Not failed'));
7119
7106
  }
7120
7107
  $.$mol_assert_fail = $mol_assert_fail;
7121
- function $mol_assert_equal(...args) {
7122
- for (let i = 0; i < args.length; ++i) {
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
- }
7108
+ function $mol_assert_like(...args) {
7109
+ $mol_assert_equal(...args);
7132
7110
  }
7133
- $.$mol_assert_equal = $mol_assert_equal;
7111
+ $.$mol_assert_like = $mol_assert_like;
7134
7112
  function $mol_assert_unique(...args) {
7135
7113
  for (let i = 0; i < args.length; ++i) {
7136
7114
  for (let j = 0; j < args.length; ++j) {
7137
7115
  if (i === j)
7138
7116
  continue;
7139
- if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
7140
- $mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
7141
- }
7117
+ if (!$mol_compare_deep(args[i], args[j]))
7118
+ continue;
7119
+ $mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
7142
7120
  }
7143
7121
  }
7144
7122
  }
7145
7123
  $.$mol_assert_unique = $mol_assert_unique;
7146
- function $mol_assert_like(head, ...tail) {
7147
- for (let [index, value] of Object.entries(tail)) {
7148
- if (!$mol_compare_deep(value, head)) {
7149
- const print = (val) => {
7150
- if (!val)
7151
- return val;
7152
- if (typeof val !== 'object')
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
- }
7124
+ function $mol_assert_equal(...args) {
7125
+ for (let i = 1; i < args.length; ++i) {
7126
+ if ($mol_compare_deep(args[0], args[i]))
7127
+ continue;
7128
+ if (args[0] instanceof Element && args[i] instanceof Element && args[0].outerHTML === args[i].outerHTML)
7129
+ continue;
7130
+ return $mol_fail(new Error(`args[0] args[${i}]\n${print(args[0])}\n---\n${print(args[i])}`));
7166
7131
  }
7167
7132
  }
7168
- $.$mol_assert_like = $mol_assert_like;
7169
- function $mol_assert_dom(left, right) {
7170
- $mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
7171
- }
7172
- $.$mol_assert_dom = $mol_assert_dom;
7133
+ $.$mol_assert_equal = $mol_assert_equal;
7134
+ const print = (val) => {
7135
+ if (!val)
7136
+ return val;
7137
+ if (typeof val !== 'object')
7138
+ return val;
7139
+ if ('outerHTML' in val)
7140
+ return val.outerHTML;
7141
+ try {
7142
+ return JSON.stringify(val, (k, v) => typeof v === 'bigint' ? String(v) : v, '\t');
7143
+ }
7144
+ catch (error) {
7145
+ console.error(error);
7146
+ return val;
7147
+ }
7148
+ };
7173
7149
  })($ || ($ = {}));
7174
7150
  //mol/assert/assert.ts
7175
7151
  ;
@@ -7190,10 +7166,10 @@ var $;
7190
7166
  $mol_assert_equal(2, 2, 2);
7191
7167
  },
7192
7168
  'two must be unique'() {
7193
- $mol_assert_unique([3], [3]);
7169
+ $mol_assert_unique([2], [3]);
7194
7170
  },
7195
7171
  'three must be unique'() {
7196
- $mol_assert_unique([3], [3], [3]);
7172
+ $mol_assert_unique([1], [2], [3]);
7197
7173
  },
7198
7174
  'two must be alike'() {
7199
7175
  $mol_assert_like([3], [3]);
@@ -7966,7 +7942,7 @@ var $;
7966
7942
  ], App, "result", null);
7967
7943
  $mol_assert_equal(App.result(), 1);
7968
7944
  App.condition(true);
7969
- $mol_assert_fail(() => App.result());
7945
+ $mol_assert_fail(() => App.result(), 'test error');
7970
7946
  App.condition(false);
7971
7947
  $mol_assert_equal(App.result(), 1);
7972
7948
  },
@@ -8905,14 +8881,14 @@ var $;
8905
8881
  },
8906
8882
  'slice span - out of range'($) {
8907
8883
  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));
8884
+ $mol_assert_fail(() => span.slice(-1, 3), `End value '3' can't be less than begin value (test.ts#1:3/5)`);
8885
+ $mol_assert_fail(() => span.slice(1, 6), `End value '6' out of range (test.ts#1:3/5)`);
8886
+ $mol_assert_fail(() => span.slice(1, 10), `End value '10' out of range (test.ts#1:3/5)`);
8911
8887
  },
8912
8888
  'error handling'($) {
8913
8889
  const span = new $mol_span('test.ts', '', 1, 3, 4);
8914
- const error = span.error('Some error\n');
8915
- $mol_assert_equal(error.message, 'Some error\ntest.ts#1:3/4');
8890
+ const error = span.error('Some error');
8891
+ $mol_assert_equal(error.message, 'Some error (test.ts#1:3/4)');
8916
8892
  }
8917
8893
  });
8918
8894
  })($ || ($ = {}));
@@ -9987,279 +9963,6 @@ var $;
9987
9963
  //mol/file/file.node.ts
9988
9964
  ;
9989
9965
  "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
9966
  var $;
10264
9967
  (function ($) {
10265
9968
  class $mol_locale extends $mol_object {
@@ -10296,12 +9999,6 @@ var $;
10296
9999
  const en = this.texts('en')[key];
10297
10000
  if (!en)
10298
10001
  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
10002
  return en;
10306
10003
  }
10307
10004
  static warn(key) {