mol_jsx_lib 0.0.61 → 0.0.64

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
@@ -820,7 +820,7 @@ var $;
820
820
  function $mol_jsx(Elem, props, ...childNodes) {
821
821
  const id = props && props.id || '';
822
822
  const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
823
- const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id}`) : $.$mol_jsx_crumbs;
823
+ const crumbs_self = id ? $.$mol_jsx_crumbs.replace(/(\S+)/g, `$1_${id.replace(/\/.*/i, '')}`) : $.$mol_jsx_crumbs;
824
824
  if (Elem && $.$mol_jsx_booked) {
825
825
  if ($.$mol_jsx_booked.has(id)) {
826
826
  $mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(guid)}`));
@@ -896,7 +896,11 @@ var $;
896
896
  $mol_dom_render_children(node, [].concat(...childNodes));
897
897
  if (!Elem)
898
898
  return node;
899
+ if (guid)
900
+ node.id = guid;
899
901
  for (const key in props) {
902
+ if (key === 'id')
903
+ continue;
900
904
  if (typeof props[key] === 'string') {
901
905
  ;
902
906
  node.setAttribute(key, props[key]);
@@ -913,8 +917,6 @@ var $;
913
917
  node[key] = props[key];
914
918
  }
915
919
  }
916
- if (guid)
917
- node.id = guid;
918
920
  if ($.$mol_jsx_crumbs)
919
921
  node.className = (props?.['class'] ? props['class'] + ' ' : '') + crumbs_self;
920
922
  return node;
@@ -1034,6 +1036,19 @@ var $;
1034
1036
  ;
1035
1037
  "use strict";
1036
1038
  var $;
