The best way to control Claude Code, Codex and more from any computer or phone
| 1 | "use strict"; |
| 2 | |
| 3 | // Precede expo-widgets so its reverse-ordered mods create and wipe the target before assets are added. |
| 4 | |
| 5 | const path = require("path"); |
| 6 | const fs = require("fs"); |
| 7 | const { withDangerousMod, withXcodeProject } = require("expo/config-plugins"); |
| 8 | const { addWidgetAssetCatalog } = require("./lib/addWidgetAssetCatalog.cjs"); |
| 9 | |
| 10 | const TARGET_NAME = "ExpoWidgetsTarget"; |
| 11 | const CATALOG_NAME = "Assets.xcassets"; |
| 12 | const IMAGE_SET = "T3Mark.imageset"; |
| 13 | const SVG_NAME = "T3Mark.svg"; |
| 14 | |
| 15 | const CATALOG_CONTENTS = JSON.stringify({ info: { author: "expo", version: 1 } }, null, 2) + "\n"; |
| 16 | const IMAGE_SET_CONTENTS = |
| 17 | JSON.stringify( |
| 18 | { |
| 19 | images: [{ idiom: "universal", filename: SVG_NAME }], |
| 20 | info: { author: "expo", version: 1 }, |
| 21 | properties: { |
| 22 | "preserves-vector-representation": true, |
| 23 | "template-rendering-intent": "template", |
| 24 | }, |
| 25 | }, |
| 26 | null, |
| 27 | 2, |
| 28 | ) + "\n"; |
| 29 | |
| 30 | function withAssetFiles(config) { |
| 31 | return withDangerousMod(config, [ |
| 32 | "ios", |
| 33 | (cfg) => { |
| 34 | const source = path.join(cfg.modRequest.projectRoot, "assets", "widget", SVG_NAME); |
| 35 | const catalogDir = path.join(cfg.modRequest.platformProjectRoot, TARGET_NAME, CATALOG_NAME); |
| 36 | const imageSetDir = path.join(catalogDir, IMAGE_SET); |
| 37 | fs.mkdirSync(imageSetDir, { recursive: true }); |
| 38 | fs.writeFileSync(path.join(catalogDir, "Contents.json"), CATALOG_CONTENTS); |
| 39 | fs.writeFileSync(path.join(imageSetDir, "Contents.json"), IMAGE_SET_CONTENTS); |
| 40 | fs.copyFileSync(source, path.join(imageSetDir, SVG_NAME)); |
| 41 | return cfg; |
| 42 | }, |
| 43 | ]); |
| 44 | } |
| 45 | |
| 46 | function withAssetWiring(config) { |
| 47 | return withXcodeProject(config, (cfg) => { |
| 48 | addWidgetAssetCatalog(cfg.modResults, { targetName: TARGET_NAME }); |
| 49 | return cfg; |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | module.exports = function withWidgetLogoAsset(config) { |
| 54 | return withAssetWiring(withAssetFiles(config)); |
| 55 | }; |