mezon-js 2.13.78 → 2.13.80

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 (38) hide show
  1. package/client.ts +3279 -2482
  2. package/dist/client.d.ts +163 -349
  3. package/dist/gateway.api.d.ts +33 -0
  4. package/dist/index.d.ts +2 -4
  5. package/dist/{api.gen.d.ts → mezon-js/api.gen.d.ts} +1 -0
  6. package/dist/mezon-js/client.d.ts +347 -0
  7. package/dist/mezon-js/gateway.api.d.ts +33 -0
  8. package/dist/mezon-js/index.d.ts +23 -0
  9. package/dist/mezon-js/session.d.ts +61 -0
  10. package/dist/mezon-js/socket.d.ts +1212 -0
  11. package/dist/mezon-js/types/index.d.ts +2212 -0
  12. package/dist/mezon-js/utils.d.ts +6 -0
  13. package/dist/mezon-js/web_socket_adapter.d.ts +83 -0
  14. package/dist/mezon-js.cjs.js +9038 -21145
  15. package/dist/mezon-js.esm.mjs +9038 -21145
  16. package/dist/mezon-js.esm.mjs.map +1 -0
  17. package/dist/session.d.ts +11 -11
  18. package/dist/socket.d.ts +385 -386
  19. package/dist/types/index.d.ts +2212 -0
  20. package/dist/utils.d.ts +2 -0
  21. package/dist/webrpc/index.d.ts +3 -0
  22. package/gateway.api.ts +577 -0
  23. package/index.ts +2 -5
  24. package/package.json +3 -2
  25. package/rollup.config.js +64 -30
  26. package/session.ts +22 -22
  27. package/socket.ts +921 -846
  28. package/types/index.ts +3883 -0
  29. package/utils.ts +107 -47
  30. package/api/api.ts +0 -39185
  31. package/api.gen.ts +0 -11777
  32. package/google/protobuf/struct.ts +0 -554
  33. package/google/protobuf/timestamp.ts +0 -223
  34. package/google/protobuf/wrappers.ts +0 -670
  35. /package/dist/{api → mezon-js/api}/api.d.ts +0 -0
  36. /package/dist/{google → mezon-js/google}/protobuf/struct.d.ts +0 -0
  37. /package/dist/{google → mezon-js/google}/protobuf/timestamp.d.ts +0 -0
  38. /package/dist/{google → mezon-js/google}/protobuf/wrappers.d.ts +0 -0
package/rollup.config.js CHANGED
@@ -1,44 +1,78 @@
1
- /*
2
- * Copyright 2020 Heroic Labs
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- // Rollup is the legacy build system for mezon-js and is only used for cocos2d-x-js support.
18
-
19
1
  import typescript from '@rollup/plugin-typescript';
20
2
  import { nodeResolve } from '@rollup/plugin-node-resolve';
21
3
  import commonjs from '@rollup/plugin-commonjs';
22
4
 
23
5
  export default {
6
+ context: 'globalThis',
24
7
  input: './index.ts',
25
- output: {
26
- format: 'umd',
27
- name: 'mezonjs',
28
- dir: "dist",
29
- entryFileNames: "mezon-js.umd.js" // workaround for TS requirement that dir is specified in config
30
- },
8
+ output: [
9
+ {
10
+ format: 'umd',
11
+ name: 'mezonjs',
12
+ dir: "dist",
13
+ entryFileNames: "mezon-js.umd.js",
14
+ sourcemap: true,
15
+ },
16
+ {
17
+ format: 'es',
18
+ name: 'mezonjs',
19
+ dir: "dist",
20
+ entryFileNames: "mezon-js.esm.mjs",
21
+ sourcemap: true,
22
+ },
23
+ {
24
+ format: 'cjs',
25
+ name: 'mezonjs',
26
+ dir: "dist",
27
+ entryFileNames: "mezon-js.cjs.js",
28
+ sourcemap: true,
29
+ }
30
+ ],
31
31
  plugins: [
32
+ // 1. nodeResolve MUST be first to find the files in node_modules and gen folder
33
+ nodeResolve({
34
+ browser: true,
35
+ extensions: ['.ts', '.js']
36
+ }),
37
+
38
+ // 2. Only ONE typescript plugin. Use it to handle everything.
32
39
  typescript({
33
- include: ["**/*.ts"],
34
- target: "es5"
40
+ // Ensure this covers your source, generated files, and connectrpc
41
+ include: [
42
+ "**/*.ts",
43
+ "../webrpc/frontend/src/gen/**/*.ts",
44
+ "src/gen/**/*.ts",
45
+ "node_modules/@connectrpc/**/*.ts"
46
+ ],
47
+ target: "es5",
48
+ module: "esnext",
49
+ tsconfig: "./tsconfig.json",
50
+ rootDir: "../",
35
51
  }),
