Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
25f58f1
:construction: Add build script to publish workflow
sduduzog Aug 5, 2021
195de2c
change echo message
sduduzog Aug 5, 2021
78c8f54
add scripts and required packages
sduduzog Aug 5, 2021
1a284cf
Add typescript configuration
sduduzog Aug 5, 2021
7b0ea45
Create copy of the origional index.js
sduduzog Aug 5, 2021
da83c6e
ignore that vue-demi doesn't expose all types it exports
sduduzog Aug 5, 2021
26fafdf
export types from supabase
sduduzog Aug 5, 2021
f18294d
:art: Cleanup branch. Closes #3
sduduzog Aug 5, 2021
a65745a
Infer types to install function
sduduzog Aug 6, 2021
e5d9d17
use prepare script to build
sduduzog Aug 7, 2021
292cbd4
add keyword
sduduzog Aug 7, 2021
bb9acef
export used functions as part of the default module
sduduzog Aug 7, 2021
2a59e63
removed build step from workflow
sduduzog Aug 7, 2021
b3242c9
prefer parallel build
sduduzog Aug 7, 2021
95849a9
remove rimraf package
sduduzog Aug 7, 2021
daafb94
change how script is prepared
sduduzog Aug 7, 2021
9166bb5
remove types config to minimise list of commands
sduduzog Aug 7, 2021
cf6d8a3
Revert "remove types config to minimise list of commands"
sduduzog Aug 7, 2021
65f7ddd
add prepack script to support yarn
sduduzog Aug 7, 2021
f535dd6
:alembic: Try postinstall for yarn
sduduzog Aug 7, 2021
b6425f1
simplify build script
sduduzog Aug 13, 2021
4131347
add npm ignore to try avoid files being removed
sduduzog Aug 13, 2021
bc07dc8
bug with useSupabase not exposed for esm usage
sduduzog Aug 13, 2021
c82b862
:art: Infer types for plugin install function
sduduzog Aug 14, 2021
2f674f5
:alembic: Change how plugin types are infered
sduduzog Aug 14, 2021
ddd1940
Change comment type to multiline
sduduzog Aug 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: https://registry.npmjs.org/
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ typings/

# next.js build output
.next

dist
Empty file added .npmignore
Empty file.
7 changes: 7 additions & 0 deletions config/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"module": "commonjs" ,
"outDir": "../dist/cjs"
}
}
7 changes: 7 additions & 0 deletions config/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"module": "ESNext",
"outDir": "../dist/esm"
}
}
8 changes: 8 additions & 0 deletions config/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"declaration": true ,
"emitDeclarationOnly": true,
"outDir": "../dist/types"
}
}
16 changes: 0 additions & 16 deletions index.d.ts

This file was deleted.

31 changes: 0 additions & 31 deletions index.js

This file was deleted.

19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
"name": "vue-supabase",
"version": "2.0.0",
"description": "A small wrapper for integrating supabase to Vuejs",
"main": "index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"engine": {
"node": ">= 1"
},
"scripts": {
"test": "npm run test"
"prepare": "npm run build",
"test": "echo 'no tests to run'",
"build": "tsc -p config/tsconfig.cjs.json && tsc -p config/tsconfig.esm.json && tsc -p config/tsconfig.types.json"
},
"repository": {
"type": "git",
Expand All @@ -16,15 +20,11 @@
"keywords": [
"vue",
"custom",
"supabase"
"supabase",
"vue-supabase"
],
"author": "Scott Robertson",
"types": "index.d.ts",
"license": "MIT",
"files": [
"index.js",
"index.d.ts"
],
"bugs": {
"url": "https://github.com/scottrobertson/vue-supabase/issues"
},
Expand All @@ -36,5 +36,8 @@
"peerDependencies": {
"@vue/composition-api": "^1.0.4",
"vue": "^2.0.0 || >=3.0.0"
},
"devDependencies": {
"typescript": "^4.3.5"
}
}
60 changes: 60 additions & 0 deletions src/index.ts
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;
16 changes: 16 additions & 0 deletions tsconfig.json
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"]
}
57 changes: 31 additions & 26 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@supabase/gotrue-js@^1.16.6":
version "1.16.6"
resolved "https://registry.yarnpkg.com/@supabase/gotrue-js/-/gotrue-js-1.16.6.tgz#d9d63740b11ad51d2f8d6c68e9ac16bb83439888"
integrity sha512-tLaG4G4sMW2P1hyq05Nr0jM/6AbdiWkjOPbM+QZsuVSsNbZ/z+BNxuE5q+6zHOnoP+YKEHup7x9xKR0zy2UqUQ==
"@supabase/gotrue-js@^1.17.0":
version "1.17.0"
resolved "https://registry.yarnpkg.com/@supabase/gotrue-js/-/gotrue-js-1.17.0.tgz#0ff46f844ddd124543d2769da8eda58ab479b49b"
integrity sha512-c+GSSoW+PIT3/r7TnBdc4gPjtWDutO/2ROafSKUFl39Pb8aHIUbUvzK9sjuedaaLKH7bV8VefuRy2L8c0BUAzg==
dependencies:
cross-fetch "^3.0.6"

