@aixa-transformation/pptx-viewer 2.0.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +18 -0
  4. package/README.md +249 -0
  5. package/dist/GLTFLoader-CV33YWNT.js +2613 -0
  6. package/dist/GLTFLoader-FQJ2I67K.mjs +2611 -0
  7. package/dist/Model3DScene-5ODZLKJM.mjs +49 -0
  8. package/dist/Model3DScene-VLHFNN5B.js +51 -0
  9. package/dist/OrbitControls-HI6CI76Z.mjs +3 -0
  10. package/dist/OrbitControls-XGY7XEC6.js +12 -0
  11. package/dist/SmartArt3DScene-3FL5JELA.mjs +333 -0
  12. package/dist/SmartArt3DScene-7IZ3IJYV.js +335 -0
  13. package/dist/SurfaceChart3DScene-C6GQQQB7.mjs +77 -0
  14. package/dist/SurfaceChart3DScene-KHMGQAGP.js +79 -0
  15. package/dist/chunk-2TOLRBFU.js +27629 -0
  16. package/dist/chunk-2X72MOPZ.mjs +2796 -0
  17. package/dist/chunk-6DZX6EAA.mjs +33 -0
  18. package/dist/chunk-AD2CLKY6.js +92338 -0
  19. package/dist/chunk-CUUYYYC5.js +2800 -0
  20. package/dist/chunk-DAKELFNP.js +915 -0
  21. package/dist/chunk-F2HFXS2Z.mjs +19063 -0
  22. package/dist/chunk-F3LO2NKI.mjs +913 -0
  23. package/dist/chunk-HNI6JYAI.js +34591 -0
  24. package/dist/chunk-IKBO6CZC.js +2 -0
  25. package/dist/chunk-KVM4DBEU.mjs +91768 -0
  26. package/dist/chunk-MOEXMRVK.js +19220 -0
  27. package/dist/chunk-QGM4M3NI.js +37 -0
  28. package/dist/chunk-SQY54X47.js +43506 -0
  29. package/dist/chunk-T5U6P2JH.mjs +1 -0
  30. package/dist/chunk-TB5ZWNMX.mjs +34577 -0
  31. package/dist/chunk-W5V6CEFL.mjs +43064 -0
  32. package/dist/chunk-XAVVR6OX.mjs +27204 -0
  33. package/dist/chunk-Y6FQDUJU.js +1160 -0
  34. package/dist/chunk-YI3G35EC.mjs +1076 -0
  35. package/dist/dist-LQJHTLHL.mjs +2 -0
  36. package/dist/dist-NVA3FEUV.js +2275 -0
  37. package/dist/i18n.d.ts +2 -0
  38. package/dist/i18n.js +19 -0
  39. package/dist/i18n.mjs +2 -0
  40. package/dist/index.d.ts +44 -0
  41. package/dist/index.js +135 -0
  42. package/dist/index.mjs +6 -0
  43. package/dist/internals.d.ts +1 -0
  44. package/dist/internals.js +311 -0
  45. package/dist/internals.mjs +6 -0
  46. package/dist/pptx-viewer.css +2 -0
  47. package/dist/presentation.d.ts +1 -0
  48. package/dist/presentation.js +11 -0
  49. package/dist/presentation.mjs +2 -0
  50. package/dist/three.module-HOXVV2KF.mjs +2 -0
  51. package/dist/three.module-QSJWIYNI.js +1771 -0
  52. package/dist/viewer/index.d.ts +1 -0
  53. package/dist/viewer/index.js +76 -0
  54. package/dist/viewer/index.mjs +7 -0
  55. package/dist/y-webrtc-DFUKFWCA.mjs +4279 -0
  56. package/dist/y-webrtc-RRACJ6WX.js +4284 -0
  57. package/dist/y-websocket-T5R5YGVE.mjs +378 -0
  58. package/dist/y-websocket-WMSHYIGX.js +384 -0
  59. package/package.json +141 -0
