@pluv/platform-pluv 0.32.1 → 0.32.3

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/platform-pluv@0.32.1 build /home/runner/work/pluv/pluv/packages/platform-pluv
2
+ > @pluv/platform-pluv@0.32.3 build /home/runner/work/pluv/pluv/packages/platform-pluv
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 3.64 KB
12
- ESM ⚡️ Build success in 79ms
13
- CJS dist/index.js 4.82 KB
14
- CJS ⚡️ Build success in 81ms
11
+ CJS dist/index.js 5.91 KB
12
+ CJS ⚡️ Build success in 103ms
13
+ ESM dist/index.mjs 4.82 KB
14
+ ESM ⚡️ Build success in 104ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 6419ms
17
- DTS dist/index.d.mts 2.29 KB
18
- DTS dist/index.d.ts 2.29 KB
16
+ DTS ⚡️ Build success in 6561ms
17
+ DTS dist/index.d.mts 2.89 KB
18
+ DTS dist/index.d.ts 2.89 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @pluv/platform-pluv
2
2
 
3
+ ## 0.32.3
4
+
5
+ ### Patch Changes
6
+
7
+ - cce989d: Added properties for internal use only.
8
+ - 5a3114f: Fixed thrown error when calling `createToken`.
9
+ - Updated dependencies [bb21274]
10
+ - @pluv/io@0.32.3
11
+ - @pluv/crdt@0.32.3
12
+ - @pluv/types@0.32.3
13
+
14
+ ## 0.32.2
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [890d45b]
19
+ - @pluv/io@0.32.2
20
+ - @pluv/crdt@0.32.2
21
+ - @pluv/types@0.32.2
22
+
3
23
  ## 0.32.1
4
24
 
5
25
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AbstractPlatform, WebSocketRegistrationMode, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, PluvIOListeners, GetInitialStorageFn, JWTEncodeParams, BaseUser as BaseUser$1 } from '@pluv/io';
2
2
  import * as hono_types from 'hono/types';
3
3
  import * as hono from 'hono';
4
- import { BaseUser, InputZodLike } from '@pluv/types';
4
+ import { BaseUser, InputZodLike, IOLike } from '@pluv/types';
5
5
 
