typespec-vscode 0.57.0-dev.1 → 0.57.0-dev.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.
@@ -10,10 +10,8 @@ granted herein, whether by implication, estoppel or otherwise.
10
10
 
11
11
  1. balanced-match version 1.0.2 (https://github.com/juliangruber/balanced-match)
12
12
  2. brace-expansion version 2.0.1 (https://github.com/juliangruber/brace-expansion)
13
- 3. lru-cache version 6.0.0 (https://github.com/isaacs/node-lru-cache)
14
- 4. minimatch version 5.1.6 (https://github.com/isaacs/minimatch)
15
- 5. semver version 7.6.0 (https://github.com/npm/node-semver)
16
- 6. yallist version 4.0.0 (https://github.com/isaacs/yallist)
13
+ 3. minimatch version 5.1.6 (https://github.com/isaacs/minimatch)
14
+ 4. semver version 7.6.2 (https://github.com/npm/node-semver)
17
15
 
18
16
 
19
17
  %% balanced-match NOTICES AND INFORMATION BEGIN HERE
@@ -72,28 +70,6 @@ SOFTWARE.
72
70
  END OF brace-expansion NOTICES AND INFORMATION
73
71
 
74
72
 
75
- %% lru-cache NOTICES AND INFORMATION BEGIN HERE
76
- =====================================================
77
- The ISC License
78
-
79
- Copyright (c) Isaac Z. Schlueter and Contributors
80
-
81
- Permission to use, copy, modify, and/or distribute this software for any
82
- purpose with or without fee is hereby granted, provided that the above
83
- copyright notice and this permission notice appear in all copies.
84
-
85
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
86
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
87
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
88
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
89
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
90
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
91
- IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
92
-
93
- =====================================================");
94
- END OF lru-cache NOTICES AND INFORMATION
95
-
96
-
97
73
  %% minimatch NOTICES AND INFORMATION BEGIN HERE
98
74
  =====================================================
99
75
  The ISC License
@@ -135,26 +111,4 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
135
111
  IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
136
112
 
137
113
  =====================================================");
138
- END OF semver NOTICES AND INFORMATION
139
-
140
-
141
- %% yallist NOTICES AND INFORMATION BEGIN HERE
142
- =====================================================
143
- The ISC License
144
-
145
- Copyright (c) Isaac Z. Schlueter and Contributors
146
-
147
- Permission to use, copy, modify, and/or distribute this software for any
148
- purpose with or without fee is hereby granted, provided that the above
149
- copyright notice and this permission notice appear in all copies.
150
-
151
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
152
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
153
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
154
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
155
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
156
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
157
- IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158
-
159
- =====================================================");
160
- END OF yallist NOTICES AND INFORMATION
114
+ END OF semver NOTICES AND INFORMATION
@@ -19440,7 +19440,7 @@ let SemVer$2 = class SemVer {
19440
19440
  do {
19441
19441
  const a = this.build[i];
19442
19442
  const b = other.build[i];
19443
- debug('prerelease compare', i, a, b);
19443
+ debug('build compare', i, a, b);
19444
19444
  if (a === undefined && b === undefined) {
19445
19445
  return 0
19446
19446
  } else if (b === undefined) {
@@ -19600,780 +19600,46 @@ const parse = (version, options, throwErrors = false) => {
19600
19600
 
19601
19601
  var parse_1 = parse;
19602
19602
 
19603
- var iterator;
19604
- var hasRequiredIterator;
19605
-
19606
- function requireIterator () {
19607
- if (hasRequiredIterator) return iterator;
19608
- hasRequiredIterator = 1;
19609
- iterator = function (Yallist) {
19610
- Yallist.prototype[Symbol.iterator] = function* () {
19611
- for (let walker = this.head; walker; walker = walker.next) {
19612
- yield walker.value;
19613
- }
19614
- };
19615
- };
19616
- return iterator;
19617
- }
19618
-
19619
- var yallist = Yallist$1;
19620
-
19621
- Yallist$1.Node = Node;
19622
- Yallist$1.create = Yallist$1;
19623
-
19624
- function Yallist$1 (list) {
19625
- var self = this;
19626
- if (!(self instanceof Yallist$1)) {
19627
- self = new Yallist$1();
19628
- }
19629
-
19630
- self.tail = null;
19631
- self.head = null;
19632
- self.length = 0;
19633
-
19634
- if (list && typeof list.forEach === 'function') {
19635
- list.forEach(function (item) {
19636
- self.push(item);
19637
- });
19638
- } else if (arguments.length > 0) {
19639
- for (var i = 0, l = arguments.length; i < l; i++) {
19640
- self.push(arguments[i]);
19641
- }
19642
- }
19643
-
19644
- return self
19645
- }
19646
-
19647
- Yallist$1.prototype.removeNode = function (node) {
19648
- if (node.list !== this) {
19649
- throw new Error('removing node which does not belong to this list')
19650
- }
19651
-
19652
- var next = node.next;
19653
- var prev = node.prev;
19654
-
19655
- if (next) {
19656
- next.prev = prev;
19657
- }
19658
-
19659
- if (prev) {
19660
- prev.next = next;
19661
- }
19662
-
19663
- if (node === this.head) {
19664
- this.head = next;
19665
- }
19666
- if (node === this.tail) {
19667
- this.tail = prev;
19668
- }
19669
-
19670
- node.list.length--;
19671
- node.next = null;
19672
- node.prev = null;
19673
- node.list = null;
19674
-
19675
- return next
19676
- };
19677
-
19678
- Yallist$1.prototype.unshiftNode = function (node) {
19679
- if (node === this.head) {
19680
- return
19681
- }
19682
-
19683
- if (node.list) {
19684
- node.list.removeNode(node);
19685
- }
19686
-
19687
- var head = this.head;
19688
- node.list = this;
19689
- node.next = head;
19690
- if (head) {
19691
- head.prev = node;
19692
- }
19693
-
19694
- this.head = node;
19695
- if (!this.tail) {
19696
- this.tail = node;
19697
- }
19698
- this.length++;
19699
- };
19700
-
19701
- Yallist$1.prototype.pushNode = function (node) {
19702
- if (node === this.tail) {
19703
- return
19704
- }
19705
-
19706
- if (node.list) {
19707
- node.list.removeNode(node);
19708
- }
19709
-
19710
- var tail = this.tail;
19711
- node.list = this;
19712
- node.prev = tail;
19713
- if (tail) {
19714
- tail.next = node;
19715
- }
19716
-
19717
- this.tail = node;
19718
- if (!this.head) {
19719
- this.head = node;
19720
- }
19721
- this.length++;
19722
- };
19723
-
19724
- Yallist$1.prototype.push = function () {
19725
- for (var i = 0, l = arguments.length; i < l; i++) {
19726
- push(this, arguments[i]);
19727
- }
19728
- return this.length
19729
- };
19730
-
19731
- Yallist$1.prototype.unshift = function () {
19732
- for (var i = 0, l = arguments.length; i < l; i++) {
19733
- unshift(this, arguments[i]);
19734
- }
19735
- return this.length
19736
- };
19737
-
19738
- Yallist$1.prototype.pop = function () {
19739
- if (!this.tail) {
19740
- return undefined
19741
- }
19742
-
19743
- var res = this.tail.value;
19744
- this.tail = this.tail.prev;
19745
- if (this.tail) {
19746
- this.tail.next = null;
19747
- } else {
19748
- this.head = null;
19749
- }
19750
- this.length--;
19751
- return res
19752
- };
19753
-
19754
- Yallist$1.prototype.shift = function () {
19755
- if (!this.head) {
19756
- return undefined
19757
- }
19758
-
19759
- var res = this.head.value;
19760
- this.head = this.head.next;
19761
- if (this.head) {
19762
- this.head.prev = null;
19763
- } else {
19764
- this.tail = null;
19765
- }
19766
- this.length--;
19767
- return res
19768
- };
19769
-
19770
- Yallist$1.prototype.forEach = function (fn, thisp) {
19771
- thisp = thisp || this;
19772
- for (var walker = this.head, i = 0; walker !== null; i++) {
19773
- fn.call(thisp, walker.value, i, this);
19774
- walker = walker.next;
19775
- }
19776
- };
19777
-
19778
- Yallist$1.prototype.forEachReverse = function (fn, thisp) {
19779
- thisp = thisp || this;
19780
- for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
19781
- fn.call(thisp, walker.value, i, this);
19782
- walker = walker.prev;
19783
- }
19784
- };
19785
-
19786
- Yallist$1.prototype.get = function (n) {
19787
- for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
19788
- // abort out of the list early if we hit a cycle
19789
- walker = walker.next;
19790
- }
19791
- if (i === n && walker !== null) {
19792
- return walker.value
19793
- }
19794
- };
19795
-
19796
- Yallist$1.prototype.getReverse = function (n) {
19797
- for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
19798
- // abort out of the list early if we hit a cycle
19799
- walker = walker.prev;
19800
- }
19801
- if (i === n && walker !== null) {
19802
- return walker.value
19803
- }
19804
- };
19805
-
19806
- Yallist$1.prototype.map = function (fn, thisp) {
19807
- thisp = thisp || this;
19808
- var res = new Yallist$1();
19809
- for (var walker = this.head; walker !== null;) {
19810
- res.push(fn.call(thisp, walker.value, this));
19811
- walker = walker.next;
19812
- }
19813
- return res
19814
- };
19815
-
19816
- Yallist$1.prototype.mapReverse = function (fn, thisp) {
19817
- thisp = thisp || this;
19818
- var res = new Yallist$1();
19819
- for (var walker = this.tail; walker !== null;) {
19820
- res.push(fn.call(thisp, walker.value, this));
19821
- walker = walker.prev;
19822
- }
19823
- return res
19824
- };
19825
-
19826
- Yallist$1.prototype.reduce = function (fn, initial) {
19827
- var acc;
19828
- var walker = this.head;
19829
- if (arguments.length > 1) {
19830
- acc = initial;
19831
- } else if (this.head) {
19832
- walker = this.head.next;
19833
- acc = this.head.value;
19834
- } else {
19835
- throw new TypeError('Reduce of empty list with no initial value')
19836
- }
19837
-
19838
- for (var i = 0; walker !== null; i++) {
19839
- acc = fn(acc, walker.value, i);
19840
- walker = walker.next;
19841
- }
19842
-
19843
- return acc
19844
- };
19845
-
19846
- Yallist$1.prototype.reduceReverse = function (fn, initial) {
19847
- var acc;
19848
- var walker = this.tail;
19849
- if (arguments.length > 1) {
19850
- acc = initial;
19851
- } else if (this.tail) {
19852
- walker = this.tail.prev;
19853
- acc = this.tail.value;
19854
- } else {
19855
- throw new TypeError('Reduce of empty list with no initial value')
19856
- }
19857
-
19858
- for (var i = this.length - 1; walker !== null; i--) {
19859
- acc = fn(acc, walker.value, i);
19860
- walker = walker.prev;
19861
- }
19862
-
19863
- return acc
19864
- };
19865
-
19866
- Yallist$1.prototype.toArray = function () {
19867
- var arr = new Array(this.length);
19868
- for (var i = 0, walker = this.head; walker !== null; i++) {
19869
- arr[i] = walker.value;
19870
- walker = walker.next;
19871
- }
19872
- return arr
19873
- };
19874
-
19875
- Yallist$1.prototype.toArrayReverse = function () {
19876
- var arr = new Array(this.length);
19877
- for (var i = 0, walker = this.tail; walker !== null; i++) {
19878
- arr[i] = walker.value;
19879
- walker = walker.prev;
19880
- }
19881
- return arr
19882
- };
19883
-
19884
- Yallist$1.prototype.slice = function (from, to) {
19885
- to = to || this.length;
19886
- if (to < 0) {
19887
- to += this.length;
19888
- }
19889
- from = from || 0;
19890
- if (from < 0) {
19891
- from += this.length;
19892
- }
19893
- var ret = new Yallist$1();
19894
- if (to < from || to < 0) {
19895
- return ret
19896
- }
19897
- if (from < 0) {
19898
- from = 0;
19899
- }
19900
- if (to > this.length) {
19901
- to = this.length;
19902
- }
19903
- for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
19904
- walker = walker.next;
19905
- }
19906
- for (; walker !== null && i < to; i++, walker = walker.next) {
19907
- ret.push(walker.value);
19908
- }
19909
- return ret
19910
- };
19911
-
19912
- Yallist$1.prototype.sliceReverse = function (from, to) {
19913
- to = to || this.length;
19914
- if (to < 0) {
19915
- to += this.length;
19916
- }
19917
- from = from || 0;
19918
- if (from < 0) {
19919
- from += this.length;
19920
- }
19921
- var ret = new Yallist$1();
19922
- if (to < from || to < 0) {
19923
- return ret
19924
- }
19925
- if (from < 0) {
19926
- from = 0;
19927
- }
19928
- if (to > this.length) {
19929
- to = this.length;
19930
- }
19931
- for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
19932
- walker = walker.prev;
19933
- }
19934
- for (; walker !== null && i > from; i--, walker = walker.prev) {
19935
- ret.push(walker.value);
19936
- }
19937
- return ret
19938
- };
19939
-
19940
- Yallist$1.prototype.splice = function (start, deleteCount, ...nodes) {
19941
- if (start > this.length) {
19942
- start = this.length - 1;
19943
- }
19944
- if (start < 0) {
19945
- start = this.length + start;
19946
- }
19947
-
19948
- for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
19949
- walker = walker.next;
19950
- }
19951
-
19952
- var ret = [];
19953
- for (var i = 0; walker && i < deleteCount; i++) {
19954
- ret.push(walker.value);
19955
- walker = this.removeNode(walker);
19956
- }
19957
- if (walker === null) {
19958
- walker = this.tail;
19959
- }
19960
-
19961
- if (walker !== this.head && walker !== this.tail) {
19962
- walker = walker.prev;
19963
- }
19964
-
19965
- for (var i = 0; i < nodes.length; i++) {
19966
- walker = insert(this, walker, nodes[i]);
19967
- }
19968
- return ret;
19969
- };
19970
-
19971
- Yallist$1.prototype.reverse = function () {
19972
- var head = this.head;
19973
- var tail = this.tail;
19974
- for (var walker = head; walker !== null; walker = walker.prev) {
19975
- var p = walker.prev;
19976
- walker.prev = walker.next;
19977
- walker.next = p;
19978
- }
19979
- this.head = tail;
19980
- this.tail = head;
19981
- return this
19982
- };
19983
-
19984
- function insert (self, node, value) {
19985
- var inserted = node === self.head ?
19986
- new Node(value, null, node, self) :
19987
- new Node(value, node, node.next, self);
19988
-
19989
- if (inserted.next === null) {
19990
- self.tail = inserted;
19991
- }
19992
- if (inserted.prev === null) {
19993
- self.head = inserted;
19994
- }
19995
-
19996
- self.length++;
19997
-
19998
- return inserted
19999
- }
20000
-
20001
- function push (self, item) {
20002
- self.tail = new Node(item, self.tail, null, self);
20003
- if (!self.head) {
20004
- self.head = self.tail;
20005
- }
20006
- self.length++;
20007
- }
20008
-
20009
- function unshift (self, item) {
20010
- self.head = new Node(item, null, self.head, self);
20011
- if (!self.tail) {
20012
- self.tail = self.head;
20013
- }
20014
- self.length++;
20015
- }
20016
-
20017
- function Node (value, prev, next, list) {
20018
- if (!(this instanceof Node)) {
20019
- return new Node(value, prev, next, list)
20020
- }
20021
-
20022
- this.list = list;
20023
- this.value = value;
20024
-
20025
- if (prev) {
20026
- prev.next = this;
20027
- this.prev = prev;
20028
- } else {
20029
- this.prev = null;
20030
- }
20031
-
20032
- if (next) {
20033
- next.prev = this;
20034
- this.next = next;
20035
- } else {
20036
- this.next = null;
20037
- }
20038
- }
20039
-
20040
- try {
20041
- // add if support for Symbol.iterator is present
20042
- requireIterator()(Yallist$1);
20043
- } catch (er) {}
20044
-
20045
- // A linked list to keep track of recently-used-ness
20046
- const Yallist = yallist;
20047
-
20048
- const MAX = Symbol('max');
20049
- const LENGTH = Symbol('length');
20050
- const LENGTH_CALCULATOR = Symbol('lengthCalculator');
20051
- const ALLOW_STALE = Symbol('allowStale');
20052
- const MAX_AGE = Symbol('maxAge');
20053
- const DISPOSE = Symbol('dispose');
20054
- const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
20055
- const LRU_LIST = Symbol('lruList');
20056
- const CACHE = Symbol('cache');
20057
- const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
20058
-
20059
- const naiveLength = () => 1;
20060
-
20061
- // lruList is a yallist where the head is the youngest
20062
- // item, and the tail is the oldest. the list contains the Hit
20063
- // objects as the entries.
20064
- // Each Hit object has a reference to its Yallist.Node. This
20065
- // never changes.
20066
- //
20067
- // cache is a Map (or PseudoMap) that matches the keys to
20068
- // the Yallist.Node object.
20069
19603
  class LRUCache {
20070
- constructor (options) {
20071
- if (typeof options === 'number')
20072
- options = { max: options };
20073
-
20074
- if (!options)
20075
- options = {};
20076
-
20077
- if (options.max && (typeof options.max !== 'number' || options.max < 0))
20078
- throw new TypeError('max must be a non-negative number')
20079
- // Kind of weird to have a default max of Infinity, but oh well.
20080
- this[MAX] = options.max || Infinity;
20081
-
20082
- const lc = options.length || naiveLength;
20083
- this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
20084
- this[ALLOW_STALE] = options.stale || false;
20085
- if (options.maxAge && typeof options.maxAge !== 'number')
20086
- throw new TypeError('maxAge must be a number')
20087
- this[MAX_AGE] = options.maxAge || 0;
20088
- this[DISPOSE] = options.dispose;
20089
- this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
20090
- this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
20091
- this.reset();
20092
- }
20093
-
20094
- // resize the cache when the max changes.
20095
- set max (mL) {
20096
- if (typeof mL !== 'number' || mL < 0)
20097
- throw new TypeError('max must be a non-negative number')
20098
-
20099
- this[MAX] = mL || Infinity;
20100
- trim(this);
20101
- }
20102
- get max () {
20103
- return this[MAX]
20104
- }
20105
-
20106
- set allowStale (allowStale) {
20107
- this[ALLOW_STALE] = !!allowStale;
20108
- }
20109
- get allowStale () {
20110
- return this[ALLOW_STALE]
20111
- }
20112
-
20113
- set maxAge (mA) {
20114
- if (typeof mA !== 'number')
20115
- throw new TypeError('maxAge must be a non-negative number')
20116
-
20117
- this[MAX_AGE] = mA;
20118
- trim(this);
20119
- }
20120
- get maxAge () {
20121
- return this[MAX_AGE]
20122
- }
20123
-
20124
- // resize the cache when the lengthCalculator changes.
20125
- set lengthCalculator (lC) {
20126
- if (typeof lC !== 'function')
20127
- lC = naiveLength;
20128
-
20129
- if (lC !== this[LENGTH_CALCULATOR]) {
20130
- this[LENGTH_CALCULATOR] = lC;
20131
- this[LENGTH] = 0;
20132
- this[LRU_LIST].forEach(hit => {
20133
- hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
20134
- this[LENGTH] += hit.length;
20135
- });
20136
- }
20137
- trim(this);
20138
- }
20139
- get lengthCalculator () { return this[LENGTH_CALCULATOR] }
20140
-
20141
- get length () { return this[LENGTH] }
20142
- get itemCount () { return this[LRU_LIST].length }
20143
-
20144
- rforEach (fn, thisp) {
20145
- thisp = thisp || this;
20146
- for (let walker = this[LRU_LIST].tail; walker !== null;) {
20147
- const prev = walker.prev;
20148
- forEachStep(this, fn, walker, thisp);
20149
- walker = prev;
20150
- }
20151
- }
20152
-
20153
- forEach (fn, thisp) {
20154
- thisp = thisp || this;
20155
- for (let walker = this[LRU_LIST].head; walker !== null;) {
20156
- const next = walker.next;
20157
- forEachStep(this, fn, walker, thisp);
20158
- walker = next;
20159
- }
20160
- }
20161
-
20162
- keys () {
20163
- return this[LRU_LIST].toArray().map(k => k.key)
20164
- }
20165
-
20166
- values () {
20167
- return this[LRU_LIST].toArray().map(k => k.value)
20168
- }
20169
-
20170
- reset () {
20171
- if (this[DISPOSE] &&
20172
- this[LRU_LIST] &&
20173
- this[LRU_LIST].length) {
20174
- this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
20175
- }
20176
-
20177
- this[CACHE] = new Map(); // hash of items by key
20178
- this[LRU_LIST] = new Yallist(); // list of items in order of use recency
20179
- this[LENGTH] = 0; // length of items in the list
20180
- }
20181
-
20182
- dump () {
20183
- return this[LRU_LIST].map(hit =>
20184
- isStale(this, hit) ? false : {
20185
- k: hit.key,
20186
- v: hit.value,
20187
- e: hit.now + (hit.maxAge || 0)
20188
- }).toArray().filter(h => h)
20189
- }
20190
-
20191
- dumpLru () {
20192
- return this[LRU_LIST]
20193
- }
20194
-
20195
- set (key, value, maxAge) {
20196
- maxAge = maxAge || this[MAX_AGE];
20197
-
20198
- if (maxAge && typeof maxAge !== 'number')
20199
- throw new TypeError('maxAge must be a number')
20200
-
20201
- const now = maxAge ? Date.now() : 0;
20202
- const len = this[LENGTH_CALCULATOR](value, key);
20203
-
20204
- if (this[CACHE].has(key)) {
20205
- if (len > this[MAX]) {
20206
- del(this, this[CACHE].get(key));
20207
- return false
20208
- }
20209
-
20210
- const node = this[CACHE].get(key);
20211
- const item = node.value;
20212
-
20213
- // dispose of the old one before overwriting
20214
- // split out into 2 ifs for better coverage tracking
20215
- if (this[DISPOSE]) {
20216
- if (!this[NO_DISPOSE_ON_SET])
20217
- this[DISPOSE](key, item.value);
20218
- }
20219
-
20220
- item.now = now;
20221
- item.maxAge = maxAge;
20222
- item.value = value;
20223
- this[LENGTH] += len - item.length;
20224
- item.length = len;
20225
- this.get(key);
20226
- trim(this);
20227
- return true
20228
- }
20229
-
20230
- const hit = new Entry(key, value, len, now, maxAge);
20231
-
20232
- // oversized objects fall out of cache automatically.
20233
- if (hit.length > this[MAX]) {
20234
- if (this[DISPOSE])
20235
- this[DISPOSE](key, value);
20236
-
20237
- return false
20238
- }
20239
-
20240
- this[LENGTH] += hit.length;
20241
- this[LRU_LIST].unshift(hit);
20242
- this[CACHE].set(key, this[LRU_LIST].head);
20243
- trim(this);
20244
- return true
20245
- }
20246
-
20247
- has (key) {
20248
- if (!this[CACHE].has(key)) return false
20249
- const hit = this[CACHE].get(key).value;
20250
- return !isStale(this, hit)
19604
+ constructor () {
19605
+ this.max = 1000;
19606
+ this.map = new Map();
20251
19607
  }
20252
19608
 
20253
19609
  get (key) {
20254
- return get(this, key, true)
20255
- }
20256
-
20257
- peek (key) {
20258
- return get(this, key, false)
20259
- }
20260
-
20261
- pop () {
20262
- const node = this[LRU_LIST].tail;
20263
- if (!node)
20264
- return null
20265
-
20266
- del(this, node);
20267
- return node.value
20268
- }
20269
-
20270
- del (key) {
20271
- del(this, this[CACHE].get(key));
20272
- }
20273
-
20274
- load (arr) {
20275
- // reset the cache
20276
- this.reset();
20277
-
20278
- const now = Date.now();
20279
- // A previous serialized cache has the most recent items first
20280
- for (let l = arr.length - 1; l >= 0; l--) {
20281
- const hit = arr[l];
20282
- const expiresAt = hit.e || 0;
20283
- if (expiresAt === 0)
20284
- // the item was created without expiration in a non aged cache
20285
- this.set(hit.k, hit.v);
20286
- else {
20287
- const maxAge = expiresAt - now;
20288
- // dont add already expired items
20289
- if (maxAge > 0) {
20290
- this.set(hit.k, hit.v, maxAge);
20291
- }
20292
- }
19610
+ const value = this.map.get(key);
19611
+ if (value === undefined) {
19612
+ return undefined
19613
+ } else {
19614
+ // Remove the key from the map and add it to the end
19615
+ this.map.delete(key);
19616
+ this.map.set(key, value);
19617
+ return value
20293
19618
  }
20294
19619
  }
20295
19620
 
20296
- prune () {
20297
- this[CACHE].forEach((value, key) => get(this, key, false));
19621
+ delete (key) {
19622
+ return this.map.delete(key)
20298
19623
  }
20299
- }
20300
19624
 
20301
- const get = (self, key, doUse) => {
20302
- const node = self[CACHE].get(key);
20303
- if (node) {
20304
- const hit = node.value;
20305
- if (isStale(self, hit)) {
20306
- del(self, node);
20307
- if (!self[ALLOW_STALE])
20308
- return undefined
20309
- } else {
20310
- if (doUse) {
20311
- if (self[UPDATE_AGE_ON_GET])
20312
- node.value.now = Date.now();
20313
- self[LRU_LIST].unshiftNode(node);
20314
- }
20315
- }
20316
- return hit.value
20317
- }
20318
- };
19625
+ set (key, value) {
19626
+ const deleted = this.delete(key);
20319
19627
 
20320
- const isStale = (self, hit) => {
20321
- if (!hit || (!hit.maxAge && !self[MAX_AGE]))
20322
- return false
20323
-
20324
- const diff = Date.now() - hit.now;
20325
- return hit.maxAge ? diff > hit.maxAge
20326
- : self[MAX_AGE] && (diff > self[MAX_AGE])
20327
- };
19628
+ if (!deleted && value !== undefined) {
19629
+ // If cache is full, delete the least recently used item
19630
+ if (this.map.size >= this.max) {
19631
+ const firstKey = this.map.keys().next().value;
19632
+ this.delete(firstKey);
19633
+ }
20328
19634
 
20329
- const trim = self => {
20330
- if (self[LENGTH] > self[MAX]) {
20331
- for (let walker = self[LRU_LIST].tail;
20332
- self[LENGTH] > self[MAX] && walker !== null;) {
20333
- // We know that we're about to delete this one, and also
20334
- // what the next least recently used key will be, so just
20335
- // go ahead and set it now.
20336
- const prev = walker.prev;
20337
- del(self, walker);
20338
- walker = prev;
19635
+ this.map.set(key, value);
20339
19636
  }
20340
- }
20341
- };
20342
-
20343
- const del = (self, node) => {
20344
- if (node) {
20345
- const hit = node.value;
20346
- if (self[DISPOSE])
20347
- self[DISPOSE](hit.key, hit.value);
20348
19637
 
20349
- self[LENGTH] -= hit.length;
20350
- self[CACHE].delete(hit.key);
20351
- self[LRU_LIST].removeNode(node);
20352
- }
20353
- };
20354
-
20355
- class Entry {
20356
- constructor (key, value, length, now, maxAge) {
20357
- this.key = key;
20358
- this.value = value;
20359
- this.length = length;
20360
- this.now = now;
20361
- this.maxAge = maxAge || 0;
19638
+ return this
20362
19639
  }
20363
19640
  }
20364
19641
 
20365
- const forEachStep = (self, fn, node, thisp) => {
20366
- let hit = node.value;
20367
- if (isStale(self, hit)) {
20368
- del(self, node);
20369
- if (!self[ALLOW_STALE])
20370
- hit = undefined;
20371
- }
20372
- if (hit)
20373
- fn.call(thisp, hit.value, hit.key, self);
20374
- };
20375
-
20376
- var lruCache = LRUCache;
19642
+ var lrucache = LRUCache;
20377
19643
 
20378
19644
  const SemVer = semver;
20379
19645
  const compare$6 = (a, b, loose) =>
@@ -20814,8 +20080,8 @@ function requireRange () {
20814
20080
 
20815
20081
  range = Range;
20816
20082
 
20817
- const LRU = lruCache;
20818
- const cache = new LRU({ max: 1000 });
20083
+ const LRU = lrucache;
20084
+ const cache = new LRU();
20819
20085
 
20820
20086
  const parseOptions = parseOptions_1;
20821
20087
  const Comparator = requireComparator();
@@ -21086,9 +20352,10 @@ function requireRange () {
21086
20352
  // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
21087
20353
  // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
21088
20354
  // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
20355
+ // TODO build?
21089
20356
  const hyphenReplace = incPr => ($0,
21090
20357
  from, fM, fm, fp, fpr, fb,
21091
- to, tM, tm, tp, tpr, tb) => {
20358
+ to, tM, tm, tp, tpr) => {
21092
20359
  if (isX(fM)) {
21093
20360
  from = '';
21094
20361
  } else if (isX(fm)) {
@@ -21777,8 +21044,116 @@ var api = {};
21777
21044
 
21778
21045
  var node = main$3;
21779
21046
 
21047
+ const TRACE_PREFIX = /^\[Trace.*?\] /iu;
21048
+ const DEBUG_PREFIX = /^\[Debug.*?\] /iu;
21049
+ const INFO_PREFIX = /^\[Info.*?\] /iu;
21050
+ const WARN_PREFIX = /^\[Warn.*?\] /iu;
21051
+ const ERROR_PREFIX = /^\[Error.*?\] /iu;
21052
+ class TypeSpecLogOutputChannel {
21053
+ delegate;
21054
+ constructor(name) {
21055
+ this.delegate = require$$0$1.window.createOutputChannel(name, { log: true });
21056
+ }
21057
+ get logLevel() {
21058
+ return this.delegate.logLevel;
21059
+ }
21060
+ get onDidChangeLogLevel() {
21061
+ return this.delegate.onDidChangeLogLevel;
21062
+ }
21063
+ trace(message, ...args) {
21064
+ this.delegate.trace(message, ...args);
21065
+ }
21066
+ debug(message, ...args) {
21067
+ this.delegate.debug(message, ...args);
21068
+ }
21069
+ info(message, ...args) {
21070
+ this.delegate.info(message, ...args);
21071
+ }
21072
+ warn(message, ...args) {
21073
+ this.delegate.warn(message, ...args);
21074
+ }
21075
+ error(error, ...args) {
21076
+ this.delegate.error(error, ...args);
21077
+ }
21078
+ get name() {
21079
+ return this.delegate.name;
21080
+ }
21081
+ replace(value) {
21082
+ this.delegate.replace(value);
21083
+ }
21084
+ clear() {
21085
+ this.delegate.clear();
21086
+ }
21087
+ show(column, preserveFocus) {
21088
+ // eslint-disable-next-line deprecation/deprecation
21089
+ this.delegate.show(column, preserveFocus);
21090
+ }
21091
+ hide() {
21092
+ this.delegate.hide();
21093
+ }
21094
+ dispose() {
21095
+ this.delegate.dispose();
21096
+ }
21097
+ append(value) {
21098
+ this.logToDelegate(value);
21099
+ }
21100
+ appendLine(value) {
21101
+ this.logToDelegate(value);
21102
+ }
21103
+ preLevel = "";
21104
+ logToDelegate(value) {
21105
+ if (TRACE_PREFIX.test(value)) {
21106
+ this.preLevel = "trace";
21107
+ this.delegate.trace(value.replace(TRACE_PREFIX, ""));
21108
+ }
21109
+ else if (DEBUG_PREFIX.test(value)) {
21110
+ this.preLevel = "debug";
21111
+ this.delegate.debug(value.replace(DEBUG_PREFIX, ""));
21112
+ }
21113
+ else if (INFO_PREFIX.test(value)) {
21114
+ this.preLevel = "info";
21115
+ this.delegate.info(value.replace(INFO_PREFIX, ""));
21116
+ }
21117
+ else if (WARN_PREFIX.test(value)) {
21118
+ this.preLevel = "warning";
21119
+ this.delegate.warn(value.replace(WARN_PREFIX, ""));
21120
+ }
21121
+ else if (ERROR_PREFIX.test(value)) {
21122
+ this.preLevel = "error";
21123
+ this.delegate.error(value.replace(ERROR_PREFIX, ""));
21124
+ }
21125
+ else {
21126
+ // a msg sent without a level prefix should be because a message is sent by calling multiple appendLine()
21127
+ // so just log it with the previous level
21128
+ switch (this.preLevel) {
21129
+ case "trace":
21130
+ this.delegate.trace(value);
21131
+ break;
21132
+ case "debug":
21133
+ this.delegate.debug(value);
21134
+ break;
21135
+ case "info":
21136
+ this.delegate.info(value);
21137
+ break;
21138
+ case "warning":
21139
+ this.delegate.warn(value);
21140
+ break;
21141
+ case "error":
21142
+ this.delegate.error(value);
21143
+ break;
21144
+ default:
21145
+ this.delegate.debug(`Log Message with invalid log level (${this.preLevel}). Raw message: ${value}`);
21146
+ }
21147
+ }
21148
+ }
21149
+ }
21150
+
21780
21151
  let client;
21781
- const outputChannel = require$$0$1.window.createOutputChannel("TypeSpec");
21152
+ /**
21153
+ * Workaround: LogOutputChannel doesn't work well with LSP RemoteConsole, so having a customized LogOutputChannel to make them work together properly
21154
+ * More detail can be found at https://github.com/microsoft/vscode-discussions/discussions/1149
21155
+ */
21156
+ const outputChannel = new TypeSpecLogOutputChannel("TypeSpec");
21782
21157
  async function activate(context) {
21783
21158
  context.subscriptions.push(require$$0$1.commands.registerCommand("typespec.showOutputChannel", () => {
21784
21159
  outputChannel.show(true /*preserveFocus*/);
@@ -21793,10 +21168,12 @@ async function restartTypeSpecServer() {
21793
21168
  if (client) {
21794
21169
  await client.stop();
21795
21170
  await client.start();
21171
+ outputChannel.debug("TypeSpec server restarted");
21796
21172
  }
21797
21173
  }
21798
21174
  async function launchLanguageClient(context) {
21799
21175
  const exe = await resolveTypeSpecServer(context);
21176
+ outputChannel.debug("TypeSpec server resolved as ", exe);
21800
21177
  const options = {
21801
21178
  synchronize: {
21802
21179
  // Synchronize the setting section 'typespec' to the server
@@ -21816,20 +21193,22 @@ async function launchLanguageClient(context) {
21816
21193
  outputChannel,
21817
21194
  };
21818
21195
  const name = "TypeSpec";
21819
- const id = "typespecLanguageServer";
21196
+ const id = "typespec";
21820
21197
  try {
21821
21198
  client = new node.LanguageClient(id, name, { run: exe, debug: exe }, options);
21822
21199
  await client.start();
21200
+ outputChannel.debug("TypeSpec server started");
21823
21201
  }
21824
21202
  catch (e) {
21825
21203
  if (typeof e === "string" && e.startsWith("Launching server using command")) {
21826
21204
  const workspaceFolder = require$$0$1.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? "";
21827
- client?.error([
21205
+ outputChannel.error([
21828
21206
  `TypeSpec server executable was not found: '${exe.command}' is not found. Make sure either:`,
21829
21207
  ` - TypeSpec is installed locally at the root of this workspace ("${workspaceFolder}") or in a parent directory.`,
21830
21208
  " - TypeSpec is installed globally with `npm install -g @typespec/compiler'.",
21831
21209
  " - TypeSpec server path is configured with https://github.com/microsoft/typespec#installing-vs-code-extension.",
21832
- ].join("\n"), undefined, false);
21210
+ ].join("\n"));
21211
+ outputChannel.error("Error detail", e);
21833
21212
  throw `TypeSpec server executable was not found: '${exe.command}' is not found.`;
21834
21213
  }
21835
21214
  else {
@@ -21846,6 +21225,7 @@ async function resolveTypeSpecServer(context) {
21846
21225
  // we use CLI instead of NODE_OPTIONS environment variable in this case
21847
21226
  // because --nolazy is not supported by NODE_OPTIONS.
21848
21227
  const options = nodeOptions?.split(" ").filter((o) => o) ?? [];
21228
+ outputChannel.debug("TypeSpec server resolved in development mode");
21849
21229
  return { command: "node", args: [...options, script, ...args] };
21850
21230
  }
21851
21231
  const options = {
@@ -21863,11 +21243,15 @@ async function resolveTypeSpecServer(context) {
21863
21243
  const workspaceFolder = require$$0$1.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? "";
21864
21244
  // Default to tsp-server on PATH, which would come from `npm install -g
21865
21245
  // @typespec/compiler` in a vanilla setup.
21866
- if (!serverPath) {
21246
+ if (serverPath) {
21247
+ outputChannel.debug(`Server path loaded from VS Code configuration: ${serverPath}`);
21248
+ }
21249
+ else {
21867
21250
  serverPath = await resolveLocalCompiler(workspaceFolder);
21868
21251
  }
21869
21252
  if (!serverPath) {
21870
21253
  const executable = process.platform === "win32" ? "tsp-server.cmd" : "tsp-server";
21254
+ outputChannel.debug(`Can't resolve server path, try to use default value ${executable}.`);
21871
21255
  return { command: executable, args, options };
21872
21256
  }
21873
21257
  const variableResolver = new VSCodeVariableResolver({
@@ -21875,6 +21259,7 @@ async function resolveTypeSpecServer(context) {
21875
21259
  workspaceRoot: workspaceFolder, // workspaceRoot is deprecated but we still support it for backwards compatibility.
21876
21260
  });
21877
21261
  serverPath = variableResolver.resolve(serverPath);
21262
+ outputChannel.debug(`Server path expanded to: ${serverPath}`);
21878
21263
  if (!serverPath.endsWith(".js")) {
21879
21264
  // Allow path to tsp-server.cmd to be passed.
21880
21265
  if (await isFile$1(serverPath)) {
@@ -21900,15 +21285,22 @@ async function resolveLocalCompiler(baseDir) {
21900
21285
  stat: promises.stat,
21901
21286
  };
21902
21287
  try {
21288
+ outputChannel.debug(`Try to resolve compiler from local, baseDir: ${baseDir}`);
21903
21289
  const executable = await resolveModule(host, "@typespec/compiler", {
21904
21290
  baseDir,
21905
21291
  });
21906
21292
  if (executable.type === "module") {
21293
+ outputChannel.debug(`Resolved compiler from local: ${executable.path}`);
21907
21294
  return executable.path;
21908
21295
  }
21296
+ else {
21297
+ outputChannel.debug(`Failed to resolve compiler from local. Unexpected executable type: ${executable.type}`);
21298
+ }
21909
21299
  }
21910
21300
  catch (e) {
21911
21301
  // Couldn't find the module
21302
+ outputChannel.debug("Exception when resolving compiler from local", e);
21303
+ return undefined;
21912
21304
  }
21913
21305
  return undefined;
21914
21306
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typespec-vscode",
3
- "version": "0.57.0-dev.1",
3
+ "version": "0.57.0-dev.3",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec language support for VS Code",
6
6
  "homepage": "https://typespec.io",
@@ -25,7 +25,7 @@
25
25
  "type": "module",
26
26
  "main": "./dist/src/extension.cjs",
27
27
  "engines": {
28
- "vscode": "^1.88.0"
28
+ "vscode": "^1.89.0"
29
29
  },
30
30
  "activationEvents": [
31
31
  "onLanguage:typespec",
@@ -59,13 +59,24 @@
59
59
  ],
60
60
  "configuration": [
61
61
  {
62
- "title": "TypeSpec Language Server Path",
62
+ "title": "TypeSpec",
63
63
  "properties": {
64
64
  "typespec.tsp-server.path": {
65
65
  "type": "string",
66
66
  "default": "",
67
67
  "description": "Path to `tsp-server` command that runs the TypeSpec language server.\n\nIf not specified, then `tsp-server` found on PATH is used.\n\nExample (User): /usr/local/bin/tsp-server\nExample (Workspace): ${workspaceFolder}/node_modules/@typespec/compiler",
68
68
  "scope": "machine-overridable"
69
+ },
70
+ "typespec.trace.server": {
71
+ "scope": "window",
72
+ "type": "string",
73
+ "enum": [
74
+ "off",
75
+ "messages",
76
+ "verbose"
77
+ ],
78
+ "default": "off",
79
+ "description": "Define whether/how the TypeSpec language server should send traces to client. For the traces to show properly in vscode Output, make sure 'Log Level' is also set to 'Trace' so that they won't be filtered at client side, which can be set through 'Developer: Set Log Level...' command."
69
80
  }
70
81
  }
71
82
  }
@@ -121,17 +132,17 @@
121
132
  "@rollup/plugin-node-resolve": "~15.2.3",
122
133
  "@rollup/plugin-typescript": "~11.1.6",
123
134
  "@types/node": "~18.11.19",
124
- "@types/vscode": "~1.88.0",
135
+ "@types/vscode": "~1.89.0",
125
136
  "@typespec/compiler": "~0.56.0 || >=0.57.0-dev <0.57.0",
126
137
  "@typespec/internal-build-utils": "~0.56.0 || >=0.57.0-dev <0.57.0",
127
- "@vitest/coverage-v8": "^1.5.0",
128
- "@vitest/ui": "^1.5.0",
129
- "@vscode/vsce": "~2.25.0",
138
+ "@vitest/coverage-v8": "^1.6.0",
139
+ "@vitest/ui": "^1.6.0",
140
+ "@vscode/vsce": "~2.26.1",
130
141
  "c8": "^9.1.0",
131
- "rimraf": "~5.0.5",
132
- "rollup": "~4.14.3",
142
+ "rimraf": "~5.0.7",
143
+ "rollup": "~4.17.2",
133
144
  "typescript": "~5.4.5",
134
- "vitest": "^1.5.0",
145
+ "vitest": "^1.6.0",
135
146
  "vscode-languageclient": "~9.0.1"
136
147
  },
137
148
  "dependencies": {},
Binary file