36
- nodeResolve({
37
- browser: true
52
+
53
+ // 3. CommonJS converts the output so UMD works correctly
54
+ commonjs({
55
+ extensions: ['.ts', '.js'],
56
+ // If connectrpc uses commonjs internally, include it here
57
+ include: [/node_modules/]
38
58
  }),
39
- commonjs()
40
59
  ],
41
60
  moduleContext: {
42
61
  [require.resolve('whatwg-fetch')]: 'window'
62
+ },
63
+ onwarn(warning, warn) {
64
+ if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids[0].includes('node_modules')) {
65
+ return;
66
+ }
67
+
68
+ if (warning.code === 'EVAL' && warning.loc && warning.loc.file.includes('protobufjs')) {
69
+ return;
70
+ }
71
+
72
+ if (warning.code === 'THIS_IS_UNDEFINED' && warning.loc && warning.loc.file.includes('@connectrpc')) {
73
+ return;
74
+ }
75
+
76
+ warn(warning);
43
77
  }
44
- };
78
+ };
package/session.ts CHANGED
@@ -25,17 +25,17 @@ export interface ISession {
25
25
  /** If the user account for this session was just created. */
26
26
  created: boolean
27
27
  /** The UNIX timestamp when this session was created. */
28
- readonly created_at: number;
28
+ readonly createdAt: number;
29
29
  /** The UNIX timestamp when this session will expire. */
30
30
  expires_at?: number;
31
31
  /** The UNIX timestamp when the refresh token will expire. */
32
32
  refresh_expires_at?: number;
33
33
  /** Refresh token that can be used for session token renewal. */
34
- refresh_token: string;
34
+ refreshToken: string;
35
35
  /** The username of the user who owns this session. */
36
36
  username?: string;
37
37
  /** The ID of the user who owns this session. */
38
- user_id?: string;
38
+ userId?: string;
39
39
  /** Any custom properties associated with this session. */
40
40
  vars?: object;
41
41
 
@@ -49,29 +49,29 @@ export interface ISession {
49
49
  export class Session implements ISession {
50
50
 
51
51
  token : string;
52
- readonly created_at: number;
52
+ readonly createdAt: number;
53
53
  expires_at?: number;
54
54
  refresh_expires_at?: number;
55
- refresh_token: string;
55
+ refreshToken: string;
56
56
  username?: string;
57
- user_id?: string;
57
+ userId?: string;
58
58
  vars?: object;
59
- is_remember?: boolean;
59
+ isRemember?: boolean;
60
60
 
61
61
  constructor(
62
62
  token: string,
63
- refresh_token: string,
63
+ refreshToken: string,
64
64
  readonly created: boolean,
65
- readonly api_url: string,
66
- readonly id_token: string,
67
- is_remember: boolean) {
65
+ readonly apiUrl: string,
66
+ readonly idToken: string,
67
+ isRemember: boolean) {
68
68
  this.token = token;
69
- this.refresh_token = refresh_token;
70
- this.id_token = id_token;
71
- this.api_url = api_url;
72
- this.created_at = Math.floor(new Date().getTime() / 1000);
73
- this.is_remember = is_remember;
74
- this.update(token, refresh_token, is_remember);
69
+ this.refreshToken = refreshToken;
70
+ this.idToken = idToken;
71
+ this.apiUrl = apiUrl;
72
+ this.createdAt = Math.floor(new Date().getTime() / 1000);
73
+ this.isRemember = isRemember;
74
+ this.update(token, refreshToken, isRemember);
75
75
  }
76
76
 
77
77
  isexpired(currenttime: number): boolean {
@@ -105,18 +105,18 @@ export class Session implements ISession {
105
105
  const refreshTokenDecoded = JSON.parse(base64.atob(refreshTokenParts[1]))
106
106
  const refreshTokenExpiresAt = Math.floor(parseInt(refreshTokenDecoded['exp']));
107
107
  this.refresh_expires_at = refreshTokenExpiresAt;
108
- this.refresh_token = refreshToken;
109
- this.is_remember = isRemember;
108
+ this.refreshToken = refreshToken;
109
+ this.isRemember = isRemember;
110
110
  }
111
111
 
112
112
  this.token = token;
113
113
  this.expires_at = tokenExpiresAt;
114
114
  this.username = tokenDecoded['usn'];
115
- this.user_id = tokenDecoded['uid'];
115
+ this.userId = tokenDecoded['uid'];
116
116
  this.vars = tokenDecoded['vrs'];
117
117
  }
118
118
 
119
- static restore(token: string, refreshToken: string, api_url: string, isRemember: boolean): Session {
120
- return new Session(token, refreshToken, false, api_url, "", isRemember);
119
+ static restore(token: string, refreshToken: string, apiUrl: string, isRemember: boolean): Session {
120
+ return new Session(token, refreshToken, false, apiUrl, "", isRemember);
121
121
  }
122
122
  }