@woven-canvas/core 0.1.0 → 0.1.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/build/_tsup-dts-rollup.d.cts +5 -0
- package/build/_tsup-dts-rollup.d.ts +5 -0
- package/build/index.cjs +30 -21
- package/build/index.cjs.map +1 -1
- package/build/index.d.cts +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +29 -21
- package/build/index.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/build/index.d.cts
CHANGED
|
@@ -35,6 +35,7 @@ export { CommandMarker_alias_1 as CommandMarker } from './_tsup-dts-rollup.cjs';
|
|
|
35
35
|
export { defineCommand_alias_1 as defineCommand } from './_tsup-dts-rollup.cjs';
|
|
36
36
|
export { on_alias_1 as on } from './_tsup-dts-rollup.cjs';
|
|
37
37
|
export { Redo_alias_1 as Redo } from './_tsup-dts-rollup.cjs';
|
|
38
|
+
export { ResetKeyboard_alias_1 as ResetKeyboard } from './_tsup-dts-rollup.cjs';
|
|
38
39
|
export { Undo_alias_1 as Undo } from './_tsup-dts-rollup.cjs';
|
|
39
40
|
export { Aabb } from './_tsup-dts-rollup.cjs';
|
|
40
41
|
export { Asset } from './_tsup-dts-rollup.cjs';
|
package/build/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { CommandMarker_alias_1 as CommandMarker } from './_tsup-dts-rollup.js';
|
|
|
35
35
|
export { defineCommand_alias_1 as defineCommand } from './_tsup-dts-rollup.js';
|
|
36
36
|
export { on_alias_1 as on } from './_tsup-dts-rollup.js';
|
|
37
37
|
export { Redo_alias_1 as Redo } from './_tsup-dts-rollup.js';
|
|
38
|
+
export { ResetKeyboard_alias_1 as ResetKeyboard } from './_tsup-dts-rollup.js';
|
|
38
39
|
export { Undo_alias_1 as Undo } from './_tsup-dts-rollup.js';
|
|
39
40
|
export { Aabb } from './_tsup-dts-rollup.js';
|
|
40
41
|
export { Asset } from './_tsup-dts-rollup.js';
|
package/build/index.js
CHANGED
|
@@ -1799,6 +1799,19 @@ var KeyboardDef = class extends CanvasSingletonDef7 {
|
|
|
1799
1799
|
isKeyUpTrigger(ctx, key) {
|
|
1800
1800
|
return getBit(this.read(ctx).keysUpTrigger, key);
|
|
1801
1801
|
}
|
|
1802
|
+
/**
|
|
1803
|
+
* Reset all keyboard state.
|
|
1804
|
+
* Clears all key states and modifier flags.
|
|
1805
|
+
*/
|
|
1806
|
+
reset(ctx) {
|
|
1807
|
+
const keyboard = this.write(ctx);
|
|
1808
|
+
clearBits(keyboard.keysDown);
|
|
1809
|
+
clearBits(keyboard.keysDownTrigger);
|
|
1810
|
+
clearBits(keyboard.keysUpTrigger);
|
|
1811
|
+
keyboard.shiftDown = false;
|
|
1812
|
+
keyboard.altDown = false;
|
|
1813
|
+
keyboard.modDown = false;
|
|
1814
|
+
}
|
|
1802
1815
|
};
|
|
1803
1816
|
var Keyboard = new KeyboardDef();
|
|
1804
1817
|
function setBit(buffer, bitIndex, value) {
|
|
@@ -2228,6 +2241,7 @@ function on(ctx, def, handler) {
|
|
|
2228
2241
|
}
|
|
2229
2242
|
var Undo = defineCommand("undo");
|
|
2230
2243
|
var Redo = defineCommand("redo");
|
|
2244
|
+
var ResetKeyboard = defineCommand("reset-keyboard");
|
|
2231
2245
|
|
|
2232
2246
|
// src/EditorSystem.ts
|
|
2233
2247
|
import { MainThreadSystem } from "@woven-ecs/core";
|
|
@@ -2292,11 +2306,7 @@ function attachKeyboardListeners(domElement) {
|
|
|
2292
2306
|
},
|
|
2293
2307
|
onBlur: () => {
|
|
2294
2308
|
state.eventsBuffer.push({ type: "blur" });
|
|
2295
|
-
}
|
|
2296
|
-
// Reusable buffers - allocated once per instance
|
|
2297
|
-
keysDown: new Uint8Array(32),
|
|
2298
|
-
keysDownTrigger: new Uint8Array(32),
|
|
2299
|
-
keysUpTrigger: new Uint8Array(32)
|
|
2309
|
+
}
|
|
2300
2310
|
};
|
|
2301
2311
|
instanceState.set(domElement, state);
|
|
2302
2312
|
domElement.addEventListener("keydown", state.onKeyDown);
|
|
@@ -2315,19 +2325,19 @@ var keyboardSystem = defineEditorSystem({ phase: "input" }, (ctx) => {
|
|
|
2315
2325
|
const resources = getResources3(ctx);
|
|
2316
2326
|
const state = instanceState.get(resources.domElement);
|
|
2317
2327
|
if (!state) return;
|
|
2328
|
+
on(ctx, ResetKeyboard, () => {
|
|
2329
|
+
Keyboard.reset(ctx);
|
|
2330
|
+
});
|
|
2318
2331
|
const hasEvents = state.eventsBuffer.length > 0;
|
|
2319
|
-
const
|
|
2332
|
+
const keyboardRead = Keyboard.read(ctx);
|
|
2333
|
+
const triggersNeedClearing = !isZeroed(keyboardRead.keysDownTrigger) || !isZeroed(keyboardRead.keysUpTrigger);
|
|
2320
2334
|
if (!hasEvents && !triggersNeedClearing) return;
|
|
2321
2335
|
const keyboard = Keyboard.write(ctx);
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
const keysUpTrigger = state.keysUpTrigger;
|
|
2325
|
-
keysDownTrigger.fill(0);
|
|
2326
|
-
keysUpTrigger.fill(0);
|
|
2327
|
-
keysDown.set(keyboard.keysDown);
|
|
2336
|
+
clearBits(keyboard.keysDownTrigger);
|
|
2337
|
+
clearBits(keyboard.keysUpTrigger);
|
|
2328
2338
|
for (const event of state.eventsBuffer) {
|
|
2329
2339
|
if (event.type === "blur") {
|
|
2330
|
-
keysDown
|
|
2340
|
+
clearBits(keyboard.keysDown);
|
|
2331
2341
|
keyboard.shiftDown = false;
|
|
2332
2342
|
keyboard.altDown = false;
|
|
2333
2343
|
keyboard.modDown = false;
|
|
@@ -2336,22 +2346,19 @@ var keyboardSystem = defineEditorSystem({ phase: "input" }, (ctx) => {
|
|
|
2336
2346
|
const keyIndex = codeToIndex[event.code];
|
|
2337
2347
|
if (keyIndex === void 0) continue;
|
|
2338
2348
|
if (event.type === "keydown") {
|
|
2339
|
-
const wasDown = getBit2(keysDown, keyIndex);
|
|
2349
|
+
const wasDown = getBit2(keyboard.keysDown, keyIndex);
|
|
2340
2350
|
if (!wasDown) {
|
|
2341
|
-
setBit(keysDownTrigger, keyIndex, true);
|
|
2351
|
+
setBit(keyboard.keysDownTrigger, keyIndex, true);
|
|
2342
2352
|
}
|
|
2343
|
-
setBit(keysDown, keyIndex, true);
|
|
2353
|
+
setBit(keyboard.keysDown, keyIndex, true);
|
|
2344
2354
|
} else if (event.type === "keyup") {
|
|
2345
|
-
setBit(keysDown, keyIndex, false);
|
|
2346
|
-
setBit(keysUpTrigger, keyIndex, true);
|
|
2355
|
+
setBit(keyboard.keysDown, keyIndex, false);
|
|
2356
|
+
setBit(keyboard.keysUpTrigger, keyIndex, true);
|
|
2347
2357
|
}
|
|
2348
2358
|
keyboard.shiftDown = event.shiftKey;
|
|
2349
2359
|
keyboard.altDown = event.altKey;
|
|
2350
2360
|
keyboard.modDown = event.ctrlKey || event.metaKey;
|
|
2351
2361
|
}
|
|
2352
|
-
keyboard.keysDown = keysDown;
|
|
2353
|
-
keyboard.keysDownTrigger = keysDownTrigger;
|
|
2354
|
-
keyboard.keysUpTrigger = keysUpTrigger;
|
|
2355
2362
|
state.eventsBuffer.length = 0;
|
|
2356
2363
|
});
|
|
2357
2364
|
function getBit2(buffer, bitIndex) {
|
|
@@ -3983,6 +3990,7 @@ export {
|
|
|
3983
3990
|
PointerType,
|
|
3984
3991
|
RankBounds,
|
|
3985
3992
|
Redo,
|
|
3993
|
+
ResetKeyboard,
|
|
3986
3994
|
SINGLETON_ENTITY_ID,
|
|
3987
3995
|
STRATUM_ORDER,
|
|
3988
3996
|
ScaleWithZoom,
|