Expand All @@ -16,40 +16,40 @@
dependencies:
cross-fetch "^3.0.6"

"@supabase/realtime-js@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@supabase/realtime-js/-/realtime-js-1.0.11.tgz#2b3a0b7822bcb8b2cf6201ec3c34220be23f40de"
integrity sha512-jE8/8I64VpEygEbrd9+RBZBIREo43Vacy8exef1QlyRegblG2VtqqK96BiQSaVG5ZwXumOs6Igl8kgyrDqUAPg==
"@supabase/realtime-js@^1.1.1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@supabase/realtime-js/-/realtime-js-1.1.2.tgz#6bdb0411df292c9d6a2d1a5a4e11c2673aec5f76"
integrity sha512-YNFiWF0T9+IuZZgswzHbGb7/O1eWJSwXvi0WlbARHTIcYBu4GQQXBdVWdFdG4bTLMS3L4K2qHpvMP91QYSasMw==
dependencies:
"@types/websocket" "^1.0.1"
"@types/websocket" "^1.0.3"
websocket "^1.0.34"

"@supabase/storage-js@^1.2.2":
version "1.2.2"
resolved "https://registry.yarnpkg.com/@supabase/storage-js/-/storage-js-1.2.2.tgz#6eeef2d1365af2497b35ae6c6384f5dfbd75f5b6"
integrity sha512-EJ2BsfD7Mc+fXJqRef3YiWF8kg/GhBdxIil7EzmrAFBSJ3VCbN4sqzvCCUYK2dtNICUV3JOKh5SBX2RrgROIOA==
"@supabase/storage-js@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@supabase/storage-js/-/storage-js-1.4.0.tgz#0692782ccaf10df27d539d9349031ed87c7ec426"
integrity sha512-7+SGyXOgdhtz8qHzXo64HiS66PT/y4F8YFNMtXqYOu1LjHh0YwtOgpPLDA8obiSsNVwZiKwpgBJkz4LHG1YvRQ==
dependencies:
cross-fetch "^3.1.0"

"@supabase/supabase-js@^1.4.2":
version "1.18.1"
resolved "https://registry.yarnpkg.com/@supabase/supabase-js/-/supabase-js-1.18.1.tgz#58fa3dfff3a1f86c169c83330282120195f6c5f1"
integrity sha512-YZhp867/HV9Az8icouAJ7S2j1SV4ZlshvQ1wTR0aV+Em+TTj9ZiS6GVykCjKn2SE2cUfG/wgmaXm9tiKecUhFg==
version "1.21.0"
resolved "https://registry.yarnpkg.com/@supabase/supabase-js/-/supabase-js-1.21.0.tgz#7fe3575a41644048ecbe2ed6eba89e830959d47b"
integrity sha512-SJgRQCdHRpnnuXVCb7X8XA/u2S4oo1Jdn92eLBl0QaUKGhREFHk2x4XlJZA9bJNzAhby9eQZ56FCtBrUda2CRQ==
dependencies:
"@supabase/gotrue-js" "^1.16.6"
"@supabase/gotrue-js" "^1.17.0"
"@supabase/postgrest-js" "^0.33.0"
"@supabase/realtime-js" "^1.0.11"
"@supabase/storage-js" "^1.2.2"
"@supabase/realtime-js" "^1.1.1"
"@supabase/storage-js" "^1.4.0"

"@types/node@*":
version "16.3.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.2.tgz#655432817f83b51ac869c2d51dd8305fb8342e16"
integrity sha512-jJs9ErFLP403I+hMLGnqDRWT0RYKSvArxuBVh2veudHV7ifEC1WAmjJADacZ7mRbA2nWgHtn8xyECMAot0SkAw==
version "16.4.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.13.tgz#7dfd9c14661edc65cccd43a29eb454174642370d"
integrity sha512-bLL69sKtd25w7p1nvg9pigE4gtKVpGTPojBFLMkGHXuUgap2sLqQt2qUnqmVCDfzGUL0DRNZP+1prIZJbMeAXg==

"@types/websocket@^1.0.1":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@types/websocket/-/websocket-1.0.3.tgz#49e09f939afd0ccdee4f7108d4712ec9feb0f153"
integrity sha512-ZdoTSwmDsKR7l1I8fpfQtmTI/hUwlOvE3q0iyJsp4tXU0MkdrYowimDzwxjhQvxU4qjhHLd3a6ig0OXRbLgIdw==
"@types/websocket@^1.0.3":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/websocket/-/websocket-1.0.4.tgz#1dc497280d8049a5450854dd698ee7e6ea9e60b8"
integrity sha512-qn1LkcFEKK8RPp459jkjzsfpbsx36BBt3oC3pITYtkoBw/aVX+EZFa5j3ThCRTNpLFvIMr5dSTD4RaMdilIOpA==
dependencies:
"@types/node" "*"

Expand Down Expand Up @@ -157,6 +157,11 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^4.3.5:
version "4.3.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==

utf-8-validate@^5.0.2:
version "5.0.5"
resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.5.tgz#dd32c2e82c72002dc9f02eb67ba6761f43456ca1"
Expand Down