mol_wire_lib 1.0.179 → 1.0.180

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.test.js CHANGED
@@ -1170,7 +1170,12 @@ var $;
1170
1170
  const fiber = temp(obj, args);
1171
1171
  return fiber.sync();
1172
1172
  };
1173
- }
1173
+ },
1174
+ apply(obj, self, args) {
1175
+ const temp = $mol_wire_task.getter(obj);
1176
+ const fiber = temp(self, args);
1177
+ return fiber.sync();
1178
+ },
1174
1179
  });
1175
1180
  }
1176
1181
  $.$mol_wire_sync = $mol_wire_sync;
@@ -1193,7 +1198,12 @@ var $;
1193
1198
  fiber = temp(obj, args);
1194
1199
  return fiber.async();
1195
1200
  };
1196
- }
1201
+ },
1202
+ apply(obj, self, args) {
1203
+ const temp = $mol_wire_task.getter(obj);
1204
+ const fiber = temp(self, args);
1205
+ return fiber.async();
1206
+ },
1197
1207
  });
1198
1208
  }
1199
1209
  $.$mol_wire_async = $mol_wire_async;
@@ -1536,48 +1546,6 @@ var $;
1536
1546
  //mol/log3/log3.ts
1537
1547
  ;
1538
1548
  "use strict";
1539
- //node/node.ts
1540
- ;
1541
- "use strict";
1542
- var $node = new Proxy({ require }, {
1543
- get(target, name, wrapper) {
1544
- if (target[name])
1545
- return target[name];
1546
- const mod = target.require('module');
1547
- if (mod.builtinModules.indexOf(name) >= 0)
1548
- return target.require(name);
1549
- const path = target.require('path');
1550
- const fs = target.require('fs');
1551
- let dir = path.resolve('.');
1552
- const suffix = `./node_modules/${name}`;
1553
- const $$ = $;
1554
- while (!fs.existsSync(path.join(dir, suffix))) {
1555
- const parent = path.resolve(dir, '..');
1556
- if (parent === dir) {
1557
- $$.$mol_exec('.', 'npm', 'install', name);
1558
- try {
1559
- $$.$mol_exec('.', 'npm', 'install', '@types/' + name);
1560
- }
1561
- catch { }
1562
- break;
1563
- }
1564
- else {
1565
- dir = parent;
1566
- }
1567
- }
1568
- return target.require(name);
1569
- },
1570
- set(target, name, value) {
1571
- target[name] = value;
1572
- return true;
1573
- },
1574
- });
1575
- require = (req => Object.assign(function require(name) {
1576
- return $node[name];
1577
- }, req))(require);
1578
- //node/node.node.ts
1579
- ;
1580
- "use strict";
1581
1549
  var $;
