@feathersjs/socketio-client 5.0.0-pre.21 → 5.0.0-pre.24

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 CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * **cli:** Add typed client to a generated app ([#2669](https://github.com/feathersjs/feathers/issues/2669)) ([5b801b5](https://github.com/feathersjs/feathers/commit/5b801b5017ddc3eaa95622b539f51d605916bc86))
12
+
13
+
14
+
15
+
16
+
17
+ # [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06)
18
+
19
+
20
+ ### Features
21
+
22
+ * **client:** Improve client side custom method support ([#2654](https://github.com/feathersjs/feathers/issues/2654)) ([c138acf](https://github.com/feathersjs/feathers/commit/c138acf50affbe6b66177d084d3c7a3e9220f09f))
23
+
24
+
25
+
26
+
27
+
28
+ # [5.0.0-pre.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24)
29
+
30
+ **Note:** Version bump only for package @feathersjs/socketio-client
31
+
32
+
33
+
34
+
35
+
6
36
  # [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23)
7
37
 
8
38
  **Note:** Version bump only for package @feathersjs/socketio-client
package/lib/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- import { Service, SocketService } from '@feathersjs/transport-commons/client';
1
+ import { SocketService } from '@feathersjs/transport-commons/client';
2
2
  import { Socket } from 'socket.io-client';
3
+ import { TransportConnection } from '@feathersjs/feathers';
3
4
  export { SocketService };
4
- export default function socketioClient(connection: Socket, options?: any): {
5
- (app: any): void;
6
- Service: typeof Service;
7
- service: (this: any, name: string) => Service<any, Partial<any>>;
8
- };
5
+ declare module '@feathersjs/feathers/lib/declarations' {
6
+ interface FeathersApplication<Services, Settings> {
7
+ /**
8
+ * The Socket.io client instance. Usually does not need
9
+ * to be accessed directly.
10
+ */
11
+ io?: Socket;
12
+ }
13
+ }
14
+ export default function socketioClient<Services = any>(connection: Socket, options?: any): TransportConnection<Services>;
package/lib/index.js CHANGED
@@ -22,6 +22,12 @@ function socketioClient(connection, options) {
22
22
  }
23
23
  app.io = connection;
24
24
  app.defaultService = defaultService;
25
+ app.mixins.unshift((service, _location, options) => {
26
+ if (options && options.methods && service instanceof client_1.Service) {
27
+ const customMethods = options.methods.filter((name) => !feathers_1.defaultServiceMethods.includes(name));
28
+ service.methods(...customMethods);
29
+ }
30
+ });
25
31
  };
26
32
  initialize.Service = client_1.Service;
27
33
  initialize.service = defaultService;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,iEAA8E;AAE9E,mDAAuD;AAIvD,SAAwB,cAAc,CAAE,UAAkB,EAAE,OAAa;IACvE,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,cAAc,GAAG,UAAqB,IAAY;QACtD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,0BAAe,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE;YAC1C,MAAM;YACN,IAAI;YACJ,UAAU;YACV,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;QAEH,OAAO,IAAI,gBAAO,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,UAAU,GAAQ;QACnC,IAAI,GAAG,CAAC,EAAE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CAAA;QACnC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;YACjD,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,YAAY,gBAAO,EAAE;gBAC5D,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,gCAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;gBAE7F,OAAO,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,CAAA;aAClC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,UAAU,CAAC,OAAO,GAAG,gBAAO,CAAA;IAC5B,UAAU,CAAC,OAAO,GAAG,cAAc,CAAA;IAEnC,OAAO,UAA2C,CAAA;AACpD,CAAC;AArCD,iCAqCC;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAC/D"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@feathersjs/socketio-client",
3
3
  "description": "The client for Socket.io through feathers-socketio",
4
- "version": "5.0.0-pre.21",
4
+ "version": "5.0.0-pre.24",
5
5
  "homepage": "https://feathersjs.com",
6
6
  "main": "lib/",
7
7
  "types": "lib/",
@@ -53,21 +53,21 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@feathersjs/transport-commons": "^5.0.0-pre.21"
56
+ "@feathersjs/transport-commons": "^5.0.0-pre.24"
57
57
  },
58
58
  "devDependencies": {
59
- "@feathersjs/commons": "^5.0.0-pre.20",
60
- "@feathersjs/feathers": "^5.0.0-pre.21",
61
- "@feathersjs/memory": "^5.0.0-pre.21",
62
- "@feathersjs/socketio": "^5.0.0-pre.21",
63
- "@feathersjs/tests": "^5.0.0-pre.21",
59
+ "@feathersjs/commons": "^5.0.0-pre.24",
60
+ "@feathersjs/feathers": "^5.0.0-pre.24",
61
+ "@feathersjs/memory": "^5.0.0-pre.24",
62
+ "@feathersjs/socketio": "^5.0.0-pre.24",
63
+ "@feathersjs/tests": "^5.0.0-pre.24",
64
64
  "@types/mocha": "^9.1.1",
65
- "@types/node": "^17.0.31",
65
+ "@types/node": "^17.0.40",
66
66
  "mocha": "^10.0.0",
67
67
  "shx": "^0.3.4",
68
- "socket.io-client": "^4.5.0",
69
- "ts-node": "^10.7.0",
70
- "typescript": "^4.6.4"
68
+ "socket.io-client": "^4.5.1",
69
+ "ts-node": "^10.8.1",
70
+ "typescript": "^4.7.3"
71
71
  },
72
- "gitHead": "ac3baed231f72370a80a06c5944538915479b96e"
72
+ "gitHead": "72779fa2938f43d7b345b6861ff0035481a07de3"
73
73
  }
package/src/index.ts CHANGED
@@ -1,41 +1,63 @@
1
- import { Service, SocketService } from '@feathersjs/transport-commons/client';
2
- import { Socket } from 'socket.io-client';
3
- import { defaultEventMap } from '@feathersjs/feathers';
4
-
5
- export { SocketService };
1
+ import { Service, SocketService } from '@feathersjs/transport-commons/client'
2
+ import { Socket } from 'socket.io-client'
3
+ import {
4
+ Application,
5
+ TransportConnection,
6
+ defaultEventMap,
7
+ defaultServiceMethods
8
+ } from '@feathersjs/feathers'
9
+
10
+ export { SocketService }
11
+
12
+ declare module '@feathersjs/feathers/lib/declarations' {
13
+ interface FeathersApplication<Services, Settings> {
14
+ /**
15
+ * The Socket.io client instance. Usually does not need
16
+ * to be accessed directly.
17
+ */
18
+ io?: Socket
19
+ }
20
+ }
6
21
 
7
- export default function socketioClient (connection: Socket, options?: any) {
22
+ export default function socketioClient<Services = any>(connection: Socket, options?: any) {
8
23
  if (!connection) {
9
- throw new Error('Socket.io connection needs to be provided');
24
+ throw new Error('Socket.io connection needs to be provided')
10
25
  }
11
26
 
12
27
  const defaultService = function (this: any, name: string) {
13
- const events = Object.values(defaultEventMap);
28
+ const events = Object.values(defaultEventMap)
14
29
  const settings = Object.assign({}, options, {
15
30
  events,
16
31
  name,
17
32
  connection,
18
33
  method: 'emit'
19
- });
34
+ })
20
35
 
21
- return new Service(settings);
22
- };
36
+ return new Service(settings) as any
37
+ }
23
38
 
24
- const initialize = function (app: any) {
39
+ const initialize = function (app: Application<Services>) {
25
40
  if (app.io !== undefined) {
26
- throw new Error('Only one default client provider can be configured');
41
+ throw new Error('Only one default client provider can be configured')
27
42
  }
28
43
 
29
- app.io = connection;
30
- app.defaultService = defaultService;
31
- };
44
+ app.io = connection as any
45
+ app.defaultService = defaultService
46
+ app.mixins.unshift((service, _location, options) => {
47
+ if (options && options.methods && service instanceof Service) {
48
+ const customMethods = options.methods.filter((name) => !defaultServiceMethods.includes(name))
49
+
50
+ service.methods(...customMethods)
51
+ }
52
+ })
53
+ }
32
54
 
33
- initialize.Service = Service;
34
- initialize.service = defaultService;
55
+ initialize.Service = Service
56
+ initialize.service = defaultService
35
57
 
36
- return initialize;
58
+ return initialize as TransportConnection<Services>
37
59
  }
38
60
 
39
61
  if (typeof module !== 'undefined') {
40
- module.exports = Object.assign(socketioClient, module.exports);
62
+ module.exports = Object.assign(socketioClient, module.exports)
41
63
  }