@lisergia/core 23.0.1 → 25.0.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/dist/Page.js ADDED
@@ -0,0 +1,133 @@
1
+ import Lenis from 'lenis';
2
+ import { makeObservable, observable } from 'mobx';
3
+ import Tempus from 'tempus';
4
+ import { Component } from './Component.js';
5
+ export class Page extends Component {
6
+ datasets = [];
7
+ scroll = 0;
8
+ scrollEnabled = true;
9
+ scrollOptions = {};
10
+ constructor({ application, classes, datasets, element, elements, scrollEnabled = true, scrollOptions = {}, }) {
11
+ super({
12
+ autoMount: false,
13
+ autoListeners: false,
14
+ classes,
15
+ element,
16
+ elements,
17
+ });
18
+ this.application = application;
19
+ this.datasets = datasets;
20
+ this.scrollEnabled = scrollEnabled;
21
+ this.scrollOptions = scrollOptions;
22
+ makeObservable(this, {
23
+ element: observable,
24
+ elements: observable,
25
+ components: observable,
26
+ scroll: observable,
27
+ });
28
+ }
29
+ create() {
30
+ super.create();
31
+ this.createResizeObserver();
32
+ this.createComponents();
33
+ this.createScroll();
34
+ this.addEventListeners();
35
+ }
36
+ createResizeObserver() {
37
+ this.resizeObserver = new ResizeObserver(() => {
38
+ this.onResize();
39
+ });
40
+ this.resizeObserver.observe(this.elements.wrapper);
41
+ }
42
+ destroyResizeObserver() {
43
+ this.resizeObserver.disconnect();
44
+ }
45
+ //
46
+ // Components.
47
+ //
48
+ components = new Set();
49
+ createComponents() {
50
+ this.datasets.forEach(({ component: Component, selector }) => {
51
+ const elements = this.element.querySelectorAll(selector);
52
+ const components = Array.from(elements).map((element) => {
53
+ const component = new Component({
54
+ application: this.application,
55
+ element: element,
56
+ });
57
+ return component;
58
+ });
59
+ components.forEach((component) => {
60
+ this.application.addComponent(component);
61
+ this.components.add(component);
62
+ });
63
+ });
64
+ }
65
+ destroyComponents() {
66
+ this.components.forEach((component) => {
67
+ this.application.removeComponent(component);
68
+ });
69
+ this.components.clear();
70
+ }
71
+ createScroll() {
72
+ if (!this.scrollEnabled) {
73
+ this.element.addEventListener('scroll', this.onScrollFallback);
74
+ return;
75
+ }
76
+ this.lenis = new Lenis({
77
+ content: this.elements.wrapper,
78
+ wrapper: this.element,
79
+ ...this.scrollOptions,
80
+ });
81
+ this.lenis.on('scroll', this.onLenisScroll);
82
+ }
83
+ onLenisScroll(event) {
84
+ this.onScroll(event.scroll);
85
+ this.emitter.emit('scroll', event);
86
+ }
87
+ destroyScroll() {
88
+ if (!this.scrollEnabled) {
89
+ this.element.removeEventListener('scroll', this.onScrollFallback);
90
+ return;
91
+ }
92
+ this.lenis.off('scroll', this.onLenisScroll);
93
+ this.lenis?.destroy();
94
+ this.lenis = undefined;
95
+ }
96
+ //
97
+ // Events.
98
+ //
99
+ onResize() {
100
+ this.lenis?.resize();
101
+ }
102
+ onRAF({ time }) {
103
+ this.lenis?.raf(time);
104
+ }
105
+ onScroll(scroll) {
106
+ this.scroll = scroll;
107
+ }
108
+ onScrollFallback() {
109
+ this.scroll = this.element.scrollTop;
110
+ this.emitter.emit('scroll', { scroll: this.scroll });
111
+ }
112
+ //
113
+ // Events.
114
+ //
115
+ addEventListeners() {
116
+ super.addEventListeners();
117
+ this.unsubscribeRaf = Tempus.add(this.onRAF);
118
+ }
119
+ removeEventListeners() {
120
+ super.removeEventListeners();
121
+ this.unsubscribeRaf?.();
122
+ this.unsubscribeRaf = undefined;
123
+ }
124
+ //
125
+ // Destroy.
126
+ //
127
+ destroy() {
128
+ this.destroyResizeObserver();
129
+ this.destroyComponents();
130
+ this.destroyScroll();
131
+ super.destroy();
132
+ }
133
+ }
@@ -0,0 +1,8 @@
1
+ export * from './App.js';
2
+ export * from './Component.js';
3
+ export * from './EventEmitter.js';
4
+ export * from './Link.js';
5
+ export * from './Links.js';
6
+ export * from './Page.js';
7
+ import Tempus from 'tempus';
8
+ export { Tempus };
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './App.js';
2
+ export * from './Component.js';
3
+ export * from './EventEmitter.js';
4
+ export * from './Link.js';
5
+ export * from './Links.js';
6
+ export * from './Page.js';
7
+ import Tempus from 'tempus';
8
+ export { Tempus };
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "@lisergia/core",
3
- "version": "23.0.1",
3
+ "version": "25.0.0",
4
+ "files": [
5
+ "dist"
6
+ ],
4
7
  "main": "./dist/index.js",
