-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4fd27cb
Showing
64 changed files
with
12,683 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: bao-io |
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,78 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Lint | ||
run: pnpm lint | ||
|
||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Check | ||
run: pnpm check | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node: [lts/*] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node ${{ matrix.node }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Build | ||
run: pnpm build | ||
|
||
- name: Test | ||
run: pnpm test |
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,29 @@ | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: lts/* | ||
|
||
- run: npx changelogithub | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
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,3 @@ | ||
node_modules | ||
dist | ||
.DS_Store |
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,43 @@ | ||
{ | ||
// Enable the ESlint flat config support | ||
"eslint.experimental.useFlatConfig": true, | ||
|
||
// Disable the default formatter, use eslint instead | ||
"prettier.enable": false, | ||
"editor.formatOnSave": false, | ||
|
||
// Auto fix | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.organizeImports": "never" | ||
}, | ||
|
||
// Silent the stylistic rules in you IDE, but still auto fix them | ||
"eslint.rules.customizations": [ | ||
{ "rule": "style/*", "severity": "off" }, | ||
{ "rule": "format/*", "severity": "off" }, | ||
{ "rule": "*-indent", "severity": "off" }, | ||
{ "rule": "*-spacing", "severity": "off" }, | ||
{ "rule": "*-spaces", "severity": "off" }, | ||
{ "rule": "*-order", "severity": "off" }, | ||
{ "rule": "*-dangle", "severity": "off" }, | ||
{ "rule": "*-newline", "severity": "off" }, | ||
{ "rule": "*quotes", "severity": "off" }, | ||
{ "rule": "*semi", "severity": "off" } | ||
], | ||
|
||
// Enable eslint for all supported languages | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact", | ||
"vue", | ||
"html", | ||
"markdown", | ||
"json", | ||
"jsonc", | ||
"yaml", | ||
"toml" | ||
] | ||
} |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2023 BaoBao (https://github.com/bao-io) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,110 @@ | ||
# MidJourney-SDK <a href="https://www.npmjs.com/package/midjourney-sdk"><img src="https://img.shields.io/npm/v/midjourney-sdk.svg?maxAge=3600" alt="npm version" /></a> | ||
|
||
MidJourney in Discord API for Node.js. | ||
|
||
## Demo | ||
|
||
[Live demo](https://midjourney-sdk-playground-next.vercel.app) | ||
|
||
![](assets/2671694615683.png) | ||
![](assets/241131694080315_.png) | ||
![](assets/[email protected]) | ||
![](assets/[email protected]) | ||
![](assets/2661694615634.png) | ||
|
||
## Support | ||
|
||
- Command | ||
- [x] `/imagine` | ||
- [x] `/info` | ||
- [x] `/settings` | ||
- [x] `/fast` | ||
- [x] `/relax` | ||
- Button Action | ||
- [x] `upscale` | ||
- [x] `variation` | ||
- [x] `reroll` | ||
- [x] `zoomout` | ||
- [x] `vary(Region)` | ||
- Remix Mode | ||
|
||
## Install | ||
|
||
```bash | ||
pnpm i midjourney-sdk | ||
``` | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { MidJourney } from 'midjourney-sdk' | ||
const ins = new MidJourney({ | ||
token: process.env.NEXT_PUBLIC_TOKEN, | ||
guild_id: process.env.NEXT_PUBLIC_GUILD_ID, | ||
channel_id: process.env.NEXT_PUBLIC_CHANNEL_ID, | ||
skipHeartbeat: true | ||
}) | ||
;(async () => { | ||
await ins.init() | ||
// trigger image job | ||
const msg1 = await ins.api.imagine('apple --q 5', ({ url, progress }) => { | ||
console(url, progress) | ||
}) | ||
// trigger button job | ||
const msg2 = await ins.api.action( | ||
'msgId', | ||
'customId', | ||
'msgFlags', | ||
({ url, progress }) => { | ||
console(url, progress) | ||
} | ||
) | ||
// trigger remix job | ||
const msg3 = await ins.api.remixSubmit( | ||
'modalMsgId', | ||
'customId', | ||
'components', | ||
({ url, progress }) => { | ||
console(url, progress) | ||
} | ||
) | ||
// trigger vary(region) job | ||
const msg4 = await ins.api.varyRegion( | ||
'customId', | ||
'prompt', | ||
'mask', | ||
({ url, progress }) => { | ||
console(url, progress) | ||
} | ||
) | ||
})() | ||
``` | ||
|
||
## Development | ||
|
||
- edit environment `.env` file | ||
|
||
``` | ||
# playground/.env | ||
NEXT_PUBLIC_TOKEN= | ||
NEXT_PUBLIC_GUILD_ID= | ||
NEXT_PUBLIC_CHANNEL_ID= | ||
# discord api proxy url | ||
NEXT_PUBLIC_API_BASE_URL= | ||
# discord websocket proxy url | ||
NEXT_PUBLIC_IMG_BASE_URL= | ||
# discord websocket proxy url | ||
NEXT_PUBLIC_WS_BASE_URL= | ||
``` | ||
|
||
- run `play` script | ||
|
||
```bash | ||
pnpm play | ||
``` | ||
|
||
- open `http://localhost:3000` | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) License © 2023-PRESENT [BaoBao](https://github.com/bao-io) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
import { antfu } from '@antfu/eslint-config' | ||
|
||
export default antfu({ | ||
rules: { | ||
'no-useless-call': 'off', | ||
'no-console': 'off', | ||
}, | ||
}) |
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,83 @@ | ||
{ | ||
"name": "midjourney-sdk", | ||
"type": "module", | ||
"version": "3.1.0", | ||
"packageManager": "[email protected]", | ||
"description": "MidJourney in Discord API for Node.js.", | ||
"author": "BaoBao <[email protected]>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/LaiBaoYuan/midjourney-sdk/#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/LaiBaoYuan/midjourney-sdk.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/LaiBaoYuan/midjourney-sdk/issues" | ||
}, | ||
"keywords": [ | ||
"midjourney", | ||
"midjourney-api", | ||
"midjourney-sdk", | ||
"custom-zoom", | ||
"vary-region", | ||
"zoom-out", | ||
"vary-strong", | ||
"vary-subtle" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=16.20.0" | ||
}, | ||
"scripts": { | ||
"dev": "tsup --watch", | ||
"build": "tsup", | ||
"test": "vitest", | ||
"lint": "eslint .", | ||
"check": "tsc --noEmit", | ||
"play": "pnpm -F playground dev", | ||
"prepublishOnly": "pnpm run build", | ||
"release": "bumpp && pnpm publish", | ||
"format": "prettier --write .", | ||
"prepare": "simple-git-hooks" | ||
}, | ||
"dependencies": { | ||
"chalk": "^5.3.0", | ||
"eventemitter3": "^5.0.1", | ||
"isomorphic-fetch": "^3.0.0", | ||
"isomorphic-ws": "^5.0.0", | ||
"snowyflake": "^2.0.0", | ||
"ws": "^8.16.0" | ||
}, | ||
"devDependencies": { | ||
"@antfu/eslint-config": "^2.4.6", | ||
"@bbao/prettier-config": "^0.0.2", | ||
"@types/isomorphic-fetch": "^0.0.39", | ||
"@types/node": "^20.10.5", | ||
"@types/ws": "^8.5.10", | ||
"bumpp": "^9.2.1", | ||
"lint-staged": "^15.2.0", | ||
"prettier": "^3.1.1", | ||
"simple-git-hooks": "^2.9.0", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.1.0" | ||
}, | ||
"simple-git-hooks": { | ||
"pre-commit": "pnpm lint-staged && pnpm check" | ||
}, | ||
"lint-staged": { | ||
"*": "eslint --fix" | ||
} | ||
} |
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,6 @@ | ||
NEXT_PUBLIC_TOKEN= | ||
NEXT_PUBLIC_GUILD_ID= | ||
NEXT_PUBLIC_CHANNEL_ID= | ||
NEXT_PUBLIC_API_BASE_URL= | ||
NEXT_PUBLIC_IMG_BASE_URL= | ||
NEXT_PUBLIC_WS_BASE_URL= |
Oops, something went wrong.