atom.io 0.41.1 → 0.42.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.
- package/dist/internal/index.d.ts +21 -38
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +82 -263
- package/dist/internal/index.js.map +1 -1
- package/dist/main/index.d.ts +18 -36
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +13 -2
- package/dist/main/index.js.map +1 -1
- package/dist/realtime/index.d.ts +2 -3
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js +1 -1
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-server/index.js +1 -1
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.js +1 -1
- package/dist/struct/index.d.ts +14 -0
- package/dist/struct/index.d.ts.map +1 -0
- package/dist/struct/index.js +35 -0
- package/dist/struct/index.js.map +1 -0
- package/dist/transceivers/o-list/index.d.ts +8 -4
- package/dist/transceivers/o-list/index.d.ts.map +1 -1
- package/dist/transceivers/o-list/index.js +2 -1
- package/dist/transceivers/o-list/index.js.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts +1 -0
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.js.map +1 -1
- package/dist/transceivers/u-list/index.d.ts +8 -4
- package/dist/transceivers/u-list/index.d.ts.map +1 -1
- package/dist/transceivers/u-list/index.js +2 -1
- package/dist/transceivers/u-list/index.js.map +1 -1
- package/dist/utility-types-aZkJVERa.d.ts +10 -0
- package/dist/utility-types-aZkJVERa.d.ts.map +1 -0
- package/package.json +13 -9
- package/src/internal/index.ts +0 -1
- package/src/internal/join/create-join.ts +8 -11
- package/src/internal/join/edit-relations-in-store.ts +6 -8
- package/src/internal/join/find-relations-in-store.ts +11 -67
- package/src/internal/join/get-internal-relations-from-store.ts +11 -5
- package/src/internal/join/get-join.ts +7 -9
- package/src/internal/join/join-internal.ts +154 -394
- package/src/internal/mutable/transceiver.ts +1 -5
- package/src/internal/set-state/dispatch-state-update.ts +1 -1
- package/src/internal/store/store.ts +1 -1
- package/src/main/join.ts +68 -151
- package/src/main/realm.ts +4 -4
- package/src/realtime/shared-room-store.ts +5 -15
- package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +1 -1
- package/src/struct/index.ts +1 -0
- package/src/{internal → struct}/micro.ts +1 -1
- package/src/transceivers/o-list/o-list.ts +13 -9
- package/src/transceivers/set-rtx/set-rtx.ts +4 -0
- package/src/transceivers/u-list/u-list.ts +13 -9
package/dist/internal/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Anarchy, AtomIOLogger, PRETTY_TOKEN_TYPES } from "atom.io";
|
|
2
2
|
import { parseJson, stringifyJson } from "atom.io/json";
|
|
3
|
-
import {
|
|
3
|
+
import { UList } from "atom.io/transceivers/u-list";
|
|
4
4
|
|
|
5
5
|
//#region src/internal/arbitrary.ts
|
|
6
6
|
function arbitrary(random = Math.random) {
|
|
@@ -3064,10 +3064,9 @@ function installIntoStore(tokens, target, source) {
|
|
|
3064
3064
|
var Join = class {
|
|
3065
3065
|
toolkit;
|
|
3066
3066
|
options;
|
|
3067
|
-
defaultContent;
|
|
3068
3067
|
relations;
|
|
3069
3068
|
states;
|
|
3070
|
-
|
|
3069
|
+
relatedKeysAtoms;
|
|
3071
3070
|
transact(toolkit, run) {
|
|
3072
3071
|
const originalToolkit = this.toolkit;
|
|
3073
3072
|
this.toolkit = toolkit;
|
|
@@ -3077,11 +3076,10 @@ var Join = class {
|
|
|
3077
3076
|
store;
|
|
3078
3077
|
realm;
|
|
3079
3078
|
[Symbol.dispose]() {}
|
|
3080
|
-
constructor(options,
|
|
3079
|
+
constructor(options, store = IMPLICIT.STORE) {
|
|
3081
3080
|
this.store = store;
|
|
3082
3081
|
this.realm = new Anarchy(store);
|
|
3083
3082
|
this.options = options;
|
|
3084
|
-
this.defaultContent = defaultContent;
|
|
3085
3083
|
this.store.miscResources.set(`join:${options.key}`, this);
|
|
3086
3084
|
this.realm.allocate(`root`, options.key);
|
|
3087
3085
|
this.toolkit = {
|
|
@@ -3096,28 +3094,9 @@ var Join = class {
|
|
|
3096
3094
|
const bSide = options.between[1];
|
|
3097
3095
|
const relatedKeysAtoms = createMutableAtomFamily(store, {
|
|
3098
3096
|
key: `${options.key}/relatedKeys`,
|
|
3099
|
-
class:
|
|
3097
|
+
class: UList
|
|
3100
3098
|
}, [`join`, `relations`]);
|
|
3101
|
-
this.
|
|
3102
|
-
const getRelatedKeys = ({ get }, key) => get(relatedKeysAtoms, key);
|
|
3103
|
-
const addRelation = ({ set }, a, b) => {
|
|
3104
|
-
if (!this.store.molecules.has(stringifyJson(a))) this.realm.allocate(options.key, a);
|
|
3105
|
-
set(relatedKeysAtoms, a, (aKeys) => aKeys.add(b));
|
|
3106
|
-
set(relatedKeysAtoms, b, (bKeys) => bKeys.add(a));
|
|
3107
|
-
};
|
|
3108
|
-
const deleteRelation = ({ set }, a, b) => {
|
|
3109
|
-
set(relatedKeysAtoms, a, (aKeys) => {
|
|
3110
|
-
aKeys.delete(b);
|
|
3111
|
-
return aKeys;
|
|
3112
|
-
});
|
|
3113
|
-
set(relatedKeysAtoms, b, (bKeys) => {
|
|
3114
|
-
bKeys.delete(a);
|
|
3115
|
-
return bKeys;
|
|
3116
|
-
});
|
|
3117
|
-
const [x, y] = [a, b].sort();
|
|
3118
|
-
const compositeKey = `${x}:${y}`;
|
|
3119
|
-
this.store.moleculeJoins.delete(compositeKey);
|
|
3120
|
-
};
|
|
3099
|
+
this.relatedKeysAtoms = relatedKeysAtoms;
|
|
3121
3100
|
const replaceRelationsSafely = (toolkit, a, newRelationsOfA) => {
|
|
3122
3101
|
const { find, get, set } = toolkit;
|
|
3123
3102
|
const relationsOfAState = find(relatedKeysAtoms, a);
|
|
@@ -3130,41 +3109,46 @@ var Join = class {
|
|
|
3130
3109
|
});
|
|
3131
3110
|
}
|
|
3132
3111
|
set(relationsOfAState, (relationsOfA) => {
|
|
3133
|
-
relationsOfA.
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3112
|
+
relationsOfA.clear();
|
|
3113
|
+
for (const newRelationB of newRelationsOfA) {
|
|
3114
|
+
const relationsOfBAtom = find(relatedKeysAtoms, newRelationB);
|
|
3115
|
+
const relationsOfB = get(relationsOfBAtom);
|
|
3116
|
+
const newRelationBIsAlreadyRelated = relationsOfB.has(a);
|
|
3117
|
+
if (this.relations.cardinality === `1:n`) {
|
|
3118
|
+
const previousOwnersToDispose = [];
|
|
3119
|
+
for (const previousOwner of relationsOfB) {
|
|
3120
|
+
if (previousOwner === a) continue;
|
|
3121
|
+
let previousOwnerSize;
|
|
3122
|
+
operateOnStore(JOIN_OP, this.store, relatedKeysAtoms, previousOwner, (relations$1) => {
|
|
3123
|
+
relations$1.delete(newRelationB);
|
|
3124
|
+
previousOwnerSize = relations$1.size;
|
|
3125
|
+
return relations$1;
|
|
3126
|
+
});
|
|
3127
|
+
if (previousOwnerSize === 0) previousOwnersToDispose.push(previousOwner);
|
|
3128
|
+
}
|
|
3129
|
+
if (!newRelationBIsAlreadyRelated && relationsOfB.size > 0) set(relationsOfBAtom, (relations$1) => {
|
|
3130
|
+
relations$1.clear();
|
|
3131
|
+
return relations$1;
|
|
3132
|
+
});
|
|
3133
|
+
for (const previousOwner of previousOwnersToDispose) {
|
|
3134
|
+
const [x, y] = [newRelationB, previousOwner].sort();
|
|
3135
|
+
const compositeKey = `${x}:${y}`;
|
|
3136
|
+
store.moleculeJoins.delete(compositeKey);
|
|
3152
3137
|
}
|
|
3153
|
-
if (!newRelationBIsAlreadyRelated) relationsOfB.add(a);
|
|
3154
|
-
nextRelationsOfA.add(newRelationB);
|
|
3155
3138
|
}
|
|
3156
|
-
|
|
3157
|
-
|
|
3139
|
+
if (!newRelationBIsAlreadyRelated) set(relationsOfBAtom, (relations$1) => {
|
|
3140
|
+
relations$1.add(a);
|
|
3141
|
+
return relations$1;
|
|
3142
|
+
});
|
|
3143
|
+
relationsOfA.add(newRelationB);
|
|
3144
|
+
}
|
|
3158
3145
|
return relationsOfA;
|
|
3159
3146
|
});
|
|
3160
3147
|
};
|
|
3161
3148
|
const replaceRelationsUnsafely = (toolkit, a, newRelationsOfA) => {
|
|
3162
3149
|
const { set } = toolkit;
|
|
3163
3150
|
set(relatedKeysAtoms, a, (relationsOfA) => {
|
|
3164
|
-
relationsOfA.
|
|
3165
|
-
for (const newRelationB of newRelationsOfA) nextRelationsOfA.add(newRelationB);
|
|
3166
|
-
return true;
|
|
3167
|
-
});
|
|
3151
|
+
for (const newRelationB of newRelationsOfA) relationsOfA.add(newRelationB);
|
|
3168
3152
|
return relationsOfA;
|
|
3169
3153
|
});
|
|
3170
3154
|
for (const newRelationB of newRelationsOfA) set(relatedKeysAtoms, newRelationB, (newRelationsB) => {
|
|
@@ -3173,66 +3157,43 @@ var Join = class {
|
|
|
3173
3157
|
});
|
|
3174
3158
|
return true;
|
|
3175
3159
|
};
|
|
3176
|
-
const
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
},
|
|
3187
|
-
deleteRelation: (a, b) => {
|
|
3188
|
-
deleteRelation(this.toolkit, a, b);
|
|
3189
|
-
},
|
|
3190
|
-
replaceRelationsSafely: (a, bs) => {
|
|
3191
|
-
replaceRelationsSafely(this.toolkit, a, bs);
|
|
3192
|
-
},
|
|
3193
|
-
replaceRelationsUnsafely: (a, bs) => {
|
|
3194
|
-
replaceRelationsUnsafely(this.toolkit, a, bs);
|
|
3195
|
-
},
|
|
3196
|
-
has: (a, b) => has(this.toolkit, a, b)
|
|
3197
|
-
};
|
|
3198
|
-
let externalStore;
|
|
3199
|
-
let contentAtoms;
|
|
3200
|
-
if (defaultContent) {
|
|
3201
|
-
contentAtoms = createRegularAtomFamily(store, {
|
|
3202
|
-
key: `${options.key}/content`,
|
|
3203
|
-
default: defaultContent
|
|
3204
|
-
}, [`join`, `content`]);
|
|
3205
|
-
const getContent = ({ get }, key) => get(contentAtoms, key);
|
|
3206
|
-
const setContent = ({ set }, key, content) => {
|
|
3207
|
-
set(contentAtoms, key, content);
|
|
3208
|
-
};
|
|
3209
|
-
externalStore = Object.assign(baseExternalStoreConfiguration, {
|
|
3210
|
-
getContent: (contentKey) => {
|
|
3211
|
-
return getContent(this.toolkit, contentKey);
|
|
3160
|
+
const relations = new Junction(options, {
|
|
3161
|
+
externalStore: {
|
|
3162
|
+
getRelatedKeys: (key) => this.toolkit.get(relatedKeysAtoms, key),
|
|
3163
|
+
addRelation: (a, b) => {
|
|
3164
|
+
this.store.moleculeJoins.set(`"${a}"`, options.key);
|
|
3165
|
+
this.store.moleculeJoins.set(`"${b}"`, options.key);
|
|
3166
|
+
if (!this.store.molecules.has(stringifyJson(a))) this.realm.allocate(options.key, a);
|
|
3167
|
+
if (!this.store.molecules.has(stringifyJson(b))) this.realm.allocate(options.key, b);
|
|
3168
|
+
this.toolkit.set(relatedKeysAtoms, a, (aKeys) => aKeys.add(b));
|
|
3169
|
+
this.toolkit.set(relatedKeysAtoms, b, (bKeys) => bKeys.add(a));
|
|
3212
3170
|
},
|
|
3213
|
-
|
|
3214
|
-
|
|
3171
|
+
deleteRelation: (a, b) => {
|
|
3172
|
+
this.toolkit.set(relatedKeysAtoms, a, (aKeys) => {
|
|
3173
|
+
aKeys.delete(b);
|
|
3174
|
+
return aKeys;
|
|
3175
|
+
});
|
|
3176
|
+
this.toolkit.set(relatedKeysAtoms, b, (bKeys) => {
|
|
3177
|
+
bKeys.delete(a);
|
|
3178
|
+
return bKeys;
|
|
3179
|
+
});
|
|
3180
|
+
const [x, y] = [a, b].sort();
|
|
3181
|
+
const compositeKey = `${x}:${y}`;
|
|
3182
|
+
this.store.moleculeJoins.delete(compositeKey);
|
|
3215
3183
|
},
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3184
|
+
replaceRelationsSafely: (a, bs) => {
|
|
3185
|
+
replaceRelationsSafely(this.toolkit, a, bs);
|
|
3186
|
+
},
|
|
3187
|
+
replaceRelationsUnsafely: (a, bs) => {
|
|
3188
|
+
replaceRelationsUnsafely(this.toolkit, a, bs);
|
|
3189
|
+
},
|
|
3190
|
+
has: (a, b) => {
|
|
3191
|
+
const aKeys = this.toolkit.get(relatedKeysAtoms, a);
|
|
3192
|
+
return b ? aKeys.has(b) : aKeys.size > 0;
|
|
3193
|
+
}
|
|
3194
|
+
},
|
|
3221
3195
|
isAType: options.isAType,
|
|
3222
|
-
isBType: options.isBType
|
|
3223
|
-
makeContentKey: (...args) => {
|
|
3224
|
-
const [a, b] = args;
|
|
3225
|
-
const [x, y] = args.sort();
|
|
3226
|
-
const compositeKey = `${x}:${y}`;
|
|
3227
|
-
const aMolecule = store.molecules.get(stringifyJson(a));
|
|
3228
|
-
const bMolecule = store.molecules.get(stringifyJson(b));
|
|
3229
|
-
if (!aMolecule) this.realm.allocate(options.key, a);
|
|
3230
|
-
if (!bMolecule) this.realm.allocate(options.key, b);
|
|
3231
|
-
this.realm.allocate(a, compositeKey, `all`);
|
|
3232
|
-
this.realm.claim(b, compositeKey);
|
|
3233
|
-
this.store.moleculeJoins.set(compositeKey, options.key);
|
|
3234
|
-
return compositeKey;
|
|
3235
|
-
}
|
|
3196
|
+
isBType: options.isBType
|
|
3236
3197
|
});
|
|
3237
3198
|
const createSingleKeySelectorFamily = () => createReadonlyPureSelectorFamily(store, {
|
|
3238
3199
|
key: `${options.key}/singleRelatedKey`,
|
|
@@ -3247,63 +3208,20 @@ var Join = class {
|
|
|
3247
3208
|
key: `${options.key}/multipleRelatedKeys`,
|
|
3248
3209
|
get: (key) => ({ get }) => {
|
|
3249
3210
|
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
3250
|
-
return get(jsonFamily, key)
|
|
3211
|
+
return get(jsonFamily, key);
|
|
3251
3212
|
}
|
|
3252
3213
|
}, [`join`, `keys`]);
|
|
3253
3214
|
};
|
|
3254
|
-
const createSingleEntrySelectorFamily = () => createReadonlyPureSelectorFamily(store, {
|
|
3255
|
-
key: `${options.key}/singleRelatedEntry`,
|
|
3256
|
-
get: (x) => ({ get }) => {
|
|
3257
|
-
const relatedKeys = get(relatedKeysAtoms, x);
|
|
3258
|
-
for (const y of relatedKeys) {
|
|
3259
|
-
let a = relations.isAType?.(x) ? x : void 0;
|
|
3260
|
-
let b = a === void 0 ? x : void 0;
|
|
3261
|
-
a ??= y;
|
|
3262
|
-
b ??= y;
|
|
3263
|
-
const contentKey = relations.makeContentKey(a, b);
|
|
3264
|
-
const content = get(contentAtoms, contentKey);
|
|
3265
|
-
return [y, content];
|
|
3266
|
-
}
|
|
3267
|
-
return null;
|
|
3268
|
-
}
|
|
3269
|
-
}, [`join`, `entries`]);
|
|
3270
|
-
const getMultipleEntrySelectorFamily = () => createReadonlyPureSelectorFamily(store, {
|
|
3271
|
-
key: `${options.key}/multipleRelatedEntries`,
|
|
3272
|
-
get: (x) => ({ get }) => {
|
|
3273
|
-
const jsonFamily = getJsonFamily(relatedKeysAtoms, store);
|
|
3274
|
-
return get(jsonFamily, x).members.map((y) => {
|
|
3275
|
-
let a = relations.isAType?.(x) ? x : void 0;
|
|
3276
|
-
let b = a === void 0 ? x : void 0;
|
|
3277
|
-
a ??= y;
|
|
3278
|
-
b ??= y;
|
|
3279
|
-
const contentKey = relations.makeContentKey(a, b);
|
|
3280
|
-
const content = get(contentAtoms, contentKey);
|
|
3281
|
-
return [y, content];
|
|
3282
|
-
});
|
|
3283
|
-
}
|
|
3284
|
-
}, [`join`, `entries`]);
|
|
3285
3215
|
switch (options.cardinality) {
|
|
3286
3216
|
case `1:1`: {
|
|
3287
3217
|
const singleRelatedKeySelectors = createSingleKeySelectorFamily();
|
|
3288
3218
|
const stateKeyA = `${aSide}KeyOf${capitalize(bSide)}`;
|
|
3289
3219
|
const stateKeyB = `${bSide}KeyOf${capitalize(aSide)}`;
|
|
3290
|
-
|
|
3220
|
+
this.relations = relations;
|
|
3221
|
+
this.states = {
|
|
3291
3222
|
[stateKeyA]: singleRelatedKeySelectors,
|
|
3292
3223
|
[stateKeyB]: singleRelatedKeySelectors
|
|
3293
3224
|
};
|
|
3294
|
-
let states;
|
|
3295
|
-
if (defaultContent) {
|
|
3296
|
-
const singleEntrySelectors = createSingleEntrySelectorFamily();
|
|
3297
|
-
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
3298
|
-
const entriesStateKeyB = `${bSide}EntryOf${capitalize(aSide)}`;
|
|
3299
|
-
const contentStates = {
|
|
3300
|
-
[entriesStateKeyA]: singleEntrySelectors,
|
|
3301
|
-
[entriesStateKeyB]: singleEntrySelectors
|
|
3302
|
-
};
|
|
3303
|
-
states = Object.assign(baseStates, contentStates);
|
|
3304
|
-
} else states = baseStates;
|
|
3305
|
-
this.relations = relations;
|
|
3306
|
-
this.states = states;
|
|
3307
3225
|
break;
|
|
3308
3226
|
}
|
|
3309
3227
|
case `1:n`: {
|
|
@@ -3315,43 +3233,19 @@ var Join = class {
|
|
|
3315
3233
|
[stateKeyA]: singleRelatedKeySelectors,
|
|
3316
3234
|
[stateKeyB]: multipleRelatedKeysSelectors
|
|
3317
3235
|
};
|
|
3318
|
-
let states;
|
|
3319
|
-
if (defaultContent) {
|
|
3320
|
-
const singleRelatedEntrySelectors = createSingleEntrySelectorFamily();
|
|
3321
|
-
const multipleRelatedEntriesSelectors = getMultipleEntrySelectorFamily();
|
|
3322
|
-
const entriesStateKeyA = `${aSide}EntryOf${capitalize(bSide)}`;
|
|
3323
|
-
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(aSide)}`;
|
|
3324
|
-
const contentStates = {
|
|
3325
|
-
[entriesStateKeyA]: singleRelatedEntrySelectors,
|
|
3326
|
-
[entriesStateKeyB]: multipleRelatedEntriesSelectors
|
|
3327
|
-
};
|
|
3328
|
-
states = Object.assign(baseStates, contentStates);
|
|
3329
|
-
} else states = baseStates;
|
|
3330
3236
|
this.relations = relations;
|
|
3331
|
-
this.states =
|
|
3237
|
+
this.states = baseStates;
|
|
3332
3238
|
break;
|
|
3333
3239
|
}
|
|
3334
3240
|
case `n:n`: {
|
|
3335
3241
|
const multipleRelatedKeysSelectors = getMultipleKeySelectorFamily();
|
|
3336
3242
|
const stateKeyA = `${aSide}KeysOf${capitalize(bSide)}`;
|
|
3337
3243
|
const stateKeyB = `${bSide}KeysOf${capitalize(aSide)}`;
|
|
3338
|
-
|
|
3244
|
+
this.relations = relations;
|
|
3245
|
+
this.states = {
|
|
3339
3246
|
[stateKeyA]: multipleRelatedKeysSelectors,
|
|
3340
3247
|
[stateKeyB]: multipleRelatedKeysSelectors
|
|
3341
3248
|
};
|
|
3342
|
-
let states;
|
|
3343
|
-
if (defaultContent) {
|
|
3344
|
-
const multipleRelatedEntriesSelectors = getMultipleEntrySelectorFamily();
|
|
3345
|
-
const entriesStateKeyA = `${aSide}EntriesOf${capitalize(bSide)}`;
|
|
3346
|
-
const entriesStateKeyB = `${bSide}EntriesOf${capitalize(aSide)}`;
|
|
3347
|
-
const contentStates = {
|
|
3348
|
-
[entriesStateKeyA]: multipleRelatedEntriesSelectors,
|
|
3349
|
-
[entriesStateKeyB]: multipleRelatedEntriesSelectors
|
|
3350
|
-
};
|
|
3351
|
-
states = Object.assign(baseStates, contentStates);
|
|
3352
|
-
} else states = baseStates;
|
|
3353
|
-
this.relations = relations;
|
|
3354
|
-
this.states = states;
|
|
3355
3249
|
}
|
|
3356
3250
|
}
|
|
3357
3251
|
}
|
|
@@ -3359,8 +3253,8 @@ var Join = class {
|
|
|
3359
3253
|
|
|
3360
3254
|
//#endregion
|
|
3361
3255
|
//#region src/internal/join/create-join.ts
|
|
3362
|
-
function createJoin(store, options
|
|
3363
|
-
store.joins.set(options.key, new Join(options
|
|
3256
|
+
function createJoin(store, options) {
|
|
3257
|
+
store.joins.set(options.key, new Join(options));
|
|
3364
3258
|
return {
|
|
3365
3259
|
key: options.key,
|
|
3366
3260
|
type: `join`,
|
|
@@ -3378,7 +3272,7 @@ function getJoin(token, store) {
|
|
|
3378
3272
|
const rootJoin = IMPLICIT.STORE.joins.get(token.key);
|
|
3379
3273
|
if (rootJoin === void 0) throw new Error(`Join "${token.key}" not found in store "${store.config.name}"`);
|
|
3380
3274
|
const root = eldest(store);
|
|
3381
|
-
myJoin = new Join(rootJoin.options,
|
|
3275
|
+
myJoin = new Join(rootJoin.options, root);
|
|
3382
3276
|
store.joins.set(token.key, myJoin);
|
|
3383
3277
|
}
|
|
3384
3278
|
return myJoin;
|
|
@@ -3416,20 +3310,6 @@ function findRelationsInStore(token, key, store) {
|
|
|
3416
3310
|
return findInStore(store, familyBA, key);
|
|
3417
3311
|
}
|
|
3418
3312
|
};
|
|
3419
|
-
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
3420
|
-
if (entryAB in myJoin.states) {
|
|
3421
|
-
const entryBA = `${token.b}EntryOf${capitalize(token.a)}`;
|
|
3422
|
-
Object.assign(relations, {
|
|
3423
|
-
get [entryAB]() {
|
|
3424
|
-
const familyAB = myJoin.states[entryAB];
|
|
3425
|
-
return findInStore(store, familyAB, key);
|
|
3426
|
-
},
|
|
3427
|
-
get [entryBA]() {
|
|
3428
|
-
const familyBA = myJoin.states[entryBA];
|
|
3429
|
-
return findInStore(store, familyBA, key);
|
|
3430
|
-
}
|
|
3431
|
-
});
|
|
3432
|
-
}
|
|
3433
3313
|
break;
|
|
3434
3314
|
}
|
|
3435
3315
|
case `1:n`: {
|
|
@@ -3445,20 +3325,6 @@ function findRelationsInStore(token, key, store) {
|
|
|
3445
3325
|
return findInStore(store, familyBA, key);
|
|
3446
3326
|
}
|
|
3447
3327
|
};
|
|
3448
|
-
const entryAB = `${token.a}EntryOf${capitalize(token.b)}`;
|
|
3449
|
-
if (entryAB in myJoin.states) {
|
|
3450
|
-
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
3451
|
-
Object.assign(relations, {
|
|
3452
|
-
get [entryAB]() {
|
|
3453
|
-
const familyAB = myJoin.states[entryAB];
|
|
3454
|
-
return findInStore(store, familyAB, key);
|
|
3455
|
-
},
|
|
3456
|
-
get [entriesBA]() {
|
|
3457
|
-
const familyBA = myJoin.states[entriesBA];
|
|
3458
|
-
return findInStore(store, familyBA, key);
|
|
3459
|
-
}
|
|
3460
|
-
});
|
|
3461
|
-
}
|
|
3462
3328
|
break;
|
|
3463
3329
|
}
|
|
3464
3330
|
case `n:n`: {
|
|
@@ -3474,20 +3340,6 @@ function findRelationsInStore(token, key, store) {
|
|
|
3474
3340
|
return findInStore(store, familyBA, key);
|
|
3475
3341
|
}
|
|
3476
3342
|
};
|
|
3477
|
-
const entriesAB = `${token.a}EntriesOf${capitalize(token.b)}`;
|
|
3478
|
-
if (entriesAB in myJoin.states) {
|
|
3479
|
-
const entriesBA = `${token.b}EntriesOf${capitalize(token.a)}`;
|
|
3480
|
-
Object.assign(relations, {
|
|
3481
|
-
get [entriesAB]() {
|
|
3482
|
-
const familyAB = myJoin.states[entriesAB];
|
|
3483
|
-
return findInStore(store, familyAB, key);
|
|
3484
|
-
},
|
|
3485
|
-
get [entriesBA]() {
|
|
3486
|
-
const familyBA = myJoin.states[entriesBA];
|
|
3487
|
-
return findInStore(store, familyBA, key);
|
|
3488
|
-
}
|
|
3489
|
-
});
|
|
3490
|
-
}
|
|
3491
3343
|
}
|
|
3492
3344
|
}
|
|
3493
3345
|
return relations;
|
|
@@ -3496,41 +3348,8 @@ function findRelationsInStore(token, key, store) {
|
|
|
3496
3348
|
//#endregion
|
|
3497
3349
|
//#region src/internal/join/get-internal-relations-from-store.ts
|
|
3498
3350
|
function getInternalRelationsFromStore(token, store) {
|
|
3499
|
-
return getJoin(token, store).
|
|
3500
|
-
}
|
|
3501
|
-
|
|
3502
|
-
//#endregion
|
|
3503
|
-
//#region src/internal/micro.ts
|
|
3504
|
-
function enumeration(values) {
|
|
3505
|
-
const result = {};
|
|
3506
|
-
let i = 0;
|
|
3507
|
-
for (const value of values) {
|
|
3508
|
-
result[value] = i;
|
|
3509
|
-
result[i] = value;
|
|
3510
|
-
++i;
|
|
3511
|
-
}
|
|
3512
|
-
return result;
|
|
3351
|
+
return getJoin(token, store).relatedKeysAtoms;
|
|
3513
3352
|
}
|
|
3514
|
-
const BOOL = `\u0001`;
|
|
3515
|
-
const NULL = `\u0002`;
|
|
3516
|
-
const STRING = `\u0003`;
|
|
3517
|
-
const NUMBER = `\u0004`;
|
|
3518
|
-
const packValue = (value) => {
|
|
3519
|
-
switch (typeof value) {
|
|
3520
|
-
case `string`: return STRING + value;
|
|
3521
|
-
case `number`: return NUMBER + value;
|
|
3522
|
-
case `boolean`: return BOOL + +value;
|
|
3523
|
-
case `object`: return NULL;
|
|
3524
|
-
}
|
|
3525
|
-
};
|
|
3526
|
-
const unpackValue = (value) => {
|
|
3527
|
-
switch (value[0]) {
|
|
3528
|
-
case STRING: return value.slice(1);
|
|
3529
|
-
case NUMBER: return +value.slice(1);
|
|
3530
|
-
case BOOL: return value.slice(1) === `1`;
|
|
3531
|
-
case NULL: return null;
|
|
3532
|
-
}
|
|
3533
|
-
};
|
|
3534
3353
|
|
|
3535
3354
|
//#endregion
|
|
3536
3355
|
//#region src/internal/timeline/create-timeline.ts
|
|
@@ -3809,5 +3628,5 @@ const timeTravel = (store, action, token) => {
|
|
|
3809
3628
|
};
|
|
3810
3629
|
|
|
3811
3630
|
//#endregion
|
|
3812
|
-
export { CircularBuffer, FamilyTracker, Future, IMPLICIT, INTERNAL_ROLES, JOIN_OP, Join, Junction, MapOverlay, NotFoundError, OWN_OP, RESET_STATE, RelationsOverlay, SetOverlay, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, capitalize, claimWithinStore, clearStore, closeOperation, createClaimTX, createDeallocateTX, createJoin, createMutableAtom, createMutableAtomFamily, createReadonlyHeldSelector, createReadonlyPureSelector, createReadonlyPureSelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneSelector, createTimeline, createTransaction, createWritableHeldSelector, createWritablePureSelector, createWritablePureSelectorFamily, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, eldest,
|
|
3631
|
+
export { CircularBuffer, FamilyTracker, Future, IMPLICIT, INTERNAL_ROLES, JOIN_OP, Join, Junction, MapOverlay, NotFoundError, OWN_OP, RESET_STATE, RelationsOverlay, SetOverlay, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, capitalize, claimWithinStore, clearStore, closeOperation, createClaimTX, createDeallocateTX, createJoin, createMutableAtom, createMutableAtomFamily, createReadonlyHeldSelector, createReadonlyPureSelector, createReadonlyPureSelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneSelector, createTimeline, createTransaction, createWritableHeldSelector, createWritablePureSelector, createWritablePureSelectorFamily, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, eldest, evictCachedValue, evictDownstreamFromAtom, evictDownstreamFromSelector, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFamilyOfToken, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, hasRole, ingestAtomUpdateEvent, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdateEvent, ingestTransactionOutcomeEvent, installIntoStore, isAtomKey, isChildStore, isDone, isFn, isReadonlySelectorKey, isReservedIntrospectionKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markDone, newest, openOperation, operateOnStore, readFromCache, readOrComputeValue, recallState, registerSelector, resetAtomOrSelector, resetInStore, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootDependency, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceRootSelectorAtoms, updateSelectorAtoms, withdraw, writeToCache };
|
|
3813
3632
|
//# sourceMappingURL=index.js.map
|