penpal 7.0.3 → 7.0.4

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.
Files changed (111) hide show
  1. package/dist/penpal.cjs +953 -0
  2. package/dist/penpal.cjs.map +1 -0
  3. package/dist/penpal.d.cts +234 -0
  4. package/dist/penpal.d.ts +234 -0
  5. package/dist/penpal.js +890 -1033
  6. package/dist/penpal.js.map +1 -0
  7. package/dist/penpal.min.js +1 -1
  8. package/dist/penpal.min.js.map +1 -1
  9. package/dist/penpal.mjs +943 -0
  10. package/dist/penpal.mjs.map +1 -0
  11. package/package.json +13 -21
  12. package/cjs/CallOptions.d.ts +0 -10
  13. package/cjs/CallOptions.js +0 -16
  14. package/cjs/ErrorCodeObj.d.ts +0 -9
  15. package/cjs/ErrorCodeObj.js +0 -14
  16. package/cjs/PenpalBugError.d.ts +0 -8
  17. package/cjs/PenpalBugError.js +0 -12
  18. package/cjs/PenpalError.d.ts +0 -6
  19. package/cjs/PenpalError.js +0 -11
  20. package/cjs/Reply.d.ts +0 -9
  21. package/cjs/Reply.js +0 -16
  22. package/cjs/backwardCompatibility.d.ts +0 -56
  23. package/cjs/backwardCompatibility.js +0 -134
  24. package/cjs/connect.d.ts +0 -33
  25. package/cjs/connect.js +0 -78
  26. package/cjs/connectCallHandler.d.ts +0 -8
  27. package/cjs/connectCallHandler.js +0 -90
  28. package/cjs/connectRemoteProxy.d.ts +0 -12
  29. package/cjs/connectRemoteProxy.js +0 -139
  30. package/cjs/debug.d.ts +0 -3
  31. package/cjs/debug.js +0 -8
  32. package/cjs/errorSerialization.d.ts +0 -9
  33. package/cjs/errorSerialization.js +0 -26
  34. package/cjs/generateId.d.ts +0 -8
  35. package/cjs/generateId.js +0 -11
  36. package/cjs/getPromiseWithResolvers.d.ts +0 -6
  37. package/cjs/getPromiseWithResolvers.js +0 -19
  38. package/cjs/guards.d.ts +0 -10
  39. package/cjs/guards.js +0 -40
  40. package/cjs/index.d.ts +0 -12
  41. package/cjs/index.js +0 -21
  42. package/cjs/indexForBundle.d.ts +0 -31
  43. package/cjs/indexForBundle.js +0 -22
  44. package/cjs/messengers/Messenger.d.ts +0 -14
  45. package/cjs/messengers/Messenger.js +0 -2
  46. package/cjs/messengers/PortMessenger.d.ts +0 -21
  47. package/cjs/messengers/PortMessenger.js +0 -47
  48. package/cjs/messengers/WindowMessenger.d.ts +0 -29
  49. package/cjs/messengers/WindowMessenger.js +0 -178
  50. package/cjs/messengers/WorkerMessenger.d.ts +0 -23
  51. package/cjs/messengers/WorkerMessenger.js +0 -86
  52. package/cjs/methodSerialization.d.ts +0 -22
  53. package/cjs/methodSerialization.js +0 -48
  54. package/cjs/namespace.d.ts +0 -2
  55. package/cjs/namespace.js +0 -3
  56. package/cjs/once.d.ts +0 -2
  57. package/cjs/once.js +0 -15
  58. package/cjs/shakeHands.d.ts +0 -76
  59. package/cjs/shakeHands.js +0 -190
  60. package/cjs/types.d.ts +0 -89
  61. package/cjs/types.js +0 -2
  62. package/lib/CallOptions.d.ts +0 -10
  63. package/lib/CallOptions.js +0 -14
  64. package/lib/ErrorCodeObj.d.ts +0 -9
  65. package/lib/ErrorCodeObj.js +0 -12
  66. package/lib/PenpalBugError.d.ts +0 -8
  67. package/lib/PenpalBugError.js +0 -10
  68. package/lib/PenpalError.d.ts +0 -6
  69. package/lib/PenpalError.js +0 -9
  70. package/lib/Reply.d.ts +0 -9
  71. package/lib/Reply.js +0 -14
  72. package/lib/backwardCompatibility.d.ts +0 -56
  73. package/lib/backwardCompatibility.js +0 -128
  74. package/lib/connect.d.ts +0 -33
  75. package/lib/connect.js +0 -76
  76. package/lib/connectCallHandler.d.ts +0 -8
  77. package/lib/connectCallHandler.js +0 -88
  78. package/lib/connectRemoteProxy.d.ts +0 -12
  79. package/lib/connectRemoteProxy.js +0 -137
  80. package/lib/debug.d.ts +0 -3
  81. package/lib/debug.js +0 -6
  82. package/lib/errorSerialization.d.ts +0 -9
  83. package/lib/errorSerialization.js +0 -21
  84. package/lib/generateId.d.ts +0 -8
  85. package/lib/generateId.js +0 -9
  86. package/lib/getPromiseWithResolvers.d.ts +0 -6
  87. package/lib/getPromiseWithResolvers.js +0 -17
  88. package/lib/guards.d.ts +0 -10
  89. package/lib/guards.js +0 -28
  90. package/lib/index.d.ts +0 -12
  91. package/lib/index.js +0 -9
  92. package/lib/indexForBundle.d.ts +0 -31
  93. package/lib/indexForBundle.js +0 -20
  94. package/lib/messengers/Messenger.d.ts +0 -14
  95. package/lib/messengers/Messenger.js +0 -1
  96. package/lib/messengers/PortMessenger.d.ts +0 -21
  97. package/lib/messengers/PortMessenger.js +0 -45
  98. package/lib/messengers/WindowMessenger.d.ts +0 -29
  99. package/lib/messengers/WindowMessenger.js +0 -176
  100. package/lib/messengers/WorkerMessenger.d.ts +0 -23
  101. package/lib/messengers/WorkerMessenger.js +0 -84
  102. package/lib/methodSerialization.d.ts +0 -22
  103. package/lib/methodSerialization.js +0 -42
  104. package/lib/namespace.d.ts +0 -2
  105. package/lib/namespace.js +0 -1
  106. package/lib/once.d.ts +0 -2
  107. package/lib/once.js +0 -13
  108. package/lib/shakeHands.d.ts +0 -76
  109. package/lib/shakeHands.js +0 -188
  110. package/lib/types.d.ts +0 -89
  111. package/lib/types.js +0 -1
