-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Initial fork and patching of sql.js #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cc4b5b7
Added initial sql.js forks with patches for the makefile.
Chriztiaan d4ee148
Added changeset config.
Chriztiaan 9a06af4
Added build worfkflow.
Chriztiaan aa2c192
Updated license.
Chriztiaan 8950d1f
Added sha3sum.
Chriztiaan cde72f6
Different sha3sum depedency.
Chriztiaan d3060d4
Added EMCC.
Chriztiaan de32978
Added dev release mechanism.
Chriztiaan 391bb17
Temporary on push for dev release.
Chriztiaan f32c673
Changed main in package.json
Chriztiaan c533779
tmp
Chriztiaan 9d731a5
Added publish config and changed from private to public.
Chriztiaan 616f472
Dist copy fix.
Chriztiaan 7d24ab7
Added release workflow.
Chriztiaan 941de22
Bumped core version. Locking sql-js clone to a specific version.
Chriztiaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,5 @@ | ||
| --- | ||
| "@powersync/sql-js": patch | ||
| --- | ||
|
|
||
| Initial release of sql.js fork with PowerSync. |
This file contains hidden or 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": "restricted", | ||
| "baseBranch": "main", | ||
| "updateInternalDependencies": "patch", | ||
| "ignore": [] | ||
| } |
This file contains hidden or 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,55 @@ | ||
| # Ensures package builds correctly | ||
| name: Build Package | ||
|
|
||
| on: | ||
| push: | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build Packages | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup NodeJS | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
|
|
||
| - uses: pnpm/action-setup@v2 | ||
| name: Install pnpm | ||
| with: | ||
| version: 9 | ||
| run_install: false | ||
|
|
||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: | | ||
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
|
||
| - uses: actions/cache@v3 | ||
| name: Setup pnpm cache | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Install sha3sum | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libdigest-sha3-perl | ||
|
|
||
| - name: Setup Emscripten | ||
| uses: mymindstorm/setup-emsdk@v14 | ||
| with: | ||
| version: "latest" | ||
| actions-cache-folder: "emsdk-cache" | ||
|
|
||
| - name: Build | ||
| run: pnpm build |
This file contains hidden or 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,57 @@ | ||
| # Action to publish packages under the `next` tag for testing | ||
| # Packages are versioned as `0.0.0-{tag}-DATETIMESTAMP` | ||
| name: Create Dev Release | ||
|
|
||
| on: workflow_dispatch | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Publish Dev Packages | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Setup NodeJS | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
| - uses: pnpm/action-setup@v2 | ||
| name: Install pnpm | ||
| with: | ||
| version: 9 | ||
| run_install: false | ||
| - name: Add NPM auth | ||
| run: echo "//registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}}" >> ~/.npmrc | ||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: | | ||
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
| - uses: actions/cache@v3 | ||
| name: Setup pnpm cache | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Install sha3sum | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libdigest-sha3-perl | ||
|
|
||
| - name: Setup Emscripten | ||
| uses: mymindstorm/setup-emsdk@v14 | ||
| with: | ||
| version: "latest" | ||
| actions-cache-folder: "emsdk-cache" | ||
|
|
||
| - name: Build | ||
| run: pnpm build | ||
|
|
||
| - name: Publish | ||
| run: | | ||
| pnpm changeset version --no-git-tag --snapshot dev | ||
| pnpm changeset publish --tag dev |
This file contains hidden or 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,63 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Repo | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: ".nvmrc" | ||
| - uses: pnpm/action-setup@v2 | ||
| name: Install pnpm | ||
| with: | ||
| # Pnpm 9.4 introduces this https://github.com/pnpm/pnpm/pull/7633 | ||
| # which causes workspace:^1.2.0 to be converted to 1.2.0^1.2.0 | ||
| version: 9.3 | ||
| run_install: false | ||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: | | ||
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
| - uses: actions/cache@v3 | ||
| name: Setup pnpm cache | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Install sha3sum | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libdigest-sha3-perl | ||
|
|
||
| - name: Setup Emscripten | ||
| uses: mymindstorm/setup-emsdk@v14 | ||
| with: | ||
| version: "latest" | ||
| actions-cache-folder: "emsdk-cache" | ||
|
|
||
| - name: Create Release Pull Request or Publish to npm | ||
| id: changesets | ||
| uses: changesets/action@v1 | ||
| with: | ||
| # Update the monorepo lockfile after versioning | ||
| version: pnpm changeset:version | ||
| # This expects you to have a script called release which does a build for your packages and calls changeset publish | ||
| publish: pnpm release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains hidden or 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 @@ | ||
| sql.js | ||
| dist | ||
| .vscode | ||
| .DS_STORE | ||
| .idea | ||
| .fleet | ||
| node_modules | ||
| *.tmp |
This file contains hidden or 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 @@ | ||
| v20.9.0 |
This file contains hidden or 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,42 @@ | ||
| # MIT license | ||
|
|
||
| Copyright (c) 2017 sql.js authors (see AUTHORS) | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
||
| # Some portions of the Makefile taken from: | ||
|
|
||
| Copyright 2017 Ryusei Yamaguchi | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or 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 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| SQLITE_VERSION="2.7.6" | ||
| POWERSYNC_CORE_VERSION="0.4.0" | ||
| SQLITE_PATH="sql.js" | ||
|
|
||
| if [ -d "$SQLITE_PATH" ]; then | ||
| echo "Deleting existing clone" | ||
| rm -rf $SQLITE_PATH | ||
| fi | ||
|
|
||
| git clone --depth 1 https://github.com/sql-js/sql.js.git $SQLITE_PATH | ||
Chriztiaan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| cd $SQLITE_PATH | ||
| git apply ../patches/* | ||
| mkdir -p powersync-libs | ||
| curl -L -o powersync-libs/libpowersync-wasm.a "https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v${POWERSYNC_CORE_VERSION}/libpowersync-wasm.a" | ||
|
|
||
| make | ||
|
|
||
| cd ../ | ||
| mkdir -p dist | ||
| cp -r $SQLITE_PATH/dist/* dist/ | ||
This file contains hidden or 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,34 @@ | ||
| { | ||
| "name": "@powersync/sql-js", | ||
| "version": "0.0.0", | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org/", | ||
| "access": "public" | ||
| }, | ||
| "description": "SQL.js fork for for JourneyApps PowerSync", | ||
| "type": "module", | ||
| "main": "sql-asm.js", | ||
| "author": "JOURNEYAPPS", | ||
| "license": "MIT", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/powersync-ja/powersync-sql-js.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/powersync-ja/powersync-js/issues" | ||
| }, | ||
| "homepage": "https://docs.powersync.com", | ||
| "scripts": { | ||
| "build": "sh build.sh", | ||
| "ci:publish": "pnpm publish -r", | ||
| "changeset:version": "pnpm changeset version && pnpm install --lockfile-only --frozen-lockfile=false", | ||
| "clean": "rm -rf dist sql.js", | ||
| "release": "pnpm build && pnpm changeset publish" | ||
| }, | ||
| "devDependencies": { | ||
| "@changesets/cli": "^2.29.5" | ||
| } | ||
| } |
This file contains hidden or 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,34 @@ | ||
| diff --git a/src/update.c b/src/update.c | ||
| new file mode 100644 | ||
| index 0000000..c7e8a23 | ||
| --- /dev/null | ||
| +++ b/src/update.c | ||
| @@ -0,0 +1,28 @@ | ||
| +#include "sqlite3ext.h" | ||
| +SQLITE_EXTENSION_INIT1 | ||
| + | ||
| +#include <emscripten.h> | ||
| +#include <stdio.h> | ||
| +#include <stdint.h> | ||
| + | ||
| +EM_JS(void, call_js_update_hook, (int db_p, int type, const char* db_name, const char* table_name), { | ||
| + if (typeof onSqliteUpdate === "function") { | ||
| + onSqliteUpdate(db_p, type, UTF8ToString(db_name), UTF8ToString(table_name)); | ||
| + } else { | ||
| + console.error("onSqliteUpdate is not defined"); | ||
| + } | ||
| +}); | ||
| + | ||
| +static void sqlite_update_callback(void* pArg, int type, const char* db, const char* table, sqlite3_int64 rowid) { | ||
| + call_js_update_hook((int)(intptr_t)pArg, type, db, table); | ||
| +} | ||
| + | ||
| +static int register_update_hook_on_open(sqlite3* db, const char** pzErrMsg, const sqlite3_api_routines* pApi) { | ||
| + SQLITE_EXTENSION_INIT2(pApi); | ||
| + sqlite3_update_hook(db, sqlite_update_callback, db); | ||
| + return SQLITE_OK; | ||
| +} | ||
| + | ||
| +void register_update_hook_extension(void) { | ||
| + sqlite3_auto_extension((void(*)(void))register_update_hook_on_open); | ||
| +} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.