efront 3.20.13 → 3.20.14

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.
@@ -118,7 +118,6 @@ var $scope = {
118
118
  $scope.currentTheta = ((currentTime * 6 + 90) % 180 - 90) / 180 * Math.PI;
119
119
  playState.width = (currentTime * 100 / duration).toFixed(2) + `%`;
120
120
  $scope.currentProcess = `width:` + playState.width;
121
- render.refresh();
122
121
  },
123
122
  effectPage(effect = !$scope.effect) {
124
123
  $scope.effect = effect;
@@ -302,6 +301,7 @@ var createControls = function () {
302
301
  touching = true;
303
302
  var { x } = value;
304
303
  let _audio = $scope.audio;
304
+ css(progress, { width: x });
305
305
  $scope.process(x / player.offsetWidth * _audio.duration, _audio.duration);
306
306
  }
307
307
  return { x: progress.offsetWidth };
@@ -187,7 +187,7 @@
187
187
  >.info {
188
188
  width: 100%;
189
189
  margin-right: -200px;
190
- line-height: 10px;
190
+ line-height: 1;
191
191
  text-align: left;
192
192
  padding: 46px 5px 0 5px;
193
193
  z-index: 2;
@@ -260,7 +260,7 @@
260
260
 
261
261
  &.page>.krc {
262
262
  text-align: center;
263
- line-height: 36px;
263
+ line-height: 2.2;
264
264
  margin-bottom: -80px;
265
265
  bottom: 50%;
266
266
  height: 180px;
@@ -13,7 +13,7 @@ var dragview = function (dragview) {
13
13
  moving = false;
14
14
  } else {
15
15
  var { childNodes } = target;
16
- if (getComputedStyle(target).cursor === 'auto') for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
16
+ if (getComputedStyle(target).cursor === 'auto' && getComputedStyle(target).userSelect !== 'none') for (var cx = 0, dx = childNodes.length; cx < dx; cx++) {
17
17
  var child = childNodes[cx];
18
18
  if (child.nodeType === 3) {
19
19
  moving = false;
@@ -56,7 +56,7 @@ function main() {
56
56
  return o.toFixed(5 - i);
57
57
  }
58
58
  });
59
- on("append")(page, function () {
59
+ on("mounted")(page, function () {
60
60
  this.querySelector('[hz="440"]').scrollIntoViewIfNeeded();
61
61
  });
62
62
  on('contextmenu')(page, function (e) {
@@ -1,13 +1,16 @@
1
+ *{
2
+ box-sizing: border-box;
3
+ }
1
4
  & {
2
5
  background: #fff;
3
6
  display: inline-block;
4
7
  resize: both;
5
- font-style: 16px;
8
+ font-size: 16px;
6
9
  position: relative;
7
10
  min-height: 100px;
8
11
  padding: 0 0 10px 16px;
9
12
  font-family: 宋体;
10
- width: 438px;
13
+ width: 422px;
11
14
 
12
15
  >a {
13
16
  display: inline-block;
@@ -1,6 +1,4 @@
1
1
  var alertError = alert.bind(null, 'error');
2
- var Context = window.webkitAudioContext || window.AudioContext;
3
- var globalContext = Context && new Context;
4
2
 
5
3
  var reportError = function (error) {
6
4
  switch (error.code || error.name) {
@@ -25,85 +23,68 @@ var reportError = function (error) {
25
23
 
26
24
  function init() {
27
25
  if (!this.audioPromise) {
28
- this.audioPromise = new Promise((ok, oh) => {
29
- navigator.mediaDevices.getUserMedia({
30
- audio: { deviceId: this.deviceId }
31
- }).then(ok).catch(oh);
32
- }).then((stream) => {
33
- var context = new Context;
26
+ this.audioPromise = navigator.mediaDevices.getUserMedia({
27
+ audio: { deviceId: this.deviceId }
28
+ }).then(async (stream) => {
29
+ var context = new AudioContext;
34
30
  this.gain = context.createGain();
31
+ var analyser = context.createAnalyser();
32
+ analyser.fftSize = 2048;
35
33
  context.resume();
36
- var audioInput = context.createMediaStreamSource(stream);
37
- console.log(stream);
38
- var createScript = context.createScriptProcessor || context.createJavaScriptNode;
39
- var recorder = createScript.apply(context, [0, 1, 1]);
40
- return [recorder, audioInput, context];
34
+ var source = context.createMediaStreamSource(stream);
35
+ return [source, context, analyser];
41
36
  });
42
37
  }
43
38
  return this.audioPromise;
44
39
  }
45
- function stop() {
40
+
41
+ async function stop() {
46
42
  var commandCount = ++this.commandCount;
47
43
  if (!this.running) return;
48
- this.init().then(([recorder, audioInput, context]) => {
49
-
50
- if (this.commandCount !== commandCount) return;
51
- this.running = false;
52
- if (this.gain) {
53
- recorder.disconnect(this.gain);
54
- this.gain.disconnect(context.destination);
55
- } else {
56
- recorder.disconnect(context.destination);
57
- }
58
- audioInput.disconnect(context.recorder);
59
- if (this.audio) this.audio.pause();
60
- });
61
-
44
+ var [source, context, analyser] = await this.init();
45
+ cancelAnimationFrame(analyser.frame);
46
+ if (this.commandCount !== commandCount) return;
47
+ this.running = false;
48
+ source.disconnect(analyser);
49
+ if (this.gain) {
50
+ source.disconnect(this.gain);
51
+ this.gain.disconnect(context.destination);
52
+ } else {
53
+ source.disconnect(context.destination);
54
+ }
55
+ this.context = null;
56
+ this.audioPromise = null;
57
+ this.gain = null;
58
+ context.suspend();
59
+ await context.close();
60
+ if (this.audio) this.audio.pause();
62
61
  }
63
- function start() {
62
+
63
+ async function start() {
64
64
  if (this.running) return;
65
65
  var commandCount = ++this.commandCount;
66
- this.init().then(([recorder, audioInput, context]) => {
67
- if (commandCount !== this.commandCount) return;
68
- this.context = context;
69
- recorder.onaudioprocess = (e) => {
70
- var buffer = copyData(e);
71
- cast(this, buffer);
72
- this.onprocess instanceof Function && this.onprocess(buffer);
73
- };
74
- this.running = true;
75
- audioInput.connect(recorder);
76
- recorder.connect(this.gain).connect(context.destination);
77
- if (this.audio) this.audio.play();
78
- }).catch(reportError);
79
- }
80
- function copyData(audioProcessingEvent) {
81
- // The input buffer is the song we loaded earlier
82
- var inputBuffer = audioProcessingEvent.inputBuffer;
83
-
84
- // The output buffer contains the samples that will be modified and played
85
- var outputBuffer = audioProcessingEvent.outputBuffer;
86
- var distBuffer = [];
87
- // Loop through the output channels (in this case there is only one)
88
- var { numberOfChannels } = inputBuffer;
89
- for (var channel = 0; channel < numberOfChannels; channel++) {
90
- var inputData = inputBuffer.getChannelData(channel);
91
- var outputData = outputBuffer.getChannelData(channel);
92
-
93
- // Loop through the 4096 samples
94
- for (var cx = 0, dx = inputData.length; cx < dx; cx++) {
95
- // make output equal to the same as the input
96
- outputData[cx] = inputData[cx];
97
- if (!distBuffer[cx]) distBuffer[cx] = inputData[cx];
98
- else distBuffer[cx] += inputData[cx];
99
-
100
- // add noise to each output sample
101
- // outputData[cx] += ((Math.random() * 2) - 1) * 0.2;
102
-
103
- }
66
+ try {
67
+ var [source, context, analyser] = await this.init();
68
+ } catch (e) {
69
+ reportError(e);
104
70
  }
105
- return distBuffer.map(a => a / numberOfChannels);
71
+ if (commandCount !== this.commandCount) return;
72
+ this.context = context;
73
+ var dancingArray = new Uint8Array(analyser.fftSize);
74
+ var animate = () => {
75
+ analyser.getByteTimeDomainData(dancingArray);
76
+ cast(this, dancingArray);
77
+ analyser.frame = requestAnimationFrame(animate);
78
+ this.onprocess instanceof Function && this.onprocess(dancingArray);
79
+ };
80
+ animate();
81
+ this.running = true;
82
+
83
+ source.connect(analyser);
84
+ source.connect(this.gain).connect(context.destination);
85
+ if (this.audio) this.audio.play();
106
86
  }
87
+
107
88
  class Source {
108
89
  running = false;
109
90
  audioPromise;
@@ -119,7 +100,7 @@ class Source {
119
100
  }
120
101
  init() {
121
102
  if (this.audioPromise) return this.audioPromise;
122
- var context = new Context;
103
+ var context = new AudioContext;
123
104
  var audio = document.createElement("audio");
124
105
  this.gain = context.createGain();
125
106
  console.log(this.gain);
@@ -131,9 +112,10 @@ class Source {
131
112
 
132
113
  return this.audioPromise = Promise.resolve([recorder, source, context]);
133
114
  }
134
- start = start;
135
- stop = stop;
136
115
  }
116
+ Source.prototype.start = start;
117
+ Source.prototype.stop = stop;
118
+
137
119
  class Recorder {
138
120
  running = false;
139
121
  hasMicrophone = navigator.getUserMedia instanceof Function;
@@ -141,6 +123,8 @@ class Recorder {
141
123
  commandCount = 0;
142
124
  onprocess;
143
125
  context;
126
+ workletUrl;
127
+ workletName;
144
128
  constructor(device) {
145
129
  if (!device) device = {};
146
130
  var config = {
@@ -154,10 +138,11 @@ class Recorder {
154
138
 
155
139
  extend(this, config);
156
140
  }
157
- init = init;
158
- start = start;
159
- stop = stop;
160
141
  }
142
+ Recorder.prototype.init = init;
143
+ Recorder.prototype.start = start;
144
+ Recorder.prototype.stop = stop;
145
+
161
146
  class Monitor {
162
147
  running = false;
163
148
  context;
@@ -171,19 +156,16 @@ class Monitor {
171
156
  extend(this, config);
172
157
 
173
158
  }
174
- init = init;
175
- start = start;
176
- stop = stop;
177
159
  }
160
+ Monitor.prototype.init = init;
161
+ Monitor.prototype.start = start;
162
+ Monitor.prototype.stop = stop;
163
+
178
164
  var audio = {
179
165
  Recorder,
180
166
  Monitor,
181
167
  Source,
182
- Context,
183
- copyData,
184
- getGlobalContext() {
185
- return globalContext;
186
- },
168
+ Context: AudioContext,
187
169
  getRecorder() {
188
170
  return new Recorder
189
171
  },
@@ -1,3 +1,3 @@
1
1
  <canvas></canvas>
2
2
  <button ng-if=!running ng-click=start()>开启</button>
3
- <button ng-if=running ng-click=stop()>关闭</button>
3
+ <button ng-else ng-click=stop()>关闭</button>
@@ -13,10 +13,8 @@ function main() {
13
13
  context.beginPath();
14
14
  context.moveTo(0, canvas.offsetHeight / 2);
15
15
  var max = 2;
16
- // [].forEach.call(buffer, function (db, cx) {
17
- // if (db > max) max = db;
18
- // });
19
16
  [].forEach.call(buffer, function (db, cx) {
17
+ db = (db - 128) / 128;
20
18
  context.lineTo(cx * canvas.width / buffer.length, canvas.height / 2 - db / max * canvas.height);
21
19
  });
22
20
  context.stroke();
@@ -53,18 +53,9 @@ function lattice(element, minWidth, maxWidth = minWidth << 1, layers) {
53
53
  if (element.with instanceof Array) element.with.forEach(build);
54
54
  else if (isElement(element.with)) build(element.with);
55
55
  };
56
- var go = _box.go;
57
- _box.go = function (value) {
58
- resize();
59
- if (!boxCount) return;
60
- go.call(_box, value);
61
- };
62
- var _onappend = function () {
63
- _box.resize();
64
- };
65
- onappend(_box, _onappend);
66
56
  _box.resize = lazy(function () {
67
57
  var savedCount = boxCount;
58
+ console.log(savedCount)
68
59
  var index = _box.index();
69
60
  resize();
70
61
  if (savedCount === boxCount) return;
@@ -74,8 +65,8 @@ function lattice(element, minWidth, maxWidth = minWidth << 1, layers) {
74
65
  [].forEach.call(_box.children, function (c) {
75
66
  build(c);
76
67
  });
77
- go.call(_box, index);
78
- }, 0);
68
+ _box.go(index);
69
+ });
79
70
  resizingList.set(_box);
80
71
  on('resize')(_box, _box.resize);
81
72
  return _box;
@@ -8,6 +8,6 @@ function main() {
8
8
  renderWithDefaults(layer, {
9
9
  data: items
10
10
  });
11
- layer.querySelector("lattice").go(0);
11
+ layer.querySelector("lattice");
12
12
  return layer;
13
13
  }
@@ -0,0 +1,3 @@
1
+ &{
2
+ word-break: break-all;
3
+ }
@@ -38,7 +38,7 @@ var create = function (url, key) {
38
38
  image.shape = function (x, y, scaled, rotate) {
39
39
  var style = get_style(x, y, scaled, rotate);
40
40
  css(imgpic, style);
41
- if (imgpic) dispatch(imgpic, 'scaled');
41
+ if (imgpic) dispatch(p, 'scaled');
42
42
  };
43
43
  image.close = function () {
44
44
  if (!p.touchclose) return false;
@@ -9,6 +9,6 @@
9
9
  <option selected>600个选项</option>
10
10
  </select>
11
11
  <select -src="(o,i) in options6000">
12
+ <option value="" insert selected>60000个选项</option>
12
13
  <option -text="'选项'+o">选项</option>
13
- <option insert selected>60000个选项</option>
14
14
  </select>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.20.13",
3
+ "version": "3.20.14",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {