@polytric/openws-sdkgen 0.0.16 → 0.0.17

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.
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "files": ["dist"],
25
25
  "dependencies": {
26
- "@polytric/openws": "^0.0.9"
26
+ "@polytric/openws": "^0.0.10"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsup",
@@ -57,11 +57,11 @@ export type <%= ctx.className %>ErrorHandler = (error: unknown) => void | Promis
57
57
  /**
58
58
  * Application callback for connection lifecycle events.
59
59
  */
60
- export type <%= ctx.className %>LifecycleHandler = (roleName: string) => void | Promise<void>
60
+ export type <%= ctx.className %>LifecycleHandler = (roleName: string, peer: <%= ctx.className %>Peer) => void | Promise<void>
61
61
  /**
62
62
  * Application callback for connection lifecycle errors.
63
63
  */
64
- export type <%= ctx.className %>LifecycleErrorHandler = (roleName: string, error: Error) => void | Promise<void>
64
+ export type <%= ctx.className %>LifecycleErrorHandler = (roleName: string, peer: <%= ctx.className %>Peer, error: Error) => void | Promise<void>
65
65
 
66
66
  type <%= ctx.className %>Connection = {
67
67
  roleName: string
@@ -132,14 +132,14 @@ export class <%= ctx.className %> {
132
132
  <% } -%>
133
133
  <% } -%>
134
134
  <% for (const remoteRole of ctx.remoteRoles) { -%>
135
- this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onOpen(async fromRole => {
136
- await this.handleOpen(fromRole)
135
+ this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onOpen(async (fromRole, peer) => {
136
+ await this.handleOpen(fromRole, peer as <%= ctx.className %>Peer)
137
137
  })
138
- this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onClose(async fromRole => {
139
- await this.handleClose(fromRole)
138
+ this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onClose(async (fromRole, peer) => {
139
+ await this.handleClose(fromRole, peer as <%= ctx.className %>Peer)
140
140
  })
141
- this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onError(async (fromRole, error) => {
142
- await this.handleError(fromRole, error)
141
+ this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onError(async (fromRole, peer, error) => {
142
+ await this.handleError(fromRole, peer as <%= ctx.className %>Peer, error)
143
143
  })
144
144
  <% } -%>
145
145
  if (canBindTransport(transport)) {
@@ -279,9 +279,9 @@ export class <%= ctx.className %> {
279
279
  /**
280
280
  * Framework entrypoint for a peer session opening.
281
281
  */
282
- async handleOpen(roleName: string): Promise<void> {
282
+ async handleOpen(roleName: string, peer: <%= ctx.className %>Peer): Promise<void> {
283
283
  for (const handler of this.openHandlers) {
284
- await handler(roleName)
284
+ await handler(roleName, peer)
285
285
  }
286
286
  }
287
287
 
@@ -298,9 +298,9 @@ export class <%= ctx.className %> {
298
298
  /**
299
299
  * Framework entrypoint for a peer session closing.
300
300
  */
301
- async handleClose(roleName: string): Promise<void> {
301
+ async handleClose(roleName: string, peer: <%= ctx.className %>Peer): Promise<void> {
302
302
  for (const handler of this.closeHandlers) {
303
- await handler(roleName)
303
+ await handler(roleName, peer)
304
304
  }
305
305
  }
306
306
 
@@ -317,9 +317,9 @@ export class <%= ctx.className %> {
317
317
  /**
318
318
  * Framework entrypoint for a peer session error.
319
319
  */
320
- async handleError(roleName: string, error: Error): Promise<void> {
320
+ async handleError(roleName: string, peer: <%= ctx.className %>Peer, error: Error): Promise<void> {
321
321
  for (const handler of this.lifecycleErrorHandlers) {
322
- await handler(roleName, error)
322
+ await handler(roleName, peer, error)
323
323
  }
324
324
  }
325
325
 
@@ -494,14 +494,14 @@ export class <%= ctx.className %> {
494
494
  <% } -%>
495
495
  <% } -%>
496
496
  <% for (const remoteRole of ctx.remoteRoles) { -%>
497
- this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onOpen(async fromRole => {
498
- await this.handleOpen(fromRole)
497
+ this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onOpen(async (fromRole, peer) => {
498
+ await this.handleOpen(fromRole, peer)
499
499
  })
500
- this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onClose(async fromRole => {
501
- await this.handleClose(fromRole)
500
+ this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onClose(async (fromRole, peer) => {
501
+ await this.handleClose(fromRole, peer)
502
502
  })
503
- this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onError(async (fromRole, error) => {
504
- await this.handleError(fromRole, error)
503
+ this.binder.fromRoles[<%- JSON.stringify(remoteRole.roleName) %>].onError(async (fromRole, peer, error) => {
504
+ await this.handleError(fromRole, peer, error)
505
505
  })
506
506
  <% } -%>
507
507
  if (canBindTransport(transport)) {
@@ -633,9 +633,9 @@ export class <%= ctx.className %> {
633
633
  /**
634
634
  * Framework entrypoint for a peer session opening.
635
635
  */
636
- async handleOpen(roleName) {
636
+ async handleOpen(roleName, peer) {
637
637
  for (const handler of this.#openHandlers) {
638
- await handler(roleName)
638
+ await handler(roleName, peer)
639
639
  }
640
640
  }
641
641
 
@@ -652,9 +652,9 @@ export class <%= ctx.className %> {
652
652
  /**
653
653
  * Framework entrypoint for a peer session closing.
654
654
  */
655
- async handleClose(roleName) {
655
+ async handleClose(roleName, peer) {
656
656
  for (const handler of this.#closeHandlers) {
657
- await handler(roleName)
657
+ await handler(roleName, peer)
658
658
  }
659
659
  }
660
660
 
@@ -671,9 +671,9 @@ export class <%= ctx.className %> {
671
671
  /**
672
672
  * Framework entrypoint for a peer session error.
673
673
  */
674
- async handleError(roleName, error) {
674
+ async handleError(roleName, peer, error) {
675
675
  for (const handler of this.#lifecycleErrorHandlers) {
676
- await handler(roleName, error)
676
+ await handler(roleName, peer, error)
677
677
  }
678
678
  }
679
679
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polytric/openws-sdkgen",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "OpenWS SDK generator CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,7 +50,7 @@
50
50
  "tsx": "^4.21.0",
51
51
  "typescript": "^5.9.3",
52
52
  "ws": "^8.18.3",
53
- "@polytric/openws": "^0.0.9"
53
+ "@polytric/openws": "^0.0.10"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsup",