Skip to content

Commit

Permalink
fix: update cli and fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Aug 30, 2024
1 parent 75368ff commit e5447be
Show file tree
Hide file tree
Showing 11 changed files with 2,131 additions and 1,677 deletions.
6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_modules
npm-debug.log
dist
docs
/coverage
.rete-cli
.sonar
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import tseslint from 'typescript-eslint';
import configs from 'rete-cli/eslint.config.mjs';
import globals from 'globals'

export default tseslint.config(
...configs,
{
languageOptions: {
globals: {
...globals.browser
}
}
}
)
3,729 changes: 2,083 additions & 1,646 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"rete-area-plugin": "^2.0.0"
},
"devDependencies": {
"globals": "^15.9.0",
"rete": "^2.0.1",
"rete-area-plugin": "^2.0.0",
"rete-cli": "^1.0.2",
"typescript": "5.0"
"rete-cli": "~2.0.0"
},
"dependencies": {
"@babel/runtime": "^7.21.0"
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ export class ContextMenuPlugin<Schemes extends BaseSchemes> extends Scope<never,
element.style.top = `${context.data.event.clientY}px`
element.style.display = ''

parent.emit({
void parent.emit({
type: 'render',
data: {
type: 'contextmenu',
element,
searchBar,
onHide() {
parent.emit({ type: 'unmount', data: { element } })
void parent.emit({ type: 'unmount', data: { element } })
},
items: list
}
})
} else if (context.type === 'pointerdown') {
if (!context.data.event.composedPath().includes(element)) {
parent.emit({ type: 'unmount', data: { element } })
void parent.emit({ type: 'unmount', data: { element } })
}
}
return context
Expand Down
19 changes: 11 additions & 8 deletions src/presets/classic/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@ export function createItem<S extends BSchemes>(
key: string | number,
context: { editor: NodeEditor<S>, area: BaseAreaPlugin<S, any> }

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

The type of 'area' contains 'any'

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

The type of 'area' contains 'any'

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

The type of 'area' contains 'any'

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

The type of 'area' contains 'any'

Check warning on line 10 in src/presets/classic/factory.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type
): Item {
const item = {
const item: Item = {
label,
key: String(key)
key: String(key),
handler() {
/* noop */
}
}

if (typeof factory === 'function') {
return <Item>{
return {
...item,
async handler() {
const node = await factory()

await context.editor.addNode(node)

context.area.translate(node.id, context.area.area.pointer)
void context.area.translate(node.id, context.area.area.pointer)
}
}
} satisfies Item
}
return <Item>{
return {
...item,
handler() {/* do nothing */},
handler() { /* do nothing */ },
subitems: factory.map((data, i) => createItem(data, i, context))
}
} satisfies Item
}
18 changes: 10 additions & 8 deletions src/presets/classic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { BSchemes, ItemDefinition } from './types'
* Configures nodes/actions items for root and Delete/Clone items for nodes
* @param nodes List of items
* @example Presets.classic.setup([
["Math", [
["Number", () => new NumberNode()],
]]
])
* ["Math", [
* ["Number", () => new NumberNode()],
* ]]
*])
*/
export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]) {
return <Items<Schemes>>(function (context, plugin) {
return function (context, plugin) {
const area = plugin.parentScope<BaseAreaPlugin<Schemes, any>>(BaseAreaPlugin)
const editor = area.parentScope<NodeEditor<Schemes>>(NodeEditor)

Expand Down Expand Up @@ -60,16 +60,18 @@ export function setup<Schemes extends BSchemes>(nodes: ItemDefinition<Schemes>[]

await editor.addNode(node)

area.translate(node.id, area.area.pointer)
void area.translate(node.id, area.area.pointer)
}
}

return {
searchBar: false,
list: [
deleteItem,
...(cloneItem ? [cloneItem] : [])
...cloneItem
? [cloneItem]
: []
]
}
})
} satisfies Items<Schemes>
}
2 changes: 1 addition & 1 deletion src/presets/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Presets that create items for root and node specific context menu.
* @module
*/
*/

export * as classic from './classic'
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export type Position = { x: number, y: number }
export type Item = {
label: string
key: string
handler(): void
handler(): void | Promise<void>
subitems?: Item[]
}

export type ItemsCollection = {
searchBar?: boolean,
searchBar?: boolean
list: Item[]
}

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"strict": true
"strict": true,
"skipLibCheck": true
},
"include": ["src"]
}

0 comments on commit e5447be

Please sign in to comment.