js-cloudimage-360-view 4.0.0 → 4.1.0-beta.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/README.md +978 -275
- package/dist/js-cloudimage-360-view.min.css +1 -1
- package/dist/js-cloudimage-360-view.min.js +1490 -901
- package/dist/react/assets/canvas.worker-Cg0fkpD1.js.map +1 -0
- package/dist/react/ci360-COjOXkWS.js +35 -0
- package/dist/react/ci360-COjOXkWS.js.map +1 -0
- package/dist/react/ci360-CbNlMnNZ.mjs +2700 -0
- package/dist/react/ci360-CbNlMnNZ.mjs.map +1 -0
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +228 -0
- package/dist/react/index.js +273 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/style.css +1 -0
- package/package.json +48 -8
- package/src/react/types.d.ts +228 -0
- package/src/types/ci360.d.ts +66 -0
- package/.prettierrc +0 -9
package/package.json
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-cloudimage-360-view",
|
|
3
|
-
"version": "4.0.0",
|
|
3
|
+
"version": "4.1.0-beta.0",
|
|
4
4
|
"main": "dist/js-cloudimage-360-view.min.js",
|
|
5
|
+
"types": "src/types/ci360.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/js-cloudimage-360-view.min.js",
|
|
8
|
+
"dist/js-cloudimage-360-view.min.css",
|
|
9
|
+
"dist/react",
|
|
10
|
+
"src/types",
|
|
11
|
+
"src/react/types.d.ts"
|
|
12
|
+
],
|
|
5
13
|
"exports": {
|
|
6
14
|
".": {
|
|
15
|
+
"types": "./src/types/ci360.d.ts",
|
|
7
16
|
"import": "./dist/js-cloudimage-360-view.min.js",
|
|
8
17
|
"require": "./dist/js-cloudimage-360-view.min.js"
|
|
18
|
+
},
|
|
19
|
+
"./css": "./dist/js-cloudimage-360-view.min.css",
|
|
20
|
+
"./react": {
|
|
21
|
+
"types": "./dist/react/index.d.ts",
|
|
22
|
+
"import": "./dist/react/index.js",
|
|
23
|
+
"require": "./dist/react/index.cjs"
|
|
9
24
|
}
|
|
10
25
|
},
|
|
11
26
|
"style": "dist/js-cloudimage-360-view.min.css",
|
|
@@ -30,40 +45,64 @@
|
|
|
30
45
|
"360 product view"
|
|
31
46
|
],
|
|
32
47
|
"scripts": {
|
|
33
|
-
"dev": "vite serve demo",
|
|
48
|
+
"dev": "vite serve demo --host",
|
|
49
|
+
"dev:react": "npm --prefix demo/react-demo run dev",
|
|
34
50
|
"clean:build": "rm -rf dist",
|
|
35
51
|
"build:bundle": "npm run clean:build && vite build",
|
|
52
|
+
"build:react": "vite build --config vite-react.config.js && cp src/react/types.d.ts dist/react/index.d.ts",
|
|
53
|
+
"build": "npm run build:bundle && npm run build:react",
|
|
36
54
|
"deploy:bundle": "npm run build:bundle && node bin/deploy-bundle",
|
|
37
55
|
"clean:dist": "rm -rf dist",
|
|
38
56
|
"clean:demo": "rm -rf demo/dist",
|
|
39
57
|
"build:npm": "npm run clean:demo && vite --config vite-npm.config.js build",
|
|
40
|
-
"build:demo": "
|
|
58
|
+
"build:demo": "vite --config vite-demo.config.js build && npm --prefix demo/react-demo run build",
|
|
41
59
|
"deploy:demo": "gh-pages -d dist",
|
|
42
|
-
"publish": "npm run build:demo && npm run deploy:demo"
|
|
60
|
+
"publish": "npm run build:demo && npm run deploy:demo",
|
|
61
|
+
"test": "vitest",
|
|
62
|
+
"test:run": "vitest run",
|
|
63
|
+
"test:coverage": "vitest run --coverage"
|
|
43
64
|
},
|
|
44
65
|
"dependencies": {
|
|
45
66
|
"@popperjs/core": "^2.11.2",
|
|
46
|
-
"lodash.debounce": "^4.0.8",
|
|
47
67
|
"lodash.throttle": "^4.1.1"
|
|
48
68
|
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"react": ">=17.0.0",
|
|
71
|
+
"react-dom": ">=17.0.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependenciesMeta": {
|
|
74
|
+
"react": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"react-dom": {
|
|
78
|
+
"optional": true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
49
81
|
"devDependencies": {
|
|
50
82
|
"@babel/cli": "^7.16.7",
|
|
83
|
+
"@types/react": "^18.2.0",
|
|
84
|
+
"@types/react-dom": "^18.2.0",
|
|
85
|
+
"@vitejs/plugin-react": "^4.2.0",
|
|
86
|
+
"react": "^18.2.0",
|
|
87
|
+
"react-dom": "^18.2.0",
|
|
88
|
+
"typescript": "^5.3.0",
|
|
51
89
|
"@babel/core": "^7.16.7",
|
|
52
90
|
"@babel/plugin-transform-runtime": "^7.16.5",
|
|
53
91
|
"@babel/preset-env": "^7.16.5",
|
|
54
92
|
"@eslint/js": "^9.12.0",
|
|
93
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
94
|
+
"autoprefixer": "^10.4.23",
|
|
55
95
|
"babel-loader": "^8.2.3",
|
|
56
96
|
"babel-plugin-array-includes": "^2.0.3",
|
|
57
|
-
"babel-preset-env": "^1.7.0",
|
|
58
|
-
"babel-preset-es2015": "^6.24.1",
|
|
59
97
|
"babel-preset-minify": "^0.5.0",
|
|
60
|
-
"babel-preset-stage-0": "^6.24.1",
|
|
61
98
|
"css-loader": "^2.1.1",
|
|
62
99
|
"dotenv": "^16.0.3",
|
|
63
100
|
"eslint": "^9.12.0",
|
|
64
101
|
"form-data": "^4.0.0",
|
|
65
102
|
"gh-pages": "^2.0.1",
|
|
66
103
|
"highlight.js": "^10.4.1",
|
|
104
|
+
"isomorphic-fetch": "^3.0.0",
|
|
105
|
+
"jsdom": "^27.4.0",
|
|
67
106
|
"mini-css-extract-plugin": "^0.9.0",
|
|
68
107
|
"mobile-detect": "^1.4.3",
|
|
69
108
|
"prettier": "3.3.3",
|
|
@@ -72,6 +111,7 @@
|
|
|
72
111
|
"vite-plugin-dts": "^4.3.0",
|
|
73
112
|
"vite-plugin-html": "^3.2.2",
|
|
74
113
|
"vite-plugin-lib-inject-css": "^2.1.1",
|
|
114
|
+
"vitest": "^4.0.17",
|
|
75
115
|
"webpack": "^5.95.0",
|
|
76
116
|
"webpack-cli": "^5.0.1",
|
|
77
117
|
"webpack-dev-server": "^4.13.3"
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { CSSProperties, RefObject, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Autoplay behavior options
|
|
5
|
+
*/
|
|
6
|
+
export type AutoplayBehavior = 'spin-x' | 'spin-y' | 'spin-xy' | 'spin-yx';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Theme options for the viewer
|
|
10
|
+
*/
|
|
11
|
+
export type Theme = 'light' | 'dark';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Hotspot orientation
|
|
15
|
+
*/
|
|
16
|
+
export type HotspotOrientation = 'x' | 'y';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hotspot position
|
|
20
|
+
*/
|
|
21
|
+
export interface HotspotPosition {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hotspot configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface Hotspot {
|
|
30
|
+
id: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
orientation?: HotspotOrientation;
|
|
33
|
+
containerSize?: [number, number];
|
|
34
|
+
positions: Record<number, HotspotPosition>;
|
|
35
|
+
content?: string;
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Hint configuration
|
|
41
|
+
*/
|
|
42
|
+
export interface Hint {
|
|
43
|
+
text: string;
|
|
44
|
+
icon?: 'drag' | 'scroll' | 'pinch' | 'keys';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Spin event data
|
|
49
|
+
*/
|
|
50
|
+
export interface SpinEventData {
|
|
51
|
+
viewerId: string;
|
|
52
|
+
direction: 'left' | 'right' | 'up' | 'down';
|
|
53
|
+
activeImageX: number;
|
|
54
|
+
activeImageY: number;
|
|
55
|
+
amountX: number;
|
|
56
|
+
amountY: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Load event data
|
|
61
|
+
*/
|
|
62
|
+
export interface LoadEventData {
|
|
63
|
+
viewerId: string;
|
|
64
|
+
imagesX: number;
|
|
65
|
+
imagesY: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Zoom event data
|
|
70
|
+
*/
|
|
71
|
+
export interface ZoomEventData {
|
|
72
|
+
viewerId: string;
|
|
73
|
+
zoomLevel: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Error event data
|
|
78
|
+
*/
|
|
79
|
+
export interface ErrorEventData {
|
|
80
|
+
viewerId: string;
|
|
81
|
+
error: { message: string; url?: string };
|
|
82
|
+
errorCount: number;
|
|
83
|
+
totalImages: number;
|
|
84
|
+
errors: Array<{ message: string; url?: string }>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Base event data (common to all events)
|
|
89
|
+
*/
|
|
90
|
+
export interface BaseEventData {
|
|
91
|
+
viewerId: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* CI360 Configuration options
|
|
96
|
+
*/
|
|
97
|
+
export interface CI360Config {
|
|
98
|
+
folder?: string;
|
|
99
|
+
apiVersion?: string;
|
|
100
|
+
filenameX?: string;
|
|
101
|
+
filenameY?: string | null;
|
|
102
|
+
imageListX?: string | string[] | null;
|
|
103
|
+
imageListY?: string | string[] | null;
|
|
104
|
+
indexZeroBase?: number;
|
|
105
|
+
amountX?: number;
|
|
106
|
+
amountY?: number;
|
|
107
|
+
draggable?: boolean;
|
|
108
|
+
swipeable?: boolean;
|
|
109
|
+
keys?: boolean;
|
|
110
|
+
keysReverse?: boolean;
|
|
111
|
+
autoplay?: boolean;
|
|
112
|
+
autoplayBehavior?: AutoplayBehavior;
|
|
113
|
+
playOnce?: boolean;
|
|
114
|
+
speed?: number;
|
|
115
|
+
autoplayReverse?: boolean;
|
|
116
|
+
dragSpeed?: number;
|
|
117
|
+
dragReverse?: boolean;
|
|
118
|
+
stopAtEdges?: boolean;
|
|
119
|
+
inertia?: boolean;
|
|
120
|
+
fullscreen?: boolean;
|
|
121
|
+
magnifier?: number | null;
|
|
122
|
+
pointerZoom?: number;
|
|
123
|
+
pinchZoom?: boolean;
|
|
124
|
+
bottomCircle?: boolean;
|
|
125
|
+
bottomCircleOffset?: number;
|
|
126
|
+
initialIconShown?: boolean;
|
|
127
|
+
hide360Logo?: boolean;
|
|
128
|
+
logoSrc?: string;
|
|
129
|
+
imageInfo?: boolean;
|
|
130
|
+
hints?: boolean | Hint[];
|
|
131
|
+
theme?: Theme;
|
|
132
|
+
ciToken?: string | null;
|
|
133
|
+
ciFilters?: string | null;
|
|
134
|
+
ciTransformation?: string | null;
|
|
135
|
+
lazyload?: boolean;
|
|
136
|
+
hotspots?: Hotspot[] | null;
|
|
137
|
+
hotspotTimelineOnClick?: boolean;
|
|
138
|
+
onReady?: (data: BaseEventData) => void;
|
|
139
|
+
onLoad?: (data: LoadEventData) => void;
|
|
140
|
+
onSpin?: (data: SpinEventData) => void;
|
|
141
|
+
onAutoplayStart?: (data: BaseEventData) => void;
|
|
142
|
+
onAutoplayStop?: (data: BaseEventData) => void;
|
|
143
|
+
onFullscreenOpen?: (data: BaseEventData) => void;
|
|
144
|
+
onFullscreenClose?: (data: BaseEventData) => void;
|
|
145
|
+
onZoomIn?: (data: ZoomEventData) => void;
|
|
146
|
+
onZoomOut?: (data: BaseEventData) => void;
|
|
147
|
+
onDragStart?: (data: BaseEventData) => void;
|
|
148
|
+
onDragEnd?: (data: BaseEventData) => void;
|
|
149
|
+
onError?: (data: ErrorEventData) => void;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* CI360 Viewer Instance methods available from the native viewer
|
|
154
|
+
*/
|
|
155
|
+
export interface CI360ViewerInstance {
|
|
156
|
+
moveLeft: (stopAtEdges?: boolean, steps?: number) => void;
|
|
157
|
+
moveRight: (stopAtEdges?: boolean, steps?: number) => void;
|
|
158
|
+
moveTop: (stopAtEdges?: boolean, steps?: number) => void;
|
|
159
|
+
moveBottom: (stopAtEdges?: boolean, steps?: number) => void;
|
|
160
|
+
play: () => void;
|
|
161
|
+
stopAutoplay: () => void;
|
|
162
|
+
toggleZoom: (event?: MouseEvent) => void;
|
|
163
|
+
removeZoom: () => void;
|
|
164
|
+
animateToFrame: (frame: number, hotspotId?: string) => void;
|
|
165
|
+
destroy: () => void;
|
|
166
|
+
update: (config: Partial<CI360Config>) => void;
|
|
167
|
+
isReady: boolean;
|
|
168
|
+
activeImageX: number;
|
|
169
|
+
activeImageY: number;
|
|
170
|
+
amountX: number;
|
|
171
|
+
amountY: number;
|
|
172
|
+
isZoomed: boolean;
|
|
173
|
+
viewerConfig: CI360Config;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Props for the CI360Viewer React component
|
|
178
|
+
*/
|
|
179
|
+
export interface CI360ViewerProps extends CI360Config {
|
|
180
|
+
id?: string;
|
|
181
|
+
className?: string;
|
|
182
|
+
style?: CSSProperties;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Ref methods exposed by CI360Viewer component
|
|
187
|
+
*/
|
|
188
|
+
export interface CI360ViewerRef {
|
|
189
|
+
moveLeft: (steps?: number) => void;
|
|
190
|
+
moveRight: (steps?: number) => void;
|
|
191
|
+
moveTop: (steps?: number) => void;
|
|
192
|
+
moveBottom: (steps?: number) => void;
|
|
193
|
+
play: () => void;
|
|
194
|
+
stop: () => void;
|
|
195
|
+
zoomIn: () => void;
|
|
196
|
+
zoomOut: () => void;
|
|
197
|
+
goToFrame: (frame: number, hotspotId?: string) => void;
|
|
198
|
+
getViewer: () => CI360ViewerInstance | null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Return type for useCI360 hook
|
|
203
|
+
*/
|
|
204
|
+
export interface UseCI360Return {
|
|
205
|
+
viewer: CI360ViewerInstance | null;
|
|
206
|
+
isReady: boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Options for useCI360 hook
|
|
211
|
+
*/
|
|
212
|
+
export interface UseCI360Options extends CI360Config {
|
|
213
|
+
autoInit?: boolean;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* CI360Viewer React Component
|
|
218
|
+
*/
|
|
219
|
+
export declare const CI360Viewer: ForwardRefExoticComponent<CI360ViewerProps & RefAttributes<CI360ViewerRef>>;
|
|
220
|
+
export default CI360Viewer;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* useCI360 Hook for advanced control
|
|
224
|
+
*/
|
|
225
|
+
export declare function useCI360(
|
|
226
|
+
containerRef: RefObject<HTMLDivElement | null>,
|
|
227
|
+
config: UseCI360Options
|
|
228
|
+
): UseCI360Return;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
declare module CI360 {
|
|
2
|
+
export interface CI360ViewerConfig {
|
|
3
|
+
folder?: string; // Default: '/'
|
|
4
|
+
apiVersion?: string; // Default: 'v7'
|
|
5
|
+
filenameX?: string; // Default: 'image-{index}.jpg'
|
|
6
|
+
filenameY?: string | null; // Default: null
|
|
7
|
+
imageListX?: string | null; // Default: null
|
|
8
|
+
imageListY?: string | null; // Default: null
|
|
9
|
+
indexZeroBase?: number; // Default: 0
|
|
10
|
+
amountX?: number; // Default: 0
|
|
11
|
+
amountY?: number; // Default: 0
|
|
12
|
+
draggable?: boolean; // Default: true
|
|
13
|
+
swipeable?: boolean; // Default: true
|
|
14
|
+
keys?: boolean; // Default: false
|
|
15
|
+
keysReverse?: boolean; // Default: false
|
|
16
|
+
bottomCircleOffset?: number; // Default: 5
|
|
17
|
+
autoplay?: boolean; // Default: false
|
|
18
|
+
autoplayBehavior?: string; // Default: AUTOPLAY_BEHAVIOR.SPIN_X
|
|
19
|
+
playOnce?: boolean; // Default: false
|
|
20
|
+
speed?: number; // Default: 80
|
|
21
|
+
autoplayReverse?: boolean; // Default: false
|
|
22
|
+
fullscreen?: boolean; // Default: false
|
|
23
|
+
magnifier?: number | null; // Default: null
|
|
24
|
+
ciToken?: string | null; // Default: null
|
|
25
|
+
ciFilters?: string | null; // Default: null
|
|
26
|
+
ciTransformation?: string | null; // Default: null
|
|
27
|
+
lazyload?: boolean; // Default: true
|
|
28
|
+
dragSpeed?: number; // Default: 150
|
|
29
|
+
stopAtEdges?: boolean; // Default: false
|
|
30
|
+
pointerZoom?: number; // Default: 0
|
|
31
|
+
imageInfo?: boolean; // Changed from string to boolean; Default: false
|
|
32
|
+
initialIconShown?: boolean; // Default: true
|
|
33
|
+
bottomCircle?: boolean; // Default: true
|
|
34
|
+
hotspots?: any; // Default: null (type adjusted as needed)
|
|
35
|
+
dragReverse?: boolean; // Default: false
|
|
36
|
+
hide360Logo?: boolean; // Default: false (not documented)
|
|
37
|
+
logoSrc?: string; // Default: Scaleflex 360 logo URL
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Define the CI360Viewer class with the config type and constructor
|
|
41
|
+
export default class CI360Viewer {
|
|
42
|
+
constructor(container: HTMLElement | string, config?: CI360ViewerConfig, fullscreen?: boolean);
|
|
43
|
+
destroy(): void;
|
|
44
|
+
update(config: CI360ViewerConfig): void;
|
|
45
|
+
viewerConfig: CI360ViewerConfig;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Define the CI360 class
|
|
49
|
+
export class CI360 {
|
|
50
|
+
views: Map<string, CI360Viewer>;
|
|
51
|
+
instances: CI360Viewer[];
|
|
52
|
+
initAll: (className?: string) => void;
|
|
53
|
+
getInstances: () => CI360Viewer[];
|
|
54
|
+
init: (
|
|
55
|
+
container: HTMLElement | string,
|
|
56
|
+
config?: CI360ViewerConfig,
|
|
57
|
+
fullscreen?: boolean
|
|
58
|
+
) => CI360Viewer | undefined;
|
|
59
|
+
getViewById: (id: string) => CI360Viewer | undefined;
|
|
60
|
+
getViews: () => CI360Viewer[];
|
|
61
|
+
updateView: (id: string, config: CI360ViewerConfig) => CI360Viewer | undefined;
|
|
62
|
+
destroy: (id: string) => void;
|
|
63
|
+
destroyAll: () => void;
|
|
64
|
+
constructor();
|
|
65
|
+
}
|
|
66
|
+
}
|