@codemerge/kernel 2.4.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../src/selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,GAAE,KAAc,GAAG,SAAS,CAK/E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAErE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAMnD;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAkB5D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,SAAS,CAKtE;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAaxD;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,KAAK,CAAA;CAAE,CAIvE"}
@@ -0,0 +1,29 @@
1
+ import { DocNode } from './types';
2
+ import { Operation } from './operations';
3
+ export declare function isTextBlock(type: string): boolean;
4
+ export declare function isListType(type: string): boolean;
5
+ /** Flatten text of a text-bearing node (paragraph / heading / listItem). */
6
+ export declare function plainText(node: DocNode): string;
7
+ /**
8
+ * Resolve selection path to a text-bearing leaf.
9
+ * Lists → first/only item; listItem → nested paragraph; table → first cell paragraph.
10
+ */
11
+ export declare function resolveTextPath(doc: DocNode, path: number[]): number[];
12
+ export declare function createListItem(content?: DocNode[]): DocNode;
13
+ export declare function createList(listType: 'bulletList' | 'orderedList', items: DocNode[]): DocNode;
14
+ /**
15
+ * Lift list item `itemIndex` out of the list at `listPath` into the list's parent.
16
+ * Removes the list, reinserts before-list (if any), lifted paragraph, after-list (if any).
17
+ */
18
+ export declare function liftIntoParent(doc: DocNode, listPath: number[], itemIndex: number): {
19
+ ops: Operation[];
20
+ selectionPath: number[];
21
+ liftedIndex: number;
22
+ };
23
+ /** Exit empty list item: lift to paragraph in the list's parent (any depth). */
24
+ export declare function exitListItemOps(doc: DocNode, listPath: number[], itemIndex: number): {
25
+ ops: Operation[];
26
+ selectionPath: number[];
27
+ };
28
+ export declare function textBlockLength(doc: DocNode, path: number[]): number;
29
+ //# sourceMappingURL=structure.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { DocNode } from './types';
2
+ import { Operation } from './operations';
3
+ export declare function isTextBlock(type: string): boolean;
4
+ export declare function isListType(type: string): boolean;
5
+ /** Flatten text of a text-bearing node (paragraph / heading / listItem). */
6
+ export declare function plainText(node: DocNode): string;
7
+ /**
8
+ * Resolve selection path to a text-bearing leaf.
9
+ * Lists → first/only item; listItem → nested paragraph; table → first cell paragraph.
10
+ */
11
+ export declare function resolveTextPath(doc: DocNode, path: number[]): number[];
12
+ export declare function createListItem(content?: DocNode[]): DocNode;
13
+ export declare function createList(listType: 'bulletList' | 'orderedList', items: DocNode[]): DocNode;
14
+ /**
15
+ * Lift list item `itemIndex` out of the list at `listPath` into the list's parent.
16
+ * Removes the list, reinserts before-list (if any), lifted paragraph, after-list (if any).
17
+ */
18
+ export declare function liftIntoParent(doc: DocNode, listPath: number[], itemIndex: number): {
19
+ ops: Operation[];
20
+ selectionPath: number[];
21
+ liftedIndex: number;
22
+ };
23
+ /** Exit empty list item: lift to paragraph in the list's parent (any depth). */
24
+ export declare function exitListItemOps(doc: DocNode, listPath: number[], itemIndex: number): {
25
+ ops: Operation[];
26
+ selectionPath: number[];
27
+ };
28
+ export declare function textBlockLength(doc: DocNode, path: number[]): number;
29
+ //# sourceMappingURL=structure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../src/structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAa/C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA+DtE;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,OAAO,EAAqB,GAAG,OAAO,CAE7E;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAM5F;AAqBD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAAE,EAClB,SAAS,EAAE,MAAM,GAChB;IAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CA4CpE;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,MAAM,EAAE,EAClB,SAAS,EAAE,MAAM,GAChB;IAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAG/C;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAMpE"}
@@ -0,0 +1,18 @@
1
+ import { DocNode, Selection } from './types';
2
+ import { Operation } from './operations';
3
+ import { Schema } from './schema';
4
+ export interface EditorState {
5
+ doc: DocNode;
6
+ selection: Selection;
7
+ }
8
+ export interface Transaction {
9
+ ops: Operation[];
10
+ meta?: Record<string, unknown>;
11
+ }
12
+ export declare function createState(doc?: DocNode, selection?: Selection): EditorState;
13
+ export declare function applyTransaction(state: EditorState, tr: Transaction, schema?: Schema): {
14
+ state: EditorState;
15
+ inverses: Operation[];
16
+ };
17
+ export declare function transaction(...ops: Operation[]): Transaction;
18
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { DocNode, Selection } from './types';
2
+ import { Operation } from './operations';
3
+ import { Schema } from './schema';
4
+ export interface EditorState {
5
+ doc: DocNode;
6
+ selection: Selection;
7
+ }
8
+ export interface Transaction {
9
+ ops: Operation[];
10
+ meta?: Record<string, unknown>;
11
+ }
12
+ export declare function createState(doc?: DocNode, selection?: Selection): EditorState;
13
+ export declare function applyTransaction(state: EditorState, tr: Transaction, schema?: Schema): {
14
+ state: EditorState;
15
+ inverses: Operation[];
16
+ };
17
+ export declare function transaction(...ops: Operation[]): Transaction;
18
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,SAAS,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,WAAW,CAAC,GAAG,GAAE,OAAqB,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,WAAW,CAO1F;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,MAAM,GACd;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,SAAS,EAAE,CAAA;CAAE,CAM/C;AAED,wBAAgB,WAAW,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,GAAG,WAAW,CAE5D"}
@@ -0,0 +1,15 @@
1
+ import { Operation } from './operations';
2
+ /**
3
+ * Transform `op` so it can be applied after `against` was already applied
4
+ * (ProseMirror-style: rebase client op against server op).
5
+ * Returns null if `op` becomes a no-op.
6
+ */
7
+ export declare function transformOp(op: Operation, against: Operation): Operation | null;
8
+ /** Transform a sequence of ops against a single already-applied op. */
9
+ export declare function transformOps(ops: Operation[], against: Operation): Operation[];
10
+ /**
11
+ * Rebase client ops that were based on `baseVersion` against server ops
12
+ * that landed since (in order). Returns ops safe to apply on the new tip.
13
+ */
14
+ export declare function rebaseOps(clientOps: Operation[], serverOps: Operation[]): Operation[];
15
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Operation } from './operations';
2
+ /**
3
+ * Transform `op` so it can be applied after `against` was already applied
4
+ * (ProseMirror-style: rebase client op against server op).
5
+ * Returns null if `op` becomes a no-op.
6
+ */
7
+ export declare function transformOp(op: Operation, against: Operation): Operation | null;
8
+ /** Transform a sequence of ops against a single already-applied op. */
9
+ export declare function transformOps(ops: Operation[], against: Operation): Operation[];
10
+ /**
11
+ * Rebase client ops that were based on `baseVersion` against server ops
12
+ * that landed since (in order). Returns ops safe to apply on the new tip.
13
+ */
14
+ export declare function rebaseOps(clientOps: Operation[], serverOps: Operation[]): Operation[];
15
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAgG9C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAkJ/E;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,CAS9E;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CASrF"}
@@ -0,0 +1,27 @@
1
+ /** Virtual document model types — own kernel, no editor-framework deps. */
2
+ export interface Mark {
3
+ type: string;
4
+ attrs?: Record<string, unknown>;
5
+ }
6
+ export interface DocNode {
7
+ type: string;
8
+ id?: string;
9
+ attrs?: Record<string, unknown>;
10
+ text?: string;
11
+ marks?: Mark[];
12
+ content?: DocNode[];
13
+ }
14
+ export interface Point {
15
+ path: number[];
16
+ offset: number;
17
+ }
18
+ export interface Selection {
19
+ anchor: Point;
20
+ focus: Point;
21
+ }
22
+ export interface JSONDoc {
23
+ version: number;
24
+ doc: DocNode;
25
+ selection?: Selection;
26
+ }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** Virtual document model types — own kernel, no editor-framework deps. */
2
+ export interface Mark {
3
+ type: string;
4
+ attrs?: Record<string, unknown>;
5
+ }
6
+ export interface DocNode {
7
+ type: string;
8
+ id?: string;
9
+ attrs?: Record<string, unknown>;
10
+ text?: string;
11
+ marks?: Mark[];
12
+ content?: DocNode[];
13
+ }
14
+ export interface Point {
15
+ path: number[];
16
+ offset: number;
17
+ }
18
+ export interface Selection {
19
+ anchor: Point;
20
+ focus: Point;
21
+ }
22
+ export interface JSONDoc {
23
+ version: number;
24
+ doc: DocNode;
25
+ selection?: Selection;
26
+ }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@codemerge/kernel",
3
+ "version": "2.4.0",
4
+ "description": "Headless document / ops / selection model for CodeMerge editors",
5
+ "license": "MIT",
6
+ "author": "Pavel Kuzmin",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/s00d/on-codemerge.git",
10
+ "directory": "packages/kernel"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.mjs",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.mjs"
25
+ },
26
+ "require": {
27
+ "types": "./dist/index.d.cts",
28
+ "default": "./dist/index.cjs"
29
+ }
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "engines": {
37
+ "node": ">=20"
38
+ },
39
+ "scripts": {
40
+ "build": "vite build",
41
+ "publint": "publint --strict"
42
+ }
43
+ }