@kokimoki/app 1.4.0 → 1.4.2
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/dist/kokimoki-client.d.ts +1 -0
- package/dist/kokimoki-client.js +19 -2
- package/dist/kokimoki.min.d.ts +1 -0
- package/dist/kokimoki.min.js +20 -3
- package/dist/kokimoki.min.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/kokimoki-client-refactored.d.ts +0 -68
- package/dist/kokimoki-client-refactored.js +0 -394
- package/dist/message-queue.d.ts +0 -8
- package/dist/message-queue.js +0 -19
- package/dist/synced-schema.d.ts +0 -59
- package/dist/synced-schema.js +0 -84
- package/dist/synced-store.d.ts +0 -7
- package/dist/synced-store.js +0 -9
- package/dist/synced-types.d.ts +0 -38
- package/dist/synced-types.js +0 -68
- package/dist/ws-message-type copy.d.ts +0 -6
- package/dist/ws-message-type copy.js +0 -7
|
@@ -34,6 +34,7 @@ export declare class KokimokiClient<ClientContextT = any> extends KokimokiClient
|
|
|
34
34
|
private _autoReconnect;
|
|
35
35
|
private _reconnectTimeout;
|
|
36
36
|
private _pingInterval;
|
|
37
|
+
private _clientTokenKey;
|
|
37
38
|
constructor(host: string, appId: string, code?: string);
|
|
38
39
|
get id(): string;
|
|
39
40
|
get connectionId(): string;
|
package/dist/kokimoki-client.js
CHANGED
|
@@ -34,6 +34,7 @@ export class KokimokiClient extends EventEmitter {
|
|
|
34
34
|
_autoReconnect = true;
|
|
35
35
|
_reconnectTimeout = 0;
|
|
36
36
|
_pingInterval;
|
|
37
|
+
_clientTokenKey = "KM_TOKEN";
|
|
37
38
|
constructor(host, appId, code = "") {
|
|
38
39
|
super();
|
|
39
40
|
this.host = host;
|
|
@@ -52,6 +53,21 @@ export class KokimokiClient extends EventEmitter {
|
|
|
52
53
|
this.ws.send(pingBuffer);
|
|
53
54
|
}
|
|
54
55
|
}, 5000);
|
|
56
|
+
// Detect devtools
|
|
57
|
+
console.log(`[KM]`, window.top, frameElement?.id);
|
|
58
|
+
if (window.top && frameElement) {
|
|
59
|
+
this._clientTokenKey = `KM_TOKEN/${frameElement.id}`;
|
|
60
|
+
window.addEventListener("message", (e) => {
|
|
61
|
+
console.log(`[KM ${frameElement?.id}] ${e.data}`);
|
|
62
|
+
if (e.data === "km:clearStorage") {
|
|
63
|
+
localStorage.removeItem(this._clientTokenKey);
|
|
64
|
+
window.location.reload();
|
|
65
|
+
}
|
|
66
|
+
else if (e.data === "km:reload") {
|
|
67
|
+
window.location.reload();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
55
71
|
}
|
|
56
72
|
get id() {
|
|
57
73
|
if (!this._id) {
|
|
@@ -102,6 +118,7 @@ export class KokimokiClient extends EventEmitter {
|
|
|
102
118
|
if (this._connectPromise) {
|
|
103
119
|
return await this._connectPromise;
|
|
104
120
|
}
|
|
121
|
+
// Set up the WebSocket connection
|
|
105
122
|
this._ws = new WebSocket(`${this._wsUrl}/apps/${this.appId}?clientVersion=${KOKIMOKI_APP_VERSION}`);
|
|
106
123
|
this._ws.binaryType = "arraybuffer";
|
|
107
124
|
// Close previous connection in hot-reload scenarios
|
|
@@ -118,7 +135,7 @@ export class KokimokiClient extends EventEmitter {
|
|
|
118
135
|
// Wait for connection
|
|
119
136
|
this._connectPromise = new Promise((onInit) => {
|
|
120
137
|
// Fetch the auth token
|
|
121
|
-
let clientToken = localStorage.getItem(
|
|
138
|
+
let clientToken = localStorage.getItem(this._clientTokenKey);
|
|
122
139
|
// Send the app token on first connect
|
|
123
140
|
this.ws.onopen = () => {
|
|
124
141
|
this.ws.send(JSON.stringify({ type: "auth", code: this.code, token: clientToken }));
|
|
@@ -184,7 +201,7 @@ export class KokimokiClient extends EventEmitter {
|
|
|
184
201
|
this.emit("connected");
|
|
185
202
|
}
|
|
186
203
|
handleInitMessage(message) {
|
|
187
|
-
localStorage.setItem(
|
|
204
|
+
localStorage.setItem(this._clientTokenKey, message.clientToken);
|
|
188
205
|
this._id = message.clientId;
|
|
189
206
|
this._connectionId = message.id;
|
|
190
207
|
this._token = message.appToken;
|
package/dist/kokimoki.min.d.ts
CHANGED
|
@@ -343,6 +343,7 @@ declare class KokimokiClient<ClientContextT = any> extends KokimokiClient_base {
|
|
|
343
343
|
private _autoReconnect;
|
|
344
344
|
private _reconnectTimeout;
|
|
345
345
|
private _pingInterval;
|
|
346
|
+
private _clientTokenKey;
|
|
346
347
|
constructor(host: string, appId: string, code?: string);
|
|
347
348
|
get id(): string;
|
|
348
349
|
get connectionId(): string;
|
package/dist/kokimoki.min.js
CHANGED
|
@@ -634,7 +634,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
|
634
634
|
var eventsExports = events.exports;
|
|
635
635
|
var EventEmitter$1 = /*@__PURE__*/getDefaultExportFromCjs(eventsExports);
|
|
636
636
|
|
|
637
|
-
const KOKIMOKI_APP_VERSION = "1.4.
|
|
637
|
+
const KOKIMOKI_APP_VERSION = "1.4.2";
|
|
638
638
|
|
|
639
639
|
/**
|
|
640
640
|
* Utility module to work with key-value stores.
|
|
@@ -12247,6 +12247,7 @@ class KokimokiClient extends EventEmitter$1 {
|
|
|
12247
12247
|
_autoReconnect = true;
|
|
12248
12248
|
_reconnectTimeout = 0;
|
|
12249
12249
|
_pingInterval;
|
|
12250
|
+
_clientTokenKey = "KM_TOKEN";
|
|
12250
12251
|
constructor(host, appId, code = "") {
|
|
12251
12252
|
super();
|
|
12252
12253
|
this.host = host;
|
|
@@ -12265,6 +12266,21 @@ class KokimokiClient extends EventEmitter$1 {
|
|
|
12265
12266
|
this.ws.send(pingBuffer);
|
|
12266
12267
|
}
|
|
12267
12268
|
}, 5000);
|
|
12269
|
+
// Detect devtools
|
|
12270
|
+
console.log(`[KM]`, window.top, frameElement?.id);
|
|
12271
|
+
if (window.top && frameElement) {
|
|
12272
|
+
this._clientTokenKey = `KM_TOKEN/${frameElement.id}`;
|
|
12273
|
+
window.addEventListener("message", (e) => {
|
|
12274
|
+
console.log(`[KM ${frameElement?.id}] ${e.data}`);
|
|
12275
|
+
if (e.data === "km:clearStorage") {
|
|
12276
|
+
localStorage.removeItem(this._clientTokenKey);
|
|
12277
|
+
window.location.reload();
|
|
12278
|
+
}
|
|
12279
|
+
else if (e.data === "km:reload") {
|
|
12280
|
+
window.location.reload();
|
|
12281
|
+
}
|
|
12282
|
+
});
|
|
12283
|
+
}
|
|
12268
12284
|
}
|
|
12269
12285
|
get id() {
|
|
12270
12286
|
if (!this._id) {
|
|
@@ -12315,6 +12331,7 @@ class KokimokiClient extends EventEmitter$1 {
|
|
|
12315
12331
|
if (this._connectPromise) {
|
|
12316
12332
|
return await this._connectPromise;
|
|
12317
12333
|
}
|
|
12334
|
+
// Set up the WebSocket connection
|
|
12318
12335
|
this._ws = new WebSocket(`${this._wsUrl}/apps/${this.appId}?clientVersion=${KOKIMOKI_APP_VERSION}`);
|
|
12319
12336
|
this._ws.binaryType = "arraybuffer";
|
|
12320
12337
|
// Close previous connection in hot-reload scenarios
|
|
@@ -12331,7 +12348,7 @@ class KokimokiClient extends EventEmitter$1 {
|
|
|
12331
12348
|
// Wait for connection
|
|
12332
12349
|
this._connectPromise = new Promise((onInit) => {
|
|
12333
12350
|
// Fetch the auth token
|
|
12334
|
-
let clientToken = localStorage.getItem(
|
|
12351
|
+
let clientToken = localStorage.getItem(this._clientTokenKey);
|
|
12335
12352
|
// Send the app token on first connect
|
|
12336
12353
|
this.ws.onopen = () => {
|
|
12337
12354
|
this.ws.send(JSON.stringify({ type: "auth", code: this.code, token: clientToken }));
|
|
@@ -12397,7 +12414,7 @@ class KokimokiClient extends EventEmitter$1 {
|
|
|
12397
12414
|
this.emit("connected");
|
|
12398
12415
|
}
|
|
12399
12416
|
handleInitMessage(message) {
|
|
12400
|
-
localStorage.setItem(
|
|
12417
|
+
localStorage.setItem(this._clientTokenKey, message.clientToken);
|
|
12401
12418
|
this._id = message.clientId;
|
|
12402
12419
|
this._connectionId = message.id;
|
|
12403
12420
|
this._token = message.appToken;
|