@microsoft/vscode-azext-utils
Advanced tools
Comparing version 2.5.3 to 2.5.4
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ReadOnlyContent = exports.openReadOnlyContent = exports.openReadOnlyJson = void 0; | ||
exports.ReadOnlyContent = exports.disposeReadOnlyContent = exports.disposeReadOnlyContents = exports.openReadOnlyContent = exports.stashReadOnlyContent = exports.openReadOnlyJson = void 0; | ||
const util_1 = require("util"); | ||
@@ -56,2 +56,9 @@ const vscode_1 = require("vscode"); | ||
exports.openReadOnlyJson = openReadOnlyJson; | ||
function stashReadOnlyContent(node, content, fileExtension) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const contentProvider = getContentProvider(); | ||
return yield contentProvider.stashReadOnlyContent(node, content, fileExtension); | ||
}); | ||
} | ||
exports.stashReadOnlyContent = stashReadOnlyContent; | ||
function openReadOnlyContent(node, content, fileExtension, options) { | ||
@@ -64,7 +71,21 @@ return __awaiter(this, void 0, void 0, function* () { | ||
exports.openReadOnlyContent = openReadOnlyContent; | ||
function disposeReadOnlyContents() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const contentProvider = getContentProvider(); | ||
contentProvider.disposeAll(); | ||
}); | ||
} | ||
exports.disposeReadOnlyContents = disposeReadOnlyContents; | ||
function disposeReadOnlyContent(uri) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const contentProvider = getContentProvider(); | ||
contentProvider.dispose(uri); | ||
}); | ||
} | ||
exports.disposeReadOnlyContent = disposeReadOnlyContent; | ||
class ReadOnlyContent { | ||
constructor(uri, emitter, content) { | ||
this._uri = uri; | ||
this._emitter = emitter; | ||
this._content = content; | ||
this.uri = uri; | ||
} | ||
@@ -77,3 +98,3 @@ get content() { | ||
this._content += content; | ||
this._emitter.fire(this._uri); | ||
this._emitter.fire(this.uri); | ||
}); | ||
@@ -83,3 +104,3 @@ } | ||
this._content = ''; | ||
this._emitter.fire(this._uri); | ||
this._emitter.fire(this.uri); | ||
} | ||
@@ -96,3 +117,3 @@ } | ||
} | ||
openReadOnlyContent(node, content, fileExtension, options) { | ||
stashReadOnlyContent(node, content, fileExtension) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -106,7 +127,13 @@ const scheme = getScheme(); | ||
this._contentMap.set(uri.toString(), readOnlyContent); | ||
yield vscode_1.window.showTextDocument(uri, options); | ||
this._onDidChangeEmitter.fire(uri); | ||
return readOnlyContent; | ||
}); | ||
} | ||
openReadOnlyContent(node, content, fileExtension, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const readOnlyContent = yield this.stashReadOnlyContent(node, content, fileExtension); | ||
yield vscode_1.window.showTextDocument(readOnlyContent.uri, options); | ||
this._onDidChangeEmitter.fire(readOnlyContent.uri); | ||
return readOnlyContent; | ||
}); | ||
} | ||
provideTextDocumentContent(uri, _token) { | ||
@@ -118,3 +145,9 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
dispose(uri) { | ||
this._contentMap.delete(uri.toString()); | ||
} | ||
disposeAll() { | ||
this._contentMap.clear(); | ||
} | ||
} | ||
//# sourceMappingURL=openReadOnlyContent.js.map |
@@ -23,2 +23,3 @@ "use strict"; | ||
const showWarningMessage_1 = require("./showWarningMessage"); | ||
const showWorkspaceFolderPick_1 = require("./showWorkspaceFolderPick"); | ||
class AzExtUserInput { | ||
@@ -93,2 +94,20 @@ constructor(context, onDidFinishPromptEmitter) { | ||
} | ||
showWorkspaceFolderPick(options) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
addStepTelemetry(this._context, options.stepName, 'WorkspaceFolderPick', options.placeHolder); | ||
if ((_a = this._context.ui.wizard) === null || _a === void 0 ? void 0 : _a.cancellationToken.isCancellationRequested) { | ||
throw new errors_1.UserCancelledError(); | ||
} | ||
try { | ||
this._isPrompting = true; | ||
const result = yield (0, showWorkspaceFolderPick_1.showWorkspaceFolderPick)(options); | ||
this._onDidFinishPromptEmitter.fire({ value: result }); | ||
return result; | ||
} | ||
finally { | ||
this._isPrompting = false; | ||
} | ||
}); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -95,0 +114,0 @@ showWarningMessage(message, ...args) { |
@@ -105,2 +105,23 @@ "use strict"; | ||
} | ||
showWorkspaceFolderPick(options) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
(0, AzExtUserInput_1.addStepTelemetry)(this._context, options.stepName, 'WorkspaceFolderPick', options.placeHolder); | ||
if ((_a = this._context.ui.wizard) === null || _a === void 0 ? void 0 : _a.cancellationToken.isCancellationRequested) { | ||
throw new errors_1.UserCancelledError(); | ||
} | ||
this._isPrompting = true; | ||
let result; | ||
const nextItemInQueue = this._inputsQueue.shift(); | ||
if (!nextItemInQueue) { | ||
result = yield this._realAzureUserInput.showWorkspaceFolderPick(options); | ||
} | ||
else { | ||
result = nextItemInQueue; | ||
this._onDidFinishPromptEmitter.fire({ value: result }); | ||
} | ||
this._isPrompting = false; | ||
return result; | ||
}); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -107,0 +128,0 @@ showWarningMessage(message, ...args) { |
@@ -43,5 +43,7 @@ "use strict"; | ||
function createSubscriptionContext(subscription) { | ||
return Object.assign(Object.assign({ subscriptionDisplayName: subscription.name, userId: '', subscriptionPath: subscription.subscriptionId }, subscription), { credentials: createCredential(subscription.authentication.getSession) }); | ||
return Object.assign(Object.assign({ subscriptionDisplayName: subscription.name, userId: '', subscriptionPath: subscription.subscriptionId }, subscription), { credentials: createCredential(subscription.authentication.getSession), createCredentialsForScopes: (scopes) => __awaiter(this, void 0, void 0, function* () { | ||
return createCredential(subscription.authentication.getSessionWithScopes.bind(subscription.authentication, scopes)); | ||
}) }); | ||
} | ||
exports.createSubscriptionContext = createSubscriptionContext; | ||
//# sourceMappingURL=credentialUtils.js.map |
@@ -34,3 +34,8 @@ "use strict"; | ||
function getRandomHexString(length = 6) { | ||
return crypto_1.crypto.randomUUID().slice(0, length); | ||
if (length <= 0) { | ||
throw new Error(`Length must be strictly positive`); | ||
} | ||
const array = new Uint8Array(Math.ceil(length / 2)); // Each byte is represented by 2 hex characters | ||
crypto_1.crypto.getRandomValues(array); | ||
return Buffer.from(array).toString('hex').slice(0, length); | ||
} | ||
@@ -37,0 +42,0 @@ randomUtils.getRandomHexString = getRandomHexString; |
{ | ||
"name": "@microsoft/vscode-azext-utils", | ||
"author": "Microsoft Corporation", | ||
"version": "2.5.3", | ||
"version": "2.5.4", | ||
"description": "Common UI tools for developing Azure extensions for VS Code", | ||
@@ -6,0 +6,0 @@ "tags": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
457871
95
8636
1