@stream-io/feeds-client 0.3.4 → 0.3.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/CHANGELOG.md +14 -0
- package/dist/cjs/index.js +2 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +1 -2
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +5 -7
- package/dist/es/react-bindings.mjs +1 -2
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{feeds-client-HvoTzr-z.js → feeds-client-47vliZx_.js} +37 -13
- package/dist/feeds-client-47vliZx_.js.map +1 -0
- package/dist/{feeds-client-CNHZvctN.mjs → feeds-client-Cd2LsXp-.mjs} +38 -14
- package/dist/feeds-client-Cd2LsXp-.mjs.map +1 -0
- package/dist/types/common/ApiClient.d.ts.map +1 -1
- package/dist/types/common/EventDispatcher.d.ts.map +1 -1
- package/dist/types/common/TokenManager.d.ts.map +1 -1
- package/dist/types/common/real-time/StableWSConnection.d.ts.map +1 -1
- package/dist/types/feed/feed.d.ts +1 -0
- package/dist/types/feed/feed.d.ts.map +1 -1
- package/dist/types/utils/deep-equal.d.ts +2 -0
- package/dist/types/utils/deep-equal.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts +2 -64
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/ApiClient.ts +2 -2
- package/src/common/EventDispatcher.ts +2 -2
- package/src/common/TokenManager.ts +2 -2
- package/src/common/real-time/StableWSConnection.ts +2 -2
- package/src/feed/feed.ts +24 -1
- package/src/feeds-client/feeds-client.ts +2 -2
- package/src/utils/deep-equal.ts +22 -0
- package/src/utils/ensure-exhausted.ts +2 -2
- package/src/utils/logger.ts +3 -4
- package/dist/feeds-client-CNHZvctN.mjs.map +0 -1
- package/dist/feeds-client-HvoTzr-z.js.map +0 -1
|
@@ -2996,8 +2996,7 @@ class FeedsApi {
|
|
|
2996
2996
|
return { ...response.body, metadata: response.metadata };
|
|
2997
2997
|
}
|
|
2998
2998
|
}
|
|
2999
|
-
const
|
|
3000
|
-
const getLogger = loggerInternal__namespace.getLogger;
|
|
2999
|
+
const feedsLoggerSystem = loggerInternal__namespace.createLoggerSystem();
|
|
3001
3000
|
const sleep = (m) => new Promise((resolve) => setTimeout(resolve, m));
|
|
3002
3001
|
function isFunction(value) {
|
|
3003
3002
|
return value && (Object.prototype.toString.call(value) === "[object Function]" || typeof value === "function" || value instanceof Function);
|
|
@@ -3112,7 +3111,7 @@ const capitalize = (s) => {
|
|
|
3112
3111
|
};
|
|
3113
3112
|
class TokenManager {
|
|
3114
3113
|
constructor() {
|
|
3115
|
-
this.logger = getLogger("token-manager");
|
|
3114
|
+
this.logger = feedsLoggerSystem.getLogger("token-manager");
|
|
3116
3115
|
this.setTokenOrProvider = (tokenOrProvider) => {
|
|
3117
3116
|
if (isFunction(tokenOrProvider)) {
|
|
3118
3117
|
this.tokenProvider = tokenOrProvider;
|
|
@@ -3229,7 +3228,7 @@ class ConnectionIdManager {
|
|
|
3229
3228
|
class EventDispatcher {
|
|
3230
3229
|
constructor() {
|
|
3231
3230
|
this.subscribers = {};
|
|
3232
|
-
this.logger = getLogger("event-dispatcher");
|
|
3231
|
+
this.logger = feedsLoggerSystem.getLogger("event-dispatcher");
|
|
3233
3232
|
this.dispatch = (event) => {
|
|
3234
3233
|
const listeners = [
|
|
3235
3234
|
...this.subscribers[event.type] ?? [],
|
|
@@ -3274,7 +3273,7 @@ class StableWSConnection {
|
|
|
3274
3273
|
this.connectionIdManager = connectionIdManager;
|
|
3275
3274
|
this.decoders = decoders2;
|
|
3276
3275
|
this.dispatcher = new EventDispatcher();
|
|
3277
|
-
this.logger = getLogger("stable-ws-connection");
|
|
3276
|
+
this.logger = feedsLoggerSystem.getLogger("stable-ws-connection");
|
|
3278
3277
|
this.on = this.dispatcher.on;
|
|
3279
3278
|
this.off = this.dispatcher.off;
|
|
3280
3279
|
this.offAll = this.dispatcher.offAll;
|
|
@@ -3782,14 +3781,14 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3782
3781
|
};
|
|
3783
3782
|
return result;
|
|
3784
3783
|
};
|
|
3785
|
-
const version = "0.3.
|
|
3784
|
+
const version = "0.3.6";
|
|
3786
3785
|
class ApiClient {
|
|
3787
3786
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
3788
3787
|
this.apiKey = apiKey;
|
|
3789
3788
|
this.tokenManager = tokenManager;
|
|
3790
3789
|
this.connectionIdManager = connectionIdManager;
|
|
3791
3790
|
this.extraHeaderInformation = {};
|
|
3792
|
-
this.logger = getLogger("api-client");
|
|
3791
|
+
this.logger = feedsLoggerSystem.getLogger("api-client");
|
|
3793
3792
|
this.sendRequest = async (method, url, pathParams, queryParams, body, requestContentType) => {
|
|
3794
3793
|
queryParams = queryParams ?? {};
|
|
3795
3794
|
queryParams.api_key = this.apiKey;
|
|
@@ -4566,7 +4565,7 @@ const isVideoFile = (file) => {
|
|
|
4566
4565
|
return file.type.startsWith("video/");
|
|
4567
4566
|
};
|
|
4568
4567
|
const ensureExhausted = (x, message) => {
|
|
4569
|
-
getLogger("helpers").warn(message, x);
|
|
4568
|
+
feedsLoggerSystem.getLogger("helpers").warn(message, x);
|
|
4570
4569
|
};
|
|
4571
4570
|
const shouldUpdateState = ({
|
|
4572
4571
|
stateUpdateQueueId,
|
|
@@ -6077,6 +6076,21 @@ function handleActivityFeedback(event) {
|
|
|
6077
6076
|
});
|
|
6078
6077
|
}
|
|
6079
6078
|
}
|
|
6079
|
+
const deepEqual = (x, y) => {
|
|
6080
|
+
if (x === y) {
|
|
6081
|
+
return true;
|
|
6082
|
+
} else if (typeof x == "object" && x != null && typeof y == "object" && y != null) {
|
|
6083
|
+
if (Object.keys(x).length != Object.keys(y).length) return false;
|
|
6084
|
+
for (const prop in x) {
|
|
6085
|
+
if (Object.prototype.hasOwnProperty.call(y, prop)) {
|
|
6086
|
+
if (!deepEqual(x[prop], y[prop])) return false;
|
|
6087
|
+
} else return false;
|
|
6088
|
+
}
|
|
6089
|
+
return true;
|
|
6090
|
+
} else {
|
|
6091
|
+
return false;
|
|
6092
|
+
}
|
|
6093
|
+
};
|
|
6080
6094
|
const _Feed = class _Feed extends FeedApi {
|
|
6081
6095
|
constructor(client, groupId, id, data, watch = false, addNewActivitiesTo = "start", activityAddedEventFilter) {
|
|
6082
6096
|
super(client, groupId, id);
|
|
@@ -6184,10 +6198,14 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6184
6198
|
async synchronize() {
|
|
6185
6199
|
const { last_get_or_create_request_config } = this.state.getLatestValue();
|
|
6186
6200
|
if (last_get_or_create_request_config?.watch) {
|
|
6201
|
+
this.inProgressGetOrCreate = void 0;
|
|
6187
6202
|
await this.getOrCreate(last_get_or_create_request_config);
|
|
6188
6203
|
}
|
|
6189
6204
|
}
|
|
6190
6205
|
async getOrCreate(request) {
|
|
6206
|
+
if (!request?.next && this.inProgressGetOrCreate && deepEqual(request, this.inProgressGetOrCreate.request)) {
|
|
6207
|
+
return this.inProgressGetOrCreate.promise;
|
|
6208
|
+
}
|
|
6191
6209
|
if (this.currentState.is_loading_activities) {
|
|
6192
6210
|
throw new Error("Only one getOrCreate call is allowed at a time");
|
|
6193
6211
|
}
|
|
@@ -6196,7 +6214,11 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6196
6214
|
is_loading_activities: true
|
|
6197
6215
|
});
|
|
6198
6216
|
try {
|
|
6199
|
-
const
|
|
6217
|
+
const responsePromise = super.getOrCreate(request);
|
|
6218
|
+
if (!request?.next) {
|
|
6219
|
+
this.inProgressGetOrCreate = { request, promise: responsePromise };
|
|
6220
|
+
}
|
|
6221
|
+
const response = await responsePromise;
|
|
6200
6222
|
const currentActivityFeeds = [];
|
|
6201
6223
|
for (const activity of response.activities) {
|
|
6202
6224
|
if (activity.current_feed) {
|
|
@@ -6268,6 +6290,9 @@ const _Feed = class _Feed extends FeedApi {
|
|
|
6268
6290
|
is_loading: false,
|
|
6269
6291
|
is_loading_activities: false
|
|
6270
6292
|
});
|
|
6293
|
+
if (!request?.next) {
|
|
6294
|
+
this.inProgressGetOrCreate = void 0;
|
|
6295
|
+
}
|
|
6271
6296
|
}
|
|
6272
6297
|
}
|
|
6273
6298
|
/**
|
|
@@ -7070,7 +7095,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7070
7095
|
this.connectionIdManager = connectionIdManager;
|
|
7071
7096
|
this.polls_by_id = /* @__PURE__ */ new Map();
|
|
7072
7097
|
this.query_batch_own_capabilties_throttling_interval = options?.query_batch_own_capabilties_throttling_interval ?? DEFAULT_BATCH_OWN_CAPABILITIES_THROTTLING_INTERVAL;
|
|
7073
|
-
configureLoggers(options?.configure_loggers_options);
|
|
7098
|
+
feedsLoggerSystem.configureLoggers(options?.configure_loggers_options);
|
|
7074
7099
|
this.on("all", (event) => {
|
|
7075
7100
|
const fid = event.fid;
|
|
7076
7101
|
const feed = typeof fid === "string" ? this.activeFeeds[fid] : void 0;
|
|
@@ -7316,10 +7341,9 @@ exports.FeedsClient = FeedsClient;
|
|
|
7316
7341
|
exports.StreamApiError = StreamApiError;
|
|
7317
7342
|
exports.StreamPoll = StreamPoll;
|
|
7318
7343
|
exports.checkHasAnotherPage = checkHasAnotherPage;
|
|
7319
|
-
exports.configureLoggers = configureLoggers;
|
|
7320
7344
|
exports.debounce = debounce;
|
|
7321
7345
|
exports.ensureExhausted = ensureExhausted;
|
|
7322
|
-
exports.
|
|
7346
|
+
exports.feedsLoggerSystem = feedsLoggerSystem;
|
|
7323
7347
|
exports.getStateUpdateQueueId = getStateUpdateQueueId;
|
|
7324
7348
|
exports.isCommentResponse = isCommentResponse;
|
|
7325
7349
|
exports.isFollowResponse = isFollowResponse;
|
|
@@ -7331,4 +7355,4 @@ exports.replaceUniqueArrayMerge = replaceUniqueArrayMerge;
|
|
|
7331
7355
|
exports.shouldUpdateState = shouldUpdateState;
|
|
7332
7356
|
exports.uniqueArrayMerge = uniqueArrayMerge;
|
|
7333
7357
|
exports.updateEntityInArray = updateEntityInArray;
|
|
7334
|
-
//# sourceMappingURL=feeds-client-
|
|
7358
|
+
//# sourceMappingURL=feeds-client-47vliZx_.js.map
|