1582
1550
  (function ($) {
1583
1551
  $.$mol_tree_convert = Symbol('$mol_tree_convert');
@@ -1909,80 +1877,77 @@ var $;
1909
1877
  ;
1910
1878
  "use strict";
1911
1879
  var $;
1880
+ (function ($) {
1881
+ class $mol_term_color {
1882
+ static reset = this.ansi(0, 0);
1883
+ static bold = this.ansi(1, 22);
1884
+ static italic = this.ansi(3, 23);
1885
+ static underline = this.ansi(4, 24);
1886
+ static inverse = this.ansi(7, 27);
1887
+ static hidden = this.ansi(8, 28);
1888
+ static strike = this.ansi(9, 29);
1889
+ static gray = this.ansi(90, 39);
1890
+ static red = this.ansi(91, 39);
1891
+ static green = this.ansi(92, 39);
1892
+ static yellow = this.ansi(93, 39);
1893
+ static blue = this.ansi(94, 39);
1894
+ static magenta = this.ansi(95, 39);
1895
+ static cyan = this.ansi(96, 39);
1896
+ static white = this.ansi(97, 39);
1897
+ static Red = (str) => this.inverse(this.red(str));
1898
+ static Green = (str) => this.inverse(this.green(str));
1899
+ static Yellow = (str) => this.inverse(this.yellow(str));
1900
+ static Blue = (str) => this.inverse(this.blue(str));
1901
+ static Magenta = (str) => this.inverse(this.magenta(str));
1902
+ static Cyan = (str) => this.inverse(this.cyan(str));
1903
+ static White = (str) => this.inverse(this.white(str));
1904
+ static ansi(open, close) {
1905
+ if (typeof process === 'undefined')
1906
+ return String;
1907
+ if (!process.stdout.isTTY)
1908
+ return String;
1909
+ const prefix = `\x1b[${open}m`;
1910
+ const postfix = `\x1b[${close}m`;
1911
+ const suffix_regexp = new RegExp(postfix.replace('[', '\\['), 'g');
1912
+ return function colorer(str) {
1913
+ str = String(str);
1914
+ if (str === '')
1915
+ return str;
1916
+ const suffix = str.replace(suffix_regexp, prefix);
1917
+ return prefix + suffix + postfix;
1918
+ };
1919
+ }
1920
+ }
1921
+ $.$mol_term_color = $mol_term_color;
1922
+ })($ || ($ = {}));
1923
+ //mol/term/color/color.ts
1924
+ ;
1925
+ "use strict";
1926
+ var $;
1912
1927
  (function ($) {
1913
1928
  function $mol_log3_node_make(level, output, type, color) {
1914
1929
  return function $mol_log3_logger(event) {
1915
1930
  if (!event.time)
1916
1931
  event = { time: new Date().toISOString(), ...event };
1917
1932
  const tree = this.$mol_tree.fromJSON(event).clone({ type });
1918
- let str = tree.toString();
1919
- if (process[output].isTTY) {
1920
- str = $node.colorette[color + 'Bright'](str);
1921
- }
1922
- ;
1933
+ let str = color(tree.toString());
1923
1934
  this.console[level](str);
1924
1935
  const self = this;
1925
1936
  return () => self.console.groupEnd();
1926
1937
  };
1927
1938
  }
1928
1939
  $.$mol_log3_node_make = $mol_log3_node_make;
1929
- $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', 'blue');
1930
- $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', 'green');
1931
- $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', 'red');
1932
- $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', 'yellow');
1933
- $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
1934
- $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
1940
+ $.$mol_log3_come = $mol_log3_node_make('info', 'stdout', 'come', $mol_term_color.blue);
1941
+ $.$mol_log3_done = $mol_log3_node_make('info', 'stdout', 'done', $mol_term_color.green);
1942
+ $.$mol_log3_fail = $mol_log3_node_make('error', 'stderr', 'fail', $mol_term_color.red);
1943
+ $.$mol_log3_warn = $mol_log3_node_make('warn', 'stderr', 'warn', $mol_term_color.yellow);
1944
+ $.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', $mol_term_color.magenta);
1945
+ $.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', $mol_term_color.cyan);
1935
1946
  })($ || ($ = {}));
1936
1947
  //mol/log3/log3.node.ts
1937
1948
  ;
1938
1949
  "use strict";
1939
1950
  var $;
1940
- (function ($) {
1941
- function $mol_env() {
1942
- return {};
1943
- }
1944
- $.$mol_env = $mol_env;
1945
- })($ || ($ = {}));
1946
- //mol/env/env.ts
1947
- ;
1948
- "use strict";
1949
- var $;
1950
- (function ($) {
1951
- $.$mol_env = function $mol_env() {
1952
- return this.process.env;
1953
- };
1954
- })($ || ($ = {}));
1955
- //mol/env/env.node.ts
1956
- ;
1957
- "use strict";
1958
- var $;
1959
- (function ($) {
1960
- function $mol_exec(dir, command, ...args) {
1961
- let [app, ...args0] = command.split(' ');
1962
- args = [...args0, ...args];
1963
- this.$mol_log3_come({
1964
- place: '$mol_exec',
1965
- dir: $node.path.relative('', dir),
1966
- message: 'Run',
1967
- command: `${app} ${args.join(' ')}`,
1968
- });
1969
- var res = $node['child_process'].spawnSync(app, args, {
1970
- cwd: $node.path.resolve(dir),
1971
- shell: true,
1972
- env: this.$mol_env(),
1973
- });
1974
- if (res.status || res.error)
1975
- return $mol_fail(res.error || new Error(res.stderr.toString()));
1976
- if (!res.stdout)
1977
- res.stdout = Buffer.from([]);
1978
- return res;
1979
- }
1980
- $.$mol_exec = $mol_exec;
1981
- })($ || ($ = {}));
1982
- //mol/exec/exec.node.ts
1983
- ;
1984
- "use strict";
1985
- var $;
1986
1951
  (function ($) {
1987
1952
  class $mol_wire_log extends $mol_object2 {
1988
1953
  static watch(task) {
@@ -2143,6 +2108,108 @@ var $;
2143
2108
  //mol/dom/context/context.ts
2144
2109
  ;
2145
2110
  "use strict";
2111
+ //node/node.ts
2112
+ ;
2113
+ "use strict";
2114
+ var $node = new Proxy({ require }, {
2115
+ get(target, name, wrapper) {
2116
+ if (target[name])
2117
+ return target[name];
2118
+ const mod = target.require('module');
2119
+ if (mod.builtinModules.indexOf(name) >= 0)
2120
+ return target.require(name);
2121
+ const path = target.require('path');
2122
+ const fs = target.require('fs');
2123
+ let dir = path.resolve('.');
2124
+ const suffix = `./node_modules/${name}`;
2125
+ const $$ = $;
2126
+ while (!fs.existsSync(path.join(dir, suffix))) {
2127
+ const parent = path.resolve(dir, '..');
2128
+ if (parent === dir) {
2129
+ $$.$mol_exec('.', 'npm', 'install', name);
2130
+ try {
2131
+ $$.$mol_exec('.', 'npm', 'install', '@types/' + name);
2132
+ }
2133
+ catch { }
2134
+ break;
2135
+ }
2136
+ else {
2137
+ dir = parent;
2138
+ }
2139
+ }
2140
+ return target.require(name);
2141
+ },
2142
+ set(target, name, value) {
2143
+ target[name] = value;
2144
+ return true;
2145
+ },
2146
+ });
2147
+ require = (req => Object.assign(function require(name) {
2148
+ return $node[name];
2149
+ }, req))(require);
2150
+ //node/node.node.ts
2151
+ ;
2152
+ "use strict";
2153
+ var $;
2154
+ (function ($_1) {
2155
+ $mol_test_mocks.push($ => {
2156
+ $.$mol_log3_come = () => { };
2157
+ $.$mol_log3_done = () => { };
2158
+ $.$mol_log3_fail = () => { };
2159
+ $.$mol_log3_warn = () => { };
2160
+ $.$mol_log3_rise = () => { };
2161
+ $.$mol_log3_area = () => () => { };
2162
+ });
2163
+ })($ || ($ = {}));
2164
+ //mol/log3/log3.test.ts
2165
+ ;
2166
+ "use strict";
2167
+ var $;
2168
+ (function ($) {
2169
+ function $mol_env() {
2170
+ return {};
2171
+ }
2172
+ $.$mol_env = $mol_env;
2173
+ })($ || ($ = {}));
2174
+ //mol/env/env.ts
2175
+ ;
2176
+ "use strict";
2177
+ var $;
2178
+ (function ($) {
2179
+ $.$mol_env = function $mol_env() {
2180
+ return this.process.env;
2181
+ };
2182
+ })($ || ($ = {}));
2183
+ //mol/env/env.node.ts
2184
+ ;
2185
+ "use strict";
2186
+ var $;
2187
+ (function ($) {
2188
+ function $mol_exec(dir, command, ...args) {
2189
+ let [app, ...args0] = command.split(' ');
2190
+ args = [...args0, ...args];
2191
+ this.$mol_log3_come({
2192
+ place: '$mol_exec',
2193
+ dir: $node.path.relative('', dir),
2194
+ message: 'Run',
2195
+ command: `${app} ${args.join(' ')}`,
2196
+ });
2197
+ var res = $node['child_process'].spawnSync(app, args, {
2198
+ cwd: $node.path.resolve(dir),
2199
+ shell: true,
2200
+ env: this.$mol_env(),
2201
+ });
2202
+ if (res.status || res.error)
2203
+ return $mol_fail(res.error || new Error(res.stderr.toString()));
2204
+ if (!res.stdout)
2205
+ res.stdout = Buffer.from([]);
2206
+ return res;
2207
+ }
2208
+ $.$mol_exec = $mol_exec;
2209
+ })($ || ($ = {}));
2210
+ //mol/exec/exec.node.ts
2211
+ ;
2212
+ "use strict";
2146
2213
  var $;
2147
2214
  (function ($) {
2148
2215
  $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
@@ -2607,20 +2674,6 @@ var $;
2607
2674
  ;
2608
2675
  "use strict";
2609
2676
  var $;
2610
- (function ($_1) {
2611
- $mol_test_mocks.push($ => {
2612
- $.$mol_log3_come = () => { };
2613
- $.$mol_log3_done = () => { };
2614
- $.$mol_log3_fail = () => { };
2615
- $.$mol_log3_warn = () => { };
2616
- $.$mol_log3_rise = () => { };
2617
- $.$mol_log3_area = () => () => { };
2618
- });
2619
- })($ || ($ = {}));
2620
- //mol/log3/log3.test.ts
2621
- ;
2622
- "use strict";
2623
- var $;
2624
2677
  (function ($) {
2625
2678
  $mol_test({
2626
2679
  'get'() {
@@ -2843,6 +2896,15 @@ var $;
2843
2896
  ;
2844
2897
  "use strict";
2845
2898
  var $;
2899
+ (function ($_1) {
2900
+ $mol_test_mocks.push($ => {
2901
+ $.$mol_after_timeout = $mol_after_mock_timeout;
2902
+ });
2903
+ })($ || ($ = {}));
2904
+ //mol/after/timeout/timeout.test.ts
2905
+ ;
2906
+ "use strict";
2907
+ var $;
2846
2908
  (function ($_1) {
2847
2909
  $mol_test({
2848
2910
  async 'Latest Calls Wins on Concurrency'($) {
@@ -2864,21 +2926,21 @@ var $;
2864
2926
  $mol_assert_like(NameLogger.first, ['john', 'jin']);
2865
2927
  $mol_assert_like(NameLogger.last, ['jin']);
2866
2928
  },
2929
+ async 'Wrap function'($) {
2930
+ const name = $mol_wire_async(function (name) {
2931
+ $.$mol_wait_timeout(0);
2932
+ return name;
2933
+ });
2934
+ const promise = name('jin');
2935
+ $.$mol_after_mock_warp();
2936
+ $mol_assert_like(await promise, 'jin');
2937
+ },
2867
2938
  });
2868
2939
  })($ || ($ = {}));
2869
2940
  //mol/wire/async/async.test.ts
2870
2941
  ;
2871
2942
  "use strict";
2872
2943
  var $;
2873
- (function ($_1) {
2874
- $mol_test_mocks.push($ => {
2875
- $.$mol_after_timeout = $mol_after_mock_timeout;
2876
- });
2877
- })($ || ($ = {}));
2878
- //mol/after/timeout/timeout.test.ts
2879
- ;
2880
- "use strict";
2881
- var $;
2882
2944
  (function ($_1) {
2883
2945
  $mol_test_mocks.push($ => {
2884
2946
  $.$mol_after_frame = $mol_after_mock_commmon;