netscape-bookmark-parser 1.1.4 → 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 +108 -98
  3. package/README.md +108 -98
  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 -130
  94. package/esm/src/BookmarksParser/BookmarksParser.d.ts.map +0 -1
  95. package/esm/src/BookmarksParser/BookmarksParser.js +0 -142
  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 -118
  100. package/esm/src/BookmarksTree/BookmarksTree.d.ts.map +0 -1
  101. package/esm/src/BookmarksTree/BookmarksTree.js +0 -225
  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 -130
  109. package/esm/src/web/BookmarksParser/BookmarksParser.d.ts.map +0 -1
  110. package/esm/src/web/BookmarksParser/BookmarksParser.js +0 -142
  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 -118
  115. package/esm/src/web/BookmarksTree/BookmarksTree.d.ts.map +0 -1
  116. package/esm/src/web/BookmarksTree/BookmarksTree.js +0 -225
  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
package/README.md CHANGED
@@ -4,7 +4,8 @@ A TypeScript/JavaScript library for parsing browser bookmark files (HTML format)
4
4
 
5
5
  > **Note:**
6
6
  > This README is an AI-generated document. Details are mostly accurate but might include inaccurate description.
7
- > 日本語ドキュメント: [`./README-ja.md`](./README-ja.md)
7
+
8
+ 日本語ドキュメント: [`./README-ja.md`](./README-ja.md)
8
9
 
9
10
  ## Features
10
11
 
@@ -30,13 +31,10 @@ import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser";
30
31
  ### Deno
31
32
 
32
33
  ```typescript
33
- import {
34
- BookmarksParser,
35
- BookmarksTree,
36
- } from "jsr:@grakeice/netscape-bookmark-parser";
34
+ import { BookmarksParser, BookmarksTree } from "jsr:@grakeice/netscape-bookmark-parser";
37
35
  ```
38
36
 
39
- > **Note:** The JSR version only includes the Node.js/Deno runtime. For browser support, please use the npm package.
37
+ > **Note:** The JSR package provides the Node.js/Deno entry. For browser support, use the npm package's dependency-free `./web` entry.
40
38
 
41
39
  ### Browser
42
40
 
@@ -50,16 +48,16 @@ import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser/web";
50
48
 
51
49
  // Example: Parse uploaded bookmark file
52
50
  function handleFileUpload(event: Event) {
53
- const file = (event.target as HTMLInputElement).files?.[0];
54
- if (file) {
55
- const reader = new FileReader();
56
- reader.onload = (e) => {
57
- const htmlContent = e.target?.result as string;
58
- const bookmarksTree = BookmarksParser.parse(htmlContent);
59
- console.log(bookmarksTree.toJSON());
60
- };
61
- reader.readAsText(file);
62
- }
51
+ const file = (event.target as HTMLInputElement).files?.[0];
52
+ if (file) {
53
+ const reader = new FileReader();
54
+ reader.onload = (e) => {
55
+ const htmlContent = e.target?.result as string;
56
+ const bookmarksTree = BookmarksParser.parse(htmlContent);
57
+ console.log(bookmarksTree.toJSON());
58
+ };
59
+ reader.readAsText(file);
60
+ }
63
61
  }
64
62
  ```
65
63
 
@@ -67,15 +65,15 @@ function handleFileUpload(event: Event) {
67
65
 
68
66
  ```html
69
67
  <script type="importmap">
70
- {
71
- "imports": {
72
- "netscape-bookmark-parser/web": "https://cdn.jsdelivr.net/npm/netscape-bookmark-parser@1.1.4/esm/mod_web.js"
73
- }
74
- }
68
+ {
69
+ "imports": {
70
+ "netscape-bookmark-parser/web": "https://cdn.jsdelivr.net/npm/netscape-bookmark-parser@1.1.4/dist/web.js"
71
+ }
72
+ }
75
73
  </script>
76
74
  <script type="module">
