@pluv/crdt-yjs 0.4.0 → 0.4.1

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,17 +1,18 @@
1
1
 
2
- > @pluv/crdt-yjs@0.4.0 build /home/runner/work/pluv/pluv/packages/crdt-yjs
2
+ > @pluv/crdt-yjs@0.4.1 build /home/runner/work/pluv/pluv/packages/crdt-yjs
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
- CLI tsup v7.0.0
7
+ CLI tsup v7.1.0
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 3.68 KB
12
- ESM ⚡️ Build success in 95ms
13
11
  CJS dist/index.js 4.87 KB
14
- CJS ⚡️ Build success in 96ms
12
+ CJS ⚡️ Build success in 73ms
13
+ ESM dist/index.mjs 3.68 KB
14
+ ESM ⚡️ Build success in 73ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 2333ms
17
- DTS dist/index.d.ts 3.17 KB
16
+ DTS ⚡️ Build success in 2186ms
17
+ DTS dist/index.d.mts 3.17 KB
18
+ DTS dist/index.d.ts 3.17 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @pluv/crdt-yjs
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8fba48b: fix including incorrect dependency
8
+ - 8997c65: bumped dependencies
9
+ - Updated dependencies [8fba48b]
10
+ - Updated dependencies [8997c65]
11
+ - @pluv/types@0.2.2
12
+
3
13
  ## 0.4.0
4
14
 
5
15
  ### Minor Changes
@@ -0,0 +1,56 @@
1
+ import { Array, Map, AbstractType, Text, XmlElement, XmlFragment, XmlText, Doc, Transaction } from 'yjs';
2
+ export { AbstractType, Array, Map, Text } from 'yjs';
3
+ import { JsonPrimitive } from '@pluv/types';
4
+
5
+ declare const array: <T extends unknown>(value?: readonly T[]) => Array<T>;
6
+
7
+ type unstable__YObjectValue = Record<string, NonNullable<JsonPrimitive> | AbstractType<any>>;
8
+ type unstable__YObject<T extends unstable__YObjectValue> = Map<T[keyof T]> & {
9
+ __$type: T;
10
+ };
11
+ declare const object: <T extends unstable__YObjectValue = {}>(value: T) => unstable__YObject<T>;
12
+
13
+ type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? {
14
+ [P in keyof ITypes]: InferYjsSharedTypeJson<ITypes[P]>;
15
+ } : never;
16
+ type InferYjsDocSharedType<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsDocSharedTypes<TDoc>[TKey];
17
+ type InferYjsDocSharedTypeJson<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsSharedTypeJson<InferYjsDocSharedTypes<TDoc>[TKey]>;
18
+ type InferYjsDocSharedTypes<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? ITypes : never;
19
+ type InferYjsSharedTypeJson<TShared extends unknown> = TShared extends AbstractType<any> ? TShared extends Array<infer IItem> ? readonly InferYjsSharedTypeJson<IItem>[] : TShared extends unstable__YObject<infer IObject> ? {
20
+ [P in keyof IObject]: InferYjsSharedTypeJson<IObject[P]>;
21
+ } : TShared extends Map<infer IItem> ? Record<string, InferYjsSharedTypeJson<IItem>> : TShared extends Text | XmlElement | XmlFragment | XmlText ? string : never : TShared;
22
+
23
+ declare class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
24
+ value: Doc;
25
+ private get _storage();
26
+ constructor(value?: T);
27
+ applyUpdate(update?: string | Uint8Array | null, origin?: string): this;
28
+ destroy(): void;
29
+ encodeStateAsUpdate(): string;
30
+ get<TKey extends keyof T>(key: TKey): T[TKey];
31
+ getSharedTypes(): T;
32
+ subscribe(fn: (update: string, origin: any, doc: Doc, transaction: Transaction) => void): () => void;
33
+ toJSON(): InferYjsDocJson<this>;
34
+ transact(fn: (transaction: Transaction) => void, origin?: any): void;
35
+ static fromUint8Array(u8a: Uint8Array): string;
36
+ static toUint8Array(str: string): Uint8Array;
37
+ }
38
+ declare const doc: <T extends Record<string, AbstractType<any>> = {}>(value?: T | undefined) => YjsDoc<T>;
39
+
40
+ declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => Map<T>;
41
+
42
+ declare const text: (value?: string) => Text;
43
+
44
+ interface XmlElementParams {
45
+ children?: readonly (XmlElement | XmlText)[];
46
+ }
47
+ declare const xmlElement: (name: string, params?: XmlElementParams) => XmlElement;
48
+
49
+ interface XmlFragmentParams {
50
+ children?: readonly (XmlElement | XmlText)[];
51
+ }
52
+ declare const xmlFragment: (params?: XmlFragmentParams) => XmlFragment;
53
+
54
+ declare const xmlText: (value?: string) => XmlText;
55
+
56
+ export { InferYjsDocJson, InferYjsDocSharedType, InferYjsDocSharedTypeJson, InferYjsDocSharedTypes, InferYjsSharedTypeJson, XmlElementParams, XmlFragmentParams, YjsDoc, array, doc, map, object, text, unstable__YObject, xmlElement, xmlFragment, xmlText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/crdt-yjs",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "yjs for @pluv/io",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,20 +17,19 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@playwright/test": "^1.35.1",
21
- "@types/react": "^18.2.13",
20
+ "@types/react": "^18.2.15",
22
21
  "js-base64": "^3.7.5",
23
- "@pluv/types": "^0.2.1"
22
+ "@pluv/types": "^0.2.2"
24
23
  },
