-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
177 additions
and
134 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
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,5 @@ | ||
'use strict'; | ||
|
||
const { addonShim } = require('@warp-drive/build-config/addon-shim.cjs'); | ||
|
||
module.exports = addonShim(__dirname); |
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 @@ | ||
import { macros } from '@warp-drive/build-config/babel-macros'; | ||
|
||
export default { | ||
plugins: [ | ||
...macros(), | ||
[ | ||
'@babel/plugin-transform-typescript', | ||
{ allExtensions: true, onlyRemoveTypeImports: true, allowDeclareFields: true }, | ||
], | ||
], | ||
}; |
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 @@ | ||
// @ts-check | ||
import { globalIgnores } from '@warp-drive/internal-config/eslint/ignore.js'; | ||
import * as node from '@warp-drive/internal-config/eslint/node.js'; | ||
import * as typescript from '@warp-drive/internal-config/eslint/typescript.js'; | ||
|
||
/** @type {import('eslint').Linter.FlatConfig[]} */ | ||
export default [ | ||
// all ================ | ||
globalIgnores(), | ||
|
||
// browser (js/ts) ================ | ||
typescript.browser({ | ||
srcDirs: ['src'], | ||
allowedImports: [], | ||
}), | ||
|
||
// node (module) ================ | ||
node.esm(), | ||
|
||
// node (script) ================ | ||
node.cjs(), | ||
]; |
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,7 +1,7 @@ | ||
{ | ||
"name": "@warp-drive/experiments", | ||
"description": "Experimental features for EmberData/WarpDrive", | ||
"version": "5.4.0-alpha.10", | ||
"version": "0.0.1-alpha.83", | ||
"private": true, | ||
"license": "MIT", | ||
"author": "Chris Thoburn <[email protected]>", | ||
|
@@ -18,14 +18,22 @@ | |
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"files": [], | ||
"files": [ | ||
"dist", | ||
"unstable-preview-types", | ||
"CHANGELOG.md", | ||
"README.md", | ||
"LICENSE.md", | ||
"NCC-1701-a-blue.svg", | ||
"NCC-1701-a.svg" | ||
], | ||
"scripts": {}, | ||
"devDependencies": { | ||
"@warp-drive/core-types": "workspace:0.0.0-alpha.56", | ||
"@warp-drive/build-config": "workspace:0.0.0-alpha.7", | ||
"@ember-data/request": "workspace:5.4.0-alpha.70", | ||
"@ember-data/request-utils": "workspace:5.4.0-alpha.70", | ||
"@ember-data/store": "workspace:5.4.0-alpha.70", | ||
"@ember-data/tracking": "workspace:5.4.0-alpha.70" | ||
"@warp-drive/core-types": "workspace:0.0.0-alpha.69", | ||
"@warp-drive/build-config": "workspace:0.0.0-alpha.20", | ||
"@ember-data/request": "workspace:5.4.0-alpha.83", | ||
"@ember-data/request-utils": "workspace:5.4.0-alpha.83", | ||
"@ember-data/store": "workspace:5.4.0-alpha.83", | ||
"@ember-data/tracking": "workspace:5.4.0-alpha.83" | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
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 @@ | ||
export { PersistedCache } from './persisted-cache/index.ts'; |
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,79 @@ | ||
<p align="center"> | ||
<img | ||
class="project-logo" | ||
src="../../NCC-1701-a-blue.svg#gh-light-mode-only" | ||
alt="WarpDrive" | ||
width="120px" | ||
title="WarpDrive" /> | ||
<img | ||
class="project-logo" | ||
src="../../NCC-1701-a.svg#gh-dark-mode-only" | ||
alt="WarpDrive" | ||
width="120px" | ||
title="WarpDrive" /> | ||
</p> | ||
|
||
<h3 align="center">PersistedCache</h3> | ||
|
||
|
||
- ⚡️ Load new tabs or windows without ever hitting network | ||
- ♻️ Replay requests reliably in any order and still get the latest state of all associated resources | ||
|
||
## Install | ||
|
||
```cli | ||
pnpm add @warp-drive/experiments | ||
``` | ||
|
||
Or use favorite your javascript package manager. | ||
|
||
## Configure | ||
|
||
|
||
|
||
## How it Works | ||
|
||
### Insertion | ||
|
||
Only "clean" (remote) state is persisted. Dirty state is not currently persisted, and thus | ||
a "refresh" of the page or opening a tab will result in new data. | ||
|
||
The PersistedCache wraps a Cache implementation. | ||
|
||
Whenever a request result is `put` into the cache, the result is used | ||
to construct a new cache entry for indexeddb for the document and associated resources. | ||
|
||
Whenever a save request commits, similarly the new state of any associated resources | ||
is persisted to indexeddb. | ||
|
||
When a `store.push` occurs (resulting in a `put` without an associated document), only | ||
the associated resource state is updated in indexeddb. | ||
|
||
### Sync | ||
|
||
Whenever IndexedDB is updated, any resources currently in the tab's in-memory cache | ||
will update. | ||
|
||
### Retrieval | ||
|
||
Requests saved to IndexedDB are replayed by using the `PersistedFetch` handler. | ||
This handler will check whether the request exists in the persisted cache | ||
and resolve it using the registered CachePolicy to determine staleness. | ||
|
||
CachePolicies which invalidate requests based on in-memory lists may fail | ||
to invalidate a persisted request since it was not known to the policy at | ||
the point of invalidation. This can be handled (for now) by integrating with IndexedDB, | ||
though we expect this handling to improve in the future once PersistedCache is | ||
combined with DataWorker, as the CachePolicy would execute from within the worker. | ||
|
||
CachePolicies may also need to take into account that they might be asked about the | ||
expiration of the same request twice: first by the primary in-memory cache handler, | ||
and then again by the persisted-cache handler should the in-memory cache not handle the | ||
request. | ||
|
||
Prior to the second inquiry, the document will be loaded into the in-memory cache so | ||
that the CachePolicy can be applied to it. | ||
|
||
### Cache Header | ||
|
||
Responses served from indexeddb will have the header `X-WarpDrive-Cache: IndexedDB` |
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 |
---|---|---|
|
@@ -61,6 +61,6 @@ | |
}, | ||
{ | ||
"path": "../build-config" | ||
}, | ||
} | ||
] | ||
} |
Oops, something went wrong.