mol_view_tree2_lib 1.0.181 → 1.0.182

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
@@ -8389,6 +8389,71 @@ var $;
8389
8389
 
8390
8390
  ;
8391
8391
  "use strict";
8392
+ var $;
8393
+ (function ($) {
8394
+ $.$mol_theme = $mol_style_prop('mol_theme', [
8395
+ 'back',
8396
+ 'hover',
8397
+ 'card',
8398
+ 'current',
8399
+ 'special',
8400
+ 'text',
8401
+ 'control',
8402
+ 'shade',
8403
+ 'line',
8404
+ 'focus',
8405
+ 'field',
8406
+ 'image',
8407
+ 'spirit',
8408
+ ]);
8409
+ })($ || ($ = {}));
8410
+
8411
+ ;
8412
+ "use strict";
8413
+ var $;
8414
+ (function ($) {
8415
+ $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:root, :where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 50% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
8416
+ })($ || ($ = {}));
8417
+
8418
+ ;
8419
+ "use strict";
8420
+
8421
+ ;
8422
+ "use strict";
8423
+ var $;
8424
+ (function ($) {
8425
+ $.$mol_gap = $mol_style_prop('mol_gap', [
8426
+ 'page',
8427
+ 'block',
8428
+ 'text',
8429
+ 'emoji',
8430
+ 'round',
8431
+ 'space',
8432
+ 'blur',
8433
+ ]);
8434
+ })($ || ($ = {}));
8435
+
8436
+ ;
8437
+ "use strict";
8438
+ var $;
8439
+ (function ($) {
8440
+ $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_page: 3rem;\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_emoji: .5rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
8441
+ })($ || ($ = {}));
8442
+
8443
+ ;
8444
+ "use strict";
8445
+ var $;
8446
+ (function ($) {
8447
+ class $mol_window extends $mol_object {
8448
+ static size() {
8449
+ return {
8450
+ width: 1024,
8451
+ height: 768,
8452
+ };
8453
+ }
8454
+ }
8455
+ $.$mol_window = $mol_window;
8456
+ })($ || ($ = {}));
8392
8457
 
8393
8458
  ;
8394
8459
  "use strict";
@@ -9003,571 +9068,75 @@ var $;
9003
9068
  "use strict";
9004
9069
  var $;
