@dxos/util 0.4.7-main.dca306f → 0.4.7-main.ea67fec

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.
@@ -325,6 +325,185 @@ var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
325
325
  // packages/common/util/src/defer-function.ts
326
326
  var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
327
327
 
328
+ // packages/common/util/src/to-fallback.ts
329
+ var idEmoji = [
330
+ // When changing this set, please check the result in a console or e.g. RunKit (https://runkit.com/thure/642214441dd6ae000855a8de)
331
+ // 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.
332
+ // This set was chosen from the characters in Unicode Emoji v15.0 based on the following criteria:
333
+ // – not people or isolated anthropomorphic faces
334
+ // – not flags
335
+ // – more concrete than abstract
336
+ // – less culturally specific
337
+ // – less easily confused with another emoji in the set
338
+ // – requires less special knowledge to identify
339
+ // – less likely to evoke negative feelings (no meat, no drugs, no weapons, etc)
340
+ // – less common as a signifier in UX
341
+ // NOTE that this is intentionally an array of strings because of the way emoji graphemes work.
342
+ "\u{1F479}",
343
+ "\u{1F47B}",
344
+ "\u{1F47D}",
345
+ "\u{1F916}",
346
+ "\u{1F383}",
347
+ "\u{1F9BE}",
348
+ "\u{1F9BF}",
349
+ "\u{1F9B7}",
350
+ "\u{1F463}",
351
+ "\u{1F441}\uFE0F",
352
+ "\u{1F9F6}",
353
+ "\u{1F451}",
354
+ "\u{1F412}",
355
+ "\u{1F986}",
356
+ "\u{1F989}",
357
+ "\u{1F434}",
358
+ "\u{1F984}",
359
+ "\u{1F41D}",
360
+ "\u{1F98B}",
361
+ "\u{1F41E}",
362
+ "\u{1FAB2}",
363
+ "\u{1F422}",
364
+ "\u{1F98E}",
365
+ "\u{1F995}",
366
+ "\u{1F991}",
367
+ "\u{1F980}",
368
+ "\u{1F420}",
369
+ "\u{1F42C}",
370
+ "\u{1F40B}",
371
+ "\u{1F9AD}",
372
+ "\u{1F405}",
373
+ "\u{1F406}",
374
+ "\u{1F993}",
375
+ "\u{1F98D}",
376
+ "\u{1F9A7}",
377
+ "\u{1F418}",
378
+ "\u{1F42B}",
379
+ "\u{1F992}",
380
+ "\u{1F998}",
381
+ "\u{1F9AC}",
382
+ "\u{1F416}",
383
+ "\u{1F40F}",
384
+ "\u{1F98C}",
385
+ "\u{1F415}",
386
+ "\u{1F408}",
387
+ "\u{1F413}",
388
+ "\u{1F99A}",
389
+ "\u{1F99C}",
390
+ "\u{1F9A2}",
391
+ "\u{1F9A9}",
392
+ "\u{1F9A6}",
393
+ "\u{1F401}",
394
+ "\u{1F43F}\uFE0F",
395
+ "\u{1F335}",
396
+ "\u{1F332}",
397
+ "\u{1F333}",
398
+ "\u{1FAB5}",
399
+ "\u{1F331}",
400
+ "\u{1F341}",
401
+ "\u{1FABA}",
402
+ "\u{1F344}",
403
+ "\u{1F41A}",
404
+ "\u{1FAB8}",
405
+ "\u{1FAA8}",
406
+ "\u{1F33E}",
407
+ "\u{1F337}",
408
+ "\u{1F33B}",
409
+ "\u2600\uFE0F",
410
+ "\u{1F319}",
411
+ "\u{1FA90}",
412
+ "\u2B50\uFE0F",
413
+ "\u26A1\uFE0F",
414
+ "\u2604\uFE0F",
415
+ "\u{1F525}",
416
+ "\u{1F308}",
417
+ "\u2601\uFE0F",
418
+ "\u{1F4A7}",
419
+ "\u26F1\uFE0F",
420
+ "\u{1F30A}",
421
+ "\u{1F34E}",
422
+ "\u{1F34B}",
423
+ "\u{1F349}",
424
+ "\u{1F347}",
425
+ "\u{1FAD0}",
426
+ "\u{1F348}",
427
+ "\u{1F352}",
428
+ "\u{1F351}",
429
+ "\u{1F96D}",
430
+ "\u{1F34D}",
431
+ "\u{1F965}",
432
+ "\u{1F95D}",
433
+ "\u{1F951}",
434
+ "\u{1F336}\uFE0F",
435
+ "\u{1F33D}",
436
+ "\u{1F955}",
437
+ "\u{1F36C}",
438
+ "\u{1F95C}",
439
+ "\u{1FAD6}",
440
+ "\u2615\uFE0F",
441
+ "\u{1F375}",
442
+ "\u{1F9CA}",
443
+ "\u{1F9C2}",
444
+ "\u{1F3D4}\uFE0F",
445
+ "\u2693\uFE0F",
446
+ "\u{1F6DF}",
447
+ "\u{1F3DD}\uFE0F",
448
+ "\u{1F6F6}",
449
+ "\u{1F680}",
450
+ "\u{1F6F0}\uFE0F",
451
+ "\u26F2\uFE0F",
452
+ "\u{1F3F0}",
453
+ "\u{1F6B2}",
454
+ "\u26FA\uFE0F",
455
+ "\u{1F399}\uFE0F",
456
+ "\u{1F9F2}",
457
+ "\u2699\uFE0F",
458
+ "\u{1F529}",
459
+ "\u{1F52E}",
460
+ "\u{1F52D}",
461
+ "\u{1F52C}",
462
+ "\u{1F9EC}",
463
+ "\u{1F321}\uFE0F",
464
+ "\u{1F9FA}",
465
+ "\u{1F6CE}\uFE0F",
466
+ "\u{1F511}",
467
+ "\u{1FA91}",
468
+ "\u{1F9F8}",
469
+ "\u{1F388}",
470
+ "\u{1F380}",
471
+ "\u{1F38A}",
472
+ "\u267B\uFE0F",
473
+ "\u{1F3B5}"
474
+ ];
475
+ var idHue = [
476
+ "red",
477
+ // 'orange' as const, /* More shades in these palettes are considered “ugly” */
478
+ "amber",
479
+ // 'yellow' as const, /* More shades in these palettes are considered “ugly” */
480
+ "lime",
481
+ "green",
482
+ "emerald",
483
+ "teal",
484
+ "cyan",
485
+ // 'sky' as const, /* Omitted since it is quite similar to the primary accent palette */
486
+ // 'blue' as const, /* Omitted since it is quite similar to the primary accent palette */
487
+ // 'indigo' as const, /* Omitted since it is quite similar to the primary accent palette */
488
+ "violet",
489
+ "purple",
490
+ "fuchsia",
491
+ "pink",
492
+ "rose"
493
+ ];
494
+ var keyToEmoji = (key) => hexToEmoji(key.toHex());
495
+ var hexToEmoji = (hex) => toEmoji(parseInt(hex, 16));
496
+ var toEmoji = (hash) => idEmoji[hash % idEmoji.length];
497
+ var keyToHue = (key) => hexToHue(key.toHex());
498
+ var hexToHue = (hex) => toHue(parseInt(hex, 16));
499
+ var toHue = (hash) => idHue[hash % idHue.length];
500
+ var keyToFallback = (key) => hexToFallback(key.toHex());
501
+ var hexToFallback = (hex) => toFallback(parseInt(hex, 16));
502
+ var toFallback = (hash) => ({
503
+ emoji: toEmoji(hash),
504
+ hue: toHue(hash)
505
+ });
506
+
328
507
  // packages/common/util/src/entry.ts
