]> git.r.bdr.sh - rbdr/canvas/commitdiff
Connect sensor to database
authorRuben Beltran del Rio <redacted>
Wed, 6 Jul 2022 20:49:06 +0000 (22:49 +0200)
committerRuben Beltran del Rio <redacted>
Wed, 6 Jul 2022 20:49:06 +0000 (22:49 +0200)
env.dist [new file with mode: 0644]
package-lock.json
package.json
src/lib/components/sensor.svelte
src/lib/config.js
src/lib/stores/widgets.js [new file with mode: 0644]
src/routes/index.svelte

diff --git a/env.dist b/env.dist
new file mode 100644 (file)
index 0000000..0b9ddb1
--- /dev/null
+++ b/env.dist
@@ -0,0 +1,2 @@
+VITE_SUPABASE_URL=
+VITE_SUPABASE_KEY=
index fdbb8cc0a1f2907eedd106caecb5c68fea2ef68a..5494add602a1c2f2b3cc417e736e81181a48e5a8 100644 (file)
@@ -8,6 +8,7 @@
                        "name": "canvas",
                        "version": "0.0.1",
                        "devDependencies": {
+                               "@supabase/supabase-js": "^1.35.4",
                                "@sveltejs/adapter-auto": "next",
                                "@sveltejs/kit": "next",
                                "eslint": "^8.16.0",
                                "node": ">= 8.0.0"
                        }
                },
+               "node_modules/@supabase/functions-js": {
+                       "version": "1.3.4",
+                       "resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-1.3.4.tgz",
+                       "integrity": "sha512-yYVgkECjv7IZEBKBI3EB5Q7R1p0FJ10g8Q9N7SWKIHUU6i6DnbEGHIMFLyQRm1hmiNWD8fL7bRVEYacmTRJhHw==",
+                       "dev": true,
+                       "dependencies": {
+                               "cross-fetch": "^3.1.5"
+                       }
+               },
+               "node_modules/@supabase/gotrue-js": {
+                       "version": "1.22.19",
+                       "resolved": "https://registry.npmjs.org/@supabase/gotrue-js/-/gotrue-js-1.22.19.tgz",
+                       "integrity": "sha512-IBkbV852iyd8AzeeJa8AgE5rGrOS54MR+N6bagQQWmDC1MdGbpRovK8uuFIkmtoRQpNvbnsl5HRSfskgqmsS+A==",
+                       "dev": true,
+                       "dependencies": {
+                               "cross-fetch": "^3.0.6"
+                       }
+               },
+               "node_modules/@supabase/postgrest-js": {
+                       "version": "0.37.4",
+                       "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-0.37.4.tgz",
+                       "integrity": "sha512-x+c2rk1fz9s6f1PrGxCJ0QTUgXPDI0G3ngIqD5sSiXhhCyfl8Q5V92mXl2EYtlDhkiUkjFNrOZFhXVbXOHgvDw==",
+                       "dev": true,
+                       "dependencies": {
+                               "cross-fetch": "^3.1.5"
+                       }
+               },
+               "node_modules/@supabase/realtime-js": {
+                       "version": "1.7.2",
+                       "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-1.7.2.tgz",
+                       "integrity": "sha512-DMUaFIKj7KszGtWTTQbhMmUzZf7UnwYqySsmY+G8HgYxvY3ZaVa+DZD0I6ofgr4OLNr0po/ODM2a4lf5m5GNBg==",
+                       "dev": true,
+                       "dependencies": {
+                               "@types/phoenix": "^1.5.4",
+                               "websocket": "^1.0.34"
+                       }
+               },
+               "node_modules/@supabase/storage-js": {
+                       "version": "1.7.2",
+                       "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-1.7.2.tgz",
+                       "integrity": "sha512-HX4HAfLUJznVgAwiKVgdTe5QD0bpUcqgc0hpk/s5Uy8qoe1tHZAc5qE9kI+tqk7rQKyymFpiA7+bAHlzyZXxxQ==",
+                       "dev": true,
+                       "dependencies": {
+                               "cross-fetch": "^3.1.0"
+                       }
+               },
+               "node_modules/@supabase/supabase-js": {
+                       "version": "1.35.4",
+                       "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-1.35.4.tgz",
+                       "integrity": "sha512-9krwmuG3hdoS7SfM1UmCIw88aW9V1WW2Zx91tofdnmQraWKfk5e2fIKfp+Wjb9owq7JIkuUIA/qziVs2qX0lLQ==",
+                       "dev": true,
+                       "dependencies": {
+                               "@supabase/functions-js": "^1.3.4",
+                               "@supabase/gotrue-js": "^1.22.17",
+                               "@supabase/postgrest-js": "^0.37.4",
+                               "@supabase/realtime-js": "^1.7.2",
+                               "@supabase/storage-js": "^1.7.2"
+                       }
+               },
                "node_modules/@sveltejs/adapter-auto": {
                        "version": "1.0.0-next.52",
                        "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-1.0.0-next.52.tgz",
                        "integrity": "sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==",
                        "dev": true
                },
