ivue 1.2.3 → 1.3.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.
Files changed (79) hide show
  1. package/coverage/clover.xml +177 -176
  2. package/coverage/coverage-final.json +1 -1
  3. package/coverage/index.html +18 -18
  4. package/coverage/index.ts.html +1 -1
  5. package/coverage/ivue.ts.html +176 -146
  6. package/dist/index.es.js +47 -46
  7. package/dist/index.umd.js +1 -1
  8. package/dist/src/ivue.d.ts +20 -11
  9. package/docs/docs/.vitepress/config.ts +24 -4
  10. package/docs/docs/.vitepress/dist/404.html +2 -2
  11. package/docs/docs/.vitepress/dist/api/ivue.html +4 -4
  12. package/docs/docs/.vitepress/dist/api/propsWithDefaults.html +4 -4
  13. package/docs/docs/.vitepress/dist/assets/{app.DQ9wCVNL.js → app.C_6IW306.js} +1 -1
  14. package/docs/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.Cfu1MyIk.js +1 -0
  15. package/docs/docs/.vitepress/dist/assets/chunks/{VPLocalSearchBox.EJpZrMkj.js → VPLocalSearchBox.BEJZ5WJL.js} +1 -1
  16. package/docs/docs/.vitepress/dist/assets/chunks/index.es.B1_StH0Z.js +1 -0
  17. package/docs/docs/.vitepress/dist/assets/chunks/{theme.BCqH7Ey3.js → theme.COJ5Yu8m.js} +2 -2
  18. package/docs/docs/.vitepress/dist/assets/{pages_advanced-usage.md.DsU0E8Oi.js → pages_advanced-usage.md.Xwq8hk_w.js} +1 -1
  19. package/docs/docs/.vitepress/dist/assets/{pages_advanced-usage.md.DsU0E8Oi.lean.js → pages_advanced-usage.md.Xwq8hk_w.lean.js} +1 -1
  20. package/docs/docs/.vitepress/dist/assets/pages_api.md.Bo9Kusmf.js +1 -0
  21. package/docs/docs/.vitepress/dist/assets/pages_api.md.Bo9Kusmf.lean.js +1 -0
  22. package/docs/docs/.vitepress/dist/assets/{pages_browse-code.md.d01mQ5OL.js → pages_browse-code.md.BS0BRUx_.js} +39 -29
  23. package/docs/docs/.vitepress/dist/assets/{pages_getting-started.md.g77_aCnX.js → pages_getting-started.md.BbVqm1ey.js} +39 -29
  24. package/docs/docs/.vitepress/dist/assets/{pages_guidelines.md.DufOHb7U.lean.js → pages_guidelines.md.fL8xf0Gx.js} +19 -19
  25. package/docs/docs/.vitepress/dist/assets/{pages_guidelines.md.DufOHb7U.js → pages_guidelines.md.fL8xf0Gx.lean.js} +19 -19
  26. package/docs/docs/.vitepress/dist/assets/{pages_how-it-works.md.BaYaFawX.js → pages_how-it-works.md.CP31gYQw.js} +40 -30
  27. package/docs/docs/.vitepress/dist/assets/{pages_how-it-works.md.BaYaFawX.lean.js → pages_how-it-works.md.CP31gYQw.lean.js} +40 -30
  28. package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.C02KZK0J.js +1 -0
  29. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.B6foeVXQ.js +1 -0
  30. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.B6foeVXQ.lean.js +1 -0
  31. package/docs/docs/.vitepress/dist/assets/{pages_usage.md.Fo9SdFjd.js → pages_usage.md.5C8BnzAi.js} +100 -68
  32. package/docs/docs/.vitepress/dist/assets/{pages_usage.md.Fo9SdFjd.lean.js → pages_usage.md.5C8BnzAi.lean.js} +100 -68
  33. package/docs/docs/.vitepress/dist/hashmap.json +1 -1
  34. package/docs/docs/.vitepress/dist/index.html +4 -4
  35. package/docs/docs/.vitepress/dist/pages/advanced-usage.html +5 -5
  36. package/docs/docs/.vitepress/dist/pages/api.html +7 -7
  37. package/docs/docs/.vitepress/dist/pages/browse-code.html +43 -33
  38. package/docs/docs/.vitepress/dist/pages/getting-started.html +44 -34
  39. package/docs/docs/.vitepress/dist/pages/guidelines.html +24 -24
  40. package/docs/docs/.vitepress/dist/pages/how-it-works.html +44 -34
  41. package/docs/docs/.vitepress/dist/pages/how-its-made.html +5 -5
  42. package/docs/docs/.vitepress/dist/pages/introduction.html +5 -5
  43. package/docs/docs/.vitepress/dist/pages/usage.html +105 -73
  44. package/docs/docs/components/advanced-usage/ConvertLegacy.vue +58 -0
  45. package/docs/docs/components/usage/CounterBasic.vue +3 -1
  46. package/docs/docs/components/usage/CounterComposables.vue +5 -3
  47. package/docs/docs/components/usage/CounterComposablesDestructuring.vue +15 -11
  48. package/docs/docs/components/usage/CounterComposablesIvue.vue +7 -3
  49. package/docs/docs/components/usage/CounterComposablesIvueDestructuring.vue +4 -2
  50. package/docs/docs/components/usage/CounterComputeds.vue +3 -1
  51. package/docs/docs/components/usage/CounterComputedsDisabled.vue +6 -4
  52. package/docs/docs/components/usage/CounterExternalRefs.vue +4 -2
  53. package/docs/docs/components/usage/CounterInsideComposables.vue +3 -1
  54. package/docs/docs/components/usage/CounterInternalRefs.vue +3 -1
  55. package/docs/docs/components/usage/CounterLifecycleHooks.vue +3 -1
  56. package/docs/docs/components/usage/CounterWatch.vue +3 -1
  57. package/docs/docs/components/usage/CounterWithProps.vue +4 -2
  58. package/docs/docs/components/usage/CounterWithPropsAndEmits.vue +3 -1
  59. package/docs/docs/components/usage/classes/CustomMouse.ts +2 -2
  60. package/docs/docs/pages/advanced-usage.md +2 -1
  61. package/docs/docs/pages/api.md +22 -7
  62. package/docs/docs/pages/guidelines.md +9 -9
  63. package/docs/docs/pages/how-it-works.md +0 -20
  64. package/docs/docs/pages/how-its-made.md +3 -3
  65. package/docs/docs/pages/introduction.md +22 -8
  66. package/docs/package.json +1 -1
  67. package/package.json +6 -1
  68. package/src/__tests__/ivue.vitest.spec.ts +61 -7
  69. package/src/ivue.ts +37 -27
  70. package/docs/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.HQhVwKCx.js +0 -1
  71. package/docs/docs/.vitepress/dist/assets/chunks/index.es.CUL6WvM-.js +0 -1
  72. package/docs/docs/.vitepress/dist/assets/pages_api.md.CElVfYwg.js +0 -1
  73. package/docs/docs/.vitepress/dist/assets/pages_api.md.CElVfYwg.lean.js +0 -1
  74. package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.CCol99CD.js +0 -1
  75. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.CCkiQtfX.js +0 -1
  76. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.CCkiQtfX.lean.js +0 -1
  77. /package/docs/docs/.vitepress/dist/assets/{pages_browse-code.md.d01mQ5OL.lean.js → pages_browse-code.md.BS0BRUx_.lean.js} +0 -0
  78. /package/docs/docs/.vitepress/dist/assets/{pages_getting-started.md.g77_aCnX.lean.js → pages_getting-started.md.BbVqm1ey.lean.js} +0 -0
  79. /package/docs/docs/.vitepress/dist/assets/{pages_how-its-made.md.CCol99CD.lean.js → pages_how-its-made.md.C02KZK0J.lean.js} +0 -0