77
- import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser/web";
78
- const tree = BookmarksParser.parse(htmlContent);
75
+ import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser/web";
76
+ const tree = BookmarksParser.parse(htmlContent);
79
77
  </script>
80
78
  ```
81
79
 
@@ -83,14 +81,14 @@ function handleFileUpload(event: Event) {
83
81
 
84
82
  ```html
85
83
  <script type="module">
86
- import {
87
- BookmarksParser,
88
- BookmarksTree,
89
- } from "https://cdn.jsdelivr.net/npm/netscape-bookmark-parser@1.1.4/esm/mod_web.js";
84
+ import {
85
+ BookmarksParser,
86
+ BookmarksTree,
87
+ } from "https://cdn.jsdelivr.net/npm/netscape-bookmark-parser@1.1.4/dist/web.js";
90
88
  </script>
91
89
  ```
92
90
 
93
- > **Browser Support:** Browser compatibility is only available through the npm package. The JSR package does not include the web-optimized version due to platform-specific dependencies.
91
+ > **Browser Support:** The web-optimized version is available from the npm `./web` export. It uses native browser APIs and has no DOM library dependency.
94
92
 
95
93
  > **Note:** The web-optimized version uses native browser APIs (DOMParser, etc.) and does not include Node.js polyfills, making it lighter and faster in browser environments.
96
94
 
@@ -199,12 +197,12 @@ console.log(devFolder.get("GitHub")); // "https://github.com"
199
197
 
200
198
  ### Web-Optimized Version
201
199
 
202
- > **Important:** Browser support is only available via npm installation. JSR version does not include browser-compatible builds.
200
+ > **Important:** Browser support is available from the npm `./web` export.
203
201
 
204
202
  The library provides a browser-optimized version that eliminates Node.js dependencies and uses native browser APIs:
205
203
 
206
204
  ```typescript
207
- // Import browser-optimized version (npm only)
205
+ // Import the browser-optimized version
208
206
  import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser/web";