+               "node_modules/@types/phoenix": {
+                       "version": "1.5.4",
+                       "resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.5.4.tgz",
+                       "integrity": "sha512-L5eZmzw89eXBKkiqVBcJfU1QGx9y+wurRIEgt0cuLH0hwNtVUxtx+6cu0R2STwWj468sjXyBYPYDtGclUd1kjQ==",
+                       "dev": true
+               },
                "node_modules/@types/pug": {
                        "version": "2.0.6",
                        "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.6.tgz",
                                "node": "*"
                        }
                },
+               "node_modules/bufferutil": {
+                       "version": "4.0.6",
+                       "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.6.tgz",
+                       "integrity": "sha512-jduaYOYtnio4aIAyc6UbvPCVcgq7nYpVnucyxr6eCYg/Woad9Hf/oxxBRDnGGjPfjUm6j5O/uBWhIu4iLebFaw==",
+                       "dev": true,
+                       "hasInstallScript": true,
+                       "dependencies": {
+                               "node-gyp-build": "^4.3.0"
+                       },
+                       "engines": {
+                               "node": ">=6.14.2"
+                       }
+               },
                "node_modules/callsites": {
                        "version": "3.1.0",
                        "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
                        "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
                        "dev": true
                },
+               "node_modules/cross-fetch": {
+                       "version": "3.1.5",
+                       "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
+                       "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
+                       "dev": true,
+                       "dependencies": {
+                               "node-fetch": "2.6.7"
+                       }
+               },
                "node_modules/cross-spawn": {
                        "version": "7.0.3",
                        "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
                                "node": ">= 8"
                        }
                },
+               "node_modules/d": {
+                       "version": "1.0.1",
+                       "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
+                       "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
+                       "dev": true,
+                       "dependencies": {
+                               "es5-ext": "^0.10.50",
+                               "type": "^1.0.1"
+                       }
+               },
                "node_modules/debug": {
                        "version": "4.3.4",
                        "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
                        "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
                        "dev": true
                },
+               "node_modules/es5-ext": {
+                       "version": "0.10.61",
+                       "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.61.tgz",
+                       "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==",
+                       "dev": true,
+                       "hasInstallScript": true,
+                       "dependencies": {
+                               "es6-iterator": "^2.0.3",
+                               "es6-symbol": "^3.1.3",
+                               "next-tick": "^1.1.0"
+                       },
+                       "engines": {
+                               "node": ">=0.10"
+                       }
+               },
+               "node_modules/es6-iterator": {
+                       "version": "2.0.3",
+                       "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+                       "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
+                       "dev": true,
+                       "dependencies": {
+                               "d": "1",
+                               "es5-ext": "^0.10.35",
+                               "es6-symbol": "^3.1.1"
+                       }
+               },
                "node_modules/es6-promise": {
                        "version": "3.3.1",
                        "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
                        "integrity": "sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==",
                        "dev": true
                },
+               "node_modules/es6-symbol": {
+                       "version": "3.1.3",
+                       "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
+                       "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
+                       "dev": true,
+                       "dependencies": {
+                               "d": "^1.0.1",
+                               "ext": "^1.1.2"
+                       }
+               },
                "node_modules/esbuild": {
                        "version": "0.14.47",
                        "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.47.tgz",
                                "node": ">=0.10.0"
                        }
                },
+               "node_modules/ext": {
+                       "version": "1.6.0",
+                       "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz",
+                       "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==",
+                       "dev": true,
+                       "dependencies": {
+                               "type": "^2.5.0"
+                       }
+               },
+               "node_modules/ext/node_modules/type": {
+                       "version": "2.6.0",
+                       "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz",
+                       "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==",
+                       "dev": true
+               },
                "node_modules/fast-deep-equal": {
                        "version": "3.1.3",
                        "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
                                "node": ">=0.12.0"
                        }
                },
