@seedprotocol/sdk 0.1.38 → 0.1.41
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/{index-C10-kbIJ.js → index-BvH0sjnH.js} +89 -42
- package/dist/index-BvH0sjnH.js.map +1 -0
- package/dist/{index-aq3KM2AI.js → index-ClKB3DC-.js} +2 -2
- package/dist/index-ClKB3DC-.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed-GJkiyGC5.js → seed-Bj6wb5Jr.js} +3 -3
- package/dist/{seed-GJkiyGC5.js.map → seed-Bj6wb5Jr.js.map} +1 -1
- package/dist/{seed-mY1NrOwT.js → seed-BpJsAlzT.js} +3 -3
- package/dist/{seed-mY1NrOwT.js.map → seed-BpJsAlzT.js.map} +1 -1
- package/dist/{seed-D1Jb9jY7.js → seed-DJoW3qHO.js} +2 -2
- package/dist/{seed-D1Jb9jY7.js.map → seed-DJoW3qHO.js.map} +1 -1
- package/dist/{seed.schema.config-Lv1DZAJh.js → seed.schema.config-CtfrG9dk.js} +2 -2
- package/dist/{seed.schema.config-Lv1DZAJh.js.map → seed.schema.config-CtfrG9dk.js.map} +1 -1
- package/dist/types/src/browser/db/write.d.ts +2 -3
- package/dist/types/src/browser/db/write.d.ts.map +1 -1
- package/dist/types/src/browser/events/files/download.d.ts.map +1 -1
- package/dist/types/src/browser/item/class.d.ts +1 -1
- package/dist/types/src/browser/item/class.d.ts.map +1 -1
- package/dist/types/src/browser/item/single/actors/saveDataToDb.d.ts +55 -1
- package/dist/types/src/browser/item/single/actors/saveDataToDb.d.ts.map +1 -1
- package/dist/types/src/browser/item/single/itemMachineSingle.d.ts +56 -1
- package/dist/types/src/browser/item/single/itemMachineSingle.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts +1 -2
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb.d.ts +1 -2
- package/dist/types/src/browser/property/actors/saveValueToDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/class.d.ts +158 -14
- package/dist/types/src/browser/property/class.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts +7 -4
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/dist/types/src/browser/react/property.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/fetchAll/actors.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-C10-kbIJ.js.map +0 -1
- package/dist/index-aq3KM2AI.js.map +0 -1
|
@@ -984,7 +984,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
984
984
|
renderValue: refResolvedDisplayValue,
|
|
985
985
|
});
|
|
986
986
|
if (propertyNameFromDb === 'storageTransactionId') {
|
|
987
|
-
const { Item } = yield import('./index-
|
|
987
|
+
const { Item } = yield import('./index-ClKB3DC-.js');
|
|
988
988
|
const item = yield Item.find({
|
|
989
989
|
seedLocalId,
|
|
990
990
|
modelName: itemModelName,
|
|
@@ -1660,6 +1660,7 @@ class ItemProperty {
|
|
|
1660
1660
|
if (!propertyName) {
|
|
1661
1661
|
throw new Error(`Property name not provided`);
|
|
1662
1662
|
}
|
|
1663
|
+
this._lastRenderedValue = propertyValue;
|
|
1663
1664
|
const serviceInput = {
|
|
1664
1665
|
propertyValue,
|
|
1665
1666
|
seedUid,
|
|
@@ -1746,7 +1747,12 @@ class ItemProperty {
|
|
|
1746
1747
|
}
|
|
1747
1748
|
if (skipTransform && !this._alias) ;
|
|
1748
1749
|
this._subject.next(renderValue);
|
|
1749
|
-
|
|
1750
|
+
if (context.seedLocalId) {
|
|
1751
|
+
eventEmitter.emit(`item.${itemModelName}.${context.seedLocalId}.update`);
|
|
1752
|
+
}
|
|
1753
|
+
if (context.seedUid) {
|
|
1754
|
+
eventEmitter.emit(`item.${itemModelName}.${context.seedUid}.update`);
|
|
1755
|
+
}
|
|
1750
1756
|
});
|
|
1751
1757
|
this._service.start();
|
|
1752
1758
|
}
|
|
@@ -3355,31 +3361,37 @@ class Item {
|
|
|
3355
3361
|
});
|
|
3356
3362
|
}
|
|
3357
3363
|
static create(props) {
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3364
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3365
|
+
if (props.seedUid || props.seedLocalId) {
|
|
3366
|
+
const seedId = props.seedUid || props.seedLocalId;
|
|
3367
|
+
if (Item.instanceCache.has(seedId)) {
|
|
3368
|
+
const { instance, refCount } = Item.instanceCache.get(seedId);
|
|
3369
|
+
Item.instanceCache.set(seedId, {
|
|
3370
|
+
instance,
|
|
3371
|
+
refCount: refCount + 1,
|
|
3372
|
+
});
|
|
3373
|
+
return instance;
|
|
3374
|
+
}
|
|
3375
|
+
if (!Item.instanceCache.has(props.seedLocalId)) {
|
|
3376
|
+
const newInstance = new Item(props);
|
|
3377
|
+
Item.instanceCache.set(seedId, {
|
|
3378
|
+
instance: newInstance,
|
|
3379
|
+
refCount: 1,
|
|
3380
|
+
});
|
|
3381
|
+
return newInstance;
|
|
3382
|
+
}
|
|
3375
3383
|
}
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3384
|
+
const { seedLocalId } = yield createNewItem({
|
|
3385
|
+
modelName: props.modelName,
|
|
3386
|
+
});
|
|
3387
|
+
props.seedLocalId = seedLocalId;
|
|
3388
|
+
const newInstance = new Item(props);
|
|
3389
|
+
Item.instanceCache.set(newInstance.seedUid || newInstance.seedLocalId, {
|
|
3390
|
+
instance: newInstance,
|
|
3391
|
+
refCount: 1,
|
|
3392
|
+
});
|
|
3393
|
+
return newInstance;
|
|
3381
3394
|
});
|
|
3382
|
-
return newInstance;
|
|
3383
3395
|
}
|
|
3384
3396
|
static find(_b) {
|
|
3385
3397
|
return __awaiter(this, arguments, void 0, function* ({ modelName, seedLocalId, seedUid, }) {
|
|
@@ -3399,7 +3411,7 @@ class Item {
|
|
|
3399
3411
|
const itemsData = yield getItemsData(modelName);
|
|
3400
3412
|
const itemInstances = [];
|
|
3401
3413
|
for (const itemData of itemsData) {
|
|
3402
|
-
itemInstances.push(Item.create(Object.assign(Object.assign({}, itemData), { modelName })));
|
|
3414
|
+
itemInstances.push(yield Item.create(Object.assign(Object.assign({}, itemData), { modelName })));
|
|
3403
3415
|
}
|
|
3404
3416
|
return orderBy(itemInstances, ['createdAt'], ['desc']);
|
|
3405
3417
|
});
|
|
@@ -4356,7 +4368,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4356
4368
|
if (!models$1) {
|
|
4357
4369
|
return;
|
|
4358
4370
|
}
|
|
4359
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
4371
|
+
const { models: SeedModels } = yield import('./seed.schema.config-CtfrG9dk.js');
|
|
4360
4372
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
4361
4373
|
let hasModelsInDb = false;
|
|
4362
4374
|
const schemaDefsByModelName = new Map();
|
|
@@ -5241,7 +5253,7 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
|
|
|
5241
5253
|
if (res.status !== 200) {
|
|
5242
5254
|
logger$8(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
5243
5255
|
excludedTransactions.add(transactionId);
|
|
5244
|
-
yield writeAppState(
|
|
5256
|
+
yield writeAppState('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
5245
5257
|
continue;
|
|
5246
5258
|
}
|
|
5247
5259
|
const dataString = yield arweave.transactions
|
|
@@ -5832,11 +5844,11 @@ const globalMachine = setup({
|
|
|
5832
5844
|
(_a) => __awaiter(void 0, [_a], void 0, function* ({ context }) {
|
|
5833
5845
|
let SeedClass;
|
|
5834
5846
|
if (context.environment === 'node') {
|
|
5835
|
-
const { SeedNode } = yield import('./seed-
|
|
5847
|
+
const { SeedNode } = yield import('./seed-Bj6wb5Jr.js');
|
|
5836
5848
|
SeedClass = SeedNode;
|
|
5837
5849
|
}
|
|
5838
5850
|
else {
|
|
5839
|
-
const { SeedBrowser } = yield import('./seed-
|
|
5851
|
+
const { SeedBrowser } = yield import('./seed-BpJsAlzT.js');
|
|
5840
5852
|
SeedClass = SeedBrowser;
|
|
5841
5853
|
}
|
|
5842
5854
|
return SeedClass;
|
|
@@ -6093,13 +6105,19 @@ const useGlobalServiceStatus = () => {
|
|
|
6093
6105
|
|
|
6094
6106
|
const logger$2 = debug('app:react:item');
|
|
6095
6107
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
6096
|
-
const [
|
|
6108
|
+
const [itemData, setItemData] = useImmer({});
|
|
6109
|
+
const [item, setItem] = useState();
|
|
6097
6110
|
const [itemSubscription, setItemSubscription] = useState();
|
|
6098
6111
|
const { status, internalStatus } = useGlobalServiceStatus();
|
|
6099
6112
|
const isReadingDb = useRef(false);
|
|
6100
6113
|
const itemStatus = useSelector(item === null || item === void 0 ? void 0 : item.getService(), (snapshot) => snapshot === null || snapshot === void 0 ? void 0 : snapshot.value);
|
|
6101
6114
|
const updateItem = useCallback((newItem) => {
|
|
6102
|
-
|
|
6115
|
+
setItemData((draft) => {
|
|
6116
|
+
Object.keys(newItem.properties).forEach((propertyName) => {
|
|
6117
|
+
const value = newItem[propertyName];
|
|
6118
|
+
draft[propertyName] = value;
|
|
6119
|
+
});
|
|
6120
|
+
});
|
|
6103
6121
|
}, []);
|
|
6104
6122
|
const readFromDb = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
6105
6123
|
if (isReadingDb.current ||
|
|
@@ -6117,12 +6135,17 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6117
6135
|
logger$2('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
6118
6136
|
return;
|
|
6119
6137
|
}
|
|
6138
|
+
setItem(foundItem);
|
|
6120
6139
|
updateItem(foundItem);
|
|
6121
6140
|
isReadingDb.current = false;
|
|
6122
6141
|
}), [internalStatus]);
|
|
6142
|
+
const listenerRef = useRef(readFromDb);
|
|
6143
|
+
useEffect(() => {
|
|
6144
|
+
listenerRef.current = readFromDb;
|
|
6145
|
+
}, [readFromDb]);
|
|
6123
6146
|
useEffect(() => {
|
|
6124
6147
|
if (internalStatus === 'ready') {
|
|
6125
|
-
|
|
6148
|
+
listenerRef.current();
|
|
6126
6149
|
}
|
|
6127
6150
|
}, [internalStatus, status]);
|
|
6128
6151
|
useEffect(() => {
|
|
@@ -6133,7 +6156,8 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6133
6156
|
logger$2('[useItem] [itemSubscription] no item found', modelName, seedLocalId);
|
|
6134
6157
|
return;
|
|
6135
6158
|
}
|
|
6136
|
-
|
|
6159
|
+
updateItem(newItem);
|
|
6160
|
+
setItem(newItem);
|
|
6137
6161
|
}));
|
|
6138
6162
|
setItemSubscription(subscription);
|
|
6139
6163
|
}
|
|
@@ -6143,13 +6167,16 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6143
6167
|
}, [item, itemSubscription]);
|
|
6144
6168
|
useEffect(() => {
|
|
6145
6169
|
const seedId = seedUid || seedLocalId;
|
|
6146
|
-
eventEmitter.addListener(`item.${modelName}.${seedId}.update`,
|
|
6170
|
+
eventEmitter.addListener(`item.${modelName}.${seedId}.update`, () => {
|
|
6171
|
+
listenerRef.current();
|
|
6172
|
+
});
|
|
6147
6173
|
return () => {
|
|
6148
6174
|
eventEmitter.removeListener(`item.${modelName}.${seedId}.update`, readFromDb);
|
|
6149
6175
|
};
|
|
6150
6176
|
}, []);
|
|
6151
6177
|
return {
|
|
6152
6178
|
item,
|
|
6179
|
+
itemData,
|
|
6153
6180
|
itemStatus,
|
|
6154
6181
|
};
|
|
6155
6182
|
};
|
|
@@ -6260,9 +6287,10 @@ const useDeleteItem = () => {
|
|
|
6260
6287
|
|
|
6261
6288
|
const logger$1 = debug('app:react:property');
|
|
6262
6289
|
const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
6263
|
-
const [property, setProperty] =
|
|
6290
|
+
const [property, setProperty] = useState();
|
|
6264
6291
|
const [isReadingFromDb, setIsReadingFromDb] = useState(false);
|
|
6265
6292
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
6293
|
+
// const isDbReady = useMemo(() => useIsDbReady(), [])
|
|
6266
6294
|
const { internalStatus } = useGlobalServiceStatus();
|
|
6267
6295
|
const value = useSelector(property === null || property === void 0 ? void 0 : property.getService(), (snapshot) => {
|
|
6268
6296
|
if (!snapshot || !snapshot.context) {
|
|
@@ -6277,8 +6305,7 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
6277
6305
|
// }
|
|
6278
6306
|
// }, [property, value])
|
|
6279
6307
|
const readFromDb = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
6280
|
-
if (
|
|
6281
|
-
internalStatus !== 'ready' ||
|
|
6308
|
+
if (internalStatus !== 'ready' ||
|
|
6282
6309
|
isReadingFromDb ||
|
|
6283
6310
|
(!seedLocalId && !seedUid)) {
|
|
6284
6311
|
return;
|
|
@@ -6289,6 +6316,7 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
6289
6316
|
seedLocalId,
|
|
6290
6317
|
seedUid,
|
|
6291
6318
|
});
|
|
6319
|
+
console.log(`[useItemPropertyTest] [readFromDb] ${propertyName} foundProperty`, foundProperty);
|
|
6292
6320
|
setIsReadingFromDb(false);
|
|
6293
6321
|
if (!foundProperty) {
|
|
6294
6322
|
logger$1(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
@@ -6297,15 +6325,34 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
6297
6325
|
if (foundProperty.status === 'waitingForDb') {
|
|
6298
6326
|
foundProperty.getService().send({ type: 'waitForDbSuccess' });
|
|
6299
6327
|
}
|
|
6300
|
-
setProperty(
|
|
6328
|
+
setProperty(foundProperty);
|
|
6301
6329
|
setIsInitialized(true);
|
|
6302
6330
|
}), [internalStatus, isReadingFromDb]);
|
|
6331
|
+
// let count = 0
|
|
6332
|
+
//
|
|
6333
|
+
// const refresh = useCallback(() => {
|
|
6334
|
+
// count++
|
|
6335
|
+
// console.log('[useItemPropertyTest] [refresh] property', property)
|
|
6336
|
+
// }, [property])
|
|
6303
6337
|
useEffect(() => {
|
|
6304
6338
|
if (internalStatus === 'ready') {
|
|
6305
|
-
console.log('[useItemPropertyTest] [useEffect] internalStatus is ready');
|
|
6306
6339
|
readFromDb();
|
|
6307
6340
|
}
|
|
6308
6341
|
}, [internalStatus]);
|
|
6342
|
+
// useEffect(() => {
|
|
6343
|
+
// eventEmitter.addListener(
|
|
6344
|
+
// `property.${seedUid || seedLocalId}.${propertyName}.update`,
|
|
6345
|
+
// (event) => {
|
|
6346
|
+
// refresh()
|
|
6347
|
+
// },
|
|
6348
|
+
// )
|
|
6349
|
+
//
|
|
6350
|
+
// return () => {
|
|
6351
|
+
// eventEmitter.removeListener(
|
|
6352
|
+
// `property.${seedUid || seedLocalId}.${propertyName}.update`,
|
|
6353
|
+
// )
|
|
6354
|
+
// }
|
|
6355
|
+
// }, [])
|
|
6309
6356
|
return {
|
|
6310
6357
|
property,
|
|
6311
6358
|
isInitialized,
|
|
@@ -6637,7 +6684,7 @@ const client = {
|
|
|
6637
6684
|
console.error('fs listeners not ready during init');
|
|
6638
6685
|
}
|
|
6639
6686
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6640
|
-
import('./seed.schema.config-
|
|
6687
|
+
import('./seed.schema.config-CtfrG9dk.js').then(({ models }) => {
|
|
6641
6688
|
for (const [key, value] of Object.entries(models)) {
|
|
6642
6689
|
setModel(key, value);
|
|
6643
6690
|
}
|
|
@@ -6694,4 +6741,4 @@ if (isNode()) {
|
|
|
6694
6741
|
}
|
|
6695
6742
|
|
|
6696
6743
|
export { CHILD_SNAPSHOT as C, GET_SCHEMAS as G, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, GET_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, internalMachine as h, itemMachineSingle as i, isNode as j, isBrowser as k, isReactNative as l, ImageSrc as m, ItemProperty as n, useItem as o, useItemProperties as p, useCreateItem as q, useItemProperty as r, useDeleteItem as s, useGlobalServiceStatus as t, useItems as u, useServices as v, withSeed as w, getGlobalService as x, client as y, getCorrectId as z };
|
|
6697
|
-
//# sourceMappingURL=index-
|
|
6744
|
+
//# sourceMappingURL=index-BvH0sjnH.js.map
|