@punica/editor 1.0.0
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/impl/commands.d.ts +3 -0
- package/dist/impl/commands.js +72 -0
- package/dist/impl/dragDrop.d.ts +31 -0
- package/dist/impl/dragDrop.js +119 -0
- package/dist/impl/extensions.d.ts +3 -0
- package/dist/impl/extensions.js +45 -0
- package/dist/impl/index.d.ts +7 -0
- package/dist/impl/index.js +7 -0
- package/dist/impl/keyboardShortcuts.d.ts +3 -0
- package/dist/impl/keyboardShortcuts.js +67 -0
- package/dist/impl/layout.d.ts +3 -0
- package/dist/impl/layout.js +59 -0
- package/dist/impl/statusbar.d.ts +3 -0
- package/dist/impl/statusbar.js +75 -0
- package/dist/impl/timeServer.d.ts +3 -0
- package/dist/impl/timeServer.js +57 -0
- package/dist/impl/view.d.ts +3 -0
- package/dist/impl/view.js +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -0
- package/package.json +62 -0
- package/types/index.d.ts +10 -0
- package/types/punica.d.ts +3 -0
- package/types/punica.module.commands.d.ts +18 -0
- package/types/punica.module.dragDrop.d.ts +23 -0
- package/types/punica.module.extensions.d.ts +16 -0
- package/types/punica.module.keyboardShortcuts.d.ts +24 -0
- package/types/punica.module.layout.d.ts +23 -0
- package/types/punica.module.statusbar.d.ts +20 -0
- package/types/punica.module.timeServer.d.ts +14 -0
- package/types/punica.module.view.d.ts +8 -0
- package/types/types.d.ts +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Uryan Sezgin TEKE
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# punica-editor
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _CommandManager_commandMap, _CommandManager_history, _CommandManager_undone;
|
|
13
|
+
class CommandManager {
|
|
14
|
+
constructor() {
|
|
15
|
+
_CommandManager_commandMap.set(this, new Map());
|
|
16
|
+
_CommandManager_history.set(this, []);
|
|
17
|
+
_CommandManager_undone.set(this, []);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param command
|
|
22
|
+
*/
|
|
23
|
+
registerCommand(command) {
|
|
24
|
+
__classPrivateFieldGet(this, _CommandManager_commandMap, "f").set(command.id, command);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param commandId
|
|
29
|
+
*/
|
|
30
|
+
executeCommand(commandId) {
|
|
31
|
+
const command = __classPrivateFieldGet(this, _CommandManager_commandMap, "f").get(commandId);
|
|
32
|
+
if (command) {
|
|
33
|
+
command.execute();
|
|
34
|
+
__classPrivateFieldGet(this, _CommandManager_history, "f").push(command);
|
|
35
|
+
__classPrivateFieldSet(this, _CommandManager_undone, [], "f");
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error(`Command with ID ${commandId} not found.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
undo() {
|
|
45
|
+
const command = __classPrivateFieldGet(this, _CommandManager_history, "f").pop();
|
|
46
|
+
if (command) {
|
|
47
|
+
command.undo();
|
|
48
|
+
__classPrivateFieldGet(this, _CommandManager_undone, "f").push(command);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.error('No command to undo.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
redo() {
|
|
58
|
+
const command = __classPrivateFieldGet(this, _CommandManager_undone, "f").pop();
|
|
59
|
+
if (command) {
|
|
60
|
+
command.execute();
|
|
61
|
+
__classPrivateFieldGet(this, _CommandManager_history, "f").push(command);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.error('No command to redo.');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_CommandManager_commandMap = new WeakMap(), _CommandManager_history = new WeakMap(), _CommandManager_undone = new WeakMap();
|
|
69
|
+
const commands = {
|
|
70
|
+
manager: new CommandManager()
|
|
71
|
+
};
|
|
72
|
+
export default commands;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DragDrop } from 'punica';
|
|
2
|
+
import { BaseListener } from '@punica/common';
|
|
3
|
+
declare const calculateMutation: (point1: DragDrop.Point, point2: DragDrop.Point) => DragDrop.Point;
|
|
4
|
+
declare const isTouchDevice: () => boolean;
|
|
5
|
+
declare const eventType: () => DragDrop.Events;
|
|
6
|
+
declare const setEventPosition: (event: MouseEvent) => DragDrop.PositionDetail;
|
|
7
|
+
declare const getTranslate: (transform: string) => DragDrop.Point;
|
|
8
|
+
declare class ServiceDragDrop extends BaseListener<DragDrop.DragDropEvents> implements DragDrop.IServiceDragDrop {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param event
|
|
13
|
+
*/
|
|
14
|
+
handleDragStart: (event: MouseEvent) => void;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param event
|
|
18
|
+
*/
|
|
19
|
+
handleDragging: (event: MouseEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param event
|
|
23
|
+
*/
|
|
24
|
+
handleDragStop: (event: MouseEvent) => void;
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param element
|
|
28
|
+
*/
|
|
29
|
+
constructor(element: HTMLElement);
|
|
30
|
+
}
|
|
31
|
+
export { ServiceDragDrop, calculateMutation, isTouchDevice, eventType, setEventPosition, getTranslate };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ServiceDragDrop_element, _ServiceDragDrop_events, _ServiceDragDrop_position;
|
|
13
|
+
import { BaseListener } from '@punica/common';
|
|
14
|
+
const calculateMutation = (point1, point2) => {
|
|
15
|
+
if (!point1 || !point2) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
x: point2.x - point1.x,
|
|
20
|
+
y: point2.y - point1.y
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const isTouchDevice = () => {
|
|
24
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
25
|
+
};
|
|
26
|
+
const eventType = () => {
|
|
27
|
+
const touch = isTouchDevice();
|
|
28
|
+
return {
|
|
29
|
+
dragStart: touch ? 'touchstart' : 'mousedown',
|
|
30
|
+
dragging: touch ? 'touchmove' : 'mousemove',
|
|
31
|
+
dragStop: touch ? 'touchend' : 'mouseup'
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const setEventPosition = (event) => {
|
|
35
|
+
return {
|
|
36
|
+
offsetX: event.offsetX,
|
|
37
|
+
offsetY: event.offsetY,
|
|
38
|
+
pageX: event.pageX,
|
|
39
|
+
pageY: event.pageY,
|
|
40
|
+
clientX: event.clientX,
|
|
41
|
+
clientY: event.clientY
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const getTranslate = (transform) => {
|
|
45
|
+
const detail = transform.match(/([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/);
|
|
46
|
+
const x = detail[1];
|
|
47
|
+
const y = detail[2];
|
|
48
|
+
return { x: parseFloat(x), y: parseFloat(y) };
|
|
49
|
+
};
|
|
50
|
+
class ServiceDragDrop extends BaseListener {
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param element
|
|
54
|
+
*/
|
|
55
|
+
constructor(element) {
|
|
56
|
+
super();
|
|
57
|
+
_ServiceDragDrop_element.set(this, void 0);
|
|
58
|
+
_ServiceDragDrop_events.set(this, void 0);
|
|
59
|
+
_ServiceDragDrop_position.set(this, void 0);
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @param event
|
|
63
|
+
*/
|
|
64
|
+
this.handleDragStart = (event) => {
|
|
65
|
+
const eventPosition = setEventPosition(event);
|
|
66
|
+
__classPrivateFieldSet(this, _ServiceDragDrop_position, {
|
|
67
|
+
x: eventPosition.clientX,
|
|
68
|
+
y: eventPosition.clientY
|
|
69
|
+
}, "f");
|
|
70
|
+
__classPrivateFieldGet(this, _ServiceDragDrop_element, "f").addEventListener(__classPrivateFieldGet(this, _ServiceDragDrop_events, "f").dragging, this.handleDragging);
|
|
71
|
+
__classPrivateFieldGet(this, _ServiceDragDrop_element, "f").addEventListener(__classPrivateFieldGet(this, _ServiceDragDrop_events, "f").dragStop, this.handleDragStop);
|
|
72
|
+
this.trigger('dragStart', {
|
|
73
|
+
startPosition: __classPrivateFieldGet(this, _ServiceDragDrop_position, "f"),
|
|
74
|
+
position: eventPosition,
|
|
75
|
+
mutation: null
|
|
76
|
+
});
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param event
|
|
82
|
+
*/
|
|
83
|
+
this.handleDragging = (event) => {
|
|
84
|
+
const eventPosition = setEventPosition(event);
|
|
85
|
+
const mutation = calculateMutation(__classPrivateFieldGet(this, _ServiceDragDrop_position, "f"), {
|
|
86
|
+
x: eventPosition.clientX,
|
|
87
|
+
y: eventPosition.clientY
|
|
88
|
+
});
|
|
89
|
+
this.trigger('dragging', {
|
|
90
|
+
startPosition: __classPrivateFieldGet(this, _ServiceDragDrop_position, "f"),
|
|
91
|
+
position: eventPosition,
|
|
92
|
+
mutation
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param event
|
|
98
|
+
*/
|
|
99
|
+
this.handleDragStop = (event) => {
|
|
100
|
+
const eventPosition = setEventPosition(event);
|
|
101
|
+
const mutation = calculateMutation(__classPrivateFieldGet(this, _ServiceDragDrop_position, "f"), {
|
|
102
|
+
x: eventPosition.clientX,
|
|
103
|
+
y: eventPosition.clientY
|
|
104
|
+
});
|
|
105
|
+
this.trigger('dragStop', {
|
|
106
|
+
startPosition: __classPrivateFieldGet(this, _ServiceDragDrop_position, "f"),
|
|
107
|
+
position: eventPosition,
|
|
108
|
+
mutation
|
|
109
|
+
});
|
|
110
|
+
__classPrivateFieldGet(this, _ServiceDragDrop_element, "f").removeEventListener(__classPrivateFieldGet(this, _ServiceDragDrop_events, "f").dragging, this.handleDragging);
|
|
111
|
+
__classPrivateFieldGet(this, _ServiceDragDrop_element, "f").removeEventListener(__classPrivateFieldGet(this, _ServiceDragDrop_events, "f").dragStop, this.handleDragStop);
|
|
112
|
+
};
|
|
113
|
+
__classPrivateFieldSet(this, _ServiceDragDrop_element, element, "f");
|
|
114
|
+
__classPrivateFieldSet(this, _ServiceDragDrop_events, eventType(), "f");
|
|
115
|
+
__classPrivateFieldGet(this, _ServiceDragDrop_element, "f").addEventListener(__classPrivateFieldGet(this, _ServiceDragDrop_events, "f").dragStart, this.handleDragStart);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_ServiceDragDrop_element = new WeakMap(), _ServiceDragDrop_events = new WeakMap(), _ServiceDragDrop_position = new WeakMap();
|
|
119
|
+
export { ServiceDragDrop, calculateMutation, isTouchDevice, eventType, setEventPosition, getTranslate };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ExtensionManager_extensions;
|
|
13
|
+
class ExtensionManager {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
_ExtensionManager_extensions.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _ExtensionManager_extensions, new Map(), "f");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param extension
|
|
24
|
+
*/
|
|
25
|
+
load(extension) {
|
|
26
|
+
if (__classPrivateFieldGet(this, _ExtensionManager_extensions, "f").has(extension.name)) {
|
|
27
|
+
console.warn(`Extension '${extension.name}' is already loaded.`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
__classPrivateFieldGet(this, _ExtensionManager_extensions, "f").set(extension.name, extension);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param extensionName
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
getExtension(extensionName) {
|
|
38
|
+
return __classPrivateFieldGet(this, _ExtensionManager_extensions, "f").get(extensionName);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
_ExtensionManager_extensions = new WeakMap();
|
|
42
|
+
const extension = {
|
|
43
|
+
manager: new ExtensionManager()
|
|
44
|
+
};
|
|
45
|
+
export default extension;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as View } from './view';
|
|
2
|
+
export { default as Extensions } from './extensions';
|
|
3
|
+
export { default as Commands } from './commands';
|
|
4
|
+
export { default as Layout } from './layout';
|
|
5
|
+
export { default as KeyboardShortcuts } from './keyboardShortcuts';
|
|
6
|
+
export { default as TimeServer } from './timeServer';
|
|
7
|
+
export { default as Statusbar } from './statusbar';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as View } from './view';
|
|
2
|
+
export { default as Extensions } from './extensions';
|
|
3
|
+
export { default as Commands } from './commands';
|
|
4
|
+
export { default as Layout } from './layout';
|
|
5
|
+
export { default as KeyboardShortcuts } from './keyboardShortcuts';
|
|
6
|
+
export { default as TimeServer } from './timeServer';
|
|
7
|
+
export { default as Statusbar } from './statusbar';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _ShortcutManager_instances, _ShortcutManager_shortcuts, _ShortcutManager_areKeysEqual, _ShortcutManager_areKeysPressed;
|
|
13
|
+
class ShortcutManager {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
_ShortcutManager_instances.add(this);
|
|
19
|
+
_ShortcutManager_shortcuts.set(this, []);
|
|
20
|
+
document.addEventListener('keydown', this.handleKeyEvent.bind(this));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param shortcut
|
|
25
|
+
*/
|
|
26
|
+
registerShortcut(shortcut) {
|
|
27
|
+
__classPrivateFieldGet(this, _ShortcutManager_shortcuts, "f").push(shortcut);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param keys
|
|
32
|
+
*/
|
|
33
|
+
unregisterShortcut(keys) {
|
|
34
|
+
__classPrivateFieldSet(this, _ShortcutManager_shortcuts, __classPrivateFieldGet(this, _ShortcutManager_shortcuts, "f").filter((shortcut) => __classPrivateFieldGet(this, _ShortcutManager_instances, "m", _ShortcutManager_areKeysEqual).call(this, shortcut.keys, keys)), "f");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param event
|
|
39
|
+
*/
|
|
40
|
+
handleKeyEvent(event) {
|
|
41
|
+
const matchedShortcut = __classPrivateFieldGet(this, _ShortcutManager_shortcuts, "f").find((shortcut) => __classPrivateFieldGet(this, _ShortcutManager_instances, "m", _ShortcutManager_areKeysPressed).call(this, event, shortcut.keys));
|
|
42
|
+
if (matchedShortcut) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
const commandsManager = window.punica.Commands.manager;
|
|
45
|
+
commandsManager.executeCommand(matchedShortcut.commandId);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
_ShortcutManager_shortcuts = new WeakMap(), _ShortcutManager_instances = new WeakSet(), _ShortcutManager_areKeysEqual = function _ShortcutManager_areKeysEqual(keys1, keys2) {
|
|
50
|
+
if (keys1.length !== keys2.length)
|
|
51
|
+
return false;
|
|
52
|
+
return keys1.every((key1, index) => key1.key.toLowerCase() === keys2[index].key.toLowerCase() &&
|
|
53
|
+
key1.ctrlKey === keys2[index].ctrlKey &&
|
|
54
|
+
key1.shiftKey === keys2[index].shiftKey &&
|
|
55
|
+
key1.altKey === keys2[index].altKey &&
|
|
56
|
+
key1.metaKey === keys2[index].metaKey);
|
|
57
|
+
}, _ShortcutManager_areKeysPressed = function _ShortcutManager_areKeysPressed(event, keys) {
|
|
58
|
+
return keys.every((key) => (key.ctrlKey ? event.ctrlKey : true) &&
|
|
59
|
+
(key.shiftKey ? event.shiftKey : true) &&
|
|
60
|
+
(key.altKey ? event.altKey : true) &&
|
|
61
|
+
(key.metaKey ? event.metaKey : true) &&
|
|
62
|
+
event.key.toLowerCase() === key.key.toLowerCase());
|
|
63
|
+
};
|
|
64
|
+
const keyboardShortcuts = {
|
|
65
|
+
manager: new ShortcutManager()
|
|
66
|
+
};
|
|
67
|
+
export default keyboardShortcuts;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _LayoutManager_item, _LayoutManager_layoutElement;
|
|
13
|
+
class LayoutManager {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
_LayoutManager_item.set(this, new Map());
|
|
19
|
+
_LayoutManager_layoutElement.set(this, void 0);
|
|
20
|
+
__classPrivateFieldSet(this, _LayoutManager_layoutElement, document.createElement('div'), "f");
|
|
21
|
+
__classPrivateFieldGet(this, _LayoutManager_layoutElement, "f").id = 'punica-editor';
|
|
22
|
+
this.addItem('appBar');
|
|
23
|
+
this.addItem('activityBar');
|
|
24
|
+
this.addItem('content');
|
|
25
|
+
this.addItem('statusbar');
|
|
26
|
+
this.addItem('primarySidebar');
|
|
27
|
+
this.addItem('secondarySidebar');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param type
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
getItem(type) {
|
|
35
|
+
return __classPrivateFieldGet(this, _LayoutManager_item, "f").get(type);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param type
|
|
40
|
+
*/
|
|
41
|
+
addItem(type) {
|
|
42
|
+
const content = document.createElement('div');
|
|
43
|
+
content.id = type;
|
|
44
|
+
__classPrivateFieldGet(this, _LayoutManager_layoutElement, "f").appendChild(content);
|
|
45
|
+
__classPrivateFieldGet(this, _LayoutManager_item, "f").set(type, { type, content });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param container
|
|
50
|
+
*/
|
|
51
|
+
render(container) {
|
|
52
|
+
container.appendChild(__classPrivateFieldGet(this, _LayoutManager_layoutElement, "f"));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_LayoutManager_item = new WeakMap(), _LayoutManager_layoutElement = new WeakMap();
|
|
56
|
+
const layout = {
|
|
57
|
+
manager: new LayoutManager()
|
|
58
|
+
};
|
|
59
|
+
export default layout;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _StatusbarManager_instances, _StatusbarManager_leftItems, _StatusbarManager_rightItems, _StatusbarManager_content, _StatusbarManager_leftContent, _StatusbarManager_rightContent, _StatusbarManager_initiliazeContent;
|
|
13
|
+
class StatusbarManager {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
_StatusbarManager_instances.add(this);
|
|
19
|
+
_StatusbarManager_leftItems.set(this, new Map());
|
|
20
|
+
_StatusbarManager_rightItems.set(this, new Map());
|
|
21
|
+
_StatusbarManager_content.set(this, void 0);
|
|
22
|
+
_StatusbarManager_leftContent.set(this, void 0);
|
|
23
|
+
_StatusbarManager_rightContent.set(this, void 0);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param alignment
|
|
28
|
+
* @param item
|
|
29
|
+
*/
|
|
30
|
+
addItem(alignment, item) {
|
|
31
|
+
if (!__classPrivateFieldGet(this, _StatusbarManager_content, "f")) {
|
|
32
|
+
__classPrivateFieldGet(this, _StatusbarManager_instances, "m", _StatusbarManager_initiliazeContent).call(this);
|
|
33
|
+
}
|
|
34
|
+
if (alignment === 'left') {
|
|
35
|
+
__classPrivateFieldGet(this, _StatusbarManager_leftItems, "f").set(item.id, item);
|
|
36
|
+
__classPrivateFieldGet(this, _StatusbarManager_leftContent, "f").appendChild(item.content);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
__classPrivateFieldGet(this, _StatusbarManager_rightItems, "f").set(item.id, item);
|
|
40
|
+
__classPrivateFieldGet(this, _StatusbarManager_rightContent, "f").appendChild(item.content);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param itemId
|
|
46
|
+
*/
|
|
47
|
+
removeItem(itemId) {
|
|
48
|
+
if (__classPrivateFieldGet(this, _StatusbarManager_leftItems, "f").has(itemId)) {
|
|
49
|
+
const item = __classPrivateFieldGet(this, _StatusbarManager_leftItems, "f").get(itemId);
|
|
50
|
+
__classPrivateFieldGet(this, _StatusbarManager_leftItems, "f").delete(itemId);
|
|
51
|
+
__classPrivateFieldGet(this, _StatusbarManager_leftContent, "f").removeChild(item.content);
|
|
52
|
+
}
|
|
53
|
+
else if (__classPrivateFieldGet(this, _StatusbarManager_rightItems, "f").has(itemId)) {
|
|
54
|
+
const item = __classPrivateFieldGet(this, _StatusbarManager_rightItems, "f").get(itemId);
|
|
55
|
+
__classPrivateFieldGet(this, _StatusbarManager_rightItems, "f").delete(itemId);
|
|
56
|
+
__classPrivateFieldGet(this, _StatusbarManager_rightContent, "f").removeChild(item.content);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
_StatusbarManager_leftItems = new WeakMap(), _StatusbarManager_rightItems = new WeakMap(), _StatusbarManager_content = new WeakMap(), _StatusbarManager_leftContent = new WeakMap(), _StatusbarManager_rightContent = new WeakMap(), _StatusbarManager_instances = new WeakSet(), _StatusbarManager_initiliazeContent = function _StatusbarManager_initiliazeContent() {
|
|
61
|
+
const layoutManager = window.punica.Layout.manager;
|
|
62
|
+
const statusBarContent = layoutManager.getItem('statusbar').content;
|
|
63
|
+
__classPrivateFieldSet(this, _StatusbarManager_content, document.createElement('punica-row'), "f");
|
|
64
|
+
__classPrivateFieldSet(this, _StatusbarManager_leftContent, document.createElement('punica-col'), "f");
|
|
65
|
+
__classPrivateFieldSet(this, _StatusbarManager_rightContent, document.createElement('punica-col'), "f");
|
|
66
|
+
__classPrivateFieldGet(this, _StatusbarManager_content, "f").setAttribute('alignItems', 'center');
|
|
67
|
+
__classPrivateFieldGet(this, _StatusbarManager_content, "f").setAttribute('justifyContent', 'space-between');
|
|
68
|
+
__classPrivateFieldGet(this, _StatusbarManager_content, "f").appendChild(__classPrivateFieldGet(this, _StatusbarManager_leftContent, "f"));
|
|
69
|
+
__classPrivateFieldGet(this, _StatusbarManager_content, "f").appendChild(__classPrivateFieldGet(this, _StatusbarManager_rightContent, "f"));
|
|
70
|
+
statusBarContent === null || statusBarContent === void 0 ? void 0 : statusBarContent.appendChild(__classPrivateFieldGet(this, _StatusbarManager_content, "f"));
|
|
71
|
+
};
|
|
72
|
+
const statusbar = {
|
|
73
|
+
manager: new StatusbarManager()
|
|
74
|
+
};
|
|
75
|
+
export default statusbar;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _TimeServerManager_instances, _TimeServerManager_subscribers, _TimeServerManager_intervalId, _TimeServerManager_start, _TimeServerManager_stop;
|
|
13
|
+
class TimeServerManager {
|
|
14
|
+
constructor() {
|
|
15
|
+
_TimeServerManager_instances.add(this);
|
|
16
|
+
_TimeServerManager_subscribers.set(this, []);
|
|
17
|
+
_TimeServerManager_intervalId.set(this, null);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param subscriber
|
|
22
|
+
*/
|
|
23
|
+
subscribe(subscriber) {
|
|
24
|
+
__classPrivateFieldGet(this, _TimeServerManager_subscribers, "f").push(subscriber);
|
|
25
|
+
if (__classPrivateFieldGet(this, _TimeServerManager_subscribers, "f").length == 1) {
|
|
26
|
+
__classPrivateFieldGet(this, _TimeServerManager_instances, "m", _TimeServerManager_start).call(this);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param subscriber
|
|
32
|
+
*/
|
|
33
|
+
unsubscribe(subscriber) {
|
|
34
|
+
__classPrivateFieldSet(this, _TimeServerManager_subscribers, __classPrivateFieldGet(this, _TimeServerManager_subscribers, "f").filter((sub) => sub !== subscriber), "f");
|
|
35
|
+
if (__classPrivateFieldGet(this, _TimeServerManager_subscribers, "f").length == 0) {
|
|
36
|
+
__classPrivateFieldGet(this, _TimeServerManager_instances, "m", _TimeServerManager_stop).call(this);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
_TimeServerManager_subscribers = new WeakMap(), _TimeServerManager_intervalId = new WeakMap(), _TimeServerManager_instances = new WeakSet(), _TimeServerManager_start = function _TimeServerManager_start() {
|
|
41
|
+
if (__classPrivateFieldGet(this, _TimeServerManager_intervalId, "f") === null) {
|
|
42
|
+
__classPrivateFieldSet(this, _TimeServerManager_intervalId, window.setInterval(() => {
|
|
43
|
+
const currentTime = new Date();
|
|
44
|
+
__classPrivateFieldGet(this, _TimeServerManager_subscribers, "f").forEach((subscriber) => subscriber.update(currentTime));
|
|
45
|
+
}, 1000), "f");
|
|
46
|
+
}
|
|
47
|
+
}, _TimeServerManager_stop = function _TimeServerManager_stop() {
|
|
48
|
+
if (__classPrivateFieldGet(this, _TimeServerManager_intervalId, "f") !== null) {
|
|
49
|
+
window.clearInterval(__classPrivateFieldGet(this, _TimeServerManager_intervalId, "f"));
|
|
50
|
+
__classPrivateFieldSet(this, _TimeServerManager_intervalId, null, "f");
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const timeServerManager = {
|
|
54
|
+
manager: new TimeServerManager()
|
|
55
|
+
};
|
|
56
|
+
//timeServerManager.manager.start();
|
|
57
|
+
export default timeServerManager;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { View, Extensions, Commands, Layout, KeyboardShortcuts, TimeServer, Statusbar } from './impl';
|
|
2
|
+
export function create() {
|
|
3
|
+
return {
|
|
4
|
+
version: '1.0.0',
|
|
5
|
+
Layout,
|
|
6
|
+
View,
|
|
7
|
+
Extensions,
|
|
8
|
+
Commands,
|
|
9
|
+
KeyboardShortcuts,
|
|
10
|
+
TimeServer,
|
|
11
|
+
Statusbar
|
|
12
|
+
};
|
|
13
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@punica/editor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Punica Editor",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "webpack-dev-server --config webpack.config.dev.js",
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"lint": "eslint . --ext .js,.ts",
|
|
15
|
+
"lint:fix": "eslint . --ext .js,.ts --fix",
|
|
16
|
+
"format": "prettier --write \"./**/*.{ts,js,json,md}\"",
|
|
17
|
+
"prepare": "husky install"
|
|
18
|
+
},
|
|
19
|
+
"eslintIgnore": [
|
|
20
|
+
"node_modules",
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"punica",
|
|
25
|
+
"editor"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*",
|
|
29
|
+
"types/**/*",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@punica/common": "^1.0.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@babel/core": "^7.24.7",
|
|
37
|
+
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
38
|
+
"@babel/preset-env": "^7.24.7",
|
|
39
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
40
|
+
"@types/node": "^20.14.10",
|
|
41
|
+
"@typescript-eslint/eslint-plugin":"",
|
|
42
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
43
|
+
"@eslint/config-array":"^0.17.0",
|
|
44
|
+
"raw-loader": "^4.0.2",
|
|
45
|
+
"babel-loader": "^9.1.3",
|
|
46
|
+
"copy-webpack-plugin": "^12.0.2",
|
|
47
|
+
"css-loader": "^7.1.2",
|
|
48
|
+
"eslint": "^8.56.0",
|
|
49
|
+
"husky": "^8.0.3",
|
|
50
|
+
"file-loader": "^6.2.0",
|
|
51
|
+
"html-webpack-plugin": "^5.6.0",
|
|
52
|
+
"portfinder-sync": "^0.0.2",
|
|
53
|
+
"prettier": "^3.3.2",
|
|
54
|
+
"serve": "^14.2.3",
|
|
55
|
+
"ts-loader": "^9.5.1",
|
|
56
|
+
"typescript": "^5.5.3",
|
|
57
|
+
"webpack": "^5.92.1",
|
|
58
|
+
"webpack-cli": "^5.1.4",
|
|
59
|
+
"webpack-dev-server": "^5.0.4",
|
|
60
|
+
"webpack-merge": "^6.0.1"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference path="punica.d.ts" />
|
|
2
|
+
/// <reference path="punica.module.commands.d.ts" />
|
|
3
|
+
/// <reference path="punica.module.dragDrop.d.ts" />
|
|
4
|
+
/// <reference path="punica.module.extensions.d.ts" />
|
|
5
|
+
/// <reference path="punica.module.keyboardShortcuts.d.ts" />
|
|
6
|
+
/// <reference path="punica.module.layout.d.ts" />
|
|
7
|
+
/// <reference path="punica.module.statusbar.d.ts" />
|
|
8
|
+
/// <reference path="punica.module.timeServer.d.ts" />
|
|
9
|
+
/// <reference path="punica.module.view.d.ts" />
|
|
10
|
+
/// <reference path="types.d.ts" />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace Commands {
|
|
3
|
+
interface ICommand {
|
|
4
|
+
id: string;
|
|
5
|
+
execute(): void;
|
|
6
|
+
undo(): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ICommandManager {
|
|
10
|
+
registerCommand(command: ICommand): void;
|
|
11
|
+
executeCommand(commandId: string): void;
|
|
12
|
+
undo(): void;
|
|
13
|
+
redo(): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const manager: ICommandManager;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace DragDrop {
|
|
3
|
+
type DragDropEvents = 'dragging' | 'dragStart' | 'dragStop';
|
|
4
|
+
type Events = { [key in DragDropEvents]: string };
|
|
5
|
+
type Point = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
type PositionDetail = {
|
|
10
|
+
offsetX: number;
|
|
11
|
+
offsetY: number;
|
|
12
|
+
pageX: number;
|
|
13
|
+
pageY: number;
|
|
14
|
+
clientX: number;
|
|
15
|
+
clientY: number;
|
|
16
|
+
};
|
|
17
|
+
interface IServiceDragDrop {
|
|
18
|
+
handleDragStart(event: MouseEvent): void;
|
|
19
|
+
handleDragging(event: MouseEvent): void;
|
|
20
|
+
handleDragStop(event: MouseEvent): void;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace Extensions {
|
|
3
|
+
interface IExtension {
|
|
4
|
+
name: string;
|
|
5
|
+
activate: () => void;
|
|
6
|
+
deactivate: () => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IExtensionManager {
|
|
10
|
+
load(extensionPath: IExtension): void;
|
|
11
|
+
getExtension(extensionName: string): IExtension | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const manager: IExtensionManager;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace KeyboardShortcuts {
|
|
3
|
+
interface IKey {
|
|
4
|
+
key: string;
|
|
5
|
+
ctrlKey?: boolean;
|
|
6
|
+
shiftKey?: boolean;
|
|
7
|
+
altKey?: boolean;
|
|
8
|
+
metaKey?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface IShortcut {
|
|
12
|
+
keys: IKey[];
|
|
13
|
+
commandId: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface IShortcutManager {
|
|
17
|
+
registerShortcut(shortcut: IShortcut): void;
|
|
18
|
+
unregisterShortcut(keys: IKey[]): void;
|
|
19
|
+
handleKeyEvent(event: KeyboardEvent): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const manager: IShortcutManager;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace Layout {
|
|
3
|
+
type ItemType =
|
|
4
|
+
| 'appBar'
|
|
5
|
+
| 'activityBar'
|
|
6
|
+
| 'content'
|
|
7
|
+
| 'statusbar'
|
|
8
|
+
| 'primarySidebar'
|
|
9
|
+
| 'secondarySidebar';
|
|
10
|
+
|
|
11
|
+
interface IItem {
|
|
12
|
+
type: ItemType;
|
|
13
|
+
content?: HTMLElement;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ILayoutManager {
|
|
17
|
+
getItem(type: ItemType): IItem;
|
|
18
|
+
render(container: HTMLElement): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const manager: ILayoutManager;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace Statusbar {
|
|
3
|
+
type Alignment = 'left' | 'right';
|
|
4
|
+
type ItemType = 'progress' | 'warning' | 'error' | 'normal';
|
|
5
|
+
|
|
6
|
+
interface IItem {
|
|
7
|
+
id: string;
|
|
8
|
+
type: ItemType;
|
|
9
|
+
content: HTMLElement;
|
|
10
|
+
command?: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface IStatusbarManager {
|
|
14
|
+
addItem(alignment: Alignment, item: IItem): void;
|
|
15
|
+
removeItem(itemId: string): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const manager: IStatusbarManager;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace TimeServer {
|
|
3
|
+
interface ISubscriber {
|
|
4
|
+
update(time: Date): void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface ITimeServerManager {
|
|
8
|
+
subscribe(subscriber: ISubscriber): void;
|
|
9
|
+
unsubscribe(subscriber: ISubscriber): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const manager: ITimeServerManager;
|
|
13
|
+
}
|
|
14
|
+
}
|