[Update/bugfix] Plugins: For development, fix hot reload issue that was restart every time updated the files.
This commit is contained in:
1
src-tauri/plugins/index.js
Normal file
1
src-tauri/plugins/index.js
Normal file
@@ -0,0 +1 @@
|
||||
// This is for preserving plugins folder. It will be detected and created 'plugins' folder to target/debug/ by tauri build. do not delete it.
|
||||
@@ -1,14 +0,0 @@
|
||||
import { initStore } from "./store/store";
|
||||
import { MainContainer } from "./main_container/MainContainer";
|
||||
|
||||
export const init = (plugin_context) => {
|
||||
initStore(plugin_context.createAtomWithHook);
|
||||
|
||||
const EntryComponents = () => {
|
||||
return <MainContainer />;
|
||||
};
|
||||
|
||||
plugin_context.registerComponent(EntryComponents);
|
||||
};
|
||||
|
||||
export default init;
|
||||
@@ -1,22 +0,0 @@
|
||||
import { useStore } from "../store/store";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export const MainContainer = () => {
|
||||
const { updateCountPluginState, currentCountPluginState } = useStore("useStore_CountPluginState");
|
||||
|
||||
const incrementCount = () => {
|
||||
updateCountPluginState((prev_value) => ({
|
||||
count: prev_value.data.count + 1,
|
||||
}));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>1 Zipped Dev Plugin Count: {currentCountPluginState?.data?.count}</p>
|
||||
<button onClick={incrementCount}>Increment Plugin Count</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"title": "VRCT Example Plugins 1",
|
||||
"plugin_id": "vrct_plugin_example_1",
|
||||
"asset_name": "vrct_plugin_example_1.zip",
|
||||
"location": "main_section",
|
||||
"plugin_version": "0.0.1",
|
||||
"min_supported_vrct_version": "3.0.4",
|
||||
"max_supported_vrct_version": "3.0.6"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
const store_hooks = {};
|
||||
|
||||
export const initStore = (createAtomWithHook) => {
|
||||
Object.assign(store_hooks, {
|
||||
useStore_CountPluginState: createAtomWithHook(
|
||||
{ count: 10 },
|
||||
"CountPluginState"
|
||||
).useHook,
|
||||
|
||||
useStore_AnotherState: createAtomWithHook(
|
||||
{ value: "initial" },
|
||||
"AnotherState"
|
||||
).useHook,
|
||||
});
|
||||
};
|
||||
|
||||
export const useStore = (hook_name) => {
|
||||
if (!store_hooks[hook_name]) {
|
||||
throw new Error(`Hook ${hook_name} is not initialized.`);
|
||||
}
|
||||
return store_hooks[hook_name]();
|
||||
};
|
||||
Reference in New Issue
Block a user