ivue 1.5.2 → 1.5.4

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 (139) hide show
  1. package/package.json +5 -1
  2. package/.editorconfig +0 -9
  3. package/.eslintignore +0 -7
  4. package/.eslintrc.js +0 -120
  5. package/.github/workflows/ci.yml +0 -68
  6. package/.idea/codeStyles/Project.xml +0 -65
  7. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  8. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  9. package/.idea/ivue.iml +0 -8
  10. package/.idea/modules.xml +0 -8
  11. package/.idea/php.xml +0 -19
  12. package/.idea/vcs.xml +0 -6
  13. package/.prettierrc +0 -5
  14. package/coverage/base.css +0 -224
  15. package/coverage/block-navigation.js +0 -87
  16. package/coverage/clover.xml +0 -191
  17. package/coverage/coverage-final.json +0 -3
  18. package/coverage/favicon.png +0 -0
  19. package/coverage/index.html +0 -131
  20. package/coverage/index.ts.html +0 -88
  21. package/coverage/ivue.ts.html +0 -1753
  22. package/coverage/prettify.css +0 -1
  23. package/coverage/prettify.js +0 -2
  24. package/coverage/sort-arrow-sprite.png +0 -0
  25. package/coverage/sorter.js +0 -196
  26. package/demo/App.vue +0 -11
  27. package/demo/main.ts +0 -6
  28. package/demo/vite.config.ts +0 -12
  29. package/docs/.editorconfig +0 -9
  30. package/docs/.eslintignore +0 -7
  31. package/docs/.eslintrc.js +0 -120
  32. package/docs/.prettierrc +0 -5
  33. package/docs/docs/.vitepress/config.ts +0 -172
  34. package/docs/docs/.vitepress/dist/404.html +0 -21
  35. package/docs/docs/.vitepress/dist/api/ivue.html +0 -24
  36. package/docs/docs/.vitepress/dist/api/propsWithDefaults.html +0 -24
  37. package/docs/docs/.vitepress/dist/assets/api_ivue.md.DyFbv52x.js +0 -1
  38. package/docs/docs/.vitepress/dist/assets/api_ivue.md.DyFbv52x.lean.js +0 -1
  39. package/docs/docs/.vitepress/dist/assets/api_propsWithDefaults.md.C6C7ZBZl.js +0 -1
  40. package/docs/docs/.vitepress/dist/assets/api_propsWithDefaults.md.C6C7ZBZl.lean.js +0 -1
  41. package/docs/docs/.vitepress/dist/assets/app.BEuVrZlt.js +0 -1
  42. package/docs/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.BuKNEz2z.js +0 -1
  43. package/docs/docs/.vitepress/dist/assets/chunks/Button.vue_vue_type_script_setup_true_lang.Bynntqk6.js +0 -1
  44. package/docs/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.CrwYL8pk.js +0 -7
  45. package/docs/docs/.vitepress/dist/assets/chunks/framework.CvEKxEoK.js +0 -1
  46. package/docs/docs/.vitepress/dist/assets/chunks/index.es.DRFH_cBG.js +0 -1
  47. package/docs/docs/.vitepress/dist/assets/chunks/theme.CvibXqSO.js +0 -2
  48. package/docs/docs/.vitepress/dist/assets/index.md.mLYKdUe1.js +0 -1
  49. package/docs/docs/.vitepress/dist/assets/index.md.mLYKdUe1.lean.js +0 -1
  50. package/docs/docs/.vitepress/dist/assets/inter-italic-cyrillic-ext.r48I6akx.woff2 +0 -0
  51. package/docs/docs/.vitepress/dist/assets/inter-italic-cyrillic.By2_1cv3.woff2 +0 -0
  52. package/docs/docs/.vitepress/dist/assets/inter-italic-greek-ext.1u6EdAuj.woff2 +0 -0
  53. package/docs/docs/.vitepress/dist/assets/inter-italic-greek.DJ8dCoTZ.woff2 +0 -0
  54. package/docs/docs/.vitepress/dist/assets/inter-italic-latin-ext.CN1xVJS-.woff2 +0 -0
  55. package/docs/docs/.vitepress/dist/assets/inter-italic-latin.C2AdPX0b.woff2 +0 -0
  56. package/docs/docs/.vitepress/dist/assets/inter-italic-vietnamese.BSbpV94h.woff2 +0 -0
  57. package/docs/docs/.vitepress/dist/assets/inter-roman-cyrillic-ext.BBPuwvHQ.woff2 +0 -0
  58. package/docs/docs/.vitepress/dist/assets/inter-roman-cyrillic.C5lxZ8CY.woff2 +0 -0
  59. package/docs/docs/.vitepress/dist/assets/inter-roman-greek-ext.CqjqNYQ-.woff2 +0 -0
  60. package/docs/docs/.vitepress/dist/assets/inter-roman-greek.BBVDIX6e.woff2 +0 -0
  61. package/docs/docs/.vitepress/dist/assets/inter-roman-latin-ext.4ZJIpNVo.woff2 +0 -0
  62. package/docs/docs/.vitepress/dist/assets/inter-roman-latin.Di8DUHzh.woff2 +0 -0
  63. package/docs/docs/.vitepress/dist/assets/inter-roman-vietnamese.BjW4sHH5.woff2 +0 -0
  64. package/docs/docs/.vitepress/dist/assets/pages_advanced-usage.md.Xwq8hk_w.js +0 -1
  65. package/docs/docs/.vitepress/dist/assets/pages_advanced-usage.md.Xwq8hk_w.lean.js +0 -1
  66. package/docs/docs/.vitepress/dist/assets/pages_api.md.Bo9Kusmf.js +0 -1
  67. package/docs/docs/.vitepress/dist/assets/pages_api.md.Bo9Kusmf.lean.js +0 -1
  68. package/docs/docs/.vitepress/dist/assets/pages_browse-code.md.DtJJKz-E.js +0 -556
  69. package/docs/docs/.vitepress/dist/assets/pages_browse-code.md.DtJJKz-E.lean.js +0 -1
  70. package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.BEgX6PyX.js +0 -563
  71. package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.BEgX6PyX.lean.js +0 -1
  72. package/docs/docs/.vitepress/dist/assets/pages_guidelines.md.D5gNjB3w.js +0 -112
  73. package/docs/docs/.vitepress/dist/assets/pages_guidelines.md.D5gNjB3w.lean.js +0 -112
  74. package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.YjizQt3g.js +0 -559
  75. package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.YjizQt3g.lean.js +0 -559
  76. package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.C02KZK0J.js +0 -1
  77. package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.C02KZK0J.lean.js +0 -1
  78. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.B6foeVXQ.js +0 -1
  79. package/docs/docs/.vitepress/dist/assets/pages_introduction.md.B6foeVXQ.lean.js +0 -1
  80. package/docs/docs/.vitepress/dist/assets/pages_usage.md.BlTPXw5A.js +0 -591
  81. package/docs/docs/.vitepress/dist/assets/pages_usage.md.BlTPXw5A.lean.js +0 -591
  82. package/docs/docs/.vitepress/dist/assets/style.Dtxde_a0.css +0 -1
  83. package/docs/docs/.vitepress/dist/hashmap.json +0 -1
  84. package/docs/docs/.vitepress/dist/index.html +0 -25
  85. package/docs/docs/.vitepress/dist/pages/advanced-usage.html +0 -24
  86. package/docs/docs/.vitepress/dist/pages/api.html +0 -30
  87. package/docs/docs/.vitepress/dist/pages/browse-code.html +0 -579
  88. package/docs/docs/.vitepress/dist/pages/getting-started.html +0 -586
  89. package/docs/docs/.vitepress/dist/pages/guidelines.html +0 -136
  90. package/docs/docs/.vitepress/dist/pages/how-it-works.html +0 -582
  91. package/docs/docs/.vitepress/dist/pages/how-its-made.html +0 -24
  92. package/docs/docs/.vitepress/dist/pages/introduction.html +0 -25
  93. package/docs/docs/.vitepress/dist/pages/usage.html +0 -615
  94. package/docs/docs/.vitepress/theme/index.js +0 -5
  95. package/docs/docs/.vitepress/theme/main.css +0 -29
  96. package/docs/docs/api/ivue.md +0 -0
  97. package/docs/docs/api/propsWithDefaults.md +0 -0
  98. package/docs/docs/components/Button.vue +0 -13
  99. package/docs/docs/components/Component.vue +0 -20
  100. package/docs/docs/components/advanced-usage/ConvertLegacy.vue +0 -58
  101. package/docs/docs/components/guidelines/CounterExternalRefsDetailed.vue +0 -41
  102. package/docs/docs/components/usage/CounterBasic.vue +0 -18
  103. package/docs/docs/components/usage/CounterComposables.vue +0 -29
  104. package/docs/docs/components/usage/CounterComposablesDestructuring.vue +0 -55
  105. package/docs/docs/components/usage/CounterComposablesIvue.vue +0 -30
  106. package/docs/docs/components/usage/CounterComposablesIvueDestructuring.vue +0 -48
  107. package/docs/docs/components/usage/CounterComputeds.vue +0 -26
  108. package/docs/docs/components/usage/CounterComputedsDisabled.vue +0 -33
  109. package/docs/docs/components/usage/CounterDefineExpose.vue +0 -12
  110. package/docs/docs/components/usage/CounterDefineExposeAdvanced.vue +0 -24
  111. package/docs/docs/components/usage/CounterDefineExposeClass.ts +0 -11
  112. package/docs/docs/components/usage/CounterExternalRefs.vue +0 -27
  113. package/docs/docs/components/usage/CounterInsideComposables.vue +0 -28
  114. package/docs/docs/components/usage/CounterInternalRefs.vue +0 -27
  115. package/docs/docs/components/usage/CounterLifecycleHooks.vue +0 -24
  116. package/docs/docs/components/usage/CounterWatch.vue +0 -30
  117. package/docs/docs/components/usage/CounterWithProps.vue +0 -30
  118. package/docs/docs/components/usage/CounterWithPropsAndEmits.vue +0 -37
  119. package/docs/docs/components/usage/classes/CustomMouse.ts +0 -23
  120. package/docs/docs/components/usage/functions/useCustomMouse.ts +0 -25
  121. package/docs/docs/index.md +0 -53
  122. package/docs/docs/pages/advanced-usage.md +0 -12
  123. package/docs/docs/pages/api.md +0 -129
  124. package/docs/docs/pages/browse-code.md +0 -18
  125. package/docs/docs/pages/getting-started.md +0 -32
  126. package/docs/docs/pages/guidelines.md +0 -139
  127. package/docs/docs/pages/how-it-works.md +0 -65
  128. package/docs/docs/pages/how-its-made.md +0 -32
  129. package/docs/docs/pages/introduction.md +0 -83
  130. package/docs/docs/pages/usage.md +0 -402
  131. package/docs/package.json +0 -37
  132. package/docs/scripts/gh-pages-deploy.js +0 -34
  133. package/docs/vite-env.d.ts +0 -7
  134. package/docs/vite.config.ts +0 -20
  135. package/index.html +0 -14
  136. package/tsconfig.json +0 -25
  137. package/vite-env.d.ts +0 -7
  138. package/vite.config.ts +0 -50
  139. package/vitest.config.ts +0 -19
