@ui-adapter/adapter 1.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.
@@ -0,0 +1,41 @@
1
+ import { Component } from 'vue';
2
+
3
+ type UILibrary = 'ant-design-vue' | 'element-plus' | string;
4
+ interface ComponentMapping {
5
+ [key: string]: Component | undefined | any;
6
+ }
7
+ interface ComponentPropMap {
8
+ [componentName: string]: Record<string, string>;
9
+ }
10
+ interface ComponentMethodMap {
11
+ [componentName: string]: Record<string, string>;
12
+ }
13
+ interface ComponentEventMap {
14
+ [componentName: string]: Record<string, string>;
15
+ }
16
+ interface AdapterOptions {
17
+ components?: Partial<ComponentMapping>;
18
+ propMap?: ComponentPropMap;
19
+ methodMap?: ComponentMethodMap;
20
+ eventMap?: ComponentEventMap;
21
+ [key: string]: any;
22
+ }
23
+ interface UIAdapter {
24
+ name: UILibrary;
25
+ options: AdapterOptions;
26
+ components: ComponentMapping;
27
+ getComponent: (name: string) => Component | undefined;
28
+ registerComponent: (name: string, component: Component) => void;
29
+ registerComponents: (components: Partial<ComponentMapping>) => void;
30
+ getFinalProps: (component: string | Component, props: Record<string, any>) => Record<string, any>;
31
+ getFinalPropName: (component: string | Component, propName: string) => string;
32
+ getFinalEventName: (component: string | Component, eventName: string) => string;
33
+ getFinalMethodName: (component: string | Component, methodName: string) => string;
34
+ }
35
+ declare function setAdapter(name: UILibrary, options?: AdapterOptions): void;
36
+ declare function getUILibrary(): UILibrary | null;
37
+ declare function getAdapter(): UIAdapter;
38
+ declare function hasAdapter(): boolean;
39
+ export type { UILibrary, AdapterOptions, UIAdapter };
40
+ export { setAdapter, getUILibrary, getAdapter, hasAdapter };
41
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/core/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAGr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C,CAAC;IAQlG,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;IAQ9E,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAQhF,kBAAkB,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACnF;AAWD,iBAAS,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAE,cAAmB,GAAG,IAAI,CAGvE;AAMD,iBAAS,YAAY,IAAI,SAAS,GAAG,IAAI,CAExC;AAMD,iBAAS,UAAU,IAAI,SAAS,CAK/B;AAMD,iBAAS,UAAU,IAAI,OAAO,CAE7B;AA4ED,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './core/adapter';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let t=null,n=null;function e(e,o={}){t=e,n=new i(e,o)}function o(){return t}function r(){if(!n)throw new Error("Adapter not set. Please call setAdapter() first.");return n}function s(){return null!==n}class i{constructor(t,n={}){this.components={},this.name=t,this.options=n,n.components&&(this.components={...n.components})}getComponent(t){if(this.components[t])return this.components[t]}registerComponent(t,n){this.components[t]=n}registerComponents(t){this.components={...this.components,...t}}getFinalProps(t,n){var e;const o="string"==typeof t?t:t.name||"default",r=null==(e=this.options.propMap)?void 0:e[o];if(!r)return n;const s={};for(const[i,p]of Object.entries(n)){s[r[i]||i]=p}return s}getFinalPropName(t,n){var e,o;const r="string"==typeof t?t:t.name||"default";return(null==(o=null==(e=this.options.propMap)?void 0:e[r])?void 0:o[n])||n}getFinalEventName(t,n){var e,o;const r="string"==typeof t?t:t.name||"default";return(null==(o=null==(e=this.options.eventMap)?void 0:e[r])?void 0:o[n])||n}getFinalMethodName(t,n){var e,o;const r="string"==typeof t?t:t.name||"default";return(null==(o=null==(e=this.options.methodMap)?void 0:e[r])?void 0:o[n])||n}}exports.getAdapter=r,exports.getUILibrary=o,exports.hasAdapter=s,exports.setAdapter=e;
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ let t=null,n=null;function o(o,e={}){t=o,n=new i(o,e)}function e(){return t}function s(){if(!n)throw new Error("Adapter not set. Please call setAdapter() first.");return n}function r(){return null!==n}class i{constructor(t,n={}){this.components={},this.name=t,this.options=n,n.components&&(this.components={...n.components})}getComponent(t){if(this.components[t])return this.components[t]}registerComponent(t,n){this.components[t]=n}registerComponents(t){this.components={...this.components,...t}}getFinalProps(t,n){var o;const e="string"==typeof t?t:t.name||"default",s=null==(o=this.options.propMap)?void 0:o[e];if(!s)return n;const r={};for(const[i,p]of Object.entries(n)){r[s[i]||i]=p}return r}getFinalPropName(t,n){var o,e;const s="string"==typeof t?t:t.name||"default";return(null==(e=null==(o=this.options.propMap)?void 0:o[s])?void 0:e[n])||n}getFinalEventName(t,n){var o,e;const s="string"==typeof t?t:t.name||"default";return(null==(e=null==(o=this.options.eventMap)?void 0:o[s])?void 0:e[n])||n}getFinalMethodName(t,n){var o,e;const s="string"==typeof t?t:t.name||"default";return(null==(e=null==(o=this.options.methodMap)?void 0:o[s])?void 0:e[n])||n}}export{s as getAdapter,e as getUILibrary,r as hasAdapter,o as setAdapter};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@ui-adapter/adapter",
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "dev": "vite build --mode development --watch",
20
+ "build": "vite build",
21
+ "typecheck": "tsc --noEmit && tsc --noEmit --project tsconfig.node.json",
22
+ "lint": "eslint src --ext .ts",
23
+ "clean": "rimraf dist",
24
+ "prepublishOnly": "npm run typecheck && npm run build",
25
+ "version:patch": "npm version patch",
26
+ "version:minor": "npm version minor",
27
+ "version:major": "npm version major",
28
+ "publish": "tsx scripts/publish.ts",
29
+ "publish:dry": "tsx scripts/publish.ts --dry-run"
30
+ },
31
+ "peerDependencies": {
32
+ "vue": "^3.3.0"
33
+ },
34
+ "devDependencies": {
35
+ "terser": "^5.46.1",
36
+ "typescript": "^5.3.3",
37
+ "vite": "^5.0.0",
38
+ "vite-plugin-dts": "^3.7.0",
39
+ "rimraf": "^5.0.5",
40
+ "tsx": "^4.6.0"
41
+ }
42
+ }