wavesurfer.js 7.0.0-alpha.0 → 7.0.0-alpha.10

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.
Files changed (57) hide show
  1. package/README.md +13 -15
  2. package/dist/base-plugin.d.ts +4 -3
  3. package/dist/base-plugin.js +3 -2
  4. package/dist/decoder.d.ts +2 -4
  5. package/dist/decoder.js +16 -16
  6. package/dist/event-emitter.d.ts +3 -1
  7. package/dist/event-emitter.js +6 -2
  8. package/dist/index.d.ts +43 -18
  9. package/dist/index.js +105 -44
  10. package/dist/player-webaudio.js +5 -4
  11. package/dist/player.d.ts +11 -2
  12. package/dist/player.js +50 -4
  13. package/dist/plugins/multitrack.d.ts +46 -0
  14. package/dist/plugins/multitrack.js +274 -0
  15. package/dist/plugins/regions.d.ts +11 -6
  16. package/dist/plugins/regions.js +106 -74
  17. package/dist/plugins/timeline.d.ts +29 -0
  18. package/dist/plugins/timeline.js +119 -0
  19. package/dist/plugins/xmultitrack.d.ts +44 -0
  20. package/dist/plugins/xmultitrack.js +260 -0
  21. package/dist/react/useWavesurfer.d.ts +5 -0
  22. package/dist/react/useWavesurfer.js +20 -0
  23. package/dist/renderer.d.ts +9 -5
  24. package/dist/renderer.js +137 -91
  25. package/dist/timer.d.ts +2 -1
  26. package/dist/timer.js +6 -1
  27. package/dist/wavesurfer.Multitrack.min.js +1 -0
  28. package/dist/wavesurfer.Regions.min.js +1 -0
  29. package/dist/wavesurfer.Timeline.min.js +1 -0
  30. package/dist/wavesurfer.min.js +1 -0
  31. package/package.json +19 -5
  32. package/.eslintrc.json +0 -24
  33. package/.prettierrc +0 -8
  34. package/examples/audio.ogg +0 -0
  35. package/examples/bars.js +0 -19
  36. package/examples/basic.js +0 -8
  37. package/examples/gradient.js +0 -28
  38. package/examples/regions.js +0 -63
  39. package/examples/video.js +0 -19
  40. package/examples/webaudio.js +0 -14
  41. package/src/base-plugin.ts +0 -20
  42. package/src/decoder.ts +0 -41
  43. package/src/event-emitter.ts +0 -35
  44. package/src/fetcher.ts +0 -7
  45. package/src/index.ts +0 -252
  46. package/src/player-webaudio.ts +0 -34
  47. package/src/player.ts +0 -50
  48. package/src/plugins/regions.ts +0 -240
  49. package/src/renderer.ts +0 -250
  50. package/src/timer.ts +0 -27
  51. package/tsconfig.json +0 -105
  52. package/tutorial/index.html +0 -47
  53. package/tutorial/src/editor.js +0 -70
  54. package/tutorial/src/init.js +0 -66
  55. package/tutorial/src/url.js +0 -25
  56. package/tutorial/style.css +0 -211
  57. package/yarn-error.log +0 -1049
