@couch-kit/host 1.2.3 → 1.2.5
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/lib/assets.d.ts.map +1 -1
- package/lib/server.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/assets.ts +7 -4
- package/src/server.ts +12 -3
package/lib/assets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,oFAAoF;IACpF,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,mBAAmB,CA6E7E"}
|
package/lib/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,kBAAkB;;;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,kBAAkB;;;;CAyEzD,CAAC"}
|
package/package.json
CHANGED
package/src/assets.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import
|
|
2
|
+
import * as FileSystem from "expo-file-system";
|
|
3
|
+
import { Paths, Directory } from "expo-file-system/next";
|
|
3
4
|
import { Platform } from "react-native";
|
|
4
5
|
import { toErrorMessage } from "@couch-kit/core";
|
|
5
6
|
|
|
@@ -62,8 +63,8 @@ export function useExtractAssets(manifest: AssetManifest): ExtractAssetsResult {
|
|
|
62
63
|
for (const filePath of manifest.files) {
|
|
63
64
|
if (cancelled) return;
|
|
64
65
|
|
|
65
|
-
const
|
|
66
|
-
const
|
|
66
|
+
const sourceUri = `asset:///www/${filePath}`;
|
|
67
|
+
const destUri = `${targetDir.uri}${filePath}`;
|
|
67
68
|
|
|
68
69
|
// Ensure subdirectory exists (e.g., "assets/" in "assets/index.js")
|
|
69
70
|
const lastSlash = filePath.lastIndexOf("/");
|
|
@@ -77,7 +78,9 @@ export function useExtractAssets(manifest: AssetManifest): ExtractAssetsResult {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
// Use legacy API — the new File API doesn't support asset:// URIs
|
|
82
|
+
// on Android because it bypasses the AssetManager
|
|
83
|
+
await FileSystem.copyAsync({ from: sourceUri, to: destUri });
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
if (cancelled) return;
|
package/src/server.ts
CHANGED
|
@@ -51,9 +51,18 @@ export const useStaticServer = (config: CouchKitHostConfig) => {
|
|
|
51
51
|
try {
|
|
52
52
|
// Use staticDir if provided (required on Android where bundle path is undefined),
|
|
53
53
|
// otherwise fall back to the iOS bundle directory via expo-file-system
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
let path = config.staticDir;
|
|
55
|
+
|
|
56
|
+
if (!path) {
|
|
57
|
+
const bundleUri = Paths.bundle?.uri;
|
|
58
|
+
if (!bundleUri) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
"No staticDir provided and Paths.bundle is unavailable. " +
|
|
61
|
+
"On Android, you must pass staticDir from useExtractAssets.",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
path = `${bundleUri.replace(/^file:\/\//, "")}www`;
|
|
65
|
+
}
|
|
57
66
|
const port = config.port || DEFAULT_HTTP_PORT;
|
|
58
67
|
|
|
59
68
|
server = new StaticServer();
|