Skip to content

Commit 7718464

Browse files
committed
feat(framework): add webview-react package
1 parent 6c81c35 commit 7718464

File tree

7 files changed

+125
-0
lines changed

7 files changed

+125
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@aurora-mp/webview-react",
3+
"version": "0.0.1-alpha.4",
4+
"description": "React webview package of the aurora-mp TypeScript framework.",
5+
"keywords": [
6+
"aurora-mp",
7+
"webview",
8+
"framework",
9+
"multiplayer",
10+
"gta",
11+
"typescript",
12+
"react"
13+
],
14+
"license": "MIT",
15+
"author": "Aurora Team",
16+
"type": "module",
17+
"main": "dist/index.js",
18+
"types": "dist/index.d.ts",
19+
"files": [
20+
"dist"
21+
],
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/aurora-mp/framework.git",
25+
"directory": "packages/webview"
26+
},
27+
"publishConfig": {
28+
"access": "public",
29+
"registry": "https://registry.npmjs.org/"
30+
},
31+
"scripts": {
32+
"build": "tsup"
33+
},
34+
"devDependencies": {
35+
"@types/react": "^19.1.8",
36+
"tsup": "^8.5.0"
37+
},
38+
"dependencies": {
39+
"@aurora-mp/core": "workspace:*",
40+
"@aurora-mp/webview": "workspace:*",
41+
"react": "^18.2.0",
42+
"react-dom": "^18.2.0"
43+
}
44+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './use-aurora';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { aurora } from '@aurora-mp/webview';
2+
import React from 'react';
3+
4+
export const useAurora = () => {
5+
const wrap = <T extends (...args: any[]) => any>(fn: T) =>
6+
React.useCallback((...args: Parameters<T>) => fn(...args), []);
7+
8+
return {
9+
on: wrap(aurora.on),
10+
onServer: wrap(aurora.onServer),
11+
emit: wrap(aurora.emit),
12+
emitServer: wrap(aurora.emitServer),
13+
invokeClientRpc: wrap(aurora.invokeClientRpc),
14+
onClientRpc: wrap(aurora.onClientRpc),
15+
invokeServerRpc: wrap(aurora.invokeServerRpc),
16+
};
17+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './hooks';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"paths": {
6+
"@webview-react/*": ["src/*"]
7+
},
8+
"outDir": "dist",
9+
"rootDir": "src"
10+
},
11+
"include": ["src/**/*.ts", "package.json"],
12+
"exclude": ["node_modules", "dist"]
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineConfig } from 'tsup';
2+
import packageJson from './package.json' assert { type: 'json' };
3+
4+
export default defineConfig({
5+
entry: ['src/index.ts'],
6+
format: ['esm'],
7+
splitting: false,
8+
sourcemap: false,
9+
clean: true,
10+
bundle: true,
11+
minify: false,
12+
dts: true,
13+
experimentalDts: false,
14+
external: [...Object.keys(packageJson.dependencies || {})],
15+
noExternal: [...Object.keys(packageJson.devDependencies)],
16+
});

pnpm-lock.yaml

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)