react-native-asset 2.2.12 → 2.2.13
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/esm/clean-assets/android.js +2 -2
- package/esm/clean-assets/ios.d.ts.map +1 -1
- package/esm/clean-assets/ios.js +2 -0
- package/esm/copy-assets/ios.d.ts +1 -1
- package/esm/copy-assets/ios.d.ts.map +1 -1
- package/esm/copy-assets/ios.js +9 -4
- package/esm/main.js +3 -3
- package/package.json +1 -1
- package/script/clean-assets/android.js +2 -2
- package/script/clean-assets/ios.d.ts.map +1 -1
- package/script/clean-assets/ios.js +2 -0
- package/script/copy-assets/ios.d.ts +1 -1
- package/script/copy-assets/ios.d.ts.map +1 -1
- package/script/copy-assets/ios.js +10 -5
- package/script/main.js +3 -3
|
@@ -2,11 +2,11 @@ import * as dntShim from "../_dnt.shims.js";
|
|
|
2
2
|
import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
3
3
|
export default async function cleanAssetsAndroid(filePaths, _platformConfig, options) {
|
|
4
4
|
console.log(`options path in cleanAssetsAndroid: ${options.path}`);
|
|
5
|
-
|
|
5
|
+
await Promise.all(filePaths.map(async (p) => {
|
|
6
6
|
const target = path.join(options.path, path.basename(p));
|
|
7
7
|
const st = await dntShim.Deno.lstat(target);
|
|
8
8
|
if (st.isFile) {
|
|
9
9
|
await dntShim.Deno.remove(target);
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
}));
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"AASA,wBAA8B,cAAc,CAC1C,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"AASA,wBAA8B,cAAc,CAC1C,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,iBAiC9B"}
|
package/esm/clean-assets/ios.js
CHANGED
|
@@ -10,6 +10,7 @@ export default async function cleanAssetsIos(filePaths, platformConfig, options)
|
|
|
10
10
|
const project = xcode.project(platformConfig.pbxprojPath).parseSync();
|
|
11
11
|
createGroupWithMessage(project, "Resources");
|
|
12
12
|
for (const targetUUID of getTargetUUIDs(project)) {
|
|
13
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
13
14
|
const plist = await getPlist(project, platformConfig.path, targetUUID);
|
|
14
15
|
const removedFiles = filePaths.map((p) => {
|
|
15
16
|
return project.removeResourceFile(path.relative(platformConfig.path, p), { target: targetUUID });
|
|
@@ -19,6 +20,7 @@ export default async function cleanAssetsIos(filePaths, platformConfig, options)
|
|
|
19
20
|
const allFonts = existingFonts.filter((file) => removedFiles.indexOf(file) === -1);
|
|
20
21
|
plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
|
|
21
22
|
}
|
|
23
|
+
// deno-lint-ignore no-await-in-loop
|
|
22
24
|
await writePlist(project, platformConfig.path, plist, targetUUID);
|
|
23
25
|
}
|
|
24
26
|
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
package/esm/copy-assets/ios.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAWA,wBAA8B,
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAWA,wBAA8B,aAAa,CACzC,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,iBAyC9B"}
|
package/esm/copy-assets/ios.js
CHANGED
|
@@ -8,7 +8,7 @@ import createGroupWithMessage from "../react-native-lib/ios/createGroupWithMessa
|
|
|
8
8
|
import getPlist from "../react-native-lib/ios/getPlist.js";
|
|
9
9
|
import writePlist from "../react-native-lib/ios/writePlist.js";
|
|
10
10
|
import { getTargetUUIDs } from "../utils.js";
|
|
11
|
-
export default async function
|
|
11
|
+
export default async function copyAssetsIos(filePaths, platformConfig, options) {
|
|
12
12
|
const project = xcode.project(platformConfig.pbxprojPath);
|
|
13
13
|
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => {
|
|
14
14
|
const decoder = new TextDecoder("utf-8");
|
|
@@ -16,14 +16,19 @@ export default async function cleanAssetsIos(filePaths, platformConfig, options)
|
|
|
16
16
|
});
|
|
17
17
|
project.hash = xcodeParser.parse(pbxprojContent);
|
|
18
18
|
createGroupWithMessage(project, "Resources");
|
|
19
|
+
const fileBasenames = filePaths.map((p) => path.basename(p));
|
|
19
20
|
for (const targetUUID of getTargetUUIDs(project)) {
|
|
21
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
20
22
|
const plist = await getPlist(project, platformConfig.path, targetUUID);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
+
for (const filePath of filePaths) {
|
|
24
|
+
project.addResourceFile(path.relative(platformConfig.path, filePath), { target: targetUUID });
|
|
25
|
+
}
|
|
26
|
+
if (options.addFont && plist) {
|
|
23
27
|
const existingFonts = plist.UIAppFonts || [];
|
|
24
|
-
const allFonts = [...existingFonts, ...
|
|
28
|
+
const allFonts = [...existingFonts, ...fileBasenames];
|
|
25
29
|
plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
|
|
26
30
|
}
|
|
31
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
27
32
|
await writePlist(project, platformConfig.path, plist, targetUUID);
|
|
28
33
|
}
|
|
29
34
|
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
package/esm/main.js
CHANGED
|
@@ -137,9 +137,7 @@ export const linkAssets = async ({ rootPath, platforms, shouldUnlink = true, })
|
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
const loadAll = async () => {
|
|
140
|
-
|
|
141
|
-
await loadAsset(p);
|
|
142
|
-
}
|
|
140
|
+
await Promise.all(assetsPaths.map((p) => loadAsset(p)));
|
|
143
141
|
assets = clearDuplicated(assets);
|
|
144
142
|
};
|
|
145
143
|
// run loading synchronously for simplicity
|
|
@@ -171,10 +169,12 @@ export const linkAssets = async ({ rootPath, platforms, shouldUnlink = true, })
|
|
|
171
169
|
.filter(filterFilesToIgnore);
|
|
172
170
|
if (su && prevRelativeAssetsWithExt.length > 0) {
|
|
173
171
|
console.info(`Cleaning previously linked ${fileConfigName} assets from ${name} project, prevRelativeAssetsWithExt: ${prevRelativeAssetsWithExt.map((x) => x.path)}`);
|
|
172
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
174
173
|
await cleanAssets(prevRelativeAssetsWithExt.map(({ path: filePath }) => getAbsolute({ filePath, dirPath: rp })), platformConfig, options);
|
|
175
174
|
}
|
|
176
175
|
if (assetsWithExt.length > 0) {
|
|
177
176
|
console.info(`Linking ${fileConfigName} assets to ${name} project`);
|
|
177
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
178
178
|
await copyAssets(assetsWithExt.map(({ path: assetPath }) => assetPath), platformConfig, options);
|
|
179
179
|
}
|
|
180
180
|
}
|
package/package.json
CHANGED
|
@@ -38,11 +38,11 @@ const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
|
38
38
|
const path = __importStar(require("../deps/jsr.io/@std/path/1.1.4/mod.js"));
|
|
39
39
|
async function cleanAssetsAndroid(filePaths, _platformConfig, options) {
|
|
40
40
|
console.log(`options path in cleanAssetsAndroid: ${options.path}`);
|
|
41
|
-
|
|
41
|
+
await Promise.all(filePaths.map(async (p) => {
|
|
42
42
|
const target = path.join(options.path, path.basename(p));
|
|
43
43
|
const st = await dntShim.Deno.lstat(target);
|
|
44
44
|
if (st.isFile) {
|
|
45
45
|
await dntShim.Deno.remove(target);
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}));
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"AASA,wBAA8B,cAAc,CAC1C,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"AASA,wBAA8B,cAAc,CAC1C,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,iBAiC9B"}
|
|
@@ -49,6 +49,7 @@ async function cleanAssetsIos(filePaths, platformConfig, options) {
|
|
|
49
49
|
const project = xcode.project(platformConfig.pbxprojPath).parseSync();
|
|
50
50
|
(0, createGroupWithMessage_js_1.default)(project, "Resources");
|
|
51
51
|
for (const targetUUID of (0, utils_js_1.getTargetUUIDs)(project)) {
|
|
52
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
52
53
|
const plist = await (0, getPlist_js_1.default)(project, platformConfig.path, targetUUID);
|
|
53
54
|
const removedFiles = filePaths.map((p) => {
|
|
54
55
|
return project.removeResourceFile(path.relative(platformConfig.path, p), { target: targetUUID });
|
|
@@ -58,6 +59,7 @@ async function cleanAssetsIos(filePaths, platformConfig, options) {
|
|
|
58
59
|
const allFonts = existingFonts.filter((file) => removedFiles.indexOf(file) === -1);
|
|
59
60
|
plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
|
|
60
61
|
}
|
|
62
|
+
// deno-lint-ignore no-await-in-loop
|
|
61
63
|
await (0, writePlist_js_1.default)(project, platformConfig.path, plist, targetUUID);
|
|
62
64
|
}
|
|
63
65
|
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAWA,wBAA8B,
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAWA,wBAA8B,aAAa,CACzC,SAAS,EAAE,MAAM,EAAE,EACnB,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,iBAyC9B"}
|
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.default =
|
|
39
|
+
exports.default = copyAssetsIos;
|
|
40
40
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
41
41
|
const path = __importStar(require("../deps/jsr.io/@std/path/1.1.4/mod.js"));
|
|
42
42
|
/// <reference types="../xcode.d.ts" />
|
|
@@ -47,7 +47,7 @@ const createGroupWithMessage_js_1 = __importDefault(require("../react-native-lib
|
|
|
47
47
|
const getPlist_js_1 = __importDefault(require("../react-native-lib/ios/getPlist.js"));
|
|
48
48
|
const writePlist_js_1 = __importDefault(require("../react-native-lib/ios/writePlist.js"));
|
|
49
49
|
const utils_js_1 = require("../utils.js");
|
|
50
|
-
async function
|
|
50
|
+
async function copyAssetsIos(filePaths, platformConfig, options) {
|
|
51
51
|
const project = xcode.project(platformConfig.pbxprojPath);
|
|
52
52
|
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => {
|
|
53
53
|
const decoder = new TextDecoder("utf-8");
|
|
@@ -55,14 +55,19 @@ async function cleanAssetsIos(filePaths, platformConfig, options) {
|
|
|
55
55
|
});
|
|
56
56
|
project.hash = xcodeParser.parse(pbxprojContent);
|
|
57
57
|
(0, createGroupWithMessage_js_1.default)(project, "Resources");
|
|
58
|
+
const fileBasenames = filePaths.map((p) => path.basename(p));
|
|
58
59
|
for (const targetUUID of (0, utils_js_1.getTargetUUIDs)(project)) {
|
|
60
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
59
61
|
const plist = await (0, getPlist_js_1.default)(project, platformConfig.path, targetUUID);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
+
for (const filePath of filePaths) {
|
|
63
|
+
project.addResourceFile(path.relative(platformConfig.path, filePath), { target: targetUUID });
|
|
64
|
+
}
|
|
65
|
+
if (options.addFont && plist) {
|
|
62
66
|
const existingFonts = plist.UIAppFonts || [];
|
|
63
|
-
const allFonts = [...existingFonts, ...
|
|
67
|
+
const allFonts = [...existingFonts, ...fileBasenames];
|
|
64
68
|
plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
|
|
65
69
|
}
|
|
70
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
66
71
|
await (0, writePlist_js_1.default)(project, platformConfig.path, plist, targetUUID);
|
|
67
72
|
}
|
|
68
73
|
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
package/script/main.js
CHANGED
|
@@ -176,9 +176,7 @@ const linkAssets = async ({ rootPath, platforms, shouldUnlink = true, }) => {
|
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
const loadAll = async () => {
|
|
179
|
-
|
|
180
|
-
await loadAsset(p);
|
|
181
|
-
}
|
|
179
|
+
await Promise.all(assetsPaths.map((p) => loadAsset(p)));
|
|
182
180
|
assets = clearDuplicated(assets);
|
|
183
181
|
};
|
|
184
182
|
// run loading synchronously for simplicity
|
|
@@ -210,10 +208,12 @@ const linkAssets = async ({ rootPath, platforms, shouldUnlink = true, }) => {
|
|
|
210
208
|
.filter(filterFilesToIgnore);
|
|
211
209
|
if (su && prevRelativeAssetsWithExt.length > 0) {
|
|
212
210
|
console.info(`Cleaning previously linked ${fileConfigName} assets from ${name} project, prevRelativeAssetsWithExt: ${prevRelativeAssetsWithExt.map((x) => x.path)}`);
|
|
211
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
213
212
|
await cleanAssets(prevRelativeAssetsWithExt.map(({ path: filePath }) => getAbsolute({ filePath, dirPath: rp })), platformConfig, options);
|
|
214
213
|
}
|
|
215
214
|
if (assetsWithExt.length > 0) {
|
|
216
215
|
console.info(`Linking ${fileConfigName} assets to ${name} project`);
|
|
216
|
+
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
217
217
|
await copyAssets(assetsWithExt.map(({ path: assetPath }) => assetPath), platformConfig, options);
|
|
218
218
|
}
|
|
219
219
|
}
|