@empjs/share 3.10.1 → 3.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empjs/share",
3
- "version": "3.10.1",
3
+ "version": "3.11.0",
4
4
  "description": "emp share and runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -85,6 +85,26 @@
85
85
  "./library": {
86
86
  "types": "./output/sdk.d.ts",
87
87
  "default": "./output/sdk.js"
88
+ },
89
+ "./react": {
90
+ "import": {
91
+ "types": "./dist/react.d.ts",
92
+ "default": "./dist/react.js"
93
+ },
94
+ "require": {
95
+ "types": "./dist/react.d.cts",
96
+ "default": "./dist/react.cjs"
97
+ }
98
+ },
99
+ "./vue": {
100
+ "import": {
101
+ "types": "./dist/vue.d.ts",
102
+ "default": "./dist/vue.js"
103
+ },
104
+ "require": {
105
+ "types": "./dist/vue.d.cts",
106
+ "default": "./dist/vue.cjs"
107
+ }
88
108
  }
89
109
  },
90
110
  "typesVersions": {
@@ -109,22 +129,28 @@
109
129
  ],
110
130
  "library": [
111
131
  "./output/index.d.ts"
132
+ ],
133
+ "react": [
134
+ "./dist/react.d.ts"
135
+ ],
136
+ "vue": [
137
+ "./dist/vue.d.ts"
112
138
  ]
113
139
  }
114
140
  },
115
141
  "engines": {
116
- "node": ">=16.0.0"
142
+ "node": ">=18.0.0"
117
143
  },
118
144
  "author": "Ken",
119
145
  "dependencies": {
120
- "@module-federation/rspack": "0.19.1",
121
- "@module-federation/runtime": "0.19.1",
122
- "@module-federation/sdk": "0.19.1",
123
- "core-js": "^3.45.1"
146
+ "@module-federation/rspack": "0.21.1",
147
+ "@module-federation/runtime": "0.21.1",
148
+ "@module-federation/sdk": "0.21.1",
149
+ "core-js": "^3.46.0"
124
150
  },
125
151
  "devDependencies": {
126
- "@swc/core": "^1.10.8",
127
- "@empjs/cli": "3.10.0"
152
+ "@swc/core": "^1.13.5",
153
+ "@empjs/cli": "3.10.3-beta.2"
128
154
  },
