@kaokei/use-vue-service 2.0.5 → 3.0.1
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/README.md +13 -31
- package/dist/computed.d.cts +1 -0
- package/dist/computed.d.ts +1 -0
- package/dist/constants.d.cts +9 -0
- package/dist/constants.d.ts +9 -0
- package/dist/core.d.cts +14 -0
- package/dist/core.d.ts +14 -0
- package/dist/find-service.d.cts +3 -0
- package/dist/find-service.d.ts +3 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +167 -0
- package/dist/interface.d.cts +6 -0
- package/dist/interface.d.ts +6 -0
- package/dist/scope.d.cts +5 -0
- package/dist/scope.d.ts +5 -0
- package/dist/utils.d.cts +3 -0
- package/dist/utils.d.ts +3 -0
- package/package.json +32 -112
- package/dist/index.cjs.js +0 -153
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.cjs.min.js +0 -11
- package/dist/index.cjs.min.js.map +0 -1
- package/dist/index.cjs.runtime.js +0 -153
- package/dist/index.cjs.runtime.js.map +0 -1
- package/dist/index.cjs.runtime.min.js +0 -11
- package/dist/index.cjs.runtime.min.js.map +0 -1
- package/dist/index.esm.js +0 -134
- package/dist/index.esm.js.map +0 -1
- package/dist/index.esm.min.js +0 -11
- package/dist/index.esm.min.js.map +0 -1
- package/dist/index.esm.runtime.js +0 -134
- package/dist/index.esm.runtime.js.map +0 -1
- package/dist/index.esm.runtime.min.js +0 -11
- package/dist/index.esm.runtime.min.js.map +0 -1
- package/dist/index.iife.js +0 -152
- package/dist/index.iife.js.map +0 -1
- package/dist/index.iife.min.js +0 -11
- package/dist/index.iife.min.js.map +0 -1
- package/dist/src/constants.d.ts +0 -2
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/declareProviders.d.ts +0 -26
- package/dist/src/declareProviders.d.ts.map +0 -1
- package/dist/src/defaultInjector.d.ts +0 -2
- package/dist/src/defaultInjector.d.ts.map +0 -1
- package/dist/src/fakeInject.d.ts +0 -11
- package/dist/src/fakeInject.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -8
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/useService.d.ts +0 -9
- package/dist/src/useService.d.ts.map +0 -1
- package/dist/src/utils.d.ts +0 -4
- package/dist/src/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,42 +1,24 @@
|
|
|
1
|
-
<h1 align="center">use-vue-service</h1>
|
|
1
|
+
<h1 align="center">npm install @kaokei/use-vue-service</h1>
|
|
2
|
+
|
|
2
3
|
<div align="center">
|
|
3
4
|
|
|
4
|
-
[](https://github.com/kaokei/use-vue-service/actions/workflows/build.yml)
|
|
6
|
+
[](https://coveralls.io/github/kaokei/use-vue-service?branch=main)
|
|
7
|
+
[](https://npmcharts.com/compare/@kaokei/use-vue-service?minimal=true)
|
|
8
|
+
[](https://www.npmjs.com/package/@kaokei/use-vue-service)
|
|
9
|
+
[](https://www.npmjs.com/package/@kaokei/use-vue-service)
|
|
10
|
+

|
|
5
11
|
|
|
6
12
|
</div>
|
|
7
13
|
|
|
8
|
-
- [documentation](https://kaokei.com/project/use-vue-service/)
|
|
9
|
-
- [online playground](https://kaokei.com/project/use-vue-service/)
|
|
10
|
-
- [online demo](https://use-vue-service.vercel.app/)
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm install @kaokei/use-vue-service @kaokei/di reflect-metadata
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## 简介
|
|
17
|
-
|
|
18
14
|
灵感来自 angular 中的服务的概念。在 angular 中不需要全局唯一的数据源 store。而是通过声明服务,以及向组件中注入服务来达到数据管理以及数据共享的。
|
|
19
15
|
|
|
20
16
|
本库也是实现了类似的效果,可以通过依赖注入实现面向服务编程、实现领域驱动开发。从而可以代替 vuex。
|
|
21
17
|
|
|
22
18
|
本库通过类来声明服务,对 typescript 支持非常棒。
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
- 发布 npm 包 `npm publish`
|
|
30
|
-
|
|
31
|
-
## 项目技术特点
|
|
32
|
-
|
|
33
|
-
- 自带单元测试
|
|
34
|
-
- 自带示例 demo 网站
|
|
35
|
-
- 使用 typescript
|
|
36
|
-
- 使用 editconfig 配置通用编辑器规范
|
|
37
|
-
- 使用 eslint 配合编辑器作语法检查
|
|
38
|
-
- 使用 eslint 配合 prettier 来格式化代码
|
|
39
|
-
- 使用 eslint 配合 husky 以及 lint-stage 自动格式化提交的代码,保证 git 仓库代码的规范性
|
|
40
|
-
- 使用 rollup 打包源码
|
|
41
|
-
|
|
42
|
-
## MIT LICENSE
|
|
20
|
+
- [入门指南](./docs/guide/README.md)
|
|
21
|
+
- [API 文档](./docs/api/README.md)
|
|
22
|
+
- [博客文章](./docs/note/01.父组件与子组件的理解.md)
|
|
23
|
+
- [codesandbox example](https://codesandbox.io/s/di-playground-zjnyv)
|
|
24
|
+
- [online demo](https://use-vue-service.vercel.app/)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Computed(_: any, key: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Computed(_: any, key: string, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Token } from '@kaokei/di';
|
|
2
|
+
import { ComponentInternalInstance } from 'vue';
|
|
3
|
+
import { FindChildService, FindChildrenServices } from './interface.ts';
|
|
4
|
+
export declare const CURRENT_COMPONENT: Token<ComponentInternalInstance>;
|
|
5
|
+
export declare const FIND_CHILD_SERVICE: Token<FindChildService>;
|
|
6
|
+
export declare const FIND_CHILDREN_SERVICES: Token<FindChildrenServices>;
|
|
7
|
+
export declare const SCOPE_KEY: unique symbol;
|
|
8
|
+
export declare const CONTAINER_TOKEN = "USE_VUE_SERVICE_CONTAINER_TOKEN";
|
|
9
|
+
export declare const DEFAULT_CONTAINER: import('@kaokei/di').Container;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Token } from '@kaokei/di';
|
|
2
|
+
import { ComponentInternalInstance } from 'vue';
|
|
3
|
+
import { FindChildService, FindChildrenServices } from './interface.ts';
|
|
4
|
+
export declare const CURRENT_COMPONENT: Token<ComponentInternalInstance>;
|
|
5
|
+
export declare const FIND_CHILD_SERVICE: Token<FindChildService>;
|
|
6
|
+
export declare const FIND_CHILDREN_SERVICES: Token<FindChildrenServices>;
|
|
7
|
+
export declare const SCOPE_KEY: unique symbol;
|
|
8
|
+
export declare const CONTAINER_TOKEN = "USE_VUE_SERVICE_CONTAINER_TOKEN";
|
|
9
|
+
export declare const DEFAULT_CONTAINER: import('@kaokei/di').Container;
|
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { CommonToken } from '@kaokei/di';
|
|
3
|
+
import { NewableProvider, FunctionProvider, Provider } from './interface.ts';
|
|
4
|
+
export declare function useService<T>(token: CommonToken<T>): T;
|
|
5
|
+
export declare function useRootService<T>(token: CommonToken<T>): T;
|
|
6
|
+
export declare function useAppService<T>(token: CommonToken<T>, app: App): T;
|
|
7
|
+
export declare function declareProviders(providers: FunctionProvider): void;
|
|
8
|
+
export declare function declareProviders(providers: NewableProvider): void;
|
|
9
|
+
export declare function declareRootProviders(providers: FunctionProvider): void;
|
|
10
|
+
export declare function declareRootProviders(providers: NewableProvider): void;
|
|
11
|
+
export declare function declareAppProviders(providers: FunctionProvider, app: App): void;
|
|
12
|
+
export declare function declareAppProviders(providers: NewableProvider, app: App): void;
|
|
13
|
+
export declare function declareAppProviders(providers: Provider, app: App): void;
|
|
14
|
+
export declare function declareAppProvidersPlugin(providers: Provider): (app: App) => void;
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { CommonToken } from '@kaokei/di';
|
|
3
|
+
import { NewableProvider, FunctionProvider, Provider } from './interface.ts';
|
|
4
|
+
export declare function useService<T>(token: CommonToken<T>): T;
|
|
5
|
+
export declare function useRootService<T>(token: CommonToken<T>): T;
|
|
6
|
+
export declare function useAppService<T>(token: CommonToken<T>, app: App): T;
|
|
7
|
+
export declare function declareProviders(providers: FunctionProvider): void;
|
|
8
|
+
export declare function declareProviders(providers: NewableProvider): void;
|
|
9
|
+
export declare function declareRootProviders(providers: FunctionProvider): void;
|
|
10
|
+
export declare function declareRootProviders(providers: NewableProvider): void;
|
|
11
|
+
export declare function declareAppProviders(providers: FunctionProvider, app: App): void;
|
|
12
|
+
export declare function declareAppProviders(providers: NewableProvider, app: App): void;
|
|
13
|
+
export declare function declareAppProviders(providers: Provider, app: App): void;
|
|
14
|
+
export declare function declareAppProvidersPlugin(providers: Provider): (app: App) => void;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@kaokei/di"),r=require("vue");function E(e,t,n){return e&&e.forEach(o=>{o&&o.isCurrentBound(t)&&n.push(o.get(t)),o.children&&E(o.children,t,n)}),n}function y(e,t){const n=[];return E(t.children,e,n),n[0]}function b(e,t){const n=[];return E(t.children,e,n),n}function T(e){const t=e,n=r.effectScope(!0);return t[S]=n,n}function R(e){return e[S]}function _(e){const t=R(e);return t||T(e)}function D(e){const t=e;if(t){const n=R(t);n&&(n.stop(),delete t[S])}}function V(e){return e!==null&&typeof e=="object"}function A(e,t){return V(t)?r.reactive(t):t}function U(e){return D(e)}function w({container:e}){return t=>y(t,e)}function j({container:e}){return t=>b(t,e)}function p(e,t){let n;return e?n=e.createChild():n=new s.Container,t&&n.bind(I).toConstantValue(r.markRaw(t)),n.bind(h).toDynamicValue(w),n.bind(N).toDynamicValue(j),n.onActivation(A),n.onDeactivation(U),n}const I=new s.Token("USE_VUE_SERVICE_CURRENT_COMPONENT"),h=new s.Token("USE_REACT_SERVICE_FIND_CHILD_SERVICE"),N=new s.Token("USE_REACT_SERVICE_FIND_CHILDREN_SERVICES"),S=Symbol(),a="USE_VUE_SERVICE_CONTAINER_TOKEN",d=p();function l(e,t){if(typeof t=="function")t(e);else for(let n=0;n<t.length;n++)e.bind(t[n]).toSelf()}function g(){const e=r.getCurrentInstance();if(e){const t=a,n=e.provides,o=e.parent&&e.parent.provides;if(n&&n!==o&&Object.prototype.hasOwnProperty.call(n,t))return n[t]}}function v(){if(r.hasInjectionContext())return r.inject(a,d);throw new Error("getProvideContainer 只能在 setup 中使用")}function F(e){return(g()||v()).get(e)}function H(e){return d.get(e)}function L(e,t){return t.runWithContext(()=>v().get(e))}function M(e){const t=g();if(t)l(t,e);else{const n=v(),o=r.getCurrentInstance();let c=p(n,o);l(c,e),r.provide(a,c),r.onUnmounted(()=>{c.destroy(),c=null})}}function x(e){l(d,e)}function m(e,t){t.runWithContext(()=>{const n=r.inject(a,null);if(n)l(n,e);else{let o=p(d);l(o,e),t.provide(a,o),t.onUnmount(()=>{o.destroy(),o=null})}})}function K(e){return t=>m(e,t)}function k(e,t,n){const o=n.get,c=n.set;return{configurable:!0,enumerable:!0,get(){const i=r.reactive(this),f=Symbol.for(t);let u=i[f];if(!u){const O=_(i).run(()=>c?r.computed({get:()=>o.call(i),set:P=>c.call(i,P)}):r.computed(()=>o.call(i)));u=r.markRaw({value:O}),i[f]=u}return u.value.value},set(i){const f=r.reactive(this),u=Symbol.for(t),C=f[u];C&&c&&(C.value.value=i)}}}exports.CURRENT_COMPONENT=I;exports.Computed=k;exports.FIND_CHILDREN_SERVICES=N;exports.FIND_CHILD_SERVICE=h;exports.declareAppProviders=m;exports.declareAppProvidersPlugin=K;exports.declareProviders=M;exports.declareRootProviders=x;exports.getEffectScope=_;exports.useAppService=L;exports.useRootService=H;exports.useService=F;Object.keys(s).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>s[e]})});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from '@kaokei/di';
|
|
2
|
+
export { CURRENT_COMPONENT, FIND_CHILD_SERVICE, FIND_CHILDREN_SERVICES, } from './constants.ts';
|
|
3
|
+
export { useService, declareProviders, useRootService, declareRootProviders, useAppService, declareAppProviders, declareAppProvidersPlugin, } from './core.ts';
|
|
4
|
+
export { Computed } from './computed.ts';
|
|
5
|
+
export { getEffectScope } from './scope.ts';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from '@kaokei/di';
|
|
2
|
+
export { CURRENT_COMPONENT, FIND_CHILD_SERVICE, FIND_CHILDREN_SERVICES, } from './constants.ts';
|
|
3
|
+
export { useService, declareProviders, useRootService, declareRootProviders, useAppService, declareAppProviders, declareAppProvidersPlugin, } from './core.ts';
|
|
4
|
+
export { Computed } from './computed.ts';
|
|
5
|
+
export { getEffectScope } from './scope.ts';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Container as y, Token as d } from "@kaokei/di";
|
|
2
|
+
export * from "@kaokei/di";
|
|
3
|
+
import { effectScope as P, markRaw as R, reactive as C, getCurrentInstance as h, provide as T, onUnmounted as V, inject as m, hasInjectionContext as b, computed as v } from "vue";
|
|
4
|
+
function E(t, e, n) {
|
|
5
|
+
return t && t.forEach((o) => {
|
|
6
|
+
o && o.isCurrentBound(e) && n.push(o.get(e)), o.children && E(o.children, e, n);
|
|
7
|
+
}), n;
|
|
8
|
+
}
|
|
9
|
+
function D(t, e) {
|
|
10
|
+
const n = [];
|
|
11
|
+
return E(e.children, t, n), n[0];
|
|
12
|
+
}
|
|
13
|
+
function U(t, e) {
|
|
14
|
+
const n = [];
|
|
15
|
+
return E(e.children, t, n), n;
|
|
16
|
+
}
|
|
17
|
+
function A(t) {
|
|
18
|
+
const e = t, n = P(!0);
|
|
19
|
+
return e[S] = n, n;
|
|
20
|
+
}
|
|
21
|
+
function I(t) {
|
|
22
|
+
return t[S];
|
|
23
|
+
}
|
|
24
|
+
function w(t) {
|
|
25
|
+
const e = I(t);
|
|
26
|
+
return e || A(t);
|
|
27
|
+
}
|
|
28
|
+
function F(t) {
|
|
29
|
+
const e = t;
|
|
30
|
+
if (e) {
|
|
31
|
+
const n = I(e);
|
|
32
|
+
n && (n.stop(), delete e[S]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function H(t) {
|
|
36
|
+
return t !== null && typeof t == "object";
|
|
37
|
+
}
|
|
38
|
+
function x(t, e) {
|
|
39
|
+
return H(e) ? C(e) : e;
|
|
40
|
+
}
|
|
41
|
+
function L(t) {
|
|
42
|
+
return F(t);
|
|
43
|
+
}
|
|
44
|
+
function j({ container: t }) {
|
|
45
|
+
return (e) => D(e, t);
|
|
46
|
+
}
|
|
47
|
+
function K({
|
|
48
|
+
container: t
|
|
49
|
+
}) {
|
|
50
|
+
return (e) => U(e, t);
|
|
51
|
+
}
|
|
52
|
+
function p(t, e) {
|
|
53
|
+
let n;
|
|
54
|
+
return t ? n = t.createChild() : n = new y(), e && n.bind(M).toConstantValue(R(e)), n.bind(W).toDynamicValue(j), n.bind(k).toDynamicValue(K), n.onActivation(x), n.onDeactivation(L), n;
|
|
55
|
+
}
|
|
56
|
+
const M = new d(
|
|
57
|
+
"USE_VUE_SERVICE_CURRENT_COMPONENT"
|
|
58
|
+
), W = new d(
|
|
59
|
+
"USE_REACT_SERVICE_FIND_CHILD_SERVICE"
|
|
60
|
+
), k = new d(
|
|
61
|
+
"USE_REACT_SERVICE_FIND_CHILDREN_SERVICES"
|
|
62
|
+
), S = Symbol(), u = "USE_VUE_SERVICE_CONTAINER_TOKEN", a = p();
|
|
63
|
+
function s(t, e) {
|
|
64
|
+
if (typeof e == "function")
|
|
65
|
+
e(t);
|
|
66
|
+
else
|
|
67
|
+
for (let n = 0; n < e.length; n++)
|
|
68
|
+
t.bind(e[n]).toSelf();
|
|
69
|
+
}
|
|
70
|
+
function N() {
|
|
71
|
+
const t = h();
|
|
72
|
+
if (t) {
|
|
73
|
+
const e = u, n = t.provides, o = t.parent && t.parent.provides;
|
|
74
|
+
if (
|
|
75
|
+
// 当前实例的provides存在
|
|
76
|
+
n && // 当前实例的provides已经和parentProvides不是一个对象,说明已经Object.create(parentProvides)
|
|
77
|
+
n !== o && // provides自身已经具有CONTAINER_TOKEN属性
|
|
78
|
+
Object.prototype.hasOwnProperty.call(n, e)
|
|
79
|
+
)
|
|
80
|
+
return n[e];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function _() {
|
|
84
|
+
if (b())
|
|
85
|
+
return m(u, a);
|
|
86
|
+
throw new Error("getProvideContainer 只能在 setup 中使用");
|
|
87
|
+
}
|
|
88
|
+
function q(t) {
|
|
89
|
+
return (N() || _()).get(t);
|
|
90
|
+
}
|
|
91
|
+
function z(t) {
|
|
92
|
+
return a.get(t);
|
|
93
|
+
}
|
|
94
|
+
function J(t, e) {
|
|
95
|
+
return e.runWithContext(() => _().get(t));
|
|
96
|
+
}
|
|
97
|
+
function Q(t) {
|
|
98
|
+
const e = N();
|
|
99
|
+
if (e)
|
|
100
|
+
s(e, t);
|
|
101
|
+
else {
|
|
102
|
+
const n = _(), o = h();
|
|
103
|
+
let r = p(n, o);
|
|
104
|
+
s(r, t), T(u, r), V(() => {
|
|
105
|
+
r.destroy(), r = null;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function X(t) {
|
|
110
|
+
s(a, t);
|
|
111
|
+
}
|
|
112
|
+
function B(t, e) {
|
|
113
|
+
e.runWithContext(() => {
|
|
114
|
+
const n = m(
|
|
115
|
+
u,
|
|
116
|
+
null
|
|
117
|
+
);
|
|
118
|
+
if (n)
|
|
119
|
+
s(n, t);
|
|
120
|
+
else {
|
|
121
|
+
let o = p(a);
|
|
122
|
+
s(o, t), e.provide(u, o), e.onUnmount(() => {
|
|
123
|
+
o.destroy(), o = null;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function Z(t) {
|
|
129
|
+
return (e) => B(t, e);
|
|
130
|
+
}
|
|
131
|
+
function $(t, e, n) {
|
|
132
|
+
const o = n.get, r = n.set;
|
|
133
|
+
return {
|
|
134
|
+
configurable: !0,
|
|
135
|
+
enumerable: !0,
|
|
136
|
+
get() {
|
|
137
|
+
const c = C(this), f = Symbol.for(e);
|
|
138
|
+
let i = c[f];
|
|
139
|
+
if (!i) {
|
|
140
|
+
const g = w(c).run(() => r ? v({
|
|
141
|
+
get: () => o.call(c),
|
|
142
|
+
set: (O) => r.call(c, O)
|
|
143
|
+
}) : v(() => o.call(c)));
|
|
144
|
+
i = R({ value: g }), c[f] = i;
|
|
145
|
+
}
|
|
146
|
+
return i.value.value;
|
|
147
|
+
},
|
|
148
|
+
set(c) {
|
|
149
|
+
const f = C(this), i = Symbol.for(e), l = f[i];
|
|
150
|
+
l && r && (l.value.value = c);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
M as CURRENT_COMPONENT,
|
|
156
|
+
$ as Computed,
|
|
157
|
+
k as FIND_CHILDREN_SERVICES,
|
|
158
|
+
W as FIND_CHILD_SERVICE,
|
|
159
|
+
B as declareAppProviders,
|
|
160
|
+
Z as declareAppProvidersPlugin,
|
|
161
|
+
Q as declareProviders,
|
|
162
|
+
X as declareRootProviders,
|
|
163
|
+
w as getEffectScope,
|
|
164
|
+
J as useAppService,
|
|
165
|
+
z as useRootService,
|
|
166
|
+
q as useService
|
|
167
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Container, Newable, CommonToken } from '@kaokei/di';
|
|
2
|
+
export type NewableProvider = Newable[];
|
|
3
|
+
export type FunctionProvider = (container: Container) => void;
|
|
4
|
+
export type Provider = NewableProvider | FunctionProvider;
|
|
5
|
+
export type FindChildService = <T>(token: CommonToken<T>) => T | undefined;
|
|
6
|
+
export type FindChildrenServices = <T>(token: CommonToken<T>) => T[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Container, Newable, CommonToken } from '@kaokei/di';
|
|
2
|
+
export type NewableProvider = Newable[];
|
|
3
|
+
export type FunctionProvider = (container: Container) => void;
|
|
4
|
+
export type Provider = NewableProvider | FunctionProvider;
|
|
5
|
+
export type FindChildService = <T>(token: CommonToken<T>) => T | undefined;
|
|
6
|
+
export type FindChildrenServices = <T>(token: CommonToken<T>) => T[];
|
package/dist/scope.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EffectScope } from 'vue';
|
|
2
|
+
export declare function createScope(obj: object): EffectScope;
|
|
3
|
+
export declare function getScope(obj: object): EffectScope | undefined;
|
|
4
|
+
export declare function getEffectScope(obj: object): EffectScope;
|
|
5
|
+
export declare function removeScope(obj: object): void;
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EffectScope } from 'vue';
|
|
2
|
+
export declare function createScope(obj: object): EffectScope;
|
|
3
|
+
export declare function getScope(obj: object): EffectScope | undefined;
|
|
4
|
+
export declare function getEffectScope(obj: object): EffectScope;
|
|
5
|
+
export declare function removeScope(obj: object): void;
|
package/dist/utils.d.cts
ADDED
package/dist/utils.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaokei/use-vue-service",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Lightweight Vue 3 state management with dependency injection, inspired by Angular services.",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"unpkg": "./dist/index.cjs",
|
|
10
|
+
"jsdelivr": "./dist/index.cjs",
|
|
10
11
|
"files": [
|
|
11
12
|
"dist/**/*"
|
|
12
13
|
],
|
|
13
14
|
"exports": {
|
|
14
15
|
".": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"browser": "./dist/index.iife.js",
|
|
18
|
-
"node": {
|
|
19
|
-
"import": {
|
|
20
|
-
"production": "./dist/index.esm.runtime.min.js",
|
|
21
|
-
"development": "./dist/index.esm.js",
|
|
22
|
-
"default": "./dist/index.esm.js"
|
|
23
|
-
},
|
|
24
|
-
"require": {
|
|
25
|
-
"production": "./dist/index.cjs.runtime.min.js",
|
|
26
|
-
"development": "./dist/index.cjs.js",
|
|
27
|
-
"default": "./dist/index.cjs.js"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
30
18
|
},
|
|
31
19
|
"./dist/*": "./dist/*",
|
|
32
20
|
"./package.json": "./package.json"
|
|
33
21
|
},
|
|
34
|
-
"browserVariableName": "UseVueService",
|
|
35
22
|
"sideEffects": false,
|
|
36
23
|
"homepage": "https://github.com/kaokei/use-vue-service",
|
|
37
24
|
"author": "kaokei",
|
|
@@ -52,100 +39,33 @@
|
|
|
52
39
|
"Dependency injection"
|
|
53
40
|
],
|
|
54
41
|
"scripts": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"dev": "webpack serve --config ./example/webpack.config.js",
|
|
61
|
-
"build:example": "webpack build --config ./example/webpack.config.js",
|
|
62
|
-
"build": "npm run check && npm run rp",
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"coverage": "vitest run --coverage",
|
|
44
|
+
"dev": "vite",
|
|
45
|
+
"build": "vue-tsc -b && vite build",
|
|
46
|
+
"preview": "vite preview",
|
|
63
47
|
"clean": "rm -rf dist/*",
|
|
48
|
+
"public": "npm publish --access public",
|
|
64
49
|
"postpublish": "git push origin --follow-tags",
|
|
65
50
|
"prepublishOnly": "npm run clean && npm run build",
|
|
66
51
|
"release": "standard-version -r",
|
|
67
|
-
"release:first": "standard-version --first-release"
|
|
68
|
-
"coverage": "open ./coverage/lcov-report/index.html",
|
|
69
|
-
"commit": "git-cz"
|
|
52
|
+
"release:first": "standard-version --first-release"
|
|
70
53
|
},
|
|
71
54
|
"devDependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"@
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
87
|
-
"@typescript-eslint/parser": "^5.11.0",
|
|
88
|
-
"@vue/compiler-sfc": "^3.2.30",
|
|
89
|
-
"@vue/test-utils": "^2.0.0-rc.17",
|
|
90
|
-
"@webpack-cli/serve": "^1.0.1",
|
|
91
|
-
"babel-jest": "^26.6.3",
|
|
92
|
-
"babel-loader": "^8.1.0",
|
|
93
|
-
"commitizen": "^4.2.4",
|
|
94
|
-
"css-loader": "^5.0.0",
|
|
95
|
-
"cz-conventional-changelog": "^3.2.0",
|
|
96
|
-
"eslint": "^7.11.0",
|
|
97
|
-
"eslint-config-prettier": "^6.13.0",
|
|
98
|
-
"eslint-plugin-prettier": "^3.1.4",
|
|
99
|
-
"eslint-plugin-vue": "^7.2.0",
|
|
100
|
-
"file-loader": "^6.1.1",
|
|
101
|
-
"fs-extra": "^9.0.1",
|
|
102
|
-
"git-cz": "^4.7.6",
|
|
103
|
-
"html-webpack-plugin": "^5.0.0-beta.6",
|
|
104
|
-
"jest": "^26.6.3",
|
|
105
|
-
"jest-environment-jsdom": "^26.6.2",
|
|
106
|
-
"jest-serializer-vue": "^2.0.2",
|
|
107
|
-
"lint-staged": "^10.4.2",
|
|
108
|
-
"prettier": "^2.1.2",
|
|
109
|
-
"reflect-metadata": "^0.2.2",
|
|
110
|
-
"rollup": "^2.67.2",
|
|
111
|
-
"rollup-plugin-node-builtins": "^2.1.2",
|
|
112
|
-
"rollup-plugin-node-globals": "^1.4.0",
|
|
113
|
-
"rollup-plugin-polyfill-node": "^0.6.2",
|
|
114
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
115
|
-
"rollup-plugin-typescript2": "^0.27.2",
|
|
116
|
-
"standard-version": "^9.0.0",
|
|
117
|
-
"style-loader": "^2.0.0",
|
|
118
|
-
"ts-jest": "^26.4.4",
|
|
119
|
-
"ts-loader": "^8.0.5",
|
|
120
|
-
"tslib": "^2.0.2",
|
|
121
|
-
"typescript": "^4.5.5",
|
|
122
|
-
"vue": "^3.2.30",
|
|
123
|
-
"vue-jest": "^5.0.0-alpha.7",
|
|
124
|
-
"vue-loader": "^16.0.0-beta.4",
|
|
125
|
-
"vue-router": "^4.0.0-alpha.13",
|
|
126
|
-
"vue-style-loader": "^4.1.3",
|
|
127
|
-
"webpack": "^5.1.3",
|
|
128
|
-
"webpack-cli": "^4.1.0",
|
|
129
|
-
"webpack-dev-server": "^3.11.0",
|
|
130
|
-
"yorkie": "^2.0.0"
|
|
55
|
+
"@kaokei/di": "^3.0.9",
|
|
56
|
+
"@types/node": "^22.15.17",
|
|
57
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
58
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
59
|
+
"@vue/test-utils": "^2.4.6",
|
|
60
|
+
"jsdom": "^25.0.1",
|
|
61
|
+
"standard-version": "^9.5.0",
|
|
62
|
+
"typescript": "~5.6.3",
|
|
63
|
+
"vite": "^5.4.19",
|
|
64
|
+
"vite-plugin-dts": "^4.5.3",
|
|
65
|
+
"vitest": "^2.1.9",
|
|
66
|
+
"vue": "^3.5.13",
|
|
67
|
+
"vue-router": "^4.5.1",
|
|
68
|
+
"vue-tsc": "^2.2.10"
|
|
131
69
|
},
|
|
132
|
-
"
|
|
133
|
-
"pre-commit": "lint-staged",
|
|
134
|
-
"commit-msg": "commitlint -e $GIT_PARAMS"
|
|
135
|
-
},
|
|
136
|
-
"lint-staged": {
|
|
137
|
-
"*.{ts,js,tsx,jsx,vue}": [
|
|
138
|
-
"eslint --fix"
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
|
-
"config": {
|
|
142
|
-
"commitizen": {
|
|
143
|
-
"path": "node_modules/cz-conventional-changelog"
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
"commitlint": {
|
|
147
|
-
"extends": [
|
|
148
|
-
"@commitlint/config-conventional"
|
|
149
|
-
]
|
|
150
|
-
}
|
|
70
|
+
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
|
|
151
71
|
}
|