@@ -1,70 +0,0 @@
1
- let editor = null
2
-
3
- export const getContent = () => {
4
- return editor ? editor.getModel().getValue() : ''
5
- }
6
-
7
- export const setContent = (newContent) => {
8
- if (!editor) {
9
- setTimeout(() => setContent(newContent), 10)
10
- } else {
11
- editor.getModel().setValue(newContent)
12
- }
13
- }
14
-
15
- const fetchCode = async (url) => {
16
- return fetch(url).then((res) => res.text())
17
- }
18
-
19
- export const initEditor = (onSetContent) => {
20
- require.config({ paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.32.0-dev.20211218/min/vs' } });
21
-
22
- require(['vs/editor/editor.main'], () => {
23
- let theme = 'vs'
24
- if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
25
- theme = 'vs-dark'
26
- }
27
-
28
- monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
29
- lib: [ 'es2019', 'dom' ],
30
- allowJs: true,
31
- allowNonTsExtensions: true,
32
- baseUrl: window.location.origin,
33
- moduleResolution: monaco.languages.typescript.ModuleResolutionKind.Classic,
34
- })
35
-
36
- const libs = [
37
- '/dist/index.d.ts',
38
- '/dist/event-emitter.d.ts',
39
- '/dist/plugins/regions.d.ts',
40
- ]
41
-
42
- Promise.all(
43
- libs.map(url => fetchCode(url))
44
- ).then((codes) => {
45
- codes.forEach((code, index) => {
46
- monaco.languages.typescript.typescriptDefaults.addExtraLib(code, libs[index])
47
- })
48
- }).then(() => {
49
- const monacoEditor = monaco.editor.create(document.getElementById('editor'), {
50
- language: 'typescript',
51
- quickSuggestions: true,
52
- automaticLayout: true,
53
- autoClosingBrackets: false,
54
- minimap: { enabled: false },
55
- tabSize: 2,
56
- theme
57
- });
58
-
59
- let debounce
60
- const model = monacoEditor.getModel()
61
- model.onDidChangeContent(() => {
62
- if (debounce) clearTimeout(debounce)
63
- debounce = setTimeout(onSetContent, 300)
64
- })
65
-
66
- // Export
67
- editor = monacoEditor
68
- })
69
- })
70
- }
@@ -1,66 +0,0 @@
1
- import { initEditor, setContent, getContent } from './editor.js'
2
-
3
- const onSetContent = () => {
4
- const code = getContent()
5
- document.getElementById('preview').srcdoc = `
6
- <!DOCTYPE html>
7
- <html>
8
- <head>
9
- <meta charset="utf-8">
10
- <title>Preview</title>
11
- <style>
12
- html, body {
13
- background-color: transparent;
14
- margin: 0;
15
- padding: 0;
16
- }
17
- body {
18
- padding: 1rem;
19
- }
20
- </style>
21
- </head>
22
- <body>
23
- <script type="module">
24
- ${code}
25
- </script>
26
- </body>
27
- </html>
28
- <body>
29
- </body>
30
- `
31
- }
32
-
33
- const fetchContent = async (url) => {
34
- return fetch(url).then(res => res.text())
35
- }
36
-
37
- const init = () => {
38
- let currentLink = null
39
-
40
- document.addEventListener('click', (e) => {
41
- const url = e.target.href
42
- if (url && url.endsWith('.js')) {
43
- e.preventDefault()
44
-
45
- fetchContent(url).then(setContent)
46
-
47
- if (currentLink) {
48
- currentLink.classList.remove('active')
49
- }
50
- currentLink = e.target
51
- currentLink.classList.add('active')
52
-
53
- window.location.hash = e.target.pathname
54
- }
55
- })
56
-
57
- const { hash } = window.location
58
- let url = '/examples/basic.js'
59
- if (hash && /^#\/examples\/.+?\.js$/.test(hash)) {
60
- url = hash.slice(1)
61
- }
62
- document.querySelector(`a[href="${url}"]`).click()
63
- }
64
-
65
- initEditor(onSetContent)
66
- init()
@@ -1,25 +0,0 @@
1
- const GIST_PARAM = 'gist'
2
-
3
- export const getQueryParam = (param) => {
4
- return new URL(location.href).searchParams.get(param)
5
- }
6
-
7
- export const clearQueryParam = (param) => {
8
- const path = location.pathname + location.search.replace(new RegExp(`\\b${param}=\\w+`), '').replace(/\?$/, '')
9
- history.pushState({}, '', path)
10
- }
11
-
12
- export const getUrlGistId = () => {
13
- return getQueryParam(GIST_PARAM)
14
- }
15
-
16
- export const setUrlGistId = (id) => {
17
- const path = `${location.pathname}?${GIST_PARAM}=${encodeURIComponent(id)}`
18
- history.pushState({}, '', path)
19
- }
20
-
21
- export const clearUrlGistId = () => {
22
- clearQueryParam(GIST_PARAM)
23
- }
24
-
25
-
@@ -1,211 +0,0 @@
1
- body, html {
2
- margin: 0;
3
- padding: 0;
4
- background: #fff;
5
- color: #333;
6
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
7
- }
8
-
9
- a {
10
- color: #333;
11
- }
12
-
13
- a:hover {
14
- color: #000;
15
- }
16
-
17
- @media (prefers-color-scheme: dark) {
18
- body, html {
19
- background: #1E1E1E;
20
- color: #fff;
21
- }
22
-
23
- a {
24
- color: #ddd;
25
- }
26
-
27
- a:hover {
28
- color: #fff;
29
- }
30
- }
31
-
32
- * {
33
- box-sizing: border-box;
34
- }
35
-
36
- .layout {
37
- display: flex;
38
- flex-wrap: wrap;
39
- flex-direction: column;
40
- height: 100vh;
41
- }
42
-
43
- .grid {
44
- display: flex;
45
- flex-wrap: nowrap;
46
- flex: 1;
47
- width: 100vw;
48
- min-height: 500px;
49
- }
50
-
51
- @media (max-width: 768px) {
52
- .grid {
53
- flex-wrap: wrap;
54
- }
55
- }
56
-
57
- .sidebar {
58
- width: 120px;
59
- padding: 10px;
60
- padding-right: 0;
61
- }
62
-
63
- .sidebar ul {
64
- list-style: none;
65
- padding: 0;
66
- margin: 0;
67
- }
68
-
69
- .sidebar li {
70
- padding: 0;
71
- margin: 0;
72
- }
73
-
74
- .sidebar a {
75
- display: block;
76
- padding: 0.5em;
77
- text-decoration: none;
78
- }
79
-
80
- .sidebar a.active {
81
- background: #ddd;
82
- position: relative;
83
- }
84
-
85
- .sidebar a.active:after {
86
- content: "▸";
87
- position: absolute;
88
- right: 0;
89
- }
90
-
91
- @media (prefers-color-scheme: dark) {
92
- .sidebar a.active {
93
- background: #333;
94
- }
95
- }
96
-
97
- #editor {
98
- margin-top: 1em;
99
- min-width: 50vw;
100
- }
101
-
102
- .preview {
103
- flex: 1;
104
- min-width: 30vw;
105
- height: 100%;
106
- padding: 1em;
107
- }
108
-
109
- .preview iframe {
110
- display: block;
111
- width: 100%;
112
- height: 100%;
113
- border: 1px solid #EDEDEC;
114
- border-radius: 6px;
115
- }
116
-
117
- header {
118
- padding: 1em;
119
- text-align: center;
120
- font-family: sans-serif;
121
- font-size: 12px;
122
- color: #fff;
123
- background: linear-gradient(to right, #3a6186, #89253e);
124
- position: relative;
125
- display: flex;
126
- align-items: center;
127
- justify-content: space-between;
128
- }
129
-
130
- header h1 {
131
- margin: 0;
132
- font-size: inherit;
133
- }
134
-
135
- header a,
136
- header a:hover,
137
- footer a,
138
- footer a:hover {
139
- color: #fff;
140
- }
141
-
142
- header a:hover,
143
- footer a:hover {
144
- text-decoration: none;
145
- }
146
-
147
- footer {
148
- padding: 1em;
149
- text-align: center;
150
- font-family: sans-serif;
151
- font-size: 12px;
152
- color: #ccc;
153
- background: linear-gradient(to left, #3a6186, #89253e);
154
- }
155
-
156
- .github {
157
- margin-right: 0.5em;
158
- }
159
-
160
- .github:before {
161
- text-decoration: none;
162
- content: '';
163
- display: inline-block;
164
- margin-right: 5px;
165
- width: 20px;
166
- height: 20px;
167
- vertical-align: middle;
168
- background: center center no-repeat url("data:image/svg+xml, %3Csvg width='1024' height='1024' viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z' transform='scale(64)' fill='%23fff'/%3E%3C/svg%3E%0A");
169
- background-size: contain;
170
- }
171
-
172
- @keyframes fadeIn {
173
- 0% { opacity: 0; }
174
- 100% { opacity: 1; }
175
- }
176
-
177
- .alert {
178
- position: fixed;
179
- z-index: 100;
180
- top: 10px;
181
- right: 10px;
182
- padding: 20px;
183
- border-radius: 6px;
184
- background: #426183;
185
- color: #fff;
186
- font-size: 20px;
187
- cursor: pointer;
188
- text-align: left;
189
- min-width: 30vw;
190
- max-width: 40vw;
191
- max-height: 5em;
192
- overflow: auto;
193
- white-space: pre-line;
194
- animation: fadeIn 100ms ease-in;
195
- }
196
-
197
- .eval-decoration {
198
- background: #CFB3B9;
199
- }
200
-
201
- @media (prefers-color-scheme: dark) {
202
- .eval-decoration {
203
- background: #792C3D;
204
- }
205
- }
206
-
207
- kbd {
208
- content: '⌨';
209
- font-size: 1.2em;
210
- margin-right: 0.2em;
211
- }