@riebeckite/plugin-docs 0.0.31 → 0.0.32

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/client.js CHANGED
@@ -1,10 +1,9 @@
1
1
  // src/docs-sidebar.client.ts
2
2
  var COLLAPSIBLE_PROPERTY = "--rb-docs-sidebar-collapsible";
3
- function initDocsSidebar() {
3
+ function initDocsSidebar(context = {}) {
4
+ const root = context.root ?? document;
4
5
  const details = Array.from(
5
- document.querySelectorAll(
6
- "[data-docs-sidebar-details]"
7
- )
6
+ root.querySelectorAll("[data-docs-sidebar-details]")
8
7
  );
9
8
  const first = details[0];
10
9
  if (!first) return;
@@ -22,6 +21,7 @@ function initDocsSidebar() {
22
21
  apply(next);
23
22
  };
24
23
  window.addEventListener("resize", sync, { passive: true });
24
+ return () => window.removeEventListener("resize", sync);
25
25
  }
26
26
  function isCollapsible(element) {
27
27
  return getComputedStyle(element).getPropertyValue(COLLAPSIBLE_PROPERTY).trim() !== "0";
package/dist/index.js CHANGED
@@ -344,11 +344,10 @@ function findDocsOptions2(plugins) {
344
344
 
345
345
  // src/docs-sidebar.client.ts
346
346
  var COLLAPSIBLE_PROPERTY = "--rb-docs-sidebar-collapsible";
347
- function initDocsSidebar() {
347
+ function initDocsSidebar(context = {}) {
348
+ const root = context.root ?? document;
348
349
  const details = Array.from(
349
- document.querySelectorAll(
350
- "[data-docs-sidebar-details]"
351
- )
350
+ root.querySelectorAll("[data-docs-sidebar-details]")
352
351
  );
353
352
  const first = details[0];
354
353
  if (!first) return;
@@ -366,6 +365,7 @@ function initDocsSidebar() {
366
365
  apply(next);
367
366
  };
368
367
  window.addEventListener("resize", sync, { passive: true });
368
+ return () => window.removeEventListener("resize", sync);
369
369
  }
370
370
  function isCollapsible(element) {
371
371
  return getComputedStyle(element).getPropertyValue(COLLAPSIBLE_PROPERTY).trim() !== "0";
@@ -455,7 +455,10 @@ function docs(options) {
455
455
  createClientEntry(
456
456
  DOCS_PLUGIN_NAME,
457
457
  "@riebeckite/plugin-docs/client",
458
- "initDocsSidebar"
458
+ "initDocsSidebar",
459
+ void 0,
460
+ void 0,
461
+ "context"
459
462
  )
460
463
  ]
461
464
  });
@@ -1 +1,5 @@
1
- export declare function initDocsSidebar(): void;
1
+ type ClientContext = {
2
+ root?: ParentNode;
3
+ };
4
+ export declare function initDocsSidebar(context?: ClientContext): () => void;
5
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-docs",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,12 +28,12 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "hono": "^4.12.25",
31
- "@riebeckite/core": "0.0.31",
32
- "@riebeckite/ui": "0.0.31"
31
+ "@riebeckite/core": "0.0.32",
32
+ "@riebeckite/ui": "0.0.32"
33
33
  },
34
34
  "devDependencies": {
35
35
  "tsx": "^4.22.4",
36
- "@riebeckite/test": "0.0.31"
36
+ "@riebeckite/test": "0.0.32"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"