@kaokei/use-vue-service 4.0.2 → 4.0.3

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 CHANGED
@@ -25,3 +25,10 @@
25
25
  ## Todo List
26
26
 
27
27
  1. 改成tsdown来打包代码
28
+ 2. 开发devtools工具-浏览器插件
29
+ 3. 开发nuxt插件,自动导入API
30
+ 4. 表格宽度应该限制在装饰器页面
31
+
32
+ 4. 装饰器是否加小括号的表格
33
+ 4. 装饰器是否加小括号的类型兼容
34
+ 5. 整理note笔记
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@kaokei/di"),o=require("vue"),y=new c.Token("FIND_CHILD_SERVICE"),P=new c.Token("FIND_CHILDREN_SERVICES"),C=Symbol("SCOPE_KEY"),b="__raw__",a=Symbol("CONTAINER_TOKEN");function T(n){const e=n,t=o.effectScope(!0);return e[C]=t,t}function D(n){return n[C]}function V(n){const e=n;if(e){const t=D(e);t&&(t.stop(),delete e[C])}}function N(n){const e=D(n);return e||T(n)}function S(n,e,t,r){if(n){for(const i of n)if(i.isCurrentBound(e)&&(t.push(i.get(e)),r)||S(i.getChildren(),e,t,r))return!0}return!1}function F(n,e){const t=[];return S(e.getChildren(),n,t,!0),t[0]}function H(n,e){const t=[];return S(e.getChildren(),n,t,!1),t}function L(n,e,t){return c.isObject(e)?c.getOwnMetadata(b,t)?o.markRaw(e):o.reactive(e):e}function K(n){return V(n)}function W({container:n}){return e=>F(e,n)}function Y({container:n}){return e=>H(e,n)}function h(n){let e;return n?e=n.createChild():e=new c.Container,e.bind(y).toDynamicValue(W),e.bind(P).toDynamicValue(Y),e.onActivation(L),e.onDeactivation(K),e}const d=h();function s(n,e){if(typeof e=="function")e(n);else for(let t=0;t<e.length;t++)n.bind(e[t]).toSelf()}function A(){const n=o.getCurrentInstance();if(n){const e=a,t=n.provides,r=n.parent&&n.parent.provides;if(t&&t!==r&&c.hasOwn(t,e))return t[e]}}function j(n){if(!o.hasInjectionContext())throw new Error(`${n} must inside setup.`)}function g(){return o.inject(a,d)}function q(n){return j("useService"),(A()||g()).get(n)}function M(n){j("declareProviders");const e=A();if(e)s(e,n);else{const t=g(),r=h(t);s(r,n),o.provide(a,r),o.onUnmounted(()=>{r.destroy()})}}function U(n){return d.get(n)}function z(n){s(d,n)}function B(n,e){return e.runWithContext(()=>g().get(n))}function k(n,e){e.runWithContext(()=>{const t=o.inject(a,null);if(t)s(t,n);else{const r=h(d);s(r,n),e.provide(a,r),e.onUnmount(()=>{r.destroy()})}})}function G(n){return e=>k(n,e)}function _(n,e){const t=e.name;return function(){const r=this,i=o.toRaw(this),R=N(i),E=n;let l,f=Object.getPrototypeOf(i);for(;f;){const u=Object.getOwnPropertyDescriptor(f,t);if(u&&u.set){l=u.set;break}f=Object.getPrototypeOf(f)}const I=l?R.run(()=>o.computed({get:()=>E.call(r),set:u=>l.call(r,u)})):R.run(()=>o.computed(()=>E.call(r)));return Object.defineProperty(i,t,{value:I,writable:!0,configurable:!0,enumerable:!0}),I}}function $(n,e){return typeof n=="function"&&(e==null?void 0:e.kind)==="getter"?_(n,e):_}function p(n){return c.isObject(n)?o.markRaw(n):n}function m(n,e){const t=e.name;e.addInitializer(function(){let r;Object.defineProperty(this,t,{configurable:!0,enumerable:!0,get(){return r},set(i){r=p(i)}})})}function O(n,e){return{get(){return n.get.call(o.toRaw(this))},set(t){n.set.call(o.toRaw(this),p(t))},init:p}}function v(n,e){e.metadata&&(e.metadata[b]=!0)}function J(n,e){return(e==null?void 0:e.kind)==="field"?m(n,e):(e==null?void 0:e.kind)==="accessor"?O(n):(e==null?void 0:e.kind)==="class"?v(n,e):(t,r)=>(r==null?void 0:r.kind)==="field"?m(t,r):(r==null?void 0:r.kind)==="accessor"?O(t):v(t,r)}function w(n,e){return function(...t){const i=N(this).run(()=>o.effectScope());return i.run(()=>n.call(this,...t)),i}}function Q(n,e){return typeof n=="function"&&(e==null?void 0:e.kind)==="method"?w(n):w}exports.Computed=$;exports.FIND_CHILDREN_SERVICES=P;exports.FIND_CHILD_SERVICE=y;exports.Raw=J;exports.RunInScope=Q;exports.declareAppProviders=k;exports.declareAppProvidersPlugin=G;exports.declareProviders=M;exports.declareRootProviders=z;exports.useAppService=B;exports.useRootService=U;exports.useService=q;Object.keys(c).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>c[n]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@kaokei/di"),o=require("vue"),y=new c.Token("FIND_CHILD_SERVICE"),P=new c.Token("FIND_CHILDREN_SERVICES"),C=Symbol("SCOPE_KEY"),b="__raw__",a=Symbol("CONTAINER_TOKEN");function T(n){const e=n,t=o.effectScope(!0);return e[C]=t,t}function D(n){return n[C]}function V(n){const e=n;if(e){const t=D(e);t&&(t.stop(),delete e[C])}}function N(n){const e=D(n);return e||T(n)}function S(n,e,t,r){if(n){for(const i of n)if(i.isCurrentBound(e)&&(t.push(i.get(e)),r)||S(i.getChildren(),e,t,r))return!0}return!1}function F(n,e){const t=[];return S(e.getChildren(),n,t,!0),t[0]}function H(n,e){const t=[];return S(e.getChildren(),n,t,!1),t}function L(n,e,t){return c.isObject(e)?c.getOwnMetadata(b,t)?o.markRaw(e):o.reactive(e):e}function K(n){return V(n)}function W({container:n}){return e=>F(e,n)}function Y({container:n}){return e=>H(e,n)}function h(n){let e;return n?e=n.createChild():e=new c.Container,e.bind(y).toDynamicValue(W),e.bind(P).toDynamicValue(Y),e.onActivation(L),e.onDeactivation(K),e}const l=h();function s(n,e){if(typeof e=="function")e(n);else for(let t=0;t<e.length;t++)n.bind(e[t]).toSelf()}function A(){const n=o.getCurrentInstance();if(n){const e=a,t=n.provides,r=n.parent&&n.parent.provides;if(t&&t!==r&&c.hasOwn(t,e))return t[e]}}function j(n){if(!o.hasInjectionContext())throw new Error(`${n} must inside setup.`)}function g(){return o.inject(a,l)}function q(n){return j("useService"),(A()||g()).get(n)}function M(n){j("declareProviders");const e=A();if(e)s(e,n);else{const t=g(),r=h(t);s(r,n),o.provide(a,r),o.onUnmounted(()=>{r.destroy()})}}function U(n){return l.get(n)}function z(n){s(l,n)}function B(n,e){return e.runWithContext(()=>g().get(n))}function k(n,e){e.runWithContext(()=>{const t=o.inject(a,null);if(t)s(t,n);else{const r=h(l);s(r,n),e.provide(a,r),e.onUnmount(()=>{r.destroy()})}})}function G(n){return e=>k(n,e)}function _(n,e){const t=e.name;return function(){const r=this,i=o.toRaw(this),R=N(i),E=n;let p,f=Object.getPrototypeOf(i);for(;f;){const u=Object.getOwnPropertyDescriptor(f,t);if(u&&u.set){p=u.set;break}f=Object.getPrototypeOf(f)}const I=p?R.run(()=>o.computed({get:()=>E.call(r),set:u=>p.call(r,u)})):R.run(()=>o.computed(()=>E.call(r)));return Object.defineProperty(i,t,{value:I,writable:!0,configurable:!0,enumerable:!0}),I}}function $(n,e){return typeof n=="function"&&(e==null?void 0:e.kind)==="getter"?_(n,e):_}function d(n){return c.isObject(n)?o.markRaw(n):n}function m(n,e){const t=e.name;return e.addInitializer(function(){let r=this[t];Object.defineProperty(this,t,{configurable:!0,enumerable:!0,get(){return r},set(i){r=d(i)}})}),d}function O(n,e){return{get(){return n.get.call(o.toRaw(this))},set(t){n.set.call(o.toRaw(this),d(t))},init:d}}function v(n,e){e.metadata&&(e.metadata[b]=!0)}function J(n,e){return(e==null?void 0:e.kind)==="field"?m(n,e):(e==null?void 0:e.kind)==="accessor"?O(n):(e==null?void 0:e.kind)==="class"?v(n,e):(t,r)=>(r==null?void 0:r.kind)==="field"?m(t,r):(r==null?void 0:r.kind)==="accessor"?O(t):v(t,r)}function w(n,e){return function(...t){const i=N(this).run(()=>o.effectScope());return i.run(()=>n.call(this,...t)),i}}function Q(n,e){return typeof n=="function"&&(e==null?void 0:e.kind)==="method"?w(n):w}exports.Computed=$;exports.FIND_CHILDREN_SERVICES=P;exports.FIND_CHILD_SERVICE=y;exports.Raw=J;exports.RunInScope=Q;exports.declareAppProviders=k;exports.declareAppProvidersPlugin=G;exports.declareProviders=M;exports.declareRootProviders=z;exports.useAppService=B;exports.useRootService=U;exports.useService=q;Object.keys(c).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>c[n]})});
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Token as D, Container as H, isObject as v, getOwnMetadata as j, hasOwn as K } from "@kaokei/di";
2
2
  export * from "@kaokei/di";
