agora-toolchain 3.3.1 → 3.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-toolchain",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "agora-tc-transpile": "./scripts/transpile.js",
@@ -1,12 +1,19 @@
1
1
  require('dotenv/config');
2
+ const opts = require('../tools/karma-options');
2
3
  const webpackConfig = require('./webpack.karma')();
3
4
  const path = require('path');
4
5
  const cwd = process.cwd();
5
6
 
7
+ const pattern = opts.file ?? '**/*.test.ts';
8
+
6
9
  const files =
7
10
  process.env.platform === 'browser'
8
- ? ['__test__/universal/**/*.test.ts', '__test__/browser/**/*.test.ts']
9
- : ['__test__/universal/**/*.test.ts', '__test__/electron/**/*.test.ts'];
11
+ ? pattern
12
+ ? [`__test__/${pattern}`]
13
+ : [`__test__/universal/**/*.test.ts`, `__test__/browser/**/*.test.ts`]
14
+ : pattern
15
+ ? [`__test__/${pattern}`]
16
+ : [`__test__/universal/**/*.test.ts`, `__test__/electron/**/*.test.ts`];
10
17
 
11
18
  const preprocessors =
12
19
  process.env.platform === 'browser'
@@ -0,0 +1,212 @@
1
+ 'use strict';
2
+ var postcss = require('postcss');
3
+ var objectAssign = require('object-assign');
4
+ var { createPropListMatcher } = require('./src/prop-list-matcher');
5
+ var { getUnitRegexp } = require('./src/pixel-unit-regexp');
6
+
7
+ var defaults = {
8
+ unitToConvert: 'px',
9
+ viewportWidth: 320,
10
+ viewportHeight: 568, // not now used; TODO: need for different units and math for different properties
11
+ unitPrecision: 5,
12
+ viewportUnit: 'vw',
13
+ fontViewportUnit: 'vw', // vmin is more suitable.
14
+ selectorBlackList: [],
15
+ propList: ['*'],
16
+ minPixelValue: 1,
17
+ mediaQuery: false,
18
+ replace: true,
19
+ landscape: false,
20
+ landscapeUnit: 'vw',
21
+ landscapeWidth: 568,
22
+ };
23
+
24
+ var ignoreNextComment = 'px-to-viewport-ignore-next';
25
+ var ignorePrevComment = 'px-to-viewport-ignore';
26
+
27
+ module.exports = postcss.plugin('postcss-px-to-viewport', function (options) {
28
+ var opts = objectAssign({}, defaults, options);
29
+ checkRegExpOrArray(opts, 'exclude');
30
+ checkRegExpOrArray(opts, 'include');
31
+
32
+ var pxRegex = getUnitRegexp(opts.unitToConvert);
33
+ var satisfyPropList = createPropListMatcher(opts.propList);
34
+ var landscapeRules = [];
35
+
36
+ return function (css, result) {
37
+ css.walkRules(function (rule) {
38
+ // Add exclude option to ignore some files like 'node_modules'
39
+ var file = rule.source && rule.source.input.file;
40
+
41
+ if (opts.include && file) {
42
+ if (Object.prototype.toString.call(opts.include) === '[object RegExp]') {
43
+ if (!opts.include.test(file)) return;
44
+ } else if (Object.prototype.toString.call(opts.include) === '[object Array]') {
45
+ var flag = false;
46
+ for (var i = 0; i < opts.include.length; i++) {
47
+ if (opts.include[i].test(file)) {
48
+ flag = true;
49
+ break;
50
+ }
51
+ }
52
+ if (!flag) return;
53
+ }
54
+ }
55
+
56
+ if (opts.exclude && file) {
57
+ if (Object.prototype.toString.call(opts.exclude) === '[object RegExp]') {
58
+ if (opts.exclude.test(file)) return;
59
+ } else if (Object.prototype.toString.call(opts.exclude) === '[object Array]') {
60
+ for (var i = 0; i < opts.exclude.length; i++) {
61
+ if (opts.exclude[i].test(file)) return;
62
+ }
63
+ }
64
+ }
65
+
66
+ if (blacklistedSelector(opts.selectorBlackList, rule.selector)) return;
67
+
68
+ if (opts.landscape && !rule.parent.params) {
69
+ var landscapeRule = rule.clone().removeAll();
70
+
71
+ rule.walkDecls(function (decl) {
72
+ if (decl.value.indexOf(opts.unitToConvert) === -1) return;
73
+ if (!satisfyPropList(decl.prop)) return;
74
+
75
+ landscapeRule.append(
76
+ decl.clone({
77
+ value: decl.value.replace(
78
+ pxRegex,
79
+ createPxReplace(opts, opts.landscapeUnit, opts.landscapeWidth),
80
+ ),
81
+ }),
82
+ );
83
+ });
84
+
85
+ if (landscapeRule.nodes.length > 0) {
86
+ landscapeRules.push(landscapeRule);
87
+ }
88
+ }
89
+
90
+ if (!validateParams(rule.parent.params, opts.mediaQuery)) return;
91
+
92
+ rule.walkDecls(function (decl, i) {
93
+ if (decl.value.indexOf(opts.unitToConvert) === -1) return;
94
+ if (!satisfyPropList(decl.prop)) return;
95
+
96
+ var prev = decl.prev();
97
+ // prev declaration is ignore conversion comment at same line
98
+ if (prev && prev.type === 'comment' && prev.text === ignoreNextComment) {
99
+ // remove comment
100
+ prev.remove();
101
+ return;
102
+ }
103
+ var next = decl.next();
104
+ // next declaration is ignore conversion comment at same line
105
+ if (next && next.type === 'comment' && next.text === ignorePrevComment) {
106
+ if (/\n/.test(next.raws.before)) {
107
+ result.warn(
108
+ 'Unexpected comment /* ' +
109
+ ignorePrevComment +
110
+ ' */ must be after declaration at same line.',
111
+ { node: next },
112
+ );
113
+ } else {
114
+ // remove comment
115
+ next.remove();
116
+ return;
117
+ }
118
+ }
119
+
120
+ var unit;
121
+ var size;
122
+ var params = rule.parent.params;
123
+
124
+ if (opts.landscape && params && params.indexOf('landscape') !== -1) {
125
+ unit = opts.landscapeUnit;
126
+ size = opts.landscapeWidth;
127
+ } else {
128
+ unit = getUnit(decl.prop, opts);
129
+ size = opts.viewportWidth;
130
+ }
131
+
132
+ var value = decl.value.replace(pxRegex, createPxReplace(opts, unit, size));
133
+
134
+ if (declarationExists(decl.parent, decl.prop, value)) return;
135
+
136
+ if (opts.replace) {
137
+ decl.value = value;
138
+ } else {
139
+ decl.parent.insertAfter(i, decl.clone({ value: value }));
140
+ }
141
+ });
142
+ });
143
+
144
+ if (landscapeRules.length > 0) {
145
+ var landscapeRoot = new postcss.AtRule({ params: '(orientation: landscape)', name: 'media' });
146
+
147
+ landscapeRules.forEach(function (rule) {
148
+ landscapeRoot.append(rule);
149
+ });
150
+ css.append(landscapeRoot);
151
+ }
152
+ };
153
+ });
154
+
155
+ function getUnit(prop, opts) {
156
+ return prop.indexOf('font') === -1 ? opts.viewportUnit : opts.fontViewportUnit;
157
+ }
158
+
159
+ function createPxReplace(opts, viewportUnit, viewportSize) {
160
+ return function (m, $1) {
161
+ if (!$1) return m;
162
+ var pixels = parseFloat($1);
163
+ if (pixels <= opts.minPixelValue) return m;
164
+ var parsedVal = toFixed((pixels / viewportSize) * 100, opts.unitPrecision);
165
+ return parsedVal === 0 ? '0' : parsedVal + viewportUnit;
166
+ };
167
+ }
168
+
169
+ function error(decl, message) {
170
+ throw decl.error(message, { plugin: 'postcss-px-to-viewport' });
171
+ }
172
+
173
+ function checkRegExpOrArray(options, optionName) {
174
+ var option = options[optionName];
175
+ if (!option) return;
176
+ if (Object.prototype.toString.call(option) === '[object RegExp]') return;
177
+ if (Object.prototype.toString.call(option) === '[object Array]') {
178
+ var bad = false;
179
+ for (var i = 0; i < option.length; i++) {
180
+ if (Object.prototype.toString.call(option[i]) !== '[object RegExp]') {
181
+ bad = true;
182
+ break;
183
+ }
184
+ }
185
+ if (!bad) return;
186
+ }
187
+ throw new Error('options.' + optionName + ' should be RegExp or Array of RegExp.');
188
+ }
189
+
190
+ function toFixed(number, precision) {
191
+ var multiplier = Math.pow(10, precision + 1),
192
+ wholeNumber = Math.floor(number * multiplier);
193
+ return (Math.round(wholeNumber / 10) * 10) / multiplier;
194
+ }
195
+
196
+ function blacklistedSelector(blacklist, selector) {
197
+ if (typeof selector !== 'string') return;
198
+ return blacklist.some(function (regex) {
199
+ if (typeof regex === 'string') return selector.indexOf(regex) !== -1;
200
+ return selector.match(regex);
201
+ });
202
+ }
203
+
204
+ function declarationExists(decls, prop, value) {
205
+ return decls.some(function (decl) {
206
+ return decl.prop === prop && decl.value === value;
207
+ });
208
+ }
209
+
210
+ function validateParams(params, mediaQuery) {
211
+ return !params || (params && mediaQuery);
212
+ }
@@ -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
+ };
@@ -1,5 +1,18 @@
1
- const autoprefixer = require("autoprefixer");
2
-
1
+ const autoprefixer = require('autoprefixer');
2
+ const postcssPxToViewport = require('./postcss-plugin/px-to-vw/index');
3
3
  module.exports = {
4
- plugins: [autoprefixer()],
4
+ plugins: [
5
+ autoprefixer(),
6
+ postcssPxToViewport({
7
+ viewportWidth: 375,
8
+ unitPrecision: 5,
9
+ viewportUnit: 'vw',
10
+ fontViewportUnit: 'vw',
11
+ exclude: [/\/node_modules\//i],
12
+ landscape: true, // 是否处理横屏情况
13
+ landscapeUnit: 'vw', // (String) 横屏时使用的单位
14
+ landscapeWidth: 812, // (Number) 横屏时使用的视口宽度
15
+ landscapeHeight: 375, // (Number) 横屏时使用的视口宽度
16
+ }),
17
+ ],
5
18
  };
@@ -34,8 +34,9 @@ module.exports = {
34
34
  'agora-foundation',
35
35
  'agora-ui-foundation',
36
36
  'agora-rte-sdk',
37
- 'agora-edu-core',
37
+ 'fcr-core',
38
38
  'fcr-ui-scene',
39
+ 'fcr-ui-scene-mobile',
39
40
  ]),
