jazz-tools 0.7.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +24 -0
- package/.turbo/turbo-build.log +24 -0
- package/CHANGELOG.md +42 -0
- package/LICENSE.txt +19 -0
- package/README.md +3 -0
- package/dist/coValueInterfaces.js +8 -0
- package/dist/coValueInterfaces.js.map +1 -0
- package/dist/coValues/account/account.js +11 -0
- package/dist/coValues/account/account.js.map +1 -0
- package/dist/coValues/account/accountOf.js +150 -0
- package/dist/coValues/account/accountOf.js.map +1 -0
- package/dist/coValues/account/migration.js +4 -0
- package/dist/coValues/account/migration.js.map +1 -0
- package/dist/coValues/coList/coList.js +2 -0
- package/dist/coValues/coList/coList.js.map +1 -0
- package/dist/coValues/coList/coListOf.js +235 -0
- package/dist/coValues/coList/coListOf.js.map +1 -0
- package/dist/coValues/coList/internalDocs.js +2 -0
- package/dist/coValues/coList/internalDocs.js.map +1 -0
- package/dist/coValues/coMap/coMap.js +2 -0
- package/dist/coValues/coMap/coMap.js.map +1 -0
- package/dist/coValues/coMap/coMapOf.js +262 -0
- package/dist/coValues/coMap/coMapOf.js.map +1 -0
- package/dist/coValues/coMap/internalDocs.js +2 -0
- package/dist/coValues/coMap/internalDocs.js.map +1 -0
- package/dist/coValues/coStream/coStream.js +2 -0
- package/dist/coValues/coStream/coStream.js.map +1 -0
- package/dist/coValues/coStream/coStreamOf.js +244 -0
- package/dist/coValues/coStream/coStreamOf.js.map +1 -0
- package/dist/coValues/construction.js +34 -0
- package/dist/coValues/construction.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +36 -0
- package/dist/coValues/extensions/imageDef.js.map +1 -0
- package/dist/coValues/group/group.js +2 -0
- package/dist/coValues/group/group.js.map +1 -0
- package/dist/coValues/group/groupOf.js +109 -0
- package/dist/coValues/group/groupOf.js.map +1 -0
- package/dist/coValues/resolution.js +66 -0
- package/dist/coValues/resolution.js.map +1 -0
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/refs.js +95 -0
- package/dist/refs.js.map +1 -0
- package/dist/schemaHelpers.js +14 -0
- package/dist/schemaHelpers.js.map +1 -0
- package/dist/subscriptionScope.js +81 -0
- package/dist/subscriptionScope.js.map +1 -0
- package/dist/tests/coList.test.js +207 -0
- package/dist/tests/coList.test.js.map +1 -0
- package/dist/tests/coMap.test.js +238 -0
- package/dist/tests/coMap.test.js.map +1 -0
- package/dist/tests/coStream.test.js +263 -0
- package/dist/tests/coStream.test.js.map +1 -0
- package/dist/tests/types.test.js +33 -0
- package/dist/tests/types.test.js.map +1 -0
- package/package.json +23 -0
- package/src/coValueInterfaces.ts +105 -0
- package/src/coValues/account/account.ts +106 -0
- package/src/coValues/account/accountOf.ts +284 -0
- package/src/coValues/account/migration.ts +12 -0
- package/src/coValues/coList/coList.ts +57 -0
- package/src/coValues/coList/coListOf.ts +377 -0
- package/src/coValues/coList/internalDocs.ts +1 -0
- package/src/coValues/coMap/coMap.ts +110 -0
- package/src/coValues/coMap/coMapOf.ts +451 -0
- package/src/coValues/coMap/internalDocs.ts +1 -0
- package/src/coValues/coStream/coStream.ts +63 -0
- package/src/coValues/coStream/coStreamOf.ts +404 -0
- package/src/coValues/construction.ts +110 -0
- package/src/coValues/extensions/imageDef.ts +51 -0
- package/src/coValues/group/group.ts +27 -0
- package/src/coValues/group/groupOf.ts +183 -0
- package/src/coValues/resolution.ts +111 -0
- package/src/errors.ts +1 -0
- package/src/index.ts +68 -0
- package/src/refs.ts +128 -0
- package/src/schemaHelpers.ts +72 -0
- package/src/subscriptionScope.ts +118 -0
- package/src/tests/coList.test.ts +283 -0
- package/src/tests/coMap.test.ts +357 -0
- package/src/tests/coStream.test.ts +415 -0
- package/src/tests/types.test.ts +37 -0
- package/tsconfig.json +15 -0
@@ -0,0 +1,262 @@
|
|
1
|
+
import { isCoValueSchema, isCoValue, inspect, } from "../../coValueInterfaces.js";
|
2
|
+
import { ValueRef, makeRefs } from "../../refs.js";
|
3
|
+
import { RawAccount, cojsonInternals } from "cojson";
|
4
|
+
import { Account, controlledAccountFromNode } from "../account/accountOf.js";
|
5
|
+
import { subscriptionsScopes } from "../../subscriptionScope.js";
|
6
|
+
import { AST, Schema } from "@effect/schema";
|
7
|
+
import { constructorOfSchemaSym, propertyIsCoValueSchema, } from "../resolution.js";
|
8
|
+
import { SharedCoValueConstructor } from "../construction.js";
|
9
|
+
import { propSigToSchema, } from "../../schemaHelpers.js";
|
10
|
+
import { pipeArguments } from "effect/Pipeable";
|
11
|
+
import { Group } from "../group/groupOf.js";
|
12
|
+
export function CoMapOf(fields, indexSignature) {
|
13
|
+
class CoMapOfFields extends SharedCoValueConstructor {
|
14
|
+
static get ast() {
|
15
|
+
return AST.setAnnotation(Schema.instanceOf(this).ast, constructorOfSchemaSym, this);
|
16
|
+
}
|
17
|
+
static pipe() {
|
18
|
+
// eslint-disable-next-line prefer-rest-params
|
19
|
+
return pipeArguments(this, arguments);
|
20
|
+
}
|
21
|
+
constructor(init, options) {
|
22
|
+
super();
|
23
|
+
let raw;
|
24
|
+
if ("fromRaw" in options) {
|
25
|
+
raw = options.fromRaw;
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
const rawOwner = options.owner._raw;
|
29
|
+
const rawInit = {};
|
30
|
+
if (init)
|
31
|
+
for (const key of Object.keys(init)) {
|
32
|
+
const initValue = init[key];
|
33
|
+
const field = fields[key] ||
|
34
|
+
(indexSignature &&
|
35
|
+
Schema.is(indexSignature.key)(key) &&
|
36
|
+
indexSignature.value);
|
37
|
+
if (!field) {
|
38
|
+
throw new Error(`Key ${String(key)} not in schema`);
|
39
|
+
}
|
40
|
+
if (propertyIsCoValueSchema(field)) {
|
41
|
+
// TOOD: check for alignment of actual value with schema
|
42
|
+
if (isCoValue(initValue)) {
|
43
|
+
rawInit[key] = initValue.id;
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
throw new Error(`Expected covalue in ${String(key)} but got ${initValue}`);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
const fieldSchema = ("propertySignatureAST" in field
|
51
|
+
? Schema.make(field.propertySignatureAST.from)
|
52
|
+
: field);
|
53
|
+
rawInit[key] =
|
54
|
+
Schema.encodeSync(fieldSchema)(initValue);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
raw = rawOwner.createMap(rawInit);
|
58
|
+
}
|
59
|
+
for (const key of Object.keys(fields)) {
|
60
|
+
if (typeof key !== "string")
|
61
|
+
continue;
|
62
|
+
const fieldSchema = fields[key];
|
63
|
+
if (propertyIsCoValueSchema(fieldSchema)) {
|
64
|
+
Object.defineProperty(this, key, {
|
65
|
+
get() {
|
66
|
+
return this.getCoValueAtKey(key);
|
67
|
+
},
|
68
|
+
set(value) {
|
69
|
+
this.setCoValueAtKey(key, value);
|
70
|
+
},
|
71
|
+
enumerable: true,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
Object.defineProperty(this, key, {
|
76
|
+
get() {
|
77
|
+
return this.getPrimitiveAtKey(key, fieldSchema);
|
78
|
+
},
|
79
|
+
set(value) {
|
80
|
+
this.setPrimitiveAtKey(key, value, fieldSchema);
|
81
|
+
},
|
82
|
+
enumerable: true,
|
83
|
+
});
|
84
|
+
}
|
85
|
+
}
|
86
|
+
const fieldsThatAreRefs = Object.entries(fields)
|
87
|
+
.filter(([_, value]) => isCoValueSchema(value))
|
88
|
+
.map(([key]) => key);
|
89
|
+
const refs = makeRefs((key) => {
|
90
|
+
return raw.get(key);
|
91
|
+
}, () => {
|
92
|
+
if (indexSignature) {
|
93
|
+
return raw
|
94
|
+
.keys()
|
95
|
+
.filter((key) => fieldsThatAreRefs.includes(key) ||
|
96
|
+
Schema.is(indexSignature.key)(key));
|
97
|
+
}
|
98
|
+
else {
|
99
|
+
return fieldsThatAreRefs;
|
100
|
+
}
|
101
|
+
}, controlledAccountFromNode(raw.core.node), (key) => fields[key] ||
|
102
|
+
(indexSignature
|
103
|
+
? indexSignature.value
|
104
|
+
: (() => {
|
105
|
+
throw new Error("Expected " + String(key) + " to be valid");
|
106
|
+
})()));
|
107
|
+
const getEdits = () => new Proxy(this, {
|
108
|
+
get(target, key, receiver) {
|
109
|
+
const schemaAtKey = fields[key] ||
|
110
|
+
(indexSignature &&
|
111
|
+
Schema.is(indexSignature?.key)(key)
|
112
|
+
? indexSignature?.value
|
113
|
+
: undefined);
|
114
|
+
if (!schemaAtKey)
|
115
|
+
return Reflect.get(target, key, receiver);
|
116
|
+
const rawEdit = raw.lastEditAt(key);
|
117
|
+
if (!rawEdit)
|
118
|
+
return undefined;
|
119
|
+
return {
|
120
|
+
get value() {
|
121
|
+
if (isCoValueSchema(schemaAtKey)) {
|
122
|
+
return this.ref?.accessFrom(target);
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
return (rawEdit?.value &&
|
126
|
+
Schema.decodeSync(propSigToSchema(schemaAtKey))(rawEdit?.value));
|
127
|
+
}
|
128
|
+
},
|
129
|
+
get ref() {
|
130
|
+
if (isCoValueSchema(schemaAtKey)) {
|
131
|
+
return (rawEdit?.value &&
|
132
|
+
new ValueRef(rawEdit?.value, target._loadedAs, schemaAtKey));
|
133
|
+
}
|
134
|
+
},
|
135
|
+
get by() {
|
136
|
+
if (cojsonInternals.isAccountID(rawEdit.by)) {
|
137
|
+
return new ValueRef(rawEdit.by, target._loadedAs, Account).accessFrom(target);
|
138
|
+
}
|
139
|
+
},
|
140
|
+
madeAt: rawEdit.at,
|
141
|
+
tx: rawEdit.tx,
|
142
|
+
};
|
143
|
+
},
|
144
|
+
});
|
145
|
+
Object.defineProperties(this, {
|
146
|
+
id: {
|
147
|
+
value: raw.id,
|
148
|
+
enumerable: false,
|
149
|
+
},
|
150
|
+
_type: { value: "CoMap", enumerable: false },
|
151
|
+
_owner: {
|
152
|
+
get: () => raw.group instanceof RawAccount
|
153
|
+
? Account.fromRaw(raw.group)
|
154
|
+
: Group.fromRaw(raw.group),
|
155
|
+
enumerable: false,
|
156
|
+
},
|
157
|
+
_refs: { value: refs, enumerable: false },
|
158
|
+
_edits: { get: getEdits, enumerable: false },
|
159
|
+
_raw: { value: raw, enumerable: false },
|
160
|
+
_loadedAs: {
|
161
|
+
get: () => controlledAccountFromNode(raw.core.node),
|
162
|
+
enumerable: false,
|
163
|
+
},
|
164
|
+
_schema: {
|
165
|
+
value: this.constructor,
|
166
|
+
enumerable: false,
|
167
|
+
},
|
168
|
+
});
|
169
|
+
if (indexSignature) {
|
170
|
+
return new Proxy(this, {
|
171
|
+
get(target, key) {
|
172
|
+
if (key in target) {
|
173
|
+
return Reflect.get(target, key);
|
174
|
+
}
|
175
|
+
else {
|
176
|
+
if (Schema.is(indexSignature.key)(key)) {
|
177
|
+
if (propertyIsCoValueSchema(indexSignature.value)) {
|
178
|
+
return target.getCoValueAtKey(key);
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
return target.getPrimitiveAtKey(key, indexSignature.value);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
else {
|
185
|
+
throw new Error("No such key " + String(key) + " in CoMap");
|
186
|
+
}
|
187
|
+
}
|
188
|
+
},
|
189
|
+
set(target, key, value) {
|
190
|
+
if (key in target) {
|
191
|
+
return Reflect.set(target, key, value);
|
192
|
+
}
|
193
|
+
else if (Schema.is(indexSignature.key)(key)) {
|
194
|
+
if (propertyIsCoValueSchema(indexSignature.value)) {
|
195
|
+
target.setCoValueAtKey(key, value);
|
196
|
+
}
|
197
|
+
else {
|
198
|
+
target.setPrimitiveAtKey(key, value, indexSignature.value);
|
199
|
+
}
|
200
|
+
return true;
|
201
|
+
}
|
202
|
+
else {
|
203
|
+
throw new Error("No such key " + String(key) + " in CoMap");
|
204
|
+
}
|
205
|
+
},
|
206
|
+
ownKeys(target) {
|
207
|
+
const keys = Reflect.ownKeys(target);
|
208
|
+
for (const key of target._raw.keys()) {
|
209
|
+
if (!keys.includes(key)) {
|
210
|
+
if (Schema.is(indexSignature.key)(key)) {
|
211
|
+
keys.push(key);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
return keys;
|
216
|
+
},
|
217
|
+
getOwnPropertyDescriptor(target, key) {
|
218
|
+
if (key in target) {
|
219
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
220
|
+
}
|
221
|
+
else if (Schema.is(indexSignature.key)(key)) {
|
222
|
+
return {
|
223
|
+
enumerable: true,
|
224
|
+
configurable: true,
|
225
|
+
};
|
226
|
+
}
|
227
|
+
},
|
228
|
+
});
|
229
|
+
}
|
230
|
+
}
|
231
|
+
static fromRaw(raw) {
|
232
|
+
return new CoMapOfFields(undefined, { fromRaw: raw });
|
233
|
+
}
|
234
|
+
getCoValueAtKey(key) {
|
235
|
+
return this._refs[key]?.accessFrom(this);
|
236
|
+
}
|
237
|
+
setCoValueAtKey(key, value) {
|
238
|
+
this._raw.set(key, value.id);
|
239
|
+
subscriptionsScopes.get(this)?.onRefAccessedOrSet(value.id);
|
240
|
+
}
|
241
|
+
getPrimitiveAtKey(key, schemaAtKey) {
|
242
|
+
return Schema.decodeSync(propSigToSchema(schemaAtKey))(this._raw.get(key));
|
243
|
+
}
|
244
|
+
setPrimitiveAtKey(key, value, schemaAtKey) {
|
245
|
+
this._raw.set(key, Schema.encodeSync(propSigToSchema(schemaAtKey))(value));
|
246
|
+
}
|
247
|
+
toJSON() {
|
248
|
+
return Object.fromEntries(Object.entries(this).flatMap(([key, value]) => typeof value === "object" && "toJSON" in value
|
249
|
+
? [[key, value?.toJSON()]]
|
250
|
+
: [[key, value]]));
|
251
|
+
}
|
252
|
+
[(Schema.TypeId, inspect)]() {
|
253
|
+
return this.toJSON();
|
254
|
+
}
|
255
|
+
static as() {
|
256
|
+
return CoMapOfFields;
|
257
|
+
}
|
258
|
+
}
|
259
|
+
CoMapOfFields.type = "CoMap";
|
260
|
+
return CoMapOfFields;
|
261
|
+
}
|
262
|
+
//# sourceMappingURL=coMapOf.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coMapOf.js","sourceRoot":"","sources":["../../../src/coValues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CACT,GAAG,EACH,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAEtC,CAClB,CAAC;QACN,CAAC;QAED,MAAM;YACF,OAAO,MAAM,CAAC,WAAW,CACrB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC1C,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK;gBAC1C,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;gBAC1B,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CACvB,CACJ,CAAC;QACN,CAAC;QAED,EA9XQ,MAAM,CAAC,MAAM,EA8XpB,OAAO,EAAC;YACL,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;QAED,MAAM,CAAC,EAAE;YACL,OAAO,aAIN,CAAC;QACN,CAAC;;IA/XM,kBAAI,GAAG,OAAgB,CAAC;IAkYnC,OAAO,aAEN,CAAC;AACN,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"internalDocs.js","sourceRoot":"","sources":["../../../src/coValues/coMap/internalDocs.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coStream.js","sourceRoot":"","sources":["../../../src/coValues/coStream/coStream.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,244 @@
|
|
1
|
+
var _a;
|
2
|
+
import { RawAccount, cojsonInternals, } from "cojson";
|
3
|
+
import { inspect, } from "../../coValueInterfaces.js";
|
4
|
+
import { SharedCoValueConstructor } from "../construction.js";
|
5
|
+
import { AST, Schema } from "@effect/schema";
|
6
|
+
import { constructorOfSchemaSym, propertyIsCoValueSchema, } from "../resolution.js";
|
7
|
+
import { pipeArguments } from "effect/Pipeable";
|
8
|
+
import { ValueRef } from "../../refs.js";
|
9
|
+
import { Account, controlledAccountFromNode } from "../account/accountOf.js";
|
10
|
+
import { Group } from "../group/groupOf.js";
|
11
|
+
export function CoStreamOf(itemSchema) {
|
12
|
+
const decodeItem = Schema.decodeSync(itemSchema);
|
13
|
+
const encodeItem = Schema.encodeSync(itemSchema);
|
14
|
+
const itemIsCoValue = propertyIsCoValueSchema(itemSchema);
|
15
|
+
class CoStreamOfItem extends SharedCoValueConstructor {
|
16
|
+
static get ast() {
|
17
|
+
return AST.setAnnotation(Schema.instanceOf(this).ast, constructorOfSchemaSym, this);
|
18
|
+
}
|
19
|
+
static pipe() {
|
20
|
+
// eslint-disable-next-line prefer-rest-params
|
21
|
+
return pipeArguments(this, arguments);
|
22
|
+
}
|
23
|
+
constructor(init, options) {
|
24
|
+
super();
|
25
|
+
let raw;
|
26
|
+
if ("fromRaw" in options) {
|
27
|
+
raw = options.fromRaw;
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
const rawOwner = options.owner._raw;
|
31
|
+
raw = rawOwner.createStream();
|
32
|
+
}
|
33
|
+
this.by = {};
|
34
|
+
this.in = {};
|
35
|
+
Object.defineProperties(this, {
|
36
|
+
id: { value: raw.id, enumerable: false },
|
37
|
+
_type: { value: "CoStream", enumerable: false },
|
38
|
+
_owner: {
|
39
|
+
get: () => raw.group instanceof RawAccount
|
40
|
+
? Account.fromRaw(raw.group)
|
41
|
+
: Group.fromRaw(raw.group),
|
42
|
+
enumerable: false,
|
43
|
+
},
|
44
|
+
_raw: { value: raw, enumerable: false },
|
45
|
+
_loadedAs: {
|
46
|
+
get: () => controlledAccountFromNode(raw.core.node),
|
47
|
+
enumerable: false,
|
48
|
+
},
|
49
|
+
_schema: { value: this.constructor, enumerable: false },
|
50
|
+
});
|
51
|
+
if (init !== undefined) {
|
52
|
+
for (const item of init) {
|
53
|
+
this.pushItem(item);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
this.updateEntries();
|
57
|
+
}
|
58
|
+
updateEntries() {
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
60
|
+
const self = this;
|
61
|
+
const raw = this._raw;
|
62
|
+
const loadedAs = this._loadedAs;
|
63
|
+
for (const accountID of this._raw.accounts()) {
|
64
|
+
Object.defineProperty(this.by, accountID, {
|
65
|
+
get() {
|
66
|
+
const rawEntry = raw.lastItemBy(accountID);
|
67
|
+
if (!rawEntry)
|
68
|
+
return;
|
69
|
+
return entryFromRawEntry(self, rawEntry, loadedAs, accountID);
|
70
|
+
},
|
71
|
+
configurable: true,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
Object.defineProperty(this.by, "me", {
|
75
|
+
get() {
|
76
|
+
return self.by[loadedAs.id];
|
77
|
+
},
|
78
|
+
enumerable: false,
|
79
|
+
configurable: true,
|
80
|
+
});
|
81
|
+
for (const sessionID of raw.sessions()) {
|
82
|
+
Object.defineProperty(this.in, sessionID, {
|
83
|
+
get() {
|
84
|
+
const rawEntry = raw.lastItemIn(sessionID);
|
85
|
+
if (!rawEntry)
|
86
|
+
return;
|
87
|
+
const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
|
88
|
+
return entryFromRawEntry(self, rawEntry, loadedAs, cojsonInternals.isAccountID(by)
|
89
|
+
? by
|
90
|
+
: undefined);
|
91
|
+
},
|
92
|
+
configurable: true,
|
93
|
+
});
|
94
|
+
}
|
95
|
+
Object.defineProperty(this.in, "currentSession", {
|
96
|
+
get() {
|
97
|
+
return self.in[loadedAs.sessionID];
|
98
|
+
},
|
99
|
+
enumerable: false,
|
100
|
+
configurable: true,
|
101
|
+
});
|
102
|
+
}
|
103
|
+
static fromRaw(raw) {
|
104
|
+
return new CoStreamOfItem(undefined, { fromRaw: raw });
|
105
|
+
}
|
106
|
+
push(...items) {
|
107
|
+
for (const item of items) {
|
108
|
+
this.pushItem(item);
|
109
|
+
}
|
110
|
+
this.updateEntries();
|
111
|
+
}
|
112
|
+
pushItem(item) {
|
113
|
+
if (itemIsCoValue) {
|
114
|
+
this._raw.push(item.id);
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
this._raw.push(encodeItem(item));
|
118
|
+
}
|
119
|
+
}
|
120
|
+
toJSON() {
|
121
|
+
return {
|
122
|
+
by: Object.fromEntries(Object.entries(this.by).map(([key, value]) => [
|
123
|
+
key,
|
124
|
+
value &&
|
125
|
+
typeof value === "object" &&
|
126
|
+
"toJSON" in value &&
|
127
|
+
typeof value.toJSON === "function"
|
128
|
+
? value.toJSON()
|
129
|
+
: value,
|
130
|
+
])),
|
131
|
+
in: Object.fromEntries(Object.entries(this.in).map(([key, value]) => [
|
132
|
+
key,
|
133
|
+
value &&
|
134
|
+
typeof value === "object" &&
|
135
|
+
"toJSON" in value &&
|
136
|
+
typeof value.toJSON === "function"
|
137
|
+
? value.toJSON()
|
138
|
+
: value,
|
139
|
+
])),
|
140
|
+
co: {
|
141
|
+
id: this.id,
|
142
|
+
type: "CoStream",
|
143
|
+
},
|
144
|
+
};
|
145
|
+
}
|
146
|
+
[(Schema.TypeId, inspect)]() {
|
147
|
+
return this.toJSON();
|
148
|
+
}
|
149
|
+
static as() {
|
150
|
+
return CoStreamOfItem;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
CoStreamOfItem.type = "CoStream";
|
154
|
+
return CoStreamOfItem;
|
155
|
+
function entryFromRawEntry(accessFrom, rawEntry, loadedAs, accountID) {
|
156
|
+
return {
|
157
|
+
get value() {
|
158
|
+
if (itemIsCoValue) {
|
159
|
+
return this.ref?.accessFrom(accessFrom);
|
160
|
+
}
|
161
|
+
else {
|
162
|
+
return decodeItem(rawEntry.value);
|
163
|
+
}
|
164
|
+
},
|
165
|
+
get ref() {
|
166
|
+
if (itemIsCoValue) {
|
167
|
+
const rawId = rawEntry.value;
|
168
|
+
return new ValueRef(rawId, loadedAs, itemSchema);
|
169
|
+
}
|
170
|
+
},
|
171
|
+
get by() {
|
172
|
+
return (accountID &&
|
173
|
+
new ValueRef(accountID, loadedAs, Account)?.accessFrom(accessFrom));
|
174
|
+
},
|
175
|
+
madeAt: rawEntry.at,
|
176
|
+
tx: rawEntry.tx,
|
177
|
+
};
|
178
|
+
}
|
179
|
+
}
|
180
|
+
class BinaryCoStreamImplClass extends SharedCoValueConstructor {
|
181
|
+
static pipe() {
|
182
|
+
// eslint-disable-next-line prefer-rest-params
|
183
|
+
return pipeArguments(this, arguments);
|
184
|
+
}
|
185
|
+
constructor(init, options) {
|
186
|
+
super();
|
187
|
+
let raw;
|
188
|
+
if ("fromRaw" in options) {
|
189
|
+
raw = options.fromRaw;
|
190
|
+
}
|
191
|
+
else {
|
192
|
+
const rawOwner = options.owner._raw;
|
193
|
+
raw = rawOwner.createBinaryStream();
|
194
|
+
}
|
195
|
+
Object.defineProperties(this, {
|
196
|
+
id: { value: raw.id, enumerable: false },
|
197
|
+
_type: { value: "BinaryCoStream", enumerable: false },
|
198
|
+
_owner: {
|
199
|
+
get: () => raw.group instanceof RawAccount
|
200
|
+
? Account.fromRaw(raw.group)
|
201
|
+
: Group.fromRaw(raw.group),
|
202
|
+
enumerable: false,
|
203
|
+
},
|
204
|
+
_raw: { value: raw, enumerable: false },
|
205
|
+
_loadedAs: {
|
206
|
+
get: () => controlledAccountFromNode(raw.core.node),
|
207
|
+
enumerable: false,
|
208
|
+
},
|
209
|
+
_schema: { value: this.constructor, enumerable: false },
|
210
|
+
});
|
211
|
+
}
|
212
|
+
static fromRaw(raw) {
|
213
|
+
return new _a(undefined, { fromRaw: raw });
|
214
|
+
}
|
215
|
+
getChunks(options) {
|
216
|
+
return this._raw.getBinaryChunks(options?.allowUnfinished);
|
217
|
+
}
|
218
|
+
start(options) {
|
219
|
+
this._raw.startBinaryStream(options);
|
220
|
+
}
|
221
|
+
push(data) {
|
222
|
+
this._raw.pushBinaryStreamChunk(data);
|
223
|
+
}
|
224
|
+
end() {
|
225
|
+
this._raw.endBinaryStream();
|
226
|
+
}
|
227
|
+
toJSON() {
|
228
|
+
return {
|
229
|
+
...this.getChunks(),
|
230
|
+
co: {
|
231
|
+
id: this.id,
|
232
|
+
type: "BinaryCoStream",
|
233
|
+
},
|
234
|
+
};
|
235
|
+
}
|
236
|
+
[(Schema.TypeId, inspect)]() {
|
237
|
+
return this.toJSON();
|
238
|
+
}
|
239
|
+
}
|
240
|
+
_a = BinaryCoStreamImplClass;
|
241
|
+
BinaryCoStreamImplClass.ast = AST.setAnnotation(Schema.instanceOf(_a).ast, constructorOfSchemaSym, _a);
|
242
|
+
BinaryCoStreamImplClass.type = "BinaryCoStream";
|
243
|
+
export const BinaryCoStreamImpl = BinaryCoStreamImplClass;
|
244
|
+
//# sourceMappingURL=coStreamOf.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coStreamOf.js","sourceRoot":"","sources":["../../../src/coValues/coStream/coStreamOf.ts"],"names":[],"mappings":";AAAA,OAAO,EAMH,UAAU,EAIV,eAAe,GAClB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAIH,OAAO,GACV,MAAM,4BAA4B,CAAC;AASpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACH,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,UAAU,UAAU,CAExB,UAAgB;IACd,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,uBAAuB,CAAC,UAAU,CAA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B,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,GAAG;QACC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;QACF,OAAO;YACH,GAAG,IAAI,CAAC,SAAS,EAAE;YACnB,EAAE,EAAE;gBACA,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,gBAAgB;aACzB;SACJ,CAAC;IACN,CAAC;IAED,EA7FQ,MAAM,CAAC,MAAM,EA6FpB,OAAO,EAAC;QACL,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;;;AApGM,2BAAG,GAAG,GAAG,CAAC,aAAa,CAC1B,MAAM,CAAC,UAAU,CAAC,EAAI,CAAC,CAAC,GAAG,EAC3B,sBAAsB,EACtB,EAAI,CACP,AAJS,CAIR;AAUK,4BAAI,GAAG,gBAAyB,AAA5B,CAA6B;AAyF5C,MAAM,CAAC,MAAM,kBAAkB,GAC3B,uBAA+C,CAAC"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { Effect, Sink, Stream } from "effect";
|
2
|
+
import { ControlledAccountCtx } from "./account/account.js";
|
3
|
+
import { ValueRef } from "../refs.js";
|
4
|
+
import { SubscriptionScope } from "../subscriptionScope.js";
|
5
|
+
export class SharedCoValueConstructor {
|
6
|
+
static loadEf(id) {
|
7
|
+
return Effect.gen(this, function* (_) {
|
8
|
+
const controlledAccount = yield* _(ControlledAccountCtx);
|
9
|
+
return yield* _(new ValueRef(id, controlledAccount, this).loadEf());
|
10
|
+
});
|
11
|
+
}
|
12
|
+
static load(id, options) {
|
13
|
+
return new ValueRef(id, options.as, this).load(options?.onProgress && { onProgress: options.onProgress });
|
14
|
+
}
|
15
|
+
static subscribe(id, options, onUpdate) {
|
16
|
+
void Effect.runPromise(Effect.provideService(this.subscribeEf(id).pipe(Stream.run(Sink.forEach((update) => Effect.sync(() => onUpdate(update))))), ControlledAccountCtx, options.as));
|
17
|
+
return function unsubscribe() { };
|
18
|
+
}
|
19
|
+
static subscribeEf(id) {
|
20
|
+
return Stream.fromEffect(this.loadEf(id)).pipe(Stream.flatMap((value) => Stream.asyncScoped((emit) => Effect.gen(this, function* (_) {
|
21
|
+
const subscription = new SubscriptionScope(value, this, (update) => {
|
22
|
+
void emit.single(update);
|
23
|
+
});
|
24
|
+
yield* _(Effect.addFinalizer(() => Effect.sync(() => subscription.unsubscribeAll())));
|
25
|
+
}))));
|
26
|
+
}
|
27
|
+
subscribe(listener) {
|
28
|
+
return this._schema.subscribe(this.id, { as: this._loadedAs }, listener);
|
29
|
+
}
|
30
|
+
subscribeEf() {
|
31
|
+
return Stream.provideService(this._schema.subscribeEf(this.id), ControlledAccountCtx, this._loadedAs);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
//# sourceMappingURL=construction.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"construction.js","sourceRoot":"","sources":["../../src/coValues/construction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQ9C,OAAO,EAAqB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,OAAgB,wBAAwB;IAK1C,MAAM,CAAC,MAAM,CAET,EAAS;QAET,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;YAChC,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC,CAAC,CAAC,CACX,IAAI,QAAQ,CAAC,EAAW,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAC9D,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,I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AAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC,CACnD,CACJ,CAAC;QACN,CAAC,CAAC,CACL,CACJ,CACJ,CAAC;IACN,CAAC;IAED,SAAS,CAAC,QAAgC;QACtC,OAAQ,IAAI,CAAC,OAAoC,CAAC,SAAS,CACvD,IAAI,CAAC,EAA4B,EACjC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,EACtB,QAAgD,CACnD,CAAC;IACN,CAAC;IAED,WAAW;QACP,OAAO,MAAM,CAAC,cAAc,CACvB,IAAI,CAAC,OAAoC,CAAC,WAAW,CAClD,IAAI,CAAC,EAA4B,CACpC,EACD,oBAAoB,EACpB,IAAI,CAAC,SAAS,CAC2C,CAAC;IAClE,CAAC;CACJ"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import * as S from "@effect/schema/Schema";
|
2
|
+
import { CoMapOf } from "../coMap/coMapOf.js";
|
3
|
+
import { BinaryCoStreamImpl } from "../coStream/coStreamOf.js";
|
4
|
+
import { subscriptionsScopes } from "../../subscriptionScope.js";
|
5
|
+
export class ImageDefinition extends CoMapOf({
|
6
|
+
originalSize: S.tuple(S.number, S.number),
|
7
|
+
placeholderDataURL: S.optional(S.string),
|
8
|
+
}, {
|
9
|
+
key: S.templateLiteral(S.string, S.literal("x"), S.string),
|
10
|
+
value: BinaryCoStreamImpl,
|
11
|
+
}).as() {
|
12
|
+
get highestResAvailable() {
|
13
|
+
if (!subscriptionsScopes.get(this)) {
|
14
|
+
console.warn("highestResAvailable() only makes sense when used within a subscription.");
|
15
|
+
}
|
16
|
+
const resolutions = Object.keys(this).filter((key) => key.match(/^\d+x\d+$/));
|
17
|
+
resolutions.sort((a, b) => {
|
18
|
+
const aWidth = Number(a.split("x")[0]);
|
19
|
+
const bWidth = Number(b.split("x")[0]);
|
20
|
+
return aWidth - bWidth;
|
21
|
+
});
|
22
|
+
let highestAvailableResolution;
|
23
|
+
for (const resolution of resolutions) {
|
24
|
+
if (this[resolution] && this[resolution]?.getChunks()) {
|
25
|
+
highestAvailableResolution = resolution;
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
return (highestAvailableResolution && {
|
29
|
+
res: highestAvailableResolution,
|
30
|
+
stream: this[highestAvailableResolution],
|
31
|
+
});
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
//# sourceMappingURL=imageDef.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"imageDef.js","sourceRoot":"","sources":["../../../src/coValues/extensions/imageDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,OAAO,eAAgB,SAAQ,OAAO,CACxC;IACI,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;IACzC,kBAAkB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;CAC3C,EACD;IACI,GAAG,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;IAC1D,KAAK,EAAE,kBAAkB;CAC5B,CACJ,CAAC,EAAE,EAAmB;IACnB,IAAI,mBAAmB;QAGnB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CACR,yEAAyE,CAC5E,CAAC;QACN,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CACjD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