@@ -0,0 +1,58 @@
1
+ <script setup lang="ts">
2
+ class Chair {
3
+ // Defaults that will be common for all the instances
4
+ static backSupport: boolean = true;
5
+ static armRests: boolean = true;
6
+
7
+ // Instance properties
8
+ color: string;
9
+ seatHeight: number;
10
+ recliningAngle: number;
11
+ headSupport: boolean;
12
+ padding: string;
13
+ seatSize: string;
14
+ isHeightAdjustable: boolean;
15
+ isMovable: boolean;
16
+ type: string;
17
+
18
+ constructor(
19
+ color: string,
20
+ seatHeight: number,
21
+ recliningAngle: number,
22
+ headSupport: boolean,
23
+ padding: string,
24
+ seatSize: string,
25
+ isHeightAdjustable: boolean,
26
+ isMovable: boolean
27
+ ) {
28
+ // Defaults which can be changed by the subclass class.
29
+ this.color = color;
30
+ this.seatHeight = seatHeight;
31
+ this.recliningAngle = recliningAngle;
32
+ this.headSupport = headSupport || false;
33
+ this.padding = padding || "3 inch";
34
+ this.seatSize = seatSize || "16 inch";
35
+ this.isHeightAdjustable = isHeightAdjustable || false;
36
+ this.isMovable = isMovable || false;
37
+ this.type = "Chair";
38
+ console.log(Chair.printDefaultProps()); // Usage of static method inside constructor
39
+ }
40
+
41
+ static logObjectProps(): void {
42
+ console.dir(this);
43
+ }
44
+
45
+ // Static within static usage
46
+ static printDefaultProps(): void {
47
+ console.log(`Chair Back Support = ${this.backSupport}`);
48
+ console.log(`Arm rests support = ${this.armRests}`);
49
+ }
50
+
51
+ adjustableHeight(): void {};
52
+ adjustAngle(): void {};
53
+ moveChair(): void {};
54
+ }
55
+ </script>
56
+ <template>
57
+ <div>Hello</div>
58
+ </template>
@@ -11,6 +11,8 @@ class Counter {
11
11
  const counter = ivue(Counter);
12
12
  </script>
13
13
  <template>
14
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
14
+ <a href="javascript:void(0)" @click="() => counter.increment()">
15
+ Increment
16
+ </a>
15
17
  Count: {{ counter.count }}
16
18
  </template>
@@ -14,13 +14,15 @@ class Counter {
14
14
  const counter = ivue(Counter);
15
15
  </script>
16
16
  <template>
17
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
17
+ <a href="javascript:void(0)" @click="() => counter.increment()">
18
+ Increment
19
+ </a>
18
20
  Count: {{ counter.count }} <br />
19
21
  <br />
20
22
  Mouse: <br />
21
23
  X: {{ counter.mouse.x }} <br />
22
- Y: {{ counter.mouse.y }} <br />
23
- <br />
24
+ Y: {{ counter.mouse.y }} <br />
25
+ <br />
24
26
  Pointer: <br />
25
27
  X: {{ counter.pointer.x }} <br />
26
28
  Y: {{ counter.pointer.y }} <br />
@@ -1,13 +1,13 @@
1
1
  <script setup lang="ts">
2
2
  import { useCustomMouse } from './functions/useCustomMouse';
3
3
 
4
- import { ivue, iuse, iref, type UseComposable } from 'ivue';
4
+ import { ivue, iuse, iref, type Use } from 'ivue';
5
5
 
6
6
  /**
7
- * Use the ivue Utility Type: UseComposable<typeof YourComposableFunctionName>
7
+ * Use the ivue Utility Type: Use<typeof YourComposableFunctionName>
8
8
  * to get he resulting unwrapped composable properties and functions.
9
9
  */
10
- type UseCustomMouse = UseComposable<typeof useCustomMouse>;
10
+ type UseCustomMouse = Use<typeof useCustomMouse>;
11
11
 
12
12
  class Counter {
13
13
  count = iref(0);
@@ -18,22 +18,22 @@ class Counter {
18
18
 
19
19
  /**
20
20
  * 'x', 'y', 'sum', 'total' are Refs that will be unwrapped to their bare raw types and destructured into the class.
21
- * Even though unwrapped (de-Refed), they will maintain their behavior as Refs and thus will maintain reactivity
22
- * and at the same time get destructured into this class root level scope because
21
+ * Even though unwrapped (de-Refed), they will maintain their behavior as Refs and thus will maintain reactivity
22
+ * and at the same time get destructured into this class root level scope because
23
23
  * Vue 3's `reactive()` Proxy will be able to resolve those Refs internally.
24
24
  */
25
25
  x: UseCustomMouse['x']; // Unwrapped Ref<number> becomes -> number
26
26
  y: UseCustomMouse['y']; // Unwrapped Ref<number> becomes -> number
27
-
27
+
28
28
  sum: UseCustomMouse['sum']; // 'sum' method that will be destructured into this class on construct()
29
- total: UseCustomMouse['total']; // 'total' computed Ref that will also be destructured into this class on construct()
29
+ total: UseCustomMouse['total']; // 'total' computed Ref that will also be destructured into this class on construct()
30
30
 
31
31
  constructor() {
32
32
  ({
33
33
  x: this.x,
34
34
  y: this.y,
35
35
  sum: this.sum,
36
- total: this.total
36
+ total: this.total,
37
37
  } = iuse(useCustomMouse, 5));
38
38
  }
39
39
  }
@@ -41,11 +41,15 @@ class Counter {
41
41
  const counter = ivue(Counter);
42
42
  </script>
43
43
  <template>
44
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
44
+ <a href="javascript:void(0)" @click="() => counter.increment()">
45
+ Increment
46
+ </a>
45
47
  Count: {{ counter.count }} <br />
46
- Mouse X: {{ counter.x }}, Y: {{ counter.y }}
48
+ Mouse X: {{ counter.x }}, Y: {{ counter.y }}
47
49
  <br />
48
50
  Total (computed): {{ counter.total }}
49
51
  <br />
50
- <button class="button" @click="() => counter.sum()">Click This Big Sum Button To Total X + Y</button>
52
+ <button class="button" @click="() => counter.sum()">
53
+ Click This Big Sum Button To Total X + Y
54
+ </button>
51
55
  </template>
@@ -10,17 +10,21 @@ class Counter {
10
10
  this.count++;
11
11
  }
12
12
 
13
- mouse = ivue(CustomMouse, 5)
13
+ mouse = ivue(CustomMouse, 5);
14
14
  }
15
15
 
16
16
  const counter = ivue(Counter);
17
17
  </script>
18
18
  <template>
19
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
19
+ <a href="javascript:void(0)" @click="() => counter.increment()">
20
+ Increment
21
+ </a>
20
22
  Count: {{ counter.count }} <br />
21
23
  Mouse X: {{ counter.mouse.x }}, Y: {{ counter.mouse.y }}
22
24
  <br />
23
25
  Total (computed): {{ counter.mouse.total }}
24
26
  <br />
25
- <button class="button" @click="() => counter.mouse.sum()">Click This Big Sum Button To Total X + Y</button>
27
+ <button class="button" @click="() => counter.mouse.sum()">
28
+ Click This Big Sum Button To Total X + Y
29
+ </button>
26
30
  </template>
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { CustomMouse } from './classes/CustomMouse';
3
3
 
4
- import { ivue, iref } from '../../../../src/ivue';
4
+ import { ivue, iref } from 'ivue';
5
5
 
6
6
  class Counter {
7
7
  count = iref(0);
@@ -34,7 +34,9 @@ class Counter {
34
34
  const counter = ivue(Counter);
35
35
  </script>
36
36
  <template>
37
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
37
+ <a href="javascript:void(0)" @click="() => counter.increment()">
38
+ Increment
39
+ </a>
38
40
  Count: {{ counter.count }} <br />
39
41
  Mouse X: {{ counter.x }}, Y: {{ counter.y }}
40
42
  <br />
@@ -17,7 +17,9 @@ class Counter {
17
17
  const counter = ivue(Counter);
18
18
  </script>
19
19
  <template>
20
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
20
+ <a href="javascript:void(0)" @click="() => counter.increment()">
21
+ Increment
22
+ </a>
21
23
  Count: {{ counter.count }} <br />
22
24
  Double Count: {{ counter.doubleCount }} <br />
23
25
  Quad Count: {{ counter.quadCount }} <br />
@@ -3,12 +3,12 @@ import { ivue, iref } from 'ivue';
3
3
 
4
4
  class Counter {
5
5
  /**
6
- * Use static ivue property to disable computed
6
+ * Use static ivue property to disable computed
7
7
  * behavior for certain getters.
8
8
  */
9
9
  static ivue = {
10
- doubleCount: false // doubleCount is a regular getter now
11
- }
10
+ doubleCount: false, // doubleCount is a regular getter now
11
+ };
12
12
  count = iref(0);
13
13
  increment() {
14
14
  this.count++;
@@ -24,7 +24,9 @@ class Counter {
24
24
  const counter = ivue(Counter);
25
25
  </script>
26
26
  <template>
27
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
27
+ <a href="javascript:void(0)" @click="() => counter.increment()">
28
+ Increment
29
+ </a>
28
30
  Count: {{ counter.count }} <br />
29
31
  Double Count: {{ counter.doubleCount }} <br />
30
32
  Quad Count: {{ counter.quadCount }} <br />
@@ -19,7 +19,9 @@ const counter = ivue(Counter, iuse(span));
19
19
  defineExpose<Counter>(counter);
20
20
  </script>
21
21
  <template>
22
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
23
- Count: {{ counter.count }}
22
+ <a href="javascript:void(0)" @click="() => counter.increment()">
23
+ Increment
24
+ </a>
25
+ Count: {{ counter.count }}
24
26
  <span ref="span"></span>
25
27
  </template>
@@ -21,6 +21,8 @@ function useCounter() {
21
21
  const { count, increment } = useCounter();
22
22
  </script>
23
23
  <template>
24
- <a href="javascript:void(0)" @click="increment">Increment</a>
24
+ <a href="javascript:void(0)" @click="increment">
25
+ Increment
26
+ </a>
25
27
  Count: {{ count }} <br />
26
28
  </template>
@@ -19,7 +19,9 @@ const { span } = counter.toRefs(['span']);
19
19
  */
20
20
  </script>
21
21
  <template>
22
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
22
+ <a href="javascript:void(0)" @click="() => counter.increment()">
23
+ Increment
24
+ </a>
23
25
  Count: {{ counter.count }}
24
26
  <span ref="span"></span>
25
27
  </template>
@@ -17,6 +17,8 @@ class Counter {
17
17
  const counter = ivue(Counter);
18
18
  </script>
19
19
  <template>
20
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
20
+ <a href="javascript:void(0)" @click="() => counter.increment()">
21
+ Increment
22
+ </a>
21
23
  Count: {{ counter.count }} (onMounted we set it to 100)
22
24
  </template>
@@ -23,6 +23,8 @@ class Counter {
23
23
  const counter = ivue(Counter);
24
24
  </script>
25
25
  <template>
26
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
26
+ <a href="javascript:void(0)" @click="() => counter.increment()">
27
+ Increment
28
+ </a>
27
29
  Count: {{ counter.count }} (Click 5 times to get an alert)
28
30
  </template>
@@ -17,12 +17,14 @@ class Counter {
17
17
  }
18
18
 
19
19
  /**
20
- * NOTICE that: ivue(ClassName, ...args) uses TypeScript to infer
20
+ * NOTICE that: ivue(ClassName, ...args) uses TypeScript to infer
21
21
  * the correct argument types that you need to pass to the constructor.
22
22
  */
23
23
  const counter = ivue(Counter, props);
24
24
  </script>
25
25
  <template>
26
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
26
+ <a href="javascript:void(0)" @click="() => counter.increment()">
27
+ Increment
28
+ </a>
27
29
  Count: {{ counter.count }}
28
30
  </template>
@@ -30,6 +30,8 @@ class Counter {
30
30
  const counter = ivue(Counter, props, emit);
31
31
  </script>
32
32
  <template>
33
- <a href="javascript:void(0)" @click="() => counter.increment()">Increment</a>
33
+ <a href="javascript:void(0)" @click="() => counter.increment()">
34
+ Increment
35
+ </a>
34
36
  Count: {{ counter.count }}
35
37
  </template>
@@ -1,7 +1,7 @@
1
1
  import { useMouse } from '@vueuse/core';
2
- import { iref, iuse, type UseComposable } from 'ivue';
2
+ import { iref, iuse, type Use } from 'ivue';
3
3
 
4
- type UseMouse = UseComposable<typeof useMouse>;
4
+ type UseMouse = Use<typeof useMouse>;
5
5
 
6
6
  export class CustomMouse {
7
7
  x: UseMouse['x'];
@@ -8,4 +8,5 @@
8
8
  ## Extend Emits
9
9
  ## Extend Slots
10
10
  ## Extend Classes
11
- ## Extend Components
11
+ ## Extend Components
12
+ ## Convert Legacy Classes to Reactive Classes with `ivue` {#legacy-to-reactive}
@@ -28,17 +28,26 @@ Core `ivue(className, ...args)` initializer is able to infer and validate the co
28
28
 
29
29
  ### `iref()`
30
30
 
31
- Create a regular `vue` Ref but cast the type to the internal unreactive type, because properties auto-unwrap in `reactive()` object that is being created by `ivue` upon initialization.
31
+ Is simply an alias to Vue 3 `ref()` function but casts the type to the internal unreactive type, because properties auto-unwrap in `reactive()` object that is being created by `ivue` upon initialization.
32
+
33
+ ### `ishallowRef()`
34
+
35
+ Is simply an alias Vue 3 `shallowRef()` function but casts the type to the internal unreactive type, because properties auto-unwrap in `reactive()` object that is being created by `ivue` upon initialization.
32
36
 
33
37
  ### `iuse()`
34
38
 
39
+
35
40
  This function unwraps the type of any composable return to the bare values without `.value`, because properties auto-unwrap in `reactive()` object that is being created by `ivue` upon initialization.
36
41
 
42
+ ## Core Methods
43
+ ### `.constructor()`
44
+ Native Class API `.constructor()` is mainly used to assign and cast Vue 3 Refs back to their original types. `.constructor()` should not be used to work with reactive state. Use `.init()` for reactive purposes.
45
+
37
46
  ### `.init()`
38
47
 
39
48
  ---
40
49
 
41
- `.init()` method is auto-run on `ivue()` initialization after `constructor()` is run.
50
+ `.init()` method is auto-run on `ivue()` initialization after `.constructor()` is run.
42
51
  `.init()` has access to the reactive state of the object via `this`.
43
52
 
44
53
  :::warning NOTICE
@@ -70,6 +79,13 @@ This improves performance if `box` has many other properties that we do not need
70
79
 
71
80
  **Returns:** `IVueRefs<InstanceType<T>>`
72
81
 
82
+ ## Core Types
83
+
84
+ ### `IVue` {#IVue}
85
+
86
+ ### `Use` {#Use}
87
+
88
+
73
89
  ## Utility Functions
74
90
 
75
91
  ### `propsWithDefaults()`
@@ -89,6 +105,10 @@ Combines statically written defaults object with the runtime type definition of
89
105
 
90
106
  ## Utility Types
91
107
 
108
+ ---
109
+
110
+ Extracts and unwraps (de-Refs) the real types of Vue 3 composable definition to make it compatible with `ivue`.
111
+
92
112
  ### `ExtractPropDefaultTypes`
93
113
 
94
114
  Extracts types of the default types definition. This type can be used to validate against the actual defaults definition to make sure both definitions are in sync.
@@ -107,8 +127,3 @@ Extracts types of a runtime emits declaration.
107
127
 
108
128
  Allows you to extend slots of a given slot interface.
109
129
 
110
- ### `UseComposable`
111
-
112
- ---
113
-
114
- Extracts and unwraps (de-Refs) the real types of Vue 3 composable definition to make it compatible with `ivue`.
@@ -7,7 +7,7 @@
7
7
  ## Dos and Don'ts
8
8
 
9
9
  ```ts
10
- type UseMouse = UseComposable<typeof useMouse>;
10
+ type UseMouse = Use<typeof useMouse>;
11
11
  /**
12
12
  * Example of a properly defined ivue class.
13
13
  */
@@ -75,7 +75,7 @@ class Counter {
75
75
  }
76
76
  }
77
77
 
78
- /** ✓ Properly intilized IVUE class runner. */
78
+ /** ✓ Properly initialized IVUE class runner. */
79
79
  const counter = ivue(Counter, props, emit);
80
80
  ```
81
81
 
@@ -97,22 +97,22 @@ Next, we convert the types back to their normal types as if they have no reactiv
97
97
  Arrow functions break full extensibility of classes because they carry their own context at the point of declaration, so avoid using them inside of `ivue` classes.
98
98
  :::
99
99
 
100
- ## constructor() vs .init()
100
+ ## `.constructor()` vs `.init()`
101
101
 
102
- #### Use `constructor()` to assign properties of the class and cast Refs to Unwrapped bare types. <br />
102
+ #### Use `.constructor()` to assign properties of the class and cast Refs to Unwrapped bare types. <br />
103
103
 
104
104
  #### Use `.init()` to declare reactive state functions like `watch`, `watchEffect`, and lifecycle hooks like `onMounted`, `onBeforeMount` etc, do assignments of reactive properties, since `.init()` already has access to `reactive()` state through `this`.<br />
105
105
 
106
106
  <hr />
107
107
 
108
- Inside the `constructor()` method you still have access to non-reactive state, because when `constructor()` is initialized, it does NOT yet have access to the reactive properties of the class, since it was not yet converted to `reactive()` by `ivue`, so if you use the properties like Refs or ComputedRefs inside `constructor()` you would have to use them with the `.value`.
108
+ Inside the `.constructor()` method you still have access to non-reactive state, because when `.constructor()` is initialized, it does NOT yet have access to the reactive properties of the class, since it was not yet converted to `reactive()` by `ivue`, so if you use the properties like Refs or ComputedRefs inside `.constructor()` you would have to use them with the `.value`.
109
109
 
110
- As a general rule, there is no need to manipulate the values in the `constructor()`, use constructor only for assigning the properties and casting the types of those assigned properties to the unwrapped (de-Refed) final state of the resulting `reactive()` object.
110
+ As a general rule, there is no need to manipulate the values in the `.constructor()`, use constructor only for assigning the properties and casting the types of those assigned properties to the unwrapped (de-Refed) final state of the resulting `reactive()` object.
111
111
 
112
- **Let's look at a `constructor()` vs `.init()` example:**
112
+ **Let's look at a `.constructor()` vs `.init()` example:**
113
113
 
114
114
  ::: code-group
115
- <<< @/components/guidelines/CounterExternalRefsDetailed.vue{5,9-13,16-20,29,32,40 vue:line-numbers}
115
+ <<< @/components/guidelines/CounterExternalRefsDetailed.vue{vue:line-numbers}
116
116
  :::
117
117
  :::details For this example we initialize the component like this:
118
118
 
@@ -132,7 +132,7 @@ As a general rule, there is no need to manipulate the values in the `constructor
132
132
 
133
133
  The key to working with `ivue` is understanding correctly the way Vue 3 does automatic Unwrapping of Refs when they are passed into the `reactive()` object. In that regard we are not relying on some magic `ivue` behavior but rather the default behavior of `reactive()` Vue 3 function.
134
134
 
135
- To match that unwrapping behavior, our class needs to Unwrap (or de-Ref) the types of Composables, Refs, ComputedRefs, if they are being passed into the constructor, to get their raw basic types those Refs are pointing to, so that you can start operating in the `ivue` environment, where there is no need to worry about `.value`. This unwrapping should be mainly done inside the `constructor()` method.
135
+ To match that unwrapping behavior, our class needs to Unwrap (or de-Ref) the types of Composables, Refs, ComputedRefs, if they are being passed into the constructor, to get their raw basic types those Refs are pointing to, so that you can start operating in the `ivue` environment, where there is no need to worry about `.value`. This unwrapping should be mainly done inside the `.constructor()` method.
136
136
 
137
137
  ## Naming Conventions
138
138
 
@@ -4,26 +4,6 @@ import CounterBasic from '../components/usage/CounterBasic.vue'
4
4
 
5
5
  # How it works?
6
6
 
7
- ## What ivue is NOT?
8
-
9
- To understand how ivue works and how it does it, it is important to understand what it does not do.
10
-
11
- ::: info `ivue` is different from other class based libraries
12
- &mdash; &nbsp;`ivue` does NOT inherit from a base Class.<br />
13
- &mdash; &nbsp;`ivue` does NOT use Decorators to achieve its objectives.<br />
14
- &mdash; &nbsp;`ivue` does NOT alter Vue 3 underlying behavior, but rather relies on it.<br />
15
- &mdash; &nbsp;`ivue` is NOT the same as Class Components (though you can build components with it).<br />
16
- &mdash; &nbsp;`ivue` aims to be opaque, by giving the developer the Class API reactivity system.<br />
17
- &mdash; &nbsp;`ivue` omits custom implementations of IOC Container, Decorators & Mixins, etc. by design.<br />
18
- &mdash; &nbsp;`ivue` enforces a sane default standard of operation to contain the ever flexible Class API.<br />
19
- :::
20
-
21
- ::: tip IVUE IMPLEMENTS MINIMAL API ARCHITECTURE
22
- Things like IOC Container, Decorators, Traits, Mixins, etc. were omitted by design to slim down the surface area and scope of `ivue` core purpose, which was JavaScript / TypeScript Class API based reactivity. Any Traits, Decorators & IOC Container can be built around it using third-party libraries or roll your own systems. You are more than welcome to contribute in this area!
23
- :::
24
-
25
- ## How it works?
26
-
27
7
  ```ts
28
8
  export function ivue<T extends AnyClass>(
29
9
  className: T,
@@ -7,9 +7,9 @@ The original inspiration for `ivue` comes from `MobX` React state management lib
7
7
 
8
8
  ## Epiphany
9
9
 
10
- After building several ports from `MobX` state management library to `VueJS` to reactivity system I realized that Vue itself is far superior in its design and perfomance and can solve the same problem without relying on second hand-library, but for that my evolution of understanding of how JavaScript getters and setters work needed to happen.
10
+ After building several ports from `MobX` state management library to `VueJS` to reactivity system I realized that Vue itself is far superior in its design and performance and can solve the same problem without relying on second hand-library, but for that my evolution of understanding of how JavaScript getters and setters work needed to happen.
11
11
 
12
- And one lucky and sunny day driving back from work in an eureka moment of light it occured to me how to use Vue 3 computeds in place of getters in classes (Yes, apparently my brain does coding while driving a car).
12
+ And one lucky and sunny day driving back from work in an eureka moment of light it occurred to me how to use Vue 3 computeds in place of getters in classes (Yes, apparently my brain does coding while driving a car).
13
13
 
14
14
  `ivue` relies on this very simple discovery of how to elegantly convert getters into Vue 3 computeds.
15
15
 
@@ -28,5 +28,5 @@ By default `ivue` does not rely on decorators, though you can use decorators if
28
28
 
29
29
  ## The Rest is Up To You
30
30
  `ivue` is like a small mustard seed core for the big tree trunk of Class Based Reactive applications to be built around it, that's why the path of utter simplicity was chosen.
31
- Everything else like an Inversion of Control (IOC) system, Traits, Mixins, Decorators can be built around the core `ivue` architecture and is upto the community of enthusiatic open source contributors, please share with us your vision of how you and all of can use `ivue` better.
31
+ Everything else like an Inversion of Control (IOC) system, Traits, Mixins, Decorators can be built around the core `ivue` architecture and is up to the community of enthusiastic open source contributors, please share with us your vision of how you and all of can use `ivue` better.
32
32
 
@@ -35,23 +35,37 @@ See: [VueJs.org &ndash; Reactivity Transform](https://vuejs.org/guide/extras/rea
35
35
 
36
36
  `ivue` is fully interoperable with Composition API and does not work against, but rather with it, so you can use all of ecosystems composables seamlessly.
37
37
 
38
- `ivue` also offers a set of functions and utility types to make extensible & exportable props defaults, extensible emits and extensible slots possible.
38
+ `ivue` also offers a set of functions and utility types to make extensible & exportable props defaults, extensible emits, extensible slots, etc. and much more possible.
39
39
 
40
+ `ivue` aims to be opaque, by giving the developer the Class API reactivity system.
40
41
 
41
- ## Classes in the Ecosystem
42
+ `ivue` omits custom implementations of IOC Container, Decorators, Mixins, etc. by design.
43
+
44
+ `ivue` enforces a sane default standard of operation to contain the ever flexible Class API.
45
+
46
+ `ivue` uses Powerful Cutting Edge TypeScript to transform Vue 3 Refs to their base types, infer Class constructor arguments, infer Composable return types and function arguments and much more, making Object Oriented DX Experience with Vue 3 a breeze.
47
+
48
+ ## OOP and TypeScript Class API in the Ecosystem
42
49
 
43
50
  With failed implementations of classes in React and also failed implementations using class components in Vue 2 / 3, the ecosystem decided that classes are bad and moved to pure procedural designs.
44
51
 
45
52
  While procedural programming has its strength, it also comes with its own weaknesses, like lack of inheritance, lack of `this` context, and thus lack of true composition.
46
53
 
47
- ::: info IVUE IS DIFFERENT
48
- &ndash; &nbsp;`ivue` does NOT inherit from a base class<br />
49
- &ndash; &nbsp;`ivue` does NOT use decorators to achieve its objectives<br />
50
- &ndash; &nbsp;`ivue` does NOT alter Vue 3 underlying behavior<br />
51
- &ndash; &nbsp;`ivue` is NOT the same as class components (though you can build components with it)<br />
54
+ ## `ivue` is different
55
+
56
+ &mdash; &nbsp;`ivue` does NOT inherit from a base Class.<br />
57
+ &mdash; &nbsp;`ivue` does NOT use Decorators to achieve its objectives.<br />
58
+ &mdash; &nbsp;`ivue` does NOT alter Vue 3 underlying behavior, but rather relies on it.<br />
59
+ &mdash; &nbsp;`ivue` is NOT Class Components (though you can build components with it).<br />
60
+
61
+
62
+ ::: tip IVUE IMPLEMENTS MINIMAL API ARCHITECTURE
63
+ Things like IOC Container, Decorators, Traits, Mixins, etc. were omitted by design to slim down the surface area and scope of `ivue` core purpose, which was JavaScript / TypeScript Class API based reactivity. Any Traits, Decorators & IOC Container can be built around it using third-party libraries or roll your own systems. You are more than welcome to contribute in this area!
52
64
  :::
53
65
 
54
- ## Infinite Vue Class Achitecture
66
+
67
+
68
+ ## Infinite Vue Class Architecture
55
69
 
56
70
  `ivue` replicates native JavaScript / TypeScript class implementation by extending descriptors (getters and setters) up the whole prototype ancestors chain thus supporting classical inheritance.
57
71
 
package/docs/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "eslint-plugin-import": "^2.29.1",
19
19
  "eslint-plugin-vue": "^9.14.1",
20
20
  "execa": "^8.0.0",
21
- "ivue": "^1.2.1",
21
+ "ivue": "^1.2.4",
22
22
  "typescript": "^4.5.4",
23
23
  "vite-plugin-dynamic-import": "^1.5.0",
24
24
  "vite-tsconfig-paths": "^4.3.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ivue",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Infinite Vue – Class Based Architecture for Vue 3",
5
5
  "type": "module",
6
6
  "exports": {
@@ -26,6 +26,11 @@
26
26
  "vue": "^3.0.0",
27
27
  "vue-demi": "^0.0.0"
28
28
  },
29
+ "peerDependenciesMeta": {
30
+ "vue-demi": {
31
+ "optional": true
32
+ }
33
+ },
29
34
  "devDependencies": {
30
35
  "@cypress/vite-dev-server": "^5.0.2",
31
36
  "@cypress/vue": "^5.0.3",