agora-appbuilder-core 4.1.31 → 4.1.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "4.1.31",
3
+ "version": "4.1.32",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "deps": "cd template && npm i --force",
14
14
  "dev-setup": "npm run uikit && npm run deps && node devSetup.js",
15
15
  "web-build": "cd template && npm run web:build && cd .. && npm run copy-vercel",
16
- "copy-vercel": "cp -r Builds/web template/dist && cp vercel.json template/dist",
16
+ "copy-vercel": "cp -r Builds/web template/dist && cp vercel.json template/dist && node scripts/publish-assetlinks.js",
17
17
  "pre-release": "cd template && cp _package-lock.json package-lock.json"
18
18
  },
19
19
  "author": {
@@ -1,3 +1,14 @@
1
+ import com.android.build.api.artifact.SingleArtifact
2
+ import groovy.json.JsonSlurper
3
+ import org.w3c.dom.Element
4
+
5
+ import javax.xml.parsers.DocumentBuilderFactory
6
+ import javax.xml.transform.TransformerFactory
7
+ import javax.xml.transform.dom.DOMSource
8
+ import javax.xml.transform.stream.StreamResult
9
+ import java.nio.file.Files
10
+ import java.nio.file.StandardCopyOption
11
+
1
12
  apply plugin: "com.android.application"
2
13
  apply plugin: "com.facebook.react"
3
14
 
@@ -146,3 +157,105 @@ dependencies {
146
157
  implementation jscFlavor
147
158
  }
148
159
  }
160
+
161
+ abstract class ConfigureAppLinks extends DefaultTask {
162
+ private static final String ANDROID = 'http://schemas.android.com/apk/res/android'
163
+ private static final String VIEW = 'android.intent.action.VIEW'
164
+ private static final String DEFAULT = 'android.intent.category.DEFAULT'
165
+ private static final String BROWSABLE = 'android.intent.category.BROWSABLE'
166
+
167
+ @Optional @InputFile @PathSensitive(PathSensitivity.NONE)
168
+ abstract RegularFileProperty getAppConfig()
169
+
170
+ @InputFile @PathSensitive(PathSensitivity.NONE)
171
+ abstract RegularFileProperty getInputManifest()
172
+
173
+ @OutputFile
174
+ abstract RegularFileProperty getOutputManifest()
175
+
176
+ @TaskAction
177
+ void configureAppLinks() {
178
+ def endpoint = appConfig.present
179
+ ? new JsonSlurper().parse(appConfig.get().asFile).FRONTEND_ENDPOINT
180
+ : null
181
+ def host = endpoint instanceof String && endpoint.startsWith('https://')
182
+ ? new URI(endpoint).host?.toLowerCase(Locale.ROOT)
183
+ : null
184
+ def input = inputManifest.get().asFile
185
+ def output = outputManifest.get().asFile
186
+ output.parentFile.mkdirs()
187
+ if (!host) {
188
+ Files.copy(input.toPath(), output.toPath(), StandardCopyOption.REPLACE_EXISTING)
189
+ return
190
+ }
191
+
192
+ def factory = DocumentBuilderFactory.newDefaultInstance()
193
+ factory.namespaceAware = true
194
+ def document = factory.newDocumentBuilder().parse(input)
195
+ def activity = elements(document.documentElement, 'activity').find {
196
+ it.getAttributeNS(ANDROID, 'name').endsWith('.MainActivity')
197
+ }
198
+ def webFilters = activity == null ? [] : elements(activity, 'intent-filter').findAll { filter ->
199
+ VIEW in values(filter, 'action', 'name') &&
200
+ BROWSABLE in values(filter, 'category', 'name') &&
201
+ values(filter, 'data', 'scheme').any { it in ['http', 'https'] }
202
+ }
203
+ def filters = webFilters.findAll { filter ->
204
+ def schemes = values(filter, 'data', 'scheme')
205
+ values(filter, 'data', 'host').toSet() == ([host] as Set) &&
206
+ schemes.contains('https') && schemes.every { it in ['http', 'https'] } &&
207
+ DEFAULT in values(filter, 'category', 'name')
208
+ }
209
+ if (activity != null && webFilters.isEmpty()) {
210
+ // Direct Core builds start with only the launcher filter.
211
+ def filter = document.createElement('intent-filter')
212
+ activity.appendChild(filter)
213
+ addFilterElement(filter, 'action', 'name', VIEW)
214
+ addFilterElement(filter, 'category', 'name', DEFAULT)
215
+ addFilterElement(filter, 'category', 'name', BROWSABLE)
216
+ def data = addFilterElement(filter, 'data', 'scheme', 'https')
217
+ data.setAttributeNS(ANDROID, 'android:host', host)
218
+ filters = [filter]
219
+ }
220
+ if (filters.isEmpty()) {
221
+ Files.copy(input.toPath(), output.toPath(), StandardCopyOption.REPLACE_EXISTING)
222
+ return
223
+ }
224
+
225
+ filters.each { filter ->
226
+ filter.setAttributeNS(ANDROID, 'android:autoVerify', 'true')
227
+ }
228
+ TransformerFactory.newDefaultInstance().newTransformer()
229
+ .transform(new DOMSource(document), new StreamResult(output))
230
+ }
231
+
232
+ static List<String> values(Element parent, String tag, String attribute) {
233
+ elements(parent, tag).collect { it.getAttributeNS(ANDROID, attribute) }.findAll()
234
+ }
235
+
236
+ static List<Element> elements(Element parent, String tag) {
237
+ def nodes = parent.getElementsByTagName(tag)
238
+ (0..<nodes.length).collect { (Element) nodes.item(it) }
239
+ }
240
+
241
+ static Element addFilterElement(Element parent, String tag, String attribute, String value) {
242
+ def element = parent.ownerDocument.createElement(tag)
243
+ element.setAttributeNS(ANDROID, "android:${attribute}", value)
244
+ parent.appendChild(element)
245
+ element
246
+ }
247
+ }
248
+
249
+ def appBuilderConfig = rootProject.layout.projectDirectory.file('../config.json')
250
+
251
+ // Work with the merged manifest so existing CLI-generated projects get the fix.
252
+ androidComponents.onVariants(androidComponents.selector().all(), { variant ->
253
+ def configureAppLinks = tasks.register("configure${variant.name.capitalize()}AppLinks", ConfigureAppLinks) {
254
+ if (appBuilderConfig.asFile.isFile()) {
255
+ appConfig.set(appBuilderConfig)
256
+ }
257
+ }
258
+ variant.artifacts.use(configureAppLinks)
259
+ .wiredWithFiles({ it.inputManifest }, { it.outputManifest })
260
+ .toTransform(SingleArtifact.MERGED_MANIFEST.INSTANCE)
261
+ } as Action)
@@ -77,8 +77,8 @@ const DefaultConfig = {
77
77
  CHAT_ORG_NAME: "",
78
78
  CHAT_APP_NAME: "",
79
79
  CHAT_URL: "",
80
- CLI_VERSION: "3.1.31",
81
- CORE_VERSION: "4.1.31",
80
+ CLI_VERSION: "3.1.32",
81
+ CORE_VERSION: "4.1.32",
82
82
  DISABLE_LANDSCAPE_MODE: false,
83
83
  STT_AUTO_START: false,
84
84
  CLOUD_RECORDING_AUTO_START: false,