New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tldraw/tlsync-client

Package Overview
Dependencies
Maintainers
4
Versions
327
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tldraw/tlsync-client - npm Package Compare versions

Comparing version

to
2.0.0-alpha.8

6

dist/cjs/lib/hooks/useLocalSyncClient.js

@@ -51,7 +51,5 @@ "use strict";

};
const initialData = initialDataRef?.current;
const store = initialData ? config.createStore({ initialData }) : config.createStore();
const initialData = initialDataRef?.current ?? void 0;
const store = config.createStore({ initialData, userId, instanceId });
const client = new import_TLLocalSyncClient.TLLocalSyncClient(store, {
instanceId,
userId,
universalPersistenceKey,

@@ -58,0 +56,0 @@ onLoad() {

@@ -62,3 +62,3 @@ "use strict";

};
const store = config.createStore();
const store = config.createStore({ instanceId, userId: (0, import_persistence_constants.getUserData)().id });
const socket = new import_ClientWebSocketAdapter.ClientWebSocketAdapter(uri);

@@ -88,3 +88,3 @@ const client = new import_tlsync.TLSyncClient({

onAfterConnect() {
store.ensureStoreIsUsable({ instanceId, currentUserId: (0, import_persistence_constants.getUserData)().id });
store.ensureStoreIsUsable();
}

@@ -135,8 +135,11 @@ });

}
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
className: "tlui-share-zone__connection-status",
"aria-label": syncedStore.connectionStatus,
style: { color: statusColor }
});
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
"div",
{
className: "tlui-share-zone__connection-status",
"aria-label": syncedStore.connectionStatus,
style: { color: statusColor }
}
);
}
//# sourceMappingURL=useRemoteSyncClient.js.map

@@ -25,3 +25,2 @@ "use strict";

module.exports = __toCommonJS(TLLocalSyncClient_exports);
var import_editor = require("@tldraw/editor");
var import_tlstore = require("@tldraw/tlstore");

@@ -47,4 +46,2 @@ var import_utils = require("@tldraw/utils");