@@ -1,23 +0,0 @@
1
- import { useMouse } from '@vueuse/core';
2
- import { iref, iuse, type Use } from 'ivue';
3
-
4
- type UseMouse = Use<typeof useMouse>;
5
-
6
- export class CustomMouse {
7
- x: UseMouse['x'];
8
- y: UseMouse['y'];
9
-
10
- _sum = iref(0);
11
-
12
- constructor(public requiredProp: number) {
13
- ({ x: this.x, y: this.y } = iuse(useMouse));
14
- }
15
-
16
- sum() {
17
- this._sum = this.x + this.y + this.requiredProp;
18
- }
19
-
20
- get total() {
21
- return this._sum;
22
- }
23
- }
@@ -1,25 +0,0 @@
1
- import { computed, ref } from 'vue';
2
- import { useMouse } from '@vueuse/core';
3
-
4
- export function useCustomMouse(requiredProp: number) {
5
- const { x, y } = useMouse();
6
-
7
- const _sum = ref(0);
8
-
9
- function sum() {
10
- _sum.value = x.value + y.value + requiredProp;
11
- }
12
-
13
- const total = computed(() => {
14
- // Returning without .value, not entirely correctly, but will still work in Vue template.
15
- // This is to test the impressive IVue unwrapping capabilities of deeply nested and confusing Refs
16
- return _sum;
17
- });
18
-
19
- return {
20
- x,
21
- y,
22
- sum,
23
- total,
24
- };
25
- }
@@ -1,53 +0,0 @@
1
- <script setup lang="ts">
2
- import Button from './components/Button.vue'
3
-
4
- </script>
5
- # <span style="font-family: 'Public Sans'; ">ivue ∞ Infinite Vue</span> Documentation
6
-
7
-
8
- ## About
9
-
10
- **<span style="font-family: 'Public Sans'; font-size: 125%;">ivue ∞ Infinite Vue</span>** is a class based composable architecture for Vue 3, that unlocks infinite scalability for Vue 3 based apps. It allows you to extend the regular Vue 3 in a simple and elegant Object Oriented way.
11
-
12
- ## `ivue` is
13
-
14
-
15
- <div style="padding-left:20px; font-size: 20px; line-height: 32px;">
16
- ∞&nbsp; Simple like Options API<br />
17
- ∞&nbsp; Flexible like Composition API<br />
18
- ∞&nbsp; Extensible like TypeScript Class API<br />
19
- ∞&nbsp; Robust, Minimal, Opaque & Unobtrusive<br />
20
- ∞&nbsp; 100% VSCode / Intellij IDE Autocomplete Intellisense<br />
21
- ∞&nbsp; 100% Vue 3 Compatible<br />
22
- ∞&nbsp; 100% Test Covered<br />
23
- ∞&nbsp; 100% Type Safe<br />
24
- ∞&nbsp; Production Ready<br />
25
- ∞&nbsp; Just <code>1.1kb</code> gzipped!<br />
26
- </div>
27
-
28
-
29
- ## Features
30
- <div style="padding-left:20px; font-size: 18px;line-height: 28px; ">
31
- &mdash;&nbsp; Extensible Classes using JavaScript / TypeScript native Class API<br />
32
- &mdash;&nbsp; Can be used as a Global Store and a ViewModel for Components<br />
33
- &mdash;&nbsp; Enhances Extensibility of Props Defaults, Props, Slots<br />
34
- &mdash;&nbsp; Improves DX by elegantly dealing with <code>.value</code><br />
35
- &mdash;&nbsp; Allows for Fully Extensible Component Architecture<br />
36
- &mdash;&nbsp; Extends Vue 3 TypeScript Capability<br />
37
- &mdash;&nbsp; Zero dependencies except Vue 3<br />
38
- </div>
39
-
40
-
41
-
42
- ## Philosophy
43
- <center>
44
- Perfection is achieved, not when there is nothing more to add, <br />
45
- but when there is nothing left to take away.
46
-
47
- <div style="padding-top: 5px; color:#888; font-size: 90%;">― Antoine de Saint-Exupéry</div>
48
- </center>
49
-
50
- ## Next Step
51
-
52
- <Button href="/pages/getting-started.html" label="Geting Started" /> &nbsp; or &nbsp; <Button href="/pages/introduction.html" label="Read Introduction" />
53
-
@@ -1,12 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
- ## Extend Props
4
- ### Typed Props
5
- ### Runtime Props
6
- ## Extend Props Defaults
7
- ### Runtime Props
8
- ## Extend Emits
9
- ## Extend Slots
10
- ## Extend Classes
11
- ## Extend Components
12
- ## Convert Legacy Classes to Reactive Classes with `ivue` {#legacy-to-reactive}
@@ -1,129 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- # API
5
-
6
- ## Core Functions
7
-
8
- ### `ivue()`
9
-
10
- ---
11
-
12
- ```ts
13
- export function ivue<T extends AnyClass>(
14
- className: T,
15
- ...args: InferredArgs<T>
16
- ): IVue<T>;
17
- ```
18
-
19
- Core `ivue(className, ...args)` initializer is able to infer and validate the constrcutor argument types of AnyClass and passes those arguments to the constructor of `AnyClass` internally.
20
-
21
- `ivue(className, arg1, arg2, arg3...)` allows you to pass any number of arguments into the class `constructor(arg1, arg2, arg3...)`
22
-
23
- `ivue()` initializer function returns an extended Vue 3 `reactive()` object in which getters and setters are internally converted to computeds and adds `.toRefs()` method to the created object. Computeds auto-unwrap themselves when they are accessed as a reactive object property, so the `.value` properties and computeds get flattened in the resulting object and do not require `.value` to be accessed.
24
-
25
- `ivue()` replicates native JavaScript / TypeScript class implementation by extending descriptors (getters and setters) up the whole prototype ancestors chain thus supporting classical inheritance.
26
-
27
- **Returns:** `<IVue<T>>` or `ivue` `reactive()` object of an `AnyClass` class with flattened (de-Refed) `Refs` and `ComputedRefs` as properties.
28
-
29
- ### `iref()`
30
-
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.
36
-
37
- ### `iuse()`
38
-
39
-
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.
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
-
46
- ### `.init()`
47
-
48
- ---
49
-
50
- `.init()` method is auto-run on `ivue()` initialization after `.constructor()` is run.
51
- `.init()` has access to the reactive state of the object via `this`.
52
-
53
- :::warning NOTICE
54
- `.init()` method has no arguments and you should never need to run this method manually.
55
- :::
56
-
57
- :::tip NEED ASYNC/AWAIT?
58
- Use `async init()` if you need `await` functionality.
59
- :::
60
-
61
- **Returns:** `void | Promise<void>`
62
-
63
- ### `.toRefs()`
64
-
65
- ---
66
-
67
- ```ts
68
- function toRefs(props?: (keyof InstanceType<T>)[]): IVueRefs<InstanceType<T>>;
69
- ```
70
-
71
- Converts an `ivue` object to a Vue 3 Composable with nested refs.
72
-
73
- :::tip You can pass the name of the properties to `.toRefs(properties)`
74
- ```ts
75
- const { width, height } = ivue(Box).toRefs(['width', 'height']);
76
- ```
77
- This improves performance if `box` has many other properties that we do not need.
78
- :::
79
-
80
- **Returns:** `IVueRefs<InstanceType<T>>`
81
-
82
- ## Core Types
83
-
84
- ### `IVue` {#IVue}
85
-
86
- ### `Use` {#Use}
87
-
88
-
89
- ## Utility Functions
90
-
91
- ### `propsWithDefaults()`
92
-
93
- ---
94
-
95
- ```ts
96
- export function propsWithDefaults<T extends VuePropsObject>(
97
- defaults: Record<string, any>,
98
- typedProps: T
99
- ): VuePropsWithDefaults<T>;
100
- ```
101
-
102
- Combines statically written defaults object with the runtime type definition of Vue 3 props.
103
-
104
- **Returns:** `VuePropsWithDefaults<T>`
105
-
106
- ## Utility Types
107
-
108
- ---
109
-
110
- Extracts and unwraps (de-Refs) the real types of Vue 3 composable definition to make it compatible with `ivue`.
111
-
112
- ### `ExtractPropDefaultTypes`
113
-
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.
115
-
116
- ---
117
-
118
- ### `ExtractEmitTypes`
119
-
120
- ---
121
-
122
- Extracts types of a runtime emits declaration.
123
-
124
- ### `ExtendSlots`
125
-
126
- ---
127
-
128
- Allows you to extend slots of a given slot interface.
129
-
@@ -1,18 +0,0 @@
1
- ---
2
- aside: false
3
- ---
4
- # Source code
5
- Or [Browse the source code on GitHub](https://github.com/infinite-system/ivue/blob/main/lib/ivue.ts)
6
-
7
- ## Install by Copying
8
-
9
- `ivue` is designed to be easily shareable and installable so if you are running TypeScript, you can just copy the
10
- `ivue.ts` into your repo and you are done:
11
-
12
- ::: tip NOTE
13
- This installation path is recommended only if you quickly want to tinker with the internals of ivue, as you won't be getting the latest updates. Also note that this code comes from github `main` branch latest which might also be in beta and not fully published to `npm`.
14
- :::
15
-
16
- :::code-group
17
- <<< ../../../lib/ivue.ts{ts:line-numbers} [ivue.ts]
18
- :::
@@ -1,32 +0,0 @@
1
- # Getting Started
2
-
3
- ## Install
4
-
5
- The only dependency for `ivue` is Vue 3, so it is easy to get started.
6
-
7
- In your terminal install `ivue` using:
8
- ```bash
9
- # yarn
10
- yarn add ivue
11
-
12
- # npm
13
- npm i ivue
14
-
15
- # pnpm
16
- pnpm i ivue
17
- ```
18
-
19
- ## Install by Copying
20
-
21
- `ivue` is designed to be easily shareable and installable so if you are running TypeScript, you can just copy the
22
- `ivue.ts` into your repo and you are done:
23
- :::details Click to expand the latest `ivue` source code to copy
24
-
25
- :::code-group
26
- <<< ../../../lib/ivue.ts{ts:line-numbers} [ivue.ts]
27
- :::
28
- Or [Copy from GitHub](https://github.com/infinite-system/ivue/blob/main/lib/ivue.ts)
29
-
30
- ::: tip NOTE
31
- This installation path is recommended only if you quickly want to tinker with the internals of ivue, as you won't be getting the latest updates. Also note that this code comes from github `main` branch latest which might also be in beta and not fully published to `npm`.
32
- :::
@@ -1,139 +0,0 @@
1
- <script setup lang="ts">
2
- import CounterExternalRefsDetailed from '../components/guidelines/CounterExternalRefsDetailed.vue';
3
- </script>
4
-
5
- # Guidelines
6
-
7
- ## Dos and Don'ts
8
-
9
- ```ts
10
- type UseMouse = Use<typeof useMouse>;
11
- /**
12
- * Example of a properly defined ivue class.
13
- */
14
- class Counter {
15
- /** ✓ Properly declared unwrapped composable. */
16
- mouse: UseMouse;
17
-
18
- /**
19
- * ✓ Properly declared DOM Ref.
20
- * ✓ Custom declared type of HTMLElement or null
21
- */
22
- spanElementRef = iref<HTMLElement | null>(null);
23
-
24
- constructor(public props: CounterProps, public emit: CounterEmit) {
25
- /** ✓ Properly declared auto-unwrapped composable. */
26
- this.mouse = iuse(useMouse);
27
- }
28
-
29
- /** ✓ Properly declared init function. */
30
- init() {
31
- /** ✓ Properly set lifecycle hook. */
32
- onMounted(() => {
33
- this.count = 4;
34
- });
35
-
36
- /** ✓ Properly set watch function */
37
- watch(() => this.count, (newCount) => {
38
- if (newCount === 5) {
39
- alert('You reached the count of ' + newCount + '!');
40
- }
41
- })
42
- }
43
-
44
- /**
45
- * Use iref() for the property to be auto cast to number
46
- * because refs auto-unwrap inside reactive().
47
- */
48
- count = iref(0); // ✓ Properly inferred type -> number
49
-
50
- /**
51
- * Use iref() for the property to be auto cast to number
52
- * because refs auto-unwrap inside reactive().
53
- */
54
- timesClicked = iref(0); // ✓ Properly inferred type -> number
55
-
56
- /** ✓ Properly declared function (not arrow function). */
57
- increment() {
58
- this.count++;
59
- }
60
-
61
- /** ✓ Properly declared function (not arrow function). */
62
- click() {
63
- this.increment();
64
- this.timesClicked++;
65
- }
66
-
67
- /**
68
- * Do NOT use arrow functions, arrow functions are not extensible.
69
- */
70
- increment = () => this.count++ ❌
71
-
72
- /** ✓ Properly declared computed getter. */
73
- get doubleCount() {
74
- return this.count * 2;
75
- }
76
- }
77
-
78
- /** ✓ Properly initialized IVUE class runner. */
79
- const counter = ivue(Counter, props, emit);
80
- ```
81
-
82
- ### Use ref() for properties
83
-
84
- `ivue` recommends all class properties to be defined as `ref()` to be able to interoperate with `defineExpose()`, if you simply pass reactive props which are not Refs through `defineExpose()`, they will lose reactivity. `ref()` refs just like computed refs get flattened into the `reactive()` object, so there is no need to worry about using `.value`. The `ref()` refs are necessary just internally for Vue 3 to know which refs to keep reactive.
85
-
86
- ### Unwrap (de-Ref) the types
87
-
88
- Next, we convert the types back to their normal types as if they have no reactivity at all, so `Ref<number>` is `number` in `ivue`, so rather than going in the direction of complexifying the types, we are going in the opposite direction towards simplification.
89
-
90
- ### Use standard declaration syntax for functions
91
-
92
- `ivue` recommends all class functions to be defined in plain full function style (not arrow functions), this allows all `ivue` classes to be extensible at any point. By using plain standard functions, it allows the developer to be able to override them at any time by simply extending the class.
93
-
94
- ### Do not use arrow functions in class declarations
95
-
96
- :::warning
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
- :::
99
-
100
- ## `.constructor()` vs `.init()`
101
-
102
- #### Use `.constructor()` to assign properties of the class and cast Refs to Unwrapped bare types. <br />
103
-
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
-
106
- <hr />
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`.
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.
111
-
112
- **Let's look at a `.constructor()` vs `.init()` example:**
113
-
114
- ::: code-group
115
- <<< @/components/guidelines/CounterExternalRefsDetailed.vue{vue:line-numbers}
116
- :::
117
- :::details For this example we initialize the component like this:
118
-
119
- ```vue
120
- <template>
121
- <CounterExternalRefsDetailed />
122
- </template>
123
- ```
124
-
125
- :::
126
-
127
- <div style="font-size: 18px; font-weight: 500;">Result</div>
128
-
129
- <CounterExternalRefsDetailed />
130
-
131
- ## Unwrapping Refs
132
-
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
-
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
-
137
- ## Naming Conventions
138
-
139
- To benefit from the full power of `ivue`, it is recommended to extract the classes into separate files. What has been an effective pattern is to name the classes and put them right beside components in the same folder that these classes are being used with. So if you have `CounterComponent.vue` component, it can have a class inside `CounterComponentClass.ts`, and you can store props, emits, and other runtime definitions inside `CounterComponentProps.ts`.
@@ -1,65 +0,0 @@
1
- <script setup lang="ts">
2
- import CounterBasic from '../components/usage/CounterBasic.vue'
3
- </script>
4
-
5
- # How it works?
6
-
7
- ```ts
8
- export function ivue<T extends AnyClass>(
9
- className: T,
10
- ...args: InferredArgs<T>
11
- ): IVue<T>;
12
- ```
13
-
14
- The main `ivue()` initializer function uses TypeScript to be able to infer and validate the constrcutor argument types of `AnyClass` and passes those arguments to the constructor of `AnyClass`.
15
-
16
- `ivue` allows you to pass any number of arguments into the class `constructor(arg1, arg2, arg3, ...etc)`
17
-
18
- `ivue()` initializer function returns an extended Vue 3 `reactive()` object in which getters and setters are internally converted to computeds and adds `.toRefs()` method to the created object. Computeds auto-unwrap themselves when they are accessed as a reactive object property, so the `.value` properties and computeds get flattened in the resulting object and do not require `.value` to be accessed.
19
-
20
- `ivue` replicates native JavaScript / TypeScript class implementation by extending descriptors (getters and setters) up the whole prototype ancestors chain thus supporting classical inheritance.
21
-
22
- `ivue` aims to be opaque and minimal, just doing the minimum to convert a class to a reactive object, leaving the rest to be implemented using Vue 3 Composition API inside an initializer function called `.init()`
23
-
24
- ## Usage Recommendation
25
-
26
- `ivue` recommends all class properties to be defined as `ref()` to be able to interoperate with `defineExpose()`, if you simply pass reactive props which are not Refs through `defineExpose()`, they will lose reactivity. `ref()` refs just like computed refs get flattened into the `reactive()` object, so there is no need to worry about using `.value`. The `ref()` refs are necessary just internally for Vue 3 to know which refs to keep reactive, and we just convert the types back to their normal types as if they have no reactivity at all, so `Ref<number>` is `number` in `ivue`, so rather than going in the direction of complexifying the types, we are going in the opposite direction towards simplification.
27
-
28
- `ivue` recommends all class functions, getters and setters to be defined in plain full function style (not arrow functions), this allows all `ivue` classes to be extensible at any point. By using plain standard functions, getters and setters allows for any getter, setter, function or property to be overriden by extending this class. Arrow functions break full extensibility of classes, so avoid using them inside of classes.
29
-
30
- See: [More Guidelines](/pages/guidelines.html)
31
-
32
- ## Minimal API Surface Area
33
-
34
- `ivue()` initializer function is the main core function to initialize the `ivue` reactive object<br />
35
- `iref()` ref initializer instantiates the Ref but Unwraps its type as the raw type of the Ref<br />
36
- `iuse()` function converts the type of composables to they Unwraped raw types<br />
37
- `.init()` method helps initialize the reactive state like `watch`, `onMount`, etc.<br />
38
- `.toRefs()` method allows to interoperate with Vue 3 Composables<br />
39
- Utility Types help to achieve the rest of `ivue` capabilities
40
-
41
- :::details Click to see the whole latest `ivue` source code from github main branch below:
42
- :::code-group
43
- <<< ../../../lib/ivue.ts{ts:line-numbers} [ivue.ts]
44
- :::
45
- Or [See on GitHub](https://github.com/infinite-system/ivue/blob/main/lib/ivue.ts)
46
-
47
- ## 100% Vue 3 Compatible
48
-
49
- `.toRefs()` allows the object to be converted to Vue 3 native composable structure with full `.value`s, so it can interoperate with native composables if needed. `.toRefs()` is also often used to get refs for `v-bind()` in css styles.
50
-
51
- ## 100% TypeScript Support
52
-
53
- `ivue` is on the cutting edge of TypeScript and owes its capabilities to the latest developments in TypeScript.
54
-
55
- `ivue` provides a set of utility types to make working with `Vue 3` even easier and more scalable.
56
-
57
- ## 100% Unit Tested Architecture
58
-
59
- At the current stage all of the code that is used to build `ivue` is 100% tested with 100% coverage, and aims to keep being at 100% always.
60
-
61
- You can clone the project and run `yarn test` yourself and examine the tests.
62
-
63
- ## Zero Dependencies
64
-
65
- `ivue` has zero dependencies except Vue 3.
@@ -1,32 +0,0 @@
1
-
2
- # How it's made
3
-
4
- ## Original Inspiration
5
-
6
- The original inspiration for `ivue` comes from `MobX` React state management library, where something similar is attempted to create a class based reactive observable architecture.
7
-
8
- ## Epiphany
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 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
-
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
-
14
- `ivue` relies on this very simple discovery of how to elegantly convert getters into Vue 3 computeds.
15
-
16
- ## Simplicity
17
-
18
- After many iterations where I created a whole inversion of control library for `ivue`, using lots of different decorators and event Traits, I realized that simplicity is paramount to good architecture.
19
-
20
- In that sweep of clarity, I got rid of 95% of the code that was just extra stuff and not the essence and left only `3` core functions: `ivue()`, `.init()`, `.toRefs()` only which are necessary to do everything `ivue` is set out to do.
21
-
22
- Use Composition API composables inside `.init()` function.
23
-
24
- ## Minimalism
25
-
26
- Thus `ivue` has minimal surface area of the API making it very robust and easy to test.
27
- By default `ivue` does not rely on decorators, though you can use decorators if you wish to.
28
-
29
- ## The Rest is Up To You
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 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
-
@@ -1,83 +0,0 @@
1
- <script setup lang="ts">
2
- import Button from '../components/Button.vue'
3
- </script>
4
- # What is <span style="font-family: 'Public Sans'; ">ivue ∞ Infinite Vue</span>?
5
-
6
- ## The Problem
7
-
8
- With the development of React hooks and Vue following in its footsteps with introduction of Vue 3 Composition API, the ecosystem has moved away from Options API.
9
-
10
- While providing greater flexibility and composability the Composition API has its own downsides, one of them is having to use `.value` to refer to the reactive variables which makes the development process more clunky when the App reaches a certain size.
11
-
12
- As you may know, `reactvity-transform` macros were an attempt to mitigate those issues, which turned out to create even more issues, and was discontinued.
13
-
14
- See: [VueJs.org &ndash; Reactivity Transform](https://vuejs.org/guide/extras/reactivity-transform.html)
15
-
16
- ## `ivue` is
17
- <div style="padding-left:20px; font-size: 1.2rem; line-height: 2rem;">
18
- &ndash;&nbsp; Simple like Options API<br />
19
- &ndash;&nbsp; Flexible like Composition API<br />
20
- &ndash;&nbsp; Extensible like TypeScript Class API<br />
21
- &ndash;&nbsp; Robust, Minimal, Opaque & Unobtrusive<br />
22
- &ndash;&nbsp; 100% Vue 3 Compatible<br />
23
- &ndash;&nbsp; 100% Test Covered<br />
24
- &ndash;&nbsp; 100% Type Safe<br />
25
- &ndash;&nbsp; Production Ready<br />
26
- &ndash;&nbsp; Just <code>1.1kb</code> gzipped!<br />
27
- &ndash;&nbsp; 100% VSCode / Intellij IDE Auto-complete Intellisence<br />
28
- </div>
29
-
30
- `ivue` is a powerful tool because it fully aligns itself with JavaScript / TypeScript Class API.
31
-
32
- `ivue` gives you a class based Composable capabilities with Inheritance and all the power of TypeScript Classes.
33
-
34
- `ivue` mitigates the downsides of both Composition API and Options API, uses only their strengths and brings back Object Oriented Programming to allow the development of complex and scalable apps.
35
-
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
-
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
-
40
- `ivue` aims to be opaque, by giving the developer the Class API reactivity system.
41
-
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
49
-
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.
51
-
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.
53
-
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!
64
- :::
65
-
66
-
67
-
68
- ## Infinite Vue Class Architecture
69
-
70
- `ivue` replicates native JavaScript / TypeScript class implementation by extending descriptors (getters and setters) up the whole prototype ancestors chain thus supporting classical inheritance.
71
-
72
- By using TypeScript we are able to infer the arguments of the main `ivue()` initializer function and pass the arguments to the constructor.
73
-
74
- `ivue()` initializer function returns a reactive object with getters converted to computeds and adds `.toRefs()` method to the object, `.toRefs()` allows the object to be converted to native composable structure, so it can interoperate as a composable if needed.
75
-
76
- `ivue` aims to be opaque and minimal, just doing the minimum to convert a class to a reactive object, leaving the rest to be implemented using Vue 3 Composition API inside an initializer function called `.init()`
77
-
78
- You can read more about `ivue` internal architecture in <Button href="/pages/how-it-works" label="How it works?" /> page.
79
-
80
- ## When to use Infinite Vue?
81
-
82
- When the complexity of your app or components becomes very high using `ivue` can become a natural choice to deal with that complexity. Because `.value` is abstracted away in `ivue`, everything is simply a reactive object of Refs.
83
-