agora-appbuilder-core 2.3.0-beta.6 → 2.3.0-beta.9

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": "2.3.0-beta.6",
3
+ "version": "2.3.0-beta.9",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -24,14 +24,33 @@ const WebpackDevServer = require('webpack-dev-server');
24
24
  const webpackConfig = require('./webpack.renderer.config');
25
25
  const webpackRsdkConfig = require('./webpack.rsdk.config');
26
26
 
27
- const BUILD_PATH =
28
- process.env.TARGET === 'wsdk'
27
+ const outPathArg = process.argv.indexOf('--outpath')
28
+ getBuildPath = () => {
29
+ if (outPathArg == -1) {
30
+ return process.env.TARGET === 'wsdk'
29
31
  ? path.join(__dirname, '../Builds/web-sdk')
30
32
  : process.env.TARGET === 'rsdk'
31
33
  ? path.join(__dirname, '../Builds/react-sdk')
32
34
  : process.env.TARGET === 'android'
33
35
  ? path.join(__dirname, '../Builds/android')
34
36
  : path.join(__dirname, '../Builds/.electron');
37
+ } else {
38
+ return process.argv[outPathArg+1].split('/').slice(0, -1).join('/')
39
+ }
40
+ }
41
+ const BUILD_PATH = getBuildPath();
42
+ const TS_DEFS_BUILD_PATH = process.env.TARGET === 'wsdk'
43
+ ? path.join(__dirname, '../Builds/ts-defs/web-sdk')
44
+ : process.env.TARGET === 'rsdk'
45
+ ? path.join(__dirname, '../Builds/ts-defs/react-sdk')
46
+ : process.env.TARGET === 'android'
47
+ ? path.join(__dirname, '../Builds/ts-defs/android')
48
+ : path.join(__dirname, '../Builds/ts-defs/.electron');
49
+
50
+ const pkgNameArg = process.argv.indexOf('--pkgname')
51
+ const PACKAGE_NAME = pkgNameArg == -1
52
+ ? 'agora-app-builder-sdk'
53
+ : process.argv[pkgNameArg+1]
35
54
 
36
55
  let PRODUCT_NAME;
37
56
 
@@ -73,7 +92,7 @@ const general = {
73
92
  });
74
93
 
