expo-modules-autolinking 0.3.0 → 0.3.4

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/README.md CHANGED
@@ -13,7 +13,7 @@ For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
16
- For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
16
+ For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
17
17
 
18
18
  ### Add the package to your npm dependencies
19
19
 
@@ -45,16 +45,19 @@ async function generatePackageListFileContentAsync(modules, className) {
45
45
  const modulesToProvide = modules.filter((module) => module.modulesClassNames.length > 0);
46
46
  const pods = modulesToProvide.map((module) => module.podName);
47
47
  const classNames = [].concat(...modulesToProvide.map((module) => module.modulesClassNames));
48
- return `// Automatically generated by expo-modules-autolinking.
49
- import ExpoModulesCore
50
-
51
- ${pods.map((podName) => `import ${podName}`).join('\n')}
48
+ return `/**
49
+ * Automatically generated by expo-modules-autolinking.
50
+ *
51
+ * This autogenerated class provides a list of classes of native Expo modules,
52
+ * but only these that are written in Swift and use the new API for creating Expo modules.
53
+ */
52
54
 
55
+ import ExpoModulesCore
56
+ ${pods.map((podName) => `import ${podName}\n`).join('')}
53
57
  @objc(${className})
54
58
  public class ${className}: ModulesProvider {
55
- public override func exportedModules() -> [AnyModule.Type] {
56
- return [
57
- ${classNames.map((className) => `${className}.self`).join(',\n ')}
59
+ public override func getModuleClasses() -> [AnyModule.Type] {
60
+ return [${classNames.map((className) => `\n ${className}.self`).join(',')}
58
61
  ]
59
62
  }
60
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AAIxB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,GAAG,CAAC,CAAC,CAAC;IACzF,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAE5F,OAAO;;;EAGP,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;QAE/C,SAAS;eACF,SAAS;;;QAGhB,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;;;;CAI3E,CAAC;AACF,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 };\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 modulesToProvide = modules.filter((module) => module.modulesClassNames.length > 0);\n const pods = modulesToProvide.map((module) => module.podName);\n const classNames = [].concat(...modulesToProvide.map((module) => module.modulesClassNames));\n\n return `// Automatically generated by expo-modules-autolinking.\nimport ExpoModulesCore\n\n${pods.map((podName) => `import ${podName}`).join('\\n')}\n\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func exportedModules() -> [AnyModule.Type] {\n return [\n ${classNames.map((className) => `${className}.self`).join(',\\n ')}\n ]\n }\n}\n`;\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,mBAAI,CAAC,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,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,iBAAiB,EAAE,MAAA,QAAQ,CAAC,MAAM,0CAAE,oBAAoB,EAAE;KAC3D,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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 };\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 modulesToProvide = modules.filter((module) => module.modulesClassNames.length > 0);\n const pods = modulesToProvide.map((module) => module.podName);\n const classNames = [].concat(...modulesToProvide.map((module) => module.modulesClassNames));\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 [${classNames.map((className) => `\\n ${className}.self`).join(',')}\n ]\n }\n}\n`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-autolinking",
3
- "version": "0.3.0",
3
+ "version": "0.3.4",
4
4
  "description": "Scripts that autolink Expo modules.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -34,10 +34,10 @@
34
34
  "license": "MIT",
35
35
  "homepage": "https://github.com/expo/expo/tree/master/packages/expo-modules-autolinking#readme",
36
36
  "devDependencies": {
37
+ "@expo/spawn-async": "^1.5.0",
37
38
  "@tsconfig/node12": "^1.0.9",
38
39
  "@types/fs-extra": "^9.0.11",
39
40
  "expo-module-scripts": "~2.0.0",
40
- "@expo/spawn-async": "1.5.0",
41
41
  "tempy": "^0.7.1"
42
42
  },
43
43
  "dependencies": {
@@ -47,5 +47,5 @@
47
47
  "find-up": "~5.0.0",
48
48
  "fs-extra": "^9.1.0"
49
49
  },
50
- "gitHead": "fe23a511edf816a3fea58d74856c2749a9de1463"
50
+ "gitHead": "f93456e96091501a9b9f99246846cee29336a964"
51
51
  }
@@ -44,7 +44,7 @@ class ExpoAutolinkingManager {
44
44
  String[] args = convertOptionsToCommandArgs('resolve', this.options)
45
45
  args += ['--json']
46
46
 
47
- String output = exec(args)
47
+ String output = exec(args, projectDir)
48
48
  Object json = new JsonSlurper().parseText(output)
49
49
 
50
50
  cachedResolvingResults = json
@@ -84,11 +84,11 @@ class ExpoAutolinkingManager {
84
84
  args += '--empty'
85
85
  }
86
86
 
87
- exec(args)
87
+ exec(args, project.rootDir)
88
88
  }
89
89
 
90
- static String exec(String[] commandArgs) {
91
- Process proc = commandArgs.execute()
90
+ static String exec(String[] commandArgs, File dir) {
91
+ Process proc = commandArgs.execute(null, dir)
92
92
  StringBuffer outputStream = new StringBuffer()
93
93
  proc.waitForProcessOutput(outputStream, System.err)
94
94
  return outputStream.toString()
@@ -57,7 +57,7 @@ module Expo
57
57
 
58
58
  # Spawns `expo-module-autolinking generate-package-list` command.
59
59
  public def generate_package_list(target_name, target_path)
60
- IO.popen(generate_package_list_command_args(target_path))
60
+ Process.wait IO.popen(generate_package_list_command_args(target_path)).pid
61
61
  end
62
62
 
63
63
  # If there is any package to autolink.
@@ -65,16 +65,6 @@ module Expo
65
65
  @packages.empty?
66
66
  end
67
67
 
68
- # Bool that is true when Swift modules are enabled
69
- public def uses_swift_modules?
70
- $ExpoUseSwiftModules
71
- end
72
-
73
- # Returns whether there is at least one package that needs to be included in the generated modules provider.
74
- public def needs_provider_generation?
75
- uses_swift_modules? && @packages.find { |package| package.modules_class_names.any? }.present?
76
- end
77
-
78
68
  # Filters only these packages that needs to be included in the generated modules provider.
79
69
  public def packages_to_generate
80
70
  @packages.select { |package| package.modules_class_names.any? }
@@ -8,7 +8,7 @@ module Expo
8
8
  # Find the targets that use expo modules and need the modules provider
9
9
  targets_with_modules_provider = targets.select do |target|
10
10
  autolinking_manager = target.target_definition.autolinking_manager
11
- autolinking_manager.present? && autolinking_manager.needs_provider_generation?
11
+ autolinking_manager.present?
12
12
  end
13
13
 
14
14
  # Find existing PBXGroup for modules providers.
@@ -56,16 +56,19 @@ async function generatePackageListFileContentAsync(
56
56
  const pods = modulesToProvide.map((module) => module.podName);
57
57
  const classNames = [].concat(...modulesToProvide.map((module) => module.modulesClassNames));
58
58
 
59
- return `// Automatically generated by expo-modules-autolinking.
60
- import ExpoModulesCore
61
-
62
- ${pods.map((podName) => `import ${podName}`).join('\n')}
59
+ return `/**
60
+ * Automatically generated by expo-modules-autolinking.
61
+ *
62
+ * This autogenerated class provides a list of classes of native Expo modules,
63
+ * but only these that are written in Swift and use the new API for creating Expo modules.
64
+ */
63
65
 
66
+ import ExpoModulesCore
67
+ ${pods.map((podName) => `import ${podName}\n`).join('')}
64
68
  @objc(${className})
65
69
  public class ${className}: ModulesProvider {
66
- public override func exportedModules() -> [AnyModule.Type] {
67
- return [
68
- ${classNames.map((className) => `${className}.self`).join(',\n ')}
70
+ public override func getModuleClasses() -> [AnyModule.Type] {
71
+ return [${classNames.map((className) => `\n ${className}.self`).join(',')}
69
72
  ]
70
73
  }
71
74
  }