rhine-var 0.10.1 → 0.10.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.
- package/.github/workflows/release.yml +1 -1
- package/dist/core/connector/connector.abstract.d.ts +4 -4
- package/dist/core/connector/connector.abstract.d.ts.map +1 -1
- package/dist/core/subscriber/event-type.enum.d.ts +7 -0
- package/dist/core/subscriber/event-type.enum.d.ts.map +1 -0
- package/dist/core/subscriber/event-type.enum.js +10 -0
- package/dist/core/subscriber/subscriber.d.ts +9 -0
- package/dist/core/subscriber/subscriber.d.ts.map +1 -0
- package/dist/core/var/rhine-var-base.class.d.ts +11 -11
- package/dist/core/var/rhine-var-base.class.d.ts.map +1 -1
- package/dist/core/var/rhine-var-base.class.js +39 -39
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/dist/core/event/callback.d.ts +0 -8
- package/dist/core/event/callback.d.ts.map +0 -1
- package/dist/core/event/change-type.enum.d.ts +0 -7
- package/dist/core/event/change-type.enum.d.ts.map +0 -1
- package/dist/core/event/change-type.enum.js +0 -10
- /package/dist/core/{event/callback.js → subscriber/subscriber.js} +0 -0
|
@@ -131,7 +131,7 @@ jobs:
|
|
|
131
131
|
npm config set @RhineAI-Lab:registry=https://npm.pkg.github.com
|
|
132
132
|
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
|
|
133
133
|
|
|
134
|
-
- name: Publish to
|
|
134
|
+
- name: Publish to Github
|
|
135
135
|
run: npm publish
|
|
136
136
|
env:
|
|
137
137
|
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { YMap, YDoc } from "../../index";
|
|
2
2
|
import { ConnectorStatus } from "./connector-status.enum";
|
|
3
3
|
import { Native } from "../native/native.type";
|
|
4
|
-
import {
|
|
4
|
+
import { SyncedSubscriber } from "../subscriber/subscriber";
|
|
5
5
|
export default abstract class Connector {
|
|
6
6
|
static STATE_KEY: string;
|
|
7
7
|
yDoc: YDoc | null;
|
|
@@ -9,9 +9,9 @@ export default abstract class Connector {
|
|
|
9
9
|
clientId: number;
|
|
10
10
|
synced: boolean;
|
|
11
11
|
status: ConnectorStatus;
|
|
12
|
-
protected syncedSubscribers:
|
|
13
|
-
subscribeSynced(callback:
|
|
14
|
-
unsubscribeSynced(callback:
|
|
12
|
+
protected syncedSubscribers: SyncedSubscriber[];
|
|
13
|
+
subscribeSynced(callback: SyncedSubscriber): () => void;
|
|
14
|
+
unsubscribeSynced(callback: SyncedSubscriber): void;
|
|
15
15
|
unsubscribeAllSynced(): void;
|
|
16
16
|
protected emitSynced(synced: boolean): void;
|
|
17
17
|
afterSynced(callback: () => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.abstract.d.ts","sourceRoot":"","sources":["../../../src/core/connector/connector.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAe;AACpC,OAAO,EAAC,eAAe,EAAC,gCAA+C;AACvE,OAAO,EAAC,MAAM,EAAC,8BAAkC;AACjD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"connector.abstract.d.ts","sourceRoot":"","sources":["../../../src/core/connector/connector.abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAe;AACpC,OAAO,EAAC,eAAe,EAAC,gCAA+C;AACvE,OAAO,EAAC,MAAM,EAAC,8BAAkC;AACjD,OAAO,EAAC,gBAAgB,EAAC,iCAAqC;AAE9D,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,SAAS;IAErC,MAAM,CAAC,SAAS,SAAU;IAE1B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAO;IACxB,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAO;IAEjC,QAAQ,SAAK;IACb,MAAM,UAAQ;IAEd,MAAM,EAAE,eAAe,CAA+B;IAGtD,SAAS,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,CAAK;IACpD,eAAe,CAAC,QAAQ,EAAE,gBAAgB;IAI1C,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB;IAG5C,oBAAoB;IAGpB,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO;IAIpC,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI;IAahC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;gBAMf,IAAI,GAAE,MAAW;IAG7B,QAAQ,IAAI,OAAO;IAInB,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7C,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAErC;AAGD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,QAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-type.enum.d.ts","sourceRoot":"","sources":["../../../src/core/subscriber/event-type.enum.ts"],"names":[],"mappings":"AACA,oBAAY,SAAS;IACnB,GAAG,QAAQ,CAAG,oBAAoB;IAClC,MAAM,WAAW,CAAG,WAAW;IAC/B,MAAM,WAAW,CAAG,oBAAoB;IACxC,IAAI,SAAS;CACd"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventType = void 0;
|
|
4
|
+
var EventType;
|
|
5
|
+
(function (EventType) {
|
|
6
|
+
EventType["ADD"] = "ADD";
|
|
7
|
+
EventType["UPDATE"] = "UPDATE";
|
|
8
|
+
EventType["DELETE"] = "DELETE";
|
|
9
|
+
EventType["SYNC"] = "SYNC";
|
|
10
|
+
})(EventType || (exports.EventType = EventType = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EventType } from "./event-type.enum";
|
|
2
|
+
import { Transaction, YArrayEvent, YMapEvent, YTextEvent } from "yjs";
|
|
3
|
+
import { RvPath } from "../native/native.type";
|
|
4
|
+
import { StoredRhineVar } from "../var/rhine-var.type";
|
|
5
|
+
export type Subscriber<T> = (type: EventType, key: keyof T, value: T[keyof T] extends object ? T[keyof T] | StoredRhineVar<T[keyof T]> : T[keyof T], oldValue: T[keyof T], nativeEvent: YMapEvent<any> | YArrayEvent<any> | YTextEvent, nativeTransaction: Transaction) => void;
|
|
6
|
+
export type KeySubscriber<T> = (type: EventType, value: T[keyof T] extends object ? T[keyof T] | StoredRhineVar<T[keyof T]> : T[keyof T], oldValue: T[keyof T], nativeEvent: YMapEvent<any> | YArrayEvent<any> | YTextEvent, nativeTransaction: Transaction) => void;
|
|
7
|
+
export type DeepSubscriber<T> = (type: EventType, path: RvPath, value: any | StoredRhineVar<any>, oldValue: any, nativeEvent: YMapEvent<any> | YArrayEvent<any> | YTextEvent, nativeTransaction: Transaction) => void;
|
|
8
|
+
export type SyncedSubscriber = (synced: boolean) => void;
|
|
9
|
+
//# sourceMappingURL=subscriber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriber.d.ts","sourceRoot":"","sources":["../../../src/core/subscriber/subscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,0BAA0C;AAC5D,OAAO,EAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACpE,OAAO,EAAC,MAAM,EAAC,8BAAkC;AACjD,OAAO,EAAC,cAAc,EAAC,8BAAkC;AAGzD,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAC1B,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,CAAC,EACZ,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,M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protocols/awareness";
|
|
3
3
|
import { Native, RvPath } from "../native/native.type";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { EventType } from "../subscriber/event-type.enum";
|
|
5
|
+
import { Subscriber, DeepSubscriber, SyncedSubscriber, KeySubscriber } from "../subscriber/subscriber";
|
|
6
6
|
import Connector from "../connector/connector.abstract";
|
|
7
7
|
import ProxyOptions from "../proxy/proxy-options.interface";
|
|
8
8
|
export default abstract class RhineVarBase<T extends object = any> {
|
|
@@ -30,24 +30,24 @@ export default abstract class RhineVarBase<T extends object = any> {
|
|
|
30
30
|
frozenJson(): T;
|
|
31
31
|
jsonString(indent?: number): string;
|
|
32
32
|
private syncedSubscribers;
|
|
33
|
-
subscribeSynced(callback:
|
|
34
|
-
unsubscribeSynced(callback:
|
|
33
|
+
subscribeSynced(callback: SyncedSubscriber): () => void;
|
|
34
|
+
unsubscribeSynced(callback: SyncedSubscriber): void;
|
|
35
35
|
unsubscribeAllSynced(): void;
|
|
36
36
|
private emitSynced;
|
|
37
37
|
private subscribers;
|
|
38
|
-
subscribe(
|
|
39
|
-
unsubscribe(
|
|
38
|
+
subscribe(subscriber: Subscriber<T>): () => void;
|
|
39
|
+
unsubscribe(subscriber: Subscriber<T>): void;
|
|
40
40
|
unsubscribeAll(): void;
|
|
41
41
|
private keySubscribers;
|
|
42
|
-
subscribeKey(key: keyof T,
|
|
43
|
-
unsubscribeKey(
|
|
42
|
+
subscribeKey(key: keyof T, subscriber: KeySubscriber<T>): () => void;
|
|
43
|
+
unsubscribeKey(subscriber: KeySubscriber<T>): void;
|
|
44
44
|
unsubscribeAllKey(): void;
|
|
45
45
|
private emit;
|
|
46
46
|
private deepSubscribers;
|
|
47
|
-
subscribeDeep(
|
|
48
|
-
unsubscribeDeep(
|
|
47
|
+
subscribeDeep(subscriber: DeepSubscriber<T>): () => void;
|
|
48
|
+
unsubscribeDeep(subscriber: DeepSubscriber<T>): void;
|
|
49
49
|
unsubscribeAllDeep(): void;
|
|
50
|
-
emitDeep(path: RvPath, value: any, oldValue: any,
|
|
50
|
+
emitDeep(type: EventType, path: RvPath, value: any, oldValue: any, nativeEvent: YMapEvent<any> | YArrayEvent<any> | YTextEvent, nativeTransaction: Transaction): void;
|
|
51
51
|
private observer;
|
|
52
52
|
private syncedObserver;
|
|
53
53
|
observe(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rhine-var-base.class.d.ts","sourceRoot":"","sources":["../../../src/core/var/rhine-var-base.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACjF,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EAAC,MAAM,EAAS,MAAM,EAAC,8BAAkC;AAChE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"rhine-var-base.class.d.ts","sourceRoot":"","sources":["../../../src/core/var/rhine-var-base.class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACjF,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EAAC,MAAM,EAAS,MAAM,EAAC,8BAAkC;AAChE,OAAO,EAAC,SAAS,EAAC,sCAA0C;AAC5D,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAC,iCAAqC;AACzG,OAAO,SAAS,wCAA4C;AAE5D,OAAO,YAAY,yCAA6C;AAKhE,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG;IAGtD,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,YAAY,GAAG,IAAI;IAC3B,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;gBAFxB,MAAM,EAAE,MAAM,EAC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C,eAAe,CAA0B;IACjD,aAAa,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAIxD,eAAe,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;IAG7C,kBAAkB;IAIlB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,iBAAiB,EAAE,WAAW;IAW9J,OAAO,CAAC,QAAQ,CAA0F;IAC1G,OAAO,CAAC,cAAc,CAA4C;IAElE,OAAO;IA4IP,SAAS;CAQV;AAGD,eAAO,MAAM,+BAA+B,sBAyD1C,CAAA"}
|
|
@@ -10,7 +10,7 @@ const index_1 = require("../../index");
|
|
|
10
10
|
const rhine_proxy_1 = require("../proxy/rhine-proxy");
|
|
11
11
|
const logger_1 = require("../../utils/logger");
|
|
12
12
|
const data_utils_1 = require("../utils/data.utils");
|
|
13
|
-
const
|
|
13
|
+
const event_type_enum_1 = require("../subscriber/event-type.enum");
|
|
14
14
|
const native_utils_1 = require("../utils/native.utils");
|
|
15
15
|
const config_1 = __importDefault(require("../../config/config"));
|
|
16
16
|
class RhineVarBase {
|
|
@@ -225,53 +225,53 @@ class RhineVarBase {
|
|
|
225
225
|
emitSynced(synced) {
|
|
226
226
|
this.syncedSubscribers.forEach(subscriber => subscriber(synced));
|
|
227
227
|
}
|
|
228
|
-
subscribe(
|
|
229
|
-
this.subscribers.push(
|
|
230
|
-
return () => this.unsubscribe(
|
|
228
|
+
subscribe(subscriber) {
|
|
229
|
+
this.subscribers.push(subscriber);
|
|
230
|
+
return () => this.unsubscribe(subscriber);
|
|
231
231
|
}
|
|
232
|
-
unsubscribe(
|
|
233
|
-
this.subscribers = this.subscribers.filter(
|
|
232
|
+
unsubscribe(subscriber) {
|
|
233
|
+
this.subscribers = this.subscribers.filter(s => s !== subscriber);
|
|
234
234
|
}
|
|
235
235
|
unsubscribeAll() {
|
|
236
236
|
this.subscribers = [];
|
|
237
237
|
}
|
|
238
|
-
subscribeKey(key,
|
|
238
|
+
subscribeKey(key, subscriber) {
|
|
239
239
|
if (!this.keySubscribers.has(key)) {
|
|
240
240
|
this.keySubscribers.set(key, []);
|
|
241
241
|
}
|
|
242
|
-
this.keySubscribers.get(key).push(
|
|
243
|
-
return () => this.unsubscribeKey(
|
|
242
|
+
this.keySubscribers.get(key).push(subscriber);
|
|
243
|
+
return () => this.unsubscribeKey(subscriber);
|
|
244
244
|
}
|
|
245
|
-
unsubscribeKey(
|
|
245
|
+
unsubscribeKey(subscriber) {
|
|
246
246
|
this.keySubscribers.forEach((subscribers, key) => {
|
|
247
|
-
this.keySubscribers.set(key, subscribers.filter(
|
|
247
|
+
this.keySubscribers.set(key, subscribers.filter(s => s !== subscriber));
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
unsubscribeAllKey() {
|
|
251
251
|
this.keySubscribers = new Map();
|
|
252
252
|
}
|
|
253
|
-
emit(key, value, oldValue,
|
|
254
|
-
this.subscribers.forEach(subscriber => subscriber(key, value, oldValue,
|
|
253
|
+
emit(type, key, value, oldValue, nativeEvent, nativeTransaction) {
|
|
254
|
+
this.subscribers.forEach(subscriber => subscriber(type, key, value, oldValue, nativeEvent, nativeTransaction));
|
|
255
255
|
if (this.keySubscribers.has(key)) {
|
|
256
|
-
this.keySubscribers.get(key).forEach(subscriber => subscriber(
|
|
256
|
+
this.keySubscribers.get(key).forEach(subscriber => subscriber(type, value, oldValue, nativeEvent, nativeTransaction));
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
subscribeDeep(
|
|
260
|
-
this.deepSubscribers.push(
|
|
261
|
-
return () => this.unsubscribeDeep(
|
|
259
|
+
subscribeDeep(subscriber) {
|
|
260
|
+
this.deepSubscribers.push(subscriber);
|
|
261
|
+
return () => this.unsubscribeDeep(subscriber);
|
|
262
262
|
}
|
|
263
|
-
unsubscribeDeep(
|
|
264
|
-
this.deepSubscribers = this.deepSubscribers.filter(
|
|
263
|
+
unsubscribeDeep(subscriber) {
|
|
264
|
+
this.deepSubscribers = this.deepSubscribers.filter(s => s !== subscriber);
|
|
265
265
|
}
|
|
266
266
|
unsubscribeAllDeep() {
|
|
267
267
|
this.deepSubscribers = [];
|
|
268
268
|
}
|
|
269
|
-
emitDeep(path, value, oldValue,
|
|
270
|
-
this.deepSubscribers.forEach(subscriber => subscriber(path, value, oldValue,
|
|
269
|
+
emitDeep(type, path, value, oldValue, nativeEvent, nativeTransaction) {
|
|
270
|
+
this.deepSubscribers.forEach(subscriber => subscriber(type, path, value, oldValue, nativeEvent, nativeTransaction));
|
|
271
271
|
if (this.parent) {
|
|
272
272
|
const key = (0, native_utils_1.getKeyFromParent)(this.native);
|
|
273
273
|
if (key !== undefined) {
|
|
274
|
-
this.parent.emitDeep([key, ...path], value, oldValue,
|
|
274
|
+
this.parent.emitDeep(type, [key, ...path], value, oldValue, nativeEvent, nativeTransaction);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
}
|
|
@@ -288,7 +288,7 @@ class RhineVarBase {
|
|
|
288
288
|
if (target instanceof index_1.YMap) {
|
|
289
289
|
this.observer = (event, transaction) => {
|
|
290
290
|
event.changes.keys.forEach(({ action, oldValue }, key) => {
|
|
291
|
-
const type = action === 'add' ?
|
|
291
|
+
const type = action === 'add' ? event_type_enum_1.EventType.ADD : (action === 'delete' ? event_type_enum_1.EventType.DELETE : event_type_enum_1.EventType.UPDATE);
|
|
292
292
|
if ((0, data_utils_1.isObjectOrArray)(oldValue)) {
|
|
293
293
|
oldValue = Reflect.get(this, key);
|
|
294
294
|
if (oldValue instanceof RhineVarBase) {
|
|
@@ -296,7 +296,7 @@ class RhineVarBase {
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
let value = undefined;
|
|
299
|
-
if (type ===
|
|
299
|
+
if (type === event_type_enum_1.EventType.ADD || type === event_type_enum_1.EventType.UPDATE) {
|
|
300
300
|
value = target.get(key);
|
|
301
301
|
if ((0, native_utils_1.isNative)(value)) {
|
|
302
302
|
Reflect.set(this._origin, key, (0, rhine_proxy_1.rhineProxyGeneral)(value, this));
|
|
@@ -305,13 +305,13 @@ class RhineVarBase {
|
|
|
305
305
|
Reflect.set(this._origin, key, value);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
|
-
else if (type ===
|
|
308
|
+
else if (type === event_type_enum_1.EventType.DELETE) {
|
|
309
309
|
Reflect.deleteProperty(this._origin, key);
|
|
310
310
|
}
|
|
311
311
|
const newValue = key in this ? Reflect.get(this, key) : value;
|
|
312
312
|
(0, logger_1.log)('Proxy.event: Map', action, key + ':', oldValue, '->', newValue);
|
|
313
|
-
this.emit(key, newValue, oldValue,
|
|
314
|
-
this.emitDeep([key], newValue, oldValue,
|
|
313
|
+
this.emit(type, key, newValue, oldValue, event, transaction);
|
|
314
|
+
this.emitDeep(type, [key], newValue, oldValue, event, transaction);
|
|
315
315
|
});
|
|
316
316
|
};
|
|
317
317
|
}
|
|
@@ -335,8 +335,8 @@ class RhineVarBase {
|
|
|
335
335
|
Reflect.deleteProperty(this._origin, k);
|
|
336
336
|
}
|
|
337
337
|
(0, logger_1.log)('Proxy.event: Array delete', i + ':', oldValue, '->', undefined);
|
|
338
|
-
this.emit(i, undefined, oldValue,
|
|
339
|
-
this.emitDeep([i], undefined, oldValue,
|
|
338
|
+
this.emit(event_type_enum_1.EventType.DELETE, i, undefined, oldValue, event, transaction);
|
|
339
|
+
this.emitDeep(event_type_enum_1.EventType.DELETE, [i], undefined, oldValue, event, transaction);
|
|
340
340
|
i++;
|
|
341
341
|
}
|
|
342
342
|
}
|
|
@@ -354,8 +354,8 @@ class RhineVarBase {
|
|
|
354
354
|
}
|
|
355
355
|
const newValue = i in this ? Reflect.get(this, i) : target.get(i);
|
|
356
356
|
(0, logger_1.log)('Proxy.event: Array add', i, ':', undefined, '->', newValue);
|
|
357
|
-
this.emit(i, newValue, undefined,
|
|
358
|
-
this.emitDeep([i], newValue, undefined,
|
|
357
|
+
this.emit(event_type_enum_1.EventType.ADD, i, newValue, undefined, event, transaction);
|
|
358
|
+
this.emitDeep(event_type_enum_1.EventType.ADD, [i], newValue, undefined, event, transaction);
|
|
359
359
|
i++;
|
|
360
360
|
});
|
|
361
361
|
}
|
|
@@ -381,8 +381,8 @@ class RhineVarBase {
|
|
|
381
381
|
let i = 0;
|
|
382
382
|
if (isUpdate) {
|
|
383
383
|
(0, logger_1.log)('Proxy.event: Text update', ':', oldValue, '->', newValue);
|
|
384
|
-
this.emit(i, newValue, oldValue,
|
|
385
|
-
this.emitDeep([i], newValue, oldValue,
|
|
384
|
+
this.emit(event_type_enum_1.EventType.UPDATE, i, newValue, oldValue, event, transaction);
|
|
385
|
+
this.emitDeep(event_type_enum_1.EventType.UPDATE, [i], newValue, oldValue, event, transaction);
|
|
386
386
|
}
|
|
387
387
|
else {
|
|
388
388
|
event.delta.forEach(deltaItem => {
|
|
@@ -392,14 +392,14 @@ class RhineVarBase {
|
|
|
392
392
|
}
|
|
393
393
|
if (deltaItem.delete !== undefined) {
|
|
394
394
|
(0, logger_1.log)('Proxy.event: Text delete', i, ':', oldValue, '->', newValue);
|
|
395
|
-
this.emit(i, newValue, oldValue,
|
|
396
|
-
this.emitDeep([i], newValue, oldValue,
|
|
395
|
+
this.emit(event_type_enum_1.EventType.DELETE, i, newValue, oldValue, event, transaction);
|
|
396
|
+
this.emitDeep(event_type_enum_1.EventType.DELETE, [i], newValue, oldValue, event, transaction);
|
|
397
397
|
i += deltaItem.delete;
|
|
398
398
|
}
|
|
399
399
|
else if (deltaItem.insert !== undefined) {
|
|
400
400
|
(0, logger_1.log)('Proxy.event: Text add', i, ':', oldValue, '->', newValue);
|
|
401
|
-
this.emit(i, newValue, oldValue,
|
|
402
|
-
this.emitDeep([i], newValue, oldValue,
|
|
401
|
+
this.emit(event_type_enum_1.EventType.ADD, i, newValue, oldValue, event, transaction);
|
|
402
|
+
this.emitDeep(event_type_enum_1.EventType.ADD, [i], newValue, oldValue, event, transaction);
|
|
403
403
|
i += newValue.length;
|
|
404
404
|
}
|
|
405
405
|
});
|
|
@@ -408,8 +408,8 @@ class RhineVarBase {
|
|
|
408
408
|
}
|
|
409
409
|
else {
|
|
410
410
|
this.observer = (event, transaction) => {
|
|
411
|
-
this.emit(
|
|
412
|
-
this.emitDeep(
|
|
411
|
+
this.emit(event_type_enum_1.EventType.UPDATE, undefined, undefined, undefined, event, transaction);
|
|
412
|
+
this.emitDeep(event_type_enum_1.EventType.UPDATE, undefined, undefined, undefined, event, transaction);
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
415
|
if (this.observer) {
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import item from "./core/proxy/items/item";
|
|
|
17
17
|
import { Doc as YDoc, Array as YArray, Map as YMap, Text as YText, XmlFragment as YXmlFragment, XmlElement as YXmlElement, XmlText as YXmlText } from "yjs";
|
|
18
18
|
import ProxyOptions from "./core/proxy/proxy-options.interface";
|
|
19
19
|
import { UndoManagerOptions } from "yjs/dist/src/utils/UndoManager";
|
|
20
|
-
import {
|
|
20
|
+
import { EventType } from "./core/subscriber/event-type.enum";
|
|
21
21
|
export type { StoredRhineVar, RhineVarAny, RecursiveCrossRhineVar, RecursiveObject, RecursiveArray, RecursiveMap, Native, RvPath, RvKey, ProxyOptions, UndoManagerOptions, };
|
|
22
|
-
export { Connector, rhineProxy, rhineProxyGeneral, item, text, map, RhineVarBase, RhineVar, RhineVarMap, RhineVarArray, RhineVarText, RhineVarXmlText, RhineVarXmlElement, RhineVarXmlFragment, SupportManager, enableRhineVarLog, enableRhineVarSyncHandshakeCheck, getRhineVarConfig, YDoc, YMap, YArray, YText, YXmlFragment, YXmlElement, YXmlText,
|
|
22
|
+
export { Connector, rhineProxy, rhineProxyGeneral, item, text, map, RhineVarBase, RhineVar, RhineVarMap, RhineVarArray, RhineVarText, RhineVarXmlText, RhineVarXmlElement, RhineVarXmlFragment, SupportManager, enableRhineVarLog, enableRhineVarSyncHandshakeCheck, getRhineVarConfig, YDoc, YMap, YArray, YText, YXmlFragment, YXmlElement, YXmlText, EventType, };
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAC,iCAAiC;AACvE,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,kCAAkC;AACzJ,OAAO,SAAS,4CAA4C;AAC5D,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAC,kCAAkC;AAChE,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAE,gCAAgC,EAAC,wBAAwB;AACvG,OAAO,YAAY,wCAAwC;AAC3D,OAAO,WAAW,6CAA6C;AAC/D,OAAO,aAAa,+CAA+C;AACnE,OAAO,YAAY,8CAA8C;AACjE,OAAO,eAAe,kDAAkD;AACxE,OAAO,kBAAkB,qDAAqD;AAC9E,OAAO,mBAAmB,sDAAsD;AAChF,OAAO,cAAc,2CAA2C;AAChE,OAAO,IAAI,gCAAgC;AAC3C,OAAO,GAAG,MAAM,wBAAwB,CAAC;AACzC,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,EACL,GAAG,IAAI,IAAI,EACX,KAAK,IAAI,MAAM,EACf,GAAG,IAAI,IAAI,EACX,IAAI,IAAI,KAAK,EACb,WAAW,IAAI,YAAY,EAC3B,UAAU,IAAI,WAAW,EACzB,OAAO,IAAI,QAAQ,EACpB,MAAM,KAAK,CAAC;AACb,OAAO,YAAY,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,kBAAkB,EA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YAAY,EACZ,kBAAkB,GACnB,CAAA;AAED,OAAO,EACL,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gCAAgC,EAChC,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,KAAK,EACL,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,SAAS,GACV,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.EventType = exports.YXmlText = exports.YXmlElement = exports.YXmlFragment = exports.YText = exports.YArray = exports.YMap = exports.YDoc = exports.getRhineVarConfig = exports.enableRhineVarSyncHandshakeCheck = exports.enableRhineVarLog = exports.SupportManager = exports.RhineVarXmlFragment = exports.RhineVarXmlElement = exports.RhineVarXmlText = exports.RhineVarText = exports.RhineVarArray = exports.RhineVarMap = exports.RhineVarBase = exports.map = exports.text = exports.item = exports.rhineProxyGeneral = exports.rhineProxy = exports.Connector = void 0;
|
|
7
7
|
const rhine_proxy_1 = require("./core/proxy/rhine-proxy");
|
|
8
8
|
Object.defineProperty(exports, "rhineProxy", { enumerable: true, get: function () { return rhine_proxy_1.rhineProxy; } });
|
|
9
9
|
Object.defineProperty(exports, "rhineProxyGeneral", { enumerable: true, get: function () { return rhine_proxy_1.rhineProxyGeneral; } });
|
|
@@ -43,5 +43,5 @@ Object.defineProperty(exports, "YText", { enumerable: true, get: function () { r
|
|
|
43
43
|
Object.defineProperty(exports, "YXmlFragment", { enumerable: true, get: function () { return yjs_1.XmlFragment; } });
|
|
44
44
|
Object.defineProperty(exports, "YXmlElement", { enumerable: true, get: function () { return yjs_1.XmlElement; } });
|
|
45
45
|
Object.defineProperty(exports, "YXmlText", { enumerable: true, get: function () { return yjs_1.XmlText; } });
|
|
46
|
-
const
|
|
47
|
-
Object.defineProperty(exports, "
|
|
46
|
+
const event_type_enum_1 = require("./core/subscriber/event-type.enum");
|
|
47
|
+
Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return event_type_enum_1.EventType; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rhine-var",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "Variables that support multi-user collaboration and persistence, making collaboration and variable operations as simple as possible, with strict and well-defined type hints.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ChangeType } from "./change-type.enum";
|
|
2
|
-
import { Transaction, YArrayEvent, YMapEvent, YTextEvent } from "yjs";
|
|
3
|
-
import { RvPath } from "../native/native.type";
|
|
4
|
-
import { StoredRhineVar } from "../var/rhine-var.type";
|
|
5
|
-
export type Callback<T> = (key: keyof T, value: T[keyof T] extends object ? T[keyof T] | StoredRhineVar<T[keyof T]> : T[keyof T], oldValue: T[keyof T], type: ChangeType, nativeEvent: YMapEvent<any> | YArrayEvent<any> | YTextEvent, nativeTransaction: Transaction) => void;
|
|
6
|
-
export type DeepCallback<T> = (path: RvPath, value: any | StoredRhineVar<any>, oldValue: any, type: ChangeType, nativeEvent: YMapEvent<any> | YArrayEvent<any> | YTextEvent, nativeTransaction: Transaction) => void;
|
|
7
|
-
export type SyncedCallback = (synced: boolean) => void;
|
|
8
|
-
//# sourceMappingURL=callback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../src/core/event/callback.ts"],"names":[],"mappings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,WAAW;IAC/B,MAAM,WAAW,CAAG,oBAAoB;IACxC,IAAI,SAAS;CACd"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChangeType = void 0;
|
|
4
|
-
var ChangeType;
|
|
5
|
-
(function (ChangeType) {
|
|
6
|
-
ChangeType["Add"] = "ADD";
|
|
7
|
-
ChangeType["Update"] = "UPDATE";
|
|
8
|
-
ChangeType["Delete"] = "DELETE";
|
|
9
|
-
ChangeType["Sync"] = "SYNC";
|
|
10
|
-
})(ChangeType || (exports.ChangeType = ChangeType = {}));
|
|
File without changes
|