9005
9070
  (function ($) {
9006
- $mol_test({
9007
- 'Primitives'() {
9008
- $mol_assert_equal($mol_key(null), 'null');
9009
- $mol_assert_equal($mol_key(false), 'false');
9010
- $mol_assert_equal($mol_key(true), 'true');
9011
- $mol_assert_equal($mol_key(0), '0');
9012
- $mol_assert_equal($mol_key(1n << 64n), '18446744073709551616n');
9013
- $mol_assert_equal($mol_key(''), '""');
9014
- },
9015
- 'Array & POJO'() {
9016
- $mol_assert_equal($mol_key([null]), '[null]');
9017
- $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
9018
- $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
9019
- },
9020
- 'Uint8Array'() {
9021
- $mol_assert_equal($mol_key(new Uint8Array([1, 2])), 'Uint8Array([1,2])');
9022
- $mol_assert_equal($mol_key([new Uint8Array([1, 2])]), '[Uint8Array([1,2])]');
9023
- $mol_assert_equal($mol_key({ foo: new Uint8Array([1, 2]) }), '{"foo":Uint8Array([1,2])}');
9024
- },
9025
- 'Function'() {
9026
- const func = () => { };
9027
- $mol_assert_equal($mol_key(func), $mol_key(func));
9028
- $mol_assert_unique($mol_key(func), $mol_key(() => { }));
9029
- },
9030
- 'Objects'() {
9031
- class User {
9032
- }
9033
- const jin = new User();
9034
- $mol_assert_equal($mol_key(jin), $mol_key(jin));
9035
- $mol_assert_unique($mol_key(jin), $mol_key(new User()));
9036
- },
9037
- 'Elements'() {
9038
- const foo = $mol_jsx("div", null, "bar");
9039
- $mol_assert_equal($mol_key(foo), $mol_key(foo));
9040
- $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
9041
- },
9042
- 'Custom JSON representation'() {
9043
- class User {
9044
- toJSON() { return 'jin'; }
9045
- }
9046
- $mol_assert_unique([$mol_key(new User)], [$mol_key(new User)]);
9047
- },
9048
- 'Custom key handler'() {
9049
- class User {
9050
- name;
9051
- age;
9052
- constructor(name, age) {
9053
- this.name = name;
9054
- this.age = age;
9055
- }
9056
- [$mol_key_handle]() { return `User(${JSON.stringify(this.name)})`; }
9057
- }
9058
- $mol_assert_equal($mol_key([new User('jin', 16)]), $mol_key([new User('jin', 18)]), '[User("jin")]');
9059
- },
9060
- 'Special native classes'() {
9061
- $mol_assert_equal($mol_key(new Date('xyz')), 'Date(NaN)');
9062
- $mol_assert_equal($mol_key(new Date(12345)), 'Date(12345)');
9063
- $mol_assert_equal($mol_key(/./), '/./');
9064
- $mol_assert_equal($mol_key(/\./gimsu), '/\\./gimsu');
9065
- },
9066
- });
9067
- })($ || ($ = {}));
9068
-
9069
- ;
9070
- "use strict";
9071
- var $;
9072
- (function ($_1) {
9073
- $mol_test_mocks.push($ => {
9074
- $.$mol_after_frame = $mol_after_mock_commmon;
9075
- });
9076
- })($ || ($ = {}));
9077
-
9078
- ;
9079
- "use strict";
9080
- var $;
9081
- (function ($) {
9082
- class $mol_wire_log extends $mol_object2 {
9083
- static watch(task) {
9084
- return task;
9085
- }
9086
- static track(fiber) {
9087
- const prev = $mol_wire_probe(() => this.track(fiber));
9088
- let next;
9089
- try {
9090
- next = fiber.sync();
9091
- }
9092
- finally {
9093
- for (const pub of fiber.pub_list) {
9094
- if (pub instanceof $mol_wire_fiber) {
9095
- this.track(pub);
9096
- }
9097
- }
9098
- }
9099
- if (fiber.host === this)
9100
- return next;
9101
- if ($mol_compare_deep(prev, next)) {
9102
- this.$.$mol_log3_rise({
9103
- message: '💧 Same',
9104
- place: fiber,
9105
- });
9106
- }
9107
- else if (prev !== undefined) {
9108
- this.$.$mol_log3_rise({
9109
- message: '🔥 Next',
9110
- place: fiber,
9111
- prev,
9112
- });
9113
- }
9114
- return next;
9115
- }
9116
- static active() {
9117
- try {
9118
- this.watch()?.();
9119
- }
9120
- catch (error) {
9121
- $mol_fail_log(error);
9071
+ class $mol_view_selection extends $mol_object {
9072
+ static focused(next, notify) {
9073
+ const parents = [];
9074
+ let element = next?.[0] ?? $mol_dom_context.document.activeElement;
9075
+ while (element?.shadowRoot) {
9076
+ element = element.shadowRoot.activeElement;
9122
9077
  }
9123
- finally {
9124
- for (const pub of $mol_wire_auto().pub_list) {
9125
- if (pub instanceof $mol_wire_fiber) {
9126
- this.track(pub);
9127
- }
9128
- }
9078
+ while (element) {
9079
+ parents.push(element);
9080
+ const parent = element.parentNode;
9081
+ if (parent instanceof ShadowRoot)
9082
+ element = parent.host;
9083
+ else
9084
+ element = parent;
9129
9085
  }
9086
+ if (!next || notify)
9087
+ return parents;
9088
+ new $mol_after_tick(() => {
9089
+ const element = this.focused()[0];
9090
+ if (element)
9091
+ element.focus();
9092
+ else
9093
+ $mol_dom_context.blur();
9094
+ });
9095
+ return parents;
9130
9096
  }
9131
9097
  }
9132
9098
  __decorate([
9133
9099
  $mol_mem
9134
- ], $mol_wire_log, "watch", null);
9135
- __decorate([
9136
- $mol_mem_key
9137
- ], $mol_wire_log, "track", null);
9138
- __decorate([
9139
- $mol_mem
9140
- ], $mol_wire_log, "active", null);
9141
- $.$mol_wire_log = $mol_wire_log;
9100
+ ], $mol_view_selection, "focused", null);
9101
+ $.$mol_view_selection = $mol_view_selection;
9142
9102
  })($ || ($ = {}));
9143
9103
 
9144
9104
  ;
9145
9105
  "use strict";
9146
9106
  var $;
9147
9107
  (function ($) {
9148
- $mol_wire_log.active();
9149
- })($ || ($ = {}));
9150
-
9151
- ;
9152
- "use strict";
9153
- var $;
9154
- (function ($) {
9155
- class $mol_state_arg extends $mol_object {
9156
- prefix;
9157
- static prolog = '';
9158
- static separator = ' ';
9159
- static href(next) {
9160
- return next || process.argv.slice(2).join(' ');
9161
- }
9162
- static href_normal() {
9163
- return this.link({});
9164
- }
9165
- static dict(next) {
9166
- if (next !== void 0)
9167
- this.href(this.make_link(next));
9168
- var href = this.href();
9169
- var chunks = href.split(' ');
9170
- var params = {};
9171
- chunks.forEach(chunk => {
9172
- if (!chunk)
9173
- return;
9174
- var vals = chunk.split('=').map(decodeURIComponent);
9175
- params[vals.shift()] = vals.join('=');
9176
- });
9177
- return params;
9178
- }
9179
- static value(key, next) {
9180
- if (next === void 0)
9181
- return this.dict()[key] ?? null;
9182
- this.href(this.link({ [key]: next }));
9183
- return next;
9184
- }
9185
- static link(next) {
9186
- const params = {};
9187
- var prev = this.dict();
9188
- for (var key in prev) {
9189
- params[key] = prev[key];
9190
- }
9191
- for (var key in next) {
9192
- params[key] = next[key];
9193
- }
9194
- return this.make_link(params);
9195
- }
9196
- static make_link(next) {
9197
- const chunks = [];
9198
- for (const key in next) {
9199
- if (next[key] !== null) {
9200
- chunks.push([key, next[key]].map(encodeURIComponent).join('='));
9201
- }
9202
- }
9203
- return chunks.join(' ');
9204
- }
9205
- static go(next) {
9206
- this.href(this.link(next));
9207
- }
9208
- static commit() { }
9209
- constructor(prefix = '') {
9210
- super();
9211
- this.prefix = prefix;
9212
- }
9213
- value(key, next) {
9214
- return this.constructor.value(this.prefix + key, next);
9215
- }
9216
- sub(postfix) {
9217
- return new this.constructor(this.prefix + postfix + '.');
9218
- }
9219
- link(next) {
9220
- const prefix = this.prefix;
9221
- const dict = {};
9222
- for (var key in next) {
9223
- dict[prefix + key] = next[key];
9224
- }
9225
- return this.constructor.link(dict);
9226
- }
9227
- }
9228
- __decorate([
9229
- $mol_mem
9230
- ], $mol_state_arg, "href", null);
9231
- __decorate([
9232
- $mol_mem
9233
- ], $mol_state_arg, "href_normal", null);
9234
- __decorate([
9235
- $mol_mem
9236
- ], $mol_state_arg, "dict", null);
9237
- __decorate([
9238
- $mol_mem_key
9239
- ], $mol_state_arg, "value", null);
9240
- __decorate([
9241
- $mol_action
9242
- ], $mol_state_arg, "go", null);
9243
- $.$mol_state_arg = $mol_state_arg;
9244
- })($ || ($ = {}));
9245
-
9246
- ;
9247
- "use strict";
9248
- var $;
9249
- (function ($) {
9250
- $mol_test_mocks.push(context => {
9251
- class $mol_state_arg_mock extends $mol_state_arg {
9252
- static $ = context;
9253
- static href(next) { return next || ''; }
9254
- static go(next) {
9255
- this.href(this.link(next));
9256
- }
9257
- }
9258
- __decorate([
9259
- $mol_mem
9260
- ], $mol_state_arg_mock, "href", null);
9261
- __decorate([
9262
- $mol_action
9263
- ], $mol_state_arg_mock, "go", null);
9264
- context.$mol_state_arg = $mol_state_arg_mock;
9265
- });
9266
- })($ || ($ = {}));
9267
-
9268
- ;
9269
- "use strict";
9270
- var $;
9271
- (function ($) {
9272
- class $mol_media extends $mol_object2 {
9273
- static match(query, next) {
9274
- if (next !== undefined)
9275
- return next;
9276
- const res = this.$.$mol_dom_context.matchMedia?.(query) ?? {};
9277
- res.onchange = () => this.match(query, res.matches);
9278
- return res.matches;
9279
- }
9280
- }
9281
- __decorate([
9282
- $mol_mem_key
9283
- ], $mol_media, "match", null);
9284
- $.$mol_media = $mol_media;
9285
- })($ || ($ = {}));
9286
-
9287
- ;
9288
- "use strict";
9289
- var $;
9290
- (function ($) {
9291
- $mol_test({
9292
- 'const returns stored value'() {
9293
- const foo = { bar: $mol_const(Math.random()) };
9294
- $mol_assert_equal(foo.bar(), foo.bar());
9295
- $mol_assert_equal(foo.bar(), foo.bar['()']);
9296
- },
9297
- });
9298
- })($ || ($ = {}));
9299
-
9300
- ;
9301
- "use strict";
9302
- var $;
9303
- (function ($) {
9304
- class TestClass extends Uint8Array {
9305
- }
9306
- $mol_test({
9307
- 'Uint8Array vs itself'() {
9308
- $mol_assert_ok($mol_compare_array(new Uint8Array, new Uint8Array));
9309
- $mol_assert_ok($mol_compare_array(new Uint8Array([0]), new Uint8Array([0])));
9310
- $mol_assert_not($mol_compare_array(new Uint8Array([0]), new Uint8Array([1])));
9311
- },
9312
- 'Uint8Array vs subclassed array'() {
9313
- $mol_assert_not($mol_compare_array(new Uint8Array, new TestClass));
9314
- },
9315
- });
9316
- })($ || ($ = {}));
9317
-
9318
- ;
9319
- "use strict";
9320
- var $;
9321
- (function ($) {
9322
- $mol_test({
9323
- 'decode utf8 string'() {
9324
- const str = 'Hello, ΧΨΩЫ';
9325
- const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
9326
- $mol_assert_equal($mol_charset_decode(encoded), str);
9327
- $mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
9328
- },
9329
- 'decode empty string'() {
9330
- const encoded = new Uint8Array([]);
9331
- $mol_assert_equal($mol_charset_decode(encoded), '');
9332
- },
9333
- });
9334
- })($ || ($ = {}));
9335
-
9336
- ;
9337
- "use strict";
9338
- var $;
9339
- (function ($) {
9340
- $mol_test({
9341
- 'encode empty'() {
9342
- $mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
9343
- },
9344
- 'encode 1 octet'() {
9345
- $mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
9346
- },
9347
- 'encode 2 octet'() {
9348
- $mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
9349
- },
9350
- 'encode 3 octet'() {
9351
- $mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
9352
- },
9353
- 'encode 4 octet'() {
9354
- $mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
9355
- },
9356
- 'encode surrogate pair'() {
9357
- $mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
9358
- },
9359
- });
9360
- })($ || ($ = {}));
9361
-
9362
- ;
9363
- "use strict";
9364
- var $;
9365
- (function ($) {
9366
- $mol_test({
9367
- 'local get set delete'() {
9368
- var key = '$mol_state_local_test:' + Math.random();
9369
- $mol_assert_equal($mol_state_local.value(key), null);
9370
- $mol_state_local.value(key, 123);
9371
- $mol_assert_equal($mol_state_local.value(key), 123);
9372
- $mol_state_local.value(key, null);
9373
- $mol_assert_equal($mol_state_local.value(key), null);
9374
- },
9375
- });
9376
- })($ || ($ = {}));
9377
-
9378
- ;
9379
- "use strict";
9380
- var $;
9381
- (function ($) {
9382
- $mol_test_mocks.push(context => {
9383
- class $mol_state_local_mock extends $mol_state_local {
9384
- static state = {};
9385
- static value(key, next = this.state[key]) {
9386
- return this.state[key] = (next || null);
9387
- }
9388
- }
9389
- __decorate([
9390
- $mol_mem_key
9391
- ], $mol_state_local_mock, "value", null);
9392
- context.$mol_state_local = $mol_state_local_mock;
9393
- });
9394
- })($ || ($ = {}));
9395
-
9396
- ;
9397
- "use strict";
9398
- var $;
9399
- (function ($) {
9400
- function parse(theme) {
9401
- if (theme === 'true')
9402
- return true;
9403
- if (theme === 'false')
9404
- return false;
9405
- return null;
9406
- }
9407
- function $mol_lights(next) {
9408
- const arg = parse(this.$mol_state_arg.value('mol_lights'));
9409
- const base = this.$mol_media.match('(prefers-color-scheme: light)');
9410
- if (next === undefined) {
9411
- return arg ?? this.$mol_state_local.value('$mol_lights') ?? base;
9412
- }
9413
- else {
9414
- if (arg === null) {
9415
- this.$mol_state_local.value('$mol_lights', next === base ? null : next);
9416
- }
9417
- else {
9418
- this.$mol_state_arg.value('mol_lights', String(next));
9419
- }
9420
- return next;
9421
- }
9422
- }
9423
- $.$mol_lights = $mol_lights;
9424
- })($ || ($ = {}));
9425
-
9426
- ;
9427
- "use strict";
9428
- var $;
9429
- (function ($) {
9430
- $.$mol_theme = $mol_style_prop('mol_theme', [
9431
- 'back',
9432
- 'hover',
9433
- 'card',
9434
- 'current',
9435
- 'special',
9436
- 'text',
9437
- 'control',
9438
- 'shade',
9439
- 'line',
9440
- 'focus',
9441
- 'field',
9442
- 'image',
9443
- 'spirit',
9444
- ]);
9445
- })($ || ($ = {}));
9446
-
9447
- ;
9448
- "use strict";
9449
- var $;
9450
- (function ($) {
9451
- $mol_style_attach("mol/theme/theme.css", ":root {\n\t--mol_theme_hue: 240deg;\n\t--mol_theme_hue_spread: 90deg;\n\tcolor-scheme: dark light;\n}\n\n:where([mol_theme]) {\n\tcolor: var(--mol_theme_text);\n\tfill: var(--mol_theme_text);\n\tbackground-color: var(--mol_theme_back);\n}\n\t\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\n\t--mol_theme_luma: -1;\n\t--mol_theme_image: invert(1) hue-rotate( 180deg );\n\t--mol_theme_spirit: hsl( 0deg, 0%, 0%, .75 );\n\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 10% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 20%, .25 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 8%, .25 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 80% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 60%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 65% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 60%, 65% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 60%, 65% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 60%, 65% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n:root, [mol_theme=\"$mol_theme_dark\"], :where([mol_theme=\"$mol_theme_dark\"]) [mol_theme] {\n\t\n\t--mol_theme_back: oklch( 20% .03 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 30% .05 var(--mol_theme_hue) / .25 );\n\t--mol_theme_field: oklch( 15% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_hover: oklch( 70% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 80% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 60% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 80% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 70% .1 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 70% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 70% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t\n\t--mol_theme_luma: 1;\n\t--mol_theme_image: none;\n\t--mol_theme_spirit: hsl( 0deg, 0%, 100%, .75 );\n\t\n\t--mol_theme_back: hsl( var(--mol_theme_hue), 20%, 92% );\n\t--mol_theme_card: hsl( var(--mol_theme_hue), 50%, 100%, .5 );\n\t--mol_theme_field: hsl( var(--mol_theme_hue), 50%, 100%, .75 );\n\t--mol_theme_hover: hsl( var(--mol_theme_hue), 0%, 50%, .1 );\n\t\n\t--mol_theme_text: hsl( var(--mol_theme_hue), 0%, 0% );\n\t--mol_theme_shade: hsl( var(--mol_theme_hue), 0%, 40%, 1 );\n\t--mol_theme_line: hsl( var(--mol_theme_hue), 0%, 50%, .25 );\n\t--mol_theme_focus: hsl( calc( var(--mol_theme_hue) + 180deg ), 100%, 40% );\n\t\n\t--mol_theme_control: hsl( var(--mol_theme_hue), 80%, 30% );\n\t--mol_theme_current: hsl( calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ), 80%, 30% );\n\t--mol_theme_special: hsl( calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ), 80%, 30% );\n\n} @supports( color: oklch( 0% 0 0deg ) ) {\n[mol_theme=\"$mol_theme_light\"], :where([mol_theme=\"$mol_theme_light\"]) [mol_theme] {\n\t--mol_theme_back: oklch( 92% .01 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 99% .01 var(--mol_theme_hue) / .5 );\n\t--mol_theme_field: oklch( 100% 0 var(--mol_theme_hue) / .5 );\n\t--mol_theme_hover: oklch( 50% 0 var(--mol_theme_hue) / .1 );\n\t\n\t--mol_theme_text: oklch( 20% 0 var(--mol_theme_hue) );\n\t--mol_theme_shade: oklch( 60% 0 var(--mol_theme_hue) );\n\t--mol_theme_line: oklch( 50% 0 var(--mol_theme_hue) / .25 );\n\t--mol_theme_focus: oklch( 60% .2 calc( var(--mol_theme_hue) + 180deg ) );\n\t\n\t--mol_theme_control: oklch( 40% .15 var(--mol_theme_hue) );\n\t--mol_theme_current: oklch( 50% .2 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_special: oklch( 50% .2 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\n} }\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 25% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 35% .1 var(--mol_theme_hue) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_base\"] {\n\t--mol_theme_back: oklch( 85% .075 var(--mol_theme_hue) );\n\t--mol_theme_card: oklch( 98% .03 var(--mol_theme_hue) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_current\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) - var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 25% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 35% .1 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_special\"] {\n\t--mol_theme_back: oklch( 85% .05 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + var(--mol_theme_hue_spread) ) / .25 );\n}\n\n:where( :root, [mol_theme=\"$mol_theme_dark\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 35% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 45% .15 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n:where( [mol_theme=\"$mol_theme_light\"] ) [mol_theme=\"$mol_theme_accent\"] {\n\t--mol_theme_back: oklch( 83% .1 calc( var(--mol_theme_hue) + 180deg ) );\n\t--mol_theme_card: oklch( 98% .03 calc( var(--mol_theme_hue) + 180deg ) / .25 );\n}\n\n");
9452
- })($ || ($ = {}));
9453
-
9454
- ;
9455
- "use strict";
9456
- var $;
9457
- (function ($) {
9458
- $mol_style_attach('$mol_theme_lights', `:root { --mol_theme_back: oklch( ${$$.$mol_lights() ? 92 : 20}% .01 var(--mol_theme_hue) ) }`);
9459
- })($ || ($ = {}));
9460
-
9461
- ;
9462
- "use strict";
9463
- var $;
9464
- (function ($) {
9465
- $.$mol_gap = $mol_style_prop('mol_gap', [
9466
- 'page',
9467
- 'block',
9468
- 'text',
9469
- 'emoji',
9470
- 'round',
9471
- 'space',
9472
- 'blur',
9473
- ]);
9474
- })($ || ($ = {}));
9475
-
9476
- ;
9477
- "use strict";
9478
- var $;
9479
- (function ($) {
9480
- $mol_style_attach("mol/gap/gap.css", ":root {\n\t--mol_gap_page: 3rem;\n\t--mol_gap_block: .75rem;\n\t--mol_gap_text: .5rem .75rem;\n\t--mol_gap_emoji: .5rem;\n\t--mol_gap_round: .25rem;\n\t--mol_gap_space: .25rem;\n\t--mol_gap_blur: .5rem;\n}\n");
9481
- })($ || ($ = {}));
9482
-
9483
- ;
9484
- "use strict";
9485
- var $;
9486
- (function ($) {
9487
- class $mol_window extends $mol_object {
9488
- static size() {
9489
- return {
9490
- width: 1024,
9491
- height: 768,
9492
- };
9493
- }
9494
- }
9495
- $.$mol_window = $mol_window;
9496
- })($ || ($ = {}));
9497
-
9498
- ;
9499
- "use strict";
9500
- var $;
9501
- (function ($) {
9502
- class $mol_view_selection extends $mol_object {
9503
- static focused(next, notify) {
9504
- const parents = [];
9505
- let element = next?.[0] ?? $mol_dom_context.document.activeElement;
9506
- while (element?.shadowRoot) {
9507
- element = element.shadowRoot.activeElement;
9508
- }
9509
- while (element) {
9510
- parents.push(element);
9511
- const parent = element.parentNode;
9512
- if (parent instanceof ShadowRoot)
9513
- element = parent.host;
9514
- else
9515
- element = parent;
9516
- }
9517
- if (!next || notify)
9518
- return parents;
9519
- new $mol_after_tick(() => {
9520
- const element = this.focused()[0];
9521
- if (element)
9522
- element.focus();
9523
- else
9524
- $mol_dom_context.blur();
9525
- });
9526
- return parents;
9527
- }
9528
- }
9529
- __decorate([
9530
- $mol_mem
9531
- ], $mol_view_selection, "focused", null);
9532
- $.$mol_view_selection = $mol_view_selection;
9533
- })($ || ($ = {}));
9534
-
9535
- ;
9536
- "use strict";
9537
- var $;
9538
- (function ($) {
9539
- class $mol_wrapper extends $mol_object2 {
9540
- static wrap;
9541
- static run(task) {
9542
- return this.func(task)();
9543
- }
9544
- static func(func) {
9545
- return this.wrap(func);
9546
- }
9547
- static get class() {
9548
- return (Class) => {
9549
- const construct = (target, args) => new Class(...args);
9550
- const handler = {
9551
- construct: this.func(construct)
9552
- };
9553
- handler[Symbol.toStringTag] = Class.name + '#';
9554
- return new Proxy(Class, handler);
9555
- };
9556
- }
9557
- static get method() {
9558
- return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
9559
- descr.value = this.func(descr.value);
9560
- return descr;
9561
- };
9562
- }
9563
- static get field() {
9564
- return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
9565
- descr.get = descr.set = this.func(descr.get);
9566
- return descr;
9567
- };
9568
- }
9569
- }
9570
- $.$mol_wrapper = $mol_wrapper;
9108
+ class $mol_wrapper extends $mol_object2 {
9109
+ static wrap;
9110
+ static run(task) {
9111
+ return this.func(task)();
9112
+ }
9113
+ static func(func) {
9114
+ return this.wrap(func);
9115
+ }
9116
+ static get class() {
9117
+ return (Class) => {
9118
+ const construct = (target, args) => new Class(...args);
9119
+ const handler = {
9120
+ construct: this.func(construct)
9121
+ };
9122
+ handler[Symbol.toStringTag] = Class.name + '#';
9123
+ return new Proxy(Class, handler);
9124
+ };
9125
+ }
9126
+ static get method() {
9127
+ return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
9128
+ descr.value = this.func(descr.value);
9129
+ return descr;
9130
+ };
9131
+ }
9132
+ static get field() {
9133
+ return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
9134
+ descr.get = descr.set = this.func(descr.get);
9135
+ return descr;
9136
+ };
9137
+ }
9138
+ }
9139
+ $.$mol_wrapper = $mol_wrapper;
9571
9140
  })($ || ($ = {}));
