@lisergia/core 2.0.0 → 3.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +11 -0
- package/dist/index.cjs +18 -9
- package/dist/index.js +51 -86
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @lisergia/core@
|
|
3
|
+
> @lisergia/core@2.0.0 build
|
|
4
4
|
> tsup src/index.ts --format cjs,esm --dts
|
|
5
5
|
|
|
6
6
|
[1G[0K[34mCLI[39m Building entry: src/index.ts
|
|
7
7
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
8
|
[34mCLI[39m tsup v8.5.0
|
|
9
|
-
[34mCLI[39m Target:
|
|
9
|
+
[34mCLI[39m Target: node16
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m13.31 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 17ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m15.43 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 17ms
|
|
16
16
|
DTS Build start
|
|
17
|
-
DTS ⚡️ Build success in
|
|
17
|
+
DTS ⚡️ Build success in 1072ms
|
|
18
|
+
DTS dist/index.d.cts 5.74 KB
|
|
18
19
|
DTS dist/index.d.ts 5.74 KB
|
|
19
|
-
DTS dist/index.d.mts 5.74 KB
|
|
20
20
|
[1G[0K⠙[1G[0K
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -219,7 +219,8 @@ var Links = class extends EventEmitter {
|
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
221
|
addEventListeners() {
|
|
222
|
-
|
|
222
|
+
var _a;
|
|
223
|
+
(_a = this.links) == null ? void 0 : _a.forEach((link) => link.destroy());
|
|
223
224
|
const links = document.querySelectorAll("a");
|
|
224
225
|
this.links = Array.from(links).map((element) => {
|
|
225
226
|
const link = new Link({
|
|
@@ -269,13 +270,15 @@ var ApplicationManager = class extends Component {
|
|
|
269
270
|
this.addEventListeners();
|
|
270
271
|
}
|
|
271
272
|
onTitleUpdate() {
|
|
272
|
-
|
|
273
|
+
var _a;
|
|
274
|
+
const title = (_a = this.nextPage) == null ? void 0 : _a.title;
|
|
273
275
|
if (title) {
|
|
274
276
|
document.title = title;
|
|
275
277
|
}
|
|
276
278
|
}
|
|
277
279
|
onTemplateUpdate() {
|
|
278
|
-
|
|
280
|
+
var _a;
|
|
281
|
+
const template = (_a = this.nextPage) == null ? void 0 : _a.template;
|
|
279
282
|
if (template) {
|
|
280
283
|
document.documentElement.dataset.template = template;
|
|
281
284
|
this.template = template;
|
|
@@ -396,6 +399,7 @@ var ApplicationManager = class extends Component {
|
|
|
396
399
|
//
|
|
397
400
|
nextPage = {};
|
|
398
401
|
async onRequest({ href, response, pushState }) {
|
|
402
|
+
var _a, _b;
|
|
399
403
|
const domParser = new DOMParser();
|
|
400
404
|
const dom = domParser.parseFromString(response, "text/html");
|
|
401
405
|
const html = dom.querySelector("html");
|
|
@@ -406,7 +410,7 @@ var ApplicationManager = class extends Component {
|
|
|
406
410
|
title: dom.title ?? document.title
|
|
407
411
|
};
|
|
408
412
|
if (this.transition) {
|
|
409
|
-
await this.transition.onTransition
|
|
413
|
+
await ((_b = (_a = this.transition).onTransition) == null ? void 0 : _b.call(_a, this));
|
|
410
414
|
} else {
|
|
411
415
|
this.currentPage.element.remove();
|
|
412
416
|
this.currentPage.destroy();
|
|
@@ -430,7 +434,8 @@ var ApplicationManager = class extends Component {
|
|
|
430
434
|
// Scroll.
|
|
431
435
|
//
|
|
432
436
|
get scroll() {
|
|
433
|
-
|
|
437
|
+
var _a;
|
|
438
|
+
return ((_a = this.currentPage) == null ? void 0 : _a.scroll) ?? 0;
|
|
434
439
|
}
|
|
435
440
|
//
|
|
436
441
|
// Listeners.
|
|
@@ -536,20 +541,23 @@ var Page = class extends Component {
|
|
|
536
541
|
});
|
|
537
542
|
}
|
|
538
543
|
destroyScroll() {
|
|
544
|
+
var _a;
|
|
539
545
|
if (!this.scrollEnabled) {
|
|
540
546
|
this.element.removeEventListener("scroll", this.onScrollFallback);
|
|
541
547
|
return;
|
|
542
548
|
}
|
|
543
|
-
this.lenis
|
|
549
|
+
(_a = this.lenis) == null ? void 0 : _a.destroy();
|
|
544
550
|
}
|
|
545
551
|
//
|
|
546
552
|
// Events.
|
|
547
553
|
//
|
|
548
554
|
onResize() {
|
|
549
|
-
|
|
555
|
+
var _a;
|
|
556
|
+
(_a = this.lenis) == null ? void 0 : _a.resize();
|
|
550
557
|
}
|
|
551
558
|
onRAF(time) {
|
|
552
|
-
|
|
559
|
+
var _a;
|
|
560
|
+
(_a = this.lenis) == null ? void 0 : _a.raf(time);
|
|
553
561
|
}
|
|
554
562
|
onScroll(scroll) {
|
|
555
563
|
this.scroll = scroll;
|
|
@@ -566,8 +574,9 @@ var Page = class extends Component {
|
|
|
566
574
|
this.unsubscribeRaf = import_tempus.default.add(this.onRAF);
|
|
567
575
|
}
|
|
568
576
|
removeEventListeners() {
|
|
577
|
+
var _a;
|
|
569
578
|
super.removeEventListeners();
|
|
570
|
-
this.unsubscribeRaf
|
|
579
|
+
(_a = this.unsubscribeRaf) == null ? void 0 : _a.call(this);
|
|
571
580
|
this.unsubscribeRaf = void 0;
|
|
572
581
|
}
|
|
573
582
|
//
|
package/dist/index.js
CHANGED
|
@@ -1,58 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
Application: () => Application,
|
|
34
|
-
ApplicationManager: () => ApplicationManager,
|
|
35
|
-
Component: () => Component,
|
|
36
|
-
EventEmitter: () => EventEmitter,
|
|
37
|
-
Link: () => Link,
|
|
38
|
-
Links: () => Links,
|
|
39
|
-
Page: () => Page,
|
|
40
|
-
Tempus: () => import_tempus2.default
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(index_exports);
|
|
43
|
-
|
|
44
1
|
// src/App.ts
|
|
45
|
-
|
|
2
|
+
import { autorun, computed, makeObservable, observable, observe } from "mobx";
|
|
46
3
|
|
|
47
4
|
// src/EventEmitter.ts
|
|
48
|
-
|
|
49
|
-
|
|
5
|
+
import AutoBind from "auto-bind";
|
|
6
|
+
import { createNanoEvents } from "nanoevents";
|
|
50
7
|
var EventEmitter = class {
|
|
51
8
|
emitter;
|
|
52
9
|
entries = /* @__PURE__ */ new Map();
|
|
53
10
|
constructor() {
|
|
54
|
-
(
|
|
55
|
-
this.emitter =
|
|
11
|
+
AutoBind(this);
|
|
12
|
+
this.emitter = createNanoEvents();
|
|
56
13
|
}
|
|
57
14
|
on(event, callback) {
|
|
58
15
|
if (!callback) {
|
|
@@ -167,7 +124,7 @@ var Component = class extends EventEmitter {
|
|
|
167
124
|
};
|
|
168
125
|
|
|
169
126
|
// src/Links.ts
|
|
170
|
-
|
|
127
|
+
import { reaction } from "mobx";
|
|
171
128
|
|
|
172
129
|
// src/Link.ts
|
|
173
130
|
var Link = class extends Component {
|
|
@@ -212,14 +169,15 @@ var Links = class extends EventEmitter {
|
|
|
212
169
|
constructor(application) {
|
|
213
170
|
super();
|
|
214
171
|
this.application = application;
|
|
215
|
-
|
|
172
|
+
reaction(
|
|
216
173
|
() => application.currentPage,
|
|
217
174
|
() => this.refresh(),
|
|
218
175
|
{ fireImmediately: true }
|
|
219
176
|
);
|
|
220
177
|
}
|
|
221
178
|
addEventListeners() {
|
|
222
|
-
|
|
179
|
+
var _a;
|
|
180
|
+
(_a = this.links) == null ? void 0 : _a.forEach((link) => link.destroy());
|
|
223
181
|
const links = document.querySelectorAll("a");
|
|
224
182
|
this.links = Array.from(links).map((element) => {
|
|
225
183
|
const link = new Link({
|
|
@@ -245,37 +203,39 @@ var ApplicationManager = class extends Component {
|
|
|
245
203
|
autoListeners: false,
|
|
246
204
|
element: ".app"
|
|
247
205
|
});
|
|
248
|
-
|
|
206
|
+
makeObservable(this, {
|
|
249
207
|
// Application DOM Element.
|
|
250
|
-
element:
|
|
208
|
+
element: observable,
|
|
251
209
|
// Components.
|
|
252
|
-
canvas:
|
|
253
|
-
components:
|
|
254
|
-
transition:
|
|
210
|
+
canvas: observable,
|
|
211
|
+
components: observable,
|
|
212
|
+
transition: observable,
|
|
255
213
|
// Page Information.
|
|
256
|
-
currentPage:
|
|
257
|
-
nextPage:
|
|
214
|
+
currentPage: observable,
|
|
215
|
+
nextPage: observable,
|
|
258
216
|
// Route Information.
|
|
259
|
-
route:
|
|
217
|
+
route: observable,
|
|
260
218
|
// Template Information.
|
|
261
|
-
template:
|
|
219
|
+
template: observable,
|
|
262
220
|
// Page Scroll.
|
|
263
|
-
scroll:
|
|
221
|
+
scroll: computed
|
|
264
222
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
223
|
+
observe(this.components, this.onComponentChange);
|
|
224
|
+
observe(this, "route", this.onRouteChange);
|
|
225
|
+
autorun(this.onTitleUpdate);
|
|
226
|
+
autorun(this.onTemplateUpdate);
|
|
269
227
|
this.addEventListeners();
|
|
270
228
|
}
|
|
271
229
|
onTitleUpdate() {
|
|
272
|
-
|
|
230
|
+
var _a;
|
|
231
|
+
const title = (_a = this.nextPage) == null ? void 0 : _a.title;
|
|
273
232
|
if (title) {
|
|
274
233
|
document.title = title;
|
|
275
234
|
}
|
|
276
235
|
}
|
|
277
236
|
onTemplateUpdate() {
|
|
278
|
-
|
|
237
|
+
var _a;
|
|
238
|
+
const template = (_a = this.nextPage) == null ? void 0 : _a.template;
|
|
279
239
|
if (template) {
|
|
280
240
|
document.documentElement.dataset.template = template;
|
|
281
241
|
this.template = template;
|
|
@@ -396,6 +356,7 @@ var ApplicationManager = class extends Component {
|
|
|
396
356
|
//
|
|
397
357
|
nextPage = {};
|
|
398
358
|
async onRequest({ href, response, pushState }) {
|
|
359
|
+
var _a, _b;
|
|
399
360
|
const domParser = new DOMParser();
|
|
400
361
|
const dom = domParser.parseFromString(response, "text/html");
|
|
401
362
|
const html = dom.querySelector("html");
|
|
@@ -406,7 +367,7 @@ var ApplicationManager = class extends Component {
|
|
|
406
367
|
title: dom.title ?? document.title
|
|
407
368
|
};
|
|
408
369
|
if (this.transition) {
|
|
409
|
-
await this.transition.onTransition
|
|
370
|
+
await ((_b = (_a = this.transition).onTransition) == null ? void 0 : _b.call(_a, this));
|
|
410
371
|
} else {
|
|
411
372
|
this.currentPage.element.remove();
|
|
412
373
|
this.currentPage.destroy();
|
|
@@ -430,7 +391,8 @@ var ApplicationManager = class extends Component {
|
|
|
430
391
|
// Scroll.
|
|
431
392
|
//
|
|
432
393
|
get scroll() {
|
|
433
|
-
|
|
394
|
+
var _a;
|
|
395
|
+
return ((_a = this.currentPage) == null ? void 0 : _a.scroll) ?? 0;
|
|
434
396
|
}
|
|
435
397
|
//
|
|
436
398
|
// Listeners.
|
|
@@ -445,9 +407,9 @@ var ApplicationManager = class extends Component {
|
|
|
445
407
|
var Application = new ApplicationManager();
|
|
446
408
|
|
|
447
409
|
// src/Page.ts
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
410
|
+
import Lenis from "lenis";
|
|
411
|
+
import { makeObservable as makeObservable2, observable as observable2 } from "mobx";
|
|
412
|
+
import Tempus from "tempus";
|
|
451
413
|
var Page = class extends Component {
|
|
452
414
|
datasets = [];
|
|
453
415
|
scroll = 0;
|
|
@@ -473,9 +435,9 @@ var Page = class extends Component {
|
|
|
473
435
|
this.datasets = datasets;
|
|
474
436
|
this.scrollEnabled = scrollEnabled;
|
|
475
437
|
this.scrollOptions = scrollOptions;
|
|
476
|
-
(
|
|
477
|
-
components:
|
|
478
|
-
scroll:
|
|
438
|
+
makeObservable2(this, {
|
|
439
|
+
components: observable2,
|
|
440
|
+
scroll: observable2
|
|
479
441
|
});
|
|
480
442
|
}
|
|
481
443
|
create() {
|
|
@@ -525,7 +487,7 @@ var Page = class extends Component {
|
|
|
525
487
|
this.element.addEventListener("scroll", this.onScrollFallback);
|
|
526
488
|
return;
|
|
527
489
|
}
|
|
528
|
-
this.lenis = new
|
|
490
|
+
this.lenis = new Lenis({
|
|
529
491
|
content: this.elements.wrapper,
|
|
530
492
|
wrapper: this.element,
|
|
531
493
|
...this.scrollOptions
|
|
@@ -536,20 +498,23 @@ var Page = class extends Component {
|
|
|
536
498
|
});
|
|
537
499
|
}
|
|
538
500
|
destroyScroll() {
|
|
501
|
+
var _a;
|
|
539
502
|
if (!this.scrollEnabled) {
|
|
540
503
|
this.element.removeEventListener("scroll", this.onScrollFallback);
|
|
541
504
|
return;
|
|
542
505
|
}
|
|
543
|
-
this.lenis
|
|
506
|
+
(_a = this.lenis) == null ? void 0 : _a.destroy();
|
|
544
507
|
}
|
|
545
508
|
//
|
|
546
509
|
// Events.
|
|
547
510
|
//
|
|
548
511
|
onResize() {
|
|
549
|
-
|
|
512
|
+
var _a;
|
|
513
|
+
(_a = this.lenis) == null ? void 0 : _a.resize();
|
|
550
514
|
}
|
|
551
515
|
onRAF(time) {
|
|
552
|
-
|
|
516
|
+
var _a;
|
|
517
|
+
(_a = this.lenis) == null ? void 0 : _a.raf(time);
|
|
553
518
|
}
|
|
554
519
|
onScroll(scroll) {
|
|
555
520
|
this.scroll = scroll;
|
|
@@ -563,11 +528,12 @@ var Page = class extends Component {
|
|
|
563
528
|
//
|
|
564
529
|
addEventListeners() {
|
|
565
530
|
super.addEventListeners();
|
|
566
|
-
this.unsubscribeRaf =
|
|
531
|
+
this.unsubscribeRaf = Tempus.add(this.onRAF);
|
|
567
532
|
}
|
|
568
533
|
removeEventListeners() {
|
|
534
|
+
var _a;
|
|
569
535
|
super.removeEventListeners();
|
|
570
|
-
this.unsubscribeRaf
|
|
536
|
+
(_a = this.unsubscribeRaf) == null ? void 0 : _a.call(this);
|
|
571
537
|
this.unsubscribeRaf = void 0;
|
|
572
538
|
}
|
|
573
539
|
//
|
|
@@ -582,9 +548,8 @@ var Page = class extends Component {
|
|
|
582
548
|
};
|
|
583
549
|
|
|
584
550
|
// src/index.ts
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
0 && (module.exports = {
|
|
551
|
+
import Tempus2 from "tempus";
|
|
552
|
+
export {
|
|
588
553
|
Application,
|
|
589
554
|
ApplicationManager,
|
|
590
555
|
Component,
|
|
@@ -592,5 +557,5 @@ var import_tempus2 = __toESM(require("tempus"));
|
|
|
592
557
|
Link,
|
|
593
558
|
Links,
|
|
594
559
|
Page,
|
|
595
|
-
Tempus
|
|
596
|
-
}
|
|
560
|
+
Tempus2 as Tempus
|
|
561
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lisergia/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lisergia/config-tsconfig": "
|
|
13
|
+
"@lisergia/config-tsconfig": "3.0.0",
|
|
14
14
|
"auto-bind": "^5.0.1",
|
|
15
15
|
"lenis": "^1.3.1",
|
|
16
16
|
"mobx": "^6.13.7",
|