mol_wire_lib 1.0.98 → 1.0.99

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
@@ -679,84 +679,6 @@ var $;
679
679
  ;
680
680
  "use strict";
681
681
  var $;
682
- (function ($) {
683
- function $mol_guid(length = 8, exists = () => false) {
684
- for (;;) {
685
- let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
686
- if (exists(id))
687
- continue;
688
- return id;
689
- }
690
- }
691
- $.$mol_guid = $mol_guid;
692
- })($ || ($ = {}));
693
- //mol/guid/guid.ts
694
- ;
695
- "use strict";
696
- var $;
697
- (function ($) {
698
- $.$mol_key_store = new WeakMap();
699
- function $mol_key(value) {
700
- if (!value)
701
- return JSON.stringify(value);
702
- if (typeof value !== 'object' && typeof value !== 'function')
703
- return JSON.stringify(value);
704
- return JSON.stringify(value, (field, value) => {
705
- if (!value)
706
- return value;
707
- if (typeof value !== 'object' && typeof value !== 'function')
708
- return value;
709
- if (Array.isArray(value))
710
- return value;
711
- const proto = Reflect.getPrototypeOf(value);
712
- if (!proto)
713
- return value;
714
- if (Reflect.getPrototypeOf(proto) === null)
715
- return value;
716
- if ('toJSON' in value)
717
- return value;
718
- if (value instanceof RegExp)
719
- return value.toString();
720
- let key = $.$mol_key_store.get(value);
721
- if (key)
722
- return key;
723
- key = $mol_guid();
724
- $.$mol_key_store.set(value, key);
725
- return key;
726
- });
727
- }
728
- $.$mol_key = $mol_key;
729
- })($ || ($ = {}));
730
- //mol/key/key.ts
731
- ;
732
- "use strict";
733
- var $;
734
- (function ($) {
735
- function $mol_wire_method(host, field, descr) {
736
- if (!descr)
737
- descr = Reflect.getOwnPropertyDescriptor(host, field);
738
- const orig = descr?.value ?? host[field];
739
- const sup = Reflect.getPrototypeOf(host);
740
- if (typeof sup[field] === 'function') {
741
- Object.defineProperty(orig, 'name', { value: sup[field].name });
742
- }
743
- const temp = $mol_wire_fiber_temp.getter(orig);
744
- const value = function (...args) {
745
- const fiber = temp(this ?? null, args);
746
- return fiber.sync();
747
- };
748
- Object.defineProperty(value, 'name', { value: orig.name + ' ' });
749
- Object.assign(value, { orig });
750
- const descr2 = { ...descr, value };
751
- Reflect.defineProperty(host, field, descr2);
752
- return descr2;
753
- }
754
- $.$mol_wire_method = $mol_wire_method;
755
- })($ || ($ = {}));
756
- //mol/wire/method/method.ts
757
- ;
758
- "use strict";
759
- var $;
760
682
  (function ($) {
761
683
  const handled = new WeakSet();
762
684
  class $mol_wire_fiber extends $mol_wire_pub_sub {
@@ -970,6 +892,40 @@ var $;
970
892
  }
971
893
  }
972
894
  $.$mol_wire_fiber = $mol_wire_fiber;
895
+ })($ || ($ = {}));
896
+ //mol/wire/fiber/fiber.ts
897
+ ;
898
+ "use strict";
899
+ var $;
900
+ (function ($) {
901
+ function $mol_wire_probe(task, next) {
902
+ const warm = $mol_wire_fiber.warm;
903
+ try {
904
+ $mol_wire_fiber.warm = false;
905
+ return task();
906
+ }
907
+ finally {
908
+ $mol_wire_fiber.warm = warm;
909
+ }
910
+ }
911
+ $.$mol_wire_probe = $mol_wire_probe;
912
+ })($ || ($ = {}));
913
+ //mol/wire/probe/probe.ts
914
+ ;
915
+ "use strict";
916
+ var $;
917
+ (function ($) {
918
+ function $mol_wire_solid() {
919
+ $mol_wire_auto().reap = nothing;
920
+ }
921
+ $.$mol_wire_solid = $mol_wire_solid;
922
+ const nothing = () => { };
923
+ })($ || ($ = {}));
924
+ //mol/wire/solid/solid.ts
925
+ ;
926
+ "use strict";
927
+ var $;
928
+ (function ($) {
973
929
  class $mol_wire_fiber_temp extends $mol_wire_fiber {
974
930
  static getter(task) {
975
931
  return function $mol_wire_fiber_temp_get(host, args) {
@@ -993,6 +949,134 @@ var $;
993
949
  }
994
950
  }
995
951
  $.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
952
+ })($ || ($ = {}));
953
+ //mol/wire/fiber/temp/temp.ts
954
+ ;
955
+ "use strict";
956
+ var $;
957
+ (function ($) {
958
+ function $mol_wire_sync(obj) {
959
+ return new Proxy(obj, {
960
+ get(obj, field) {
961
+ const val = obj[field];
962
+ if (typeof val !== 'function')
963
+ return val;
964
+ const temp = $mol_wire_fiber_temp.getter(val);
965
+ return function $mol_wire_sync(...args) {
966
+ const fiber = temp(obj, args);
967
+ return fiber.sync();
968
+ };
969
+ }
970
+ });
971
+ }
972
+ $.$mol_wire_sync = $mol_wire_sync;
973
+ })($ || ($ = {}));
974
+ //mol/wire/sync/sync.ts
975
+ ;
976
+ "use strict";
977
+ var $;
978
+ (function ($) {
979
+ function $mol_wire_async(obj) {
980
+ return new Proxy(obj, {
981
+ get(obj, field) {
982
+ const val = obj[field];
983
+ if (typeof val !== 'function')
984
+ return val;
985
+ let fiber;
986
+ const temp = $mol_wire_fiber_temp.getter(val);
987
+ return function $mol_wire_async(...args) {
988
+ fiber?.destructor();
989
+ fiber = temp(obj, args);
990
+ return fiber.async();
991
+ };
992
+ }
993
+ });
994
+ }
995
+ $.$mol_wire_async = $mol_wire_async;
996
+ })($ || ($ = {}));
997
+ //mol/wire/async/async.ts
998
+ ;
999
+ "use strict";
1000
+ var $;
1001
+ (function ($) {
1002
+ function $mol_guid(length = 8, exists = () => false) {
1003
+ for (;;) {
1004
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
1005
+ if (exists(id))
1006
+ continue;
1007
+ return id;
1008
+ }
1009
+ }
1010
+ $.$mol_guid = $mol_guid;
1011
+ })($ || ($ = {}));
1012
+ //mol/guid/guid.ts
1013
+ ;
1014
+ "use strict";
1015
+ var $;
1016
+ (function ($) {
1017
+ $.$mol_key_store = new WeakMap();
1018
+ function $mol_key(value) {
1019
+ if (!value)
1020
+ return JSON.stringify(value);
1021
+ if (typeof value !== 'object' && typeof value !== 'function')
1022
+ return JSON.stringify(value);
1023
+ return JSON.stringify(value, (field, value) => {
1024
+ if (!value)
1025
+ return value;
1026
+ if (typeof value !== 'object' && typeof value !== 'function')
1027
+ return value;
1028
+ if (Array.isArray(value))
1029
+ return value;
1030
+ const proto = Reflect.getPrototypeOf(value);
1031
+ if (!proto)
1032
+ return value;
1033
+ if (Reflect.getPrototypeOf(proto) === null)
1034
+ return value;
1035
+ if ('toJSON' in value)
1036
+ return value;
1037
+ if (value instanceof RegExp)
1038
+ return value.toString();
1039
+ let key = $.$mol_key_store.get(value);
1040
+ if (key)
1041
+ return key;
1042
+ key = $mol_guid();
1043
+ $.$mol_key_store.set(value, key);
1044
+ return key;
1045
+ });
1046
+ }
1047
+ $.$mol_key = $mol_key;
1048
+ })($ || ($ = {}));
1049
+ //mol/key/key.ts
1050
+ ;
1051
+ "use strict";
1052
+ var $;
1053
+ (function ($) {
1054
+ function $mol_wire_method(host, field, descr) {
1055
+ if (!descr)
1056
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1057
+ const orig = descr?.value ?? host[field];
1058
+ const sup = Reflect.getPrototypeOf(host);
1059
+ if (typeof sup[field] === 'function') {
1060
+ Object.defineProperty(orig, 'name', { value: sup[field].name });
1061
+ }
1062
+ const temp = $mol_wire_fiber_temp.getter(orig);
1063
+ const value = function (...args) {
1064
+ const fiber = temp(this ?? null, args);
1065
+ return fiber.sync();
1066
+ };
1067
+ Object.defineProperty(value, 'name', { value: orig.name + ' ' });
1068
+ Object.assign(value, { orig });
1069
+ const descr2 = { ...descr, value };
1070
+ Reflect.defineProperty(host, field, descr2);
1071
+ return descr2;
1072
+ }
1073
+ $.$mol_wire_method = $mol_wire_method;
1074
+ })($ || ($ = {}));
1075
+ //mol/wire/method/method.ts
1076
+ ;
1077
+ "use strict";
1078
+ var $;
1079
+ (function ($) {
996
1080
  class $mol_wire_fiber_persist extends $mol_wire_fiber {
997
1081
  static getter(task, keys) {
998
1082
  const field = task.name + '()';
@@ -1065,79 +1149,7 @@ var $;
1065
1149
  ], $mol_wire_fiber_persist.prototype, "once", null);
1066
1150
  $.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
1067
1151
  })($ || ($ = {}));
1068
- //mol/wire/fiber/fiber.ts
1069
- ;
1070
- "use strict";
1071
- var $;
1072
- (function ($) {
1073
- function $mol_wire_probe(task, next) {
1074
- const warm = $mol_wire_fiber.warm;
1075
- try {
1076
- $mol_wire_fiber.warm = false;
1077
- return task();
1078
- }
1079
- finally {
1080
- $mol_wire_fiber.warm = warm;
1081
- }
1082
- }
1083
- $.$mol_wire_probe = $mol_wire_probe;
1084
- })($ || ($ = {}));
1085
- //mol/wire/probe/probe.ts
1086
- ;
1087
- "use strict";
1088
- var $;
1089
- (function ($) {
1090
- function $mol_wire_solid() {
1091
- $mol_wire_auto().reap = nothing;
1092
- }
1093
- $.$mol_wire_solid = $mol_wire_solid;
1094
- const nothing = () => { };
1095
- })($ || ($ = {}));
1096
- //mol/wire/solid/solid.ts
1097
- ;
1098
- "use strict";
1099
- var $;
1100
- (function ($) {
1101
- function $mol_wire_sync(obj) {
1102
- return new Proxy(obj, {
1103
- get(obj, field) {
1104
- const val = obj[field];
1105
- if (typeof val !== 'function')
1106
- return val;
1107
- const temp = $mol_wire_fiber_temp.getter(val);
1108
- return function $mol_wire_sync(...args) {
1109
- const fiber = temp(obj, args);
1110
- return fiber.sync();
1111
- };
1112
- }
1113
- });
1114
- }
1115
- $.$mol_wire_sync = $mol_wire_sync;
1116
- })($ || ($ = {}));
1117
- //mol/wire/sync/sync.ts
1118
- ;
1119
- "use strict";
1120
- var $;
1121
- (function ($) {
1122
- function $mol_wire_async(obj) {
1123
- return new Proxy(obj, {
1124
- get(obj, field) {
1125
- const val = obj[field];
1126
- if (typeof val !== 'function')
1127
- return val;
1128
- let fiber;
1129
- const temp = $mol_wire_fiber_temp.getter(val);
1130
- return function $mol_wire_async(...args) {
1131
- fiber?.destructor();
1132
- fiber = temp(obj, args);
1133
- return fiber.async();
1134
- };
1135
- }
1136
- });
1137
- }
1138
- $.$mol_wire_async = $mol_wire_async;
1139
- })($ || ($ = {}));
1140
- //mol/wire/async/async.ts
1152
+ //mol/wire/fiber/persist/persist.ts
1141
1153
  ;
1142
1154
  "use strict";
1143
1155
  var $;
@@ -2338,61 +2350,6 @@ var $;
2338
2350
  ;
2339
2351
  "use strict";
2340
2352
  var $;
2341
- (function ($) {
2342
- $mol_test({
2343
- 'Primitives'() {
2344
- $mol_assert_equal($mol_key(null), 'null');
2345
- $mol_assert_equal($mol_key(false), 'false');
2346
- $mol_assert_equal($mol_key(true), 'true');
2347
- $mol_assert_equal($mol_key(0), '0');
2348
- $mol_assert_equal($mol_key(''), '""');
2349
- },
2350
- 'Array & POJO'() {
2351
- $mol_assert_equal($mol_key([null]), '[null]');
2352
- $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
2353
- $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
2354
- },
2355
- 'Function'() {
2356
- const func = () => { };
2357
- $mol_assert_equal($mol_key(func), $mol_key(func));
2358
- $mol_assert_unique($mol_key(func), $mol_key(() => { }));
2359
- },
2360
- 'Objects'() {
2361
- class User {
2362
- }
2363
- const jin = new User();
2364
- $mol_assert_equal($mol_key(jin), $mol_key(jin));
2365
- $mol_assert_unique($mol_key(jin), $mol_key(new User()));
2366
- },
2367
- 'Elements'() {
2368
- const foo = $mol_jsx("div", null, "bar");
2369
- $mol_assert_equal($mol_key(foo), $mol_key(foo));
2370
- $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
2371
- },
2372
- 'Custom JSON representation'() {
2373
- class User {
2374
- name;
2375
- age;
2376
- constructor(name, age) {
2377
- this.name = name;
2378
- this.age = age;
2379
- }
2380
- toJSON() { return { name: this.name }; }
2381
- }
2382
- $mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
2383
- },
2384
- 'Special native classes'() {
2385
- $mol_assert_equal($mol_key(new Date('xyz')), 'null');
2386
- $mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
2387
- $mol_assert_equal($mol_key(/./), '"/./"');
2388
- $mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
2389
- },
2390
- });
2391
- })($ || ($ = {}));
2392
- //mol/key/key.test.tsx
2393
- ;
2394
- "use strict";
2395
- var $;
2396
2353
  (function ($) {
2397
2354
  $mol_test({
2398
2355
  'Sync execution'() {
@@ -2475,6 +2432,61 @@ var $;
2475
2432
  ;
2476
2433
  "use strict";
2477
2434
  var $;
2435
+ (function ($) {
2436
+ $mol_test({
2437
+ 'Primitives'() {
2438
+ $mol_assert_equal($mol_key(null), 'null');
2439
+ $mol_assert_equal($mol_key(false), 'false');
2440
+ $mol_assert_equal($mol_key(true), 'true');
2441
+ $mol_assert_equal($mol_key(0), '0');
2442
+ $mol_assert_equal($mol_key(''), '""');
2443
+ },
2444
+ 'Array & POJO'() {
2445
+ $mol_assert_equal($mol_key([null]), '[null]');
2446
+ $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
2447
+ $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
2448
+ },
2449
+ 'Function'() {
2450
+ const func = () => { };
2451
+ $mol_assert_equal($mol_key(func), $mol_key(func));
2452
+ $mol_assert_unique($mol_key(func), $mol_key(() => { }));
2453
+ },
2454
+ 'Objects'() {
2455
+ class User {
2456
+ }
2457
+ const jin = new User();
2458
+ $mol_assert_equal($mol_key(jin), $mol_key(jin));
2459
+ $mol_assert_unique($mol_key(jin), $mol_key(new User()));
2460
+ },
2461
+ 'Elements'() {
2462
+ const foo = $mol_jsx("div", null, "bar");
2463
+ $mol_assert_equal($mol_key(foo), $mol_key(foo));
2464
+ $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
2465
+ },
2466
+ 'Custom JSON representation'() {
2467
+ class User {
2468
+ name;
2469
+ age;
2470
+ constructor(name, age) {
2471
+ this.name = name;
2472
+ this.age = age;
2473
+ }
2474
+ toJSON() { return { name: this.name }; }
2475
+ }
2476
+ $mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
2477
+ },
2478
+ 'Special native classes'() {
2479
+ $mol_assert_equal($mol_key(new Date('xyz')), 'null');
2480
+ $mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
2481
+ $mol_assert_equal($mol_key(/./), '"/./"');
2482
+ $mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
2483
+ },
2484
+ });
2485
+ })($ || ($ = {}));
2486
+ //mol/key/key.test.tsx
2487
+ ;
2488
+ "use strict";
2489
+ var $;
2478
2490
  (function ($_1) {
2479
2491
  $mol_test({
2480
2492
  'Cached channel'($) {