@rozenite/vite-plugin 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/bundle-dts.ts +125 -0
- package/src/client-plugin.ts +392 -0
- package/src/dev-config-module.ts +29 -0
- package/src/dev-host/App.tsx +567 -0
- package/src/dev-host/components/DispatchForm.tsx +169 -0
- package/src/dev-host/components/FlowList.tsx +142 -0
- package/src/dev-host/components/MessageDetailsPane.tsx +109 -0
- package/src/dev-host/components/MessageLogPane.tsx +84 -0
- package/src/dev-host/components/MessagePayloadDetail.tsx +32 -0
- package/src/dev-host/components/PanelTabs.tsx +22 -0
- package/src/dev-host/components/ResizeHandle.tsx +33 -0
- package/src/dev-host/components/icons.tsx +79 -0
- package/src/dev-host/components/ui/Button.tsx +91 -0
- package/src/dev-host/components/ui/DropdownMenu.tsx +84 -0
- package/src/dev-host/components/ui/IconButton.tsx +41 -0
- package/src/dev-host/components/ui/Input.tsx +73 -0
- package/src/dev-host/components/ui/ScrollArea.tsx +20 -0
- package/src/dev-host/components/ui/Tabs.tsx +166 -0
- package/src/dev-host/components/ui/Textarea.tsx +79 -0
- package/src/dev-host/components/ui/ToggleGroup.tsx +120 -0
- package/src/dev-host/config.ts +107 -0
- package/src/dev-host/constants.ts +31 -0
- package/src/dev-host/flow-runtime.ts +297 -0
- package/src/dev-host/index.html +12 -0
- package/src/dev-host/main.tsx +31 -0
- package/src/dev-host/server.ts +55 -0
- package/src/dev-host/styles.css +969 -0
- package/src/dev-host/types.ts +61 -0
- package/src/dev-host/utils.ts +96 -0
- package/src/dev-host/vite.config.mts +20 -0
- package/src/index.ts +114 -0
- package/src/load-config.ts +117 -0
- package/src/package-json.ts +16 -0
- package/src/react-native-plugin.ts +49 -0
- package/src/require-plugin.ts +221 -0
- package/src/sdk-plugin.ts +44 -0
- package/src/server-plugin.ts +36 -0
- package/src/utils.ts +31 -0
- package/src/virtual-modules.d.ts +7 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const rozeniteSdkPlugin = (): Plugin => {
|
|
5
|
+
return {
|
|
6
|
+
name: 'rozenite-sdk-plugin',
|
|
7
|
+
config(config) {
|
|
8
|
+
const projectRoot = config.root ?? process.cwd();
|
|
9
|
+
|
|
10
|
+
config.build ??= {};
|
|
11
|
+
config.build.lib = {
|
|
12
|
+
entry: path.resolve(projectRoot, 'sdk.ts'),
|
|
13
|
+
formats: ['es' as const, 'cjs' as const],
|
|
14
|
+
fileName: (format) => `sdk/index.${format === 'es' ? 'js' : 'cjs'}`,
|
|
15
|
+
};
|
|
16
|
+
config.build.rollupOptions ??= {};
|
|
17
|
+
config.build.rollupOptions.external = (id) => {
|
|
18
|
+
if (id.startsWith('node:')) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return !id.startsWith('.') && !path.isAbsolute(id);
|
|
23
|
+
};
|
|
24
|
+
config.build.rollupOptions.output = [
|
|
25
|
+
{
|
|
26
|
+
format: 'es',
|
|
27
|
+
exports: 'named',
|
|
28
|
+
interop: 'auto',
|
|
29
|
+
entryFileNames: 'sdk/index.js',
|
|
30
|
+
chunkFileNames: 'sdk/chunks/[name].js',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
format: 'cjs',
|
|
34
|
+
exports: 'named',
|
|
35
|
+
interop: 'auto',
|
|
36
|
+
entryFileNames: 'sdk/index.cjs',
|
|
37
|
+
chunkFileNames: 'sdk/chunks/[name].cjs',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
delete config.build.rollupOptions.input;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
export const rozeniteServerPlugin = (): Plugin => {
|
|
6
|
+
return {
|
|
7
|
+
name: 'rozenite-server-plugin',
|
|
8
|
+
|
|
9
|
+
config(config) {
|
|
10
|
+
const projectRoot = config.root ?? process.cwd();
|
|
11
|
+
|
|
12
|
+
config.build ??= {};
|
|
13
|
+
config.build.lib = {
|
|
14
|
+
entry: path.resolve(projectRoot, 'metro.ts'),
|
|
15
|
+
formats: ['es' as const, 'cjs' as const],
|
|
16
|
+
fileName: (format) => `metro/index.${format === 'es' ? 'js' : 'cjs'}`,
|
|
17
|
+
};
|
|
18
|
+
config.build.ssr = true;
|
|
19
|
+
config.build.rollupOptions ??= {};
|
|
20
|
+
config.build.rollupOptions.output = [
|
|
21
|
+
{
|
|
22
|
+
format: 'es',
|
|
23
|
+
entryFileNames: 'metro/index.js',
|
|
24
|
+
exports: 'named',
|
|
25
|
+
interop: 'auto',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
format: 'cjs',
|
|
29
|
+
entryFileNames: 'metro/index.cjs',
|
|
30
|
+
exports: 'named',
|
|
31
|
+
interop: 'auto',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const resolveFileWithExtensions = (
|
|
5
|
+
directory: string,
|
|
6
|
+
baseName: string
|
|
7
|
+
): string | null => {
|
|
8
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js'];
|
|
9
|
+
|
|
10
|
+
for (const ext of extensions) {
|
|
11
|
+
const filePath = path.join(directory, baseName + ext);
|
|
12
|
+
|
|
13
|
+
if (fs.existsSync(filePath)) {
|
|
14
|
+
return filePath;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const memo = <T>(fn: () => T): (() => T) => {
|
|
22
|
+
let result: T | null = null;
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
if (result === null) {
|
|
26
|
+
result = fn();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
};
|