3
- import { effectScope as N, markRaw as P, reactive as L, inject as b, provide as W, onUnmounted as Y, hasInjectionContext as U, getCurrentInstance as z, toRaw as d, computed as E } from "vue";
3
+ import { effectScope as N, markRaw as P, reactive as L, inject as b, provide as W, onUnmounted as Y, hasInjectionContext as U, getCurrentInstance as z, toRaw as l, computed as E } from "vue";
4
4
  const B = new D(
5
5
  "FIND_CHILD_SERVICE"
6
6
  ), G = new D(
@@ -26,8 +26,8 @@ function T(n) {
26
26
  }
27
27
  function C(n, e, t, r) {
28
28
  if (n) {
29
- for (const o of n)
30
- if (o.isCurrentBound(e) && (t.push(o.get(e)), r) || C(o.getChildren(), e, t, r))
29
+ for (const i of n)
30
+ if (i.isCurrentBound(e) && (t.push(i.get(e)), r) || C(i.getChildren(), e, t, r))
31
31
  return !0;
32
32
  }
33
33
  return !1;
@@ -58,7 +58,7 @@ function S(n) {
58
58
  let e;
59
59
  return n ? e = n.createChild() : e = new H(), e.bind(B).toDynamicValue(Z), e.bind(G).toDynamicValue(x), e.onActivation(Q), e.onDeactivation(X), e;
60
60
  }
61
- const a = S();
61
+ const f = S();
62
62
  function c(n, e) {
63
63
  if (typeof e == "function")
64
64
  e(n);
@@ -79,12 +79,12 @@ function F(n) {
79
79
  throw new Error(`${n} must inside setup.`);
80
80
  }
81
81
  function h() {
82
- return b(u, a);
82
+ return b(u, f);
83
83
  }
84
84
  function re(n) {
85
85
  return F("useService"), (V() || h()).get(n);
86
86
  }
87
- function oe(n) {
87
+ function ie(n) {
88
88
  F("declareProviders");
89
89
  const e = V();
90
90
  if (e)
@@ -96,11 +96,11 @@ function oe(n) {
96
96
  });
97
97
  }
98
98
  }
99
- function ie(n) {
100
- return a.get(n);
99
+ function oe(n) {
100
+ return f.get(n);
101
101
  }
102
102
  function ue(n) {
103
- c(a, n);
103
+ c(f, n);
104
104
  }
105
105
  function ce(n, e) {
106
106
  return e.runWithContext(() => h().get(n));
@@ -111,7 +111,7 @@ function ee(n, e) {
111
111
  if (t)
112
112
  c(t, n);
113
113
  else {
114
- const r = S(a);
114
+ const r = S(f);
115
115
  c(r, n), e.provide(u, r), e.onUnmount(() => {
116
116
  r.destroy();
117
117
  });
@@ -124,23 +124,23 @@ function se(n) {
124
124
  function I(n, e) {
125
125
  const t = e.name;
126
126
  return function() {
127
- const r = this, o = d(this), g = T(o), m = n;
128
- let f, s = Object.getPrototypeOf(o);
127
+ const r = this, i = l(this), g = T(i), m = n;
128
+ let d, s = Object.getPrototypeOf(i);
129
129
  for (; s; ) {
130
- const i = Object.getOwnPropertyDescriptor(s, t);
131
- if (i && i.set) {
132
- f = i.set;
130
+ const o = Object.getOwnPropertyDescriptor(s, t);
131
+ if (o && o.set) {
132
+ d = o.set;
133
133
  break;
134
134
  }
135
135
  s = Object.getPrototypeOf(s);
136
136
  }
137
- const _ = f ? g.run(
137
+ const _ = d ? g.run(
138
138
  () => E({
139
139
  get: () => m.call(r),
140
- set: (i) => f.call(r, i)
140
+ set: (o) => d.call(r, o)
141
141
  })
142
142
  ) : g.run(() => E(() => m.call(r)));
143
- return Object.defineProperty(o, t, {
143
+ return Object.defineProperty(i, t, {
144
144
  value: _,
145
145
  writable: !0,
146
146
  configurable: !0,
@@ -151,34 +151,34 @@ function I(n, e) {
151
151
  function ae(n, e) {
152
152
  return typeof n == "function" && (e == null ? void 0 : e.kind) === "getter" ? I(n, e) : I;
153
153
  }
154
- function l(n) {
154
+ function a(n) {
155
155
  return v(n) ? P(n) : n;
156
156
  }
157
157
  function w(n, e) {
158
158
  const t = e.name;
159
- e.addInitializer(function() {
160
- let r;
159
+ return e.addInitializer(function() {
160
+ let r = this[t];
161
161
  Object.defineProperty(this, t, {
162
162
  configurable: !0,
163
163
  enumerable: !0,
164
164
  get() {
165
165
  return r;
166
166
  },
167
- set(o) {
168
- r = l(o);
167
+ set(i) {
168
+ r = a(i);
169
169
  }
170
170
  });
171
- });
171
+ }), a;
172
172
  }
173
173
  function O(n, e) {
174
174
  return {
175
175
  get() {
176
- return n.get.call(d(this));
176
+ return n.get.call(l(this));
177
177
  },
178
178
  set(t) {
179
- n.set.call(d(this), l(t));
179
+ n.set.call(l(this), a(t));
180
180
  },
181
- init: l
181
+ init: a
182
182
  };
183
183
  }
184
184
  function R(n, e) {
@@ -189,8 +189,8 @@ function fe(n, e) {
189
189
  }
190
190
  function y(n, e) {
191
191
  return function(...t) {
192
- const o = T(this).run(() => N());
193
- return o.run(() => n.call(this, ...t)), o;
192
+ const i = T(this).run(() => N());
193
+ return i.run(() => n.call(this, ...t)), i;
194
194
  };
195
195
  }
196
196
  function de(n, e) {
@@ -204,9 +204,9 @@ export {
204
204
  de as RunInScope,
205
205
  ee as declareAppProviders,
206
206
  se as declareAppProvidersPlugin,
207
- oe as declareProviders,
207
+ ie as declareProviders,
208
208
  ue as declareRootProviders,
209
209
  ce as useAppService,
210
- ie as useRootService,
210
+ oe as useRootService,
211
211
  re as useService
212
212
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaokei/use-vue-service",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "type": "module",
5
5
  "description": "Lightweight Vue 3 state management with dependency injection, inspired by Angular services.",
6
6
  "main": "./dist/index.cjs",
@@ -43,7 +43,6 @@
43
43
  "coverage": "vitest run --coverage",
44
44
  "build": "vue-tsc -b tsconfig.app.json && vite build",
45
45
  "clean": "rm -rf dist/*",
46
- "public": "npm publish --access public",
47
46
  "postpublish": "git push origin --follow-tags",
48
47
  "prepublishOnly": "npm run clean && npm run build",
49
48
  "release": "standard-version -r",
@@ -79,5 +78,8 @@
79
78
  "reflect-metadata": "^0.2.2",
80
79
  "unplugin-swc": "^1.5.9"
81
80
  },
81
+ "publishConfig": {
82
+ "access": "public"
83
+ },
82
84
  "packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
83
85
  }