@expo/config-plugins 5.0.4 → 6.0.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/build/Plugin.types.d.ts +7 -7
- package/build/Plugin.types.js +0 -9
- package/build/Plugin.types.js.map +1 -1
- package/build/android/AllowBackup.js +0 -15
- package/build/android/AllowBackup.js.map +1 -1
- package/build/android/BuildProperties.js +2 -16
- package/build/android/BuildProperties.js.map +1 -1
- package/build/android/Colors.js +3 -25
- package/build/android/Colors.js.map +1 -1
- package/build/android/EasBuild.js +2 -22
- package/build/android/EasBuild.js.map +1 -1
- package/build/android/EasBuildGradleScript.js.map +1 -1
- package/build/android/GoogleMapsApiKey.js +0 -12
- package/build/android/GoogleMapsApiKey.js.map +1 -1
- package/build/android/GoogleServices.js +10 -48
- package/build/android/GoogleServices.js.map +1 -1
- package/build/android/IntentFilters.d.ts +1 -1
- package/build/android/IntentFilters.js +8 -24
- package/build/android/IntentFilters.js.map +1 -1
- package/build/android/Manifest.d.ts +19 -19
- package/build/android/Manifest.js +7 -66
- package/build/android/Manifest.js.map +1 -1
- package/build/android/Name.js +6 -27
- package/build/android/Name.js.map +1 -1
- package/build/android/Orientation.js +2 -12
- package/build/android/Orientation.js.map +1 -1
- package/build/android/Package.js +26 -111
- package/build/android/Package.js.map +1 -1
- package/build/android/Paths.d.ts +2 -2
- package/build/android/Paths.js +0 -47
- package/build/android/Paths.js.map +1 -1
- package/build/android/Permissions.js +8 -52
- package/build/android/Permissions.js.map +1 -1
- package/build/android/PrimaryColor.js +0 -18
- package/build/android/PrimaryColor.js.map +1 -1
- package/build/android/Properties.d.ts +1 -1
- package/build/android/Properties.js +0 -9
- package/build/android/Properties.js.map +1 -1
- package/build/android/Resources.d.ts +4 -4
- package/build/android/Resources.js +9 -29
- package/build/android/Resources.js.map +1 -1
- package/build/android/Scheme.d.ts +1 -1
- package/build/android/Scheme.js +13 -66
- package/build/android/Scheme.js.map +1 -1
- package/build/android/StatusBar.js +5 -33
- package/build/android/StatusBar.js.map +1 -1
- package/build/android/Strings.js +0 -14
- package/build/android/Strings.js.map +1 -1
- package/build/android/Styles.js +7 -34
- package/build/android/Styles.js.map +1 -1
- package/build/android/Updates.d.ts +2 -0
- package/build/android/Updates.js +50 -47
- package/build/android/Updates.js.map +1 -1
- package/build/android/Version.js +3 -29
- package/build/android/Version.js.map +1 -1
- package/build/android/WindowSoftInputMode.js +0 -14
- package/build/android/WindowSoftInputMode.js.map +1 -1
- package/build/android/codeMod.js +6 -22
- package/build/android/codeMod.js.map +1 -1
- package/build/android/index.js +0 -94
- package/build/android/index.js.map +1 -1
- package/build/index.js +2 -65
- package/build/index.js.map +1 -1
- package/build/ios/Bitcode.d.ts +1 -1
- package/build/ios/Bitcode.js +8 -28
- package/build/ios/Bitcode.js.map +1 -1
- package/build/ios/BuildProperties.js +2 -14
- package/build/ios/BuildProperties.js.map +1 -1
- package/build/ios/BuildScheme.js +2 -34
- package/build/ios/BuildScheme.js.map +1 -1
- package/build/ios/BundleIdentifier.js +13 -72
- package/build/ios/BundleIdentifier.js.map +1 -1
- package/build/ios/DeviceFamily.js +6 -24
- package/build/ios/DeviceFamily.js.map +1 -1
- package/build/ios/Entitlements.js +4 -45
- package/build/ios/Entitlements.js.map +1 -1
- package/build/ios/Google.d.ts +2 -2
- package/build/ios/Google.js +11 -66
- package/build/ios/Google.js.map +1 -1
- package/build/ios/IosConfig.types.d.ts +6 -11
- package/build/ios/IosConfig.types.js.map +1 -1
- package/build/ios/Locales.d.ts +3 -3
- package/build/ios/Locales.js +12 -43
- package/build/ios/Locales.js.map +1 -1
- package/build/ios/Maps.js +15 -53
- package/build/ios/Maps.js.map +1 -1
- package/build/ios/Name.js +7 -31
- package/build/ios/Name.js.map +1 -1
- package/build/ios/Orientation.js +2 -10
- package/build/ios/Orientation.js.map +1 -1
- package/build/ios/Paths.d.ts +2 -2
- package/build/ios/Paths.js +8 -73
- package/build/ios/Paths.js.map +1 -1
- package/build/ios/Permissions.js +1 -16
- package/build/ios/Permissions.js.map +1 -1
- package/build/ios/ProvisioningProfile.d.ts +1 -1
- package/build/ios/ProvisioningProfile.js +0 -18
- package/build/ios/ProvisioningProfile.js.map +1 -1
- package/build/ios/RequiresFullScreen.js +19 -31
- package/build/ios/RequiresFullScreen.js.map +1 -1
- package/build/ios/Scheme.js +10 -32
- package/build/ios/Scheme.js.map +1 -1
- package/build/ios/Swift.js +16 -50
- package/build/ios/Swift.js.map +1 -1
- package/build/ios/Target.js +0 -30
- package/build/ios/Target.js.map +1 -1
- package/build/ios/Updates.js +10 -49
- package/build/ios/Updates.js.map +1 -1
- package/build/ios/UsesNonExemptEncryption.js +4 -10
- package/build/ios/UsesNonExemptEncryption.js.map +1 -1
- package/build/ios/Version.js +4 -11
- package/build/ios/Version.js.map +1 -1
- package/build/ios/XcodeProjectFile.js +5 -23
- package/build/ios/XcodeProjectFile.js.map +1 -1
- package/build/ios/codeMod.js +19 -60
- package/build/ios/codeMod.js.map +1 -1
- package/build/ios/index.js +0 -97
- package/build/ios/index.js.map +1 -1
- package/build/ios/utils/Xcodeproj.d.ts +6 -6
- package/build/ios/utils/Xcodeproj.js +15 -101
- package/build/ios/utils/Xcodeproj.js.map +1 -1
- package/build/ios/utils/getInfoPlistPath.js +2 -15
- package/build/ios/utils/getInfoPlistPath.js.map +1 -1
- package/build/ios/utils/string.js +0 -1
- package/build/ios/utils/string.js.map +1 -1
- package/build/plugins/android-plugins.d.ts +2 -2
- package/build/plugins/android-plugins.js +11 -42
- package/build/plugins/android-plugins.js.map +1 -1
- package/build/plugins/createBaseMod.d.ts +3 -3
- package/build/plugins/createBaseMod.js +8 -25
- package/build/plugins/createBaseMod.js.map +1 -1
- package/build/plugins/ios-plugins.d.ts +2 -2
- package/build/plugins/ios-plugins.js +8 -48
- package/build/plugins/ios-plugins.js.map +1 -1
- package/build/plugins/mod-compiler.js +21 -72
- package/build/plugins/mod-compiler.js.map +1 -1
- package/build/plugins/withAndroidBaseMods.d.ts +1 -1
- package/build/plugins/withAndroidBaseMods.js +4 -89
- package/build/plugins/withAndroidBaseMods.js.map +1 -1
- package/build/plugins/withDangerousMod.js +0 -5
- package/build/plugins/withDangerousMod.js.map +1 -1
- package/build/plugins/withIosBaseMods.d.ts +1 -1
- package/build/plugins/withIosBaseMods.js +26 -118
- package/build/plugins/withIosBaseMods.js.map +1 -1
- package/build/plugins/withMod.d.ts +1 -1
- package/build/plugins/withMod.js +24 -59
- package/build/plugins/withMod.js.map +1 -1
- package/build/plugins/withPlugins.js +0 -9
- package/build/plugins/withPlugins.js.map +1 -1
- package/build/plugins/withRunOnce.js +3 -9
- package/build/plugins/withRunOnce.js.map +1 -1
- package/build/plugins/withStaticPlugin.js +21 -43
- package/build/plugins/withStaticPlugin.js.map +1 -1
- package/build/utils/BuildProperties.types.d.ts +2 -2
- package/build/utils/BuildProperties.types.js.map +1 -1
- package/build/utils/Updates.d.ts +3 -1
- package/build/utils/Updates.js +18 -77
- package/build/utils/Updates.js.map +1 -1
- package/build/utils/XML.d.ts +1 -1
- package/build/utils/XML.js +7 -44
- package/build/utils/XML.js.map +1 -1
- package/build/utils/commonCodeMod.js +2 -10
- package/build/utils/commonCodeMod.js.map +1 -1
- package/build/utils/errors.d.ts +1 -1
- package/build/utils/errors.js +3 -11
- package/build/utils/errors.js.map +1 -1
- package/build/utils/fs.js +1 -12
- package/build/utils/fs.js.map +1 -1
- package/build/utils/generateCode.d.ts +1 -1
- package/build/utils/generateCode.js +8 -25
- package/build/utils/generateCode.js.map +1 -1
- package/build/utils/history.d.ts +1 -1
- package/build/utils/history.js +0 -6
- package/build/utils/history.js.map +1 -1
- package/build/utils/matchBrackets.d.ts +3 -3
- package/build/utils/matchBrackets.js +2 -17
- package/build/utils/matchBrackets.js.map +1 -1
- package/build/utils/modules.js +0 -10
- package/build/utils/modules.js.map +1 -1
- package/build/utils/obj.js +0 -4
- package/build/utils/obj.js.map +1 -1
- package/build/utils/plugin-resolver.js +25 -69
- package/build/utils/plugin-resolver.js.map +1 -1
- package/build/utils/sortObject.js +4 -10
- package/build/utils/sortObject.js.map +1 -1
- package/build/utils/versions.js +0 -10
- package/build/utils/versions.js.map +1 -1
- package/build/utils/warnings.js +1 -9
- package/build/utils/warnings.js.map +1 -1
- package/package.json +5 -5
package/build/ios/codeMod.js
CHANGED
|
@@ -11,27 +11,20 @@ exports.insertContentsInsideObjcFunctionBlock = insertContentsInsideObjcFunction
|
|
|
11
11
|
exports.insertContentsInsideObjcInterfaceBlock = insertContentsInsideObjcInterfaceBlock;
|
|
12
12
|
exports.insertContentsInsideSwiftClassBlock = insertContentsInsideSwiftClassBlock;
|
|
13
13
|
exports.insertContentsInsideSwiftFunctionBlock = insertContentsInsideSwiftFunctionBlock;
|
|
14
|
-
|
|
15
14
|
function _commonCodeMod() {
|
|
16
15
|
const data = require("../utils/commonCodeMod");
|
|
17
|
-
|
|
18
16
|
_commonCodeMod = function () {
|
|
19
17
|
return data;
|
|
20
18
|
};
|
|
21
|
-
|
|
22
19
|
return data;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
function _matchBrackets() {
|
|
26
22
|
const data = require("../utils/matchBrackets");
|
|
27
|
-
|
|
28
23
|
_matchBrackets = function () {
|
|
29
24
|
return data;
|
|
30
25
|
};
|
|
31
|
-
|
|
32
26
|
return data;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
/**
|
|
36
29
|
* Add Objective-C import
|
|
37
30
|
* @param source source contents
|
|
@@ -39,19 +32,18 @@ function _matchBrackets() {
|
|
|
39
32
|
* @returns updated contents
|
|
40
33
|
*/
|
|
41
34
|
function addObjcImports(source, imports) {
|
|
42
|
-
const lines = source.split('\n');
|
|
43
|
-
|
|
35
|
+
const lines = source.split('\n');
|
|
36
|
+
// Try to insert statements after first #import where would probably not in #if block
|
|
44
37
|
const lineIndexWithFirstImport = lines.findIndex(line => line.match(/^#import .*$/));
|
|
45
|
-
|
|
46
38
|
for (const importElement of imports) {
|
|
47
39
|
if (!source.includes(importElement)) {
|
|
48
40
|
const importStatement = `#import ${importElement}`;
|
|
49
41
|
lines.splice(lineIndexWithFirstImport + 1, 0, importStatement);
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
return lines.join('\n');
|
|
54
45
|
}
|
|
46
|
+
|
|
55
47
|
/**
|
|
56
48
|
* Find code block of Objective-C interface or implementation
|
|
57
49
|
*
|
|
@@ -59,15 +51,11 @@ function addObjcImports(source, imports) {
|
|
|
59
51
|
* @param declaration interface/implementation, e.g. '@interface Foo'
|
|
60
52
|
* @returns found CodeBlock, or null if not found
|
|
61
53
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
54
|
function findObjcInterfaceCodeBlock(contents, declaration) {
|
|
65
55
|
const start = contents.search(new RegExp(`^${declaration}\\W`, 'm'));
|
|
66
|
-
|
|
67
56
|
if (start < 0) {
|
|
68
57
|
return null;
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
let end = contents.indexOf('\n@end', start);
|
|
72
60
|
end += 5; // '\n@end'.length === 5
|
|
73
61
|
|
|
@@ -77,6 +65,7 @@ function findObjcInterfaceCodeBlock(contents, declaration) {
|
|
|
77
65
|
code: contents.substring(start, end)
|
|
78
66
|
};
|
|
79
67
|
}
|
|
68
|
+
|
|
80
69
|
/**
|
|
81
70
|
* Find code block of Objective-C function without declaration, will return only {} block
|
|
82
71
|
*
|
|
@@ -84,13 +73,10 @@ function findObjcInterfaceCodeBlock(contents, declaration) {
|
|
|
84
73
|
* @param selector function selector, e.g. 'doSomething:withSomeValue:'
|
|
85
74
|
* @returns found CodeBlock, or null if not found.
|
|
86
75
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
76
|
function findObjcFunctionCodeBlock(contents, selector) {
|
|
90
77
|
const symbols = selector.split(':');
|
|
91
78
|
const argsCount = symbols.length - 1;
|
|
92
79
|
let pattern = '^[\\-+]\\s*\\(.+?\\)';
|
|
93
|
-
|
|
94
80
|
if (argsCount === 0) {
|
|
95
81
|
pattern += `${symbols[0]}\\s+`;
|
|
96
82
|
} else {
|
|
@@ -99,14 +85,11 @@ function findObjcFunctionCodeBlock(contents, selector) {
|
|
|
99
85
|
pattern += `${argSymbol}\\s+`;
|
|
100
86
|
}
|
|
101
87
|
}
|
|
102
|
-
|
|
103
88
|
pattern += '{';
|
|
104
89
|
let start = contents.search(new RegExp(pattern, 'm'));
|
|
105
|
-
|
|
106
90
|
if (start < 0) {
|
|
107
91
|
return null;
|
|
108
92
|
}
|
|
109
|
-
|
|
110
93
|
start = contents.indexOf('{', start);
|
|
111
94
|
const end = (0, _matchBrackets().findMatchingBracketPosition)(contents, '{', start);
|
|
112
95
|
return {
|
|
@@ -115,6 +98,7 @@ function findObjcFunctionCodeBlock(contents, selector) {
|
|
|
115
98
|
code: contents.substring(start, end + 1)
|
|
116
99
|
};
|
|
117
100
|
}
|
|
101
|
+
|
|
118
102
|
/**
|
|
119
103
|
* Insert contents to the Objective-C function block
|
|
120
104
|
*
|
|
@@ -124,11 +108,10 @@ function findObjcFunctionCodeBlock(contents, selector) {
|
|
|
124
108
|
* @param options insertion options
|
|
125
109
|
* @returns updated contents
|
|
126
110
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
111
|
function insertContentsInsideObjcFunctionBlock(srcContents, selector, insertion, options) {
|
|
130
112
|
return insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, 'objc');
|
|
131
113
|
}
|
|
114
|
+
|
|
132
115
|
/**
|
|
133
116
|
* Insert contents to the Objective-C interface/implementation block
|
|
134
117
|
*
|
|
@@ -138,19 +121,14 @@ function insertContentsInsideObjcFunctionBlock(srcContents, selector, insertion,
|
|
|
138
121
|
* @param options insertion options
|
|
139
122
|
* @returns updated contents
|
|
140
123
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
124
|
function insertContentsInsideObjcInterfaceBlock(srcContents, declaration, insertion, options) {
|
|
144
125
|
const codeBlock = findObjcInterfaceCodeBlock(srcContents, declaration);
|
|
145
|
-
|
|
146
126
|
if (!codeBlock) {
|
|
147
127
|
return srcContents;
|
|
148
128
|
}
|
|
149
|
-
|
|
150
129
|
const {
|
|
151
130
|
position
|
|
152
131
|
} = options;
|
|
153
|
-
|
|
154
132
|
if (position === 'head') {
|
|
155
133
|
const firstNewLineIndex = srcContents.indexOf('\n', codeBlock.start);
|
|
156
134
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, insertion, firstNewLineIndex);
|
|
@@ -158,9 +136,9 @@ function insertContentsInsideObjcInterfaceBlock(srcContents, declaration, insert
|
|
|
158
136
|
const endLen = '@end'.length;
|
|
159
137
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, insertion, codeBlock.end - endLen);
|
|
160
138
|
}
|
|
161
|
-
|
|
162
139
|
return srcContents;
|
|
163
140
|
}
|
|
141
|
+
|
|
164
142
|
/**
|
|
165
143
|
* Find code block of Swift function without declaration, will return only {} block
|
|
166
144
|
*
|
|
@@ -168,39 +146,37 @@ function insertContentsInsideObjcInterfaceBlock(srcContents, declaration, insert
|
|
|
168
146
|
* @param selector function selector, e.g. 'doSomething(_:withSomeValue:)'
|
|
169
147
|
* @returns found CodeBlock, or null if not found.
|
|
170
148
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
149
|
function findSwiftFunctionCodeBlock(contents, selector) {
|
|
174
|
-
const parenthesesIndex = selector.indexOf('(');
|
|
175
|
-
|
|
176
|
-
const funcName = selector.substring(0, parenthesesIndex);
|
|
177
|
-
|
|
150
|
+
const parenthesesIndex = selector.indexOf('(');
|
|
151
|
+
// `functName` === 'doSomething' of 'doSomething(_:withSomeValue:)'
|
|
152
|
+
const funcName = selector.substring(0, parenthesesIndex);
|
|
153
|
+
// `argLabels` === ['_', 'withSomeValue'] 'doSomething(_:withSomeValue:)'
|
|
178
154
|
const argLabels = selector.substring(parenthesesIndex + 1, selector.length - 2).split(':');
|
|
179
155
|
let searchOffset = 0;
|
|
180
156
|
const funcCandidateRegExp = new RegExp(`\\sfunc\\s+${funcName}\\(`, 'm');
|
|
181
157
|
let funcCandidateOffset = (0, _commonCodeMod().searchFromOffset)(contents, funcCandidateRegExp, searchOffset);
|
|
182
|
-
|
|
183
158
|
while (funcCandidateOffset >= 0) {
|
|
184
159
|
// Parse function parameters
|
|
185
160
|
const paramsStartOffset = contents.indexOf('(', funcCandidateOffset);
|
|
186
161
|
const paramsEndOffset = (0, _matchBrackets().findMatchingBracketPosition)(contents, '(', paramsStartOffset);
|
|
187
162
|
const paramsString = contents.substring(paramsStartOffset + 1, paramsEndOffset);
|
|
188
|
-
const params = paramsString.split(',').map(parseSwiftFunctionParam);
|
|
163
|
+
const params = paramsString.split(',').map(parseSwiftFunctionParam);
|
|
189
164
|
|
|
165
|
+
// Prepare offset for next round
|
|
190
166
|
searchOffset = paramsEndOffset + 1;
|
|
191
|
-
funcCandidateOffset = (0, _commonCodeMod().searchFromOffset)(contents, funcCandidateRegExp, searchOffset);
|
|
167
|
+
funcCandidateOffset = (0, _commonCodeMod().searchFromOffset)(contents, funcCandidateRegExp, searchOffset);
|
|
192
168
|
|
|
169
|
+
// Try to match function parameters
|
|
193
170
|
if (argLabels.length !== params.length) {
|
|
194
171
|
continue;
|
|
195
172
|
}
|
|
196
|
-
|
|
197
173
|
for (let i = 0; i < argLabels.length; ++i) {
|
|
198
174
|
if (argLabels[i] !== params[i].argumentLabel) {
|
|
199
175
|
continue;
|
|
200
176
|
}
|
|
201
|
-
}
|
|
202
|
-
|
|
177
|
+
}
|
|
203
178
|
|
|
179
|
+
// This function is matched one, get the code block.
|
|
204
180
|
const codeBlockStart = contents.indexOf('{', paramsEndOffset);
|
|
205
181
|
const codeBlockEnd = (0, _matchBrackets().findMatchingBracketPosition)(contents, '{', paramsEndOffset);
|
|
206
182
|
const codeBlock = contents.substring(codeBlockStart, codeBlockEnd + 1);
|
|
@@ -210,10 +186,8 @@ function findSwiftFunctionCodeBlock(contents, selector) {
|
|
|
210
186
|
code: codeBlock
|
|
211
187
|
};
|
|
212
188
|
}
|
|
213
|
-
|
|
214
189
|
return null;
|
|
215
190
|
}
|
|
216
|
-
|
|
217
191
|
function parseSwiftFunctionParam(paramTuple) {
|
|
218
192
|
const semiIndex = paramTuple.indexOf(':');
|
|
219
193
|
const [argumentLabel, parameterName] = paramTuple.substring(0, semiIndex).split(/\s+/);
|
|
@@ -224,6 +198,7 @@ function parseSwiftFunctionParam(paramTuple) {
|
|
|
224
198
|
typeString
|
|
225
199
|
};
|
|
226
200
|
}
|
|
201
|
+
|
|
227
202
|
/**
|
|
228
203
|
* Insert contents to the swift class block
|
|
229
204
|
*
|
|
@@ -233,19 +208,14 @@ function parseSwiftFunctionParam(paramTuple) {
|
|
|
233
208
|
* @param options insertion options
|
|
234
209
|
* @returns updated contents
|
|
235
210
|
*/
|
|
236
|
-
|
|
237
|
-
|
|
238
211
|
function insertContentsInsideSwiftClassBlock(srcContents, declaration, insertion, options) {
|
|
239
212
|
const start = srcContents.search(new RegExp(`\\s*${declaration}.*?[\\(\\{]`));
|
|
240
|
-
|
|
241
213
|
if (start < 0) {
|
|
242
214
|
throw new Error(`Unable to find class code block - declaration[${declaration}]`);
|
|
243
215
|
}
|
|
244
|
-
|
|
245
216
|
const {
|
|
246
217
|
position
|
|
247
218
|
} = options;
|
|
248
|
-
|
|
249
219
|
if (position === 'head') {
|
|
250
220
|
const firstBracketIndex = srcContents.indexOf('{', start);
|
|
251
221
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, insertion, firstBracketIndex + 1);
|
|
@@ -253,9 +223,9 @@ function insertContentsInsideSwiftClassBlock(srcContents, declaration, insertion
|
|
|
253
223
|
const endBracketIndex = (0, _matchBrackets().findMatchingBracketPosition)(srcContents, '{', start);
|
|
254
224
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, insertion, endBracketIndex);
|
|
255
225
|
}
|
|
256
|
-
|
|
257
226
|
return srcContents;
|
|
258
227
|
}
|
|
228
|
+
|
|
259
229
|
/**
|
|
260
230
|
* Insert contents to the Swift function block
|
|
261
231
|
*
|
|
@@ -265,42 +235,31 @@ function insertContentsInsideSwiftClassBlock(srcContents, declaration, insertion
|
|
|
265
235
|
* @param options insertion options
|
|
266
236
|
* @returns updated contents
|
|
267
237
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
238
|
function insertContentsInsideSwiftFunctionBlock(srcContents, selector, insertion, options) {
|
|
271
239
|
return insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, 'swift');
|
|
272
240
|
}
|
|
273
|
-
|
|
274
241
|
function insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, language) {
|
|
275
242
|
var _options$indent;
|
|
276
|
-
|
|
277
243
|
const codeBlock = language === 'objc' ? findObjcFunctionCodeBlock(srcContents, selector) : findSwiftFunctionCodeBlock(srcContents, selector);
|
|
278
|
-
|
|
279
244
|
if (!codeBlock) {
|
|
280
245
|
return srcContents;
|
|
281
246
|
}
|
|
282
|
-
|
|
283
247
|
const {
|
|
284
248
|
position
|
|
285
249
|
} = options;
|
|
286
250
|
const indent = ' '.repeat((_options$indent = options.indent) !== null && _options$indent !== void 0 ? _options$indent : 2);
|
|
287
|
-
|
|
288
251
|
if (position === 'head') {
|
|
289
252
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, `\n${indent}${insertion}`, codeBlock.start + 1);
|
|
290
253
|
} else if (position === 'tail') {
|
|
291
254
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, `\n${indent}${insertion}`, codeBlock.end - 1);
|
|
292
255
|
} else if (position === 'tailBeforeLastReturn') {
|
|
293
256
|
let lastReturnIndex = srcContents.lastIndexOf(' return ', codeBlock.end);
|
|
294
|
-
|
|
295
257
|
if (lastReturnIndex < 0) {
|
|
296
258
|
throw new Error(`Cannot find last return statement:\n${srcContents}`);
|
|
297
259
|
}
|
|
298
|
-
|
|
299
260
|
lastReturnIndex += 1; // +1 for the prefix space
|
|
300
|
-
|
|
301
261
|
srcContents = (0, _commonCodeMod().insertContentsAtOffset)(srcContents, `${insertion}\n${indent}`, lastReturnIndex);
|
|
302
262
|
}
|
|
303
|
-
|
|
304
263
|
return srcContents;
|
|
305
264
|
}
|
|
306
265
|
//# sourceMappingURL=codeMod.js.map
|
package/build/ios/codeMod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeMod.js","names":["addObjcImports","source","imports","lines","split","lineIndexWithFirstImport","findIndex","line","match","importElement","includes","importStatement","splice","join","findObjcInterfaceCodeBlock","contents","declaration","start","search","RegExp","end","indexOf","code","substring","findObjcFunctionCodeBlock","selector","symbols","argsCount","length","pattern","i","argSymbol","findMatchingBracketPosition","insertContentsInsideObjcFunctionBlock","srcContents","insertion","options","insertContentsInsideFunctionBlock","insertContentsInsideObjcInterfaceBlock","codeBlock","position","firstNewLineIndex","insertContentsAtOffset","endLen","findSwiftFunctionCodeBlock","parenthesesIndex","funcName","argLabels","searchOffset","funcCandidateRegExp","funcCandidateOffset","searchFromOffset","paramsStartOffset","paramsEndOffset","paramsString","params","map","parseSwiftFunctionParam","argumentLabel","codeBlockStart","codeBlockEnd","paramTuple","semiIndex","parameterName","typeString","trim","insertContentsInsideSwiftClassBlock","Error","firstBracketIndex","endBracketIndex","insertContentsInsideSwiftFunctionBlock","language","indent","repeat","lastReturnIndex","lastIndexOf"],"sources":["../../src/ios/codeMod.ts"],"sourcesContent":["import { CodeBlock, insertContentsAtOffset, searchFromOffset } from '../utils/commonCodeMod';\nimport { findMatchingBracketPosition } from '../utils/matchBrackets';\n\ninterface SwiftFunctionParam {\n argumentLabel: string;\n parameterName: string;\n typeString: string;\n}\n\ninterface InsertContentFunctionOptions {\n position: 'head' | 'tail' | 'tailBeforeLastReturn';\n indent?: number;\n}\n\n/**\n * Add Objective-C import\n * @param source source contents\n * @param imports array of imports, e.g. ['<Foundation/Foundation.h>']\n * @returns updated contents\n */\nexport function addObjcImports(source: string, imports: string[]): string {\n const lines = source.split('\\n');\n // Try to insert statements after first #import where would probably not in #if block\n const lineIndexWithFirstImport = lines.findIndex((line) => line.match(/^#import .*$/));\n for (const importElement of imports) {\n if (!source.includes(importElement)) {\n const importStatement = `#import ${importElement}`;\n lines.splice(lineIndexWithFirstImport + 1, 0, importStatement);\n }\n }\n return lines.join('\\n');\n}\n\n/**\n * Find code block of Objective-C interface or implementation\n *\n * @param contents source contents\n * @param declaration interface/implementation, e.g. '@interface Foo'\n * @returns found CodeBlock, or null if not found\n */\nexport function findObjcInterfaceCodeBlock(\n contents: string,\n declaration: string\n): CodeBlock | null {\n const start = contents.search(new RegExp(`^${declaration}\\\\W`, 'm'));\n if (start < 0) {\n return null;\n }\n\n let end = contents.indexOf('\\n@end', start);\n end += 5; // '\\n@end'.length === 5\n\n return {\n start,\n end,\n code: contents.substring(start, end),\n };\n}\n\n/**\n * Find code block of Objective-C function without declaration, will return only {} block\n *\n * @param contents source contents\n * @param selector function selector, e.g. 'doSomething:withSomeValue:'\n * @returns found CodeBlock, or null if not found.\n */\nexport function findObjcFunctionCodeBlock(contents: string, selector: string): CodeBlock | null {\n const symbols = selector.split(':');\n const argsCount = symbols.length - 1;\n let pattern = '^[\\\\-+]\\\\s*\\\\(.+?\\\\)';\n if (argsCount === 0) {\n pattern += `${symbols[0]}\\\\s+`;\n } else {\n for (let i = 0; i < argsCount; ++i) {\n const argSymbol = `${symbols[i]}:\\\\(.+\\\\)\\\\w+`;\n pattern += `${argSymbol}\\\\s+`;\n }\n }\n pattern += '{';\n let start = contents.search(new RegExp(pattern, 'm'));\n if (start < 0) {\n return null;\n }\n start = contents.indexOf('{', start);\n\n const end = findMatchingBracketPosition(contents, '{', start);\n return {\n start,\n end,\n code: contents.substring(start, end + 1),\n };\n}\n\n/**\n * Insert contents to the Objective-C function block\n *\n * @param srcContents source contents\n * @param selector function selector, e.g. 'doSomething:withSomeValue:'\n * @param insertion code to insert\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideObjcFunctionBlock(\n srcContents: string,\n selector: string,\n insertion: string,\n options: InsertContentFunctionOptions\n): string {\n return insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, 'objc');\n}\n\n/**\n * Insert contents to the Objective-C interface/implementation block\n *\n * @param srcContents source contents\n * @param declaration interface/implementation, e.g. '@interface Foo'\n * @param insertion code to insert\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideObjcInterfaceBlock(\n srcContents: string,\n declaration: string,\n insertion: string,\n options: {\n position: 'head' | 'tail';\n }\n): string {\n const codeBlock = findObjcInterfaceCodeBlock(srcContents, declaration);\n if (!codeBlock) {\n return srcContents;\n }\n\n const { position } = options;\n if (position === 'head') {\n const firstNewLineIndex = srcContents.indexOf('\\n', codeBlock.start);\n srcContents = insertContentsAtOffset(srcContents, insertion, firstNewLineIndex);\n } else if (position === 'tail') {\n const endLen = '@end'.length;\n srcContents = insertContentsAtOffset(srcContents, insertion, codeBlock.end - endLen);\n }\n return srcContents;\n}\n\n/**\n * Find code block of Swift function without declaration, will return only {} block\n *\n * @param contents source contents\n * @param selector function selector, e.g. 'doSomething(_:withSomeValue:)'\n * @returns found CodeBlock, or null if not found.\n */\nexport function findSwiftFunctionCodeBlock(contents: string, selector: string): CodeBlock | null {\n const parenthesesIndex = selector.indexOf('(');\n // `functName` === 'doSomething' of 'doSomething(_:withSomeValue:)'\n const funcName = selector.substring(0, parenthesesIndex);\n // `argLabels` === ['_', 'withSomeValue'] 'doSomething(_:withSomeValue:)'\n const argLabels = selector.substring(parenthesesIndex + 1, selector.length - 2).split(':');\n\n let searchOffset = 0;\n const funcCandidateRegExp = new RegExp(`\\\\sfunc\\\\s+${funcName}\\\\(`, 'm');\n let funcCandidateOffset = searchFromOffset(contents, funcCandidateRegExp, searchOffset);\n while (funcCandidateOffset >= 0) {\n // Parse function parameters\n const paramsStartOffset = contents.indexOf('(', funcCandidateOffset);\n const paramsEndOffset = findMatchingBracketPosition(contents, '(', paramsStartOffset);\n const paramsString = contents.substring(paramsStartOffset + 1, paramsEndOffset);\n const params = paramsString.split(',').map(parseSwiftFunctionParam);\n\n // Prepare offset for next round\n searchOffset = paramsEndOffset + 1;\n funcCandidateOffset = searchFromOffset(contents, funcCandidateRegExp, searchOffset);\n\n // Try to match function parameters\n if (argLabels.length !== params.length) {\n continue;\n }\n for (let i = 0; i < argLabels.length; ++i) {\n if (argLabels[i] !== params[i].argumentLabel) {\n continue;\n }\n }\n\n // This function is matched one, get the code block.\n const codeBlockStart = contents.indexOf('{', paramsEndOffset);\n const codeBlockEnd = findMatchingBracketPosition(contents, '{', paramsEndOffset);\n const codeBlock = contents.substring(codeBlockStart, codeBlockEnd + 1);\n return {\n start: codeBlockStart,\n end: codeBlockEnd,\n code: codeBlock,\n };\n }\n\n return null;\n}\n\nfunction parseSwiftFunctionParam(paramTuple: string): SwiftFunctionParam {\n const semiIndex = paramTuple.indexOf(':');\n const [argumentLabel, parameterName] = paramTuple.substring(0, semiIndex).split(/\\s+/);\n const typeString = paramTuple.substring(semiIndex + 1).trim();\n return {\n argumentLabel,\n parameterName,\n typeString,\n };\n}\n\n/**\n * Insert contents to the swift class block\n *\n * @param srcContents source contents\n * @param declaration class/extension declaration, e.g. 'class AppDelegate'\n * @param insertion code to append\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideSwiftClassBlock(\n srcContents: string,\n declaration: string,\n insertion: string,\n options: {\n position: 'head' | 'tail';\n }\n): string {\n const start = srcContents.search(new RegExp(`\\\\s*${declaration}.*?[\\\\(\\\\{]`));\n if (start < 0) {\n throw new Error(`Unable to find class code block - declaration[${declaration}]`);\n }\n\n const { position } = options;\n if (position === 'head') {\n const firstBracketIndex = srcContents.indexOf('{', start);\n srcContents = insertContentsAtOffset(srcContents, insertion, firstBracketIndex + 1);\n } else if (position === 'tail') {\n const endBracketIndex = findMatchingBracketPosition(srcContents, '{', start);\n srcContents = insertContentsAtOffset(srcContents, insertion, endBracketIndex);\n }\n return srcContents;\n}\n\n/**\n * Insert contents to the Swift function block\n *\n * @param srcContents source contents\n * @param selector function selector, e.g. 'doSomething:withSomeValue:'\n * @param insertion code to insert\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideSwiftFunctionBlock(\n srcContents: string,\n selector: string,\n insertion: string,\n options: InsertContentFunctionOptions\n): string {\n return insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, 'swift');\n}\n\nfunction insertContentsInsideFunctionBlock(\n srcContents: string,\n selector: string,\n insertion: string,\n options: InsertContentFunctionOptions,\n language: 'objc' | 'swift'\n): string {\n const codeBlock =\n language === 'objc'\n ? findObjcFunctionCodeBlock(srcContents, selector)\n : findSwiftFunctionCodeBlock(srcContents, selector);\n if (!codeBlock) {\n return srcContents;\n }\n\n const { position } = options;\n const indent = ' '.repeat(options.indent ?? 2);\n\n if (position === 'head') {\n srcContents = insertContentsAtOffset(\n srcContents,\n `\\n${indent}${insertion}`,\n codeBlock.start + 1\n );\n } else if (position === 'tail') {\n srcContents = insertContentsAtOffset(srcContents, `\\n${indent}${insertion}`, codeBlock.end - 1);\n } else if (position === 'tailBeforeLastReturn') {\n let lastReturnIndex = srcContents.lastIndexOf(' return ', codeBlock.end);\n if (lastReturnIndex < 0) {\n throw new Error(`Cannot find last return statement:\\n${srcContents}`);\n }\n lastReturnIndex += 1; // +1 for the prefix space\n srcContents = insertContentsAtOffset(srcContents, `${insertion}\\n${indent}`, lastReturnIndex);\n }\n\n return srcContents;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAwBC,MAAxB,EAAwCC,OAAxC,EAAmE;EACxE,MAAMC,KAAK,GAAGF,MAAM,CAACG,KAAP,CAAa,IAAb,CAAd,CADwE,CAExE;;EACA,MAAMC,wBAAwB,GAAGF,KAAK,CAACG,SAAN,CAAiBC,IAAD,IAAUA,IAAI,CAACC,KAAL,CAAW,cAAX,CAA1B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N;IACD;;IACDwC,eAAe,IAAI,CAAnB,CAL8C,CAKxB;;IACtBxC,WAAW,GAAG,IAAAQ,uCAAA,EAAuBR,WAAvB,EAAqC,GAAEC,SAAU,KAAIqC,MAAO,EAA5D,EAA+DE,eAA/D,CAAd;EACD;;EAED,OAAOxC,WAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"codeMod.js","names":["addObjcImports","source","imports","lines","split","lineIndexWithFirstImport","findIndex","line","match","importElement","includes","importStatement","splice","join","findObjcInterfaceCodeBlock","contents","declaration","start","search","RegExp","end","indexOf","code","substring","findObjcFunctionCodeBlock","selector","symbols","argsCount","length","pattern","i","argSymbol","findMatchingBracketPosition","insertContentsInsideObjcFunctionBlock","srcContents","insertion","options","insertContentsInsideFunctionBlock","insertContentsInsideObjcInterfaceBlock","codeBlock","position","firstNewLineIndex","insertContentsAtOffset","endLen","findSwiftFunctionCodeBlock","parenthesesIndex","funcName","argLabels","searchOffset","funcCandidateRegExp","funcCandidateOffset","searchFromOffset","paramsStartOffset","paramsEndOffset","paramsString","params","map","parseSwiftFunctionParam","argumentLabel","codeBlockStart","codeBlockEnd","paramTuple","semiIndex","parameterName","typeString","trim","insertContentsInsideSwiftClassBlock","Error","firstBracketIndex","endBracketIndex","insertContentsInsideSwiftFunctionBlock","language","indent","repeat","lastReturnIndex","lastIndexOf"],"sources":["../../src/ios/codeMod.ts"],"sourcesContent":["import { CodeBlock, insertContentsAtOffset, searchFromOffset } from '../utils/commonCodeMod';\nimport { findMatchingBracketPosition } from '../utils/matchBrackets';\n\ninterface SwiftFunctionParam {\n argumentLabel: string;\n parameterName: string;\n typeString: string;\n}\n\ninterface InsertContentFunctionOptions {\n position: 'head' | 'tail' | 'tailBeforeLastReturn';\n indent?: number;\n}\n\n/**\n * Add Objective-C import\n * @param source source contents\n * @param imports array of imports, e.g. ['<Foundation/Foundation.h>']\n * @returns updated contents\n */\nexport function addObjcImports(source: string, imports: string[]): string {\n const lines = source.split('\\n');\n // Try to insert statements after first #import where would probably not in #if block\n const lineIndexWithFirstImport = lines.findIndex((line) => line.match(/^#import .*$/));\n for (const importElement of imports) {\n if (!source.includes(importElement)) {\n const importStatement = `#import ${importElement}`;\n lines.splice(lineIndexWithFirstImport + 1, 0, importStatement);\n }\n }\n return lines.join('\\n');\n}\n\n/**\n * Find code block of Objective-C interface or implementation\n *\n * @param contents source contents\n * @param declaration interface/implementation, e.g. '@interface Foo'\n * @returns found CodeBlock, or null if not found\n */\nexport function findObjcInterfaceCodeBlock(\n contents: string,\n declaration: string\n): CodeBlock | null {\n const start = contents.search(new RegExp(`^${declaration}\\\\W`, 'm'));\n if (start < 0) {\n return null;\n }\n\n let end = contents.indexOf('\\n@end', start);\n end += 5; // '\\n@end'.length === 5\n\n return {\n start,\n end,\n code: contents.substring(start, end),\n };\n}\n\n/**\n * Find code block of Objective-C function without declaration, will return only {} block\n *\n * @param contents source contents\n * @param selector function selector, e.g. 'doSomething:withSomeValue:'\n * @returns found CodeBlock, or null if not found.\n */\nexport function findObjcFunctionCodeBlock(contents: string, selector: string): CodeBlock | null {\n const symbols = selector.split(':');\n const argsCount = symbols.length - 1;\n let pattern = '^[\\\\-+]\\\\s*\\\\(.+?\\\\)';\n if (argsCount === 0) {\n pattern += `${symbols[0]}\\\\s+`;\n } else {\n for (let i = 0; i < argsCount; ++i) {\n const argSymbol = `${symbols[i]}:\\\\(.+\\\\)\\\\w+`;\n pattern += `${argSymbol}\\\\s+`;\n }\n }\n pattern += '{';\n let start = contents.search(new RegExp(pattern, 'm'));\n if (start < 0) {\n return null;\n }\n start = contents.indexOf('{', start);\n\n const end = findMatchingBracketPosition(contents, '{', start);\n return {\n start,\n end,\n code: contents.substring(start, end + 1),\n };\n}\n\n/**\n * Insert contents to the Objective-C function block\n *\n * @param srcContents source contents\n * @param selector function selector, e.g. 'doSomething:withSomeValue:'\n * @param insertion code to insert\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideObjcFunctionBlock(\n srcContents: string,\n selector: string,\n insertion: string,\n options: InsertContentFunctionOptions\n): string {\n return insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, 'objc');\n}\n\n/**\n * Insert contents to the Objective-C interface/implementation block\n *\n * @param srcContents source contents\n * @param declaration interface/implementation, e.g. '@interface Foo'\n * @param insertion code to insert\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideObjcInterfaceBlock(\n srcContents: string,\n declaration: string,\n insertion: string,\n options: {\n position: 'head' | 'tail';\n }\n): string {\n const codeBlock = findObjcInterfaceCodeBlock(srcContents, declaration);\n if (!codeBlock) {\n return srcContents;\n }\n\n const { position } = options;\n if (position === 'head') {\n const firstNewLineIndex = srcContents.indexOf('\\n', codeBlock.start);\n srcContents = insertContentsAtOffset(srcContents, insertion, firstNewLineIndex);\n } else if (position === 'tail') {\n const endLen = '@end'.length;\n srcContents = insertContentsAtOffset(srcContents, insertion, codeBlock.end - endLen);\n }\n return srcContents;\n}\n\n/**\n * Find code block of Swift function without declaration, will return only {} block\n *\n * @param contents source contents\n * @param selector function selector, e.g. 'doSomething(_:withSomeValue:)'\n * @returns found CodeBlock, or null if not found.\n */\nexport function findSwiftFunctionCodeBlock(contents: string, selector: string): CodeBlock | null {\n const parenthesesIndex = selector.indexOf('(');\n // `functName` === 'doSomething' of 'doSomething(_:withSomeValue:)'\n const funcName = selector.substring(0, parenthesesIndex);\n // `argLabels` === ['_', 'withSomeValue'] 'doSomething(_:withSomeValue:)'\n const argLabels = selector.substring(parenthesesIndex + 1, selector.length - 2).split(':');\n\n let searchOffset = 0;\n const funcCandidateRegExp = new RegExp(`\\\\sfunc\\\\s+${funcName}\\\\(`, 'm');\n let funcCandidateOffset = searchFromOffset(contents, funcCandidateRegExp, searchOffset);\n while (funcCandidateOffset >= 0) {\n // Parse function parameters\n const paramsStartOffset = contents.indexOf('(', funcCandidateOffset);\n const paramsEndOffset = findMatchingBracketPosition(contents, '(', paramsStartOffset);\n const paramsString = contents.substring(paramsStartOffset + 1, paramsEndOffset);\n const params = paramsString.split(',').map(parseSwiftFunctionParam);\n\n // Prepare offset for next round\n searchOffset = paramsEndOffset + 1;\n funcCandidateOffset = searchFromOffset(contents, funcCandidateRegExp, searchOffset);\n\n // Try to match function parameters\n if (argLabels.length !== params.length) {\n continue;\n }\n for (let i = 0; i < argLabels.length; ++i) {\n if (argLabels[i] !== params[i].argumentLabel) {\n continue;\n }\n }\n\n // This function is matched one, get the code block.\n const codeBlockStart = contents.indexOf('{', paramsEndOffset);\n const codeBlockEnd = findMatchingBracketPosition(contents, '{', paramsEndOffset);\n const codeBlock = contents.substring(codeBlockStart, codeBlockEnd + 1);\n return {\n start: codeBlockStart,\n end: codeBlockEnd,\n code: codeBlock,\n };\n }\n\n return null;\n}\n\nfunction parseSwiftFunctionParam(paramTuple: string): SwiftFunctionParam {\n const semiIndex = paramTuple.indexOf(':');\n const [argumentLabel, parameterName] = paramTuple.substring(0, semiIndex).split(/\\s+/);\n const typeString = paramTuple.substring(semiIndex + 1).trim();\n return {\n argumentLabel,\n parameterName,\n typeString,\n };\n}\n\n/**\n * Insert contents to the swift class block\n *\n * @param srcContents source contents\n * @param declaration class/extension declaration, e.g. 'class AppDelegate'\n * @param insertion code to append\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideSwiftClassBlock(\n srcContents: string,\n declaration: string,\n insertion: string,\n options: {\n position: 'head' | 'tail';\n }\n): string {\n const start = srcContents.search(new RegExp(`\\\\s*${declaration}.*?[\\\\(\\\\{]`));\n if (start < 0) {\n throw new Error(`Unable to find class code block - declaration[${declaration}]`);\n }\n\n const { position } = options;\n if (position === 'head') {\n const firstBracketIndex = srcContents.indexOf('{', start);\n srcContents = insertContentsAtOffset(srcContents, insertion, firstBracketIndex + 1);\n } else if (position === 'tail') {\n const endBracketIndex = findMatchingBracketPosition(srcContents, '{', start);\n srcContents = insertContentsAtOffset(srcContents, insertion, endBracketIndex);\n }\n return srcContents;\n}\n\n/**\n * Insert contents to the Swift function block\n *\n * @param srcContents source contents\n * @param selector function selector, e.g. 'doSomething:withSomeValue:'\n * @param insertion code to insert\n * @param options insertion options\n * @returns updated contents\n */\nexport function insertContentsInsideSwiftFunctionBlock(\n srcContents: string,\n selector: string,\n insertion: string,\n options: InsertContentFunctionOptions\n): string {\n return insertContentsInsideFunctionBlock(srcContents, selector, insertion, options, 'swift');\n}\n\nfunction insertContentsInsideFunctionBlock(\n srcContents: string,\n selector: string,\n insertion: string,\n options: InsertContentFunctionOptions,\n language: 'objc' | 'swift'\n): string {\n const codeBlock =\n language === 'objc'\n ? findObjcFunctionCodeBlock(srcContents, selector)\n : findSwiftFunctionCodeBlock(srcContents, selector);\n if (!codeBlock) {\n return srcContents;\n }\n\n const { position } = options;\n const indent = ' '.repeat(options.indent ?? 2);\n\n if (position === 'head') {\n srcContents = insertContentsAtOffset(\n srcContents,\n `\\n${indent}${insertion}`,\n codeBlock.start + 1\n );\n } else if (position === 'tail') {\n srcContents = insertContentsAtOffset(srcContents, `\\n${indent}${insertion}`, codeBlock.end - 1);\n } else if (position === 'tailBeforeLastReturn') {\n let lastReturnIndex = srcContents.lastIndexOf(' return ', codeBlock.end);\n if (lastReturnIndex < 0) {\n throw new Error(`Cannot find last return statement:\\n${srcContents}`);\n }\n lastReturnIndex += 1; // +1 for the prefix space\n srcContents = insertContentsAtOffset(srcContents, `${insertion}\\n${indent}`, lastReturnIndex);\n }\n\n return srcContents;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAaA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAc,CAACC,MAAc,EAAEC,OAAiB,EAAU;EACxE,MAAMC,KAAK,GAAGF,MAAM,CAACG,KAAK,CAAC,IAAI,CAAC;EAChC;EACA,MAAMC,wBAAwB,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKA,IAAI,CAACC,KAAK,CAAC,cAAc,CAAC,CAAC;EACtF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