agora-toolchain 3.7.9-alpha → 3.8.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.
@@ -43,4 +43,19 @@ app.addListener('ready', () => {
43
43
  enable(mainWindow.webContents);
44
44
 
45
45
  mainWindow.loadURL(baseUrl);
46
+
47
+ mainWindow.webContents.setWindowOpenHandler(() => {
48
+ return {
49
+ action: 'allow',
50
+ overrideBrowserWindowOptions: {
51
+ webPreferences: {
52
+ ...defaultWebPreferences,
53
+ },
54
+ },
55
+ };
56
+ });
57
+
58
+ mainWindow.webContents.on('did-create-window', (window) => {
59
+ enable(window.webContents);
60
+ });
46
61
  });
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../presets/tsconfig.base.json",
3
+ "files": ["./electron.setup.ts", "./karma-setup.ts"]
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-toolchain",
3
- "version": "3.7.9-alpha",
3
+ "version": "3.8.0",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "agora-tc-transpile": "./scripts/transpile.js",
@@ -5,6 +5,9 @@ const path = require('path');
5
5
  const cwd = process.cwd();
6
6
 
7
7
  const pattern = opts.file ?? '**/*.test.ts';
8
+ const singleRun = opts.singleRun ?? false;
9
+ const fakeMedia = opts.fakeMedia ?? false;
10
+ const headless = opts.headless ?? false;
8
11
 
9
12
  const files =
10
13
  process.env.platform === 'browser'
@@ -26,7 +29,21 @@ const preprocessors =
26
29
  [path.join(cwd, '__test__/electron/**/*.test.ts')]: ['webpack'],
27
30
  };
28
31
 
29
- const browsers = process.env.platform === 'browser' ? ['Chrome'] : [];
32
+ const browsers = process.env.platform === 'browser' ? ['Chrome_Custom'] : [];
33
+ const launcherFlags = [];
34
+
35
+ if (fakeMedia) {
36
+ launcherFlags.push('--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream');
37
+ }
38
+
39
+ if (headless) {
40
+ launcherFlags.push(
41
+ '--headless=new',
42
+ '--no-sandbox',
43
+ '--disable-gpu',
44
+ '--window-size=1280,800',
45
+ );
46
+ }
30
47
 
31
48
  module.exports = (config) => {
32
49
  config.set({
@@ -88,10 +105,17 @@ module.exports = (config) => {
88
105
 
89
106
  // Continuous Integration mode
90
107
  // if true, Karma captures browsers, runs the tests and exits
91
- singleRun: false,
108
+ singleRun,
92
109
 
93
110
  // Concurrency level
94
111
  // how many browser instances should be started simultaneously
95
112
  concurrency: Infinity,
113
+
114
+ customLaunchers: {
115
+ Chrome_Custom: {
116
+ base: 'Chrome',
117
+ flags: launcherFlags,
118
+ },
119
+ },
96
120
  });
97
121
  };
@@ -0,0 +1,14 @@
1
+ // excluding regex trick: http://www.rexegg.com/regex-best-trick.html
2
+
3
+ // Not anything inside double quotes
4
+ // Not anything inside single quotes
5
+ // Not anything inside url()
6
+ // Any digit followed by px
7
+ // !singlequotes|!doublequotes|!url()|pixelunit
8
+ function getUnitRegexp(unit) {
9
+ return new RegExp('"[^"]+"|\'[^\']+\'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)' + unit, 'g');
10
+ }
11
+
12
+ module.exports = {
13
+ getUnitRegexp,
14
+ };
@@ -0,0 +1,118 @@
1
+ var filterPropList = {
2
+ exact: function (list) {
3
+ return list.filter(function (m) {
4
+ return m.match(/^[^\*\!]+$/);
5
+ });
6
+ },
7
+ contain: function (list) {
8
+ return list
9
+ .filter(function (m) {
10
+ return m.match(/^\*.+\*$/);
11
+ })
12
+ .map(function (m) {
13
+ return m.substr(1, m.length - 2);
14
+ });
15
+ },
16
+ endWith: function (list) {
17
+ return list
18
+ .filter(function (m) {
19
+ return m.match(/^\*[^\*]+$/);
20
+ })
21
+ .map(function (m) {
22
+ return m.substr(1);
23
+ });
24
+ },
25
+ startWith: function (list) {
26
+ return list
27
+ .filter(function (m) {
28
+ return m.match(/^[^\*\!]+\*$/);
29
+ })
30
+ .map(function (m) {
31
+ return m.substr(0, m.length - 1);
32
+ });
33
+ },
34
+ notExact: function (list) {
35
+ return list
36
+ .filter(function (m) {
37
+ return m.match(/^\![^\*].*$/);
38
+ })
39
+ .map(function (m) {
40
+ return m.substr(1);
41
+ });
42
+ },
43
+ notContain: function (list) {
44
+ return list
45
+ .filter(function (m) {
46
+ return m.match(/^\!\*.+\*$/);
47
+ })
48
+ .map(function (m) {
49
+ return m.substr(2, m.length - 3);
50
+ });
51
+ },
52
+ notEndWith: function (list) {
53
+ return list
54
+ .filter(function (m) {
55
+ return m.match(/^\!\*[^\*]+$/);
56
+ })
57
+ .map(function (m) {
58
+ return m.substr(2);
59
+ });
60
+ },
61
+ notStartWith: function (list) {
62
+ return list
63
+ .filter(function (m) {
64
+ return m.match(/^\![^\*]+\*$/);
65
+ })
66
+ .map(function (m) {
67
+ return m.substr(1, m.length - 2);
68
+ });
69
+ },
70
+ };
71
+
72
+ function createPropListMatcher(propList) {
73
+ var hasWild = propList.indexOf('*') > -1;
74
+ var matchAll = hasWild && propList.length === 1;
75
+ var lists = {
76
+ exact: filterPropList.exact(propList),
77
+ contain: filterPropList.contain(propList),
78
+ startWith: filterPropList.startWith(propList),
79
+ endWith: filterPropList.endWith(propList),
80
+ notExact: filterPropList.notExact(propList),
81
+ notContain: filterPropList.notContain(propList),
82
+ notStartWith: filterPropList.notStartWith(propList),
83
+ notEndWith: filterPropList.notEndWith(propList),
84
+ };
85
+ return function (prop) {
86
+ if (matchAll) return true;
87
+ return (
88
+ (hasWild ||
89
+ lists.exact.indexOf(prop) > -1 ||
90
+ lists.contain.some(function (m) {
91
+ return prop.indexOf(m) > -1;
92
+ }) ||
93
+ lists.startWith.some(function (m) {
94
+ return prop.indexOf(m) === 0;
95
+ }) ||
96
+ lists.endWith.some(function (m) {
97
+ return prop.indexOf(m) === prop.length - m.length;
98
+ })) &&
99
+ !(
100
+ lists.notExact.indexOf(prop) > -1 ||
101
+ lists.notContain.some(function (m) {
102
+ return prop.indexOf(m) > -1;
103
+ }) ||
104
+ lists.notStartWith.some(function (m) {
105
+ return prop.indexOf(m) === 0;
106
+ }) ||
107
+ lists.notEndWith.some(function (m) {
108
+ return prop.indexOf(m) === prop.length - m.length;
109
+ })
110
+ )
111
+ );
112
+ };
113
+ }
114
+
115
+ module.exports = {
116
+ filterPropList,
117
+ createPropListMatcher,
118
+ };
@@ -13,7 +13,9 @@ module.exports = {
13
13
  AGORA_TEST_RTM_APP_CERTIFICATE: JSON.stringify(process.env.AGORA_TEST_RTM_APP_CERTIFICATE),
14
14
  DEMO_APP_VERSION: JSON.stringify(require(resolveCwd('package.json')).version),
15
15
  DEMO_APP_SHARE_LINK: JSON.stringify(process.env.fcr_app_share_link),
16
- DEMO_APP_BUILD_TIME: JSON.stringify(new Date(new Date().getTime() + 8 * 60 * 60 * 1000).toISOString().replace('Z', '+08:00')),
16
+ DEMO_APP_BUILD_TIME: JSON.stringify(
17
+ new Date(new Date().getTime() + 8 * 60 * 60 * 1000).toISOString().replace('Z', '+08:00'),
18
+ ),
17
19
  }),
