expo-watch 0.1.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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +120 -0
  3. package/android/.gradle/8.9/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
  5. package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/8.9/gc.properties +0 -0
  8. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  9. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  10. package/android/.gradle/vcs-1/gc.properties +0 -0
  11. package/android/build.gradle +43 -0
  12. package/android/src/main/AndroidManifest.xml +2 -0
  13. package/android/src/main/java/expo/modules/watch/ExpoWatchModule.kt +47 -0
  14. package/android/src/main/java/expo/modules/watch/ExpoWatchView.kt +7 -0
  15. package/app.plugin.js +1 -0
  16. package/build/ExpoWatch.types.d.ts +7 -0
  17. package/build/ExpoWatch.types.d.ts.map +1 -0
  18. package/build/ExpoWatch.types.js +2 -0
  19. package/build/ExpoWatch.types.js.map +1 -0
  20. package/build/ExpoWatchModule.d.ts +3 -0
  21. package/build/ExpoWatchModule.d.ts.map +1 -0
  22. package/build/ExpoWatchModule.js +5 -0
  23. package/build/ExpoWatchModule.js.map +1 -0
  24. package/build/ExpoWatchModule.web.d.ts +7 -0
  25. package/build/ExpoWatchModule.web.d.ts.map +1 -0
  26. package/build/ExpoWatchModule.web.js +12 -0
  27. package/build/ExpoWatchModule.web.js.map +1 -0
  28. package/build/ExpoWatchView.d.ts +4 -0
  29. package/build/ExpoWatchView.d.ts.map +1 -0
  30. package/build/ExpoWatchView.js +7 -0
  31. package/build/ExpoWatchView.js.map +1 -0
  32. package/build/ExpoWatchView.web.d.ts +4 -0
  33. package/build/ExpoWatchView.web.d.ts.map +1 -0
  34. package/build/ExpoWatchView.web.js +7 -0
  35. package/build/ExpoWatchView.web.js.map +1 -0
  36. package/build/index.d.ts +9 -0
  37. package/build/index.d.ts.map +1 -0
  38. package/build/index.js +19 -0
  39. package/build/index.js.map +1 -0
  40. package/expo-module.config.json +9 -0
  41. package/ios/ExpoWatch.podspec +27 -0
  42. package/ios/ExpoWatchModule.swift +44 -0
  43. package/ios/ExpoWatchView.swift +7 -0
  44. package/package.json +45 -0
  45. package/plugin/build/addBuildPhases.d.ts +13 -0
  46. package/plugin/build/addBuildPhases.js +26 -0
  47. package/plugin/build/addPbxGroup.d.ts +5 -0
  48. package/plugin/build/addPbxGroup.js +15 -0
  49. package/plugin/build/addProductFile.d.ts +5 -0
  50. package/plugin/build/addProductFile.js +18 -0
  51. package/plugin/build/addTargetDependency.d.ts +4 -0
  52. package/plugin/build/addTargetDependency.js +14 -0
  53. package/plugin/build/addToPbxNativeTargetSection.d.ts +24 -0
  54. package/plugin/build/addToPbxNativeTargetSection.js +21 -0
  55. package/plugin/build/addToPbxProjectSection.d.ts +4 -0
  56. package/plugin/build/addToPbxProjectSection.js +13 -0
  57. package/plugin/build/addXCConfigurationList.d.ts +9 -0
  58. package/plugin/build/addXCConfigurationList.js +19 -0
  59. package/plugin/build/withWatchApp.d.ts +11 -0
  60. package/plugin/build/withWatchApp.js +51 -0
  61. package/plugin/src/addBuildPhases.ts +83 -0
  62. package/plugin/src/addPbxGroup.ts +31 -0
  63. package/plugin/src/addProductFile.ts +22 -0
  64. package/plugin/src/addTargetDependency.ts +17 -0
  65. package/plugin/src/addToPbxNativeTargetSection.ts +35 -0
  66. package/plugin/src/addToPbxProjectSection.ts +21 -0
  67. package/plugin/src/addXCConfigurationList.ts +37 -0
  68. package/plugin/src/withWatchApp.ts +79 -0
  69. package/plugin/tsconfig.json +9 -0
  70. package/src/ExpoWatch.types.ts +7 -0
  71. package/src/ExpoWatchModule.ts +5 -0
  72. package/src/ExpoWatchModule.web.ts +13 -0
  73. package/src/ExpoWatchView.tsx +11 -0
  74. package/src/ExpoWatchView.web.tsx +11 -0
  75. package/src/index.ts +26 -0
  76. package/tsconfig.json +9 -0