25
24
  "peerDependencies": {
26
25
  "yjs": "^13.0.0"
27
26
  },
28
27
  "devDependencies": {
29
- "tsup": "^7.0.0",
30
- "typescript": "^5.1.3",
31
- "yjs": "^13.6.4",
32
- "@pluv/tsconfig": "^0.1.7",
33
- "eslint-config-pluv": "^0.1.13"
28
+ "tsup": "^7.1.0",
29
+ "typescript": "^5.1.6",
30
+ "yjs": "^13.6.6",
31
+ "@pluv/tsconfig": "^0.1.8",
32
+ "eslint-config-pluv": "^0.1.14"
34
33
  },
35
34
  "scripts": {
36
35
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/array.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Array as YArray } from "yjs";
2
2
 
3
3
  export const array = <T extends unknown>(
4
- value: readonly T[] = []
4
+ value: readonly T[] = [],
5
5
  ): YArray<T> => {
6
6
  const yarray = new YArray<T>();
7
7
 
package/src/doc.ts CHANGED
@@ -28,7 +28,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
28
28
 
29
29
  public applyUpdate(
30
30
  update?: string | Uint8Array | null,
31
- origin?: string
31
+ origin?: string,
32
32
  ): this {
33
33
  if (update === null || typeof update === "undefined") return this;
34
34
 
@@ -55,7 +55,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
55
55
  public getSharedTypes(): T {
56
56
  return Array.from(this._storage.keys()).reduce(
57
57
  (acc, key) => ({ ...acc, [key]: this._storage.get(key) }),
58
- {} as T
58
+ {} as T,
59
59
  );
60
60
  }
61
61
 
@@ -64,14 +64,14 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
64
64
  update: string,
65
65
  origin: any,
66
66
  doc: YDoc,
67
- transaction: Transaction
68
- ) => void
67
+ transaction: Transaction,
68
+ ) => void,
69
69
  ): () => void {
70
70
  const _fn = (
71
71
  update: Uint8Array,
72
72
  origin: any,
73
73
  doc: YDoc,
74
- transaction: Transaction
74
+ transaction: Transaction,
75
75
  ) => fn(YjsDoc.fromUint8Array(update), origin, doc, transaction);
76
76
 
77
77
  this.value.on("update", _fn);
@@ -87,7 +87,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
87
87
 
88
88
  public transact(
89
89
  fn: (transaction: Transaction) => void,
90
- origin?: any
90
+ origin?: any,
91
91
  ): void {
92
92
  this.value.transact((tx) => {
93
93
  fn(tx);
@@ -104,7 +104,7 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
104
104
  }
105
105
 
106
106
  export const doc = <T extends Record<string, AbstractType<any>> = {}>(
107
- value?: T
107
+ value?: T,
108
108
  ): YjsDoc<T> => {
109
109
  return new YjsDoc(value);
110
110
  };
package/src/map.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Map as YMap } from "yjs";
2
2
 
3
3
  export const map = <T extends unknown>(
4
- value: readonly (readonly [key: string, value: T])[] = []
4
+ value: readonly (readonly [key: string, value: T])[] = [],
5
5
  ): YMap<T> => {
6
6
  return new YMap(value);
7
7
  };
package/src/object.ts CHANGED
@@ -12,7 +12,7 @@ export type unstable__YObject<T extends unstable__YObjectValue> = YMap<
12
12
  > & { __$type: T };
13
13
 
14
14
  export const object = <T extends unstable__YObjectValue = {}>(
15
- value: T
15
+ value: T,
16
16
  ): unstable__YObject<T> => {
17
17
  return new YMap(Object.entries(value)) as unstable__YObject<T>;
18
18
  };
package/src/types.ts CHANGED
@@ -18,12 +18,14 @@ export type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<
18
18
 
19
19
  export type InferYjsDocSharedType<
20
20
  TDoc extends YjsDoc<any>,
21
- TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>
21
+ TKey extends
22
+ keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>,
22
23
  > = InferYjsDocSharedTypes<TDoc>[TKey];
23
24
 
24
25
  export type InferYjsDocSharedTypeJson<
25
26
  TDoc extends YjsDoc<any>,
26
- TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>
27
+ TKey extends
28
+ keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>,
27
29
  > = InferYjsSharedTypeJson<InferYjsDocSharedTypes<TDoc>[TKey]>;
28
30
 
29
31
  export type InferYjsDocSharedTypes<TDoc extends YjsDoc<any>> =
package/src/xmlElement.ts CHANGED
@@ -7,7 +7,7 @@ export interface XmlElementParams {
7
7
 
8
8
  export const xmlElement = (
9
9
  name: string,
10
- params: XmlElementParams = {}
10
+ params: XmlElementParams = {},
11
11
  ): YXmlElement => {
12
12
  const { children = [] } = params;
13
13