@note3/utils 0.0.20 → 0.0.23

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/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './map';
3
3
  export * from './note3-regex-constants';
4
4
  export * from './note3-utils-nodeps';
5
5
  export * from './queries';
6
+ export * from './tree-builder';
6
7
  export * from './types';
7
8
  export * from './relation-ordering';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA"}
package/dist/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- import"./chunk-KHOUPFOL.min.js";import{a as o,b as r,c as e,d as f,e as m}from"./chunk-PA6WBVCJ.min.js";import{a as p}from"./chunk-IFY2JCCQ.min.js";import{a as H,b as I,c as J,d as K,e as L,f as M,g as N}from"./chunk-44UQ54GR.min.js";import{a as u,b as v,c as w,d as y,e as z,f as A,g as B,h as C,i as D,j as E,k as F}from"./chunk-LDNVHZO7.min.js";import{a as t,b as x,c as a,d as b,e as c,f as d,g,h,i,j,k,l,m as n,n as q,o as s}from"./chunk-POX3PUJK.min.js";import{a as G}from"./chunk-KY36PVHK.min.js";import"./chunk-MXMMU6NF.min.js";export{i as RE_ANY_TAG_ONLY,s as RE_ANY_TAG_WITHCONTEXT,h as RE_AT_TAG_ONLY,q as RE_AT_TAG_WITHCONTEXT,d as RE_HASH_TAG_ONLY,l as RE_HASH_TAG_WITHCONTEXT,g as RE_PLUS_TAG_ONLY,n as RE_PLUS_TAG_WITHCONTEXT,c as RE_TAG_BODY,a as RE_TAG_BODY_CHAR,b as RE_TAG_BODY_REQUIRED_CHAR,k as RE_TAG_CONTEXT_POST,j as RE_TAG_CONTEXT_PRE,p as SetMap,x as TAG_MIN_LENGTH,t as TIPTAP_EMPTY,e as asyncIterableToArray,f as blobToAsyncIterable,F as contentVlToPlaintext,E as getAllTagsInText,H as getChildIDs,J as getChildRelations,L as getContent,M as getContentText,I as getParentIDs,K as getParentRelations,N as getRootIDs,o as lazyVal,G as orderRelations,v as parseBlockContentValue,B as plainContentMatchAnyTag,A as plainContentMatchAtTag,y as plainContentMatchHashTag,z as plainContentMatchPlusTag,C as plainContentMatchTagGeneric,u as plaintextStringToTiptap,r as racePromises,D as rawContentMatchTag,m as recurseWithLoopProtection,w as tiptapToPlaintext};
1
+ import{a as O,b as P,c as Q,d as R,e as S}from"./chunk-WMNPGCQZ.min.js";import"./chunk-KHOUPFOL.min.js";import{a as o,b as r,c as e,d as f,e as m}from"./chunk-PA6WBVCJ.min.js";import{a as p}from"./chunk-IFY2JCCQ.min.js";import{a as H,b as I,c as J,d as K,e as L,f as M,g as N}from"./chunk-44UQ54GR.min.js";import{a as u,b as v,c as w,d as y,e as z,f as A,g as B,h as C,i as D,j as E,k as F}from"./chunk-LDNVHZO7.min.js";import{a as t,b as x,c as a,d as b,e as c,f as d,g,h,i,j,k,l,m as n,n as q,o as s}from"./chunk-POX3PUJK.min.js";import{a as G}from"./chunk-KY36PVHK.min.js";import"./chunk-MXMMU6NF.min.js";export{i as RE_ANY_TAG_ONLY,s as RE_ANY_TAG_WITHCONTEXT,h as RE_AT_TAG_ONLY,q as RE_AT_TAG_WITHCONTEXT,d as RE_HASH_TAG_ONLY,l as RE_HASH_TAG_WITHCONTEXT,g as RE_PLUS_TAG_ONLY,n as RE_PLUS_TAG_WITHCONTEXT,c as RE_TAG_BODY,a as RE_TAG_BODY_CHAR,b as RE_TAG_BODY_REQUIRED_CHAR,k as RE_TAG_CONTEXT_POST,j as RE_TAG_CONTEXT_PRE,p as SetMap,x as TAG_MIN_LENGTH,t as TIPTAP_EMPTY,e as asyncIterableToArray,f as blobToAsyncIterable,F as contentVlToPlaintext,O as createBlockApplogs,P as createRelationApplogs,Q as createSingleNodeApplogs,S as createSingleTree,R as createTreeApplogs,E as getAllTagsInText,H as getChildIDs,J as getChildRelations,L as getContent,M as getContentText,I as getParentIDs,K as getParentRelations,N as getRootIDs,o as lazyVal,G as orderRelations,v as parseBlockContentValue,B as plainContentMatchAnyTag,A as plainContentMatchAtTag,y as plainContentMatchHashTag,z as plainContentMatchPlusTag,C as plainContentMatchTagGeneric,u as plaintextStringToTiptap,r as racePromises,D as rawContentMatchTag,m as recurseWithLoopProtection,w as tiptapToPlaintext};
2
2
  //# sourceMappingURL=index.min.js.map