6
6
  declare class PluvPlatform extends AbstractPlatform {
7
7
  _registrationMode: WebSocketRegistrationMode;
@@ -22,7 +22,18 @@ interface PluvAuthorize<TUser extends BaseUser> {
22
22
  secret: string;
23
23
  user: InputZodLike<TUser>;
24
24
  }
25
+ interface PluvIOEndpoints {
26
+ createToken: string;
27
+ }
25
28
  type PluvIOConfig<TUser extends BaseUser> = Partial<Pick<PluvIOListeners<PluvPlatform, PluvAuthorize<TUser>, {}, {}>, "onRoomDeleted">> & {
29
+ /**
30
+ * @ignore
31
+ * @readonly
32
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
33
+ */
34
+ _defs?: {
35
+ endpoints?: PluvIOEndpoints;
36
+ };
26
37
  authorize: {
27
38
  user: InputZodLike<TUser>;
28
39
  };
@@ -31,13 +42,25 @@ type PluvIOConfig<TUser extends BaseUser> = Partial<Pick<PluvIOListeners<PluvPla
31
42
  publicKey: string;
32
43
  secretKey: string;
33
44
  };
34
- declare class PluvIO<TUser extends BaseUser> {
45
+ declare class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUser>, {}> {
35
46
  private readonly _authorize;
36
47
  private readonly _basePath;
48
+ private readonly _endpoints;
37
49
  private readonly _getInitialStorage?;
38
50
  private readonly _listeners;
39
51
  private readonly _publicKey;
40
52
  private readonly _secretKey;
53
+ /**
54
+ * @ignore
55
+ * @readonly
56
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
57
+ */
58
+ get _defs(): {
59
+ authorize: PluvAuthorize<TUser>;
60
+ context: {};
61
+ events: {};
62
+ readonly platform: void;
63
+ };
41
64
  get fetch(): (request: Request, Env?: unknown, executionCtx?: hono.ExecutionContext) => Response | Promise<Response>;
42
65
  get handler(): (req: Request, requestContext: hono_types.FetchEventLike) => Response | Promise<Response>;
43
66
  private _webhooks;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AbstractPlatform, WebSocketRegistrationMode, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, PluvIOListeners, GetInitialStorageFn, JWTEncodeParams, BaseUser as BaseUser$1 } from '@pluv/io';
2
2
  import * as hono_types from 'hono/types';
3
3
  import * as hono from 'hono';
4
- import { BaseUser, InputZodLike } from '@pluv/types';
4
+ import { BaseUser, InputZodLike, IOLike } from '@pluv/types';
5
5
 
6
6
  declare class PluvPlatform extends AbstractPlatform {
7
7
  _registrationMode: WebSocketRegistrationMode;
@@ -22,7 +22,18 @@ interface PluvAuthorize<TUser extends BaseUser> {
22
22
  secret: string;
23
23
  user: InputZodLike<TUser>;
24
24
  }
25
+ interface PluvIOEndpoints {
26
+ createToken: string;
27
+ }
25
28
  type PluvIOConfig<TUser extends BaseUser> = Partial<Pick<PluvIOListeners<PluvPlatform, PluvAuthorize<TUser>, {}, {}>, "onRoomDeleted">> & {
29
+ /**
30
+ * @ignore
31
+ * @readonly
32
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
33
+ */
34
+ _defs?: {
35
+ endpoints?: PluvIOEndpoints;
36
+ };
26
37
  authorize: {
27
38
  user: InputZodLike<TUser>;
28
39
  };
@@ -31,13 +42,25 @@ type PluvIOConfig<TUser extends BaseUser> = Partial<Pick<PluvIOListeners<PluvPla
31
42
  publicKey: string;
32
43
  secretKey: string;
33
44
  };
34
- declare class PluvIO<TUser extends BaseUser> {
45
+ declare class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUser>, {}> {
35
46
  private readonly _authorize;
36
47
  private readonly _basePath;
48
+ private readonly _endpoints;
37
49
  private readonly _getInitialStorage?;
38
50
  private readonly _listeners;
39
51
  private readonly _publicKey;
40
52
  private readonly _secretKey;
53
+ /**
54
+ * @ignore
55
+ * @readonly
56
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
57
+ */
58
+ get _defs(): {
59
+ authorize: PluvAuthorize<TUser>;
60
+ context: {};
61
+ events: {};
62
+ readonly platform: void;
63
+ };
41
64
  get fetch(): (request: Request, Env?: unknown, executionCtx?: hono.ExecutionContext) => Response | Promise<Response>;
42
65
  get handler(): (req: Request, requestContext: hono_types.FetchEventLike) => Response | Promise<Response>;
43
66
  private _webhooks;
package/dist/index.js CHANGED
@@ -2,7 +2,21 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
6
20
  var __export = (target, all) => {
7
21
  for (var name in all)
8
22
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -90,18 +104,36 @@ var PluvIO = class {
90
104
  return c.json({ data: { ok: true } }, 200);
91
105
  }
92
106
  }));
93
- const { authorize, basePath, onRoomDeleted, getInitialStorage, publicKey, secretKey } = options;
107
+ const { _defs, authorize, basePath, onRoomDeleted, getInitialStorage, publicKey, secretKey } = options;
94
108
  this._authorize = {
95
109
  required: true,
96
110
  secret: "",
97
111
  user: authorize.user
98
112
  };
99
113
  this._basePath = basePath;
114
+ this._endpoints = __spreadValues({
115
+ createToken: "https://pluv.io/api/room/token"
116
+ }, _defs == null ? void 0 : _defs.endpoints);
100
117
  this._getInitialStorage = getInitialStorage;
101
118
  this._listeners = { onRoomDeleted: (event) => onRoomDeleted == null ? void 0 : onRoomDeleted(event) };
102
119
  this._publicKey = publicKey;
103
120
  this._secretKey = secretKey;
104
121
  }
122
+ /**
123
+ * @ignore
124
+ * @readonly
125
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
126
+ */
127
+ get _defs() {
128
+ return {
129
+ authorize: this._authorize,
130
+ context: {},
131
+ events: {},
132
+ get platform() {
133
+ throw new Error("Invalid platform reference");
134
+ }
135
+ };
136
+ }
105
137
  get fetch() {
106
138
  const app = new import_hono.Hono().basePath(this._basePath).route("/", this._webhooks);
107
139
  return app.fetch;
@@ -114,12 +146,13 @@ var PluvIO = class {
114
146
  return __async(this, null, function* () {
115
147
  var _a;
116
148
  const parsed = this._authorize.user.parse(params.user);
117
- const res = yield fetch("https://pluv.io/api/room/token", {
149
+ const res = yield fetch(this._endpoints.createToken, {
150
+ headers: { "content-type": "application/json" },
118
151
  method: "post",
119
152
  body: JSON.stringify({
120
153
  maxAge: (_a = params.maxAge) != null ? _a : null,
121
- room: params.room,
122
154
  publicKey: this._publicKey,
155
+ room: params.room,
123
156
  secretKey: this._secretKey,
124
157
  user: parsed
125
158
  })
package/dist/index.mjs CHANGED
@@ -1,3 +1,19 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
1
17
  var __async = (__this, __arguments, generator) => {
2
18
  return new Promise((resolve, reject) => {
3
19
  var fulfilled = (value) => {
@@ -65,18 +81,36 @@ var PluvIO = class {
65
81
  return c.json({ data: { ok: true } }, 200);
66
82
  }
67
83
  }));
68
- const { authorize, basePath, onRoomDeleted, getInitialStorage, publicKey, secretKey } = options;
84
+ const { _defs, authorize, basePath, onRoomDeleted, getInitialStorage, publicKey, secretKey } = options;
69
85
  this._authorize = {
70
86
  required: true,
71
87
  secret: "",
72
88
  user: authorize.user
73
89
  };
74
90
  this._basePath = basePath;
91
+ this._endpoints = __spreadValues({
92
+ createToken: "https://pluv.io/api/room/token"
93
+ }, _defs == null ? void 0 : _defs.endpoints);
75
94
  this._getInitialStorage = getInitialStorage;
76
95
  this._listeners = { onRoomDeleted: (event) => onRoomDeleted == null ? void 0 : onRoomDeleted(event) };
77
96
  this._publicKey = publicKey;
78
97
  this._secretKey = secretKey;
79
98
  }
99
+ /**
100
+ * @ignore
101
+ * @readonly
102
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
103
+ */
104
+ get _defs() {
105
+ return {
106
+ authorize: this._authorize,
107
+ context: {},
108
+ events: {},
109
+ get platform() {
110
+ throw new Error("Invalid platform reference");
111
+ }
112
+ };
113
+ }
80
114
  get fetch() {
81
115
  const app = new Hono().basePath(this._basePath).route("/", this._webhooks);
82
116
  return app.fetch;
@@ -89,12 +123,13 @@ var PluvIO = class {
89
123
  return __async(this, null, function* () {
90
124
  var _a;
91
125
  const parsed = this._authorize.user.parse(params.user);
92
- const res = yield fetch("https://pluv.io/api/room/token", {
126
+ const res = yield fetch(this._endpoints.createToken, {
127
+ headers: { "content-type": "application/json" },
93
128
  method: "post",
94
129
  body: JSON.stringify({
95
130
  maxAge: (_a = params.maxAge) != null ? _a : null,
96
- room: params.room,
97
131
  publicKey: this._publicKey,
132
+ room: params.room,
98
133
  secretKey: this._secretKey,
99
134
  user: parsed
100
135
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/platform-pluv",
3
- "version": "0.32.1",
3
+ "version": "0.32.3",
4
4
  "description": "@pluv/io adapter for pluv.io",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,19 +17,19 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@types/node": "^22.7.4",
21
- "hono": "^4.6.3",
20
+ "@types/node": "^22.7.5",
21
+ "hono": "^4.6.5",
22
22
  "zod": "^3.23.8",
23
- "@pluv/crdt": "^0.32.1",
24
- "@pluv/io": "^0.32.1",
25
- "@pluv/types": "^0.32.1"
23
+ "@pluv/crdt": "^0.32.3",
24
+ "@pluv/io": "^0.32.3",
25
+ "@pluv/types": "^0.32.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^8.57.0",
29
29
  "tsup": "^8.3.0",
30
- "typescript": "^5.6.2",
31
- "@pluv/tsconfig": "^0.32.1",
32
- "eslint-config-pluv": "^0.32.1"
30
+ "typescript": "^5.6.3",
31
+ "@pluv/tsconfig": "^0.32.3",
32
+ "eslint-config-pluv": "^0.32.3"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/PluvIO.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { GetInitialStorageFn, JWTEncodeParams, PluvIOListeners } from "@pluv/io";
2
- import type { BaseUser, InputZodLike } from "@pluv/types";
2
+ import type { BaseUser, IOLike, InputZodLike } from "@pluv/types";
3
3
  import { Hono } from "hono";
4
4
  import { handle } from "hono/vercel";
5
5
  import type { PluvPlatform } from "./PluvPlatform";
@@ -11,9 +11,21 @@ interface PluvAuthorize<TUser extends BaseUser> {
11
11
  user: InputZodLike<TUser>;
12
12
  }
13
13
 
14
+ interface PluvIOEndpoints {
15
+ createToken: string;
16
+ }
17
+
14
18
  export type PluvIOConfig<TUser extends BaseUser> = Partial<
15
19
  Pick<PluvIOListeners<PluvPlatform, PluvAuthorize<TUser>, {}, {}>, "onRoomDeleted">
16
20
  > & {
21
+ /**
22
+ * @ignore
23
+ * @readonly
24
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
25
+ */
26
+ _defs?: {
27
+ endpoints?: PluvIOEndpoints;
28
+ };
17
29
  authorize: {
18
30
  user: InputZodLike<TUser>;
19
31
  };
@@ -23,14 +35,31 @@ export type PluvIOConfig<TUser extends BaseUser> = Partial<
23
35
  secretKey: string;
24
36
  };
25
37
 
26
- export class PluvIO<TUser extends BaseUser> {
38
+ export class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUser>, {}> {
27
39
  private readonly _authorize: PluvAuthorize<TUser>;
28
40
  private readonly _basePath: string;
41
+ private readonly _endpoints: PluvIOEndpoints;
29
42
  private readonly _getInitialStorage?: GetInitialStorageFn<PluvPlatform>;
30
43
  private readonly _listeners: Pick<PluvIOListeners<PluvPlatform, PluvAuthorize<TUser>, {}, {}>, "onRoomDeleted">;
31
44
  private readonly _publicKey: string;
32
45
  private readonly _secretKey: string;
33
46
 
47
+ /**
48
+ * @ignore
49
+ * @readonly
50
+ * @deprecated Internal use only. Changes to this will never be marked as breaking.
51
+ */
52
+ public get _defs() {
53
+ return {
54
+ authorize: this._authorize,
55
+ context: {},
56
+ events: {},
57
+ get platform() {
58
+ throw new Error("Invalid platform reference");
59
+ },
60
+ };
61
+ }
62
+
34
63
  public get fetch() {
35
64
  const app = new Hono().basePath(this._basePath).route("/", this._webhooks);
36
65
 
@@ -72,7 +101,7 @@ export class PluvIO<TUser extends BaseUser> {
72
101
  });
73
102
 
74
103
  constructor(options: PluvIOConfig<TUser>) {
75
- const { authorize, basePath, onRoomDeleted, getInitialStorage, publicKey, secretKey } = options;
104
+ const { _defs, authorize, basePath, onRoomDeleted, getInitialStorage, publicKey, secretKey } = options;
76
105
 
77
106
  this._authorize = {
78
107
  required: true,
@@ -80,6 +109,10 @@ export class PluvIO<TUser extends BaseUser> {
80
109
  user: authorize.user,
81
110
  };
82
111
  this._basePath = basePath;
112
+ this._endpoints = {
113
+ createToken: "https://pluv.io/api/room/token",
114
+ ..._defs?.endpoints,
115
+ };
83
116
  this._getInitialStorage = getInitialStorage;
84
117
  this._listeners = { onRoomDeleted: (event) => onRoomDeleted?.(event) };
85
118
  this._publicKey = publicKey;
@@ -89,12 +122,13 @@ export class PluvIO<TUser extends BaseUser> {
89
122
  public async createToken(params: JWTEncodeParams<TUser, PluvPlatform>): Promise<string> {
90
123
  const parsed = this._authorize.user.parse(params.user);
91
124
 
92
- const res = await fetch("https://pluv.io/api/room/token", {
125
+ const res = await fetch(this._endpoints.createToken, {
126
+ headers: { "content-type": "application/json" },
93
127
  method: "post",
94
128
  body: JSON.stringify({
95
129
  maxAge: params.maxAge ?? null,
96
- room: params.room,
97
130
  publicKey: this._publicKey,
131
+ room: params.room,
98
132
  secretKey: this._secretKey,
99
133
  user: parsed,
100
134
  }),