@lisergia/core 2.0.0 → 4.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.
@@ -1,20 +1,20 @@
1
1
 
2
2
  
3
- > @lisergia/core@1.0.0 build
3
+ > @lisergia/core@4.0.0 build
4
4
  > tsup src/index.ts --format cjs,esm --dts
5
5
 
6
6
  CLI Building entry: src/index.ts
7
7
  CLI Using tsconfig: tsconfig.json
8
8
  CLI tsup v8.5.0
9
- CLI Target: esnext
9
+ CLI Target: node16
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/index.js 15.04 KB
13
- CJS ⚡️ Build success in 39ms
14
- ESM dist/index.mjs 12.93 KB
15
- ESM ⚡️ Build success in 39ms
12
+ ESM dist/index.js 13.37 KB
13
+ ESM ⚡️ Build success in 24ms
14
+ CJS dist/index.cjs 15.51 KB
15
+ CJS ⚡️ Build success in 24ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 1055ms
17
+ DTS ⚡️ Build success in 876ms
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
  ⠙
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @lisergia/core
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Update build.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @lisergia/config-tsconfig@4.0.0
13
+
14
+ ## 3.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - Fix issue on managers distribution.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @lisergia/config-tsconfig@3.0.0
24
+
3
25
  ## 2.0.0
4
26
 
5
27
  ### Major Changes
package/dist/index.cjs CHANGED
@@ -219,7 +219,8 @@ var Links = class extends EventEmitter {
219
219
  );
220
220
  }
221
221
  addEventListeners() {
222
- this.links?.forEach((link) => link.destroy());
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
- const title = this.nextPage?.title;
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
- const template = this.nextPage?.template;
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?.(this);
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
- return this.currentPage?.scroll ?? 0;
437
+ var _a;
438
+ return ((_a = this.currentPage) == null ? void 0 : _a.scroll) ?? 0;
434
439
  }
435
440
  //
436
441
  // Listeners.
@@ -474,6 +479,8 @@ var Page = class extends Component {
474
479
  this.scrollEnabled = scrollEnabled;
475
480
  this.scrollOptions = scrollOptions;
476
481
  (0, import_mobx3.makeObservable)(this, {
482
+ element: import_mobx3.observable,
483
+ elements: import_mobx3.observable,
477
484
  components: import_mobx3.observable,
478
485
  scroll: import_mobx3.observable
479
486
  });
@@ -536,20 +543,23 @@ var Page = class extends Component {
536
543
  });
537
544
  }
538
545
  destroyScroll() {
546
+ var _a;
539
547
  if (!this.scrollEnabled) {
540
548
  this.element.removeEventListener("scroll", this.onScrollFallback);
541
549
  return;
542
550
  }
543
- this.lenis?.destroy();
551
+ (_a = this.lenis) == null ? void 0 : _a.destroy();
544
552
  }
545
553
  //
546
554
  // Events.
547
555
  //
548
556
  onResize() {
549
- this.lenis?.resize();
557
+ var _a;
558
+ (_a = this.lenis) == null ? void 0 : _a.resize();
550
559
  }
551
560
  onRAF(time) {
552
- this.lenis?.raf(time);
561
+ var _a;
562
+ (_a = this.lenis) == null ? void 0 : _a.raf(time);
553
563
  }
