Skip to content
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
20 changes: 10 additions & 10 deletions .config/prettierignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.config
../.github
../.vscode
../docs
../es6
../js-legacy
../node_modules
../screenshots
../LICENSE
../package-lock.json
../types/generated
.github
.vscode
docs
es6
js-legacy
node_modules
screenshots
LICENSE
package-lock.json
types
3 changes: 1 addition & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
command: [format-check, test-es6, test-legacy]
command: [format-check, test-es6, build-test-types, test-legacy]

steps:
- uses: actions/checkout@v3
Expand All @@ -25,5 +25,4 @@ jobs:
node-version: 18.x
cache: 'npm'
- run: npm ci
# - run: npm run build --if-present
- run: npm run ${{ matrix.command }}
6 changes: 4 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm ci && npm run gen:dts:check
- run: npm ci
- run: npm test
- run: npm build-test-types

publish-npm:
needs: build
Expand All @@ -28,7 +29,8 @@ jobs:
node-version: 18.x
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run gen:dts && npm run build
- run: npm run build
- run: npm run build-types
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "0.8.7",
"description": "jsMind is a pure javascript library for mindmap, it base on html5 canvas. jsMind was released under BSD license, you can embed it in any project, if only you observe the license.",
"main": "es6/jsmind.js",
"types": "types/generated/types-index.d.ts",
"types": "types/generated/index.d.ts",
"exports": {
".": {
"import": "./es6/jsmind.js",
"require": "./es6/jsmind.js",
"types": "./types/generated/types-index.d.ts"
"types": "./types/generated/index.d.ts"
},
"./draggable-node": {
"import": "./es6/jsmind.draggable-node.js",
Expand Down Expand Up @@ -36,16 +36,14 @@
"scripts": {
"server": "http-server",
"build": "rollup -c .config/rollup.config.js",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"test-legacy": "jest tests/legacy",
"build-types": "npx -p typescript tsc -p types/tsconfig.declaration.json",
"test": "NODE_OPTIONS=--experimental-vm-modules jest tests/unit",
"test-es6": "NODE_OPTIONS=--experimental-vm-modules jest tests/unit",
"gen:dts": "tsc -p tsconfig.decls.json",
"gen:dts:check": "npm run gen:dts && test -d types/generated && ls types/generated >/dev/null",
"test-types": "NODE_OPTIONS=--experimental-vm-modules jest tests/types",
"build-test-types": "npm run build-types && npm run test-types",
"test-legacy": "jest tests/legacy",
"format": "prettier --config .config/prettierrc.json --ignore-path .config/prettierignore --write .",
"format-check": "prettier --config .config/prettierrc.json --ignore-path .config/prettierignore --check .",
"pretest": "npm run gen:dts",
"prepare": "npm run gen:dts",
"prepublishOnly": "npm run build && npm run gen:dts"
"format-check": "prettier --config .config/prettierrc.json --ignore-path .config/prettierignore --check ."
},
"repository": {
"type": "git",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import jsMind, {
NodeTreeFormat,
NodeTreeData,
} from 'jsmind';
import { EventData } from 'types/generated/jsmind';
// Note: in real usage, plugins should be imported to register themselves
// import 'jsmind/draggable-node';
// import 'jsmind/screenshot';
Expand Down Expand Up @@ -79,7 +80,7 @@ const fullOptions: JsMindOptions = {
step: 0.2,
mask_key: 4096,
},
custom_node_render: (jm, element, node) => {
custom_node_render: (jm: jsMind, element: HTMLElement, node: Node) => {
element.innerHTML = `<strong>${node.topic}</strong>`;
},
expander_style: 'number',
Expand Down Expand Up @@ -229,7 +230,7 @@ jm.resize();

// Event listener with stricter data shape

jm.add_event_listener((type, data) => {
jm.add_event_listener((type: number, data: EventData) => {
// data: { evt?: string; data?: unknown[]; node?: string }
console.log(`Event ${type} triggered with data:`, data);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function formatHost() {
}

describe('TypeScript typings validation', () => {
test('tests/fixtures/typescript-test.ts should pass type-check (no diagnostics)', () => {
test('tests/types/fixtures/typescript-test.ts should pass type-check (no diagnostics)', () => {
const projectRoot = process.cwd();
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');

Expand Down
3 changes: 3 additions & 0 deletions tests/types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"noEmit": true,
"baseUrl": ".",
"paths": {
"jsmind": ["types/generated/types-index.d.ts"],
"jsmind": ["types/generated/index.d.ts"],
"jsmind/draggable-node": ["types/generated/plugins/jsmind.draggable-node.d.ts"],
"jsmind/screenshot": ["types/generated/plugins/jsmind.screenshot.d.ts"]
}
},
"include": ["types/**/*.d.ts", "tests/fixtures/typescript-test.ts"],
"include": ["types/**/*.d.ts", "tests/types/fixtures/typescript-test.ts"],
"exclude": ["node_modules", "dist"]
}
9 changes: 4 additions & 5 deletions tsconfig.decls.json → types/tsconfig.declaration.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
"module": "ESNext",
"moduleResolution": "node",
"strict": false,
"skipLibCheck": true,
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true,
"emitDeclarationOnly": true,
"stripInternal": true,
"allowJs": true,
"checkJs": false,
"outDir": "types/generated",
"rootDir": "src",
"rootDirs": ["../src"],
"outDir": "./generated",
"baseUrl": "."
},
"include": ["src/**/*.js", "src/**/*.ts"],
"exclude": ["node_modules", "dist", "tests", "example", "es6", "js-legacy", "js-legacy/**/*.js"]
"include" : ["../src/**/*.ts", "../src/**/*.js"]
}