129
155
  "scripts": {
130
156
  "dev": "pnpm --filter @empjs/share run /^dev:.*/",
@@ -1,2 +0,0 @@
1
- "use strict";var u=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(e,n)=>{for(var s in n)u(e,s,{get:n[s],enumerable:!0})},h=(e,n,s,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of c(n))!p.call(e,o)&&o!==s&&u(e,o,{get:()=>n[o],enumerable:!(t=a(n,o))||t.enumerable});return e};var f=e=>h(u({},"__esModule",{value:!0}),e);var $={};l($,{Vue2InVue3Adapter:()=>V});module.exports=f($);var r={vue:{defineComponent:null,h:null,ref:null},increaseId:Date.now()},i=window;function m(e,n){return Object.keys(e).map(s=>{let t=e[s];return t.context=n,t})}function v(e,n){let s=i.EMP_ADAPTER_VUE.Vue,t;return{mounted(){let o=this.$slots?m(this.$slots,this.__self):null;t=new s({render:d=>d(e,{on:this.$attrs,attrs:this.$attrs,props:{...this.$props,...this.$attrs},scopedSlots:this.$scopedSlots},o)}),t.$mount(`#${n}`)},props:e.props||{},render(){t&&t.$forceUpdate()}}}var y=e=>{r.vue=e},V=(()=>{y(i.Vue);let{defineComponent:e,h:n,ref:s}=r.vue;return e&&n&&s?e({props:{mfComponent:{type:Function,required:!0}},setup(){let t=s(r.increaseId);return r.increaseId++,{renderId:t}},render(){let{renderId:t}=this;return n("div",[n("div",{id:`vue2-in-vue3${t}`})])},mounted(){(async()=>{let t=await this.mfComponent();v(t.default,`vue2-in-vue3${this.renderId}`).mounted()})()}}):(console.warn("emp3 Vue2InVue3Adapter has not init"),()=>{})})();0&&(module.exports={Vue2InVue3Adapter});
2
- //# sourceMappingURL=adapterVue.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/adapter/vue.ts"],"sourcesContent":["const globalVue3Cache: any = {vue: {defineComponent: null, h: null, ref: null}, increaseId: Date.now()}\nconst win = window as any\nfunction bindSlotContext(target: any, context: any) {\n return Object.keys(target).map(key => {\n const vnode = target[key]\n vnode.context = context\n return vnode\n })\n}\n\nfunction vue2ToVue3(WrapperComponent: any, wrapperId: string): any {\n const Vue2 = win.EMP_ADAPTER_VUE.Vue\n let vm: any\n return {\n mounted() {\n const slots = this.$slots ? bindSlotContext(this.$slots, this.__self) : null\n vm = new Vue2({\n render: (createElement: any) => {\n return createElement(\n WrapperComponent,\n {\n on: this.$attrs,\n attrs: this.$attrs,\n props: {...this.$props, ...this.$attrs}, // 合并 props 和 attrs\n scopedSlots: this.$scopedSlots,\n },\n slots,\n )\n },\n })\n vm.$mount(`#${wrapperId}`)\n },\n // 继承原组件的所有 props 定义\n props: WrapperComponent.props || {},\n render() {\n vm && vm.$forceUpdate()\n },\n }\n}\n\nconst initVue2InVue3Adapter = (vue: any) => {\n globalVue3Cache.vue = vue\n}\n// 创建组件\nexport const Vue2InVue3Adapter = (() => {\n initVue2InVue3Adapter(win.Vue)\n const {defineComponent, h, ref} = globalVue3Cache.vue\n if (!(defineComponent && h && ref)) {\n console.warn('emp3 Vue2InVue3Adapter has not init')\n return () => {}\n }\n return defineComponent({\n // 声明props\n props: {\n mfComponent: {\n type: Function,\n required: true,\n },\n },\n setup() {\n const renderId = ref(globalVue3Cache.increaseId)\n globalVue3Cache.increaseId++\n return {\n renderId,\n }\n },\n render() {\n const {renderId} = this\n return h('div', [h('div', {id: `vue2-in-vue3${renderId}`})])\n },\n mounted() {\n ;(async () => {\n const fc = await this.mfComponent()\n vue2ToVue3(fc.default, `vue2-in-vue3${this.renderId}`).mounted()\n })()\n },\n })\n})()\n\n// const Vue3InVue2Adapter = () => {\n// console.log('not implement')\n// }\n\n// export default {Vue2InVue3Adapter, Vue3InVue2Adapter}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAMI,EAAuB,CAAC,IAAK,CA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,eAAeE,CAAQ,EAAE,CAAC,CAAC,CAAC,CAC7D,EACA,SAAU,EACN,SAAY,CACZ,IAAMC,EAAK,MAAM,KAAK,YAAY,EAClCb,EAAWa,EAAG,QAAS,eAAe,KAAK,QAAQ,EAAE,EAAE,QAAQ,CACjE,GAAG,CACL,CACF,CAAC,GA5BC,QAAQ,KAAK,qCAAqC,EAC3C,IAAM,CAAC,EA4BlB,GAAG","names":["vue_exports","__export","Vue2InVue3Adapter","__toCommonJS","globalVue3Cache","win","bindSlotContext","target","context","key","vnode","vue2ToVue3","WrapperComponent","wrapperId","Vue2","vm","slots","createElement","initVue2InVue3Adapter","vue","defineComponent","h","ref","renderId","fc"]}
@@ -1,3 +0,0 @@
1
- declare const Vue2InVue3Adapter: any;
2
-
3
- export { Vue2InVue3Adapter };
@@ -1,3 +0,0 @@
1
- declare const Vue2InVue3Adapter: any;
2
-
3
- export { Vue2InVue3Adapter };
@@ -1,2 +0,0 @@
1
- var o={vue:{defineComponent:null,h:null,ref:null},increaseId:Date.now()},r=window;function d(n,t){return Object.keys(n).map(s=>{let e=n[s];return e.context=t,e})}function a(n,t){let s=r.EMP_ADAPTER_VUE.Vue,e;return{mounted(){let u=this.$slots?d(this.$slots,this.__self):null;e=new s({render:i=>i(n,{on:this.$attrs,attrs:this.$attrs,props:{...this.$props,...this.$attrs},scopedSlots:this.$scopedSlots},u)}),e.$mount(`#${t}`)},props:n.props||{},render(){e&&e.$forceUpdate()}}}var c=n=>{o.vue=n},p=(()=>{c(r.Vue);let{defineComponent:n,h:t,ref:s}=o.vue;return n&&t&&s?n({props:{mfComponent:{type:Function,required:!0}},setup(){let e=s(o.increaseId);return o.increaseId++,{renderId:e}},render(){let{renderId:e}=this;return t("div",[t("div",{id:`vue2-in-vue3${e}`})])},mounted(){(async()=>{let e=await this.mfComponent();a(e.default,`vue2-in-vue3${this.renderId}`).mounted()})()}}):(console.warn("emp3 Vue2InVue3Adapter has not init"),()=>{})})();export{p as Vue2InVue3Adapter};
2
- //# sourceMappingURL=adapterVue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/adapter/vue.ts"],"sourcesContent":["const globalVue3Cache: any = {vue: {defineComponent: null, h: null, ref: null}, increaseId: Date.now()}\nconst win = window as any\nfunction bindSlotContext(target: any, context: any) {\n return Object.keys(target).map(key => {\n const vnode = target[key]\n vnode.context = context\n return vnode\n })\n}\n\nfunction vue2ToVue3(WrapperComponent: any, wrapperId: string): any {\n const Vue2 = win.EMP_ADAPTER_VUE.Vue\n let vm: any\n return {\n mounted() {\n const slots = this.$slots ? bindSlotContext(this.$slots, this.__self) : null\n vm = new Vue2({\n render: (createElement: any) => {\n return createElement(\n WrapperComponent,\n {\n on: this.$attrs,\n attrs: this.$attrs,\n props: {...this.$props, ...this.$attrs}, // 合并 props 和 attrs\n scopedSlots: this.$scopedSlots,\n },\n slots,\n )\n },\n })\n vm.$mount(`#${wrapperId}`)\n },\n // 继承原组件的所有 props 定义\n props: WrapperComponent.props || {},\n render() {\n vm && vm.$forceUpdate()\n },\n }\n}\n\nconst initVue2InVue3Adapter = (vue: any) => {\n globalVue3Cache.vue = vue\n}\n// 创建组件\nexport const Vue2InVue3Adapter = (() => {\n initVue2InVue3Adapter(win.Vue)\n const {defineComponent, h, ref} = globalVue3Cache.vue\n if (!(defineComponent && h && ref)) {\n console.warn('emp3 Vue2InVue3Adapter has not init')\n return () => {}\n }\n return defineComponent({\n // 声明props\n props: {\n mfComponent: {\n type: Function,\n required: true,\n },\n },\n setup() {\n const renderId = ref(globalVue3Cache.increaseId)\n globalVue3Cache.increaseId++\n return {\n renderId,\n }\n },\n render() {\n const {renderId} = this\n return h('div', [h('div', {id: `vue2-in-vue3${renderId}`})])\n },\n mounted() {\n ;(async () => {\n const fc = await this.mfComponent()\n vue2ToVue3(fc.default, `vue2-in-vue3${this.renderId}`).mounted()\n })()\n },\n })\n})()\n\n// const Vue3InVue2Adapter = () => {\n// console.log('not implement')\n// }\n\n// export default {Vue2InVue3Adapter,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AAI,KACnB,OAAOF,EAAE,MAAO,CAACA,EAAE,MAAO,CAAC,GAAI,eAAeE,CAAQ,EAAE,CAAC,CAAC,CAAC,CAC7D,EACA,SAAU,EACN,SAAY,CACZ,IAAMC,EAAK,MAAM,KAAK,YAAY,EAClCd,EAAWc,EAAG,QAAS,eAAe,KAAK,QAAQ,EAAE,EAAE,QAAQ,CACjE,GAAG,CACL,CACF,CAAC,GA5BC,QAAQ,KAAK,qCAAqC,EAC3C,IAAM,CAAC,EA4BlB,GAAG","names":["globalVue3Cache","win","bindSlotContext","target","context","key","vnode","vue2ToVue3","WrapperComponent","wrapperId","Vue2","vm","slots","createElement","initVue2InVue3Adapter","vue","Vue2InVue3Adapter","defineComponent","h","ref","renderId","fc"]}