@luna-editor/engine 0.2.0 → 0.3.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.
Files changed (74) hide show
  1. package/dist/Player.d.ts +1 -1
  2. package/dist/Player.js +676 -95
  3. package/dist/api/conversationBranch.d.ts +4 -0
  4. package/dist/api/conversationBranch.js +83 -0
  5. package/dist/components/BackgroundLayer.d.ts +19 -0
  6. package/dist/components/BackgroundLayer.js +220 -0
  7. package/dist/components/ClickWaitIndicator.d.ts +10 -0
  8. package/dist/components/ClickWaitIndicator.js +31 -0
  9. package/dist/components/ConversationBranchBox.d.ts +2 -0
  10. package/dist/components/ConversationBranchBox.js +29 -0
  11. package/dist/components/DialogueBox.js +16 -1
  12. package/dist/components/FontSettingsPanel.d.ts +10 -0
  13. package/dist/components/FontSettingsPanel.js +30 -0
  14. package/dist/components/FullscreenTextBox.d.ts +6 -0
  15. package/dist/components/FullscreenTextBox.js +70 -0
  16. package/dist/components/GameScreen.d.ts +9 -2
  17. package/dist/components/GameScreen.js +396 -80
  18. package/dist/components/OverlayUI.d.ts +2 -3
  19. package/dist/components/OverlayUI.js +3 -14
  20. package/dist/components/PluginComponentProvider.d.ts +3 -3
  21. package/dist/components/PluginComponentProvider.js +22 -4
  22. package/dist/components/TimeWaitIndicator.d.ts +15 -0
  23. package/dist/components/TimeWaitIndicator.js +17 -0
  24. package/dist/contexts/AudioContext.d.ts +1 -0
  25. package/dist/contexts/AudioContext.js +1 -0
  26. package/dist/contexts/DataContext.d.ts +3 -1
  27. package/dist/contexts/DataContext.js +104 -17
  28. package/dist/contexts/PlaybackTextContext.d.ts +32 -0
  29. package/dist/contexts/PlaybackTextContext.js +29 -0
  30. package/dist/data-api-types.d.ts +251 -0
  31. package/dist/data-api-types.js +6 -0
  32. package/dist/emotion-effect-types.d.ts +86 -0
  33. package/dist/emotion-effect-types.js +6 -0
  34. package/dist/hooks/useBacklog.js +3 -1
  35. package/dist/hooks/useConversationBranch.d.ts +16 -0
  36. package/dist/hooks/useConversationBranch.js +125 -0
  37. package/dist/hooks/useFontLoader.d.ts +30 -0
  38. package/dist/hooks/useFontLoader.js +192 -0
  39. package/dist/hooks/useFullscreenText.d.ts +17 -0
  40. package/dist/hooks/useFullscreenText.js +120 -0
  41. package/dist/hooks/useImagePreloader.d.ts +5 -0
  42. package/dist/hooks/useImagePreloader.js +53 -0
  43. package/dist/hooks/usePlayerLogic.d.ts +10 -3
  44. package/dist/hooks/usePlayerLogic.js +115 -18
  45. package/dist/hooks/usePluginAPI.js +1 -1
  46. package/dist/hooks/usePluginEvents.d.ts +4 -1
  47. package/dist/hooks/usePluginEvents.js +16 -11
  48. package/dist/hooks/usePreloadImages.js +27 -7
  49. package/dist/hooks/useSoundPlayer.d.ts +15 -0
  50. package/dist/hooks/useSoundPlayer.js +209 -0
  51. package/dist/hooks/useTypewriter.d.ts +6 -2
  52. package/dist/hooks/useTypewriter.js +42 -6
  53. package/dist/hooks/useVoice.js +4 -1
  54. package/dist/index.d.ts +5 -3
  55. package/dist/index.js +3 -1
  56. package/dist/plugin/PluginManager.d.ts +86 -5
  57. package/dist/plugin/PluginManager.js +427 -94
  58. package/dist/sdk.d.ts +133 -162
  59. package/dist/sdk.js +39 -4
  60. package/dist/types.d.ts +300 -4
  61. package/dist/utils/branchBlockConverter.d.ts +2 -0
  62. package/dist/utils/branchBlockConverter.js +21 -0
  63. package/dist/utils/branchNavigator.d.ts +14 -0
  64. package/dist/utils/branchNavigator.js +55 -0
  65. package/dist/utils/facePositionCalculator.js +0 -1
  66. package/dist/utils/variableManager.d.ts +18 -0
  67. package/dist/utils/variableManager.js +159 -0
  68. package/package.json +6 -6
  69. package/dist/components/ConversationLogUI.d.ts +0 -2
  70. package/dist/components/ConversationLogUI.js +0 -115
  71. package/dist/hooks/useConversationLog.d.ts +0 -14
  72. package/dist/hooks/useConversationLog.js +0 -82
  73. package/dist/hooks/useUIVisibility.d.ts +0 -9
  74. package/dist/hooks/useUIVisibility.js +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luna-editor/engine",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Luna Editor scenario playback engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,11 +31,11 @@
