expo-modules-autolinking 0.4.0 → 0.5.0

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/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.5.0 — 2021-12-03
14
+
15
+ ### 🎉 New features
16
+
17
+ - Patch React podspecs on the fly to support Swift integration. ([#15299](https://github.com/expo/expo/pull/15299) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 0.4.0 — 2021-11-17
14
20
 
15
21
  ### 🎉 New features
@@ -17,6 +23,7 @@
17
23
  - Added "silent" property for silencing resolution warnings. ([#14891](https://github.com/expo/expo/pull/14891) by [@EvanBacon](https://github.com/EvanBacon))
18
24
  - Listing module's app delegate subscribers in the generated `ExpoModulesProvider.swift`. ([#14867](https://github.com/expo/expo/pull/14867) by [@tsapeta](https://github.com/tsapeta))
19
25
  - Search for Android package in the entire source code other than just `src` directory. ([#14883](https://github.com/expo/expo/pull/14883) by [@kudo](https://github.com/kudo))
26
+ - Introduce React Native bridge delegate handlers on iOS. ([#15138](https://github.com/expo/expo/pull/15138) by [@kudo](https://github.com/kudo))
20
27
 
21
28
  ### 🐛 Bug fixes
22
29
 
@@ -17,6 +17,10 @@ export declare class ExpoModuleConfig {
17
17
  * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.
18
18
  */
19
19
  iosAppDelegateSubscribers(): string[];
20
+ /**
21
+ * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.
22
+ */
23
+ iosReactDelegateHandlers(): string[];
20
24
  /**
21
25
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
22
26
  */
@@ -29,6 +29,13 @@ class ExpoModuleConfig {
29
29
  var _a, _b;
30
30
  return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.appDelegateSubscribers) !== null && _b !== void 0 ? _b : [];
31
31
  }
32
+ /**
33
+ * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.
34
+ */
35
+ iosReactDelegateHandlers() {
36
+ var _a, _b;
37
+ return (_b = (_a = this.rawConfig.ios) === null || _a === void 0 ? void 0 : _a.reactDelegateHandlers) !== null && _b !== void 0 ? _b : [];
38
+ }
32
39
  /**
33
40
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
34
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,gBAAgB;IAC3B,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;;QAC1C,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,SAAS,0CAAE,QAAQ,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,oBAAoB;;QAClB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,yBAAyB;;QACvB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,sBAAsB,mCAAI,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,0CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AArCD,4CAqCC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,IAAY;IAC5D,kDAAkD;IAClD,4DAA4D;IAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAwB,CAAC,CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { RawExpoModuleConfig, SupportedPlatform } from './types';\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModulesClassNames() {\n return this.rawConfig.ios?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModulesClassNames() {\n return this.rawConfig.android?.modulesClassNames ?? [];\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/**\n * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class.\n */\nexport function requireAndResolveExpoModuleConfig(path: string): ExpoModuleConfig {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n return new ExpoModuleConfig(require(path) as RawExpoModuleConfig);\n}\n"]}
1
+ {"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,gBAAgB;IAC3B,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;;QAC1C,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,SAAS,0CAAE,QAAQ,CAAC,QAAQ,CAAC,mCAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,oBAAoB;;QAClB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,yBAAyB;;QACvB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,sBAAsB,mCAAI,EAAE,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,0CAAE,qBAAqB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,wBAAwB;;QACtB,OAAO,MAAA,MAAA,IAAI,CAAC,SAAS,CAAC,OAAO,0CAAE,iBAAiB,mCAAI,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA5CD,4CA4CC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,IAAY;IAC5D,kDAAkD;IAClD,4DAA4D;IAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAwB,CAAC,CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { RawExpoModuleConfig, SupportedPlatform } from './types';\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModulesClassNames() {\n return this.rawConfig.ios?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n iosReactDelegateHandlers(): string[] {\n return this.rawConfig.ios?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModulesClassNames() {\n return this.rawConfig.android?.modulesClassNames ?? [];\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/**\n * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class.\n */\nexport function requireAndResolveExpoModuleConfig(path: string): ExpoModuleConfig {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n return new ExpoModuleConfig(require(path) as RawExpoModuleConfig);\n}\n"]}
@@ -7,3 +7,7 @@ export declare function resolveModuleAsync(packageName: string, revision: Packag
7
7
  * Generates Swift file that contains all autolinked Swift packages.
8
8
  */
9
9
  export declare function generatePackageListAsync(modules: ModuleDescriptor[], targetPath: string): Promise<void>;
10
+ /**
11
+ * Formats an array of modules to Swift's array containing ReactDelegateHandlers
12
+ */
13
+ export declare function formatArrayOfReactDelegateHandler(modules: ModuleDescriptor[]): string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generatePackageListAsync = exports.resolveModuleAsync = void 0;
6
+ exports.formatArrayOfReactDelegateHandler = exports.generatePackageListAsync = exports.resolveModuleAsync = void 0;
7
7
  const fast_glob_1 = __importDefault(require("fast-glob"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -11,7 +11,7 @@ const path_1 = __importDefault(require("path"));
11
11
  * Resolves module search result with additional details required for iOS platform.
12
12
  */
13
13
  async function resolveModuleAsync(packageName, revision, options) {
14
- var _a, _b;
14
+ var _a, _b, _c;
15
15
  const [podspecFile] = await (0, fast_glob_1.default)('*/*.podspec', {
16
16
  cwd: revision.path,
17
17
  ignore: ['**/node_modules/**'],
@@ -27,6 +27,7 @@ async function resolveModuleAsync(packageName, revision, options) {
27
27
  flags: options.flags,
28
28
  modulesClassNames: (_a = revision.config) === null || _a === void 0 ? void 0 : _a.iosModulesClassNames(),
29
29
  appDelegateSubscribers: (_b = revision.config) === null || _b === void 0 ? void 0 : _b.iosAppDelegateSubscribers(),
30
+ reactDelegateHandlers: (_c = revision.config) === null || _c === void 0 ? void 0 : _c.iosReactDelegateHandlers(),
30
31
  };
31
32
  }
32
33
  exports.resolveModuleAsync = resolveModuleAsync;
@@ -43,7 +44,9 @@ exports.generatePackageListAsync = generatePackageListAsync;
43
44
  * Generates the string to put into the generated package list.
44
45
  */
45
46
  async function generatePackageListFileContentAsync(modules, className) {
46
- const modulesToImport = modules.filter((module) => module.modulesClassNames.length + module.appDelegateSubscribers.length > 0);
47
+ const modulesToImport = modules.filter((module) => module.modulesClassNames.length ||
48
+ module.appDelegateSubscribers.length ||
49
+ module.reactDelegateHandlers.length);
47
50
  const pods = modulesToImport.map((module) => module.podName);
48
51
  const modulesClassNames = []
49
52
  .concat(...modulesToImport.map((module) => module.modulesClassNames))
@@ -51,6 +54,7 @@ async function generatePackageListFileContentAsync(modules, className) {
51
54
  const appDelegateSubscribers = []
52
55
  .concat(...modulesToImport.map((module) => module.appDelegateSubscribers))
53
56
  .filter(Boolean);
57
+ const reactDelegateHandlerModules = modulesToImport.filter((module) => !!module.reactDelegateHandlers.length);
54
58
  return `/**
55
59
  * Automatically generated by expo-modules-autolinking.
56
60
  *
@@ -69,6 +73,10 @@ public class ${className}: ModulesProvider {
69
73
  public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
70
74
  return ${formatArrayOfClassNames(appDelegateSubscribers)}
71
75
  }
76
+
77
+ public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
78
+ return ${formatArrayOfReactDelegateHandler(reactDelegateHandlerModules)}
79
+ }
72
80
  }
73
81
  `;
74
82
  }
@@ -80,4 +88,19 @@ function formatArrayOfClassNames(classNames) {
80
88
  return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
81
89
  ${indent.repeat(2)}]`;
82
90
  }
91
+ /**
92
+ * Formats an array of modules to Swift's array containing ReactDelegateHandlers
93
+ */
94
+ function formatArrayOfReactDelegateHandler(modules) {
95
+ const values = [];
96
+ for (const module of modules) {
97
+ for (const handler of module.reactDelegateHandlers) {
98
+ values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
99
+ }
100
+ }
101
+ const indent = ' ';
102
+ return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
103
+ ${indent.repeat(2)}]`;
104
+ }
105
+ exports.formatArrayOfReactDelegateHandler = formatArrayOfReactDelegateHandler;
83
106
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,QAAyB,EACzB,OAAsB;;IAEtB,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,IAAA,mBAAI,EAAC,aAAa,EAAE;QAC9C,GAAG,EAAE,QAAQ,CAAC,IAAI;QAClB,MAAM,EAAE,CAAC,oBAAoB,CAAC;KAC/B,CAAC,CAAC;IAEH,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,OAAO,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACtE,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAEvE,OAAO;QACL,OAAO;QACP,UAAU;QACV,KA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AM,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO;;;;;;;;EAQP,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,SAAS;eACF,SAAS;;aAEX,uBAAuB,CAAC,iBAAiB,CAAC;;;;aAI1C,uBAAuB,CAAC,sBAAsB,CAAC;;;CAG3D,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,UAAoB;IACnD,MAAM,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC5F,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ModuleDescriptor, PackageRevision, SearchOptions } from '../types';\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise<ModuleDescriptor | null> {\n const [podspecFile] = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n if (!podspecFile) {\n return null;\n }\n\n const podName = path.basename(podspecFile, path.extname(podspecFile));\n const podspecDir = path.dirname(path.join(revision.path, podspecFile));\n\n return {\n podName,\n podspecDir,\n flags: options.flags,\n modulesClassNames: revision.config?.iosModulesClassNames(),\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers(),\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptor[],\n targetPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptor[],\n className: string\n): Promise<string> {\n const modulesToImport = modules.filter(\n (module) => module.modulesClassNames.length + module.appDelegateSubscribers.length > 0\n );\n const pods = modulesToImport.map((module) => module.podName);\n\n const modulesClassNames = []\n .concat(...modulesToImport.map((module) => module.modulesClassNames))\n .filter(Boolean);\n\n const appDelegateSubscribers = []\n .concat(...modulesToImport.map((module) => module.appDelegateSubscribers))\n .filter(Boolean);\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${pods.map((podName) => `import ${podName}\\n`).join('')}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n return ${formatArrayOfClassNames(modulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n return ${formatArrayOfClassNames(appDelegateSubscribers)}\n }\n}\n`;\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n const indent = ' ';\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n"]}
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,QAAyB,EACzB,OAAsB;;IAEtB,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,IAAA,mBAAI,EAAC,aAAa,EAAE;QAC9C,GAAG,EAAE,QAAQ,CAAC,IAAI;QA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,CAAC,GAAG,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,OAA2B;IAC3E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,WAAW,eAAe,OAAO,QAAQ,CAAC,CAAC;SACjF;KACF;IACD,MAAM,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC3E,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC;AAVD,8EAUC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { ModuleDescriptor, PackageRevision, SearchOptions } from '../types';\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise<ModuleDescriptor | null> {\n const [podspecFile] = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n if (!podspecFile) {\n return null;\n }\n\n const podName = path.basename(podspecFile, path.extname(podspecFile));\n const podspecDir = path.dirname(path.join(revision.path, podspecFile));\n\n return {\n podName,\n podspecDir,\n flags: options.flags,\n modulesClassNames: revision.config?.iosModulesClassNames(),\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers(),\n reactDelegateHandlers: revision.config?.iosReactDelegateHandlers(),\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptor[],\n targetPath: string\n): Promise<void> {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptor[],\n className: string\n): Promise<string> {\n const modulesToImport = modules.filter(\n (module) =>\n module.modulesClassNames.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n const pods = modulesToImport.map((module) => module.podName);\n\n const modulesClassNames = []\n .concat(...modulesToImport.map((module) => module.modulesClassNames))\n .filter(Boolean);\n\n const appDelegateSubscribers = []\n .concat(...modulesToImport.map((module) => module.appDelegateSubscribers))\n .filter(Boolean);\n\n const reactDelegateHandlerModules = modulesToImport.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${pods.map((podName) => `import ${podName}\\n`).join('')}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n return ${formatArrayOfClassNames(modulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n return ${formatArrayOfClassNames(appDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n return ${formatArrayOfReactDelegateHandler(reactDelegateHandlerModules)}\n }\n}\n`;\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n const indent = ' ';\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n\n/**\n * Formats an array of modules to Swift's array containing ReactDelegateHandlers\n */\nexport function formatArrayOfReactDelegateHandler(modules: ModuleDescriptor[]): string {\n const values: string[] = [];\n for (const module of modules) {\n for (const handler of module.reactDelegateHandlers) {\n values.push(`(packageName: \"${module.packageName}\", handler: ${handler}.self)`);\n }\n }\n const indent = ' ';\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n"]}
package/build/types.d.ts CHANGED
@@ -46,6 +46,10 @@ export interface RawExpoModuleConfig {
46
46
  * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.
47
47
  */
48
48
  appDelegateSubscribers?: string[];
49
+ /**
50
+ * Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.
51
+ */
52
+ reactDelegateHandlers?: string[];
49
53
  };
50
54
  /**
51
55
  * Android-specific config.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ExpoModuleConfig } from './ExpoModuleConfig';\n\nexport type SupportedPlatform = 'ios' | 'android' | 'web';\n\nexport interface SearchOptions {\n // Available in the CLI\n searchPaths: string[];\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n platform: SupportedPlatform;\n silent?: boolean;\n\n // Scratched from project's config\n flags?: Record<string, any>;\n}\n\nexport interface ResolveOptions extends SearchOptions {\n json?: boolean;\n}\n\nexport interface GenerateOptions extends ResolveOptions {\n target: string;\n namespace?: string;\n empty?: boolean;\n}\n\nexport type PackageRevision = {\n path: string;\n version: string;\n config?: ExpoModuleConfig;\n duplicates?: PackageRevision[];\n};\n\nexport type SearchResults = {\n [moduleName: string]: PackageRevision;\n};\n\nexport type ModuleDescriptor = Record<string, any>;\n\n/**\n * Represents a raw config from `expo-module.json`.\n */\nexport interface RawExpoModuleConfig {\n /**\n * An array of supported platforms.\n */\n platforms?: SupportedPlatform[];\n\n /**\n * iOS-specific config.\n */\n ios?: {\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n */\n modulesClassNames?: string[];\n\n /**\n * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.\n */\n appDelegateSubscribers?: string[];\n };\n\n /**\n * Android-specific config.\n */\n android?: {\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n */\n modulesClassNames?: string[];\n };\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ExpoModuleConfig } from './ExpoModuleConfig';\n\nexport type SupportedPlatform = 'ios' | 'android' | 'web';\n\nexport interface SearchOptions {\n // Available in the CLI\n searchPaths: string[];\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n platform: SupportedPlatform;\n silent?: boolean;\n\n // Scratched from project's config\n flags?: Record<string, any>;\n}\n\nexport interface ResolveOptions extends SearchOptions {\n json?: boolean;\n}\n\nexport interface GenerateOptions extends ResolveOptions {\n target: string;\n namespace?: string;\n empty?: boolean;\n}\n\nexport type PackageRevision = {\n path: string;\n version: string;\n config?: ExpoModuleConfig;\n duplicates?: PackageRevision[];\n};\n\nexport type SearchResults = {\n [moduleName: string]: PackageRevision;\n};\n\nexport type ModuleDescriptor = Record<string, any>;\n\n/**\n * Represents a raw config from `expo-module.json`.\n */\nexport interface RawExpoModuleConfig {\n /**\n * An array of supported platforms.\n */\n platforms?: SupportedPlatform[];\n\n /**\n * iOS-specific config.\n */\n ios?: {\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n */\n modulesClassNames?: string[];\n\n /**\n * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.\n */\n appDelegateSubscribers?: string[];\n\n /**\n * Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.\n */\n reactDelegateHandlers?: string[];\n };\n\n /**\n * Android-specific config.\n */\n android?: {\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n */\n modulesClassNames?: string[];\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-autolinking",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Scripts that autolink Expo modules.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "find-up": "^5.0.0",
48
48
  "fs-extra": "^9.1.0"
49
49
  },
50
- "gitHead": "9faa58818454ba59dbff95077b9025a1c1cbd9fd"
50
+ "gitHead": "2e5c6983b86d5ecfca028ba64002897d8adc2cc4"
51
51
  }
@@ -0,0 +1,6 @@
1
+ module React {
2
+ umbrella "../../Public/React-Core/React"
3
+
4
+ export *
5
+ module * { export * }
6
+ }
@@ -2,7 +2,7 @@ require_relative 'constants'
2
2
  require_relative 'package'
3
3
 
4
4
  # Require extensions to CocoaPods' classes
5
- require_relative 'cocoapods/pod_target'
5
+ require_relative 'cocoapods/sandbox'
6
6
  require_relative 'cocoapods/target_definition'
7
7
  require_relative 'cocoapods/user_project_integrator'
8
8
 
@@ -0,0 +1,75 @@
1
+ # Overrides CocoaPods `Sandbox` class to patch podspecs on the fly
2
+ # See: https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/sandbox.rb
3
+
4
+ require 'json'
5
+
6
+ module Pod
7
+ class Sandbox
8
+ private
9
+
10
+ _original_store_podspec = instance_method(:store_podspec)
11
+
12
+ public
13
+
14
+ define_method(:store_podspec) do |name, podspec, _external_source, json|
15
+ spec = _original_store_podspec.bind(self).(name, podspec, _external_source, json)
16
+ patched_spec = nil
17
+
18
+ # Patch `React-Core.podspec` for clang to generate correct submodules for swift integration
19
+ if name == 'React-Core'
20
+ spec_json = JSON.parse(spec.to_pretty_json)
21
+
22
+ # CocoaPods's default modulemap did not generate submodules correctly
23
+ # `ios/Pods/Headers/Public/React/React-Core.modulemap`
24
+ # ```
25
+ # module React {
26
+ # umbrella header "React-Core-umbrella.h"
27
+ #
28
+ # export *
29
+ # module * { export * }
30
+ # }
31
+ # ```
32
+ # clang will generate submodules for headers relative to the umbrella header directory.
33
+ # https://github.com/llvm/llvm-project/blob/2782cb8da0b3c180fa7c8627cb255a026f3d25a2/clang/lib/Lex/ModuleMap.cpp#L1133
34
+ # In this case, it is `ios/Pods/Headers/Public/React`.
35
+ # But React headers are placed in `ios/Pods/Headers/Public/React-Core/React`, so clang cannot find the headers and generate submodules.
36
+ # We patch `React-Core.podspec` to use custom modulemap and use `umbrella "../../Public/React-Core/React"` for clang to generate submodules correctly.
37
+ # Since CocoaPods generates the umbrella headers based on public headers,
38
+ # it is pretty safe to replace the umbrella header with the `umbrella` directory search inside the public headers directory.
39
+ spec_json['module_map'] ||= File.join(__dir__, '..', 'React-Core.modulemap')
40
+
41
+ # clang module does not support objc++.
42
+ # We should put Hermes headers inside private headers directory.
43
+ # Otherwise, clang will throw errors in building module.
44
+ hermes_subspec_index = spec_json['subspecs'].index { |subspec| subspec['name'] == 'Hermes' }
45
+ if hermes_subspec_index
46
+ spec_json['subspecs'][hermes_subspec_index]['private_header_files'] ||= [
47
+ 'ReactCommon/hermes/executor/*.h',
48
+ 'ReactCommon/hermes/inspector/*.h',
49
+ 'ReactCommon/hermes/inspector/chrome/*.h',
50
+ 'ReactCommon/hermes/inspector/detail/*.h',
51
+ ]
52
+ end
53
+
54
+ patched_spec = Specification.from_json(spec_json.to_json)
55
+
56
+ # Patch `ReactCommon.podspec` to define module
57
+ elsif name == 'ReactCommon'
58
+ spec_json = JSON.parse(podspec.to_pretty_json)
59
+ spec_json['pod_target_xcconfig']['DEFINES_MODULE'] = 'YES'
60
+ patched_spec = Specification.from_json(spec_json.to_json)
61
+ end
62
+
63
+ if patched_spec != nil
64
+ # Store the patched spec with original checksum and local saved file path
65
+ patched_spec.defined_in_file = spec.defined_in_file
66
+ patched_spec.instance_variable_set(:@checksum, spec.checksum)
67
+ @stored_podspecs[spec.name] = patched_spec
68
+ return patched_spec
69
+ end
70
+
71
+ return spec
72
+ end # define_method(:store_podspec)
73
+
74
+ end # class Sandbox
75
+ end # module Pod
@@ -27,6 +27,13 @@ export class ExpoModuleConfig {
27
27
  return this.rawConfig.ios?.appDelegateSubscribers ?? [];
28
28
  }
29
29
 
30
+ /**
31
+ * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.
32
+ */
33
+ iosReactDelegateHandlers(): string[] {
34
+ return this.rawConfig.ios?.reactDelegateHandlers ?? [];
35
+ }
36
+
30
37
  /**
31
38
  * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.
32
39
  */
@@ -30,6 +30,7 @@ export async function resolveModuleAsync(
30
30
  flags: options.flags,
31
31
  modulesClassNames: revision.config?.iosModulesClassNames(),
32
32
  appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers(),
33
+ reactDelegateHandlers: revision.config?.iosReactDelegateHandlers(),
33
34
  };
34
35
  }
35
36
 
@@ -54,7 +55,10 @@ async function generatePackageListFileContentAsync(
54
55
  className: string
55
56
  ): Promise<string> {
56
57
  const modulesToImport = modules.filter(
57
- (module) => module.modulesClassNames.length + module.appDelegateSubscribers.length > 0
58
+ (module) =>
59
+ module.modulesClassNames.length ||
60
+ module.appDelegateSubscribers.length ||
61
+ module.reactDelegateHandlers.length
58
62
  );
59
63
  const pods = modulesToImport.map((module) => module.podName);
60
64
 
@@ -66,6 +70,10 @@ async function generatePackageListFileContentAsync(
66
70
  .concat(...modulesToImport.map((module) => module.appDelegateSubscribers))
67
71
  .filter(Boolean);
68
72
 
73
+ const reactDelegateHandlerModules = modulesToImport.filter(
74
+ (module) => !!module.reactDelegateHandlers.length
75
+ );
76
+
69
77
  return `/**
70
78
  * Automatically generated by expo-modules-autolinking.
71
79
  *
@@ -84,6 +92,10 @@ public class ${className}: ModulesProvider {
84
92
  public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {
85
93
  return ${formatArrayOfClassNames(appDelegateSubscribers)}
86
94
  }
95
+
96
+ public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {
97
+ return ${formatArrayOfReactDelegateHandler(reactDelegateHandlerModules)}
98
+ }
87
99
  }
88
100
  `;
89
101
  }
@@ -96,3 +108,18 @@ function formatArrayOfClassNames(classNames: string[]): string {
96
108
  return `[${classNames.map((className) => `\n${indent.repeat(3)}${className}.self`).join(',')}
97
109
  ${indent.repeat(2)}]`;
98
110
  }
111
+
112
+ /**
113
+ * Formats an array of modules to Swift's array containing ReactDelegateHandlers
114
+ */
115
+ export function formatArrayOfReactDelegateHandler(modules: ModuleDescriptor[]): string {
116
+ const values: string[] = [];
117
+ for (const module of modules) {
118
+ for (const handler of module.reactDelegateHandlers) {
119
+ values.push(`(packageName: "${module.packageName}", handler: ${handler}.self)`);
120
+ }
121
+ }
122
+ const indent = ' ';
123
+ return `[${values.map((value) => `\n${indent.repeat(3)}${value}`).join(',')}
124
+ ${indent.repeat(2)}]`;
125
+ }
package/src/types.ts CHANGED
@@ -59,6 +59,11 @@ export interface RawExpoModuleConfig {
59
59
  * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.
60
60
  */
61
61
  appDelegateSubscribers?: string[];
62
+
63
+ /**
64
+ * Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.
65
+ */
66
+ reactDelegateHandlers?: string[];
62
67
  };
63
68
 
64
69
  /**
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
- "include": ["./src"],
3
2
  "extends": "@tsconfig/node12/tsconfig.json",
3
+ "include": ["./src"],
4
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"],
4
5
  "compilerOptions": {
5
6
  "outDir": "./build",
6
7
  "module": "commonjs",
@@ -1,38 +0,0 @@
1
- # Overrides CocoaPods `PodTarget` class to make the `ReactCommon` pod define a module
2
- # and tell CocoaPods to generate a modulemap for it. This is needed for Swift/JSI integration
3
- # until the upstream podspec add `DEFINES_MODULE => YES` to build settings.
4
- # See: https://github.com/CocoaPods/CocoaPods/blob/master/lib/cocoapods/target/pod_target.rb
5
-
6
- module Pod
7
- class PodTarget
8
-
9
- private
10
-
11
- _original_defines_module = instance_method(:defines_module?)
12
-
13
- public
14
-
15
- # @return [Boolean] Whether the target defines a "module"
16
- # (and thus will need a module map and umbrella header).
17
- #
18
- # @note Static library targets can temporarily opt in to this behavior by setting
19
- # `DEFINES_MODULE = YES` in their specification's `pod_target_xcconfig`.
20
- #
21
- define_method(:defines_module?) do
22
- # Call the original method
23
- original_result = _original_defines_module.bind(self).()
24
-
25
- # Make ReactCommon specs define a module. This is required for ExpoModulesCore
26
- # to use `ReactCommon/turbomodule/core` subspec as a module, from Swift.
27
- # It also needs to handle versioned pods in Expo Go, so we check if the pod name
28
- # ends with `ReactCommon` instead of checking if they're equal.
29
- if !original_result && name.end_with?('ReactCommon')
30
- root_spec.consumer(platform).pod_target_xcconfig['DEFINES_MODULE'] = 'YES'
31
- return @defines_module = true
32
- end
33
-
34
- # Return the original value if not applicable for hack.
35
- return original_result
36
- end
37
- end
38
- end