jazz-tools 0.7.0-alpha.6 → 0.7.0-alpha.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/coValues/account.js +62 -29
  3. package/dist/coValues/account.js.map +1 -1
  4. package/dist/coValues/coList.js +139 -89
  5. package/dist/coValues/coList.js.map +1 -1
  6. package/dist/coValues/coMap.js +135 -151
  7. package/dist/coValues/coMap.js.map +1 -1
  8. package/dist/coValues/coStream.js +131 -57
  9. package/dist/coValues/coStream.js.map +1 -1
  10. package/dist/coValues/extensions/imageDef.js +10 -7
  11. package/dist/coValues/extensions/imageDef.js.map +1 -1
  12. package/dist/coValues/group.js +8 -30
  13. package/dist/coValues/group.js.map +1 -1
  14. package/dist/coValues/interfaces.js +6 -2
  15. package/dist/coValues/interfaces.js.map +1 -1
  16. package/dist/implementation/encoding.js +21 -0
  17. package/dist/implementation/encoding.js.map +1 -1
  18. package/dist/implementation/refs.js +10 -9
  19. package/dist/implementation/refs.js.map +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/tests/coList.test.js +5 -9
  23. package/dist/tests/coList.test.js.map +1 -1
  24. package/dist/tests/coMap.test.js +99 -36
  25. package/dist/tests/coMap.test.js.map +1 -1
  26. package/dist/tests/coStream.test.js +46 -51
  27. package/dist/tests/coStream.test.js.map +1 -1
  28. package/package.json +2 -2
  29. package/src/coValues/account.ts +82 -52
  30. package/src/coValues/coList.ts +170 -107
  31. package/src/coValues/coMap.ts +196 -230
  32. package/src/coValues/coStream.ts +169 -91
  33. package/src/coValues/extensions/imageDef.ts +7 -11
  34. package/src/coValues/group.ts +16 -63
  35. package/src/coValues/interfaces.ts +9 -8
  36. package/src/implementation/encoding.ts +55 -16
  37. package/src/implementation/refs.ts +12 -10
  38. package/src/index.ts +1 -1
  39. package/src/tests/coList.test.ts +5 -9
  40. package/src/tests/coMap.test.ts +77 -51
  41. package/src/tests/coStream.test.ts +61 -66
@@ -1,6 +1,6 @@
1
1
  var _a;
2
2
  import { Schema } from "@effect/schema";
3
- import { Account, CoValueBase, Ref, inspect, makeRefs, subscriptionsScopes, } from "../internal.js";
3
+ import { Account, CoValueBase, Ref, SchemaInit, inspect, makeRefs, subscriptionsScopes, ItemsSym, InitValues, } from "../internal.js";
4
4
  export class CoMap extends CoValueBase {
5
5
  get _encoding() {
6
6
  return this.constructor._encoding;
@@ -9,7 +9,7 @@ export class CoMap extends CoValueBase {
9
9
  return makeRefs((key) => this._raw.get(key), () => Object.keys(this._encoding).filter((key) => {
10
10
  const schema = this._encoding[key];
11
11
  schema !== "json" && "ref" in schema;
12
- }), this._loadedAs, (key) => this._encoding[key].ref());
12
+ }), this._loadedAs, (key) => this._encoding[key]);
13
13
  }
