netscape-bookmark-parser 1.1.3 → 1.2.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.
Files changed (122) hide show
  1. package/LICENSE +2 -2
  2. package/README-ja.md +233 -386
  3. package/README.md +152 -302
  4. package/dist/index.d.ts +240 -0
  5. package/dist/index.js +333 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/web.d.ts +241 -0
  8. package/dist/web.js +330 -0
  9. package/dist/web.js.map +1 -0
  10. package/package.json +58 -15
  11. package/esm/_dnt.polyfills.d.ts +0 -101
  12. package/esm/_dnt.polyfills.d.ts.map +0 -1
  13. package/esm/_dnt.polyfills.js +0 -127
  14. package/esm/_dnt.shims.d.ts +0 -6
  15. package/esm/_dnt.shims.d.ts.map +0 -1
  16. package/esm/_dnt.shims.js +0 -61
  17. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/build/deno-wasm/deno-wasm.d.ts +0 -14
  18. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/build/deno-wasm/deno-wasm.d.ts.map +0 -1
  19. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/build/deno-wasm/deno-wasm.js +0 -151
  20. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/deno-dom-wasm.d.ts +0 -23
  21. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/deno-dom-wasm.d.ts.map +0 -1
  22. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/deno-dom-wasm.js +0 -26
  23. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/api.d.ts +0 -24
  24. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/api.d.ts.map +0 -1
  25. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/api.js +0 -48
  26. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/constructor-lock.d.ts +0 -5
  27. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/constructor-lock.d.ts.map +0 -1
  28. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/constructor-lock.js +0 -4
  29. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/deserialize.d.ts +0 -4
  30. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/deserialize.d.ts.map +0 -1
  31. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/deserialize.js +0 -61
  32. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/document-fragment.d.ts +0 -19
  33. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/document-fragment.d.ts.map +0 -1
  34. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/document-fragment.js +0 -110
  35. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/document.d.ts +0 -68
  36. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/document.d.ts.map +0 -1
  37. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/document.js +0 -322
  38. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/dom-parser.d.ts +0 -6
  39. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/dom-parser.d.ts.map +0 -1
  40. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/dom-parser.js +0 -46
  41. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/element.d.ts +0 -127
  42. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/element.d.ts.map +0 -1
  43. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/element.js +0 -1068
  44. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/elements/html-template-element.d.ts +0 -29
  45. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/elements/html-template-element.d.ts.map +0 -1
  46. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/elements/html-template-element.js +0 -94
  47. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/html-collection.d.ts +0 -21
  48. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/html-collection.d.ts.map +0 -1
  49. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/html-collection.js +0 -80
  50. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/node-list.d.ts +0 -23
  51. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/node-list.d.ts.map +0 -1
  52. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/node-list.js +0 -159
  53. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/node.d.ts +0 -127
  54. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/node.d.ts.map +0 -1
  55. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/node.js +0 -629
  56. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/custom-api.d.ts +0 -6
  57. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/custom-api.d.ts.map +0 -1
  58. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/custom-api.js +0 -5
  59. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/nwsapi-types.d.ts +0 -12
  60. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/nwsapi-types.d.ts.map +0 -1
  61. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/nwsapi-types.js +0 -2
  62. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/nwsapi.d.ts +0 -90
  63. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/nwsapi.d.ts.map +0 -1
  64. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/nwsapi.js +0 -1611
  65. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/selectors.d.ts +0 -16
  66. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/selectors.d.ts.map +0 -1
  67. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/selectors.js +0 -28
  68. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/sizzle-types.d.ts +0 -8
  69. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/sizzle-types.d.ts.map +0 -1
  70. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/sizzle-types.js +0 -2
  71. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/sizzle.d.ts +0 -7
  72. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/sizzle.d.ts.map +0 -1
  73. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/selectors/sizzle.js +0 -2061
  74. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/string-cache.d.ts +0 -3
  75. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/string-cache.d.ts.map +0 -1
  76. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/string-cache.js +0 -10
  77. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/utils-types.d.ts +0 -13
  78. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/utils-types.d.ts.map +0 -1
  79. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/utils-types.js +0 -8
  80. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/utils.d.ts +0 -31
  81. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/utils.d.ts.map +0 -1
  82. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/dom/utils.js +0 -239
  83. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/parser.d.ts +0 -5
  84. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/parser.d.ts.map +0 -1
  85. package/esm/deps/jsr.io/@b-fuze/deno-dom/0.1.49/src/parser.js +0 -20
  86. package/esm/mod.d.ts +0 -10
  87. package/esm/mod.d.ts.map +0 -1
  88. package/esm/mod.js +0 -9
  89. package/esm/mod_web.d.ts +0 -9
  90. package/esm/mod_web.d.ts.map +0 -1
  91. package/esm/mod_web.js +0 -8
  92. package/esm/package.json +0 -3
  93. package/esm/src/BookmarksParser/BookmarksParser.d.ts +0 -66
  94. package/esm/src/BookmarksParser/BookmarksParser.d.ts.map +0 -1
  95. package/esm/src/BookmarksParser/BookmarksParser.js +0 -70
  96. package/esm/src/BookmarksParser/index.d.ts +0 -8
  97. package/esm/src/BookmarksParser/index.d.ts.map +0 -1
  98. package/esm/src/BookmarksParser/index.js +0 -7
  99. package/esm/src/BookmarksTree/BookmarksTree.d.ts +0 -112
  100. package/esm/src/BookmarksTree/BookmarksTree.d.ts.map +0 -1
  101. package/esm/src/BookmarksTree/BookmarksTree.js +0 -217
  102. package/esm/src/BookmarksTree/index.d.ts +0 -8
  103. package/esm/src/BookmarksTree/index.d.ts.map +0 -1
  104. package/esm/src/BookmarksTree/index.js +0 -7
  105. package/esm/src/deps.d.ts +0 -9
  106. package/esm/src/deps.d.ts.map +0 -1
  107. package/esm/src/deps.js +0 -7
  108. package/esm/src/web/BookmarksParser/BookmarksParser.d.ts +0 -66
  109. package/esm/src/web/BookmarksParser/BookmarksParser.d.ts.map +0 -1
  110. package/esm/src/web/BookmarksParser/BookmarksParser.js +0 -70
  111. package/esm/src/web/BookmarksParser/index.d.ts +0 -8
  112. package/esm/src/web/BookmarksParser/index.d.ts.map +0 -1
  113. package/esm/src/web/BookmarksParser/index.js +0 -7
  114. package/esm/src/web/BookmarksTree/BookmarksTree.d.ts +0 -112
  115. package/esm/src/web/BookmarksTree/BookmarksTree.d.ts.map +0 -1
  116. package/esm/src/web/BookmarksTree/BookmarksTree.js +0 -217
  117. package/esm/src/web/BookmarksTree/index.d.ts +0 -8
  118. package/esm/src/web/BookmarksTree/index.d.ts.map +0 -1
  119. package/esm/src/web/BookmarksTree/index.js +0 -7
  120. package/esm/src/web/deps.d.ts +0 -10
  121. package/esm/src/web/deps.d.ts.map +0 -1
  122. package/esm/src/web/deps.js +0 -9