75
94
  let newPackage = {
76
- name: 'agora-app-builder-sdk',
95
+ name: PACKAGE_NAME,
77
96
  version,
78
97
  private,
79
98
  author,
@@ -129,6 +148,15 @@ const general = {
129
148
  typescriptClean: () => {
130
149
  return del([`${path.join(BUILD_PATH, '../', '/')}*.d.ts`], {force: true});
131
150
  },
151
+ genTsDefs: (cb) => {
152
+ runCli(`mkdir -p ${TS_DEFS_BUILD_PATH} && cp ${BUILD_PATH}/index.d.ts ${TS_DEFS_BUILD_PATH}/index.d.ts`, cb);
153
+ },
154
+ useTsDefs: (cb) => {
155
+ runCli(`cp ${TS_DEFS_BUILD_PATH}/index.d.ts ${BUILD_PATH}/index.d.ts`, cb)
156
+ },
157
+ npmPack: (cb) => {
158
+ runCli(`cd ${BUILD_PATH} && npm pack`, cb)
159
+ }
132
160
  };
133
161
 
134
162
  const electron = {
@@ -167,7 +195,18 @@ const reactSdk = {
167
195
  runCli('webpack --config ./webpack.rsdk.config.js', cb);
168
196
  },
169
197
  esbuild: (cb) => {
170
- runCli('go build -o ../esbuild-bin/rsdk ./esbuild.rsdk.go && ../esbuild-bin/rsdk', cb);
198
+ let outPath = '';
199
+ if (outPathArg != -1) {
200
+ outPath = ` --outpath ${process.argv[outPathArg+1]}`
201
+ }
202
+ let configTransformerPath = '';
203
+ const configTransformerPathArg = process.argv.indexOf('--configtransformerpath')
204
+ if (configTransformerPathArg != -1) {
205
+ configTransformerPath = ` --configtransformerpath ${process.argv[configTransformerPathArg+1]}`
206
+ }
207
+ let esbuildCmd = `go build -o ../esbuild-bin/rsdk ./esbuild.rsdk.go && ../esbuild-bin/rsdk${outPath}${configTransformerPath}`
208
+ console.log(esbuildCmd)
209
+ runCli(esbuildCmd, cb);
171
210
  },
172
211
  typescript: (cb) => {
173
212
  runCli(
@@ -189,9 +228,6 @@ const reactSdk = {
189
228
  .pipe(replace('"fpe-api"', '"fpe-api/index"'))
190
229
  .pipe(header('// @ts-nocheck\n'))
191
230
  .pipe(dest(BUILD_PATH));
192
- },
193
- npmPack: (cb) => {
194
- runCli('cd ../Builds/react-sdk && npm pack',cb)
195
231
  }
196
232
  };
197
233
 
@@ -284,7 +320,7 @@ module.exports.reactSdk = series(
284
320
  reactSdk.typescript,
285
321
  reactSdk.typescriptFix,
286
322
  general.typescriptClean,
287
- reactSdk.npmPack,
323
+ general.npmPack,
288
324
  );
289
325
 
290
326
  // react-sdk-esbuild
@@ -298,7 +334,31 @@ module.exports.reactSdkEsbuild = series (
298
334
  reactSdk.typescript,
299
335
  reactSdk.typescriptFix,
300
336
  general.typescriptClean,
301
- reactSdk.npmPack,
337
+ general.npmPack,
338
+ )
339
+
340
+ // generate typescript definitions
341
+ module.exports.makeRsdkTsDefs = series (
342
+ general.clean,
343
+ general.createBuildDirectory,
344
+ general.packageJson,
345
+ reactSdk.esbuild,
346
+ general.typescript,
347
+ general.typescriptFix,
348
+ reactSdk.typescript,
349
+ reactSdk.typescriptFix,
350
+ general.typescriptClean,
351
+ general.genTsDefs,
352
+ )
353
+
354
+ // react-sdk-esbuild with cached type definitions
355
+ module.exports.reactSdkEsbuildCachedTsc = series (
356
+ general.clean,
357
+ general.createBuildDirectory,
358
+ general.packageJson,
359
+ reactSdk.esbuild,
360
+ general.useTsDefs,
361
+ general.npmPack,
302
362
  )
303
363
 
304
364
  // web-sdk
@@ -316,7 +376,35 @@ module.exports.webSdk = series(
316
376
  general.typescriptClean,
317
377
  ),
318
378
  ),
319
- webSdk.npmPack,
379
+ general.npmPack,
380
+ );
381
+
382
+ module.exports.makeWsdkTsDefs = series(
383
+ general.clean,
384
+ general.createBuildDirectory,
385
+ general.packageJson,
386
+ parallel(
387
+ webSdk.webpack,
388
+ series(
389
+ general.typescript,
390
+ general.typescriptFix,
391
+ webSdk.typescript,
392
+ webSdk.typescriptFix,
393
+ general.typescriptClean,
394
+ ),
395
+ ),
396
+ general.genTsDefs,
397
+ );
398
+
399
+ module.exports.webSdkCachedTsc = series(
400
+ general.clean,
401
+ general.createBuildDirectory,
402
+ general.packageJson,
403
+ parallel(
404
+ webSdk.webpack,
405
+ general.useTsDefs,
406
+ ),
407
+ general.npmPack,
320
408
  );
321
409
 
322
410
  module.exports.androidUnix = series(
@@ -334,7 +422,7 @@ module.exports.androidWin = series(
334
422
  );
335
423
 
336
424
  module.exports.test = series(
337
- reactSdk.npmPack,
425
+ general.npmPack,
338
426
  // general.typescript,
339
427
  // general.typescriptFix,
340
428
  // reactSdk.typescript,
@@ -6631,9 +6631,9 @@
6631
6631
  }
6632
6632
  },
6633
6633
  "node_modules/acorn": {
6634
- "version": "7.4.1",
6635
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
6636
- "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
6634
+ "version": "8.8.0",
6635
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
6636
+ "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
6637
6637
  "dev": true,
6638
6638
  "bin": {
6639
6639
  "acorn": "bin/acorn"
@@ -12231,6 +12231,18 @@
12231
12231
  "node": ">=6.0.0"
12232
12232
  }
12233
12233
  },
12234
+ "node_modules/espree/node_modules/acorn": {
12235
+ "version": "7.4.1",
12236
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
12237
+ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
12238
+ "dev": true,
12239
+ "bin": {
12240
+ "acorn": "bin/acorn"
12241
+ },
12242
+ "engines": {
12243
+ "node": ">=0.4.0"
12244
+ }
12245
+ },
12234
12246
  "node_modules/esprima": {
12235
12247
  "version": "4.0.1",
12236
12248
  "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
@@ -20243,6 +20255,18 @@
20243
20255
  }
20244
20256
  }
20245
20257
  },
20258
+ "node_modules/jsdom/node_modules/acorn": {
20259
+ "version": "7.4.1",
20260
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
20261
+ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
20262
+ "dev": true,
20263
+ "bin": {
20264
+ "acorn": "bin/acorn"
20265
+ },
20266
+ "engines": {
20267
+ "node": ">=0.4.0"
20268
+ }
20269
+ },
20246
20270
  "node_modules/jsdom/node_modules/tough-cookie": {
20247
20271
  "version": "3.0.1",
20248
20272
  "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz",
@@ -26213,6 +26237,14 @@
26213
26237
  "node": ">=6"
26214
26238
  }
26215
26239
  },
26240
+ "node_modules/stacktrace-parser/node_modules/type-fest": {
26241
+ "version": "0.7.1",
26242
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.7.1.tgz",
26243
+ "integrity": "sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==",
26244
+ "engines": {
26245
+ "node": ">=8"
26246
+ }
26247
+ },
26216
26248
  "node_modules/stat-mode": {
26217
26249
  "version": "1.0.0",
26218
26250
  "resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-1.0.0.tgz",
@@ -26770,18 +26802,6 @@
26770
26802
  }
26771
26803
  }
26772
26804
  },
26773
- "node_modules/terser-webpack-plugin/node_modules/acorn": {
26774
- "version": "8.8.0",
26775
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
26776
- "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
26777
- "dev": true,
26778
- "bin": {
26779
- "acorn": "bin/acorn"
26780
- },
26781
- "engines": {
26782
- "node": ">=0.4.0"
26783
- }
26784
- },
26785
26805
  "node_modules/terser-webpack-plugin/node_modules/has-flag": {
26786
26806
  "version": "4.0.0",
26787
26807
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -27325,11 +27345,17 @@
27325
27345
  }
27326
27346
  },