40
41
  },
41
42
  extensions: ['.ts', '.js', '.tsx'],
@@ -8,7 +8,6 @@ const { getCodeOfDeclaredVariables } = require('../tools/ast-utils');
8
8
  const baseConfig = require('./webpack.base');
9
9
  const { resolveCwd, resolveModule } = require('../tools/paths');
10
10
  const fs = require('fs');
11
-
12
11
  module.exports = createConfig = ({ entry, port = 3000, analyze }) => {
13
12
  const extractArray = (str = '') => {
14
13
  if (!str) {
package/scripts/bundle.js CHANGED
@@ -8,8 +8,15 @@ const webpackConfig = require(webpackProdPath)({ entry, analyze, out });
8
8
 
9
9
  Webpack(webpackConfig, (err, stats) => {
10
10
  // TODO: write error stack and stats to local disk, dont print log to the console
11
+
11
12
  if (err || stats.hasErrors()) {
12
- console.error('Stats', stats);
13
- console.error('Build failed', err);
13
+ console.error(`Build failed`);
14
+ if (err) {
15
+ console.error(`cause: ${err.cause}`);
16
+ console.error(`message: ${err.message}`);
17
+ console.error(`stack: ${err.stack}`);
18
+ }
19
+ console.error(`stats: ${stats.toString()}`);
20
+ process.exit(1);
14
21
  }
15
22
  });
@@ -78,7 +78,9 @@ const options = {
78
78
  to: 'assets/pretest.mp3',
79
79
  },
80
80
  ],
81
- files: cpp ? ['!**/node_modules/agora-electron-sdk/**/*'] : ['**/*'],
81
+ files: cpp
82
+ ? ['!**/node_modules/agora-electron-sdk/**/*', '!**/artifactory_deps/**/*']
83
+ : ['**/*', '!**/artifactory_deps/**/*'],
82
84
  // files: [
83
85
  // // 'node_modules//**/*',
84
86
  // {
@@ -114,6 +116,11 @@ const options = {
114
116
  NSMicrophoneUsageDescription: 'Fcr Meeting wants to acquire your microphone permission',
115
117
  NSCameraUsageDescription: 'Fcr Meeting wants to acquire your camera permission',
116
118
  NSScreenCaptureDescription: 'Fcr Meeting wants to acquire your screen capture permission',
119
+ 'com.apple.security.device.audio-input': true,
120
+ 'com.apple.security.cs.allow-jit': true,
121
+ 'com.apple.security.cs.allow-unsigned-executable-memory': true,
122
+ 'com.apple.security.cs.allow-dyld-environment-variables': true,
123
+ 'com.apple.security.device.camera': true,
117
124
  },
118
125
  },
119
126
  dmg: {
@@ -32,8 +32,10 @@ function copyDirSync(source, target) {
32
32
  }
33
33
  }
34
34
  }
