@agoric/zone 0.1.1-dev-4874362.0 → 0.1.1-dev-a1c0b7a.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +41 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Zones
2
+
3
+ Each Zone provides an API that allows the allocation of [Exo objects](https://github.com/endojs/endo/tree/master/packages/exo#readme) and [Stores
4
+ (object collections)](../store/README.md) which use the same underlying persistence mechanism. This
5
+ allows library code to be agnostic to whether its objects are backed purely by
6
+ the JS heap (ephemeral), pageable out to disk (virtual) or can be revived after
7
+ a vat upgrade (durable).
8
+
9
+ See [SwingSet vat upgrade documentation](../SwingSet/docs/vat-upgrade.md) for more example use of the zone API.
10
+
11
+ An example of making a Zone-aware vat might look something like this:
12
+
13
+ ```js
14
+ import { makeDurableZone } from '@agoric/zone/durable.js';
15
+ import { zoneFrobulator } from 'frob-package';
16
+ import { zoneWidget } from 'widget-package';
17
+
18
+ export const buildRootObject = (vatPowers, _args, baggage) => {
19
+ const zone = makeDurableZone(baggage);
20
+
21
+ // Ensure that Widgets cannot interfere with Frobs.
22
+ const makeWidget = zoneWidget(zone.subZone('Widgets'));
23
+
24
+ // Create a collection of frobulators.
25
+ const frobZone = zone.subZone('Frobs');
26
+ const makeFrobulator = zoneFrobulator(frobZone);
27
+ const widgetToFrob = frobZone.mapStore('widgetToFrob');
28
+
29
+ return Far('WidgetFrobulator', {
30
+ makeWidget,
31
+ registerWidget(w) {
32
+ const frobulator = makeFrobulator();
33
+ widgetToFrob.init(w, frobulator);
34
+ },
35
+ frobWidget(w) {
36
+ const frobulator = widgetToFrob.get(w);
37
+ return frobulator.frob(w);
38
+ },
39
+ });
40
+ }
41
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/zone",
3
- "version": "0.1.1-dev-4874362.0+4874362",
3
+ "version": "0.1.1-dev-a1c0b7a.0+a1c0b7a",
4
4
  "description": "Allocation zone abstraction for objects on the heap, persistent stores, etc.",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/Agoric/agoric-sdk",
@@ -25,8 +25,8 @@
25
25
  "author": "Agoric",
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@agoric/store": "0.8.4-dev-4874362.0+4874362",
29
- "@agoric/vat-data": "0.4.4-dev-4874362.0+4874362",
28
+ "@agoric/store": "0.8.4-dev-a1c0b7a.0+a1c0b7a",
29
+ "@agoric/vat-data": "0.4.4-dev-a1c0b7a.0+a1c0b7a",
30
30
  "@endo/far": "^0.2.14"
31
31
  },
32
32
  "publishConfig": {
@@ -42,5 +42,5 @@
42
42
  "timeout": "20m",
43
43
  "workerThreads": false
44
44
  },
45
- "gitHead": "4874362b8f9aa4f7c9f67ef7761bd78df126f267"
45
+ "gitHead": "a1c0b7a8f05d3f359d07935d0b782adeffb9af4c"
46
46
  }