-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improvements for contextless * linter * CloseActivity page * fix import * tabs -> spaces * nvm
- Loading branch information
1 parent
107c444
commit f5012e0
Showing
13 changed files
with
122 additions
and
21 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 |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"**/dist", | ||
"**/build", | ||
"**/coverage", | ||
"**/lib" | ||
"**/lib", | ||
"**/.wrangler" | ||
] | ||
}, | ||
"organizeImports": { | ||
|
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 |
---|---|---|
|
@@ -24,3 +24,5 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.idea |
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
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
18 changes: 18 additions & 0 deletions
18
sdk-playground/packages/client/src/pages/CloseActivity.tsx
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,18 @@ | ||
import React from 'react'; | ||
|
||
import discordSdk from '../discordSdk'; | ||
import { RPCCloseCodes } from '@discord/embedded-app-sdk'; | ||
|
||
export default function CloseActivity() { | ||
React.useEffect(() => { | ||
discordSdk.close(RPCCloseCodes.CLOSE_NORMAL, 'Activity closed'); | ||
}, []); | ||
|
||
return ( | ||
<div style={{padding: 32}}> | ||
<div> | ||
<h1>Close the Activity</h1> | ||
</div> | ||
</div> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
sdk-playground/packages/client/src/pages/GetActivityInstance.tsx
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,31 @@ | ||
import React from 'react'; | ||
import discordSdk from '../discordSdk'; | ||
import ReactJsonView from '../components/ReactJsonView'; | ||
import {authStore} from '../stores/authStore'; | ||
|
||
export default function GetActivityInstance() { | ||
const [instance, setInstance] = React.useState<any | null>(null); | ||
const auth = authStore(); | ||
|
||
React.useEffect(() => { | ||
async function update() { | ||
if (!auth) { | ||
return; | ||
} | ||
const instanceResponse = await fetch(`/api/activity-instance/${discordSdk.instanceId}`); | ||
setInstance(await instanceResponse.json()); | ||
} | ||
update(); | ||
}, [auth]); | ||
|
||
return ( | ||
<div style={{padding: 32}}> | ||
<div> | ||
<h1>Current Validated Instance</h1> | ||
<br /> | ||
<br /> | ||
{instance ? <ReactJsonView src={instance} /> : null} | ||
</div> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,23 +1,26 @@ | ||
import react from '@vitejs/plugin-react'; | ||
import { defineConfig } from 'vite'; | ||
import { defineConfig, loadEnv } from 'vite'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
envDir: '../../', | ||
server: { | ||
port: 3000, | ||
proxy: { | ||
'/api': { | ||
target: 'http://localhost:8787', | ||
changeOrigin: true, | ||
secure: false, | ||
ws: true, | ||
// rewrite: (path) => path.replace(/^\/api/, ""), | ||
export default defineConfig(({ mode }) => { | ||
const env = loadEnv(mode, '../../', ''); | ||
return { | ||
plugins: [react()], | ||
envDir: '../../', | ||
server: { | ||
port: Number.parseInt(env.WEBAPP_SERVE_PORT), | ||
proxy: { | ||
'/api': { | ||
target: 'http://localhost:8787', | ||
changeOrigin: true, | ||
secure: false, | ||
ws: true, | ||
// rewrite: (path) => path.replace(/^\/api/, ""), | ||
}, | ||
}, | ||
hmr: { | ||
clientPort: 443, | ||
}, | ||
}, | ||
hmr: { | ||
clientPort: 443, | ||
}, | ||
}, | ||
}; | ||
}); |
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
21 changes: 21 additions & 0 deletions
21
sdk-playground/packages/server/src/handlers/getActivityInstanceHandler.ts
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 @@ | ||
import type { Env, IGetOAuthToken } from '../types'; | ||
import { readRequestBody, requestHeaders } from '../utils'; | ||
|
||
export default async function getActivityInstanceHandler( | ||
path: string[], | ||
request: Request, | ||
env: Env, | ||
) { | ||
try { | ||
const instanceId = path[1]; | ||
return await fetch( | ||
`${env.VITE_DISCORD_API_BASE}/applications/${env.VITE_CLIENT_ID}/activity-instances/${instanceId}`, | ||
{ | ||
headers: requestHeaders(env), | ||
}, | ||
); | ||
} catch (ex) { | ||
console.error(ex); | ||
return new Response(`Internal Error: ${ex}`, { status: 500 }); | ||
} | ||
} |