|
9 | 9 | isOverlayRuntimeToggleModifierActive, |
10 | 10 | LEVEL17_OVERLAY_CYCLE_KEY, |
11 | 11 | } from '/samples/phase-17/shared/overlayCycleInput.js'; |
| 12 | +import { normalizeOverlayRuntimeExtensions } from '/samples/phase-17/shared/overlayRuntimeExtensionNormalization.js'; |
12 | 13 | import { cloneJsonData, safeJsonParse, safeJsonStringify } from '/src/shared/io/index.js'; |
13 | 14 | import { asFiniteNumber } from '/src/shared/number/index.js'; |
14 | 15 |
|
@@ -64,62 +65,6 @@ const OVERLAY_RUNTIME_DEFAULT_PRESET_DEFINITIONS = Object.freeze([ |
64 | 65 | }), |
65 | 66 | ]); |
66 | 67 |
|
67 | | -function normalizeRuntimeExtensionEntry(entry) { |
68 | | - if (!entry || typeof entry !== 'object') { |
69 | | - return null; |
70 | | - } |
71 | | - |
72 | | - const overlayId = String(entry.overlayId || '').trim(); |
73 | | - const onStep = typeof entry.onStep === 'function' ? entry.onStep : null; |
74 | | - const onRender = typeof entry.onRender === 'function' ? entry.onRender : null; |
75 | | - if (!onStep && !onRender) { |
76 | | - return null; |
77 | | - } |
78 | | - |
79 | | - const layerOrderRaw = Number(entry.layerOrder); |
80 | | - const layerOrder = Number.isFinite(layerOrderRaw) ? layerOrderRaw : 0; |
81 | | - const visualPriorityRaw = Number(entry.visualPriority); |
82 | | - const visualPriority = Number.isFinite(visualPriorityRaw) ? visualPriorityRaw : layerOrder; |
83 | | - const compose = entry.compose === true; |
84 | | - const panelWidthRaw = Number(entry.panelWidth); |
85 | | - const panelHeightRaw = Number(entry.panelHeight); |
86 | | - const panelWidth = Number.isFinite(panelWidthRaw) && panelWidthRaw > 0 ? panelWidthRaw : 260; |
87 | | - const panelHeight = Number.isFinite(panelHeightRaw) && panelHeightRaw > 0 ? panelHeightRaw : 96; |
88 | | - const resolvePanelSize = typeof entry.resolvePanelSize === 'function' ? entry.resolvePanelSize : null; |
89 | | - const resolveContextBehavior = typeof entry.resolveContextBehavior === 'function' |
90 | | - ? entry.resolveContextBehavior |
91 | | - : null; |
92 | | - |
93 | | - return Object.freeze({ |
94 | | - overlayId, |
95 | | - onStep, |
96 | | - onRender, |
97 | | - resolvePanelSize, |
98 | | - resolveContextBehavior, |
99 | | - compose, |
100 | | - layerOrder, |
101 | | - visualPriority, |
102 | | - panelWidth, |
103 | | - panelHeight, |
104 | | - }); |
105 | | -} |
106 | | - |
107 | | -function normalizeRuntimeExtensions(runtimeExtensions) { |
108 | | - if (!Array.isArray(runtimeExtensions) || runtimeExtensions.length === 0) { |
109 | | - return Object.freeze([]); |
110 | | - } |
111 | | - |
112 | | - const normalized = []; |
113 | | - for (let i = 0; i < runtimeExtensions.length; i += 1) { |
114 | | - const candidate = normalizeRuntimeExtensionEntry(runtimeExtensions[i]); |
115 | | - if (!candidate) { |
116 | | - continue; |
117 | | - } |
118 | | - normalized.push(candidate); |
119 | | - } |
120 | | - return Object.freeze(normalized); |
121 | | -} |
122 | | - |
123 | 68 | function shouldRunRuntimeExtension(extension, activeOverlayId) { |
124 | 69 | if (!extension) { |
125 | 70 | return false; |
@@ -1697,7 +1642,7 @@ export function createOverlayGameplayRuntime({ |
1697 | 1642 | cycleKey = LEVEL17_OVERLAY_CYCLE_KEY, |
1698 | 1643 | } = {}) { |
1699 | 1644 | const runtime = { |
1700 | | - runtimeExtensions: normalizeRuntimeExtensions(runtimeExtensions), |
| 1645 | + runtimeExtensions: normalizeOverlayRuntimeExtensions(runtimeExtensions), |
1701 | 1646 | interactionVisible: true, |
1702 | 1647 | interactionIndex: 0, |
1703 | 1648 | interactionCycleLatch: false, |
@@ -1734,7 +1679,7 @@ export function setOverlayGameplayRuntimeExtensions(runtime, runtimeExtensions) |
1734 | 1679 | if (!runtime) { |
1735 | 1680 | return false; |
1736 | 1681 | } |
1737 | | - runtime.runtimeExtensions = normalizeRuntimeExtensions(runtimeExtensions); |
| 1682 | + runtime.runtimeExtensions = normalizeOverlayRuntimeExtensions(runtimeExtensions); |
1738 | 1683 | normalizeInteractionIndex(runtime); |
1739 | 1684 | return true; |
1740 | 1685 | } |
|
0 commit comments