react-native-asset 2.2.12 → 2.2.14

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.
@@ -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
- for (const p of filePaths) {
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,iBA+B9B"}
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"}
@@ -1,6 +1,5 @@
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
- /// <reference types="../xcode.d.ts" />
4
3
  import * as xcode from "xcode";
5
4
  import createGroupWithMessage from "../react-native-lib/ios/createGroupWithMessage.js";
6
5
  import getPlist from "../react-native-lib/ios/getPlist.js";
@@ -10,6 +9,7 @@ export default async function cleanAssetsIos(filePaths, platformConfig, options)
10
9
  const project = xcode.project(platformConfig.pbxprojPath).parseSync();
11
10
  createGroupWithMessage(project, "Resources");
12
11
  for (const targetUUID of getTargetUUIDs(project)) {
12
+ // deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
13
13
  const plist = await getPlist(project, platformConfig.path, targetUUID);
14
14
  const removedFiles = filePaths.map((p) => {
15
15
  return project.removeResourceFile(path.relative(platformConfig.path, p), { target: targetUUID });
@@ -19,6 +19,7 @@ export default async function cleanAssetsIos(filePaths, platformConfig, options)
19
19
  const allFonts = existingFonts.filter((file) => removedFiles.indexOf(file) === -1);
20
20
  plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
21
21
  }
22
+ // deno-lint-ignore no-await-in-loop
22
23
  await writePlist(project, platformConfig.path, plist, targetUUID);
23
24
  }
24
25
  await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
@@ -1,4 +1,4 @@
1
- export default function cleanAssetsIos(filePaths: string[], platformConfig: {
1
+ export default function copyAssetsIos(filePaths: string[], platformConfig: {
2
2
  path: string;
3
3
  pbxprojPath: string;
4
4
  }, options: {
@@ -1 +1 @@
1
- {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAWA,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,iBAsC9B"}
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,iBAyC9B"}
@@ -1,14 +1,13 @@
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
- /// <reference types="../xcode.d.ts" />
4
3
  import * as xcode from "xcode";
5
- /// <reference types="../xcode.d.ts" />
6
- import * as xcodeParser from "xcode/lib/parser/pbxproj.js";
4
+ import * as xcodeParserUntyped from "xcode/lib/parser/pbxproj.js";
5
+ const xcodeParser = xcodeParserUntyped;
7
6
  import createGroupWithMessage from "../react-native-lib/ios/createGroupWithMessage.js";
8
7
  import getPlist from "../react-native-lib/ios/getPlist.js";
9
8
  import writePlist from "../react-native-lib/ios/writePlist.js";
10
9
  import { getTargetUUIDs } from "../utils.js";
11
- export default async function cleanAssetsIos(filePaths, platformConfig, options) {
10
+ export default async function copyAssetsIos(filePaths, platformConfig, options) {
12
11
  const project = xcode.project(platformConfig.pbxprojPath);
13
12
  const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => {
14
13
  const decoder = new TextDecoder("utf-8");
@@ -16,14 +15,19 @@ export default async function cleanAssetsIos(filePaths, platformConfig, options)
16
15
  });
17
16
  project.hash = xcodeParser.parse(pbxprojContent);
18
17
  createGroupWithMessage(project, "Resources");
18
+ const fileBasenames = filePaths.map((p) => path.basename(p));
19
19
  for (const targetUUID of getTargetUUIDs(project)) {
20
+ // deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
20
21
  const plist = await getPlist(project, platformConfig.path, targetUUID);
21
- const addedFiles = filePaths.map((p) => project.addResourceFile(path.relative(platformConfig.path, p), { target: targetUUID })).filter((x) => x).map((file) => file.basename);
22
- if (options.addFont) {
22
+ for (const filePath of filePaths) {
23
+ project.addResourceFile(path.relative(platformConfig.path, filePath), { target: targetUUID });
24
+ }
25
+ if (options.addFont && plist) {
23
26
  const existingFonts = plist.UIAppFonts || [];
24
- const allFonts = [...existingFonts, ...addedFiles];
27
+ const allFonts = [...existingFonts, ...fileBasenames];
25
28
  plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
26
29
  }
30
+ // deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
27
31
  await writePlist(project, platformConfig.path, plist, targetUUID);
28
32
  }
29
33
  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
- for (const p of assetsPaths) {
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/esm/utils.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type xcode from "xcode";
1
+ import type { Project } 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: xcode.Project): string[];
5
+ export declare function getTargetUUIDs(project: Project): string[];
6
6
  /**
7
7
  * Get a target by UUID
8
8
  */
9
- export declare function getTargetByUUID(project: xcode.Project, uuid: string): unknown;
9
+ export declare function getTargetByUUID(project: Project, uuid: string): unknown;
10
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,EAAE,CAE/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,WAEnE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAEzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAE7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-asset",
3
- "version": "2.2.12",
3
+ "version": "2.2.14",
4
4
  "description": "Linking and unlinking of assets in your react-native app, works for fonts and sounds",
5
5
  "keywords": [
6
6
  "react-native",
@@ -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
- for (const p of filePaths) {
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,iBA+B9B"}
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"}
@@ -39,7 +39,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  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
- /// <reference types="../xcode.d.ts" />
43
42
  const xcode = __importStar(require("xcode"));
44
43
  const createGroupWithMessage_js_1 = __importDefault(require("../react-native-lib/ios/createGroupWithMessage.js"));
45
44
  const getPlist_js_1 = __importDefault(require("../react-native-lib/ios/getPlist.js"));
@@ -49,6 +48,7 @@ async function cleanAssetsIos(filePaths, platformConfig, options) {
49
48
  const project = xcode.project(platformConfig.pbxprojPath).parseSync();
50
49
  (0, createGroupWithMessage_js_1.default)(project, "Resources");
51
50
  for (const targetUUID of (0, utils_js_1.getTargetUUIDs)(project)) {
51
+ // deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
52
52
  const plist = await (0, getPlist_js_1.default)(project, platformConfig.path, targetUUID);
53
53
  const removedFiles = filePaths.map((p) => {
54
54
  return project.removeResourceFile(path.relative(platformConfig.path, p), { target: targetUUID });
@@ -58,6 +58,7 @@ async function cleanAssetsIos(filePaths, platformConfig, options) {
58
58
  const allFonts = existingFonts.filter((file) => removedFiles.indexOf(file) === -1);
59
59
  plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
60
60
  }
61
+ // deno-lint-ignore no-await-in-loop
61
62
  await (0, writePlist_js_1.default)(project, platformConfig.path, plist, targetUUID);
62
63
  }
63
64
  await dntShim.Deno.writeTextFile(platformConfig.pbxprojPath, project.writeSync());
@@ -1,4 +1,4 @@
1
- export default function cleanAssetsIos(filePaths: string[], platformConfig: {
1
+ export default function copyAssetsIos(filePaths: string[], platformConfig: {
2
2
  path: string;
3
3
  pbxprojPath: string;
4
4
  }, options: {
@@ -1 +1 @@
1
- {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/copy-assets/ios.ts"],"names":[],"mappings":"AAWA,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,iBAsC9B"}
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,iBAyC9B"}
@@ -36,18 +36,17 @@ 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 = cleanAssetsIos;
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
- /// <reference types="../xcode.d.ts" />
43
42
  const xcode = __importStar(require("xcode"));
44
- /// <reference types="../xcode.d.ts" />
45
- const xcodeParser = __importStar(require("xcode/lib/parser/pbxproj.js"));
43
+ const xcodeParserUntyped = __importStar(require("xcode/lib/parser/pbxproj.js"));
44
+ const xcodeParser = xcodeParserUntyped;
46
45
  const createGroupWithMessage_js_1 = __importDefault(require("../react-native-lib/ios/createGroupWithMessage.js"));
47
46
  const getPlist_js_1 = __importDefault(require("../react-native-lib/ios/getPlist.js"));
48
47
  const writePlist_js_1 = __importDefault(require("../react-native-lib/ios/writePlist.js"));
49
48
  const utils_js_1 = require("../utils.js");
50
- async function cleanAssetsIos(filePaths, platformConfig, options) {
49
+ async function copyAssetsIos(filePaths, platformConfig, options) {
51
50
  const project = xcode.project(platformConfig.pbxprojPath);
52
51
  const pbxprojContent = await dntShim.Deno.readFile(platformConfig.pbxprojPath).then((buf) => {
53
52
  const decoder = new TextDecoder("utf-8");
@@ -55,14 +54,19 @@ async function cleanAssetsIos(filePaths, platformConfig, options) {
55
54
  });
56
55
  project.hash = xcodeParser.parse(pbxprojContent);
57
56
  (0, createGroupWithMessage_js_1.default)(project, "Resources");
57
+ const fileBasenames = filePaths.map((p) => path.basename(p));
58
58
  for (const targetUUID of (0, utils_js_1.getTargetUUIDs)(project)) {
59
+ // deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
59
60
  const plist = await (0, getPlist_js_1.default)(project, platformConfig.path, targetUUID);
60
- const addedFiles = filePaths.map((p) => project.addResourceFile(path.relative(platformConfig.path, p), { target: targetUUID })).filter((x) => x).map((file) => file.basename);
61
- if (options.addFont) {
61
+ for (const filePath of filePaths) {
62
+ project.addResourceFile(path.relative(platformConfig.path, filePath), { target: targetUUID });
63
+ }
64
+ if (options.addFont && plist) {
62
65
  const existingFonts = plist.UIAppFonts || [];
63
- const allFonts = [...existingFonts, ...addedFiles];
66
+ const allFonts = [...existingFonts, ...fileBasenames];
64
67
  plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing
65
68
  }
69
+ // deno-lint-ignore no-await-in-loop -- sequential read/write to same plist file
66
70
  await (0, writePlist_js_1.default)(project, platformConfig.path, plist, targetUUID);
67
71
  }
68
72
  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
- for (const p of assetsPaths) {
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
  }
package/script/utils.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type xcode from "xcode";
1
+ import type { Project } 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: xcode.Project): string[];
5
+ export declare function getTargetUUIDs(project: Project): string[];
6
6
  /**
7
7
  * Get a target by UUID
8
8
  */
9
- export declare function getTargetByUUID(project: xcode.Project, uuid: string): unknown;
9
+ export declare function getTargetByUUID(project: Project, uuid: string): unknown;
10
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,MAAM,EAAE,CAE/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,WAEnE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAEzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAE7D"}