-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move package files to public repo, update lockfiles
- Loading branch information
Showing
79 changed files
with
14,976 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
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,37 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
|
||
- name: Setup .yarnrc.yml | ||
run: | | ||
yarn config set npmAuthToken $NPM_TOKEN | ||
yarn config set npmAlwaysAuth true | ||
env: | ||
NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} | ||
|
||
- name: Install | ||
run: yarn install --immutable | ||
|
||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
version: yarn run version | ||
publish: yarn run release:packages | ||
env: | ||
NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }} |
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,24 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
branches: ['main'] | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: 'yarn' | ||
|
||
- run: yarn install --immutable | ||
- run: cd packages/db && yarn test | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }} |
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 |
---|---|---|
@@ -1 +1,12 @@ | ||
node_modules | ||
# dependencies | ||
node_modules | ||
|
||
# Yarn 3 files | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
Binary file not shown.
183 changes: 183 additions & 0 deletions
183
.yarn/patches/tuple-database-npm-2.1.19-fc22a10d75.patch
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,183 @@ | ||
diff --git a/database/sync/TupleDatabaseClient.js b/database/sync/TupleDatabaseClient.js | ||
index 2618ff8e5b785e8599495e82afa5c903a3d54db5..fe337b679157e67f348e39b88a34ab9237a86704 100644 | ||
--- a/database/sync/TupleDatabaseClient.js | ||
+++ b/database/sync/TupleDatabaseClient.js | ||
@@ -41,7 +41,7 @@ class TupleDatabaseClient { | ||
scan(args = {}, txId) { | ||
const storageScanArgs = (0, subspaceHelpers_1.normalizeSubspaceScanArgs)(this.subspacePrefix, args); | ||
const pairs = this.db.scan(storageScanArgs, txId); | ||
- const result = (0, subspaceHelpers_1.removePrefixFromTupleValuePairs)(this.subspacePrefix, pairs); | ||
+ const result = this.subspacePrefix.length ? (0, subspaceHelpers_1.removePrefixFromTupleValuePairs)(this.subspacePrefix, pairs) : pairs; | ||
return result; | ||
} | ||
subscribe(args, callback) { | ||
diff --git a/helpers/sortedList.js b/helpers/sortedList.js | ||
index 157addcddfa75dbbaeb7866ee7383945890d54f7..1b0bc90cb8a9f30ed0459d3359ca54eeac402424 100644 | ||
--- a/helpers/sortedList.js | ||
+++ b/helpers/sortedList.js | ||
@@ -41,89 +41,104 @@ function scan(list, args, cmp) { | ||
throw new Error("Invalid bounds."); | ||
} | ||
// Start at lower bound. | ||
- let i; | ||
- if (args.reverse) { | ||
+ // let i; | ||
+ let li; | ||
+ let ui | ||
+ // let indexSearch = performance.now(); | ||
+ | ||
+ // if (args.reverse) { | ||
if (end === undefined) { | ||
- i = list.length - 1; | ||
+ ui = list.length - 1; | ||
} | ||
else { | ||
const result = (0, binarySearch_1.binarySearch)(list, end, cmp); | ||
if (result.found === undefined) { | ||
- i = result.closest - 1; // i could be -1! | ||
+ ui = result.closest - 1; // i could be -1! | ||
} | ||
else { | ||
if (args.lt) | ||
- i = result.found - 1; | ||
+ ui = result.found - 1; | ||
else | ||
- i = result.found; | ||
+ ui = result.found; | ||
} | ||
} | ||
- } | ||
- else { | ||
+ // } | ||
+ // else { | ||
if (start === undefined) { | ||
- i = 0; | ||
+ li = 0; | ||
} | ||
else { | ||
const result = (0, binarySearch_1.binarySearch)(list, start, cmp); | ||
if (result.found === undefined) { | ||
- i = result.closest; | ||
+ li = result.closest; | ||
} | ||
else { | ||
if (args.gt) | ||
- i = result.found + 1; | ||
+ li = result.found + 1; | ||
else | ||
- i = result.found; | ||
+ li = result.found; | ||
} | ||
} | ||
- } | ||
- const results = []; | ||
- while (true) { | ||
- // End of array. | ||
- if (i >= list.length || i < 0) { | ||
- break; | ||
- } | ||
- if (args.limit && results.length >= args.limit) { | ||
- // Limit condition. | ||
- break; | ||
- } | ||
- if (args.reverse) { | ||
- // Lower bound condition. | ||
- const item = list[i]; | ||
- if (args.gt) { | ||
- const dir = cmp(args.gt, item); | ||
- if (dir >= 0) { | ||
- break; | ||
- } | ||
- } | ||
- if (args.gte) { | ||
- const dir = cmp(args.gte, item); | ||
- if (dir > 0) { | ||
- break; | ||
- } | ||
- } | ||
- results.push(item); | ||
- i -= 1; | ||
- } | ||
- else { | ||
- // Upper bound condition. | ||
- const item = list[i]; | ||
- if (args.lt) { | ||
- const dir = cmp(item, args.lt); | ||
- if (dir >= 0) { | ||
- break; | ||
- } | ||
- } | ||
- if (args.lte) { | ||
- const dir = cmp(item, args.lte); | ||
- if (dir > 0) { | ||
- break; | ||
- } | ||
- } | ||
- results.push(item); | ||
- i += 1; | ||
- } | ||
- } | ||
- return results; | ||
+ // } | ||
+ // console.log(`index search on ${list.length} elements took`, performance.now() - indexSearch, 'ms') | ||
+ | ||
+ // const results = []; | ||
+ // let scanStart = performance.now(); | ||
+ // let i = li; | ||
+ // while (true) { | ||
+ // // End of array. | ||
+ // if (i >= list.length || i < 0) { | ||
+ // break; | ||
+ // } | ||
+ // if (args.limit && results.length >= args.limit) { | ||
+ // // Limit condition. | ||
+ // break; | ||
+ // } | ||
+ // if (args.reverse) { | ||
+ // // Lower bound condition. | ||
+ // const item = list[i]; | ||
+ // if (args.gt) { | ||
+ // const dir = cmp(args.gt, item); | ||
+ // if (dir >= 0) { | ||
+ // break; | ||
+ // } | ||
+ // } | ||
+ // if (args.gte) { | ||
+ // const dir = cmp(args.gte, item); | ||
+ // if (dir > 0) { | ||
+ // break; | ||
+ // } | ||
+ // } | ||
+ // results.push(item); | ||
+ // i -= 1; | ||
+ // } | ||
+ // else { | ||
+ // // Upper bound condition. | ||
+ // const item = list[i]; | ||
+ // if (args.lt) { | ||
+ // const dir = cmp(item, args.lt); | ||
+ // if (dir >= 0) { | ||
+ // break; | ||
+ // } | ||
+ // } | ||
+ // if (args.lte) { | ||
+ // const dir = cmp(item, args.lte); | ||
+ // if (dir > 0) { | ||
+ // break; | ||
+ // } | ||
+ // } | ||
+ // results.push(item); | ||
+ // i += 1; | ||
+ // } | ||
+ // } | ||
+ // console.log(`scan of ${results.length} elements took`, performance.now() - scanStart, 'ms') | ||
+ | ||
+ // const bulkReadStart = performance.now(); | ||
+ const resultsSlice = list.slice(li, ui+1); | ||
+ // console.log(`slice of ${resultsSlice.length} elements took`, performance.now() - bulkReadStart, 'ms') | ||
+ | ||
+ return resultsSlice; | ||
+ // return results; | ||
} | ||
exports.scan = scan; | ||
//# sourceMappingURL=../../src/helpers/sortedList.js.map |
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,22 @@ | ||
diff --git a/main.d.ts b/main.d.ts | ||
index 86532b7201c1adb652edb226daca0f09a3a2b35f..3a9ee9369babb439b845e9294570620783da9e81 100644 | ||
--- a/main.d.ts | ||
+++ b/main.d.ts | ||
@@ -14,4 +14,5 @@ export * from "./database/types"; | ||
export * from "./helpers/namedTupleToObject"; | ||
export * from "./storage/InMemoryTupleStorage"; | ||
export * from "./storage/types"; | ||
+export * from "./helpers/compareTuple"; | ||
//# sourceMappingURL=../src/main.d.ts.map | ||
\ No newline at end of file | ||
diff --git a/main.js b/main.js | ||
index c0cc1999201fdf94fe67a216cb467257d3ad7667..a42c57f0f7af0fae8c28d4eddfc3a0fe5d2c6f20 100644 | ||
--- a/main.js | ||
+++ b/main.js | ||
@@ -29,4 +29,5 @@ __exportStar(require("./database/types"), exports); | ||
__exportStar(require("./helpers/namedTupleToObject"), exports); | ||
__exportStar(require("./storage/InMemoryTupleStorage"), exports); | ||
__exportStar(require("./storage/types"), exports); | ||
+__exportStar(require("./helpers/compareTuple"), exports); | ||
//# sourceMappingURL=../src/main.js.map | ||
\ No newline at end of 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,32 @@ | ||
diff --git a/storage/IndexedDbTupleStorage.js b/storage/IndexedDbTupleStorage.js | ||
index e70827a269c14dfb9381786035f6e7836bd3368d..bb48e8d6d0e2c5f2fc4e675c8dc2ab74c64add37 100644 | ||
--- a/storage/IndexedDbTupleStorage.js | ||
+++ b/storage/IndexedDbTupleStorage.js | ||
@@ -18,6 +18,18 @@ class IndexedDbTupleStorage { | ||
const db = await this.db; | ||
const tx = db.transaction(storeName, "readonly"); | ||
const index = tx.store; // primary key | ||
+ | ||
+ let results = []; | ||
+ | ||
+ // If no args, faster to just get all keys and values | ||
+ if(!args) { | ||
+ const keys = (await index.getAllKeys()).map((key) => (0, codec_1.decodeTuple)(key)); | ||
+ const values = await index.getAll(); | ||
+ results = keys.map((key, i) => ({ key, value: values[i] })); | ||
+ await tx.done; | ||
+ return results; | ||
+ } | ||
+ | ||
const lower = (args === null || args === void 0 ? void 0 : args.gt) || (args === null || args === void 0 ? void 0 : args.gte); | ||
const lowerEq = Boolean(args === null || args === void 0 ? void 0 : args.gte); | ||
const upper = (args === null || args === void 0 ? void 0 : args.lt) || (args === null || args === void 0 ? void 0 : args.lte); | ||
@@ -41,7 +53,7 @@ class IndexedDbTupleStorage { | ||
} | ||
const direction = (args === null || args === void 0 ? void 0 : args.reverse) ? "prev" : "next"; | ||
const limit = (args === null || args === void 0 ? void 0 : args.limit) || Infinity; | ||
- let results = []; | ||
+ | ||
for await (const cursor of index.iterate(range, direction)) { | ||
results.push({ | ||
key: (0, codec_1.decodeTuple)(cursor.key), |
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 |
---|---|---|
|
@@ -4,5 +4,21 @@ | |
"workspaces": [ | ||
"packages/*" | ||
], | ||
"packageManager": "[email protected]" | ||
"scripts": { | ||
"build:packages": "yarn workspace @triplit/db run build && yarn workspace @triplit/client run build && yarn workspace @triplit/react run build", | ||
"release:packages": "yarn build:packages && yarn workspace @triplit/client run publish-pkg && yarn workspace @triplit/react run publish-pkg && yarn changeset tag", | ||
"lint": "yarn workspaces foreach --all run lint", | ||
"version": "yarn changeset version && yarn install --mode update-lockfile", | ||
"changeset": "changeset" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.26.1", | ||
"esbuild": "0.17.18", | ||
"prettier": "^2.6.2", | ||
"typescript": "^4.9.5" | ||
}, | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"tuple-database@^2.2.0": "patch:tuple-database@patch%3Atuple-database@npm%253A2.2.0%23./.yarn/patches/tuple-database-npm-2.2.0-131af7737b.patch%3A%3Aversion=2.2.0&hash=a2c0f3&locator=%2540triplit%2540workspace%253A.#./.yarn/patches/tuple-database-patch-021b29bc0c.patch" | ||
} | ||
} |
Oops, something went wrong.