+               "node_modules/is-typedarray": {
+                       "version": "1.0.0",
+                       "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
+                       "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==",
+                       "dev": true
+               },
                "node_modules/isarray": {
                        "version": "1.0.0",
                        "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
                                "ms": "^2.1.1"
                        }
                },
+               "node_modules/next-tick": {
+                       "version": "1.1.0",
+                       "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
+                       "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==",
+                       "dev": true
+               },
                "node_modules/node-fetch": {
                        "version": "2.6.7",
                        "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
                        "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
                        "dev": true
                },
+               "node_modules/type": {
+                       "version": "1.2.0",
+                       "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
+                       "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==",
+                       "dev": true
+               },
                "node_modules/type-check": {
                        "version": "0.4.0",
                        "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
                                "url": "https://github.com/sponsors/sindresorhus"
                        }
                },
+               "node_modules/typedarray-to-buffer": {
+                       "version": "3.1.5",
+                       "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
+                       "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
+                       "dev": true,
+                       "dependencies": {
+                               "is-typedarray": "^1.0.0"
+                       }
+               },
                "node_modules/typescript": {
                        "version": "4.7.4",
                        "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
                                "punycode": "^2.1.0"
                        }
                },
+               "node_modules/utf-8-validate": {
+                       "version": "5.0.9",
+                       "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.9.tgz",
+                       "integrity": "sha512-Yek7dAy0v3Kl0orwMlvi7TPtiCNrdfHNd7Gcc/pLq4BLXqfAmd0J7OWMizUQnTTJsyjKn02mU7anqwfmUP4J8Q==",
+                       "dev": true,
+                       "hasInstallScript": true,
+                       "dependencies": {
+                               "node-gyp-build": "^4.3.0"
+                       },
+                       "engines": {
+                               "node": ">=6.14.2"
+                       }
+               },
                "node_modules/util-deprecate": {
                        "version": "1.0.2",
                        "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
                        "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
                        "dev": true
                },
+               "node_modules/websocket": {
+                       "version": "1.0.34",
+                       "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz",
+                       "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==",
+                       "dev": true,
+                       "dependencies": {
+                               "bufferutil": "^4.0.1",
+                               "debug": "^2.2.0",
+                               "es5-ext": "^0.10.50",
+                               "typedarray-to-buffer": "^3.1.5",
+                               "utf-8-validate": "^5.0.2",
+                               "yaeti": "^0.0.6"
+                       },
+                       "engines": {
+                               "node": ">=4.0.0"
+                       }
+               },
+               "node_modules/websocket/node_modules/debug": {
+                       "version": "2.6.9",
+                       "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+                       "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+                       "dev": true,
+                       "dependencies": {
+                               "ms": "2.0.0"
+                       }
+               },
+               "node_modules/websocket/node_modules/ms": {
+                       "version": "2.0.0",
+                       "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+                       "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+                       "dev": true
+               },
                "node_modules/whatwg-url": {
                        "version": "5.0.0",
                        "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
                        "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
                        "dev": true
                },
+               "node_modules/yaeti": {
+                       "version": "0.0.6",
+                       "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
+                       "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==",
+                       "dev": true,
+                       "engines": {
+                               "node": ">=0.10.32"
+                       }
+               },
                "node_modules/yallist": {
                        "version": "4.0.0",
                        "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
                                "picomatch": "^2.2.2"
                        }
                },