18
20
  ],
19
21
  resolve: {
@@ -35,6 +37,7 @@ module.exports = {
35
37
  'agora-ui-foundation',
36
38
  'agora-rte-sdk',
37
39
  'fcr-core',
40
+ 'fcr-ui-widget-sdk',
38
41
  'fcr-ui-scene',
39
42
  'fcr-ui-scene-mobile',
40
43
  ]),
@@ -90,6 +93,10 @@ module.exports = {
90
93
  test: /\.(png|jpe?g|gif|svg|mp4|webm|ogg|mp3|wav|flac|aac|woff|woff2|eot|ttf)$/,
91
94
  type: 'asset',
92
95
  },
96
+ {
97
+ resourceQuery: /raw/,
98
+ type: 'asset/source',
99
+ },
93
100
  ],
94
101
  },
95
102
  };
@@ -99,10 +99,7 @@ module.exports = createConfig = ({ entry, analyze, out = 'dist' }) => {
99
99
  codeAppendPlugins.push(
100
100
  new AppendCodePlugin({
101
101
  code: `window.runtime && window.runtime.setFragmentOptions('${fragment}', ${windowOptions} || {}, ${webPreferences} || {});`,
102
- patterns: [
103
- /main.[0-9a-f]{20}.js$/,
104
- ...fragments.map((f) => new RegExp(`${f}.[0-9a-f]{20}.js$`)),
105
- ],
102
+ patterns: [/main.[0-9a-f]{20}.js$/, ...fragments.map((f) => new RegExp(`${f}.[0-9a-f]{20}.js$`))],
106
103
  }),
107
104
  );
108
105
 
@@ -126,21 +123,11 @@ module.exports = createConfig = ({ entry, analyze, out = 'dist' }) => {
126
123
  otherPlugins.push(new BundleAnalyzerPlugin());
127
124
  }
128
125
 
129
- const debug = process.env.fcr_debug === true || process.env.fcr_debug === 'true';
130
-
131
- console.log('webpack prod debug:', debug);
132
-
133
- const baseWebpackConfig = {
134
- mode: 'production',
135
- };
136
-
137
- if (debug) {
138
- baseWebpackConfig.mode = 'development';
139
- baseWebpackConfig.devtool = 'eval-source-map';
140
- }
141
-
142
126
  const prodConfig = {
143
- ...baseWebpackConfig,
127
+ // mode: 'development',
128
+ mode: 'production',
129
+ // devtool: 'eval',
130
+ // devtool: 'source-map',
144
131
  entry: entries,
145
132
  output: {
146
133
  clean: true,
@@ -2,6 +2,9 @@ const { program } = require('commander');
2
2
 
3
3
  const opts = program
4
4
  .option('--file <file>', 'Specify an UT to run')
5
+ .option('--single-run', 'Run tests once and exit', false)
6
+ .option('--fake-media', 'Use fake media devices in browser tests', false)
7
+ .option('--headless', 'Run browser tests in headless mode', false)
5
8
  .parse(process.argv)
6
9
  .opts();
7
10