35
-
36
- // copyDirSync(resolveBase('lib'), resolveCwd('dist'));
35
+ if (!fs.existsSync(resolveCwd('dist/assets'))) {
36
+ fs.mkdirSync(resolveCwd('dist/assets'));
37
+ }
38
+ fs.copyFileSync(resolveCwd('public/assets/loading.gif'), resolveCwd('dist/assets/loading.gif'));
37
39
 
38
40
  // Let's get that intellisense working
39
41
  /**
@@ -82,6 +84,7 @@ const options = {
82
84
  output: resolveCwd('release'),
83
85
  buildResources: resolveCwd('installer/resources'),
84
86
  },
87
+ files: ['!**/artifactory_deps/**/*'],
85
88
  // files: [
86
89
  // // 'node_modules//**/*',
87
90
  // {
@@ -94,6 +97,10 @@ const options = {
94
97
  from: resolveCwd('public/assets/pretest.mp3'),
95
98
  to: 'assets/pretest.mp3',
96
99
  },
100
+ {
101
+ from: resolveCwd('public/assets/loading.gif'),
102
+ to: 'assets/loading.gif',
103
+ },
97
104
  ],
98
105
  // extraFiles: [
99
106
  // {
@@ -7,7 +7,7 @@ const karmaPresetPath = path.join(presetsDir, 'karma.conf.js');
7
7
 
