@punica/editor 1.0.3 → 1.0.5

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.
Files changed (38) hide show
  1. package/dist/index.bundle.esm.js +2 -0
  2. package/dist/index.bundle.esm.js.map +1 -0
  3. package/dist/index.bundle.umd.js +2 -0
  4. package/dist/index.bundle.umd.js.map +1 -0
  5. package/package.json +16 -6
  6. package/types/index.d.ts +6 -0
  7. package/types/punica.module.extensions.d.ts +24 -1
  8. package/dist/impl/activityBar/index.js +0 -75
  9. package/dist/impl/commands/index.js +0 -52
  10. package/dist/impl/extensions/active/decorators/base.js +0 -19
  11. package/dist/impl/extensions/active/decorators/configuration/index.js +0 -20
  12. package/dist/impl/extensions/active/decorators/index.js +0 -3
  13. package/dist/impl/extensions/active/decorators/moduleLoader/index.js +0 -29
  14. package/dist/impl/extensions/active/decorators/views/index.js +0 -34
  15. package/dist/impl/extensions/active/getter/index.js +0 -28
  16. package/dist/impl/extensions/active/index.js +0 -14
  17. package/dist/impl/extensions/analysis/decorators/activationEvents/commands/base.js +0 -2
  18. package/dist/impl/extensions/analysis/decorators/activationEvents/commands/index.js +0 -2
  19. package/dist/impl/extensions/analysis/decorators/activationEvents/commands/onCommand.js +0 -16
  20. package/dist/impl/extensions/analysis/decorators/activationEvents/commands/onExtension.js +0 -16
  21. package/dist/impl/extensions/analysis/decorators/activationEvents/handler/index.js +0 -32
  22. package/dist/impl/extensions/analysis/decorators/activationEvents/index.js +0 -29
  23. package/dist/impl/extensions/analysis/decorators/base.js +0 -19
  24. package/dist/impl/extensions/analysis/decorators/commands/index.js +0 -37
  25. package/dist/impl/extensions/analysis/decorators/index.js +0 -4
  26. package/dist/impl/extensions/analysis/decorators/keybindings/index.js +0 -65
  27. package/dist/impl/extensions/analysis/decorators/menus/index.js +0 -20
  28. package/dist/impl/extensions/analysis/index.js +0 -15
  29. package/dist/impl/extensions/analysis/reader/index.js +0 -31
  30. package/dist/impl/extensions/index.js +0 -76
  31. package/dist/impl/history/index.js +0 -57
  32. package/dist/impl/index.js +0 -9
  33. package/dist/impl/keyboardShortcuts/index.js +0 -67
  34. package/dist/impl/layout/index.js +0 -50
  35. package/dist/impl/statusbar/index.js +0 -81
  36. package/dist/impl/timeServer/index.js +0 -49
  37. package/dist/impl/view/index.js +0 -7
  38. package/dist/index.js +0 -15
