@couch-kit/host 1.2.2 → 1.2.4
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/package.json +1 -1
- package/src/assets.ts +11 -6
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/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
|
|
|
@@ -56,14 +57,14 @@ export function useExtractAssets(manifest: AssetManifest): ExtractAssetsResult {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
// Create the root target directory
|
|
59
|
-
targetDir.create(
|
|
60
|
+
targetDir.create();
|
|
60
61
|
|
|
61
62
|
// Copy each file from APK assets to filesystem
|
|
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("/");
|
|
@@ -72,10 +73,14 @@ export function useExtractAssets(manifest: AssetManifest): ExtractAssetsResult {
|
|
|
72
73
|
targetDir,
|
|
73
74
|
filePath.substring(0, lastSlash),
|
|
74
75
|
);
|
|
75
|
-
subDir.
|
|
76
|
+
if (!subDir.exists) {
|
|
77
|
+
subDir.create();
|
|
78
|
+
}
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
|
|
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 });
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
if (cancelled) return;
|