From 3d05a6b2775c19bfe95784bd4249756613fab03d Mon Sep 17 00:00:00 2001 From: kizahasi <21971954+kizahasi@users.noreply.github.com> Date: Sat, 18 Feb 2023 09:13:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(web-server):=20=E3=83=A1=E3=83=83=E3=82=BB?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=8C=E8=BF=BD=E5=8A=A0=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=81=A8=E3=81=8D=E3=80=81=E5=A4=9A=E9=87=8D=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=95=E3=82=8C=E3=82=8B=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E3=81=8A?= =?UTF-8?q?=E3=81=9D=E3=82=89=E3=81=8F=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/sdk-urql/dist/cjs/index.js | 26 ++++++------- packages/sdk-urql/dist/cjs/index.js.map | 2 +- .../cjs/internal/createGraphQLClient.d.ts.map | 2 +- packages/sdk-urql/dist/esm/index.js | 30 +++++++-------- packages/sdk-urql/dist/esm/index.js.map | 2 +- .../esm/internal/createGraphQLClient.d.ts.map | 2 +- .../src/internal/createGraphQLClient.ts | 38 ++++++++++--------- 7 files changed, 50 insertions(+), 52 deletions(-) diff --git a/packages/sdk-urql/dist/cjs/index.js b/packages/sdk-urql/dist/cjs/index.js index 766023b90..a4ab05b65 100644 --- a/packages/sdk-urql/dist/cjs/index.js +++ b/packages/sdk-urql/dist/cjs/index.js @@ -140,21 +140,19 @@ const createGraphQLClientForRoomClient = (client) => { return result.Result.error(result$1.error); }), roomEventSubscription: variables => { - const roomEventSubscriptionSource = client.subscription(typedDocumentNodeV0_7_1.RoomEventDocument, variables); - const roomEventSubscriptionAsWonkaObservable = wonka.toObservable(roomEventSubscriptionSource); - return new rxjs.Observable(observer => { - return roomEventSubscriptionAsWonkaObservable.subscribe({ - next: value => { - if (value.data != null) { - observer.next(result.Result.ok(value.data)); - return; - } - observer.next(result.Result.error(value.error)); - }, - error: e => observer.error(e), - complete: () => observer.complete(), - }); + // 当初は、client.subscription() の戻り値を wonka の toObservable で wonka の Observable に変換して、それを RxJS の Observable に変換していた。 + // だがこの方法だと unsubscribe が効かないという問題が発生したため、toObservable を使わずに実装している。 + const observable = new rxjs.Observable(observer => { + const subscription = wonka.pipe(client.subscription(typedDocumentNodeV0_7_1.RoomEventDocument, variables), wonka.subscribe(value => { + if (value.data != null) { + observer.next(result.Result.ok(value.data)); + return; + } + observer.next(result.Result.error(value.error)); + })); + return subscription; }); + return observable.pipe(rxjs.share()); }, }; }; diff --git a/packages/sdk-urql/dist/cjs/index.js.map b/packages/sdk-urql/dist/cjs/index.js.map index 9190a78a1..24cf6bedc 100644 --- a/packages/sdk-urql/dist/cjs/index.js.map +++ b/packages/sdk-urql/dist/cjs/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../../src/internal/createUrqlClient.ts","../../../src/internal/createGraphQLClient.ts"],"sourcesContent":[null,null],"names":["createWsClient","authToken","authExchange","makeOperation","dedupExchange","cacheExchange","fetchExchange","subscriptionExchange","createClient","GetMessagesDocument","result","Result","GetRoomConnectionsDocument","GetRoomDocument","OperateDocument","UpdateWritingMessageStatusDocument","RoomEventDocument","toObservable","Observable"],"mappings":";;;;;;;;;;;AAeA,MAAM,wBAAwB,GAAG,OAC7B,MAA4B,KACG;IAC/B,IAAI,MAAM,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;IACD,OAAO,MAAM,MAAM,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,cAAoC,KACjEA,sBAAc,CAAC;AACX,IAAA,GAAG,EAAE,KAAK;IACV,gBAAgB,EAAE,YAAW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,aAAM,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;4BACrC,OAAO;AACV,yBAAA;AACD,wBAAA,QAAQ,CAAC,IAAI,CAACA,aAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAM,CAAC,CAAC,CAAC;qBAC7C;oBACD,KAAK,EAAE,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,oBAAA,QAAQ,EAAE,MAAM,QAAQ,CAAC,QAAQ,EAAE;AACtC,iBAAA,CAAC,CAAC;AACP,aAAC,CAAC,CAAC;SACN;KACJ,CAAC;AACN;;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../../../src/internal/createUrqlClient.ts","../../../src/internal/createGraphQLClient.ts"],"sourcesContent":[null,null],"names":["createWsClient","authToken","authExchange","makeOperation","dedupExchange","cacheExchange","fetchExchange","subscriptionExchange","createClient","GetMessagesDocument","result","Result","GetRoomConnectionsDocument","GetRoomDocument","OperateDocument","UpdateWritingMessageStatusDocument","Observable","pipe","RoomEventDocument","subscribe","share"],"mappings":";;;;;;;;;;;AAeA,MAAM,wBAAwB,GAAG,OAC7B,MAA4B,KACG;IAC/B,IAAI,MAAM,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;IACD,OAAO,MAAM,MAAM,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,cAAoC,KACjEA,sBAAc,CAAC;AACX,IAAA,GAAG,EAAE,KAAK;IACV,gBAAgB,EAAE,YAAW;AACzB,QAAA,MAAM,aAAa,GAAG,MAAM,wBAAwB,CAAC,cAAc,CAAC,CAAC;QACrE,IAAI,aAAa,IAAI,IAAI,EAAE;AACvB,YAAA,OAAO,EAAE,CAAC;AACb,SAAA;QACD,OAAO,EAAE,CAACC,cAAS,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;KAC/C;AACJ,CAAA,CAAC,CAA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AAC;SACnC;KACJ,CAAC;AACN;;;;;"} \ No newline at end of file diff --git a/packages/sdk-urql/dist/cjs/internal/createGraphQLClient.d.ts.map b/packages/sdk-urql/dist/cjs/internal/createGraphQLClient.d.ts.map index f65b91b41..666dc48fc 100644 --- a/packages/sdk-urql/dist/cjs/internal/createGraphQLClient.d.ts.map +++ b/packages/sdk-urql/dist/cjs/internal/createGraphQLClient.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"createGraphQLClient.d.ts","sourceRoot":"","sources":["../../../src/internal/createGraphQLClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAG7C,eAAO,MAAM,gCAAgC,WAAY,MAAM,KAAG,cAAc,aAAa,CA0E5F,CAAC"} \ No newline at end of file +{"version":3,"file":"createGraphQLClient.d.ts","sourceRoot":"","sources":["../../../src/internal/createGraphQLClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAG7C,eAAO,MAAM,gCAAgC,WAAY,MAAM,KAAG,cAAc,aAAa,CA4E5F,CAAC"} \ No newline at end of file diff --git a/packages/sdk-urql/dist/esm/index.js b/packages/sdk-urql/dist/esm/index.js index 61996110c..a29857941 100644 --- a/packages/sdk-urql/dist/esm/index.js +++ b/packages/sdk-urql/dist/esm/index.js @@ -4,8 +4,8 @@ import { createClient as createClient$1 } from 'graphql-ws'; import { makeOperation, dedupExchange, cacheExchange, fetchExchange, subscriptionExchange, createClient } from 'urql'; import { GetMessagesDocument, GetRoomConnectionsDocument, GetRoomDocument, OperateDocument, UpdateWritingMessageStatusDocument, RoomEventDocument } from '@flocon-trpg/typed-document-node-v0.7.1'; import { Result } from '@kizahasi/result'; -import { Observable } from 'rxjs'; -import { toObservable } from 'wonka'; +import { Observable, share } from 'rxjs'; +import { pipe, subscribe } from 'wonka'; const execGetUserIdTokenResult = async (source) => { if (source == null) { @@ -138,21 +138,19 @@ const createGraphQLClientForRoomClient = (client) => { return Result.error(result.error); }), roomEventSubscription: variables => { - const roomEventSubscriptionSource = client.subscription(RoomEventDocument, variables); - const roomEventSubscriptionAsWonkaObservable = toObservable(roomEventSubscriptionSource); - return new Observable(observer => { - return roomEventSubscriptionAsWonkaObservable.subscribe({ - next: value => { - if (value.data != null) { - observer.next(Result.ok(value.data)); - return; - } - observer.next(Result.error(value.error)); - }, - error: e => observer.error(e), - complete: () => observer.complete(), - }); + // 当初は、client.subscription() の戻り値を wonka の toObservable で wonka の Observable に変換して、それを RxJS の Observable に変換していた。 + // だがこの方法だと unsubscribe が効かないという問題が発生したため、toObservable を使わずに実装している。 + const observable = new Observable(observer => { + const subscription = pipe(client.subscription(RoomEventDocument, variables), subscribe(value => { + if (value.data != null) { + observer.next(Result.ok(value.data)); + return; + } + observer.next(Result.error(value.error)); + })); + return subscription; }); + return observable.pipe(share()); }, }; }; diff --git a/packages/sdk-urql/dist/esm/index.js.map b/packages/sdk-urql/dist/esm/index.js.map index 6d7d3cc53..97e1318d9 100644 --- a/packages/sdk-urql/dist/esm/index.js.map +++ b/packages/sdk-urql/dist/esm/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../../src/internal/createUrqlClient.ts","../../../src/internal/createGraphQLClient.ts"],"sourcesContent":[null,null],"names":["createWsClient"],"mappings":";;;;;;;;;AAeA,MAAM,wBAAwB,GAAG,OAC7B,MAA4B,KACG;IAC/B,IAAI,MAAM,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;IACD,OAAO,MAAM,MAAM,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,cAAoC,KACjEA,cAAc,CAAC;AACX,IAAA,GAAG,EAAE,KAAK;IACV,g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C,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;4BACrC,OAAO;AACV,yBAAA;AACD,wBAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAM,CAAC,CAAC,CAAC;qBAC7C;oBACD,KAAK,EAAE,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,oBAAA,QAAQ,EAAE,MAAM,QAAQ,CAAC,QAAQ,EAAE;AACtC,iBAAA,CAAC,CAAC;AACP,aAAC,CAAC,CAAC;SACN;KACJ,CAAC;AACN;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../../../src/internal/createUrqlClient.ts","../../../src/internal/createGraphQLClient.ts"],"sourcesContent":[null,null],"names":["createWsClient"],"mappings":";;;;;;;;;AAeA,MAAM,wBAAwB,GAAG,OAC7B,MAA4B,KACG;IAC/B,IAAI,MAAM,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;IACD,OAAO,MAAM,MAAM,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,cAAoC,KACjEA,cAAc,CAAC;AACX,IAAA,GAAG,EAAE,KAAK;IACV,gBAAgB,EAAE,YAAW;AACzB,QAAA,MAAM,aAAa,GAAG,MAAM,wBAAwB,CAAC,cAAc,CAAC,CAAC;QACrE,IAAI,aAAa,IAAI,IAAI,EAAE;AACvB,YAAA,OAAO,EAAE,CAAC;AACb,SAAA;QACD,OAAO,EAAE,CAAC,SAAS,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;KAC/C;AACJ,CAAA,CAAC,CAAC;AAiCM,MAAA,gBAAgB,GAAG,CAAC,MAAc,KAAI;AAC/C,IAAA,IAAI,kBAAmC,CAAC;IACxC,IAAI,MAAM,CAAC,aAAa,EAAE;AACtB,QAAA,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;QACzD,kBAAkB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C;AACV,QAAA,mCAAmC,EAAE,SAAS,IAC1C,MAAM;AACD,aAAA,QAAQ,CAAC,kCAAkC,EAAE,SAAS,CAAC;AACvD,aAAA,SAAS,EAAE;aACX,IAAI,CAAC,MAAM,IAAG;AACX,YAAA,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE;gBACrB,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjC,aAAA;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAM,CAAC,CAAC;AACvC,SAAC,CAAC;QACV,qBAAqB,EAAE,SAAS,IAAG;;;AAI/B,YAAA,MAAM,UAAU,GAAG,IAAI,UAAU,CAC7B,QAAQ,IAAG;AACP,gBAAA,MAAM,YAAY,GAAG,IAAI,CACrB,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,SAAS,CAAC,EACjD,SAAS,CAAC,KAAK,IAAG;AACd,oBAAA,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE;AACpB,wBAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBACrC,OAAO;AACV,qBAAA;AACD,oBAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAM,CAAC,CAAC,CAAC;iBAC7C,CAAC,CACL,CAAC;AACF,gBAAA,OAAO,YAAY,CAAC;AACxB,aAAC,CACJ,CAAC;AACF,YAAA,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SACnC;KACJ,CAAC;AACN;;;;"} \ No newline at end of file diff --git a/packages/sdk-urql/dist/esm/internal/createGraphQLClient.d.ts.map b/packages/sdk-urql/dist/esm/internal/createGraphQLClient.d.ts.map index f65b91b41..666dc48fc 100644 --- a/packages/sdk-urql/dist/esm/internal/createGraphQLClient.d.ts.map +++ b/packages/sdk-urql/dist/esm/internal/createGraphQLClient.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"createGraphQLClient.d.ts","sourceRoot":"","sources":["../../../src/internal/createGraphQLClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAG7C,eAAO,MAAM,gCAAgC,WAAY,MAAM,KAAG,cAAc,aAAa,CA0E5F,CAAC"} \ No newline at end of file +{"version":3,"file":"createGraphQLClient.d.ts","sourceRoot":"","sources":["../../../src/internal/createGraphQLClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAG7C,eAAO,MAAM,gCAAgC,WAAY,MAAM,KAAG,cAAc,aAAa,CA4E5F,CAAC"} \ No newline at end of file diff --git a/packages/sdk-urql/src/internal/createGraphQLClient.ts b/packages/sdk-urql/src/internal/createGraphQLClient.ts index 49d5c0023..079ce31e6 100644 --- a/packages/sdk-urql/src/internal/createGraphQLClient.ts +++ b/packages/sdk-urql/src/internal/createGraphQLClient.ts @@ -9,9 +9,9 @@ import { UpdateWritingMessageStatusDocument, } from '@flocon-trpg/typed-document-node-v0.7.1'; import { Result } from '@kizahasi/result'; -import { Observable } from 'rxjs'; +import { Observable, share } from 'rxjs'; import { Client, CombinedError } from 'urql'; -import { toObservable } from 'wonka'; +import { pipe, subscribe } from 'wonka'; export const createGraphQLClientForRoomClient = (client: Client): GraphQLClient => { return { @@ -68,23 +68,25 @@ export const createGraphQLClientForRoomClient = (client: Client): GraphQLClient< return Result.error(result.error!); }), roomEventSubscription: variables => { - const roomEventSubscriptionSource = client.subscription(RoomEventDocument, variables); - const roomEventSubscriptionAsWonkaObservable = toObservable( - roomEventSubscriptionSource + // 当初は、client.subscription() の戻り値を wonka の toObservable で wonka の Observable に変換して、それを RxJS の Observable に変換していた。 + // だがこの方法だと unsubscribe が効かないという問題が発生したため、toObservable を使わずに実装している。 + + const observable = new Observable>( + observer => { + const subscription = pipe( + client.subscription(RoomEventDocument, variables), + subscribe(value => { + if (value.data != null) { + observer.next(Result.ok(value.data)); + return; + } + observer.next(Result.error(value.error!)); + }) + ); + return subscription; + } ); - return new Observable>(observer => { - return roomEventSubscriptionAsWonkaObservable.subscribe({ - next: value => { - if (value.data != null) { - observer.next(Result.ok(value.data)); - return; - } - observer.next(Result.error(value.error!)); - }, - error: e => observer.error(e), - complete: () => observer.complete(), - }); - }); + return observable.pipe(share()); }, }; };