@@ -0,0 +1,49 @@
1
+ import { mountModel3D } from './chunk-XAVVR6OX.mjs';
2
+ import './chunk-KVM4DBEU.mjs';
3
+ import './chunk-6DZX6EAA.mjs';
4
+ import { useRef, useEffect } from 'react';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ function Model3DScene({ modelUrl, interactive, width, height }) {
8
+ const containerRef = useRef(null);
9
+ const handleRef = useRef(null);
10
+ useEffect(() => {
11
+ const container = containerRef.current;
12
+ if (!container) {
13
+ return;
14
+ }
15
+ let disposed = false;
16
+ void mountModel3D(container, modelUrl, { width, height, interactive }).then((handle) => {
17
+ if (disposed) {
18
+ handle.dispose();
19
+ } else {
20
+ handleRef.current = handle;
21
+ }
22
+ return void 0;
23
+ });
24
+ return () => {
25
+ disposed = true;
26
+ handleRef.current?.dispose();
27
+ handleRef.current = null;
28
+ };
29
+ }, [modelUrl]);
30
+ useEffect(() => {
31
+ handleRef.current?.setInteractive(interactive);
32
+ }, [interactive]);
33
+ useEffect(() => {
34
+ handleRef.current?.resize(width, height);
35
+ }, [width, height]);
36
+ return /* @__PURE__ */ jsx(
37
+ "div",
38
+ {
39
+ ref: containerRef,
40
+ style: {
41
+ width,
42
+ height,
43
+ willChange: "transform"
44
+ }
45
+ }
46
+ );
47
+ }
48
+
49
+ export { Model3DScene as default };
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var chunk2TOLRBFU_js = require('./chunk-2TOLRBFU.js');
4
+ require('./chunk-AD2CLKY6.js');
5
+ require('./chunk-QGM4M3NI.js');
6
+ var react = require('react');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function Model3DScene({ modelUrl, interactive, width, height }) {
10
+ const containerRef = react.useRef(null);
11
+ const handleRef = react.useRef(null);
12
+ react.useEffect(() => {
13
+ const container = containerRef.current;
14
+ if (!container) {
15
+ return;
16
+ }
17
+ let disposed = false;
18
+ void chunk2TOLRBFU_js.mountModel3D(container, modelUrl, { width, height, interactive }).then((handle) => {
19
+ if (disposed) {
20
+ handle.dispose();
21
+ } else {
22
+ handleRef.current = handle;
23
+ }
24
+ return void 0;
25
+ });
26
+ return () => {
27
+ disposed = true;
28
+ handleRef.current?.dispose();
29
+ handleRef.current = null;
30
+ };
31
+ }, [modelUrl]);
32
+ react.useEffect(() => {
33
+ handleRef.current?.setInteractive(interactive);
34
+ }, [interactive]);
35
+ react.useEffect(() => {
36
+ handleRef.current?.resize(width, height);
37
+ }, [width, height]);
38
+ return /* @__PURE__ */ jsxRuntime.jsx(
39
+ "div",
40
+ {
41
+ ref: containerRef,
42
+ style: {
43
+ width,
44
+ height,
45
+ willChange: "transform"
46
+ }
47
+ }
48
+ );
49
+ }
50
+
51
+ module.exports = Model3DScene;
@@ -0,0 +1,3 @@
1
+ export { OrbitControls } from './chunk-F3LO2NKI.mjs';
2
+ import './chunk-W5V6CEFL.mjs';
3
+ import './chunk-6DZX6EAA.mjs';
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var chunkDAKELFNP_js = require('./chunk-DAKELFNP.js');
4
+ require('./chunk-SQY54X47.js');
5
+ require('./chunk-QGM4M3NI.js');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "OrbitControls", {
10
+ enumerable: true,
11
+ get: function () { return chunkDAKELFNP_js.OrbitControls; }
12
+ });
@@ -0,0 +1,333 @@
1
+ import { OrbitControls } from './chunk-F3LO2NKI.mjs';
2
+ import { WebGLRenderer, Scene, Color, PerspectiveCamera, AmbientLight, DirectionalLight, Group, MeshStandardMaterial, Mesh, EdgesGeometry, LineBasicMaterial, LineSegments, PlaneGeometry, MeshBasicMaterial, Euler, Vector3, BufferGeometry, Line, Shape, ExtrudeGeometry, CanvasTexture, SRGBColorSpace, LinearFilter, RepeatWrapping } from './chunk-W5V6CEFL.mjs';
3
+ import './chunk-6DZX6EAA.mjs';
4
+ import { useRef, useEffect } from 'react';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ // ../shared/dist/smartart-3d/index.mjs
8
+ var SUPERSAMPLE = 4;
9
+ var FILL = 0.86;
10
+ function wrapLines(ctx, text, maxWidth) {
11
+ const words = text.split(/\s+/u).filter(Boolean);
12
+ if (words.length === 0) {
13
+ return [];
14
+ }
15
+ const lines = [];
16
+ let line = words[0];
17
+ for (let i = 1; i < words.length; i++) {
18
+ const candidate = `${line} ${words[i]}`;
19
+ if (ctx.measureText(candidate).width <= maxWidth) {
20
+ line = candidate;
21
+ } else {
22
+ lines.push(line);
23
+ line = words[i];
24
+ }
25
+ }
26
+ lines.push(line);
27
+ return lines;
28
+ }
29
+ function makeTextTexture(text, color, fontSize, footW, footH) {
30
+ if (typeof document === "undefined" || !text.trim() || footW <= 0 || footH <= 0) {
31
+ return null;
32
+ }
33
+ const worldWidth = footW * FILL;
34
+ const worldHeight = footH * FILL;
35
+ const canvas = document.createElement("canvas");
36
+ canvas.width = Math.max(8, Math.round(worldWidth * SUPERSAMPLE));
37
+ canvas.height = Math.max(8, Math.round(worldHeight * SUPERSAMPLE));
38
+ const ctx = canvas.getContext("2d");
39
+ if (!ctx) {
40
+ return null;
41
+ }
42
+ const family = "system-ui, -apple-system, Segoe UI, Roboto, sans-serif";
43
+ const maxTextWidth = canvas.width * 0.94;
44
+ let px = Math.max(6, fontSize) * SUPERSAMPLE;
45
+ let lines = [];
46
+ for (let attempt = 0; attempt < 12; attempt++) {
47
+ ctx.font = `600 ${px}px ${family}`;
48
+ lines = wrapLines(ctx, text, maxTextWidth);
49
+ const lineHeight2 = px * 1.2;
50
+ if (lines.length * lineHeight2 <= canvas.height * 0.96 || px <= 6 * SUPERSAMPLE) {
51
+ break;
52
+ }
53
+ px *= 0.88;
54
+ }
55
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
56
+ ctx.fillStyle = color;
57
+ ctx.textAlign = "center";
58
+ ctx.textBaseline = "middle";
59
+ ctx.font = `600 ${px}px ${family}`;
60
+ const lineHeight = px * 1.2;
61
+ const blockHeight = lines.length * lineHeight;
62
+ const startY = canvas.height / 2 - blockHeight / 2 + lineHeight / 2;
63
+ for (let i = 0; i < lines.length; i++) {
64
+ ctx.fillText(lines[i], canvas.width / 2, startY + i * lineHeight);
65
+ }
66
+ const texture = new CanvasTexture(canvas);
67
+ texture.colorSpace = SRGBColorSpace;
68
+ texture.minFilter = LinearFilter;
69
+ texture.magFilter = LinearFilter;
70
+ texture.flipY = false;
71
+ texture.premultiplyAlpha = false;
72
+ texture.wrapT = RepeatWrapping;
73
+ texture.repeat.set(1, -1);
74
+ texture.offset.set(0, 1);
75
+ texture.needsUpdate = true;
76
+ return { texture, worldWidth, worldHeight };
77
+ }
78
+ function extrudeGeometry(m) {
79
+ const shape = new Shape();
80
+ m.outline.forEach((p, i) => {
81
+ if (i === 0) {
82
+ shape.moveTo(p.x, p.y);
83
+ } else {
84
+ shape.lineTo(p.x, p.y);
85
+ }
86
+ });
87
+ shape.closePath();
88
+ const bevelEnabled = m.bevel > 0;
89
+ return new ExtrudeGeometry(shape, {
90
+ depth: m.depth,
91
+ bevelEnabled,
92
+ bevelThickness: m.bevel,
93
+ bevelSize: m.bevel,
94
+ bevelSegments: 2,
95
+ curveSegments: m.rounded ? 24 : 1,
96
+ steps: 1
97
+ });
98
+ }
99
+ function addBlock(group, disposables, m) {
100
+ const geo = extrudeGeometry(m);
101
+ const material = new MeshStandardMaterial({
102
+ color: new Color(m.fill),
103
+ metalness: 0.12,
104
+ roughness: 0.52,
105
+ transparent: m.opacity < 1,
106
+ opacity: m.opacity
107
+ });
108
+ const mesh = new Mesh(geo, material);
109
+ mesh.position.set(m.position.x, m.position.y, m.position.z);
110
+ mesh.rotation.set(m.rotation.x, m.rotation.y, m.rotation.z);
111
+ group.add(mesh);
112
+ disposables.push(geo, material);
113
+ if (m.strokeWidth > 0) {
114
+ const edges = new EdgesGeometry(geo, 30);
115
+ const lineMaterial = new LineBasicMaterial({ color: new Color(m.stroke) });
116
+ const line = new LineSegments(edges, lineMaterial);
117
+ line.position.copy(mesh.position);
118
+ line.rotation.copy(mesh.rotation);
119
+ group.add(line);
120
+ disposables.push(edges, lineMaterial);
121
+ }
122
+ return geo;
123
+ }
124
+ function addLabel(group, disposables, m) {
125
+ if (!m.text) {
126
+ return;
127
+ }
128
+ const tex = makeTextTexture(m.text, m.textColor, m.fontSize, m.halfWidth * 2, m.halfHeight * 2);
129
+ if (!tex) {
130
+ return;
131
+ }
132
+ const planeGeo = new PlaneGeometry(tex.worldWidth, tex.worldHeight);
133
+ const planeMaterial = new MeshBasicMaterial({
134
+ map: tex.texture,
135
+ transparent: true,
136
+ depthWrite: false
137
+ });
138
+ const plane = new Mesh(planeGeo, planeMaterial);
139
+ const euler = new Euler(m.rotation.x, m.rotation.y, m.rotation.z);
140
+ const offset = new Vector3(0, 0, m.depth + m.bevel + 0.4).applyEuler(euler);
141
+ plane.position.set(m.position.x + offset.x, m.position.y + offset.y, m.position.z + offset.z);
142
+ plane.rotation.copy(euler);
143
+ group.add(plane);
144
+ disposables.push(planeGeo, planeMaterial, tex.texture);
145
+ }
146
+ function addConnectors(group, disposables, model) {
147
+ for (const c of model.connectors) {
148
+ if (c.points.length < 2) {
149
+ continue;
150
+ }
151
+ const geo = new BufferGeometry().setFromPoints(c.points.map((p) => new Vector3(p.x, p.y, p.z)));
152
+ const material = new LineBasicMaterial({
153
+ color: new Color(c.color),
154
+ transparent: true,
155
+ opacity: 0.7
156
+ });
157
+ group.add(new Line(geo, material));
158
+ disposables.push(geo, material);
159
+ }
160
+ }
161
+ function buildMeshGroup(model) {
162
+ const group = new Group();
163
+ const disposables = [];
164
+ for (const m of model.meshes) {
165
+ addBlock(group, disposables, m);
166
+ addLabel(group, disposables, m);
167
+ }
168
+ addConnectors(group, disposables, model);
169
+ return {
170
+ group,
171
+ dispose() {
172
+ for (const d of disposables) {
173
+ d.dispose();
174
+ }
175
+ }
176
+ };
177
+ }
178
+ var FOV = 42;
179
+ function contentSphere(model) {
180
+ let minX = Infinity;
181
+ let minY = Infinity;
182
+ let minZ = Infinity;
183
+ let maxX = -Infinity;
184
+ let maxY = -Infinity;
185
+ let maxZ = -Infinity;
186
+ const expand = (x, y, z, r) => {
187
+ minX = Math.min(minX, x - r);
188
+ minY = Math.min(minY, y - r);
189
+ minZ = Math.min(minZ, z - r);
190
+ maxX = Math.max(maxX, x + r);
191
+ maxY = Math.max(maxY, y + r);
192
+ maxZ = Math.max(maxZ, z + r);
193
+ };
194
+ for (const m of model.meshes) {
195
+ const r = Math.max(m.halfWidth, m.halfHeight) + m.depth + m.bevel;
196
+ expand(m.position.x, m.position.y, m.position.z, r);
197
+ }
198
+ for (const c of model.connectors) {
199
+ for (const p of c.points) {
200
+ expand(p.x, p.y, p.z, 1);
201
+ }
202
+ }
203
+ if (!Number.isFinite(minX)) {
204
+ const fallback = Math.max(model.bounds.width, model.bounds.height) / 2 || 1;
205
+ return { cx: 0, cy: 0, cz: 0, radius: fallback };
206
+ }
207
+ return {
208
+ cx: (minX + maxX) / 2,
209
+ cy: (minY + maxY) / 2,
210
+ cz: (minZ + maxZ) / 2,
211
+ radius: 0.5 * Math.hypot(maxX - minX, maxY - minY, maxZ - minZ) || 1
212
+ };
213
+ }
214
+ function frameDistance(radius, aspect) {
215
+ const vFov = FOV * Math.PI / 180;
216
+ const hFov = 2 * Math.atan(Math.tan(vFov / 2) * aspect);
217
+ const minFov = Math.min(vFov, hFov);
218
+ return radius / Math.sin(minFov / 2) * 1.1;
219
+ }
220
+ function mountSmartArt3D(canvas, model, width, height, options = {}) {
221
+ const renderer = new WebGLRenderer({ canvas, antialias: true, alpha: !options.background });
222
+ renderer.setPixelRatio(
223
+ Math.min(
224
+ typeof window === "undefined" ? 1 : window.devicePixelRatio || 1,
225
+ options.maxPixelRatio ?? 2
226
+ )
227
+ );
228
+ renderer.setSize(width, height, false);
229
+ const scene = new Scene();
230
+ if (options.background) {
231
+ scene.background = new Color(options.background);
232
+ }
233
+ const { cx, cy, cz, radius } = contentSphere(model);
234
+ const aspect = width / Math.max(1, height);
235
+ const dist = frameDistance(radius, aspect);
236
+ const camera = new PerspectiveCamera(FOV, aspect, 0.1, dist * 8 + radius * 4);
237
+ camera.position.set(cx + radius * 0.25, cy + radius * 0.3, cz + dist);
238
+ camera.lookAt(cx, cy, cz);
239
+ scene.add(new AmbientLight(16777215, 0.62));
240
+ const key = new DirectionalLight(16777215, 0.95);
241
+ key.position.set(cx + radius, cy + radius * 1.4, cz + dist);
242
+ scene.add(key);
243
+ const fill = new DirectionalLight(16777215, 0.3);
244
+ fill.position.set(cx - radius, cy - radius * 0.6, cz + dist * 0.6);
245
+ scene.add(fill);
246
+ const built = buildMeshGroup(model);
247
+ scene.add(built.group);
248
+ let controls = null;
249
+ const enableControls = (on) => {
250
+ if (on && !controls) {
251
+ controls = new OrbitControls(camera, canvas);
252
+ controls.enablePan = false;
253
+ controls.target.set(cx, cy, cz);
254
+ controls.minDistance = dist * 0.4;
255
+ controls.maxDistance = dist * 3;
256
+ controls.update();
257
+ } else if (!on && controls) {
258
+ controls.dispose();
259
+ controls = null;
260
+ }
261
+ if (controls) {
262
+ controls.autoRotate = Boolean(options.autoRotate);
263
+ controls.autoRotateSpeed = 1.2;
264
+ }
265
+ };
266
+ enableControls(Boolean(options.interactive));
267
+ let frame = 0;
268
+ let disposed = false;
269
+ const renderLoop = () => {
270
+ if (disposed) {
271
+ return;
272
+ }
273
+ frame = requestAnimationFrame(renderLoop);
274
+ controls?.update();
275
+ renderer.render(scene, camera);
276
+ };
277
+ frame = requestAnimationFrame(renderLoop);
278
+ return {
279
+ resize(w, h) {
280
+ camera.aspect = w / Math.max(1, h);
281
+ camera.updateProjectionMatrix();
282
+ renderer.setSize(w, h, false);
283
+ },
284
+ setInteractive(on) {
285
+ enableControls(on);
286
+ },
287
+ dispose() {
288
+ disposed = true;
289
+ cancelAnimationFrame(frame);
290
+ controls?.dispose();
291
+ built.dispose();
292
+ renderer.dispose();
293
+ }
294
+ };
295
+ }
296
+ function SmartArt3DScene({
297
+ model,
298
+ width,
299
+ height,
300
+ interactive
301
+ }) {
302
+ const canvasRef = useRef(null);
303
+ const handleRef = useRef(null);
304
+ useEffect(() => {
305
+ const canvas = canvasRef.current;
306
+ if (!canvas) {
307
+ return;
308
+ }
309
+ const handle = mountSmartArt3D(canvas, model, width, height, {
310
+ interactive
311
+ });
312
+ handleRef.current = handle;
313
+ return () => {
314
+ handle.dispose();
315
+ handleRef.current = null;
316
+ };
317
+ }, [model]);
318
+ useEffect(() => {
319
+ handleRef.current?.resize(width, height);
320
+ }, [width, height]);
321
+ useEffect(() => {
322
+ handleRef.current?.setInteractive(interactive);
323
+ }, [interactive]);
324
+ return /* @__PURE__ */ jsx(
325
+ "canvas",
326
+ {
327
+ ref: canvasRef,
328
+ style: { width, height, display: "block", pointerEvents: interactive ? "auto" : "none" }
329
+ }
330
+ );
331
+ }
332
+
333
+ export { SmartArt3DScene as default };