Skip to content

Commit

Permalink
chore: nuxt 4 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Whipstickgostop committed Sep 25, 2024
1 parent 2046921 commit 897494a
Show file tree
Hide file tree
Showing 37 changed files with 7,454 additions and 5,391 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/docs/content/0.index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Streamerbot Client
description: Typescript client for interacting with the Streamer.bot WebSocket API
description: Official client for interacting with the Streamer.bot WebSocket API
navigation: false
hero:
links:
Expand Down
46 changes: 32 additions & 14 deletions apps/docs/content/1.get-started/0.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ title: Installation
description: Add @streamerbot/client to your project
---

### Browser

For usage in browser contexts, such as basic static HTML and JS projects.

Add the following `<script>` tag within the `<head>` of your HTML page.

::code-group
```html [unpkg]
<script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
```
::

The `StreamerbotClient` constructor will become available on the global `window` object.

::code-group
```html [example.html]
<!DOCTYPE html>
<html>
<head>
<title>Streamer.bot Client</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
</head>
<body>
<script type="text/javascript">
const client = new StreamerbotClient();
</script>
</body>
</html>
```
::

### NodeJS & TypeScript

Add `@streamerbot/client` with your favorite package manager:
Expand Down Expand Up @@ -33,20 +65,6 @@ Import Streamer.bot client in your `.js` or `.ts`:
```
::

### Browser / CDN

For usage in browser contexts.

Add the following `<script>` tag within the `<head>` of your HTML page.

The `StreamerbotClient` constructor will become available on the global `window` object.

::code-group
```html [unpkg]
<script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
```
::

### Module

You can also directly import the module from Skypack if you are using the `<script type="module">` syntax:
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/2.guide/1.events.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ Utilizing the `client.on()`{lang=ts} method will make your life easier by:
Subscribe to a specific event, with callback:
```ts
// Subscribe to Twitch ChatMessage events
await client.on('Twitch.ChatMessage', (data) => {
client.on('Twitch.ChatMessage', (data) => {
console.log('New Twitch Chat Message:', data);
});
```

You can subscribe to all events of a specific source with `"[sourceName].*"`
```ts
// Subscribe to all Twitch events
await client.on('Twitch.*', (data) => {
client.on('Twitch.*', (data) => {
console.log('Twitch Event Received:' data);
});
```

If you want to subscribe to **all** event sources & events from Streamer.bot, simply pass `"*"`
```ts
await client.on('*', (data) => {
client.on('*', (data) => {
console.log('Event Received:', data);
});
```
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/content/2.guide/2.custom-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can easily [subscribe](/guide/events) to your custom events using the `.on()

```ts [example.ts]
// Subscribe to all custom events from the connected Streamer.bot instance
await client.on('General.Custom', (data) => {
client.on('General.Custom', (data) => {
console.log('Custom Event:', data);
});
```
Expand All @@ -41,7 +41,7 @@ CPH.WebsocketBroadcastJson(json);
On the client side, we will handle these events with the following event handler:

```ts [example.ts]
await client.on('General.Custom', (payload) => {
client.on('General.Custom', (payload) => {
if (payload.data.event === 'mediaPlayer' && payload.data.action === 'pause') {
// handle media player pause events in here :)
}
Expand Down
24 changes: 6 additions & 18 deletions apps/docs/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export default defineNuxtConfig({
extends: ['@nuxt/ui-pro'],

Expand All @@ -7,7 +6,6 @@ export default defineNuxtConfig({
'@vueuse/nuxt',
'nuxt-og-image',
'nuxt-link-checker',
'nuxt-icon',
'@nuxt/content',
],

Expand Down Expand Up @@ -94,22 +92,6 @@ export default defineNuxtConfig({
},
},

hooks: {
// Related to https://github.com/nuxt/nuxt/pull/22558
// Adding all global components to the main entry
// To avoid lagging during page navigation on client-side
// Downside: bigger JS bundle
// With sync: 465KB, gzip: 204KB
// Without: 418KB, gzip: 184KB
'components:extend'(components) {
for (const comp of components) {
if (comp.global) {
comp.global = 'sync';
}
}
},
},

ogImage: {
runtimeCacheStorage: true,
defaults: {
Expand All @@ -126,4 +108,10 @@ export default defineNuxtConfig({
markdown: true,
},
},

future: {
compatibilityVersion: 4,
},

compatibilityDate: '2024-09-25',
});
3 changes: 1 addition & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"@nuxt/content": "^2.13.2",
"@nuxt/ui-pro": "^0.7.5",
"@streamerbot/vue": "workspace:^",
"nuxt-component-meta": "^0.6.6",
"nuxt-icon": "^0.6.10"
"nuxt-component-meta": "^0.6.6"
},
"devDependencies": {
"@iconify-json/carbon": "^1.2.1",
Expand Down
4 changes: 2 additions & 2 deletions examples/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<title>Twitch Chat Example | Streamer.bot Client</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
<script type="text/javascript" src="script.js"></script>
<body>
<div id="chat"></div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"engines": {
"node": ">=14.0.0"
},
"packageManager": "pnpm@8.14.1+sha1.d039b38e0b20ad012ed548e44267b8d4c88b447a"
"packageManager": "pnpm@9.11.0"
}
Loading

0 comments on commit 897494a

Please sign in to comment.