5
8
  "types": "./dist/index.d.ts",
6
9
  "type": "module",
7
10
  "scripts": {
8
- "build": "tsup src/index.ts --format cjs,esm --dts",
9
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch"
11
+ "build": "tsc --build --clean && tsc --build",
12
+ "dev": "tsc --build --watch"
10
13
  },
11
14
  "dependencies": {
12
- "@lisergia/config-tsconfig": "23.0.0",
15
+ "@lisergia/config-tsconfig": "25.0.0",
13
16
  "auto-bind": "^5.0.1",
14
- "gsap": "^3.13.0",
15
- "lenis": "^1.3.1",
16
- "mobx": "^6.13.7",
17
- "nanoevents": "^9.1.0",
18
- "tempus": "^1.0.0-dev.10",
19
- "tsup": "^8.5.0"
17
+ "lenis": "^1.3.26",
18
+ "mobx": "^7.0.3",
19
+ "nanoevents": "^10.0.0",
20
+ "tempus": "^1.0.0"
20
21
  }
21
22
  }
package/CHANGELOG.md DELETED
@@ -1,254 +0,0 @@
1
- # @lisergia/core
2
-
3
- ## 23.0.0
4
-
5
- ### Major Changes
6
-
7
- - Add IS_LINKS_ENABLED flag.
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies
12
- - @lisergia/config-tsconfig@23.0.0
13
-
14
- ## 22.0.0
15
-
16
- ### Major Changes
17
-
18
- - Make sure Viewport unsubscribes events.
19
-
20
- ### Patch Changes
21
-
22
- - Updated dependencies
23
- - @lisergia/config-tsconfig@22.0.0
24
-
25
- ## 21.0.0
26
-
27
- ### Major Changes
28
-
29
- - Cleanup GSAP and Lenis events.
30
-
31
- ### Patch Changes
32
-
33
- - Updated dependencies
34
- - @lisergia/config-tsconfig@21.0.0
35
-
36
- ## 20.0.0
37
-
38
- ### Major Changes
39
-
40
- - Delete Map entries.
41
-
42
- ### Patch Changes
43
-
44
- - Updated dependencies
45
- - @lisergia/config-tsconfig@20.0.0
46
-
47
- ## 19.0.0
48
-
49
- ### Major Changes
50
-
51
- - Cleanup elements from Component on destroy.
52
-
53
- ### Patch Changes
54
-
55
- - Updated dependencies
56
- - @lisergia/config-tsconfig@19.0.0
57
-
58
- ## 18.0.0
59
-
60
- ### Major Changes
61
-
62
- - Fix memory leak from DOMParser.
63
-
64
- ### Patch Changes
65
-
66
- - Updated dependencies
67
- - @lisergia/config-tsconfig@18.0.0
68
-
69
- ## 17.0.0
70
-
71
- ### Major Changes
72
-
73
- - Fix bug with pushState.
74
-
75
- ### Patch Changes
76
-
77
- - Updated dependencies
78
- - @lisergia/config-tsconfig@17.0.0
79
-
80
- ## 16.0.0
81
-
82
- ### Major Changes
83
-
84
- - Update routing popState logic.
85
-
86
- ### Patch Changes
87
-
88
- - Updated dependencies
89
- - @lisergia/config-tsconfig@16.0.0
90
-
91
- ## 15.0.0
92
-
93
- ### Major Changes
94
-
95
- - Fix Link class URL redirect and build from Changesets.
96
-
97
- ### Patch Changes
98
-
99
- - Updated dependencies
100
- - @lisergia/config-tsconfig@15.0.0
101
-
102
- ## 14.0.0
103
-
104
- ### Major Changes
105
-
106
- - Avoid route to contain pathname.
107
-
108
- ### Patch Changes
109
-
110
- - Updated dependencies
111
- - @lisergia/config-tsconfig@14.0.0
112
-
113
- ## 13.0.0
114
-
115
- ### Major Changes
116
-
117
- - Add missing ScrollTrigger dependency.
118
-
119
- ### Patch Changes
120
-
121
- - Updated dependencies
122
- - @lisergia/config-tsconfig@13.0.0
123
-
124
- ## 12.0.0
125
-
126
- ### Major Changes
127
-
128
- - Fix hashchange and popstate conflict.
129
-
130
- ### Patch Changes
131
-
132
- - Updated dependencies
133
- - @lisergia/config-tsconfig@12.0.0
134
-
135
- ## 11.0.0
136
-
137
- ### Major Changes
138
-
139
- - Add GSAP with lagSmoothing fix.
140
-
141
- ### Patch Changes
142
-
143
- - Updated dependencies
144
- - @lisergia/config-tsconfig@11.0.0
145
-
146
- ## 10.0.0
147
-
148
- ### Major Changes
149
-
150
- - Update ESLint configuration with sort.
151
-
152
- ### Patch Changes
153
-
154
- - Updated dependencies
155
- - @lisergia/config-tsconfig@10.0.0
156
-
157
- ## 9.0.0
158
-
159
- ### Major Changes
160
-
161
- - Update Prettier configuration.
162
-
163
- ### Patch Changes
164
-
165
- - Updated dependencies
166
- - @lisergia/config-tsconfig@9.0.0
167
-
168
- ## 8.0.0
169
-
170
- ### Major Changes
171
-
172
- - Fix styles reference to include-media.
173
-
174
- ### Patch Changes
175
-
176
- - Updated dependencies
177
- - @lisergia/config-tsconfig@8.0.0
178
-
179
- ## 7.0.0
180
-
181
- ### Major Changes
182
-
183
- - Fix hash querySelector.
184
-
185
- ### Patch Changes
186
-
187
- - Updated dependencies
188
- - @lisergia/config-tsconfig@7.0.0
189
-
190
- ## 6.0.0
191
-
192
- ### Major Changes
193
-
194
- - Fix Prettier dependency.
195
-
196
- ### Patch Changes
197
-
198
- - Updated dependencies
199
- - @lisergia/config-tsconfig@6.0.0
200
-
201
- ## 5.0.0
202
-
203
- ### Major Changes
204
-
205
- - - Add Tempus utilities.
206
- - Remove module type from packages.
207
- - Add Prettier configuration as dependency.
208
- - Move Front End and Back End packages to separate repositories.
209
-
210
- ### Patch Changes
211
-
212
- - Updated dependencies
213
- - @lisergia/config-tsconfig@5.0.0
214
-
215
- ## 4.0.0
216
-
217
- ### Major Changes
218
-
219
- - Update build.
220
-
221
- ### Patch Changes
222
-
223
- - Updated dependencies
224
- - @lisergia/config-tsconfig@4.0.0
225
-
226
- ## 3.0.0
227
-
228
- ### Major Changes
229
-
230
- - Fix issue on managers distribution.
231
-
232
- ### Patch Changes
233
-
234
- - Updated dependencies
235
- - @lisergia/config-tsconfig@3.0.0
236
-
237
- ## 2.0.0
238
-
239
- ### Major Changes
240
-
241
- - Update build and serving of npm packages.
242
- - Updating build and serving of npm packages.
243
-
244
- ### Patch Changes
245
-
246
- - Updated dependencies
247
- - Updated dependencies
248
- - @lisergia/config-tsconfig@2.0.0
249
-
250
- ## 1.0.0
251
-
252
- ### Major Changes
253
-
254
- - 9c70654: Initial release of Lisergia packages.