@eclipse-glsp/protocol
Advanced tools
Comparing version 1.1.0-next.87e91b0.235 to 1.1.0-next.8fb13fd.272
@@ -22,3 +22,3 @@ "use strict"; | ||
Action.hasKind = hasKind; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
var ActionMessage; | ||
@@ -31,3 +31,3 @@ (function (ActionMessage) { | ||
ActionMessage.is = is; | ||
})(ActionMessage = exports.ActionMessage || (exports.ActionMessage = {})); | ||
})(ActionMessage || (exports.ActionMessage = ActionMessage = {})); | ||
var RequestAction; | ||
@@ -53,3 +53,3 @@ (function (RequestAction) { | ||
RequestAction.generateRequestId = generateRequestId; | ||
})(RequestAction = exports.RequestAction || (exports.RequestAction = {})); | ||
})(RequestAction || (exports.RequestAction = RequestAction = {})); | ||
var ResponseAction; | ||
@@ -70,3 +70,3 @@ (function (ResponseAction) { | ||
ResponseAction.hasValidResponseId = hasValidResponseId; | ||
})(ResponseAction = exports.ResponseAction || (exports.ResponseAction = {})); | ||
})(ResponseAction || (exports.ResponseAction = ResponseAction = {})); | ||
var RejectAction; | ||
@@ -83,3 +83,3 @@ (function (RejectAction) { | ||
RejectAction.create = create; | ||
})(RejectAction = exports.RejectAction || (exports.RejectAction = {})); | ||
})(RejectAction || (exports.RejectAction = RejectAction = {})); | ||
var Operation; | ||
@@ -101,3 +101,3 @@ (function (Operation) { | ||
Operation.hasKind = hasKind; | ||
})(Operation = exports.Operation || (exports.Operation = {})); | ||
})(Operation || (exports.Operation = Operation = {})); | ||
var CompoundOperation; | ||
@@ -118,3 +118,3 @@ (function (CompoundOperation) { | ||
CompoundOperation.create = create; | ||
})(CompoundOperation = exports.CompoundOperation || (exports.CompoundOperation = {})); | ||
})(CompoundOperation || (exports.CompoundOperation = CompoundOperation = {})); | ||
//# sourceMappingURL=base-protocol.js.map |
@@ -53,6 +53,2 @@ import { Action } from './base-protocol'; | ||
details?: string; | ||
/** | ||
* Timeout after which a displayed message disappears. | ||
*/ | ||
timeout?: number; | ||
} | ||
@@ -65,5 +61,81 @@ export declare namespace ServerMessageAction { | ||
details?: string; | ||
timeout?: number; | ||
}): ServerMessageAction; | ||
} | ||
/** | ||
* Sent by the server to the client to request presenting the progress of a long running process in the UI. | ||
*/ | ||
export interface StartProgressAction extends Action { | ||
kind: typeof StartProgressAction.KIND; | ||
/** | ||
* An ID that can be used in subsequent `updateProgress` and `endProgress` events to make them refer to the same progress reporting. | ||
*/ | ||
progressId: string; | ||
/** | ||
* Short title of the progress reporting. Shown in the UI to describe the long running process. | ||
*/ | ||
title: string; | ||
/** | ||
* Optional additional progress message. Shown in the UI to describe the long running process. | ||
*/ | ||
message?: string; | ||
/** | ||
* Progress percentage to display (value range: 0 to 100). If omitted no percentage is shown. | ||
*/ | ||
percentage?: number; | ||
} | ||
export declare namespace StartProgressAction { | ||
const KIND = "startProgress"; | ||
function is(object: any): object is StartProgressAction; | ||
function create(options: { | ||
progressId: string; | ||
title: string; | ||
message?: string; | ||
percentage?: number; | ||
}): StartProgressAction; | ||
} | ||
/** | ||
* Sent by the server to the client to presenting an update of the progress of a long running process in the UI. | ||
*/ | ||
export interface UpdateProgressAction extends Action { | ||
kind: typeof UpdateProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
/** | ||
* The percentage (value range: 0 to 100) to show in the progress reporting. | ||
*/ | ||
percentage?: number; | ||
} | ||
export declare namespace UpdateProgressAction { | ||
const KIND = "updateProgress"; | ||
function is(object: any): object is UpdateProgressAction; | ||
function create(progressId: string, options?: { | ||
message?: string; | ||
percentage?: number; | ||
}): UpdateProgressAction; | ||
} | ||
/** | ||
* Sent by the server to the client to end the reporting of a progress. | ||
*/ | ||
export interface EndProgressAction extends Action { | ||
kind: typeof EndProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
} | ||
export declare namespace EndProgressAction { | ||
const KIND = "endProgress"; | ||
function is(object: any): object is EndProgressAction; | ||
function create(progressId: string, message?: string): EndProgressAction; | ||
} | ||
//# sourceMappingURL=client-notification.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ServerMessageAction = exports.ServerStatusAction = void 0; | ||
exports.EndProgressAction = exports.UpdateProgressAction = exports.StartProgressAction = exports.ServerMessageAction = exports.ServerStatusAction = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -32,3 +32,3 @@ * This program and the accompanying materials are made available under the | ||
ServerStatusAction.create = create; | ||
})(ServerStatusAction = exports.ServerStatusAction || (exports.ServerStatusAction = {})); | ||
})(ServerStatusAction || (exports.ServerStatusAction = ServerStatusAction = {})); | ||
var ServerMessageAction; | ||
@@ -45,3 +45,43 @@ (function (ServerMessageAction) { | ||
ServerMessageAction.create = create; | ||
})(ServerMessageAction = exports.ServerMessageAction || (exports.ServerMessageAction = {})); | ||
})(ServerMessageAction || (exports.ServerMessageAction = ServerMessageAction = {})); | ||
var StartProgressAction; | ||
(function (StartProgressAction) { | ||
StartProgressAction.KIND = 'startProgress'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, StartProgressAction.KIND) && (0, type_util_1.hasStringProp)(object, 'progressId') && (0, type_util_1.hasStringProp)(object, 'title'); | ||
} | ||
StartProgressAction.is = is; | ||
function create(options) { | ||
return Object.assign({ kind: StartProgressAction.KIND }, options); | ||
} | ||
StartProgressAction.create = create; | ||
})(StartProgressAction || (exports.StartProgressAction = StartProgressAction = {})); | ||
var UpdateProgressAction; | ||
(function (UpdateProgressAction) { | ||
UpdateProgressAction.KIND = 'updateProgress'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, UpdateProgressAction.KIND) && (0, type_util_1.hasStringProp)(object, 'progressId'); | ||
} | ||
UpdateProgressAction.is = is; | ||
function create(progressId, options = {}) { | ||
return Object.assign({ kind: UpdateProgressAction.KIND, progressId }, options); | ||
} | ||
UpdateProgressAction.create = create; | ||
})(UpdateProgressAction || (exports.UpdateProgressAction = UpdateProgressAction = {})); | ||
var EndProgressAction; | ||
(function (EndProgressAction) { | ||
EndProgressAction.KIND = 'endProgress'; | ||
function is(object) { | ||
return base_protocol_1.Action.hasKind(object, EndProgressAction.KIND) && (0, type_util_1.hasStringProp)(object, 'progressId'); | ||
} | ||
EndProgressAction.is = is; | ||
function create(progressId, message) { | ||
return { | ||
kind: EndProgressAction.KIND, | ||
progressId, | ||
message | ||
}; | ||
} | ||
EndProgressAction.create = create; | ||
})(EndProgressAction || (exports.EndProgressAction = EndProgressAction = {})); | ||
//# sourceMappingURL=client-notification.js.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
RequestClipboardDataAction.create = create; | ||
})(RequestClipboardDataAction = exports.RequestClipboardDataAction || (exports.RequestClipboardDataAction = {})); | ||
})(RequestClipboardDataAction || (exports.RequestClipboardDataAction = RequestClipboardDataAction = {})); | ||
var SetClipboardDataAction; | ||
@@ -45,3 +45,3 @@ (function (SetClipboardDataAction) { | ||
SetClipboardDataAction.create = create; | ||
})(SetClipboardDataAction = exports.SetClipboardDataAction || (exports.SetClipboardDataAction = {})); | ||
})(SetClipboardDataAction || (exports.SetClipboardDataAction = SetClipboardDataAction = {})); | ||
var CutOperation; | ||
@@ -62,3 +62,3 @@ (function (CutOperation) { | ||
CutOperation.create = create; | ||
})(CutOperation = exports.CutOperation || (exports.CutOperation = {})); | ||
})(CutOperation || (exports.CutOperation = CutOperation = {})); | ||
var PasteOperation; | ||
@@ -75,3 +75,3 @@ (function (PasteOperation) { | ||
PasteOperation.create = create; | ||
})(PasteOperation = exports.PasteOperation || (exports.PasteOperation = {})); | ||
})(PasteOperation || (exports.PasteOperation = PasteOperation = {})); | ||
//# sourceMappingURL=clipboard.js.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
RequestContextActions.create = create; | ||
})(RequestContextActions = exports.RequestContextActions || (exports.RequestContextActions = {})); | ||
})(RequestContextActions || (exports.RequestContextActions = RequestContextActions = {})); | ||
var SetContextActions; | ||
@@ -45,3 +45,3 @@ (function (SetContextActions) { | ||
SetContextActions.create = create; | ||
})(SetContextActions = exports.SetContextActions || (exports.SetContextActions = {})); | ||
})(SetContextActions || (exports.SetContextActions = SetContextActions = {})); | ||
//# sourceMappingURL=contexts.js.map |
@@ -35,3 +35,3 @@ "use strict"; | ||
ReconnectEdgeOperation.create = create; | ||
})(ReconnectEdgeOperation = exports.ReconnectEdgeOperation || (exports.ReconnectEdgeOperation = {})); | ||
})(ReconnectEdgeOperation || (exports.ReconnectEdgeOperation = ReconnectEdgeOperation = {})); | ||
var ChangeRoutingPointsOperation; | ||
@@ -52,3 +52,3 @@ (function (ChangeRoutingPointsOperation) { | ||
ChangeRoutingPointsOperation.create = create; | ||
})(ChangeRoutingPointsOperation = exports.ChangeRoutingPointsOperation || (exports.ChangeRoutingPointsOperation = {})); | ||
})(ChangeRoutingPointsOperation || (exports.ChangeRoutingPointsOperation = ChangeRoutingPointsOperation = {})); | ||
//# sourceMappingURL=edge-modification.js.map |
@@ -37,3 +37,3 @@ "use strict"; | ||
CreateOperation.hasKind = hasKind; | ||
})(CreateOperation = exports.CreateOperation || (exports.CreateOperation = {})); | ||
})(CreateOperation || (exports.CreateOperation = CreateOperation = {})); | ||
var CreateNodeOperation; | ||
@@ -50,3 +50,3 @@ (function (CreateNodeOperation) { | ||
CreateNodeOperation.create = create; | ||
})(CreateNodeOperation = exports.CreateNodeOperation || (exports.CreateNodeOperation = {})); | ||
})(CreateNodeOperation || (exports.CreateNodeOperation = CreateNodeOperation = {})); | ||
var CreateEdgeOperation; | ||
@@ -63,3 +63,3 @@ (function (CreateEdgeOperation) { | ||
CreateEdgeOperation.create = create; | ||
})(CreateEdgeOperation = exports.CreateEdgeOperation || (exports.CreateEdgeOperation = {})); | ||
})(CreateEdgeOperation || (exports.CreateEdgeOperation = CreateEdgeOperation = {})); | ||
var DeleteElementOperation; | ||
@@ -80,3 +80,3 @@ (function (DeleteElementOperation) { | ||
DeleteElementOperation.create = create; | ||
})(DeleteElementOperation = exports.DeleteElementOperation || (exports.DeleteElementOperation = {})); | ||
})(DeleteElementOperation || (exports.DeleteElementOperation = DeleteElementOperation = {})); | ||
//# sourceMappingURL=element-creation.js.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
RequestPopupModelAction.create = create; | ||
})(RequestPopupModelAction = exports.RequestPopupModelAction || (exports.RequestPopupModelAction = {})); | ||
})(RequestPopupModelAction || (exports.RequestPopupModelAction = RequestPopupModelAction = {})); | ||
var SetPopupModelAction; | ||
@@ -30,3 +30,3 @@ (function (SetPopupModelAction) { | ||
SetPopupModelAction.create = create; | ||
})(SetPopupModelAction = exports.SetPopupModelAction || (exports.SetPopupModelAction = {})); | ||
})(SetPopupModelAction || (exports.SetPopupModelAction = SetPopupModelAction = {})); | ||
//# sourceMappingURL=element-hover.js.map |
@@ -112,3 +112,3 @@ "use strict"; | ||
NavigationTarget.getTextPosition = getTextPosition; | ||
})(NavigationTarget = exports.NavigationTarget || (exports.NavigationTarget = {})); | ||
})(NavigationTarget || (exports.NavigationTarget = NavigationTarget = {})); | ||
var RequestNavigationTargetsAction; | ||
@@ -125,3 +125,3 @@ (function (RequestNavigationTargetsAction) { | ||
RequestNavigationTargetsAction.create = create; | ||
})(RequestNavigationTargetsAction = exports.RequestNavigationTargetsAction || (exports.RequestNavigationTargetsAction = {})); | ||
})(RequestNavigationTargetsAction || (exports.RequestNavigationTargetsAction = RequestNavigationTargetsAction = {})); | ||
var SetNavigationTargetsAction; | ||
@@ -138,3 +138,3 @@ (function (SetNavigationTargetsAction) { | ||
SetNavigationTargetsAction.create = create; | ||
})(SetNavigationTargetsAction = exports.SetNavigationTargetsAction || (exports.SetNavigationTargetsAction = {})); | ||
})(SetNavigationTargetsAction || (exports.SetNavigationTargetsAction = SetNavigationTargetsAction = {})); | ||
var NavigateToTargetAction; | ||
@@ -154,3 +154,3 @@ (function (NavigateToTargetAction) { | ||
NavigateToTargetAction.create = create; | ||
})(NavigateToTargetAction = exports.NavigateToTargetAction || (exports.NavigateToTargetAction = {})); | ||
})(NavigateToTargetAction || (exports.NavigateToTargetAction = NavigateToTargetAction = {})); | ||
var ResolveNavigationTargetAction; | ||
@@ -167,3 +167,3 @@ (function (ResolveNavigationTargetAction) { | ||
ResolveNavigationTargetAction.create = create; | ||
})(ResolveNavigationTargetAction = exports.ResolveNavigationTargetAction || (exports.ResolveNavigationTargetAction = {})); | ||
})(ResolveNavigationTargetAction || (exports.ResolveNavigationTargetAction = ResolveNavigationTargetAction = {})); | ||
var SetResolvedNavigationTargetAction; | ||
@@ -180,3 +180,3 @@ (function (SetResolvedNavigationTargetAction) { | ||
SetResolvedNavigationTargetAction.create = create; | ||
})(SetResolvedNavigationTargetAction = exports.SetResolvedNavigationTargetAction || (exports.SetResolvedNavigationTargetAction = {})); | ||
})(SetResolvedNavigationTargetAction || (exports.SetResolvedNavigationTargetAction = SetResolvedNavigationTargetAction = {})); | ||
var NavigateToExternalTargetAction; | ||
@@ -196,3 +196,3 @@ (function (NavigateToExternalTargetAction) { | ||
NavigateToExternalTargetAction.create = create; | ||
})(NavigateToExternalTargetAction = exports.NavigateToExternalTargetAction || (exports.NavigateToExternalTargetAction = {})); | ||
})(NavigateToExternalTargetAction || (exports.NavigateToExternalTargetAction = NavigateToExternalTargetAction = {})); | ||
//# sourceMappingURL=element-navigation.js.map |
@@ -35,2 +35,6 @@ /******************************************************************************** | ||
deselectedElementsIDs: string[]; | ||
/** | ||
* Whether all currently selected elements should be deselected. | ||
*/ | ||
deselectAll?: boolean; | ||
} | ||
@@ -42,4 +46,7 @@ export declare namespace SelectAction { | ||
selectedElementsIDs?: string[]; | ||
deselectedElementsIDs?: string[]; | ||
deselectedElementsIDs?: string[] | boolean; | ||
}): SelectAction; | ||
function addSelection(selectedElementsIDs: string[]): SelectAction; | ||
function removeSelection(deselectedElementsIDs: string[]): SelectAction; | ||
function setSelection(selectedElementsIDs: string[]): SelectAction; | ||
} | ||
@@ -46,0 +53,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SelectAllAction = exports.SelectAction = void 0; | ||
const array_util_1 = require("../utils/array-util"); | ||
const type_util_1 = require("../utils/type-util"); | ||
@@ -14,6 +15,25 @@ const base_protocol_1 = require("./base-protocol"); | ||
function create(options = {}) { | ||
return Object.assign({ kind: SelectAction.KIND, selectedElementsIDs: [], deselectedElementsIDs: [] }, options); | ||
var _a, _b; | ||
const deselectedElementsIDs = (_a = options.deselectedElementsIDs) !== null && _a !== void 0 ? _a : []; | ||
return { | ||
kind: SelectAction.KIND, | ||
selectedElementsIDs: (_b = options.selectedElementsIDs) !== null && _b !== void 0 ? _b : [], | ||
deselectedElementsIDs: (0, array_util_1.isStringArray)(deselectedElementsIDs, true) ? deselectedElementsIDs : [], | ||
deselectAll: typeof deselectedElementsIDs === 'boolean' ? deselectedElementsIDs : false | ||
}; | ||
} | ||
SelectAction.create = create; | ||
})(SelectAction = exports.SelectAction || (exports.SelectAction = {})); | ||
function addSelection(selectedElementsIDs) { | ||
return create({ selectedElementsIDs }); | ||
} | ||
SelectAction.addSelection = addSelection; | ||
function removeSelection(deselectedElementsIDs) { | ||
return create({ deselectedElementsIDs }); | ||
} | ||
SelectAction.removeSelection = removeSelection; | ||
function setSelection(selectedElementsIDs) { | ||
return create({ selectedElementsIDs, deselectedElementsIDs: true }); | ||
} | ||
SelectAction.setSelection = setSelection; | ||
})(SelectAction || (exports.SelectAction = SelectAction = {})); | ||
var SelectAllAction; | ||
@@ -33,3 +53,3 @@ (function (SelectAllAction) { | ||
SelectAllAction.create = create; | ||
})(SelectAllAction = exports.SelectAllAction || (exports.SelectAllAction = {})); | ||
})(SelectAllAction || (exports.SelectAllAction = SelectAllAction = {})); | ||
//# sourceMappingURL=element-selection.js.map |
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource and others. | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
@@ -4,0 +4,0 @@ * This program and the accompanying materials are made available under the |
@@ -20,3 +20,3 @@ "use strict"; | ||
RequestEditValidationAction.create = create; | ||
})(RequestEditValidationAction = exports.RequestEditValidationAction || (exports.RequestEditValidationAction = {})); | ||
})(RequestEditValidationAction || (exports.RequestEditValidationAction = RequestEditValidationAction = {})); | ||
var SetEditValidationResultAction; | ||
@@ -33,3 +33,3 @@ (function (SetEditValidationResultAction) { | ||
SetEditValidationResultAction.create = create; | ||
})(SetEditValidationResultAction = exports.SetEditValidationResultAction || (exports.SetEditValidationResultAction = {})); | ||
})(SetEditValidationResultAction || (exports.SetEditValidationResultAction = SetEditValidationResultAction = {})); | ||
var ApplyLabelEditOperation; | ||
@@ -46,3 +46,3 @@ (function (ApplyLabelEditOperation) { | ||
ApplyLabelEditOperation.create = create; | ||
})(ApplyLabelEditOperation = exports.ApplyLabelEditOperation || (exports.ApplyLabelEditOperation = {})); | ||
})(ApplyLabelEditOperation || (exports.ApplyLabelEditOperation = ApplyLabelEditOperation = {})); | ||
var ValidationStatus; | ||
@@ -53,3 +53,2 @@ (function (ValidationStatus) { | ||
*/ | ||
// eslint-disable-next-line no-shadow | ||
let Severity; | ||
@@ -62,3 +61,2 @@ (function (Severity) { | ||
Severity[Severity["OK"] = 4] = "OK"; | ||
// eslint-disable-next-line no-shadow | ||
Severity[Severity["NONE"] = 5] = "NONE"; | ||
@@ -106,3 +104,3 @@ })(Severity = ValidationStatus.Severity || (ValidationStatus.Severity = {})); | ||
ValidationStatus.isError = isError; | ||
})(ValidationStatus = exports.ValidationStatus || (exports.ValidationStatus = {})); | ||
})(ValidationStatus || (exports.ValidationStatus = ValidationStatus = {})); | ||
//# sourceMappingURL=element-text-editing.js.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
RequestTypeHintsAction.create = create; | ||
})(RequestTypeHintsAction = exports.RequestTypeHintsAction || (exports.RequestTypeHintsAction = {})); | ||
})(RequestTypeHintsAction || (exports.RequestTypeHintsAction = RequestTypeHintsAction = {})); | ||
var SetTypeHintsAction; | ||
@@ -45,3 +45,3 @@ (function (SetTypeHintsAction) { | ||
SetTypeHintsAction.create = create; | ||
})(SetTypeHintsAction = exports.SetTypeHintsAction || (exports.SetTypeHintsAction = {})); | ||
})(SetTypeHintsAction || (exports.SetTypeHintsAction = SetTypeHintsAction = {})); | ||
//# sourceMappingURL=element-type-hints.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -30,3 +30,3 @@ * This program and the accompanying materials are made available under the | ||
MarkerKind.ERROR = 'error'; | ||
})(MarkerKind = exports.MarkerKind || (exports.MarkerKind = {})); | ||
})(MarkerKind || (exports.MarkerKind = MarkerKind = {})); | ||
/** | ||
@@ -41,3 +41,3 @@ * The default reasons for markers. | ||
MarkersReason.LIVE = 'live'; | ||
})(MarkersReason = exports.MarkersReason || (exports.MarkersReason = {})); | ||
})(MarkersReason || (exports.MarkersReason = MarkersReason = {})); | ||
var RequestMarkersAction; | ||
@@ -54,3 +54,3 @@ (function (RequestMarkersAction) { | ||
RequestMarkersAction.create = create; | ||
})(RequestMarkersAction = exports.RequestMarkersAction || (exports.RequestMarkersAction = {})); | ||
})(RequestMarkersAction || (exports.RequestMarkersAction = RequestMarkersAction = {})); | ||
var SetMarkersAction; | ||
@@ -67,3 +67,3 @@ (function (SetMarkersAction) { | ||
SetMarkersAction.create = create; | ||
})(SetMarkersAction = exports.SetMarkersAction || (exports.SetMarkersAction = {})); | ||
})(SetMarkersAction || (exports.SetMarkersAction = SetMarkersAction = {})); | ||
var DeleteMarkersAction; | ||
@@ -83,3 +83,3 @@ (function (DeleteMarkersAction) { | ||
DeleteMarkersAction.create = create; | ||
})(DeleteMarkersAction = exports.DeleteMarkersAction || (exports.DeleteMarkersAction = {})); | ||
})(DeleteMarkersAction || (exports.DeleteMarkersAction = DeleteMarkersAction = {})); | ||
//# sourceMappingURL=element-validation.js.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
RequestModelAction.create = create; | ||
})(RequestModelAction = exports.RequestModelAction || (exports.RequestModelAction = {})); | ||
})(RequestModelAction || (exports.RequestModelAction = RequestModelAction = {})); | ||
var SetModelAction; | ||
@@ -30,3 +30,3 @@ (function (SetModelAction) { | ||
SetModelAction.create = create; | ||
})(SetModelAction = exports.SetModelAction || (exports.SetModelAction = {})); | ||
})(SetModelAction || (exports.SetModelAction = SetModelAction = {})); | ||
var UpdateModelAction; | ||
@@ -43,3 +43,3 @@ (function (UpdateModelAction) { | ||
UpdateModelAction.create = create; | ||
})(UpdateModelAction = exports.UpdateModelAction || (exports.UpdateModelAction = {})); | ||
})(UpdateModelAction || (exports.UpdateModelAction = UpdateModelAction = {})); | ||
var SourceModelChangedAction; | ||
@@ -59,3 +59,3 @@ (function (SourceModelChangedAction) { | ||
SourceModelChangedAction.create = create; | ||
})(SourceModelChangedAction = exports.SourceModelChangedAction || (exports.SourceModelChangedAction = {})); | ||
})(SourceModelChangedAction || (exports.SourceModelChangedAction = SourceModelChangedAction = {})); | ||
//# sourceMappingURL=model-data.js.map |
@@ -35,3 +35,3 @@ "use strict"; | ||
SetEditModeAction.create = create; | ||
})(SetEditModeAction = exports.SetEditModeAction || (exports.SetEditModeAction = {})); | ||
})(SetEditModeAction || (exports.SetEditModeAction = SetEditModeAction = {})); | ||
/** | ||
@@ -44,3 +44,3 @@ * The potential default values for the `editMode` property of a {@link SetEditModeAction}. | ||
EditMode.EDITABLE = 'editable'; | ||
})(EditMode = exports.EditMode || (exports.EditMode = {})); | ||
})(EditMode || (exports.EditMode = EditMode = {})); | ||
//# sourceMappingURL=model-edit-mode.js.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
RequestBoundsAction.create = create; | ||
})(RequestBoundsAction = exports.RequestBoundsAction || (exports.RequestBoundsAction = {})); | ||
})(RequestBoundsAction || (exports.RequestBoundsAction = RequestBoundsAction = {})); | ||
var ComputedBoundsAction; | ||
@@ -30,3 +30,3 @@ (function (ComputedBoundsAction) { | ||
ComputedBoundsAction.create = create; | ||
})(ComputedBoundsAction = exports.ComputedBoundsAction || (exports.ComputedBoundsAction = {})); | ||
})(ComputedBoundsAction || (exports.ComputedBoundsAction = ComputedBoundsAction = {})); | ||
var LayoutOperation; | ||
@@ -47,3 +47,3 @@ (function (LayoutOperation) { | ||
LayoutOperation.create = create; | ||
})(LayoutOperation = exports.LayoutOperation || (exports.LayoutOperation = {})); | ||
})(LayoutOperation || (exports.LayoutOperation = LayoutOperation = {})); | ||
//# sourceMappingURL=model-layout.js.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
SaveModelAction.create = create; | ||
})(SaveModelAction = exports.SaveModelAction || (exports.SaveModelAction = {})); | ||
})(SaveModelAction || (exports.SaveModelAction = SaveModelAction = {})); | ||
var SetDirtyStateAction; | ||
@@ -45,3 +45,3 @@ (function (SetDirtyStateAction) { | ||
SetDirtyStateAction.create = create; | ||
})(SetDirtyStateAction = exports.SetDirtyStateAction || (exports.SetDirtyStateAction = {})); | ||
})(SetDirtyStateAction || (exports.SetDirtyStateAction = SetDirtyStateAction = {})); | ||
var RequestExportSvgAction; | ||
@@ -58,3 +58,3 @@ (function (RequestExportSvgAction) { | ||
RequestExportSvgAction.create = create; | ||
})(RequestExportSvgAction = exports.RequestExportSvgAction || (exports.RequestExportSvgAction = {})); | ||
})(RequestExportSvgAction || (exports.RequestExportSvgAction = RequestExportSvgAction = {})); | ||
var ExportSvgAction; | ||
@@ -71,3 +71,3 @@ (function (ExportSvgAction) { | ||
ExportSvgAction.create = create; | ||
})(ExportSvgAction = exports.ExportSvgAction || (exports.ExportSvgAction = {})); | ||
})(ExportSvgAction || (exports.ExportSvgAction = ExportSvgAction = {})); | ||
//# sourceMappingURL=model-saving.js.map |
@@ -16,3 +16,3 @@ "use strict"; | ||
SModelElementSchema.is = is; | ||
})(SModelElementSchema = exports.SModelElementSchema || (exports.SModelElementSchema = {})); | ||
})(SModelElementSchema || (exports.SModelElementSchema = SModelElementSchema = {})); | ||
//# sourceMappingURL=model-structure.js.map |
@@ -36,3 +36,3 @@ "use strict"; | ||
ChangeBoundsOperation.create = create; | ||
})(ChangeBoundsOperation = exports.ChangeBoundsOperation || (exports.ChangeBoundsOperation = {})); | ||
})(ChangeBoundsOperation || (exports.ChangeBoundsOperation = ChangeBoundsOperation = {})); | ||
var ChangeContainerOperation; | ||
@@ -49,3 +49,3 @@ (function (ChangeContainerOperation) { | ||
ChangeContainerOperation.create = create; | ||
})(ChangeContainerOperation = exports.ChangeContainerOperation || (exports.ChangeContainerOperation = {})); | ||
})(ChangeContainerOperation || (exports.ChangeContainerOperation = ChangeContainerOperation = {})); | ||
//# sourceMappingURL=node-modification.js.map |
@@ -32,3 +32,3 @@ "use strict"; | ||
TriggerNodeCreationAction.create = create; | ||
})(TriggerNodeCreationAction = exports.TriggerNodeCreationAction || (exports.TriggerNodeCreationAction = {})); | ||
})(TriggerNodeCreationAction || (exports.TriggerNodeCreationAction = TriggerNodeCreationAction = {})); | ||
var TriggerEdgeCreationAction; | ||
@@ -45,3 +45,3 @@ (function (TriggerEdgeCreationAction) { | ||
TriggerEdgeCreationAction.create = create; | ||
})(TriggerEdgeCreationAction = exports.TriggerEdgeCreationAction || (exports.TriggerEdgeCreationAction = {})); | ||
})(TriggerEdgeCreationAction || (exports.TriggerEdgeCreationAction = TriggerEdgeCreationAction = {})); | ||
//# sourceMappingURL=tool-palette.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
EditorContext.is = is; | ||
})(EditorContext = exports.EditorContext || (exports.EditorContext = {})); | ||
})(EditorContext || (exports.EditorContext = EditorContext = {})); | ||
var LabeledAction; | ||
@@ -30,3 +30,3 @@ (function (LabeledAction) { | ||
LabeledAction.toActionArray = toActionArray; | ||
})(LabeledAction = exports.LabeledAction || (exports.LabeledAction = {})); | ||
})(LabeledAction || (exports.LabeledAction = LabeledAction = {})); | ||
var PaletteItem; | ||
@@ -52,3 +52,3 @@ (function (PaletteItem) { | ||
PaletteItem.isTriggerElementCreationAction = isTriggerElementCreationAction; | ||
})(PaletteItem = exports.PaletteItem || (exports.PaletteItem = {})); | ||
})(PaletteItem || (exports.PaletteItem = PaletteItem = {})); | ||
var MenuItem; | ||
@@ -60,3 +60,3 @@ (function (MenuItem) { | ||
MenuItem.is = is; | ||
})(MenuItem = exports.MenuItem || (exports.MenuItem = {})); | ||
})(MenuItem || (exports.MenuItem = MenuItem = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -33,3 +33,3 @@ "use strict"; | ||
UndoAction.create = create; | ||
})(UndoAction = exports.UndoAction || (exports.UndoAction = {})); | ||
})(UndoAction || (exports.UndoAction = UndoAction = {})); | ||
var RedoAction; | ||
@@ -48,3 +48,3 @@ (function (RedoAction) { | ||
RedoAction.create = create; | ||
})(RedoAction = exports.RedoAction || (exports.RedoAction = {})); | ||
})(RedoAction || (exports.RedoAction = RedoAction = {})); | ||
//# sourceMappingURL=undo-redo.js.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
CenterAction.create = create; | ||
})(CenterAction = exports.CenterAction || (exports.CenterAction = {})); | ||
})(CenterAction || (exports.CenterAction = CenterAction = {})); | ||
var FitToScreenAction; | ||
@@ -30,3 +30,3 @@ (function (FitToScreenAction) { | ||
FitToScreenAction.create = create; | ||
})(FitToScreenAction = exports.FitToScreenAction || (exports.FitToScreenAction = {})); | ||
})(FitToScreenAction || (exports.FitToScreenAction = FitToScreenAction = {})); | ||
//# sourceMappingURL=viewport.js.map |
@@ -31,7 +31,11 @@ /******************************************************************************** | ||
export * from './action-protocol'; | ||
export * from './disposable/disposable'; | ||
export * from './glsp-client'; | ||
export * from './jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './jsonrpc/glsp-jsonrpc-client'; | ||
export * from './jsonrpc/websocket-connection'; | ||
export * from './client-server-protocol/base-glsp-client'; | ||
export * from './client-server-protocol/glsp-client'; | ||
export * from './client-server-protocol/glsp-server'; | ||
export * from './client-server-protocol/jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-server'; | ||
export * from './client-server-protocol/jsonrpc/websocket-connection'; | ||
export * from './client-server-protocol/jsonrpc/ws-connection-provider'; | ||
export * from './client-server-protocol/types'; | ||
export * from './model/default-types'; | ||
@@ -41,4 +45,6 @@ export * from './model/model-schema'; | ||
export * from './utils/di-util'; | ||
export * from './utils/disposable'; | ||
export * from './utils/event'; | ||
export * from './utils/type-util'; | ||
export { SetBoundsAction, SetViewportAction }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -49,7 +49,11 @@ "use strict"; | ||
__exportStar(require("./action-protocol"), exports); | ||
__exportStar(require("./disposable/disposable"), exports); | ||
__exportStar(require("./glsp-client"), exports); | ||
__exportStar(require("./jsonrpc/base-jsonrpc-glsp-client"), exports); | ||
__exportStar(require("./jsonrpc/glsp-jsonrpc-client"), exports); | ||
__exportStar(require("./jsonrpc/websocket-connection"), exports); | ||
__exportStar(require("./client-server-protocol/base-glsp-client"), exports); | ||
__exportStar(require("./client-server-protocol/glsp-client"), exports); | ||
__exportStar(require("./client-server-protocol/glsp-server"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/base-jsonrpc-glsp-client"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/glsp-jsonrpc-client"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/glsp-jsonrpc-server"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/websocket-connection"), exports); | ||
__exportStar(require("./client-server-protocol/jsonrpc/ws-connection-provider"), exports); | ||
__exportStar(require("./client-server-protocol/types"), exports); | ||
__exportStar(require("./model/default-types"), exports); | ||
@@ -59,3 +63,5 @@ __exportStar(require("./model/model-schema"), exports); | ||
__exportStar(require("./utils/di-util"), exports); | ||
__exportStar(require("./utils/disposable"), exports); | ||
__exportStar(require("./utils/event"), exports); | ||
__exportStar(require("./utils/type-util"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -50,3 +50,3 @@ "use strict"; | ||
DefaultTypes.NODE_DIAMOND = 'node:diamond'; | ||
})(DefaultTypes = exports.DefaultTypes || (exports.DefaultTypes = {})); | ||
})(DefaultTypes || (exports.DefaultTypes = DefaultTypes = {})); | ||
//# sourceMappingURL=default-types.js.map |
@@ -30,11 +30,17 @@ /******************************************************************************** | ||
* Initializes a container with the given {@link ContainerConfiguration}. The container configuration | ||
* consists of the set of {@link ContainerModule}s that should be loaded in the container and/or | ||
* consists of the set of {@link ContainerModule}s that should be loaded in the container. | ||
* In addition, for more fine-grained control {@link ModuleConfiguration}s can be passed as part fo the container configuration | ||
* Module loading is distinct,this means each module will only get loaded once even if it is configured multiple times. | ||
@param containerConfiguration | ||
@param containerConfigurations | ||
* Custom modules to be loaded in addition to the default modules and/or default modules that should be excluded. | ||
@returns The initialized container. | ||
*/ | ||
export declare function initializeContainer(container: Container, ...containerConfiguration: ContainerConfiguration): Container; | ||
export declare function initializeContainer(container: Container, ...containerConfigurations: ContainerConfiguration): Container; | ||
/** | ||
* Processes the given container configurations and returns the corresponding set of {@link ContainerModule}s. | ||
* @param containerConfigurations The container configurations to resolves | ||
* @returns an Array of resolved container modules | ||
*/ | ||
export declare function resolveContainerConfiguration(...containerConfigurations: ContainerConfiguration): ContainerModule[]; | ||
/** | ||
* Union type for the set of {@link ContainerModule}s and addition {@link ModuleConfiguration}s | ||
@@ -55,2 +61,42 @@ * used to configure a DI container. | ||
/** | ||
* Optional constructor options for {@link FeatureModule}s. | ||
*/ | ||
export interface FeatureModuleOptions { | ||
/** | ||
* The set of feature modules that is required in order for this module to load. | ||
*/ | ||
requires?: MaybeArray<FeatureModule>; | ||
/** | ||
* Optional `featureId` that should be used. If omitted an id will be autogenerated | ||
*/ | ||
featureId?: symbol; | ||
} | ||
/** | ||
* A `FeatureModule` is a specialized {@link ContainerModule} that can declare dependencies to other {@link FeatureModule}. | ||
* A feature module will only be loaded into a container if all of its required modules haven been loaded before. T | ||
* Each feature module binds its `featureId` be default. This enables querying of existing container to check wether a | ||
* feature module has been loaded into this container. | ||
*/ | ||
export declare class FeatureModule extends ContainerModule { | ||
readonly featureId: symbol; | ||
readonly requires?: MaybeArray<FeatureModule>; | ||
constructor(registry: interfaces.ContainerModuleCallBack, options?: FeatureModuleOptions); | ||
protected createFeatureId(): symbol; | ||
/** | ||
* Configures the feature module i.e. checks if the requirements are met. | ||
* If this is the case the {@link FeatureModule.featureId} will be bound and the module will be loaded | ||
* @param bind container bind function | ||
* @param isBound container isBound function | ||
* @returns `true` if all requirements are met and the module is loaded. `false` otherwise | ||
*/ | ||
configure(bind: interfaces.Bind, isBound: interfaces.IsBound): boolean; | ||
/** | ||
* Checks if all required {@link FeatureModule}s are already loaded/bound in the container. | ||
* @param isBound The `isBound` property of the module callback. Used to check the required modules. | ||
* @returns `true` if all requirements are met, `false` otherwise | ||
*/ | ||
protected checkRequirements(isBound: interfaces.IsBound): boolean; | ||
isLoaded(context: Pick<BindingContext, 'isBound'>): boolean; | ||
} | ||
/** | ||
* Checks wether the given service identifier is already bound in the given context | ||
@@ -57,0 +103,0 @@ * then either calls the `bind` or `rebind` function respectively. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bindAsService = exports.lazyBind = exports.bindOrRebind = exports.initializeContainer = void 0; | ||
exports.bindAsService = exports.lazyBind = exports.bindOrRebind = exports.FeatureModule = exports.resolveContainerConfiguration = exports.initializeContainer = void 0; | ||
/******************************************************************************** | ||
* Copyright (c) 2023 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
const inversify_1 = require("inversify"); | ||
const array_util_1 = require("./array-util"); | ||
@@ -8,12 +24,23 @@ const type_util_1 = require("./type-util"); | ||
* Initializes a container with the given {@link ContainerConfiguration}. The container configuration | ||
* consists of the set of {@link ContainerModule}s that should be loaded in the container and/or | ||
* consists of the set of {@link ContainerModule}s that should be loaded in the container. | ||
* In addition, for more fine-grained control {@link ModuleConfiguration}s can be passed as part fo the container configuration | ||
* Module loading is distinct,this means each module will only get loaded once even if it is configured multiple times. | ||
@param containerConfiguration | ||
@param containerConfigurations | ||
* Custom modules to be loaded in addition to the default modules and/or default modules that should be excluded. | ||
@returns The initialized container. | ||
*/ | ||
function initializeContainer(container, ...containerConfiguration) { | ||
function initializeContainer(container, ...containerConfigurations) { | ||
const modules = resolveContainerConfiguration(...containerConfigurations); | ||
container.load(...modules); | ||
return container; | ||
} | ||
exports.initializeContainer = initializeContainer; | ||
/** | ||
* Processes the given container configurations and returns the corresponding set of {@link ContainerModule}s. | ||
* @param containerConfigurations The container configurations to resolves | ||
* @returns an Array of resolved container modules | ||
*/ | ||
function resolveContainerConfiguration(...containerConfigurations) { | ||
const modules = []; | ||
containerConfiguration.forEach(config => { | ||
containerConfigurations.forEach(config => { | ||
if (isContainerModule(config)) { | ||
@@ -31,6 +58,5 @@ (0, array_util_1.distinctAdd)(modules, config); | ||
}); | ||
container.load(...modules); | ||
return container; | ||
return modules; | ||
} | ||
exports.initializeContainer = initializeContainer; | ||
exports.resolveContainerConfiguration = resolveContainerConfiguration; | ||
/** | ||
@@ -45,2 +71,49 @@ * The container modules might originate form different inversify contexts (e.g. `inversify` vs. `@theia/core/shared/inversify`). | ||
/** | ||
* A `FeatureModule` is a specialized {@link ContainerModule} that can declare dependencies to other {@link FeatureModule}. | ||
* A feature module will only be loaded into a container if all of its required modules haven been loaded before. T | ||
* Each feature module binds its `featureId` be default. This enables querying of existing container to check wether a | ||
* feature module has been loaded into this container. | ||
*/ | ||
class FeatureModule extends inversify_1.ContainerModule { | ||
constructor(registry, options = {}) { | ||
var _a; | ||
super((bind, unbind, isBound, ...rest) => { | ||
if (this.configure(bind, isBound)) { | ||
registry(bind, unbind, isBound, ...rest); | ||
} | ||
}); | ||
this.featureId = (_a = options.featureId) !== null && _a !== void 0 ? _a : this.createFeatureId(); | ||
this.requires = options.requires; | ||
} | ||
createFeatureId() { | ||
return Symbol(this.id); | ||
} | ||
/** | ||
* Configures the feature module i.e. checks if the requirements are met. | ||
* If this is the case the {@link FeatureModule.featureId} will be bound and the module will be loaded | ||
* @param bind container bind function | ||
* @param isBound container isBound function | ||
* @returns `true` if all requirements are met and the module is loaded. `false` otherwise | ||
*/ | ||
configure(bind, isBound) { | ||
if (this.checkRequirements(isBound)) { | ||
bind(this.featureId).toConstantValue(this.featureId); | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
* Checks if all required {@link FeatureModule}s are already loaded/bound in the container. | ||
* @param isBound The `isBound` property of the module callback. Used to check the required modules. | ||
* @returns `true` if all requirements are met, `false` otherwise | ||
*/ | ||
checkRequirements(isBound) { | ||
return this.requires ? (0, array_util_1.asArray)(this.requires).every(module => isBound(module.featureId)) : true; | ||
} | ||
isLoaded(context) { | ||
return context.isBound(this.featureId); | ||
} | ||
} | ||
exports.FeatureModule = FeatureModule; | ||
/** | ||
* Checks wether the given service identifier is already bound in the given context | ||
@@ -47,0 +120,0 @@ * then either calls the `bind` or `rebind` function respectively. |
@@ -59,2 +59,7 @@ /******************************************************************************** | ||
/** | ||
* Utility type that represents an arbitrary function. Should be used instead | ||
* of the default `Function` type which is considered to be unsafe. | ||
*/ | ||
export type SafeFunction<T = any> = (...args: any[]) => T; | ||
/** | ||
* Validates whether the given object has a property of type `string` with the given key. | ||
@@ -61,0 +66,0 @@ * @param object The object that should be validated |
@@ -31,3 +31,3 @@ "use strict"; | ||
AnyObject.is = is; | ||
})(AnyObject = exports.AnyObject || (exports.AnyObject = {})); | ||
})(AnyObject || (exports.AnyObject = AnyObject = {})); | ||
/** | ||
@@ -51,3 +51,4 @@ * Utility function that create a typeguard function for a given class constructor. | ||
function hasStringProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? typeof object[propertyKey] === 'string' : optional; | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'string' : optional; | ||
} | ||
@@ -63,3 +64,4 @@ exports.hasStringProp = hasStringProp; | ||
function hasBooleanProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? typeof object[propertyKey] === 'boolean' : optional; | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'boolean' : optional; | ||
} | ||
@@ -75,3 +77,4 @@ exports.hasBooleanProp = hasBooleanProp; | ||
function hasNumberProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? typeof object[propertyKey] === 'number' : optional; | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'number' : optional; | ||
} | ||
@@ -87,3 +90,4 @@ exports.hasNumberProp = hasNumberProp; | ||
function hasObjectProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? AnyObject.is(object[propertyKey]) : optional; | ||
const property = object[propertyKey]; | ||
return property !== undefined ? AnyObject.is(property) : optional; | ||
} | ||
@@ -99,3 +103,4 @@ exports.hasObjectProp = hasObjectProp; | ||
function hasFunctionProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? typeof object[propertyKey] === 'function' : optional; | ||
const property = object[propertyKey]; | ||
return property !== undefined ? typeof property === 'function' : optional; | ||
} | ||
@@ -111,5 +116,6 @@ exports.hasFunctionProp = hasFunctionProp; | ||
function hasArrayProp(object, propertyKey, optional = false) { | ||
return propertyKey in object ? Array.isArray(object[propertyKey]) : optional; | ||
const property = object[propertyKey]; | ||
return property !== undefined ? Array.isArray(property) : optional; | ||
} | ||
exports.hasArrayProp = hasArrayProp; | ||
//# sourceMappingURL=type-util.js.map |
{ | ||
"name": "@eclipse-glsp/protocol", | ||
"version": "1.1.0-next.87e91b0.235+87e91b0", | ||
"version": "1.1.0-next.8fb13fd.272+8fb13fd", | ||
"description": "The protocol definition for client-server communication in GLSP", | ||
@@ -49,3 +49,3 @@ "keywords": [ | ||
"dependencies": { | ||
"sprotty-protocol": "0.13.0-next.f4445dd.342", | ||
"sprotty-protocol": "0.14.0-next.02bbac0.26", | ||
"uuid": "7.0.3", | ||
@@ -63,3 +63,3 @@ "vscode-jsonrpc": "^8.0.2" | ||
}, | ||
"gitHead": "87e91b0f13ed3e1b1b76799bf7fa513c9295dda6" | ||
"gitHead": "8fb13fdbf29abff6ac0e4d0c4903ab6eed54e97f" | ||
} |
@@ -11,4 +11,4 @@ # Eclipse GLSP - Protocol | ||
For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/). | ||
If you have questions, contact us on our [spectrum chat](https://spectrum.chat/glsp/) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). | ||
If you have questions, please raise them in the [discussions](https://github.com/eclipse-glsp/glsp/discussions) and have a look at our [communication and support options](https://www.eclipse.org/glsp/contact/). | ||
![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif) |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -18,3 +18,9 @@ * This program and the accompanying materials are made available under the | ||
import { expect } from 'chai'; | ||
import { ServerMessageAction, ServerStatusAction } from './client-notification'; | ||
import { | ||
EndProgressAction, | ||
ServerMessageAction, | ||
ServerStatusAction, | ||
StartProgressAction, | ||
UpdateProgressAction | ||
} from './client-notification'; | ||
/** | ||
@@ -83,10 +89,109 @@ * Tests for the utility functions declared in the namespaces of the protocol | ||
details: 'details', | ||
severity: 'ERROR', | ||
timeout: 5 | ||
severity: 'ERROR' | ||
}; | ||
const { message, severity, timeout, details } = expected; | ||
expect(ServerMessageAction.create(message, { severity, timeout, details })).to.deep.equals(expected); | ||
const { message, severity, details } = expected; | ||
expect(ServerMessageAction.create(message, { severity, details })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('StartProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: StartProgressAction = { kind: 'startProgress', progressId: '1', title: 'Progress title' }; | ||
expect(StartProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(StartProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(StartProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const title = 'Progress title'; | ||
const expected: StartProgressAction = { kind: StartProgressAction.KIND, progressId, title }; | ||
expect(StartProgressAction.create({ progressId, title })).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: StartProgressAction = { | ||
kind: StartProgressAction.KIND, | ||
progressId: '1', | ||
title: 'Progress title', | ||
message: 'Some message', | ||
percentage: 10 | ||
}; | ||
const { progressId, title, message, percentage } = expected; | ||
expect(StartProgressAction.create({ progressId, title, message, percentage })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('UpdateProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: UpdateProgressAction = { kind: 'updateProgress', progressId: '1' }; | ||
expect(UpdateProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(UpdateProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(UpdateProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const expected: UpdateProgressAction = { kind: UpdateProgressAction.KIND, progressId }; | ||
expect(UpdateProgressAction.create(progressId)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: UpdateProgressAction = { | ||
kind: UpdateProgressAction.KIND, | ||
progressId: '1', | ||
message: 'Some message', | ||
percentage: 10 | ||
}; | ||
const { progressId, message, percentage } = expected; | ||
expect(UpdateProgressAction.create(progressId, { message, percentage })).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
describe('EndProgressAction', () => { | ||
describe('is', () => { | ||
it('should return true for an object having the correct type and a value for all required interface properties', () => { | ||
const messageAction: EndProgressAction = { kind: 'endProgress', progressId: '1' }; | ||
expect(EndProgressAction.is(messageAction)).to.be.true; | ||
}); | ||
it('should return false for `undefined`', () => { | ||
expect(EndProgressAction.is(undefined)).to.be.false; | ||
}); | ||
it('should return false for an object that does not have all required interface properties', () => { | ||
expect(EndProgressAction.is({ kind: 'notTheRightOne' })).to.be.false; | ||
}); | ||
}); | ||
describe('create', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required arguments and default values for the optional arguments', () => { | ||
const progressId = '1'; | ||
const expected: EndProgressAction = { kind: EndProgressAction.KIND, progressId, message: undefined }; | ||
expect(EndProgressAction.create(progressId)).to.deep.equals(expected); | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: EndProgressAction = { | ||
kind: EndProgressAction.KIND, | ||
progressId: '1', | ||
message: 'Some message' | ||
}; | ||
const { progressId, message } = expected; | ||
expect(EndProgressAction.create(progressId, message)).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -87,7 +87,2 @@ * This program and the accompanying materials are made available under the | ||
details?: string; | ||
/** | ||
* Timeout after which a displayed message disappears. | ||
*/ | ||
timeout?: number; | ||
} | ||
@@ -107,3 +102,2 @@ | ||
details?: string; | ||
timeout?: number; | ||
} = {} | ||
@@ -119,1 +113,114 @@ ): ServerMessageAction { | ||
} | ||
/** | ||
* Sent by the server to the client to request presenting the progress of a long running process in the UI. | ||
*/ | ||
export interface StartProgressAction extends Action { | ||
kind: typeof StartProgressAction.KIND; | ||
/** | ||
* An ID that can be used in subsequent `updateProgress` and `endProgress` events to make them refer to the same progress reporting. | ||
*/ | ||
progressId: string; | ||
/** | ||
* Short title of the progress reporting. Shown in the UI to describe the long running process. | ||
*/ | ||
title: string; | ||
/** | ||
* Optional additional progress message. Shown in the UI to describe the long running process. | ||
*/ | ||
message?: string; | ||
/** | ||
* Progress percentage to display (value range: 0 to 100). If omitted no percentage is shown. | ||
*/ | ||
percentage?: number; | ||
} | ||
export namespace StartProgressAction { | ||
export const KIND = 'startProgress'; | ||
export function is(object: any): object is StartProgressAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'progressId') && hasStringProp(object, 'title'); | ||
} | ||
export function create(options: { progressId: string; title: string; message?: string; percentage?: number }): StartProgressAction { | ||
return { | ||
kind: KIND, | ||
...options | ||
}; | ||
} | ||
} | ||
/** | ||
* Sent by the server to the client to presenting an update of the progress of a long running process in the UI. | ||
*/ | ||
export interface UpdateProgressAction extends Action { | ||
kind: typeof UpdateProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
/** | ||
* The percentage (value range: 0 to 100) to show in the progress reporting. | ||
*/ | ||
percentage?: number; | ||
} | ||
export namespace UpdateProgressAction { | ||
export const KIND = 'updateProgress'; | ||
export function is(object: any): object is UpdateProgressAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'progressId'); | ||
} | ||
export function create( | ||
progressId: string, | ||
options: { | ||
message?: string; | ||
percentage?: number; | ||
} = {} | ||
): UpdateProgressAction { | ||
return { | ||
kind: KIND, | ||
progressId, | ||
...options | ||
}; | ||
} | ||
} | ||
/** | ||
* Sent by the server to the client to end the reporting of a progress. | ||
*/ | ||
export interface EndProgressAction extends Action { | ||
kind: typeof EndProgressAction.KIND; | ||
/** | ||
* The ID of the progress reporting to update. | ||
*/ | ||
progressId: string; | ||
/** | ||
* The message to show in the progress reporting. | ||
*/ | ||
message?: string; | ||
} | ||
export namespace EndProgressAction { | ||
export const KIND = 'endProgress'; | ||
export function is(object: any): object is EndProgressAction { | ||
return Action.hasKind(object, KIND) && hasStringProp(object, 'progressId'); | ||
} | ||
export function create(progressId: string, message?: string): EndProgressAction { | ||
return { | ||
kind: KIND, | ||
progressId, | ||
message | ||
}; | ||
} | ||
} |
@@ -48,3 +48,4 @@ /******************************************************************************** | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: [] | ||
deselectedElementsIDs: [], | ||
deselectAll: false | ||
}; | ||
@@ -57,3 +58,4 @@ expect(SelectAction.create()).to.deep.equals(expected); | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: ['deselected'] | ||
deselectedElementsIDs: ['deselected'], | ||
deselectAll: false | ||
}; | ||
@@ -63,3 +65,49 @@ const { selectedElementsIDs, deselectedElementsIDs } = expected; | ||
}); | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments: deselectAll', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: true | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
expect(SelectAction.create({ deselectedElementsIDs: true, selectedElementsIDs })).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('addSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: false | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
expect(SelectAction.addSelection(selectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('removeSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: ['deselected'], | ||
deselectAll: false | ||
}; | ||
const { deselectedElementsIDs } = expected; | ||
expect(SelectAction.removeSelection(deselectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
describe('setSelection', () => { | ||
it('should return an object conforming to the interface with matching properties for the given required and optional arguments', () => { | ||
const expected: SelectAction = { | ||
kind: 'elementSelected', | ||
selectedElementsIDs: ['selected'], | ||
deselectedElementsIDs: [], | ||
deselectAll: true | ||
}; | ||
const { selectedElementsIDs } = expected; | ||
expect(SelectAction.setSelection(selectedElementsIDs)).to.deep.equals(expected); | ||
}); | ||
}); | ||
}); | ||
@@ -66,0 +114,0 @@ |
@@ -17,2 +17,3 @@ /******************************************************************************** | ||
import * as sprotty from 'sprotty-protocol/lib/actions'; | ||
import { isStringArray } from '../utils/array-util'; | ||
import { hasArrayProp, hasBooleanProp } from '../utils/type-util'; | ||
@@ -40,2 +41,7 @@ import { Action } from './base-protocol'; | ||
deselectedElementsIDs: string[]; | ||
/** | ||
* Whether all currently selected elements should be deselected. | ||
*/ | ||
deselectAll?: boolean; | ||
} | ||
@@ -50,10 +56,23 @@ | ||
export function create(options: { selectedElementsIDs?: string[]; deselectedElementsIDs?: string[] } = {}): SelectAction { | ||
export function create(options: { selectedElementsIDs?: string[]; deselectedElementsIDs?: string[] | boolean } = {}): SelectAction { | ||
const deselectedElementsIDs = options.deselectedElementsIDs ?? []; | ||
return { | ||
kind: KIND, | ||
selectedElementsIDs: [], | ||
deselectedElementsIDs: [], | ||
...options | ||
selectedElementsIDs: options.selectedElementsIDs ?? [], | ||
deselectedElementsIDs: isStringArray(deselectedElementsIDs, true) ? deselectedElementsIDs : [], | ||
deselectAll: typeof deselectedElementsIDs === 'boolean' ? deselectedElementsIDs : false | ||
}; | ||
} | ||
export function addSelection(selectedElementsIDs: string[]): SelectAction { | ||
return create({ selectedElementsIDs }); | ||
} | ||
export function removeSelection(deselectedElementsIDs: string[]): SelectAction { | ||
return create({ deselectedElementsIDs }); | ||
} | ||
export function setSelection(selectedElementsIDs: string[]): SelectAction { | ||
return create({ selectedElementsIDs, deselectedElementsIDs: true }); | ||
} | ||
} | ||
@@ -60,0 +79,0 @@ |
/******************************************************************************** | ||
* Copyright (c) 2020-2022 EclipseSource and others. | ||
* Copyright (c) 2020-2023 EclipseSource and others. | ||
* | ||
@@ -167,3 +167,2 @@ * This program and the accompanying materials are made available under the | ||
*/ | ||
// eslint-disable-next-line no-shadow | ||
export enum Severity { | ||
@@ -175,3 +174,2 @@ FATAL, | ||
OK, | ||
// eslint-disable-next-line no-shadow | ||
NONE | ||
@@ -178,0 +176,0 @@ } |
/******************************************************************************** | ||
* Copyright (c) 2022 STMicroelectronics and others. | ||
* Copyright (c) 2022-2023 STMicroelectronics and others. | ||
* | ||
@@ -4,0 +4,0 @@ * This program and the accompanying materials are made available under the |
/******************************************************************************** | ||
* Copyright (c) 2021-2022 STMicroelectronics and others. | ||
* Copyright (c) 2021-2023 STMicroelectronics and others. | ||
* | ||
@@ -4,0 +4,0 @@ * This program and the accompanying materials are made available under the |
@@ -22,3 +22,3 @@ /******************************************************************************** | ||
declare module 'sprotty-protocol/lib/actions' { | ||
// eslint-disable-next-line no-shadow | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
namespace SetViewportAction { | ||
@@ -28,3 +28,3 @@ export function is(object: any): object is SetViewportAction; | ||
// eslint-disable-next-line no-shadow | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
namespace SetBoundsAction { | ||
@@ -52,7 +52,11 @@ export function is(object: any): object is SetBoundsAction; | ||
export * from './action-protocol'; | ||
export * from './disposable/disposable'; | ||
export * from './glsp-client'; | ||
export * from './jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './jsonrpc/glsp-jsonrpc-client'; | ||
export * from './jsonrpc/websocket-connection'; | ||
export * from './client-server-protocol/base-glsp-client'; | ||
export * from './client-server-protocol/glsp-client'; | ||
export * from './client-server-protocol/glsp-server'; | ||
export * from './client-server-protocol/jsonrpc/base-jsonrpc-glsp-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-client'; | ||
export * from './client-server-protocol/jsonrpc/glsp-jsonrpc-server'; | ||
export * from './client-server-protocol/jsonrpc/websocket-connection'; | ||
export * from './client-server-protocol/jsonrpc/ws-connection-provider'; | ||
export * from './client-server-protocol/types'; | ||
export * from './model/default-types'; | ||
@@ -62,3 +66,5 @@ export * from './model/model-schema'; | ||
export * from './utils/di-util'; | ||
export * from './utils/disposable'; | ||
export * from './utils/event'; | ||
export * from './utils/type-util'; | ||
export { SetBoundsAction, SetViewportAction }; |
@@ -17,3 +17,3 @@ /******************************************************************************** | ||
import { Container, ContainerModule, interfaces } from 'inversify'; | ||
import { asArray, distinctAdd, MaybeArray, remove } from './array-util'; | ||
import { MaybeArray, asArray, distinctAdd, remove } from './array-util'; | ||
import { hasFunctionProp, hasNumberProp } from './type-util'; | ||
@@ -34,12 +34,23 @@ | ||
* Initializes a container with the given {@link ContainerConfiguration}. The container configuration | ||
* consists of the set of {@link ContainerModule}s that should be loaded in the container and/or | ||
* consists of the set of {@link ContainerModule}s that should be loaded in the container. | ||
* In addition, for more fine-grained control {@link ModuleConfiguration}s can be passed as part fo the container configuration | ||
* Module loading is distinct,this means each module will only get loaded once even if it is configured multiple times. | ||
@param containerConfiguration | ||
@param containerConfigurations | ||
* Custom modules to be loaded in addition to the default modules and/or default modules that should be excluded. | ||
@returns The initialized container. | ||
*/ | ||
export function initializeContainer(container: Container, ...containerConfiguration: ContainerConfiguration): Container { | ||
export function initializeContainer(container: Container, ...containerConfigurations: ContainerConfiguration): Container { | ||
const modules = resolveContainerConfiguration(...containerConfigurations); | ||
container.load(...modules); | ||
return container; | ||
} | ||
/** | ||
* Processes the given container configurations and returns the corresponding set of {@link ContainerModule}s. | ||
* @param containerConfigurations The container configurations to resolves | ||
* @returns an Array of resolved container modules | ||
*/ | ||
export function resolveContainerConfiguration(...containerConfigurations: ContainerConfiguration): ContainerModule[] { | ||
const modules: ContainerModule[] = []; | ||
containerConfiguration.forEach(config => { | ||
containerConfigurations.forEach(config => { | ||
if (isContainerModule(config)) { | ||
@@ -56,6 +67,4 @@ distinctAdd(modules, config); | ||
}); | ||
container.load(...modules); | ||
return container; | ||
return modules; | ||
} | ||
/** | ||
@@ -88,2 +97,69 @@ * The container modules might originate form different inversify contexts (e.g. `inversify` vs. `@theia/core/shared/inversify`). | ||
/** | ||
* Optional constructor options for {@link FeatureModule}s. | ||
*/ | ||
export interface FeatureModuleOptions { | ||
/** | ||
* The set of feature modules that is required in order for this module to load. | ||
*/ | ||
requires?: MaybeArray<FeatureModule>; | ||
/** | ||
* Optional `featureId` that should be used. If omitted an id will be autogenerated | ||
*/ | ||
featureId?: symbol; | ||
} | ||
/** | ||
* A `FeatureModule` is a specialized {@link ContainerModule} that can declare dependencies to other {@link FeatureModule}. | ||
* A feature module will only be loaded into a container if all of its required modules haven been loaded before. T | ||
* Each feature module binds its `featureId` be default. This enables querying of existing container to check wether a | ||
* feature module has been loaded into this container. | ||
*/ | ||
export class FeatureModule extends ContainerModule { | ||
readonly featureId: symbol; | ||
readonly requires?: MaybeArray<FeatureModule>; | ||
constructor(registry: interfaces.ContainerModuleCallBack, options: FeatureModuleOptions = {}) { | ||
super((bind, unbind, isBound, ...rest) => { | ||
if (this.configure(bind, isBound)) { | ||
registry(bind, unbind, isBound, ...rest); | ||
} | ||
}); | ||
this.featureId = options.featureId ?? this.createFeatureId(); | ||
this.requires = options.requires; | ||
} | ||
protected createFeatureId(): symbol { | ||
return Symbol(this.id); | ||
} | ||
/** | ||
* Configures the feature module i.e. checks if the requirements are met. | ||
* If this is the case the {@link FeatureModule.featureId} will be bound and the module will be loaded | ||
* @param bind container bind function | ||
* @param isBound container isBound function | ||
* @returns `true` if all requirements are met and the module is loaded. `false` otherwise | ||
*/ | ||
configure(bind: interfaces.Bind, isBound: interfaces.IsBound): boolean { | ||
if (this.checkRequirements(isBound)) { | ||
bind(this.featureId).toConstantValue(this.featureId); | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
* Checks if all required {@link FeatureModule}s are already loaded/bound in the container. | ||
* @param isBound The `isBound` property of the module callback. Used to check the required modules. | ||
* @returns `true` if all requirements are met, `false` otherwise | ||
*/ | ||
protected checkRequirements(isBound: interfaces.IsBound): boolean { | ||
return this.requires ? asArray(this.requires).every(module => isBound(module.featureId)) : true; | ||
} | ||
isLoaded(context: Pick<BindingContext, 'isBound'>): boolean { | ||
return context.isBound(this.featureId); | ||
} | ||
} | ||
/** | ||
* Checks wether the given service identifier is already bound in the given context | ||
@@ -90,0 +166,0 @@ * then either calls the `bind` or `rebind` function respectively. |
@@ -66,2 +66,8 @@ /******************************************************************************** | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasStringProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasStringProp({ someProp: 'someKey' }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -85,2 +91,8 @@ | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasBooleanProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasBooleanProp({ someProp: true }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -104,2 +116,8 @@ | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasNumberProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasNumberProp({ someProp: 123 }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -123,2 +141,8 @@ | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasObjectProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasObjectProp({ someProp: { value: 'someKey' } }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -143,2 +167,9 @@ | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasFunctionProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
expect(hasFunctionProp({ someProp: () => {} }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
@@ -162,3 +193,9 @@ | ||
}); | ||
it('should return true for an object that has a property with matching name but without value when using the optional flag', () => { | ||
expect(hasArrayProp({ someProp: undefined }, 'someProp', true)).to.be.true; | ||
}); | ||
it('should return true for an object that has a property that matches the given key and type when using the optional flag', () => { | ||
expect(hasArrayProp({ someProp: ['some', 'prop'] }, 'someProp', true)).to.be.true; | ||
}); | ||
}); | ||
}); |
@@ -72,2 +72,8 @@ /******************************************************************************** | ||
/** | ||
* Utility type that represents an arbitrary function. Should be used instead | ||
* of the default `Function` type which is considered to be unsafe. | ||
*/ | ||
export type SafeFunction<T = any> = (...args: any[]) => T; | ||
/** | ||
* Validates whether the given object has a property of type `string` with the given key. | ||
@@ -80,3 +86,4 @@ * @param object The object that should be validated | ||
export function hasStringProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === 'string' : optional; | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'string' : optional; | ||
} | ||
@@ -92,3 +99,4 @@ | ||
export function hasBooleanProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === 'boolean' : optional; | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'boolean' : optional; | ||
} | ||
@@ -104,3 +112,4 @@ | ||
export function hasNumberProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === 'number' : optional; | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'number' : optional; | ||
} | ||
@@ -116,3 +125,4 @@ | ||
export function hasObjectProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? AnyObject.is((object as any)[propertyKey]) : optional; | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? AnyObject.is(property) : optional; | ||
} | ||
@@ -128,3 +138,4 @@ | ||
export function hasFunctionProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? typeof (object as any)[propertyKey] === 'function' : optional; | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? typeof property === 'function' : optional; | ||
} | ||
@@ -140,3 +151,4 @@ | ||
export function hasArrayProp(object: AnyObject, propertyKey: string, optional = false): boolean { | ||
return propertyKey in object ? Array.isArray((object as any)[propertyKey]) : optional; | ||
const property = (object as any)[propertyKey]; | ||
return property !== undefined ? Array.isArray(property) : optional; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 13 instances 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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 11 instances in 1 package
846900
229
22
14656
+ Addedsprotty-protocol@0.14.0-next.02bbac0.26(transitive)
- Removedsprotty-protocol@0.13.0-next.f4445dd.342(transitive)