@luna-editor/engine 0.3.2 → 0.4.1
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/dist/Player.js +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/plugin/PluginManager.d.ts +2 -2
- package/dist/plugin/PluginManager.js +13 -6
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
package/dist/Player.js
CHANGED
|
@@ -342,7 +342,7 @@ export const Player = ({ scenario: scenarioProp, settings, plugins = [], sounds
|
|
|
342
342
|
for (const plugin of newPlugins) {
|
|
343
343
|
if (isCancelled)
|
|
344
344
|
return;
|
|
345
|
-
yield pluginManager.loadPlugin(plugin.packageName, plugin.bundleUrl, plugin.config, plugin.assets);
|
|
345
|
+
yield pluginManager.loadPlugin(plugin.packageName, plugin.bundleUrl, plugin.config, plugin.assets, plugin.plugin);
|
|
346
346
|
loadedPluginNamesRef.current.add(plugin.packageName);
|
|
347
347
|
}
|
|
348
348
|
if (isCancelled)
|
|
@@ -359,6 +359,9 @@ export const Player = ({ scenario: scenarioProp, settings, plugins = [], sounds
|
|
|
359
359
|
loadPlugins();
|
|
360
360
|
return () => {
|
|
361
361
|
isCancelled = true;
|
|
362
|
+
// Strict Mode再マウント時にPluginManagerインスタンスが変わる場合に備えて
|
|
363
|
+
// ロード済みリストをクリアし、新しいインスタンスで再ロードされるようにする
|
|
364
|
+
loadedPluginNamesRef.current.clear();
|
|
362
365
|
};
|
|
363
366
|
}, [plugins, sounds]);
|
|
364
367
|
// 初回レンダリング完了フラグ
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { getFontFamilyStyle, getUIFontFamilyStyle, } from "./hooks/useFontLoader
|
|
|
9
9
|
export { setGlobalUIAPI, usePluginAPI, useUIVisibility, } from "./hooks/usePluginAPI";
|
|
10
10
|
export { useScreenScale, useScreenSize, useToPixel, } from "./hooks/useScreenSize";
|
|
11
11
|
export { Player } from "./Player";
|
|
12
|
-
export type { BacklogData, BlockChangeContext, DataAPI, DataContext, FontsData, PlayerSettingsData, ScenarioPlaybackData, TransitionSource, } from "./sdk";
|
|
13
|
-
export { ComponentType, renderTextWithLineBreaks } from "./sdk";
|
|
12
|
+
export type { BacklogData, BlockChangeContext, DataAPI, DataContext, FontsData, LunaPlugin, PlayerSettingsData, PluginAPI, ScenarioPlaybackData, TransitionSource, } from "./sdk";
|
|
13
|
+
export { ComponentType, definePlugin, renderTextWithLineBreaks } from "./sdk";
|
|
14
14
|
export type { ActionNode, BacklogEntry, Character, DisplayedCharacter, EntityState, FontType, PlayerProps, PlayerSettings, PlayerState, PluginConfig, PublishedScenario, ScenarioBlock, ScenarioBlockAttributeValue, ScenarioBlockCharacter, ScenarioBlockEntityAttributeValue, ScenarioBlockType, WorkFont, WorkSound, } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -9,4 +9,4 @@ export { getFontFamilyStyle, getUIFontFamilyStyle, } from "./hooks/useFontLoader
|
|
|
9
9
|
export { setGlobalUIAPI, usePluginAPI, useUIVisibility, } from "./hooks/usePluginAPI";
|
|
10
10
|
export { useScreenScale, useScreenSize, useToPixel, } from "./hooks/useScreenSize";
|
|
11
11
|
export { Player } from "./Player";
|
|
12
|
-
export { ComponentType, renderTextWithLineBreaks } from "./sdk";
|
|
12
|
+
export { ComponentType, definePlugin, renderTextWithLineBreaks } from "./sdk";
|
|
@@ -62,10 +62,10 @@ export declare class PluginManager {
|
|
|
62
62
|
* 既に初期化済みの場合はスキップ
|
|
63
63
|
*/
|
|
64
64
|
private initializeReactRuntime;
|
|
65
|
-
loadPlugin(packageName: string, bundleUrl: string, config?: unknown, assets?: {
|
|
65
|
+
loadPlugin(packageName: string, bundleUrl: string | undefined, config?: unknown, assets?: {
|
|
66
66
|
filename: string;
|
|
67
67
|
url: string;
|
|
68
|
-
}[]): Promise<void>;
|
|
68
|
+
}[], plugin?: LunaPlugin): Promise<void>;
|
|
69
69
|
private doLoadPlugin;
|
|
70
70
|
private loadPluginScript;
|
|
71
71
|
private createPluginAPI;
|
|
@@ -112,7 +112,7 @@ export class PluginManager {
|
|
|
112
112
|
getFontFamilyStyle,
|
|
113
113
|
getUIFontFamilyStyle });
|
|
114
114
|
}
|
|
115
|
-
loadPlugin(packageName, bundleUrl, config, assets) {
|
|
115
|
+
loadPlugin(packageName, bundleUrl, config, assets, plugin) {
|
|
116
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
117
|
// 開発環境ではキャッシュをバイパスして常に最新コードをロード
|
|
118
118
|
const isDevelopment = this.isDevelopment();
|
|
@@ -174,7 +174,7 @@ export class PluginManager {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
// ロード処理をPromiseとして保存
|
|
177
|
-
const loadPromise = this.doLoadPlugin(packageName, bundleUrl, config, assets);
|
|
177
|
+
const loadPromise = this.doLoadPlugin(packageName, bundleUrl, config, assets, plugin);
|
|
178
178
|
globalLoadingPlugins.set(packageName, loadPromise);
|
|
179
179
|
try {
|
|
180
180
|
yield loadPromise;
|
|
@@ -185,11 +185,13 @@ export class PluginManager {
|
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
doLoadPlugin(packageName, bundleUrl, config, assets) {
|
|
188
|
+
doLoadPlugin(packageName, bundleUrl, config, assets, localPlugin) {
|
|
189
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
190
190
|
try {
|
|
191
|
-
//
|
|
192
|
-
const plugin =
|
|
191
|
+
// ローカルプラグインが渡された場合はスクリプトロードをスキップ
|
|
192
|
+
const plugin = localPlugin
|
|
193
|
+
? localPlugin
|
|
194
|
+
: yield this.loadPluginScript(bundleUrl, packageName);
|
|
193
195
|
const instance = {
|
|
194
196
|
actionNodes: new Map(),
|
|
195
197
|
hooks: {},
|
|
@@ -1015,9 +1017,14 @@ export class PluginManager {
|
|
|
1015
1017
|
getPluginAssetUrl(packageName, filename) {
|
|
1016
1018
|
const plugin = this.plugins.get(packageName);
|
|
1017
1019
|
if (!plugin) {
|
|
1020
|
+
console.warn(`[PluginManager] Plugin not found: "${packageName}", registered plugins:`, Array.from(this.plugins.keys()));
|
|
1018
1021
|
return "";
|
|
1019
1022
|
}
|
|
1020
|
-
|
|
1023
|
+
const url = plugin.instance.assetUrls.get(filename) || "";
|
|
1024
|
+
if (!url) {
|
|
1025
|
+
console.warn(`[PluginManager] Asset not found: "${filename}" in "${packageName}", registered assets:`, Array.from(plugin.instance.assetUrls.keys()));
|
|
1026
|
+
}
|
|
1027
|
+
return url;
|
|
1021
1028
|
}
|
|
1022
1029
|
/**
|
|
1023
1030
|
* UI コンポーネントの表示状態を設定
|
package/dist/types.d.ts
CHANGED
|
@@ -323,7 +323,10 @@ export interface PlayerSettings {
|
|
|
323
323
|
}
|
|
324
324
|
export interface PluginConfig {
|
|
325
325
|
packageName: string;
|
|
326
|
-
|
|
326
|
+
/** リモートプラグインのバンドルURL(plugin未指定時に必須) */
|
|
327
|
+
bundleUrl?: string;
|
|
328
|
+
/** ローカルプラグイン: LunaPluginオブジェクトを直接渡す(bundleUrl不要) */
|
|
329
|
+
plugin?: import("./sdk").LunaPlugin;
|
|
327
330
|
config?: unknown;
|
|
328
331
|
/** アセットのファイル名→絶対URLマッピング(外部アプリから利用時に必要) */
|
|
329
332
|
assets?: {
|