@expo/serve-sim 0.1.35-canary.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.
Files changed (39) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +279 -0
  3. package/Sources/SimAXSettings/build.sh +21 -0
  4. package/Sources/SimAXSettings/sim-ax-settings.m +273 -0
  5. package/Sources/SimCameraHelper/build.sh +33 -0
  6. package/Sources/SimCameraHelper/main.m +955 -0
  7. package/Sources/SimCameraInjector/SimCamFakes.h +88 -0
  8. package/Sources/SimCameraInjector/SimCamFakes.m +704 -0
  9. package/Sources/SimCameraInjector/SimCamFrameSource.h +26 -0
  10. package/Sources/SimCameraInjector/SimCamFrameSource.m +577 -0
  11. package/Sources/SimCameraInjector/SimCamLog.h +5 -0
  12. package/Sources/SimCameraInjector/SimCamLog.m +9 -0
  13. package/Sources/SimCameraInjector/SimCamSwizzles.h +3 -0
  14. package/Sources/SimCameraInjector/SimCamSwizzles.m +1338 -0
  15. package/Sources/SimCameraInjector/SimCameraInjector.m +19 -0
  16. package/Sources/SimCameraInjector/build.sh +39 -0
  17. package/Sources/SimCameraInjector/include/SimCamShared.h +79 -0
  18. package/dist/bin/LiveKitWebRTC.framework/LiveKitWebRTC +0 -0
  19. package/dist/bin/LiveKitWebRTC.framework/Resources/Info.plist +36 -0
  20. package/dist/bin/LiveKitWebRTC.framework/Resources/LICENSE.webrtc +29 -0
  21. package/dist/bin/LiveKitWebRTC.framework/Resources/PrivacyInfo.xcprivacy +32 -0
  22. package/dist/bin/LiveKitWebRTC.framework/_CodeSignature/CodeResources +150 -0
  23. package/dist/middleware.cjs +2 -0
  24. package/dist/middleware.js +123 -0
  25. package/dist/native/serve-sim-native.node +0 -0
  26. package/dist/serve-sim.js +218 -0
  27. package/dist/simax/serve-sim-ax-settings +0 -0
  28. package/dist/simcam/libSimCameraInjector.dylib +0 -0
  29. package/dist/simcam/serve-sim-camera-helper +0 -0
  30. package/dist/state.js +1 -0
  31. package/package.json +99 -0
  32. package/src/ax-shared.ts +25 -0
  33. package/src/ax.ts +258 -0
  34. package/src/camera-helper.ts +150 -0
  35. package/src/connect-to-fetch.ts +239 -0
  36. package/src/middleware.ts +2208 -0
  37. package/src/native.ts +294 -0
  38. package/src/state.ts +86 -0
  39. package/src/stream-settings.ts +202 -0
