@bowenyao/my-component 0.0.6 → 0.0.8
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 +11 -11
- package/dist/cjs/index.cjs.js +5 -0
- package/dist/es/index.es.js +386 -0
- package/dist/iife/index.iife.js +5 -0
- package/dist/index.css +1 -0
- package/dist/umd/index.umd.js +5 -0
- package/package.json +1 -15
package/README.md
CHANGED
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
### npm 安装
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install @
|
|
19
|
+
npm install @bowenyao/my-component
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
### yarn 安装
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
yarn add @
|
|
25
|
+
yarn add @bowenyao/my-component
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### pnpm 安装
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
pnpm add @
|
|
31
|
+
pnpm add @bowenyao/my-component
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## 🚀 使用方法
|
|
@@ -38,7 +38,7 @@ pnpm add @cery/my-component
|
|
|
38
38
|
```javascript
|
|
39
39
|
import { createApp } from 'vue'
|
|
40
40
|
import App from './App.vue'
|
|
41
|
-
import MyComponent from '@
|
|
41
|
+
import MyComponent from '@bowenyao/my-component'
|
|
42
42
|
|
|
43
43
|
const app = createApp(App)
|
|
44
44
|
app.use(MyComponent)
|
|
@@ -56,7 +56,7 @@ app.mount('#app')
|
|
|
56
56
|
### 方式二:按需引入单个组件
|
|
57
57
|
|
|
58
58
|
```javascript
|
|
59
|
-
import { MyComponent } from '@
|
|
59
|
+
import { MyComponent } from '@bowenyao/my-component'
|
|
60
60
|
|
|
61
61
|
export default {
|
|
62
62
|
components: {
|
|
@@ -74,8 +74,8 @@ export default {
|
|
|
74
74
|
<meta charset="UTF-8">
|
|
75
75
|
<title>MyComponent Demo</title>
|
|
76
76
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
|
77
|
-
<script src="https://unpkg.com/@
|
|
78
|
-
<link rel="stylesheet" href="https://unpkg.com/@
|
|
77
|
+
<script src="https://unpkg.com/@bowenyao/my-component/dist/umd/index.umd.js"></script>
|
|
78
|
+
<link rel="stylesheet" href="https://unpkg.com/@bowenyao/my-component/dist/index.css">
|
|
79
79
|
</head>
|
|
80
80
|
<body>
|
|
81
81
|
<div id="app">
|
|
@@ -96,13 +96,13 @@ export default {
|
|
|
96
96
|
如果组件有独立样式,可以单独引入:
|
|
97
97
|
|
|
98
98
|
```javascript
|
|
99
|
-
import '@
|
|
99
|
+
import '@bowenyao/my-component/dist/style'
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
或
|
|
103
103
|
|
|
104
104
|
```javascript
|
|
105
|
-
import '@
|
|
105
|
+
import '@bowenyao/my-component/dist/index.css'
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
## 🏗️ 打包说明
|
|
@@ -133,7 +133,7 @@ pnpm preview
|
|
|
133
133
|
|
|
134
134
|
```json
|
|
135
135
|
{
|
|
136
|
-
"name": "@
|
|
136
|
+
"name": "@bowenyao/my-component", // 包名
|
|
137
137
|
"version": "0.0.6", // 版本号
|
|
138
138
|
"type": "module", // 模块类型
|
|
139
139
|
"main": "./dist/cjs/index.cjs.js", // CommonJS 入口
|
|
@@ -210,7 +210,7 @@ npm version major
|
|
|
210
210
|
|
|
211
211
|
### 6. 发布作用域包
|
|
212
212
|
|
|
213
|
-
由于包名是 `@
|
|
213
|
+
由于包名是 `@bowenyao/my-component`(作用域包),确保:
|
|
214
214
|
|
|
215
215
|
1. `publishConfig.access` 设置为 `"public"`
|
|
216
216
|
2. 或者创建私有作用域:`npm publish --access restricted`
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const t=require("vue"),R=require("element-plus");const P=typeof window<"u";let O;const x=e=>O=e;process.env.NODE_ENV;const A=process.env.NODE_ENV!=="production"?Symbol("pinia"):Symbol();function V(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var k;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(k||(k={}));function Q(e,a){for(const r in a){const o=a[r];if(!(r in e))continue;const u=e[r];V(u)&&V(o)&&!t.isRef(o)&&!t.isReactive(o)?e[r]=Q(u,o):e[r]=o}return e}const X=()=>{};function q(e,a,r,o=X){e.add(a);const u=()=>{e.delete(a)&&o()};return!r&&t.getCurrentScope()&&t.onScopeDispose(u),u}function D(e,...a){e.forEach(r=>{r(...a)})}const oe=e=>e(),H=Symbol(),M=Symbol();function F(e,a){e instanceof Map&&a instanceof Map?a.forEach((r,o)=>e.set(o,r)):e instanceof Set&&a instanceof Set&&a.forEach(e.add,e);for(const r in a){if(!a.hasOwnProperty(r))continue;const o=a[r],u=e[r];V(u)&&V(o)&&e.hasOwnProperty(r)&&!t.isRef(o)&&!t.isReactive(o)?e[r]=F(u,o):e[r]=o}return e}const ne=process.env.NODE_ENV!=="production"?Symbol("pinia:skipHydration"):Symbol();function se(e){return!V(e)||!Object.prototype.hasOwnProperty.call(e,ne)}const{assign:v}=Object;function J(e){return!!(t.isRef(e)&&e.effect)}function z(e,a,r,o){const{state:u,actions:p,getters:i}=a,N=r.state.value[e];let b;function d(){!N&&(process.env.NODE_ENV==="production"||!o)&&(r.state.value[e]=u?u():{});const f=process.env.NODE_ENV!=="production"&&o?t.toRefs(t.ref(u?u():{}).value):t.toRefs(r.state.value[e]);return v(f,p,Object.keys(i||{}).reduce((E,m)=>(process.env.NODE_ENV!=="production"&&m in f&&console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${m}" in store "${e}".`),E[m]=t.markRaw(t.computed(()=>{x(r);const y=r._s.get(e);return i[m].call(y,y)})),E),{}))}return b=U(e,d,a,r,o,!0),b}function U(e,a,r={},o,u,p){let i;const N=v({actions:{}},r);if(process.env.NODE_ENV!=="production"&&!o._e.active)throw new Error("Pinia destroyed");const b={deep:!0};process.env.NODE_ENV!=="production"&&(b.onTrigger=s=>{d?y=s:d==!1&&!c._hotUpdating&&(Array.isArray(y)?y.push(s):console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."))});let d,f,E=new Set,m=new Set,y;const S=o.state.value[e];!p&&!S&&(process.env.NODE_ENV==="production"||!u)&&(o.state.value[e]={});const I=t.ref({});let L;function W(s){let n;d=f=!1,process.env.NODE_ENV!=="production"&&(y=[]),typeof s=="function"?(s(o.state.value[e]),n={type:k.patchFunction,storeId:e,events:y}):(F(o.state.value[e],s),n={type:k.patchObject,payload:s,storeId:e,events:y});const l=L=Symbol();t.nextTick().then(()=>{L===l&&(d=!0)}),f=!0,D(E,n,o.state.value[e])}const G=p?function(){const{state:n}=r,l=n?n():{};this.$patch(_=>{v(_,l)})}:process.env.NODE_ENV!=="production"?()=>{throw new Error(`🍍: Store "${e}" is built using the setup syntax and does not implement $reset().`)}:X;function K(){i.stop(),E.clear(),m.clear(),o._s.delete(e)}const $=(s,n="")=>{if(H in s)return s[M]=n,s;const l=function(){x(o);const _=Array.from(arguments),j=new Set,T=new Set;function ee(h){j.add(h)}function te(h){T.add(h)}D(m,{args:_,name:l[M],store:c,after:ee,onError:te});let w;try{w=s.apply(this&&this.$id===e?this:c,_)}catch(h){throw D(T,h),h}return w instanceof Promise?w.then(h=>(D(j,h),h)).catch(h=>(D(T,h),Promise.reject(h))):(D(j,w),w)};return l[H]=!0,l[M]=n,l},C=t.markRaw({actions:{},getters:{},state:[],hotState:I}),B={_p:o,$id:e,$onAction:q.bind(null,m),$patch:W,$reset:G,$subscribe(s,n={}){const l=q(E,s,n.detached,()=>_()),_=i.run(()=>t.watch(()=>o.state.value[e],j=>{(n.flush==="sync"?f:d)&&s({storeId:e,type:k.direct,events:y},j)},v({},b,n)));return l},$dispose:K},c=t.reactive(process.env.NODE_ENV!=="production"||process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&P?v({_hmrPayload:C,_customProperties:t.markRaw(new Set)},B):B);o._s.set(e,c);const g=(o._a&&o._a.runWithContext||oe)(()=>o._e.run(()=>(i=t.effectScope()).run(()=>a({action:$}))));for(const s in g){const n=g[s];if(t.isRef(n)&&!J(n)||t.isReactive(n))process.env.NODE_ENV!=="production"&&u?I.value[s]=t.toRef(g,s):p||(S&&se(n)&&(t.isRef(n)?n.value=S[s]:F(n,S[s])),o.state.value[e][s]=n),process.env.NODE_ENV!=="production"&&C.state.push(s);else if(typeof n=="function"){const l=process.env.NODE_ENV!=="production"&&u?n:$(n,s);g[s]=l,process.env.NODE_ENV!=="production"&&(C.actions[s]=n),N.actions[s]=n}else process.env.NODE_ENV!=="production"&&J(n)&&(C.getters[s]=p?r.getters[s]:n,P&&(g._getters||(g._getters=t.markRaw([]))).push(s))}if(v(c,g),v(t.toRaw(c),g),Object.defineProperty(c,"$state",{get:()=>process.env.NODE_ENV!=="production"&&u?I.value:o.state.value[e],set:s=>{if(process.env.NODE_ENV!=="production"&&u)throw new Error("cannot set hotState");W(n=>{v(n,s)})}}),process.env.NODE_ENV!=="production"&&(c._hotUpdate=t.markRaw(s=>{c._hotUpdating=!0,s._hmrPayload.state.forEach(n=>{if(n in c.$state){const l=s.$state[n],_=c.$state[n];typeof l=="object"&&V(l)&&V(_)?Q(l,_):s.$state[n]=_}c[n]=t.toRef(s.$state,n)}),Object.keys(c.$state).forEach(n=>{n in s.$state||delete c[n]}),d=!1,f=!1,o.state.value[e]=t.toRef(s._hmrPayload,"hotState"),f=!0,t.nextTick().then(()=>{d=!0});for(const n in s._hmrPayload.actions){const l=s[n];c[n]=$(l,n)}for(const n in s._hmrPayload.getters){const l=s._hmrPayload.getters[n],_=p?t.computed(()=>(x(o),l.call(c,c))):l;c[n]=_}Object.keys(c._hmrPayload.getters).forEach(n=>{n in s._hmrPayload.getters||delete c[n]}),Object.keys(c._hmrPayload.actions).forEach(n=>{n in s._hmrPayload.actions||delete c[n]}),c._hmrPayload=s._hmrPayload,c._getters=s._getters,c._hotUpdating=!1})),process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&P){const s={writable:!0,configurable:!0,enumerable:!1};["_p","_hmrPayload","_getters","_customProperties"].forEach(n=>{Object.defineProperty(c,n,v({value:c[n]},s))})}return o._p.forEach(s=>{if(process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&P){const n=i.run(()=>s({store:c,app:o._a,pinia:o,options:N}));Object.keys(n||{}).forEach(l=>c._customProperties.add(l)),v(c,n)}else v(c,i.run(()=>s({store:c,app:o._a,pinia:o,options:N})))}),process.env.NODE_ENV!=="production"&&c.$state&&typeof c.$state=="object"&&typeof c.$state.constructor=="function"&&!c.$state.constructor.toString().includes("[native code]")&&console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
2
|
+
state: () => new MyClass()
|
|
3
|
+
Found in store "${c.$id}".`),S&&p&&r.hydrate&&r.hydrate(c.$state,S),d=!0,f=!0,c}function re(e,a,r){let o;const u=typeof a=="function";o=u?r:a;function p(i,N){const b=t.hasInjectionContext();if(i=(process.env.NODE_ENV==="test"&&O&&O._testing?null:i)||(b?t.inject(A,null):null),i&&x(i),process.env.NODE_ENV!=="production"&&!O)throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
4
|
+
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
5
|
+
This will fail in production.`);i=O,i._s.has(e)||(u?U(e,a,o,i):z(e,o,i),process.env.NODE_ENV!=="production"&&(p._pinia=i));const d=i._s.get(e);if(process.env.NODE_ENV!=="production"&&N){const f="__hot:"+e,E=u?U(f,a,o,i,!0):z(f,v({},o),i,!0);N._hotUpdate(E),delete i.state.value[f],i._s.delete(f)}if(process.env.NODE_ENV!=="production"&&P){const f=t.getCurrentInstance();if(f&&f.proxy&&!N){const E=f.proxy,m="_pStores"in E?E._pStores:E._pStores={};m[e]=d}}return d}return p.$id=e,p}function ce(e){const a=t.toRaw(e),r={};for(const o in a){const u=a[o];u.effect?r[o]=t.computed({get:()=>e[o],set(p){e[o]=p}}):(t.isRef(u)||t.isReactive(u))&&(r[o]=t.toRef(e,o))}return r}const ae=re("user",()=>({token:t.ref(123)})),ie=()=>({userStore:ae()}),ue=(e,a)=>{const r=e.__vccOpts||e;for(const[o,u]of a)r[o]=u;return r},le={class:"my-component"},fe={class:"my-wrapper"},pe={__name:"MyComponent",props:{title:{type:String,default:"你好,你是第一个使用我组件的人"}},setup(e){const{userStore:a}=ie(),{token:r}=ce(a),o=t.ref(0),u=()=>{R.ElMessage.success("成功触发 Element Plus 消息!")};return(p,i)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",le,[t.createElementVNode("h2",null,t.toDisplayString(e.title),1),t.createVNode(t.unref(R.ElButton),{onClick:i[0]||(i[0]=N=>o.value++)},{default:t.withCtx(()=>[t.createTextVNode("点击量: "+t.toDisplayString(o.value),1)]),_:1})]),t.createElementVNode("div",fe,[i[2]||(i[2]=t.createElementVNode("h3",null,"这是我的组件,内嵌了 Element Plus",-1)),t.createVNode(t.unref(R.ElButton),{type:"primary",onClick:u},{default:t.withCtx(()=>[...i[1]||(i[1]=[t.createTextVNode("点击我",-1)])]),_:1}),i[3]||(i[3]=t.createElementVNode("div",{style:{"margin-bottom":"20px"}},null,-1)),t.createVNode(t.unref(R.ElTag),{type:"success"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(e.title),1)]),_:1}),t.createVNode(t.unref(R.ElTag),{type:"success"},{default:t.withCtx(()=>[t.createTextVNode("这是pinia数据"+t.toDisplayString(t.unref(r)),1)]),_:1})])],64))}},Y=ue(pe,[["__scopeId","data-v-112f53bc"]]),Z={install(e){e.component("MyComponent",Y)}};Z.MyComponent=Y;module.exports=Z;
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { hasInjectionContext as z, inject as Q, toRaw as le, computed as G, isRef as D, isReactive as L, toRef as T, getCurrentInstance as ye, ref as W, reactive as me, markRaw as x, effectScope as Ne, nextTick as oe, getCurrentScope as be, onScopeDispose as ge, watch as Oe, toRefs as ne, openBlock as Ve, createElementBlock as Pe, Fragment as Se, createElementVNode as C, toDisplayString as R, createVNode as M, unref as w, withCtx as A, createTextVNode as F } from "vue";
|
|
2
|
+
import { ElButton as se, ElTag as re, ElMessage as De } from "element-plus";
|
|
3
|
+
const S = typeof window < "u";
|
|
4
|
+
let g;
|
|
5
|
+
const U = (e) => g = e;
|
|
6
|
+
process.env.NODE_ENV;
|
|
7
|
+
const X = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia") : (
|
|
8
|
+
/* istanbul ignore next */
|
|
9
|
+
/* @__PURE__ */ Symbol()
|
|
10
|
+
);
|
|
11
|
+
function O(e) {
|
|
12
|
+
return e && typeof e == "object" && Object.prototype.toString.call(e) === "[object Object]" && typeof e.toJSON != "function";
|
|
13
|
+
}
|
|
14
|
+
var I;
|
|
15
|
+
(function(e) {
|
|
16
|
+
e.direct = "direct", e.patchObject = "patch object", e.patchFunction = "patch function";
|
|
17
|
+
})(I || (I = {}));
|
|
18
|
+
function fe(e, c) {
|
|
19
|
+
for (const s in c) {
|
|
20
|
+
const t = c[s];
|
|
21
|
+
if (!(s in e))
|
|
22
|
+
continue;
|
|
23
|
+
const u = e[s];
|
|
24
|
+
O(u) && O(t) && !D(t) && !L(t) ? e[s] = fe(u, t) : e[s] = t;
|
|
25
|
+
}
|
|
26
|
+
return e;
|
|
27
|
+
}
|
|
28
|
+
const pe = () => {
|
|
29
|
+
};
|
|
30
|
+
function ce(e, c, s, t = pe) {
|
|
31
|
+
e.add(c);
|
|
32
|
+
const u = () => {
|
|
33
|
+
e.delete(c) && t();
|
|
34
|
+
};
|
|
35
|
+
return !s && be() && ge(u), u;
|
|
36
|
+
}
|
|
37
|
+
function P(e, ...c) {
|
|
38
|
+
e.forEach((s) => {
|
|
39
|
+
s(...c);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const je = (e) => e(), ae = /* @__PURE__ */ Symbol(), J = /* @__PURE__ */ Symbol();
|
|
43
|
+
function Y(e, c) {
|
|
44
|
+
e instanceof Map && c instanceof Map ? c.forEach((s, t) => e.set(t, s)) : e instanceof Set && c instanceof Set && c.forEach(e.add, e);
|
|
45
|
+
for (const s in c) {
|
|
46
|
+
if (!c.hasOwnProperty(s))
|
|
47
|
+
continue;
|
|
48
|
+
const t = c[s], u = e[s];
|
|
49
|
+
O(u) && O(t) && e.hasOwnProperty(s) && !D(t) && !L(t) ? e[s] = Y(u, t) : e[s] = t;
|
|
50
|
+
}
|
|
51
|
+
return e;
|
|
52
|
+
}
|
|
53
|
+
const ke = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ Symbol("pinia:skipHydration") : (
|
|
54
|
+
/* istanbul ignore next */
|
|
55
|
+
/* @__PURE__ */ Symbol()
|
|
56
|
+
);
|
|
57
|
+
function Ce(e) {
|
|
58
|
+
return !O(e) || !Object.prototype.hasOwnProperty.call(e, ke);
|
|
59
|
+
}
|
|
60
|
+
const { assign: h } = Object;
|
|
61
|
+
function ue(e) {
|
|
62
|
+
return !!(D(e) && e.effect);
|
|
63
|
+
}
|
|
64
|
+
function ie(e, c, s, t) {
|
|
65
|
+
const { state: u, actions: f, getters: a } = c, v = s.state.value[e];
|
|
66
|
+
let b;
|
|
67
|
+
function p() {
|
|
68
|
+
!v && (process.env.NODE_ENV === "production" || !t) && (s.state.value[e] = u ? u() : {});
|
|
69
|
+
const l = process.env.NODE_ENV !== "production" && t ? (
|
|
70
|
+
// use ref() to unwrap refs inside state TODO: check if this is still necessary
|
|
71
|
+
ne(W(u ? u() : {}).value)
|
|
72
|
+
) : ne(s.state.value[e]);
|
|
73
|
+
return h(l, f, Object.keys(a || {}).reduce((d, y) => (process.env.NODE_ENV !== "production" && y in l && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${y}" in store "${e}".`), d[y] = x(G(() => {
|
|
74
|
+
U(s);
|
|
75
|
+
const m = s._s.get(e);
|
|
76
|
+
return a[y].call(m, m);
|
|
77
|
+
})), d), {}));
|
|
78
|
+
}
|
|
79
|
+
return b = Z(e, p, c, s, t, !0), b;
|
|
80
|
+
}
|
|
81
|
+
function Z(e, c, s = {}, t, u, f) {
|
|
82
|
+
let a;
|
|
83
|
+
const v = h({ actions: {} }, s);
|
|
84
|
+
if (process.env.NODE_ENV !== "production" && !t._e.active)
|
|
85
|
+
throw new Error("Pinia destroyed");
|
|
86
|
+
const b = { deep: !0 };
|
|
87
|
+
process.env.NODE_ENV !== "production" && (b.onTrigger = (n) => {
|
|
88
|
+
p ? m = n : p == !1 && !r._hotUpdating && (Array.isArray(m) ? m.push(n) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
|
|
89
|
+
});
|
|
90
|
+
let p, l, d = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), m;
|
|
91
|
+
const V = t.state.value[e];
|
|
92
|
+
!f && !V && (process.env.NODE_ENV === "production" || !u) && (t.state.value[e] = {});
|
|
93
|
+
const B = W({});
|
|
94
|
+
let K;
|
|
95
|
+
function ee(n) {
|
|
96
|
+
let o;
|
|
97
|
+
p = l = !1, process.env.NODE_ENV !== "production" && (m = []), typeof n == "function" ? (n(t.state.value[e]), o = {
|
|
98
|
+
type: I.patchFunction,
|
|
99
|
+
storeId: e,
|
|
100
|
+
events: m
|
|
101
|
+
}) : (Y(t.state.value[e], n), o = {
|
|
102
|
+
type: I.patchObject,
|
|
103
|
+
payload: n,
|
|
104
|
+
storeId: e,
|
|
105
|
+
events: m
|
|
106
|
+
});
|
|
107
|
+
const i = K = /* @__PURE__ */ Symbol();
|
|
108
|
+
oe().then(() => {
|
|
109
|
+
K === i && (p = !0);
|
|
110
|
+
}), l = !0, P(d, o, t.state.value[e]);
|
|
111
|
+
}
|
|
112
|
+
const Ee = f ? function() {
|
|
113
|
+
const { state: o } = s, i = o ? o() : {};
|
|
114
|
+
this.$patch((E) => {
|
|
115
|
+
h(E, i);
|
|
116
|
+
});
|
|
117
|
+
} : (
|
|
118
|
+
/* istanbul ignore next */
|
|
119
|
+
process.env.NODE_ENV !== "production" ? () => {
|
|
120
|
+
throw new Error(`🍍: Store "${e}" is built using the setup syntax and does not implement $reset().`);
|
|
121
|
+
} : pe
|
|
122
|
+
);
|
|
123
|
+
function _e() {
|
|
124
|
+
a.stop(), d.clear(), y.clear(), t._s.delete(e);
|
|
125
|
+
}
|
|
126
|
+
const H = (n, o = "") => {
|
|
127
|
+
if (ae in n)
|
|
128
|
+
return n[J] = o, n;
|
|
129
|
+
const i = function() {
|
|
130
|
+
U(t);
|
|
131
|
+
const E = Array.from(arguments), j = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Set();
|
|
132
|
+
function he(_) {
|
|
133
|
+
j.add(_);
|
|
134
|
+
}
|
|
135
|
+
function ve(_) {
|
|
136
|
+
q.add(_);
|
|
137
|
+
}
|
|
138
|
+
P(y, {
|
|
139
|
+
args: E,
|
|
140
|
+
name: i[J],
|
|
141
|
+
store: r,
|
|
142
|
+
after: he,
|
|
143
|
+
onError: ve
|
|
144
|
+
});
|
|
145
|
+
let k;
|
|
146
|
+
try {
|
|
147
|
+
k = n.apply(this && this.$id === e ? this : r, E);
|
|
148
|
+
} catch (_) {
|
|
149
|
+
throw P(q, _), _;
|
|
150
|
+
}
|
|
151
|
+
return k instanceof Promise ? k.then((_) => (P(j, _), _)).catch((_) => (P(q, _), Promise.reject(_))) : (P(j, k), k);
|
|
152
|
+
};
|
|
153
|
+
return i[ae] = !0, i[J] = o, i;
|
|
154
|
+
}, $ = /* @__PURE__ */ x({
|
|
155
|
+
actions: {},
|
|
156
|
+
getters: {},
|
|
157
|
+
state: [],
|
|
158
|
+
hotState: B
|
|
159
|
+
}), te = {
|
|
160
|
+
_p: t,
|
|
161
|
+
// _s: scope,
|
|
162
|
+
$id: e,
|
|
163
|
+
$onAction: ce.bind(null, y),
|
|
164
|
+
$patch: ee,
|
|
165
|
+
$reset: Ee,
|
|
166
|
+
$subscribe(n, o = {}) {
|
|
167
|
+
const i = ce(d, n, o.detached, () => E()), E = a.run(() => Oe(() => t.state.value[e], (j) => {
|
|
168
|
+
(o.flush === "sync" ? l : p) && n({
|
|
169
|
+
storeId: e,
|
|
170
|
+
type: I.direct,
|
|
171
|
+
events: m
|
|
172
|
+
}, j);
|
|
173
|
+
}, h({}, b, o)));
|
|
174
|
+
return i;
|
|
175
|
+
},
|
|
176
|
+
$dispose: _e
|
|
177
|
+
}, r = me(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && S ? h(
|
|
178
|
+
{
|
|
179
|
+
_hmrPayload: $,
|
|
180
|
+
_customProperties: x(/* @__PURE__ */ new Set())
|
|
181
|
+
// devtools custom properties
|
|
182
|
+
},
|
|
183
|
+
te
|
|
184
|
+
// must be added later
|
|
185
|
+
// setupStore
|
|
186
|
+
) : te);
|
|
187
|
+
t._s.set(e, r);
|
|
188
|
+
const N = (t._a && t._a.runWithContext || je)(() => t._e.run(() => (a = Ne()).run(() => c({ action: H }))));
|
|
189
|
+
for (const n in N) {
|
|
190
|
+
const o = N[n];
|
|
191
|
+
if (D(o) && !ue(o) || L(o))
|
|
192
|
+
process.env.NODE_ENV !== "production" && u ? B.value[n] = T(N, n) : f || (V && Ce(o) && (D(o) ? o.value = V[n] : Y(o, V[n])), t.state.value[e][n] = o), process.env.NODE_ENV !== "production" && $.state.push(n);
|
|
193
|
+
else if (typeof o == "function") {
|
|
194
|
+
const i = process.env.NODE_ENV !== "production" && u ? o : H(o, n);
|
|
195
|
+
N[n] = i, process.env.NODE_ENV !== "production" && ($.actions[n] = o), v.actions[n] = o;
|
|
196
|
+
} else process.env.NODE_ENV !== "production" && ue(o) && ($.getters[n] = f ? (
|
|
197
|
+
// @ts-expect-error
|
|
198
|
+
s.getters[n]
|
|
199
|
+
) : o, S && (N._getters || // @ts-expect-error: same
|
|
200
|
+
(N._getters = x([]))).push(n));
|
|
201
|
+
}
|
|
202
|
+
if (h(r, N), h(le(r), N), Object.defineProperty(r, "$state", {
|
|
203
|
+
get: () => process.env.NODE_ENV !== "production" && u ? B.value : t.state.value[e],
|
|
204
|
+
set: (n) => {
|
|
205
|
+
if (process.env.NODE_ENV !== "production" && u)
|
|
206
|
+
throw new Error("cannot set hotState");
|
|
207
|
+
ee((o) => {
|
|
208
|
+
h(o, n);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}), process.env.NODE_ENV !== "production" && (r._hotUpdate = x((n) => {
|
|
212
|
+
r._hotUpdating = !0, n._hmrPayload.state.forEach((o) => {
|
|
213
|
+
if (o in r.$state) {
|
|
214
|
+
const i = n.$state[o], E = r.$state[o];
|
|
215
|
+
typeof i == "object" && O(i) && O(E) ? fe(i, E) : n.$state[o] = E;
|
|
216
|
+
}
|
|
217
|
+
r[o] = T(n.$state, o);
|
|
218
|
+
}), Object.keys(r.$state).forEach((o) => {
|
|
219
|
+
o in n.$state || delete r[o];
|
|
220
|
+
}), p = !1, l = !1, t.state.value[e] = T(n._hmrPayload, "hotState"), l = !0, oe().then(() => {
|
|
221
|
+
p = !0;
|
|
222
|
+
});
|
|
223
|
+
for (const o in n._hmrPayload.actions) {
|
|
224
|
+
const i = n[o];
|
|
225
|
+
r[o] = //
|
|
226
|
+
H(i, o);
|
|
227
|
+
}
|
|
228
|
+
for (const o in n._hmrPayload.getters) {
|
|
229
|
+
const i = n._hmrPayload.getters[o], E = f ? (
|
|
230
|
+
// special handling of options api
|
|
231
|
+
G(() => (U(t), i.call(r, r)))
|
|
232
|
+
) : i;
|
|
233
|
+
r[o] = //
|
|
234
|
+
E;
|
|
235
|
+
}
|
|
236
|
+
Object.keys(r._hmrPayload.getters).forEach((o) => {
|
|
237
|
+
o in n._hmrPayload.getters || delete r[o];
|
|
238
|
+
}), Object.keys(r._hmrPayload.actions).forEach((o) => {
|
|
239
|
+
o in n._hmrPayload.actions || delete r[o];
|
|
240
|
+
}), r._hmrPayload = n._hmrPayload, r._getters = n._getters, r._hotUpdating = !1;
|
|
241
|
+
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && S) {
|
|
242
|
+
const n = {
|
|
243
|
+
writable: !0,
|
|
244
|
+
configurable: !0,
|
|
245
|
+
// avoid warning on devtools trying to display this property
|
|
246
|
+
enumerable: !1
|
|
247
|
+
};
|
|
248
|
+
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((o) => {
|
|
249
|
+
Object.defineProperty(r, o, h({ value: r[o] }, n));
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return t._p.forEach((n) => {
|
|
253
|
+
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && S) {
|
|
254
|
+
const o = a.run(() => n({
|
|
255
|
+
store: r,
|
|
256
|
+
app: t._a,
|
|
257
|
+
pinia: t,
|
|
258
|
+
options: v
|
|
259
|
+
}));
|
|
260
|
+
Object.keys(o || {}).forEach((i) => r._customProperties.add(i)), h(r, o);
|
|
261
|
+
} else
|
|
262
|
+
h(r, a.run(() => n({
|
|
263
|
+
store: r,
|
|
264
|
+
app: t._a,
|
|
265
|
+
pinia: t,
|
|
266
|
+
options: v
|
|
267
|
+
})));
|
|
268
|
+
}), process.env.NODE_ENV !== "production" && r.$state && typeof r.$state == "object" && typeof r.$state.constructor == "function" && !r.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
269
|
+
state: () => new MyClass()
|
|
270
|
+
Found in store "${r.$id}".`), V && f && s.hydrate && s.hydrate(r.$state, V), p = !0, l = !0, r;
|
|
271
|
+
}
|
|
272
|
+
// @__NO_SIDE_EFFECTS__
|
|
273
|
+
function we(e, c, s) {
|
|
274
|
+
let t;
|
|
275
|
+
const u = typeof c == "function";
|
|
276
|
+
t = u ? s : c;
|
|
277
|
+
function f(a, v) {
|
|
278
|
+
const b = z();
|
|
279
|
+
if (a = // in test mode, ignore the argument provided as we can always retrieve a
|
|
280
|
+
// pinia instance with getActivePinia()
|
|
281
|
+
(process.env.NODE_ENV === "test" && g && g._testing ? null : a) || (b ? Q(X, null) : null), a && U(a), process.env.NODE_ENV !== "production" && !g)
|
|
282
|
+
throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
283
|
+
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
284
|
+
This will fail in production.`);
|
|
285
|
+
a = g, a._s.has(e) || (u ? Z(e, c, t, a) : ie(e, t, a), process.env.NODE_ENV !== "production" && (f._pinia = a));
|
|
286
|
+
const p = a._s.get(e);
|
|
287
|
+
if (process.env.NODE_ENV !== "production" && v) {
|
|
288
|
+
const l = "__hot:" + e, d = u ? Z(l, c, t, a, !0) : ie(l, h({}, t), a, !0);
|
|
289
|
+
v._hotUpdate(d), delete a.state.value[l], a._s.delete(l);
|
|
290
|
+
}
|
|
291
|
+
if (process.env.NODE_ENV !== "production" && S) {
|
|
292
|
+
const l = ye();
|
|
293
|
+
if (l && l.proxy && // avoid adding stores that are just built for hot module replacement
|
|
294
|
+
!v) {
|
|
295
|
+
const d = l.proxy, y = "_pStores" in d ? d._pStores : d._pStores = {};
|
|
296
|
+
y[e] = p;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return p;
|
|
300
|
+
}
|
|
301
|
+
return f.$id = e, f;
|
|
302
|
+
}
|
|
303
|
+
function xe(e) {
|
|
304
|
+
const c = le(e), s = {};
|
|
305
|
+
for (const t in c) {
|
|
306
|
+
const u = c[t];
|
|
307
|
+
u.effect ? s[t] = // ...
|
|
308
|
+
G({
|
|
309
|
+
get: () => e[t],
|
|
310
|
+
set(f) {
|
|
311
|
+
e[t] = f;
|
|
312
|
+
}
|
|
313
|
+
}) : (D(u) || L(u)) && (s[t] = // ---
|
|
314
|
+
T(e, t));
|
|
315
|
+
}
|
|
316
|
+
return s;
|
|
317
|
+
}
|
|
318
|
+
const Ie = /* @__PURE__ */ we("user", () => ({
|
|
319
|
+
token: W(123)
|
|
320
|
+
})), $e = () => ({
|
|
321
|
+
userStore: Ie()
|
|
322
|
+
}), Re = (e, c) => {
|
|
323
|
+
const s = e.__vccOpts || e;
|
|
324
|
+
for (const [t, u] of c)
|
|
325
|
+
s[t] = u;
|
|
326
|
+
return s;
|
|
327
|
+
}, Me = { class: "my-component" }, Ae = { class: "my-wrapper" }, Fe = {
|
|
328
|
+
__name: "MyComponent",
|
|
329
|
+
props: {
|
|
330
|
+
title: {
|
|
331
|
+
type: String,
|
|
332
|
+
default: "你好,你是第一个使用我组件的人"
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
setup(e) {
|
|
336
|
+
const { userStore: c } = $e(), { token: s } = xe(c), t = W(0), u = () => {
|
|
337
|
+
De.success("成功触发 Element Plus 消息!");
|
|
338
|
+
};
|
|
339
|
+
return (f, a) => (Ve(), Pe(Se, null, [
|
|
340
|
+
C("div", Me, [
|
|
341
|
+
C("h2", null, R(e.title), 1),
|
|
342
|
+
M(w(se), {
|
|
343
|
+
onClick: a[0] || (a[0] = (v) => t.value++)
|
|
344
|
+
}, {
|
|
345
|
+
default: A(() => [
|
|
346
|
+
F("点击量: " + R(t.value), 1)
|
|
347
|
+
]),
|
|
348
|
+
_: 1
|
|
349
|
+
})
|
|
350
|
+
]),
|
|
351
|
+
C("div", Ae, [
|
|
352
|
+
a[2] || (a[2] = C("h3", null, "这是我的组件,内嵌了 Element Plus", -1)),
|
|
353
|
+
M(w(se), {
|
|
354
|
+
type: "primary",
|
|
355
|
+
onClick: u
|
|
356
|
+
}, {
|
|
357
|
+
default: A(() => [...a[1] || (a[1] = [
|
|
358
|
+
F("点击我", -1)
|
|
359
|
+
])]),
|
|
360
|
+
_: 1
|
|
361
|
+
}),
|
|
362
|
+
a[3] || (a[3] = C("div", { style: { "margin-bottom": "20px" } }, null, -1)),
|
|
363
|
+
M(w(re), { type: "success" }, {
|
|
364
|
+
default: A(() => [
|
|
365
|
+
F(R(e.title), 1)
|
|
366
|
+
]),
|
|
367
|
+
_: 1
|
|
368
|
+
}),
|
|
369
|
+
M(w(re), { type: "success" }, {
|
|
370
|
+
default: A(() => [
|
|
371
|
+
F("这是pinia数据" + R(w(s)), 1)
|
|
372
|
+
]),
|
|
373
|
+
_: 1
|
|
374
|
+
})
|
|
375
|
+
])
|
|
376
|
+
], 64));
|
|
377
|
+
}
|
|
378
|
+
}, de = /* @__PURE__ */ Re(Fe, [["__scopeId", "data-v-112f53bc"]]), Te = {
|
|
379
|
+
install(e) {
|
|
380
|
+
e.component("MyComponent", de);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
Te.MyComponent = de;
|
|
384
|
+
export {
|
|
385
|
+
Te as default
|
|
386
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var MyComponent=(function(e,w){"use strict";const D=typeof window<"u";let V;const x=t=>V=t;process.env.NODE_ENV;const v=process.env.NODE_ENV!=="production"?Symbol("pinia"):Symbol();function O(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var R;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(R||(R={}));function L(t,a){for(const r in a){const o=a[r];if(!(r in t))continue;const l=t[r];O(l)&&O(o)&&!e.isRef(o)&&!e.isReactive(o)?t[r]=L(l,o):t[r]=o}return t}const W=()=>{};function B(t,a,r,o=W){t.add(a);const l=()=>{t.delete(a)&&o()};return!r&&e.getCurrentScope()&&e.onScopeDispose(l),l}function P(t,...a){t.forEach(r=>{r(...a)})}const G=t=>t(),H=Symbol(),$=Symbol();function T(t,a){t instanceof Map&&a instanceof Map?a.forEach((r,o)=>t.set(o,r)):t instanceof Set&&a instanceof Set&&a.forEach(t.add,t);for(const r in a){if(!a.hasOwnProperty(r))continue;const o=a[r],l=t[r];O(l)&&O(o)&&t.hasOwnProperty(r)&&!e.isRef(o)&&!e.isReactive(o)?t[r]=T(l,o):t[r]=o}return t}const K=process.env.NODE_ENV!=="production"?Symbol("pinia:skipHydration"):Symbol();function tt(t){return!O(t)||!Object.prototype.hasOwnProperty.call(t,K)}const{assign:E}=Object;function q(t){return!!(e.isRef(t)&&t.effect)}function J(t,a,r,o){const{state:l,actions:p,getters:i}=a,y=r.state.value[t];let S;function d(){!y&&(process.env.NODE_ENV==="production"||!o)&&(r.state.value[t]=l?l():{});const u=process.env.NODE_ENV!=="production"&&o?e.toRefs(e.ref(l?l():{}).value):e.toRefs(r.state.value[t]);return E(u,p,Object.keys(i||{}).reduce((_,m)=>(process.env.NODE_ENV!=="production"&&m in u&&console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${m}" in store "${t}".`),_[m]=e.markRaw(e.computed(()=>{x(r);const g=r._s.get(t);return i[m].call(g,g)})),_),{}))}return S=M(t,d,a,r,o,!0),S}function M(t,a,r={},o,l,p){let i;const y=E({actions:{}},r);if(process.env.NODE_ENV!=="production"&&!o._e.active)throw new Error("Pinia destroyed");const S={deep:!0};process.env.NODE_ENV!=="production"&&(S.onTrigger=s=>{d?g=s:d==!1&&!c._hotUpdating&&(Array.isArray(g)?g.push(s):console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."))});let d,u,_=new Set,m=new Set,g;const j=o.state.value[t];!p&&!j&&(process.env.NODE_ENV==="production"||!l)&&(o.state.value[t]={});const A=e.ref({});let X;function Y(s){let n;d=u=!1,process.env.NODE_ENV!=="production"&&(g=[]),typeof s=="function"?(s(o.state.value[t]),n={type:R.patchFunction,storeId:t,events:g}):(T(o.state.value[t],s),n={type:R.patchObject,payload:s,storeId:t,events:g});const f=X=Symbol();e.nextTick().then(()=>{X===f&&(d=!0)}),u=!0,P(_,n,o.state.value[t])}const it=p?function(){const{state:n}=r,f=n?n():{};this.$patch(h=>{E(h,f)})}:process.env.NODE_ENV!=="production"?()=>{throw new Error(`🍍: Store "${t}" is built using the setup syntax and does not implement $reset().`)}:W;function lt(){i.stop(),_.clear(),m.clear(),o._s.delete(t)}const F=(s,n="")=>{if(H in s)return s[$]=n,s;const f=function(){x(o);const h=Array.from(arguments),C=new Set,U=new Set;function ft(N){C.add(N)}function ut(N){U.add(N)}P(m,{args:h,name:f[$],store:c,after:ft,onError:ut});let k;try{k=s.apply(this&&this.$id===t?this:c,h)}catch(N){throw P(U,N),N}return k instanceof Promise?k.then(N=>(P(C,N),N)).catch(N=>(P(U,N),Promise.reject(N))):(P(C,k),k)};return f[H]=!0,f[$]=n,f},I=e.markRaw({actions:{},getters:{},state:[],hotState:A}),Z={_p:o,$id:t,$onAction:B.bind(null,m),$patch:Y,$reset:it,$subscribe(s,n={}){const f=B(_,s,n.detached,()=>h()),h=i.run(()=>e.watch(()=>o.state.value[t],C=>{(n.flush==="sync"?u:d)&&s({storeId:t,type:R.direct,events:g},C)},E({},S,n)));return f},$dispose:lt},c=e.reactive(process.env.NODE_ENV!=="production"||process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&D?E({_hmrPayload:I,_customProperties:e.markRaw(new Set)},Z):Z);o._s.set(t,c);const b=(o._a&&o._a.runWithContext||G)(()=>o._e.run(()=>(i=e.effectScope()).run(()=>a({action:F}))));for(const s in b){const n=b[s];if(e.isRef(n)&&!q(n)||e.isReactive(n))process.env.NODE_ENV!=="production"&&l?A.value[s]=e.toRef(b,s):p||(j&&tt(n)&&(e.isRef(n)?n.value=j[s]:T(n,j[s])),o.state.value[t][s]=n),process.env.NODE_ENV!=="production"&&I.state.push(s);else if(typeof n=="function"){const f=process.env.NODE_ENV!=="production"&&l?n:F(n,s);b[s]=f,process.env.NODE_ENV!=="production"&&(I.actions[s]=n),y.actions[s]=n}else process.env.NODE_ENV!=="production"&&q(n)&&(I.getters[s]=p?r.getters[s]:n,D&&(b._getters||(b._getters=e.markRaw([]))).push(s))}if(E(c,b),E(e.toRaw(c),b),Object.defineProperty(c,"$state",{get:()=>process.env.NODE_ENV!=="production"&&l?A.value:o.state.value[t],set:s=>{if(process.env.NODE_ENV!=="production"&&l)throw new Error("cannot set hotState");Y(n=>{E(n,s)})}}),process.env.NODE_ENV!=="production"&&(c._hotUpdate=e.markRaw(s=>{c._hotUpdating=!0,s._hmrPayload.state.forEach(n=>{if(n in c.$state){const f=s.$state[n],h=c.$state[n];typeof f=="object"&&O(f)&&O(h)?L(f,h):s.$state[n]=h}c[n]=e.toRef(s.$state,n)}),Object.keys(c.$state).forEach(n=>{n in s.$state||delete c[n]}),d=!1,u=!1,o.state.value[t]=e.toRef(s._hmrPayload,"hotState"),u=!0,e.nextTick().then(()=>{d=!0});for(const n in s._hmrPayload.actions){const f=s[n];c[n]=F(f,n)}for(const n in s._hmrPayload.getters){const f=s._hmrPayload.getters[n],h=p?e.computed(()=>(x(o),f.call(c,c))):f;c[n]=h}Object.keys(c._hmrPayload.getters).forEach(n=>{n in s._hmrPayload.getters||delete c[n]}),Object.keys(c._hmrPayload.actions).forEach(n=>{n in s._hmrPayload.actions||delete c[n]}),c._hmrPayload=s._hmrPayload,c._getters=s._getters,c._hotUpdating=!1})),process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&D){const s={writable:!0,configurable:!0,enumerable:!1};["_p","_hmrPayload","_getters","_customProperties"].forEach(n=>{Object.defineProperty(c,n,E({value:c[n]},s))})}return o._p.forEach(s=>{if(process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&D){const n=i.run(()=>s({store:c,app:o._a,pinia:o,options:y}));Object.keys(n||{}).forEach(f=>c._customProperties.add(f)),E(c,n)}else E(c,i.run(()=>s({store:c,app:o._a,pinia:o,options:y})))}),process.env.NODE_ENV!=="production"&&c.$state&&typeof c.$state=="object"&&typeof c.$state.constructor=="function"&&!c.$state.constructor.toString().includes("[native code]")&&console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
2
|
+
state: () => new MyClass()
|
|
3
|
+
Found in store "${c.$id}".`),j&&p&&r.hydrate&&r.hydrate(c.$state,j),d=!0,u=!0,c}function et(t,a,r){let o;const l=typeof a=="function";o=l?r:a;function p(i,y){const S=e.hasInjectionContext();if(i=(process.env.NODE_ENV==="test"&&V&&V._testing?null:i)||(S?e.inject(v,null):null),i&&x(i),process.env.NODE_ENV!=="production"&&!V)throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
4
|
+
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
5
|
+
This will fail in production.`);i=V,i._s.has(t)||(l?M(t,a,o,i):J(t,o,i),process.env.NODE_ENV!=="production"&&(p._pinia=i));const d=i._s.get(t);if(process.env.NODE_ENV!=="production"&&y){const u="__hot:"+t,_=l?M(u,a,o,i,!0):J(u,E({},o),i,!0);y._hotUpdate(_),delete i.state.value[u],i._s.delete(u)}if(process.env.NODE_ENV!=="production"&&D){const u=e.getCurrentInstance();if(u&&u.proxy&&!y){const _=u.proxy,m="_pStores"in _?_._pStores:_._pStores={};m[t]=d}}return d}return p.$id=t,p}function ot(t){const a=e.toRaw(t),r={};for(const o in a){const l=a[o];l.effect?r[o]=e.computed({get:()=>t[o],set(p){t[o]=p}}):(e.isRef(l)||e.isReactive(l))&&(r[o]=e.toRef(t,o))}return r}const nt=et("user",()=>({token:e.ref(123)})),st=()=>({userStore:nt()}),rt=(t,a)=>{const r=t.__vccOpts||t;for(const[o,l]of a)r[o]=l;return r},ct={class:"my-component"},at={class:"my-wrapper"},z=rt({__name:"MyComponent",props:{title:{type:String,default:"你好,你是第一个使用我组件的人"}},setup(t){const{userStore:a}=st(),{token:r}=ot(a),o=e.ref(0),l=()=>{w.ElMessage.success("成功触发 Element Plus 消息!")};return(p,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ct,[e.createElementVNode("h2",null,e.toDisplayString(t.title),1),e.createVNode(e.unref(w.ElButton),{onClick:i[0]||(i[0]=y=>o.value++)},{default:e.withCtx(()=>[e.createTextVNode("点击量: "+e.toDisplayString(o.value),1)]),_:1})]),e.createElementVNode("div",at,[i[2]||(i[2]=e.createElementVNode("h3",null,"这是我的组件,内嵌了 Element Plus",-1)),e.createVNode(e.unref(w.ElButton),{type:"primary",onClick:l},{default:e.withCtx(()=>[...i[1]||(i[1]=[e.createTextVNode("点击我",-1)])]),_:1}),i[3]||(i[3]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},null,-1)),e.createVNode(e.unref(w.ElTag),{type:"success"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:1}),e.createVNode(e.unref(w.ElTag),{type:"success"},{default:e.withCtx(()=>[e.createTextVNode("这是pinia数据"+e.toDisplayString(e.unref(r)),1)]),_:1})])],64))}},[["__scopeId","data-v-112f53bc"]]),Q={install(t){t.component("MyComponent",z)}};return Q.MyComponent=z,Q})(Vue,ElementPlus);
|
package/dist/index.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.my-component[data-v-112f53bc]{padding:10px;border:1px solid #42b883;border-radius:8px}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(function(e,b){typeof exports=="object"&&typeof module<"u"?module.exports=b(require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["vue","element-plus"],b):(e=typeof globalThis<"u"?globalThis:e||self,e.MyComponent=b(e.Vue,e.ElementPlus))})(this,(function(e,b){"use strict";const P=typeof window<"u";let O;const x=t=>O=t;process.env.NODE_ENV;const v=process.env.NODE_ENV!=="production"?Symbol("pinia"):Symbol();function S(t){return t&&typeof t=="object"&&Object.prototype.toString.call(t)==="[object Object]"&&typeof t.toJSON!="function"}var R;(function(t){t.direct="direct",t.patchObject="patch object",t.patchFunction="patch function"})(R||(R={}));function L(t,a){for(const r in a){const o=a[r];if(!(r in t))continue;const l=t[r];S(l)&&S(o)&&!e.isRef(o)&&!e.isReactive(o)?t[r]=L(l,o):t[r]=o}return t}const W=()=>{};function B(t,a,r,o=W){t.add(a);const l=()=>{t.delete(a)&&o()};return!r&&e.getCurrentScope()&&e.onScopeDispose(l),l}function j(t,...a){t.forEach(r=>{r(...a)})}const G=t=>t(),q=Symbol(),$=Symbol();function T(t,a){t instanceof Map&&a instanceof Map?a.forEach((r,o)=>t.set(o,r)):t instanceof Set&&a instanceof Set&&a.forEach(t.add,t);for(const r in a){if(!a.hasOwnProperty(r))continue;const o=a[r],l=t[r];S(l)&&S(o)&&t.hasOwnProperty(r)&&!e.isRef(o)&&!e.isReactive(o)?t[r]=T(l,o):t[r]=o}return t}const K=process.env.NODE_ENV!=="production"?Symbol("pinia:skipHydration"):Symbol();function tt(t){return!S(t)||!Object.prototype.hasOwnProperty.call(t,K)}const{assign:E}=Object;function H(t){return!!(e.isRef(t)&&t.effect)}function J(t,a,r,o){const{state:l,actions:p,getters:i}=a,N=r.state.value[t];let D;function d(){!N&&(process.env.NODE_ENV==="production"||!o)&&(r.state.value[t]=l?l():{});const u=process.env.NODE_ENV!=="production"&&o?e.toRefs(e.ref(l?l():{}).value):e.toRefs(r.state.value[t]);return E(u,p,Object.keys(i||{}).reduce((h,y)=>(process.env.NODE_ENV!=="production"&&y in u&&console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${y}" in store "${t}".`),h[y]=e.markRaw(e.computed(()=>{x(r);const g=r._s.get(t);return i[y].call(g,g)})),h),{}))}return D=M(t,d,a,r,o,!0),D}function M(t,a,r={},o,l,p){let i;const N=E({actions:{}},r);if(process.env.NODE_ENV!=="production"&&!o._e.active)throw new Error("Pinia destroyed");const D={deep:!0};process.env.NODE_ENV!=="production"&&(D.onTrigger=s=>{d?g=s:d==!1&&!c._hotUpdating&&(Array.isArray(g)?g.push(s):console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."))});let d,u,h=new Set,y=new Set,g;const w=o.state.value[t];!p&&!w&&(process.env.NODE_ENV==="production"||!l)&&(o.state.value[t]={});const A=e.ref({});let X;function Y(s){let n;d=u=!1,process.env.NODE_ENV!=="production"&&(g=[]),typeof s=="function"?(s(o.state.value[t]),n={type:R.patchFunction,storeId:t,events:g}):(T(o.state.value[t],s),n={type:R.patchObject,payload:s,storeId:t,events:g});const f=X=Symbol();e.nextTick().then(()=>{X===f&&(d=!0)}),u=!0,j(h,n,o.state.value[t])}const it=p?function(){const{state:n}=r,f=n?n():{};this.$patch(_=>{E(_,f)})}:process.env.NODE_ENV!=="production"?()=>{throw new Error(`🍍: Store "${t}" is built using the setup syntax and does not implement $reset().`)}:W;function lt(){i.stop(),h.clear(),y.clear(),o._s.delete(t)}const F=(s,n="")=>{if(q in s)return s[$]=n,s;const f=function(){x(o);const _=Array.from(arguments),C=new Set,U=new Set;function ft(m){C.add(m)}function ut(m){U.add(m)}j(y,{args:_,name:f[$],store:c,after:ft,onError:ut});let k;try{k=s.apply(this&&this.$id===t?this:c,_)}catch(m){throw j(U,m),m}return k instanceof Promise?k.then(m=>(j(C,m),m)).catch(m=>(j(U,m),Promise.reject(m))):(j(C,k),k)};return f[q]=!0,f[$]=n,f},I=e.markRaw({actions:{},getters:{},state:[],hotState:A}),Z={_p:o,$id:t,$onAction:B.bind(null,y),$patch:Y,$reset:it,$subscribe(s,n={}){const f=B(h,s,n.detached,()=>_()),_=i.run(()=>e.watch(()=>o.state.value[t],C=>{(n.flush==="sync"?u:d)&&s({storeId:t,type:R.direct,events:g},C)},E({},D,n)));return f},$dispose:lt},c=e.reactive(process.env.NODE_ENV!=="production"||process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&P?E({_hmrPayload:I,_customProperties:e.markRaw(new Set)},Z):Z);o._s.set(t,c);const V=(o._a&&o._a.runWithContext||G)(()=>o._e.run(()=>(i=e.effectScope()).run(()=>a({action:F}))));for(const s in V){const n=V[s];if(e.isRef(n)&&!H(n)||e.isReactive(n))process.env.NODE_ENV!=="production"&&l?A.value[s]=e.toRef(V,s):p||(w&&tt(n)&&(e.isRef(n)?n.value=w[s]:T(n,w[s])),o.state.value[t][s]=n),process.env.NODE_ENV!=="production"&&I.state.push(s);else if(typeof n=="function"){const f=process.env.NODE_ENV!=="production"&&l?n:F(n,s);V[s]=f,process.env.NODE_ENV!=="production"&&(I.actions[s]=n),N.actions[s]=n}else process.env.NODE_ENV!=="production"&&H(n)&&(I.getters[s]=p?r.getters[s]:n,P&&(V._getters||(V._getters=e.markRaw([]))).push(s))}if(E(c,V),E(e.toRaw(c),V),Object.defineProperty(c,"$state",{get:()=>process.env.NODE_ENV!=="production"&&l?A.value:o.state.value[t],set:s=>{if(process.env.NODE_ENV!=="production"&&l)throw new Error("cannot set hotState");Y(n=>{E(n,s)})}}),process.env.NODE_ENV!=="production"&&(c._hotUpdate=e.markRaw(s=>{c._hotUpdating=!0,s._hmrPayload.state.forEach(n=>{if(n in c.$state){const f=s.$state[n],_=c.$state[n];typeof f=="object"&&S(f)&&S(_)?L(f,_):s.$state[n]=_}c[n]=e.toRef(s.$state,n)}),Object.keys(c.$state).forEach(n=>{n in s.$state||delete c[n]}),d=!1,u=!1,o.state.value[t]=e.toRef(s._hmrPayload,"hotState"),u=!0,e.nextTick().then(()=>{d=!0});for(const n in s._hmrPayload.actions){const f=s[n];c[n]=F(f,n)}for(const n in s._hmrPayload.getters){const f=s._hmrPayload.getters[n],_=p?e.computed(()=>(x(o),f.call(c,c))):f;c[n]=_}Object.keys(c._hmrPayload.getters).forEach(n=>{n in s._hmrPayload.getters||delete c[n]}),Object.keys(c._hmrPayload.actions).forEach(n=>{n in s._hmrPayload.actions||delete c[n]}),c._hmrPayload=s._hmrPayload,c._getters=s._getters,c._hotUpdating=!1})),process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&P){const s={writable:!0,configurable:!0,enumerable:!1};["_p","_hmrPayload","_getters","_customProperties"].forEach(n=>{Object.defineProperty(c,n,E({value:c[n]},s))})}return o._p.forEach(s=>{if(process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&P){const n=i.run(()=>s({store:c,app:o._a,pinia:o,options:N}));Object.keys(n||{}).forEach(f=>c._customProperties.add(f)),E(c,n)}else E(c,i.run(()=>s({store:c,app:o._a,pinia:o,options:N})))}),process.env.NODE_ENV!=="production"&&c.$state&&typeof c.$state=="object"&&typeof c.$state.constructor=="function"&&!c.$state.constructor.toString().includes("[native code]")&&console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
2
|
+
state: () => new MyClass()
|
|
3
|
+
Found in store "${c.$id}".`),w&&p&&r.hydrate&&r.hydrate(c.$state,w),d=!0,u=!0,c}function et(t,a,r){let o;const l=typeof a=="function";o=l?r:a;function p(i,N){const D=e.hasInjectionContext();if(i=(process.env.NODE_ENV==="test"&&O&&O._testing?null:i)||(D?e.inject(v,null):null),i&&x(i),process.env.NODE_ENV!=="production"&&!O)throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
4
|
+
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
5
|
+
This will fail in production.`);i=O,i._s.has(t)||(l?M(t,a,o,i):J(t,o,i),process.env.NODE_ENV!=="production"&&(p._pinia=i));const d=i._s.get(t);if(process.env.NODE_ENV!=="production"&&N){const u="__hot:"+t,h=l?M(u,a,o,i,!0):J(u,E({},o),i,!0);N._hotUpdate(h),delete i.state.value[u],i._s.delete(u)}if(process.env.NODE_ENV!=="production"&&P){const u=e.getCurrentInstance();if(u&&u.proxy&&!N){const h=u.proxy,y="_pStores"in h?h._pStores:h._pStores={};y[t]=d}}return d}return p.$id=t,p}function ot(t){const a=e.toRaw(t),r={};for(const o in a){const l=a[o];l.effect?r[o]=e.computed({get:()=>t[o],set(p){t[o]=p}}):(e.isRef(l)||e.isReactive(l))&&(r[o]=e.toRef(t,o))}return r}const nt=et("user",()=>({token:e.ref(123)})),st=()=>({userStore:nt()}),rt=(t,a)=>{const r=t.__vccOpts||t;for(const[o,l]of a)r[o]=l;return r},ct={class:"my-component"},at={class:"my-wrapper"},z=rt({__name:"MyComponent",props:{title:{type:String,default:"你好,你是第一个使用我组件的人"}},setup(t){const{userStore:a}=st(),{token:r}=ot(a),o=e.ref(0),l=()=>{b.ElMessage.success("成功触发 Element Plus 消息!")};return(p,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ct,[e.createElementVNode("h2",null,e.toDisplayString(t.title),1),e.createVNode(e.unref(b.ElButton),{onClick:i[0]||(i[0]=N=>o.value++)},{default:e.withCtx(()=>[e.createTextVNode("点击量: "+e.toDisplayString(o.value),1)]),_:1})]),e.createElementVNode("div",at,[i[2]||(i[2]=e.createElementVNode("h3",null,"这是我的组件,内嵌了 Element Plus",-1)),e.createVNode(e.unref(b.ElButton),{type:"primary",onClick:l},{default:e.withCtx(()=>[...i[1]||(i[1]=[e.createTextVNode("点击我",-1)])]),_:1}),i[3]||(i[3]=e.createElementVNode("div",{style:{"margin-bottom":"20px"}},null,-1)),e.createVNode(e.unref(b.ElTag),{type:"success"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:1}),e.createVNode(e.unref(b.ElTag),{type:"success"},{default:e.withCtx(()=>[e.createTextVNode("这是pinia数据"+e.toDisplayString(e.unref(r)),1)]),_:1})])],64))}},[["__scopeId","data-v-112f53bc"]]),Q={install(t){t.component("MyComponent",z)}};return Q.MyComponent=z,Q}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bowenyao/my-component",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs.js",
|
|
6
6
|
"module": "./dist/es/index.es.js",
|
|
@@ -17,20 +17,6 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"dev": "vite",
|
|
22
|
-
"build": "vite build",
|
|
23
|
-
"preview": "vite preview"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@vitejs/plugin-vue": "^6.0.4",
|
|
27
|
-
"vite": "^7.3.1",
|
|
28
|
-
"vite-plugin-static-copy": "^3.2.0"
|
|
29
|
-
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"element-plus": "^2.13.2",
|
|
32
|
-
"vue": "^3.5.29"
|
|
33
|
-
},
|
|
34
20
|
"publishConfig": {
|
|
35
21
|
"access": "public"
|
|
36
22
|
}
|