-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add vite-dts * Build types for ElectronAPI * prefix @comfyorg on package name * Add publish config * Regen lock * Add prepare types script * nit
- Loading branch information
Showing
5 changed files
with
677 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Read the main package.json | ||
const mainPackage = require('../package.json'); | ||
|
||
// Create the types-only package.json | ||
const typesPackage = { | ||
name: `${mainPackage.name}-types`, | ||
version: mainPackage.version, | ||
types: './index.d.ts', | ||
exports: { | ||
'.': { | ||
types: './index.d.ts' | ||
} | ||
}, | ||
files: [ | ||
'index.d.ts' | ||
], | ||
publishConfig: { | ||
access: 'public' | ||
}, | ||
repository: mainPackage.repository, | ||
homepage: mainPackage.homepage, | ||
description: `TypeScript definitions for ${mainPackage.name}`, | ||
author: mainPackage.author, | ||
license: mainPackage.license, | ||
}; | ||
|
||
// Ensure dist directory exists | ||
const distDir = path.join(__dirname, '../dist'); | ||
if (!fs.existsSync(distDir)) { | ||
fs.mkdirSync(distDir, { recursive: true }); | ||
} | ||
|
||
// Write the new package.json to the dist directory | ||
fs.writeFileSync( | ||
path.join(distDir, 'package.json'), | ||
JSON.stringify(typesPackage, null, 2) | ||
); | ||
|
||
// Create an empty yarn.lock file | ||
fs.writeFileSync(path.join(distDir, 'yarn.lock'), ''); | ||
|
||
console.log('Types package.json and yarn.lock have been prepared in the dist directory'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export * from './constants'; | ||
export * from './preload'; | ||
import { ElectronAPI } from './preload'; | ||
|
||
declare global { | ||
interface Window { | ||
electronAPI: ElectronAPI; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { defineConfig } from 'vite'; | ||
import dts from 'vite-plugin-dts'; | ||
import { resolve } from 'path'; | ||
|
||
export default defineConfig({ | ||
build: { | ||
lib: { | ||
entry: resolve(__dirname, 'src/main_types.ts'), | ||
name: 'comfyui-electron-api', | ||
fileName: 'index', | ||
formats: ['es'], | ||
}, | ||
rollupOptions: { | ||
external: ['electron'], | ||
}, | ||
}, | ||
plugins: [ | ||
dts({ | ||
rollupTypes: true, | ||
}), | ||
], | ||
}); |
Oops, something went wrong.