@@ -1,31 +0,0 @@
1
- import yaml from 'yaml';
2
- class Reader {
3
- #extensionURL;
4
- /**
5
- *
6
- * @param extensionURL
7
- */
8
- constructor(extensionURL) {
9
- this.#extensionURL = extensionURL;
10
- }
11
- /**
12
- *
13
- * @param extension
14
- * @returns
15
- */
16
- execute() {
17
- return new Promise((resolve) => {
18
- const extensionConfig = `${this.#extensionURL}.punica/config.yaml`;
19
- fetch(extensionConfig, { method: 'GET' })
20
- .then((res) => {
21
- return res.text();
22
- })
23
- .then((config) => {
24
- const extension = yaml.parse(config);
25
- extension.moduleURL = this.#extensionURL;
26
- resolve(extension);
27
- });
28
- });
29
- }
30
- }
31
- export default Reader;
@@ -1,76 +0,0 @@
1
- import { analysisExtension } from './analysis';
2
- import { activeExtension } from './active';
3
- class ExtensionManager {
4
- #extensions;
5
- #activeExtension;
6
- /**
7
- *
8
- */
9
- constructor() {
10
- this.#extensions = new Map();
11
- this.#activeExtension = new Map();
12
- }
13
- /**
14
- *
15
- * @param extensionURL
16
- * @param args
17
- */
18
- async load(extensionURL, ...args) {
19
- try {
20
- const extensionURLs = [extensionURL, ...args];
21
- for (const url of extensionURLs) {
22
- const analysis = analysisExtension(url);
23
- const extension = await analysis.execute();
24
- this.#extensions.set(extension.name, extension);
25
- this.#activeExtension.set(extension.name, false);
26
- console.log(extension.name, extension);
27
- }
28
- }
29
- catch (error) {
30
- console.error(error);
31
- }
32
- }
33
- /**
34
- *
35
- * @param extensionName
36
- */
37
- async activate(extensionName) {
38
- if (this.#activeExtension.get(extensionName)) {
39
- console.log(`Extension "${extensionName}" is already active.`);
40
- return;
41
- }
42
- const extension = this.#extensions.get(extensionName);
43
- if (!extension) {
44
- console.error(`Extension "${extensionName}" not found.`);
45
- return;
46
- }
47
- try {
48
- const active = activeExtension(extensionName);
49
- const activatedExtension = await active.execute();
50
- if (activatedExtension &&
51
- activatedExtension.module &&
52
- typeof activatedExtension.module.activate === 'function') {
53
- await activatedExtension.module.activate({});
54
- this.#activeExtension.set(extensionName, true);
55
- }
56
- else {
57
- throw new Error(`Failed to activate extension "${extensionName}". The "activate" method is missing or invalid.`);
58
- }
59
- }
60
- catch (error) {
61
- console.error(`Error activating extension "${extensionName}":`, error);
62
- }
63
- }
64
- /**
65
- *
66
- * @param extensionName
67
- * @returns
68
- */
69
- getExtension(extensionName) {
70
- return this.#extensions.get(extensionName);
71
- }
72
- }
73
- const extension = {
74
- manager: new ExtensionManager()
75
- };
76
- export default extension;
@@ -1,57 +0,0 @@
1
- class HistoryManager {
2
- #commandMap = new Map();
3
- #history = [];
4
- #undone = [];
5
- /**
6
- *
7
- * @param command
8
- */
9
- registerCommand(command) {
10
- this.#commandMap.set(command.id, command);
11
- }
12
- /**
13
- *
14
- * @param commandId
15
- */
16
- executeCommand(commandId) {
17
- const command = this.#commandMap.get(commandId);
18
- if (command) {
19
- command.execute();
20
- this.#history.push(command);
21
- this.#undone = [];
22
- }
23
- else {
24
- console.error(`Command with ID ${commandId} not found.`);
25
- }
26
- }
27
- /**
28
- *
29
- */
30
- undo() {
31
- const command = this.#history.pop();
32
- if (command) {
33
- command.undo();
34
- this.#undone.push(command);
35
- }
36
- else {
37
- console.error('No command to undo.');
38
- }
39
- }
40
- /**
41
- *
42
- */
43
- redo() {
44
- const command = this.#undone.pop();
45
- if (command) {
46
- command.execute();
47
- this.#history.push(command);
48
- }
49
- else {
50
- console.error('No command to redo.');
51
- }
52
- }
53
- }
54
- const history = {
55
- manager: new HistoryManager()
56
- };
57
- export default history;
@@ -1,9 +0,0 @@
1
- export { default as ActivityBar } from './activityBar';
2
- export { default as Commands } from './commands';
3
- export { default as History } from './history';
4
- export { default as Extensions } from './extensions';
5
- export { default as KeyboardShortcuts } from './keyboardShortcuts';
6
- export { default as Layout } from './layout';
7
- export { default as Statusbar } from './statusbar';
8
- export { default as TimeServer } from './timeServer';
9
- export { default as View } from './view';
@@ -1,67 +0,0 @@
1
- class KeyboardShortcutsManager {
2
- #shortcuts = [];
3
- /**
4
- *
5
- * @param keys1
6
- * @param keys2
7
- * @returns
8
- */
9
- #areKeysEqual(keys1, keys2) {
10
- if (keys1.length !== keys2.length)
11
- return false;
12
- return keys1.every((key1, index) => key1.key.toLowerCase() === keys2[index].key.toLowerCase() &&
13
- key1.ctrlKey === keys2[index].ctrlKey &&
14
- key1.shiftKey === keys2[index].shiftKey &&
15
- key1.altKey === keys2[index].altKey &&
16
- key1.metaKey === keys2[index].metaKey);
17
- }
18
- /**
19
- *
20
- * @param event
21
- * @param keys
22
- * @returns
23
- */
24
- #areKeysPressed(event, keys) {
25
- return keys.every((key) => (key.ctrlKey ? event.ctrlKey : true) &&
26
- (key.shiftKey ? event.shiftKey : true) &&
27
- (key.altKey ? event.altKey : true) &&
28
- (key.metaKey ? event.metaKey : true) &&
29
- event.key.toLowerCase() === key.key.toLowerCase());
30
- }
31
- /**
32
- *
33
- */
34
- constructor() {
35
- document.addEventListener('keydown', this.handleKeyEvent.bind(this));
36
- }
37
- /**
38
- *
39
- * @param shortcut
40
- */
41
- registerShortcut(shortcut) {
42
- this.#shortcuts.push(shortcut);
43
- }
44
- /**
45
- *
46
- * @param keys
47
- */
48
- unregisterShortcut(keys) {
49
- this.#shortcuts = this.#shortcuts.filter((shortcut) => this.#areKeysEqual(shortcut.keys, keys));
50
- }
51
- /**
52
- *
53
- * @param event
54
- */
55
- handleKeyEvent(event) {
56
- const matchedShortcut = this.#shortcuts.find((shortcut) => this.#areKeysPressed(event, shortcut.keys));
57
- if (matchedShortcut) {
58
- event.preventDefault();
59
- const commandsManager = window.punica.Commands.manager;
60
- commandsManager.executeCommand(matchedShortcut.command);
61
- }
62
- }
63
- }
64
- const keyboardShortcuts = {
65
- manager: new KeyboardShortcutsManager()
66
- };
67
- export default keyboardShortcuts;
@@ -1,50 +0,0 @@
1
- class LayoutManager {
2
- #item = new Map();
3
- #layoutElement;
4
- /**
5
- *
6
- * @param type
7
- */
8
- #addItem(type) {
9
- const content = document.createElement('div');
10
- content.id = type;
11
- this.#layoutElement.appendChild(content);
12
- this.#item.set(type, { type, content });
13
- }
14
- /**
15
- *
16
- */
17
- constructor() {
18
- this.#layoutElement = document.createElement('div');
19
- this.#layoutElement.id = 'punica-editor';
20
- this.#addItem('appBar');
21
- this.#addItem('activityBar');
22
- this.#addItem('content');
23
- this.#addItem('statusbar');
24
- this.#addItem('primarySidebar');
25
- this.#addItem('secondarySidebar');
26
- }
27
- /**
28
- *
29
- * @param type
30
- * @returns
31
- */
32
- getItem(type) {
33
- const item = this.#item.get(type);
34
- if (item === undefined) {
35
- throw new Error(`Item of type '${type}' not found`);
36
- }
37
- return item;
38
- }
39
- /**
40
- *
41
- * @param container
42
- */
43
- render(container) {
44
- container.appendChild(this.#layoutElement);
45
- }
46
- }
47
- const layout = {
48
- manager: new LayoutManager()
49
- };
50
- export default layout;
@@ -1,81 +0,0 @@
1
- class StatusbarManager {
2
- #primaryItems = new Map();
3
- #secondaryItems = new Map();
4
- #content;
5
- #primaryContent;
6
- #secondaryContent;
7
- /**
8
- *
9
- */
10
- #initiliazeContent() {
11
- const layoutManager = window.punica.Layout.manager;
12
- const statusbarContent = layoutManager.getItem('statusbar').content;
13
- this.#content = document.createElement('punica-row');
14
- this.#primaryContent = document.createElement('punica-col');
15
- this.#secondaryContent = document.createElement('punica-col');
16
- this.#content.setAttribute('alignItems', 'center');
17
- this.#content.setAttribute('justifyContent', 'space-between');
18
- this.#content.appendChild(this.#primaryContent);
19
- this.#content.appendChild(this.#secondaryContent);
20
- statusbarContent?.appendChild(this.#content);
21
- }
22
- /**
23
- *
24
- */
25
- constructor() { }
26
- /**
27
- *
28
- * @param alignment
29
- * @param item
30
- */
31
- addItem(item) {
32
- if (!this.#content) {
33
- this.#initiliazeContent();
34
- }
35
- const button = document.createElement('punica-button');
36
- button.setAttribute('id', item.id);
37
- button.setAttribute('disabled', 'false');
38
- button.setAttribute('size', 'dd');
39
- button.setAttribute('title', item.title);
40
- button.onclick = () => { };
41
- button.className = 'status-bar-action';
42
- if (item.icon) {
43
- button.innerHTML = `<punica-icon size="xlarge">${item.icon}</punica-icon>`;
44
- }
45
- else if (item.label) {
46
- button.innerHTML = item.label;
47
- }
48
- if (item.alignment === 'primary') {
49
- this.#primaryItems.set(item.id, item);
50
- this.#primaryContent.appendChild(button);
51
- }
52
- else {
53
- this.#secondaryItems.set(item.id, item);
54
- this.#secondaryContent.appendChild(button);
55
- }
56
- }
57
- /**
58
- *
59
- * @param itemId
60
- */
61
- removeItem(itemId) {
62
- if (this.#primaryItems.has(itemId)) {
63
- const itemElement = this.#primaryContent.querySelector('#' + itemId);
64
- if (itemElement) {
65
- this.#primaryContent.removeChild(itemElement);
66
- this.#primaryItems.delete(itemId);
67
- }
68
- }
69
- else if (this.#secondaryItems.has(itemId)) {
70
- const itemElement = this.#secondaryContent.querySelector('#' + itemId);
71
- if (itemElement) {
72
- this.#secondaryContent.removeChild(itemElement);
73
- this.#secondaryItems.delete(itemId);
74
- }
75
- }
76
- }
77
- }
78
- const statusbar = {
79
- manager: new StatusbarManager()
80
- };
81
- export default statusbar;
@@ -1,49 +0,0 @@
1
- class TimeServerManager {
2
- #subscribers = [];
3
- #intervalId = null;
4
- /**
5
- *
6
- */
7
- #start() {
8
- if (this.#intervalId === null) {
9
- this.#intervalId = window.setInterval(() => {
10
- const currentTime = new Date();
11
- this.#subscribers.forEach((subscriber) => subscriber.update(currentTime));
12
- }, 1000);
13
- }
14
- }
15
- /**
16
- *
17
- */
18
- #stop() {
19
- if (this.#intervalId !== null) {
20
- window.clearInterval(this.#intervalId);
21
- this.#intervalId = null;
22
- }
23
- }
24
- /**
25
- *
26
- * @param subscriber
27
- */
28
- subscribe(subscriber) {
29
- this.#subscribers.push(subscriber);
30
- if (this.#subscribers.length == 1) {
31
- this.#start();
32
- }
33
- }
34
- /**
35
- *
36
- * @param subscriber
37
- */
38
- unsubscribe(subscriber) {
39
- this.#subscribers = this.#subscribers.filter((sub) => sub !== subscriber);
40
- if (this.#subscribers.length == 0) {
41
- this.#stop();
42
- }
43
- }
44
- }
45
- const timeServerManager = {
46
- manager: new TimeServerManager()
47
- };
48
- //timeServerManager.manager.start();
49
- export default timeServerManager;
@@ -1,7 +0,0 @@
1
- const view = {
2
- showInformationMessage: (message, ...items) => {
3
- console.log(message, items);
4
- return [];
5
- }
6
- };
7
- export default view;
package/dist/index.js DELETED
@@ -1,15 +0,0 @@
1
- import { ActivityBar, Commands, History, Extensions, KeyboardShortcuts, Layout, Statusbar, TimeServer, View } from './impl';
2
- export function initialize() {
3
- window.punica = {
4
- version: '1.0.0',
5
- ActivityBar,
6
- Commands,
7
- History,
8
- Extensions,
9
- KeyboardShortcuts,
10
- Layout,
11
- Statusbar,
12
- TimeServer,
13
- View
14
- };
15
- }