@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
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "@punica/editor",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Punica Editor",
5
5
  "private": false,
6
- "main": "dist/index.js",
6
+ "type": "module",
7
+ "main": "dist/index.bundle.esm.js",
8
+ "module": "dist/index.bundle.esm.js",
9
+ "browser": "dist/index.bundle.umd.js",
7
10
  "types": "types/index.d.ts",
8
11
  "publishConfig": {
9
12
  "access": "public"
10
13
  },
11
14
  "scripts": {
12
- "build": "tsc -p tsconfig.build.json",
15
+ "build": "rollup -c",
13
16
  "lint": "eslint . --ext .js,.ts",
14
17
  "lint:fix": "eslint . --ext .js,.ts --fix",
15
18
  "format": "prettier --write \"./**/*.{ts,js,json,md}\"",
@@ -30,17 +33,24 @@
30
33
  ],
31
34
  "dependencies": {
32
35
  "@punica/common": "^1.0.2",
33
- "yaml":"^2.4.5",
34
- "classnames": "^2.3.2"
36
+ "classnames": "^2.3.2",
37
+ "yaml": "^2.4.5"
35
38
  },
36
39
  "devDependencies": {
40
+ "@eslint/config-array": "^0.17.0",
41
+ "@rollup/plugin-commonjs": "^28.0.9",
42
+ "@rollup/plugin-json": "^6.1.0",
43
+ "@rollup/plugin-node-resolve": "^15.3.1",
44
+ "@rollup/plugin-terser": "^0.4.4",
45
+ "@rollup/plugin-typescript": "^12.3.0",
37
46
  "@types/node": "^20.14.10",
38
47
  "@typescript-eslint/eslint-plugin": "",
39
48
  "@typescript-eslint/parser": "^7.16.0",
40
- "@eslint/config-array": "^0.17.0",
41
49
  "eslint": "^8.56.0",
42
50
  "husky": "^9.1.1",
43
51
  "prettier": "^3.3.2",
52
+ "rollup": "^4.53.2",
53
+ "tslib": "^2.8.1",
44
54
  "typescript": "^5.5.3"
45
55
  }
46
56
  }
package/types/index.d.ts CHANGED
@@ -14,6 +14,12 @@ declare module 'punica' {
14
14
  export const version: string;
15
15
  }
16
16
 
17
+ declare global {
18
+ interface Window {
19
+ punica: typeof import('punica');
20
+ }
21
+ }
22
+
17
23
  export function initialize(): void;
18
24
 
19
25
  export {};
@@ -124,8 +124,31 @@ declare module 'punica' {
124
124
  }
125
125
 
126
126
  interface IExtensionManager {
127
+ /**
128
+ * Load one or more extensions from URL or file path.
129
+ */
127
130
  load(extensionPath: string, ...args: string[]): Promise<void>;
128
- activate(extensionName): Promise<void>;
131
+
132
+ /**
133
+ * Activate a specific extension by name.
134
+ */
135
+ activate(extensionName: string): Promise<void>;
136
+
137
+ /**
138
+ * Trigger activation of all extensions that declare `onStartup:begin`
139
+ * in their activationEvents.
140
+ */
141
+ startupBegin(): Promise<void>;
142
+
143
+ /**
144
+ * Trigger activation of all extensions that declare `onStartup:finish`
145
+ * in their activationEvents.
146
+ */
147
+ startupFinish(): Promise<void>;
148
+
149
+ /**
150
+ * Get loaded extension metadata by name.
151
+ */
129
152
  getExtension(extensionName: string): Extension | undefined;
130
153
  }
131
154
 
