sfml.js 1.0.0 → 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 +10 -9
- package/README.ko.md +10 -9
- package/README.md +10 -9
- package/README.zh-CN.md +10 -9
- 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 +40 -48
- 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 -144
- package/docs/development.ko.md +0 -144
- package/docs/development.md +0 -146
- package/docs/development.zh-CN.md +0 -146
- 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 -107
- 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
|
@@ -2,18 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.streamDispatch = void 0;
|
|
4
4
|
const error_1 = require("../system/error");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Keep the stream alive until native decoding and every pending read finish.
|
|
7
|
+
*/
|
|
6
8
|
function streamDispatch(stream, onError) {
|
|
7
|
-
if (!stream ||
|
|
9
|
+
if (!stream ||
|
|
10
|
+
['read', 'seek', 'tell', 'getSize'].some(key => typeof stream[key] !== 'function')) {
|
|
8
11
|
throw new TypeError('Expected an InputStream');
|
|
12
|
+
}
|
|
9
13
|
return (operation, data, position, complete) => {
|
|
10
14
|
const execute = async () => {
|
|
11
15
|
switch (operation) {
|
|
12
|
-
case 0:
|
|
13
|
-
|
|
14
|
-
case
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
case 0:
|
|
17
|
+
return await stream.read(data);
|
|
18
|
+
case 1:
|
|
19
|
+
return await stream.seek(position);
|
|
20
|
+
case 2:
|
|
21
|
+
return await stream.tell();
|
|
22
|
+
case 3:
|
|
23
|
+
return await stream.getSize();
|
|
24
|
+
default:
|
|
25
|
+
throw new error_1.SFMLError('Unknown stream operation');
|
|
17
26
|
}
|
|
18
27
|
};
|
|
19
28
|
void execute().then(result => complete(null, result), error => {
|
|
@@ -5,7 +5,8 @@ const storage = Symbol('NumericProperties.storage');
|
|
|
5
5
|
/** Numeric JS value fields share one allocation until copied into a draw. */
|
|
6
6
|
function numericProperties(target, defaults) {
|
|
7
7
|
// Float64 preserves invalid numbers until the existing API validation point.
|
|
8
|
-
// In particular, Uint32 coercion must not turn NaN/fractions
|
|
8
|
+
// In particular, Uint32 coercion must not turn NaN/fractions
|
|
9
|
+
// into valid enums.
|
|
9
10
|
const entries = Object.entries(defaults);
|
|
10
11
|
const data = new Float64Array(entries.length);
|
|
11
12
|
// A writable data property keeps seal() distinct from freeze().
|
|
@@ -13,8 +13,9 @@ function enumeration(value, maximum) {
|
|
|
13
13
|
/** Validate before a user callback or a leaf command reserves queue space. */
|
|
14
14
|
function validateRenderStates(states) {
|
|
15
15
|
// Default and its value members are frozen and known to be valid.
|
|
16
|
-
if (states === exports.defaultRenderStates)
|
|
16
|
+
if (states === exports.defaultRenderStates) {
|
|
17
17
|
return;
|
|
18
|
+
}
|
|
18
19
|
const b = states.blendMode;
|
|
19
20
|
const s = states.stencilMode;
|
|
20
21
|
if (!(b instanceof blend_mode_1.BlendMode) || !(s instanceof stencil_mode_1.StencilMode)) {
|
package/dist/internal/scalar.js
CHANGED
|
@@ -24,31 +24,39 @@ function validateScalar(type) {
|
|
|
24
24
|
}
|
|
25
25
|
exports.validateScalar = validateScalar;
|
|
26
26
|
function toScalar(type, value) {
|
|
27
|
-
if (type === 'f32')
|
|
27
|
+
if (type === 'f32') {
|
|
28
28
|
return Math.fround(value);
|
|
29
|
-
|
|
29
|
+
}
|
|
30
|
+
if (type === 'f64') {
|
|
30
31
|
return value;
|
|
31
|
-
|
|
32
|
-
if (type === 'i8')
|
|
32
|
+
}
|
|
33
|
+
if (type === 'i8') {
|
|
34
|
+
// eslint-disable-next-line no-bitwise
|
|
33
35
|
return (value << 24) >> 24;
|
|
34
|
-
|
|
35
|
-
if (type === 'u8')
|
|
36
|
+
}
|
|
37
|
+
if (type === 'u8') {
|
|
38
|
+
// eslint-disable-next-line no-bitwise
|
|
36
39
|
return value & 255;
|
|
37
|
-
|
|
38
|
-
if (type === 'i16')
|
|
40
|
+
}
|
|
41
|
+
if (type === 'i16') {
|
|
42
|
+
// eslint-disable-next-line no-bitwise
|
|
39
43
|
return (value << 16) >> 16;
|
|
40
|
-
|
|
41
|
-
if (type === 'u16')
|
|
44
|
+
}
|
|
45
|
+
if (type === 'u16') {
|
|
46
|
+
// eslint-disable-next-line no-bitwise
|
|
42
47
|
return value & 65535;
|
|
48
|
+
}
|
|
43
49
|
// eslint-disable-next-line no-bitwise
|
|
44
50
|
return type === 'i32' ? value | 0 : value >>> 0;
|
|
45
51
|
}
|
|
46
52
|
exports.toScalar = toScalar;
|
|
47
53
|
function scalarProduct(type, lhs, rhs) {
|
|
48
|
-
if (type === 'f32')
|
|
54
|
+
if (type === 'f32') {
|
|
49
55
|
return Math.fround(lhs * rhs);
|
|
50
|
-
|
|
56
|
+
}
|
|
57
|
+
if (type === 'f64') {
|
|
51
58
|
return lhs * rhs;
|
|
59
|
+
}
|
|
52
60
|
return Math.imul(lhs, rhs);
|
|
53
61
|
}
|
|
54
62
|
exports.scalarProduct = scalarProduct;
|
|
@@ -79,8 +87,9 @@ function convertScalar(type, value) {
|
|
|
79
87
|
const rest = magnitude - (rounded << bits);
|
|
80
88
|
const half = 1n << (bits - 1n);
|
|
81
89
|
/* eslint-enable no-bitwise */
|
|
82
|
-
if (rest > half || (rest === half && rounded % 2n !== 0n))
|
|
90
|
+
if (rest > half || (rest === half && rounded % 2n !== 0n)) {
|
|
83
91
|
rounded++;
|
|
92
|
+
}
|
|
84
93
|
return (negative ? -1 : 1) * Number(rounded) * 2 ** shift;
|
|
85
94
|
}
|
|
86
95
|
}
|
|
@@ -4,7 +4,9 @@ import type { TextIndices } from './text-indices';
|
|
|
4
4
|
import { type Glyph } from '../graphics/glyph';
|
|
5
5
|
import { type Vector2f } from '../system/vector2';
|
|
6
6
|
import type { ShapedGlyph, TextDirection } from '../graphics/text';
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* One set of typed views per native allocation, shared by all glyph wrappers.
|
|
9
|
+
*/
|
|
8
10
|
export declare class ShapedGlyphBuffer {
|
|
9
11
|
readonly mapping: NativeShapedGlyphs;
|
|
10
12
|
readonly bytes: Uint8Array;
|
|
@@ -5,7 +5,9 @@ const native_1 = require("./native");
|
|
|
5
5
|
const lazy_value_1 = require("./lazy-value");
|
|
6
6
|
const glyph_1 = require("../graphics/glyph");
|
|
7
7
|
const vector2_1 = require("../system/vector2");
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* One set of typed views per native allocation, shared by all glyph wrappers.
|
|
10
|
+
*/
|
|
9
11
|
class ShapedGlyphBuffer {
|
|
10
12
|
constructor(mapping) {
|
|
11
13
|
this.mapping = mapping;
|
|
@@ -44,8 +46,14 @@ class ShapedGlyphView {
|
|
|
44
46
|
get textDirection() {
|
|
45
47
|
return this.storage.words[this.index * 20 + 14];
|
|
46
48
|
}
|
|
47
|
-
get baseline() {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
get baseline() {
|
|
50
|
+
return this.storage.floats[this.index * 20 + 15];
|
|
51
|
+
}
|
|
52
|
+
get vertexOffset() {
|
|
53
|
+
return this.storage.doubles[this.index * 10 + 8];
|
|
54
|
+
}
|
|
55
|
+
get vertexCount() {
|
|
56
|
+
return this.storage.doubles[this.index * 10 + 9];
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
exports.ShapedGlyphView = ShapedGlyphView;
|
|
@@ -4,7 +4,9 @@ export interface NativeStruct {
|
|
|
4
4
|
buffers: ArrayBuffer[];
|
|
5
5
|
fields: Record<string, readonly [FieldType, number, number]>;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Read-only resource metadata, with offsets supplied by native member pointers.
|
|
9
|
+
*/
|
|
8
10
|
export declare function nativeStruct<T extends object>(mapping: NativeStruct, extra?: Partial<T>): Readonly<T>;
|
|
9
11
|
/** Frozen named getters over native-owned bytes; no mirrored scalar fields. */
|
|
10
12
|
export declare function readonlyStruct<T extends object>(buffer: ArrayBuffer, fields: StructFields<T>, extra?: Partial<T>): Readonly<T>;
|
|
@@ -13,7 +13,9 @@ const readers = {
|
|
|
13
13
|
i64: (data, offset) => data.getBigInt64(offset, littleEndian),
|
|
14
14
|
size64: (data, offset) => Number(data.getBigUint64(offset, littleEndian)),
|
|
15
15
|
};
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Read-only resource metadata, with offsets supplied by native member pointers.
|
|
18
|
+
*/
|
|
17
19
|
function nativeStruct(mapping, extra = {}) {
|
|
18
20
|
const data = mapping.buffers.map(buffer => new DataView(buffer));
|
|
19
21
|
const descriptors = {};
|
|
@@ -15,8 +15,9 @@ function vectorData(value) {
|
|
|
15
15
|
return value[value_storage_1.vector2Storage];
|
|
16
16
|
}
|
|
17
17
|
function angleData(value) {
|
|
18
|
-
if (!(value instanceof angle_1.Angle))
|
|
18
|
+
if (!(value instanceof angle_1.Angle)) {
|
|
19
19
|
throw new TypeError('Expected an Angle');
|
|
20
|
+
}
|
|
20
21
|
return value.asRadians();
|
|
21
22
|
}
|
|
22
23
|
function vectorCopy(data, offset) {
|
package/dist/network/common.js
CHANGED
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.waitFor = exports.SerialQueue = exports.bytes = exports.uint = exports.millisecondsOf = void 0;
|
|
4
4
|
const time_1 = require("../system/time");
|
|
5
5
|
function millisecondsOf(time) {
|
|
6
|
-
if (!(time instanceof time_1.Time))
|
|
6
|
+
if (!(time instanceof time_1.Time)) {
|
|
7
7
|
throw new TypeError('Expected a Time');
|
|
8
|
+
}
|
|
8
9
|
const value = time.asMicroseconds();
|
|
9
|
-
if (value < 0n)
|
|
10
|
+
if (value < 0n) {
|
|
10
11
|
throw new RangeError('Timeout must be non-negative');
|
|
12
|
+
}
|
|
11
13
|
return value === 0n ? 0 : Math.max(1, Number(value / 1000n));
|
|
12
14
|
}
|
|
13
15
|
exports.millisecondsOf = millisecondsOf;
|
|
@@ -19,8 +21,9 @@ function uint(value, max = 0xffffffff) {
|
|
|
19
21
|
}
|
|
20
22
|
exports.uint = uint;
|
|
21
23
|
function bytes(value) {
|
|
22
|
-
if (!(value instanceof Uint8Array))
|
|
24
|
+
if (!(value instanceof Uint8Array)) {
|
|
23
25
|
throw new TypeError('Expected bytes');
|
|
26
|
+
}
|
|
24
27
|
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
25
28
|
}
|
|
26
29
|
exports.bytes = bytes;
|
|
@@ -48,31 +51,40 @@ function waitFor(events, check, timeout = 0, signal) {
|
|
|
48
51
|
function finish(value, error) {
|
|
49
52
|
events.off('change', inspect);
|
|
50
53
|
signal?.removeEventListener('abort', abort);
|
|
51
|
-
if (timer)
|
|
54
|
+
if (timer) {
|
|
52
55
|
clearTimeout(timer);
|
|
53
|
-
|
|
56
|
+
}
|
|
57
|
+
if (error) {
|
|
54
58
|
reject(error);
|
|
55
|
-
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
56
61
|
resolve(value);
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
function inspect() {
|
|
59
65
|
try {
|
|
60
|
-
if (check())
|
|
66
|
+
if (check()) {
|
|
61
67
|
finish(true);
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
catch (error) {
|
|
64
71
|
finish(false, error);
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
|
-
function abort() {
|
|
74
|
+
function abort() {
|
|
75
|
+
finish(false);
|
|
76
|
+
}
|
|
68
77
|
events.on('change', inspect);
|
|
69
78
|
signal?.addEventListener('abort', abort, { once: true });
|
|
70
|
-
if (timeout)
|
|
79
|
+
if (timeout) {
|
|
71
80
|
timer = setTimeout(() => finish(false), timeout);
|
|
72
|
-
|
|
81
|
+
}
|
|
82
|
+
if (signal?.aborted) {
|
|
73
83
|
abort();
|
|
74
|
-
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
75
86
|
inspect();
|
|
87
|
+
}
|
|
76
88
|
});
|
|
77
89
|
}
|
|
78
90
|
exports.waitFor = waitFor;
|
package/dist/network/dns.js
CHANGED
|
@@ -12,8 +12,9 @@ async function query(servers, timeout, action) {
|
|
|
12
12
|
resolver.setServers(servers.map(address => address.toString()));
|
|
13
13
|
}
|
|
14
14
|
let timer;
|
|
15
|
-
if (milliseconds)
|
|
15
|
+
if (milliseconds) {
|
|
16
16
|
timer = setTimeout(() => resolver.cancel(), milliseconds);
|
|
17
|
+
}
|
|
17
18
|
try {
|
|
18
19
|
return await action(resolver);
|
|
19
20
|
}
|
|
@@ -21,8 +22,9 @@ async function query(servers, timeout, action) {
|
|
|
21
22
|
return undefined;
|
|
22
23
|
}
|
|
23
24
|
finally {
|
|
24
|
-
if (timer)
|
|
25
|
+
if (timer) {
|
|
25
26
|
clearTimeout(timer);
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
@@ -40,8 +42,9 @@ async function query(servers, timeout, action) {
|
|
|
40
42
|
*/
|
|
41
43
|
async function resolve(hostname, servers = [], timeout = (0, time_1.seconds)(1)) {
|
|
42
44
|
const literal = ip_address_1.IpAddress.fromString(hostname);
|
|
43
|
-
if (literal)
|
|
45
|
+
if (literal) {
|
|
44
46
|
return [literal];
|
|
47
|
+
}
|
|
45
48
|
if (!servers.length) {
|
|
46
49
|
try {
|
|
47
50
|
const records = await (0, promises_1.lookup)(hostname, { all: true });
|
|
@@ -53,11 +56,14 @@ async function resolve(hostname, servers = [], timeout = (0, time_1.seconds)(1))
|
|
|
53
56
|
}
|
|
54
57
|
return query(servers, timeout, async (resolver) => {
|
|
55
58
|
const results = await Promise.allSettled([
|
|
56
|
-
resolver.resolve4(hostname),
|
|
59
|
+
resolver.resolve4(hostname),
|
|
60
|
+
resolver.resolve6(hostname),
|
|
57
61
|
]);
|
|
58
62
|
const addresses = results.flatMap(result => (result.status === 'fulfilled' ? result.value : []));
|
|
59
|
-
if (!addresses.length &&
|
|
63
|
+
if (!addresses.length &&
|
|
64
|
+
results.every(result => result.status === 'rejected')) {
|
|
60
65
|
throw new Error('DNS lookup failed');
|
|
66
|
+
}
|
|
61
67
|
return addresses.map(address => ip_address_1.IpAddress.fromString(address));
|
|
62
68
|
});
|
|
63
69
|
}
|
|
@@ -72,8 +78,7 @@ exports.resolve = resolve;
|
|
|
72
78
|
* 조회 실패 시 빈 배열을 반환합니다.
|
|
73
79
|
*/
|
|
74
80
|
async function queryNs(hostname, servers = [], timeout = (0, time_1.seconds)(1)) {
|
|
75
|
-
return await query(servers, timeout, resolver => resolver.resolveNs(hostname))
|
|
76
|
-
?? [];
|
|
81
|
+
return ((await query(servers, timeout, resolver => resolver.resolveNs(hostname))) ?? []);
|
|
77
82
|
}
|
|
78
83
|
exports.queryNs = queryNs;
|
|
79
84
|
/**
|
|
@@ -86,9 +91,9 @@ exports.queryNs = queryNs;
|
|
|
86
91
|
* 조회 실패 시 빈 배열을 반환합니다.
|
|
87
92
|
*/
|
|
88
93
|
async function queryMx(hostname, servers = [], timeout = (0, time_1.seconds)(1)) {
|
|
89
|
-
return (await query(servers, timeout, resolver => resolver.resolveMx(hostname))
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
return ((await query(servers, timeout, resolver => resolver.resolveMx(hostname))) ?? []).map(record => ({
|
|
95
|
+
exchange: record.exchange,
|
|
96
|
+
preference: record.priority,
|
|
92
97
|
}));
|
|
93
98
|
}
|
|
94
99
|
exports.queryMx = queryMx;
|
|
@@ -102,9 +107,12 @@ exports.queryMx = queryMx;
|
|
|
102
107
|
* 실패 시 빈 배열을 반환합니다.
|
|
103
108
|
*/
|
|
104
109
|
async function querySrv(hostname, servers = [], timeout = (0, time_1.seconds)(1)) {
|
|
105
|
-
return (await query(servers, timeout, resolver => resolver.resolveSrv(hostname))
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
return ((await query(servers, timeout, resolver => resolver.resolveSrv(hostname))) ?? []).map(record => ({
|
|
111
|
+
target: record.name,
|
|
112
|
+
port: record.port,
|
|
113
|
+
weight: record.weight,
|
|
114
|
+
priority: record.priority,
|
|
115
|
+
}));
|
|
108
116
|
}
|
|
109
117
|
exports.querySrv = querySrv;
|
|
110
118
|
/**
|
|
@@ -117,8 +125,7 @@ exports.querySrv = querySrv;
|
|
|
117
125
|
* 실패 시 빈 배열을 반환합니다.
|
|
118
126
|
*/
|
|
119
127
|
async function queryTxt(hostname, servers = [], timeout = (0, time_1.seconds)(1)) {
|
|
120
|
-
return await query(servers, timeout, resolver => resolver.resolveTxt(hostname))
|
|
121
|
-
?? [];
|
|
128
|
+
return ((await query(servers, timeout, resolver => resolver.resolveTxt(hostname))) ?? []);
|
|
122
129
|
}
|
|
123
130
|
exports.queryTxt = queryTxt;
|
|
124
131
|
/**
|
|
@@ -132,8 +139,9 @@ exports.queryTxt = queryTxt;
|
|
|
132
139
|
*/
|
|
133
140
|
async function getPublicAddress(timeout = time_1.Time.Zero, type = ip_address_1.IpAddressType.IpV4) {
|
|
134
141
|
(0, common_1.uint)(type, 1);
|
|
135
|
-
const servers = [
|
|
136
|
-
|
|
142
|
+
const servers = [
|
|
143
|
+
ip_address_1.IpAddress.fromString(type === ip_address_1.IpAddressType.IpV4 ? '208.67.222.222' : '2620:119:35::35'),
|
|
144
|
+
];
|
|
137
145
|
const addresses = await query(servers, timeout, resolver => (type === ip_address_1.IpAddressType.IpV4
|
|
138
146
|
? resolver.resolve4('myip.opendns.com')
|
|
139
147
|
: resolver.resolve6('myip.opendns.com')));
|
package/dist/network/ftp.js
CHANGED
|
@@ -39,21 +39,27 @@ class FtpResponse {
|
|
|
39
39
|
* @ko 상태 코드가 400 미만인지 반환하며,
|
|
40
40
|
* 성공 및 추가 작업이 필요한 응답을 포함합니다.
|
|
41
41
|
*/
|
|
42
|
-
isOk() {
|
|
42
|
+
isOk() {
|
|
43
|
+
return this.status < 400;
|
|
44
|
+
}
|
|
43
45
|
/**
|
|
44
46
|
* Return the response status code.
|
|
45
47
|
* @zh 返回响应状态码。
|
|
46
48
|
* @ja レスポンスの状態コードを返します。
|
|
47
49
|
* @ko 응답 상태 코드를 반환합니다.
|
|
48
50
|
*/
|
|
49
|
-
getStatus() {
|
|
51
|
+
getStatus() {
|
|
52
|
+
return this.status;
|
|
53
|
+
}
|
|
50
54
|
/**
|
|
51
55
|
* Return the server or client error message.
|
|
52
56
|
* @zh 返回服务端或客户端错误消息。
|
|
53
57
|
* @ja サーバーまたはクライアントのエラーメッセージを返します。
|
|
54
58
|
* @ko 서버 또는 클라이언트 오류 메시지를 반환합니다.
|
|
55
59
|
*/
|
|
56
|
-
getMessage() {
|
|
60
|
+
getMessage() {
|
|
61
|
+
return this.message;
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
65
|
* FTP status code enumeration.
|
|
@@ -78,8 +84,11 @@ class FtpDirectoryResponse extends FtpResponse {
|
|
|
78
84
|
*/
|
|
79
85
|
constructor(response) {
|
|
80
86
|
super(response.getStatus(), response.getMessage());
|
|
81
|
-
this.directory =
|
|
82
|
-
|
|
87
|
+
this.directory =
|
|
88
|
+
response
|
|
89
|
+
.getMessage()
|
|
90
|
+
.match(/"((?:[^"]|"")*)"/)?.[1]
|
|
91
|
+
.replace(/""/g, '"') ?? '';
|
|
83
92
|
}
|
|
84
93
|
/**
|
|
85
94
|
* Return the parsed directory path, or an empty string if none was parsed.
|
|
@@ -87,7 +96,9 @@ class FtpDirectoryResponse extends FtpResponse {
|
|
|
87
96
|
* @ja 解析したディレクトリパスを返します。解析できなければ空文字列です。
|
|
88
97
|
* @ko 파싱한 디렉터리 경로를 반환하며 파싱하지 못했으면 빈 문자열입니다.
|
|
89
98
|
*/
|
|
90
|
-
getDirectory() {
|
|
99
|
+
getDirectory() {
|
|
100
|
+
return this.directory;
|
|
101
|
+
}
|
|
91
102
|
}
|
|
92
103
|
exports.FtpDirectoryResponse = FtpDirectoryResponse;
|
|
93
104
|
/**
|
|
@@ -113,7 +124,9 @@ class FtpListingResponse extends FtpResponse {
|
|
|
113
124
|
* @ja ディレクトリエントリー名の読み取り専用型の配列を返します。
|
|
114
125
|
* @ko 디렉터리 항목 이름을 읽기 전용 타입의 배열로 반환합니다.
|
|
115
126
|
*/
|
|
116
|
-
getListing() {
|
|
127
|
+
getListing() {
|
|
128
|
+
return this.listing;
|
|
129
|
+
}
|
|
117
130
|
}
|
|
118
131
|
exports.FtpListingResponse = FtpListingResponse;
|
|
119
132
|
function commandPart(value) {
|
|
@@ -126,12 +139,12 @@ function response(value) {
|
|
|
126
139
|
return new FtpResponse(value.code, value.message);
|
|
127
140
|
}
|
|
128
141
|
function failure(error) {
|
|
129
|
-
if (error instanceof basic_ftp_1.FTPError)
|
|
142
|
+
if (error instanceof basic_ftp_1.FTPError) {
|
|
130
143
|
return new FtpResponse(error.code, error.message);
|
|
144
|
+
}
|
|
131
145
|
const value = error;
|
|
132
146
|
const localFile = ['ENOENT', 'EACCES', 'EISDIR', 'ENOTDIR'].includes(value.code ?? '');
|
|
133
|
-
return new FtpResponse(localFile ? constants_1.FtpStatus.InvalidFile
|
|
134
|
-
: constants_1.FtpStatus.ConnectionClosed, value.message ?? String(error));
|
|
147
|
+
return new FtpResponse(localFile ? constants_1.FtpStatus.InvalidFile : constants_1.FtpStatus.ConnectionClosed, value.message ?? String(error));
|
|
135
148
|
}
|
|
136
149
|
/**
|
|
137
150
|
* FTP client based on basic-ftp; queued operations run in call order.
|
|
@@ -155,15 +168,17 @@ class Ftp {
|
|
|
155
168
|
* Time.Zero는 연결 제한 시간이 없으며 연결 후 별도로 login해야 합니다.
|
|
156
169
|
*/
|
|
157
170
|
connect(server, port = 21, timeout = time_1.Time.Zero) {
|
|
158
|
-
if (!(server instanceof ip_address_1.IpAddress))
|
|
171
|
+
if (!(server instanceof ip_address_1.IpAddress)) {
|
|
159
172
|
throw new TypeError('Expected IpAddress');
|
|
173
|
+
}
|
|
160
174
|
(0, common_1.uint)(port, 65535);
|
|
161
175
|
const milliseconds = (0, common_1.millisecondsOf)(timeout);
|
|
162
176
|
return this.queue.run(async () => {
|
|
163
177
|
this.client.close();
|
|
164
178
|
this.client = new basic_ftp_1.Client(0);
|
|
165
179
|
const client = this.client;
|
|
166
|
-
const timer = milliseconds
|
|
180
|
+
const timer = milliseconds
|
|
181
|
+
? setTimeout(() => client.close(), milliseconds)
|
|
167
182
|
: undefined;
|
|
168
183
|
try {
|
|
169
184
|
return response(await client.connect(server.toString(), port));
|
|
@@ -172,8 +187,9 @@ class Ftp {
|
|
|
172
187
|
return new FtpResponse(constants_1.FtpStatus.ConnectionFailed, error instanceof Error ? error.message : String(error));
|
|
173
188
|
}
|
|
174
189
|
finally {
|
|
175
|
-
if (timer)
|
|
190
|
+
if (timer) {
|
|
176
191
|
clearTimeout(timer);
|
|
192
|
+
}
|
|
177
193
|
}
|
|
178
194
|
});
|
|
179
195
|
}
|
|
@@ -202,7 +218,9 @@ class Ftp {
|
|
|
202
218
|
* @ja 未完了の操作を中止し、両方の接続を解放します。
|
|
203
219
|
* @ko 미완료 작업을 중단하고 두 연결을 모두 해제합니다.
|
|
204
220
|
*/
|
|
205
|
-
close() {
|
|
221
|
+
close() {
|
|
222
|
+
this.client.close();
|
|
223
|
+
}
|
|
206
224
|
/**
|
|
207
225
|
* Log in asynchronously; omitted arguments use an anonymous account.
|
|
208
226
|
* @zh 异步登录,省略参数时使用匿名账号。
|
|
@@ -220,7 +238,9 @@ class Ftp {
|
|
|
220
238
|
* @ja NOOP を送信して接続を維持します。
|
|
221
239
|
* @ko NOOP를 보내 연결을 유지합니다.
|
|
222
240
|
*/
|
|
223
|
-
keepAlive() {
|
|
241
|
+
keepAlive() {
|
|
242
|
+
return this.sendCommand('NOOP');
|
|
243
|
+
}
|
|
224
244
|
/**
|
|
225
245
|
* Query the server's current working directory.
|
|
226
246
|
* @zh 查询服务器当前工作目录。
|
|
@@ -261,7 +281,9 @@ class Ftp {
|
|
|
261
281
|
});
|
|
262
282
|
const result = await (0, transfer_1.downloadTo)(destination, {
|
|
263
283
|
command: directory ? `NLST ${directory}` : 'NLST',
|
|
264
|
-
remotePath: directory,
|
|
284
|
+
remotePath: directory,
|
|
285
|
+
type: 'list',
|
|
286
|
+
ftp: this.client.ftp,
|
|
265
287
|
tracker: new ProgressTracker_1.ProgressTracker(),
|
|
266
288
|
});
|
|
267
289
|
return new FtpListingResponse(response(result), Buffer.concat(chunks, count).toString('utf8'));
|
|
@@ -286,7 +308,9 @@ class Ftp {
|
|
|
286
308
|
* @ja サーバーの現在のディレクトリの親に移動します。
|
|
287
309
|
* @ko 서버의 현재 디렉터리에서 상위 디렉터리로 이동합니다.
|
|
288
310
|
*/
|
|
289
|
-
parentDirectory() {
|
|
311
|
+
parentDirectory() {
|
|
312
|
+
return this.sendCommand('CDUP');
|
|
313
|
+
}
|
|
290
314
|
/**
|
|
291
315
|
* Create a remote directory.
|
|
292
316
|
* @zh 创建远端目录。
|
|
@@ -357,7 +381,8 @@ class Ftp {
|
|
|
357
381
|
return this.run(async () => {
|
|
358
382
|
await this.client.send(`TYPE ${['I', 'A', 'E'][mode]}`);
|
|
359
383
|
const target = node_path_1.posix.join(remotePath, (0, node_path_1.basename)(localFile));
|
|
360
|
-
return append
|
|
384
|
+
return append
|
|
385
|
+
? this.client.appendFrom(localFile, target)
|
|
361
386
|
: this.client.uploadFrom(localFile, target);
|
|
362
387
|
});
|
|
363
388
|
}
|