-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps,lib,src: add experimental web storage
This commit introduces an experimental implementation of the Web Storage API using SQLite as the backing data store.
- Loading branch information
Showing
99 changed files
with
268,189 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,20 @@ | ||
{ | ||
'variables': { | ||
'sqlite3_sources': [ | ||
'sqlite3.c', | ||
], | ||
}, | ||
'targets': [ | ||
{ | ||
'target_name': 'sqlite3', | ||
'type': 'static_library', | ||
'include_dirs': ['.'], | ||
'sources': [ | ||
'<@(sqlite3_sources)', | ||
], | ||
'direct_dependent_settings': { | ||
'include_dirs': ['.'], | ||
}, | ||
}, | ||
], | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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,57 @@ | ||
'use strict'; | ||
const { | ||
MathAbs, | ||
ObjectDefineProperty, | ||
StringPrototypeCharCodeAt, | ||
} = primordials; | ||
const { emitExperimentalWarning } = require('internal/util'); | ||
const { kConstructorKey, Storage } = internalBinding('webstorage'); | ||
const { basename, join } = require('path'); | ||
|
||
emitExperimentalWarning('Web storage'); | ||
|
||
module.exports = { Storage }; | ||
|
||
let lazyLocalStorage; | ||
let lazySessionStorage; | ||
|
||
ObjectDefineProperty(module.exports, 'localStorage', { | ||
__proto__: null, | ||
configurable: true, | ||
enumerable: true, | ||
get() { | ||
if (lazyLocalStorage === undefined) { | ||
const entry = process.argv[1] ?? process.argv[0]; | ||
const base = basename(entry); | ||
const hash = hashCode(entry); | ||
const location = join(process.cwd(), `${base}.${hash}.localstorage`); | ||
|
||
lazyLocalStorage = new Storage(kConstructorKey, location); | ||
} | ||
|
||
return lazyLocalStorage; | ||
}, | ||
}); | ||
|
||
ObjectDefineProperty(module.exports, 'sessionStorage', { | ||
__proto__: null, | ||
configurable: true, | ||
enumerable: true, | ||
get() { | ||
if (lazySessionStorage === undefined) { | ||
lazySessionStorage = new Storage(kConstructorKey, ':memory:'); | ||
} | ||
|
||
return lazySessionStorage; | ||
}, | ||
}); | ||
|
||
function hashCode(s) { | ||
let h = 0; | ||
|
||
for (let i = 0; i < s.length; ++i) { | ||
h = (h << 5) - h + StringPrototypeCharCodeAt(s, i) | 0; | ||
} | ||
|
||
return MathAbs(h); | ||
} |
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
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
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 |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
V(wasi) \ | ||
V(wasm_web_api) \ | ||
V(watchdog) \ | ||
V(webstorage) \ | ||
V(worker) \ | ||
V(zlib) | ||
|
||
|
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
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
Oops, something went wrong.