@@ -1,75 +0,0 @@
1
- class ActivityBarManager {
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 activityBarContent = layoutManager.getItem('activityBar').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('direction', 'column');
17
- this.#content.setAttribute('alignitems', 'stretch');
18
- this.#content.appendChild(this.#primaryContent);
19
- this.#content.appendChild(this.#secondaryContent);
20
- activityBarContent?.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('title', item.title);
39
- button.onclick = () => { };
40
- button.innerHTML = `<punica-icon size="xlarge">${item.icon}</punica-icon>`;
41
- button.className = 'extension';
42
- if (item.alignment === 'primary') {
43
- this.#primaryItems.set(item.id, item);
44
- this.#primaryContent.appendChild(button);
45
- }
46
- else {
47
- this.#secondaryItems.set(item.id, item);
48
- this.#secondaryContent.appendChild(button);
49
- }
50
- }
51
- /**
52
- *
53
- * @param itemId
54
- */
55
- removeItem(itemId) {
56
- if (this.#primaryItems.has(itemId)) {
57
- const itemElement = this.#primaryContent.querySelector('#' + itemId);
58
- if (itemElement) {
59
- this.#primaryContent.removeChild(itemElement);
60
- this.#primaryItems.delete(itemId);
61
- }
62
- }
63
- else if (this.#secondaryItems.has(itemId)) {
64
- const itemElement = this.#secondaryContent.querySelector('#' + itemId);
65
- if (itemElement) {
66
- this.#secondaryContent.removeChild(itemElement);
67
- this.#secondaryItems.delete(itemId);
68
- }
69
- }
70
- }
71
- }
72
- const activityBar = {
73
- manager: new ActivityBarManager()
74
- };
75
- export default activityBar;
@@ -1,52 +0,0 @@
1
- class CommandManager {
2
- #commands = new Map();
3
- #disposables = new Map();
4
- /**
5
- *
6
- * @param commandName
7
- * @param command
8
- * @returns
9
- */
10
- registerCommand(commandName, command) {
11
- const disposable = {
12
- dispose: () => {
13
- this.#commands.delete(commandName);
14
- this.#disposables.delete(commandName);
15
- }
16
- };
17
- command.disposable = disposable;
18
- this.#disposables.set(commandName, disposable);
19
- this.#commands.set(commandName, command);
20
- }
21
- /**
22
- *
23
- * @param commandName
24
- * @param args
25
- */
26
- executeCommand(commandName, ...args) {
27
- const command = this.#commands.get(commandName);
28
- if (command) {
29
- command.execute(...args);
30
- }
31
- else {
32
- console.error(`Command ${commandName} not found`);
33
- }
34
- }
35
- /**
36
- *
37
- * @param commandName
38
- */
39
- disposeCommand(commandName) {
40
- const disposable = this.#disposables.get(commandName);
41
- if (disposable) {
42
- disposable.dispose();
43
- }
44
- else {
45
- console.error(`Command ${commandName} not found or already disposed`);
46
- }
47
- }
48
- }
49
- const commands = {
50
- manager: new CommandManager()
51
- };
52
- export default commands;
@@ -1,19 +0,0 @@
1
- class BaseDecorator {
2
- #decorator;
3
- /**
4
- *
5
- * @param decorator
6
- */
7
- constructor(decorator) {
8
- this.#decorator = decorator;
9
- }
10
- /**
11
- *
12
- * @param extension
13
- */
14
- async execute() {
15
- const extension = await this.#decorator.execute();
16
- return extension;
17
- }
18
- }
19
- export default BaseDecorator;
@@ -1,20 +0,0 @@
1
- import BaseReader from '../base';
2
- class Decorator extends BaseReader {
3
- /**
4
- *
5
- * @param decorator
6
- */
7
- constructor(decorator) {
8
- super(decorator);
9
- }
10
- /**
11
- *
12
- * @param extension
13
- * @returns
14
- */
15
- async execute() {
16
- const extension = await super.execute();
17
- return extension;
18
- }
19
- }
20
- export default Decorator;
@@ -1,3 +0,0 @@
1
- export { default as Configuration } from './configuration';
2
- export { default as ModuleLoader } from './moduleLoader';
3
- export { default as Views } from './views';
@@ -1,29 +0,0 @@
1
- import BaseReader from '../base';
2
- class Decorator extends BaseReader {
3
- /**
4
- *
5
- * @param decorator
6
- */
7
- constructor(decorator) {
8
- super(decorator);
9
- }
10
- /**
11
- *
12
- * @param extension
13
- * @returns
14
- */
15
- async execute() {
16
- try {
17
- const extension = await super.execute();
18
- const extensionMain = `${extension.moduleURL}${extension.main}`;
19
- const module = await import(/* webpackIgnore: true */ `${extensionMain}`);
20
- const extensionModule = module.default;
21
- extension.module = extensionModule;
22
- return extension;
23
- }
24
- catch (error) {
25
- throw new Error();
26
- }
27
- }
28
- }
29
- export default Decorator;
@@ -1,34 +0,0 @@
1
- import BaseReader from '../base';
2
- class Decorator extends BaseReader {
3
- /**
4
- * Creates an instance of Decorator.
5
- * @param decorator An ExtensionDecorator instance to decorate.
6
- */
7
- constructor(decorator) {
8
- super(decorator);
9
- }
10
- /**
11
- * Reads the extension and adds it to the relevant views.
12
- * @returns A promise resolving to the read extension.
13
- */
14
- async execute() {
15
- const extension = await super.execute();
16
- const { integrations } = extension;
17
- if (!integrations) {
18
- return extension;
19
- }
20
- const { views } = integrations;
21
- if (!views) {
22
- return extension;
23
- }
24
- const { activityBar, statusBar } = views;
25
- if (activityBar) {
26
- window.punica.ActivityBar.manager.addItem(activityBar);
27
- }
28
- if (statusBar) {
29
- window.punica.Statusbar.manager.addItem(statusBar);
30
- }
31
- return extension;
32
- }
33
- }
34
- export default Decorator;
@@ -1,28 +0,0 @@
1
- class Getter {
2
- #name;
3
- /**
4
- *
5
- * @param name
6
- */
7
- constructor(name) {
8
- this.#name = name;
9
- }
10
- /**
11
- *
12
- * @param extension
13
- * @returns
14
- */
15
- execute() {
16
- return new Promise((resolve, reject) => {
17
- const extensionManager = window.punica.Extensions.manager;
18
- const extension = extensionManager.getExtension(this.#name);
19
- if (extension) {
20
- resolve(extension);
21
- }
22
- else {
23
- reject(new Error('Extension not found'));
24
- }
25
- });
26
- }
27
- }
28
- export default Getter;
@@ -1,14 +0,0 @@
1
- import Getter from './getter';
2
- import { Views, Configuration, ModuleLoader } from './decorators';
3
- /**
4
- *
5
- * @param extensionName
6
- * @returns
7
- */
8
- export const activeExtension = (extensionName) => {
9
- const getter = new Getter(extensionName);
10
- const moduleLoader = new ModuleLoader(getter);
11
- const views = new Views(moduleLoader);
12
- const configuration = new Configuration(views);
13
- return configuration;
14
- };
@@ -1,2 +0,0 @@
1
- export class Command {
2
- }
@@ -1,2 +0,0 @@
1
- export * from './onCommand';
2
- export * from './onExtension';
@@ -1,16 +0,0 @@
1
- import { Command } from './base';
2
- export class OnCommand extends Command {
3
- #detail;
4
- /**
5
- *
6
- * @param detail
7
- */
8
- constructor(detail) {
9
- super();
10
- this.#detail = detail;
11
- }
12
- /**
13
- *
14
- */
15
- execute() { }
16
- }
@@ -1,16 +0,0 @@
1
- import { Command } from './base';
2
- export class OnExtensionCommand extends Command {
3
- #detail;
4
- /**
5
- *
6
- * @param detail
7
- */
8
- constructor(detail) {
9
- super();
10
- this.#detail = detail;
11
- }
12
- /**
13
- *
14
- */
15
- execute() { }
16
- }
@@ -1,32 +0,0 @@
1
- export class EventHandler {
2
- #commandMap;
3
- /**
4
- *
5
- */
6
- constructor() {
7
- this.#commandMap = new Map();
8
- }
9
- /**
10
- *
11
- * @param eventType
12
- * @param commandClass
13
- */
14
- register(eventType, commandClass) {
15
- this.#commandMap.set(eventType, commandClass);
16
- }
17
- /**
18
- *
19
- * @param event
20
- */
21
- handleEvent(event) {
22
- const [eventType, eventDetail] = event.split(':');
23
- const CommandClass = this.#commandMap.get(eventType);
24
- if (CommandClass) {
25
- const command = new CommandClass(eventDetail);
26
- command.execute();
27
- }
28
- else {
29
- console.warn(`Unknown event type: ${eventType}`);
30
- }
31
- }
32
- }
@@ -1,29 +0,0 @@
1
- import BaseReader from '../base';
2
- import { EventHandler } from './handler';
3
- import { OnCommand, OnExtensionCommand } from './commands';
4
- class Decorator extends BaseReader {
5
- #eventHandler;
6
- /**
7
- *
8
- * @param decorator
9
- */
10
- constructor(decorator) {
11
- super(decorator);
12
- this.#eventHandler = new EventHandler();
13
- this.#eventHandler.register('onExtension', OnExtensionCommand);
14
- this.#eventHandler.register('onCommand', OnCommand);
15
- }
16
- /**
17
- *
18
- * @returns
19
- */
20
- async execute() {
21
- const extension = await super.execute();
22
- const { activationEvents } = extension;
23
- if (activationEvents) {
24
- activationEvents.forEach((event) => this.#eventHandler.handleEvent(event));
25
- }
26
- return extension;
27
- }
28
- }
29
- export default Decorator;
@@ -1,19 +0,0 @@
1
- class BaseDecorator {
2
- #decorator;
3
- /**
4
- *
5
- * @param decorator
6
- */
7
- constructor(decorator) {
8
- this.#decorator = decorator;
9
- }
10
- /**
11
- *
12
- * @param extension
13
- */
14
- async execute() {
15
- const extension = await this.#decorator.execute();
16
- return extension;
17
- }
18
- }
19
- export default BaseDecorator;
@@ -1,37 +0,0 @@
1
- import BaseReader from '../base';
2
- class Decorator extends BaseReader {
3
- /**
4
- *
5
- * @param decorator
6
- */
7
- constructor(decorator) {
8
- super(decorator);
9
- }
10
- /**
11
- *
12
- * @param extension
13
- * @returns
14
- */
15
- async execute() {
16
- const extension = await super.execute();
17
- const { integrations } = extension;
18
- if (integrations) {
19
- const { commands } = integrations;
20
- if (commands) {
21
- commands.forEach((item) => {
22
- const { command, title } = item;
23
- const commandsManager = window.punica.Commands.manager;
24
- const extensionsManager = window.punica.Extensions.manager;
25
- commandsManager.registerCommand(command, {
26
- title,
27
- execute: () => {
28
- extensionsManager.activate(extension.name);
29
- }
30
- });
31
- });
32
- }
33
- }
34
- return extension;
35
- }
36
- }
37
- export default Decorator;
@@ -1,4 +0,0 @@
1
- export { default as ActivationEvents } from './activationEvents';
2
- export { default as Commands } from './commands';
3
- export { default as Keybindings } from './keybindings';
4
- export { default as Menus } from './menus';
@@ -1,65 +0,0 @@
1
- import BaseReader from '../base';
2
- class Decorator extends BaseReader {
3
- /**
4
- *
5
- * @param shortcut
6
- * @returns
7
- */
8
- #parseShortcut(shortcut) {
9
- const parts = shortcut.split('+').map((part) => part.trim().toLowerCase());
10
- const shortcutObj = {
11
- key: ''
12
- };
13
- parts.forEach((part) => {
14
- switch (part) {
15
- case 'ctrl':
16
- shortcutObj.ctrlKey = true;
17
- break;
18
- case 'shift':
19
- shortcutObj.shiftKey = true;
20
- break;
21
- case 'alt':
22
- shortcutObj.altKey = true;
23
- break;
24
- case 'meta':
25
- case 'cmd':
26
- case 'command':
27
- shortcutObj.metaKey = true;
28
- break;
29
- default:
30
- shortcutObj.key = part;
31
- }
32
- });
33
- return shortcutObj;
34
- }
35
- /**
36
- *
37
- * @param decorator
38
- */
39
- constructor(decorator) {
40
- super(decorator);
41
- }
42
- /**
43
- *
44
- * @returns
45
- */
46
- async execute() {
47
- const extension = await super.execute();
48
- const { integrations } = extension;
49
- if (integrations) {
50
- const { keybindings } = integrations;
51
- if (keybindings) {
52
- keybindings.forEach((item) => {
53
- const { command, key } = item;
54
- const keyboardShortcutsManager = window.punica.KeyboardShortcuts.manager;
55
- keyboardShortcutsManager.registerShortcut({
56
- command,
57
- keys: [this.#parseShortcut(key)]
58
- });
59
- });
60
- }
61
- }
62
- return extension;
63
- }
64
- }
65
- export default Decorator;
@@ -1,20 +0,0 @@
1
- import BaseReader from '../base';
2
- class Decorator extends BaseReader {
3
- /**
4
- *
5
- * @param decorator
6
- */
7
- constructor(decorator) {
8
- super(decorator);
9
- }
10
- /**
11
- *
12
- * @param extension
13
- * @returns
14
- */
15
- async execute() {
16
- const extension = await super.execute();
17
- return extension;
18
- }
19
- }
20
- export default Decorator;
@@ -1,15 +0,0 @@
1
- import Reader from './reader';
2
- import { ActivationEvents, Commands, Keybindings, Menus } from './decorators';
3
- /**
4
- *
5
- * @param extensionURL
6
- * @returns
7
- */
8
- export const analysisExtension = (extensionURL) => {
9
- const reader = new Reader(extensionURL);
10
- const commands = new Commands(reader);
11
- const keybindings = new Keybindings(commands);
12
- const menus = new Menus(keybindings);
13
- const activationEvents = new ActivationEvents(menus);
14
- return activationEvents;
15
- };