@akanjs/signal 0.9.60-canary.1 → 0.9.60-canary.3
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/cjs/src/client.js +7 -2
- package/cjs/src/fetchInfo.js +12 -14
- package/esm/src/client.js +7 -2
- package/esm/src/fetchInfo.js +12 -14
- package/package.json +1 -1
- package/src/client.d.ts +4 -1
package/cjs/src/client.js
CHANGED
|
@@ -50,8 +50,13 @@ class SocketIo {
|
|
|
50
50
|
hasListeners(event) {
|
|
51
51
|
return this.socket.hasListeners(event);
|
|
52
52
|
}
|
|
53
|
-
emit(key, data) {
|
|
54
|
-
this.socket
|
|
53
|
+
emit(key, data, { volatile = false, timeout } = {}) {
|
|
54
|
+
let socket = this.socket;
|
|
55
|
+
if (volatile)
|
|
56
|
+
socket = socket.volatile;
|
|
57
|
+
if (timeout)
|
|
58
|
+
socket = socket.timeout(timeout);
|
|
59
|
+
socket.emit(key, data);
|
|
55
60
|
}
|
|
56
61
|
subscribe(option) {
|
|
57
62
|
if (!this.roomSubscribeMap.has(option.roomId)) {
|
package/cjs/src/fetchInfo.js
CHANGED
|
@@ -230,11 +230,13 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
230
230
|
modelSortKeys: `${fieldName}SortKeys`
|
|
231
231
|
};
|
|
232
232
|
const fetch = serviceFetchOf(signal);
|
|
233
|
+
const fetchInstance = typeof global !== "undefined" ? global.fetch : window.fetch;
|
|
233
234
|
const util = {
|
|
235
|
+
// TODO: migrate file endpoint to shared
|
|
234
236
|
[names.addModelFiles]: async (files, id, option2) => {
|
|
235
237
|
const metas = Array.from(files).map((file) => ({ lastModifiedAt: new Date(file.lastModified), size: file.size }));
|
|
236
238
|
//! will not work properly
|
|
237
|
-
return await
|
|
239
|
+
return await fetchInstance[names.addFiles](
|
|
238
240
|
files,
|
|
239
241
|
metas,
|
|
240
242
|
names.model,
|
|
@@ -243,14 +245,14 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
243
245
|
);
|
|
244
246
|
},
|
|
245
247
|
[names.mergeModel]: async (modelOrId, data, option2) => {
|
|
246
|
-
const model = typeof modelOrId === "string" ? await
|
|
248
|
+
const model = typeof modelOrId === "string" ? await fetchInstance[names._model](modelOrId) : modelOrId;
|
|
247
249
|
const input = cnst.purify({ ...model, ...data });
|
|
248
250
|
if (!input)
|
|
249
251
|
throw new Error("Error");
|
|
250
|
-
return await
|
|
252
|
+
return await fetchInstance[names.updateModel](model.id, input, option2);
|
|
251
253
|
},
|
|
252
254
|
[names.viewModel]: async (id, option2) => {
|
|
253
|
-
const modelObj = await
|
|
255
|
+
const modelObj = await fetchInstance[names._model](id, option2);
|
|
254
256
|
return {
|
|
255
257
|
[names.model]: cnst.crystalize(modelObj),
|
|
256
258
|
[names.modelView]: {
|
|
@@ -261,7 +263,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
261
263
|
};
|
|
262
264
|
},
|
|
263
265
|
[names.getModelView]: async (id, option2) => {
|
|
264
|
-
const modelView = await
|
|
266
|
+
const modelView = await fetchInstance[names._model](id, option2);
|
|
265
267
|
return {
|
|
266
268
|
refName: names.model,
|
|
267
269
|
[names.modelObj]: modelView,
|
|
@@ -269,7 +271,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
269
271
|
};
|
|
270
272
|
},
|
|
271
273
|
[names.editModel]: async (id, option2) => {
|
|
272
|
-
const modelObj = await
|
|
274
|
+
const modelObj = await fetchInstance[names._model](id, option2);
|
|
273
275
|
return {
|
|
274
276
|
[names.model]: cnst.crystalize(modelObj),
|
|
275
277
|
[names.modelEdit]: {
|
|
@@ -280,7 +282,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
280
282
|
};
|
|
281
283
|
},
|
|
282
284
|
[names.getModelEdit]: async (id, option2) => {
|
|
283
|
-
const modelEdit = await
|
|
285
|
+
const modelEdit = await fetchInstance[names.editModel](id, option2);
|
|
284
286
|
return modelEdit[names.modelEdit];
|
|
285
287
|
},
|
|
286
288
|
[names.modelSortKeys]: signal.filter?.sortKeys
|
|
@@ -309,14 +311,14 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
309
311
|
const { page = 1, limit = 20, sort = "latest", insight } = fetchInitOption;
|
|
310
312
|
const skip = (page - 1) * limit;
|
|
311
313
|
const [modelObjList, modelObjInsight] = await Promise.all([
|
|
312
|
-
|
|
314
|
+
fetchInstance[`_${namesOfSlice.modelList}`](
|
|
313
315
|
...queryArgs,
|
|
314
316
|
skip,
|
|
315
317
|
limit,
|
|
316
318
|
sort,
|
|
317
319
|
fetchInitOption
|
|
318
320
|
),
|
|
319
|
-
|
|
321
|
+
fetchInstance[`_${namesOfSlice.modelInsight}`](
|
|
320
322
|
...queryArgs,
|
|
321
323
|
fetchInitOption
|
|
322
324
|
)
|
|
@@ -356,11 +358,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
356
358
|
return [...acc, [namesOfSlice.getModelInit, getInitFn], [namesOfSlice.initModel, initFn]];
|
|
357
359
|
}, [])
|
|
358
360
|
);
|
|
359
|
-
const modelGql = Object.assign(fetch, {
|
|
360
|
-
...util,
|
|
361
|
-
...sliceUtil
|
|
362
|
-
// slices: [...overwriteSlices, ...sigMeta.slices],
|
|
363
|
-
});
|
|
361
|
+
const modelGql = Object.assign(fetch, { ...util, ...sliceUtil });
|
|
364
362
|
(0, import_gql.setGqlOnStorage)(signal.refName, modelGql);
|
|
365
363
|
return modelGql;
|
|
366
364
|
};
|
package/esm/src/client.js
CHANGED
|
@@ -28,8 +28,13 @@ class SocketIo {
|
|
|
28
28
|
hasListeners(event) {
|
|
29
29
|
return this.socket.hasListeners(event);
|
|
30
30
|
}
|
|
31
|
-
emit(key, data) {
|
|
32
|
-
this.socket
|
|
31
|
+
emit(key, data, { volatile = false, timeout } = {}) {
|
|
32
|
+
let socket = this.socket;
|
|
33
|
+
if (volatile)
|
|
34
|
+
socket = socket.volatile;
|
|
35
|
+
if (timeout)
|
|
36
|
+
socket = socket.timeout(timeout);
|
|
37
|
+
socket.emit(key, data);
|
|
33
38
|
}
|
|
34
39
|
subscribe(option) {
|
|
35
40
|
if (!this.roomSubscribeMap.has(option.roomId)) {
|
package/esm/src/fetchInfo.js
CHANGED
|
@@ -207,11 +207,13 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
207
207
|
modelSortKeys: `${fieldName}SortKeys`
|
|
208
208
|
};
|
|
209
209
|
const fetch = serviceFetchOf(signal);
|
|
210
|
+
const fetchInstance = typeof global !== "undefined" ? global.fetch : window.fetch;
|
|
210
211
|
const util = {
|
|
212
|
+
// TODO: migrate file endpoint to shared
|
|
211
213
|
[names.addModelFiles]: async (files, id, option2) => {
|
|
212
214
|
const metas = Array.from(files).map((file) => ({ lastModifiedAt: new Date(file.lastModified), size: file.size }));
|
|
213
215
|
//! will not work properly
|
|
214
|
-
return await
|
|
216
|
+
return await fetchInstance[names.addFiles](
|
|
215
217
|
files,
|
|
216
218
|
metas,
|
|
217
219
|
names.model,
|
|
@@ -220,14 +222,14 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
220
222
|
);
|
|
221
223
|
},
|
|
222
224
|
[names.mergeModel]: async (modelOrId, data, option2) => {
|
|
223
|
-
const model = typeof modelOrId === "string" ? await
|
|
225
|
+
const model = typeof modelOrId === "string" ? await fetchInstance[names._model](modelOrId) : modelOrId;
|
|
224
226
|
const input = cnst.purify({ ...model, ...data });
|
|
225
227
|
if (!input)
|
|
226
228
|
throw new Error("Error");
|
|
227
|
-
return await
|
|
229
|
+
return await fetchInstance[names.updateModel](model.id, input, option2);
|
|
228
230
|
},
|
|
229
231
|
[names.viewModel]: async (id, option2) => {
|
|
230
|
-
const modelObj = await
|
|
232
|
+
const modelObj = await fetchInstance[names._model](id, option2);
|
|
231
233
|
return {
|
|
232
234
|
[names.model]: cnst.crystalize(modelObj),
|
|
233
235
|
[names.modelView]: {
|
|
@@ -238,7 +240,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
238
240
|
};
|
|
239
241
|
},
|
|
240
242
|
[names.getModelView]: async (id, option2) => {
|
|
241
|
-
const modelView = await
|
|
243
|
+
const modelView = await fetchInstance[names._model](id, option2);
|
|
242
244
|
return {
|
|
243
245
|
refName: names.model,
|
|
244
246
|
[names.modelObj]: modelView,
|
|
@@ -246,7 +248,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
246
248
|
};
|
|
247
249
|
},
|
|
248
250
|
[names.editModel]: async (id, option2) => {
|
|
249
|
-
const modelObj = await
|
|
251
|
+
const modelObj = await fetchInstance[names._model](id, option2);
|
|
250
252
|
return {
|
|
251
253
|
[names.model]: cnst.crystalize(modelObj),
|
|
252
254
|
[names.modelEdit]: {
|
|
@@ -257,7 +259,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
257
259
|
};
|
|
258
260
|
},
|
|
259
261
|
[names.getModelEdit]: async (id, option2) => {
|
|
260
|
-
const modelEdit = await
|
|
262
|
+
const modelEdit = await fetchInstance[names.editModel](id, option2);
|
|
261
263
|
return modelEdit[names.modelEdit];
|
|
262
264
|
},
|
|
263
265
|
[names.modelSortKeys]: signal.filter?.sortKeys
|
|
@@ -286,14 +288,14 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
286
288
|
const { page = 1, limit = 20, sort = "latest", insight } = fetchInitOption;
|
|
287
289
|
const skip = (page - 1) * limit;
|
|
288
290
|
const [modelObjList, modelObjInsight] = await Promise.all([
|
|
289
|
-
|
|
291
|
+
fetchInstance[`_${namesOfSlice.modelList}`](
|
|
290
292
|
...queryArgs,
|
|
291
293
|
skip,
|
|
292
294
|
limit,
|
|
293
295
|
sort,
|
|
294
296
|
fetchInitOption
|
|
295
297
|
),
|
|
296
|
-
|
|
298
|
+
fetchInstance[`_${namesOfSlice.modelInsight}`](
|
|
297
299
|
...queryArgs,
|
|
298
300
|
fetchInitOption
|
|
299
301
|
)
|
|
@@ -333,11 +335,7 @@ const databaseFetchOf = (signal, option = {}) => {
|
|
|
333
335
|
return [...acc, [namesOfSlice.getModelInit, getInitFn], [namesOfSlice.initModel, initFn]];
|
|
334
336
|
}, [])
|
|
335
337
|
);
|
|
336
|
-
const modelGql = Object.assign(fetch, {
|
|
337
|
-
...util,
|
|
338
|
-
...sliceUtil
|
|
339
|
-
// slices: [...overwriteSlices, ...sigMeta.slices],
|
|
340
|
-
});
|
|
338
|
+
const modelGql = Object.assign(fetch, { ...util, ...sliceUtil });
|
|
341
339
|
setGqlOnStorage(signal.refName, modelGql);
|
|
342
340
|
return modelGql;
|
|
343
341
|
};
|
package/package.json
CHANGED
package/src/client.d.ts
CHANGED
|
@@ -17,7 +17,10 @@ declare class SocketIo {
|
|
|
17
17
|
removeListener(event: string, callback?: (data: any) => void): void;
|
|
18
18
|
removeAllListeners(): void;
|
|
19
19
|
hasListeners(event: string): boolean;
|
|
20
|
-
emit(key: string, data: any
|
|
20
|
+
emit(key: string, data: any, { volatile, timeout }?: {
|
|
21
|
+
volatile?: boolean;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
}): void;
|
|
21
24
|
subscribe(option: {
|
|
22
25
|
key: string;
|
|
23
26
|
roomId: string;
|