8
8
  process.env.platform = 'browser';
9
9
 
10
- spawn(require.resolve('.bin/karma'), ['start', karmaPresetPath], {
10
+ spawn(require.resolve('.bin/karma'), ['start', karmaPresetPath, ...process.argv], {
11
11
  stdio: 'inherit',
12
12
  }).on('exit', (code) => {
13
13
  if (code === 0) {
@@ -41,7 +41,7 @@ waitOn(
41
41
  },
42
42
  );
43
43
 
44
- spawn(require.resolve('.bin/karma'), ['start', karmaPresetPath], {
44
+ spawn(require.resolve('.bin/karma'), ['start', karmaPresetPath, ...process.argv], {
45
45
  stdio: 'inherit',
46
46
  }).on('exit', (code) => {
47
47
  if (code === 0) {
@@ -0,0 +1,8 @@
1
+ const { program } = require('commander');
2
+
3
+ const opts = program
4
+ .option('--file <file>', 'Specify an UT to run')
5
+ .parse(process.argv)
6
+ .opts();
7
+
8
+ module.exports = opts;
@@ -3,19 +3,24 @@ const { resolveModule } = require('./paths');
3
3
 
4
4
  const sourceAlias = (libs) => {
5
5
  return libs.reduce((prev, libName) => {
6
- const modulePath = resolveModule(libName);
6
+ try {
7
+ const modulePath = resolveModule(libName);
7
8
 
8
- const srcPath = `${modulePath}/src`;
9
+ const srcPath = `${modulePath}/src`;
9
10
 
10
- if (existsSync(srcPath)) {
11
- console.log(`source linker: ${libName} linked`);
11
+ if (existsSync(srcPath)) {
12
+ console.log(`source linker: ${libName} linked`);
12
13
 
13
- prev[`${libName}/lib`] = srcPath;
14
+ prev[`${libName}/lib`] = srcPath;
14
15
 
15
- prev[`${libName}`] = srcPath;
16
- }
16
+ prev[`${libName}`] = srcPath;
17
+ }
17
18
 
18
- return prev;
19
+ return prev;
20
+ } catch (e) {
21
+ console.log(`source linker: ${libName} not found`);
22
+ return prev;
23
+ }
19
24
  }, {});
20
25
  };
21
26