import { CloudbaseAdapter } from '@cloudbase/adapter-interface' ; import * as Web from './platforms/web' ; import { isArray } from '../lib/util' ; export enum RUNTIME { WEB = 'web' , WX_MP = 'wx_mp' } export function useAdapters ( adapters ) { const adapterList = isArray ( adapters ) ? adapters as CloudbaseAdapter [ ] : [ adapters as CloudbaseAdapter ] ; for ( const adapter of adapterList ) { const { isMatch , genAdapter , runtime } = adapter ; if ( isMatch ( ) ) { return { adapter : genAdapter ( ) , runtime } ; } } } export function useDefaultAdapter ( ) { return { adapter : Web . genAdapter ( ) , runtime : RUNTIME . WEB } ; } export const Adapter = { adapter : null , runtime : undefined } ;