-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from sduduzog/introduce_build_step
- Loading branch information
Showing
12 changed files
with
143 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,5 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
dist |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig", | ||
"compilerOptions": { | ||
"module": "commonjs" , | ||
"outDir": "../dist/cjs" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig", | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"outDir": "../dist/esm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../tsconfig", | ||
"compilerOptions": { | ||
"declaration": true , | ||
"emitDeclarationOnly": true, | ||
"outDir": "../dist/types" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** @ts-ignore , vue-demi seems to be not strongly typed so typescript freaks out. */ | ||
import { isVue3, inject, App, Vue2, Plugin, PluginObject } from 'vue-demi'; | ||
import { | ||
createClient, | ||
SupabaseClient, | ||
SupabaseClientOptions, | ||
SupabaseRealtimePayload, | ||
AuthUser, | ||
AuthSession, | ||
} from '@supabase/supabase-js'; | ||
|
||
const supabaseSymbol = Symbol('supabase'); | ||
|
||
/** | ||
* Used to get the injected instance of SupabaseClient. | ||
* If using Vuejs 2.x, this function will be undefined, please use | ||
* `this.$supabase` instead. | ||
* @returns SupabaseClient | ||
*/ | ||
export function useSupabase(): SupabaseClient { | ||
return inject(supabaseSymbol); | ||
} | ||
|
||
type Options = { | ||
supabaseUrl: string; | ||
supabaseKey: string; | ||
supabaseOptions: SupabaseClientOptions; | ||
} | ||
|
||
function install(app: typeof Vue2 | App, options: Options) { | ||
const supabase = createClient(options.supabaseUrl, options.supabaseKey, options.supabaseOptions) | ||
|
||
if (isVue3){ | ||
app.config.globalProperties.$supabase = supabase; | ||
app.provide(supabaseSymbol, supabase); | ||
} else { | ||
Object.defineProperties(app.prototype, { | ||
$supabase: { | ||
get: function() { | ||
return supabase; | ||
}, | ||
}, | ||
}); | ||
app.supabase = supabase; | ||
} | ||
} | ||
|
||
export { | ||
SupabaseClient, | ||
SupabaseClientOptions, | ||
SupabaseRealtimePayload, | ||
AuthUser, | ||
AuthSession, | ||
} | ||
|
||
const VueSupabase: PluginObject<Options> | Plugin = { | ||
install | ||
} | ||
|
||
export default VueSupabase; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"strictNullChecks": true, | ||
"module": "commonjs", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"rootDir": "src", | ||
"sourceMap": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters