ivue 1.0.2 → 1.0.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.
- package/.idea/codeStyles/Project.xml +65 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/ivue.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/php.xml +19 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +23 -7
- package/coverage/clover.xml +159 -159
- package/coverage/coverage-final.json +1 -1
- package/coverage/index.html +17 -17
- package/coverage/index.ts.html +86 -107
- package/dist/index.es.js +74 -90
- package/dist/index.umd.js +1 -1
- package/dist/src/index.d.ts +1 -196
- package/dist/src/ivue.d.ts +218 -0
- package/docs/docs/.vitepress/config.ts +110 -22
- package/docs/docs/.vitepress/dist/404.html +4 -4
- package/docs/docs/.vitepress/dist/api/ivue.html +8 -8
- package/docs/docs/.vitepress/dist/api/propsWithDefaults.html +8 -8
- package/docs/docs/.vitepress/dist/assets/{api_ivue.md.BCZ4q_0D.js → api_ivue.md.MRwb9Lcb.js} +1 -1
- package/docs/docs/.vitepress/dist/assets/{api_ivue.md.BCZ4q_0D.lean.js → api_ivue.md.MRwb9Lcb.lean.js} +1 -1
- package/docs/docs/.vitepress/dist/assets/{api_propsWithDefaults.md.Cr5FwI9o.lean.js → api_propsWithDefaults.md.CeE4IC-K.js} +1 -1
- package/docs/docs/.vitepress/dist/assets/{api_propsWithDefaults.md.Cr5FwI9o.js → api_propsWithDefaults.md.CeE4IC-K.lean.js} +1 -1
- package/docs/docs/.vitepress/dist/assets/{app.DRiljpSE.js → app.ConZRsN0.js} +1 -1
- package/docs/docs/.vitepress/dist/assets/chunks/@localSearchIndexroot.CGLWArGd.js +1 -0
- package/docs/docs/.vitepress/dist/assets/chunks/Button.vue_vue_type_script_setup_true_lang.P7niV-n8.js +1 -0
- package/docs/docs/.vitepress/dist/assets/chunks/VPLocalSearchBox.C7VDyivS.js +7 -0
- package/docs/docs/.vitepress/dist/assets/chunks/framework.CNtPHGsN.js +1 -0
- package/docs/docs/.vitepress/dist/assets/chunks/index.es.DnWLDAUc.js +1 -0
- package/docs/docs/.vitepress/dist/assets/chunks/theme.B7n-r1TY.js +2 -0
- package/docs/docs/.vitepress/dist/assets/index.md.wPLoTLBY.js +1 -0
- package/docs/docs/.vitepress/dist/assets/index.md.wPLoTLBY.lean.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_advanced-usage.md.BZgX-VP7.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_advanced-usage.md.BZgX-VP7.lean.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_api.md.C_PvCZns.js +7 -0
- package/docs/docs/.vitepress/dist/assets/pages_api.md.C_PvCZns.lean.js +7 -0
- package/docs/docs/.vitepress/dist/assets/pages_browse-code.md.CPluoaap.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_browse-code.md.CPluoaap.lean.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.knQcOZyP.js +8 -0
- package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.knQcOZyP.lean.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_guidelines.md.DddPdPom.js +101 -0
- package/docs/docs/.vitepress/dist/assets/pages_guidelines.md.DddPdPom.lean.js +101 -0
- package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.OJGcGEXF.js +4 -0
- package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.OJGcGEXF.lean.js +4 -0
- package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.Vv9Z9TEi.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_how-its-made.md.Vv9Z9TEi.lean.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_introduction.md.DrDm-R8F.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_introduction.md.DrDm-R8F.lean.js +1 -0
- package/docs/docs/.vitepress/dist/assets/pages_usage.md.zSOVjtFF.js +430 -0
- package/docs/docs/.vitepress/dist/assets/pages_usage.md.zSOVjtFF.lean.js +430 -0
- package/docs/docs/.vitepress/dist/assets/style.Fgx7OB_D.css +1 -0
- package/docs/docs/.vitepress/dist/hashmap.json +1 -1
- package/docs/docs/.vitepress/dist/index.html +9 -8
- package/docs/docs/.vitepress/dist/pages/advanced-usage.html +24 -0
- package/docs/docs/.vitepress/dist/pages/api.html +30 -0
- package/docs/docs/.vitepress/dist/pages/browse-code.html +24 -0
- package/docs/docs/.vitepress/dist/pages/getting-started.html +11 -11
- package/docs/docs/.vitepress/dist/pages/guidelines.html +125 -0
- package/docs/docs/.vitepress/dist/pages/how-it-works.html +11 -8
- package/docs/docs/.vitepress/dist/pages/how-its-made.html +24 -0
- package/docs/docs/.vitepress/dist/pages/introduction.html +9 -8
- package/docs/docs/.vitepress/dist/pages/usage.html +428 -14
- package/docs/docs/.vitepress/theme/index.js +5 -0
- package/docs/docs/.vitepress/theme/main.css +29 -0
- package/docs/docs/components/Button.vue +1 -1
- package/docs/docs/components/guidelines/CounterExternalRefsDetailed.vue +41 -0
- package/docs/docs/components/usage/CounterBasic.vue +17 -0
- package/docs/docs/components/usage/CounterComposables.vue +19 -0
- package/docs/docs/components/usage/CounterComposablesDestructuring.vue +46 -0
- package/docs/docs/components/usage/CounterComputeds.vue +25 -0
- package/docs/docs/components/usage/CounterComputedsDisabled.vue +32 -0
- package/docs/docs/components/usage/CounterDefineExpose.vue +12 -0
- package/docs/docs/components/usage/CounterDefineExposeAdvanced.vue +25 -0
- package/docs/docs/components/usage/CounterDefineExposeClass.ts +11 -0
- package/docs/docs/components/usage/CounterExternalRefs.vue +25 -0
- package/docs/docs/components/usage/CounterInsideComposables.vue +27 -0
- package/docs/docs/components/usage/CounterInternalRefs.vue +26 -0
- package/docs/docs/components/usage/CounterLifecycleHooks.vue +22 -0
- package/docs/docs/components/usage/CounterWatch.vue +25 -0
- package/docs/docs/components/usage/CounterWithProps.vue +29 -0
- package/docs/docs/components/usage/CounterWithPropsAndEmits.vue +36 -0
- package/docs/docs/components/usage/functions/useMouse.ts +22 -0
- package/docs/docs/index.md +10 -9
- package/docs/docs/pages/advanced-usage.md +11 -0
- package/docs/docs/pages/api.md +106 -0
- package/docs/docs/pages/browse-code.md +18 -0
- package/docs/docs/pages/getting-started.md +23 -5
- package/docs/docs/pages/guidelines.md +128 -0
- package/docs/docs/pages/how-it-works.md +71 -0
- package/docs/docs/pages/how-its-made.md +32 -0
- package/docs/docs/pages/introduction.md +37 -20
- package/docs/docs/pages/usage.md +347 -10
- package/docs/package.json +4 -3
- package/package.json +4 -2
- package/src/__tests__/ivue.vitest.spec.ts +228 -132
- package/src/index.ts +1 -463
- package/src/ivue.ts +495 -0
- package/vite.config.ts +4 -0
- package/docs/.env +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/framework.CEhE-9HF.js +0 -1
- package/docs/docs/.vitepress/dist/assets/chunks/theme.CldUEgAJ.js +0 -1
- package/docs/docs/.vitepress/dist/assets/index.md.B1vDz5mb.js +0 -1
- package/docs/docs/.vitepress/dist/assets/index.md.B1vDz5mb.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.C7qtPEWU.js +0 -8
- package/docs/docs/.vitepress/dist/assets/pages_getting-started.md.C7qtPEWU.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.DKizt6Ny.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_how-it-works.md.DKizt6Ny.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_introduction.md.Dkqu-XCz.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_introduction.md.Dkqu-XCz.lean.js +0 -1
- package/docs/docs/.vitepress/dist/assets/pages_usage.md.qo7ICfLC.js +0 -17
- package/docs/docs/.vitepress/dist/assets/pages_usage.md.qo7ICfLC.lean.js +0 -17
- package/docs/docs/.vitepress/dist/assets/style.BSZVsGuP.css +0 -1
- package/docs/docs/components/examples/Counter.vue +0 -17
package/coverage/index.ts.html
CHANGED
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">100% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>160/160</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
33
|
<span class="strong">100% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>71/71</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">100% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>10/10</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">100% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>160/160</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -519,19 +519,7 @@
|
|
|
519
519
|
<a name='L454'></a><a href='#L454'>454</a>
|
|
520
520
|
<a name='L455'></a><a href='#L455'>455</a>
|
|
521
521
|
<a name='L456'></a><a href='#L456'>456</a>
|
|
522
|
-
<a name='L457'></a><a href='#L457'>457</a>
|
|
523
|
-
<a name='L458'></a><a href='#L458'>458</a>
|
|
524
|
-
<a name='L459'></a><a href='#L459'>459</a>
|
|
525
|
-
<a name='L460'></a><a href='#L460'>460</a>
|
|
526
|
-
<a name='L461'></a><a href='#L461'>461</a>
|
|
527
|
-
<a name='L462'></a><a href='#L462'>462</a>
|
|
528
|
-
<a name='L463'></a><a href='#L463'>463</a>
|
|
529
|
-
<a name='L464'></a><a href='#L464'>464</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
|
530
|
-
<span class="cline-any cline-neutral"> </span>
|
|
531
|
-
<span class="cline-any cline-neutral"> </span>
|
|
532
|
-
<span class="cline-any cline-neutral"> </span>
|
|
533
|
-
<span class="cline-any cline-neutral"> </span>
|
|
534
|
-
<span class="cline-any cline-neutral"> </span>
|
|
522
|
+
<a name='L457'></a><a href='#L457'>457</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
|
535
523
|
<span class="cline-any cline-neutral"> </span>
|
|
536
524
|
<span class="cline-any cline-neutral"> </span>
|
|
537
525
|
<span class="cline-any cline-yes">1x</span>
|
|
@@ -667,8 +655,6 @@
|
|
|
667
655
|
<span class="cline-any cline-neutral"> </span>
|
|
668
656
|
<span class="cline-any cline-neutral"> </span>
|
|
669
657
|
<span class="cline-any cline-neutral"> </span>
|
|
670
|
-
<span class="cline-any cline-neutral"> </span>
|
|
671
|
-
<span class="cline-any cline-neutral"> </span>
|
|
672
658
|
<span class="cline-any cline-yes">1x</span>
|
|
673
659
|
<span class="cline-any cline-neutral"> </span>
|
|
674
660
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -930,19 +916,22 @@
|
|
|
930
916
|
<span class="cline-any cline-neutral"> </span>
|
|
931
917
|
<span class="cline-any cline-neutral"> </span>
|
|
932
918
|
<span class="cline-any cline-neutral"> </span>
|
|
919
|
+
<span class="cline-any cline-yes">1x</span>
|
|
920
|
+
<span class="cline-any cline-yes">14x</span>
|
|
921
|
+
<span class="cline-any cline-neutral"> </span>
|
|
922
|
+
<span class="cline-any cline-yes">14x</span>
|
|
923
|
+
<span class="cline-any cline-neutral"> </span>
|
|
924
|
+
<span class="cline-any cline-neutral"> </span>
|
|
925
|
+
<span class="cline-any cline-yes">14x</span>
|
|
933
926
|
<span class="cline-any cline-neutral"> </span>
|
|
934
927
|
<span class="cline-any cline-yes">1x</span>
|
|
935
|
-
<span class="cline-any cline-
|
|
928
|
+
<span class="cline-any cline-yes">14x</span>
|
|
929
|
+
<span class="cline-any cline-yes">3x</span>
|
|
930
|
+
<span class="cline-any cline-yes">3x</span>
|
|
931
|
+
<span class="cline-any cline-yes">14x</span>
|
|
936
932
|
<span class="cline-any cline-neutral"> </span>
|
|
937
|
-
<span class="cline-any cline-no"> </span>
|
|
938
933
|
<span class="cline-any cline-neutral"> </span>
|
|
939
934
|
<span class="cline-any cline-neutral"> </span>
|
|
940
|
-
<span class="cline-any cline-no"> </span>
|
|
941
|
-
<span class="cline-any cline-no"> </span>
|
|
942
|
-
<span class="cline-any cline-no"> </span>
|
|
943
|
-
<span class="cline-any cline-no"> </span>
|
|
944
|
-
<span class="cline-any cline-no"> </span>
|
|
945
|
-
<span class="cline-any cline-no"> </span>
|
|
946
935
|
<span class="cline-any cline-neutral"> </span>
|
|
947
936
|
<span class="cline-any cline-neutral"> </span>
|
|
948
937
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -966,41 +955,33 @@
|
|
|
966
955
|
<span class="cline-any cline-neutral"> </span>
|
|
967
956
|
<span class="cline-any cline-neutral"> </span>
|
|
968
957
|
<span class="cline-any cline-neutral"> </span>
|
|
958
|
+
<span class="cline-any cline-yes">1x</span>
|
|
959
|
+
<span class="cline-any cline-yes">1x</span>
|
|
960
|
+
<span class="cline-any cline-yes">1x</span>
|
|
961
|
+
<span class="cline-any cline-yes">1x</span>
|
|
962
|
+
<span class="cline-any cline-yes">1x</span>
|
|
963
|
+
<span class="cline-any cline-yes">8x</span>
|
|
969
964
|
<span class="cline-any cline-neutral"> </span>
|
|
965
|
+
<span class="cline-any cline-yes">2x</span>
|
|
966
|
+
<span class="cline-any cline-yes">8x</span>
|
|
967
|
+
<span class="cline-any cline-yes">6x</span>
|
|
970
968
|
<span class="cline-any cline-neutral"> </span>
|
|
969
|
+
<span class="cline-any cline-yes">1x</span>
|
|
970
|
+
<span class="cline-any cline-yes">6x</span>
|
|
971
971
|
<span class="cline-any cline-neutral"> </span>
|
|
972
|
+
<span class="cline-any cline-yes">5x</span>
|
|
973
|
+
<span class="cline-any cline-yes">5x</span>
|
|
974
|
+
<span class="cline-any cline-yes">6x</span>
|
|
975
|
+
<span class="cline-any cline-yes">8x</span>
|
|
976
|
+
<span class="cline-any cline-yes">1x</span>
|
|
972
977
|
<span class="cline-any cline-yes">1x</span>
|
|
973
|
-
<span class="cline-any cline-no"> </span>
|
|
974
|
-
<span class="cline-any cline-no"> </span>
|
|
975
|
-
<span class="cline-any cline-no"> </span>
|
|
976
|
-
<span class="cline-any cline-no"> </span>
|
|
977
|
-
<span class="cline-any cline-no"> </span>
|
|
978
|
-
<span class="cline-any cline-neutral"> </span>
|
|
979
|
-
<span class="cline-any cline-no"> </span>
|
|
980
|
-
<span class="cline-any cline-no"> </span>
|
|
981
|
-
<span class="cline-any cline-no"> </span>
|
|
982
|
-
<span class="cline-any cline-neutral"> </span>
|
|
983
|
-
<span class="cline-any cline-no"> </span>
|
|
984
|
-
<span class="cline-any cline-no"> </span>
|
|
985
|
-
<span class="cline-any cline-neutral"> </span>
|
|
986
|
-
<span class="cline-any cline-no"> </span>
|
|
987
|
-
<span class="cline-any cline-no"> </span>
|
|
988
|
-
<span class="cline-any cline-no"> </span>
|
|
989
|
-
<span class="cline-any cline-no"> </span>
|
|
990
|
-
<span class="cline-any cline-no"> </span>
|
|
991
|
-
<span class="cline-any cline-no"> </span>
|
|
992
978
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">/* eslint-disable @typescript-eslint/ban-types */
|
|
993
979
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
994
|
-
import type {
|
|
995
|
-
|
|
996
|
-
ExtractPropTypes,
|
|
997
|
-
ToRef,
|
|
998
|
-
UnwrapNestedRefs,
|
|
999
|
-
} from 'vue';
|
|
1000
|
-
import { computed, reactive, toRef } from 'vue';
|
|
980
|
+
import type { ComputedRef, ExtractPropTypes, Ref, ToRef } from 'vue';
|
|
981
|
+
import { UnwrapRef, computed, reactive, toRef } from 'vue';
|
|
1001
982
|
|
|
1002
983
|
/** Types */
|
|
1003
|
-
/**
|
|
984
|
+
/**
|
|
1004
985
|
* IVue core reactive instance type with an extended .toRefs() method added.
|
|
1005
986
|
*/
|
|
1006
987
|
export type IVue<T extends AnyClass> = InstanceType<T> & ExtendWithToRefs<T>;
|
|
@@ -1030,8 +1011,13 @@ export type IVueToRefsFnReturn<T = any> = {
|
|
|
1030
1011
|
/**
|
|
1031
1012
|
* Unwraps the returned Refs of composable method T to a reactive type definition.
|
|
1032
1013
|
*/
|
|
1033
|
-
export type UnwrapComposable<T extends (...args: any[]) => any> =
|
|
1034
|
-
|
|
1014
|
+
export type UnwrapComposable<T extends (...args: any[]) => any> = {
|
|
1015
|
+
[K in keyof ReturnType<T>]: UnwrapRef<ReturnType<T>>[K] extends Function
|
|
1016
|
+
? UnwrapRef<ReturnType<T>>[K] // Handle function
|
|
1017
|
+
: UnwrapRef<ReturnType<T>>[K] extends Ref
|
|
1018
|
+
? UnwrapRef<ReturnType<T>>[K]['value']
|
|
1019
|
+
: UnwrapRef<ReturnType<T>>[K]; // Handle property
|
|
1020
|
+
};
|
|
1035
1021
|
|
|
1036
1022
|
/**
|
|
1037
1023
|
* Extracts object defined emit types by converting them to a plain interface
|
|
@@ -1046,7 +1032,9 @@ export type ExtractEmitTypes<T extends Record<string, any>> =
|
|
|
1046
1032
|
/**
|
|
1047
1033
|
* Extract properties as all assigned properties because they have defaults.
|
|
1048
1034
|
*/
|
|
1049
|
-
export type ExtractPropDefaultTypes<O> =
|
|
1035
|
+
export type ExtractPropDefaultTypes<O> = {
|
|
1036
|
+
[K in keyof O]: ValueOf<ExtractPropTypes<O>, K>;
|
|
1037
|
+
};
|
|
1050
1038
|
|
|
1051
1039
|
/**
|
|
1052
1040
|
* Extend slots interface T with prefixed 'before--' & 'after--' slots to create fully extensible flexible slots.
|
|
@@ -1113,15 +1101,6 @@ export type UnionToIntersection<U> = (
|
|
|
1113
1101
|
*/
|
|
1114
1102
|
export type RecordToUnion<T extends Record<string, any>> = T[keyof T];
|
|
1115
1103
|
|
|
1116
|
-
/**
|
|
1117
|
-
* Required Properties converts an interface with possible
|
|
1118
|
-
* optionally assigned properties like: { optional?: any; }
|
|
1119
|
-
* to a definitevely defined interface.
|
|
1120
|
-
*/
|
|
1121
|
-
export type RequiredProperties<O> = {
|
|
1122
|
-
[K in keyof O]: ValueOf<ExtractPropTypes<O>, K>;
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
1104
|
/**
|
|
1126
1105
|
* Gets object T property by key [K].
|
|
1127
1106
|
*/
|
|
@@ -1367,7 +1346,6 @@ export function ivueToRefs<T extends AnyClass>(
|
|
|
1367
1346
|
};
|
|
1368
1347
|
}
|
|
1369
1348
|
|
|
1370
|
-
|
|
1371
1349
|
/**
|
|
1372
1350
|
* Vue props interface in defineComponent() style.
|
|
1373
1351
|
*/
|
|
@@ -1390,32 +1368,33 @@ export type VuePropsWithDefaults<T extends VuePropsObject> = {
|
|
|
1390
1368
|
/**
|
|
1391
1369
|
* Determines if the value is a JavaScript Class.
|
|
1392
1370
|
* Note that class is a class function in JavaScript.
|
|
1393
|
-
*
|
|
1371
|
+
*
|
|
1394
1372
|
* @param val Any value
|
|
1395
1373
|
* @returns boolean If it's a JavaScript Class returns true
|
|
1396
1374
|
*/
|
|
1397
|
-
export
|
|
1398
|
-
|
|
1375
|
+
export function isClass(val: any): boolean {
|
|
1376
|
+
if (typeof val !== 'function') return false; // Not a function, so not a class function either
|
|
1399
1377
|
|
|
1400
|
-
|
|
1378
|
+
if (!val.prototype) return false; // Arrow function, so not a class
|
|
1401
1379
|
|
|
1402
1380
|
// Finally -> distinguish between a normal function and a class function
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1381
|
+
if (Object.getOwnPropertyDescriptor(val, 'prototype')?.writable) {
|
|
1382
|
+
// Has writable prototype
|
|
1383
|
+
return false; // Normal function
|
|
1384
|
+
} else {
|
|
1385
|
+
return true; // Class -> Not a function
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1409
1388
|
|
|
1410
1389
|
/**
|
|
1411
1390
|
* Creates props with defaults in defineComponent() style.
|
|
1412
|
-
*
|
|
1413
|
-
* Merge defaults regular object with Vue types object
|
|
1391
|
+
*
|
|
1392
|
+
* Merge defaults regular object with Vue types object
|
|
1414
1393
|
* declared in defineComponent() style.
|
|
1415
|
-
*
|
|
1394
|
+
*
|
|
1416
1395
|
* This is made so that the defaults can be declared "as they are"
|
|
1417
1396
|
* without requiring objects to be function callbacks returning an object.
|
|
1418
|
-
*
|
|
1397
|
+
*
|
|
1419
1398
|
* // You don't need to wrap objects in () => ({ nest: { nest :{} } })
|
|
1420
1399
|
* // You can just delcare them normally.
|
|
1421
1400
|
* const defaults = {
|
|
@@ -1423,35 +1402,35 @@ export <span class="fstat-no" title="function not covered" >function isClass(val
|
|
|
1423
1402
|
* nest
|
|
1424
1403
|
* }
|
|
1425
1404
|
* }
|
|
1426
|
-
*
|
|
1427
|
-
* This function will create the Vue expected callbacks for Objects, Arrays & Classes
|
|
1428
|
-
* but leave primitive properties and functions intact so that
|
|
1405
|
+
*
|
|
1406
|
+
* This function will create the Vue expected callbacks for Objects, Arrays & Classes
|
|
1407
|
+
* but leave primitive properties and functions intact so that
|
|
1429
1408
|
* the final object is fully defineComponent() style compatible.
|
|
1430
|
-
*
|
|
1409
|
+
*
|
|
1431
1410
|
* @param defaults Regular object of default key -> values
|
|
1432
1411
|
* @param typedProps Props declared in defineComponent() style with type and possibly required declared, but without default
|
|
1433
1412
|
* @returns Props declared in defineComponent() style with all properties having default property declared.
|
|
1434
1413
|
*/
|
|
1435
|
-
export
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
/** Handle Arrays & Objects -> wrap them with an arrow function. */
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1414
|
+
export function propsWithDefaults<T extends VuePropsObject>(
|
|
1415
|
+
defaults: Record<string, any>,
|
|
1416
|
+
typedProps: T
|
|
1417
|
+
): VuePropsWithDefaults<T> {
|
|
1418
|
+
for (const prop in typedProps) {
|
|
1419
|
+
if (typeof defaults?.[prop] === 'object' && defaults?.[prop] !== null) {
|
|
1420
|
+
/** Handle Arrays & Objects -> wrap them with an arrow function. */
|
|
1421
|
+
typedProps[prop].default = () => defaults?.[prop];
|
|
1422
|
+
} else {
|
|
1423
|
+
if (isClass(defaults?.[prop])) {
|
|
1445
1424
|
/** Handle JavaScript Classes -> wrap them with an arrow function */
|
|
1446
|
-
|
|
1447
|
-
|
|
1425
|
+
typedProps[prop].default = () => defaults?.[prop];
|
|
1426
|
+
} else {
|
|
1448
1427
|
/** Handle JavaScript Function And All primitive properties -> output directly */
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1428
|
+
typedProps[prop].default = defaults?.[prop];
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
return typedProps as VuePropsWithDefaults<T>;
|
|
1433
|
+
}
|
|
1455
1434
|
</pre></td></tr></table></pre>
|
|
1456
1435
|
|
|
1457
1436
|
<div class='push'></div><!-- for sticky footer -->
|
|
@@ -1459,7 +1438,7 @@ export <span class="fstat-no" title="function not covered" >function createProps
|
|
|
1459
1438
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
1460
1439
|
Code coverage generated by
|
|
1461
1440
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
1462
|
-
at 2024-08-
|
|
1441
|
+
at 2024-08-13T00:42:34.338Z
|
|
1463
1442
|
</div>
|
|
1464
1443
|
<script src="prettify.js"></script>
|
|
1465
1444
|
<script>
|
package/dist/index.es.js
CHANGED
|
@@ -1,108 +1,92 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
6
|
-
const
|
|
7
|
-
let t =
|
|
1
|
+
import { reactive as y, computed as g, ref as O, toRef as d } from "vue";
|
|
2
|
+
const l = /* @__PURE__ */ new Map();
|
|
3
|
+
function h(e) {
|
|
4
|
+
if (l.has(e))
|
|
5
|
+
return l.get(e);
|
|
6
|
+
const r = /* @__PURE__ */ new Map();
|
|
7
|
+
let t = e.prototype;
|
|
8
8
|
for (; t.constructor !== Object; )
|
|
9
|
-
Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
), t = Object.getPrototypeOf(t);
|
|
15
|
-
return y.set(n, o), o;
|
|
9
|
+
Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i, s]) => {
|
|
10
|
+
const n = r.get(i);
|
|
11
|
+
n !== s && (s != null && s.get || s != null && s.set) && (n != null && n.get && (s.get = n == null ? void 0 : n.get), n != null && n.set && (s.set = n == null ? void 0 : n.set), r.set(i, s));
|
|
12
|
+
}), t = Object.getPrototypeOf(t);
|
|
13
|
+
return l.set(e, r), r;
|
|
16
14
|
}
|
|
17
|
-
function
|
|
18
|
-
var
|
|
19
|
-
const t =
|
|
20
|
-
for (const [
|
|
21
|
-
((
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
O[g]
|
|
27
|
-
) : (
|
|
28
|
-
/** Create the computed and return it, because we are in reactive scope, .value will auto unwrap itself. */
|
|
29
|
-
O[g] = l({
|
|
30
|
-
get: (b = i.get) == null ? void 0 : b.bind(e),
|
|
31
|
-
set: (w = i.set) == null ? void 0 : w.bind(e)
|
|
32
|
-
})
|
|
33
|
-
);
|
|
34
|
-
} : void 0,
|
|
35
|
-
set: (h = i.set) == null ? void 0 : h.bind(e),
|
|
36
|
-
enumerable: !1
|
|
37
|
-
});
|
|
38
|
-
return Object.defineProperty(e, "toRefs", {
|
|
39
|
-
get: () => R(e, t, O),
|
|
40
|
-
enumerable: !1
|
|
41
|
-
}), "init" in e && e.init(), e;
|
|
15
|
+
function v(e, ...r) {
|
|
16
|
+
var n, f;
|
|
17
|
+
const t = h(e), i = t != null && t.size ? {} : null, s = y(new e(...r));
|
|
18
|
+
for (const [c, o] of t)
|
|
19
|
+
((n = e == null ? void 0 : e.ivue) == null ? void 0 : n[c]) !== !1 && Object.defineProperty(s, c, { get: o.get ? () => {
|
|
20
|
+
var u, a;
|
|
21
|
+
return c in i ? i[c] : i[c] = g({ get: (u = o.get) == null ? void 0 : u.bind(s), set: (a = o.set) == null ? void 0 : a.bind(s) });
|
|
22
|
+
} : void 0, set: (f = o.set) == null ? void 0 : f.bind(s), enumerable: !1 });
|
|
23
|
+
return Object.defineProperty(s, "toRefs", { get: () => w(s, t, i), enumerable: !1 }), "init" in s && s.init(), s;
|
|
42
24
|
}
|
|
43
|
-
const
|
|
44
|
-
function
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
47
|
-
const
|
|
25
|
+
const p = /* @__PURE__ */ new Map();
|
|
26
|
+
function j(e) {
|
|
27
|
+
if (p.has(e.constructor))
|
|
28
|
+
return p.get(e.constructor);
|
|
29
|
+
const r = e.constructor, t = /* @__PURE__ */ new Set();
|
|
48
30
|
do
|
|
49
|
-
Object.getOwnPropertyNames(
|
|
50
|
-
["caller", "callee", "arguments", "constructor"].includes(
|
|
51
|
-
}),
|
|
52
|
-
while (
|
|
53
|
-
return
|
|
31
|
+
Object.getOwnPropertyNames(e).forEach((i) => {
|
|
32
|
+
["caller", "callee", "arguments", "constructor"].includes(i) || t.add(i);
|
|
33
|
+
}), e = Object.getPrototypeOf(e);
|
|
34
|
+
while (e.constructor !== Object);
|
|
35
|
+
return p.set(r, t), t;
|
|
36
|
+
}
|
|
37
|
+
function M(e) {
|
|
38
|
+
return O(e);
|
|
39
|
+
}
|
|
40
|
+
function A(e) {
|
|
41
|
+
return e;
|
|
54
42
|
}
|
|
55
|
-
function
|
|
56
|
-
return function(
|
|
57
|
-
var
|
|
58
|
-
const
|
|
59
|
-
if (Array.isArray(
|
|
60
|
-
for (let
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
64
|
-
|
|
43
|
+
function w(e, r, t) {
|
|
44
|
+
return function(i) {
|
|
45
|
+
var n, f;
|
|
46
|
+
const s = {};
|
|
47
|
+
if (Array.isArray(i) && i.length)
|
|
48
|
+
for (let c = 0; c < i.length; c++) {
|
|
49
|
+
const o = i[c];
|
|
50
|
+
if (r.has(o))
|
|
51
|
+
if (o in t)
|
|
52
|
+
s[o] = t[o];
|
|
65
53
|
else {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
get: (f = b == null ? void 0 : b.get) == null ? void 0 : f.bind(n),
|
|
69
|
-
set: (h = b == null ? void 0 : b.set) == null ? void 0 : h.bind(n)
|
|
70
|
-
});
|
|
54
|
+
const u = r.get(o);
|
|
55
|
+
s[o] = t[o] = g({ get: (n = u == null ? void 0 : u.get) == null ? void 0 : n.bind(e), set: (f = u == null ? void 0 : u.set) == null ? void 0 : f.bind(e) });
|
|
71
56
|
}
|
|
72
57
|
else
|
|
73
|
-
typeof
|
|
58
|
+
typeof e[o] == "function" ? s[o] = e[o].bind(e) : s[o] = d(e, o);
|
|
74
59
|
}
|
|
75
60
|
else {
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}), g.forEach((i) => {
|
|
84
|
-
typeof n[i] == "function" ? e[i] = n[i].bind(n) : e[i] = M(n, i), g == null || g.delete(i);
|
|
85
|
-
}), g = null;
|
|
61
|
+
let c = new Set(j(e));
|
|
62
|
+
r.forEach((o, u) => {
|
|
63
|
+
var a, b;
|
|
64
|
+
s[u] = u in t ? t[u] : t[u] = g({ get: (a = o.get) == null ? void 0 : a.bind(e), set: (b = o.set) == null ? void 0 : b.bind(e) }), c == null || c.delete(u);
|
|
65
|
+
}), c.forEach((o) => {
|
|
66
|
+
typeof e[o] == "function" ? s[o] = e[o].bind(e) : s[o] = d(e, o);
|
|
67
|
+
}), c = null;
|
|
86
68
|
}
|
|
87
|
-
return
|
|
69
|
+
return s;
|
|
88
70
|
};
|
|
89
71
|
}
|
|
90
|
-
function P(
|
|
91
|
-
var
|
|
92
|
-
return
|
|
72
|
+
function P(e) {
|
|
73
|
+
var r;
|
|
74
|
+
return typeof e == "function" && !!e.prototype && !((r = Object.getOwnPropertyDescriptor(e, "prototype")) != null && r.writable);
|
|
93
75
|
}
|
|
94
|
-
function
|
|
95
|
-
for (const t in
|
|
96
|
-
typeof (
|
|
97
|
-
return
|
|
76
|
+
function D(e, r) {
|
|
77
|
+
for (const t in r)
|
|
78
|
+
typeof (e == null ? void 0 : e[t]) == "object" && (e == null ? void 0 : e[t]) !== null || P(e == null ? void 0 : e[t]) ? r[t].default = () => e == null ? void 0 : e[t] : r[t].default = e == null ? void 0 : e[t];
|
|
79
|
+
return r;
|
|
98
80
|
}
|
|
99
81
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
l as descriptorsMap,
|
|
83
|
+
h as getAllClassDescriptors,
|
|
84
|
+
j as getAllClassProperties,
|
|
85
|
+
M as iref,
|
|
103
86
|
P as isClass,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
87
|
+
A as iuse,
|
|
88
|
+
v as ivue,
|
|
89
|
+
w as ivueToRefs,
|
|
90
|
+
p as propsMap,
|
|
91
|
+
D as propsWithDefaults
|
|
108
92
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l
|
|
1
|
+
(function(s,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):l((s=typeof globalThis<"u"?globalThis:s||self).ivue={},s.Vue)})(this,function(s,l){"use strict";const d=new Map;function b(t){if(d.has(t))return d.get(t);const r=new Map;let e=t.prototype;for(;e.constructor!==Object;)Object.entries(Object.getOwnPropertyDescriptors(e)).forEach(([c,o])=>{const i=r.get(c);i!==o&&(o!=null&&o.get||o!=null&&o.set)&&(i!=null&&i.get&&(o.get=i==null?void 0:i.get),i!=null&&i.set&&(o.set=i==null?void 0:i.set),r.set(c,o))}),e=Object.getPrototypeOf(e);return d.set(t,r),r}const g=new Map;function y(t){if(g.has(t.constructor))return g.get(t.constructor);const r=t.constructor,e=new Set;do Object.getOwnPropertyNames(t).forEach(c=>{["caller","callee","arguments","constructor"].includes(c)||e.add(c)}),t=Object.getPrototypeOf(t);while(t.constructor!==Object);return g.set(r,e),e}function O(t,r,e){return function(c){var i,p;const o={};if(Array.isArray(c)&&c.length)for(let u=0;u<c.length;u++){const n=c[u];if(r.has(n))if(n in e)o[n]=e[n];else{const f=r.get(n);o[n]=e[n]=l.computed({get:(i=f==null?void 0:f.get)==null?void 0:i.bind(t),set:(p=f==null?void 0:f.set)==null?void 0:p.bind(t)})}else typeof t[n]=="function"?o[n]=t[n].bind(t):o[n]=l.toRef(t,n)}else{let u=new Set(y(t));r.forEach((n,f)=>{var a,j;o[f]=f in e?e[f]:e[f]=l.computed({get:(a=n.get)==null?void 0:a.bind(t),set:(j=n.set)==null?void 0:j.bind(t)}),u==null||u.delete(f)}),u.forEach(n=>{typeof t[n]=="function"?o[n]=t[n].bind(t):o[n]=l.toRef(t,n)}),u=null}return o}}function h(t){var r;return typeof t=="function"&&!!t.prototype&&!((r=Object.getOwnPropertyDescriptor(t,"prototype"))!=null&&r.writable)}s.descriptorsMap=d,s.getAllClassDescriptors=b,s.getAllClassProperties=y,s.iref=function(t){return l.ref(t)},s.isClass=h,s.iuse=function(t){return t},s.ivue=function(t,...r){var i,p;const e=b(t),c=e!=null&&e.size?{}:null,o=l.reactive(new t(...r));for(const[u,n]of e)((i=t==null?void 0:t.ivue)==null?void 0:i[u])!==!1&&Object.defineProperty(o,u,{get:n.get?()=>{var f,a;return u in c?c[u]:c[u]=l.computed({get:(f=n.get)==null?void 0:f.bind(o),set:(a=n.set)==null?void 0:a.bind(o)})}:void 0,set:(p=n.set)==null?void 0:p.bind(o),enumerable:!1});return Object.defineProperty(o,"toRefs",{get:()=>O(o,e,c),enumerable:!1}),"init"in o&&o.init(),o},s.ivueToRefs=O,s.propsMap=g,s.propsWithDefaults=function(t,r){for(const e in r)typeof(t==null?void 0:t[e])=="object"&&(t==null?void 0:t[e])!==null||h(t==null?void 0:t[e])?r[e].default=()=>t==null?void 0:t[e]:r[e].default=t==null?void 0:t[e];return r},Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|