209
207
  ```
210
208
 
@@ -218,49 +216,49 @@ import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser/web";
218
216
 
219
217
  - [`static parse(htmlString: string): BookmarksTree`](#static-parsehtmlstring-string-bookmarkstree)
220
218
 
221
- - Parses a Netscape Bookmark format HTML string and returns a `BookmarksTree`.
222
- - Alias for [`parseFromHTMLString`](#static-parsefromhtmlstringhtmlstring-string-bookmarkstree).
219
+ - Parses a Netscape Bookmark format HTML string and returns a `BookmarksTree`.
220
+ - Alias for [`parseFromHTMLString`](#static-parsefromhtmlstringhtmlstring-string-bookmarkstree).
223
221
 
224
- **Example:**
222
+ **Example:**
225
223
 
226
- ```typescript
227
- const html = `<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<HTML><BODY><DL><p>\n <DT><A HREF=\"https://example.com\">Example</A>\n</DL><p></BODY></HTML>`;
228
- const tree = BookmarksParser.parse(html);
229
- console.log(tree.toJSON());
230
- ```
224
+ ```typescript
225
+ const html = `<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<HTML><BODY><DL><p>\n <DT><A HREF=\"https://example.com\">Example</A>\n</DL><p></BODY></HTML>`;
226
+ const tree = BookmarksParser.parse(html);
227
+ console.log(tree.toJSON());
228
+ ```
231
229
 
232
230
  - [`static parseFromHTMLString(htmlString: string): BookmarksTree`](#static-parsefromhtmlstringhtmlstring-string-bookmarkstree)
233
231
 
234
- - Parses a Netscape Bookmark format HTML string and returns a `BookmarksTree`.
232
+ - Parses a Netscape Bookmark format HTML string and returns a `BookmarksTree`.
235
233
 
236
- **Example:**
234
+ **Example:**
237
235
 
238
- ```typescript
239
- const html = `<!DOCTYPE NETSCAPE-Bookmark-file-1>...`;
240
- const tree = BookmarksParser.parseFromHTMLString(html);
241
- ```
236
+ ```typescript
237
+ const html = `<!DOCTYPE NETSCAPE-Bookmark-file-1>...`;
238
+ const tree = BookmarksParser.parseFromHTMLString(html);
239
+ ```
242
240
 
243
241
  - [`static parseFromDOM(dom: HTMLDocument): BookmarksTree`](#static-parsefromdomdom-htmldocument-bookmarkstree)
244
242
 
245
- - Converts an existing `HTMLDocument` to a `BookmarksTree`.
243
+ - Converts an existing `HTMLDocument` to a `BookmarksTree`.
246
244
 
247
- **Example:**
245
+ **Example:**
248
246
 
249
- ```typescript
250
- const dom = new DOMParser().parseFromString(html, "text/html");
251
- const tree = BookmarksParser.parseFromDOM(dom);
252
- ```
247
+ ```typescript
248
+ const dom = new DOMParser().parseFromString(html, "text/html");
249
+ const tree = BookmarksParser.parseFromDOM(dom);
250
+ ```
253
251
 
254
252
  - [`static parseFromJSON(jsonString: string): BookmarksTree`](#static-parsefromjsonjsonstring-string-bookmarkstree)
255
253
 
256
- - Parses a JSON string and returns a `BookmarksTree`.
254
+ - Parses a JSON string and returns a `BookmarksTree`.
257
255
 
258
- **Example:**
256
+ **Example:**
259
257
 
260
- ```typescript
261
- const json = '{"Google": "https://google.com"}';
262
- const tree = BookmarksParser.parseFromJSON(json);
263
- ```
258
+ ```typescript
259
+ const json = '{"Google": "https://google.com"}';
260
+ const tree = BookmarksParser.parseFromJSON(json);
261
+ ```
264
262
 
265
263
  ---
266
264
 
@@ -272,73 +270,73 @@ import { BookmarksParser, BookmarksTree } from "netscape-bookmark-parser/web";
272
270
 
273
271
  - [`new BookmarksTree()`](#constructor)
274
272
 
275
- **Example:**
273
+ **Example:**
276
274
 
277
- ```typescript
278
- const tree = new BookmarksTree();
279
- tree.set("Google", "https://google.com");
280
- ```
275
+ ```typescript
276
+ const tree = new BookmarksTree();
277
+ tree.set("Google", "https://google.com");
278
+ ```
281
279
 
282
280
  #### Instance Methods
283
281
 
284
282
  - [`toJSON(): Record<string, unknown>`](#tojson-recordstring-unknown)
285
283
 
286
- - Converts the tree to a JSON object representation.
284
+ - Converts the tree to a JSON object representation.
287
285
 
288
- **Example:**
286
+ **Example:**
289
287
 
290
- ```typescript
291
- const json = tree.toJSON();
292
- console.log(json);
293
- ```
288
+ ```typescript
289
+ const json = tree.toJSON();
290
+ console.log(json);
291
+ ```
294
292
 
295
293
  - [`toDOM(): HTMLDocument`](#todom-htmldocument)
296
294
 
297
- - Converts the tree to a Netscape Bookmark format HTML document.
295
+ - Converts the tree to a Netscape Bookmark format HTML document.
298
296
 
299
- **Example:**
297
+ **Example:**
300
298
 
301
- ```typescript
302
- const dom = tree.toDOM();
303
- ```
299
+ ```typescript
300
+ const dom = tree.toDOM();
301
+ ```
304
302
 
305
303
  - [`get HTMLString(): string`](#get-htmlstring-string)
306
304
 
307
- - Gets the complete HTML string in Netscape Bookmark format.
305
+ - Gets the complete HTML string in Netscape Bookmark format.
308
306
 
309
- **Example:**
307
+ **Example:**
310
308
 
311
- ```typescript
312
- const html = tree.HTMLString;
313
- console.log(html);
314
- ```
309
+ ```typescript
310
+ const html = tree.HTMLString;
311
+ console.log(html);
312
+ ```
315
313
 
316
314
  - [`get HTMLText(): string`](#get-htmltext-string)
317
- - Alias for `HTMLString` (deprecated).
315
+ - Alias for `HTMLString` (deprecated).
318
316
 
319
317
  #### Static Methods
320
318
 
321
319
  - [`static fromJSON(json: Record<string, unknown>): BookmarksTree`](#static-fromjsonjson-recordstring-unknown-bookmarkstree)
322
320
 
323
- - Creates a tree from a JSON object.
321
+ - Creates a tree from a JSON object.
324
322
 
325
- **Example:**
323
+ **Example:**
326
324
 
327
- ```typescript
328
- const json = { Google: "https://google.com" };
329
- const tree = BookmarksTree.fromJSON(json);
330
- ```
325
+ ```typescript
326
+ const json = { Google: "https://google.com" };
327
+ const tree = BookmarksTree.fromJSON(json);
328
+ ```
331
329
 
332
330
  - [`static fromDOM(dom: HTMLDocument): BookmarksTree`](#static-fromdomdom-htmldocument-bookmarkstree)
333
331
 
334
- - Creates a tree from an HTML document.
332
+ - Creates a tree from an HTML document.
335
333
 
336
- **Example:**
334
+ **Example:**
337
335
 
338
- ```typescript
339
- const dom = new DOMParser().parseFromString(html, "text/html");
340
- const tree = BookmarksTree.fromDOM(dom);
341
- ```
336
+ ```typescript
337
+ const dom = new DOMParser().parseFromString(html, "text/html");
338
+ const tree = BookmarksTree.fromDOM(dom);
339
+ ```
342
340
 
343
341
  ## Project Structure
344
342
 
@@ -353,16 +351,28 @@ src/
353
351
  ├── BookmarksParser.test.ts # Parser tests
354
352
  └── index.ts # Export definitions
355
353
  scripts/
356
- └── build_npm.ts # NPM build script
354
+ └── sync-jsr-version.mjs # Keep JSR version in sync with package.json
357
355
  .github/
358
356
  └── workflows/
359
- └── release.yml # CI/CD pipeline
360
- npm/ # Node.js build artifacts
361
- ├── esm/ # ES modules
362
- ├── package.json
363
- └── README.md
357
+ ├── changesets.yml # Changesets version pull requests
358
+ ├── ci.yml # Test, typecheck, and build checks
359
+ └── release.yml # NPM/JSR publishing and GitHub releases
360
+ dist/ # Generated package files (not committed)
364
361
  ```