@@ -0,0 +1,240 @@
1
+ import { HTMLDocument } from "@b-fuze/deno-dom";
2
+
3
+ //#region src/BookmarksTree/BookmarksTree.d.ts
4
+
5
+ /**
6
+ * A class representing a bookmark tree in Netscape Bookmark format
7
+ *
8
+ * This class extends Map and manages folders (BookmarksTree) and bookmarks (URL strings)
9
+ * in a hierarchical structure.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const tree = new BookmarksTree();
14
+ * tree.set("Google", "https://google.com");
15
+ *
16
+ * const folder = new BookmarksTree();
17
+ * folder.set("GitHub", "https://github.com");
18
+ * tree.set("Development", folder);
19
+ * ```
20
+ */
21
+ declare class BookmarksTree extends Map<string, string | BookmarksTree> {
22
+ /**
23
+ * Creates a new BookmarksTree instance
24
+ */
25
+ constructor();
26
+ /**
27
+ * Converts the BookmarksTree to a JSON object
28
+ *
29
+ * Folders are recursively converted to objects, and bookmarks are preserved as strings.
30
+ *
31
+ * @returns JSON object representation of the bookmark data
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const tree = new BookmarksTree();
36
+ * tree.set("Google", "https://google.com");
37
+ * const json = tree.toJSON();
38
+ * // { "Google": "https://google.com" }
39
+ * ```
40
+ */
41
+ toJSON(): Record<string, unknown>;
42
+ /**
43
+ * Creates a BookmarksTree from a JSON object
44
+ *
45
+ * String properties are treated as bookmarks, and object properties are
46
+ * recursively processed as folders.
47
+ *
48
+ * @param json The source JSON object to convert
49
+ * @returns A new BookmarksTree instance
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const json = { "Google": "https://google.com", "Development": { "GitHub": "https://github.com" } };
54
+ * const tree = BookmarksTree.fromJSON(json);
55
+ * ```
56
+ */
57
+ static fromJSON(json: Record<string, unknown>): BookmarksTree;
58
+ /**
59
+ * Creates a BookmarksTree from an HTML document (Netscape Bookmark format)
60
+ *
61
+ * Parses Netscape Bookmark format HTML and generates a BookmarksTree that preserves
62
+ * the hierarchical structure. H3 elements within DT elements are treated as folders,
63
+ * and A elements are treated as bookmarks.
64
+ *
65
+ * @param dom The HTML document to parse
66
+ * @returns A new BookmarksTree instance
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const parser = new DOMParser();
71
+ * const dom = parser.parseFromString(bookmarkHtml, "text/html");
72
+ * const tree = BookmarksTree.fromDOM(dom);
73
+ * ```
74
+ */
75
+ static fromDOM(dom: HTMLDocument): BookmarksTree;
76
+ /**
77
+ * Converts the BookmarksTree to an HTML document
78
+ *
79
+ * Generates an HTML document in Netscape Bookmark format.
80
+ *
81
+ * @returns HTML document in Netscape Bookmark format
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const tree = new BookmarksTree();
86
+ * tree.set("Google", "https://google.com");
87
+ * const dom = tree.toDOM();
88
+ * ```
89
+ */
90
+ toDOM(): HTMLDocument;
91
+ /**
92
+ * Gets the BookmarksTree as an HTML string in Netscape Bookmark format
93
+ *
94
+ * Generates a complete HTML document string including DOCTYPE, metadata, and body
95
+ * in Netscape Bookmark format.
96
+ *
97
+ * @returns HTML string in Netscape Bookmark format
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const tree = new BookmarksTree();
102
+ * tree.set("Google", "https://google.com");
103
+ * const html = tree.HTMLString;
104
+ * console.log(html); // <!DOCTYPE NETSCAPE-Bookmark-file-1>...
105
+ * ```
106
+ */
107
+ get HTMLString(): string;
108
+ /**
109
+ * @deprecated Use {@link HTMLString} instead.
110
+ *
111
+ * Gets the BookmarksTree as an HTML string in Netscape Bookmark format.
112
+ */
113
+ get HTMLText(): string;
114
+ }
115
+ //#endregion
116
+ //#region src/BookmarksParser/BookmarksParser.d.ts
117
+ /**
118
+ * A parser for Netscape Bookmark format files
119
+ *
120
+ * This class provides static methods to parse Netscape Bookmark format HTML strings
121
+ * and convert them into BookmarksTree instances for easier manipulation.
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
126
+ * <HTML>
127
+ * <BODY>
128
+ * <DL><p>
129
+ * <DT><A HREF="https://google.com">Google</A>
130
+ * <DT><H3>Development</H3>
131
+ * <DL><p>
132
+ * <DT><A HREF="https://github.com">GitHub</A>
133
+ * </DL><p>
134
+ * </DL>
135
+ * </BODY>
136
+ * </HTML>`;
137
+ *
138
+ * const tree = BookmarksParser.parse(bookmarkHtml);
139
+ * ```
140
+ */
141
+ declare class BookmarksParser {
142
+ /**
143
+ * Alias for the {@link parseFromHTMLString} method.
144
+ *
145
+ * @param htmlString HTML string in Netscape Bookmark format
146
+ * @returns The parsed BookmarksTree
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
151
+ * <HTML>
152
+ * <BODY>
153
+ * <DL><p>
154
+ * <DT><A HREF="https://google.com">Google</A>
155
+ * <DT><H3>Development</H3>
156
+ * <DL><p>
157
+ * <DT><A HREF="https://github.com">GitHub</A>
158
+ * </DL><p>
159
+ * </DL>
160
+ * </BODY>
161
+ * </HTML>`;
162
+ *
163
+ * const tree = BookmarksParser.parse(bookmarkHtml);
164
+ * ```
165
+ */
166
+ static parse(htmlString: string): BookmarksTree;
167
+ /**
168
+ * Parses a Netscape Bookmark format HTML string and returns a BookmarksTree.
169
+ *
170
+ * @param htmlString HTML string in Netscape Bookmark format
171
+ * @returns The parsed BookmarksTree
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
176
+ * <HTML>
177
+ * <BODY>
178
+ * <DL><p>
179
+ * <DT><A HREF="https://google.com">Google</A>
180
+ * <DT><H3>Development</H3>
181
+ * <DL><p>
182
+ * <DT><A HREF="https://github.com">GitHub</A>
183
+ * </DL><p>
184
+ * </DL>
185
+ * </BODY>
186
+ * </HTML>`;
187
+ *
188
+ * const tree = BookmarksParser.parseFromHTMLString(bookmarkHtml);
189
+ * ```
190
+ */
191
+ static parseFromHTMLString(htmlString: string): BookmarksTree;
192
+ /**
193
+ * Creates a BookmarksTree from an existing HTMLDocument.
194
+ *
195
+ * This is an alias for {@link BookmarksTree.fromDOM}.
196
+ *
197
+ * Use this when you already have a parsed HTMLDocument and want to convert it to a BookmarksTree.
198
+ *
199
+ * @param dom An HTMLDocument instance
200
+ * @returns The parsed BookmarksTree
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const dom = new DOMParser().parseFromString(bookmarkHtml, "text/html");
205
+ * const tree = BookmarksParser.parseFromDOM(dom);
206
+ * ```
207
+ */
208
+ static parseFromDOM(dom: HTMLDocument): BookmarksTree;
209
+ /**
210
+ * Parses a JSON string and returns a BookmarksTree.
211
+ *
212
+ * @param jsonString JSON string representing the bookmark structure
213
+ * @returns The parsed BookmarksTree
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const json = '{"Google":"https://google.com","Development":{"GitHub":"https://github.com"}}';
218
+ * const tree = BookmarksParser.parseFromJSONString(json);
219
+ * ```
220
+ */
221
+ static parseFromJSONString(jsonString: string): BookmarksTree;
222
+ /**
223
+ * Parses a JSON object and returns a BookmarksTree.
224
+ *
225
+ * This is an alias for {@link BookmarksTree.fromJSON}.
226
+ *
227
+ * @param jsonObj JSON object representing the bookmark structure
228
+ * @returns The parsed BookmarksTree
229
+ *
230
+ * @example
231
+ * ```typescript
232
+ * const obj = { "Google": "https://google.com", "Development": { "GitHub": "https://github.com" } };
233
+ * const tree = BookmarksParser.parseFromJSON(obj);
234
+ * ```
235
+ */
236
+ static parseFromJSON(jsonObj: Record<string, unknown>): BookmarksTree;
237
+ }
238
+ //#endregion
239
+ export { BookmarksParser, BookmarksTree };
240
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,333 @@
1
+ import { DOMParser } from "@b-fuze/deno-dom";
2
+
3
+ //#region src/dom.ts
4
+ let DOMParser$1 = globalThis.DOMParser;
5
+ const setDOMParser = (parser) => {
6
+ DOMParser$1 = parser;
7
+ };
8
+
9
+ //#endregion
10
+ //#region src/node-dom.ts
11
+ setDOMParser(DOMParser);
12
+
13
+ //#endregion
14
+ //#region src/BookmarksTree/BookmarksTree.ts
15
+ /**
16
+ * A class representing a bookmark tree in Netscape Bookmark format
17
+ *
18
+ * This class extends Map and manages folders (BookmarksTree) and bookmarks (URL strings)
19
+ * in a hierarchical structure.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const tree = new BookmarksTree();
24
+ * tree.set("Google", "https://google.com");
25
+ *
26
+ * const folder = new BookmarksTree();
27
+ * folder.set("GitHub", "https://github.com");
28
+ * tree.set("Development", folder);
29
+ * ```
30
+ */
31
+ var BookmarksTree = class BookmarksTree extends Map {
32
+ /**
33
+ * Creates a new BookmarksTree instance
34
+ */
35
+ constructor() {
36
+ super();
37
+ }
38
+ /**
39
+ * Converts the BookmarksTree to a JSON object
40
+ *
41
+ * Folders are recursively converted to objects, and bookmarks are preserved as strings.
42
+ *
43
+ * @returns JSON object representation of the bookmark data
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const tree = new BookmarksTree();
48
+ * tree.set("Google", "https://google.com");
49
+ * const json = tree.toJSON();
50
+ * // { "Google": "https://google.com" }
51
+ * ```
52
+ */
53
+ toJSON() {
54
+ const json = {};
55
+ for (const [key, value] of this.entries()) if (typeof value === "string") json[key] = value;
56
+ else if (value instanceof BookmarksTree) json[key] = value.toJSON();
57
+ return json;
58
+ }
59
+ /**
60
+ * Creates a BookmarksTree from a JSON object
61
+ *
62
+ * String properties are treated as bookmarks, and object properties are
63
+ * recursively processed as folders.
64
+ *
65
+ * @param json The source JSON object to convert
66
+ * @returns A new BookmarksTree instance
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const json = { "Google": "https://google.com", "Development": { "GitHub": "https://github.com" } };
71
+ * const tree = BookmarksTree.fromJSON(json);
72
+ * ```
73
+ */
74
+ static fromJSON(json) {
75
+ const tree = new BookmarksTree();
76
+ if (typeof json === "object" && json !== null) {
77
+ for (const [key, value] of Object.entries(json)) if (typeof value === "string") tree.set(key, value);
78
+ else if (typeof value === "object" && value !== null) tree.set(key, BookmarksTree.fromJSON(value));
79
+ }
80
+ return tree;
81
+ }
82
+ /**
83
+ * Creates a BookmarksTree from an HTML document (Netscape Bookmark format)
84
+ *
85
+ * Parses Netscape Bookmark format HTML and generates a BookmarksTree that preserves
86
+ * the hierarchical structure. H3 elements within DT elements are treated as folders,
87
+ * and A elements are treated as bookmarks.
88
+ *
89
+ * @param dom The HTML document to parse
90
+ * @returns A new BookmarksTree instance
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const parser = new DOMParser();
95
+ * const dom = parser.parseFromString(bookmarkHtml, "text/html");
96
+ * const tree = BookmarksTree.fromDOM(dom);
97
+ * ```
98
+ */
99
+ static fromDOM(dom) {
100
+ const tree = new BookmarksTree();
101
+ const document = dom;
102
+ const processElement = (element, currentTree) => {
103
+ const children = Array.from(element.children);
104
+ for (let i = 0; i < children.length; i++) {
105
+ const child = children[i];
106
+ if (child.tagName === "DT") {
107
+ const h3 = child.querySelector("h3");
108
+ const link = child.querySelector("a");
109
+ if (h3) {
110
+ const folderName = h3.textContent?.trim() || "";
111
+ if (folderName) {
112
+ const folderTree = new BookmarksTree();
113
+ currentTree.set(folderName, folderTree);
114
+ processElement(child, folderTree);
115
+ }
116
+ } else if (link) {
117
+ const href = link.getAttribute("href");
118
+ const title = link.textContent?.trim() || "";
119
+ if (href && title) currentTree.set(title, href);
120
+ }
121
+ } else if (child.tagName === "DL") processElement(child, currentTree);
122
+ }
123
+ };
124
+ const body = document.body;
125
+ if (body) processElement(body, tree);
126
+ return tree;
127
+ }
128
+ /**
129
+ * Converts the BookmarksTree to an HTML document
130
+ *
131
+ * Generates an HTML document in Netscape Bookmark format.
132
+ *
133
+ * @returns HTML document in Netscape Bookmark format
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const tree = new BookmarksTree();
138
+ * tree.set("Google", "https://google.com");
139
+ * const dom = tree.toDOM();
140
+ * ```
141
+ */
142
+ toDOM() {
143
+ return new DOMParser$1().parseFromString(this.HTMLString, "text/html");
144
+ }
145
+ /**
146
+ * Gets the BookmarksTree as an HTML string in Netscape Bookmark format
147
+ *
148
+ * Generates a complete HTML document string including DOCTYPE, metadata, and body
149
+ * in Netscape Bookmark format.
150
+ *
151
+ * @returns HTML string in Netscape Bookmark format
152
+ *
153
+ * @example
154
+ * ```typescript
155
+ * const tree = new BookmarksTree();
156
+ * tree.set("Google", "https://google.com");
157
+ * const html = tree.HTMLString;
158
+ * console.log(html); // <!DOCTYPE NETSCAPE-Bookmark-file-1>...
159
+ * ```
160
+ */
161
+ get HTMLString() {
162
+ const escapeHtml = (text) => {
163
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
164
+ };
165
+ const createBookmarkList = (tree, indent = "") => {
166
+ let html = `${indent}<DL><p>\n`;
167
+ for (const [key, value] of tree.entries()) if (typeof value === "string") html += `${indent} <DT><A HREF="${escapeHtml(value)}">${escapeHtml(key)}</A>\n`;
168
+ else if (value instanceof BookmarksTree) {
169
+ html += `${indent} <DT><H3>${escapeHtml(key)}</H3>\n`;
170
+ html += createBookmarkList(value, indent + " ");
171
+ html += `${indent} </DL><p>\n`;
172
+ }
173
+ if (indent === "") html += `</DL>\n`;
174
+ return html;
175
+ };
176
+ return `<!DOCTYPE NETSCAPE-Bookmark-file-1>
177
+ <HTML>
178
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
179
+ <TITLE>Bookmark</TITLE>
180
+ <H1>Bookmark</H1>
181
+ <BODY>
182
+ ${createBookmarkList(this)}</BODY>
183
+ </HTML>`;
184
+ }
185
+ /**
186
+ * @deprecated Use {@link HTMLString} instead.
187
+ *
188
+ * Gets the BookmarksTree as an HTML string in Netscape Bookmark format.
189
+ */
190
+ get HTMLText() {
191
+ return this.HTMLString;
192
+ }
193
+ };
194
+
195
+ //#endregion
196
+ //#region src/BookmarksParser/BookmarksParser.ts
197
+ /**
198
+ * A parser for Netscape Bookmark format files
199
+ *
200
+ * This class provides static methods to parse Netscape Bookmark format HTML strings
201
+ * and convert them into BookmarksTree instances for easier manipulation.
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
206
+ * <HTML>
207
+ * <BODY>
208
+ * <DL><p>
209
+ * <DT><A HREF="https://google.com">Google</A>
210
+ * <DT><H3>Development</H3>
211
+ * <DL><p>
212
+ * <DT><A HREF="https://github.com">GitHub</A>
213
+ * </DL><p>
214
+ * </DL>
215
+ * </BODY>
216
+ * </HTML>`;
217
+ *
218
+ * const tree = BookmarksParser.parse(bookmarkHtml);
219
+ * ```
220
+ */
221
+ var BookmarksParser = class {
222
+ /**
223
+ * Alias for the {@link parseFromHTMLString} method.
224
+ *
225
+ * @param htmlString HTML string in Netscape Bookmark format
226
+ * @returns The parsed BookmarksTree
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
231
+ * <HTML>
232
+ * <BODY>
233
+ * <DL><p>
234
+ * <DT><A HREF="https://google.com">Google</A>
235
+ * <DT><H3>Development</H3>
236
+ * <DL><p>
237
+ * <DT><A HREF="https://github.com">GitHub</A>
238
+ * </DL><p>
239
+ * </DL>
240
+ * </BODY>
241
+ * </HTML>`;
242
+ *
243
+ * const tree = BookmarksParser.parse(bookmarkHtml);
244
+ * ```
245
+ */
246
+ static parse(htmlString) {
247
+ return this.parseFromHTMLString(htmlString);
248
+ }
249
+ /**
250
+ * Parses a Netscape Bookmark format HTML string and returns a BookmarksTree.
251
+ *
252
+ * @param htmlString HTML string in Netscape Bookmark format
253
+ * @returns The parsed BookmarksTree
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>
258
+ * <HTML>
259
+ * <BODY>
260
+ * <DL><p>
261
+ * <DT><A HREF="https://google.com">Google</A>
262
+ * <DT><H3>Development</H3>
263
+ * <DL><p>
264
+ * <DT><A HREF="https://github.com">GitHub</A>
265
+ * </DL><p>
266
+ * </DL>
267
+ * </BODY>
268
+ * </HTML>`;
269
+ *
270
+ * const tree = BookmarksParser.parseFromHTMLString(bookmarkHtml);
271
+ * ```
272
+ */
273
+ static parseFromHTMLString(htmlString) {
274
+ const dom = new DOMParser$1().parseFromString(htmlString, "text/html");
275
+ return BookmarksTree.fromDOM(dom);
276
+ }
277
+ /**
278
+ * Creates a BookmarksTree from an existing HTMLDocument.
279
+ *
280
+ * This is an alias for {@link BookmarksTree.fromDOM}.
281
+ *
282
+ * Use this when you already have a parsed HTMLDocument and want to convert it to a BookmarksTree.
283
+ *
284
+ * @param dom An HTMLDocument instance
285
+ * @returns The parsed BookmarksTree
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * const dom = new DOMParser().parseFromString(bookmarkHtml, "text/html");
290
+ * const tree = BookmarksParser.parseFromDOM(dom);
291
+ * ```
292
+ */
293
+ static parseFromDOM(dom) {
294
+ return BookmarksTree.fromDOM(dom);
295
+ }
296
+ /**
297
+ * Parses a JSON string and returns a BookmarksTree.
298
+ *
299
+ * @param jsonString JSON string representing the bookmark structure
300
+ * @returns The parsed BookmarksTree
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * const json = '{"Google":"https://google.com","Development":{"GitHub":"https://github.com"}}';
305
+ * const tree = BookmarksParser.parseFromJSONString(json);
306
+ * ```
307
+ */
308
+ static parseFromJSONString(jsonString) {
309
+ const obj = JSON.parse(jsonString);
310
+ return BookmarksTree.fromJSON(obj);
311
+ }
312
+ /**
313
+ * Parses a JSON object and returns a BookmarksTree.
314
+ *
315
+ * This is an alias for {@link BookmarksTree.fromJSON}.
316
+ *
317
+ * @param jsonObj JSON object representing the bookmark structure
318
+ * @returns The parsed BookmarksTree
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * const obj = { "Google": "https://google.com", "Development": { "GitHub": "https://github.com" } };
323
+ * const tree = BookmarksParser.parseFromJSON(obj);
324
+ * ```
325
+ */
326
+ static parseFromJSON(jsonObj) {
327
+ return BookmarksTree.fromJSON(jsonObj);
328
+ }
329
+ };
330
+
331
+ //#endregion
332
+ export { BookmarksParser, BookmarksTree };
333
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["DOMParser: typeof NodeDOMParser","NodeDOMParser","json: Record<string, unknown>","DOMParser","DOMParser"],"sources":["../src/dom.ts","../src/node-dom.ts","../src/BookmarksTree/BookmarksTree.ts","../src/BookmarksParser/BookmarksParser.ts"],"sourcesContent":["/**\n * Copyright (c) 2025-2026 kurage(@umitsukidev)\n *\n * This software is released under the MIT License.\n * https://opensource.org/licenses/MIT\n */\n\nimport type { DOMParser as NodeDOMParser } from \"@b-fuze/deno-dom\";\n\nexport let DOMParser: typeof NodeDOMParser =\n\tglobalThis.DOMParser as unknown as typeof NodeDOMParser;\n\nexport const setDOMParser = (parser: typeof NodeDOMParser): void => {\n\tDOMParser = parser;\n};\n","/**\n * Copyright (c) 2025-2026 kurage(@umitsukidev)\n *\n * This software is released under the MIT License.\n * https://opensource.org/licenses/MIT\n */\n\nimport { DOMParser as NodeDOMParser } from \"@b-fuze/deno-dom\";\nimport { setDOMParser } from \"./dom.ts\";\n\nsetDOMParser(NodeDOMParser);\n","/**\n * Copyright (c) 2025-2026 kurage(@umitsukidev)\n *\n * This software is released under the MIT License.\n * https://opensource.org/licenses/MIT\n */\n\nimport { DOMParser } from \"../dom.ts\";\nimport type { Element, HTMLDocument } from \"#dom-types\";\n\n/**\n * A class representing a bookmark tree in Netscape Bookmark format\n *\n * This class extends Map and manages folders (BookmarksTree) and bookmarks (URL strings)\n * in a hierarchical structure.\n *\n * @example\n * ```typescript\n * const tree = new BookmarksTree();\n * tree.set(\"Google\", \"https://google.com\");\n *\n * const folder = new BookmarksTree();\n * folder.set(\"GitHub\", \"https://github.com\");\n * tree.set(\"Development\", folder);\n * ```\n */\nexport class BookmarksTree extends Map<string, string | BookmarksTree> {\n\t/**\n\t * Creates a new BookmarksTree instance\n\t */\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Converts the BookmarksTree to a JSON object\n\t *\n\t * Folders are recursively converted to objects, and bookmarks are preserved as strings.\n\t *\n\t * @returns JSON object representation of the bookmark data\n\t *\n\t * @example\n\t * ```typescript\n\t * const tree = new BookmarksTree();\n\t * tree.set(\"Google\", \"https://google.com\");\n\t * const json = tree.toJSON();\n\t * // { \"Google\": \"https://google.com\" }\n\t * ```\n\t */\n\ttoJSON(): Record<string, unknown> {\n\t\tconst json: Record<string, unknown> = {};\n\n\t\tfor (const [key, value] of this.entries()) {\n\t\t\tif (typeof value === \"string\") {\n\t\t\t\tjson[key] = value;\n\t\t\t} else if (value instanceof BookmarksTree) {\n\t\t\t\tjson[key] = value.toJSON();\n\t\t\t}\n\t\t}\n\n\t\treturn json;\n\t}\n\n\t/**\n\t * Creates a BookmarksTree from a JSON object\n\t *\n\t * String properties are treated as bookmarks, and object properties are\n\t * recursively processed as folders.\n\t *\n\t * @param json The source JSON object to convert\n\t * @returns A new BookmarksTree instance\n\t *\n\t * @example\n\t * ```typescript\n\t * const json = { \"Google\": \"https://google.com\", \"Development\": { \"GitHub\": \"https://github.com\" } };\n\t * const tree = BookmarksTree.fromJSON(json);\n\t * ```\n\t */\n\tstatic fromJSON(json: Record<string, unknown>): BookmarksTree {\n\t\tconst tree = new BookmarksTree();\n\n\t\tif (typeof json === \"object\" && json !== null) {\n\t\t\tfor (const [key, value] of Object.entries(json)) {\n\t\t\t\tif (typeof value === \"string\") {\n\t\t\t\t\ttree.set(key, value);\n\t\t\t\t} else if (typeof value === \"object\" && value !== null) {\n\t\t\t\t\ttree.set(key, BookmarksTree.fromJSON(value as Record<string, unknown>));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Creates a BookmarksTree from an HTML document (Netscape Bookmark format)\n\t *\n\t * Parses Netscape Bookmark format HTML and generates a BookmarksTree that preserves\n\t * the hierarchical structure. H3 elements within DT elements are treated as folders,\n\t * and A elements are treated as bookmarks.\n\t *\n\t * @param dom The HTML document to parse\n\t * @returns A new BookmarksTree instance\n\t *\n\t * @example\n\t * ```typescript\n\t * const parser = new DOMParser();\n\t * const dom = parser.parseFromString(bookmarkHtml, \"text/html\");\n\t * const tree = BookmarksTree.fromDOM(dom);\n\t * ```\n\t */\n\tstatic fromDOM(dom: HTMLDocument): BookmarksTree {\n\t\tconst tree = new BookmarksTree();\n\t\tconst document = dom;\n\n\t\tconst processElement = (element: Element, currentTree: BookmarksTree) => {\n\t\t\tconst children = Array.from(element.children) as Element[];\n\n\t\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\t\tconst child = children[i];\n\n\t\t\t\tif (child.tagName === \"DT\") {\n\t\t\t\t\tconst h3 = child.querySelector(\"h3\");\n\t\t\t\t\tconst link = child.querySelector(\"a\");\n\n\t\t\t\t\tif (h3) {\n\t\t\t\t\t\t// フォルダの場合\n\t\t\t\t\t\tconst folderName = h3.textContent?.trim() || \"\";\n\t\t\t\t\t\tif (folderName) {\n\t\t\t\t\t\t\tconst folderTree = new BookmarksTree();\n\t\t\t\t\t\t\tcurrentTree.set(folderName, folderTree);\n\t\t\t\t\t\t\tprocessElement(child, folderTree);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (link) {\n\t\t\t\t\t\t// リンクの場合\n\t\t\t\t\t\tconst href = link.getAttribute(\"href\");\n\t\t\t\t\t\tconst title = link.textContent?.trim() || \"\";\n\t\t\t\t\t\tif (href && title) {\n\t\t\t\t\t\t\tcurrentTree.set(title, href);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (child.tagName === \"DL\") {\n\t\t\t\t\t// ネストしたDLタグの場合も処理\n\t\t\t\t\tprocessElement(child, currentTree);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// HTMLのBODY全体から処理を開始\n\t\tconst body = document.body;\n\t\tif (body) {\n\t\t\tprocessElement(body, tree);\n\t\t}\n\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Converts the BookmarksTree to an HTML document\n\t *\n\t * Generates an HTML document in Netscape Bookmark format.\n\t *\n\t * @returns HTML document in Netscape Bookmark format\n\t *\n\t * @example\n\t * ```typescript\n\t * const tree = new BookmarksTree();\n\t * tree.set(\"Google\", \"https://google.com\");\n\t * const dom = tree.toDOM();\n\t * ```\n\t */\n\ttoDOM(): HTMLDocument {\n\t\treturn new DOMParser().parseFromString(this.HTMLString, \"text/html\");\n\t}\n\n\t/**\n\t * Gets the BookmarksTree as an HTML string in Netscape Bookmark format\n\t *\n\t * Generates a complete HTML document string including DOCTYPE, metadata, and body\n\t * in Netscape Bookmark format.\n\t *\n\t * @returns HTML string in Netscape Bookmark format\n\t *\n\t * @example\n\t * ```typescript\n\t * const tree = new BookmarksTree();\n\t * tree.set(\"Google\", \"https://google.com\");\n\t * const html = tree.HTMLString;\n\t * console.log(html); // <!DOCTYPE NETSCAPE-Bookmark-file-1>...\n\t * ```\n\t */\n\tget HTMLString(): string {\n\t\tconst escapeHtml = (text: string): string => {\n\t\t\treturn text\n\t\t\t\t.replace(/&/g, \"&amp;\")\n\t\t\t\t.replace(/</g, \"&lt;\")\n\t\t\t\t.replace(/>/g, \"&gt;\")\n\t\t\t\t.replace(/\"/g, \"&quot;\")\n\t\t\t\t.replace(/'/g, \"&#39;\");\n\t\t};\n\n\t\tconst createBookmarkList = (tree: BookmarksTree, indent: string = \"\"): string => {\n\t\t\tlet html = `${indent}<DL><p>\\n`;\n\n\t\t\tfor (const [key, value] of tree.entries()) {\n\t\t\t\tif (typeof value === \"string\") {\n\t\t\t\t\t// ブックマークの場合: <DT><A HREF=\"url\">タイトル</A>\n\t\t\t\t\thtml += `${indent} <DT><A HREF=\"${escapeHtml(value)}\">${escapeHtml(key)}</A>\\n`;\n\t\t\t\t} else if (value instanceof BookmarksTree) {\n\t\t\t\t\t// フォルダの場合: <DT><H3>フォルダ名</H3>\n\t\t\t\t\thtml += `${indent} <DT><H3>${escapeHtml(key)}</H3>\\n`;\n\t\t\t\t\thtml += createBookmarkList(value, indent + \" \");\n\t\t\t\t\thtml += `${indent} </DL><p>\\n`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (indent === \"\") {\n\t\t\t\t// ルートレベルの場合は閉じタグを追加\n\t\t\t\thtml += `</DL>\\n`;\n\t\t\t}\n\n\t\t\treturn html;\n\t\t};\n\n\t\tconst htmlTemplate = `<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<HTML>\n<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\">\n<TITLE>Bookmark</TITLE>\n<H1>Bookmark</H1>\n<BODY>\n${createBookmarkList(this)}</BODY>\n</HTML>`;\n\t\treturn htmlTemplate;\n\t}\n\n\t/**\n\t * @deprecated Use {@link HTMLString} instead.\n\t *\n\t * Gets the BookmarksTree as an HTML string in Netscape Bookmark format.\n\t */\n\tget HTMLText(): string {\n\t\treturn this.HTMLString;\n\t}\n}\n","/**\n * Copyright (c) 2025-2026 kurage(@umitsukidev)\n *\n * This software is released under the MIT License.\n * https://opensource.org/licenses/MIT\n */\n\nimport { DOMParser } from \"../dom.ts\";\nimport type { HTMLDocument } from \"#dom-types\";\nimport { BookmarksTree } from \"../BookmarksTree/index.ts\";\n\n/**\n * A parser for Netscape Bookmark format files\n *\n * This class provides static methods to parse Netscape Bookmark format HTML strings\n * and convert them into BookmarksTree instances for easier manipulation.\n *\n * @example\n * ```typescript\n * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>\n * <HTML>\n * <BODY>\n * <DL><p>\n * <DT><A HREF=\"https://google.com\">Google</A>\n * <DT><H3>Development</H3>\n * <DL><p>\n * <DT><A HREF=\"https://github.com\">GitHub</A>\n * </DL><p>\n * </DL>\n * </BODY>\n * </HTML>`;\n *\n * const tree = BookmarksParser.parse(bookmarkHtml);\n * ```\n */\nexport class BookmarksParser {\n\t/**\n\t * Alias for the {@link parseFromHTMLString} method.\n\t *\n\t * @param htmlString HTML string in Netscape Bookmark format\n\t * @returns The parsed BookmarksTree\n\t *\n\t * @example\n\t * ```typescript\n\t * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>\n\t * <HTML>\n\t * <BODY>\n\t * <DL><p>\n\t * <DT><A HREF=\"https://google.com\">Google</A>\n\t * <DT><H3>Development</H3>\n\t * <DL><p>\n\t * <DT><A HREF=\"https://github.com\">GitHub</A>\n\t * </DL><p>\n\t * </DL>\n\t * </BODY>\n\t * </HTML>`;\n\t *\n\t * const tree = BookmarksParser.parse(bookmarkHtml);\n\t * ```\n\t */\n\tstatic parse(htmlString: string): BookmarksTree {\n\t\treturn this.parseFromHTMLString(htmlString);\n\t}\n\n\t/**\n\t * Parses a Netscape Bookmark format HTML string and returns a BookmarksTree.\n\t *\n\t * @param htmlString HTML string in Netscape Bookmark format\n\t * @returns The parsed BookmarksTree\n\t *\n\t * @example\n\t * ```typescript\n\t * const bookmarkHtml = `<!DOCTYPE NETSCAPE-Bookmark-file-1>\n\t * <HTML>\n\t * <BODY>\n\t * <DL><p>\n\t * <DT><A HREF=\"https://google.com\">Google</A>\n\t * <DT><H3>Development</H3>\n\t * <DL><p>\n\t * <DT><A HREF=\"https://github.com\">GitHub</A>\n\t * </DL><p>\n\t * </DL>\n\t * </BODY>\n\t * </HTML>`;\n\t *\n\t * const tree = BookmarksParser.parseFromHTMLString(bookmarkHtml);\n\t * ```\n\t */\n\tstatic parseFromHTMLString(htmlString: string): BookmarksTree {\n\t\tconst dom = new DOMParser().parseFromString(htmlString, \"text/html\");\n\t\tconst tree = BookmarksTree.fromDOM(dom);\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Creates a BookmarksTree from an existing HTMLDocument.\n\t *\n\t * This is an alias for {@link BookmarksTree.fromDOM}.\n\t *\n\t * Use this when you already have a parsed HTMLDocument and want to convert it to a BookmarksTree.\n\t *\n\t * @param dom An HTMLDocument instance\n\t * @returns The parsed BookmarksTree\n\t *\n\t * @example\n\t * ```typescript\n\t * const dom = new DOMParser().parseFromString(bookmarkHtml, \"text/html\");\n\t * const tree = BookmarksParser.parseFromDOM(dom);\n\t * ```\n\t */\n\tstatic parseFromDOM(dom: HTMLDocument): BookmarksTree {\n\t\treturn BookmarksTree.fromDOM(dom);\n\t}\n\n\t/**\n\t * Parses a JSON string and returns a BookmarksTree.\n\t *\n\t * @param jsonString JSON string representing the bookmark structure\n\t * @returns The parsed BookmarksTree\n\t *\n\t * @example\n\t * ```typescript\n\t * const json = '{\"Google\":\"https://google.com\",\"Development\":{\"GitHub\":\"https://github.com\"}}';\n\t * const tree = BookmarksParser.parseFromJSONString(json);\n\t * ```\n\t */\n\tstatic parseFromJSONString(jsonString: string): BookmarksTree {\n\t\tconst obj = JSON.parse(jsonString);\n\t\treturn BookmarksTree.fromJSON(obj);\n\t}\n\n\t/**\n\t * Parses a JSON object and returns a BookmarksTree.\n\t *\n\t * This is an alias for {@link BookmarksTree.fromJSON}.\n\t *\n\t * @param jsonObj JSON object representing the bookmark structure\n\t * @returns The parsed BookmarksTree\n\t *\n\t * @example\n\t * ```typescript\n\t * const obj = { \"Google\": \"https://google.com\", \"Development\": { \"GitHub\": \"https://github.com\" } };\n\t * const tree = BookmarksParser.parseFromJSON(obj);\n\t * ```\n\t */\n\tstatic parseFromJSON(jsonObj: Record<string, unknown>): BookmarksT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