@@ -0,0 +1,117 @@
1
+ import type { ApplogForInsertOptionalAgent, EntityID } from '@wovin/core/applog';
2
+ import type { TiptapContent } from './note3-utils-nodeps';
3
+ /**
4
+ * Represents a single node in a tree structure.
5
+ * Content can be a string or a Tiptap JSON object.
6
+ * Children are optional and can be recursively nested.
7
+ */
8
+ export interface TreeNode {
9
+ /** Content as string or Tiptap object (auto-serialized) */
10
+ content: string | TiptapContent;
11
+ /** Optional child nodes */
12
+ children?: TreeNode[];
13
+ }
14
+ /**
15
+ * Result of creating a single node with its applogs
16
+ */
17
+ export interface NodeCreationResult {
18
+ blockID: EntityID;
19
+ applogs: ApplogForInsertOptionalAgent[];
20
+ }
21
+ /**
22
+ * Result of creating a tree with applogs
23
+ */
24
+ export interface TreeCreationResult {
25
+ rootIDs: EntityID[];
26
+ applogs: ApplogForInsertOptionalAgent[];
27
+ }
28
+ /**
29
+ * Creates block applogs for a single piece of content.
30
+ * Generates an entity ID using getHashID, including positional context
31
+ * (parent and after) to ensure uniqueness even for identical content.
32
+ *
33
+ * @param content - String or TiptapContent object
34
+ * @param parentID - Optional parent ID for positional context in hash
35
+ * @param after - Optional previous sibling ID for positional context in hash
36
+ * @param entityID - Optional pre-computed entity ID
37
+ * @returns Object with generated entityID and applogs array
38
+ */
39
+ export declare function createBlockApplogs(content: string | TiptapContent, parentID?: EntityID, after?: EntityID | null, entityID?: EntityID): {
40
+ en: EntityID;
41
+ applogs: ApplogForInsertOptionalAgent[];
42
+ };
43
+ /**
44
+ * Creates relation applogs that connect a block as a child of a parent.
45
+ * Generates three applogs: one for the block reference, one for the parent reference,
46
+ * and one for the sibling ordering (after).
47
+ *
48
+ * @param blockID - The ID of the child block
49
+ * @param childOf - The ID of the parent block
50
+ * @param after - The ID of the previous sibling (or null if first child)
51
+ * @param relationID - Optional pre-computed relation entity ID
52
+ * @returns Object with relation entity ID and applogs array
53
+ */
54
+ export declare function createRelationApplogs(blockID: EntityID, childOf: EntityID, after: EntityID | null, relationID?: EntityID): {
55
+ en: EntityID;
56
+ applogs: ApplogForInsertOptionalAgent[];
57
+ };
58
+ /**
59
+ * Recursively creates applogs for a single node and its children.
60
+ * Maintains proper sibling ordering using the 'after' field.
61
+ *
62
+ * @param node - The node to create
63
+ * @param parentID - Optional parent block ID. If provided, creates a relation to parent.
64
+ * @param after - Optional previous sibling ID for proper ordering
65
+ * @returns Object with block ID and flattened applogs array
66
+ */
67
+ export declare function createSingleNodeApplogs(node: TreeNode, parentID?: EntityID, after?: EntityID | null): NodeCreationResult;
68
+ /**
69
+ * Creates applogs for multiple root nodes (nodes without a parent).
70
+ * All nodes are created as standalone roots.
71
+ *
72
+ * @param nodes - Array of root nodes
73
+ * @returns Object with array of root IDs and flattened applogs
74
+ *
75
+ * @example
76
+ * const nodes: TreeNode[] = [
77
+ * { content: 'Root 1', children: [{ content: 'Child 1' }] },
78
+ * { content: 'Root 2' }
79
+ * ]
80
+ * const { rootIDs, applogs } = createTreeApplogs(nodes)
81
+ */
82
+ export declare function createTreeApplogs(nodes: TreeNode[]): TreeCreationResult;
83
+ /**
84
+ * Creates applogs for multiple nodes as children of a parent.
85
+ * All nodes are created as children of the specified parent.
86
+ *
87
+ * @param nodes - Array of nodes
88
+ * @param parentID - Parent block ID. Nodes will be created as children of this parent.
89
+ * @returns Object with array of created block IDs and flattened applogs
90
+ *
91
+ * @example
92
+ * const subtree: TreeNode[] = [
93
+ * { content: 'Child 1' },
94
+ * { content: 'Child 2' }
95
+ * ]
96
+ * const { rootIDs, applogs } = createTreeApplogs(subtree, 'existingParentID')
97
+ */
98
+ export declare function createTreeApplogs(nodes: TreeNode[], parentID: EntityID): TreeCreationResult;
99
+ /**
100
+ * Creates applogs for a single root node with its descendants.
101
+ * Convenience function that returns just the root block ID instead of an array.
102
+ *
103
+ * @param root - The root node
104
+ * @returns Object with root block ID and applogs
105
+ *
106
+ * @example
107
+ * const node: TreeNode = {
108
+ * content: 'Parent',
109
+ * children: [
110
+ * { content: 'Child 1' },
111
+ * { content: 'Child 2' }
112
+ * ]
113
+ * }
114
+ * const { blockID, applogs } = createSingleTree(node)
115
+ */
116
+ export declare function createSingleTree(root: TreeNode): NodeCreationResult;
117
+ //# sourceMappingURL=tree-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-builder.d.ts","sourceRoot":"","sources":["../src/tree-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAEhF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACxB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,GAAG,aAAa,CAAA;IAC/B,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;CACrB;AAED;;GA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BAAkB,CAEnE"}
@@ -0,0 +1,2 @@
1
+ import{a,b,c,d,e}from"./chunk-WMNPGCQZ.min.js";import"./chunk-MXMMU6NF.min.js";export{a as createBlockApplogs,b as createRelationApplogs,c as createSingleNodeApplogs,e as createSingleTree,d as createTreeApplogs};
2
+ //# sourceMappingURL=tree-builder.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@note3/utils",
3
- "version": "0.0.20",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.min.js",
@@ -27,7 +27,7 @@
27
27
  "bundle": false
28
28
  },
29
29
  "dependencies": {
30
- "@wovin/core": "0.0.20",
30
+ "@wovin/core": "0.0.23",
31
31
  "besonders-logger": "1.0.2",
32
32
  "comlink": "^4.4.2",
33
33
  "core-js": "^3.45.1",