@dxos/util 0.4.6 → 0.4.7-main.0a4f1cd

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.
@@ -65,7 +65,12 @@ __export(node_exports, {
65
65
  getDeep: () => getDeep,
66
66
  getHostPlatform: () => getHostPlatform,
67
67
  getPrototypeSpecificInstanceId: () => getPrototypeSpecificInstanceId,
68
+ hexToEmoji: () => hexToEmoji,
69
+ hexToFallback: () => hexToFallback,
70
+ hexToHue: () => hexToHue,
68
71
  humanize: () => humanize,
72
+ idEmoji: () => idEmoji,
73
+ idHue: () => idHue,
69
74
  inferObjectOrder: () => inferObjectOrder,
70
75
  inferRecordOrder: () => inferRecordOrder,
71
76
  iosCheck: () => iosCheck,
@@ -75,6 +80,9 @@ __export(node_exports, {
75
80
  jsonKeyReplacer: () => jsonKeyReplacer,
76
81
  jsonReplacer: () => jsonReplacer,
77
82
  jsonify: () => jsonify,
83
+ keyToEmoji: () => keyToEmoji,
84
+ keyToFallback: () => keyToFallback,
85
+ keyToHue: () => keyToHue,
78
86
  makeMap: () => makeMap,
79
87
  makeSet: () => makeSet,
80
88
  mapValues: () => mapValues,
@@ -95,6 +103,9 @@ __export(node_exports, {
95
103
  stringToArray: () => stringToArray,
96
104
  stripUndefinedValues: () => stripUndefinedValues,
97
105
  sum: () => sum,
106
+ toEmoji: () => toEmoji,
107
+ toFallback: () => toFallback,
108
+ toHue: () => toHue,
98
109
  tracer: () => tracer
99
110
  });
100
111
  module.exports = __toCommonJS(node_exports);
@@ -407,6 +418,183 @@ var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
407
418
  }
408
419
  };
409
420
  var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
421
+ var idEmoji = [
422
+ // When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
423
+ // Emoji sometimes use a combination of code points, and some code points aren't visible on their own, so by adding or deleting you may unintentionally create non-visible items.
424
+ // This set was chosen from the characters in Unicode Emoji v15.0 based on the following criteria:
425
+ // – not people or isolated anthropomorphic faces
426
+ // – not flags
427
+ // – more concrete than abstract
428
+ // – less culturally specific
429
+ // – less easily confused with another emoji in the set
430
+ // – requires less special knowledge to identify
431
+ // – less likely to evoke negative feelings (no meat, no drugs, no weapons, etc)
432
+ // – less common as a signifier in UX
433
+ // NOTE that this is intentionally an array of strings because of the way emoji graphemes work.
434
+ "\u{1F479}",
435
+ "\u{1F47B}",
436
+ "\u{1F47D}",
437
+ "\u{1F916}",
438
+ "\u{1F383}",
439
+ "\u{1F9BE}",
440
+ "\u{1F9BF}",
441
+ "\u{1F9B7}",
442
+ "\u{1F463}",
443
+ "\u{1F441}\uFE0F",
444
+ "\u{1F9F6}",
445
+ "\u{1F451}",
446
+ "\u{1F412}",
447
+ "\u{1F986}",
448
+ "\u{1F989}",
449
+ "\u{1F434}",
450
+ "\u{1F984}",
451
+ "\u{1F41D}",
452
+ "\u{1F98B}",
453
+ "\u{1F41E}",
454
+ "\u{1FAB2}",
455
+ "\u{1F422}",
456
+ "\u{1F98E}",
457
+ "\u{1F995}",
458
+ "\u{1F991}",
459
+ "\u{1F980}",
460
+ "\u{1F420}",
461
+ "\u{1F42C}",
462
+ "\u{1F40B}",
463
+ "\u{1F9AD}",
464
+ "\u{1F405}",
465
+ "\u{1F406}",
466
+ "\u{1F993}",
467
+ "\u{1F98D}",
468
+ "\u{1F9A7}",
469
+ "\u{1F418}",
470
+ "\u{1F42B}",
471
+ "\u{1F992}",
472
+ "\u{1F998}",
473
+ "\u{1F9AC}",
474
+ "\u{1F416}",
475
+ "\u{1F40F}",
476
+ "\u{1F98C}",
477
+ "\u{1F415}",
478
+ "\u{1F408}",
479
+ "\u{1F413}",
480
+ "\u{1F99A}",
481
+ "\u{1F99C}",
482
+ "\u{1F9A2}",
483
+ "\u{1F9A9}",
484
+ "\u{1F9A6}",
485
+ "\u{1F401}",
486
+ "\u{1F43F}\uFE0F",
487
+ "\u{1F335}",
488
+ "\u{1F332}",
489
+ "\u{1F333}",
490
+ "\u{1FAB5}",
491
+ "\u{1F331}",
492
+ "\u{1F341}",
493
+ "\u{1FABA}",
494
+ "\u{1F344}",
495
+ "\u{1F41A}",
496
+ "\u{1FAB8}",
497
+ "\u{1FAA8}",
498
+ "\u{1F33E}",
499
+ "\u{1F337}",
500
+ "\u{1F33B}",
501
+ "\u2600\uFE0F",
502
+ "\u{1F319}",
503
+ "\u{1FA90}",
504
+ "\u2B50\uFE0F",
505
+ "\u26A1\uFE0F",
506
+ "\u2604\uFE0F",
507
+ "\u{1F525}",
508
+ "\u{1F308}",
509
+ "\u2601\uFE0F",
510
+ "\u{1F4A7}",
511
+ "\u26F1\uFE0F",
512
+ "\u{1F30A}",
513
+ "\u{1F34E}",
514
+ "\u{1F34B}",
515
+ "\u{1F349}",
516
+ "\u{1F347}",
517
+ "\u{1FAD0}",
518
+ "\u{1F348}",
519
+ "\u{1F352}",
520
+ "\u{1F351}",
521
+ "\u{1F96D}",
522
+ "\u{1F34D}",
523
+ "\u{1F965}",
524
+ "\u{1F95D}",
525
+ "\u{1F951}",
526
+ "\u{1F336}\uFE0F",
527
+ "\u{1F33D}",
528
+ "\u{1F955}",
529
+ "\u{1F36C}",
530
+ "\u{1F95C}",
531
+ "\u{1FAD6}",
532
+ "\u2615\uFE0F",
533
+ "\u{1F375}",
534
+ "\u{1F9CA}",
535
+ "\u{1F9C2}",
536
+ "\u{1F3D4}\uFE0F",
537
+ "\u2693\uFE0F",
538
+ "\u{1F6DF}",
539
+ "\u{1F3DD}\uFE0F",
540
+ "\u{1F6F6}",
541
+ "\u{1F680}",
542
+ "\u{1F6F0}\uFE0F",
543
+ "\u26F2\uFE0F",
544
+ "\u{1F3F0}",
545
+ "\u{1F6B2}",
546
+ "\u26FA\uFE0F",
547
+ "\u{1F399}\uFE0F",
548
+ "\u{1F9F2}",
549
+ "\u2699\uFE0F",
550
+ "\u{1F529}",
551
+ "\u{1F52E}",
552
+ "\u{1F52D}",
553
+ "\u{1F52C}",
554
+ "\u{1F9EC}",
555
+ "\u{1F321}\uFE0F",
556
+ "\u{1F9FA}",
557
+ "\u{1F6CE}\uFE0F",
558
+ "\u{1F511}",
559
+ "\u{1FA91}",
560
+ "\u{1F9F8}",
561
+ "\u{1F388}",
562
+ "\u{1F380}",
563
+ "\u{1F38A}",
564
+ "\u267B\uFE0F",
565
+ "\u{1F3B5}"
566
+ ];
567
+ var idHue = [
568
+ "red",
569
+ // 'orange' as const, /* More shades in these palettes are considered “ugly” */
570
+ "amber",
571
+ // 'yellow' as const, /* More shades in these palettes are considered “ugly” */
572
+ "lime",
573
+ "green",
574
+ "emerald",
575
+ "teal",
576
+ "cyan",
577
+ // 'sky' as const, /* Omitted since it is quite similar to the primary accent palette */
578
+ // 'blue' as const, /* Omitted since it is quite similar to the primary accent palette */
579
+ // 'indigo' as const, /* Omitted since it is quite similar to the primary accent palette */
580
+ "violet",
581
+ "purple",
582
+ "fuchsia",
583
+ "pink",
584
+ "rose"
585
+ ];
586
+ var keyToEmoji = (key) => hexToEmoji(key.toHex());
587
+ var hexToEmoji = (hex) => toEmoji(parseInt(hex, 16));
588
+ var toEmoji = (hash) => idEmoji[hash % idEmoji.length];
589
+ var keyToHue = (key) => hexToHue(key.toHex());
590
+ var hexToHue = (hex) => toHue(parseInt(hex, 16));
591
+ var toHue = (hash) => idHue[hash % idHue.length];
592
+ var keyToFallback = (key) => hexToFallback(key.toHex());
593
+ var hexToFallback = (hex) => toFallback(parseInt(hex, 16));
594
+ var toFallback = (hash) => ({
595
+ emoji: toEmoji(hash),
596
+ hue: toHue(hash)
597
+ });
410
598
  var entry = (map, key) => new MapEntry(map, key);
411
599
  var MapEntry = class {
412
600
  /**
@@ -1338,7 +1526,12 @@ var DeferAsyncGuard = class {
1338
1526
  getDeep,
1339
1527
  getHostPlatform,
1340
1528
  getPrototypeSpecificInstanceId,
1529
+ hexToEmoji,
1530
+ hexToFallback,
1531
+ hexToHue,
1341
1532
  humanize,
1533
+ idEmoji,
1534
+ idHue,
1342
1535
  inferObjectOrder,
1343
1536
  inferRecordOrder,
1344
1537
  iosCheck,
@@ -1348,6 +1541,9 @@ var DeferAsyncGuard = class {
1348
1541
  jsonKeyReplacer,
1349
1542
  jsonReplacer,
1350
1543
  jsonify,
1544
+ keyToEmoji,
1545
+ keyToFallback,
1546
+ keyToHue,
1351
1547
  makeMap,
1352
1548
  makeSet,
1353
1549
  mapValues,
@@ -1368,6 +1564,9 @@ var DeferAsyncGuard = class {
1368
1564
  stringToArray,
1369
1565
  stripUndefinedValues,
1370
1566
  sum,
1567
+ toEmoji,
1568
+ toFallback,
1569
+ toHue,
1371
1570
  tracer
1372
1571
  });
1373
1572
  //# sourceMappingURL=index.cjs.map