expo-targets 0.2.1 → 0.2.3
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/build/plugin/src/config.d.ts +64 -1
- package/build/plugin/src/config.d.ts.map +1 -1
- package/build/plugin/src/config.js +5 -1
- package/build/plugin/src/config.js.map +1 -1
- package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts +1 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts.map +1 -1
- package/build/plugin/src/ios/config-plugins/withEntitlements.js +5 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.js.map +1 -1
- package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts +5 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts.map +1 -1
- package/build/plugin/src/ios/config-plugins/withIOSTarget.js +18 -5
- package/build/plugin/src/ios/config-plugins/withIOSTarget.js.map +1 -1
- package/build/plugin/src/ios/config-plugins/withPodfile.d.ts.map +1 -1
- package/build/plugin/src/ios/config-plugins/withPodfile.js +3 -5
- package/build/plugin/src/ios/config-plugins/withPodfile.js.map +1 -1
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts +5 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts.map +1 -1
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.js +72 -3
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.js.map +1 -1
- package/build/plugin/src/ios/target.d.ts +4 -1
- package/build/plugin/src/ios/target.d.ts.map +1 -1
- package/build/plugin/src/ios/target.js +108 -12
- package/build/plugin/src/ios/target.js.map +1 -1
- package/build/plugin/src/ios/utils/index.d.ts +1 -0
- package/build/plugin/src/ios/utils/index.d.ts.map +1 -1
- package/build/plugin/src/ios/utils/index.js +2 -1
- package/build/plugin/src/ios/utils/index.js.map +1 -1
- package/build/plugin/src/ios/utils/paths.d.ts +11 -5
- package/build/plugin/src/ios/utils/paths.d.ts.map +1 -1
- package/build/plugin/src/ios/utils/paths.js +12 -10
- package/build/plugin/src/ios/utils/paths.js.map +1 -1
- package/build/plugin/src/ios/utils/plist.d.ts.map +1 -1
- package/build/plugin/src/ios/utils/plist.js +2 -0
- package/build/plugin/src/ios/utils/plist.js.map +1 -1
- package/build/plugin/src/ios/utils/podfile.d.ts.map +1 -1
- package/build/plugin/src/ios/utils/podfile.js +55 -22
- package/build/plugin/src/ios/utils/podfile.js.map +1 -1
- package/build/plugin/src/ios/utils/safari.d.ts +69 -0
- package/build/plugin/src/ios/utils/safari.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/safari.js +359 -0
- package/build/plugin/src/ios/utils/safari.js.map +1 -0
- package/build/plugin/src/withTargetsDir.d.ts.map +1 -1
- package/build/plugin/src/withTargetsDir.js +102 -2
- package/build/plugin/src/withTargetsDir.js.map +1 -1
- package/build/src/Target.d.ts +8 -1
- package/build/src/Target.d.ts.map +1 -1
- package/build/src/Target.js +136 -26
- package/build/src/Target.js.map +1 -1
- package/build/src/index.d.ts +3 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +14 -1
- package/build/src/index.js.map +1 -1
- package/build/src/modules/safari/index.d.ts +109 -0
- package/build/src/modules/safari/index.d.ts.map +1 -0
- package/build/src/modules/safari/index.js +288 -0
- package/build/src/modules/safari/index.js.map +1 -0
- package/metro/{src/index.ts → build/index.d.ts} +1 -0
- package/metro/build/index.d.ts.map +1 -0
- package/metro/build/index.js +6 -0
- package/metro/build/index.js.map +1 -0
- package/metro/build/withTargetsMetro.d.ts +5 -0
- package/metro/build/withTargetsMetro.d.ts.map +1 -0
- package/metro/build/withTargetsMetro.js +78 -0
- package/metro/build/withTargetsMetro.js.map +1 -0
- package/package.json +11 -1
- package/plugin/build/android/withAndroidAppBuildGradle.d.ts +7 -0
- package/plugin/build/android/withAndroidAppBuildGradle.d.ts.map +1 -0
- package/plugin/build/android/withAndroidAppBuildGradle.js +31 -0
- package/plugin/build/android/withAndroidAppBuildGradle.js.map +1 -0
- package/plugin/build/android/withAndroidTarget.d.ts +10 -0
- package/plugin/build/android/withAndroidTarget.d.ts.map +1 -0
- package/plugin/build/android/withAndroidTarget.js +22 -0
- package/plugin/build/android/withAndroidTarget.js.map +1 -0
- package/plugin/build/android/withAndroidWidget.d.ts +13 -0
- package/plugin/build/android/withAndroidWidget.d.ts.map +1 -0
- package/plugin/build/android/withAndroidWidget.js +564 -0
- package/plugin/build/android/withAndroidWidget.js.map +1 -0
- package/plugin/build/config.d.ts +204 -0
- package/plugin/build/config.d.ts.map +1 -0
- package/plugin/build/config.js +58 -0
- package/plugin/build/config.js.map +1 -0
- package/plugin/build/index.d.ts +9 -0
- package/plugin/build/index.d.ts.map +1 -0
- package/plugin/build/index.js +11 -0
- package/plugin/build/index.js.map +1 -0
- package/plugin/build/ios/config-plugins/withEntitlements.d.ts +12 -0
- package/plugin/build/ios/config-plugins/withEntitlements.d.ts.map +1 -0
- package/plugin/build/ios/config-plugins/withEntitlements.js +54 -0
- package/plugin/build/ios/config-plugins/withEntitlements.js.map +1 -0
- package/plugin/build/ios/config-plugins/withIOSTarget.d.ts +22 -0
- package/plugin/build/ios/config-plugins/withIOSTarget.d.ts.map +1 -0
- package/plugin/build/ios/config-plugins/withIOSTarget.js +165 -0
- package/plugin/build/ios/config-plugins/withIOSTarget.js.map +1 -0
- package/plugin/build/ios/config-plugins/withIosColorset.d.ts +8 -0
- package/plugin/build/ios/config-plugins/withIosColorset.d.ts.map +1 -0
- package/plugin/build/ios/config-plugins/withIosColorset.js +25 -0
- package/plugin/build/ios/config-plugins/withIosColorset.js.map +1 -0
- package/plugin/build/ios/config-plugins/withIosStickerPack.d.ts +8 -0
- package/plugin/build/ios/config-plugins/withIosStickerPack.d.ts.map +1 -0
- package/plugin/build/ios/config-plugins/withIosStickerPack.js +52 -0
- package/plugin/build/ios/config-plugins/withIosStickerPack.js.map +1 -0
- package/plugin/build/ios/config-plugins/withPodfile.d.ts +12 -0
- package/plugin/build/ios/config-plugins/withPodfile.d.ts.map +1 -0
- package/plugin/build/ios/config-plugins/withPodfile.js +160 -0
- package/plugin/build/ios/config-plugins/withPodfile.js.map +1 -0
- package/plugin/build/ios/config-plugins/withXcodeChanges.d.ts +20 -0
- package/plugin/build/ios/config-plugins/withXcodeChanges.d.ts.map +1 -0
- package/plugin/build/ios/config-plugins/withXcodeChanges.js +715 -0
- package/plugin/build/ios/config-plugins/withXcodeChanges.js.map +1 -0
- package/plugin/build/ios/target.d.ts +44 -0
- package/plugin/build/ios/target.d.ts.map +1 -0
- package/plugin/build/ios/target.js +670 -0
- package/plugin/build/ios/target.js.map +1 -0
- package/plugin/build/ios/utils/asset.d.ts +60 -0
- package/plugin/build/ios/utils/asset.d.ts.map +1 -0
- package/plugin/build/ios/utils/asset.js +375 -0
- package/plugin/build/ios/utils/asset.js.map +1 -0
- package/plugin/build/ios/utils/file.d.ts +33 -0
- package/plugin/build/ios/utils/file.d.ts.map +1 -0
- package/plugin/build/ios/utils/file.js +88 -0
- package/plugin/build/ios/utils/file.js.map +1 -0
- package/plugin/{src/ios/utils/index.ts → build/ios/utils/index.d.ts} +2 -1
- package/plugin/build/ios/utils/index.d.ts.map +1 -0
- package/plugin/build/ios/utils/index.js +39 -0
- package/plugin/build/ios/utils/index.js.map +1 -0
- package/plugin/build/ios/utils/paths.d.ts +134 -0
- package/plugin/build/ios/utils/paths.d.ts.map +1 -0
- package/plugin/build/ios/utils/paths.js +143 -0
- package/plugin/build/ios/utils/paths.js.map +1 -0
- package/plugin/build/ios/utils/plist.d.ts +29 -0
- package/plugin/build/ios/utils/plist.d.ts.map +1 -0
- package/plugin/build/ios/utils/plist.js +116 -0
- package/plugin/build/ios/utils/plist.js.map +1 -0
- package/plugin/build/ios/utils/podfile.d.ts +82 -0
- package/plugin/build/ios/utils/podfile.d.ts.map +1 -0
- package/plugin/build/ios/utils/podfile.js +441 -0
- package/plugin/build/ios/utils/podfile.js.map +1 -0
- package/plugin/build/ios/utils/reactNativeSwift.d.ts +11 -0
- package/plugin/build/ios/utils/reactNativeSwift.d.ts.map +1 -0
- package/plugin/build/ios/utils/reactNativeSwift.js +263 -0
- package/plugin/build/ios/utils/reactNativeSwift.js.map +1 -0
- package/plugin/build/ios/utils/safari.d.ts +69 -0
- package/plugin/build/ios/utils/safari.d.ts.map +1 -0
- package/plugin/build/ios/utils/safari.js +359 -0
- package/plugin/build/ios/utils/safari.js.map +1 -0
- package/plugin/build/ios/utils/xcode.d.ts +185 -0
- package/plugin/build/ios/utils/xcode.d.ts.map +1 -0
- package/plugin/build/ios/utils/xcode.js +706 -0
- package/plugin/build/ios/utils/xcode.js.map +1 -0
- package/plugin/build/logger.d.ts +10 -0
- package/plugin/build/logger.d.ts.map +1 -0
- package/plugin/build/logger.js +62 -0
- package/plugin/build/logger.js.map +1 -0
- package/plugin/build/parseTargetConfig.d.ts +3 -0
- package/plugin/build/parseTargetConfig.d.ts.map +1 -0
- package/plugin/build/parseTargetConfig.js +113 -0
- package/plugin/build/parseTargetConfig.js.map +1 -0
- package/plugin/build/withTargetsDir.d.ts +6 -0
- package/plugin/build/withTargetsDir.d.ts.map +1 -0
- package/plugin/build/withTargetsDir.js +190 -0
- package/plugin/build/withTargetsDir.js.map +1 -0
- package/.eslintrc.js +0 -2
- package/metro/src/withTargetsMetro.ts +0 -72
- package/metro/tsconfig.build.json +0 -9
- package/plugin/src/android/withAndroidAppBuildGradle.ts +0 -34
- package/plugin/src/android/withAndroidTarget.ts +0 -26
- package/plugin/src/android/withAndroidWidget.ts +0 -778
- package/plugin/src/config.ts +0 -255
- package/plugin/src/index.ts +0 -19
- package/plugin/src/ios/config-plugins/withEntitlements.ts +0 -69
- package/plugin/src/ios/config-plugins/withIOSTarget.ts +0 -179
- package/plugin/src/ios/config-plugins/withIosColorset.ts +0 -29
- package/plugin/src/ios/config-plugins/withIosStickerPack.ts +0 -65
- package/plugin/src/ios/config-plugins/withPodfile.ts +0 -238
- package/plugin/src/ios/config-plugins/withXcodeChanges.ts +0 -891
- package/plugin/src/ios/target.ts +0 -668
- package/plugin/src/ios/utils/asset.ts +0 -490
- package/plugin/src/ios/utils/file.ts +0 -80
- package/plugin/src/ios/utils/paths.ts +0 -253
- package/plugin/src/ios/utils/plist.ts +0 -101
- package/plugin/src/ios/utils/podfile.ts +0 -534
- package/plugin/src/ios/utils/reactNativeSwift.ts +0 -283
- package/plugin/src/ios/utils/xcode.ts +0 -989
- package/plugin/src/logger.ts +0 -63
- package/plugin/src/parseTargetConfig.ts +0 -115
- package/plugin/src/types/normalize-colors.d.ts +0 -3
- package/plugin/src/withTargetsDir.ts +0 -120
- package/plugin/tsconfig.build.json +0 -9
- package/plugin/tsconfig.json +0 -9
- package/src/Target.ts +0 -239
- package/src/index.ts +0 -52
- package/src/modules/extension/index.ts +0 -54
- package/src/modules/messages/index.ts +0 -124
- package/src/modules/storage/index.ts +0 -126
- package/tsconfig.json +0 -8
- /package/plugin/{src → build}/ios/templates/MessagesViewController.swift +0 -0
- /package/plugin/{src → build}/ios/templates/ReactNativeViewController.swift +0 -0
- /package/plugin/{src → build}/ios/templates/action-extension-data.swift +0 -0
- /package/plugin/{src → build}/ios/templates/clip-extension-data.swift +0 -0
- /package/plugin/{src → build}/ios/templates/messages-extension-data.swift +0 -0
- /package/plugin/{src → build}/ios/templates/share-extension-data.swift +0 -0
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
|
|
4
|
-
import type { ExtensionType } from '../../config';
|
|
5
|
-
|
|
6
|
-
const TEMPLATES_DIR = path.join(__dirname, '..', 'templates');
|
|
7
|
-
|
|
8
|
-
export interface ReactNativeViewControllerOptions {
|
|
9
|
-
type: ExtensionType;
|
|
10
|
-
moduleName: string;
|
|
11
|
-
targetName: string;
|
|
12
|
-
preprocessingFile?: string;
|
|
13
|
-
entry?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function readTemplate(filename: string): string {
|
|
17
|
-
const templatePath = path.join(TEMPLATES_DIR, filename);
|
|
18
|
-
return fs.readFileSync(templatePath, 'utf-8');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getExtensionDataForType(
|
|
22
|
-
type: ExtensionType,
|
|
23
|
-
preprocessingFile?: string
|
|
24
|
-
): {
|
|
25
|
-
properties: string;
|
|
26
|
-
loadMethod: string;
|
|
27
|
-
propsMethod: string;
|
|
28
|
-
} {
|
|
29
|
-
switch (type) {
|
|
30
|
-
case 'share': {
|
|
31
|
-
const dataTemplate = readTemplate('share-extension-data.swift');
|
|
32
|
-
|
|
33
|
-
// Handle preprocessing file
|
|
34
|
-
let preprocessingLoad = '';
|
|
35
|
-
if (preprocessingFile) {
|
|
36
|
-
preprocessingLoad = `
|
|
37
|
-
// Load preprocessed web data
|
|
38
|
-
if let jsDict = extensionItem.userInfo?[NSExtensionJavaScriptPreprocessingResultsKey] as? [String: Any] {
|
|
39
|
-
self.preprocessedWebData = jsDict
|
|
40
|
-
}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const modifiedTemplate = dataTemplate.replace(
|
|
44
|
-
'{{PREPROCESSING_DATA_LOAD}}',
|
|
45
|
-
preprocessingLoad
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// Split template into sections
|
|
49
|
-
const lines = modifiedTemplate.split('\n');
|
|
50
|
-
const properties: string[] = [];
|
|
51
|
-
const loadMethodLines: string[] = [];
|
|
52
|
-
const propsMethodLines: string[] = [];
|
|
53
|
-
|
|
54
|
-
let currentSection: 'properties' | 'load' | 'props' | null = null;
|
|
55
|
-
|
|
56
|
-
for (const line of lines) {
|
|
57
|
-
if (line.includes('private var ')) {
|
|
58
|
-
currentSection = 'properties';
|
|
59
|
-
properties.push(line);
|
|
60
|
-
} else if (line.includes('private func loadSharedContent()')) {
|
|
61
|
-
currentSection = 'load';
|
|
62
|
-
loadMethodLines.push(line);
|
|
63
|
-
} else if (line.includes('private func getSharedDataProps()')) {
|
|
64
|
-
currentSection = 'props';
|
|
65
|
-
propsMethodLines.push(line);
|
|
66
|
-
} else if (
|
|
67
|
-
currentSection === 'properties' &&
|
|
68
|
-
line.trim().startsWith('private')
|
|
69
|
-
) {
|
|
70
|
-
properties.push(line);
|
|
71
|
-
} else if (currentSection === 'load') {
|
|
72
|
-
loadMethodLines.push(line);
|
|
73
|
-
} else if (currentSection === 'props') {
|
|
74
|
-
propsMethodLines.push(line);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
properties: properties.join('\n '),
|
|
80
|
-
loadMethod: `// Load shared content before creating React Native view
|
|
81
|
-
Task {
|
|
82
|
-
await loadSharedContent()
|
|
83
|
-
// Create React Native view with loaded content
|
|
84
|
-
await MainActor.run {
|
|
85
|
-
let sharedData = getSharedDataProps()
|
|
86
|
-
setupReactNativeView(with: sharedData)
|
|
87
|
-
}
|
|
88
|
-
}`,
|
|
89
|
-
propsMethod:
|
|
90
|
-
loadMethodLines.join('\n') + '\n\n' + propsMethodLines.join('\n'),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
case 'action': {
|
|
95
|
-
const dataTemplate = readTemplate('action-extension-data.swift');
|
|
96
|
-
const lines = dataTemplate.split('\n');
|
|
97
|
-
const properties: string[] = [];
|
|
98
|
-
const loadMethodLines: string[] = [];
|
|
99
|
-
const propsMethodLines: string[] = [];
|
|
100
|
-
|
|
101
|
-
let currentSection: 'properties' | 'load' | 'props' | null = null;
|
|
102
|
-
|
|
103
|
-
for (const line of lines) {
|
|
104
|
-
if (line.includes('private var ')) {
|
|
105
|
-
currentSection = 'properties';
|
|
106
|
-
properties.push(line);
|
|
107
|
-
} else if (line.includes('private func loadActionContent()')) {
|
|
108
|
-
currentSection = 'load';
|
|
109
|
-
loadMethodLines.push(line);
|
|
110
|
-
} else if (line.includes('private func getActionDataProps()')) {
|
|
111
|
-
currentSection = 'props';
|
|
112
|
-
propsMethodLines.push(line);
|
|
113
|
-
} else if (
|
|
114
|
-
currentSection === 'properties' &&
|
|
115
|
-
line.trim().startsWith('private')
|
|
116
|
-
) {
|
|
117
|
-
properties.push(line);
|
|
118
|
-
} else if (currentSection === 'load') {
|
|
119
|
-
loadMethodLines.push(line);
|
|
120
|
-
} else if (currentSection === 'props') {
|
|
121
|
-
propsMethodLines.push(line);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
properties: properties.join('\n '),
|
|
127
|
-
loadMethod: `// Load action content before creating React Native view
|
|
128
|
-
Task {
|
|
129
|
-
await loadActionContent()
|
|
130
|
-
// Create React Native view with loaded content
|
|
131
|
-
await MainActor.run {
|
|
132
|
-
let actionData = getActionDataProps()
|
|
133
|
-
setupReactNativeView(with: actionData)
|
|
134
|
-
}
|
|
135
|
-
}`,
|
|
136
|
-
propsMethod:
|
|
137
|
-
loadMethodLines.join('\n') + '\n\n' + propsMethodLines.join('\n'),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
case 'clip': {
|
|
142
|
-
const dataTemplate = readTemplate('clip-extension-data.swift');
|
|
143
|
-
const lines = dataTemplate.split('\n');
|
|
144
|
-
const properties: string[] = [];
|
|
145
|
-
const loadMethodLines: string[] = [];
|
|
146
|
-
const propsMethodLines: string[] = [];
|
|
147
|
-
|
|
148
|
-
let currentSection: 'properties' | 'load' | 'props' | null = null;
|
|
149
|
-
|
|
150
|
-
for (const line of lines) {
|
|
151
|
-
if (line.includes('private var ')) {
|
|
152
|
-
currentSection = 'properties';
|
|
153
|
-
properties.push(line);
|
|
154
|
-
} else if (line.includes('private func loadClipContent()')) {
|
|
155
|
-
currentSection = 'load';
|
|
156
|
-
loadMethodLines.push(line);
|
|
157
|
-
} else if (line.includes('private func getClipDataProps()')) {
|
|
158
|
-
currentSection = 'props';
|
|
159
|
-
propsMethodLines.push(line);
|
|
160
|
-
} else if (
|
|
161
|
-
currentSection === 'properties' &&
|
|
162
|
-
line.trim().startsWith('private')
|
|
163
|
-
) {
|
|
164
|
-
properties.push(line);
|
|
165
|
-
} else if (currentSection === 'load') {
|
|
166
|
-
loadMethodLines.push(line);
|
|
167
|
-
} else if (currentSection === 'props') {
|
|
168
|
-
propsMethodLines.push(line);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
properties: properties.join('\n '),
|
|
174
|
-
loadMethod: `loadClipContent()
|
|
175
|
-
let clipData = getClipDataProps()
|
|
176
|
-
setupReactNativeView(with: clipData)`,
|
|
177
|
-
propsMethod:
|
|
178
|
-
loadMethodLines.join('\n') + '\n\n' + propsMethodLines.join('\n'),
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
case 'messages': {
|
|
183
|
-
const dataTemplate = readTemplate('messages-extension-data.swift');
|
|
184
|
-
const lines = dataTemplate.split('\n');
|
|
185
|
-
const properties: string[] = [];
|
|
186
|
-
const loadMethodLines: string[] = [];
|
|
187
|
-
const propsMethodLines: string[] = [];
|
|
188
|
-
|
|
189
|
-
let currentSection: 'properties' | 'load' | 'props' | null = null;
|
|
190
|
-
|
|
191
|
-
for (const line of lines) {
|
|
192
|
-
if (line.includes('private var ')) {
|
|
193
|
-
currentSection = 'properties';
|
|
194
|
-
properties.push(line);
|
|
195
|
-
} else if (line.includes('private func loadMessagesContent()')) {
|
|
196
|
-
currentSection = 'load';
|
|
197
|
-
loadMethodLines.push(line);
|
|
198
|
-
} else if (line.includes('private func getMessagesDataProps()')) {
|
|
199
|
-
currentSection = 'props';
|
|
200
|
-
propsMethodLines.push(line);
|
|
201
|
-
} else if (
|
|
202
|
-
currentSection === 'properties' &&
|
|
203
|
-
line.trim().startsWith('private')
|
|
204
|
-
) {
|
|
205
|
-
properties.push(line);
|
|
206
|
-
} else if (currentSection === 'load') {
|
|
207
|
-
loadMethodLines.push(line);
|
|
208
|
-
} else if (currentSection === 'props') {
|
|
209
|
-
propsMethodLines.push(line);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
properties: properties.join('\n '),
|
|
215
|
-
loadMethod: `loadMessagesContent()
|
|
216
|
-
let messagesData = getMessagesDataProps()
|
|
217
|
-
setupReactNativeView(with: messagesData)`,
|
|
218
|
-
propsMethod:
|
|
219
|
-
loadMethodLines.join('\n') + '\n\n' + propsMethodLines.join('\n'),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
default:
|
|
224
|
-
// For other types, no extension-specific data
|
|
225
|
-
return {
|
|
226
|
-
properties: '',
|
|
227
|
-
loadMethod: 'setupReactNativeView(with: nil)',
|
|
228
|
-
propsMethod: '',
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export function generateMessagesViewController(): string {
|
|
234
|
-
return readTemplate('MessagesViewController.swift');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export function generateReactNativeViewController(
|
|
238
|
-
options: ReactNativeViewControllerOptions
|
|
239
|
-
): string {
|
|
240
|
-
let baseTemplate = readTemplate('ReactNativeViewController.swift');
|
|
241
|
-
const extensionData = getExtensionDataForType(
|
|
242
|
-
options.type,
|
|
243
|
-
options.preprocessingFile
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
// Add Messages import for messages type
|
|
247
|
-
if (options.type === 'messages') {
|
|
248
|
-
baseTemplate = baseTemplate.replace(
|
|
249
|
-
'import ReactAppDependencyProvider',
|
|
250
|
-
'import ReactAppDependencyProvider\nimport Messages'
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Convert entry path to bundle root for Metro
|
|
255
|
-
// e.g., "./targets/rn-share/index.tsx" -> "targets/rn-share/index"
|
|
256
|
-
let bundleRoot = '.expo/.virtual-metro-entry';
|
|
257
|
-
if (options.entry) {
|
|
258
|
-
bundleRoot = options.entry
|
|
259
|
-
.replace(/^\.\//, '') // Remove leading ./
|
|
260
|
-
.replace(/\.(tsx?|jsx?)$/, ''); // Remove file extension
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Replace placeholders (use replaceAll to catch multiple occurrences)
|
|
264
|
-
let result = baseTemplate
|
|
265
|
-
.replace(/{{MODULE_NAME}}/g, options.moduleName)
|
|
266
|
-
.replace(/{{TARGET_NAME}}/g, options.targetName)
|
|
267
|
-
.replace(/{{BUNDLE_ROOT}}/g, bundleRoot)
|
|
268
|
-
.replace('{{EXTENSION_DATA_PROPERTIES}}', extensionData.properties)
|
|
269
|
-
.replace('{{LOAD_EXTENSION_DATA}}', extensionData.loadMethod);
|
|
270
|
-
|
|
271
|
-
// Add extension data methods if needed
|
|
272
|
-
if (extensionData.propsMethod) {
|
|
273
|
-
const closingBraceIndex = result.lastIndexOf('}');
|
|
274
|
-
result =
|
|
275
|
-
result.slice(0, closingBraceIndex) +
|
|
276
|
-
'\n // MARK: - Extension Data\n \n' +
|
|
277
|
-
extensionData.propsMethod +
|
|
278
|
-
'\n' +
|
|
279
|
-
result.slice(closingBraceIndex);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return result;
|
|
283
|
-
}
|