custom-electron-titlebar 3.2.6 → 3.2.10
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/.github/FUNDING.yml +1 -0
- package/README.md +15 -24
- package/_config.yml +1 -0
- package/{lib → build}/browser/browser.d.ts +0 -0
- package/{lib → build}/browser/browser.js +0 -0
- package/{lib → build}/browser/browser.js.map +0 -0
- package/{lib → build}/browser/event.d.ts +0 -0
- package/{lib → build}/browser/event.js +2 -1
- package/{lib → build}/browser/event.js.map +1 -1
- package/{lib → build}/browser/iframe.d.ts +0 -0
- package/{lib → build}/browser/iframe.js +0 -0
- package/{lib → build}/browser/iframe.js.map +0 -0
- package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
- package/{lib → build}/browser/keyboardEvent.js +0 -0
- package/{lib → build}/browser/keyboardEvent.js.map +0 -0
- package/{lib → build}/browser/mouseEvent.d.ts +0 -0
- package/{lib → build}/browser/mouseEvent.js +0 -0
- package/{lib → build}/browser/mouseEvent.js.map +0 -0
- package/{lib → build}/common/arrays.d.ts +0 -0
- package/{lib → build}/common/arrays.js +0 -0
- package/{lib → build}/common/arrays.js.map +0 -0
- package/{lib → build}/common/async.d.ts +0 -0
- package/{lib → build}/common/async.js +0 -0
- package/{lib → build}/common/async.js.map +0 -0
- package/{lib → build}/common/charCode.d.ts +0 -0
- package/{lib → build}/common/charCode.js +0 -0
- package/{lib → build}/common/charCode.js.map +0 -0
- package/{lib → build}/common/color.d.ts +0 -0
- package/{lib → build}/common/color.js +0 -0
- package/{lib → build}/common/color.js.map +0 -0
- package/{lib → build}/common/dom.d.ts +0 -0
- package/{lib → build}/common/dom.js +16 -14
- package/build/common/dom.js.map +1 -0
- package/{lib → build}/common/event.d.ts +0 -0
- package/{lib → build}/common/event.js +1 -1
- package/build/common/event.js.map +1 -0
- package/{lib → build}/common/iterator.d.ts +0 -0
- package/{lib → build}/common/iterator.js +0 -0
- package/{lib → build}/common/iterator.js.map +0 -0
- package/{lib → build}/common/keyCodes.d.ts +0 -0
- package/{lib → build}/common/keyCodes.js +0 -0
- package/{lib → build}/common/keyCodes.js.map +0 -0
- package/{lib → build}/common/lifecycle.d.ts +0 -0
- package/{lib → build}/common/lifecycle.js +0 -0
- package/{lib → build}/common/lifecycle.js.map +0 -0
- package/{lib → build}/common/linkedList.d.ts +0 -0
- package/{lib → build}/common/linkedList.js +0 -0
- package/{lib → build}/common/linkedList.js.map +0 -0
- package/{lib → build}/common/platform.d.ts +0 -0
- package/{lib → build}/common/platform.js +0 -0
- package/{lib → build}/common/platform.js.map +0 -0
- package/{lib → build}/index.d.ts +0 -0
- package/{lib → build}/index.js +0 -0
- package/{lib → build}/index.js.map +0 -0
- package/{lib → build}/menu/menu.d.ts +0 -0
- package/{lib → build}/menu/menu.js +38 -38
- package/build/menu/menu.js.map +1 -0
- package/{lib → build}/menu/menuitem.d.ts +10 -2
- package/{lib → build}/menu/menuitem.js +70 -34
- package/build/menu/menuitem.js.map +1 -0
- package/{lib → build}/menubar.d.ts +0 -0
- package/{lib → build}/menubar.js +29 -30
- package/build/menubar.js.map +1 -0
- package/{lib → build}/themebar.d.ts +0 -0
- package/{lib → build}/themebar.js +2 -2
- package/build/themebar.js.map +1 -0
- package/{lib → build}/titlebar.d.ts +0 -0
- package/{lib → build}/titlebar.js +61 -58
- package/build/titlebar.js.map +1 -0
- package/package.json +13 -7
- package/lib/common/dom.js.map +0 -1
- package/lib/common/enableNativeMenuCommands.d.ts +0 -1
- package/lib/common/enableNativeMenuCommands.js +0 -32
- package/lib/common/enableNativeMenuCommands.js.map +0 -1
- package/lib/common/event.js.map +0 -1
- package/lib/main.d.ts +0 -1
- package/lib/main.js +0 -14
- package/lib/main.js.map +0 -1
- package/lib/menu/menu.js.map +0 -1
- package/lib/menu/menuitem.js.map +0 -1
- package/lib/menubar.js.map +0 -1
- package/lib/themebar.js.map +0 -1
- package/lib/titlebar.js.map +0 -1
- package/lib/vs/base/browser/browser.js +0 -150
- package/lib/vs/base/browser/canIUse.js +0 -58
- package/lib/vs/base/browser/codicons.js +0 -37
- package/lib/vs/base/browser/contextmenu.js +0 -9
- package/lib/vs/base/browser/dnd.js +0 -113
- package/lib/vs/base/browser/dom.js +0 -1417
- package/lib/vs/base/browser/event.js +0 -36
- package/lib/vs/base/browser/fastDomNode.js +0 -265
- package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
- package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
- package/lib/vs/base/browser/history.js +0 -9
- package/lib/vs/base/browser/iframe.js +0 -126
- package/lib/vs/base/browser/keyboardEvent.js +0 -599
- package/lib/vs/base/browser/mouseEvent.js +0 -155
- package/lib/vs/base/browser/touch.js +0 -315
- package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
- package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
- package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
- package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
- package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
- package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
- package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
- package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
- package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
- package/lib/vs/base/browser/ui/list/list.js +0 -54
- package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
- package/lib/vs/base/browser/ui/list/listView.js +0 -1388
- package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
- package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
- package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
- package/lib/vs/base/browser/ui/list/splice.js +0 -23
- package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
- package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
- package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
- package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
- package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
- package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
- package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
- package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
- package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
- package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
- package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
- package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
- package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
- package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
- package/lib/vs/base/browser/ui/widget.js +0 -69
- package/lib/vs/base/common/actions.js +0 -224
- package/lib/vs/base/common/amd.js +0 -31
- package/lib/vs/base/common/arrays.js +0 -641
- package/lib/vs/base/common/assert.js +0 -21
- package/lib/vs/base/common/async.js +0 -966
- package/lib/vs/base/common/buffer.js +0 -250
- package/lib/vs/base/common/cache.js +0 -40
- package/lib/vs/base/common/cancellation.js +0 -146
- package/lib/vs/base/common/charCode.js +0 -9
- package/lib/vs/base/common/codicon.js +0 -136
- package/lib/vs/base/common/codicons.js +0 -1378
- package/lib/vs/base/common/collections.js +0 -133
- package/lib/vs/base/common/color.js +0 -716
- package/lib/vs/base/common/comparers.js +0 -280
- package/lib/vs/base/common/console.js +0 -142
- package/lib/vs/base/common/date.js +0 -113
- package/lib/vs/base/common/decorators.js +0 -169
- package/lib/vs/base/common/errorMessage.js +0 -93
- package/lib/vs/base/common/errors.js +0 -213
- package/lib/vs/base/common/errorsWithActions.js +0 -28
- package/lib/vs/base/common/event.js +0 -873
- package/lib/vs/base/common/extpath.js +0 -401
- package/lib/vs/base/common/filters.js +0 -948
- package/lib/vs/base/common/functional.js +0 -28
- package/lib/vs/base/common/fuzzyScorer.js +0 -811
- package/lib/vs/base/common/glob.js +0 -696
- package/lib/vs/base/common/hash.js +0 -359
- package/lib/vs/base/common/history.js +0 -116
- package/lib/vs/base/common/htmlContent.js +0 -162
- package/lib/vs/base/common/idGenerator.js +0 -25
- package/lib/vs/base/common/iterator.js +0 -118
- package/lib/vs/base/common/json.js +0 -1624
- package/lib/vs/base/common/jsonEdit.js +0 -272
- package/lib/vs/base/common/jsonErrorMessages.js +0 -69
- package/lib/vs/base/common/jsonFormatter.js +0 -316
- package/lib/vs/base/common/jsonSchema.js +0 -9
- package/lib/vs/base/common/keyCodes.js +0 -591
- package/lib/vs/base/common/keybindingLabels.js +0 -231
- package/lib/vs/base/common/keybindingParser.js +0 -142
- package/lib/vs/base/common/labels.js +0 -430
- package/lib/vs/base/common/lazy.js +0 -71
- package/lib/vs/base/common/lifecycle.js +0 -308
- package/lib/vs/base/common/linkedList.js +0 -152
- package/lib/vs/base/common/linkedText.js +0 -73
- package/lib/vs/base/common/map.js +0 -1108
- package/lib/vs/base/common/marshalling.js +0 -80
- package/lib/vs/base/common/mime.js +0 -321
- package/lib/vs/base/common/navigator.js +0 -50
- package/lib/vs/base/common/network.js +0 -160
- package/lib/vs/base/common/normalization.js +0 -78
- package/lib/vs/base/common/numbers.js +0 -55
- package/lib/vs/base/common/objects.js +0 -268
- package/lib/vs/base/common/paging.js +0 -190
- package/lib/vs/base/common/parsers.js +0 -78
- package/lib/vs/base/common/path.js +0 -1550
- package/lib/vs/base/common/platform.js +0 -245
- package/lib/vs/base/common/process.js +0 -52
- package/lib/vs/base/common/processes.js +0 -32
- package/lib/vs/base/common/range.js +0 -79
- package/lib/vs/base/common/resourceTree.js +0 -185
- package/lib/vs/base/common/resources.js +0 -421
- package/lib/vs/base/common/scanCode.js +0 -1472
- package/lib/vs/base/common/scrollable.js +0 -397
- package/lib/vs/base/common/search.js +0 -55
- package/lib/vs/base/common/sequence.js +0 -64
- package/lib/vs/base/common/severity.js +0 -55
- package/lib/vs/base/common/skipList.js +0 -234
- package/lib/vs/base/common/stopwatch.js +0 -45
- package/lib/vs/base/common/stream.js +0 -418
- package/lib/vs/base/common/strings.js +0 -1283
- package/lib/vs/base/common/styler.js +0 -9
- package/lib/vs/base/common/types.js +0 -296
- package/lib/vs/base/common/uint.js +0 -46
- package/lib/vs/base/common/uri.js +0 -756
- package/lib/vs/base/common/uriIpc.js +0 -154
- package/lib/vs/base/common/uuid.js +0 -70
- package/lib/vs/nls.mock.js +0 -31
- package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
- package/lib/vs/platform/actions/common/actions.js +0 -456
- package/lib/vs/platform/actions/common/menuService.js +0 -194
- package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
- package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
- package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
- package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
- package/lib/vs/platform/contextview/browser/contextView.js +0 -15
- package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
- package/lib/vs/platform/environment/common/argv.js +0 -9
- package/lib/vs/platform/environment/common/environment.js +0 -15
- package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
- package/lib/vs/platform/instantiation/common/extensions.js +0 -26
- package/lib/vs/platform/instantiation/common/graph.js +0 -93
- package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
- package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
- package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
- package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
- package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
- package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
- package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
- package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
- package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
- package/lib/vs/platform/layout/browser/layoutService.js +0 -14
- package/lib/vs/platform/menubar/common/menubar.js +0 -34
- package/lib/vs/platform/registry/common/platform.js +0 -38
- package/lib/vs/platform/theme/browser/checkbox.js +0 -32
- package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
- package/lib/vs/platform/theme/common/styler.js +0 -290
- package/lib/vs/platform/theme/common/theme.js +0 -21
- package/lib/vs/platform/theme/common/themeService.js +0 -176
- package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
- package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.compareByPrefix = exports.compareAnything = exports.comparePaths = exports.compareFileExtensionsDefault = exports.compareFileExtensions = exports.noIntlCompareFileNames = exports.compareFileNamesDefault = exports.compareFileNames = void 0;
|
|
11
|
-
|
|
12
|
-
const path_1 = require("./path");
|
|
13
|
-
|
|
14
|
-
const async_1 = require("./async"); // When comparing large numbers of strings, such as in sorting large arrays, is better for
|
|
15
|
-
// performance to create an Intl.Collator object and use the function provided by its compare
|
|
16
|
-
// property than it is to use String.prototype.localeCompare()
|
|
17
|
-
// A collator with numeric sorting enabled, and no sensitivity to case or to accents
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const intlFileNameCollatorBaseNumeric = new async_1.IdleValue(() => {
|
|
21
|
-
const collator = new Intl.Collator(undefined, {
|
|
22
|
-
numeric: true,
|
|
23
|
-
sensitivity: 'base'
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
collator: collator,
|
|
27
|
-
collatorIsNumeric: collator.resolvedOptions().numeric
|
|
28
|
-
};
|
|
29
|
-
}); // A collator with numeric sorting enabled.
|
|
30
|
-
|
|
31
|
-
const intlFileNameCollatorNumeric = new async_1.IdleValue(() => {
|
|
32
|
-
const collator = new Intl.Collator(undefined, {
|
|
33
|
-
numeric: true
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
collator: collator
|
|
37
|
-
};
|
|
38
|
-
}); // A collator with numeric sorting enabled, and sensitivity to accents and diacritics but not case.
|
|
39
|
-
|
|
40
|
-
const intlFileNameCollatorNumericCaseInsenstive = new async_1.IdleValue(() => {
|
|
41
|
-
const collator = new Intl.Collator(undefined, {
|
|
42
|
-
numeric: true,
|
|
43
|
-
sensitivity: 'accent'
|
|
44
|
-
});
|
|
45
|
-
return {
|
|
46
|
-
collator: collator
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
/** Compares filenames without distinguishing the name from the extension. Disambiguates by unicode comparison. */
|
|
50
|
-
|
|
51
|
-
function compareFileNames(one, other, caseSensitive = false) {
|
|
52
|
-
const a = one || '';
|
|
53
|
-
const b = other || '';
|
|
54
|
-
const result = intlFileNameCollatorBaseNumeric.value.collator.compare(a, b); // Using the numeric option in the collator will
|
|
55
|
-
// make compare(`foo1`, `foo01`) === 0. We must disambiguate.
|
|
56
|
-
|
|
57
|
-
if (intlFileNameCollatorBaseNumeric.value.collatorIsNumeric && result === 0 && a !== b) {
|
|
58
|
-
return a < b ? -1 : 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exports.compareFileNames = compareFileNames;
|
|
65
|
-
/** Compares filenames without distinguishing the name from the extension. Disambiguates by length, not unicode comparison. */
|
|
66
|
-
|
|
67
|
-
function compareFileNamesDefault(one, other) {
|
|
68
|
-
const collatorNumeric = intlFileNameCollatorNumeric.value.collator;
|
|
69
|
-
one = one || '';
|
|
70
|
-
other = other || ''; // Compare the entire filename - both name and extension - and disambiguate by length if needed
|
|
71
|
-
|
|
72
|
-
return compareAndDisambiguateByLength(collatorNumeric, one, other);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
exports.compareFileNamesDefault = compareFileNamesDefault;
|
|
76
|
-
|
|
77
|
-
function noIntlCompareFileNames(one, other, caseSensitive = false) {
|
|
78
|
-
if (!caseSensitive) {
|
|
79
|
-
one = one && one.toLowerCase();
|
|
80
|
-
other = other && other.toLowerCase();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const [oneName, oneExtension] = extractNameAndExtension(one);
|
|
84
|
-
const [otherName, otherExtension] = extractNameAndExtension(other);
|
|
85
|
-
|
|
86
|
-
if (oneName !== otherName) {
|
|
87
|
-
return oneName < otherName ? -1 : 1;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (oneExtension === otherExtension) {
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return oneExtension < otherExtension ? -1 : 1;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
exports.noIntlCompareFileNames = noIntlCompareFileNames;
|
|
98
|
-
|
|
99
|
-
function compareFileExtensions(one, other) {
|
|
100
|
-
const [oneName, oneExtension] = extractNameAndExtension(one);
|
|
101
|
-
const [otherName, otherExtension] = extractNameAndExtension(other);
|
|
102
|
-
let result = intlFileNameCollatorBaseNumeric.value.collator.compare(oneExtension, otherExtension);
|
|
103
|
-
|
|
104
|
-
if (result === 0) {
|
|
105
|
-
// Using the numeric option in the collator will
|
|
106
|
-
// make compare(`foo1`, `foo01`) === 0. We must disambiguate.
|
|
107
|
-
if (intlFileNameCollatorBaseNumeric.value.collatorIsNumeric && oneExtension !== otherExtension) {
|
|
108
|
-
return oneExtension < otherExtension ? -1 : 1;
|
|
109
|
-
} // Extensions are equal, compare filenames
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
result = intlFileNameCollatorBaseNumeric.value.collator.compare(oneName, otherName);
|
|
113
|
-
|
|
114
|
-
if (intlFileNameCollatorBaseNumeric.value.collatorIsNumeric && result === 0 && oneName !== otherName) {
|
|
115
|
-
return oneName < otherName ? -1 : 1;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return result;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
exports.compareFileExtensions = compareFileExtensions;
|
|
123
|
-
/** Compares filenames by extenson, then by full filename */
|
|
124
|
-
|
|
125
|
-
function compareFileExtensionsDefault(one, other) {
|
|
126
|
-
one = one || '';
|
|
127
|
-
other = other || '';
|
|
128
|
-
const oneExtension = extractExtension(one);
|
|
129
|
-
const otherExtension = extractExtension(other);
|
|
130
|
-
const collatorNumeric = intlFileNameCollatorNumeric.value.collator;
|
|
131
|
-
const collatorNumericCaseInsensitive = intlFileNameCollatorNumericCaseInsenstive.value.collator;
|
|
132
|
-
let result; // Check for extension differences, ignoring differences in case and comparing numbers numerically.
|
|
133
|
-
|
|
134
|
-
result = compareAndDisambiguateByLength(collatorNumericCaseInsensitive, oneExtension, otherExtension);
|
|
135
|
-
|
|
136
|
-
if (result !== 0) {
|
|
137
|
-
return result;
|
|
138
|
-
} // Compare full filenames
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return compareAndDisambiguateByLength(collatorNumeric, one, other);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
exports.compareFileExtensionsDefault = compareFileExtensionsDefault;
|
|
145
|
-
const FileNameMatch = /^(.*?)(\.([^.]*))?$/;
|
|
146
|
-
/** Extracts the name and extension from a full filename, with optional special handling for dotfiles */
|
|
147
|
-
|
|
148
|
-
function extractNameAndExtension(str, dotfilesAsNames = false) {
|
|
149
|
-
const match = str ? FileNameMatch.exec(str) : [];
|
|
150
|
-
let result = [match && match[1] || '', match && match[3] || '']; // if the dotfilesAsNames option is selected, treat an empty filename with an extension,
|
|
151
|
-
// or a filename that starts with a dot, as a dotfile name
|
|
152
|
-
|
|
153
|
-
if (dotfilesAsNames && (!result[0] && result[1] || result[0] && result[0].charAt(0) === '.')) {
|
|
154
|
-
result = [result[0] + '.' + result[1], ''];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
/** Extracts the extension from a full filename. Treats dotfiles as names, not extensions. */
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
function extractExtension(str) {
|
|
163
|
-
const match = str ? FileNameMatch.exec(str) : [];
|
|
164
|
-
return match && match[1] && match[1].charAt(0) !== '.' && match[3] || '';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function compareAndDisambiguateByLength(collator, one, other) {
|
|
168
|
-
// Check for differences
|
|
169
|
-
let result = collator.compare(one, other);
|
|
170
|
-
|
|
171
|
-
if (result !== 0) {
|
|
172
|
-
return result;
|
|
173
|
-
} // In a numeric comparison, `foo1` and `foo01` will compare as equivalent.
|
|
174
|
-
// Disambiguate by sorting the shorter string first.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (one.length !== other.length) {
|
|
178
|
-
return one.length < other.length ? -1 : 1;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return 0;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function comparePathComponents(one, other, caseSensitive = false) {
|
|
185
|
-
if (!caseSensitive) {
|
|
186
|
-
one = one && one.toLowerCase();
|
|
187
|
-
other = other && other.toLowerCase();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (one === other) {
|
|
191
|
-
return 0;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return one < other ? -1 : 1;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function comparePaths(one, other, caseSensitive = false) {
|
|
198
|
-
const oneParts = one.split(path_1.sep);
|
|
199
|
-
const otherParts = other.split(path_1.sep);
|
|
200
|
-
const lastOne = oneParts.length - 1;
|
|
201
|
-
const lastOther = otherParts.length - 1;
|
|
202
|
-
let endOne, endOther;
|
|
203
|
-
|
|
204
|
-
for (let i = 0;; i++) {
|
|
205
|
-
endOne = lastOne === i;
|
|
206
|
-
endOther = lastOther === i;
|
|
207
|
-
|
|
208
|
-
if (endOne && endOther) {
|
|
209
|
-
return compareFileNames(oneParts[i], otherParts[i], caseSensitive);
|
|
210
|
-
} else if (endOne) {
|
|
211
|
-
return -1;
|
|
212
|
-
} else if (endOther) {
|
|
213
|
-
return 1;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const result = comparePathComponents(oneParts[i], otherParts[i], caseSensitive);
|
|
217
|
-
|
|
218
|
-
if (result !== 0) {
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
exports.comparePaths = comparePaths;
|
|
225
|
-
|
|
226
|
-
function compareAnything(one, other, lookFor) {
|
|
227
|
-
const elementAName = one.toLowerCase();
|
|
228
|
-
const elementBName = other.toLowerCase(); // Sort prefix matches over non prefix matches
|
|
229
|
-
|
|
230
|
-
const prefixCompare = compareByPrefix(one, other, lookFor);
|
|
231
|
-
|
|
232
|
-
if (prefixCompare) {
|
|
233
|
-
return prefixCompare;
|
|
234
|
-
} // Sort suffix matches over non suffix matches
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const elementASuffixMatch = elementAName.endsWith(lookFor);
|
|
238
|
-
const elementBSuffixMatch = elementBName.endsWith(lookFor);
|
|
239
|
-
|
|
240
|
-
if (elementASuffixMatch !== elementBSuffixMatch) {
|
|
241
|
-
return elementASuffixMatch ? -1 : 1;
|
|
242
|
-
} // Understand file names
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const r = compareFileNames(elementAName, elementBName);
|
|
246
|
-
|
|
247
|
-
if (r !== 0) {
|
|
248
|
-
return r;
|
|
249
|
-
} // Compare by name
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return elementAName.localeCompare(elementBName);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
exports.compareAnything = compareAnything;
|
|
256
|
-
|
|
257
|
-
function compareByPrefix(one, other, lookFor) {
|
|
258
|
-
const elementAName = one.toLowerCase();
|
|
259
|
-
const elementBName = other.toLowerCase(); // Sort prefix matches over non prefix matches
|
|
260
|
-
|
|
261
|
-
const elementAPrefixMatch = elementAName.startsWith(lookFor);
|
|
262
|
-
const elementBPrefixMatch = elementBName.startsWith(lookFor);
|
|
263
|
-
|
|
264
|
-
if (elementAPrefixMatch !== elementBPrefixMatch) {
|
|
265
|
-
return elementAPrefixMatch ? -1 : 1;
|
|
266
|
-
} // Same prefix: Sort shorter matches to the top to have those on top that match more precisely
|
|
267
|
-
else if (elementAPrefixMatch && elementBPrefixMatch) {
|
|
268
|
-
if (elementAName.length < elementBName.length) {
|
|
269
|
-
return -1;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (elementAName.length > elementBName.length) {
|
|
273
|
-
return 1;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return 0;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
exports.compareByPrefix = compareByPrefix;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.log = exports.getFirstFrame = exports.parse = exports.isRemoteConsoleLog = void 0;
|
|
11
|
-
|
|
12
|
-
const uri_1 = require("./uri");
|
|
13
|
-
|
|
14
|
-
function isRemoteConsoleLog(obj) {
|
|
15
|
-
const entry = obj;
|
|
16
|
-
return entry && typeof entry.type === 'string' && typeof entry.severity === 'string';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
exports.isRemoteConsoleLog = isRemoteConsoleLog;
|
|
20
|
-
|
|
21
|
-
function parse(entry) {
|
|
22
|
-
const args = [];
|
|
23
|
-
let stack; // Parse Entry
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const parsedArguments = JSON.parse(entry.arguments); // Check for special stack entry as last entry
|
|
27
|
-
|
|
28
|
-
const stackArgument = parsedArguments[parsedArguments.length - 1];
|
|
29
|
-
|
|
30
|
-
if (stackArgument && stackArgument.__$stack) {
|
|
31
|
-
parsedArguments.pop(); // stack is handled specially
|
|
32
|
-
|
|
33
|
-
stack = stackArgument.__$stack;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
args.push(...parsedArguments);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
args.push('Unable to log remote console arguments', entry.arguments);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
args,
|
|
43
|
-
stack
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
exports.parse = parse;
|
|
48
|
-
|
|
49
|
-
function getFirstFrame(arg0) {
|
|
50
|
-
if (typeof arg0 !== 'string') {
|
|
51
|
-
return getFirstFrame(parse(arg0).stack);
|
|
52
|
-
} // Parse a source information out of the stack if we have one. Format can be:
|
|
53
|
-
// at vscode.commands.registerCommand (/Users/someone/Desktop/test-ts/out/src/extension.js:18:17)
|
|
54
|
-
// or
|
|
55
|
-
// at /Users/someone/Desktop/test-ts/out/src/extension.js:18:17
|
|
56
|
-
// or
|
|
57
|
-
// at c:\Users\someone\Desktop\end-js\extension.js:19:17
|
|
58
|
-
// or
|
|
59
|
-
// at e.$executeContributedCommand(c:\Users\someone\Desktop\end-js\extension.js:19:17)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const stack = arg0;
|
|
63
|
-
|
|
64
|
-
if (stack) {
|
|
65
|
-
const topFrame = findFirstFrame(stack); // at [^\/]* => line starts with "at" followed by any character except '/' (to not capture unix paths too late)
|
|
66
|
-
// (?:(?:[a-zA-Z]+:)|(?:[\/])|(?:\\\\) => windows drive letter OR unix root OR unc root
|
|
67
|
-
// (?:.+) => simple pattern for the path, only works because of the line/col pattern after
|
|
68
|
-
// :(?:\d+):(?:\d+) => :line:column data
|
|
69
|
-
|
|
70
|
-
const matches = /at [^\/]*((?:(?:[a-zA-Z]+:)|(?:[\/])|(?:\\\\))(?:.+)):(\d+):(\d+)/.exec(topFrame || '');
|
|
71
|
-
|
|
72
|
-
if (matches && matches.length === 4) {
|
|
73
|
-
return {
|
|
74
|
-
uri: uri_1.URI.file(matches[1]),
|
|
75
|
-
line: Number(matches[2]),
|
|
76
|
-
column: Number(matches[3])
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports.getFirstFrame = getFirstFrame;
|
|
85
|
-
|
|
86
|
-
function findFirstFrame(stack) {
|
|
87
|
-
if (!stack) {
|
|
88
|
-
return stack;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const newlineIndex = stack.indexOf('\n');
|
|
92
|
-
|
|
93
|
-
if (newlineIndex === -1) {
|
|
94
|
-
return stack;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return stack.substring(0, newlineIndex);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function log(entry, label) {
|
|
101
|
-
const {
|
|
102
|
-
args,
|
|
103
|
-
stack
|
|
104
|
-
} = parse(entry);
|
|
105
|
-
const isOneStringArg = typeof args[0] === 'string' && args.length === 1;
|
|
106
|
-
let topFrame = findFirstFrame(stack);
|
|
107
|
-
|
|
108
|
-
if (topFrame) {
|
|
109
|
-
topFrame = `(${topFrame.trim()})`;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
let consoleArgs = []; // First arg is a string
|
|
113
|
-
|
|
114
|
-
if (typeof args[0] === 'string') {
|
|
115
|
-
if (topFrame && isOneStringArg) {
|
|
116
|
-
consoleArgs = [`%c[${label}] %c${args[0]} %c${topFrame}`, color('blue'), color(''), color('grey')];
|
|
117
|
-
} else {
|
|
118
|
-
consoleArgs = [`%c[${label}] %c${args[0]}`, color('blue'), color(''), ...args.slice(1)];
|
|
119
|
-
}
|
|
120
|
-
} // First arg is something else, just apply all
|
|
121
|
-
else {
|
|
122
|
-
consoleArgs = [`%c[${label}]%`, color('blue'), ...args];
|
|
123
|
-
} // Stack: add to args unless already aded
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (topFrame && !isOneStringArg) {
|
|
127
|
-
consoleArgs.push(topFrame);
|
|
128
|
-
} // Log it
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (typeof console[entry.severity] !== 'function') {
|
|
132
|
-
throw new Error('Unknown console method');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
console[entry.severity].apply(console, consoleArgs);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
exports.log = log;
|
|
139
|
-
|
|
140
|
-
function color(color) {
|
|
141
|
-
return `color: ${color}`;
|
|
142
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.toLocalISOString = exports.fromNow = void 0;
|
|
11
|
-
|
|
12
|
-
const nls_1 = require("../../nls");
|
|
13
|
-
|
|
14
|
-
const minute = 60;
|
|
15
|
-
const hour = minute * 60;
|
|
16
|
-
const day = hour * 24;
|
|
17
|
-
const week = day * 7;
|
|
18
|
-
const month = day * 30;
|
|
19
|
-
const year = day * 365;
|
|
20
|
-
|
|
21
|
-
function fromNow(date, appendAgoLabel) {
|
|
22
|
-
if (typeof date !== 'number') {
|
|
23
|
-
date = date.getTime();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const seconds = Math.round((new Date().getTime() - date) / 1000);
|
|
27
|
-
|
|
28
|
-
if (seconds < -30) {
|
|
29
|
-
return nls_1.localize('date.fromNow.in', 'in {0}', fromNow(new Date().getTime() + seconds * 1000, false));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (seconds < 30) {
|
|
33
|
-
return nls_1.localize('date.fromNow.now', 'now');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let value;
|
|
37
|
-
|
|
38
|
-
if (seconds < minute) {
|
|
39
|
-
value = seconds;
|
|
40
|
-
|
|
41
|
-
if (appendAgoLabel) {
|
|
42
|
-
return value === 1 ? nls_1.localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value) : nls_1.localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value);
|
|
43
|
-
} else {
|
|
44
|
-
return value === 1 ? nls_1.localize('date.fromNow.seconds.singular', '{0} sec', value) : nls_1.localize('date.fromNow.seconds.plural', '{0} secs', value);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (seconds < hour) {
|
|
49
|
-
value = Math.floor(seconds / minute);
|
|
50
|
-
|
|
51
|
-
if (appendAgoLabel) {
|
|
52
|
-
return value === 1 ? nls_1.localize('date.fromNow.minutes.singular.ago', '{0} min ago', value) : nls_1.localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value);
|
|
53
|
-
} else {
|
|
54
|
-
return value === 1 ? nls_1.localize('date.fromNow.minutes.singular', '{0} min', value) : nls_1.localize('date.fromNow.minutes.plural', '{0} mins', value);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (seconds < day) {
|
|
59
|
-
value = Math.floor(seconds / hour);
|
|
60
|
-
|
|
61
|
-
if (appendAgoLabel) {
|
|
62
|
-
return value === 1 ? nls_1.localize('date.fromNow.hours.singular.ago', '{0} hr ago', value) : nls_1.localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value);
|
|
63
|
-
} else {
|
|
64
|
-
return value === 1 ? nls_1.localize('date.fromNow.hours.singular', '{0} hr', value) : nls_1.localize('date.fromNow.hours.plural', '{0} hrs', value);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (seconds < week) {
|
|
69
|
-
value = Math.floor(seconds / day);
|
|
70
|
-
|
|
71
|
-
if (appendAgoLabel) {
|
|
72
|
-
return value === 1 ? nls_1.localize('date.fromNow.days.singular.ago', '{0} day ago', value) : nls_1.localize('date.fromNow.days.plural.ago', '{0} days ago', value);
|
|
73
|
-
} else {
|
|
74
|
-
return value === 1 ? nls_1.localize('date.fromNow.days.singular', '{0} day', value) : nls_1.localize('date.fromNow.days.plural', '{0} days', value);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (seconds < month) {
|
|
79
|
-
value = Math.floor(seconds / week);
|
|
80
|
-
|
|
81
|
-
if (appendAgoLabel) {
|
|
82
|
-
return value === 1 ? nls_1.localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value) : nls_1.localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value);
|
|
83
|
-
} else {
|
|
84
|
-
return value === 1 ? nls_1.localize('date.fromNow.weeks.singular', '{0} wk', value) : nls_1.localize('date.fromNow.weeks.plural', '{0} wks', value);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (seconds < year) {
|
|
89
|
-
value = Math.floor(seconds / month);
|
|
90
|
-
|
|
91
|
-
if (appendAgoLabel) {
|
|
92
|
-
return value === 1 ? nls_1.localize('date.fromNow.months.singular.ago', '{0} mo ago', value) : nls_1.localize('date.fromNow.months.plural.ago', '{0} mos ago', value);
|
|
93
|
-
} else {
|
|
94
|
-
return value === 1 ? nls_1.localize('date.fromNow.months.singular', '{0} mo', value) : nls_1.localize('date.fromNow.months.plural', '{0} mos', value);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
value = Math.floor(seconds / year);
|
|
99
|
-
|
|
100
|
-
if (appendAgoLabel) {
|
|
101
|
-
return value === 1 ? nls_1.localize('date.fromNow.years.singular.ago', '{0} yr ago', value) : nls_1.localize('date.fromNow.years.plural.ago', '{0} yrs ago', value);
|
|
102
|
-
} else {
|
|
103
|
-
return value === 1 ? nls_1.localize('date.fromNow.years.singular', '{0} yr', value) : nls_1.localize('date.fromNow.years.plural', '{0} yrs', value);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
exports.fromNow = fromNow;
|
|
108
|
-
|
|
109
|
-
function toLocalISOString(date) {
|
|
110
|
-
return date.getFullYear() + '-' + String(date.getMonth() + 1).padStart(2, '0') + '-' + String(date.getDate()).padStart(2, '0') + 'T' + String(date.getHours()).padStart(2, '0') + ':' + String(date.getMinutes()).padStart(2, '0') + ':' + String(date.getSeconds()).padStart(2, '0') + '.' + (date.getMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
exports.toLocalISOString = toLocalISOString;
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.throttle = exports.debounce = exports.memoize = exports.createMemoizer = exports.createDecorator = void 0;
|
|
11
|
-
|
|
12
|
-
function createDecorator(mapFn) {
|
|
13
|
-
return (target, key, descriptor) => {
|
|
14
|
-
let fnKey = null;
|
|
15
|
-
let fn = null;
|
|
16
|
-
|
|
17
|
-
if (typeof descriptor.value === 'function') {
|
|
18
|
-
fnKey = 'value';
|
|
19
|
-
fn = descriptor.value;
|
|
20
|
-
} else if (typeof descriptor.get === 'function') {
|
|
21
|
-
fnKey = 'get';
|
|
22
|
-
fn = descriptor.get;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!fn) {
|
|
26
|
-
throw new Error('not supported');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
descriptor[fnKey] = mapFn(fn, key);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.createDecorator = createDecorator;
|
|
34
|
-
let memoizeId = 0;
|
|
35
|
-
|
|
36
|
-
function createMemoizer() {
|
|
37
|
-
const memoizeKeyPrefix = `$memoize${memoizeId++}`;
|
|
38
|
-
let self = undefined;
|
|
39
|
-
|
|
40
|
-
const result = function memoize(target, key, descriptor) {
|
|
41
|
-
let fnKey = null;
|
|
42
|
-
let fn = null;
|
|
43
|
-
|
|
44
|
-
if (typeof descriptor.value === 'function') {
|
|
45
|
-
fnKey = 'value';
|
|
46
|
-
fn = descriptor.value;
|
|
47
|
-
|
|
48
|
-
if (fn.length !== 0) {
|
|
49
|
-
console.warn('Memoize should only be used in functions with zero parameters');
|
|
50
|
-
}
|
|
51
|
-
} else if (typeof descriptor.get === 'function') {
|
|
52
|
-
fnKey = 'get';
|
|
53
|
-
fn = descriptor.get;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!fn) {
|
|
57
|
-
throw new Error('not supported');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const memoizeKey = `${memoizeKeyPrefix}:${key}`;
|
|
61
|
-
|
|
62
|
-
descriptor[fnKey] = function (...args) {
|
|
63
|
-
self = this;
|
|
64
|
-
|
|
65
|
-
if (!this.hasOwnProperty(memoizeKey)) {
|
|
66
|
-
Object.defineProperty(this, memoizeKey, {
|
|
67
|
-
configurable: true,
|
|
68
|
-
enumerable: false,
|
|
69
|
-
writable: true,
|
|
70
|
-
value: fn.apply(this, args)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return this[memoizeKey];
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
result.clear = () => {
|
|
79
|
-
if (typeof self === 'undefined') {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
Object.getOwnPropertyNames(self).forEach(property => {
|
|
84
|
-
if (property.indexOf(memoizeKeyPrefix) === 0) {
|
|
85
|
-
delete self[property];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
exports.createMemoizer = createMemoizer;
|
|
94
|
-
|
|
95
|
-
function memoize(target, key, descriptor) {
|
|
96
|
-
return createMemoizer()(target, key, descriptor);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
exports.memoize = memoize;
|
|
100
|
-
|
|
101
|
-
function debounce(delay, reducer, initialValueProvider) {
|
|
102
|
-
return createDecorator((fn, key) => {
|
|
103
|
-
const timerKey = `$debounce$${key}`;
|
|
104
|
-
const resultKey = `$debounce$result$${key}`;
|
|
105
|
-
return function (...args) {
|
|
106
|
-
if (!this[resultKey]) {
|
|
107
|
-
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
clearTimeout(this[timerKey]);
|
|
111
|
-
|
|
112
|
-
if (reducer) {
|
|
113
|
-
this[resultKey] = reducer(this[resultKey], ...args);
|
|
114
|
-
args = [this[resultKey]];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
this[timerKey] = setTimeout(() => {
|
|
118
|
-
fn.apply(this, args);
|
|
119
|
-
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
|
|
120
|
-
}, delay);
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
exports.debounce = debounce;
|
|
126
|
-
|
|
127
|
-
function throttle(delay, reducer, initialValueProvider) {
|
|
128
|
-
return createDecorator((fn, key) => {
|
|
129
|
-
const timerKey = `$throttle$timer$${key}`;
|
|
130
|
-
const resultKey = `$throttle$result$${key}`;
|
|
131
|
-
const lastRunKey = `$throttle$lastRun$${key}`;
|
|
132
|
-
const pendingKey = `$throttle$pending$${key}`;
|
|
133
|
-
return function (...args) {
|
|
134
|
-
if (!this[resultKey]) {
|
|
135
|
-
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (this[lastRunKey] === null || this[lastRunKey] === undefined) {
|
|
139
|
-
this[lastRunKey] = -Number.MAX_VALUE;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (reducer) {
|
|
143
|
-
this[resultKey] = reducer(this[resultKey], ...args);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (this[pendingKey]) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const nextTime = this[lastRunKey] + delay;
|
|
151
|
-
|
|
152
|
-
if (nextTime <= Date.now()) {
|
|
153
|
-
this[lastRunKey] = Date.now();
|
|
154
|
-
fn.apply(this, [this[resultKey]]);
|
|
155
|
-
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
|
|
156
|
-
} else {
|
|
157
|
-
this[pendingKey] = true;
|
|
158
|
-
this[timerKey] = setTimeout(() => {
|
|
159
|
-
this[pendingKey] = false;
|
|
160
|
-
this[lastRunKey] = Date.now();
|
|
161
|
-
fn.apply(this, [this[resultKey]]);
|
|
162
|
-
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
|
|
163
|
-
}, nextTime - Date.now());
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
exports.throttle = throttle;
|