animot-presenter 0.1.0 → 0.1.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 +29 -0
- package/dist/AnimotPresenter.svelte +9 -7
- package/dist/cdn/animot-presenter.css +1 -1
- package/dist/cdn/animot-presenter.esm.js +2362 -2335
- package/dist/cdn/animot-presenter.min.js +8 -8
- package/dist/{element.d.ts → element.svelte.d.ts} +4 -3
- package/dist/{element.js → element.svelte.js} +23 -27
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -3
- package/package.json +6 -5
|
@@ -6,6 +6,8 @@ declare class AnimotPresenterElement extends HTMLElement {
|
|
|
6
6
|
private _data;
|
|
7
7
|
private _onslidechange;
|
|
8
8
|
private _oncomplete;
|
|
9
|
+
private _mounted;
|
|
10
|
+
private _props;
|
|
9
11
|
set data(value: AnimotProject | null);
|
|
10
12
|
get data(): AnimotProject | null;
|
|
11
13
|
set onslidechange(fn: ((index: number, total: number) => void) | null);
|
|
@@ -13,11 +15,10 @@ declare class AnimotPresenterElement extends HTMLElement {
|
|
|
13
15
|
connectedCallback(): void;
|
|
14
16
|
disconnectedCallback(): void;
|
|
15
17
|
attributeChangedCallback(): void;
|
|
16
|
-
private
|
|
18
|
+
private _buildProps;
|
|
19
|
+
private _updateProps;
|
|
17
20
|
private _mount;
|
|
18
21
|
private _unmount;
|
|
19
|
-
private _remount;
|
|
20
|
-
goto(index: number): void;
|
|
21
22
|
next(): void;
|
|
22
23
|
prev(): void;
|
|
23
24
|
}
|
|
@@ -7,7 +7,6 @@ import AnimotPresenter from './AnimotPresenter.svelte';
|
|
|
7
7
|
// Inject floating animation CSS into the document (once)
|
|
8
8
|
import './styles/presenter.css';
|
|
9
9
|
const BOOLEAN_ATTRS = new Set(['autoplay', 'loop', 'controls', 'arrows', 'progress', 'keyboard']);
|
|
10
|
-
const NUMBER_ATTRS = new Set(['duration', 'start-slide']);
|
|
11
10
|
class AnimotPresenterElement extends HTMLElement {
|
|
12
11
|
static get observedAttributes() {
|
|
13
12
|
return ['src', 'autoplay', 'loop', 'controls', 'arrows', 'progress', 'keyboard', 'duration', 'start-slide'];
|
|
@@ -16,56 +15,58 @@ class AnimotPresenterElement extends HTMLElement {
|
|
|
16
15
|
_data = null;
|
|
17
16
|
_onslidechange = null;
|
|
18
17
|
_oncomplete = null;
|
|
19
|
-
|
|
18
|
+
_mounted = false;
|
|
19
|
+
// Reactive props object that Svelte reads from
|
|
20
|
+
_props = $state({});
|
|
20
21
|
set data(value) {
|
|
21
22
|
this._data = value;
|
|
22
|
-
this.
|
|
23
|
+
this._updateProps();
|
|
23
24
|
}
|
|
24
25
|
get data() {
|
|
25
26
|
return this._data;
|
|
26
27
|
}
|
|
27
28
|
set onslidechange(fn) {
|
|
28
29
|
this._onslidechange = fn;
|
|
29
|
-
this.
|
|
30
|
+
this._updateProps();
|
|
30
31
|
}
|
|
31
32
|
set oncomplete(fn) {
|
|
32
33
|
this._oncomplete = fn;
|
|
33
|
-
this.
|
|
34
|
+
this._updateProps();
|
|
34
35
|
}
|
|
35
36
|
connectedCallback() {
|
|
37
|
+
this._mounted = true;
|
|
36
38
|
this._mount();
|
|
37
39
|
}
|
|
38
40
|
disconnectedCallback() {
|
|
41
|
+
this._mounted = false;
|
|
39
42
|
this._unmount();
|
|
40
43
|
}
|
|
41
44
|
attributeChangedCallback() {
|
|
42
|
-
|
|
45
|
+
// Only update props if already mounted — don't remount
|
|
46
|
+
if (this._mounted && this._component) {
|
|
47
|
+
this._updateProps();
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
|
-
|
|
50
|
+
_buildProps() {
|
|
45
51
|
const props = {};
|
|
46
|
-
// String attributes
|
|
47
52
|
const src = this.getAttribute('src');
|
|
48
53
|
if (src)
|
|
49
54
|
props.src = src;
|
|
50
|
-
// Boolean attributes (presence = true)
|
|
51
55
|
for (const attr of BOOLEAN_ATTRS) {
|
|
52
56
|
props[attr] = this.hasAttribute(attr);
|
|
53
57
|
}
|
|
54
|
-
// Number attributes
|
|
55
58
|
const duration = this.getAttribute('duration');
|
|
56
59
|
if (duration)
|
|
57
60
|
props.duration = Number(duration);
|
|
58
61
|
const startSlide = this.getAttribute('start-slide');
|
|
59
62
|
if (startSlide)
|
|
60
63
|
props.startSlide = Number(startSlide);
|
|
61
|
-
// Programmatic props
|
|
62
64
|
if (this._data)
|
|
63
65
|
props.data = this._data;
|
|
64
66
|
if (this._onslidechange) {
|
|
65
67
|
props.onslidechange = this._onslidechange;
|
|
66
68
|
}
|
|
67
69
|
else {
|
|
68
|
-
// Dispatch custom event for vanilla JS listeners
|
|
69
70
|
props.onslidechange = (index, total) => {
|
|
70
71
|
this.dispatchEvent(new CustomEvent('slidechange', { detail: { index, total }, bubbles: true }));
|
|
71
72
|
};
|
|
@@ -80,16 +81,24 @@ class AnimotPresenterElement extends HTMLElement {
|
|
|
80
81
|
}
|
|
81
82
|
return props;
|
|
82
83
|
}
|
|
84
|
+
_updateProps() {
|
|
85
|
+
const newProps = this._buildProps();
|
|
86
|
+
// Update the reactive props object in place so Svelte picks up changes
|
|
87
|
+
for (const key of Object.keys(newProps)) {
|
|
88
|
+
this._props[key] = newProps[key];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
83
91
|
_mount() {
|
|
84
92
|
if (this._component)
|
|
85
93
|
return;
|
|
86
|
-
// Ensure the element has dimensions
|
|
87
94
|
if (!this.style.display) {
|
|
88
95
|
this.style.display = 'block';
|
|
89
96
|
}
|
|
97
|
+
// Build initial props
|
|
98
|
+
Object.assign(this._props, this._buildProps());
|
|
90
99
|
this._component = mount(AnimotPresenter, {
|
|
91
100
|
target: this,
|
|
92
|
-
props: this.
|
|
101
|
+
props: this._props
|
|
93
102
|
});
|
|
94
103
|
}
|
|
95
104
|
_unmount() {
|
|
@@ -98,18 +107,6 @@ class AnimotPresenterElement extends HTMLElement {
|
|
|
98
107
|
this._component = null;
|
|
99
108
|
}
|
|
100
109
|
}
|
|
101
|
-
_remount() {
|
|
102
|
-
if (!this.isConnected)
|
|
103
|
-
return;
|
|
104
|
-
this._unmount();
|
|
105
|
-
this._mount();
|
|
106
|
-
}
|
|
107
|
-
// Public methods that proxy to the Svelte component
|
|
108
|
-
goto(index) {
|
|
109
|
-
const btn = this.querySelector('.animot-controls button');
|
|
110
|
-
// Fire a custom event the component can listen to
|
|
111
|
-
this.dispatchEvent(new CustomEvent('animot-goto', { detail: { index } }));
|
|
112
|
-
}
|
|
113
110
|
next() {
|
|
114
111
|
const nextBtn = this.querySelectorAll('.animot-controls button')[2];
|
|
115
112
|
if (nextBtn && !nextBtn.disabled)
|
|
@@ -121,7 +118,6 @@ class AnimotPresenterElement extends HTMLElement {
|
|
|
121
118
|
prevBtn.click();
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
|
-
// Register the custom element
|
|
125
121
|
if (typeof customElements !== 'undefined' && !customElements.get('animot-presenter')) {
|
|
126
122
|
customElements.define('animot-presenter', AnimotPresenterElement);
|
|
127
123
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { default as AnimotPresenter } from './AnimotPresenter.svelte';
|
|
2
2
|
export type { AnimotProject, AnimotPresenterProps, Slide, SlideCanvas, CanvasElement, CanvasBackground, TransitionConfig, TransitionType, ProjectSettings, BaseElement, CodeElement, TextElement, ArrowElement, ImageElement, ShapeElement, CounterElement, ChartElement, IconElement, ElementAnimationConfig, FloatingAnimationConfig, ParticlesConfig, ConfettiConfig } from './types';
|
|
3
|
-
export { AnimotPresenterElement } from './element';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as AnimotPresenter } from './AnimotPresenter.svelte';
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
export { AnimotPresenterElement } from './element';
|
|
2
|
+
// Web component registration is in a separate entry point: 'animot-presenter/element'
|
|
3
|
+
// Do NOT re-export from here — it extends HTMLElement which breaks SSR
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "animot-presenter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Embed animated presentations anywhere. Works with vanilla JS, React, Vue, Angular, Svelte, and any frontend framework. Morphing animations, code highlighting, charts, particles, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
7
|
-
"main": "./dist/cdn/animot-presenter.min.js",
|
|
8
|
-
"module": "./dist/cdn/animot-presenter.esm.js",
|
|
9
7
|
"types": "./dist/index.d.ts",
|
|
10
8
|
"exports": {
|
|
11
9
|
".": {
|
|
12
10
|
"svelte": "./dist/index.js",
|
|
13
11
|
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./element": {
|
|
14
15
|
"import": "./dist/cdn/animot-presenter.esm.js",
|
|
15
16
|
"require": "./dist/cdn/animot-presenter.min.js"
|
|
16
17
|
},
|
|
17
|
-
"./
|
|
18
|
+
"./cdn": {
|
|
18
19
|
"import": "./dist/cdn/animot-presenter.esm.js",
|
|
19
20
|
"require": "./dist/cdn/animot-presenter.min.js"
|
|
20
21
|
},
|
|
@@ -78,6 +79,6 @@
|
|
|
78
79
|
"license": "BUSL-1.1",
|
|
79
80
|
"repository": {
|
|
80
81
|
"type": "git",
|
|
81
|
-
"url": "https://github.com/
|
|
82
|
+
"url": "https://github.com/beeblock/animot-presenter"
|
|
82
83
|
}
|
|
83
84
|
}
|