365
362
 
363
+ ## Development and Release
364
+
365
+ Install dependencies with pnpm and run the local checks:
366
+
367
+ ```bash
368
+ pnpm install
369
+ pnpm test
370
+ pnpm typecheck
371
+ pnpm build
372
+ ```
373
+
374
+ Create a release note with `pnpm changeset`. Changesets opens a version pull request on `main`; merging it updates `package.json` and synchronizes the JSR version in `jsr.json`. A subsequent `main` push publishes the package to NPM and JSR and creates the matching `v<version>` Git tag and GitHub release.
375
+
366
376
  ## Supported Formats
367
377
 
368
378
  ### Input Formats
@@ -474,7 +484,7 @@ MIT License - See [LICENSE](LICENSE) file for details.
474
484
  ### v1.1.0
475
485
 
476
486
  - 🌐 **Browser Support**: Added web-optimized version for browser environments
477
- - 📦 **Dual Entry Points**: Separate builds for Node.js/Deno (`./mod.ts`) and browsers (`./mod_web.ts`)
487
+ - 📦 **Dual Entry Points**: Separate builds for Node.js/Deno (`src/index.ts`) and browsers (`src/web.ts`)
478
488
  - ⚡ **Native DOM APIs**: Browser version uses native DOMParser and DOM APIs for better performance
479
489
  - 🔧 **Build Optimization**: Enhanced build process with polyfill removal for browser compatibility
480
490
  - 📚 **Updated Documentation**: Added browser usage examples and API reference
@@ -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