@car-cutter/vue-webplayer 0.3.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/.turbo/turbo-build.log +16 -0
- package/.turbo/turbo-lint.log +4 -0
- package/README.md +11 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +8264 -0
- package/dist/index.umd.cjs +48 -0
- package/index.ts +23 -0
- package/package.json +30 -0
- package/src/WebPlayer.vue +83 -0
- package/tsconfig.app.json +8 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +5 -0
- package/vite.config.ts +52 -0
package/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export {
|
|
2
|
+
default as WebPlayer,
|
|
3
|
+
type WebPlayerProps,
|
|
4
|
+
type WebPlayerEvents,
|
|
5
|
+
} from "./src/WebPlayer.vue";
|
|
6
|
+
|
|
7
|
+
// Expose parent package
|
|
8
|
+
export {
|
|
9
|
+
// - Components
|
|
10
|
+
WEB_PLAYER_WC_TAG,
|
|
11
|
+
WEB_PLAYER_ICON_WC_TAG,
|
|
12
|
+
// - Events
|
|
13
|
+
DEFAULT_EVENT_PREFIX,
|
|
14
|
+
EVENT_COMPOSITION_LOADING,
|
|
15
|
+
EVENT_COMPOSITION_LOADED,
|
|
16
|
+
EVENT_COMPOSITION_LOAD_ERROR,
|
|
17
|
+
EVENT_EXTEND_MODE_ON,
|
|
18
|
+
EVENT_EXTEND_MODE_OFF,
|
|
19
|
+
EVENT_HOTSPOTS_ON,
|
|
20
|
+
EVENT_HOTSPOTS_OFF,
|
|
21
|
+
EVENT_GALLERY_OPEN,
|
|
22
|
+
EVENT_GALLERY_CLOSE,
|
|
23
|
+
} from "@car-cutter/wc-webplayer";
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@car-cutter/vue-webplayer",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.umd.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "vue-tsc -b && vite build",
|
|
11
|
+
"lint": "eslint . --ext ts --max-warnings 0",
|
|
12
|
+
"analyze": "vite-bundle-visualizer"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@car-cutter/wc-webplayer": "0.3.0"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"vue": ">=3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@vitejs/plugin-vue": "^5.1.2",
|
|
22
|
+
"eslint": "^8.57.0",
|
|
23
|
+
"typescript": "^5.5.3",
|
|
24
|
+
"vite": "^5.4.1",
|
|
25
|
+
"vite-bundle-visualizer": "^1.2.1",
|
|
26
|
+
"vite-plugin-dts": "^4.0.3",
|
|
27
|
+
"vue": "^3.4.37",
|
|
28
|
+
"vue-tsc": "^2.0.29"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { onMounted, onUnmounted } from "vue";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_EVENT_PREFIX,
|
|
6
|
+
EVENT_COMPOSITION_LOADING,
|
|
7
|
+
EVENT_COMPOSITION_LOADED,
|
|
8
|
+
EVENT_COMPOSITION_LOAD_ERROR,
|
|
9
|
+
EVENT_EXTEND_MODE_ON,
|
|
10
|
+
EVENT_EXTEND_MODE_OFF,
|
|
11
|
+
EVENT_HOTSPOTS_ON,
|
|
12
|
+
EVENT_HOTSPOTS_OFF,
|
|
13
|
+
EVENT_GALLERY_OPEN,
|
|
14
|
+
EVENT_GALLERY_CLOSE,
|
|
15
|
+
} from "@car-cutter/core";
|
|
16
|
+
import { type WebPlayerProps } from "@car-cutter/core-ui";
|
|
17
|
+
import { ensureCustomElementsDefinition } from "@car-cutter/wc-webplayer";
|
|
18
|
+
|
|
19
|
+
export type { WebPlayerProps };
|
|
20
|
+
export type WebPlayerEvents = {
|
|
21
|
+
compositionLoading: [];
|
|
22
|
+
compositionLoaded: [];
|
|
23
|
+
compositionLoadError: [];
|
|
24
|
+
extendModeOn: [];
|
|
25
|
+
extendModeOff: [];
|
|
26
|
+
hotspotsOn: [];
|
|
27
|
+
hotspotsOff: [];
|
|
28
|
+
galleryOpen: [];
|
|
29
|
+
galleryClose: [];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const props = defineProps<WebPlayerProps>();
|
|
33
|
+
ensureCustomElementsDefinition();
|
|
34
|
+
|
|
35
|
+
// -- Event listeners
|
|
36
|
+
const emit = defineEmits<WebPlayerEvents>();
|
|
37
|
+
|
|
38
|
+
const eventPrefix = props.eventPrefix ?? DEFAULT_EVENT_PREFIX;
|
|
39
|
+
|
|
40
|
+
const generateEventName = (event: string) => `${eventPrefix}${event}`;
|
|
41
|
+
|
|
42
|
+
const eventListenerMap = new Map([
|
|
43
|
+
[EVENT_COMPOSITION_LOADING, () => emit("compositionLoading")],
|
|
44
|
+
[EVENT_COMPOSITION_LOADED, () => emit("compositionLoaded")],
|
|
45
|
+
[EVENT_COMPOSITION_LOAD_ERROR, () => emit("compositionLoadError")],
|
|
46
|
+
[EVENT_EXTEND_MODE_ON, () => emit("extendModeOn")],
|
|
47
|
+
[EVENT_EXTEND_MODE_OFF, () => emit("extendModeOff")],
|
|
48
|
+
[EVENT_HOTSPOTS_ON, () => emit("hotspotsOn")],
|
|
49
|
+
[EVENT_HOTSPOTS_OFF, () => emit("hotspotsOff")],
|
|
50
|
+
[EVENT_GALLERY_OPEN, () => emit("galleryOpen")],
|
|
51
|
+
[EVENT_GALLERY_CLOSE, () => emit("galleryClose")],
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
onMounted(() => {
|
|
55
|
+
eventListenerMap.forEach((emiter, event) => {
|
|
56
|
+
const eventName = generateEventName(event);
|
|
57
|
+
document.addEventListener(eventName, emiter);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
onUnmounted(() => {
|
|
62
|
+
eventListenerMap.forEach((emiter, event) => {
|
|
63
|
+
const eventName = generateEventName(event);
|
|
64
|
+
document.removeEventListener(eventName, emiter);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<cc-webplayer
|
|
71
|
+
:composition-url="compositionUrl"
|
|
72
|
+
:infinite-carrousel="infiniteCarrousel"
|
|
73
|
+
:permanent-gallery="permanentGallery"
|
|
74
|
+
:image-load-strategy="imageLoadStrategy"
|
|
75
|
+
:min-image-width="minImageWidth"
|
|
76
|
+
:max-image-width="maxImageWidth"
|
|
77
|
+
:flatten="flatten"
|
|
78
|
+
:prevent-full-screen="preventFullScreen"
|
|
79
|
+
:eventPrefix="eventPrefix"
|
|
80
|
+
:reverse360="reverse360"
|
|
81
|
+
>
|
|
82
|
+
</cc-webplayer>
|
|
83
|
+
</template>
|
package/tsconfig.json
ADDED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolve } from "path";
|
|
2
|
+
|
|
3
|
+
import vue from "@vitejs/plugin-vue";
|
|
4
|
+
import { defineConfig } from "vite";
|
|
5
|
+
import dts from "vite-plugin-dts";
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [
|
|
9
|
+
vue({
|
|
10
|
+
template: {
|
|
11
|
+
compilerOptions: {
|
|
12
|
+
isCustomElement: tag => ["cc-webplayer"].includes(tag),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
dts({
|
|
17
|
+
tsconfigPath: resolve(__dirname, "./tsconfig.app.json"),
|
|
18
|
+
rollupTypes: true,
|
|
19
|
+
bundledPackages: [
|
|
20
|
+
"@car-cutter/core",
|
|
21
|
+
"@car-cutter/core-ui",
|
|
22
|
+
"@car-cutter/core-wc",
|
|
23
|
+
"@car-cutter/wc-webplayer",
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
define: {
|
|
29
|
+
"process.env": {
|
|
30
|
+
NODE_ENV: "production",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
build: {
|
|
34
|
+
lib: {
|
|
35
|
+
name: "vue-webplayer",
|
|
36
|
+
fileName: "index",
|
|
37
|
+
entry: resolve(__dirname, "./index.ts"),
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
chunkSizeWarningLimit: 400,
|
|
41
|
+
|
|
42
|
+
// Vue is an external dependency, it should be provided by the consumer
|
|
43
|
+
rollupOptions: {
|
|
44
|
+
external: ["vue"],
|
|
45
|
+
output: {
|
|
46
|
+
globals: {
|
|
47
|
+
vue: "Vue",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|