+               "@supabase/functions-js": {
+                       "version": "1.3.4",
+                       "resolved": "https://registry.npmjs.org/@supabase/functions-js/-/functions-js-1.3.4.tgz",
+                       "integrity": "sha512-yYVgkECjv7IZEBKBI3EB5Q7R1p0FJ10g8Q9N7SWKIHUU6i6DnbEGHIMFLyQRm1hmiNWD8fL7bRVEYacmTRJhHw==",
+                       "dev": true,
+                       "requires": {
+                               "cross-fetch": "^3.1.5"
+                       }
+               },
+               "@supabase/gotrue-js": {
+                       "version": "1.22.19",
+                       "resolved": "https://registry.npmjs.org/@supabase/gotrue-js/-/gotrue-js-1.22.19.tgz",
+                       "integrity": "sha512-IBkbV852iyd8AzeeJa8AgE5rGrOS54MR+N6bagQQWmDC1MdGbpRovK8uuFIkmtoRQpNvbnsl5HRSfskgqmsS+A==",
+                       "dev": true,
+                       "requires": {
+                               "cross-fetch": "^3.0.6"
+                       }
+               },
+               "@supabase/postgrest-js": {
+                       "version": "0.37.4",
+                       "resolved": "https://registry.npmjs.org/@supabase/postgrest-js/-/postgrest-js-0.37.4.tgz",
+                       "integrity": "sha512-x+c2rk1fz9s6f1PrGxCJ0QTUgXPDI0G3ngIqD5sSiXhhCyfl8Q5V92mXl2EYtlDhkiUkjFNrOZFhXVbXOHgvDw==",
+                       "dev": true,
+                       "requires": {
+                               "cross-fetch": "^3.1.5"
+                       }
+               },
+               "@supabase/realtime-js": {
+                       "version": "1.7.2",
+                       "resolved": "https://registry.npmjs.org/@supabase/realtime-js/-/realtime-js-1.7.2.tgz",
+                       "integrity": "sha512-DMUaFIKj7KszGtWTTQbhMmUzZf7UnwYqySsmY+G8HgYxvY3ZaVa+DZD0I6ofgr4OLNr0po/ODM2a4lf5m5GNBg==",
+                       "dev": true,
+                       "requires": {
+                               "@types/phoenix": "^1.5.4",
+                               "websocket": "^1.0.34"
+                       }
+               },
+               "@supabase/storage-js": {
+                       "version": "1.7.2",
+                       "resolved": "https://registry.npmjs.org/@supabase/storage-js/-/storage-js-1.7.2.tgz",
+                       "integrity": "sha512-HX4HAfLUJznVgAwiKVgdTe5QD0bpUcqgc0hpk/s5Uy8qoe1tHZAc5qE9kI+tqk7rQKyymFpiA7+bAHlzyZXxxQ==",
+                       "dev": true,
+                       "requires": {
+                               "cross-fetch": "^3.1.0"
+                       }
+               },
+               "@supabase/supabase-js": {
+                       "version": "1.35.4",
+                       "resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-1.35.4.tgz",
+                       "integrity": "sha512-9krwmuG3hdoS7SfM1UmCIw88aW9V1WW2Zx91tofdnmQraWKfk5e2fIKfp+Wjb9owq7JIkuUIA/qziVs2qX0lLQ==",
+                       "dev": true,
+                       "requires": {
+                               "@supabase/functions-js": "^1.3.4",
+                               "@supabase/gotrue-js": "^1.22.17",
+                               "@supabase/postgrest-js": "^0.37.4",
+                               "@supabase/realtime-js": "^1.7.2",
+                               "@supabase/storage-js": "^1.7.2"
+                       }
+               },
                "@sveltejs/adapter-auto": {
                        "version": "1.0.0-next.52",
                        "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-1.0.0-next.52.tgz",
                        "integrity": "sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==",
                        "dev": true
                },
+               "@types/phoenix": {
+                       "version": "1.5.4",
+                       "resolved": "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.5.4.tgz",
+                       "integrity": "sha512-L5eZmzw89eXBKkiqVBcJfU1QGx9y+wurRIEgt0cuLH0hwNtVUxtx+6cu0R2STwWj468sjXyBYPYDtGclUd1kjQ==",
+                       "dev": true
+               },
                "@types/pug": {
                        "version": "2.0.6",
                        "resolved": "https://registry.npmjs.org/@types/pug/-/pug-2.0.6.tgz",
                        "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==",
                        "dev": true
                },
+               "bufferutil": {
+                       "version": "4.0.6",
+                       "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.6.tgz",
+                       "integrity": "sha512-jduaYOYtnio4aIAyc6UbvPCVcgq7nYpVnucyxr6eCYg/Woad9Hf/oxxBRDnGGjPfjUm6j5O/uBWhIu4iLebFaw==",
+                       "dev": true,
+                       "requires": {
+                               "node-gyp-build": "^4.3.0"
+                       }
+               },
                "callsites": {
                        "version": "3.1.0",
                        "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
                        "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
                        "dev": true
                },
+               "cross-fetch": {
+                       "version": "3.1.5",
+                       "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
+                       "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
+                       "dev": true,
+                       "requires": {
+                               "node-fetch": "2.6.7"
+                       }
+               },
                "cross-spawn": {
                        "version": "7.0.3",
                        "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
                                "which": "^2.0.1"
                        }
                },
