From 5cc157ef780d7603880bf38b400df6b25339ffd1 Mon Sep 17 00:00:00 2001 From: Ni55aN Date: Fri, 14 Jul 2023 21:08:44 +0300 Subject: [PATCH 1/2] docs: add tsdoc comments --- .gitignore | 1 + package-lock.json | 36 ++++++++++++++++++++++++++++-------- package.json | 6 ++++-- src/index.ts | 25 ++++++++++++++++++++++++- src/presets/classic/index.ts | 10 ++++++++++ src/presets/index.ts | 5 +++++ src/types.ts | 3 +++ 7 files changed, 75 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 16c50a3..16d4bcf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules .vscode/ npm-debug.log dist +docs diff --git a/package-lock.json b/package-lock.json index e53f29c..ded03fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,8 @@ "devDependencies": { "rete": "^2.0.1", "rete-area-plugin": "^2.0.0", - "rete-cli": "^1.0.1" + "rete-cli": "^1.0.1", + "typescript": "5.0" }, "peerDependencies": { "rete": "^2.0.1", @@ -2597,9 +2598,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.8.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.2.tgz", - "integrity": "sha512-cRMwIgdDN43GO4xMWAfJAecYn8wV4JbsOGHNfNUIDiuYkUYAR5ec4Rj7IO2SAhFPEfpPtLtUTbbny/TCT7aDwA==", + "version": "20.4.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.2.tgz", + "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==", "dev": true }, "node_modules/@types/prettier": { @@ -6071,6 +6072,25 @@ "rete": "bin/index.js" } }, + "node_modules/rete-cli/node_modules/@types/node": { + "version": "18.8.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.8.2.tgz", + "integrity": "sha512-cRMwIgdDN43GO4xMWAfJAecYn8wV4JbsOGHNfNUIDiuYkUYAR5ec4Rj7IO2SAhFPEfpPtLtUTbbny/TCT7aDwA==", + "dev": true + }, + "node_modules/rete-cli/node_modules/typescript": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -6704,16 +6724,16 @@ } }, "node_modules/typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=12.20" } }, "node_modules/unicode-canonical-property-names-ecmascript": { diff --git a/package.json b/package.json index ff548e2..e8d67cb 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "", "scripts": { "build": "rete build -c rete.config.ts", - "lint": "rete lint" + "lint": "rete lint", + "doc": "rete doc" }, "author": "Vitaliy Stoliarov", "license": "MIT", @@ -28,7 +29,8 @@ "devDependencies": { "rete": "^2.0.1", "rete-area-plugin": "^2.0.0", - "rete-cli": "^1.0.1" + "rete-cli": "^1.0.1", + "typescript": "5.0" }, "dependencies": { "@babel/runtime": "^7.21.0" diff --git a/src/index.ts b/src/index.ts index 17cd03c..9680fb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,12 +5,22 @@ import { Item, Items, Position } from './types' export * as Presets from './presets' -type Props = { +/** + * Context menu plugin props + * @priority 8 + */ +export type Props = { + /** delay before hiding context menu */ delay?: number + /** menu items, can be produced by preset */ items: Items } export type RenderMeta = { filled?: boolean } +/** + * Signal types produced by ContextMenuPlugin instance + * @priority 10 + */ export type ContextMenuExtra = | RenderSignal<'contextmenu', { items: Item[] @@ -23,7 +33,20 @@ type Requires = | { type: 'unmount', data: { element: HTMLElement } } | { type: 'pointerdown', data: { position: Position, event: PointerEvent } } +/** + * Plugin for context menu. + * Responsible for initialing rendering of context menu with predefined items. + * @priority 9 + * @emits render + * @emits unmount + * @listens unmount + * @listens contextmenu + * @listens pointerdown + */ export class ContextMenuPlugin extends Scope | ContextMenuExtra]> { + /** + * @param props Properties + */ constructor(private props: Props) { super('context-menu') } diff --git a/src/presets/classic/index.ts b/src/presets/classic/index.ts index 3749a51..6fc81ea 100644 --- a/src/presets/classic/index.ts +++ b/src/presets/classic/index.ts @@ -5,6 +5,16 @@ import { Item, Items } from '../../types' import { createItem } from './factory' import { BSchemes, ItemDefinition } from './types' +/** + * Classic context menu preset. + * 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()], + ]] +]) + */ export function setup(nodes: ItemDefinition[]) { return >(function (context, plugin) { const area = plugin.parentScope>(BaseAreaPlugin) diff --git a/src/presets/index.ts b/src/presets/index.ts index 83198dc..dce10a6 100644 --- a/src/presets/index.ts +++ b/src/presets/index.ts @@ -1 +1,6 @@ +/** + * Presets that create items for root and node specific context menu. + * @module +*/ + export * as classic from './classic' diff --git a/src/types.ts b/src/types.ts index fba840a..55cc9bc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,6 +4,9 @@ import { ContextMenuPlugin } from '.' export type Position = { x: number, y: number } +/** + * Item type of context menu + */ export type Item = { label: string key: string From 31883e05b9c225b61c9aa1d3ab82328080cbdeaf Mon Sep 17 00:00:00 2001 From: Ni55aN Date: Fri, 14 Jul 2023 21:09:18 +0300 Subject: [PATCH 2/2] ci: update docs path --- .github/workflows/update-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index 953a9b7..8e0fe9e 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -3,12 +3,12 @@ name: Update docs on: workflow_dispatch: push: - branches: [ "main" ] + branches: ["main"] jobs: pull: uses: retejs/.github/.github/workflows/update-docs.yml@main secrets: inherit with: - filename: '1.rete' - package: rete + filename: "5.rete-context-menu-plugin" + package: rete-context-menu-plugin