9572
9141
 
9573
9142
  ;
@@ -9659,31 +9228,154 @@ var $;
9659
9228
  return a ** this.level;
9660
9229
  }
9661
9230
  }
9662
- __decorate([
9663
- Plus1.method
9664
- ], Foo, "pow", null);
9665
- $mol_assert_equal(Foo.pow(2), 5);
9231
+ __decorate([
9232
+ Plus1.method
9233
+ ], Foo, "pow", null);
9234
+ $mol_assert_equal(Foo.pow(2), 5);
9235
+ },
9236
+ 'decorate class'() {
9237
+ class BarInc extends $mol_wrapper {
9238
+ static wrap(task) {
9239
+ return function (...args) {
9240
+ const foo = task.call(this, ...args);
9241
+ foo.bar++;
9242
+ return foo;
9243
+ };
9244
+ }
9245
+ }
9246
+ let Foo = class Foo {
9247
+ bar;
9248
+ constructor(bar) {
9249
+ this.bar = bar;
9250
+ }
9251
+ };
9252
+ Foo = __decorate([
9253
+ BarInc.class
9254
+ ], Foo);
9255
+ $mol_assert_equal(new Foo(2).bar, 3);
9256
+ },
9257
+ });
9258
+ })($ || ($ = {}));
9259
+
9260
+ ;
9261
+ "use strict";
9262
+ var $;
9263
+ (function ($) {
9264
+ class $mol_memo extends $mol_wrapper {
9265
+ static wrap(task) {
9266
+ const store = new WeakMap();
9267
+ const fun = function (next) {
9268
+ if (next === undefined && store.has(this))
9269
+ return store.get(this);
9270
+ const val = task.call(this, next) ?? next;
9271
+ store.set(this, val);
9272
+ return val;
9273
+ };
9274
+ Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
9275
+ return fun;
9276
+ }
9277
+ }
9278
+ $.$mol_memo = $mol_memo;
9279
+ })($ || ($ = {}));
9280
+
9281
+ ;
9282
+ "use strict";
9283
+ var $;
9284
+ (function ($) {
9285
+ $mol_test({
9286
+ 'memoize field'() {
9287
+ class Foo {
9288
+ static one = 1;
9289
+ static get two() {
9290
+ return ++this.one;
9291
+ }
9292
+ static set two(next) { }
9293
+ }
9294
+ __decorate([
9295
+ $mol_memo.field
9296
+ ], Foo, "two", null);
9297
+ $mol_assert_equal(Foo.two, 2);
9298
+ $mol_assert_equal(Foo.two, 2);
9299
+ Foo.two = 3;
9300
+ $mol_assert_equal(Foo.two, 3);
9301
+ $mol_assert_equal(Foo.two, 3);
9302
+ },
9303
+ });
9304
+ })($ || ($ = {}));
9305
+
9306
+ ;
9307
+ "use strict";
9308
+ var $;
9309
+ (function ($) {
9310
+ function $mol_dom_qname(name) {
9311
+ return name.replace(/\W/g, '').replace(/^(?=\d+)/, '_');
9312
+ }
9313
+ $.$mol_dom_qname = $mol_dom_qname;
9314
+ })($ || ($ = {}));
9315
+
9316
+ ;
9317
+ "use strict";
9318
+ var $;
9319
+ (function ($) {
9320
+ $mol_test({
9321
+ 'Primitives'() {
9322
+ $mol_assert_equal($mol_key(null), 'null');
9323
+ $mol_assert_equal($mol_key(false), 'false');
9324
+ $mol_assert_equal($mol_key(true), 'true');
9325
+ $mol_assert_equal($mol_key(0), '0');
9326
+ $mol_assert_equal($mol_key(1n << 64n), '18446744073709551616n');
9327
+ $mol_assert_equal($mol_key(''), '""');
9328
+ },
9329
+ 'Array & POJO'() {
9330
+ $mol_assert_equal($mol_key([null]), '[null]');
9331
+ $mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
9332
+ $mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
9333
+ },
9334
+ 'Uint8Array'() {
9335
+ $mol_assert_equal($mol_key(new Uint8Array([1, 2])), 'Uint8Array([1,2])');
9336
+ $mol_assert_equal($mol_key([new Uint8Array([1, 2])]), '[Uint8Array([1,2])]');
9337
+ $mol_assert_equal($mol_key({ foo: new Uint8Array([1, 2]) }), '{"foo":Uint8Array([1,2])}');
9338
+ },
9339
+ 'Function'() {
9340
+ const func = () => { };
9341
+ $mol_assert_equal($mol_key(func), $mol_key(func));
9342
+ $mol_assert_unique($mol_key(func), $mol_key(() => { }));
9343
+ },
9344
+ 'Objects'() {
9345
+ class User {
9346
+ }
9347
+ const jin = new User();
9348
+ $mol_assert_equal($mol_key(jin), $mol_key(jin));
9349
+ $mol_assert_unique($mol_key(jin), $mol_key(new User()));
9350
+ },
9351
+ 'Elements'() {
9352
+ const foo = $mol_jsx("div", null, "bar");
9353
+ $mol_assert_equal($mol_key(foo), $mol_key(foo));
9354
+ $mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
9355
+ },
9356
+ 'Custom JSON representation'() {
9357
+ class User {
9358
+ toJSON() { return 'jin'; }
9359
+ }
9360
+ $mol_assert_unique([$mol_key(new User)], [$mol_key(new User)]);
9666
9361
  },
9667
- 'decorate class'() {
9668
- class BarInc extends $mol_wrapper {
9669
- static wrap(task) {
9670
- return function (...args) {
9671
- const foo = task.call(this, ...args);
9672
- foo.bar++;
9673
- return foo;
9674
- };
9362
+ 'Custom key handler'() {
9363
+ class User {
9364
+ name;
9365
+ age;
9366
+ constructor(name, age) {
9367
+ this.name = name;
9368
+ this.age = age;
9675
9369
  }
9370
+ [$mol_key_handle]() { return `User(${JSON.stringify(this.name)})`; }
9676
9371
  }
9677
- let Foo = class Foo {
9678
- bar;
9679
- constructor(bar) {
9680
- this.bar = bar;
9681
- }
9682
- };
9683
- Foo = __decorate([
9684
- BarInc.class
9685
- ], Foo);
9686
- $mol_assert_equal(new Foo(2).bar, 3);
9372
+ $mol_assert_equal($mol_key([new User('jin', 16)]), $mol_key([new User('jin', 18)]), '[User("jin")]');
9373
+ },
9374
+ 'Special native classes'() {
9375
+ $mol_assert_equal($mol_key(new Date('xyz')), 'Date(NaN)');
9376
+ $mol_assert_equal($mol_key(new Date(12345)), 'Date(12345)');
9377
+ $mol_assert_equal($mol_key(/./), '/./');
9378
+ $mol_assert_equal($mol_key(/\./gimsu), '/\\./gimsu');
9687
9379
  },
9688
9380
  });
9689
9381
  })($ || ($ = {}));
@@ -9691,57 +9383,83 @@ var $;
9691
9383
  ;
9692
9384
  "use strict";
9693
9385
  var $;
9694
- (function ($) {
9695
- class $mol_memo extends $mol_wrapper {
9696
- static wrap(task) {
9697
- const store = new WeakMap();
9698
- const fun = function (next) {
9699
- if (next === undefined && store.has(this))
9700
- return store.get(this);
9701
- const val = task.call(this, next) ?? next;
9702
- store.set(this, val);
9703
- return val;
9704
- };
9705
- Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
9706
- return fun;
9707
- }
9708
- }
9709
- $.$mol_memo = $mol_memo;
9386
+ (function ($_1) {
9387
+ $mol_test_mocks.push($ => {
9388
+ $.$mol_after_frame = $mol_after_mock_commmon;
9389
+ });
9710
9390
  })($ || ($ = {}));
9711
9391
 
9712
9392
  ;
9713
9393
  "use strict";
9714
9394
  var $;
9715
9395
  (function ($) {
9716
- $mol_test({
9717
- 'memoize field'() {
9718
- class Foo {
9719
- static one = 1;
9720
- static get two() {
9721
- return ++this.one;
9396
+ class $mol_wire_log extends $mol_object2 {
9397
+ static watch(task) {
9398
+ return task;
9399
+ }
9400
+ static track(fiber) {
9401
+ const prev = $mol_wire_probe(() => this.track(fiber));
9402
+ let next;
9403
+ try {
9404
+ next = fiber.sync();
9405
+ }
9406
+ finally {
9407
+ for (const pub of fiber.pub_list) {
9408
+ if (pub instanceof $mol_wire_fiber) {
9409
+ this.track(pub);
9410
+ }
9722
9411
  }
9723
- static set two(next) { }
9724
9412
  }
9725
- __decorate([
9726
- $mol_memo.field
9727
- ], Foo, "two", null);
9728
- $mol_assert_equal(Foo.two, 2);
9729
- $mol_assert_equal(Foo.two, 2);
9730
- Foo.two = 3;
9731
- $mol_assert_equal(Foo.two, 3);
9732
- $mol_assert_equal(Foo.two, 3);
9733
- },
9734
- });
9413
+ if (fiber.host === this)
9414
+ return next;
9415
+ if ($mol_compare_deep(prev, next)) {
9416
+ this.$.$mol_log3_rise({
9417
+ message: '💧 Same',
9418
+ place: fiber,
9419
+ });
9420
+ }
9421
+ else if (prev !== undefined) {
9422
+ this.$.$mol_log3_rise({
9423
+ message: '🔥 Next',
9424
+ place: fiber,
9425
+ prev,
9426
+ });
9427
+ }
9428
+ return next;
9429
+ }
9430
+ static active() {
9431
+ try {
9432
+ this.watch()?.();
9433
+ }
9434
+ catch (error) {
9435
+ $mol_fail_log(error);
9436
+ }
9437
+ finally {
9438
+ for (const pub of $mol_wire_auto().pub_list) {
9439
+ if (pub instanceof $mol_wire_fiber) {
9440
+ this.track(pub);
9441
+ }
9442
+ }
9443
+ }
9444
+ }
9445
+ }
9446
+ __decorate([
9447
+ $mol_mem
9448
+ ], $mol_wire_log, "watch", null);
9449
+ __decorate([
9450
+ $mol_mem_key
9451
+ ], $mol_wire_log, "track", null);
9452
+ __decorate([
9453
+ $mol_mem
9454
+ ], $mol_wire_log, "active", null);
9455
+ $.$mol_wire_log = $mol_wire_log;
9735
9456
  })($ || ($ = {}));
9736
9457
 
9737
9458
  ;
9738
9459
  "use strict";
9739
9460
  var $;
9740
9461
  (function ($) {
9741
- function $mol_dom_qname(name) {
9742
- return name.replace(/\W/g, '').replace(/^(?=\d+)/, '_');
9743
- }
9744
- $.$mol_dom_qname = $mol_dom_qname;
9462
+ $mol_wire_log.active();
9745
9463
  })($ || ($ = {}));
9746
9464
 
9747
9465
  ;
@@ -9760,6 +9478,19 @@ var $;
9760
9478
  $.$mol_wire_watch = $mol_wire_watch;
9761
9479
  })($ || ($ = {}));
9762
9480
 
9481
+ ;
9482
+ "use strict";
9483
+ var $;
9484
+ (function ($) {
9485
+ $mol_test({
9486
+ 'const returns stored value'() {
9487
+ const foo = { bar: $mol_const(Math.random()) };
9488
+ $mol_assert_equal(foo.bar(), foo.bar());
9489
+ $mol_assert_equal(foo.bar(), foo.bar['()']);
9490
+ },
9491
+ });
9492
+ })($ || ($ = {}));
9493
+
9763
9494
  ;
9764
9495
  "use strict";
9765
9496
  var $;
@@ -11488,6 +11219,102 @@ Clear
11488
11219
  })($$ = $_1.$$ || ($_1.$$ = {}));
11489
11220
  })($ || ($ = {}));
11490
11221
 
11222
+ ;
11223
+ "use strict";
11224
+ var $;
11225
+ (function ($) {
11226
+ class TestClass extends Uint8Array {
11227
+ }
11228
+ $mol_test({
11229
+ 'Uint8Array vs itself'() {
11230
+ $mol_assert_ok($mol_compare_array(new Uint8Array, new Uint8Array));
11231
+ $mol_assert_ok($mol_compare_array(new Uint8Array([0]), new Uint8Array([0])));
11232
+ $mol_assert_not($mol_compare_array(new Uint8Array([0]), new Uint8Array([1])));
11233
+ },
11234
+ 'Uint8Array vs subclassed array'() {
11235
+ $mol_assert_not($mol_compare_array(new Uint8Array, new TestClass));
11236
+ },
11237
+ });
11238
+ })($ || ($ = {}));
11239
+
11240
+ ;
11241
+ "use strict";
11242
+ var $;
11243
+ (function ($) {
11244
+ $mol_test({
11245
+ 'decode utf8 string'() {
11246
+ const str = 'Hello, ΧΨΩЫ';
11247
+ const encoded = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 206, 167, 206, 168, 206, 169, 208, 171]);
11248
+ $mol_assert_equal($mol_charset_decode(encoded), str);
11249
+ $mol_assert_equal($mol_charset_decode(encoded, 'utf8'), str);
11250
+ },
11251
+ 'decode empty string'() {
11252
+ const encoded = new Uint8Array([]);
11253
+ $mol_assert_equal($mol_charset_decode(encoded), '');
11254
+ },
11255
+ });
11256
+ })($ || ($ = {}));
11257
+
11258
+ ;
11259
+ "use strict";
11260
+ var $;
11261
+ (function ($) {
11262
+ $mol_test({
11263
+ 'encode empty'() {
11264
+ $mol_assert_equal($mol_charset_encode(''), new Uint8Array([]));
11265
+ },
11266
+ 'encode 1 octet'() {
11267
+ $mol_assert_equal($mol_charset_encode('F'), new Uint8Array([0x46]));
11268
+ },
11269
+ 'encode 2 octet'() {
11270
+ $mol_assert_equal($mol_charset_encode('Б'), new Uint8Array([0xd0, 0x91]));
11271
+ },
11272
+ 'encode 3 octet'() {
11273
+ $mol_assert_equal($mol_charset_encode('ह'), new Uint8Array([0xe0, 0xa4, 0xb9]));
11274
+ },
11275
+ 'encode 4 octet'() {
11276
+ $mol_assert_equal($mol_charset_encode('𐍈'), new Uint8Array([0xf0, 0x90, 0x8d, 0x88]));
11277
+ },
11278
+ 'encode surrogate pair'() {
11279
+ $mol_assert_equal($mol_charset_encode('😀'), new Uint8Array([0xf0, 0x9f, 0x98, 0x80]));
11280
+ },
11281
+ });
11282
+ })($ || ($ = {}));
11283
+
11284
+ ;
11285
+ "use strict";
11286
+ var $;
11287
+ (function ($) {
11288
+ $mol_test({
11289
+ 'local get set delete'() {
11290
+ var key = '$mol_state_local_test:' + Math.random();
11291
+ $mol_assert_equal($mol_state_local.value(key), null);
11292
+ $mol_state_local.value(key, 123);
11293
+ $mol_assert_equal($mol_state_local.value(key), 123);
11294
+ $mol_state_local.value(key, null);
11295
+ $mol_assert_equal($mol_state_local.value(key), null);
11296
+ },
11297
+ });
11298
+ })($ || ($ = {}));
11299
+
11300
+ ;
11301
+ "use strict";
11302
+ var $;
11303
+ (function ($) {
11304
+ $mol_test_mocks.push(context => {
11305
+ class $mol_state_local_mock extends $mol_state_local {
11306
+ static state = {};
11307
+ static value(key, next = this.state[key]) {
11308
+ return this.state[key] = (next || null);
11309
+ }
11310
+ }
11311
+ __decorate([
11312
+ $mol_mem_key
11313
+ ], $mol_state_local_mock, "value", null);
11314
+ context.$mol_state_local = $mol_state_local_mock;
11315
+ });
11316
+ })($ || ($ = {}));
11317
+
11491
11318
  ;
11492
11319
  "use strict";
11493
11320
  var $;