@luna-editor/engine 0.3.1 → 0.4.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/dist/Player.js +1 -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 +20 -7
- 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)
|
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();
|
|
@@ -120,8 +120,19 @@ export class PluginManager {
|
|
|
120
120
|
// 開発環境では強制リロード(キャッシュをクリア)
|
|
121
121
|
globalLoadedPlugins.delete(packageName);
|
|
122
122
|
this.plugins.delete(packageName);
|
|
123
|
-
//
|
|
124
|
-
globalLoadingPlugins.
|
|
123
|
+
// ロード中の場合はそのPromiseを待って完了させる(二重ロード防止)
|
|
124
|
+
const existingLoadPromise = globalLoadingPlugins.get(packageName);
|
|
125
|
+
if (existingLoadPromise) {
|
|
126
|
+
yield existingLoadPromise;
|
|
127
|
+
const loaded = globalLoadedPlugins.get(packageName);
|
|
128
|
+
if (loaded) {
|
|
129
|
+
this.plugins.set(packageName, Object.assign(Object.assign({}, loaded), { config: config !== null && config !== void 0 ? config : loaded.config }));
|
|
130
|
+
for (const [type, component] of loaded.instance.components) {
|
|
131
|
+
this.componentRegistry.set(type, component);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
125
136
|
}
|
|
126
137
|
else {
|
|
127
138
|
// 本番環境のみキャッシュを使用
|
|
@@ -163,7 +174,7 @@ export class PluginManager {
|
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
176
|
// ロード処理をPromiseとして保存
|
|
166
|
-
const loadPromise = this.doLoadPlugin(packageName, bundleUrl, config, assets);
|
|
177
|
+
const loadPromise = this.doLoadPlugin(packageName, bundleUrl, config, assets, plugin);
|
|
167
178
|
globalLoadingPlugins.set(packageName, loadPromise);
|
|
168
179
|
try {
|
|
169
180
|
yield loadPromise;
|
|
@@ -174,11 +185,13 @@ export class PluginManager {
|
|
|
174
185
|
}
|
|
175
186
|
});
|
|
176
187
|
}
|
|
177
|
-
doLoadPlugin(packageName, bundleUrl, config, assets) {
|
|
188
|
+
doLoadPlugin(packageName, bundleUrl, config, assets, localPlugin) {
|
|
178
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
179
190
|
try {
|
|
180
|
-
//
|
|
181
|
-
const plugin =
|
|
191
|
+
// ローカルプラグインが渡された場合はスクリプトロードをスキップ
|
|
192
|
+
const plugin = localPlugin
|
|
193
|
+
? localPlugin
|
|
194
|
+
: yield this.loadPluginScript(bundleUrl, packageName);
|
|
182
195
|
const instance = {
|
|
183
196
|
actionNodes: new Map(),
|
|
184
197
|
hooks: {},
|
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?: {
|