@voicenter-team/voicenter-ui-plus 4.0.0-beta.1 → 4.0.0-beta.2
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/README.md +13 -45
- package/library/assets/components/VcChatComposer/VcChatComposer.css +1 -1
- package/library/assets/components/VcMdEditor/ParameterNode.css +1 -1
- package/library/assets/components/VcMdEditor/VcMdEditorContent.css +1 -1
- package/library/components/VcChatComposer/VcChatComposer.vue.mjs +173 -139
- package/library/components/VcChatComposer/tiptap.mjs +45 -0
- package/library/components/VcCodeBlock/VcCodeBlock.vue.mjs +18 -5
- package/library/components/VcCodeBlock/highlight.mjs +8 -0
- package/library/components/VcEmojiPicker/VcEmojiPicker.vue.mjs +3 -4
- package/library/components/VcEmojiPicker/emojiData.mjs +16 -21
- package/library/components/VcHtmlEditor/VcHtmlEditor.vue.mjs +19 -12
- package/library/components/VcHtmlEditor/codemirror.mjs +14 -0
- package/library/components/VcImageUploader/VcImageUploader.vue.mjs +14 -8
- package/library/components/VcImageUploader/cropper.mjs +5 -0
- package/library/components/VcJsonSchema/Components/JsonCodeMirror.vue.mjs +16 -7
- package/library/components/VcJsonSchema/Components/codemirror.mjs +15 -0
- package/library/components/VcMdEditor/ParameterNode.vue.mjs +1 -1
- package/library/components/VcMdEditor/ParameterNode.vue2.mjs +2 -2
- package/library/components/VcMdEditor/VcMdEditor.vue.mjs +114 -108
- package/library/components/VcMdEditor/VcMdEditorContent.vue.mjs +18 -21
- package/library/components/VcMdEditor/ltrNumbersPlugin.mjs +42 -39
- package/library/components/VcMdEditor/mdEditor.config.mjs +107 -99
- package/library/components/VcMdEditor/milkdown.mjs +67 -0
- package/library/components/VcMdEditor/rtlCursorPlugin.mjs +3 -3
- package/library/components/VcPdfViewer/VcPdfDocument.vue.mjs +4 -8
- package/library/components/VcPdfViewer/pdfjslib.mjs +13 -16
- package/library/components/VcSoundplayer/VcSoundPlayerProgress.vue.mjs +1 -1
- package/library/components/VcSoundplayer/VcSoundPlayerWrapper.vue.mjs +17 -6
- package/library/components/VcSoundplayer/wavesurfer.mjs +14 -0
- package/library/style.css +3 -3
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/types/components/VcChatComposer/VcChatComposer.vue.d.ts +2 -1
- package/library/types/components/VcChatComposer/tiptap.d.ts +61 -0
- package/library/types/components/VcCodeBlock/highlight.d.ts +3 -0
- package/library/types/components/VcEmojiPicker/VcEmojiPicker.vue.d.ts +1 -1
- package/library/types/components/VcEmojiPicker/emojiData.d.ts +3 -3
- package/library/types/components/VcHtmlEditor/codemirror.d.ts +8 -0
- package/library/types/components/VcImageUploader/VcImageUploader.vue.d.ts +1 -1
- package/library/types/components/VcImageUploader/cropper.d.ts +34 -0
- package/library/types/components/VcJsonSchema/Components/codemirror.d.ts +9 -0
- package/library/types/components/VcMdEditor/ltrNumbersPlugin.d.ts +7 -13
- package/library/types/components/VcMdEditor/mdEditor.config.d.ts +12 -16
- package/library/types/components/VcMdEditor/milkdown.d.ts +25 -0
- package/library/types/components/VcMdEditor/rtlCursorPlugin.d.ts +3 -2
- package/library/types/components/VcPdfViewer/VcPdfDocument.vue.d.ts +1 -1
- package/library/types/components/VcPdfViewer/VcPdfDocumentPage.vue.d.ts +1 -1
- package/library/types/components/VcPdfViewer/pdfjslib.d.ts +1 -1
- package/library/types/components/VcSoundplayer/VcSoundPlayerWrapper.vue.d.ts +1 -1
- package/library/types/components/VcSoundplayer/wavesurfer.d.ts +8 -0
- package/library/types/types/VcSoundPlayer.types.d.ts +1 -1
- package/library/types/utils/optionalPeer.d.ts +33 -0
- package/library/utils/excelParser/helper.mjs +2 -7
- package/library/utils/optionalPeer.mjs +32 -0
- package/package.json +95 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WaveSurferOptions } from 'wavesurfer.js';
|
|
1
|
+
import type { WaveSurferOptions } from 'wavesurfer.js';
|
|
2
2
|
import type { HoverPluginOptions } from 'wavesurfer.js/dist/plugins/hover';
|
|
3
3
|
import type { GenericPlugin } from 'wavesurfer.js/dist/base-plugin';
|
|
4
4
|
import { VcSoundPlayerSize } from '../../types/VcSoundPlayer.types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type WaveSurfer from 'wavesurfer.js';
|
|
2
|
+
import type Hover from 'wavesurfer.js/dist/plugins/hover';
|
|
3
|
+
export interface IWaveSurferModules {
|
|
4
|
+
WaveSurfer: typeof WaveSurfer;
|
|
5
|
+
Hover: typeof Hover;
|
|
6
|
+
}
|
|
7
|
+
/** wavesurfer.js and its hover plugin, an optional peer (src/utils/optionalPeer.ts), shared by every sound player. */
|
|
8
|
+
export declare const loadWaveSurfer: () => Promise<IWaveSurferModules>;
|
|
@@ -18,7 +18,7 @@ export declare type VcSoundPlayerProvideType = {
|
|
|
18
18
|
volume?: Ref<number>;
|
|
19
19
|
defaultVolume?: () => number;
|
|
20
20
|
isPlayingInProgress?: Ref<boolean>;
|
|
21
|
-
initWavesurfer?: (id: string, el?: HTMLElement) => void
|
|
21
|
+
initWavesurfer?: (id: string, el?: HTMLElement) => Promise<void>;
|
|
22
22
|
play?: (time?: number) => void;
|
|
23
23
|
pause?: () => void;
|
|
24
24
|
stop?: () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading the optional peers: the packages that package.json `peerDependenciesMeta` marks optional
|
|
3
|
+
* (README, "Optional peers"). An application installs only those of the components it renders, so the
|
|
4
|
+
* library loads each of them with `import()` where it is used and never with a static import (eslint
|
|
5
|
+
* fails on one; `import type` loads nothing and is allowed).
|
|
6
|
+
*
|
|
7
|
+
* Why `import()`: the application's bundler builds a module in place of a peer that is not installed.
|
|
8
|
+
* Vite's one throws when it is evaluated (the dev server, a Vite 7+ production build) or is an empty
|
|
9
|
+
* `export default {}` (a Vite 5 production build), and a static named import from it fails the
|
|
10
|
+
* application's build, also in a chunk the application never loads. Behind a static import the throw
|
|
11
|
+
* fails the whole chunk that imports the peer, and in plugin mode the application, since the plugin
|
|
12
|
+
* imports every component. Behind `import()` it is a rejected promise when a component renders:
|
|
13
|
+
* only that component fails, and as the component returns the promise from its hook, the rejection
|
|
14
|
+
* reaches the application's error handler.
|
|
15
|
+
*
|
|
16
|
+
* A loader is a `cachedLoad` of `loadOptionalPeer` calls (`loadOptionalPeer('@tiptap/vue-3', import('@tiptap/vue-3'))`).
|
|
17
|
+
* The component's documentation page lists the packages it loads (documentation/components/OptionalPeersInstall.vue).
|
|
18
|
+
*
|
|
19
|
+
* A peer's stylesheet is not loaded this way: Vite builds no module in place of a missing stylesheet, and
|
|
20
|
+
* the application's build fails on it. It is an `@import` in the component's `<style>` instead, which
|
|
21
|
+
* Vite's CSS `@import` inlining builds into the library's stylesheet.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* The module of an optional peer: resolves with what `module` (an `import()` of `packageName` or of a
|
|
25
|
+
* path inside it) resolves with, and rejects with the error of `module` or, when the module is the empty
|
|
26
|
+
* one Vite 5 builds in place of a missing package, with an error that names `packageName`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function loadOptionalPeer<T>(packageName: string, module: Promise<T>): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* `load`, called once and its promise shared by every call after it. A rejected promise is dropped,
|
|
31
|
+
* so the next call loads again.
|
|
32
|
+
*/
|
|
33
|
+
export declare function cachedLoad<T>(load: () => Promise<T>): () => Promise<T>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { ignoredAsciiCodeSymbols } from "./configs.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!xlsxPromise) {
|
|
5
|
-
xlsxPromise = import("xlsx");
|
|
6
|
-
}
|
|
7
|
-
return xlsxPromise;
|
|
8
|
-
}
|
|
2
|
+
import { cachedLoad, loadOptionalPeer } from "../optionalPeer.mjs";
|
|
3
|
+
const getXlsx = cachedLoad(() => loadOptionalPeer("xlsx", import("xlsx")));
|
|
9
4
|
const readXLSXFile = async (bStr) => {
|
|
10
5
|
const XLSX = await getXlsx();
|
|
11
6
|
return XLSX.read(bStr, { type: "binary" });
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function isMissingPeerModule(module) {
|
|
2
|
+
if (typeof module !== "object" || module === null) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const keys = Object.keys(module);
|
|
6
|
+
if (keys.length !== 1 || keys[0] !== "default") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const value = Reflect.get(module, "default");
|
|
10
|
+
return typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype && Object.keys(value).length === 0;
|
|
11
|
+
}
|
|
12
|
+
async function loadOptionalPeer(packageName, module) {
|
|
13
|
+
const loaded = await module;
|
|
14
|
+
if (isMissingPeerModule(loaded)) {
|
|
15
|
+
throw new Error(`[voicenter-ui-plus] ${packageName} is not installed: it is an optional peer dependency of @voicenter-team/voicenter-ui-plus that this component needs (README, "Optional peers")`);
|
|
16
|
+
}
|
|
17
|
+
return loaded;
|
|
18
|
+
}
|
|
19
|
+
function cachedLoad(load) {
|
|
20
|
+
let promise;
|
|
21
|
+
return () => {
|
|
22
|
+
promise ?? (promise = load().catch((error) => {
|
|
23
|
+
promise = void 0;
|
|
24
|
+
throw error;
|
|
25
|
+
}));
|
|
26
|
+
return promise;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
cachedLoad,
|
|
31
|
+
loadOptionalPeer
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voicenter-team/voicenter-ui-plus",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite",
|
|
6
6
|
"build": "vite build",
|
|
@@ -137,8 +137,102 @@
|
|
|
137
137
|
"wavesurfer.js": "^7.7.15",
|
|
138
138
|
"xlsx": "^0.18.5"
|
|
139
139
|
},
|
|
140
|
+
"peerDependenciesMeta": {
|
|
141
|
+
"@codemirror/lang-html": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
144
|
+
"@codemirror/lang-json": {
|
|
145
|
+
"optional": true
|
|
146
|
+
},
|
|
147
|
+
"@codemirror/lang-markdown": {
|
|
148
|
+
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"@floating-ui/dom": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"@milkdown/crepe": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
156
|
+
"@milkdown/kit": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"@milkdown/utils": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"@milkdown/vue": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"@prosemirror-adapter/vue": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"@tiptap/core": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"@tiptap/extension-bold": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"@tiptap/extension-code": {
|
|
175
|
+
"optional": true
|
|
176
|
+
},
|
|
177
|
+
"@tiptap/extension-document": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
180
|
+
"@tiptap/extension-italic": {
|
|
181
|
+
"optional": true
|
|
182
|
+
},
|
|
183
|
+
"@tiptap/extension-mention": {
|
|
184
|
+
"optional": true
|
|
185
|
+
},
|
|
186
|
+
"@tiptap/extension-paragraph": {
|
|
187
|
+
"optional": true
|
|
188
|
+
},
|
|
189
|
+
"@tiptap/extension-strike": {
|
|
190
|
+
"optional": true
|
|
191
|
+
},
|
|
192
|
+
"@tiptap/extension-text": {
|
|
193
|
+
"optional": true
|
|
194
|
+
},
|
|
195
|
+
"@tiptap/extensions": {
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
198
|
+
"@tiptap/pm": {
|
|
199
|
+
"optional": true
|
|
200
|
+
},
|
|
201
|
+
"@tiptap/suggestion": {
|
|
202
|
+
"optional": true
|
|
203
|
+
},
|
|
204
|
+
"@tiptap/vue-3": {
|
|
205
|
+
"optional": true
|
|
206
|
+
},
|
|
207
|
+
"codemirror": {
|
|
208
|
+
"optional": true
|
|
209
|
+
},
|
|
210
|
+
"emojibase-data": {
|
|
211
|
+
"optional": true
|
|
212
|
+
},
|
|
213
|
+
"highlight.js": {
|
|
214
|
+
"optional": true
|
|
215
|
+
},
|
|
216
|
+
"pdfjs-dist": {
|
|
217
|
+
"optional": true
|
|
218
|
+
},
|
|
219
|
+
"vue-advanced-cropper": {
|
|
220
|
+
"optional": true
|
|
221
|
+
},
|
|
222
|
+
"vue-codemirror6": {
|
|
223
|
+
"optional": true
|
|
224
|
+
},
|
|
225
|
+
"wavesurfer.js": {
|
|
226
|
+
"optional": true
|
|
227
|
+
},
|
|
228
|
+
"xlsx": {
|
|
229
|
+
"optional": true
|
|
230
|
+
}
|
|
231
|
+
},
|
|
140
232
|
"devDependencies": {
|
|
233
|
+
"@codemirror/lang-html": "^6.0.0",
|
|
141
234
|
"@codemirror/lang-json": "^6.0.1",
|
|
235
|
+
"@codemirror/lang-markdown": "^6.0.0",
|
|
142
236
|
"@floating-ui/dom": "^1.8.0",
|
|
143
237
|
"@fullhuman/postcss-purgecss": "^7.0.2",
|
|
144
238
|
"@highlightjs/vue-plugin": "^2.1.0",
|