31
31
  "lucide-react": "^0.503.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/react": "^19",
35
- "@types/react-dom": "^19",
36
- "typescript": "^5",
37
- "react": "^19.0.0",
38
- "react-dom": "^19.0.0"
34
+ "@types/react": "^19.2.9",
35
+ "@types/react-dom": "^19.2.3",
36
+ "react": "^19.2.3",
37
+ "react-dom": "^19.2.3",
38
+ "typescript": "^5"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -1,2 +0,0 @@
1
- import type React from "react";
2
- export declare const ConversationLogUI: React.FC;
@@ -1,115 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useCallback, useState } from "react";
3
- import { useDataAPI } from "../contexts/DataContext";
4
- export const ConversationLogUI = () => {
5
- const dataAPI = useDataAPI();
6
- const logs = dataAPI.get("conversationLog", "entries");
7
- const [isDialogOpen, setIsDialogOpen] = useState(false);
8
- const openDialog = useCallback((e) => {
9
- e.stopPropagation();
10
- e.preventDefault();
11
- setIsDialogOpen(true);
12
- }, []);
13
- const closeDialog = useCallback((e) => {
14
- if (e) {
15
- e.stopPropagation();
16
- e.preventDefault();
17
- }
18
- setIsDialogOpen(false);
19
- }, []);
20
- const handleDialogBackdropClick = useCallback((e) => {
21
- if (e.target === e.currentTarget) {
22
- closeDialog();
23
- }
24
- }, [closeDialog]);
25
- return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: openDialog, style: {
26
- position: "fixed",
27
- top: "20px",
28
- right: "20px",
29
- width: "50px",
30
- height: "50px",
31
- background: "rgba(74, 144, 226, 0.9)",
32
- border: "none",
33
- borderRadius: "25px",
34
- color: "white",
35
- fontSize: "20px",
36
- cursor: "pointer",
37
- zIndex: 1000,
38
- boxShadow: "0 2px 10px rgba(0,0,0,0.3)",
39
- transition: "all 0.3s ease",
40
- }, onMouseOver: (e) => {
41
- e.stopPropagation();
42
- e.currentTarget.style.background = "rgba(74, 144, 226, 1)";
43
- e.currentTarget.style.transform = "scale(1.1)";
44
- }, onMouseOut: (e) => {
45
- e.stopPropagation();
46
- e.currentTarget.style.background = "rgba(74, 144, 226, 0.9)";
47
- e.currentTarget.style.transform = "scale(1)";
48
- }, title: "\u4F1A\u8A71\u30ED\u30B0\u3092\u8868\u793A", children: "\uD83D\uDCDA" }), isDialogOpen && (_jsx("div", { style: {
49
- position: "fixed",
50
- top: 0,
51
- left: 0,
52
- right: 0,
53
- bottom: 0,
54
- backgroundColor: "rgba(0, 0, 0, 0.5)",
55
- display: "flex",
56
- justifyContent: "center",
57
- alignItems: "center",
58
- zIndex: 10000,
59
- }, onClick: handleDialogBackdropClick, children: _jsxs("div", { style: {
60
- width: "80vw",
61
- maxWidth: "800px",
62
- maxHeight: "80vh",
63
- background: "rgba(0, 0, 0, 0.9)",
64
- border: "1px solid #333",
65
- borderRadius: "8px",
66
- padding: "20px",
67
- color: "white",
68
- fontFamily: "sans-serif",
69
- boxShadow: "0 4px 20px rgba(0,0,0,0.5)",
70
- }, onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { style: {
71
- display: "flex",
72
- justifyContent: "space-between",
73
- alignItems: "center",
74
- marginBottom: "16px",
75
- borderBottom: "1px solid #333",
76
- paddingBottom: "12px",
77
- }, children: [_jsx("h3", { style: {
78
- margin: 0,
79
- fontSize: "1.2em",
80
- color: "#4A90E2",
81
- }, children: "\uD83D\uDCDA \u4F1A\u8A71\u30ED\u30B0" }), _jsx("button", { type: "button", onClick: closeDialog, style: {
82
- background: "#666",
83
- border: "none",
84
- color: "white",
85
- padding: "6px 12px",
86
- borderRadius: "4px",
87
- cursor: "pointer",
88
- }, children: "\u2715 \u9589\u3058\u308B" })] }), _jsx("div", { style: {
89
- maxHeight: "60vh",
90
- overflowY: "auto",
91
- marginBottom: "16px",
92
- scrollbarWidth: "thin",
93
- scrollbarColor: "#666 transparent",
94
- }, children: logs.length > 0 ? (logs.map((log) => (_jsxs("div", { style: {
95
- marginBottom: "12px",
96
- padding: "12px",
97
- background: "rgba(255,255,255,0.1)",
98
- borderRadius: "4px",
99
- borderLeft: "3px solid #4A90E2",
100
- }, children: [_jsx("div", { style: {
101
- marginBottom: "6px",
102
- fontSize: "1em",
103
- }, children: log.speakerName ? (_jsx("strong", { children: log.speakerName })) : (_jsx("em", { children: "\u30CA\u30EC\u30FC\u30B7\u30E7\u30F3" })) }), _jsx("div", { style: {
104
- fontSize: "1em",
105
- lineHeight: "1.5",
106
- }, children: log.content || "(内容なし)" })] }, log.id)))) : (_jsx("div", { style: {
107
- textAlign: "center",
108
- color: "#888",
109
- padding: "20px",
110
- }, children: "\u307E\u3060\u4F1A\u8A71\u30ED\u30B0\u304C\u3042\u308A\u307E\u305B\u3093" })) }), _jsxs("div", { style: {
111
- textAlign: "center",
112
- fontSize: "0.8em",
113
- color: "#888",
114
- }, children: [logs.length, "\u4EF6\u306E\u4F1A\u8A71\u3092\u8868\u793A\u4E2D"] })] }) }))] }));
115
- };
@@ -1,14 +0,0 @@
1
- import type { ConversationLogEntry, PublishedScenario, ScenarioBlock } from "../types";
2
- interface UseConversationLogOptions {
3
- scenario: PublishedScenario;
4
- currentBlockIndex: number;
5
- currentBlock: ScenarioBlock | null;
6
- }
7
- interface UseConversationLogReturn {
8
- logs: ConversationLogEntry[];
9
- addLogEntry: (entry: ConversationLogEntry) => void;
10
- clearLogs: () => void;
11
- buildInitialHistory: (upToIndex: number) => void;
12
- }
13
- export declare function useConversationLog({ scenario, currentBlockIndex, currentBlock, }: UseConversationLogOptions): UseConversationLogReturn;
14
- export {};
@@ -1,82 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from "react";
2
- export function useConversationLog({ scenario, currentBlockIndex, currentBlock, }) {
3
- const [logs, setLogs] = useState([]);
4
- const hasBuiltInitialHistory = useRef(false);
5
- const processedBlocks = useRef(new Set());
6
- // ログエントリを追加する関数
7
- const addLogEntry = useCallback((entry) => {
8
- setLogs((prevLogs) => {
9
- // 既存の同じブロックインデックスのエントリを削除(重複防止)
10
- const filteredLogs = prevLogs.filter((log) => log.blockIndex !== entry.blockIndex);
11
- // 新しいエントリを追加してソート
12
- const newLogs = [...filteredLogs, entry];
13
- return newLogs.sort((a, b) => a.blockIndex - b.blockIndex);
14
- });
15
- }, []);
16
- // ログをクリアする関数
17
- const clearLogs = useCallback(() => {
18
- setLogs([]);
19
- hasBuiltInitialHistory.current = false;
20
- processedBlocks.current.clear();
21
- }, []);
22
- // 初期履歴を構築する関数
23
- const buildInitialHistory = useCallback((upToIndex) => {
24
- const conversationBlocks = scenario.blocks
25
- .slice(0, upToIndex + 1)
26
- .map((block, index) => ({ block, realIndex: index }))
27
- .filter(({ block }) => block.blockType === "dialogue" || block.blockType === "narration");
28
- console.log(`Building conversation history up to index ${upToIndex}, found ${conversationBlocks.length} conversation blocks`);
29
- conversationBlocks.forEach(({ block, realIndex }) => {
30
- var _a, _b;
31
- if (!processedBlocks.current.has(realIndex)) {
32
- const logEntry = {
33
- id: `${block.id}_init`,
34
- timestamp: Date.now(),
35
- blockIndex: realIndex,
36
- blockType: block.blockType,
37
- content: block.content,
38
- speakerName: (_a = block.speaker) === null || _a === void 0 ? void 0 : _a.name,
39
- speakerState: (_b = block.speakerState) === null || _b === void 0 ? void 0 : _b.name,
40
- };
41
- addLogEntry(logEntry);
42
- processedBlocks.current.add(realIndex);
43
- }
44
- });
45
- hasBuiltInitialHistory.current = true;
46
- }, [scenario.blocks, addLogEntry]);
47
- // 新しいブロックを処理
48
- useEffect(() => {
49
- var _a, _b;
50
- if (!currentBlock || !hasBuiltInitialHistory.current) {
51
- return;
52
- }
53
- // 会話ブロックのみログに追加
54
- if (currentBlock.blockType === "dialogue" ||
55
- currentBlock.blockType === "narration") {
56
- if (!processedBlocks.current.has(currentBlockIndex)) {
57
- console.log("Adding new conversation block to log:", currentBlock);
58
- const logEntry = {
59
- id: `${currentBlock.id}_${Date.now()}`,
60
- timestamp: Date.now(),
61
- blockIndex: currentBlockIndex,
62
- blockType: currentBlock.blockType,
63
- content: currentBlock.content,
64
- speakerName: (_a = currentBlock.speaker) === null || _a === void 0 ? void 0 : _a.name,
65
- speakerState: (_b = currentBlock.speakerState) === null || _b === void 0 ? void 0 : _b.name,
66
- };
67
- addLogEntry(logEntry);
68
- processedBlocks.current.add(currentBlockIndex);
69
- }
70
- }
71
- }, [currentBlock, currentBlockIndex, addLogEntry]);
72
- // シナリオ変更時にリセット
73
- useEffect(() => {
74
- clearLogs();
75
- }, [scenario.id, clearLogs]);
76
- return {
77
- logs,
78
- addLogEntry,
79
- clearLogs,
80
- buildInitialHistory,
81
- };
82
- }
@@ -1,9 +0,0 @@
1
- import type { PluginManager } from "../plugin/PluginManager";
2
- import type { ComponentType } from "../sdk";
3
- /**
4
- * UI コンポーネントの表示状態を管理するフック
5
- * @param pluginManager - PluginManager インスタンス
6
- * @param type - コンポーネントタイプ
7
- * @returns [isVisible, show, hide, toggle]
8
- */
9
- export declare function useUIVisibility(pluginManager: PluginManager, type: ComponentType): [boolean, () => void, () => void, () => void];
@@ -1,19 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- /**
3
- * UI コンポーネントの表示状態を管理するフック
4
- * @param pluginManager - PluginManager インスタンス
5
- * @param type - コンポーネントタイプ
6
- * @returns [isVisible, show, hide, toggle]
7
- */
8
- export function useUIVisibility(pluginManager, type) {
9
- const [isVisible, setIsVisible] = useState(() => pluginManager.getUIVisibility(type));
10
- useEffect(() => {
11
- // UI 状態の変更を監視
12
- const unsubscribe = pluginManager.subscribeUIVisibility(type, setIsVisible);
13
- return unsubscribe;
14
- }, [pluginManager, type]);
15
- const show = () => pluginManager.showUI(type);
16
- const hide = () => pluginManager.hideUI(type);
17
- const toggle = () => pluginManager.toggleUIVisibility(type);
18
- return [isVisible, show, hide, toggle];
19
- }