@@ -0,0 +1,5 @@
1
+ import { XcodeProject } from '@expo/config-plugins';
2
+ export declare function addProductFile(xcodeProject: XcodeProject, { targetName, groupName }: {
3
+ targetName: string;
4
+ groupName: string;
5
+ }): any;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addProductFile = addProductFile;
4
+ function addProductFile(xcodeProject, { targetName, groupName }) {
5
+ const options = {
6
+ basename: `${targetName}`,
7
+ group: groupName,
8
+ explicitFileType: 'wrapper.application',
9
+ settings: {
10
+ ATTRIBUTES: ['RemoveHeadersOnCopy'],
11
+ },
12
+ includeInIndex: 0,
13
+ path: `${targetName}`,
14
+ sourceTree: 'BUILT_PRODUCTS_DIR',
15
+ };
16
+ const productFile = xcodeProject.addProductFile(targetName, options);
17
+ return productFile;
18
+ }
@@ -0,0 +1,4 @@
1
+ import { XcodeProject } from '@expo/config-plugins';
2
+ export declare function addTargetDependency(xcodeProject: XcodeProject, target: {
3
+ uuid: string;
4
+ }): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTargetDependency = addTargetDependency;
4
+ function addTargetDependency(xcodeProject, target) {
5
+ if (!xcodeProject.hash.project.objects['PBXTargetDependency']) {
6
+ xcodeProject.hash.project.objects['PBXTargetDependency'] = {};
7
+ }
8
+ if (!xcodeProject.hash.project.objects['PBXContainerItemProxy']) {
9
+ xcodeProject.hash.project.objects['PBXContainerItemProxy'] = {};
10
+ }
11
+ xcodeProject.addTargetDependency(xcodeProject.getFirstTarget().uuid, [
12
+ target.uuid,
13
+ ]);
14
+ }
@@ -0,0 +1,24 @@
1
+ import { XcodeProject } from '@expo/config-plugins';
2
+ export declare function addToPbxNativeTargetSection(xcodeProject: XcodeProject, { targetName, targetUuid, productFile, xCConfigurationList, }: {
3
+ targetName: string;
4
+ targetUuid: string;
5
+ productFile: {
6
+ fileRef: string;
7
+ };
8
+ xCConfigurationList: {
9
+ uuid: string;
10
+ };
11
+ }): {
12
+ uuid: string;
13
+ pbxNativeTarget: {
14
+ isa: string;
15
+ buildConfigurationList: string;
16
+ buildPhases: never[];
17
+ buildRules: never[];
18
+ dependencies: never[];
19
+ name: string;
20
+ productName: string;
21
+ productReference: string;
22
+ productType: string;
23
+ };
24
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addToPbxNativeTargetSection = addToPbxNativeTargetSection;
4
+ function addToPbxNativeTargetSection(xcodeProject, { targetName, targetUuid, productFile, xCConfigurationList, }) {
5
+ const target = {
6
+ uuid: targetUuid,
7
+ pbxNativeTarget: {
8
+ isa: 'PBXNativeTarget',
9
+ buildConfigurationList: xCConfigurationList.uuid,
10
+ buildPhases: [],
11
+ buildRules: [],
12
+ dependencies: [],
13
+ name: `"${targetName}"`,
14
+ productName: `"${targetName}"`,
15
+ productReference: productFile.fileRef,
16
+ productType: `"com.apple.product-type.application"`,
17
+ },
18
+ };
19
+ xcodeProject.addToPbxNativeTargetSection(target);
20
+ return target;
21
+ }
@@ -0,0 +1,4 @@
1
+ import { XcodeProject } from '@expo/config-plugins';
2
+ export declare function addToPbxProjectSection(xcodeProject: XcodeProject, target: {
3
+ uuid: string;
4
+ }): void;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addToPbxProjectSection = addToPbxProjectSection;
4
+ function addToPbxProjectSection(xcodeProject, target) {
5
+ xcodeProject.addToPbxProjectSection(target);
6
+ if (!xcodeProject.pbxProjectSection()[xcodeProject.getFirstProject().uuid]
7
+ .attributes.TargetAttributes) {
8
+ xcodeProject.pbxProjectSection()[xcodeProject.getFirstProject().uuid].attributes.TargetAttributes = {};
9
+ }
10
+ xcodeProject.pbxProjectSection()[xcodeProject.getFirstProject().uuid].attributes.TargetAttributes[target.uuid] = {
11
+ LastSwiftMigration: 1250,
12
+ };
13
+ }
@@ -0,0 +1,9 @@
1
+ import { XcodeProject } from '@expo/config-plugins';
2
+ interface BuildSettigs {
3
+ [key: string]: string | number;
4
+ }
5
+ export declare function addXCConfigurationList(xcodeProject: XcodeProject, { targetName, buildSettings, }: {
6
+ targetName: string;
7
+ buildSettings: BuildSettigs;
8
+ }): any;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addXCConfigurationList = addXCConfigurationList;
4
+ function addXCConfigurationList(xcodeProject, { targetName, buildSettings, }) {
5
+ const buildConfigurationsList = [
6
+ {
7
+ isa: 'XCBuildConfiguration',
8
+ buildSettings,
9
+ name: 'Debug',
10
+ },
11
+ {
12
+ isa: 'XCBuildConfiguration',
13
+ buildSettings,
14
+ name: 'Release',
15
+ },
16
+ ];
17
+ const xCConfigurationList = xcodeProject.addXCConfigurationList(buildConfigurationsList, 'Release', `Build configuration list for PBXNativeTarget "${targetName}"`);
18
+ return xCConfigurationList;
19
+ }
@@ -0,0 +1,11 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ declare const withWatchApp: ConfigPlugin<{
3
+ targetName?: string;
4
+ groupName?: string;
5
+ setVersionFromCompanionApp?: boolean;
6
+ buildSettings?: Record<string, string | number>;
7
+ files?: string[];
8
+ compileSources?: string[];
9
+ copyBundleResources?: string[];
10
+ }>;
11
+ export default withWatchApp;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_plugins_1 = require("@expo/config-plugins");
4
+ const addBuildPhases_1 = require("./addBuildPhases");
5
+ const addPbxGroup_1 = require("./addPbxGroup");
6
+ const addProductFile_1 = require("./addProductFile");
7
+ const addTargetDependency_1 = require("./addTargetDependency");
8
+ const addToPbxNativeTargetSection_1 = require("./addToPbxNativeTargetSection");
9
+ const addToPbxProjectSection_1 = require("./addToPbxProjectSection");
10
+ const addXCConfigurationList_1 = require("./addXCConfigurationList");
11
+ const withWatchApp = (config, { targetName = 'Sample Watch App', groupName = 'Embed Watch Content', setVersionFromCompanionApp = true, buildSettings = {}, files = [], compileSources = [], copyBundleResources = [], } = {}) => {
12
+ return (0, config_plugins_1.withXcodeProject)(config, (config) => {
13
+ const version = config.version ?? '1.0.0';
14
+ const xcodeProject = config.modResults;
15
+ const targetUuid = xcodeProject.generateUuid();
16
+ const xCConfigurationList = (0, addXCConfigurationList_1.addXCConfigurationList)(xcodeProject, {
17
+ targetName,
18
+ buildSettings: {
19
+ ...buildSettings,
20
+ ...(setVersionFromCompanionApp
21
+ ? { MARKETING_VERSION: version }
22
+ : undefined),
23
+ },
24
+ });
25
+ const productFile = (0, addProductFile_1.addProductFile)(xcodeProject, {
26
+ targetName,
27
+ groupName,
28
+ });
29
+ const target = (0, addToPbxNativeTargetSection_1.addToPbxNativeTargetSection)(xcodeProject, {
30
+ targetName,
31
+ targetUuid,
32
+ productFile,
33
+ xCConfigurationList,
34
+ });
35
+ (0, addTargetDependency_1.addTargetDependency)(xcodeProject, target);
36
+ (0, addToPbxProjectSection_1.addToPbxProjectSection)(xcodeProject, target);
37
+ (0, addPbxGroup_1.addPbxGroup)(xcodeProject, {
38
+ targetName,
39
+ files,
40
+ });
41
+ (0, addBuildPhases_1.addBuildPhases)(xcodeProject, {
42
+ targetUuid,
43
+ groupName,
44
+ productFile,
45
+ compileSources,
46
+ copyBundleResources,
47
+ });
48
+ return config;
49
+ });
50
+ };
51
+ exports.default = withWatchApp;
@@ -0,0 +1,83 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+ import util from 'util'
3
+
4
+ export function addBuildPhases(
5
+ xcodeProject: XcodeProject,
6
+ {
7
+ targetUuid,
8
+ groupName,
9
+ productFile,
10
+ compileSources,
11
+ copyBundleResources,
12
+ }: {
13
+ targetUuid: string
14
+ groupName: string
15
+ productFile: {
16
+ uuid: string
17
+ target: string
18
+ basename: string
19
+ group: string
20
+ }
21
+ compileSources: string[]
22
+ copyBundleResources: string[]
23
+ },
24
+ ) {
25
+ const buildPath = `"$(CONTENTS_FOLDER_PATH)/Watch"`
26
+ const folderType = 'watch2_app'
27
+
28
+ // Sources build phase
29
+ xcodeProject.addBuildPhase(
30
+ compileSources,
31
+ 'PBXSourcesBuildPhase',
32
+ groupName,
33
+ targetUuid,
34
+ folderType,
35
+ buildPath,
36
+ )
37
+
38
+ // Copy files build phase
39
+ xcodeProject.addBuildPhase(
40
+ [],
41
+ 'PBXCopyFilesBuildPhase',
42
+ groupName,
43
+ xcodeProject.getFirstTarget().uuid,
44
+ folderType,
45
+ buildPath,
46
+ )
47
+
48
+ xcodeProject
49
+ .buildPhaseObject(
50
+ 'PBXCopyFilesBuildPhase',
51
+ groupName,
52
+ productFile.target,
53
+ )
54
+ .files.push({
55
+ value: productFile.uuid,
56
+ comment: util.format(
57
+ '%s in %s',
58
+ productFile.basename,
59
+ productFile.group,
60
+ ), // longComment(file);
61
+ })
62
+ xcodeProject.addToPbxBuildFileSection(productFile)
63
+
64
+ // Frameworks build phase
65
+ xcodeProject.addBuildPhase(
66
+ [],
67
+ 'PBXFrameworksBuildPhase',
68
+ groupName,
69
+ targetUuid,
70
+ folderType,
71
+ buildPath,
72
+ )
73
+
74
+ // Resources build phase
75
+ xcodeProject.addBuildPhase(
76
+ copyBundleResources,
77
+ 'PBXResourcesBuildPhase',
78
+ groupName,
79
+ targetUuid,
80
+ folderType,
81
+ buildPath,
82
+ )
83
+ }
@@ -0,0 +1,31 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+
3
+ export function addPbxGroup(
4
+ xcodeProject: XcodeProject,
5
+
6
+ {
7
+ targetName,
8
+ files,
9
+ }: {
10
+ targetName: string
11
+ files: string[]
12
+ },
13
+ ) {
14
+ const { uuid: pbxGroupUuid } = xcodeProject.addPbxGroup(
15
+ files,
16
+ `"${targetName}"`,
17
+ `"../${targetName}"`,
18
+ )
19
+
20
+ const groups = xcodeProject.hash.project.objects['PBXGroup']
21
+ if (pbxGroupUuid) {
22
+ Object.keys(groups).forEach(function (key) {
23
+ if (
24
+ groups[key].name === undefined &&
25
+ groups[key].path === undefined
26
+ ) {
27
+ xcodeProject.addToPbxGroup(pbxGroupUuid, key)
28
+ }
29
+ })
30
+ }
31
+ }
@@ -0,0 +1,22 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+
3
+ export function addProductFile(
4
+ xcodeProject: XcodeProject,
5
+ { targetName, groupName }: { targetName: string; groupName: string },
6
+ ) {
7
+ const options = {
8
+ basename: `${targetName}`,
9
+ group: groupName,
10
+ explicitFileType: 'wrapper.application',
11
+ settings: {
12
+ ATTRIBUTES: ['RemoveHeadersOnCopy'],
13
+ },
14
+ includeInIndex: 0,
15
+ path: `${targetName}`,
16
+ sourceTree: 'BUILT_PRODUCTS_DIR',
17
+ }
18
+
19
+ const productFile = xcodeProject.addProductFile(targetName, options)
20
+
21
+ return productFile
22
+ }
@@ -0,0 +1,17 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+
3
+ export function addTargetDependency(
4
+ xcodeProject: XcodeProject,
5
+ target: { uuid: string },
6
+ ) {
7
+ if (!xcodeProject.hash.project.objects['PBXTargetDependency']) {
8
+ xcodeProject.hash.project.objects['PBXTargetDependency'] = {}
9
+ }
10
+ if (!xcodeProject.hash.project.objects['PBXContainerItemProxy']) {
11
+ xcodeProject.hash.project.objects['PBXContainerItemProxy'] = {}
12
+ }
13
+
14
+ xcodeProject.addTargetDependency(xcodeProject.getFirstTarget().uuid, [
15
+ target.uuid,
16
+ ])
17
+ }
@@ -0,0 +1,35 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+
3
+ export function addToPbxNativeTargetSection(
4
+ xcodeProject: XcodeProject,
5
+ {
6
+ targetName,
7
+ targetUuid,
8
+ productFile,
9
+ xCConfigurationList,
10
+ }: {
11
+ targetName: string
12
+ targetUuid: string
13
+ productFile: { fileRef: string }
14
+ xCConfigurationList: { uuid: string }
15
+ },
16
+ ) {
17
+ const target = {
18
+ uuid: targetUuid,
19
+ pbxNativeTarget: {
20
+ isa: 'PBXNativeTarget',
21
+ buildConfigurationList: xCConfigurationList.uuid,
22
+ buildPhases: [],
23
+ buildRules: [],
24
+ dependencies: [],
25
+ name: `"${targetName}"`,
26
+ productName: `"${targetName}"`,
27
+ productReference: productFile.fileRef,
28
+ productType: `"com.apple.product-type.application"`,
29
+ },
30
+ }
31
+
32
+ xcodeProject.addToPbxNativeTargetSection(target)
33
+
34
+ return target
35
+ }
@@ -0,0 +1,21 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+
3
+ export function addToPbxProjectSection(
4
+ xcodeProject: XcodeProject,
5
+ target: { uuid: string },
6
+ ) {
7
+ xcodeProject.addToPbxProjectSection(target)
8
+ if (
9
+ !xcodeProject.pbxProjectSection()[xcodeProject.getFirstProject().uuid]
10
+ .attributes.TargetAttributes
11
+ ) {
12
+ xcodeProject.pbxProjectSection()[
13
+ xcodeProject.getFirstProject().uuid
14
+ ].attributes.TargetAttributes = {}
15
+ }
16
+ xcodeProject.pbxProjectSection()[
17
+ xcodeProject.getFirstProject().uuid
18
+ ].attributes.TargetAttributes[target.uuid] = {
19
+ LastSwiftMigration: 1250,
20
+ }
21
+ }
@@ -0,0 +1,37 @@
1
+ import { XcodeProject } from '@expo/config-plugins'
2
+
3
+ interface BuildSettigs {
4
+ [key: string]: string | number
5
+ }
6
+
7
+ export function addXCConfigurationList(
8
+ xcodeProject: XcodeProject,
9
+ {
10
+ targetName,
11
+ buildSettings,
12
+ }: {
13
+ targetName: string
14
+ buildSettings: BuildSettigs
15
+ },
16
+ ) {
17
+ const buildConfigurationsList = [
18
+ {
19
+ isa: 'XCBuildConfiguration',
20
+ buildSettings,
21
+ name: 'Debug',
22
+ },
23
+ {
24
+ isa: 'XCBuildConfiguration',
25
+ buildSettings,
26
+ name: 'Release',
27
+ },
28
+ ]
29
+
30
+ const xCConfigurationList = xcodeProject.addXCConfigurationList(
31
+ buildConfigurationsList,
32
+ 'Release',
33
+ `Build configuration list for PBXNativeTarget "${targetName}"`,
34
+ )
35
+
36
+ return xCConfigurationList
37
+ }
@@ -0,0 +1,79 @@
1
+ import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins'
2
+
3
+ import { addBuildPhases } from './addBuildPhases'
4
+ import { addPbxGroup } from './addPbxGroup'
5
+ import { addProductFile } from './addProductFile'
6
+ import { addTargetDependency } from './addTargetDependency'
7
+ import { addToPbxNativeTargetSection } from './addToPbxNativeTargetSection'
8
+ import { addToPbxProjectSection } from './addToPbxProjectSection'
9
+ import { addXCConfigurationList } from './addXCConfigurationList'
10
+
11
+ const withWatchApp: ConfigPlugin<{
12
+ targetName?: string
13
+ groupName?: string
14
+ setVersionFromCompanionApp?: boolean
15
+ buildSettings?: Record<string, string | number>
16
+ files?: string[]
17
+ compileSources?: string[]
18
+ copyBundleResources?: string[]
19
+ }> = (
20
+ config,
21
+ {
22
+ targetName = 'Sample Watch App',
23
+ groupName = 'Embed Watch Content',
24
+ setVersionFromCompanionApp = true,
25
+ buildSettings = {},
26
+ files = [],
27
+ compileSources = [],
28
+ copyBundleResources = [],
29
+ } = {},
30
+ ) => {
31
+ return withXcodeProject(config, (config) => {
32
+ const version = config.version ?? '1.0.0'
33
+ const xcodeProject = config.modResults
34
+
35
+ const targetUuid = xcodeProject.generateUuid()
36
+
37
+ const xCConfigurationList = addXCConfigurationList(xcodeProject, {
38
+ targetName,
39
+ buildSettings: {
40
+ ...buildSettings,
41
+ ...(setVersionFromCompanionApp
42
+ ? { MARKETING_VERSION: version }
43
+ : undefined),
44
+ },
45
+ })
46
+
47
+ const productFile = addProductFile(xcodeProject, {
48
+ targetName,
49
+ groupName,
50
+ })
51
+
52
+ const target = addToPbxNativeTargetSection(xcodeProject, {
53
+ targetName,
54
+ targetUuid,
55
+ productFile,
56
+ xCConfigurationList,
57
+ })
58
+
59
+ addTargetDependency(xcodeProject, target)
60
+ addToPbxProjectSection(xcodeProject, target)
61
+
62
+ addPbxGroup(xcodeProject, {
63
+ targetName,
64
+ files,
65
+ })
66
+
67
+ addBuildPhases(xcodeProject, {
68
+ targetUuid,
69
+ groupName,
70
+ productFile,
71
+ compileSources,
72
+ copyBundleResources,
73
+ })
74
+
75
+ return config
76
+ })
77
+ }
78
+
79
+ export default withWatchApp
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "expo-module-scripts/tsconfig.plugin",
3
+ "compilerOptions": {
4
+ "outDir": "build",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }
@@ -0,0 +1,7 @@
1
+ export type ChangeEventPayload = {
2
+ value: string;
3
+ };
4
+
5
+ export type ExpoWatchViewProps = {
6
+ name: string;
7
+ };
@@ -0,0 +1,5 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+
3
+ // It loads the native module object from the JSI or falls back to
4
+ // the bridge module (from NativeModulesProxy) if the remote debugger is on.
5
+ export default requireNativeModule('ExpoWatch');
@@ -0,0 +1,13 @@
1
+ import { EventEmitter } from 'expo-modules-core';
2
+
3
+ const emitter = new EventEmitter({} as any);
4
+
5
+ export default {
6
+ PI: Math.PI,
7
+ async setValueAsync(value: string): Promise<void> {
8
+ emitter.emit('onChange', { value });
9
+ },
10
+ hello() {
11
+ return 'Hello world! 👋';
12
+ },
13
+ };
@@ -0,0 +1,11 @@
1
+ import { requireNativeViewManager } from 'expo-modules-core';
2
+ import * as React from 'react';
3
+
4
+ import { ExpoWatchViewProps } from './ExpoWatch.types';
5
+
6
+ const NativeView: React.ComponentType<ExpoWatchViewProps> =
7
+ requireNativeViewManager('ExpoWatch');
8
+
9
+ export default function ExpoWatchView(props: ExpoWatchViewProps) {
10
+ return <NativeView {...props} />;
11
+ }
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+
3
+ import { ExpoWatchViewProps } from './ExpoWatch.types';
4
+
5
+ export default function ExpoWatchView(props: ExpoWatchViewProps) {
6
+ return (
7
+ <div>
8
+ <span>{props.name}</span>
9
+ </div>
10
+ );
11
+ }
package/src/index.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { NativeModulesProxy, EventEmitter, Subscription } from 'expo-modules-core';
2
+
3
+ // Import the native module. On web, it will be resolved to ExpoWatch.web.ts
4
+ // and on native platforms to ExpoWatch.ts
5
+ import ExpoWatchModule from './ExpoWatchModule';
6
+ import ExpoWatchView from './ExpoWatchView';
7
+ import { ChangeEventPayload, ExpoWatchViewProps } from './ExpoWatch.types';
8
+
9
+ // Get the native constant value.
10
+ export const PI = ExpoWatchModule.PI;
11
+
12
+ export function hello(): string {
13
+ return ExpoWatchModule.hello();
14
+ }
15
+
16
+ export async function setValueAsync(value: string) {
17
+ return await ExpoWatchModule.setValueAsync(value);
18
+ }
19
+
20
+ const emitter = new EventEmitter(ExpoWatchModule ?? NativeModulesProxy.ExpoWatch);
21
+
22
+ export function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription {
23
+ return emitter.addListener<ChangeEventPayload>('onChange', listener);
24
+ }
25
+
26
+ export { ExpoWatchView, ExpoWatchViewProps, ChangeEventPayload };
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ // @generated by expo-module-scripts
2
+ {
3
+ "extends": "expo-module-scripts/tsconfig.base",
4
+ "compilerOptions": {
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["./src"],
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
+ }