atom.io 0.14.4 → 0.14.6
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.
- package/data/dist/index.cjs +47 -1416
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +16 -317
- package/data/dist/index.d.ts +16 -317
- package/data/dist/index.js +4 -6
- package/data/dist/index.js.map +1 -1
- package/dist/chunk-NYTGCPHB.js +261 -0
- package/dist/chunk-NYTGCPHB.js.map +1 -0
- package/dist/chunk-PZLG2HP3.js +36 -0
- package/dist/chunk-PZLG2HP3.js.map +1 -0
- package/dist/chunk-XACXFU3B.js +46 -0
- package/dist/chunk-XACXFU3B.js.map +1 -0
- package/dist/index.cjs +55 -2330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -269
- package/dist/index.d.ts +21 -269
- package/dist/index.js +152 -1
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/internal/dist/index.cjs +30 -159
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +28 -229
- package/internal/dist/index.d.ts +28 -229
- package/internal/dist/index.js +2027 -1
- package/internal/dist/index.js.map +1 -1
- package/introspection/dist/index.cjs +45 -1565
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +4 -376
- package/introspection/dist/index.d.ts +4 -376
- package/introspection/dist/index.js +298 -2
- package/introspection/dist/index.js.map +1 -1
- package/json/dist/index.cjs +5 -1502
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +7 -373
- package/json/dist/index.d.ts +7 -373
- package/json/dist/index.js +37 -1
- package/json/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/react/dist/index.cjs +14 -1549
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +4 -377
- package/react/dist/index.d.ts +4 -377
- package/react/dist/index.js +62 -2
- package/react/dist/index.js.map +1 -1
- package/react-devtools/dist/index.cjs +135 -2153
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.cts +24 -149
- package/react-devtools/dist/index.d.ts +24 -149
- package/react-devtools/dist/index.js +5 -3
- package/react-devtools/dist/index.js.map +1 -1
- package/realtime-client/dist/index.cjs +34 -1529
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +12 -384
- package/realtime-client/dist/index.d.ts +12 -384
- package/realtime-client/dist/index.js +165 -2
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-react/dist/index.cjs +35 -1727
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +9 -49
- package/realtime-react/dist/index.d.ts +9 -49
- package/realtime-react/dist/index.js +66 -4
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-server/dist/index.cjs +57 -1548
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +11 -394
- package/realtime-server/dist/index.d.ts +11 -394
- package/realtime-server/dist/index.js +21 -27
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-testing/dist/index.cjs +15 -2376
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +3 -489
- package/realtime-testing/dist/index.d.ts +3 -489
- package/realtime-testing/dist/index.js +10 -9
- package/realtime-testing/dist/index.js.map +1 -1
- package/transceivers/set-rtx/dist/index.cjs +9 -31
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +3 -29
- package/transceivers/set-rtx/dist/index.d.ts +3 -29
- package/transceivers/set-rtx/dist/index.js +3 -2
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/dist/chunk-GMN5KH6A.js +0 -309
- package/dist/chunk-GMN5KH6A.js.map +0 -1
- package/dist/chunk-HQWWV67P.js +0 -62
- package/dist/chunk-HQWWV67P.js.map +0 -1
- package/dist/chunk-MK4OJD24.js +0 -67
- package/dist/chunk-MK4OJD24.js.map +0 -1
- package/dist/chunk-N7ADBQJG.js +0 -176
- package/dist/chunk-N7ADBQJG.js.map +0 -1
- package/dist/chunk-PURABO5G.js +0 -2581
- package/dist/chunk-PURABO5G.js.map +0 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// ../rel8/junction/src/junction.ts
|
|
2
|
+
var Junction = class {
|
|
3
|
+
constructor(data, config) {
|
|
4
|
+
this.relations = /* @__PURE__ */ new Map();
|
|
5
|
+
this.contents = /* @__PURE__ */ new Map();
|
|
6
|
+
this.makeContentKey = (a, b) => `${a}:${b}`;
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
this.a = data.between[0];
|
|
9
|
+
this.b = data.between[1];
|
|
10
|
+
this.cardinality = data.cardinality;
|
|
11
|
+
if (!(config == null ? void 0 : config.externalStore)) {
|
|
12
|
+
this.relations = new Map((_a = data.relations) == null ? void 0 : _a.map(([a, b]) => [a, new Set(b)]));
|
|
13
|
+
this.contents = new Map(data.contents);
|
|
14
|
+
}
|
|
15
|
+
this.isContent = (_b = config == null ? void 0 : config.isContent) != null ? _b : null;
|
|
16
|
+
if (config == null ? void 0 : config.makeContentKey) {
|
|
17
|
+
this.makeContentKey = config.makeContentKey;
|
|
18
|
+
}
|
|
19
|
+
if (config == null ? void 0 : config.externalStore) {
|
|
20
|
+
const externalStore = config.externalStore;
|
|
21
|
+
this.has = (a, b) => externalStore.has(a, b);
|
|
22
|
+
this.addRelation = (a, b) => {
|
|
23
|
+
externalStore.addRelation(a, b);
|
|
24
|
+
};
|
|
25
|
+
this.deleteRelation = (a, b) => {
|
|
26
|
+
externalStore.deleteRelation(a, b);
|
|
27
|
+
};
|
|
28
|
+
this.replaceRelationsSafely = (a, bs) => {
|
|
29
|
+
externalStore.replaceRelationsSafely(a, bs);
|
|
30
|
+
};
|
|
31
|
+
this.replaceRelationsUnsafely = (a, bs) => {
|
|
32
|
+
externalStore.replaceRelationsUnsafely(a, bs);
|
|
33
|
+
};
|
|
34
|
+
this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
|
|
35
|
+
if (externalStore.getContent) {
|
|
36
|
+
this.getContentInternal = (contentKey) => {
|
|
37
|
+
return externalStore.getContent(contentKey);
|
|
38
|
+
};
|
|
39
|
+
this.setContent = (contentKey, content) => {
|
|
40
|
+
externalStore.setContent(contentKey, content);
|
|
41
|
+
};
|
|
42
|
+
this.deleteContent = (contentKey) => {
|
|
43
|
+
externalStore.deleteContent(contentKey);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
for (const [x, ys] of (_c = data.relations) != null ? _c : []) {
|
|
47
|
+
for (const y of ys)
|
|
48
|
+
this.addRelation(x, y);
|
|
49
|
+
}
|
|
50
|
+
for (const [contentKey, content] of (_d = data.contents) != null ? _d : []) {
|
|
51
|
+
this.setContent(contentKey, content);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
getRelatedKeys(key) {
|
|
56
|
+
return this.relations.get(key);
|
|
57
|
+
}
|
|
58
|
+
addRelation(a, b) {
|
|
59
|
+
let aRelations = this.relations.get(a);
|
|
60
|
+
let bRelations = this.relations.get(b);
|
|
61
|
+
if (aRelations) {
|
|
62
|
+
aRelations.add(b);
|
|
63
|
+
} else {
|
|
64
|
+
aRelations = /* @__PURE__ */ new Set([b]);
|
|
65
|
+
this.relations.set(a, aRelations);
|
|
66
|
+
}
|
|
67
|
+
if (bRelations) {
|
|
68
|
+
bRelations.add(a);
|
|
69
|
+
} else {
|
|
70
|
+
bRelations = /* @__PURE__ */ new Set([a]);
|
|
71
|
+
this.relations.set(b, bRelations);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
deleteRelation(a, b) {
|
|
75
|
+
const aRelations = this.relations.get(a);
|
|
76
|
+
if (aRelations) {
|
|
77
|
+
aRelations.delete(b);
|
|
78
|
+
if (aRelations.size === 0) {
|
|
79
|
+
this.relations.delete(a);
|
|
80
|
+
}
|
|
81
|
+
const bRelations = this.relations.get(b);
|
|
82
|
+
if (bRelations) {
|
|
83
|
+
bRelations.delete(a);
|
|
84
|
+
if (bRelations.size === 0) {
|
|
85
|
+
this.relations.delete(b);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
replaceRelationsUnsafely(a, bs) {
|
|
91
|
+
this.relations.set(a, new Set(bs));
|
|
92
|
+
for (const b of bs) {
|
|
93
|
+
const bRelations = /* @__PURE__ */ new Set([a]);
|
|
94
|
+
this.relations.set(b, bRelations);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
replaceRelationsSafely(a, bs) {
|
|
98
|
+
const aRelationsPrev = this.relations.get(a);
|
|
99
|
+
if (aRelationsPrev) {
|
|
100
|
+
for (const b of aRelationsPrev) {
|
|
101
|
+
const bRelations = this.relations.get(b);
|
|
102
|
+
if (bRelations) {
|
|
103
|
+
if (bRelations.size === 1) {
|
|
104
|
+
this.relations.delete(b);
|
|
105
|
+
} else {
|
|
106
|
+
bRelations.delete(a);
|
|
107
|
+
}
|
|
108
|
+
this.contents.delete(this.makeContentKey(a, b));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
this.relations.set(a, new Set(bs));
|
|
113
|
+
for (const b of bs) {
|
|
114
|
+
let bRelations = this.relations.get(b);
|
|
115
|
+
if (bRelations) {
|
|
116
|
+
bRelations.add(a);
|
|
117
|
+
} else {
|
|
118
|
+
bRelations = /* @__PURE__ */ new Set([a]);
|
|
119
|
+
this.relations.set(b, bRelations);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
getContentInternal(contentKey) {
|
|
124
|
+
return this.contents.get(contentKey);
|
|
125
|
+
}
|
|
126
|
+
setContent(contentKey, content) {
|
|
127
|
+
this.contents.set(contentKey, content);
|
|
128
|
+
}
|
|
129
|
+
deleteContent(contentKey) {
|
|
130
|
+
this.contents.delete(contentKey);
|
|
131
|
+
}
|
|
132
|
+
toJSON() {
|
|
133
|
+
return {
|
|
134
|
+
between: [this.a, this.b],
|
|
135
|
+
cardinality: this.cardinality,
|
|
136
|
+
relations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),
|
|
137
|
+
contents: [...this.contents.entries()]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
set(a, ...rest) {
|
|
141
|
+
var _a;
|
|
142
|
+
const b = typeof rest[0] === `string` ? rest[0] : a[this.b];
|
|
143
|
+
const content = ((_a = rest[1]) != null ? _a : typeof rest[0] === `string`) ? void 0 : rest[0];
|
|
144
|
+
a = typeof a === `string` ? a : a[this.a];
|
|
145
|
+
switch (this.cardinality) {
|
|
146
|
+
case `1:1`: {
|
|
147
|
+
const bPrev = this.getRelatedKey(a);
|
|
148
|
+
if (bPrev && bPrev !== b)
|
|
149
|
+
this.delete(bPrev, a);
|
|
150
|
+
}
|
|
151
|
+
case `1:n`: {
|
|
152
|
+
const aPrev = this.getRelatedKey(b);
|
|
153
|
+
if (aPrev && aPrev !== a)
|
|
154
|
+
this.delete(aPrev, b);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (content) {
|
|
158
|
+
const contentKey = this.makeContentKey(a, b);
|
|
159
|
+
this.setContent(contentKey, content);
|
|
160
|
+
}
|
|
161
|
+
this.addRelation(a, b);
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
delete(x, b) {
|
|
165
|
+
b = typeof b === `string` ? b : x[this.b];
|
|
166
|
+
const a = typeof x === `string` ? x : x[this.a];
|
|
167
|
+
if (a === void 0 && typeof b === `string`) {
|
|
168
|
+
const bRelations = this.getRelatedKeys(b);
|
|
169
|
+
if (bRelations) {
|
|
170
|
+
for (const a2 of bRelations) {
|
|
171
|
+
this.delete(a2, b);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (typeof a === `string` && b === void 0) {
|
|
176
|
+
const aRelations = this.getRelatedKeys(a);
|
|
177
|
+
if (aRelations) {
|
|
178
|
+
for (const b2 of aRelations) {
|
|
179
|
+
this.delete(a, b2);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (typeof a === `string` && typeof b === `string`) {
|
|
184
|
+
this.deleteRelation(a, b);
|
|
185
|
+
const contentKey = this.makeContentKey(a, b);
|
|
186
|
+
this.deleteContent(contentKey);
|
|
187
|
+
}
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
getRelatedKey(key) {
|
|
191
|
+
const relations = this.getRelatedKeys(key);
|
|
192
|
+
if (relations) {
|
|
193
|
+
if (relations.size > 1) {
|
|
194
|
+
console.warn(
|
|
195
|
+
`${relations.size} related keys were found for key "${key}": (${[
|
|
196
|
+
...relations
|
|
197
|
+
].map((k) => `"${k}"`).join(`, `)}). Only one related key was expected.`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
for (const relation of relations) {
|
|
201
|
+
return relation;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
replaceRelations(a, relations, config) {
|
|
206
|
+
const hasContent = !Array.isArray(relations);
|
|
207
|
+
const bs = hasContent ? Object.keys(relations) : relations;
|
|
208
|
+
if (config == null ? void 0 : config.reckless) {
|
|
209
|
+
this.replaceRelationsUnsafely(a, bs);
|
|
210
|
+
} else {
|
|
211
|
+
this.replaceRelationsSafely(a, bs);
|
|
212
|
+
}
|
|
213
|
+
if (hasContent) {
|
|
214
|
+
for (const b of bs) {
|
|
215
|
+
const contentKey = this.makeContentKey(a, b);
|
|
216
|
+
const content = relations[b];
|
|
217
|
+
this.setContent(contentKey, content);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
getContent(a, b) {
|
|
223
|
+
const contentKey = this.makeContentKey(a, b);
|
|
224
|
+
return this.getContentInternal(contentKey);
|
|
225
|
+
}
|
|
226
|
+
getRelationEntries(input) {
|
|
227
|
+
const a = input[this.a];
|
|
228
|
+
const b = input[this.b];
|
|
229
|
+
if (a !== void 0 && b === void 0) {
|
|
230
|
+
const aRelations = this.getRelatedKeys(a);
|
|
231
|
+
if (aRelations) {
|
|
232
|
+
return [...aRelations].map((b2) => {
|
|
233
|
+
var _a;
|
|
234
|
+
return [b2, (_a = this.getContent(a, b2)) != null ? _a : null];
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (a === void 0 && b !== void 0) {
|
|
239
|
+
const bRelations = this.getRelatedKeys(b);
|
|
240
|
+
if (bRelations) {
|
|
241
|
+
return [...bRelations].map((a2) => {
|
|
242
|
+
var _a;
|
|
243
|
+
return [a2, (_a = this.getContent(a2, b)) != null ? _a : null];
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
has(a, b) {
|
|
250
|
+
var _a;
|
|
251
|
+
if (b) {
|
|
252
|
+
const setA = this.getRelatedKeys(a);
|
|
253
|
+
return (_a = setA == null ? void 0 : setA.has(b)) != null ? _a : false;
|
|
254
|
+
}
|
|
255
|
+
return this.relations.has(a);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export { Junction };
|
|
260
|
+
//# sourceMappingURL=out.js.map
|
|
261
|
+
//# sourceMappingURL=chunk-NYTGCPHB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../rel8/junction/src/junction.ts"],"names":["a","b"],"mappings":";AAoDO,IAAM,WAAN,MAIL;AAAA,EA0FM,YACN,MACA,QACC;AAzFF,SAAgB,YAAY,oBAAI,IAAyB;AACzD,SAAgB,WAAW,oBAAI,IAAqB;AAGpD,SAAO,iBAAiB,CAAC,GAAW,MAAsB,GAAG,CAAC,IAAI,CAAC;AAhEpE;AAsJE,SAAK,IAAI,KAAK,QAAQ,CAAC;AACvB,SAAK,IAAI,KAAK,QAAQ,CAAC;AAEvB,SAAK,cAAc,KAAK;AACxB,QAAI,EAAC,iCAAQ,gBAAe;AA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f,eAAO,CAAC,GAAG,UAAU,EAAE,IAAI,CAACA,OAAM;AAxVtC;AAyVK,iBAAO,CAACA,KAAG,UAAK,WAAW,GAAGA,EAAC,MAApB,YAA0B,IAAgB;AAAA,QACtD,CAAC;AAAA,MACF;AAAA,IACD;AACA,QAAI,MAAM,UAAa,MAAM,QAAW;AACvC,YAAM,aAAa,KAAK,eAAe,CAAC;AACxC,UAAI,YAAY;AACf,eAAO,CAAC,GAAG,UAAU,EAAE,IAAI,CAACD,OAAM;AAhWtC;AAiWK,iBAAO,CAACA,KAAG,UAAK,WAAWA,IAAG,CAAC,MAApB,YAA0B,IAAgB;AAAA,QACtD,CAAC;AAAA,MACF;AAAA,IACD;AACA,WAAO,CAAC;AAAA,EACT;AAAA,EAEO,IAAI,GAAW,GAAqB;AAxW5C;AAyWE,QAAI,GAAG;AACN,YAAM,OAAO,KAAK,eAAe,CAAC;AAClC,cAAO,kCAAM,IAAI,OAAV,YAAgB;AAAA,IACxB;AACA,WAAO,KAAK,UAAU,IAAI,CAAC;AAAA,EAC5B;AACD","sourcesContent":["import type { Cardinality, Json, Refinement } from \"rel8\"\n\nexport interface JunctionEntries<Content extends Json.Object | null>\n\textends Json.Object {\n\treadonly relations: [string, string[]][]\n\treadonly contents: [string, Content][]\n}\nexport interface JunctionSchema<ASide extends string, BSide extends string>\n\textends Json.Object {\n\treadonly between: [a: ASide, b: BSide]\n\treadonly cardinality: Cardinality\n}\n\nexport type BaseExternalStoreConfiguration = {\n\taddRelation: (a: string, b: string) => void\n\tdeleteRelation: (a: string, b: string) => void\n\treplaceRelationsSafely: (a: string, bs: string[]) => void\n\treplaceRelationsUnsafely: (a: string, bs: string[]) => void\n\tgetRelatedKeys: (key: string) => Set<string> | undefined\n\thas: (a: string, b?: string) => boolean\n}\n\nexport type ExternalStoreWithContentConfiguration<Content extends Json.Object> =\n\t{\n\t\tgetContent: (contentKey: string) => Content | undefined\n\t\tsetContent: (contentKey: string, content: Content) => void\n\t\tdeleteContent: (contentKey: string) => void\n\t}\n\nexport type Empty<Obj extends object> = {\n\t[Key in keyof Obj]?: undefined\n}\n\nexport type ExternalStoreConfiguration<Content extends Json.Object | null> =\n\tContent extends Json.Object\n\t\t? BaseExternalStoreConfiguration &\n\t\t\t\tExternalStoreWithContentConfiguration<Content>\n\t\t: BaseExternalStoreConfiguration &\n\t\t\t\tEmpty<ExternalStoreWithContentConfiguration<Json.Object>>\n\nexport type JunctionAdvancedConfiguration<Content extends Json.Object | null> = {\n\texternalStore?: ExternalStoreConfiguration<Content>\n\tisContent?: Refinement<unknown, Content>\n\tmakeContentKey?: (a: string, b: string) => string\n}\n\nexport type JunctionJSON<\n\tASide extends string,\n\tBSide extends string,\n\tContent extends Json.Object | null,\n> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>\n\nexport class Junction<\n\tconst ASide extends string,\n\tconst BSide extends string,\n\tconst Content extends Json.Object | null = null,\n> {\n\tpublic readonly a: ASide\n\tpublic readonly b: BSide\n\tpublic readonly cardinality: Cardinality\n\tpublic readonly relations = new Map<string, Set<string>>()\n\tpublic readonly contents = new Map<string, Content>()\n\n\tpublic isContent: Refinement<unknown, Content> | null\n\tpublic makeContentKey = (a: string, b: string): string => `${a}:${b}`\n\n\tpublic getRelatedKeys(key: string): Set<string> | undefined {\n\t\treturn this.relations.get(key)\n\t}\n\tprotected addRelation(a: string, b: string): void {\n\t\tlet aRelations = this.relations.get(a)\n\t\tlet bRelations = this.relations.get(b)\n\t\tif (aRelations) {\n\t\t\taRelations.add(b)\n\t\t} else {\n\t\t\taRelations = new Set([b])\n\t\t\tthis.relations.set(a, aRelations)\n\t\t}\n\t\tif (bRelations) {\n\t\t\tbRelations.add(a)\n\t\t} else {\n\t\t\tbRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected deleteRelation(a: string, b: string): void {\n\t\tconst aRelations = this.relations.get(a)\n\t\tif (aRelations) {\n\t\t\taRelations.delete(b)\n\t\t\tif (aRelations.size === 0) {\n\t\t\t\tthis.relations.delete(a)\n\t\t\t}\n\t\t\tconst bRelations = this.relations.get(b)\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.delete(a)\n\t\t\t\tif (bRelations.size === 0) {\n\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected replaceRelationsUnsafely(a: string, bs: string[]): void {\n\t\tthis.relations.set(a, new Set(bs))\n\t\tfor (const b of bs) {\n\t\t\tconst bRelations = new Set([a])\n\t\t\tthis.relations.set(b, bRelations)\n\t\t}\n\t}\n\tprotected replaceRelationsSafely(a: string, bs: string[]): void {\n\t\tconst aRelationsPrev = this.relations.get(a)\n\t\tif (aRelationsPrev) {\n\t\t\tfor (const b of aRelationsPrev) {\n\t\t\t\tconst bRelations = this.relations.get(b)\n\t\t\t\tif (bRelations) {\n\t\t\t\t\tif (bRelations.size === 1) {\n\t\t\t\t\t\tthis.relations.delete(b)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbRelations.delete(a)\n\t\t\t\t\t}\n\t\t\t\t\tthis.contents.delete(this.makeContentKey(a, b))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.relations.set(a, new Set(bs))\n\t\tfor (const b of bs) {\n\t\t\tlet bRelations = this.relations.get(b)\n\t\t\tif (bRelations) {\n\t\t\t\tbRelations.add(a)\n\t\t\t} else {\n\t\t\t\tbRelations = new Set([a])\n\t\t\t\tthis.relations.set(b, bRelations)\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected getContentInternal(contentKey: string): Content | undefined {\n\t\treturn this.contents.get(contentKey)\n\t}\n\tprotected setContent(contentKey: string, content: Content): void {\n\t\tthis.contents.set(contentKey, content)\n\t}\n\tprotected deleteContent(contentKey: string): void {\n\t\tthis.contents.delete(contentKey)\n\t}\n\n\tpublic constructor(\n\t\tdata: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>,\n\t\tconfig?: JunctionAdvancedConfiguration<Content>,\n\t) {\n\t\tthis.a = data.between[0]\n\t\tthis.b = data.between[1]\n\n\t\tthis.cardinality = data.cardinality\n\t\tif (!config?.externalStore) {\n\t\t\tthis.relations = new Map(data.relations?.map(([a, b]) => [a, new Set(b)]))\n\t\t\tthis.contents = new Map(data.contents)\n\t\t}\n\t\tthis.isContent = config?.isContent ?? null\n\t\tif (config?.makeContentKey) {\n\t\t\tthis.makeContentKey = config.makeContentKey\n\t\t}\n\t\tif (config?.externalStore) {\n\t\t\tconst externalStore = config.externalStore\n\t\t\tthis.has = (a, b) => externalStore.has(a, b)\n\t\t\tthis.addRelation = (a, b) => {\n\t\t\t\texternalStore.addRelation(a, b)\n\t\t\t}\n\t\t\tthis.deleteRelation = (a, b) => {\n\t\t\t\texternalStore.deleteRelation(a, b)\n\t\t\t}\n\t\t\tthis.replaceRelationsSafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsSafely(a, bs)\n\t\t\t}\n\t\t\tthis.replaceRelationsUnsafely = (a, bs) => {\n\t\t\t\texternalStore.replaceRelationsUnsafely(a, bs)\n\t\t\t}\n\t\t\tthis.getRelatedKeys = (key) => externalStore.getRelatedKeys(key)\n\t\t\tif (externalStore.getContent) {\n\t\t\t\tthis.getContentInternal = (contentKey) => {\n\t\t\t\t\treturn externalStore.getContent(contentKey) as any\n\t\t\t\t}\n\t\t\t\tthis.setContent = (contentKey, content) => {\n\t\t\t\t\texternalStore.setContent(contentKey, content as any)\n\t\t\t\t}\n\t\t\t\tthis.deleteContent = (contentKey) => {\n\t\t\t\t\texternalStore.deleteContent(contentKey)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [x, ys] of data.relations ?? []) {\n\t\t\t\tfor (const y of ys) this.addRelation(x, y)\n\t\t\t}\n\t\t\tfor (const [contentKey, content] of data.contents ?? []) {\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t}\n\tpublic toJSON(): JunctionJSON<ASide, BSide, Content> {\n\t\treturn {\n\t\t\tbetween: [this.a, this.b],\n\t\t\tcardinality: this.cardinality,\n\t\t\trelations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),\n\t\t\tcontents: [...this.contents.entries()],\n\t\t}\n\t}\n\n\tpublic set(\n\t\ta: string,\n\t\t...rest: Content extends null ? [b: string] : [b: string, content: Content]\n\t): this\n\tpublic set(\n\t\trelation: { [Key in ASide | BSide]: string },\n\t\t...rest: Content extends null ? [] | [b?: undefined] : [content: Content]\n\t): this\n\tpublic set(\n\t\ta: string | { [Key in ASide | BSide]: string },\n\t\t...rest: Content extends null\n\t\t\t? [] | [b?: string | undefined]\n\t\t\t: [b: string, content: Content] | [content: Content]\n\t): this {\n\t\tconst b: string =\n\t\t\ttypeof rest[0] === `string`\n\t\t\t\t? rest[0]\n\t\t\t\t: (a[this.b as keyof typeof a] as string)\n\t\tconst content: Content | undefined =\n\t\t\trest[1] ?? typeof rest[0] === `string` ? undefined : (rest[0] as Content)\n\t\ta = typeof a === `string` ? a : a[this.a]\n\t\tswitch (this.cardinality) {\n\t\t\t// biome-ignore lint/suspicious/noFallthroughSwitchClause: perfect here\n\t\t\tcase `1:1`: {\n\t\t\t\tconst bPrev = this.getRelatedKey(a)\n\t\t\t\tif (bPrev && bPrev !== b) this.delete(bPrev, a)\n\t\t\t}\n\t\t\tcase `1:n`: {\n\t\t\t\tconst aPrev = this.getRelatedKey(b)\n\t\t\t\tif (aPrev && aPrev !== a) this.delete(aPrev, b)\n\t\t\t}\n\t\t}\n\t\tif (content) {\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.setContent(contentKey, content)\n\t\t}\n\t\tthis.addRelation(a, b)\n\t\treturn this\n\t}\n\n\tpublic delete(a: string, b?: string): this\n\tpublic delete(\n\t\trelation:\n\t\t\t| Record<ASide | BSide, string>\n\t\t\t| Record<ASide, string>\n\t\t\t| Record<BSide, string>,\n\t\tb?: undefined,\n\t): this\n\tpublic delete(\n\t\tx:\n\t\t\t| Record<ASide | BSide, string>\n\t\t\t| Record<ASide, string>\n\t\t\t| Record<BSide, string>\n\t\t\t| string,\n\t\tb?: string | undefined,\n\t): this {\n\t\t// @ts-expect-error we deduce that this.b may index x\n\t\tb = typeof b === `string` ? b : (x[this.b] as string | undefined)\n\t\t// @ts-expect-error we deduce that this.a may index x\n\t\tconst a = typeof x === `string` ? x : (x[this.a] as string | undefined)\n\n\t\tif (a === undefined && typeof b === `string`) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\tfor (const a of bRelations) {\n\t\t\t\t\tthis.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (typeof a === `string` && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\tfor (const b of aRelations) {\n\t\t\t\t\tthis.delete(a, b)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (typeof a === `string` && typeof b === `string`) {\n\t\t\tthis.deleteRelation(a, b)\n\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\tthis.deleteContent(contentKey)\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getRelatedKey(key: string): string | undefined {\n\t\tconst relations = this.getRelatedKeys(key)\n\t\tif (relations) {\n\t\t\tif (relations.size > 1) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${relations.size} related keys were found for key \"${key}\": (${[\n\t\t\t\t\t\t...relations,\n\t\t\t\t\t]\n\t\t\t\t\t\t.map((k) => `\"${k}\"`)\n\t\t\t\t\t\t.join(`, `)}). Only one related key was expected.`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tfor (const relation of relations) {\n\t\t\t\treturn relation\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic replaceRelations(\n\t\ta: string,\n\t\trelations: Content extends null ? string[] : Record<string, Content>,\n\t\tconfig?: { reckless: boolean },\n\t): this {\n\t\tconst hasContent = !Array.isArray(relations)\n\t\tconst bs = hasContent ? Object.keys(relations) : relations\n\t\tif (config?.reckless) {\n\t\t\tthis.replaceRelationsUnsafely(a, bs)\n\t\t} else {\n\t\t\tthis.replaceRelationsSafely(a, bs)\n\t\t}\n\t\tif (hasContent) {\n\t\t\tfor (const b of bs) {\n\t\t\t\tconst contentKey = this.makeContentKey(a, b)\n\t\t\t\tconst content = relations[b] as Content\n\t\t\t\tthis.setContent(contentKey, content)\n\t\t\t}\n\t\t}\n\t\treturn this\n\t}\n\n\tpublic getContent(a: string, b: string): Content | undefined {\n\t\tconst contentKey = this.makeContentKey(a, b)\n\t\treturn this.getContentInternal(contentKey)\n\t}\n\n\tpublic getRelationEntries(\n\t\tinput: Record<ASide, string> | Record<BSide, string>,\n\t): [string, Content][] {\n\t\tconst a: string | undefined = (input as any)[this.a]\n\t\tconst b: string | undefined = (input as any)[this.b]\n\t\tif (a !== undefined && b === undefined) {\n\t\t\tconst aRelations = this.getRelatedKeys(a)\n\t\t\tif (aRelations) {\n\t\t\t\treturn [...aRelations].map((b) => {\n\t\t\t\t\treturn [b, this.getContent(a, b) ?? (null as Content)]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (a === undefined && b !== undefined) {\n\t\t\tconst bRelations = this.getRelatedKeys(b)\n\t\t\tif (bRelations) {\n\t\t\t\treturn [...bRelations].map((a) => {\n\t\t\t\t\treturn [a, this.getContent(a, b) ?? (null as Content)]\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn []\n\t}\n\n\tpublic has(a: string, b?: string): boolean {\n\t\tif (b) {\n\t\t\tconst setA = this.getRelatedKeys(a)\n\t\t\treturn setA?.has(b) ?? false\n\t\t}\n\t\treturn this.relations.has(a)\n\t}\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { __objRest, __restKey, __spreadProps, __spreadValues };
|
|
35
|
+
//# sourceMappingURL=out.js.map
|
|
36
|
+
//# sourceMappingURL=chunk-PZLG2HP3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ../anvl/src/json/json-interface.ts
|
|
2
|
+
var stringSetJsonInterface = {
|
|
3
|
+
toJson: (stringSet) => Array.from(stringSet),
|
|
4
|
+
fromJson: (json) => new Set(json)
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// ../anvl/src/json/index.ts
|
|
8
|
+
var parseJson = (str) => JSON.parse(str);
|
|
9
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
10
|
+
var JSON_TYPE_NAMES = [
|
|
11
|
+
`array`,
|
|
12
|
+
`boolean`,
|
|
13
|
+
`null`,
|
|
14
|
+
`number`,
|
|
15
|
+
`object`,
|
|
16
|
+
`string`
|
|
17
|
+
];
|
|
18
|
+
var JSON_DEFAULTS = {
|
|
19
|
+
array: [],
|
|
20
|
+
boolean: false,
|
|
21
|
+
null: null,
|
|
22
|
+
number: 0,
|
|
23
|
+
object: {},
|
|
24
|
+
string: ``
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// ../anvl/src/primitive/index.ts
|
|
28
|
+
var isString = (input) => {
|
|
29
|
+
return typeof input === `string`;
|
|
30
|
+
};
|
|
31
|
+
var isNumber = (input) => {
|
|
32
|
+
return typeof input === `number`;
|
|
33
|
+
};
|
|
34
|
+
var isBoolean = (input) => {
|
|
35
|
+
return typeof input === `boolean`;
|
|
36
|
+
};
|
|
37
|
+
var isNull = (input) => {
|
|
38
|
+
return input === null;
|
|
39
|
+
};
|
|
40
|
+
var isPrimitive = (input) => {
|
|
41
|
+
return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson };
|
|
45
|
+
//# sourceMappingURL=out.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-XACXFU3B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../anvl/src/json/json-interface.ts","../../anvl/src/json/index.ts","../../anvl/src/primitive/index.ts"],"names":[],"mappings":";AAOO,IAAM,yBAGT;AAAA,EACH,QAAQ,CAAC,cAAc,MAAM,KAAK,SAAS;AAAA,EAC3C,UAAU,CAAC,SAAS,IAAI,IAAI,IAAI;AACjC;;;ACTO,IAAM,YAAY,CACxB,QAC4D,KAAK,MAAM,GAAG;AAIpE,IAAM,gBAAgB,CAC5B,SACoB,KAAK,UAAU,IAAI;AAIjC,IAAM,kBAAkB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAaO,IAAM,gBAA2B;AAAA,EACvC,OAAO,CAAC;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ,CAAC;AAAA,EACT,QAAQ;AACT;;;ACzCO,IAAM,WAAW,CAAC,UAAoC;AAC5D,SAAO,OAAO,UAAU;AACzB;AAEO,IAAM,WAAW,CAAC,UAAoC;AAC5D,SAAO,OAAO,UAAU;AACzB;AAEO,IAAM,YAAY,CAAC,UAAqC;AAC9D,SAAO,OAAO,UAAU;AACzB;AAEO,IAAM,SAAS,CAAC,UAAkC;AACxD,SAAO,UAAU;AAClB;AAEO,IAAM,cAAc,CAAC,UAAuC;AAClE,SAAO,SAAS,KAAK,KAAK,SAAS,KAAK,KAAK,UAAU,KAAK,KAAK,OAAO,KAAK;AAC9E","sourcesContent":["import type { Json } from \".\"\n\nexport type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {\n\ttoJson: (t: T) => J\n\tfromJson: (json: J) => T\n}\n\nexport const stringSetJsonInterface: JsonInterface<\n\tSet<string>,\n\tJson.Array<string>\n> = {\n\ttoJson: (stringSet) => Array.from(stringSet),\n\tfromJson: (json) => new Set(json),\n}\n","export * from \"./json-interface\"\nimport type * as Json from \"./json\"\nexport { Json }\n\nexport const parseJson = <S extends Stringified<Json.Serializable>>(\n\tstr: S | string,\n): S extends Stringified<infer J> ? J : Json.Serializable => JSON.parse(str)\n\nexport type Stringified<J extends Json.Serializable> = string & { __json: J }\n\nexport const stringifyJson = <J extends Json.Serializable>(\n\tjson: J,\n): Stringified<J> => JSON.stringify(json) as Stringified<J>\n\nexport type Empty = Record<string, never>\n\nexport const JSON_TYPE_NAMES = [\n\t`array`,\n\t`boolean`,\n\t`null`,\n\t`number`,\n\t`object`,\n\t`string`,\n] as const\n\nexport type JsonTypeName = (typeof JSON_TYPE_NAMES)[number]\n\nexport interface JsonTypes extends Record<JsonTypeName, Json.Serializable> {\n\tarray: Json.Array\n\tboolean: boolean\n\tnull: null\n\tnumber: number\n\tobject: Json.Object\n\tstring: string\n}\n\nexport const JSON_DEFAULTS: JsonTypes = {\n\tarray: [],\n\tboolean: false,\n\tnull: null,\n\tnumber: 0,\n\tobject: {},\n\tstring: ``,\n}\n","export type primitive = boolean | number | string | null\n\nexport const isString = (input: unknown): input is string => {\n\treturn typeof input === `string`\n}\n\nexport const isNumber = (input: unknown): input is number => {\n\treturn typeof input === `number`\n}\n\nexport const isBoolean = (input: unknown): input is boolean => {\n\treturn typeof input === `boolean`\n}\n\nexport const isNull = (input: unknown): input is null => {\n\treturn input === null\n}\n\nexport const isPrimitive = (input: unknown): input is primitive => {\n\treturn isString(input) || isNumber(input) || isBoolean(input) || isNull(input)\n}\n"]}
|