Skip to content

Commit

Permalink
Merge pull request #708 from nature-heart-software/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
Wurielle authored Oct 12, 2024
2 parents 8e1379b + 691f1f4 commit 55f4b8b
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 11 deletions.
5 changes: 4 additions & 1 deletion apps/app/src/modules/vue-hitboxes/NvHitbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
useIntersectionObserver,
useMutationObserver,
useResizeObserver,
useEventListener,
} from '@vueuse/core'
import { useHitboxesStore } from '@/modules/vue-hitboxes/hitboxes.store'
Expand Down Expand Up @@ -52,10 +53,12 @@ const updateHitbox = throttle(
useIntersectionObserver(componentRef, updateHitbox)
useMutationObserver(componentRef, updateHitbox, { attributes: true })
useResizeObserver(componentRef, updateHitbox)
useEventListener('resize', updateHitbox)
useEventListener('focus', updateHitbox)
onBeforeUnmount(() => {
hitboxesStore.removeHitbox(hitboxes.value.id)
})
onMounted(() => {
updateHitbox()
})
Expand Down
4 changes: 4 additions & 0 deletions apps/app/src/modules/vue-hitboxes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ const onElementChange = (element: Element, callback: () => any) => {
resizeObserver.observe(element)
intersectionObserver.observe(element)
mutationObserver.observe(element, { attributes: true })
window.addEventListener('resize', callback)
window.addEventListener('focus', callback)
return () => {
resizeObserver.unobserve(element)
intersectionObserver.unobserve(element)
mutationObserver.disconnect()
window.removeEventListener('resize', callback)
window.removeEventListener('focus', callback)
}
}
export const watchHitbox = (selector: string) => {
Expand Down
18 changes: 12 additions & 6 deletions apps/app/src/utils/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ import CryptoJS from 'crypto-js'
export const encrypt = (valueToEncrypt: string) =>
CryptoJS.AES.encrypt(
valueToEncrypt,
import.meta.env.VITE_ENCRYPTION_KEY as string,
import.meta.env.VITE_APP_ENCRYPTION_KEY as string,
).toString()

export const decrypt = (valueToDecrypt: string) => {
const bytes = CryptoJS.AES.decrypt(
valueToDecrypt,
import.meta.env.VITE_ENCRYPTION_KEY || '',
)
return bytes.toString(CryptoJS.enc.Utf8)
let result = ''
try {
const bytes = CryptoJS.AES.decrypt(
valueToDecrypt,
import.meta.env.VITE_APP_ENCRYPTION_KEY || '',
)
bytes.toString(CryptoJS.enc.Utf8)
} catch (e) {
console.warn('Could not decrypt value.')
}
return result
}

export const useEncryption = () => ({
Expand Down
69 changes: 69 additions & 0 deletions examples/custom-engine-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Custom Engine Api

## List Voices

### Method: `POST`

```
http://localhost:3000/list-voices
```

### Body: `application/json`

```json
{
"credentials": {
"apiKey": ""
}
}
```

### Response: `application/json`

```json
[
{
"id": "Microsoft Hazel Desktop",
"name": "Microsoft Hazel Desktop",
"category": "Say",
"languageCode": "en-US"
},
{
"id": "Microsoft Zira Desktop",
"name": "Microsoft Zira Desktop",
"category": "Say",
"languageCode": "en-US"
}
]
```

⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃ ⁃

## Synthesize Speech

### Method: `POST`

```
http://localhost:3000/synthesize-speech
```

### Body: `application/json`

```json
{
"credentials": {
"apiKey": ""
},
"payload": {
"text": "Hello world, programmed to work and not to feel.",
"voice": {
"id": "Microsoft Hazel Desktop",
"name": "Microsoft Hazel Desktop",
"category": "Say",
"languageCode": "en-US"
}
}
}
```

### Response: `audio/mp3`
19 changes: 19 additions & 0 deletions examples/custom-engine-api/bruno/List Voices.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: List Voices
type: http
seq: 2
}

post {
url: http://localhost:3000/list-voices
body: json
auth: none
}

body:json {
{
"credentials": {
"apiKey": ""
}
}
}
28 changes: 28 additions & 0 deletions examples/custom-engine-api/bruno/Synthesize Speech.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
meta {
name: Synthesize Speech
type: http
seq: 3
}

post {
url: http://localhost:3000/synthesize-speech
body: json
auth: none
}

body:json {
{
"credentials": {
"apiKey": ""
},
"payload": {
"text": "Hello world, programmed to work and not to feel.",
"voice": {
"id": "Microsoft Hazel Desktop",
"name": "Microsoft Hazel Desktop",
"category": "Say",
"languageCode": "en-US"
}
}
}
}
6 changes: 6 additions & 0 deletions examples/custom-engine-api/bruno/bruno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1",
"name": "Custom Engine Api",
"type": "collection",
"ignore": ["node_modules", ".git"]
}
5 changes: 1 addition & 4 deletions examples/custom-engine-api/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const express = require('express')
const app = express()
const port = 3000
const pkg = require('./package.json')
const say = require('say')
const cors = require('cors')
Expand All @@ -25,7 +24,6 @@ app.post('/list-voices', async (req, res) => {
},
},
} = req
console.log(req.body)
const voices = await new Promise((resolve, reject) => {
say.getInstalledVoices((err, voices) => {
if (err) return reject(err)
Expand Down Expand Up @@ -63,7 +61,6 @@ app.post('/synthesize-speech', async (req, res) => {
},
},
} = req
console.log(req.body)
const outputFile = path.join(__dirname, 'example.mp3')
fs.mkdirSync(path.parse(outputFile).dir, { recursive: true })
fs.writeFileSync(outputFile, '')
Expand All @@ -89,7 +86,7 @@ app.post('/synthesize-speech', async (req, res) => {
}
})

app.listen(port, () => {
app.listen(ENDPOINT_PORT, () => {
console.log(
`[${pkg.name}] API endpoint: ${ENDPOINT_BASE_URL}${
ENDPOINT_PORT ? `:${ENDPOINT_PORT}` : ''
Expand Down
2 changes: 2 additions & 0 deletions examples/custom-engine-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"start": "nodemon index.js"
},
"dependencies": {
"body-parser": "^1.20.0",
"cors": "^2.8.5",
"express": "^4.20.0",
"nodemon": "^2.0.20",
"say": "^0.16.0"
Expand Down
63 changes: 63 additions & 0 deletions examples/custom-engine-api/postman/postman.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"info": {
"name": "Custom Engine Api",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "List Voices",
"event": [],
"request": {
"method": "POST",
"header": [],
"auth": null,
"description": "",
"url": {
"raw": "http://localhost:3000/list-voices",
"protocol": "http",
"host": ["localhost:3000"],
"path": ["list-voices"],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"raw": "{\n \"credentials\": {\n \"apiKey\": \"\"\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
}
}
},
{
"name": "Synthesize Speech",
"event": [],
"request": {
"method": "POST",
"header": [],
"auth": null,
"description": "",
"url": {
"raw": "http://localhost:3000/synthesize-speech",
"protocol": "http",
"host": ["localhost:3000"],
"path": ["synthesize-speech"],
"query": [],
"variable": []
},
"body": {
"mode": "raw",
"raw": "{\n \"credentials\": {\n \"apiKey\": \"\"\n },\n \"payload\": {\n \"text\": \"Hello world, programmed to work and not to feel.\",\n \"voice\": {\n \"id\": \"Microsoft Hazel Desktop\",\n \"name\": \"Microsoft Hazel Desktop\",\n \"category\": \"Say\",\n \"languageCode\": \"en-US\"\n }\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
}
}
}
],
"variable": []
}

0 comments on commit 55f4b8b

Please sign in to comment.