package/lib/types.d.ts DELETED
@@ -1,89 +0,0 @@
1
- import CallOptions from './CallOptions.js';
2
- import Reply from './Reply.js';
3
- import namespace from './namespace.js';
4
- import ErrorCodeObj from './ErrorCodeObj.js';
5
- type ExtractValueFromReply<R> = R extends Reply ? Awaited<R['value']> : R;
6
- /**
7
- * An object representing methods exposed by the remote but that can be called
8
- * locally.
9
- */
10
- export type RemoteProxy<TMethods extends Methods = Methods> = {
11
- [K in keyof TMethods]: TMethods[K] extends (...args: infer A) => infer R ? (...args: [...A, CallOptions?]) => Promise<ExtractValueFromReply<Awaited<R>>> : TMethods[K] extends Methods ? RemoteProxy<TMethods[K]> : never;
12
- };
13
- /**
14
- * An object representing the connection as a result of calling connect().
15
- */
16
- export type Connection<TMethods extends Methods = Methods> = {
17
- /**
18
- * A promise which will be resolved once the connection has been established.
19
- */
20
- promise: Promise<RemoteProxy<TMethods>>;
21
- /**
22
- * A method that, when called, will disconnect any communication.
23
- * You may call this even before a connection has been established.
24
- */
25
- destroy: () => void;
26
- };
27
- /**
28
- * Methods to expose to the remote window. May contain nested objects
29
- * with methods as well.
30
- */
31
- export type Methods = {
32
- [index: string]: Methods | Function;
33
- };
34
- /**
35
- * An array of path segments (object property keys) to use to find a method
36
- * within a Methods object. We avoid using a period-delimited string because
37
- * property names can have periods in them which could cause issues.
38
- */
39
- export type MethodPath = string[];
40
- export type ErrorCode = typeof ErrorCodeObj[keyof typeof ErrorCodeObj];
41
- export type SerializedError = {
42
- name: string;
43
- message: string;
44
- stack?: string;
45
- penpalCode?: ErrorCode;
46
- };
47
- type MessageBase = {
48
- namespace: typeof namespace;
49
- channel: string | undefined;
50
- };
51
- export type SynMessage = MessageBase & {
52
- type: 'SYN';
53
- participantId: string;
54
- };
55
- export type Ack1Message = MessageBase & {
56
- type: 'ACK1';
57
- methodPaths: MethodPath[];
58
- };
59
- export type Ack2Message = MessageBase & {
60
- type: 'ACK2';
61
- };
62
- export type CallMessage = MessageBase & {
63
- type: 'CALL';
64
- id: string;
65
- methodPath: MethodPath;
66
- args: unknown[];
67
- };
68
- export type ReplyMessage = MessageBase & {
69
- type: 'REPLY';
70
- callId: string;
71
- } & ({
72
- value: unknown;
73
- isError?: false;
74
- isSerializedErrorInstance?: false;
75
- } | {
76
- value: unknown;
77
- isError: true;
78
- isSerializedErrorInstance?: false;
79
- } | {
80
- value: SerializedError;
81
- isError: true;
82
- isSerializedErrorInstance: true;
83
- });
84
- export type DestroyMessage = MessageBase & {
85
- type: 'DESTROY';
86
- };
87
- export type Message = SynMessage | Ack1Message | Ack2Message | CallMessage | ReplyMessage | DestroyMessage;
88
- export type Log = (...args: unknown[]) => void;
89
- export {};
package/lib/types.js DELETED
@@ -1 +0,0 @@
1
- export {};