27327
27347
  "node_modules/type-fest": {
27328
- "version": "0.7.1",
27329
- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.7.1.tgz",
27330
- "integrity": "sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==",
27348
+ "version": "2.18.0",
27349
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.18.0.tgz",
27350
+ "integrity": "sha512-pRS+/yrW5TjPPHNOvxhbNZexr2bS63WjrMU8a+VzEBhUi9Tz1pZeD+vQz3ut0svZ46P+SRqMEPnJmk2XnvNzTw==",
27351
+ "dev": true,
27352
+ "optional": true,
27353
+ "peer": true,
27331
27354
  "engines": {
27332
- "node": ">=8"
27355
+ "node": ">=12.20"
27356
+ },
27357
+ "funding": {
27358
+ "url": "https://github.com/sponsors/sindresorhus"
27333
27359
  }
27334
27360
  },
27335
27361
  "node_modules/type-is": {
@@ -28750,18 +28776,6 @@
28750
28776
  "node": ">=10.13.0"
28751
28777
  }
28752
28778
  },
28753
- "node_modules/webpack/node_modules/acorn": {
28754
- "version": "8.8.0",
28755
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
28756
- "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
28757
- "dev": true,
28758
- "bin": {
28759
- "acorn": "bin/acorn"
28760
- },
28761
- "engines": {
28762
- "node": ">=0.4.0"
28763
- }
28764
- },
28765
28779
  "node_modules/webpack/node_modules/enhanced-resolve": {
28766
28780
  "version": "5.10.0",
28767
28781
  "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
@@ -34323,9 +34337,9 @@
34323
34337
  }
34324
34338
  },
34325
34339
  "acorn": {
34326
- "version": "7.4.1",
34327
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
34328
- "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
34340
+ "version": "8.8.0",
34341
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
34342
+ "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
34329
34343
  "dev": true
34330
34344
  },
34331
34345
  "acorn-globals": {
@@ -38670,6 +38684,14 @@
38670
38684
  "acorn": "^7.1.1",
38671
38685
  "acorn-jsx": "^5.2.0",
38672
38686
  "eslint-visitor-keys": "^1.1.0"
38687
+ },
38688
+ "dependencies": {
38689
+ "acorn": {
38690
+ "version": "7.4.1",
38691
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
38692
+ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
38693
+ "dev": true
38694
+ }
38673
38695
  }
38674
38696
  },
38675
38697
  "esprima": {
@@ -44861,6 +44883,12 @@
44861
44883
  "xml-name-validator": "^3.0.0"
44862
44884
  },
