serve-sim 0.1.25 → 0.1.27
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.md +1 -1
- package/Sources/SimCameraHelper/build.sh +1 -1
- package/Sources/SimCameraHelper/main.m +28 -17
- package/Sources/SimCameraInjector/SimCamFakes.h +86 -0
- package/Sources/SimCameraInjector/SimCamFakes.m +635 -0
- package/Sources/SimCameraInjector/SimCamFrameSource.h +26 -0
- package/Sources/SimCameraInjector/SimCamFrameSource.m +546 -0
- package/Sources/SimCameraInjector/SimCamLog.h +5 -0
- package/Sources/SimCameraInjector/SimCamLog.m +9 -0
- package/Sources/SimCameraInjector/SimCamSwizzles.h +3 -0
- package/Sources/SimCameraInjector/SimCamSwizzles.m +1014 -0
- package/Sources/SimCameraInjector/SimCameraInjector.m +9 -1150
- package/Sources/SimCameraInjector/build.sh +6 -1
- package/bin/serve-sim-bin +0 -0
- package/dist/middleware.js +18 -18
- package/dist/serve-sim.js +32 -32
- package/dist/simcam/libSimCameraInjector.dylib +0 -0
- package/dist/simcam/serve-sim-camera-helper +0 -0
- package/package.json +3 -1
- package/src/middleware.ts +39 -23
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serve-sim",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Evan Bacon",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"src/state.ts",
|
|
36
36
|
"bin/serve-sim-bin",
|
|
37
37
|
"Sources/SimCameraInjector/SimCameraInjector.m",
|
|
38
|
+
"Sources/SimCameraInjector/SimCam*.h",
|
|
39
|
+
"Sources/SimCameraInjector/SimCam*.m",
|
|
38
40
|
"Sources/SimCameraInjector/include/SimCamShared.h",
|
|
39
41
|
"Sources/SimCameraInjector/build.sh",
|
|
40
42
|
"Sources/SimCameraHelper/main.m",
|
package/src/middleware.ts
CHANGED
|
@@ -250,6 +250,43 @@ function endpoint(base: string, path: string, device: string): string {
|
|
|
250
250
|
return `${value}?device=${encodeURIComponent(device)}`;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
export function previewConfigForState(
|
|
254
|
+
state: ServeSimState,
|
|
255
|
+
base: string,
|
|
256
|
+
serveSimBin: string,
|
|
257
|
+
execToken: string,
|
|
258
|
+
): ServeSimState & {
|
|
259
|
+
basePath: string;
|
|
260
|
+
logsEndpoint: string;
|
|
261
|
+
appStateEndpoint: string;
|
|
262
|
+
axEndpoint: string;
|
|
263
|
+
devtoolsEndpoint: string;
|
|
264
|
+
serveSimBin: string;
|
|
265
|
+
gridApiEndpoint: string;
|
|
266
|
+
gridStartEndpoint: string;
|
|
267
|
+
gridShutdownEndpoint: string;
|
|
268
|
+
gridMemoryEndpoint: string;
|
|
269
|
+
previewEndpoint: string;
|
|
270
|
+
execToken: string;
|
|
271
|
+
} {
|
|
272
|
+
const gridApiBase = (base === "" ? "" : base) + "/grid/api";
|
|
273
|
+
return {
|
|
274
|
+
...state,
|
|
275
|
+
basePath: base,
|
|
276
|
+
logsEndpoint: endpoint(base, "/logs", state.device),
|
|
277
|
+
appStateEndpoint: endpoint(base, "/appstate", state.device),
|
|
278
|
+
axEndpoint: endpoint(base, "/ax", state.device),
|
|
279
|
+
devtoolsEndpoint: endpoint(base, "/devtools", state.device),
|
|
280
|
+
serveSimBin,
|
|
281
|
+
gridApiEndpoint: gridApiBase,
|
|
282
|
+
gridStartEndpoint: gridApiBase + "/start",
|
|
283
|
+
gridShutdownEndpoint: gridApiBase + "/shutdown",
|
|
284
|
+
gridMemoryEndpoint: gridApiBase + "/memory",
|
|
285
|
+
previewEndpoint: base === "" ? "/" : base,
|
|
286
|
+
execToken,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
253
290
|
async function isLocalPortFree(port: number): Promise<boolean> {
|
|
254
291
|
return new Promise((resolve) => {
|
|
255
292
|
const server = createNetServer();
|
|
@@ -681,28 +718,7 @@ export function simMiddleware(options?: SimMiddlewareOptions) {
|
|
|
681
718
|
}
|
|
682
719
|
|
|
683
720
|
if (state) {
|
|
684
|
-
|
|
685
|
-
// stream via fetch() (CORS is fine — serve-sim sends Access-Control-Allow-Origin: *)
|
|
686
|
-
// and connects to the WS directly (WS has no CORS).
|
|
687
|
-
const gridApiBase = (base === "" ? "" : base) + "/grid/api";
|
|
688
|
-
const config = JSON.stringify({
|
|
689
|
-
...state,
|
|
690
|
-
basePath: base,
|
|
691
|
-
logsEndpoint: endpoint(base, "/logs", state.device),
|
|
692
|
-
appStateEndpoint: endpoint(base, "/appstate", state.device),
|
|
693
|
-
axEndpoint: endpoint(base, "/ax", state.device),
|
|
694
|
-
devtoolsEndpoint: endpoint(base, "/devtools", state.device),
|
|
695
|
-
// Forward the absolute path of the running serve-sim entry script
|
|
696
|
-
// so the in-page Camera tool can shell out via `node <bin> camera`
|
|
697
|
-
// without depending on `serve-sim` being on PATH.
|
|
698
|
-
serveSimBin: serveSimBinPath(),
|
|
699
|
-
gridApiEndpoint: gridApiBase,
|
|
700
|
-
gridStartEndpoint: gridApiBase + "/start",
|
|
701
|
-
gridShutdownEndpoint: gridApiBase + "/shutdown",
|
|
702
|
-
gridMemoryEndpoint: gridApiBase + "/memory",
|
|
703
|
-
previewEndpoint: base === "" ? "/" : base,
|
|
704
|
-
execToken,
|
|
705
|
-
});
|
|
721
|
+
const config = JSON.stringify(previewConfigForState(state, base, serveSimBinPath(), execToken));
|
|
706
722
|
const configScript = `<script>window.__SIM_PREVIEW__=${config}</script>`;
|
|
707
723
|
html = html.replace("<!--__SIM_PREVIEW_CONFIG__-->", configScript);
|
|
708
724
|
}
|
|
@@ -974,7 +990,7 @@ export function simMiddleware(options?: SimMiddlewareOptions) {
|
|
|
974
990
|
"Content-Type": "application/json",
|
|
975
991
|
"Cache-Control": "no-store",
|
|
976
992
|
});
|
|
977
|
-
res.end(JSON.stringify(state
|
|
993
|
+
res.end(JSON.stringify(state ? previewConfigForState(state, base, serveSimBinPath(), execToken) : null));
|
|
978
994
|
return;
|
|
979
995
|
}
|
|
980
996
|
|