14
14
  get _edits() {
15
15
  return new Proxy(this, {
@@ -23,12 +23,14 @@ export class CoMap extends CoValueBase {
23
23
  ? rawEdit.value
24
24
  : "encoded" in descriptor
25
25
  ? Schema.decodeSync(descriptor.encoded)(rawEdit.value)
26
- : new Ref(rawEdit.value, target._loadedAs, descriptor.ref()).accessFrom(target),
26
+ : new Ref(rawEdit.value, target._loadedAs, descriptor).accessFrom(target),
27
27
  ref: descriptor !== "json" && "ref" in descriptor
28
- ? new Ref(rawEdit.value, target._loadedAs, descriptor.ref())
28
+ ? new Ref(rawEdit.value, target._loadedAs, descriptor)
29
29
  : undefined,
30
30
  by: rawEdit.by &&
31
- new Ref(rawEdit.by, target._loadedAs, Account).accessFrom(target),
31
+ new Ref(rawEdit.by, target._loadedAs, {
32
+ ref: () => Account,
33
+ }).accessFrom(target),
32
34
  madeAt: rawEdit.at,
33
35
  };
34
36
  },
@@ -39,23 +41,22 @@ export class CoMap extends CoValueBase {
39
41
  }
40
42
  constructor(init, options) {
41
43
  super();
42
- if (!this._encoding) {
43
- throw new Error("No schema found in " +
44
- this.constructor.name +
45
- " - ensure that you have a `static { this.define({...}) }` block in the class definition.");
44
+ if (init && "owner" in options) {
45
+ this[InitValues] = { init, owner: options.owner };
46
46
  }
47
- const raw = this.rawFromInit(options, init);
48
- Object.defineProperties(this, {
49
- id: {
50
- value: raw.id,
51
- enumerable: false,
52
- },
53
- _raw: { value: raw, enumerable: false },
54
- });
55
- this.definePropertiesFromSchema();
56
- if (this._encoding._item) {
57
- return new Proxy(this, CoMapProxyHandler());
47
+ else if ("fromRaw" in options) {
48
+ Object.defineProperties(this, {
49
+ id: {
50
+ value: options.fromRaw.id,
51
+ enumerable: false,
52
+ },
53
+ _raw: { value: options.fromRaw, enumerable: false },
54
+ });
58
55
  }
56
+ else {
57
+ throw new Error("Invalid CoMap constructor arguments");
58
+ }
59
+ return new Proxy(this, CoMapProxyHandler);
59
60
  }
60
61
  toJSON() {
61
62
  const jsonedFields = this._raw.keys().map((key) => {
@@ -81,111 +82,59 @@ export class CoMap extends CoValueBase {
81
82
  [inspect]() {
82
83
  return this.toJSON();
83
84
  }
84
- rawFromInit(options, init) {
85
- let raw;
86
- if ("fromRaw" in options) {
87
- raw = options.fromRaw;
88
- }
89
- else {
90
- const rawOwner = options.owner._raw;
91
- const rawInit = {};
92
- if (init)
93
- for (const key of Object.keys(init)) {
94
- const initValue = init[key];
95
- const descriptor = (this._encoding[key] || this._encoding._item);
96
- if (descriptor === "json") {
97
- rawInit[key] = initValue;
98
- }
99
- else if ("ref" in descriptor) {
100
- if (initValue) {
101
- rawInit[key] = initValue.id;
102
- }
103
- }
104
- else if ("encoded" in descriptor) {
105
- rawInit[key] = Schema.encodeSync(descriptor.encoded)(initValue);
85
+ rawFromInit(init, owner) {
86
+ const rawOwner = owner._raw;
87
+ const rawInit = {};
88
+ if (init)
89
+ for (const key of Object.keys(init)) {
90
+ const initValue = init[key];
91
+ const descriptor = (this._encoding[key] || this._encoding[ItemsSym]);
92
+ if (descriptor === "json") {
93
+ rawInit[key] = initValue;
94
+ }
95
+ else if ("ref" in descriptor) {
96
+ if (initValue) {
97
+ rawInit[key] = initValue.id;
106
98
  }
107
99
  }
108
- raw = rawOwner.createMap(rawInit);
109
- }
110
- return raw;
111
- }
112
- static encoding(fields) {
113
- this._encoding || (this._encoding = {});
114
- Object.assign(this._encoding, fields);
115
- }
116
- definePropertiesFromSchema() {
117
- for (const [key, fieldSchema] of Object.entries(this._encoding)) {
118
- if (key === "indexSignature")
119
- continue;
120
- const descriptor = fieldSchema;
121
- if (descriptor === "json") {
122
- Object.defineProperty(this, key, this.primitivePropDef(key));
123
- }
124
- else if ("encoded" in descriptor) {
125
- Object.defineProperty(this, key, this.encodedPropDef(key, descriptor.encoded));
126
- }
127
- else if ("ref" in descriptor) {
128
- Object.defineProperty(this, key, this.refPropDef(key, descriptor.ref));
100
+ else if ("encoded" in descriptor) {
101
+ rawInit[key] = Schema.encodeSync(descriptor.encoded)(initValue);
102
+ }
129
103
  }
130
- }
131
- }
132
- primitivePropDef(key) {
133
- return {
134
- get: () => {
135
- return this._raw.get(key);
136
- },
137
- set(value) {
138
- this._raw.set(key, value);
139
- },
140
- enumerable: true,
141
- configurable: true,
142
- };
143
- }
144
- encodedPropDef(key, arg) {
145
- return {
146
- get: () => {
147
- const raw = this._raw.get(key);
148
- return raw === undefined
149
- ? undefined
150
- : Schema.decodeSync(arg)(raw);
151
- },
152
- set(value) {
153
- this._raw.set(key, Schema.encodeSync(arg)(value));
154
- },
155
- enumerable: true,
156
- configurable: true,
157
- };
158
- }
159
- refPropDef(key, ref) {
160
- return {
161
- get: () => {
162
- const rawID = this._raw.get(key);
163
- return rawID === undefined
164
- ? undefined
165
- : new Ref(rawID, this._loadedAs, ref()).accessFrom(this);
166
- },
167
- set: (value) => {
168
- this._raw.set(key, value.id);
169
- subscriptionsScopes.get(this)?.onRefAccessedOrSet(value.id);
170
- },
171
- enumerable: true,
172
- configurable: true,
173
- };
104
+ return rawOwner.createMap(rawInit);
174
105
  }
175
106
  }
176
107
  _a = CoMap;
177
108
  (() => {
178
109
  _a.prototype._type = "CoMap";
179
110
  })();
111
+ function tryInit(map) {
112
+ if (map[InitValues] &&
113
+ (map._encoding[ItemsSym] ||
114
+ Object.keys(map[InitValues].init).every((key) => map._encoding[key]))) {
115
+ const raw = map.rawFromInit(map[InitValues].init, map[InitValues].owner);
116
+ Object.defineProperties(map, {
117
+ id: {
118
+ value: raw.id,
119
+ enumerable: false,
120
+ },
121
+ _raw: { value: raw, enumerable: false },
122
+ });
123
+ delete map[InitValues];
124
+ }
125
+ }
180
126
  // TODO: cache handlers per descriptor for performance?
181
- function CoMapProxyHandler() {
182
- return {
183
- get(target, key, receiver) {
184
- const descriptor = target._encoding._item;
185
- if (key in target || typeof key === "symbol") {
186
- return Reflect.get(target, key, receiver);
187
- }
188
- else {
127
+ const CoMapProxyHandler = {
128
+ get(target, key, receiver) {
129
+ if (key === "_encoding") {
130
+ return Reflect.get(target, key);
131
+ }
132
+ else if (key in target) {
133
+ return Reflect.get(target, key, receiver);
134
+ }
135
+ else {
136
+ const descriptor = (target._encoding[key] || target._encoding[ItemsSym]);
137
+ if (descriptor && typeof key === "string") {
189
138
  const raw = target._raw.get(key);
190
139
  if (descriptor === "json") {
191
140
  return raw;
@@ -198,52 +147,87 @@ function CoMapProxyHandler() {
198
147
  else if ("ref" in descriptor) {
199
148
  return raw === undefined
200
149
  ? undefined
201
- : new Ref(raw, target._loadedAs, descriptor.ref()).accessFrom(target);
150
+ : new Ref(raw, target._loadedAs, descriptor).accessFrom(receiver);
202
151
  }
203
152
  }
204
- },
205
- set(target, key, value, receiver) {
206
- const descriptor = target._encoding._item;
207
- if (key in target || typeof key === "symbol") {
208
- return Reflect.set(target, key, value, receiver);
209
- }
210
153
  else {
211
- if (descriptor === "json") {
212
- target._raw.set(key, value);
213
- }
214
- else if ("encoded" in descriptor) {
215
- target._raw.set(key, Schema.encodeSync(descriptor.encoded)(value));
216
- }
217
- else if ("ref" in descriptor) {
218
- target._raw.set(key, value.id);
219
- subscriptionsScopes
220
- .get(target)
221
- ?.onRefAccessedOrSet(value.id);
222
- }
223
- return true;
154
+ return undefined;
224
155
  }
225
- },
226
- ownKeys(target) {
227
- const keys = Reflect.ownKeys(target).filter((k) => k !== "_item");
228
- for (const key of target._raw.keys()) {
229
- if (!keys.includes(key)) {
230
- keys.push(key);
231
- }
156
+ }
157
+ },
158
+ set(target, key, value, receiver) {
159
+ var _b;
160
+ if ((typeof key === "string" || ItemsSym) &&
161
+ typeof value === "object" &&
162
+ SchemaInit in value) {
163
+ (_b = target.constructor)._encoding || (_b._encoding = {});
164
+ target.constructor._encoding[key] =
165
+ value[SchemaInit];
166
+ tryInit(target);
167
+ return true;
168
+ }
169
+ const descriptor = (target._encoding[key] ||
170
+ target._encoding[ItemsSym]);
171
+ if (descriptor && typeof key === "string") {
172
+ if (descriptor === "json") {
173
+ target._raw.set(key, value);
174
+ }
175
+ else if ("encoded" in descriptor) {
176
+ target._raw.set(key, Schema.encodeSync(descriptor.encoded)(value));
177
+ }
178
+ else if ("ref" in descriptor) {
179
+ target._raw.set(key, value.id);
180
+ subscriptionsScopes.get(target)?.onRefAccessedOrSet(value.id);
181
+ }
182
+ return true;
183
+ }
184
+ else {
185
+ return Reflect.set(target, key, value, receiver);
186
+ }
187
+ },
188
+ defineProperty(target, key, attributes) {
189
+ var _b;
190
+ if ("value" in attributes &&
191
+ typeof attributes.value === "object" &&
192
+ SchemaInit in attributes.value) {
193
+ (_b = target.constructor)._encoding || (_b._encoding = {});
194
+ target.constructor._encoding[key] =
195
+ attributes.value[SchemaInit];
196
+ tryInit(target);
197
+ return true;
198
+ }
199
+ else {
200
+ return Reflect.defineProperty(target, key, attributes);
201
+ }
202
+ },
203
+ ownKeys(target) {
204
+ const keys = Reflect.ownKeys(target).filter((k) => k !== ItemsSym);
205
+ for (const key of Reflect.ownKeys(target._encoding)) {
206
+ if (key !== ItemsSym && !keys.includes(key)) {
207
+ keys.push(key);
232
208
  }
233
- return keys;
234
- },
235
- getOwnPropertyDescriptor(target, key) {
236
- if (key in target) {
237
- return Reflect.getOwnPropertyDescriptor(target, key);
209
+ }
210
+ for (const key of target._raw.keys()) {
211
+ if (!keys.includes(key)) {
212
+ keys.push(key);
238
213
  }
239
- else if (key in target._raw.ops) {
214
+ }
215
+ return keys;
216
+ },
217
+ getOwnPropertyDescriptor(target, key) {
218
+ if (key in target) {
219
+ return Reflect.getOwnPropertyDescriptor(target, key);
220
+ }
221
+ else {
222
+ const descriptor = (target._encoding[key] || target._encoding[ItemsSym]);
223
+ if (descriptor || key in target._raw.ops) {
240
224
  return {
241
225
  enumerable: true,
242
226
  configurable: true,
243
227
  writable: true,
244
228
  };
245
229
  }
246
- },
247
- };
248
- }
230
+ }
231
+ },
232
+ };
249
233
  //# sourceMappingURL=coMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coMap.js","sourceRoot":"","sources":["../../src/coValues/coMap.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAYxC,OAAO,EACH,OAAO,EACP,WAAW,EACX,GAAG,EACH,OAAO,EACP,QAAQ,EACR,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAkCxB,MAAM,OAAO,KACT,SAAQ,WAAW;IAWnB,IAAI,SAAS;QAOT,OAAQ,IAAI,CAAC,WAA4B,CAAC,SAAS,CAAC;IACxD,CAAC;IAED,IAAI,KAAK;QAOL,OAAO,QAAQ,CACX,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAa,CAA2B,EAC/D,GAAG,EAAE,CACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CACzB,GAAkC,CACzB,CAAC;YACd,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI,MAAM,CAAC;QACzC,CAAC,CAAsB,EAC3B,IAAI,CAAC,SAAS,EACd,CAAC,GAAG,EAAE,EAAE,CAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAyB,CAAC,GAAG,EAAE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E,GAAG,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACJ,MAAM,UAAU,GAAG,CAAC,MAAM,CAAC,SAAS,CAChC,GAA+B,CAClC,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAa,CAAC;YAC7C,IAAI,UAAU,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACvC,OAAO;oBACH,UAAU,EAAE,IAAI;oBAChB,YAAY,EAAE,IAAI;oBAClB,QAAQ,EAAE,IAAI;iBACjB,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;CACJ,CAAC"}
@@ -1,80 +1,54 @@
1
1
  var _a;
2
2
  import { cojsonInternals } from "cojson";
3
- import { Account, CoValueBase, Ref, inspect } from "../internal.js";
3
+ import { ItemsSym, Account, CoValueBase, Ref, inspect, val, InitValues, SchemaInit, } from "../internal.js";
4
4
  import { Schema } from "@effect/schema";
5
5
  export class CoStream extends CoValueBase {
6
+ static Of(item) {
7
+ var _b, _c;
8
+ return _c = class CoStreamOf extends _a {
9
+ constructor() {
10
+ super(...arguments);
11
+ this[_b] = item;
12
+ }
13
+ },
14
+ _b = val.items,
15
+ _c;
16
+ }
6
17
  get _encoding() {
7
18
  return this.constructor._encoding;
8
19
  }
9
20
  get byMe() {
10
- return this.by[this._loadedAs.id];
21
+ return this[this._loadedAs.id];
11
22
  }
12
23
  get inCurrentSession() {
13
- return this.in[this._loadedAs.sessionID];
24
+ return this.perSession[this._loadedAs.sessionID];
14
25
  }
15
26
  constructor(init, options) {
16
27
  super();
17
- this.by = {};
18
- this.in = {};
19
- let raw;
20
28
  if ("fromRaw" in options) {
21
- raw = options.fromRaw;
22
- }
23
- else {
24
- const rawOwner = options.owner._raw;
25
- raw = rawOwner.createStream();
26
- }
27
- Object.defineProperties(this, {
28
- id: {
29
- value: raw.id,
30
- enumerable: false,
31
- },
32
- _raw: { value: raw, enumerable: false },
33
- });
34
- if (init !== undefined) {
35
- for (const item of init) {
36
- this.pushItem(item);
37
- }
38
- }
39
- this.updateEntries();
40
- }
41
- updateEntries() {
42
- for (const accountID of this._raw.accounts()) {
43
- Object.defineProperty(this.by, accountID, {
44
- get: () => {
45
- const rawEntry = this._raw.lastItemBy(accountID);
46
- if (!rawEntry)
47
- return;
48
- return entryFromRawEntry(this, rawEntry, this._loadedAs, accountID, this._encoding._item);
29
+ Object.defineProperties(this, {
30
+ id: {
31
+ value: options.fromRaw.id,
32
+ enumerable: false,
49
33
  },
50
- configurable: true,
51
- enumerable: true,
34
+ _raw: { value: options.fromRaw, enumerable: false },
52
35
  });
53
36
  }
54
- for (const sessionID of this._raw.sessions()) {
55
- Object.defineProperty(this.in, sessionID, {
56
- get: () => {
57
- const rawEntry = this._raw.lastItemIn(sessionID);
58
- if (!rawEntry)
59
- return;
60
- const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
61
- return entryFromRawEntry(this, rawEntry, this._loadedAs, cojsonInternals.isAccountID(by)
62
- ? by
63
- : undefined, this._encoding._item);
64
- },
65
- configurable: true,
66
- enumerable: true,
67
- });
37
+ else {
38
+ this[InitValues] = {
39
+ init,
40
+ owner: options.owner,
41
+ };
68
42
  }
43
+ return new Proxy(this, CoStreamProxyHandler);
69
44
  }
70
45
  push(...items) {
71
46
  for (const item of items) {
72
47
  this.pushItem(item);
73
48
  }
74
- this.updateEntries();
75
49
  }
76
50
  pushItem(item) {
77
- const itemDescriptor = this._encoding._item;
51
+ const itemDescriptor = this._encoding[ItemsSym];
78
52
  if (itemDescriptor === "json") {
79
53
  this._raw.push(item);
80
54
  }
@@ -86,7 +60,7 @@ export class CoStream extends CoValueBase {
86
60
  }
87
61
  }
88
62
  toJSON() {
89
- const itemDescriptor = this._encoding._item;
63
+ const itemDescriptor = this._encoding[ItemsSym];
90
64
  const mapper = itemDescriptor === "json"
91
65
  ? (v) => v
92
66
  : "encoded" in itemDescriptor
@@ -95,11 +69,11 @@ export class CoStream extends CoValueBase {
95
69
  return {
96
70
  id: this.id,
97
71
  _type: this._type,
98
- by: Object.fromEntries(Object.entries(this.by).map(([account, entry]) => [
72
+ ...Object.fromEntries(Object.entries(this).map(([account, entry]) => [
99
73
  account,
100
74
  mapper(entry.value),
101
75
  ])),
102
- in: Object.fromEntries(Object.entries(this.in).map(([session, entry]) => [
76
+ in: Object.fromEntries(Object.entries(this.perSession).map(([session, entry]) => [
103
77
  session,
104
78
  mapper(entry.value),
105
79
  ])),
@@ -133,17 +107,117 @@ function entryFromRawEntry(accessFrom, rawEntry, loadedAs, accountID, itemField)
133
107
  get ref() {
134
108
  if (itemField !== "json" && "ref" in itemField) {
135
109
  const rawId = rawEntry.value;
136
- return new Ref(rawId, loadedAs, itemField.ref());
110
+ return new Ref(rawId, loadedAs, itemField);
137
111
  }
138
112
  },
139
113
  get by() {
140
114
  return (accountID &&
141
- new Ref(accountID, loadedAs, Account)?.accessFrom(accessFrom));
115
+ new Ref(accountID, loadedAs, { ref: () => Account })?.accessFrom(accessFrom));
142
116
  },
143
117
  madeAt: rawEntry.at,
144
118
  tx: rawEntry.tx,
145
119
  };
146
120
  }
121
+ function init(stream) {
122
+ const init = stream[InitValues];
123
+ if (!init)
124
+ return;
125
+ const raw = init.owner._raw.createStream();
126
+ Object.defineProperties(stream, {
127
+ id: {
128
+ value: raw.id,
129
+ enumerable: false,
130
+ },
131
+ _raw: { value: raw, enumerable: false },
132
+ });
133
+ if (init.init) {
134
+ stream.push(...init.init);
135
+ }
136
+ delete stream[InitValues];
137
+ }
138
+ export const CoStreamProxyHandler = {
139
+ get(target, key, receiver) {
140
+ if (typeof key === "string" && key.startsWith("co_")) {
141
+ const rawEntry = target._raw.lastItemBy(key);
142
+ if (!rawEntry)
143
+ return;
144
+ return entryFromRawEntry(receiver, rawEntry, target._loadedAs, key, target._encoding[ItemsSym]);
145
+ }
146
+ else if (key === "perSession") {
147
+ return new Proxy(receiver, CoStreamPerSessionProxyHandler);
148
+ }
149
+ else {
150
+ return Reflect.get(target, key, receiver);
151
+ }
152
+ },
153
+ set(target, key, value, receiver) {
154
+ var _b;
155
+ if (key === ItemsSym &&
156
+ typeof value === "object" &&
157
+ SchemaInit in value) {
158
+ (_b = target.constructor)._encoding || (_b._encoding = {});
159
+ target.constructor._encoding[ItemsSym] =
160
+ value[SchemaInit];
161
+ init(target);
162
+ return true;
163
+ }
164
+ else {
165
+ return Reflect.set(target, key, value, receiver);
166
+ }
167
+ },
168
+ defineProperty(target, key, descriptor) {
169
+ var _b;
170
+ if (descriptor.value &&
171
+ key === ItemsSym &&
172
+ typeof descriptor.value === "object" &&
173
+ SchemaInit in descriptor.value) {
174
+ (_b = target.constructor)._encoding || (_b._encoding = {});
175
+ target.constructor._encoding[ItemsSym] =
176
+ descriptor.value[SchemaInit];
177
+ init(target);
178
+ return true;
179
+ }
180
+ else {
181
+ return Reflect.defineProperty(target, key, descriptor);
182
+ }
183
+ },
184
+ ownKeys(target) {
185
+ const keys = Reflect.ownKeys(target);
186
+ for (const accountID of target._raw.accounts()) {
187
+ keys.push(accountID);
188
+ }
189
+ return keys;
190
+ },
191
+ getOwnPropertyDescriptor(target, key) {
192
+ if (typeof key === "string" && key.startsWith("co_")) {
193
+ return {
194
+ configurable: true,
195
+ enumerable: true,
196
+ writable: false,
197
+ };
198
+ }
199
+ else {
200
+ return Reflect.getOwnPropertyDescriptor(target, key);
201
+ }
202
+ },
203
+ };
204
+ const CoStreamPerSessionProxyHandler = {
205
+ get(target, key, receiver) {
206
+ if (typeof key === "string" && key.includes("session")) {
207
+ const sessionID = key;
208
+ const rawEntry = target._raw.lastItemIn(sessionID);
209
+ if (!rawEntry)
210
+ return;
211
+ const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
212
+ return entryFromRawEntry(target, rawEntry, target._loadedAs, cojsonInternals.isAccountID(by)
213
+ ? by
214
+ : undefined, target._encoding[ItemsSym]);
215
+ }
216
+ else {
217
+ return Reflect.get(target, key, receiver);
218
+ }
219
+ },
220
+ };
147
221
  export class BinaryCoStream extends CoValueBase {
148
222
  constructor(init, options) {
149
223
  super();