44863
44885
  "dependencies": {
44886
+ "acorn": {
44887
+ "version": "7.4.1",
44888
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
44889
+ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
44890
+ "dev": true
44891
+ },
44864
44892
  "tough-cookie": {
44865
44893
  "version": "3.0.1",
44866
44894
  "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz",
@@ -49666,6 +49694,13 @@
49666
49694
  "integrity": "sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==",
49667
49695
  "requires": {
49668
49696
  "type-fest": "^0.7.1"
49697
+ },
49698
+ "dependencies": {
49699
+ "type-fest": {
49700
+ "version": "0.7.1",
49701
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.7.1.tgz",
49702
+ "integrity": "sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg=="
49703
+ }
49669
49704
  }
49670
49705
  },
49671
49706
  "stat-mode": {
@@ -50094,12 +50129,6 @@
50094
50129
  "terser": "^5.7.2"
50095
50130
  },
50096
50131
  "dependencies": {
50097
- "acorn": {
50098
- "version": "8.8.0",
50099
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
50100
- "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
50101
- "dev": true
50102
- },
50103
50132
  "has-flag": {
50104
50133
  "version": "4.0.0",
50105
50134
  "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
@@ -50515,9 +50544,12 @@
50515
50544
  "dev": true
50516
50545
  },
50517
50546
  "type-fest": {
50518
- "version": "0.7.1",
50519
- "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.7.1.tgz",
50520
- "integrity": "sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg=="
50547
+ "version": "2.18.0",
50548
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.18.0.tgz",
50549
+ "integrity": "sha512-pRS+/yrW5TjPPHNOvxhbNZexr2bS63WjrMU8a+VzEBhUi9Tz1pZeD+vQz3ut0svZ46P+SRqMEPnJmk2XnvNzTw==",
50550
+ "dev": true,
50551
+ "optional": true,
50552
+ "peer": true
50521
50553
  },
50522
50554
  "type-is": {
50523
50555
  "version": "1.6.18",
@@ -51167,12 +51199,6 @@
51167
51199
  "webpack-sources": "^3.2.3"
51168
51200
  },
51169
51201
  "dependencies": {
51170
- "acorn": {
51171
- "version": "8.8.0",
51172
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
51173
- "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
51174
- "dev": true
51175
- },
51176
51202
  "enhanced-resolve": {
51177
51203
  "version": "5.10.0",
51178
51204
  "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
@@ -1,6 +1,7 @@
1
1
  package main
2
2
 
3
3
  import (
4
+ "flag"
4
5
  "log"
5
6
  "os"
6
7
  "path/filepath"
@@ -9,6 +10,11 @@ import (
9
10
  "github.com/evanw/esbuild/pkg/api"
10
11
  )
11
12
 
13
+ type ioPaths struct {
14
+ outPath string
15
+ configTransformerPath string
16
+ }
17
+
12
18
  func commonAliasResolver() api.Plugin {
13
19
  aliasResolvers := api.Plugin{
14
20
  Name: "importAliases",
@@ -152,7 +158,7 @@ func commonLoader() map[string]api.Loader {
152
158
  return loader
153
159
  }
154
160
 
155
- func common() api.BuildOptions {
161
+ func common(iopath *ioPaths) api.BuildOptions {
156
162
  commonBuildOpts := api.BuildOptions{
157
163
  // we can safely ignore (webpack) plugins for now because they seem to be used only for not reactsdk
158
164
 
@@ -164,14 +170,14 @@ func common() api.BuildOptions {
164
170
  Define: map[string]string{
165
171
  "$config": "config",
166
172
  },
167
- Inject: []string{"./esbuildConfigTransform.js"},
173
+ Inject: []string{iopath.configTransformerPath},
168
174
  }
169
175
 
170
176
  return commonBuildOpts
171
177
  }
172
178
 
173
- func rsdk() api.BuildResult {
174
- commonBuildOpts := common()
179
+ func rsdk(iopath *ioPaths) api.BuildResult {
180
+ commonBuildOpts := common(iopath)
175
181
  rsdkBuildOpts := api.BuildOptions{
176
182
  // build options common to rsdk and other components
177
183
  Plugins: commonBuildOpts.Plugins,
@@ -197,7 +203,7 @@ func rsdk() api.BuildResult {
197
203
  // bundle in cjs format because this index.js is meant to be used by other host applications
198
204
  // like webpack which runs on node
199
205
  Format: api.FormatCommonJS,
200
- Outfile: "../Builds/react-sdk/index.js",
206
+ Outfile: iopath.outPath,
201
207
 
202
208
  // other esbuild options
203
209
  Write: true,
@@ -215,7 +221,15 @@ func rsdk() api.BuildResult {
215
221
  }
216
222
 
217
223
  func main() {
218
- rsdkRes := rsdk()
224
+ outPath := flag.String("outpath", "../Builds/react-sdk/index.js", "path to write bundled js file")
225
+ configTransformerPath := flag.String("configtransformerpath", "./esbuildConfigTransform.js", "path to inject file")
226
+ flag.Parse()
227
+ iopath := &ioPaths{
228
+ outPath: *outPath,
229
+ configTransformerPath: *configTransformerPath,
230
+ }
231
+ log.Println("esbuild args = ", iopath)
232
+ rsdkRes := rsdk(iopath)
219
233
  if len(rsdkRes.Errors) > 0 {
220
234
  spew.Dump(rsdkRes)
221
235
  log.Fatalln("build failed")
@@ -18,6 +18,7 @@ export {
18
18
  ParticipantsView,
19
19
  Controls,
20
20
  ControlsComponentsArray,
21
+ ChatBubble,
21
22
  } from '../src/pages/video-call/index';
22
23
  export {default as GridLayout} from '../src/components/GridVideo';
23
24
  export {default as PinnedLayout} from '../src/components/PinnedVideo';
@@ -45,10 +45,13 @@ export interface PreCallInterface extends BeforeAndAfterInterface {
45
45
  joinButton?: React.ComponentType;
46
46
  textBox?: React.ComponentType;
47
47
  }
48
- export interface ChatCmpInterface extends BeforeAndAfterInterface {
48
+ export interface ChatCmpInterface {
49
+ //commented for v1 release
50
+ //extends BeforeAndAfterInterface
49
51
  chatBubble?: React.ComponentType<ChatBubbleProps>;
50
- chatInput?: React.ComponentType<ChatTextInputProps>;
51
- chatSentButton?: React.ComponentType<ChatSendButtonProps>;
52
+ //commented for v1 release
53
+ //chatInput?: React.ComponentType<ChatTextInputProps>;
54
+ //chatSentButton?: React.ComponentType<ChatSendButtonProps>;
52
55
  }
53
56
 
54
57
  export interface renderComponentInterface {
@@ -85,8 +88,7 @@ export interface VideoCallInterface extends BeforeAndAfterInterface {
85
88
  //settingsPanel?: React.ComponentType;
86
89
  participantsPanel?: React.ComponentType;
87
90
  bottomBar?: React.ComponentType;
88
- // commented for v1 release
89
- //chat?: ChatCmpInterface;
91
+ chat?: ChatCmpInterface;
90
92
  customContent?: renderComponentObjectInterface;
91
93
  customLayout?: (layouts: layoutObjectType[]) => layoutObjectType[];
92
94
  }
@@ -22,8 +22,7 @@ export {default as useIsAudioEnabled} from '../src/utils/isAudioEnabled';
22
22
  export {default as useIsVideoEnabled} from '../src/utils/isVideoEnabled';
23
23
  export {default as useSetName} from '../src/utils/useSetName';
24
24
  export {default as useGetName} from '../src/utils/useGetName';
25
- // commented for v1 release
26
- //export {useSidePanel} from '../src/utils/useSidePanel';
25
+ export {useSidePanel} from '../src/utils/useSidePanel';
27
26
  // commented for v1 release
28
27
  // export {
29
28
  // default as useUnreadMessageCount,
@@ -18,7 +18,6 @@
18
18
  "web-sdk:build": "cross-env TARGET=wsdk NODE_ENV=production gulp webSdk",
19
19
  "react-sdk": "cross-env TARGET=rsdk NODE_ENV=development gulp reactSdk",
20
20
  "react-sdk:build": "cross-env TARGET=rsdk NODE_ENV=production gulp reactSdk",
21
- "react-sdk-esbuild": "cross-env TARGET=rsdk NODE_ENV=production gulp reactSdkEsbuild",
22
21
  "electron:start": "cross-env NODE_ENV=development gulp electron_development",
23
22
  "electron:build": "cross-env NODE_ENV=production gulp electron_build",
24
23
  "windows": "cross-env TARGET=windows npm run electron:start",
@@ -32,7 +31,9 @@
32
31
  "icons:android": "react-native set-icon --path ./build/icon.png",
33
32
  "icons:ios": "react-native set-icon --path ./build/icon.png",
34
33
  "package:mac": "npm run mac:build && electron-builder --publish=always",
35
- "release": "electron-builder --mac --windows --linux --publish always --config ./electron-builder.js "
34
+ "release": "electron-builder --mac --windows --linux --publish always --config ./electron-builder.js ",
35
+ "make-rsdk-ts-defs": "cross-env TARGET=rsdk NODE_ENV=production gulp makeRsdkTsDefs",
36
+ "make-wsdk-ts-defs": "cross-env TARGET=wsdk NODE_ENV=production gulp makeWsdkTsDefs"
36
37
  },
37
38
  "publish": [
38
39
  {
@@ -18,6 +18,12 @@ export interface ChatBubbleProps {
18
18
  message: string;
19
19
  timestamp: string;
20
20
  uid: UidType;
21
+ render?: (
22
+ isLocal: boolean,
23
+ message: string,
24
+ timestamp: string,
25
+ uid: UidType,
26
+ ) => JSX.Element;
21
27
  }
22
28
 
23
29
  export interface messageStoreInterface {
@@ -58,8 +64,6 @@ export interface chatContext {
58
64
  engine: RtmEngine;
59
65
  localUid: UidType;
60
66
  onlineUsersCount: number;
61
- displayName: string;
62
- setDisplayName: React.Dispatch<SetStateAction<string>>;
63
67
  }
64
68
 
65
69
  export enum controlMessageEnum {
@@ -33,6 +33,9 @@ import {
33
33
  import {EventUtils, EventsQueue, eventMessageType} from '../rtm-events';
34
34
  import RTMEngine from '../rtm/RTMEngine';
35
35
  import {filterObject} from '../utils';
36
+ import CustomEvents, {EventLevel} from '../custom-events';
37
+ import {EventNames} from '../rtm-events';
38
+ import useLocalScreenShareUid from '../utils/useLocalShareScreenUid';
36
39
 
37
40
  export enum UserType {
38
41
  ScreenShare = 'screenshare',
@@ -56,6 +59,7 @@ const parsePayload = (data: string) => {
56
59
 
57
60
  const RtmConfigure = (props: any) => {
58
61
  const localUid = useLocalUid();
62
+ const screenShareUid = useLocalScreenShareUid();
59
63
  const {callActive} = props;
60
64
  const {rtcProps} = useContext(PropsContext);
61
65
  const {RtcEngine, dispatch} = useContext(RtcContext);
@@ -75,21 +79,6 @@ const RtmConfigure = (props: any) => {
75
79
  renderListRef.current.renderList = renderList;
76
80
  }, [renderList]);
77
81
 
78
- const {store, setStore} = useContext(StorageContext);
79
- const getInitialUsername = () =>
80
- store?.displayName ? store.displayName : '';
81
- const [displayName, setDisplayName] = useState(getInitialUsername());
82
-
83
- //Update the store displayName value if the state is changed
84
- useEffect(() => {
85
- setStore((prevState) => {
86
- return {
87
- ...prevState,
88
- displayName,
89
- };
90
- });
91
- }, [displayName]);
92
-
93
82
  const [login, setLogin] = useState<boolean>(false);
94
83
 
95
84
  const [hasUserJoinedRTM, setHasUserJoinedRTM] = useState<boolean>(false);
@@ -145,7 +134,6 @@ const RtmConfigure = (props: any) => {
145
134
 
146
135
  const setAttribute = async () => {
147
136
  const rtmAttributes = [
148
- {key: 'name', value: displayName || userText},
149
137
  {key: 'screenUid', value: String(rtcProps.screenShareUid)},
150
138
  ];
151
139
  try {
@@ -227,10 +215,6 @@ const RtmConfigure = (props: any) => {
227
215
  const screenUid = parseInt(attr?.attributes?.screenUid);
228
216
  //start - updating user data in rtc
229
217
  const userData = {
230
- name:
231
- String(member.uid)[0] === '1'
232
- ? pstnUserLabel
233
- : attr?.attributes?.name || userText,
234
218
  screenUid: screenUid,
235
219
  //below thing for livestreaming
236
220
  type: 'rtc',
@@ -240,7 +224,6 @@ const RtmConfigure = (props: any) => {
240
224
 
241
225
  //start - updating screenshare data in rtc
242
226
  const screenShareUser = {
243
- name: getScreenShareName(attr?.attributes?.name || userText),
244
227
  type: UserType.ScreenShare,
245
228
  };
246
229
  updateRenderListState(screenUid, screenShareUser);
@@ -329,10 +312,6 @@ const RtmConfigure = (props: any) => {
329
312
  const screenUid = parseInt(attr?.attributes?.screenUid);
330
313
  //start - updating user data in rtc
331
314
  const userData = {
332
- name:
333
- String(data.uid)[0] === '1'
334
- ? pstnUserLabel
335
- : attr?.attributes?.name || userText,
336
315
  screenUid: screenUid,
337
316
  //below thing for livestreaming
338
317
  type: 'rtc',
@@ -342,7 +321,6 @@ const RtmConfigure = (props: any) => {
342
321
 
343
322
  //start - updating screenshare data in rtc
344
323
  const screenShareUser = {
345
- name: getScreenShareName(attr?.attributes?.name || userText),
346
324
  type: UserType.ScreenShare,
347
325
  };
348
326
  updateRenderListState(screenUid, screenShareUser);
@@ -602,8 +580,6 @@ const RtmConfigure = (props: any) => {
602
580
  engine: engine.current,
603
581
  localUid: localUid,
604
582
  onlineUsersCount,
605
- setDisplayName,
606
- displayName,
607
583
  }}>
608
584
  {login ? props.children : <></>}
609
585
  </ChatContext.Provider>
@@ -30,7 +30,7 @@ const PreCallTextInput: React.FC = () => {
30
30
  return (
31
31
  <TextInput
32
32
  value={username}
33
- onChangeText={(text) => setUsername(text ? text.trim() : '')}
33
+ onChangeText={(text) => setUsername(text ? text : '')}
34
34
  onSubmitEditing={() => {}}
35
35
  placeholder={
36
36
  isJoinDataFetched ? userNamePlaceholder : fetchingNamePlaceholder
@@ -148,7 +148,7 @@ const ShareLinkProvider = (props: ShareLinkProvideProps) => {
148
148
  if (baseURL) {
149
149
  stringToCopy += `${baseURL}/${meetingPassphrase.attendee}`;
150
150
  } else {
151
- stringToCopy += `${meetingIdText}: ${meetingPassphrase.attendee}`;
151
+ stringToCopy += `${meetingPassphrase.attendee}`;
152
152
  }
153
153
  }
154
154
  return stringToCopy;
@@ -161,7 +161,7 @@ const ShareLinkProvider = (props: ShareLinkProvideProps) => {
161
161
  if (baseURL) {
162
162
  stringToCopy += `${baseURL}/${meetingPassphrase.host}`;
163
163
  } else {
164
- stringToCopy += `${meetingIdText}: ${meetingPassphrase.host}`;
164
+ stringToCopy += `${meetingPassphrase.host}`;
165
165
  }
166
166
  }
167
167
  return stringToCopy;
@@ -0,0 +1,125 @@
1
+ /*
2
+ ********************************************
3
+ Copyright © 2021 Agora Lab, Inc., all rights reserved.
4
+ AppBuilder and all associated components, source code, APIs, services, and documentation
5
+ (the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
6
+ accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
7
+ Use without a license or in violation of any license terms and conditions (including use for
8
+ any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
9
+ information visit https://appbuilder.agora.io.
10
+ *********************************************
11
+ */
12
+ import React, {useState, useContext, useEffect} from 'react';
13
+ import {RenderInterface, useLocalUid} from '../../agora-rn-uikit';
14
+ import {RtcContext} from '../../agora-rn-uikit';
15
+ import {useString} from '../utils/useString';
16
+ import StorageContext from './StorageContext';
17
+ import CustomEvents, {EventLevel} from '../custom-events';
18
+ import {EventNames} from '../rtm-events';
19
+ import useLocalScreenShareUid from '../utils/useLocalShareScreenUid';
20
+ import {createHook} from 'fpe-implementation';
21
+ import ChatContext from './ChatContext';
22
+
23
+ interface UserPreferenceContextInterface {
24
+ displayName: string;
25
+ setDisplayName: React.Dispatch<React.SetStateAction<string>>;
26
+ }
27
+
28
+ const UserPreferenceContext =
29
+ React.createContext<UserPreferenceContextInterface>({
30
+ displayName: '',
31
+ setDisplayName: () => {},
32
+ });
33
+
34
+ const UserPreferenceProvider = (props: {children: React.ReactNode}) => {
35
+ const localUid = useLocalUid();
36
+ const screenShareUid = useLocalScreenShareUid();
37
+ const {dispatch} = useContext(RtcContext);
38
+
39
+ const {store, setStore} = useContext(StorageContext);
40
+ const {hasUserJoinedRTM} = useContext(ChatContext);
41
+ const getInitialUsername = () =>
42
+ store?.displayName ? store.displayName : '';
43
+ const [displayName, setDisplayName] = useState(getInitialUsername());
44
+
45
+ //commented for v1 release
46
+ // const userText = useString('remoteUserDefaultLabel')();
47
+ const userText = 'User';
48
+ const pstnUserLabel = useString('pstnUserLabel')();
49
+ //commented for v1 release
50
+ //const getScreenShareName = useString('screenshareUserName');
51
+ const getScreenShareName = (name: string) => `${name}'s screenshare`;
52
+
53
+ useEffect(() => {
54
+ CustomEvents.on(EventNames.NAME_ATTRIBUTE, (data) => {
55
+ const value = JSON.parse(data?.payload?.value);
56
+ if (value) {
57
+ if (value?.uid) {
58
+ updateRenderListState(value?.uid, {
59
+ name:
60
+ String(value?.uid)[0] === '1'
61
+ ? pstnUserLabel
62
+ : value?.name || userText,
63
+ });
64
+ }
65
+ if (value?.screenShareUid) {
66
+ updateRenderListState(value?.screenShareUid, {
67
+ name: getScreenShareName(value?.name),
68
+ });
69
+ }
70
+ }
71
+ });
72
+ return () => {
73
+ CustomEvents.off(EventNames.NAME_ATTRIBUTE);
74
+ };
75
+ }, []);
76
+
77
+ useEffect(() => {
78
+ //Update the store displayName value if the state is changed
79
+ setStore((prevState) => {
80
+ return {
81
+ ...prevState,
82
+ displayName,
83
+ };
84
+ });
85
+
86
+ //update local state for user and screenshare
87
+ updateRenderListState(localUid, {name: displayName});
88
+ updateRenderListState(screenShareUid, {
89
+ name: getScreenShareName(displayName),
90
+ });
91
+
92
+ if (hasUserJoinedRTM) {
93
+ //update remote state for user and screenshare
94
+ CustomEvents.send(EventNames.NAME_ATTRIBUTE, {
95
+ value: JSON.stringify({
96
+ uid: localUid,
97
+ screenShareUid: screenShareUid,
98
+ name: displayName,
99
+ }),
100
+ level: EventLevel.LEVEL2,
101
+ });
102
+ }
103
+ }, [displayName, hasUserJoinedRTM]);
104
+
105
+ const updateRenderListState = (
106
+ uid: number,
107
+ data: Partial<RenderInterface>,
108
+ ) => {
109
+ dispatch({type: 'UpdateRenderList', value: [uid, data]});
110
+ };
111
+
112
+ return (
113
+ <UserPreferenceContext.Provider
114
+ value={{
115
+ setDisplayName,
116
+ displayName,
117
+ }}>
118
+ {props.children}
119
+ </UserPreferenceContext.Provider>
120
+ );
121
+ };
122
+
123
+ const useUserPreference = createHook(UserPreferenceContext);
124
+
125
+ export {useUserPreference, UserPreferenceProvider};
@@ -52,6 +52,7 @@ import {WhiteboardProvider} from '../components/contexts/WhiteboardContext';
52
52
  import {useWakeLock} from '../components/useWakeLock';
53
53
  import StorageContext from '../components/StorageContext';
54
54
  import SDKEvents from '../utils/SdkEvents';
55
+ import {UserPreferenceProvider} from '../components/useUserPreference';
55
56
 
56
57
  enum RnEncryptionEnum {
57
58
  /**
@@ -210,51 +211,53 @@ const VideoCall: React.FC = () => {
210
211
  <RtmConfigure
211
212
  setRecordingActive={setRecordingActive}
212
213
  callActive={callActive}>
213
- <WhiteboardProvider>
214
- <LayoutProvider
215
- value={{
216
- activeLayoutName,
217
- setActiveLayoutName,
218
- }}>
219
- <RecordingProvider
214
+ <UserPreferenceProvider>
215
+ <WhiteboardProvider>
216
+ <LayoutProvider
220
217
  value={{
221
- setRecordingActive,
222
- isRecordingActive,
218
+ activeLayoutName,
219
+ setActiveLayoutName,
223
220
  }}>
224
- <ScreenshareConfigure>
225
- <LiveStreamContextProvider
226
- value={{
227
- setRtcProps,
228
- rtcProps,
229
- callActive,
230
- }}>
231
- <LiveStreamDataProvider>
232
- <LocalUserContext
233
- localUid={rtcProps?.uid || 0}>
234
- <CustomUserContextHolder>
235
- <NetworkQualityProvider>
236
- {callActive ? (
237
- <VideoCallScreen />
238
- ) : $config.PRECALL ? (
239
- <PreCallProvider
240
- value={{
241
- callActive,
242
- setCallActive,
243
- }}>
244
- <Precall />
245
- </PreCallProvider>
246
- ) : (
247
- <></>
248
- )}
249
- </NetworkQualityProvider>
250
- </CustomUserContextHolder>
251
- </LocalUserContext>
252
- </LiveStreamDataProvider>
253
- </LiveStreamContextProvider>
254
- </ScreenshareConfigure>
255
- </RecordingProvider>
256
- </LayoutProvider>
257
- </WhiteboardProvider>
221
+ <RecordingProvider
222
+ value={{
223
+ setRecordingActive,
224
+ isRecordingActive,
225
+ }}>
226
+ <ScreenshareConfigure>
227
+ <LiveStreamContextProvider
228
+ value={{
229
+ setRtcProps,
230
+ rtcProps,
231
+ callActive,
232
+ }}>
233
+ <LiveStreamDataProvider>
234
+ <LocalUserContext
235
+ localUid={rtcProps?.uid || 0}>
236
+ <CustomUserContextHolder>
237
+ <NetworkQualityProvider>
238
+ {callActive ? (
239
+ <VideoCallScreen />
240
+ ) : $config.PRECALL ? (
241
+ <PreCallProvider
242
+ value={{
243
+ callActive,
244
+ setCallActive,
245
+ }}>
246
+ <Precall />
247
+ </PreCallProvider>
248
+ ) : (
249
+ <></>
250
+ )}
251
+ </NetworkQualityProvider>
252
+ </CustomUserContextHolder>
253
+ </LocalUserContext>
254
+ </LiveStreamDataProvider>
255
+ </LiveStreamContextProvider>
256
+ </ScreenshareConfigure>
257
+ </RecordingProvider>
258
+ </LayoutProvider>
259
+ </WhiteboardProvider>
260
+ </UserPreferenceProvider>
258
261
  </RtmConfigure>
259
262
  </ScreenShareProvider>
260
263
  </SidePanelProvider>
@@ -26,7 +26,8 @@ const ROLE_ATTRIBUTE = 'role';
26
26
  // 3. CHAT MESSAGES
27
27
  const PUBLIC_CHAT_MESSAGE = 'PUBLIC_CHAT_MESSAGE';
28
28
  const PRIVATE_CHAT_MESSAGE = 'PRIVATE_CHAT_MESSAGE';
29
-
29
+ // 4. NAME ATTRIBUTE
30
+ const NAME_ATTRIBUTE = 'name';
30
31
  const EventNames = {
31
32
  RECORDING_ATTRIBUTE,
32
33
  RAISED_ATTRIBUTE,
@@ -34,6 +35,7 @@ const EventNames = {
34
35
  PUBLIC_CHAT_MESSAGE,
35
36
  PRIVATE_CHAT_MESSAGE,
36
37
  SCREENSHARE_ATTRIBUTE,
38
+ NAME_ATTRIBUTE,
37
39
  };
38
40
  /** ***** EVENT NAMES ENDS ***** */
39
41
 
@@ -36,7 +36,9 @@ const ChatBubble = (props: ChatBubbleProps) => {
36
36
  //commented for v1 release
37
37
  //const remoteUserDefaultLabel = useString('remoteUserDefaultLabel')();
38
38
  const remoteUserDefaultLabel = 'User';
39
- return (
39
+ return props?.render ? (
40
+ props.render(isLocal, message, timestamp, uid)
41
+ ) : (
40
42
  <View>
41
43
  <View style={isLocal ? style.chatSenderViewLocal : style.chatSenderView}>
42
44
  <Text style={isLocal ? style.timestampTextLocal : style.timestampText}>
@@ -26,7 +26,7 @@ import {useLocalUid} from '../../agora-rn-uikit';
26
26
  import {ImageIcon} from '../../agora-rn-uikit';
27
27
  import TextWithTooltip from './TextWithTooltip';
28
28
  import {useFpe} from 'fpe-api';
29
- import {isWeb} from '../utils/common';
29
+ import {isValidReactComponent, isWeb} from '../utils/common';
30
30
  import {useString} from '../utils/useString';
31
31
  import {useChatUIControl} from '../components/chat-ui/useChatUIControl';
32
32
  import useUserList from '../utils/useUserList';
@@ -66,20 +66,20 @@ const ChatContainer = (props: any) => {
66
66
  data?.components?.videoCall &&
67
67
  typeof data?.components?.videoCall === 'object'
68
68
  ) {
69
- // commented for v1 release
70
- // if (
71
- // data?.components?.videoCall?.chat &&
72
- // typeof data?.components?.videoCall?.chat === 'object'
73
- // ) {
74
- // if (
75
- // data?.components?.videoCall?.chat?.chatBubble &&
76
- // typeof data?.components?.videoCall?.chat?.chatBubble !== 'object' &&
77
- // isValidReactComponent(data?.components?.videoCall?.chat?.chatBubble)
78
- // ) {
79
- // components.ChatBubbleComponent =
80
- // data?.components?.videoCall?.chat?.chatBubble;
81
- // }
82
- // }
69
+ //commented for v1 release
70
+ if (
71
+ data?.components?.videoCall?.chat &&
72
+ typeof data?.components?.videoCall?.chat === 'object'
73
+ ) {
74
+ if (
75
+ data?.components?.videoCall?.chat?.chatBubble &&
76
+ typeof data?.components?.videoCall?.chat?.chatBubble !== 'object' &&
77
+ isValidReactComponent(data?.components?.videoCall?.chat?.chatBubble)
78
+ ) {
79
+ components.ChatBubbleComponent =
80
+ data?.components?.videoCall?.chat?.chatBubble;
81
+ }
82
+ }
83
83
  }
84
84
  return components;
85
85
  });
@@ -9,11 +9,10 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import {useContext} from 'react';
13
- import ChatContext from '../components/ChatContext';
12
+ import {useUserPreference} from '../components/useUserPreference';
14
13
 
15
14
  function useGetName() {
16
- const {displayName} = useContext(ChatContext);
15
+ const {displayName} = useUserPreference();
17
16
  return displayName;
18
17
  }
19
18
 
@@ -0,0 +1,19 @@
1
+ /*
2
+ ********************************************
3
+ Copyright © 2021 Agora Lab, Inc., all rights reserved.
4
+ AppBuilder and all associated components, source code, APIs, services, and documentation
5
+ (the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
6
+ accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
7
+ Use without a license or in violation of any license terms and conditions (including use for
8
+ any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
9
+ information visit https://appbuilder.agora.io.
10
+ *********************************************
11
+ */
12
+ import {useContext} from 'react';
13
+ import {PropsContext} from '../../agora-rn-uikit';
14
+
15
+ const useLocalScreenShareUid = () => {
16
+ const {rtcProps} = useContext(PropsContext);
17
+ return rtcProps?.screenShareUid || 0;
18
+ };
19
+ export default useLocalScreenShareUid;
@@ -9,11 +9,9 @@
9
9
  information visit https://appbuilder.agora.io.
10
10
  *********************************************
11
11
  */
12
- import {useContext} from 'react';
13
- import ChatContext from '../components/ChatContext';
14
-
12
+ import {useUserPreference} from '../components/useUserPreference';
15
13
  function useSetName() {
16
- const {setDisplayName} = useContext(ChatContext);
14
+ const {setDisplayName} = useUserPreference();
17
15
  return setDisplayName;
18
16
  }
19
17