sfml.js 1.0.0-rc.2 → 1.1.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/README.ja.md +16 -11
- package/README.ko.md +16 -11
- package/README.md +16 -11
- package/README.zh-CN.md +16 -11
- package/assets/breakout.png +0 -0
- package/binding.gyp +23 -16
- package/dist/audio/effect-processor.js +9 -3
- package/dist/audio/input-sound-file.js +41 -15
- package/dist/audio/listener.js +33 -11
- package/dist/audio/music.js +41 -18
- package/dist/audio/output-sound-file.js +4 -2
- package/dist/audio/playback-device.js +11 -3
- package/dist/audio/sound-buffer-recorder.js +8 -5
- package/dist/audio/sound-buffer.js +40 -17
- package/dist/audio/sound-file-factory.js +21 -9
- package/dist/audio/sound-file-reader.js +21 -7
- package/dist/audio/sound-recorder.js +36 -15
- package/dist/audio/sound-source.js +117 -40
- package/dist/audio/sound-stream.js +14 -5
- package/dist/audio/sound.js +9 -4
- package/dist/audio/value.js +42 -16
- package/dist/graphics/blend-mode.js +2 -1
- package/dist/graphics/boolean-vector.d.ts +1 -2
- package/dist/graphics/boolean-vector.js +19 -9
- package/dist/graphics/color.js +2 -1
- package/dist/graphics/convex-shape.js +7 -3
- package/dist/graphics/font.js +52 -23
- package/dist/graphics/glsl-matrix.js +8 -3
- package/dist/graphics/glsl.js +47 -16
- package/dist/graphics/glyph.js +27 -10
- package/dist/graphics/image.js +30 -14
- package/dist/graphics/rect.js +15 -8
- package/dist/graphics/render-states.js +18 -9
- package/dist/graphics/render-target.js +49 -23
- package/dist/graphics/render-texture.js +24 -12
- package/dist/graphics/render-window.js +6 -3
- package/dist/graphics/shader.js +67 -32
- package/dist/graphics/shape.js +25 -13
- package/dist/graphics/sprite.js +19 -9
- package/dist/graphics/stencil-mode.js +10 -6
- package/dist/graphics/swap.js +2 -1
- package/dist/graphics/text.js +123 -48
- package/dist/graphics/texture.js +48 -24
- package/dist/graphics/transform.js +29 -13
- package/dist/graphics/transformable.js +2 -1
- package/dist/graphics/vertex-array.js +40 -18
- package/dist/graphics/vertex-buffer.js +39 -19
- package/dist/graphics/vertex.js +6 -3
- package/dist/graphics/view.js +30 -14
- package/dist/index.d.ts +4 -4
- package/dist/internal/audio-codec-registry.js +12 -6
- package/dist/internal/audio-input-stream.js +2 -1
- package/dist/internal/audio-music-pump.js +58 -24
- package/dist/internal/audio-recorder-session.js +17 -7
- package/dist/internal/audio-worker-session.js +28 -10
- package/dist/internal/audio-worker.js +40 -21
- package/dist/internal/glsl-value.d.ts +3 -1
- package/dist/internal/glsl-value.js +18 -8
- package/dist/internal/graphics-state.js +29 -15
- package/dist/internal/input-stream.d.ts +3 -1
- package/dist/internal/input-stream.js +16 -7
- package/dist/internal/numeric-properties.js +2 -1
- package/dist/internal/render-states.js +2 -1
- package/dist/internal/scalar.js +22 -13
- package/dist/internal/shaped-glyph.d.ts +3 -1
- package/dist/internal/shaped-glyph.js +12 -4
- package/dist/internal/struct-view.d.ts +3 -1
- package/dist/internal/struct-view.js +3 -1
- package/dist/internal/transformable.js +2 -1
- package/dist/network/common.js +23 -11
- package/dist/network/dns.js +25 -17
- package/dist/network/ftp.js +43 -18
- package/dist/network/http.js +126 -56
- package/dist/network/ip-address.js +50 -25
- package/dist/network/packet.js +63 -25
- package/dist/network/sftp.js +175 -74
- package/dist/network/socket-selector.js +28 -14
- package/dist/network/socket.js +71 -30
- package/dist/network/tcp-listener.js +42 -19
- package/dist/network/tcp-socket.js +111 -53
- package/dist/network/tls-material.js +2 -1
- package/dist/network/udp-socket.js +68 -33
- package/dist/system/angle.js +2 -1
- package/dist/system/clock.js +4 -2
- package/dist/system/err.js +5 -2
- package/dist/system/file-input-stream.js +8 -4
- package/dist/system/input-stream.js +6 -3
- package/dist/system/operators.d.ts +1 -1
- package/dist/system/operators.js +90 -50
- package/dist/system/sleep.js +4 -2
- package/dist/system/time.js +12 -6
- package/dist/system/vector2.js +6 -7
- package/dist/system/vector3.js +11 -6
- package/dist/window/clipboard.js +2 -1
- package/dist/window/context.js +10 -5
- package/dist/window/cursor.js +2 -1
- package/dist/window/event.js +9 -5
- package/dist/window/mouse.js +4 -2
- package/dist/window/video-mode.js +2 -1
- package/dist/window/window.js +19 -12
- package/native/addon.cc +25 -12
- package/native/audio-binding.cc +266 -126
- package/native/audio-codec-binding.cc +147 -77
- package/native/audio-device-binding.cc +76 -49
- package/native/audio-file-binding.cc +116 -67
- package/native/audio-recorder-binding.cc +147 -98
- package/native/audio-recorder.h +1 -1
- package/native/audio-state.h +53 -30
- package/native/audio-stream-binding.cc +148 -94
- package/native/audio-stream.h +5 -4
- package/native/audio-worker-binding.cc +163 -81
- package/native/audio-worker.h +35 -19
- package/native/batch-drawable.cc +29 -16
- package/native/batch-drawable.h +11 -8
- package/native/context-binding.cc +40 -27
- package/native/context-settings.h +15 -8
- package/native/deferred-delete.cc +9 -6
- package/native/deferred-delete.h +7 -8
- package/native/error-stream-binding.cc +42 -28
- package/native/font-binding.cc +89 -48
- package/native/graphics-binding.cc +122 -72
- package/native/graphics-state.h +50 -36
- package/native/image-binding.cc +38 -24
- package/native/image-state.h +26 -18
- package/native/input-binding.cc +42 -27
- package/native/render-window-binding.cc +38 -23
- package/native/shader-binding.cc +115 -50
- package/native/shape-binding.cc +94 -49
- package/native/shape-state.h +18 -9
- package/native/shaped-glyph-storage.h +9 -5
- package/native/stream-binding.cc +143 -117
- package/native/system-binding.cc +17 -12
- package/native/text-binding.cc +68 -35
- package/native/text-state.h +25 -18
- package/native/texture-binding.cc +42 -33
- package/native/texture-resource.h +20 -12
- package/native/time-value.h +3 -1
- package/native/transformable-binding.cc +12 -6
- package/native/transformable-state.h +6 -6
- package/native/value-binding.h +46 -28
- package/native/value-layout.h +10 -10
- package/native/values-binding.cc +29 -23
- package/native/vertex-binding.cc +18 -12
- package/native/vertex-buffer-binding.cc +38 -24
- package/native/vertex-storage.h +2 -2
- package/native/view-data.h +4 -3
- package/native/window-binding.cc +75 -45
- package/native/window-event.h +20 -11
- package/native/window-owner.h +15 -12
- package/package.json +43 -50
- package/src/audio/effect-processor.ts +9 -3
- package/src/audio/input-sound-file.ts +108 -36
- package/src/audio/listener.ts +39 -13
- package/src/audio/music.ts +112 -47
- package/src/audio/output-sound-file.ts +40 -11
- package/src/audio/playback-device.ts +23 -8
- package/src/audio/sound-buffer-recorder.ts +35 -13
- package/src/audio/sound-buffer.ts +166 -58
- package/src/audio/sound-file-factory.ts +127 -49
- package/src/audio/sound-file-reader.ts +49 -15
- package/src/audio/sound-recorder.ts +100 -34
- package/src/audio/sound-source.ts +142 -45
- package/src/audio/sound-stream.ts +15 -5
- package/src/audio/sound.ts +12 -4
- package/src/audio/value.ts +89 -26
- package/src/graphics/blend-mode.ts +3 -1
- package/src/graphics/boolean-vector.ts +56 -26
- package/src/graphics/color.ts +3 -1
- package/src/graphics/convex-shape.ts +10 -3
- package/src/graphics/font.ts +171 -50
- package/src/graphics/glsl-matrix.ts +9 -3
- package/src/graphics/glsl.ts +81 -35
- package/src/graphics/glyph.ts +67 -26
- package/src/graphics/image.ts +119 -45
- package/src/graphics/rect.ts +56 -24
- package/src/graphics/render-states.ts +31 -14
- package/src/graphics/render-target.ts +197 -81
- package/src/graphics/render-texture.ts +36 -12
- package/src/graphics/render-window.ts +9 -3
- package/src/graphics/shader.ts +186 -61
- package/src/graphics/shape.ts +93 -35
- package/src/graphics/sprite.ts +64 -25
- package/src/graphics/stencil-mode.ts +12 -6
- package/src/graphics/swap.ts +3 -2
- package/src/graphics/text.ts +229 -74
- package/src/graphics/texture.ts +180 -61
- package/src/graphics/transform.ts +132 -47
- package/src/graphics/transformable.ts +3 -1
- package/src/graphics/vertex-array.ts +87 -35
- package/src/graphics/vertex-buffer.ts +97 -33
- package/src/graphics/vertex.ts +9 -3
- package/src/graphics/view.ts +59 -21
- package/src/index.ts +101 -23
- package/src/internal/audio-codec-registry.ts +18 -6
- package/src/internal/audio-input-stream.ts +6 -2
- package/src/internal/audio-music-pump.ts +116 -41
- package/src/internal/audio-native.ts +249 -96
- package/src/internal/audio-recorder-session.ts +68 -24
- package/src/internal/audio-worker-session.ts +65 -21
- package/src/internal/audio-worker.ts +85 -41
- package/src/internal/glsl-value.ts +26 -11
- package/src/internal/graphics-state.ts +57 -20
- package/src/internal/input-stream.ts +23 -10
- package/src/internal/native.ts +252 -99
- package/src/internal/numeric-properties.ts +2 -1
- package/src/internal/render-states.ts +3 -1
- package/src/internal/scalar.ts +33 -14
- package/src/internal/shaped-glyph.ts +25 -12
- package/src/internal/struct-view.ts +40 -13
- package/src/internal/transformable.ts +3 -1
- package/src/network/common.ts +35 -11
- package/src/network/dns.ts +95 -38
- package/src/network/ftp.ts +129 -47
- package/src/network/http.ts +232 -77
- package/src/network/ip-address.ts +118 -48
- package/src/network/packet.ts +161 -54
- package/src/network/sftp.ts +498 -168
- package/src/network/socket-selector.ts +66 -26
- package/src/network/socket.ts +133 -46
- package/src/network/tcp-listener.ts +78 -29
- package/src/network/tcp-socket.ts +240 -95
- package/src/network/tls-material.ts +6 -2
- package/src/network/udp-socket.ts +147 -53
- package/src/system/angle.ts +3 -1
- package/src/system/clock.ts +12 -4
- package/src/system/err.ts +5 -2
- package/src/system/file-input-stream.ts +12 -4
- package/src/system/input-stream.ts +9 -3
- package/src/system/operators.ts +290 -115
- package/src/system/sleep.ts +6 -2
- package/src/system/time.ts +18 -6
- package/src/system/timeout-with-predicate.ts +19 -8
- package/src/system/vector2.ts +101 -49
- package/src/system/vector3.ts +85 -36
- package/src/window/clipboard.ts +3 -1
- package/src/window/context.ts +15 -5
- package/src/window/cursor.ts +3 -1
- package/src/window/event.ts +26 -12
- package/src/window/mouse.ts +6 -2
- package/src/window/video-mode.ts +3 -1
- package/src/window/window.ts +119 -37
- package/test/native/audio-probes.cc +74 -36
- package/test/native/deferred-delete-probes.cc +17 -11
- package/test/native/drawable-probes.cc +70 -36
- package/test/native/exception-probes.cc +14 -9
- package/test/native/image-probes.cc +20 -10
- package/test/native/matrix-probes.cc +8 -4
- package/test/native/network-oracle.cc +17 -11
- package/test/native/render-texture-probes.cc +33 -24
- package/test/native/shader-probes.cc +9 -9
- package/test/native/shape-probes.cc +37 -23
- package/test/native/sprite-probes.cc +41 -25
- package/test/native/system-probes.cc +58 -35
- package/test/native/text-probes.cc +77 -44
- package/test/native/texture-probes.cc +43 -26
- package/test/native/time-probes.cc +18 -12
- package/test/native/transform-probes.cc +15 -10
- package/test/native/transformable-probes.cc +23 -17
- package/test/native/value-oracle.h +9 -4
- package/test/native/value-probes.cc +31 -23
- package/test/native/vertex-array-probes.cc +22 -14
- package/test/native/vertex-buffer-probes.cc +28 -17
- package/test/native/view-probes.cc +29 -17
- package/test/native/window-probes.cc +66 -33
- package/tools/ensure-sfml.cjs +9 -0
- package/tools/generate-network-constants.cjs +11 -6
- package/tools/generate-window-constants.cjs +31 -12
- package/docs/README.ja.md +0 -30
- package/docs/README.ko.md +0 -30
- package/docs/README.md +0 -30
- package/docs/README.zh-CN.md +0 -30
- package/docs/api.ja.md +0 -84
- package/docs/api.ko.md +0 -84
- package/docs/api.md +0 -81
- package/docs/api.zh-CN.md +0 -81
- package/docs/audio.ja.md +0 -249
- package/docs/audio.ko.md +0 -251
- package/docs/audio.md +0 -252
- package/docs/audio.zh-CN.md +0 -252
- package/docs/concepts.ja.md +0 -130
- package/docs/concepts.ko.md +0 -130
- package/docs/concepts.md +0 -131
- package/docs/concepts.zh-CN.md +0 -131
- package/docs/development.ja.md +0 -148
- package/docs/development.ko.md +0 -148
- package/docs/development.md +0 -150
- package/docs/development.zh-CN.md +0 -150
- package/docs/getting-started.ja.md +0 -154
- package/docs/getting-started.ko.md +0 -154
- package/docs/getting-started.md +0 -156
- package/docs/getting-started.zh-CN.md +0 -156
- package/docs/graphics.ja.md +0 -256
- package/docs/graphics.ko.md +0 -254
- package/docs/graphics.md +0 -255
- package/docs/graphics.zh-CN.md +0 -257
- package/docs/network.ja.md +0 -214
- package/docs/network.ko.md +0 -216
- package/docs/network.md +0 -218
- package/docs/network.zh-CN.md +0 -218
- package/docs/system.ja.md +0 -169
- package/docs/system.ko.md +0 -171
- package/docs/system.md +0 -173
- package/docs/system.zh-CN.md +0 -173
- package/docs/window.ja.md +0 -138
- package/docs/window.ko.md +0 -140
- package/docs/window.md +0 -141
- package/docs/window.zh-CN.md +0 -141
- package/native/exception-boundary.h +0 -97
- package/native/numeric-fields.h +0 -96
- package/native/shared-handle.h +0 -69
- package/test/tsconfig.json +0 -8
- package/tools/configure-lsp.cjs +0 -23
- package/tools/lib_downloader.cjs +0 -92
- package/tools/lib_downloader_urls.cjs +0 -23
package/src/window/event.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Vector2, Vector2i, Vector2u } from '../system/vector2';
|
|
2
2
|
import { Vector3, Vector3f } from '../system/vector3';
|
|
3
3
|
import type {
|
|
4
|
-
KeyboardKey,
|
|
5
|
-
|
|
4
|
+
KeyboardKey,
|
|
5
|
+
KeyboardScancode,
|
|
6
|
+
MouseButton,
|
|
7
|
+
MouseWheel,
|
|
8
|
+
JoystickAxis,
|
|
9
|
+
SensorType,
|
|
6
10
|
} from './gen/constants';
|
|
7
11
|
|
|
8
12
|
interface KeyEvent {
|
|
@@ -502,10 +506,12 @@ export class Event<K extends EventKind = EventKind> {
|
|
|
502
506
|
for (const key of Object.keys(copy)) {
|
|
503
507
|
const value = (copy as Record<string, unknown>)[key];
|
|
504
508
|
if (value instanceof Vector2 || value instanceof Vector3) {
|
|
505
|
-
(copy as Record<string, unknown>)[key] =
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
:
|
|
509
|
+
(copy as Record<string, unknown>)[key] =
|
|
510
|
+
value instanceof Vector3
|
|
511
|
+
? new Vector3f(value as Vector3f)
|
|
512
|
+
: value.scalarType === 'u32'
|
|
513
|
+
? new Vector2u(value as Vector2u)
|
|
514
|
+
: new Vector2i(value as Vector2i);
|
|
509
515
|
}
|
|
510
516
|
}
|
|
511
517
|
this.data = copy;
|
|
@@ -538,7 +544,7 @@ export class Event<K extends EventKind = EventKind> {
|
|
|
538
544
|
* @ko 종류가 일치하면 데이터를, 그렇지 않으면 undefined를 반환한다.
|
|
539
545
|
*/
|
|
540
546
|
getIf<P extends EventKind>(kind: P): EventData<P> | undefined {
|
|
541
|
-
return this.is(kind) ? this.data as EventData<P> : undefined;
|
|
547
|
+
return this.is(kind) ? (this.data as EventData<P>) : undefined;
|
|
542
548
|
}
|
|
543
549
|
|
|
544
550
|
/**
|
|
@@ -554,8 +560,10 @@ export class Event<K extends EventKind = EventKind> {
|
|
|
554
560
|
|
|
555
561
|
type NativeFields<T> = {
|
|
556
562
|
[K in keyof T]: T[K] extends Vector2<'i32' | 'u32'>
|
|
557
|
-
? [number, number]
|
|
558
|
-
|
|
563
|
+
? [number, number]
|
|
564
|
+
: T[K] extends Vector3f
|
|
565
|
+
? [number, number, number]
|
|
566
|
+
: T[K];
|
|
559
567
|
};
|
|
560
568
|
export type NativeWindowEvent = {
|
|
561
569
|
[K in EventKind]: NativeFields<EventData<K>>;
|
|
@@ -564,10 +572,16 @@ export type NativeWindowEvent = {
|
|
|
564
572
|
export function windowEvent(raw: NativeWindowEvent): Event {
|
|
565
573
|
const data = { ...raw } as unknown as EventData;
|
|
566
574
|
if (data.kind === 'Resized') {
|
|
567
|
-
data.size = new Vector2u(
|
|
575
|
+
data.size = new Vector2u(
|
|
576
|
+
...(raw as NativeFields<EventData<'Resized'>>).size,
|
|
577
|
+
);
|
|
568
578
|
}
|
|
569
|
-
if (
|
|
570
|
-
|
|
579
|
+
if (
|
|
580
|
+
'position' in data &&
|
|
581
|
+
'position' in raw &&
|
|
582
|
+
Array.isArray(raw.position)
|
|
583
|
+
) {
|
|
584
|
+
data.position = new Vector2i(...(raw.position as [number, number]));
|
|
571
585
|
}
|
|
572
586
|
if (data.kind === 'MouseMovedRaw' && raw.kind === 'MouseMovedRaw') {
|
|
573
587
|
data.delta = new Vector2i(...raw.delta);
|
package/src/window/mouse.ts
CHANGED
|
@@ -11,8 +11,12 @@ export {
|
|
|
11
11
|
function windowHandle(
|
|
12
12
|
window?: Window,
|
|
13
13
|
): NativeGraphicsHandle<'window'> | undefined {
|
|
14
|
-
if (window === undefined)
|
|
15
|
-
|
|
14
|
+
if (window === undefined) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
if (!(window instanceof Window)) {
|
|
18
|
+
throw new TypeError('Expected a Window');
|
|
19
|
+
}
|
|
16
20
|
return window[graphicsNative];
|
|
17
21
|
}
|
|
18
22
|
|
package/src/window/video-mode.ts
CHANGED
|
@@ -60,7 +60,9 @@ export class VideoMode {
|
|
|
60
60
|
) {
|
|
61
61
|
const size = source instanceof VideoMode ? source.size
|
|
62
62
|
: source as Readonly<Vector2u> | undefined;
|
|
63
|
-
if (size !== undefined)
|
|
63
|
+
if (size !== undefined) {
|
|
64
|
+
windowSize(size, false);
|
|
65
|
+
}
|
|
64
66
|
this.sizeValue = size === undefined ? new Vector2u() : new Vector2u(size);
|
|
65
67
|
numericProperties(this, { bitsPerPixel: 0 });
|
|
66
68
|
this.bitsPerPixel = source instanceof VideoMode
|
package/src/window/window.ts
CHANGED
|
@@ -4,13 +4,18 @@ import { Vector2, Vector2i, Vector2u } from '../system/vector2';
|
|
|
4
4
|
import { Time } from '../system/time';
|
|
5
5
|
import type { ReadonlyValue } from '../internal/value-storage';
|
|
6
6
|
import {
|
|
7
|
-
contextSettings,
|
|
7
|
+
contextSettings,
|
|
8
|
+
settingsFromBuffer,
|
|
9
|
+
type ContextSettings,
|
|
8
10
|
} from './context-settings';
|
|
9
11
|
import { Style, State } from './gen/constants';
|
|
10
12
|
import { VideoMode, windowSize, unsigned } from './video-mode';
|
|
11
13
|
import { Cursor, rgbaPixels } from './cursor';
|
|
12
14
|
import {
|
|
13
|
-
Event,
|
|
15
|
+
Event,
|
|
16
|
+
windowEvent,
|
|
17
|
+
type EventHandlers,
|
|
18
|
+
type EventVisitor,
|
|
14
19
|
} from './event';
|
|
15
20
|
|
|
16
21
|
/**
|
|
@@ -62,7 +67,10 @@ const mixedWindows = new WeakSet<object>();
|
|
|
62
67
|
* @ko 윈도우 훅은 약한 키로만 유지하여 Native가 역참조로 JS 객체를 유지하지
|
|
63
68
|
* 않도록 한다.
|
|
64
69
|
*/
|
|
65
|
-
const windowHooks = new WeakMap<
|
|
70
|
+
const windowHooks = new WeakMap<
|
|
71
|
+
Window,
|
|
72
|
+
readonly [() => void, () => void]
|
|
73
|
+
>();
|
|
66
74
|
|
|
67
75
|
/**
|
|
68
76
|
* Register dynamic hooks after construction, allowing render windows to
|
|
@@ -74,7 +82,9 @@ const windowHooks = new WeakMap<Window, readonly [() => void, () => void]>();
|
|
|
74
82
|
* 초기화할 수 있게 한다.
|
|
75
83
|
*/
|
|
76
84
|
export function registerWindowHooks(
|
|
77
|
-
window: Window,
|
|
85
|
+
window: Window,
|
|
86
|
+
onCreate: () => void,
|
|
87
|
+
onResize: () => void,
|
|
78
88
|
): void {
|
|
79
89
|
windowHooks.set(window, [ onCreate, onResize ]);
|
|
80
90
|
}
|
|
@@ -90,8 +100,11 @@ export function registerWindowHooks(
|
|
|
90
100
|
*/
|
|
91
101
|
function dispatchWindowHooks(window: Window): void {
|
|
92
102
|
let notification: 'create' | 'resize' | undefined;
|
|
93
|
-
while (
|
|
94
|
-
native.takeWindowNotification(
|
|
103
|
+
while (
|
|
104
|
+
(notification = native.takeWindowNotification(
|
|
105
|
+
window[graphicsNative],
|
|
106
|
+
)) !== undefined
|
|
107
|
+
) {
|
|
95
108
|
windowHooks.get(window)?.[notification === 'create' ? 0 : 1]();
|
|
96
109
|
}
|
|
97
110
|
}
|
|
@@ -110,9 +123,13 @@ export class Window {
|
|
|
110
123
|
readonly [graphicsNative]: NativeGraphicsHandle<'window'>;
|
|
111
124
|
|
|
112
125
|
static [Symbol.hasInstance](value: unknown): boolean {
|
|
113
|
-
return
|
|
114
|
-
(this
|
|
115
|
-
|
|
126
|
+
return (
|
|
127
|
+
Function.prototype[Symbol.hasInstance].call(this, value) ||
|
|
128
|
+
(this === Window &&
|
|
129
|
+
typeof value === 'object' &&
|
|
130
|
+
value !== null &&
|
|
131
|
+
mixedWindows.has(value))
|
|
132
|
+
);
|
|
116
133
|
}
|
|
117
134
|
|
|
118
135
|
/**
|
|
@@ -129,7 +146,8 @@ export class Window {
|
|
|
129
146
|
* @ko 픽셀 크기, 제목, 설정을 지정하여 윈도우를 연다.
|
|
130
147
|
*/
|
|
131
148
|
constructor(
|
|
132
|
-
mode: Readonly<VideoMode> | Readonly<Vector2u>,
|
|
149
|
+
mode: Readonly<VideoMode> | Readonly<Vector2u>,
|
|
150
|
+
title: string,
|
|
133
151
|
options?: Readonly<WindowOptions>,
|
|
134
152
|
);
|
|
135
153
|
/**
|
|
@@ -150,7 +168,11 @@ export class Window {
|
|
|
150
168
|
} else if (mode !== undefined) {
|
|
151
169
|
Window.prototype.create.bind(this)(mode, title as string, options);
|
|
152
170
|
}
|
|
153
|
-
registerWindowHooks(
|
|
171
|
+
registerWindowHooks(
|
|
172
|
+
this,
|
|
173
|
+
() => this.onCreate(),
|
|
174
|
+
() => this.onResize(),
|
|
175
|
+
);
|
|
154
176
|
}
|
|
155
177
|
|
|
156
178
|
/**
|
|
@@ -182,7 +204,8 @@ export class Window {
|
|
|
182
204
|
* @ko 윈도우를 열거나 다시 생성한다. mode는 픽셀 크기 또는 전체 비디오 모드이다.
|
|
183
205
|
*/
|
|
184
206
|
create(
|
|
185
|
-
mode: Readonly<VideoMode> | Readonly<Vector2u>,
|
|
207
|
+
mode: Readonly<VideoMode> | Readonly<Vector2u>,
|
|
208
|
+
title: string,
|
|
186
209
|
options?: Readonly<WindowOptions>,
|
|
187
210
|
): void;
|
|
188
211
|
/**
|
|
@@ -198,17 +221,23 @@ export class Window {
|
|
|
198
221
|
options: Readonly<WindowOptions> = {},
|
|
199
222
|
): void {
|
|
200
223
|
if (typeof mode === 'bigint') {
|
|
201
|
-
native.openWindowHandle(
|
|
202
|
-
|
|
224
|
+
native.openWindowHandle(
|
|
225
|
+
this[graphicsNative],
|
|
226
|
+
mode,
|
|
227
|
+
contextSettings((title as ContextSettings) ?? {}),
|
|
228
|
+
);
|
|
203
229
|
dispatchWindowHooks(this);
|
|
204
230
|
return;
|
|
205
231
|
}
|
|
206
|
-
const size = mode instanceof VideoMode ? mode.size : mode as Vector2u;
|
|
232
|
+
const size = mode instanceof VideoMode ? mode.size : (mode as Vector2u);
|
|
207
233
|
const bits = mode instanceof VideoMode ? mode.bitsPerPixel : 32;
|
|
208
234
|
windowSize(size);
|
|
209
235
|
unsigned(bits);
|
|
210
|
-
const {
|
|
211
|
-
|
|
236
|
+
const {
|
|
237
|
+
style = Style.Default,
|
|
238
|
+
state = State.Windowed,
|
|
239
|
+
settings = {},
|
|
240
|
+
} = options;
|
|
212
241
|
unsigned(style);
|
|
213
242
|
// eslint-disable-next-line no-bitwise
|
|
214
243
|
if ((style & ~Style.Default) !== 0) {
|
|
@@ -217,8 +246,16 @@ export class Window {
|
|
|
217
246
|
if (state !== State.Windowed && state !== State.Fullscreen) {
|
|
218
247
|
throw new RangeError('Unknown window state');
|
|
219
248
|
}
|
|
220
|
-
native.openWindow(
|
|
221
|
-
|
|
249
|
+
native.openWindow(
|
|
250
|
+
this[graphicsNative],
|
|
251
|
+
size.x,
|
|
252
|
+
size.y,
|
|
253
|
+
title as string,
|
|
254
|
+
bits,
|
|
255
|
+
style,
|
|
256
|
+
state,
|
|
257
|
+
contextSettings(settings),
|
|
258
|
+
);
|
|
222
259
|
dispatchWindowHooks(this);
|
|
223
260
|
}
|
|
224
261
|
|
|
@@ -273,7 +310,12 @@ export class Window {
|
|
|
273
310
|
if (!(position instanceof Vector2) || position.scalarType !== 'i32') {
|
|
274
311
|
throw new TypeError('Expected a Vector2i');
|
|
275
312
|
}
|
|
276
|
-
native.windowCommand(
|
|
313
|
+
native.windowCommand(
|
|
314
|
+
this[graphicsNative],
|
|
315
|
+
'position',
|
|
316
|
+
position.x,
|
|
317
|
+
position.y,
|
|
318
|
+
);
|
|
277
319
|
}
|
|
278
320
|
|
|
279
321
|
/**
|
|
@@ -296,8 +338,15 @@ export class Window {
|
|
|
296
338
|
* @ko 클라이언트 영역의 최소 픽셀 크기를 설정한다. undefined는 제한을 해제한다.
|
|
297
339
|
*/
|
|
298
340
|
setMinimumSize(size: Readonly<Vector2u> | undefined): void {
|
|
299
|
-
if (size !== undefined)
|
|
300
|
-
|
|
341
|
+
if (size !== undefined) {
|
|
342
|
+
windowSize(size);
|
|
343
|
+
}
|
|
344
|
+
native.windowCommand(
|
|
345
|
+
this[graphicsNative],
|
|
346
|
+
'minimumSize',
|
|
347
|
+
size?.x,
|
|
348
|
+
size?.y,
|
|
349
|
+
);
|
|
301
350
|
dispatchWindowHooks(this);
|
|
302
351
|
}
|
|
303
352
|
|
|
@@ -309,8 +358,15 @@ export class Window {
|
|
|
309
358
|
* @ko 클라이언트 영역의 최대 픽셀 크기를 설정한다. undefined는 제한을 해제한다.
|
|
310
359
|
*/
|
|
311
360
|
setMaximumSize(size: Readonly<Vector2u> | undefined): void {
|
|
312
|
-
if (size !== undefined)
|
|
313
|
-
|
|
361
|
+
if (size !== undefined) {
|
|
362
|
+
windowSize(size);
|
|
363
|
+
}
|
|
364
|
+
native.windowCommand(
|
|
365
|
+
this[graphicsNative],
|
|
366
|
+
'maximumSize',
|
|
367
|
+
size?.x,
|
|
368
|
+
size?.y,
|
|
369
|
+
);
|
|
314
370
|
dispatchWindowHooks(this);
|
|
315
371
|
}
|
|
316
372
|
|
|
@@ -378,7 +434,9 @@ export class Window {
|
|
|
378
434
|
* @ko 윈도우 안에서 사용할 커서를 설정한다.
|
|
379
435
|
*/
|
|
380
436
|
setMouseCursor(cursor: Cursor): void {
|
|
381
|
-
if (!(cursor instanceof Cursor))
|
|
437
|
+
if (!(cursor instanceof Cursor)) {
|
|
438
|
+
throw new TypeError('Expected a Cursor');
|
|
439
|
+
}
|
|
382
440
|
native.setWindowCursor(this[graphicsNative], cursor[graphicsNative]);
|
|
383
441
|
}
|
|
384
442
|
|
|
@@ -402,7 +460,11 @@ export class Window {
|
|
|
402
460
|
if (!Number.isFinite(threshold) || threshold < 0 || threshold > 100) {
|
|
403
461
|
throw new RangeError('Joystick threshold must be from 0 to 100');
|
|
404
462
|
}
|
|
405
|
-
native.windowCommand(
|
|
463
|
+
native.windowCommand(
|
|
464
|
+
this[graphicsNative],
|
|
465
|
+
'joystickThreshold',
|
|
466
|
+
threshold,
|
|
467
|
+
);
|
|
406
468
|
}
|
|
407
469
|
|
|
408
470
|
/**
|
|
@@ -444,9 +506,15 @@ export class Window {
|
|
|
444
506
|
* @ja 作成した VkSurfaceKHR を返す。作成に失敗した場合は undefined。
|
|
445
507
|
* @ko 생성한 VkSurfaceKHR를 반환한다. 생성 실패 시 undefined를 반환한다.
|
|
446
508
|
*/
|
|
447
|
-
createVulkanSurface(
|
|
509
|
+
createVulkanSurface(
|
|
510
|
+
instance: bigint,
|
|
511
|
+
allocator = 0n,
|
|
512
|
+
): bigint | undefined {
|
|
448
513
|
return native.createWindowVulkanSurface(
|
|
449
|
-
this[graphicsNative],
|
|
514
|
+
this[graphicsNative],
|
|
515
|
+
instance,
|
|
516
|
+
allocator,
|
|
517
|
+
);
|
|
450
518
|
}
|
|
451
519
|
|
|
452
520
|
/**
|
|
@@ -457,7 +525,9 @@ export class Window {
|
|
|
457
525
|
* @ko 실제 생성된 OpenGL 컨텍스트 설정을 반환한다. 요청한 값과 다를 수 있다.
|
|
458
526
|
*/
|
|
459
527
|
getSettings(): Readonly<Required<ContextSettings>> {
|
|
460
|
-
return settingsFromBuffer(
|
|
528
|
+
return settingsFromBuffer(
|
|
529
|
+
native.getWindowSettings(this[graphicsNative]),
|
|
530
|
+
);
|
|
461
531
|
}
|
|
462
532
|
|
|
463
533
|
/**
|
|
@@ -504,9 +574,13 @@ export class Window {
|
|
|
504
574
|
* @ko SFML처럼 호출 스레드를 블로킹한다. Time.Zero는 무기한 대기한다.
|
|
505
575
|
*/
|
|
506
576
|
waitEvent(timeout: ReadonlyValue<Time> = Time.Zero): Event | undefined {
|
|
507
|
-
if (!(timeout instanceof Time))
|
|
577
|
+
if (!(timeout instanceof Time)) {
|
|
578
|
+
throw new TypeError('Expected a Time');
|
|
579
|
+
}
|
|
508
580
|
const raw = native.waitWindowEvent(
|
|
509
|
-
this[graphicsNative],
|
|
581
|
+
this[graphicsNative],
|
|
582
|
+
timeout.asMicroseconds(),
|
|
583
|
+
);
|
|
510
584
|
dispatchWindowHooks(this);
|
|
511
585
|
return raw === undefined ? undefined : windowEvent(raw);
|
|
512
586
|
}
|
|
@@ -527,12 +601,15 @@ export class Window {
|
|
|
527
601
|
*/
|
|
528
602
|
handleEvents(visitor: EventVisitor): void;
|
|
529
603
|
handleEvents(
|
|
530
|
-
handlers: EventHandlers | EventVisitor,
|
|
604
|
+
handlers: EventHandlers | EventVisitor,
|
|
605
|
+
fallback?: EventVisitor,
|
|
531
606
|
): void {
|
|
532
607
|
let event: Event | undefined;
|
|
533
608
|
while ((event = this.pollEvent()) !== undefined) {
|
|
534
|
-
const handler =
|
|
535
|
-
|
|
609
|
+
const handler =
|
|
610
|
+
typeof handlers === 'function'
|
|
611
|
+
? handlers
|
|
612
|
+
: (handlers[event.kind] as EventVisitor | undefined);
|
|
536
613
|
(handler ?? fallback)?.(event.data);
|
|
537
614
|
}
|
|
538
615
|
}
|
|
@@ -572,8 +649,13 @@ export class Window {
|
|
|
572
649
|
*/
|
|
573
650
|
export function installWindowMethods(prototype: object): void {
|
|
574
651
|
for (const key of Reflect.ownKeys(Window.prototype)) {
|
|
575
|
-
if (key === 'constructor' || key in prototype)
|
|
576
|
-
|
|
577
|
-
|
|
652
|
+
if (key === 'constructor' || key in prototype) {
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
Object.defineProperty(
|
|
656
|
+
prototype,
|
|
657
|
+
key,
|
|
658
|
+
Object.getOwnPropertyDescriptor(Window.prototype, key)!,
|
|
659
|
+
);
|
|
578
660
|
}
|
|
579
661
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
#include "../../native/audio-worker.h"
|
|
2
1
|
#include "../../native/audio-recorder.h"
|
|
2
|
+
#include "../../native/audio-worker.h"
|
|
3
3
|
|
|
4
|
+
namespace sfmljs::audio {
|
|
4
5
|
namespace {
|
|
5
|
-
using namespace sfmljs;
|
|
6
|
-
using namespace sfmljs::audio;
|
|
7
6
|
|
|
8
7
|
NAN_METHOD(AudioSourceOracle) {
|
|
9
8
|
auto* handle = SourceHandle::From(info[0]);
|
|
@@ -18,17 +17,30 @@ NAN_METHOD(AudioSourceOracle) {
|
|
|
18
17
|
const auto direction = sound.getDirection();
|
|
19
18
|
const auto velocity = sound.getVelocity();
|
|
20
19
|
const std::array<float, 24> values{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
sound.getPitch(),
|
|
21
|
+
sound.getPan(),
|
|
22
|
+
sound.getVolume(),
|
|
23
|
+
static_cast<float>(sound.isSpatializationEnabled()),
|
|
24
|
+
position.x,
|
|
25
|
+
position.y,
|
|
26
|
+
position.z,
|
|
27
|
+
direction.x,
|
|
28
|
+
direction.y,
|
|
29
|
+
direction.z,
|
|
30
|
+
cone.innerAngle.asRadians(),
|
|
31
|
+
cone.outerAngle.asRadians(),
|
|
32
|
+
cone.outerGain,
|
|
33
|
+
velocity.x,
|
|
34
|
+
velocity.y,
|
|
35
|
+
velocity.z,
|
|
36
|
+
sound.getDopplerFactor(),
|
|
37
|
+
sound.getDirectionalAttenuationFactor(),
|
|
38
|
+
static_cast<float>(sound.isRelativeToListener()),
|
|
39
|
+
sound.getMinDistance(),
|
|
40
|
+
sound.getMaxDistance(),
|
|
41
|
+
sound.getMinGain(),
|
|
42
|
+
sound.getMaxGain(),
|
|
43
|
+
sound.getAttenuation()};
|
|
32
44
|
auto result = Nan::New<v8::Array>(values.size());
|
|
33
45
|
for (unsigned i = 0; i < values.size(); ++i) {
|
|
34
46
|
Nan::Set(result, i, Nan::New(values[i])).FromJust();
|
|
@@ -42,7 +54,8 @@ NAN_METHOD(AudioBufferAliases) {
|
|
|
42
54
|
if (!handle || !ReadBytes(info[1], samples, true)) return;
|
|
43
55
|
const auto& buffer = handle->owner()->current->buffer;
|
|
44
56
|
info.GetReturnValue().Set(buffer.getSamples() == samples.data &&
|
|
45
|
-
|
|
57
|
+
buffer.getSampleCount() * sizeof(std::int16_t) ==
|
|
58
|
+
samples.size);
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
NAN_METHOD(AudioSoundBufferMatches) {
|
|
@@ -51,8 +64,8 @@ NAN_METHOD(AudioSoundBufferMatches) {
|
|
|
51
64
|
if (!source || !buffer) return;
|
|
52
65
|
const auto* sound = source->owner()->AsSound();
|
|
53
66
|
if (!sound) return Nan::ThrowTypeError("Expected a Sound");
|
|
54
|
-
info.GetReturnValue().Set(
|
|
55
|
-
|
|
67
|
+
info.GetReturnValue().Set(&sound->getBuffer() ==
|
|
68
|
+
&buffer->owner()->current->buffer);
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
NAN_METHOD(AudioAssignmentState) {
|
|
@@ -62,12 +75,17 @@ NAN_METHOD(AudioAssignmentState) {
|
|
|
62
75
|
auto result = Nan::New<v8::Object>();
|
|
63
76
|
const auto pointer = [&](const void* value) {
|
|
64
77
|
return v8::BigInt::NewFromUnsigned(info.GetIsolate(),
|
|
65
|
-
|
|
78
|
+
reinterpret_cast<std::uintptr_t>(value));
|
|
66
79
|
};
|
|
67
80
|
Set(result, "sound", pointer(source->sound.get()));
|
|
68
81
|
Set(result, "effect", pointer(source->effect.get()));
|
|
69
|
-
Set(result,
|
|
70
|
-
|
|
82
|
+
Set(result,
|
|
83
|
+
"generation",
|
|
84
|
+
v8::BigInt::NewFromUnsigned(
|
|
85
|
+
info.GetIsolate(),
|
|
86
|
+
source->effect
|
|
87
|
+
? source->effect->generation.load(std::memory_order_acquire)
|
|
88
|
+
: 0));
|
|
71
89
|
info.GetReturnValue().Set(result);
|
|
72
90
|
}
|
|
73
91
|
|
|
@@ -75,7 +93,8 @@ NAN_METHOD(CreateAudioQueueProbe) {
|
|
|
75
93
|
unsigned kind, frames, channels, rate, slots;
|
|
76
94
|
if (!Unsigned(info[0], kind) || !Unsigned(info[1], frames) ||
|
|
77
95
|
!Unsigned(info[2], channels) || !Unsigned(info[3], rate) ||
|
|
78
|
-
!Unsigned(info[4], slots))
|
|
96
|
+
!Unsigned(info[4], slots))
|
|
97
|
+
return;
|
|
79
98
|
auto state = CreateWorkerState(kind, frames, channels, rate, slots);
|
|
80
99
|
state->running = true;
|
|
81
100
|
auto result = Nan::New<v8::Object>();
|
|
@@ -90,15 +109,18 @@ NAN_METHOD(PrepareAudioRecorderProbe) {
|
|
|
90
109
|
auto* handle = RecorderHandle::From(info[0]);
|
|
91
110
|
unsigned rate, frames, slots;
|
|
92
111
|
if (!handle || !Unsigned(info[1], rate) || !Unsigned(info[2], frames) ||
|
|
93
|
-
!Unsigned(info[3], slots))
|
|
112
|
+
!Unsigned(info[3], slots))
|
|
113
|
+
return;
|
|
94
114
|
auto recorder = handle->owner();
|
|
95
115
|
if (recorder->active) return Nan::ThrowError("Recorder is already running");
|
|
96
116
|
if (!rate) return Nan::ThrowRangeError("Sample rate must be positive");
|
|
97
117
|
recorder->callbackRecorder = recorder->bufferRecorder && info[4]->IsTrue();
|
|
98
118
|
recorder->values[0] = rate;
|
|
99
119
|
recorder->current.reset();
|
|
100
|
-
recorder->worker =
|
|
101
|
-
|
|
120
|
+
recorder->worker =
|
|
121
|
+
recorder->bufferRecorder && !recorder->callbackRecorder
|
|
122
|
+
? nullptr
|
|
123
|
+
: CreateWorkerState(1, frames, recorder->values[1], rate, slots);
|
|
102
124
|
auto result = Nan::New<v8::Object>();
|
|
103
125
|
if (recorder->worker) {
|
|
104
126
|
recorder->worker->running.store(true, std::memory_order_release);
|
|
@@ -126,12 +148,17 @@ NAN_METHOD(AudioQueueProbe) {
|
|
|
126
148
|
sf::SoundStream::Chunk chunk;
|
|
127
149
|
const bool more = state->Stream(chunk);
|
|
128
150
|
auto samples = std::make_shared<std::vector<std::int16_t>>();
|
|
129
|
-
if (chunk.sampleCount)
|
|
151
|
+
if (chunk.sampleCount)
|
|
152
|
+
samples->assign(chunk.samples, chunk.samples + chunk.sampleCount);
|
|
130
153
|
auto result = Nan::New<v8::Object>();
|
|
131
154
|
Set(result, "more", Nan::New(more));
|
|
132
|
-
Set(result,
|
|
133
|
-
|
|
134
|
-
|
|
155
|
+
Set(result,
|
|
156
|
+
"samples",
|
|
157
|
+
samples->empty() ? v8::ArrayBuffer::New(info.GetIsolate(), 0)
|
|
158
|
+
: MapShared(info.GetIsolate(),
|
|
159
|
+
samples,
|
|
160
|
+
samples->data(),
|
|
161
|
+
samples->size() * 2));
|
|
135
162
|
info.GetReturnValue().Set(result);
|
|
136
163
|
} else if (command == 1) {
|
|
137
164
|
Bytes samples;
|
|
@@ -146,11 +173,14 @@ NAN_METHOD(AudioQueueProbe) {
|
|
|
146
173
|
float* input = nullptr;
|
|
147
174
|
unsigned inFrames{};
|
|
148
175
|
if (!info[2]->IsNull()) {
|
|
149
|
-
if (!info[2]->IsFloat32Array())
|
|
176
|
+
if (!info[2]->IsFloat32Array())
|
|
177
|
+
return Nan::ThrowTypeError("Expected float samples");
|
|
150
178
|
auto view = info[2].As<v8::Float32Array>();
|
|
151
|
-
if (view->Buffer()->WasDetached())
|
|
179
|
+
if (view->Buffer()->WasDetached())
|
|
180
|
+
return Nan::ThrowTypeError("Detached samples");
|
|
152
181
|
input = reinterpret_cast<float*>(
|
|
153
|
-
static_cast<std::byte*>(view->Buffer()->GetBackingStore()->Data()) +
|
|
182
|
+
static_cast<std::byte*>(view->Buffer()->GetBackingStore()->Data()) +
|
|
183
|
+
view->ByteOffset());
|
|
154
184
|
inFrames = static_cast<unsigned>(view->Length() / channels);
|
|
155
185
|
}
|
|
156
186
|
auto output = std::make_shared<std::vector<float>>(outFrames * channels);
|
|
@@ -158,16 +188,22 @@ NAN_METHOD(AudioQueueProbe) {
|
|
|
158
188
|
auto result = Nan::New<v8::Object>();
|
|
159
189
|
Set(result, "inputFrames", Nan::New(inFrames));
|
|
160
190
|
Set(result, "outputFrames", Nan::New(outFrames));
|
|
161
|
-
Set(result,
|
|
191
|
+
Set(result,
|
|
192
|
+
"samples",
|
|
193
|
+
MapShared(
|
|
194
|
+
info.GetIsolate(), output, output->data(), output->size() * 4));
|
|
162
195
|
info.GetReturnValue().Set(result);
|
|
163
196
|
} else if (command == 3) {
|
|
164
|
-
if (!info[2]->IsBigInt())
|
|
197
|
+
if (!info[2]->IsBigInt())
|
|
198
|
+
return Nan::ThrowTypeError("Expected seek microseconds");
|
|
165
199
|
state->Seek(info[2].As<v8::BigInt>()->Int64Value());
|
|
166
200
|
} else if (command == 4) {
|
|
167
201
|
state->running.store(false, std::memory_order_release);
|
|
168
|
-
} else
|
|
169
|
-
|
|
202
|
+
} else {
|
|
203
|
+
return Nan::ThrowRangeError("Unknown audio probe command");
|
|
204
|
+
}
|
|
170
205
|
}
|
|
206
|
+
} // namespace
|
|
171
207
|
|
|
172
208
|
NAN_MODULE_INIT(InitializeAudioProbes) {
|
|
173
209
|
sfmljs::SetMethod<AudioSourceOracle>(target, "audioSourceOracle");
|
|
@@ -175,7 +211,9 @@ NAN_MODULE_INIT(InitializeAudioProbes) {
|
|
|
175
211
|
sfmljs::SetMethod<AudioSoundBufferMatches>(target, "audioSoundBufferMatches");
|
|
176
212
|
sfmljs::SetMethod<AudioAssignmentState>(target, "audioAssignmentState");
|
|
177
213
|
sfmljs::SetMethod<CreateAudioQueueProbe>(target, "createAudioQueueProbe");
|
|
178
|
-
sfmljs::SetMethod<PrepareAudioRecorderProbe>(target,
|
|
214
|
+
sfmljs::SetMethod<PrepareAudioRecorderProbe>(target,
|
|
215
|
+
"prepareAudioRecorderProbe");
|
|
179
216
|
sfmljs::SetMethod<StartAudioRecorderProbe>(target, "startAudioRecorderProbe");
|
|
180
217
|
sfmljs::SetMethod<AudioQueueProbe>(target, "audioQueueProbe");
|
|
181
218
|
}
|
|
219
|
+
} // namespace sfmljs::audio
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#include "../../native/deferred-delete.h"
|
|
2
|
-
#include "../../native/shared-handle.h"
|
|
3
|
-
|
|
4
1
|
#include <atomic>
|
|
5
|
-
#include <thread>
|
|
2
|
+
#include <thread> // NOLINT(build/c++11)
|
|
3
|
+
|
|
4
|
+
#include "../../native/deferred-delete.h"
|
|
5
|
+
#include "shared-handle.h"
|
|
6
6
|
|
|
7
7
|
namespace {
|
|
8
8
|
struct Observation {
|
|
@@ -27,11 +27,15 @@ NAN_METHOD(CreateDeletionProbe) {
|
|
|
27
27
|
auto observation = std::make_shared<Observation>();
|
|
28
28
|
auto owner = sfmljs::MakeThreadOwned<Resource>(observation);
|
|
29
29
|
auto result = Nan::New<v8::Object>();
|
|
30
|
-
Nan::Set(result,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
Nan::Set(result,
|
|
31
|
+
Nan::New("observation").ToLocalChecked(),
|
|
32
|
+
ObservationHandle::Create(observation))
|
|
33
|
+
.FromJust();
|
|
34
|
+
Nan::Set(result,
|
|
35
|
+
Nan::New("buffer").ToLocalChecked(),
|
|
36
|
+
sfmljs::MapShared(
|
|
37
|
+
info.GetIsolate(), owner, &owner->value, sizeof(owner->value)))
|
|
38
|
+
.FromJust();
|
|
35
39
|
info.GetReturnValue().Set(result);
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -49,8 +53,10 @@ NAN_METHOD(ReadDeletionProbe) {
|
|
|
49
53
|
auto* observation = ObservationHandle::From(info[0]);
|
|
50
54
|
if (!observation) return;
|
|
51
55
|
auto result = Nan::New<v8::Array>(2);
|
|
52
|
-
Nan::Set(result, 0, Nan::New(observation->owner()->destroyed.load()))
|
|
53
|
-
|
|
56
|
+
Nan::Set(result, 0, Nan::New(observation->owner()->destroyed.load()))
|
|
57
|
+
.FromJust();
|
|
58
|
+
Nan::Set(result, 1, Nan::New(observation->owner()->wrongThread.load()))
|
|
59
|
+
.FromJust();
|
|
54
60
|
info.GetReturnValue().Set(result);
|
|
55
61
|
}
|
|
56
62
|
} // namespace
|