@caperjs/core 0.2.4 → 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/build/assetpack.mjs +90 -0
- package/build/index.mjs +3 -1
- package/build/internal/discovery.mjs +1 -1
- package/build/internal/manifest.mjs +8 -3
- package/build/internal/validate.mjs +3 -1
- package/build/plugins/assetTypes.mjs +4 -4
- package/build/plugins/caperConfig.mjs +12 -5
- package/build/plugins/lists.mjs +29 -9
- package/build/plugins/pruneFallbacks.mjs +25 -2
- package/cli/create.mjs +57 -6
- package/cli/create.test.mjs +36 -0
- package/cli/update.mjs +1 -1
- package/lib/{CaptionsPlugin-WPAcfAkx.js → CaptionsPlugin-cSJj-R9M.js} +5 -5
- package/lib/{CaptionsPlugin-WPAcfAkx.js.map → CaptionsPlugin-cSJj-R9M.js.map} +1 -1
- package/lib/{DataAdapter-DS-twowe.js → DataAdapter-D2tc6hx9.js} +15 -10
- package/lib/DataAdapter-D2tc6hx9.js.map +1 -0
- package/lib/{DebugRenderer-D1ryrRYx.js → DebugRenderer-CGUKy6Fy.js} +2 -2
- package/lib/{DebugRenderer-D1ryrRYx.js.map → DebugRenderer-CGUKy6Fy.js.map} +1 -1
- package/lib/{DevToolsPlugin-DH7zX7HU.js → DevToolsPlugin-B8GX3H9b.js} +2 -2
- package/lib/{DevToolsPlugin-DH7zX7HU.js.map → DevToolsPlugin-B8GX3H9b.js.map} +1 -1
- package/lib/{GSAPPlugin-BBtRjUqe.js → GSAPPlugin-Br9AjuTD.js} +6 -6
- package/lib/{GSAPPlugin-BBtRjUqe.js.map → GSAPPlugin-Br9AjuTD.js.map} +1 -1
- package/lib/{LayoutPlugin-Co6vcoV4.js → LayoutPlugin-BX3OP7pw.js} +4 -4
- package/lib/{LayoutPlugin-Co6vcoV4.js.map → LayoutPlugin-BX3OP7pw.js.map} +1 -1
- package/lib/{SpinePlugin-uN641Hmk.js → SpinePlugin-C-JDdXpf.js} +690 -793
- package/lib/SpinePlugin-C-JDdXpf.js.map +1 -0
- package/lib/{StatsPlugin-vZQRm6wh.js → StatsPlugin-yJlJtoQ2.js} +7 -7
- package/lib/StatsPlugin-yJlJtoQ2.js.map +1 -0
- package/lib/{VoiceOverPlugin-KlZdGj1G.js → VoiceOverPlugin-DjSZp4Ko.js} +7 -6
- package/lib/VoiceOverPlugin-DjSZp4Ko.js.map +1 -0
- package/lib/caper.mjs +159 -1917
- package/lib/caper.mjs.map +1 -1
- package/lib/const-C3sxeYhl.js +1746 -0
- package/lib/const-C3sxeYhl.js.map +1 -0
- package/lib/core/Application.d.ts +8 -3
- package/lib/core/Application.d.ts.map +1 -1
- package/lib/core/Application.test.d.ts +2 -0
- package/lib/core/Application.test.d.ts.map +1 -0
- package/lib/core/config.d.ts +6 -1
- package/lib/core/config.d.ts.map +1 -1
- package/lib/core/config.test.d.ts +2 -0
- package/lib/core/config.test.d.ts.map +1 -0
- package/lib/core/create.d.ts.map +1 -1
- package/lib/core/interfaces/IApplication.d.ts +6 -6
- package/lib/core/interfaces/IApplication.d.ts.map +1 -1
- package/lib/core/interfaces/ICoreSignals.d.ts +2 -1
- package/lib/core/interfaces/ICoreSignals.d.ts.map +1 -1
- package/lib/display/Camera.test.d.ts +2 -0
- package/lib/display/Camera.test.d.ts.map +1 -0
- package/lib/display/Entity.d.ts +2 -2
- package/lib/display/SceneTransition.test.d.ts +1 -0
- package/lib/display/SceneTransition.test.d.ts.map +1 -0
- package/lib/display/SpineAnimation.d.ts +3 -3
- package/lib/mixins/factory/methods.d.ts.map +1 -1
- package/lib/padding-1kHDpGlQ.js +41 -0
- package/lib/padding-1kHDpGlQ.js.map +1 -0
- package/lib/plugins/AssetsPlugin.d.ts.map +1 -1
- package/lib/plugins/AssetsPlugin.test.d.ts +2 -0
- package/lib/plugins/AssetsPlugin.test.d.ts.map +1 -0
- package/lib/plugins/DataAdapter.d.ts.map +1 -1
- package/lib/plugins/DataAdapter.test.d.ts +2 -0
- package/lib/plugins/DataAdapter.test.d.ts.map +1 -0
- package/lib/plugins/FullScreenPlugin.d.ts +0 -5
- package/lib/plugins/FullScreenPlugin.d.ts.map +1 -1
- package/lib/plugins/FullScreenPlugin.test.d.ts +2 -0
- package/lib/plugins/FullScreenPlugin.test.d.ts.map +1 -0
- package/lib/plugins/GSAPPlugin.d.ts +0 -2
- package/lib/plugins/GSAPPlugin.d.ts.map +1 -1
- package/lib/plugins/GSAPPlugin.test.d.ts +2 -0
- package/lib/plugins/GSAPPlugin.test.d.ts.map +1 -0
- package/lib/plugins/KeyboardPlugin.d.ts +0 -1
- package/lib/plugins/KeyboardPlugin.d.ts.map +1 -1
- package/lib/plugins/LookupPlugin.d.ts +6 -1
- package/lib/plugins/LookupPlugin.d.ts.map +1 -1
- package/lib/plugins/LookupPlugin.test.d.ts +2 -0
- package/lib/plugins/LookupPlugin.test.d.ts.map +1 -0
- package/lib/plugins/Plugin.d.ts +101 -2
- package/lib/plugins/Plugin.d.ts.map +1 -1
- package/lib/plugins/PopupManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/PopupManagerPlugin.test.d.ts +1 -0
- package/lib/plugins/PopupManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/SceneManagerPlugin.d.ts +1 -1
- package/lib/plugins/SceneManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/SceneManagerPlugin.test.d.ts +2 -0
- package/lib/plugins/SceneManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/StatsPlugin.d.ts.map +1 -1
- package/lib/plugins/TimerPlugin.d.ts.map +1 -1
- package/lib/plugins/WebEventsPlugin.d.ts +0 -1
- package/lib/plugins/WebEventsPlugin.d.ts.map +1 -1
- package/lib/plugins/actions/ActionsPlugin.test.d.ts +2 -0
- package/lib/plugins/actions/ActionsPlugin.test.d.ts.map +1 -0
- package/lib/plugins/audio/AudioChannel.d.ts.map +1 -1
- package/lib/plugins/audio/AudioManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/audio/AudioManagerPlugin.test.d.ts +2 -0
- package/lib/plugins/audio/AudioManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/audio/VoiceOverPlugin.d.ts.map +1 -1
- package/lib/plugins/breakpoints/BreakpointPlugin.d.ts.map +1 -1
- package/lib/plugins/captions/CaptionsPlugin.test.d.ts +2 -0
- package/lib/plugins/captions/CaptionsPlugin.test.d.ts.map +1 -0
- package/lib/plugins/focus/FocusManagerPlugin.d.ts.map +1 -1
- package/lib/plugins/focus/FocusManagerPlugin.test.d.ts +2 -0
- package/lib/plugins/focus/FocusManagerPlugin.test.d.ts.map +1 -0
- package/lib/plugins/gesture/GesturePlugin.d.ts.map +1 -1
- package/lib/plugins/input/AbstractControls.d.ts +47 -3
- package/lib/plugins/input/AbstractControls.d.ts.map +1 -1
- package/lib/plugins/input/Controls.test.d.ts +2 -0
- package/lib/plugins/input/Controls.test.d.ts.map +1 -0
- package/lib/plugins/input/InputPlugin.d.ts.map +1 -1
- package/lib/plugins/input/controlsCore.d.ts +58 -0
- package/lib/plugins/input/controlsCore.d.ts.map +1 -0
- package/lib/plugins/input/controlsCore.test.d.ts +2 -0
- package/lib/plugins/input/controlsCore.test.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/KeyboardControls.d.ts +15 -0
- package/lib/plugins/input/keyboard/KeyboardControls.d.ts.map +1 -0
- package/lib/plugins/input/keyboard/index.d.ts +1 -1
- package/lib/plugins/input/keyboard/index.d.ts.map +1 -1
- package/lib/plugins/input/touch/VirtualControls.d.ts +8 -14
- package/lib/plugins/input/touch/VirtualControls.d.ts.map +1 -1
- package/lib/plugins/input/touch/VirtualControls.test.d.ts +2 -0
- package/lib/plugins/input/touch/VirtualControls.test.d.ts.map +1 -0
- package/lib/{registries-BLrxALZ0.js → registries-BfV-VF7a.js} +665 -597
- package/lib/registries-BfV-VF7a.js.map +1 -0
- package/lib/store/Store.d.ts.map +1 -1
- package/lib/ui/Button.d.ts.map +1 -1
- package/lib/ui/UICanvas.d.ts +10 -1
- package/lib/ui/UICanvas.d.ts.map +1 -1
- package/lib/ui/UICanvas.test.d.ts +0 -1
- package/lib/ui/UICanvas.test.d.ts.map +1 -1
- package/lib/utils/color.d.ts.map +1 -1
- package/lib/utils/color.test.d.ts +2 -0
- package/lib/utils/color.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/core/Application.test.ts +168 -0
- package/src/core/Application.ts +37 -27
- package/src/core/config.test.ts +79 -0
- package/src/core/config.ts +28 -6
- package/src/core/create.ts +11 -0
- package/src/core/interfaces/IApplication.ts +6 -6
- package/src/core/interfaces/ICoreSignals.ts +2 -0
- package/src/display/Camera.test.ts +40 -0
- package/src/display/Camera.ts +3 -3
- package/src/display/Entity.ts +2 -2
- package/src/display/SceneTransition.test.ts +58 -0
- package/src/display/SceneTransition.ts +1 -1
- package/src/display/SpineAnimation.ts +4 -4
- package/src/mixins/factory/methods.ts +0 -1
- package/src/plugins/AssetsPlugin.test.ts +48 -0
- package/src/plugins/AssetsPlugin.ts +3 -1
- package/src/plugins/DataAdapter.test.ts +32 -0
- package/src/plugins/DataAdapter.ts +5 -1
- package/src/plugins/FullScreenPlugin.test.ts +48 -0
- package/src/plugins/FullScreenPlugin.ts +9 -18
- package/src/plugins/GSAPPlugin.test.ts +31 -0
- package/src/plugins/GSAPPlugin.ts +1 -4
- package/src/plugins/KeyboardPlugin.ts +3 -10
- package/src/plugins/LookupPlugin.test.ts +42 -0
- package/src/plugins/LookupPlugin.ts +15 -3
- package/src/plugins/Plugin.test.ts +130 -2
- package/src/plugins/Plugin.ts +159 -3
- package/src/plugins/PopupManagerPlugin.test.ts +53 -0
- package/src/plugins/PopupManagerPlugin.ts +5 -3
- package/src/plugins/SceneManagerPlugin.test.ts +76 -0
- package/src/plugins/SceneManagerPlugin.ts +18 -13
- package/src/plugins/StatsPlugin.ts +3 -2
- package/src/plugins/TimerPlugin.ts +1 -2
- package/src/plugins/WebEventsPlugin.test.ts +32 -0
- package/src/plugins/WebEventsPlugin.ts +9 -16
- package/src/plugins/actions/ActionsPlugin.test.ts +68 -0
- package/src/plugins/actions/ActionsPlugin.ts +5 -5
- package/src/plugins/audio/AudioChannel.test.ts +19 -0
- package/src/plugins/audio/AudioChannel.ts +8 -1
- package/src/plugins/audio/AudioManagerPlugin.test.ts +41 -0
- package/src/plugins/audio/AudioManagerPlugin.ts +3 -2
- package/src/plugins/audio/VoiceOverPlugin.ts +1 -0
- package/src/plugins/breakpoints/BreakpointPlugin.ts +1 -2
- package/src/plugins/captions/CaptionsPlugin.test.ts +40 -0
- package/src/plugins/captions/CaptionsPlugin.ts +2 -2
- package/src/plugins/focus/FocusManagerPlugin.test.ts +71 -0
- package/src/plugins/focus/FocusManagerPlugin.ts +7 -0
- package/src/plugins/gesture/GesturePlugin.ts +4 -8
- package/src/plugins/input/AbstractControls.ts +104 -3
- package/src/plugins/input/Controls.test.ts +205 -0
- package/src/plugins/input/InputPlugin.ts +6 -14
- package/src/plugins/input/controlsCore.test.ts +151 -0
- package/src/plugins/input/controlsCore.ts +162 -0
- package/src/plugins/input/keyboard/KeyboardControls.ts +84 -0
- package/src/plugins/input/keyboard/index.ts +1 -1
- package/src/plugins/input/touch/VirtualControls.test.ts +38 -0
- package/src/plugins/input/touch/VirtualControls.ts +53 -120
- package/src/plugins/spine/SpinePlugin.ts +2 -2
- package/src/store/Store.test.ts +15 -0
- package/src/store/Store.ts +4 -1
- package/src/ui/Button.test.ts +12 -0
- package/src/ui/Button.ts +1 -0
- package/src/ui/UICanvas.test.ts +109 -6
- package/src/ui/UICanvas.ts +41 -3
- package/src/utils/color.test.ts +16 -0
- package/src/utils/color.ts +2 -1
- package/src/utils/platform.ts +1 -1
- package/src/version.ts +1 -1
- package/lib/DataAdapter-DS-twowe.js.map +0 -1
- package/lib/SpinePlugin-uN641Hmk.js.map +0 -1
- package/lib/StatsPlugin-vZQRm6wh.js.map +0 -1
- package/lib/VoiceOverPlugin-KlZdGj1G.js.map +0 -1
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts +0 -28
- package/lib/plugins/input/keyboard/KeyboardContols.d.ts.map +0 -1
- package/lib/registries-BLrxALZ0.js.map +0 -1
- package/src/plugins/input/keyboard/KeyboardContols.ts +0 -182
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { Application } from '../../../core/Application';
|
|
2
|
-
import { WithSignals } from '../../../mixins/signals';
|
|
3
|
-
import { bindAllMethods } from '../../../utils';
|
|
4
|
-
import type { Action } from '../../actions';
|
|
5
|
-
import { normalizeKey, type KeyboardEventDetail } from '../../KeyboardPlugin';
|
|
6
|
-
import { AbstractControls } from '../AbstractControls';
|
|
7
|
-
import type { ControlsActionMap, KeyboardControlsMap, KeyboardControlsScheme } from '../types';
|
|
8
|
-
|
|
9
|
-
export class KeyboardControls extends WithSignals(AbstractControls) {
|
|
10
|
-
protected scheme: Partial<KeyboardControlsMap>;
|
|
11
|
-
private _keyDownMap: Partial<KeyboardControlsScheme>;
|
|
12
|
-
private _keyUpMap: Partial<KeyboardControlsScheme>;
|
|
13
|
-
private _keyCombinations: string[][] = [];
|
|
14
|
-
private _singleDownKeys: Set<string> = new Set();
|
|
15
|
-
private _keyCombinationsMap: Map<string[], Action> = new Map();
|
|
16
|
-
private _activeDownKeys: Map<string, Action> = new Map();
|
|
17
|
-
private _activeUpKeys: Map<string, Action> = new Map();
|
|
18
|
-
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
bindAllMethods(this);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get app() {
|
|
25
|
-
return Application.getInstance();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
isActionActive(action: Action): boolean {
|
|
29
|
-
const controlsAction = this.scheme['down']?.[action] ?? null;
|
|
30
|
-
if (!controlsAction) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(controlsAction)) {
|
|
34
|
-
return (
|
|
35
|
-
this._keyCombinationsMap.has(controlsAction) || controlsAction.some((key) => this._singleDownKeys.has(key))
|
|
36
|
-
);
|
|
37
|
-
} else {
|
|
38
|
-
return this._singleDownKeys.has(controlsAction);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public initialize(scheme: Partial<KeyboardControlsMap>): void {
|
|
43
|
-
super.initialize(scheme as Partial<ControlsActionMap>);
|
|
44
|
-
this._keyDownMap = scheme.down || {};
|
|
45
|
-
this._keyUpMap = scheme.up || {};
|
|
46
|
-
this._sortActions();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public connect() {
|
|
50
|
-
this.addSignalConnection(
|
|
51
|
-
this.app.signal.onActionContextChanged.connect(this._handleContextChanged),
|
|
52
|
-
this.app.keyboard.onKeyDown().connect(this._handleKeyDown),
|
|
53
|
-
this.app.keyboard.onKeyUp().connect(this._handleKeyUp),
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
this._handleContextChanged();
|
|
57
|
-
this.app.ticker.add(this._update);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private _sortActions() {
|
|
61
|
-
const actions = this.app.actionsPlugin.getActions();
|
|
62
|
-
this._keyCombinations = [];
|
|
63
|
-
this._keyCombinationsMap.clear();
|
|
64
|
-
this._activeDownKeys.clear();
|
|
65
|
-
this._activeUpKeys.clear();
|
|
66
|
-
let keys = Object.keys(this._keyDownMap);
|
|
67
|
-
|
|
68
|
-
keys.forEach((key) => {
|
|
69
|
-
const item = this._keyDownMap[key];
|
|
70
|
-
const action = actions[key];
|
|
71
|
-
if (
|
|
72
|
-
action.context !== '*' &&
|
|
73
|
-
action.context !== this.app.actionContext &&
|
|
74
|
-
!action.context.includes(this.app.actionContext)
|
|
75
|
-
) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
let input = item;
|
|
79
|
-
if (input) {
|
|
80
|
-
if (!Array.isArray(input)) {
|
|
81
|
-
input = [input];
|
|
82
|
-
}
|
|
83
|
-
input.forEach((inputString: string) => {
|
|
84
|
-
if (inputString.includes('+')) {
|
|
85
|
-
const combo = inputString.split('+');
|
|
86
|
-
this._keyCombinations.push(combo);
|
|
87
|
-
this._keyCombinationsMap.set(combo, key as Action);
|
|
88
|
-
} else {
|
|
89
|
-
this._activeDownKeys.set(inputString, key as Action);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// sort them from the largest to smallest
|
|
96
|
-
this._keyCombinations.sort((a, b) => b.length - a.length);
|
|
97
|
-
|
|
98
|
-
keys = Object.keys(this._keyUpMap);
|
|
99
|
-
keys.forEach((key) => {
|
|
100
|
-
const item = this._keyUpMap[key];
|
|
101
|
-
let input = item;
|
|
102
|
-
if (input) {
|
|
103
|
-
if (!Array.isArray(input)) {
|
|
104
|
-
input = [input];
|
|
105
|
-
}
|
|
106
|
-
input.forEach((inputString: string) => {
|
|
107
|
-
this._activeUpKeys.set(inputString, key as Action);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
//Logger.log('keyDownMap', this._keyDownMap, 'activeDownKeys', this._activeDownKeys);
|
|
113
|
-
//Logger.log('keyUpMap', this._keyUpMap, 'activeUpKeys', this._activeUpKeys);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private _handleContextChanged() {
|
|
117
|
-
this._getPossibleActions();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private _getPossibleActions() {
|
|
121
|
-
this._sortActions();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private _handleKeyDown(detail: KeyboardEventDetail): void {
|
|
125
|
-
const key = normalizeKey(detail.event.key);
|
|
126
|
-
this._singleDownKeys.add(key);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private _handleKeyUp(detail: KeyboardEventDetail): void {
|
|
130
|
-
const key = normalizeKey(detail.event.key);
|
|
131
|
-
this._singleDownKeys.delete(key);
|
|
132
|
-
|
|
133
|
-
const action = this._activeUpKeys.get(key);
|
|
134
|
-
if (action) {
|
|
135
|
-
this.app.action(action, { combination: false, inputState: 'up', key });
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private _update() {
|
|
140
|
-
if (!this.app.keyboard) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const keysDown = this.app.keyboard.keysDown;
|
|
144
|
-
if (keysDown.size === 0) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const eliminated = new Set<string>();
|
|
148
|
-
// this._keyCombinations is already sorted from largest to smallest
|
|
149
|
-
for (let i = 0; i < this._keyCombinations.length; i++) {
|
|
150
|
-
const combination = this._keyCombinations[i];
|
|
151
|
-
// check if all of the keys in the combination are down
|
|
152
|
-
if (combination.some((key) => eliminated.has(key))) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
if (combination.every((key) => keysDown.has(key))) {
|
|
156
|
-
combination.forEach((key) => eliminated.add(key));
|
|
157
|
-
// send the action
|
|
158
|
-
const action = this._keyCombinationsMap.get(combination);
|
|
159
|
-
if (action) {
|
|
160
|
-
this.app.action(action, {
|
|
161
|
-
key: combination,
|
|
162
|
-
combination: true,
|
|
163
|
-
inputState: 'down',
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// order doesn't matter here
|
|
170
|
-
this._singleDownKeys.forEach((key) => {
|
|
171
|
-
if (eliminated.has(key)) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (keysDown.has(key)) {
|
|
175
|
-
const action = this._activeDownKeys.get(key);
|
|
176
|
-
if (action) {
|
|
177
|
-
this.app.action(action, { key, combination: false, inputState: 'down' });
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|