Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(type-designer): migrate plugin to independant plugin packages #112

Merged
merged 15 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
},
"files": {
"ignoreUnknown": false,
"ignore": []
"ignore": [
"packages/core/src/scd-events-v1/edit.scd-events-v1.ts",
"packages/core/src/scd-events-v1/open.scd-events-v1.ts",
"packages/core/src/scd-xml/foundation.ts"
]
},
"formatter": {
"enabled": true,
Expand Down Expand Up @@ -49,7 +53,15 @@
},
"overrides": [
{
"include": ["*.svelte"]
"include": ["*.svelte"],
"linter": {
"rules": {
"style": {
"useConst": "off",
"useImportType": "off"
}
}
}
}
]
}
29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
{
"name": "@oscd-plugins/network",
"name": "@oscd-plugins/monorepo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --mode=DEV",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
"//====== FORMAT & LINT ======//": "",
"biome:check": "biome check .",
"biome:fix": "biome check . --write",
"//====== PREPARE ======//": "",
"prepare": "husky install"
"prepare": "husky install",
"//====== LAUNCHING SCRIPTS ======//": "",
"storybook": "pnpm --filter @oscd-plugins/ui storybook",
"//====== LOCAL DEPENDENCIES INSTALL ======//": "",
"install:core": "pnpm --filter @oscd-plugins/core i",
"install:ui": "pnpm --filter @oscd-plugins/ui i",
"//====== PLUGIN INSTALL ======//": "",
"install:type-designer": "pnpm install:core && pnpm install:ui && pnpm --filter @oscd-plugins/type-designer i",
"//====== PLUGIN STAND ALONE MODE ======//": "",
"dev:type-designer": "pnpm install:type-designer && pnpm --filter @oscd-plugins/type-designer dev",
"//====== PLUGIN INTEGRATED MODE ======//": "",
"dev:integrated:type-designer": "pnpm install:type-designer && pnpm --filter @oscd-plugins/type-designer build:watch"
},
"devDependencies": {
"@biomejs/biome": "1.9.2",
"@sveltejs/vite-plugin-svelte": "^2.0.2",
michelguerin marked this conversation as resolved.
Show resolved Hide resolved
"@tsconfig/svelte": "^3.0.0",
"husky": "^8.0.3",
"svelte": "^3.55.1",
"svelte-check": "^2.10.3",
"tslib": "^2.5.0",
"turbo": "^1.8.3",
"typescript": "^4.9.3",
"vite": "^4.1.0"
"husky": "^8.0.3"
},
"packageManager": "[email protected]+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c"
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"eslint-plugin-promise": "^6.0.0",
"happy-dom": "^8.9.0",
"safaridriver": "^0.0.4",
"svelte": "^4.2.19",
"typescript": "4.9.4",
"vitest": "^0.29.7",
"webdriverio": "^8.6.7"
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ export * from './constants/element.constant'

// UTILS
export type * from './utils'

// PLUGIN
export * from './scd-plugin'
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE DIRECTLY ! MAKE A PR TO MODIFY THE CORE LIBRARY. //
// AS FOR NOW THE OPENSCD EVENTS PACKAGE IS NOT PUBLISHED //
// WE USE A COPY OF ITS CORE EDITOR FUNCTIONALITIES - THIS IS THE V1 MARK AS DEPRECATED BUT STILL IN USE //
// SEE SOURCE https://github.com/openscd/open-scd/blob/main/packages/core/foundation/deprecated/editor.ts //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE DIRECTLY ! MAKE A PR TO MODIFY THE CORE LIBRARY.
// AS FOR NOW THE OPENSCD EVENTS PACKAGE IS NOT PUBLISHED
// WE USE A COPY OF ITS CORE EDITOR FUNCTIONALITIES - THIS IS THE V1 MARK AS DEPRECATED BUT STILL IN USE
// SEE SOURCE https://github.com/openscd/open-scd/blob/main/packages/core/foundation/deprecated/editor.ts
// THIS FILE IS IGNORED BY BIOME
//////////////////////////////////////////////////////////////////////////////////////////////////////////