1039
+ (function ($) {
1040
+ function $mol_const(value) {
1041
+ var getter = (() => value);
1042
+ getter['()'] = value;
1043
+ getter[Symbol.toStringTag] = value;
1044
+ return getter;
1045
+ }
1046
+ $.$mol_const = $mol_const;
1047
+ })($ || ($ = {}));
1048
+ //mol/const/const.ts
1049
+ ;
1050
+ "use strict";
1051
+ var $;
1037
1052
  (function ($) {
1038
1053
  $['devtoolsFormatters'] = $['devtoolsFormatters'] || [];
1039
1054
  function $mol_dev_format_register(config) {
@@ -1862,6 +1877,40 @@ var $;
1862
1877
  ;
1863
1878
  "use strict";
1864
1879
  var $;
1880
+ (function ($) {
1881
+ function $mol_wire_field(host, field, descr) {
1882
+ if (!descr)
1883
+ descr = Reflect.getOwnPropertyDescriptor(host, field);
1884
+ const _get = descr?.get || $mol_const(descr?.value);
1885
+ const persist = $mol_wire_atom.getter(_get, 0);
1886
+ const _set = descr?.set || function (next) {
1887
+ persist(this, []).put(next);
1888
+ };
1889
+ const sup = Reflect.getPrototypeOf(host);
1890
+ const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
1891
+ Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
1892
+ Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
1893
+ function get() {
1894
+ return persist(this, []).sync();
1895
+ }
1896
+ const temp = $mol_wire_task.getter(_set);
1897
+ function set(next) {
1898
+ temp(this, [next]).sync();
1899
+ }
1900
+ Object.defineProperty(get, 'name', { value: _get.name + '$' });
1901
+ Object.defineProperty(set, 'name', { value: _set.name + '@' });
1902
+ Object.assign(get, { orig: _get });
1903
+ Object.assign(set, { orig: _set });
1904
+ const { value, writable, ...descr2 } = { ...descr, get, set };
1905
+ Reflect.defineProperty(host, field, descr2);
1906
+ return descr2;
1907
+ }
1908
+ $.$mol_wire_field = $mol_wire_field;
1909
+ })($ || ($ = {}));
1910
+ //mol/wire/field/field.ts
1911
+ ;
1912
+ "use strict";
1913
+ var $;
1865
1914
  (function ($) {
1866
1915
  function $mol_wire_mem(keys) {
1867
1916
  const wrap = $mol_wire_mem_func(keys);
@@ -1929,12 +1978,8 @@ var $;
1929
1978
  ownerDocument;
1930
1979
  className;
1931
1980
  get childNodes() {
1932
- return this._kids();
1981
+ return [];
1933
1982
  }
1934
- set childNodes(next) {
1935
- this._kids(next);
1936
- }
1937
- _kids(next = []) { return next; }
1938
1983
  valueOf() {
1939
1984
  const prefix = $mol_jsx_prefix;
1940
1985
  const booked = $mol_jsx_booked;
@@ -1954,13 +1999,10 @@ var $;
1954
1999
  $mol_jsx_document = document;
1955
2000
  }
1956
2001
  }
1957
- render() {
1958
- return $mol_fail(new Error(`render() isn't implemented`));
1959
- }
1960
2002
  }
1961
2003
  __decorate([
1962
- $mol_mem
1963
- ], $mol_jsx_view.prototype, "_kids", null);
2004
+ $mol_wire_field
2005
+ ], $mol_jsx_view.prototype, "childNodes", null);
1964
2006
  __decorate([
1965
2007
  $mol_mem
1966
2008
  ], $mol_jsx_view.prototype, "valueOf", null);
@@ -2070,53 +2112,6 @@ var $;
2070
2112
  ;
2071
2113
  "use strict";
2072
2114
  var $;
2073
- (function ($) {
2074
- function $mol_const(value) {
2075
- var getter = (() => value);
2076
- getter['()'] = value;
2077
- getter[Symbol.toStringTag] = value;
2078
- return getter;
2079
- }
2080
- $.$mol_const = $mol_const;
2081
- })($ || ($ = {}));
2082
- //mol/const/const.ts
2083
- ;
2084
- "use strict";
2085
- var $;
2086
- (function ($) {
2087
- function $mol_wire_field(host, field, descr) {
2088
- if (!descr)
2089
- descr = Reflect.getOwnPropertyDescriptor(host, field);
2090
- const _get = descr?.get || $mol_const(descr?.value);
2091
- const persist = $mol_wire_atom.getter(_get, 0);
2092
- const _set = descr?.set || function (next) {
2093
- persist(this, []).put(next);
2094
- };
2095
- const sup = Reflect.getPrototypeOf(host);
2096
- const sup_descr = Reflect.getOwnPropertyDescriptor(sup, field);
2097
- Object.defineProperty(_get, 'name', { value: sup_descr?.get?.name ?? field });
2098
- Object.defineProperty(_set, 'name', { value: sup_descr?.set?.name ?? field });
2099
- function get() {
2100
- return persist(this, []).sync();
2101
- }
2102
- const temp = $mol_wire_task.getter(_set);
2103
- function set(next) {
2104
- temp(this, [next]).sync();
2105
- }
2106
- Object.defineProperty(get, 'name', { value: _get.name + '$' });
2107
- Object.defineProperty(set, 'name', { value: _set.name + '@' });
2108
- Object.assign(get, { orig: _get });
2109
- Object.assign(set, { orig: _set });
2110
- const { value, writable, ...descr2 } = { ...descr, get, set };
2111
- Reflect.defineProperty(host, field, descr2);
2112
- return descr2;
2113
- }
2114
- $.$mol_wire_field = $mol_wire_field;
2115
- })($ || ($ = {}));
2116
- //mol/wire/field/field.ts
2117
- ;
2118
- "use strict";
2119
- var $;
2120
2115
  (function ($) {
2121
2116
  function $mol_wire_patch(obj) {
2122
2117
  for (const field of Reflect.ownKeys(obj)) {
@@ -2825,7 +2820,7 @@ var $;
2825
2820
  return $mol_jsx("button", { title: props.hint }, target());
2826
2821
  };
2827
2822
  const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
2828
- $mol_assert_equal(dom.outerHTML, '<button title="click me" id="foo" class="Button">hey!</button>');
2823
+ $mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
2829
2824
  },
2830
2825
  'Nested guid generation'() {
2831
2826
  const Foo = () => {
@@ -3809,6 +3804,19 @@ var $;
3809
3804
  ;
3810
3805
  "use strict";
3811
3806
  var $;
3807
+ (function ($) {
3808
+ $mol_test({
3809
+ 'const returns stored value'() {
3810
+ const foo = { bar: $mol_const(Math.random()) };
3811
+ $mol_assert_equal(foo.bar(), foo.bar());
3812
+ $mol_assert_equal(foo.bar(), foo.bar['()']);
3813
+ },
3814
+ });
3815
+ })($ || ($ = {}));
3816
+ //mol/const/const.test.ts
3817
+ ;
3818
+ "use strict";
3819
+ var $;
3812
3820
  (function ($) {
3813
3821
  $mol_test({
3814
3822
  'Primitives'() {
@@ -3871,6 +3879,41 @@ var $;
3871
3879
  ;
3872
3880
  "use strict";
3873
3881
  var $;
3882
+ (function ($_1) {
3883
+ $mol_test({
3884
+ 'Cached field'($) {
3885
+ class App extends $mol_object2 {
3886
+ static $ = $;
3887
+ static low = 1;
3888
+ static get high() {
3889
+ return this.low + 1;
3890
+ }
3891
+ static set high(next) {
3892
+ this.low = next - 1;
3893
+ }
3894
+ static test() {
3895
+ $mol_assert_equal(App.high, 2);
3896
+ App.high = 3;
3897
+ $mol_assert_equal(App.high, 3);
3898
+ }
3899
+ }
3900
+ __decorate([
3901
+ $mol_wire_field
3902
+ ], App, "low", void 0);
3903
+ __decorate([
3904
+ $mol_wire_field
3905
+ ], App, "high", null);
3906
+ __decorate([
3907
+ $mol_wire_method
3908
+ ], App, "test", null);
3909
+ App.test();
3910
+ },
3911
+ });
3912
+ })($ || ($ = {}));
3913
+ //mol/wire/field/field.test.ts
3914
+ ;
3915
+ "use strict";
3916
+ var $;
3874
3917
  (function ($_1) {
3875
3918
  $mol_test({
3876
3919
  'Class as component'() {
@@ -3967,54 +4010,6 @@ var $;
3967
4010
  ;
3968
4011
  "use strict";
3969
4012
  var $;
3970
- (function ($) {
3971
- $mol_test({
3972
- 'const returns stored value'() {
3973
- const foo = { bar: $mol_const(Math.random()) };
3974
- $mol_assert_equal(foo.bar(), foo.bar());
3975
- $mol_assert_equal(foo.bar(), foo.bar['()']);
3976
- },
3977
- });
3978
- })($ || ($ = {}));
3979
- //mol/const/const.test.ts
3980
- ;
3981
- "use strict";
3982
- var $;
3983
- (function ($_1) {
3984
- $mol_test({
3985
- 'Cached field'($) {
3986
- class App extends $mol_object2 {
3987
- static $ = $;
3988
- static low = 1;
3989
- static get high() {
3990
- return this.low + 1;
3991
- }
3992
- static set high(next) {
3993
- this.low = next - 1;
3994
- }
3995
- static test() {
3996
- $mol_assert_equal(App.high, 2);
3997
- App.high = 3;
3998
- $mol_assert_equal(App.high, 3);
3999
- }
4000
- }
4001
- __decorate([
4002
- $mol_wire_field
4003
- ], App, "low", void 0);
4004
- __decorate([
4005
- $mol_wire_field
4006
- ], App, "high", null);
4007
- __decorate([
4008
- $mol_wire_method
4009
- ], App, "test", null);
4010
- App.test();
4011
- },
4012
- });
4013
- })($ || ($ = {}));
4014
- //mol/wire/field/field.test.ts
4015
- ;
4016
- "use strict";
4017
- var $;
4018
4013
  (function ($_1) {
4019
4014
  $mol_test({
4020
4015
  'Watch one value'($) {