constructor(store, {
instanceId,
userId,
universalPersistenceKey,

@@ -60,4 +57,2 @@ onLoad,

}
this.instanceId = instanceId;
this.userId = userId;
this.universalPersistenceKey = universalPersistenceKey;

@@ -73,3 +68,3 @@ this.serializedSchema = this.store.schema.serialize();

type: "diff",
instanceId: this.instanceId,
instanceId: this.store.props.instanceId,
changes,

@@ -90,4 +85,2 @@ schema: this.serializedSchema

isReloading = false;
instanceId;
userId;
universalPersistenceKey;

@@ -120,15 +113,11 @@ serializedSchema;

if (data) {
const bstore = new import_editor.TLStore({
schema: this.store.schema,
initialData: Object.fromEntries(data.records.map((r) => [r.id, r])),
UNSAFE_SKIP_INITIAL_VALIDATION: true
});
const result = this.store.schema.migrateStore(bstore, data.schema);
if (result.type === "error") {
console.error("failed to migrate store", result);
onLoadError(new Error(`Failed to migrate store: ${result.reason}`));
const snapshot = Object.fromEntries(data.records.map((r) => [r.id, r]));
const migrationResult = this.store.schema.migrateStoreSnapshot(snapshot, data.schema);
if (migrationResult.type === "error") {
console.error("failed to migrate store", migrationResult);
onLoadError(new Error(`Failed to migrate store: ${migrationResult.reason}`));
return;
}
this.store.mergeRemoteChanges(() => {
this.store.put(bstore.allRecords(), "initialize");
this.store.put(Object.values(migrationResult.value), "initialize");
});

@@ -162,3 +151,6 @@ }

this.debug("applying diff");
const doesDeleteInstance = (0, import_utils.hasOwnProperty)(msg2.changes.removed, this.instanceId);
const doesDeleteInstance = (0, import_utils.hasOwnProperty)(
msg2.changes.removed,
this.store.props.instanceId
);
(0, import_signia.transact)(() => {

@@ -169,6 +161,3 @@ this.store.mergeRemoteChanges(() => {

if (doesDeleteInstance) {
this.store.ensureStoreIsUsable({
instanceId: this.instanceId,
currentUserId: this.userId
});
this.store.ensureStoreIsUsable();
}

@@ -175,0 +164,0 @@ });

@@ -31,7 +31,5 @@ import {

};
const initialData = initialDataRef?.current;
const store = initialData ? config.createStore({ initialData }) : config.createStore();
const initialData = initialDataRef?.current ?? void 0;
const store = config.createStore({ initialData, userId, instanceId });
const client = new TLLocalSyncClient(store, {
instanceId,
userId,
universalPersistenceKey,

@@ -38,0 +36,0 @@ onLoad() {

@@ -37,3 +37,3 @@ import { jsx } from "react/jsx-runtime";

};
const store = config.createStore();
const store = config.createStore({ instanceId, userId: getUserData().id });
const socket = new ClientWebSocketAdapter(uri);

@@ -63,3 +63,3 @@ const client = new TLSyncClient({

onAfterConnect() {
store.ensureStoreIsUsable({ instanceId, currentUserId: getUserData().id });
store.ensureStoreIsUsable();
}

@@ -110,7 +110,10 @@ });

}
return /* @__PURE__ */ jsx("div", {
className: "tlui-share-zone__connection-status",
"aria-label": syncedStore.connectionStatus,
style: { color: statusColor }
});
return /* @__PURE__ */ jsx(
"div",
{
className: "tlui-share-zone__connection-status",
"aria-label": syncedStore.connectionStatus,
style: { color: statusColor }
}
);
}

@@ -117,0 +120,0 @@ export {

@@ -1,2 +0,1 @@

import { TLStore } from "@tldraw/editor";
import { compareSchemas, squashRecordDiffs } from "@tldraw/tlstore";

@@ -22,4 +21,2 @@ import { assert, hasOwnProperty } from "@tldraw/utils";

constructor(store, {
instanceId,
userId,
universalPersistenceKey,

@@ -35,4 +32,2 @@ onLoad,

}
this.instanceId = instanceId;
this.userId = userId;
this.universalPersistenceKey = universalPersistenceKey;

@@ -48,3 +43,3 @@ this.serializedSchema = this.store.schema.serialize();

type: "diff",
instanceId: this.instanceId,
instanceId: this.store.props.instanceId,
changes,

@@ -65,4 +60,2 @@ schema: this.serializedSchema

isReloading = false;
instanceId;
userId;
universalPersistenceKey;

@@ -95,15 +88,11 @@ serializedSchema;

if (data) {
const bstore = new TLStore({
schema: this.store.schema,
initialData: Object.fromEntries(data.records.map((r) => [r.id, r])),
UNSAFE_SKIP_INITIAL_VALIDATION: true
});
const result = this.store.schema.migrateStore(bstore, data.schema);
if (result.type === "error") {
console.error("failed to migrate store", result);
onLoadError(new Error(`Failed to migrate store: ${result.reason}`));
const snapshot = Object.fromEntries(data.records.map((r) => [r.id, r]));
const migrationResult = this.store.schema.migrateStoreSnapshot(snapshot, data.schema);
if (migrationResult.type === "error") {
console.error("failed to migrate store", migrationResult);
onLoadError(new Error(`Failed to migrate store: ${migrationResult.reason}`));
return;
}
this.store.mergeRemoteChanges(() => {
this.store.put(bstore.allRecords(), "initialize");
this.store.put(Object.values(migrationResult.value), "initialize");
});

@@ -137,3 +126,6 @@ }

this.debug("applying diff");
const doesDeleteInstance = hasOwnProperty(msg2.changes.removed, this.instanceId);
const doesDeleteInstance = hasOwnProperty(
msg2.changes.removed,
this.store.props.instanceId
);
transact(() => {

@@ -144,6 +136,3 @@ this.store.mergeRemoteChanges(() => {

if (doesDeleteInstance) {
this.store.ensureStoreIsUsable({
instanceId: this.instanceId,
currentUserId: this.userId
});
this.store.ensureStoreIsUsable();
}

@@ -150,0 +139,0 @@ });

@@ -119,4 +119,2 @@ import { ReadySyncedStore } from '@tldraw/editor';

private isReloading;
readonly instanceId: TLInstanceId;
readonly userId: TLUserId;
readonly universalPersistenceKey: string;

@@ -127,5 +125,3 @@ readonly serializedSchema: SerializedSchema;

private debug;
constructor(store: TLStore, { instanceId, userId, universalPersistenceKey, onLoad, onLoadError, }: {
instanceId: TLInstanceId;
userId: TLUserId;
constructor(store: TLStore, { universalPersistenceKey, onLoad, onLoadError, }: {
universalPersistenceKey: string;

@@ -132,0 +128,0 @@ onLoad: (self: TLLocalSyncClient) => void;

@@ -5,3 +5,3 @@ {

"description": "A tiny little drawing app (multiplayer sync).",
"version": "2.0.0-alpha.7",
"version": "2.0.0-alpha.8",
"author": "tldraw GB Ltd.",

@@ -53,9 +53,11 @@ "homepage": "https://tldraw.dev",

},
"peerDependencies": {
"signia": "^0",
"signia-react": "^0"
},
"dependencies": {
"@tldraw/editor": "2.0.0-alpha.7",
"@tldraw/tlstore": "2.0.0-alpha.7",
"@tldraw/tlsync": "2.0.0-alpha.7",
"idb": "^7.1.0",
"signia": "^0.0.8",
"signia-react": "^0.0.8"
"@tldraw/editor": "2.0.0-alpha.8",
"@tldraw/tlstore": "2.0.0-alpha.8",
"@tldraw/tlsync": "2.0.0-alpha.8",
"idb": "^7.1.0"
},

@@ -62,0 +64,0 @@ "module": "dist/esm/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet