@sp-days-framework/docusaurus-plugin-interactive-tasks 1.0.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 (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/lib/contexts/DocTaskCounterContext.d.ts +15 -0
  4. package/lib/contexts/DocTaskCounterContext.d.ts.map +1 -0
  5. package/lib/contexts/DocTaskCounterContext.js +7 -0
  6. package/lib/contexts/DocTaskCounterContext.js.map +1 -0
  7. package/lib/contexts/TaskContext.d.ts +72 -0
  8. package/lib/contexts/TaskContext.d.ts.map +1 -0
  9. package/lib/contexts/TaskContext.js +6 -0
  10. package/lib/contexts/TaskContext.js.map +1 -0
  11. package/lib/index.d.ts +14 -0
  12. package/lib/index.d.ts.map +1 -0
  13. package/lib/index.js +59 -0
  14. package/lib/index.js.map +1 -0
  15. package/lib/plugin/TaskRegistryPlugin.d.ts +27 -0
  16. package/lib/plugin/TaskRegistryPlugin.d.ts.map +1 -0
  17. package/lib/plugin/TaskRegistryPlugin.js +328 -0
  18. package/lib/plugin/TaskRegistryPlugin.js.map +1 -0
  19. package/lib/plugin/remarkTaskDirective.d.ts +29 -0
  20. package/lib/plugin/remarkTaskDirective.d.ts.map +1 -0
  21. package/lib/plugin/remarkTaskDirective.js +277 -0
  22. package/lib/plugin/remarkTaskDirective.js.map +1 -0
  23. package/lib/theme/DocRoot/Layout/index.d.ts +14 -0
  24. package/lib/theme/DocRoot/Layout/index.d.ts.map +1 -0
  25. package/lib/theme/DocRoot/Layout/index.js +27 -0
  26. package/lib/theme/DocRoot/Layout/index.js.map +1 -0
  27. package/lib/theme/DocRoot/index.d.ts +22 -0
  28. package/lib/theme/DocRoot/index.d.ts.map +1 -0
  29. package/lib/theme/DocRoot/index.js +33 -0
  30. package/lib/theme/DocRoot/index.js.map +1 -0
  31. package/lib/theme/DocSidebar/Desktop/CollapseButton/index.d.ts +4 -0
  32. package/lib/theme/DocSidebar/Desktop/CollapseButton/index.d.ts.map +1 -0
  33. package/lib/theme/DocSidebar/Desktop/CollapseButton/index.js +24 -0
  34. package/lib/theme/DocSidebar/Desktop/CollapseButton/index.js.map +1 -0
  35. package/lib/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +40 -0
  36. package/lib/theme/DocSidebar/Desktop/Content/index.d.ts +4 -0
  37. package/lib/theme/DocSidebar/Desktop/Content/index.d.ts.map +1 -0
  38. package/lib/theme/DocSidebar/Desktop/Content/index.js +67 -0
  39. package/lib/theme/DocSidebar/Desktop/Content/index.js.map +1 -0
  40. package/lib/theme/DocSidebar/Desktop/Content/styles.module.css +16 -0
  41. package/lib/theme/DocSidebar/Desktop/index.d.ts +6 -0
  42. package/lib/theme/DocSidebar/Desktop/index.d.ts.map +1 -0
  43. package/lib/theme/DocSidebar/Desktop/index.js +21 -0
  44. package/lib/theme/DocSidebar/Desktop/index.js.map +1 -0
  45. package/lib/theme/DocSidebar/Desktop/styles.module.css +37 -0
  46. package/lib/theme/DocSidebar/Mobile/index.d.ts +6 -0
  47. package/lib/theme/DocSidebar/Mobile/index.d.ts.map +1 -0
  48. package/lib/theme/DocSidebar/Mobile/index.js +29 -0
  49. package/lib/theme/DocSidebar/Mobile/index.js.map +1 -0
  50. package/lib/theme/DocSidebar/index.d.ts +4 -0
  51. package/lib/theme/DocSidebar/index.d.ts.map +1 -0
  52. package/lib/theme/DocSidebar/index.js +21 -0
  53. package/lib/theme/DocSidebar/index.js.map +1 -0
  54. package/lib/theme/DocSidebarItem/Category/index.d.ts +4 -0
  55. package/lib/theme/DocSidebarItem/Category/index.d.ts.map +1 -0
  56. package/lib/theme/DocSidebarItem/Category/index.js +316 -0
  57. package/lib/theme/DocSidebarItem/Category/index.js.map +1 -0
  58. package/lib/theme/DocSidebarItem/Category/styles.module.css +187 -0
  59. package/lib/theme/DocSidebarItem/Html/index.d.ts +4 -0
  60. package/lib/theme/DocSidebarItem/Html/index.d.ts.map +1 -0
  61. package/lib/theme/DocSidebarItem/Html/index.js +17 -0
  62. package/lib/theme/DocSidebarItem/Html/index.js.map +1 -0
  63. package/lib/theme/DocSidebarItem/Html/styles.module.css +6 -0
  64. package/lib/theme/DocSidebarItem/Link/index.d.ts +6 -0
  65. package/lib/theme/DocSidebarItem/Link/index.d.ts.map +1 -0
  66. package/lib/theme/DocSidebarItem/Link/index.js +149 -0
  67. package/lib/theme/DocSidebarItem/Link/index.js.map +1 -0
  68. package/lib/theme/DocSidebarItem/Link/styles.module.css +197 -0
  69. package/lib/theme/DocSidebarItem/index.d.ts +4 -0
  70. package/lib/theme/DocSidebarItem/index.d.ts.map +1 -0
  71. package/lib/theme/DocSidebarItem/index.js +22 -0
  72. package/lib/theme/DocSidebarItem/index.js.map +1 -0
  73. package/lib/theme/DocSidebarItems/index.d.ts +6 -0
  74. package/lib/theme/DocSidebarItems/index.d.ts.map +1 -0
  75. package/lib/theme/DocSidebarItems/index.js +48 -0
  76. package/lib/theme/DocSidebarItems/index.js.map +1 -0
  77. package/lib/theme/DocTaskCounterProvider/index.d.ts +20 -0
  78. package/lib/theme/DocTaskCounterProvider/index.d.ts.map +1 -0
  79. package/lib/theme/DocTaskCounterProvider/index.js +105 -0
  80. package/lib/theme/DocTaskCounterProvider/index.js.map +1 -0
  81. package/lib/theme/MDXComponents.d.ts +19 -0
  82. package/lib/theme/MDXComponents.d.ts.map +1 -0
  83. package/lib/theme/MDXComponents.js +52 -0
  84. package/lib/theme/MDXComponents.js.map +1 -0
  85. package/lib/theme/Root.d.ts +9 -0
  86. package/lib/theme/Root.d.ts.map +1 -0
  87. package/lib/theme/Root.js +105 -0
  88. package/lib/theme/Root.js.map +1 -0
  89. package/lib/theme/Task/Hint/index.d.ts +14 -0
  90. package/lib/theme/Task/Hint/index.d.ts.map +1 -0
  91. package/lib/theme/Task/Hint/index.js +23 -0
  92. package/lib/theme/Task/Hint/index.js.map +1 -0
  93. package/lib/theme/Task/Hint/styles.module.css +72 -0
  94. package/lib/theme/Task/Solution/index.d.ts +14 -0
  95. package/lib/theme/Task/Solution/index.d.ts.map +1 -0
  96. package/lib/theme/Task/Solution/index.js +23 -0
  97. package/lib/theme/Task/Solution/index.js.map +1 -0
  98. package/lib/theme/Task/Solution/styles.module.css +71 -0
  99. package/lib/theme/Task/Text/index.d.ts +14 -0
  100. package/lib/theme/Task/Text/index.d.ts.map +1 -0
  101. package/lib/theme/Task/Text/index.js +18 -0
  102. package/lib/theme/Task/Text/index.js.map +1 -0
  103. package/lib/theme/Task/Text/styles.module.css +39 -0
  104. package/lib/theme/Task/index.d.ts +11 -0
  105. package/lib/theme/Task/index.d.ts.map +1 -0
  106. package/lib/theme/Task/index.js +286 -0
  107. package/lib/theme/Task/index.js.map +1 -0
  108. package/lib/theme/Task/styles.module.css +529 -0
  109. package/lib/theme/TaskAutoHideToggle/index.d.ts +10 -0
  110. package/lib/theme/TaskAutoHideToggle/index.d.ts.map +1 -0
  111. package/lib/theme/TaskAutoHideToggle/index.js +79 -0
  112. package/lib/theme/TaskAutoHideToggle/index.js.map +1 -0
  113. package/lib/theme/TaskAutoHideToggle/styles.module.css +41 -0
  114. package/lib/theme/TaskExample/index.d.ts +16 -0
  115. package/lib/theme/TaskExample/index.d.ts.map +1 -0
  116. package/lib/theme/TaskExample/index.js +249 -0
  117. package/lib/theme/TaskExample/index.js.map +1 -0
  118. package/lib/theme/TaskPlaceholder/README.md +119 -0
  119. package/lib/theme/TaskPlaceholder/index.d.ts +23 -0
  120. package/lib/theme/TaskPlaceholder/index.d.ts.map +1 -0
  121. package/lib/theme/TaskPlaceholder/index.js +293 -0
  122. package/lib/theme/TaskPlaceholder/index.js.map +1 -0
  123. package/lib/theme/TaskProgression/index.d.ts +11 -0
  124. package/lib/theme/TaskProgression/index.d.ts.map +1 -0
  125. package/lib/theme/TaskProgression/index.js +131 -0
  126. package/lib/theme/TaskProgression/index.js.map +1 -0
  127. package/lib/theme/TaskProgression/styles.module.css +162 -0
  128. package/lib/theme/TaskProgressionOverview/index.d.ts +10 -0
  129. package/lib/theme/TaskProgressionOverview/index.d.ts.map +1 -0
  130. package/lib/theme/TaskProgressionOverview/index.js +123 -0
  131. package/lib/theme/TaskProgressionOverview/index.js.map +1 -0
  132. package/lib/theme/TaskProgressionOverview/styles.module.css +159 -0
  133. package/lib/theme/TaskProvider/index.d.ts +15 -0
  134. package/lib/theme/TaskProvider/index.d.ts.map +1 -0
  135. package/lib/theme/TaskProvider/index.js +134 -0
  136. package/lib/theme/TaskProvider/index.js.map +1 -0
  137. package/lib/utils/badgeStyles.d.ts +29 -0
  138. package/lib/utils/badgeStyles.d.ts.map +1 -0
  139. package/lib/utils/badgeStyles.js +60 -0
  140. package/lib/utils/badgeStyles.js.map +1 -0
  141. package/lib/utils/icons.d.ts +38 -0
  142. package/lib/utils/icons.d.ts.map +1 -0
  143. package/lib/utils/icons.js +53 -0
  144. package/lib/utils/icons.js.map +1 -0
  145. package/lib/utils/logger.d.ts +38 -0
  146. package/lib/utils/logger.d.ts.map +1 -0
  147. package/lib/utils/logger.js +72 -0
  148. package/lib/utils/logger.js.map +1 -0
  149. package/lib/utils/storage.d.ts +33 -0
  150. package/lib/utils/storage.d.ts.map +1 -0
  151. package/lib/utils/storage.js +105 -0
  152. package/lib/utils/storage.js.map +1 -0
  153. package/lib/utils/useDocTaskStats.d.ts +58 -0
  154. package/lib/utils/useDocTaskStats.d.ts.map +1 -0
  155. package/lib/utils/useDocTaskStats.js +206 -0
  156. package/lib/utils/useDocTaskStats.js.map +1 -0
  157. package/lib/utils/usePluginId.d.ts +24 -0
  158. package/lib/utils/usePluginId.d.ts.map +1 -0
  159. package/lib/utils/usePluginId.js +61 -0
  160. package/lib/utils/usePluginId.js.map +1 -0
  161. package/lib/utils/useResolveDocPath.d.ts +33 -0
  162. package/lib/utils/useResolveDocPath.d.ts.map +1 -0
  163. package/lib/utils/useResolveDocPath.js +122 -0
  164. package/lib/utils/useResolveDocPath.js.map +1 -0
  165. package/lib/utils/useTaskBadgeAnimation.d.ts +16 -0
  166. package/lib/utils/useTaskBadgeAnimation.d.ts.map +1 -0
  167. package/lib/utils/useTaskBadgeAnimation.js +51 -0
  168. package/lib/utils/useTaskBadgeAnimation.js.map +1 -0
  169. package/lib/validateThemeConfig.d.ts +8 -0
  170. package/lib/validateThemeConfig.d.ts.map +1 -0
  171. package/lib/validateThemeConfig.js +15 -0
  172. package/lib/validateThemeConfig.js.map +1 -0
  173. package/package.json +82 -0
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Interactive Tasks Plugin Logger
3
+ * Wraps Docusaurus logger for consistent build-time logging
4
+ * This is for Node.js build-time only (plugins, webpack)
5
+ */
6
+ /**
7
+ * Log info message
8
+ * Format: [INFO] [Interactive Tasks] message
9
+ */
10
+ export declare function logInfo(message: string): void;
11
+ /**
12
+ * Log warning message
13
+ * Format: [WARNING] [Interactive Tasks] message
14
+ */
15
+ export declare function logWarn(message: string): void;
16
+ /**
17
+ * Log error message
18
+ * Format: [ERROR] [Interactive Tasks] message
19
+ */
20
+ export declare function logError(message: string, error?: any): void;
21
+ /**
22
+ * Log success message
23
+ * Format: [SUCCESS] [Interactive Tasks] message
24
+ */
25
+ export declare function logSuccess(message: string): void;
26
+ /**
27
+ * Format a file path for logging (with blue underline)
28
+ */
29
+ export declare function formatPath(filePath: string): string;
30
+ /**
31
+ * Format a number for logging (with cyan color)
32
+ */
33
+ export declare function formatNumber(num: number): string;
34
+ /**
35
+ * Format code/identifier for logging (with cyan color)
36
+ */
37
+ export declare function formatCode(code: string): string;
38
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;GAGG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAO3D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * Interactive Tasks Plugin Logger
4
+ * Wraps Docusaurus logger for consistent build-time logging
5
+ * This is for Node.js build-time only (plugins, webpack)
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.logInfo = logInfo;
12
+ exports.logWarn = logWarn;
13
+ exports.logError = logError;
14
+ exports.logSuccess = logSuccess;
15
+ exports.formatPath = formatPath;
16
+ exports.formatNumber = formatNumber;
17
+ exports.formatCode = formatCode;
18
+ const logger_1 = __importDefault(require("@docusaurus/logger"));
19
+ const PLUGIN_PREFIX = "Interactive Tasks";
20
+ /**
21
+ * Log info message
22
+ * Format: [INFO] [Interactive Tasks] message
23
+ */
24
+ function logInfo(message) {
25
+ logger_1.default.info `[${PLUGIN_PREFIX}] ${message}`;
26
+ }
27
+ /**
28
+ * Log warning message
29
+ * Format: [WARNING] [Interactive Tasks] message
30
+ */
31
+ function logWarn(message) {
32
+ logger_1.default.warn `[${PLUGIN_PREFIX}] ${message}`;
33
+ }
34
+ /**
35
+ * Log error message
36
+ * Format: [ERROR] [Interactive Tasks] message
37
+ */
38
+ function logError(message, error) {
39
+ if (error) {
40
+ logger_1.default.error `[${PLUGIN_PREFIX}] ${message}`;
41
+ console.error(error);
42
+ }
43
+ else {
44
+ logger_1.default.error `[${PLUGIN_PREFIX}] ${message}`;
45
+ }
46
+ }
47
+ /**
48
+ * Log success message
49
+ * Format: [SUCCESS] [Interactive Tasks] message
50
+ */
51
+ function logSuccess(message) {
52
+ logger_1.default.success `[${PLUGIN_PREFIX}] ${message}`;
53
+ }
54
+ /**
55
+ * Format a file path for logging (with blue underline)
56
+ */
57
+ function formatPath(filePath) {
58
+ return logger_1.default.path(filePath);
59
+ }
60
+ /**
61
+ * Format a number for logging (with cyan color)
62
+ */
63
+ function formatNumber(num) {
64
+ return logger_1.default.cyan(num);
65
+ }
66
+ /**
67
+ * Format code/identifier for logging (with cyan color)
68
+ */
69
+ function formatCode(code) {
70
+ return logger_1.default.code(code);
71
+ }
72
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AAUH,0BAEC;AAMD,0BAEC;AAMD,4BAOC;AAMD,gCAEC;AAKD,gCAEC;AAKD,oCAEC;AAKD,gCAEC;AA5DD,gEAAwC;AAExC,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,gBAAM,CAAC,IAAI,CAAA,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,gBAAM,CAAC,IAAI,CAAA,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,OAAe,EAAE,KAAW;IACnD,IAAI,KAAK,EAAE,CAAC;QACV,gBAAM,CAAC,KAAK,CAAA,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;QAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,gBAAM,CAAC,KAAK,CAAA,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU,CAAC,OAAe;IACxC,gBAAM,CAAC,OAAO,CAAA,IAAI,aAAa,KAAK,OAAO,EAAE,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,QAAgB;IACzC,OAAO,gBAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,gBAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Storage utilities for task persistence
3
+ */
4
+ import type { TasksState } from "../contexts/TaskContext";
5
+ /**
6
+ * Check if we're in a browser environment
7
+ */
8
+ export declare function isBrowser(): boolean;
9
+ /**
10
+ * Load tasks from localStorage
11
+ */
12
+ export declare function loadTasksFromStorage(): TasksState;
13
+ /**
14
+ * Save tasks to localStorage
15
+ */
16
+ export declare function saveTasksToStorage(tasks: TasksState): void;
17
+ /**
18
+ * Load auto-collapse preference from localStorage
19
+ */
20
+ export declare function loadAutoCollapseFromStorage(): boolean;
21
+ /**
22
+ * Save auto-collapse preference to localStorage
23
+ */
24
+ export declare function saveAutoCollapseToStorage(autoCollapse: boolean): void;
25
+ /**
26
+ * Generate a task key for storage
27
+ * Format: task-{pluginId}-{docId}-{taskNumber}-{encodedName}
28
+ *
29
+ * Encodes the task name to be URL-safe and consistent with the task registry.
30
+ * Special characters are replaced with dashes to ensure compatibility.
31
+ */
32
+ export declare function generateTaskKey(pluginId?: string, docId?: string, taskNumber?: number, name?: string): string;
33
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAK1D;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAInC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,UAAU,CAkBjD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAa1D;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAerD;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAarE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAeR"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Storage utilities for task persistence
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isBrowser = isBrowser;
7
+ exports.loadTasksFromStorage = loadTasksFromStorage;
8
+ exports.saveTasksToStorage = saveTasksToStorage;
9
+ exports.loadAutoCollapseFromStorage = loadAutoCollapseFromStorage;
10
+ exports.saveAutoCollapseToStorage = saveAutoCollapseToStorage;
11
+ exports.generateTaskKey = generateTaskKey;
12
+ const STORAGE_KEY = "sp-tasks";
13
+ const AUTO_COLLAPSE_KEY = "autoCollapseCompletedTasks";
14
+ /**
15
+ * Check if we're in a browser environment
16
+ */
17
+ function isBrowser() {
18
+ return (typeof window !== "undefined" && typeof window.localStorage !== "undefined");
19
+ }
20
+ /**
21
+ * Load tasks from localStorage
22
+ */
23
+ function loadTasksFromStorage() {
24
+ if (!isBrowser()) {
25
+ return {};
26
+ }
27
+ try {
28
+ const stored = localStorage.getItem(STORAGE_KEY);
29
+ if (stored) {
30
+ return JSON.parse(stored);
31
+ }
32
+ return {};
33
+ }
34
+ catch (error) {
35
+ console.error("[Interactive Tasks] Failed to load tasks from storage:", error);
36
+ return {};
37
+ }
38
+ }
39
+ /**
40
+ * Save tasks to localStorage
41
+ */
42
+ function saveTasksToStorage(tasks) {
43
+ if (!isBrowser()) {
44
+ return;
45
+ }
46
+ try {
47
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(tasks));
48
+ }
49
+ catch (error) {
50
+ console.error("[Interactive Tasks] Failed to save tasks to storage:", error);
51
+ }
52
+ }
53
+ /**
54
+ * Load auto-collapse preference from localStorage
55
+ */
56
+ function loadAutoCollapseFromStorage() {
57
+ if (!isBrowser()) {
58
+ return false;
59
+ }
60
+ try {
61
+ const stored = localStorage.getItem(AUTO_COLLAPSE_KEY);
62
+ return stored === "true";
63
+ }
64
+ catch (error) {
65
+ console.error("[Interactive Tasks] Failed to load auto-collapse preference:", error);
66
+ return false;
67
+ }
68
+ }
69
+ /**
70
+ * Save auto-collapse preference to localStorage
71
+ */
72
+ function saveAutoCollapseToStorage(autoCollapse) {
73
+ if (!isBrowser()) {
74
+ return;
75
+ }
76
+ try {
77
+ localStorage.setItem(AUTO_COLLAPSE_KEY, String(autoCollapse));
78
+ }
79
+ catch (error) {
80
+ console.error("[Interactive Tasks] Failed to save auto-collapse preference:", error);
81
+ }
82
+ }
83
+ /**
84
+ * Generate a task key for storage
85
+ * Format: task-{pluginId}-{docId}-{taskNumber}-{encodedName}
86
+ *
87
+ * Encodes the task name to be URL-safe and consistent with the task registry.
88
+ * Special characters are replaced with dashes to ensure compatibility.
89
+ */
90
+ function generateTaskKey(pluginId, docId, taskNumber, name) {
91
+ // Convert name to a URL-safe slug: lowercase, replace spaces and special chars with dashes
92
+ const encodedName = name
93
+ ? name
94
+ .toLowerCase()
95
+ .replace(/\s+/g, "-") // Replace spaces with dashes
96
+ .replace(/[^a-z0-9-]/g, "-") // Replace special chars with dashes
97
+ .replace(/-+/g, "-") // Collapse multiple dashes
98
+ .replace(/^-|-$/g, "") // Remove leading/trailing dashes
99
+ : "unnamed";
100
+ const pluginStr = pluginId || "unknown";
101
+ const docStr = docId || "unknown";
102
+ const taskStr = taskNumber !== undefined ? taskNumber : "unknown";
103
+ return `task-${pluginStr}-${docStr}-${taskStr}-${encodedName}`;
104
+ }
105
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAUH,8BAIC;AAKD,oDAkBC;AAKD,gDAaC;AAKD,kEAeC;AAKD,8DAaC;AASD,0CAoBC;AAtHD,MAAM,WAAW,GAAG,UAAU,CAAC;AAC/B,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;AAEvD;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,CACL,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,WAAW,CAC5E,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB;IAClC,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,wDAAwD,EACxD,KAAK,CACN,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAiB;IAClD,IAAI,CAAC,SAA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AAa,EAAE,GAAG,CAAC,CAAC,oCAAoC;aAChE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,2BAA2B;aAC/C,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,iCAAiC;QAC5D,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,SAAS,GAAG,QAAQ,IAAI,SAAS,CAAC;IACxC,MAAM,MAAM,GAAG,KAAK,IAAI,SAAS,CAAC;IAClC,MAAM,OAAO,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAClE,OAAO,QAAQ,SAAS,IAAI,MAAM,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Custom hook for getting task statistics for a specific document
3
+ * Combines data from task registry (metadata) and task context (completion states)
4
+ */
5
+ import type { BadgeConfig } from "../contexts/TaskContext";
6
+ export interface DocTaskStats {
7
+ /** Total number of tasks in this doc */
8
+ totalTasks: number;
9
+ /** Number of completed tasks */
10
+ completedTasks: number;
11
+ /** Whether this doc has a custom section name */
12
+ hasSectionName: boolean;
13
+ /** The section name (e.g., "Module 1") or falls back to title */
14
+ sectionName: string;
15
+ /** The document title */
16
+ title: string;
17
+ /** The permalink to this doc */
18
+ permalink: string;
19
+ /** Completion percentage (0-100) */
20
+ percentage: number;
21
+ /** Whether all tasks are completed */
22
+ isComplete: boolean;
23
+ /** Whether this doc has any tasks at all */
24
+ hasAnyTasks: boolean;
25
+ /** Badge customization configuration */
26
+ badgeConfig?: BadgeConfig;
27
+ }
28
+ /**
29
+ * Get task statistics for a specific document
30
+ *
31
+ * @param docId - The document ID (e.g., "module1", "tutorial-basics/create-a-page")
32
+ * @param pluginId - The docs plugin instance ID (default: "default")
33
+ * @returns Task statistics or null if doc not found or has no tasks
34
+ *
35
+ * @example
36
+ * const stats = useDocTaskStats("module1", "default");
37
+ * if (stats?.hasAnyTasks) {
38
+ * return <Badge>{stats.completedTasks}/{stats.totalTasks}</Badge>;
39
+ * }
40
+ */
41
+ export declare function useDocTaskStats(docId: string | undefined, pluginId?: string): DocTaskStats | null;
42
+ /**
43
+ * Aggregate task statistics for multiple documents (e.g., category children)
44
+ *
45
+ * @param docIds - Array of document IDs
46
+ * @param pluginId - The docs plugin instance ID (default: "default")
47
+ * @param customProps - Optional customProps from sidebar item for badge configuration
48
+ * @returns Aggregated statistics or null if no tasks found
49
+ *
50
+ * @example
51
+ * const categoryStats = useCategoryTaskStats(
52
+ * categoryItem.items.map(item => item.docId),
53
+ * "default",
54
+ * categoryItem.customProps
55
+ * );
56
+ */
57
+ export declare function useCategoryTaskStats(docIds: (string | undefined)[], pluginId?: string, customProps?: Record<string, any>): Pick<DocTaskStats, "totalTasks" | "completedTasks" | "percentage" | "isComplete" | "hasAnyTasks" | "badgeConfig"> | null;
58
+ //# sourceMappingURL=useDocTaskStats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocTaskStats.d.ts","sourceRoot":"","sources":["../../src/utils/useDocTaskStats.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAoB3D,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,cAAc,EAAE,OAAO,CAAC;IACxB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,WAAW,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,GAAE,MAAkB,GAC3B,YAAY,GAAG,IAAI,CAsDrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAC9B,QAAQ,GAAE,MAAkB,EAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,IAAI,CACL,YAAY,EACV,YAAY,GACZ,gBAAgB,GAChB,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,aAAa,CAChB,GAAG,IAAI,CAgIP"}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ /**
3
+ * Custom hook for getting task statistics for a specific document
4
+ * Combines data from task registry (metadata) and task context (completion states)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useDocTaskStats = useDocTaskStats;
8
+ exports.useCategoryTaskStats = useCategoryTaskStats;
9
+ const react_1 = require("react");
10
+ const TaskProvider_1 = require("../theme/TaskProvider");
11
+ /**
12
+ * Safe version of useTaskContext that returns null if provider is not available
13
+ * This is needed for sidebar components that may render outside the TaskProvider
14
+ * (though after our fix, this should always have context available)
15
+ */
16
+ function useSafeTaskContext() {
17
+ try {
18
+ return (0, TaskProvider_1.useTaskContext)();
19
+ }
20
+ catch (error) {
21
+ if (typeof window !== "undefined") {
22
+ console.warn("[Interactive Tasks] TaskContext not available in component. This may indicate a configuration issue.");
23
+ }
24
+ return null;
25
+ }
26
+ }
27
+ /**
28
+ * Get task statistics for a specific document
29
+ *
30
+ * @param docId - The document ID (e.g., "module1", "tutorial-basics/create-a-page")
31
+ * @param pluginId - The docs plugin instance ID (default: "default")
32
+ * @returns Task statistics or null if doc not found or has no tasks
33
+ *
34
+ * @example
35
+ * const stats = useDocTaskStats("module1", "default");
36
+ * if (stats?.hasAnyTasks) {
37
+ * return <Badge>{stats.completedTasks}/{stats.totalTasks}</Badge>;
38
+ * }
39
+ */
40
+ function useDocTaskStats(docId, pluginId = "default") {
41
+ const contextResult = useSafeTaskContext();
42
+ const { tasks, taskRegistry } = contextResult || {
43
+ tasks: {},
44
+ taskRegistry: null,
45
+ };
46
+ return (0, react_1.useMemo)(() => {
47
+ // Early returns inside useMemo are safe - they don't violate Rules of Hooks
48
+ // No context or no docId - return null
49
+ if (!contextResult || !docId) {
50
+ return null;
51
+ }
52
+ // Registry not loaded yet - return null
53
+ // This is expected during initial mount while registry loads
54
+ if (!taskRegistry) {
55
+ return null;
56
+ }
57
+ // Build the registry key: "pluginId/docId"
58
+ const docKey = `${pluginId}/${docId}`;
59
+ const docInfo = taskRegistry.docPages[docKey];
60
+ // Doc doesn't exist or has no tasks
61
+ if (!docInfo || docInfo.totalTasks === 0) {
62
+ return null;
63
+ }
64
+ // Count completed tasks
65
+ const taskKeys = Object.keys(docInfo.tasks);
66
+ const completedCount = taskKeys.filter((taskKey) => tasks[taskKey]?.completed).length;
67
+ const percentage = docInfo.totalTasks > 0
68
+ ? Math.round((completedCount / docInfo.totalTasks) * 100)
69
+ : 0;
70
+ return {
71
+ totalTasks: docInfo.totalTasks,
72
+ completedTasks: completedCount,
73
+ hasSectionName: docInfo.sectionName !== docInfo.title,
74
+ sectionName: docInfo.sectionName,
75
+ title: docInfo.title,
76
+ permalink: docInfo.permalink,
77
+ percentage,
78
+ isComplete: completedCount === docInfo.totalTasks,
79
+ hasAnyTasks: true,
80
+ badgeConfig: docInfo.badgeConfig,
81
+ };
82
+ }, [docId, pluginId, tasks, taskRegistry]);
83
+ }
84
+ /**
85
+ * Aggregate task statistics for multiple documents (e.g., category children)
86
+ *
87
+ * @param docIds - Array of document IDs
88
+ * @param pluginId - The docs plugin instance ID (default: "default")
89
+ * @param customProps - Optional customProps from sidebar item for badge configuration
90
+ * @returns Aggregated statistics or null if no tasks found
91
+ *
92
+ * @example
93
+ * const categoryStats = useCategoryTaskStats(
94
+ * categoryItem.items.map(item => item.docId),
95
+ * "default",
96
+ * categoryItem.customProps
97
+ * );
98
+ */
99
+ function useCategoryTaskStats(docIds, pluginId = "default", customProps) {
100
+ const contextResult = useSafeTaskContext();
101
+ const { tasks, taskRegistry } = contextResult || {
102
+ tasks: {},
103
+ taskRegistry: null,
104
+ };
105
+ return (0, react_1.useMemo)(() => {
106
+ // Early returns inside useMemo are safe
107
+ if (!taskRegistry || docIds.length === 0) {
108
+ return null;
109
+ }
110
+ // TODO: Remove after debugging - Log category stats calculation
111
+ console.log("[Interactive Tasks] useCategoryTaskStats called:", {
112
+ docIdsCount: docIds.length,
113
+ pluginId,
114
+ hasCustomProps: !!customProps,
115
+ customProps,
116
+ });
117
+ let totalTasks = 0;
118
+ let completedTasks = 0;
119
+ // Aggregate stats from all child docs
120
+ docIds.forEach((docId) => {
121
+ if (!docId)
122
+ return;
123
+ const docKey = `${pluginId}/${docId}`;
124
+ const docInfo = taskRegistry.docPages[docKey];
125
+ if (docInfo) {
126
+ totalTasks += docInfo.totalTasks;
127
+ // Count completed tasks for this doc
128
+ Object.keys(docInfo.tasks).forEach((taskKey) => {
129
+ if (tasks[taskKey]?.completed) {
130
+ completedTasks++;
131
+ }
132
+ });
133
+ }
134
+ });
135
+ // No tasks found in any child
136
+ if (totalTasks === 0) {
137
+ // TODO: Remove after debugging
138
+ console.log("[Interactive Tasks] No tasks found in category children");
139
+ return null;
140
+ }
141
+ const percentage = Math.round((completedTasks / totalTasks) * 100);
142
+ // Extract badge config from customProps if provided
143
+ let badgeConfig;
144
+ if (customProps) {
145
+ const config = {};
146
+ let hasConfig = false;
147
+ if (customProps.sidebar_task_hide_progress !== undefined) {
148
+ config.hide = Boolean(customProps.sidebar_task_hide_progress);
149
+ hasConfig = true;
150
+ }
151
+ if (customProps.sidebar_task_disable_icon !== undefined) {
152
+ config.disableIcon = Boolean(customProps.sidebar_task_disable_icon);
153
+ hasConfig = true;
154
+ }
155
+ if (customProps.sidebar_task_badge_colors) {
156
+ const colors = customProps.sidebar_task_badge_colors;
157
+ config.colors = {};
158
+ if (colors.completed) {
159
+ config.colors.completed = {
160
+ lightmode: colors.completed.lightmode
161
+ ? String(colors.completed.lightmode)
162
+ : undefined,
163
+ darkmode: colors.completed.darkmode
164
+ ? String(colors.completed.darkmode)
165
+ : undefined,
166
+ };
167
+ hasConfig = true;
168
+ }
169
+ if (colors.incomplete) {
170
+ config.colors.incomplete = {
171
+ lightmode: colors.incomplete.lightmode
172
+ ? String(colors.incomplete.lightmode)
173
+ : undefined,
174
+ darkmode: colors.incomplete.darkmode
175
+ ? String(colors.incomplete.darkmode)
176
+ : undefined,
177
+ };
178
+ hasConfig = true;
179
+ }
180
+ if (colors.font) {
181
+ config.colors.font = {
182
+ lightmode: colors.font.lightmode
183
+ ? String(colors.font.lightmode)
184
+ : undefined,
185
+ darkmode: colors.font.darkmode
186
+ ? String(colors.font.darkmode)
187
+ : undefined,
188
+ };
189
+ hasConfig = true;
190
+ }
191
+ }
192
+ badgeConfig = hasConfig ? config : undefined;
193
+ // TODO: Remove after debugging
194
+ console.log("[Interactive Tasks] Extracted badge config from customProps:", badgeConfig);
195
+ }
196
+ return {
197
+ totalTasks,
198
+ completedTasks,
199
+ percentage,
200
+ isComplete: completedTasks === totalTasks,
201
+ hasAnyTasks: true,
202
+ badgeConfig,
203
+ };
204
+ }, [docIds, pluginId, customProps, tasks, taskRegistry]);
205
+ }
206
+ //# sourceMappingURL=useDocTaskStats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocTaskStats.js","sourceRoot":"","sources":["../../src/utils/useDocTaskStats.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AA4DH,0CAyDC;AAiBD,oDA4IC;AAhRD,iCAAgC;AAChC,wDAAuD;AAGvD;;;;GAIG;AACH,SAAS,kBAAkB;IACzB,IAAI,CAAC;QACH,OAAO,IAAA,6BAAc,GAAE,CAAC;IAC1B,CAAC;IAAC,OAAO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GAAG;wBACnB,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS;4BAC9B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;4BAC/B,CAAC,CAAC,SAAS;wBACb,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ;4BAC5B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;4BAC9B,CAAC,CAAC,SAAS;qBACd,CAAC;oBACF,SAAS,GAAG,IAAI,CAAC;gBACnB,CAAC;YACH,CAAC;YAED,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;YAE7C,+BAA+B;YAC/B,OAAO,CAAC,GAAG,CACT,8DAA8D,EAC9D,WAAW,CACZ,CAAC;QACJ,CAAC;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,UAAU;YACV,UAAU,EAAE,cAAc,KAAK,UAAU;YACzC,WAAW,EAAE,IAAI;YACjB,WAAW;SACZ,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Utility hook to reliably get the current plugin ID
3
+ * Uses Docusaurus internal APIs to determine which docs plugin instance
4
+ * the current page belongs to
5
+ */
6
+ /**
7
+ * Get the plugin ID for the current documentation page
8
+ *
9
+ * This hook dynamically discovers all docs plugin instances and determines
10
+ * which one the current page belongs to by checking the active doc context.
11
+ *
12
+ * @param fallbackPluginId - Plugin ID to use if detection fails (default: 'default')
13
+ * @returns The detected plugin ID or the fallback
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * const pluginId = usePluginId();
18
+ * // On a page in the 'course' docs instance, returns 'course'
19
+ * // On a page in the 'resources' docs instance, returns 'resources'
20
+ * // Falls back to 'default' if cannot be determined
21
+ * ```
22
+ */
23
+ export declare function usePluginId(fallbackPluginId?: string): string;
24
+ //# sourceMappingURL=usePluginId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePluginId.d.ts","sourceRoot":"","sources":["../../src/utils/usePluginId.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,gBAAgB,GAAE,MAAkB,GAAG,MAAM,CAoCxE"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Utility hook to reliably get the current plugin ID
4
+ * Uses Docusaurus internal APIs to determine which docs plugin instance
5
+ * the current page belongs to
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.usePluginId = usePluginId;
9
+ const client_1 = require("@docusaurus/plugin-content-docs/client");
10
+ const useGlobalData_1 = require("@docusaurus/useGlobalData");
11
+ /**
12
+ * Get the plugin ID for the current documentation page
13
+ *
14
+ * This hook dynamically discovers all docs plugin instances and determines
15
+ * which one the current page belongs to by checking the active doc context.
16
+ *
17
+ * @param fallbackPluginId - Plugin ID to use if detection fails (default: 'default')
18
+ * @returns The detected plugin ID or the fallback
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const pluginId = usePluginId();
23
+ * // On a page in the 'course' docs instance, returns 'course'
24
+ * // On a page in the 'resources' docs instance, returns 'resources'
25
+ * // Falls back to 'default' if cannot be determined
26
+ * ```
27
+ */
28
+ function usePluginId(fallbackPluginId = "default") {
29
+ try {
30
+ // Get all instances of the docs plugin
31
+ const allDocsData = (0, useGlobalData_1.useAllPluginInstancesData)("docusaurus-plugin-content-docs");
32
+ // Extract plugin IDs from the global data
33
+ const pluginIds = Object.keys(allDocsData || {});
34
+ // If no plugin instances found, use fallback
35
+ if (pluginIds.length === 0) {
36
+ return fallbackPluginId;
37
+ }
38
+ // Try each plugin instance to find which one has the active doc
39
+ for (const id of pluginIds) {
40
+ try {
41
+ const context = (0, client_1.useActiveDocContext)(id);
42
+ // If this context has an active doc, this is our plugin
43
+ if (context?.activeDoc) {
44
+ return id;
45
+ }
46
+ }
47
+ catch (e) {
48
+ // This plugin instance doesn't have an active doc, continue
49
+ continue;
50
+ }
51
+ }
52
+ // If no active context found, use fallback
53
+ return fallbackPluginId;
54
+ }
55
+ catch (e) {
56
+ // If hook isn't available (shouldn't happen), use fallback
57
+ console.warn("[Interactive Tasks] Failed to detect pluginId:", e);
58
+ return fallbackPluginId;
59
+ }
60
+ }
61
+ //# sourceMappingURL=usePluginId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePluginId.js","sourceRoot":"","sources":["../../src/utils/usePluginId.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAsBH,kCAoCC;AAxDD,mEAA6E;AAC7E,6DAAsE;AAEtE;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,WAAW,CAAC,mBAA2B,SAAS;IAC9D,IAAI,CAAC;QACH,uCAAuC;QACvC,MAAM,WAAW,GAAG,IAAA,yCAAyB,EAC3C,gCAAgC,CACjC,CAAC;QAEF,0CAA0C;QAC1C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAEjD,6CAA6C;QAC7C,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QAED,gEAAgE;QAChE,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,IAAA,4BAAmB,EAAC,EAAE,CAAC,CAAC;gBACxC,wDAAwD;gBACxD,IAAI,OAAO,EAAE,SAAS,EAAE,CAAC;oBACvB,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,4DAA4D;gBAC5D,SAAS;YACX,CAAC;QACH,CAAC;QAED,2CAA2C;QAC3C,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,2DAA2D;QAC3D,OAAO,CAAC,IAAI,CAAC,gDAAgD,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;AACH,CAAC"}