329
508
  var entry = (map, key) => new MapEntry(map, key);
330
509
  var MapEntry = class {
@@ -1305,7 +1484,12 @@ export {
1305
1484
  getDeep,
1306
1485
  getHostPlatform,
1307
1486
  getPrototypeSpecificInstanceId,
1487
+ hexToEmoji,
1488
+ hexToFallback,
1489
+ hexToHue,
1308
1490
  humanize,
1491
+ idEmoji,
1492
+ idHue,
1309
1493
  inferObjectOrder,
1310
1494
  inferRecordOrder,
1311
1495
  iosCheck,
@@ -1315,6 +1499,9 @@ export {
1315
1499
  jsonKeyReplacer,
1316
1500
  jsonReplacer,
1317
1501
  jsonify,
1502
+ keyToEmoji,
1503
+ keyToFallback,
1504
+ keyToHue,
1318
1505
  makeMap,
1319
1506
  makeSet,
1320
1507
  mapValues,
@@ -1335,6 +1522,9 @@ export {
1335
1522
  stringToArray,
1336
1523
  stripUndefinedValues,
1337
1524
  sum,
1525
+ toEmoji,
1526
+ toFallback,
1527
+ toHue,
1338
1528
  tracer
1339
1529
  };
1340
1530
  //# sourceMappingURL=index.mjs.map