securemark 0.276.1 → 0.276.3
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/CHANGELOG.md +8 -0
- package/design.md +1 -0
- package/dist/index.js +207 -160
- package/package.json +10 -10
- package/src/combinator/control/manipulation/fence.ts +1 -1
- package/src/parser/api/bind.test.ts +3 -3
- package/src/parser/api/parse.test.ts +33 -33
- package/src/parser/block/blockquote.test.ts +1 -1
- package/src/parser/block/extension/example.test.ts +1 -1
- package/src/parser/inline/link.ts +13 -13
- package/src/parser/inline/mark.ts +2 -6
- package/src/parser/inline/ruby.ts +1 -1
- package/src/parser/processor/note.test.ts +25 -30
- package/src/parser/processor/note.ts +34 -21
- package/src/parser/visibility.ts +17 -17
- package/webpack.config.js +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.276.
|
|
1
|
+
/*! securemark v0.276.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -394,12 +394,12 @@ DWCはこの最適化を行っても状態数の多さに比例して増加し
|
|
|
394
394
|
|
|
395
395
|
*/
|
|
396
396
|
class Entry {
|
|
397
|
-
constructor(key, value, size, partition,
|
|
397
|
+
constructor(key, value, size, partition, affiliation, expiration) {
|
|
398
398
|
this.key = key;
|
|
399
399
|
this.value = value;
|
|
400
400
|
this.size = size;
|
|
401
401
|
this.partition = partition;
|
|
402
|
-
this.
|
|
402
|
+
this.affiliation = affiliation;
|
|
403
403
|
this.expiration = expiration;
|
|
404
404
|
this.enode = undefined;
|
|
405
405
|
this.next = undefined;
|
|
@@ -423,7 +423,9 @@ class Cache {
|
|
|
423
423
|
},
|
|
424
424
|
sweep: {
|
|
425
425
|
threshold: 10,
|
|
426
|
+
ratio: 50,
|
|
426
427
|
window: 2,
|
|
428
|
+
room: 50,
|
|
427
429
|
range: 1,
|
|
428
430
|
shift: 2
|
|
429
431
|
}
|
|
@@ -434,7 +436,7 @@ class Cache {
|
|
|
434
436
|
this.overlapLRU = 0;
|
|
435
437
|
this.overlapLFU = 0;
|
|
436
438
|
this.$size = 0;
|
|
437
|
-
this.
|
|
439
|
+
this.declination = 1;
|
|
438
440
|
if (typeof capacity === 'object') {
|
|
439
441
|
opts = capacity;
|
|
440
442
|
capacity = opts.capacity ?? 0;
|
|
@@ -445,8 +447,9 @@ class Cache {
|
|
|
445
447
|
this.capacity = capacity = settings.capacity;
|
|
446
448
|
if (capacity >>> 0 !== capacity) throw new Error(`Spica: Cache: Capacity must be integer.`);
|
|
447
449
|
if (capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
|
|
448
|
-
this.window = capacity * settings.window / 100 >>> 0;
|
|
450
|
+
this.window = capacity * settings.window / 100 >>> 0 || 1;
|
|
449
451
|
this.partition = capacity - this.window;
|
|
452
|
+
this.injection = 100 * this.declination;
|
|
450
453
|
this.sample = settings.sample;
|
|
451
454
|
this.resource = settings.resource ?? capacity;
|
|
452
455
|
this.expiration = opts.age !== undefined;
|
|
@@ -456,7 +459,7 @@ class Cache {
|
|
|
456
459
|
stable: false
|
|
457
460
|
});
|
|
458
461
|
}
|
|
459
|
-
this.sweeper = new Sweeper(this.LRU, settings.sweep.
|
|
462
|
+
this.sweeper = new Sweeper(this.LRU, capacity, settings.sweep.window, settings.sweep.room, settings.sweep.threshold, settings.sweep.ratio, settings.sweep.range, settings.sweep.shift);
|
|
460
463
|
this.disposer = settings.disposer;
|
|
461
464
|
}
|
|
462
465
|
get length() {
|
|
@@ -469,32 +472,80 @@ class Cache {
|
|
|
469
472
|
get size() {
|
|
470
473
|
return this.$size;
|
|
471
474
|
}
|
|
475
|
+
resize(capacity, resource) {
|
|
476
|
+
if (capacity >>> 0 !== capacity) throw new Error(`Spica: Cache: Capacity must be integer.`);
|
|
477
|
+
if (capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
|
|
478
|
+
this.partition = this.partition / this.capacity * capacity >>> 0;
|
|
479
|
+
this.capacity = capacity;
|
|
480
|
+
const {
|
|
481
|
+
settings
|
|
482
|
+
} = this;
|
|
483
|
+
this.window = capacity * settings.window / 100 >>> 0 || 1;
|
|
484
|
+
this.resource = resource ?? settings.resource ?? capacity;
|
|
485
|
+
this.sweeper.resize(capacity, settings.sweep.window, settings.sweep.room, settings.sweep.range);
|
|
486
|
+
this.ensure(0);
|
|
487
|
+
}
|
|
488
|
+
clear() {
|
|
489
|
+
const {
|
|
490
|
+
LRU,
|
|
491
|
+
LFU
|
|
492
|
+
} = this;
|
|
493
|
+
this.$size = 0;
|
|
494
|
+
this.partition = this.capacity - this.window;
|
|
495
|
+
this.injection = 100 * this.declination;
|
|
496
|
+
this.dict = new Map();
|
|
497
|
+
this.LRU = new list_1.List();
|
|
498
|
+
this.LFU = new list_1.List();
|
|
499
|
+
this.overlapLRU = 0;
|
|
500
|
+
this.overlapLFU = 0;
|
|
501
|
+
this.expirations?.clear();
|
|
502
|
+
this.sweeper.clear();
|
|
503
|
+
this.sweeper.replace(this.LRU);
|
|
504
|
+
if (!this.disposer || !this.settings.capture.clear) return;
|
|
505
|
+
for (const {
|
|
506
|
+
key,
|
|
507
|
+
value
|
|
508
|
+
} of LRU) {
|
|
509
|
+
this.disposer(value, key);
|
|
510
|
+
}
|
|
511
|
+
for (const {
|
|
512
|
+
key,
|
|
513
|
+
value
|
|
514
|
+
} of LFU) {
|
|
515
|
+
this.disposer(value, key);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
472
518
|
evict$(entry, callback) {
|
|
473
519
|
//assert(this.dict.size <= this.capacity);
|
|
474
520
|
|
|
475
|
-
|
|
521
|
+
this.overlap(entry, true);
|
|
476
522
|
if (entry.enode !== undefined) {
|
|
477
523
|
this.expirations.delete(entry.enode);
|
|
478
524
|
entry.enode = undefined;
|
|
479
525
|
}
|
|
480
|
-
entry.partition.delete(entry);
|
|
526
|
+
entry.partition === 'LRU' ? this.LRU.delete(entry) : this.LFU.delete(entry);
|
|
481
527
|
this.dict.delete(entry.key);
|
|
482
528
|
//assert(this.dict.size <= this.capacity);
|
|
483
529
|
this.$size -= entry.size;
|
|
484
530
|
callback && this.disposer?.(entry.value, entry.key);
|
|
485
531
|
}
|
|
486
|
-
overlap(entry) {
|
|
487
|
-
if (entry.partition ===
|
|
488
|
-
if (entry.
|
|
532
|
+
overlap(entry, eviction = false) {
|
|
533
|
+
if (entry.partition === 'LRU') {
|
|
534
|
+
if (entry.affiliation === 'LRU') {
|
|
535
|
+
if (eviction) return entry;
|
|
489
536
|
++this.overlapLRU;
|
|
490
537
|
} else {
|
|
491
538
|
--this.overlapLFU;
|
|
492
539
|
}
|
|
493
540
|
} else {
|
|
494
|
-
if (entry.
|
|
541
|
+
if (entry.affiliation === 'LFU') {
|
|
542
|
+
if (eviction) return entry;
|
|
495
543
|
++this.overlapLFU;
|
|
496
544
|
} else {
|
|
497
545
|
--this.overlapLRU;
|
|
546
|
+
if (this.declination !== 1 && this.overlapLRU * 100 < this.LFU.length * this.sample) {
|
|
547
|
+
this.declination = 1;
|
|
548
|
+
}
|
|
498
549
|
}
|
|
499
550
|
}
|
|
500
551
|
return entry;
|
|
@@ -507,7 +558,7 @@ class Cache {
|
|
|
507
558
|
LFU
|
|
508
559
|
} = this;
|
|
509
560
|
while (this.size + margin - size > this.resource) {
|
|
510
|
-
this.injection = (0, alias_1.min)(this.injection + this.sample, 100);
|
|
561
|
+
this.injection = (0, alias_1.min)(this.injection + this.sample, 100 * this.declination);
|
|
511
562
|
let victim = this.expirations?.peek()?.value;
|
|
512
563
|
if (victim !== undefined && victim !== target && victim.expiration < (0, chrono_1.now)()) {} else if (LRU.length === 0) {
|
|
513
564
|
victim = LFU.head.prev;
|
|
@@ -519,16 +570,17 @@ class Cache {
|
|
|
519
570
|
if (entry !== undefined) {
|
|
520
571
|
LFU.delete(entry);
|
|
521
572
|
LRU.unshift(this.overlap(entry));
|
|
522
|
-
entry.partition = LRU;
|
|
573
|
+
entry.partition = 'LRU';
|
|
523
574
|
}
|
|
524
575
|
}
|
|
525
|
-
if (
|
|
576
|
+
if (LRU.length >= this.window && this.injection === 100 * this.declination) {
|
|
526
577
|
const entry = LRU.head.prev;
|
|
527
|
-
if (entry.
|
|
578
|
+
if (entry.affiliation === 'LRU') {
|
|
528
579
|
LRU.delete(entry);
|
|
529
580
|
LFU.unshift(this.overlap(entry));
|
|
530
|
-
entry.partition = LFU;
|
|
581
|
+
entry.partition = 'LFU';
|
|
531
582
|
this.injection = 0;
|
|
583
|
+
this.declination = this.overlapLRU * 100 < LFU.length * this.sample ? 1 : (0, alias_1.min)(this.declination * 1.5, 10);
|
|
532
584
|
}
|
|
533
585
|
}
|
|
534
586
|
if (this.sweeper.isActive()) {
|
|
@@ -575,29 +627,31 @@ class Cache {
|
|
|
575
627
|
LRU,
|
|
576
628
|
LFU
|
|
577
629
|
} = this;
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
entry.
|
|
630
|
+
if (entry.partition === 'LRU') {
|
|
631
|
+
if (entry.affiliation === 'LRU') {
|
|
632
|
+
// For memoize.
|
|
633
|
+
// Strict checks are ineffective for OLTP.
|
|
634
|
+
if (entry === LRU.head) return;
|
|
635
|
+
entry.affiliation = 'LFU';
|
|
584
636
|
} else {
|
|
585
|
-
const delta = LRU.length > LFU.length && LRU.length >= this.capacity - this.partition ? LRU.length / (LFU.length || 1) * (this.overlapLRU
|
|
637
|
+
const delta = LRU.length > LFU.length && LRU.length >= this.capacity - this.partition ? LRU.length / (LFU.length || 1) * (0, alias_1.max)(this.overlapLRU / this.overlapLFU, 1) | 0 || 1 : 1;
|
|
586
638
|
this.partition = (0, alias_1.min)(this.partition + delta, this.capacity - this.window);
|
|
587
639
|
--this.overlapLFU;
|
|
588
640
|
}
|
|
589
641
|
LRU.delete(entry);
|
|
590
642
|
LFU.unshift(entry);
|
|
591
|
-
entry.partition = LFU;
|
|
643
|
+
entry.partition = 'LFU';
|
|
592
644
|
} else {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if (entry.region === 'LFU') {} else {
|
|
596
|
-
const delta = LFU.length > LRU.length && LFU.length >= this.partition ? LFU.length / (LRU.length || 1) * (this.overlapLFU || 1) / this.overlapLRU | 0 || 1 : 1;
|
|
645
|
+
if (entry.affiliation === 'LFU') {} else {
|
|
646
|
+
const delta = LFU.length > LRU.length && LFU.length >= this.partition ? LFU.length / (LRU.length || 1) * (0, alias_1.max)(this.overlapLFU / this.overlapLRU, 1) | 0 || 1 : 1;
|
|
597
647
|
this.partition = (0, alias_1.max)(this.partition - delta, 0);
|
|
598
|
-
entry.
|
|
648
|
+
entry.affiliation = 'LFU';
|
|
599
649
|
--this.overlapLRU;
|
|
650
|
+
if (this.declination !== 1 && this.overlapLRU * 100 < this.LFU.length * this.sample) {
|
|
651
|
+
this.declination = 1;
|
|
652
|
+
}
|
|
600
653
|
}
|
|
654
|
+
if (entry === LFU.head) return;
|
|
601
655
|
LFU.delete(entry);
|
|
602
656
|
LFU.unshift(entry);
|
|
603
657
|
}
|
|
@@ -626,16 +680,16 @@ class Cache {
|
|
|
626
680
|
victim = this.ensure(size, victim, true);
|
|
627
681
|
// Note that the key will be duplicate if the key is evicted and added again in disposing.
|
|
628
682
|
if (victim !== undefined) {
|
|
629
|
-
victim.
|
|
683
|
+
victim.affiliation === 'LFU' && --this.overlapLFU;
|
|
630
684
|
this.dict.delete(victim.key);
|
|
631
685
|
this.dict.set(key, victim);
|
|
632
|
-
victim.
|
|
686
|
+
victim.affiliation = 'LRU';
|
|
633
687
|
LRU.head = victim;
|
|
634
688
|
this.update(victim, key, value, size, expiration);
|
|
635
689
|
return true;
|
|
636
690
|
}
|
|
637
691
|
this.$size += size;
|
|
638
|
-
const entry = new Entry(key, value, size, LRU, 'LRU', expiration);
|
|
692
|
+
const entry = new Entry(key, value, size, 'LRU', 'LRU', expiration);
|
|
639
693
|
LRU.unshift(entry);
|
|
640
694
|
this.dict.set(key, entry);
|
|
641
695
|
if (this.expiration && this.expirations !== undefined && expiration !== Infinity) {
|
|
@@ -681,6 +735,7 @@ class Cache {
|
|
|
681
735
|
this.evict$(entry, true);
|
|
682
736
|
return;
|
|
683
737
|
}
|
|
738
|
+
this.sweeper.hit();
|
|
684
739
|
this.replace(entry);
|
|
685
740
|
return entry.value;
|
|
686
741
|
}
|
|
@@ -699,36 +754,6 @@ class Cache {
|
|
|
699
754
|
this.evict$(entry, this.settings.capture.delete === true);
|
|
700
755
|
return true;
|
|
701
756
|
}
|
|
702
|
-
clear() {
|
|
703
|
-
const {
|
|
704
|
-
LRU,
|
|
705
|
-
LFU
|
|
706
|
-
} = this;
|
|
707
|
-
this.injection = 0;
|
|
708
|
-
this.$size = 0;
|
|
709
|
-
this.partition = this.capacity - this.window;
|
|
710
|
-
this.dict = new Map();
|
|
711
|
-
this.LRU = new list_1.List();
|
|
712
|
-
this.LFU = new list_1.List();
|
|
713
|
-
this.overlapLRU = 0;
|
|
714
|
-
this.overlapLFU = 0;
|
|
715
|
-
this.expirations?.clear();
|
|
716
|
-
this.sweeper.clear();
|
|
717
|
-
this.sweeper.replace(this.LRU);
|
|
718
|
-
if (!this.disposer || !this.settings.capture.clear) return;
|
|
719
|
-
for (const {
|
|
720
|
-
key,
|
|
721
|
-
value
|
|
722
|
-
} of LRU) {
|
|
723
|
-
this.disposer(value, key);
|
|
724
|
-
}
|
|
725
|
-
for (const {
|
|
726
|
-
key,
|
|
727
|
-
value
|
|
728
|
-
} of LFU) {
|
|
729
|
-
this.disposer(value, key);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
757
|
*[Symbol.iterator]() {
|
|
733
758
|
for (const {
|
|
734
759
|
key,
|
|
@@ -744,60 +769,87 @@ class Cache {
|
|
|
744
769
|
}
|
|
745
770
|
return;
|
|
746
771
|
}
|
|
747
|
-
resize(capacity, resource) {
|
|
748
|
-
if (capacity >>> 0 !== capacity) throw new Error(`Spica: Cache: Capacity must be integer.`);
|
|
749
|
-
if (capacity >= 1 === false) throw new Error(`Spica: Cache: Capacity must be 1 or more.`);
|
|
750
|
-
this.partition = this.partition / this.capacity * capacity >>> 0;
|
|
751
|
-
this.capacity = capacity;
|
|
752
|
-
this.window = capacity * this.settings.window / 100 >>> 0;
|
|
753
|
-
this.resource = resource ?? this.settings.resource ?? capacity;
|
|
754
|
-
this.sweeper.resize(capacity, this.settings.sweep.window, this.settings.sweep.range);
|
|
755
|
-
this.ensure(0);
|
|
756
|
-
}
|
|
757
772
|
}
|
|
758
773
|
exports.Cache = Cache;
|
|
759
774
|
// Transitive Wide MRU with Cyclic Replacement
|
|
760
775
|
class Sweeper {
|
|
761
|
-
constructor(target,
|
|
776
|
+
constructor(target, capacity, window, room, threshold, ratio, range, shift) {
|
|
762
777
|
this.target = target;
|
|
763
|
-
this.threshold = threshold;
|
|
764
778
|
this.window = window;
|
|
779
|
+
this.room = room;
|
|
780
|
+
this.threshold = threshold;
|
|
781
|
+
this.ratio = ratio;
|
|
765
782
|
this.range = range;
|
|
766
783
|
this.shift = shift;
|
|
767
|
-
this.
|
|
768
|
-
this.
|
|
769
|
-
this.
|
|
770
|
-
this.
|
|
784
|
+
this.currWindowHits = 0;
|
|
785
|
+
this.currWindowMisses = 0;
|
|
786
|
+
this.prevWindowHits = 0;
|
|
787
|
+
this.prevWindowMisses = 0;
|
|
788
|
+
this.currRoomHits = 0;
|
|
789
|
+
this.currRoomMisses = 0;
|
|
790
|
+
this.prevRoomHits = 0;
|
|
791
|
+
this.prevRoomMisses = 0;
|
|
771
792
|
this.processing = false;
|
|
772
793
|
this.direction = true;
|
|
773
794
|
this.initial = true;
|
|
774
795
|
this.back = 0;
|
|
775
796
|
this.advance = 0;
|
|
776
797
|
this.threshold *= 100;
|
|
798
|
+
this.resize(capacity, window, room, range);
|
|
799
|
+
}
|
|
800
|
+
replace(target) {
|
|
801
|
+
this.target = target;
|
|
802
|
+
}
|
|
803
|
+
resize(capacity, window, room, range) {
|
|
777
804
|
this.window = (0, alias_1.round)(capacity * window / 100) || 1;
|
|
805
|
+
this.room = (0, alias_1.round)(capacity * room / 100) || 1;
|
|
778
806
|
this.range = capacity * range / 100;
|
|
807
|
+
this.currWindowHits + this.currWindowMisses >= this.window && this.slideWindow();
|
|
808
|
+
this.currRoomHits + this.currRoomMisses >= this.room && this.slideRoom();
|
|
809
|
+
this.active = undefined;
|
|
779
810
|
}
|
|
780
|
-
|
|
781
|
-
this.
|
|
782
|
-
this.
|
|
783
|
-
this.
|
|
784
|
-
this.
|
|
811
|
+
clear() {
|
|
812
|
+
this.active = undefined;
|
|
813
|
+
this.processing = true;
|
|
814
|
+
this.reset();
|
|
815
|
+
this.slideWindow();
|
|
816
|
+
this.slideWindow();
|
|
817
|
+
this.slideRoom();
|
|
818
|
+
this.slideRoom();
|
|
819
|
+
}
|
|
820
|
+
slideWindow() {
|
|
821
|
+
this.prevWindowHits = this.currWindowHits;
|
|
822
|
+
this.prevWindowMisses = this.currWindowMisses;
|
|
823
|
+
this.currWindowHits = 0;
|
|
824
|
+
this.currWindowMisses = 0;
|
|
825
|
+
}
|
|
826
|
+
slideRoom() {
|
|
827
|
+
this.prevRoomHits = this.currRoomHits;
|
|
828
|
+
this.prevRoomMisses = this.currRoomMisses;
|
|
829
|
+
this.currRoomHits = 0;
|
|
830
|
+
this.currRoomMisses = 0;
|
|
785
831
|
}
|
|
786
832
|
hit() {
|
|
787
833
|
this.active = undefined;
|
|
788
|
-
++this.
|
|
834
|
+
++this.currWindowHits + this.currWindowMisses === this.window && this.slideWindow();
|
|
835
|
+
++this.currRoomHits + this.currRoomMisses === this.room && this.slideRoom();
|
|
789
836
|
this.processing && !this.isActive() && this.reset();
|
|
790
837
|
}
|
|
791
838
|
miss() {
|
|
792
839
|
this.active = undefined;
|
|
793
|
-
this.
|
|
840
|
+
this.currWindowHits + ++this.currWindowMisses === this.window && this.slideWindow();
|
|
841
|
+
this.currRoomHits + ++this.currRoomMisses === this.room && this.slideRoom();
|
|
794
842
|
}
|
|
795
843
|
isActive() {
|
|
796
|
-
if (this.
|
|
797
|
-
|
|
844
|
+
if (this.threshold === 0) return false;
|
|
845
|
+
if (this.prevWindowHits === 0 && this.prevWindowMisses === 0) return false;
|
|
846
|
+
return this.active ??= this.ratioWindow() < (0, alias_1.max)(this.ratioRoom() * this.ratio / 100, this.threshold);
|
|
798
847
|
}
|
|
799
|
-
|
|
800
|
-
return ratio(this.window, [this.
|
|
848
|
+
ratioWindow() {
|
|
849
|
+
return ratio(this.window, [this.currWindowHits, this.prevWindowHits], [this.currWindowMisses, this.prevWindowMisses], 0);
|
|
850
|
+
}
|
|
851
|
+
ratioRoom() {
|
|
852
|
+
return ratio(this.room, [this.currRoomHits, this.prevRoomHits], [this.currRoomMisses, this.prevRoomMisses], 0);
|
|
801
853
|
}
|
|
802
854
|
sweep() {
|
|
803
855
|
const {
|
|
@@ -844,22 +896,6 @@ class Sweeper {
|
|
|
844
896
|
this.back = 0;
|
|
845
897
|
this.advance = 0;
|
|
846
898
|
}
|
|
847
|
-
clear() {
|
|
848
|
-
this.active = undefined;
|
|
849
|
-
this.processing = true;
|
|
850
|
-
this.reset();
|
|
851
|
-
this.slide();
|
|
852
|
-
this.slide();
|
|
853
|
-
}
|
|
854
|
-
replace(target) {
|
|
855
|
-
this.target = target;
|
|
856
|
-
}
|
|
857
|
-
resize(capacity, window, range) {
|
|
858
|
-
this.window = (0, alias_1.round)(capacity * window / 100) || 1;
|
|
859
|
-
this.range = capacity * range / 100;
|
|
860
|
-
this.currHits + this.currMisses >= this.window && this.slide();
|
|
861
|
-
this.active = undefined;
|
|
862
|
-
}
|
|
863
899
|
}
|
|
864
900
|
function ratio(window, targets, remains, offset) {
|
|
865
901
|
const currHits = targets[0];
|
|
@@ -1395,7 +1431,7 @@ exports["default"] = global;
|
|
|
1395
1431
|
|
|
1396
1432
|
|
|
1397
1433
|
// @ts-ignore
|
|
1398
|
-
var global = globalThis;
|
|
1434
|
+
var global = (/* unused pure expression or super */ null && (globalThis));
|
|
1399
1435
|
|
|
1400
1436
|
/***/ }),
|
|
1401
1437
|
|
|
@@ -2860,7 +2896,7 @@ function fence(opener, limit, separation = true) {
|
|
|
2860
2896
|
const matches = source.match(opener);
|
|
2861
2897
|
if (!matches) return;
|
|
2862
2898
|
const delim = matches[1];
|
|
2863
|
-
if (matches[0].
|
|
2899
|
+
if (matches[0].includes(delim, delim.length)) return;
|
|
2864
2900
|
let rest = source.slice(matches[0].length);
|
|
2865
2901
|
// Prevent annoying parsing in editing.
|
|
2866
2902
|
if ((0, line_1.isBlank)((0, line_1.firstline)(rest)) && (0, line_1.firstline)(rest.slice((0, line_1.firstline)(rest).length)).trimEnd() !== delim) return;
|
|
@@ -6506,21 +6542,20 @@ const optspec = {
|
|
|
6506
6542
|
};
|
|
6507
6543
|
Object.setPrototypeOf(optspec, null);
|
|
6508
6544
|
exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.union)([exports.medialink, exports.textlink])));
|
|
6509
|
-
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
|
|
6510
|
-
|
|
6545
|
+
exports.textlink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */ | 8 /* State.media */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, visibility_1.trimBlankStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => {
|
|
6546
|
+
if (content.length !== 0 && (0, visibility_1.trimNodeEnd)(content = (0, dom_1.defrag)(content)).length === 0) return;
|
|
6547
|
+
return [[parse(content, params, context)], rest];
|
|
6511
6548
|
}))));
|
|
6512
|
-
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params,
|
|
6549
|
+
exports.medialink = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(16 /* State.link */ | 8 /* State.media */, false, (0, combinator_1.syntax)(16 /* Syntax.link */, 2, 10, 502 /* State.linkers */, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.sequence)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.union)([inline_1.media, inline_1.shortmedia]), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
|
|
6513
6550
|
exports.linemedialink = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.medialink]), /^(?=[^\S\n]*(?:$|\n))/);
|
|
6514
|
-
exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => parse(content, params,
|
|
6551
|
+
exports.unsafelink = (0, combinator_1.lazy)(() => (0, combinator_1.creation)(10, (0, combinator_1.precedence)(2, (0, combinator_1.bind)((0, combinator_1.reverse)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([source_1.unescsource]), ']'), ']')), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))])), ([params, content = []], rest, context) => [[parse((0, dom_1.defrag)(content), params, context)], rest]))));
|
|
6515
6552
|
exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, source_1.str)(/^\S+/)), (0, source_1.str)(/^[^\s{}]+/)]);
|
|
6516
6553
|
exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]), (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`])]);
|
|
6517
|
-
function parse(content, params,
|
|
6518
|
-
if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
|
|
6554
|
+
function parse(content, params, context) {
|
|
6519
6555
|
const INSECURE_URI = params.shift();
|
|
6520
6556
|
const uri = new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
|
|
6521
|
-
const el = elem(INSECURE_URI,
|
|
6522
|
-
|
|
6523
|
-
return [[(0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params))], rest];
|
|
6557
|
+
const el = elem(INSECURE_URI, content, uri, context.host?.origin || location.origin);
|
|
6558
|
+
return el.className === 'invalid' ? el : (0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params));
|
|
6524
6559
|
}
|
|
6525
6560
|
function elem(INSECURE_URI, content, uri, origin) {
|
|
6526
6561
|
let type;
|
|
@@ -6617,12 +6652,11 @@ const visibility_1 = __webpack_require__(7618);
|
|
|
6617
6652
|
const array_1 = __webpack_require__(8112);
|
|
6618
6653
|
const dom_1 = __webpack_require__(3252);
|
|
6619
6654
|
exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('==', '='), (0, combinator_1.constraint)(4 /* State.mark */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 1, 1, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('=='), [[/^\\?\n/, 9]]), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '=', [[/^\\?\n/, 9]]), exports.mark)]))))), (0, source_1.str)('=='), false, ([, bs], rest, {
|
|
6620
|
-
id
|
|
6621
|
-
state
|
|
6655
|
+
id
|
|
6622
6656
|
}) => {
|
|
6623
6657
|
const el = (0, dom_1.html)('mark', (0, dom_1.defrag)(bs));
|
|
6624
6658
|
return [[(0, dom_1.define)(el, {
|
|
6625
|
-
id:
|
|
6659
|
+
id: (0, indexee_1.identity)(id, (0, indexee_1.signature)(el), 'mark')
|
|
6626
6660
|
}), el.id && (0, dom_1.html)('a', {
|
|
6627
6661
|
href: `#${el.id}`
|
|
6628
6662
|
})], rest];
|
|
@@ -6871,7 +6905,7 @@ function attributes(texts, rubies) {
|
|
|
6871
6905
|
let attrs;
|
|
6872
6906
|
for (const ss of [texts, rubies]) {
|
|
6873
6907
|
for (let i = 0; i < ss.length; ++i) {
|
|
6874
|
-
if (ss[i].
|
|
6908
|
+
if (!ss[i].includes('\x1B')) continue;
|
|
6875
6909
|
ss[i] = ss[i].replace(/\x1B/g, '');
|
|
6876
6910
|
attrs ??= {
|
|
6877
6911
|
class: 'invalid',
|
|
@@ -7096,6 +7130,7 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
7096
7130
|
exports.reference = exports.annotation = exports.note = void 0;
|
|
7097
7131
|
const indexee_1 = __webpack_require__(1269);
|
|
7098
7132
|
const util_1 = __webpack_require__(9437);
|
|
7133
|
+
const memoize_1 = __webpack_require__(1808);
|
|
7099
7134
|
const dom_1 = __webpack_require__(3252);
|
|
7100
7135
|
function* note(target, notes, opts = {}, bottom = null) {
|
|
7101
7136
|
for (let es = target.querySelectorAll(`.annotations`), len = es.length, i = 0; i < len; ++i) {
|
|
@@ -7112,6 +7147,18 @@ exports.reference = build('reference', (n, abbr) => `[${abbr || n}]`);
|
|
|
7112
7147
|
function build(syntax, marker, splitter = '') {
|
|
7113
7148
|
// Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
|
|
7114
7149
|
// 構文ごとに各1回の処理では不可能
|
|
7150
|
+
const memory = (0, memoize_1.memoize)(ref => {
|
|
7151
|
+
const content = ref.firstElementChild;
|
|
7152
|
+
content.replaceWith(content.cloneNode());
|
|
7153
|
+
const abbr = ref.getAttribute('data-abbr') ?? '';
|
|
7154
|
+
const identifier = abbr ? (0, indexee_1.identity)(undefined, abbr.match(/^(?:\S+ )+?(?:(?:January|February|March|April|May|June|August|September|October|November|December) \d{1,2}(?:-\d{0,2})?, \d{1,4}(?:-\d{0,4})?[a-z]?|n\.d\.)(?=,|$)/)?.[0] ?? abbr.match(/^[^,\s]+(?:,? [^,\s]+)*?(?: \d{1,4}(?:-\d{0,4})?[a-z]?(?=,|$)|(?=,(?: [a-z]+\.?)? [0-9]))/)?.[0] ?? abbr, '')?.slice(2) || '' : (0, indexee_1.identity)(undefined, (0, indexee_1.signature)(content), 'mark')?.slice(6) || '';
|
|
7155
|
+
return {
|
|
7156
|
+
content,
|
|
7157
|
+
identifier,
|
|
7158
|
+
abbr,
|
|
7159
|
+
text: (0, indexee_1.text)(content).trim()
|
|
7160
|
+
};
|
|
7161
|
+
}, new WeakMap());
|
|
7115
7162
|
return function* (target, note, opts = {}, bottom = null) {
|
|
7116
7163
|
const defs = new Map();
|
|
7117
7164
|
const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
|
|
@@ -7126,7 +7173,7 @@ function build(syntax, marker, splitter = '') {
|
|
|
7126
7173
|
let refIndex = 0;
|
|
7127
7174
|
for (let len = refs.length, i = 0; i < len; ++i) {
|
|
7128
7175
|
const ref = refs[i];
|
|
7129
|
-
if (
|
|
7176
|
+
if (!target.contains(ref)) {
|
|
7130
7177
|
yield;
|
|
7131
7178
|
continue;
|
|
7132
7179
|
}
|
|
@@ -7141,8 +7188,12 @@ function build(syntax, marker, splitter = '') {
|
|
|
7141
7188
|
yield;
|
|
7142
7189
|
}
|
|
7143
7190
|
}
|
|
7144
|
-
const
|
|
7145
|
-
|
|
7191
|
+
const {
|
|
7192
|
+
content,
|
|
7193
|
+
identifier,
|
|
7194
|
+
abbr,
|
|
7195
|
+
text
|
|
7196
|
+
} = memory(ref);
|
|
7146
7197
|
const refSubindex = refSubindexes.get(identifier) + 1 || 1;
|
|
7147
7198
|
refSubindexes.set(identifier, refSubindex);
|
|
7148
7199
|
const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${identifier}:${refSubindex}` : undefined;
|
|
@@ -7153,15 +7204,13 @@ function build(syntax, marker, splitter = '') {
|
|
|
7153
7204
|
const def = initial ? (0, dom_1.html)('li', {
|
|
7154
7205
|
id: defId,
|
|
7155
7206
|
'data-marker': note ? undefined : marker(total + defs.size + 1, abbr)
|
|
7156
|
-
}, [(0, dom_1.
|
|
7157
|
-
hidden: null
|
|
7158
|
-
}), (0, dom_1.html)('sup')]) : defs.get(identifier);
|
|
7207
|
+
}, [content.cloneNode(true), (0, dom_1.html)('sup')]) : defs.get(identifier);
|
|
7159
7208
|
initial && defs.set(identifier, def);
|
|
7160
7209
|
const defIndex = initial ? total + defs.size : defIndexes.get(def);
|
|
7161
7210
|
initial && defIndexes.set(def, defIndex);
|
|
7162
|
-
const title = initial ?
|
|
7211
|
+
const title = initial ? text : titles.get(identifier);
|
|
7163
7212
|
initial && titles.set(identifier, title);
|
|
7164
|
-
ref.
|
|
7213
|
+
ref.childElementCount > 1 && ref.lastElementChild.remove();
|
|
7165
7214
|
(0, dom_1.define)(ref, {
|
|
7166
7215
|
id: refId,
|
|
7167
7216
|
class: opts.id !== '' ? undefined : void ref.classList.add('disabled'),
|
|
@@ -7186,7 +7235,7 @@ function build(syntax, marker, splitter = '') {
|
|
|
7186
7235
|
}, marker(defIndex, abbr)));
|
|
7187
7236
|
def.lastElementChild.appendChild((0, dom_1.html)('a', {
|
|
7188
7237
|
href: refId && `#${refId}`,
|
|
7189
|
-
title: abbr &&
|
|
7238
|
+
title: abbr && text || undefined
|
|
7190
7239
|
}, `^${++refIndex}`));
|
|
7191
7240
|
}
|
|
7192
7241
|
if (note || defs.size > 0) {
|
|
@@ -7629,7 +7678,7 @@ exports.stringify = stringify;
|
|
|
7629
7678
|
Object.defineProperty(exports, "__esModule", ({
|
|
7630
7679
|
value: true
|
|
7631
7680
|
}));
|
|
7632
|
-
exports.trimNodeEnd = exports.
|
|
7681
|
+
exports.trimNodeEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.blankWith = exports.visualize = exports.blank = void 0;
|
|
7633
7682
|
const parser_1 = __webpack_require__(6728);
|
|
7634
7683
|
const combinator_1 = __webpack_require__(2087);
|
|
7635
7684
|
const htmlentity_1 = __webpack_require__(1562);
|
|
@@ -7757,24 +7806,23 @@ exports.trimBlankStart = trimBlankStart;
|
|
|
7757
7806
|
function trimBlankEnd(parser) {
|
|
7758
7807
|
return (0, combinator_1.fmap)(parser, trimNodeEnd);
|
|
7759
7808
|
}
|
|
7760
|
-
function trimNode(nodes) {
|
|
7761
|
-
return trimNodeStart(trimNodeEnd(nodes));
|
|
7762
|
-
}
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
if (
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
}
|
|
7809
|
+
//export function trimNode<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
7810
|
+
// return trimNodeStart(trimNodeEnd(nodes));
|
|
7811
|
+
//}
|
|
7812
|
+
//function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
|
|
7813
|
+
// for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[0], 0);) {
|
|
7814
|
+
// if (nodes.length === 1 && typeof node === 'object' && node.className === 'indexer') break;
|
|
7815
|
+
// if (typeof node === 'string') {
|
|
7816
|
+
// const pos = node.trimStart().length;
|
|
7817
|
+
// if (pos > 0) {
|
|
7818
|
+
// nodes[0] = node.slice(-pos) as T;
|
|
7819
|
+
// break;
|
|
7820
|
+
// }
|
|
7821
|
+
// }
|
|
7822
|
+
// nodes.shift();
|
|
7823
|
+
// }
|
|
7824
|
+
// return nodes;
|
|
7825
|
+
//}
|
|
7778
7826
|
function trimNodeEnd(nodes) {
|
|
7779
7827
|
const skip = nodes.length > 0 && typeof nodes[nodes.length - 1] === 'object' && nodes[nodes.length - 1]['className'] === 'indexer' ? [nodes.pop()] : [];
|
|
7780
7828
|
for (let node = nodes[0]; nodes.length > 0 && !isVisible(node = nodes[nodes.length - 1], -1);) {
|
|
@@ -8433,7 +8481,7 @@ function unlink(h) {
|
|
|
8433
8481
|
/***/ 3252:
|
|
8434
8482
|
/***/ (function(module) {
|
|
8435
8483
|
|
|
8436
|
-
/*! typed-dom v0.0.
|
|
8484
|
+
/*! typed-dom v0.0.335 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
|
|
8437
8485
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
8438
8486
|
if(true)
|
|
8439
8487
|
module.exports = factory();
|
|
@@ -8710,15 +8758,14 @@ exports.prepend = prepend;
|
|
|
8710
8758
|
function defrag(nodes) {
|
|
8711
8759
|
const acc = [];
|
|
8712
8760
|
let appendable = false;
|
|
8713
|
-
for (let i = 0
|
|
8761
|
+
for (let i = 0, len = nodes.length; i < len; ++i) {
|
|
8714
8762
|
const node = nodes[i];
|
|
8715
|
-
if (node === '')
|
|
8716
|
-
if (typeof node === 'string') {
|
|
8717
|
-
appendable ? acc[acc.length - 1] += node : acc.push(node);
|
|
8718
|
-
appendable = true;
|
|
8719
|
-
} else {
|
|
8763
|
+
if (typeof node === 'object') {
|
|
8720
8764
|
acc.push(node);
|
|
8721
8765
|
appendable = false;
|
|
8766
|
+
} else if (node !== '') {
|
|
8767
|
+
appendable ? acc[acc.length - 1] += node : acc.push(node);
|
|
8768
|
+
appendable = true;
|
|
8722
8769
|
}
|
|
8723
8770
|
}
|
|
8724
8771
|
return acc;
|
|
@@ -8733,7 +8780,7 @@ exports.defrag = defrag;
|
|
|
8733
8780
|
/******/ var __webpack_module_cache__ = {};
|
|
8734
8781
|
/******/
|
|
8735
8782
|
/******/ // The require function
|
|
8736
|
-
/******/ function
|
|
8783
|
+
/******/ function __nested_webpack_require_11654__(moduleId) {
|
|
8737
8784
|
/******/ // Check if module is in cache
|
|
8738
8785
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
8739
8786
|
/******/ if (cachedModule !== undefined) {
|
|
@@ -8747,7 +8794,7 @@ exports.defrag = defrag;
|
|
|
8747
8794
|
/******/ };
|
|
8748
8795
|
/******/
|
|
8749
8796
|
/******/ // Execute the module function
|
|
8750
|
-
/******/ __webpack_modules__[moduleId](module, module.exports,
|
|
8797
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_11654__);
|
|
8751
8798
|
/******/
|
|
8752
8799
|
/******/ // Return the exports of the module
|
|
8753
8800
|
/******/ return module.exports;
|
|
@@ -8758,7 +8805,7 @@ exports.defrag = defrag;
|
|
|
8758
8805
|
/******/ // startup
|
|
8759
8806
|
/******/ // Load entry module and return exports
|
|
8760
8807
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
8761
|
-
/******/ var __nested_webpack_exports__ =
|
|
8808
|
+
/******/ var __nested_webpack_exports__ = __nested_webpack_require_11654__(7521);
|
|
8762
8809
|
/******/
|
|
8763
8810
|
/******/ return __nested_webpack_exports__;
|
|
8764
8811
|
/******/ })()
|
|
@@ -8770,7 +8817,7 @@ exports.defrag = defrag;
|
|
|
8770
8817
|
/***/ 6120:
|
|
8771
8818
|
/***/ (function(module) {
|
|
8772
8819
|
|
|
8773
|
-
/*! typed-dom v0.0.
|
|
8820
|
+
/*! typed-dom v0.0.335 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
|
|
8774
8821
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
8775
8822
|
if(true)
|
|
8776
8823
|
module.exports = factory();
|