+               "d": {
+                       "version": "1.0.1",
+                       "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
+                       "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
+                       "dev": true,
+                       "requires": {
+                               "es5-ext": "^0.10.50",
+                               "type": "^1.0.1"
+                       }
+               },
                "debug": {
                        "version": "4.3.4",
                        "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
                        "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
                        "dev": true
                },
+               "es5-ext": {
+                       "version": "0.10.61",
+                       "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.61.tgz",
+                       "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==",
+                       "dev": true,
+                       "requires": {
+                               "es6-iterator": "^2.0.3",
+                               "es6-symbol": "^3.1.3",
+                               "next-tick": "^1.1.0"
+                       }
+               },
+               "es6-iterator": {
+                       "version": "2.0.3",
+                       "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
+                       "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==",
+                       "dev": true,
+                       "requires": {
+                               "d": "1",
+                               "es5-ext": "^0.10.35",
+                               "es6-symbol": "^3.1.1"
+                       }
+               },
                "es6-promise": {
                        "version": "3.3.1",
                        "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz",
                        "integrity": "sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==",
                        "dev": true
                },
+               "es6-symbol": {
+                       "version": "3.1.3",
+                       "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
+                       "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
+                       "dev": true,
+                       "requires": {
+                               "d": "^1.0.1",
+                               "ext": "^1.1.2"
+                       }
+               },
                "esbuild": {
                        "version": "0.14.47",
                        "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.47.tgz",
                        "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
                        "dev": true
                },
+               "ext": {
+                       "version": "1.6.0",
+                       "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz",
+                       "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==",
+                       "dev": true,
+                       "requires": {
+                               "type": "^2.5.0"
+                       },
+                       "dependencies": {
+                               "type": {
+                                       "version": "2.6.0",
+                                       "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz",
+                                       "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==",
+                                       "dev": true
+                               }
+                       }
+               },
                "fast-deep-equal": {
                        "version": "3.1.3",
                        "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
                        "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
                        "dev": true
                },
+               "is-typedarray": {
+                       "version": "1.0.0",
+                       "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
+                       "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==",
+                       "dev": true
+               },
                "isarray": {
                        "version": "1.0.0",
                        "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
                                }
                        }
                },
+               "next-tick": {
+                       "version": "1.1.0",
+                       "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
+                       "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==",
+                       "dev": true
+               },
                "node-fetch": {
                        "version": "2.6.7",
                        "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
                        "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
                        "dev": true
                },
+               "type": {
+                       "version": "1.2.0",
+                       "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
+                       "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==",
+                       "dev": true
+               },
                "type-check": {
                        "version": "0.4.0",
                        "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
                        "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
                        "dev": true
                },
+               "typedarray-to-buffer": {
+                       "version": "3.1.5",
+                       "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
+                       "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
+                       "dev": true,
+                       "requires": {
+                               "is-typedarray": "^1.0.0"
+                       }
+               },
                "typescript": {
                        "version": "4.7.4",
                        "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
                                "punycode": "^2.1.0"
                        }
                },
+               "utf-8-validate": {
+                       "version": "5.0.9",
+                       "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.9.tgz",
+                       "integrity": "sha512-Yek7dAy0v3Kl0orwMlvi7TPtiCNrdfHNd7Gcc/pLq4BLXqfAmd0J7OWMizUQnTTJsyjKn02mU7anqwfmUP4J8Q==",
+                       "dev": true,
+                       "requires": {
+                               "node-gyp-build": "^4.3.0"
+                       }
+               },
                "util-deprecate": {
                        "version": "1.0.2",
                        "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
                        "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
                        "dev": true
                },
+               "websocket": {
+                       "version": "1.0.34",
+                       "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz",
+                       "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==",
+                       "dev": true,
+                       "requires": {
+                               "bufferutil": "^4.0.1",
+                               "debug": "^2.2.0",
+                               "es5-ext": "^0.10.50",
+                               "typedarray-to-buffer": "^3.1.5",
+                               "utf-8-validate": "^5.0.2",
+                               "yaeti": "^0.0.6"
+                       },
+                       "dependencies": {
+                               "debug": {
+                                       "version": "2.6.9",
+                                       "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+                                       "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+                                       "dev": true,
+                                       "requires": {
+                                               "ms": "2.0.0"
+                                       }
+                               },
+                               "ms": {
+                                       "version": "2.0.0",
+                                       "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+                                       "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+                                       "dev": true
+                               }
+                       }
+               },
                "whatwg-url": {
                        "version": "5.0.0",
                        "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
                        "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
                        "dev": true
                },
