Skip to content

Commit aa0a23c

Browse files
committed
chore: include TypeScript declaration file
1 parent 1cdcc74 commit aa0a23c

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

.github/workflows/publish.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,19 @@ jobs:
3636
TAG_VERSION=${TAG_VERSION#v}
3737
npm version $TAG_VERSION --no-git-tag-version --allow-same-version
3838
39+
- name: Check if version already published
40+
id: check
41+
run: |
42+
PACKAGE_NAME=$(node -p "require('./package.json').name")
43+
VERSION=$(node -p "require('./package.json').version")
44+
if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
45+
echo "Version $VERSION already published, skipping"
46+
echo "skip=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "Version $VERSION not published yet"
49+
echo "skip=false" >> $GITHUB_OUTPUT
50+
fi
51+
3952
- name: Publish to npm
53+
if: steps.check.outputs.skip != 'true'
4054
run: npm publish --provenance --access public

esbuild.config.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const esbuild = require('esbuild');
2+
const fs = require('fs');
3+
const path = require('path');
24

35
// Build configurations for different module formats
46
const builds = [
@@ -47,13 +49,73 @@ const builds = [
4749
},
4850
];
4951

52+
// TypeScript declaration content
53+
const typeDeclaration = `// Type definitions for @matdata/yasgui-graph-plugin
54+
// Project: https://github.com/Matdata-eu/yasgui-graph-plugin
55+
56+
declare module '@matdata/yasgui-graph-plugin' {
57+
import type { default as Yasr } from '@zazuko/yasgui/build/ts/yasr';
58+
59+
/**
60+
* YASGUI plugin for visualizing SPARQL CONSTRUCT and DESCRIBE query results as interactive graphs
61+
*/
62+
export default class GraphPlugin {
63+
/**
64+
* Creates a new GraphPlugin instance
65+
* @param yasr - The YASR instance
66+
*/
67+
constructor(yasr: typeof Yasr);
68+
69+
/**
70+
* Plugin priority (higher = shown first in tabs)
71+
*/
72+
static get priority(): number;
73+
74+
/**
75+
* Plugin label for tab display
76+
*/
77+
static get label(): string;
78+
79+
/**
80+
* Check if plugin can handle the current results
81+
* @returns True if results are from CONSTRUCT or DESCRIBE query
82+
*/
83+
canHandleResults(): boolean;
84+
85+
/**
86+
* Render the graph visualization
87+
*/
88+
draw(): void;
89+
90+
/**
91+
* Download the current visualization as PNG
92+
*/
93+
download(): void;
94+
95+
/**
96+
* Get vis-network configuration options
97+
* @returns Network options for vis-network
98+
*/
99+
getNetworkOptions(): any;
100+
}
101+
}
102+
`;
103+
50104
// Build all formats
51105
Promise.all(builds.map(config => esbuild.build(config)))
52106
.then(() => {
107+
// Create TypeScript declaration file
108+
const distDir = path.join(__dirname, 'dist');
109+
if (!fs.existsSync(distDir)) {
110+
fs.mkdirSync(distDir, { recursive: true });
111+
}
112+
fs.writeFileSync(path.join(distDir, 'index.d.ts'), typeDeclaration);
113+
53114
console.log('✅ Build complete:');
54115
console.log(' - dist/yasgui-graph-plugin.esm.js (ES Module for bundlers)');
55116
console.log(' - dist/yasgui-graph-plugin.cjs.js (CommonJS for Node.js)');
56117
console.log(' - dist/yasgui-graph-plugin.min.js (IIFE for browsers/unpkg)');
118+
console.log(' - dist/index.d.ts (TypeScript declarations)');
57119
})
58120
.catch((err) => {
59121
console.error('❌ Build failed:', err);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "dist/yasgui-graph-plugin.cjs.js",
77
"module": "dist/yasgui-graph-plugin.esm.js",
88
"unpkg": "dist/yasgui-graph-plugin.min.js",
9+
"types": "dist/index.d.ts",
910
"files": [
1011
"dist",
1112
"README.md",

0 commit comments

Comments
 (0)