@@ -0,0 +1,19 @@
1
+ #import <UIKit/UIKit.h>
2
+ #include <unistd.h>
3
+
4
+ #import "SimCamFakes.h"
5
+ #import "SimCamFrameSource.h"
6
+ #import "SimCamLog.h"
7
+ #import "SimCamSwizzles.h"
8
+
9
+ __attribute__((constructor))
10
+ static void SimCamInit(void) {
11
+ @autoreleasepool {
12
+ simcam_log(@"loaded into pid %d", getpid());
13
+ SimCamReadMirrorModeFromEnv();
14
+ SimCamFrameSourceOpenShmIfRequested();
15
+ if (!SimCamFrameSourceIsShmAttached()) SimCamFrameSourceLoadImage();
16
+ SimCamInstallSwizzles();
17
+ simcam_log(@"swizzles installed");
18
+ }
19
+ }
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ HERE="$(cd "$(dirname "$0")" && pwd)"
5
+ OUT_DIR="${1:-$HERE/../../dist/simcam}"
6
+ mkdir -p "$OUT_DIR"
7
+
8
+ SDK="$(xcrun --sdk iphonesimulator --show-sdk-path)"
9
+ DYLIB="$OUT_DIR/libSimCameraInjector.dylib"
10
+
11
+ # Apple silicon simulators run arm64 processes; no Intel slice is shipped.
12
+ xcrun --sdk iphonesimulator clang \
13
+ -arch arm64 \
14
+ -mios-simulator-version-min=15.0 \
15
+ -isysroot "$SDK" \
16
+ -dynamiclib \
17
+ -fobjc-arc \
18
+ -fmodules \
19
+ -fobjc-weak \
20
+ -framework Foundation \
21
+ -framework UIKit \
22
+ -framework AVFoundation \
23
+ -framework CoreImage \
24
+ -framework CoreMedia \
25
+ -framework CoreMotion \
26
+ -framework CoreVideo \
27
+ -framework CoreGraphics \
28
+ -framework IOSurface \
29
+ -framework QuartzCore \
30
+ -install_name "@rpath/libSimCameraInjector.dylib" \
31
+ -o "$DYLIB" \
32
+ "$HERE/SimCameraInjector.m" \
33
+ "$HERE/SimCamLog.m" \
34
+ "$HERE/SimCamFakes.m" \
35
+ "$HERE/SimCamFrameSource.m" \
36
+ "$HERE/SimCamSwizzles.m"
37
+
38
+ echo "Built: $DYLIB"
39
+ file "$DYLIB"
@@ -0,0 +1,79 @@
1
+ // Wire format for serve-sim's simulator camera feed.
2
+ //
3
+ // Frames travel over a small ring of IOSurfaces shared by global surface ID.
4
+ // The host helper (running on macOS) renders BGRA frames straight into the
5
+ // surfaces; the injected dylib inside the simulator app looks the surfaces up
6
+ // by ID and wraps the latest one as a CVPixelBuffer — no per-frame pixel copy.
7
+ //
8
+ // A tiny POSIX shared-memory region acts as the control channel: it carries
9
+ // the surface IDs, which surface holds the newest frame, the frame sequence
10
+ // number, and the mirror mode. The pixels themselves live in the IOSurfaces,
11
+ // not in this region.
12
+ //
13
+ // Surfaces are BGRA. Row stride comes from IOSurfaceGetBytesPerRow (it may be
14
+ // padded beyond width*4); `bytesPerRow` below mirrors that actual stride.
15
+ //
16
+ // Synchronization is lock-free and lossy. The writer renders into a surface
17
+ // the reader is not holding, points `latestIndex` at it, then bumps `frameSeq`
18
+ // last. The reader samples `frameSeq` before and after wrapping the surface and
19
+ // retries on the next tick if they disagree. A single dropped frame is fine for
20
+ // a 30 fps camera.
21
+
22
+ #ifndef SIM_CAM_SHARED_H
23
+ #define SIM_CAM_SHARED_H
24
+
25
+ #include <stddef.h>
26
+ #include <stdint.h>
27
+ #include <stdatomic.h>
28
+
29
+ #define SIMCAM_SHM_MAGIC 0x53434D31u // 'SCM1'
30
+ #define SIMCAM_PIXEL_BGRA 0u
31
+ #define SIMCAM_DEFAULT_WIDTH 1280u
32
+ #define SIMCAM_DEFAULT_HEIGHT 720u
33
+
34
+ // Number of IOSurfaces in the ring. The writer keeps off whichever surface the
35
+ // reader most recently published, so a few buffers absorb a reader that holds
36
+ // a frame for a tick or two without tearing.
37
+ #define SIMCAM_SURFACE_RING 4u
38
+
39
+ // Mirror mode codes for SimCamShmHeader.mirrorMode.
40
+ // "Unset" lets the dylib fall back to its env-var configuration (back-compat
41
+ // with hosts that don't write the byte).
42
+ #define SIMCAM_MIRROR_UNSET 0xFF
43
+ #define SIMCAM_MIRROR_AUTO 0
44
+ #define SIMCAM_MIRROR_ON 1
45
+ #define SIMCAM_MIRROR_OFF 2
46
+
47
+ // Control header is 64 bytes. The surface-ID table follows immediately after.
48
+ typedef struct {
49
+ uint32_t magic; // SIMCAM_SHM_MAGIC
50
+ uint32_t version; // bumps on layout change
51
+ uint32_t width;
52
+ uint32_t height;
53
+ uint32_t pixelFormat; // SIMCAM_PIXEL_BGRA
54
+ uint32_t bytesPerRow; // actual IOSurface row stride (may exceed width*4)
55
+ uint64_t pixelByteSize;// logical frame size: width*height*4
56
+ _Atomic uint64_t frameSeq; // written LAST with release; readers acquire-load
57
+ uint64_t timestampNs; // mach_absolute_time-based, host monotonic
58
+ uint8_t mirrorMode; // SIMCAM_MIRROR_*; UNSET = ignore (use env)
59
+ uint8_t reserved[15];
60
+ } SimCamShmHeader;
61
+
62
+ _Static_assert(sizeof(SimCamShmHeader) == 64, "SimCamShmHeader must be 64 bytes");
63
+ _Static_assert(offsetof(SimCamShmHeader, frameSeq) == 32, "frameSeq offset must stay stable");
64
+ _Static_assert(offsetof(SimCamShmHeader, mirrorMode) == 48, "mirrorMode offset must stay stable");
65
+
66
+ // Ring of global IOSurface IDs, written once at startup. `latestIndex` is
67
+ // updated each frame (before frameSeq) to point at the freshest surface.
68
+ typedef struct __attribute__((packed)) {
69
+ uint32_t surfaceCount; // valid entries in ids[]
70
+ uint32_t latestIndex; // ids[] slot holding the newest frame
71
+ uint32_t ids[SIMCAM_SURFACE_RING]; // global IOSurface IDs
72
+ } SimCamSurfaceTable;
73
+
74
+ // Total control-region size: header + surface table.
75
+ static inline uint64_t SimCamControlSize(void) {
76
+ return (uint64_t)sizeof(SimCamShmHeader) + (uint64_t)sizeof(SimCamSurfaceTable);
77
+ }
78
+
79
+ #endif
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>en</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>LiveKitWebRTC</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>io.livekit.LiveKitWebRTC</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>LiveKitWebRTC</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleSignature</key>
20
+ <string>????</string>
21
+ <key>CFBundleVersion</key>
22
+ <string>1.0</string>
23
+ <key>DTCompiler</key>
24
+ <string>com.apple.compilers.llvm.clang.1_0</string>
25
+ <key>DTSDKBuild</key>
26
+ <string>25A352</string>
27
+ <key>DTSDKName</key>
28
+ <string>macosx26.0</string>
29
+ <key>DTXcode</key>
30
+ <string>2601</string>
31
+ <key>DTXcodeBuild</key>
32
+ <string>17A400</string>
33
+ <key>NSPrincipalClass</key>
34
+ <string></string>
35
+ </dict>
36
+ </plist>
@@ -0,0 +1,29 @@
1
+ Copyright (c) 2011, The WebRTC project authors. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in
12
+ the documentation and/or other materials provided with the
13
+ distribution.
14
+
15
+ * Neither the name of Google nor the names of its contributors may
16
+ be used to endorse or promote products derived from this software
17
+ without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSPrivacyAccessedAPITypes</key>
6
+ <array>
7
+ <dict>
8
+ <key>NSPrivacyAccessedAPIType</key>
9
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
10
+ <key>NSPrivacyAccessedAPITypeReasons</key>
11
+ <array>
12
+ <string>35F9.1</string>
13
+ <string>8FFB.1</string>
14
+ </array>
15
+ </dict>
16
+ <dict>
17
+ <key>NSPrivacyAccessedAPIType</key>
18
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
19
+ <key>NSPrivacyAccessedAPITypeReasons</key>
20
+ <array>
21
+ <string>C617.1</string>
22
+ </array>
23
+ </dict>
24
+ </array>
25
+ <key>NSPrivacyCollectedDataTypes</key>
26
+ <array/>
27
+ <key>NSPrivacyTracking</key>
28
+ <false/>
29
+ <key>NSPrivacyTrackingDomains</key>
30
+ <array/>
31
+ </dict>
32
+ </plist>
@@ -0,0 +1,150 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>files</key>
6
+ <dict>
7
+ <key>Resources/Info.plist</key>
8
+ <data>
9
+ EJ1fszw48+Ah3wnSxXgMjW0voLU=
10
+ </data>
11
+ <key>Resources/LICENSE.webrtc</key>
12
+ <data>
13
+ Zrqh+IyAVvN3xzZ4aEgpfOlI7pA=
14
+ </data>
15
+ <key>Resources/PrivacyInfo.xcprivacy</key>
16
+ <data>
17
+ awkbSyTtHswWIztjoenYOFh5sXk=
18
+ </data>
19
+ </dict>
20
+ <key>files2</key>
21
+ <dict>
22
+ <key>Resources/Info.plist</key>
23
+ <dict>
24
+ <key>hash2</key>
25
+ <data>
26
+ kgzcar34cKNeljngnjnKptnptSIyV3G/XbT+9YyTXtI=
27
+ </data>
28
+ </dict>
29
+ <key>Resources/LICENSE.webrtc</key>
30
+ <dict>
31
+ <key>hash2</key>
32
+ <data>
33
+ qwCkgrajkC5AIRtDxdBEGWLqmbbMfCXA8kP6Jwt41II=
34
+ </data>
35
+ </dict>
36
+ <key>Resources/PrivacyInfo.xcprivacy</key>
37
+ <dict>
38
+ <key>hash2</key>
39
+ <data>
40
+ 65M38t7lmS90risQ949SbT7sHajP3gKRMQgcCxhXlhQ=
41
+ </data>
42
+ </dict>
43
+ </dict>
44
+ <key>rules</key>
45
+ <dict>
46
+ <key>^Resources/</key>
47
+ <true/>
48
+ <key>^Resources/.*\.lproj/</key>
49
+ <dict>
50
+ <key>optional</key>
51
+ <true/>
52
+ <key>weight</key>
53
+ <real>1000</real>
54
+ </dict>
55
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
56
+ <dict>
57
+ <key>omit</key>
58
+ <true/>
59
+ <key>weight</key>
60
+ <real>1100</real>
61
+ </dict>
62
+ <key>^Resources/Base\.lproj/</key>
63
+ <dict>
64
+ <key>weight</key>
65
+ <real>1010</real>
66
+ </dict>
67
+ <key>^version.plist$</key>
68
+ <true/>
69
+ </dict>
70
+ <key>rules2</key>
71
+ <dict>
72
+ <key>.*\.dSYM($|/)</key>
73
+ <dict>
74
+ <key>weight</key>
75
+ <real>11</real>
76
+ </dict>
77
+ <key>^(.*/)?\.DS_Store$</key>
78
+ <dict>
79
+ <key>omit</key>
80
+ <true/>
81
+ <key>weight</key>
82
+ <real>2000</real>
83
+ </dict>
84
+ <key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
85
+ <dict>
86
+ <key>nested</key>
87
+ <true/>
88
+ <key>weight</key>
89
+ <real>10</real>
90
+ </dict>
91
+ <key>^.*</key>
92
+ <true/>
93
+ <key>^Info\.plist$</key>
94
+ <dict>
95
+ <key>omit</key>
96
+ <true/>
97
+ <key>weight</key>
98
+ <real>20</real>
99
+ </dict>
100
+ <key>^PkgInfo$</key>
101
+ <dict>
102
+ <key>omit</key>
103
+ <true/>
104
+ <key>weight</key>
105
+ <real>20</real>
106
+ </dict>
107
+ <key>^Resources/</key>
108
+ <dict>
109
+ <key>weight</key>
110
+ <real>20</real>
111
+ </dict>
112
+ <key>^Resources/.*\.lproj/</key>
113
+ <dict>
114
+ <key>optional</key>
115
+ <true/>
116
+ <key>weight</key>
117
+ <real>1000</real>
118
+ </dict>
119
+ <key>^Resources/.*\.lproj/locversion.plist$</key>
120
+ <dict>
121
+ <key>omit</key>
122
+ <true/>
123
+ <key>weight</key>
124
+ <real>1100</real>
125
+ </dict>
126
+ <key>^Resources/Base\.lproj/</key>
127
+ <dict>
128
+ <key>weight</key>
129
+ <real>1010</real>
130
+ </dict>
131
+ <key>^[^/]+$</key>
132
+ <dict>
133
+ <key>nested</key>
134
+ <true/>
135
+ <key>weight</key>
136
+ <real>10</real>
137
+ </dict>
138
+ <key>^embedded\.provisionprofile$</key>
139
+ <dict>
140
+ <key>weight</key>
141
+ <real>20</real>
142
+ </dict>
143
+ <key>^version\.plist$</key>
144
+ <dict>
145
+ <key>weight</key>
146
+ <real>20</real>
147
+ </dict>
148
+ </dict>
149
+ </dict>
150
+ </plist>
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ module.exports = require("./middleware.js");