forked from fdzcxy212206413/gsl_grs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
2.6 KiB
1 line
2.6 KiB
2 months ago
|
{"version":3,"file":"install.mjs","sources":["../../../../../packages/utils/vue/install.ts"],"sourcesContent":["import { NOOP } from '../functions'\n\nimport type { App, Directive } from 'vue'\nimport type { SFCInstallWithContext, SFCWithInstall } from './typescript'\n\nexport const withInstall = <T, E extends Record<string, any>>(\n main: T,\n extra?: E\n) => {\n ;(main as SFCWithInstall<T>).install = (app): void => {\n for (const comp of [main, ...Object.values(extra ?? {})]) {\n app.component(comp.name, comp)\n }\n }\n\n if (extra) {\n for (const [key, comp] of Object.entries(extra)) {\n ;(main as any)[key] = comp\n }\n }\n return main as SFCWithInstall<T> & E\n}\n\nexport const withInstallFunction = <T>(fn: T, name: string) => {\n ;(fn as SFCWithInstall<T>).install = (app: App) => {\n ;(fn as SFCInstallWithContext<T>)._context = app._context\n app.config.globalProperties[name] = fn\n }\n\n return fn as SFCInstallWithContext<T>\n}\n\nexport const withInstallDirective = <T extends Directive>(\n directive: T,\n name: string\n) => {\n ;(directive as SFCWithInstall<T>).install = (app: App): void => {\n app.directive(name, directive)\n }\n\n return directive as SFCWithInstall<T>\n}\n\nexport const withNoopInstall = <T>(component: T) => {\n ;(component as SFCWithInstall<T>).install = NOOP\n\n return component as SFCWithInstall<T>\n}\n"],"names":[],"mappings":";;;AACY,MAAC,WAAW,GAAG,CAAC,IAAI,EAAE,KAAK,KAAK;AAC5C,EAAE,CAAC;AACH,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK;AAC1B,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,EAAE;AAC7E,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC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