react-native-asset 2.2.14 → 2.2.15
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/ios.d.ts.map +1 -1
- package/esm/clean-assets/ios.js +5 -1
- package/esm/copy-assets/ios.d.ts.map +1 -1
- package/esm/copy-assets/ios.js +27 -9
- package/esm/utils.d.ts +3 -3
- package/esm/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/clean-assets/ios.d.ts.map +1 -1
- package/script/clean-assets/ios.js +5 -1
- package/script/copy-assets/ios.d.ts.map +1 -1
- package/script/copy-assets/ios.js +27 -9
- package/script/utils.d.ts +3 -3
- package/script/utils.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"AAaA,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,iBAqC9B"}
|
package/esm/clean-assets/ios.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
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
|
import * as xcode from "xcode";
|
|
4
|
+
import * as xcodeParserUntyped from "xcode/lib/parser/pbxproj.js";
|
|
5
|
+
const xcodeParser = xcodeParserUntyped;
|
|
4
6
|
import createGroupWithMessage from "../react-native-lib/ios/createGroupWithMessage.js";
|
|
5
7
|
import getPlist from "../react-native-lib/ios/getPlist.js";
|
|
6
8
|
import writePlist from "../react-native-lib/ios/writePlist.js";
|
|
7
9
|
import { getTargetUUIDs } from "../utils.js";
|
|
8
10
|
export default async function cleanAssetsIos(filePaths, platformConfig, options) {
|
|
9
|
-
const project = xcode.project(platformConfig.pbxprojPath)
|
|
11
|
+
const project = xcode.project(platformConfig.pbxprojPath);
|
|
12
|
+
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => new TextDecoder("utf-8").decode(buf));
|
|
13
|
+
project.hash = xcodeParser.parse(pbxprojContent);
|
|
10
14
|
createGroupWithMessage(project, "Resources");
|
|
11
15
|
for (const targetUUID of getTargetUUIDs(project)) {
|
|
12
16
|
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAaA,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,
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAaA,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,iBAwD9B"}
|
package/esm/copy-assets/ios.js
CHANGED
|
@@ -9,19 +9,38 @@ import writePlist from "../react-native-lib/ios/writePlist.js";
|
|
|
9
9
|
import { getTargetUUIDs } from "../utils.js";
|
|
10
10
|
export default async function copyAssetsIos(filePaths, platformConfig, options) {
|
|
11
11
|
const project = xcode.project(platformConfig.pbxprojPath);
|
|
12
|
-
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) =>
|
|
13
|
-
const decoder = new TextDecoder("utf-8");
|
|
14
|
-
return decoder.decode(buf);
|
|
15
|
-
});
|
|
12
|
+
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => new TextDecoder("utf-8").decode(buf));
|
|
16
13
|
project.hash = xcodeParser.parse(pbxprojContent);
|
|
17
14
|
createGroupWithMessage(project, "Resources");
|
|
15
|
+
const targetUUIDs = getTargetUUIDs(project);
|
|
16
|
+
for (const filePath of filePaths) {
|
|
17
|
+
const relativeFilePath = path.relative(platformConfig.path, filePath);
|
|
18
|
+
let file = false;
|
|
19
|
+
for (const target of targetUUIDs) {
|
|
20
|
+
if (!file) {
|
|
21
|
+
file = project.addResourceFile(relativeFilePath, { target });
|
|
22
|
+
if (!file) {
|
|
23
|
+
// We know the resource is already in the project but there's no obvious way to get the PBXFile reference
|
|
24
|
+
// It's kinda sloppy but we can remove and re-add the resource to get the reference
|
|
25
|
+
// This has the side effect of unlinking all other targets... not a problem because we're about to link them anyway
|
|
26
|
+
project.removeResourceFile(relativeFilePath, { target });
|
|
27
|
+
file = project.addResourceFile(relativeFilePath, { target });
|
|
28
|
+
if (!file) {
|
|
29
|
+
throw new Error(`Failed to add file to pbxproj "${filePath}"`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
file.target = target;
|
|
35
|
+
project.addToPbxResourcesBuildPhase(file);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
|
18
40
|
const fileBasenames = filePaths.map((p) => path.basename(p));
|
|
19
|
-
for (const targetUUID of
|
|
41
|
+
for (const targetUUID of targetUUIDs) {
|
|
20
42
|
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
21
43
|
const plist = await getPlist(project, platformConfig.path, targetUUID);
|
|
22
|
-
for (const filePath of filePaths) {
|
|
23
|
-
project.addResourceFile(path.relative(platformConfig.path, filePath), { target: targetUUID });
|
|
24
|
-
}
|
|
25
44
|
if (options.addFont && plist) {
|
|
26
45
|
const existingFonts = plist.UIAppFonts || [];
|
|
27
46
|
const allFonts = [...existingFonts, ...fileBasenames];
|
|
@@ -30,5 +49,4 @@ export default async function copyAssetsIos(filePaths, platformConfig, options)
|
|
|
30
49
|
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
31
50
|
await writePlist(project, platformConfig.path, plist, targetUUID);
|
|
32
51
|
}
|
|
33
|
-
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
|
34
52
|
}
|
package/esm/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PBXProject } from "./xcode";
|
|
2
2
|
/**
|
|
3
3
|
* Get an array containing the UUID of each target in the project
|
|
4
4
|
*/
|
|
5
|
-
export declare function getTargetUUIDs(project:
|
|
5
|
+
export declare function getTargetUUIDs(project: PBXProject): string[];
|
|
6
6
|
/**
|
|
7
7
|
* Get a target by UUID
|
|
8
8
|
*/
|
|
9
|
-
export declare function getTargetByUUID(project:
|
|
9
|
+
export declare function getTargetByUUID(project: PBXProject, uuid: string): unknown;
|
|
10
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/esm/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,EAAE,CAE5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAEhE"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/clean-assets/ios.ts"],"names":[],"mappings":"AAaA,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,iBAqC9B"}
|
|
@@ -40,12 +40,16 @@ exports.default = cleanAssetsIos;
|
|
|
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
|
const xcode = __importStar(require("xcode"));
|
|
43
|
+
const xcodeParserUntyped = __importStar(require("xcode/lib/parser/pbxproj.js"));
|
|
44
|
+
const xcodeParser = xcodeParserUntyped;
|
|
43
45
|
const createGroupWithMessage_js_1 = __importDefault(require("../react-native-lib/ios/createGroupWithMessage.js"));
|
|
44
46
|
const getPlist_js_1 = __importDefault(require("../react-native-lib/ios/getPlist.js"));
|
|
45
47
|
const writePlist_js_1 = __importDefault(require("../react-native-lib/ios/writePlist.js"));
|
|
46
48
|
const utils_js_1 = require("../utils.js");
|
|
47
49
|
async function cleanAssetsIos(filePaths, platformConfig, options) {
|
|
48
|
-
const project = xcode.project(platformConfig.pbxprojPath)
|
|
50
|
+
const project = xcode.project(platformConfig.pbxprojPath);
|
|
51
|
+
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => new TextDecoder("utf-8").decode(buf));
|
|
52
|
+
project.hash = xcodeParser.parse(pbxprojContent);
|
|
49
53
|
(0, createGroupWithMessage_js_1.default)(project, "Resources");
|
|
50
54
|
for (const targetUUID of (0, utils_js_1.getTargetUUIDs)(project)) {
|
|
51
55
|
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAaA,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,
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAaA,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,iBAwD9B"}
|
|
@@ -48,19 +48,38 @@ const writePlist_js_1 = __importDefault(require("../react-native-lib/ios/writePl
|
|
|
48
48
|
const utils_js_1 = require("../utils.js");
|
|
49
49
|
async function copyAssetsIos(filePaths, platformConfig, options) {
|
|
50
50
|
const project = xcode.project(platformConfig.pbxprojPath);
|
|
51
|
-
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) =>
|
|
52
|
-
const decoder = new TextDecoder("utf-8");
|
|
53
|
-
return decoder.decode(buf);
|
|
54
|
-
});
|
|
51
|
+
const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => new TextDecoder("utf-8").decode(buf));
|
|
55
52
|
project.hash = xcodeParser.parse(pbxprojContent);
|
|
56
53
|
(0, createGroupWithMessage_js_1.default)(project, "Resources");
|
|
54
|
+
const targetUUIDs = (0, utils_js_1.getTargetUUIDs)(project);
|
|
55
|
+
for (const filePath of filePaths) {
|
|
56
|
+
const relativeFilePath = path.relative(platformConfig.path, filePath);
|
|
57
|
+
let file = false;
|
|
58
|
+
for (const target of targetUUIDs) {
|
|
59
|
+
if (!file) {
|
|
60
|
+
file = project.addResourceFile(relativeFilePath, { target });
|
|
61
|
+
if (!file) {
|
|
62
|
+
// We know the resource is already in the project but there's no obvious way to get the PBXFile reference
|
|
63
|
+
// It's kinda sloppy but we can remove and re-add the resource to get the reference
|
|
64
|
+
// This has the side effect of unlinking all other targets... not a problem because we're about to link them anyway
|
|
65
|
+
project.removeResourceFile(relativeFilePath, { target });
|
|
66
|
+
file = project.addResourceFile(relativeFilePath, { target });
|
|
67
|
+
if (!file) {
|
|
68
|
+
throw new Error(`Failed to add file to pbxproj "${filePath}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
file.target = target;
|
|
74
|
+
project.addToPbxResourcesBuildPhase(file);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
|
57
79
|
const fileBasenames = filePaths.map((p) => path.basename(p));
|
|
58
|
-
for (const targetUUID of
|
|
80
|
+
for (const targetUUID of targetUUIDs) {
|
|
59
81
|
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
60
82
|
const plist = await (0, getPlist_js_1.default)(project, platformConfig.path, targetUUID);
|
|
61
|
-
for (const filePath of filePaths) {
|
|
62
|
-
project.addResourceFile(path.relative(platformConfig.path, filePath), { target: targetUUID });
|
|
63
|
-
}
|
|
64
83
|
if (options.addFont && plist) {
|
|
65
84
|
const existingFonts = plist.UIAppFonts || [];
|
|
66
85
|
const allFonts = [...existingFonts, ...fileBasenames];
|
|
@@ -69,5 +88,4 @@ async function copyAssetsIos(filePaths, platformConfig, options) {
|
|
|
69
88
|
// deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
|
|
70
89
|
await (0, writePlist_js_1.default)(project, platformConfig.path, plist, targetUUID);
|
|
71
90
|
}
|
|
72
|
-
await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
|
|
73
91
|
}
|
package/script/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PBXProject } from "./xcode";
|
|
2
2
|
/**
|
|
3
3
|
* Get an array containing the UUID of each target in the project
|
|
4
4
|
*/
|
|
5
|
-
export declare function getTargetUUIDs(project:
|
|
5
|
+
export declare function getTargetUUIDs(project: PBXProject): string[];
|
|
6
6
|
/**
|
|
7
7
|
* Get a target by UUID
|
|
8
8
|
*/
|
|
9
|
-
export declare function getTargetByUUID(project:
|
|
9
|
+
export declare function getTargetByUUID(project: PBXProject, uuid: string): unknown;
|
|
10
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/script/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,EAAE,CAE5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAEhE"}
|