[Update] Plugins: Send all logics to the plugins when it's registered.
This commit is contained in:
@@ -16,7 +16,9 @@ import JSZip from "jszip";
|
||||
|
||||
import { useFetch } from "@logics_common";
|
||||
import { useSoftwareVersion } from "@logics_configs";
|
||||
import * as logic_configs from "@logics_configs";
|
||||
import * as logics_configs from "@logics_configs";
|
||||
import * as logics_main from "@logics_main";
|
||||
import * as logics_common from "@logics_common";
|
||||
|
||||
|
||||
// PLUGIN_LIST_URL は中央リポジトリにある、各プラグインの plugin_info.json への URL の配列を保持する JSON の URL
|
||||
@@ -51,7 +53,7 @@ export const usePlugins = () => {
|
||||
});
|
||||
},
|
||||
createAtomWithHook: (...args) => createAtomWithHook(...args),
|
||||
logic_configs: logic_configs,
|
||||
logics: { ...logics_common, ...logics_configs, ...logics_main }
|
||||
};
|
||||
return plugin_context;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,11 @@ import { SubtitlesController } from "./subtitle_system_container/_controllers/Su
|
||||
|
||||
export const init = (plugin_context) => {
|
||||
initStore(plugin_context.createAtomWithHook);
|
||||
const { logic_configs } = plugin_context;
|
||||
|
||||
loadPluginCSS("./main.css");
|
||||
const { logics } = plugin_context;
|
||||
|
||||
const EntryComponents = () => {
|
||||
return (
|
||||
<StoreContext.Provider value={logic_configs}>
|
||||
<StoreContext.Provider value={logics}>
|
||||
<SubtitlesController />
|
||||
|
||||
<SubtitleSystemContainer />
|
||||
@@ -22,16 +20,3 @@ export const init = (plugin_context) => {
|
||||
};
|
||||
|
||||
export default init;
|
||||
|
||||
|
||||
// CSS を動的に読み込む関数
|
||||
const loadPluginCSS = (cssUrl) => {
|
||||
if (typeof document === "undefined") return;
|
||||
// すでに読み込まれているかチェック
|
||||
if (document.getElementById("plugin-main-css")) return;
|
||||
const link = document.createElement("link");
|
||||
link.rel = "stylesheet";
|
||||
link.href = cssUrl;
|
||||
link.id = "plugin-main-css";
|
||||
document.head.appendChild(link);
|
||||
};
|
||||
@@ -2,16 +2,6 @@ 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,
|
||||
|
||||
useStore_IsSubtitlePlaying: createAtomWithHook(false, "IsSubtitlePlaying", { is_state_ok: true }).useHook,
|
||||
useStore_SubtitlePlaybackMode: createAtomWithHook("relative", "SubtitlePlaybackMode", { is_state_ok: true }).useHook,
|
||||
useStore_SubtitleAbsoluteTargetTime: createAtomWithHook({
|
||||
|
||||
@@ -4,8 +4,8 @@ import { useSubtitles } from "../_logics/useSubtitles";
|
||||
import { secToDayTime } from "../_subtitles_utils"
|
||||
import { useEffect } from "react";
|
||||
export const SubtitlesController = () => {
|
||||
const logic_configs = useStoreContext();
|
||||
const { sendTextToOverlay } = logic_configs.useSendTextToOverlay();
|
||||
const { useSendTextToOverlay } = useStoreContext();
|
||||
const { sendTextToOverlay } = useSendTextToOverlay();
|
||||
|
||||
const {
|
||||
currentIsSubtitlePlaying,
|
||||
|
||||
@@ -1,23 +1,8 @@
|
||||
import { useStore, useStoreContext } from "../../store/store.js";
|
||||
|
||||
// import { useSendTextToOverlay } from "@logics_configs";
|
||||
// import {
|
||||
// useStore_SubtitleFileName,
|
||||
// useStore_IsSubtitlePlaying,
|
||||
// useStore_SubtitlePlaybackMode,
|
||||
// useStore_SubtitleAbsoluteTargetTime,
|
||||
// useStore_IsCuesScheduled,
|
||||
// useStore_CountdownAdjustment,
|
||||
// useStore_EffectiveCountdown,
|
||||
// useStore_SubtitleCues,
|
||||
|
||||
// useStore_SubtitleTimers,
|
||||
// useStore_SubtitleCountdownTimerId,
|
||||
// } from "../../store/store.js";
|
||||
|
||||
export const useSubtitles = () => {
|
||||
const logic_configs = useStoreContext();
|
||||
const { sendTextToOverlay } = logic_configs.useSendTextToOverlay();
|
||||
const { useSendTextToOverlay } = useStoreContext();
|
||||
const { sendTextToOverlay } = useSendTextToOverlay();
|
||||
|
||||
const { currentSubtitleFileName, updateSubtitleFileName } = useStore("useStore_SubtitleFileName");
|
||||
const { currentIsSubtitlePlaying, updateIsSubtitlePlaying } = useStore("useStore_IsSubtitlePlaying");
|
||||
|
||||
Reference in New Issue
Block a user