Skip to content
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

Web support vol.2 #190

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

.DS_Store
.idea/
.vscode/
*.iml

download/
Expand Down
34 changes: 34 additions & 0 deletions objectbox-js/.cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "0.1",
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json",
"language": "en",
"words": [
"bitjson",
"bitauth",
"cimg",
"circleci",
"codecov",
"commitlint",
"dependabot",
"editorconfig",
"esnext",
"execa",
"exponentiate",
"globby",
"libauth",
"mkdir",
"prettierignore",
"sandboxed",
"transpiled",
"typedoc",
"untracked"
],
"flagWords": [],
"ignorePaths": [
"package.json",
"package-lock.json",
"yarn.lock",
"tsconfig.json",
"node_modules/**"
]
}
15 changes: 15 additions & 0 deletions objectbox-js/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
35 changes: 35 additions & 0 deletions objectbox-js/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
// TODO, doesn't like webpack config
// "parserOptions": { "project": "./tsconfig.json" },
"env": { "es6": true },
"ignorePatterns": ["node_modules", "build", "coverage"],
"plugins": ["import", "eslint-comments", "functional"],
"extends": [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:functional/lite",
"prettier",
"prettier/@typescript-eslint"
],
"globals": { "BigInt": true, "console": true, "WebAssembly": true },
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"eslint-comments/disable-enable-pair": [
"error",
{ "allowWholeFile": true }
],
"eslint-comments/no-unused-disable": "error",
"import/order": [
"error",
{ "newlines-between": "always", "alphabetize": { "order": "asc" } }
],
"sort-imports": [
"error",
{ "ignoreDeclarationSort": true, "ignoreCase": true }
]
}
}
9 changes: 9 additions & 0 deletions objectbox-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.idea/*
.nyc_output
build
node_modules
test
src/**.js
coverage
*.log
yarn.lock
2 changes: 2 additions & 0 deletions objectbox-js/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# package.json is formatted by package managers, so we ignore it here
package.json
8 changes: 8 additions & 0 deletions objectbox-js/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"eamodio.gitlens",
"streetsidesoftware.code-spell-checker",
]
}
29 changes: 29 additions & 0 deletions objectbox-js/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
// To debug, make sure a *.spec.ts file is active in the editor, then run a configuration
{
"type": "node",
"request": "launch",
"name": "Debug Active Spec",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": ["debug", "--break", "--serial", "${file}"],
"port": 9229,
"outputCapture": "std",
"skipFiles": ["<node_internals>/**/*.js"],
"preLaunchTask": "npm: build"
// "smartStep": true
},
{
// Use this one if you're already running `yarn watch`
"type": "node",
"request": "launch",
"name": "Debug Active Spec (no build)",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": ["debug", "--break", "--serial", "${file}"],
"port": 9229,
"outputCapture": "std",
"skipFiles": ["<node_internals>/**/*.js"]
// "smartStep": true
}]
}
7 changes: 7 additions & 0 deletions objectbox-js/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"cSpell.userWords": [], // only use words from .cspell.json
"cSpell.enabled": true,
"editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
31 changes: 31 additions & 0 deletions objectbox-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ObjectBox TS/JS (based on IndexedDB)

This is a very basic ObjectBox implementation for JavaScript/TypeScript, based on IndexedDB instead of the native objectbox-c API.

### Build and copy to objectbox-dart

The following code builds TypeScript files into `build` folder, uses `webpack` to create a single JS,
copies the JS (and sourcemap) to `../objectbox/lib/`, and generates dart binding code in `../objectbox/lib/src/web/`.
```shell
npm run build:main
npm run install
npm run generate:dart
```

Or run a single action to do it all:
```shell
npm run all:dart
```

### Notes and useful links about the compilation/integration:

* modules are not supported, we need to compile to a single JS file (using `webpack`)
* example: https://github.com/google/chartjs.dart/
* example: https://github.com/matanlurey/dart_js_interop
* modules issue: https://github.com/dart-lang/sdk/issues/25059

### IndexedDB resources

* https://developers.google.com/web/ilt/pwa/working-with-indexeddb
* https://www.tutorialspoint.com/html5/html5_indexeddb.htm
* https://javascript.info/indexeddb
Loading