@lightningjs/blits 2.0.0-beta.10 → 2.0.0-beta.11

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 (2) hide show
  1. package/index.d.ts +60 -32
  2. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -401,11 +401,9 @@ declare module '@lightningjs/blits' {
401
401
  readonly $hasFocus: boolean,
402
402
 
403
403
  /**
404
- * Parent component instance.
405
- * Note: will be undefined for the root Application component or after destroy.
406
- *
404
+ * Parent component instance. Undefined for the root Application component (destroyed case not modeled).
407
405
  */
408
- readonly $parent: ComponentBase,
406
+ readonly $parent: ComponentBase | undefined,
409
407
 
410
408
  /**
411
409
  * Indicates whether the component currently is hovered
@@ -546,6 +544,20 @@ declare module '@lightningjs/blits' {
546
544
  }) => void
547
545
  }
548
546
 
547
+ /**
548
+ * Context type for the root Application: no parent.
549
+ */
550
+ export interface ApplicationBase extends Omit<ComponentBase, '$parent'> {
551
+ readonly $parent: undefined
552
+ }
553
+
554
+ /**
555
+ * Context type for Components (Blits.Component): always has a parent when mounted. Destroyed case is not modeled.
556
+ */
557
+ export interface ChildComponentBase extends Omit<ComponentBase, '$parent'> {
558
+ readonly $parent: ComponentBase
559
+ }
560
+
549
561
  /**
550
562
  * Prop object
551
563
  */
@@ -589,7 +601,14 @@ declare module '@lightningjs/blits' {
589
601
  S,
590
602
  M,
591
603
  C
592
- > = ThisType<Readonly<InferProps<P>> & S & M & Readonly<C> & ComponentBase>
604
+ > = ThisType<Readonly<InferProps<P>> & S & M & Readonly<C> & ChildComponentBase>
605
+
606
+ export type ApplicationContext<
607
+ P extends Record<string, any>,
608
+ S,
609
+ M,
610
+ C
611
+ > = ThisType<Readonly<InferProps<P>> & S & M & Readonly<C> & ApplicationBase>
593
612
 
594
613
  export interface ComponentConfig<P extends Props = {}, S, M, C, W> {
595
614
  components?: {
@@ -647,7 +666,7 @@ declare module '@lightningjs/blits' {
647
666
  * }
648
667
  * ```
649
668
  */
650
- state?: (this: Readonly<InferProps<P>> & ComponentBase) => S;
669
+ state?: (this: Readonly<InferProps<P>> & ChildComponentBase) => S;
651
670
  /**
652
671
  * Methods for abstracting more complex business logic into separate function
653
672
  */
@@ -718,32 +737,41 @@ declare module '@lightningjs/blits' {
718
737
  backNavigation?: boolean
719
738
  }
720
739
 
721
- export type ApplicationConfig<P extends Props, S, M, C, W> = ComponentConfig<P, S, M, C, W> & (
722
- {
723
- /**
724
- * Router Configuration
725
- */
726
- router?: RouterConfig<P, S, M, C>,
727
- routes?: never
728
- }
729
- |
730
- {
731
- router?: never
732
- /**
733
- * Routes definition
734
- *
735
- * @example
736
- *
737
- * ```js
738
- * routes: [
739
- * { path: '/', component: Home },
740
- * { path: '/details', component: Details },
741
- * { path: '/account', component: Account },
742
- * ]
743
- * ```
744
- */
745
- routes?: Route[]
746
- }
740
+ export type ApplicationConfig<P extends Props, S, M, C, W> = Omit<
741
+ ComponentConfig<P, S, M, C, W>,
742
+ 'hooks' | 'methods' | 'input' | 'computed' | 'watch' | 'state'
743
+ > & {
744
+ hooks?: Hooks & ApplicationContext<P, S, M, C>
745
+ methods?: M & ApplicationContext<P, S, M, C>
746
+ input?: Input & ApplicationContext<P, S, M, C>
747
+ computed?: C & ApplicationContext<P, S, M, C>
748
+ watch?: W & ApplicationContext<P, S, M, C>
749
+ state?: (this: Readonly<InferProps<P>> & ApplicationBase) => S
750
+ } & (
751
+ | {
752
+ /**
753
+ * Router Configuration
754
+ */
755
+ router?: RouterConfig<P, S, M, C>
756
+ routes?: never
757
+ }
758
+ | {
759
+ router?: never
760
+ /**
761
+ * Routes definition
762
+ *
763
+ * @example
764
+ *
765
+ * ```js
766
+ * routes: [
767
+ * { path: '/', component: Home },
768
+ * { path: '/details', component: Details },
769
+ * { path: '/account', component: Account },
770
+ * ]
771
+ * ```
772
+ */
773
+ routes?: Route[]
774
+ }
747
775
  )
748
776
 
749
777
  export interface Transition {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "2.0.0-beta.10",
3
+ "version": "2.0.0-beta.11",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -75,7 +75,7 @@
75
75
  "tape": "^5.5.0"
76
76
  },
77
77
  "dependencies": {
78
- "@lightningjs/renderer": "3.0.0-beta23",
78
+ "@lightningjs/renderer": "3.0.0-beta24",
79
79
  "magic-string": "^0.30.21"
80
80
  },
81
81
  "repository": {