554
564
  onScroll(scroll) {
555
565
  this.scroll = scroll;
@@ -566,8 +576,9 @@ var Page = class extends Component {
566
576
  this.unsubscribeRaf = import_tempus.default.add(this.onRAF);
567
577
  }
568
578
  removeEventListeners() {
579
+ var _a;
569
580
  super.removeEventListeners();
570
- this.unsubscribeRaf?.();
581
+ (_a = this.unsubscribeRaf) == null ? void 0 : _a.call(this);
571
582
  this.unsubscribeRaf = void 0;
572
583
  }
573
584
  //
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
- var import_mobx2 = require("mobx");
2
+ import { autorun, computed, makeObservable, observable, observe } from "mobx";
46
3
 
47
4
  // src/EventEmitter.ts
48
- var import_auto_bind = __toESM(require("auto-bind"));
49
- var import_nanoevents = require("nanoevents");
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
- (0, import_auto_bind.default)(this);
55
- this.emitter = (0, import_nanoevents.createNanoEvents)();
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
- var import_mobx = require("mobx");
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
- (0, import_mobx.reaction)(
172
+ reaction(
216
173
  () => application.currentPage,
217
174
  () => this.refresh(),
218
175
  { fireImmediately: true }
219
176
  );
220
177
  }
221
178
  addEventListeners() {
222
- this.links?.forEach((link) => link.destroy());
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
- (0, import_mobx2.makeObservable)(this, {
206
+ makeObservable(this, {
249
207
  // Application DOM Element.
250
- element: import_mobx2.observable,
208
+ element: observable,
251
209
  // Components.
252
- canvas: import_mobx2.observable,
253
- components: import_mobx2.observable,
254
- transition: import_mobx2.observable,
210
+ canvas: observable,
211
+ components: observable,
212
+ transition: observable,
255
213
  // Page Information.
256
- currentPage: import_mobx2.observable,
257
- nextPage: import_mobx2.observable,
214
+ currentPage: observable,
215
+ nextPage: observable,
258
216
  // Route Information.
259
- route: import_mobx2.observable,
217
+ route: observable,
260
218
  // Template Information.
261
- template: import_mobx2.observable,
219
+ template: observable,
262
220
  // Page Scroll.
263
- scroll: import_mobx2.computed
221
+ scroll: computed
264
222
  });
265
- (0, import_mobx2.observe)(this.components, this.onComponentChange);
266
- (0, import_mobx2.observe)(this, "route", this.onRouteChange);
267
- (0, import_mobx2.autorun)(this.onTitleUpdate);
268
- (0, import_mobx2.autorun)(this.onTemplateUpdate);
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
- const title = this.nextPage?.title;
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
- const template = this.nextPage?.template;
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?.(this);
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
- return this.currentPage?.scroll ?? 0;
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
- var import_lenis = __toESM(require("lenis"));
449
- var import_mobx3 = require("mobx");
450
- var import_tempus = __toESM(require("tempus"));
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,11 @@ var Page = class extends Component {
473
435
  this.datasets = datasets;
474
436
  this.scrollEnabled = scrollEnabled;
475
437
  this.scrollOptions = scrollOptions;
476
- (0, import_mobx3.makeObservable)(this, {
477
- components: import_mobx3.observable,
478
- scroll: import_mobx3.observable
438
+ makeObservable2(this, {
439
+ element: observable2,
440
+ elements: observable2,
441
+ components: observable2,
442
+ scroll: observable2
479
443
  });
480
444
  }
481
445
  create() {
@@ -525,7 +489,7 @@ var Page = class extends Component {
525
489
  this.element.addEventListener("scroll", this.onScrollFallback);
526
490
  return;
527
491
  }
528
- this.lenis = new import_lenis.default({
492
+ this.lenis = new Lenis({
529
493
  content: this.elements.wrapper,
530
494
  wrapper: this.element,
531
495
  ...this.scrollOptions
@@ -536,20 +500,23 @@ var Page = class extends Component {
536
500
  });
537
501
  }
538
502
  destroyScroll() {
503
+ var _a;
539
504
  if (!this.scrollEnabled) {
540
505
  this.element.removeEventListener("scroll", this.onScrollFallback);
541
506
  return;
542
507
  }
543
- this.lenis?.destroy();
508
+ (_a = this.lenis) == null ? void 0 : _a.destroy();
544
509
  }
545
510
  //
546
511
  // Events.
547
512
  //
548
513
  onResize() {
549
- this.lenis?.resize();
514
+ var _a;
515
+ (_a = this.lenis) == null ? void 0 : _a.resize();
550
516
  }
551
517
  onRAF(time) {
552
- this.lenis?.raf(time);
518
+ var _a;
519
+ (_a = this.lenis) == null ? void 0 : _a.raf(time);
553
520
  }
554
521
  onScroll(scroll) {
555
522
  this.scroll = scroll;
@@ -563,11 +530,12 @@ var Page = class extends Component {
563
530
  //
564
531
  addEventListeners() {
565
532
  super.addEventListeners();
566
- this.unsubscribeRaf = import_tempus.default.add(this.onRAF);
533
+ this.unsubscribeRaf = Tempus.add(this.onRAF);
567
534
  }
568
535
  removeEventListeners() {
536
+ var _a;
569
537
  super.removeEventListeners();
570
- this.unsubscribeRaf?.();
538
+ (_a = this.unsubscribeRaf) == null ? void 0 : _a.call(this);
571
539
  this.unsubscribeRaf = void 0;
572
540
  }
573
541
  //
@@ -582,9 +550,8 @@ var Page = class extends Component {
582
550
  };
583
551
 
584
552
  // src/index.ts
585
- var import_tempus2 = __toESM(require("tempus"));
586
- // Annotate the CommonJS export names for ESM import in node:
587
- 0 && (module.exports = {
553
+ import Tempus2 from "tempus";
554
+ export {
588
555
  Application,
589
556
  ApplicationManager,
590
557
  Component,
@@ -592,5 +559,5 @@ var import_tempus2 = __toESM(require("tempus"));
592
559
  Link,
593
560
  Links,
594
561
  Page,
595
- Tempus
596
- });
562
+ Tempus2 as Tempus
563
+ };
package/dist/index.mjs CHANGED
@@ -176,7 +176,8 @@ var Links = class extends EventEmitter {
176
176
  );
177
177
  }
178
178
  addEventListeners() {
179
- this.links?.forEach((link) => link.destroy());
179
+ var _a;
180
+ (_a = this.links) == null ? void 0 : _a.forEach((link) => link.destroy());
180
181
  const links = document.querySelectorAll("a");
181
182
  this.links = Array.from(links).map((element) => {
182
183
  const link = new Link({
@@ -226,13 +227,15 @@ var ApplicationManager = class extends Component {
226
227
  this.addEventListeners();
227
228
  }
228
229
  onTitleUpdate() {
229
- const title = this.nextPage?.title;
230
+ var _a;
231
+ const title = (_a = this.nextPage) == null ? void 0 : _a.title;
230
232
  if (title) {
231
233
  document.title = title;
232
234
  }
233
235
  }
234
236
  onTemplateUpdate() {
235
- const template = this.nextPage?.template;
237
+ var _a;
238
+ const template = (_a = this.nextPage) == null ? void 0 : _a.template;
236
239
  if (template) {
237
240
  document.documentElement.dataset.template = template;
238
241
  this.template = template;
@@ -353,6 +356,7 @@ var ApplicationManager = class extends Component {
353
356
  //
354
357
  nextPage = {};
355
358
  async onRequest({ href, response, pushState }) {
359
+ var _a, _b;
356
360
  const domParser = new DOMParser();
357
361
  const dom = domParser.parseFromString(response, "text/html");
358
362
  const html = dom.querySelector("html");
@@ -363,7 +367,7 @@ var ApplicationManager = class extends Component {
363
367
  title: dom.title ?? document.title
364
368
  };
365
369
  if (this.transition) {
366
- await this.transition.onTransition?.(this);
370
+ await ((_b = (_a = this.transition).onTransition) == null ? void 0 : _b.call(_a, this));
367
371
  } else {
368
372
  this.currentPage.element.remove();
369
373
  this.currentPage.destroy();
@@ -387,7 +391,8 @@ var ApplicationManager = class extends Component {
387
391
  // Scroll.
388
392
  //
389
393
  get scroll() {
390
- return this.currentPage?.scroll ?? 0;
394
+ var _a;
395
+ return ((_a = this.currentPage) == null ? void 0 : _a.scroll) ?? 0;
391
396
  }
392
397
  //
393
398
  // Listeners.
@@ -431,6 +436,8 @@ var Page = class extends Component {
431
436
  this.scrollEnabled = scrollEnabled;
432
437
  this.scrollOptions = scrollOptions;
433
438
  makeObservable2(this, {
439
+ element: observable2,
440
+ elements: observable2,
434
441
  components: observable2,
435
442
  scroll: observable2
436
443
  });
@@ -493,20 +500,23 @@ var Page = class extends Component {
493
500
  });
494
501
  }
495
502
  destroyScroll() {
503
+ var _a;
496
504
  if (!this.scrollEnabled) {
497
505
  this.element.removeEventListener("scroll", this.onScrollFallback);
498
506
  return;
499
507
  }
500
- this.lenis?.destroy();
508
+ (_a = this.lenis) == null ? void 0 : _a.destroy();
501
509
  }
502
510
  //
503
511
  // Events.
504
512
  //
505
513
  onResize() {
506
- this.lenis?.resize();
514
+ var _a;
515
+ (_a = this.lenis) == null ? void 0 : _a.resize();
507
516
  }
508
517
  onRAF(time) {
509
- this.lenis?.raf(time);
518
+ var _a;
519
+ (_a = this.lenis) == null ? void 0 : _a.raf(time);
510
520
  }
511
521
  onScroll(scroll) {
512
522
  this.scroll = scroll;
@@ -523,8 +533,9 @@ var Page = class extends Component {
523
533
  this.unsubscribeRaf = Tempus.add(this.onRAF);
524
534
  }
525
535
  removeEventListeners() {
536
+ var _a;
526
537
  super.removeEventListeners();
527
- this.unsubscribeRaf?.();
538
+ (_a = this.unsubscribeRaf) == null ? void 0 : _a.call(this);
528
539
  this.unsubscribeRaf = void 0;
529
540
  }
530
541
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lisergia/core",
3
- "version": "2.0.0",
3
+ "version": "4.0.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -10,11 +10,12 @@
10
10
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch"
11
11
  },
12
12
  "dependencies": {
13
- "@lisergia/config-tsconfig": "2.0.0",
13
+ "@lisergia/config-tsconfig": "4.0.0",
14
14
  "auto-bind": "^5.0.1",
15
15
  "lenis": "^1.3.1",
16
16
  "mobx": "^6.13.7",
17
17
  "nanoevents": "^9.1.0",
18
- "tempus": "^1.0.0-dev.10"
18
+ "tempus": "^1.0.0-dev.10",
19
+ "tsup": "^8.5.0"
19
20
  }
20
21
  }
package/src/Page.ts CHANGED
@@ -58,6 +58,8 @@ export class Page extends Component {
58
58
  this.scrollOptions = scrollOptions
59
59
 
60
60
  makeObservable(this, {
61
+ element: observable,
62
+ elements: observable,
61
63
  components: observable,
62
64
  scroll: observable,
63
65
  })