+               "yaeti": {
+                       "version": "0.0.6",
+                       "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
+                       "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==",
+                       "dev": true
+               },
                "yallist": {
                        "version": "4.0.0",
                        "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
index a551ca26ee6bac4989e41abdeaae8aad3cdd5045..ea6b7a6e12b2e85a20c152a8bbe1e21643c7b77d 100644 (file)
@@ -13,6 +13,7 @@
                "format": "prettier --write --plugin-search-dir=. ."
        },
        "devDependencies": {
+               "@supabase/supabase-js": "^1.35.4",
                "@sveltejs/adapter-auto": "next",
                "@sveltejs/kit": "next",
                "eslint": "^8.16.0",
index da968a3220432c74dc24401af9fa54d48175cd7a..e98b74086b30b208c3f349fc527f7ca6c3a0d736 100644 (file)
@@ -1,6 +1,7 @@
 <script>
   import { browser } from '$app/env';
   import { maxSize } from '$lib/config';
+  import { sensor } from '$lib/stores/widgets';
 
   export let x;
   export let y;
@@ -16,7 +17,7 @@
   const fetchItems = function fetchItems( left, top, right, bottom ) {
     clearTimeout(timer);
                timer = setTimeout(() => {
-      console.log('fetching', left, top, right, bottom);
+      sensor.set({ left, top, right, bottom });
                }, 50);
   }
 
index 3d243ed678c6e166d39ad1201817e0cd30ef32bb..b450d84a41c0b6f683d8ca27ae90efa73f0cad1c 100644 (file)
@@ -1,2 +1,7 @@
 export const coordinateLength = 6;
 export const maxSize = Math.pow(16, coordinateLength);
+
+export const supabase = {
+       url: import.meta.env.VITE_SUPABASE_URL,
+       key: import.meta.env.VITE_SUPABASE_KEY
+};
diff --git a/src/lib/stores/widgets.js b/src/lib/stores/widgets.js
new file mode 100644 (file)
index 0000000..ff5c53e
--- /dev/null
@@ -0,0 +1,31 @@
+import { derived, writable } from 'svelte/store';
+import { createClient } from '@supabase/supabase-js';
+import { supabase } from '$lib/config';
+import { maxSize } from '$lib/config';
+
+const client = createClient(supabase.url, supabase.key);
+
+export const sensor = writable({left: 0, top: 0, right: 0, bottom: 0});
+
+const getBoxes = function getBoxes ({left, top, right, bottom}) {
+  return [
+    `box.ov."(${left},${top},${right},${bottom})"`,
+    `box.ov."(${left+maxSize},${top+maxSize},${right+maxSize},${bottom+maxSize})"`,
+    `box.ov."(${left+maxSize},${top},${right+maxSize},${bottom})"`,
+    `box.ov."(${left},${top+maxSize},${right},${bottom+maxSize})"`
+  ]
+};
+
+let ac = null;
+export const widgets = derived(sensor, async function ($sensor, set) {
+
+  const boxes = getBoxes($sensor);
+  ac && ac.abort()
+  ac = new AbortController();
+  const { data } = await client
+    .from('widgets')
+    .select()
+    .or(boxes.join(','))
+    .abortSignal(ac.signal)
+  return set(data);
+});
index 2943d232e6b90b4f29bb269add540a037e744f23..06c2357590d3157bf668b58e39f777df0632703a 100644 (file)
@@ -4,6 +4,7 @@
   import Palette from '$lib/components/palette.svelte';
   import Hud from '$lib/components/hud.svelte';
   import { modulo } from '$lib/math';
+  import { widgets } from '$lib/stores/widgets';
 
   import { coordinateLength, maxSize } from '$lib/config';
 
@@ -56,7 +57,7 @@
   on:contextmenu={showPalette}
   on:mousedown={startDragging}
   on:mouseup={stopDragging}
-  on:mousemove={moveCanvas}>
+  on:mousemove={moveCanvas}
 >
   <Sensor x={x} y={y} />
   <Background x={x} y={y} />
@@ -65,6 +66,8 @@
   {#if shouldShowPalette }
     <Palette/>
   {/if}
+
+  <p>{JSON.stringify($widgets)}</p>
 </div>
 
 <style>