export type Initiator = 'user' | 'system' | 'undo' | 'redo' | string

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/scd-events-v1/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './scd-edit-events'
export * from './edit.scd-events-v1'
michelguerin marked this conversation as resolved.
Show resolved Hide resolved
export * from './open.scd-events-v1'
33 changes: 33 additions & 0 deletions packages/core/src/scd-events-v1/open.scd-events-v1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE DIRECTLY ! MAKE A PR TO MODIFY THE CORE LIBRARY.
// AS FOR NOW THE OPENSCD EVENTS PACKAGE IS NOT PUBLISHED
// WE USE A COPY OF ITS CORE EDITOR FUNCTIONALITIES - THIS IS THE V1 MARK AS DEPRECATED BUT STILL IN USE
// SEE SOURCE https://github.com/openscd/open-scd/blob/main/packages/core/foundation/deprecated/open-event.js
// THIS FILE IS IGNORED BY BIOME
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

/** Represents a document to be opened. */
export interface OpenDocDetail {
doc: XMLDocument
docName: string
docId?: string
}
export type OpenDocEvent = CustomEvent<OpenDocDetail>
export function newOpenDocEvent(
doc: XMLDocument,
docName: string,
eventInitDict?: CustomEventInit<Partial<OpenDocDetail>>
): OpenDocEvent {
return new CustomEvent<OpenDocDetail>('open-doc', {
bubbles: true,
composed: true,
...eventInitDict,
detail: { doc, docName, ...eventInitDict?.detail }
})
}

declare global {
interface ElementEventMap {
['open-doc']: OpenDocEvent
}
}
1 change: 0 additions & 1 deletion packages/core/src/scd-events/index.ts

This file was deleted.

184 changes: 0 additions & 184 deletions packages/core/src/scd-events/scd-edit-events.ts

This file was deleted.

60 changes: 60 additions & 0 deletions packages/core/src/scd-plugin/editor-instance.scd-plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// TYPES
import type { SvelteComponent, ComponentType } from 'svelte'
import type { PluginConstructor } from './types.scd-plugin'

export default function editorPluginInstance(
pluginComponent: ComponentType<SvelteComponent>
) {
//====== INITIALIZATION ======//

// this emulate the class declaration we need for custom components
function EditorPlugin() {
return Reflect.construct(HTMLElement, [], new.target)
}
EditorPlugin.prototype = Object.create(HTMLElement.prototype)

//====== PROPERTIES ======//

EditorPlugin.prototype.pluginInstance = undefined
EditorPlugin.prototype.localDoc = undefined
EditorPlugin.prototype.localDocName = undefined

//====== METHODS ======//

Object.defineProperty(EditorPlugin.prototype, 'doc', {
get: function doc() {
return this.localDoc
},
set: function doc(newDoc: XMLDocument) {
this.localDoc = newDoc
if (!this.pluginInstance) return

this.pluginInstance.$set({ xmlDocument: newDoc })
}
})

Object.defineProperty(EditorPlugin.prototype, 'docName', {
get: function docName() {
return this.localDocName
},
set: function docName(newDocName: string) {
this.localDocName = newDocName
}
})

//====== LIFECYCLE METHODS ======//

EditorPlugin.prototype.connectedCallback = function () {
this.pluginInstance = new pluginComponent({
target: this.attachShadow({ mode: 'open' }),
props: {
xmlDocument: this.localDoc,
pluginHostElement: this
}
})
}

//====== RETURN PLUGIN INSTANCE ======//

return EditorPlugin as unknown as PluginConstructor
}
3 changes: 3 additions & 0 deletions packages/core/src/scd-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './wrapper.scd-plugin'
// TYPES
export type { PluginType } from './types.scd-plugin'
Loading