@real1ty-obsidian-plugins/utils 2.2.3 → 2.4.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 (152) hide show
  1. package/README.md +29 -9
  2. package/dist/{async-utils.d.ts → async/async.d.ts} +1 -1
  3. package/dist/async/async.d.ts.map +1 -0
  4. package/dist/{async-utils.js → async/async.js} +1 -1
  5. package/dist/async/async.js.map +1 -0
  6. package/dist/async/batch-operations.d.ts.map +1 -0
  7. package/dist/async/batch-operations.js.map +1 -0
  8. package/dist/async/index.d.ts +3 -0
  9. package/dist/async/index.d.ts.map +1 -0
  10. package/dist/async/index.js +3 -0
  11. package/dist/async/index.js.map +1 -0
  12. package/dist/core/evaluator-base.d.ts.map +1 -0
  13. package/dist/core/evaluator-base.js.map +1 -0
  14. package/dist/core/generate.d.ts.map +1 -0
  15. package/dist/core/generate.js.map +1 -0
  16. package/dist/core/index.d.ts +3 -0
  17. package/dist/core/index.d.ts.map +1 -0
  18. package/dist/core/index.js +3 -0
  19. package/dist/core/index.js.map +1 -0
  20. package/dist/{date-recurrence-utils.d.ts → date/date-recurrence.d.ts} +1 -1
  21. package/dist/date/date-recurrence.d.ts.map +1 -0
  22. package/dist/{date-recurrence-utils.js → date/date-recurrence.js} +1 -1
  23. package/dist/date/date-recurrence.js.map +1 -0
  24. package/dist/{date-utils.d.ts → date/date.d.ts} +1 -1
  25. package/dist/date/date.d.ts.map +1 -0
  26. package/dist/{date-utils.js → date/date.js} +1 -1
  27. package/dist/date/date.js.map +1 -0
  28. package/dist/date/index.d.ts +3 -0
  29. package/dist/date/index.d.ts.map +1 -0
  30. package/dist/date/index.js +3 -0
  31. package/dist/date/index.js.map +1 -0
  32. package/dist/{child-reference-utils.d.ts → file/child-reference.d.ts} +1 -1
  33. package/dist/file/child-reference.d.ts.map +1 -0
  34. package/dist/{child-reference-utils.js → file/child-reference.js} +1 -1
  35. package/dist/file/child-reference.js.map +1 -0
  36. package/dist/file/file-operations.d.ts.map +1 -0
  37. package/dist/{file-operations.js → file/file-operations.js} +2 -2
  38. package/dist/file/file-operations.js.map +1 -0
  39. package/dist/file/file.d.ts +263 -0
  40. package/dist/file/file.d.ts.map +1 -0
  41. package/dist/file/file.js +466 -0
  42. package/dist/file/file.js.map +1 -0
  43. package/dist/{frontmatter-utils.d.ts → file/frontmatter.d.ts} +1 -1
  44. package/dist/file/frontmatter.d.ts.map +1 -0
  45. package/dist/{frontmatter-utils.js → file/frontmatter.js} +1 -1
  46. package/dist/file/frontmatter.js.map +1 -0
  47. package/dist/file/index.d.ts +7 -0
  48. package/dist/file/index.d.ts.map +1 -0
  49. package/dist/file/index.js +7 -0
  50. package/dist/file/index.js.map +1 -0
  51. package/dist/file/link-parser.d.ts.map +1 -0
  52. package/dist/file/link-parser.js.map +1 -0
  53. package/dist/{templater-utils.d.ts → file/templater.d.ts} +1 -1
  54. package/dist/file/templater.d.ts.map +1 -0
  55. package/dist/{templater-utils.js → file/templater.js} +1 -1
  56. package/dist/file/templater.js.map +1 -0
  57. package/dist/index.d.ts +6 -15
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +12 -15
  60. package/dist/index.js.map +1 -1
  61. package/dist/settings/index.d.ts +3 -0
  62. package/dist/settings/index.d.ts.map +1 -0
  63. package/dist/settings/index.js +3 -0
  64. package/dist/settings/index.js.map +1 -0
  65. package/dist/settings/settings-store.d.ts.map +1 -0
  66. package/dist/settings/settings-store.js.map +1 -0
  67. package/dist/settings/settings-ui-builder.d.ts.map +1 -0
  68. package/dist/settings/settings-ui-builder.js.map +1 -0
  69. package/dist/string/index.d.ts +2 -0
  70. package/dist/string/index.d.ts.map +1 -0
  71. package/dist/string/index.js +2 -0
  72. package/dist/string/index.js.map +1 -0
  73. package/dist/{string-utils.d.ts → string/string.d.ts} +1 -1
  74. package/dist/string/string.d.ts.map +1 -0
  75. package/dist/{string-utils.js → string/string.js} +1 -1
  76. package/dist/string/string.js.map +1 -0
  77. package/dist/testing/mocks/obsidian.d.ts +1 -0
  78. package/dist/testing/mocks/obsidian.d.ts.map +1 -1
  79. package/dist/testing/mocks/obsidian.js +6 -0
  80. package/dist/testing/mocks/obsidian.js.map +1 -1
  81. package/package.json +3 -5
  82. package/src/async/async.ts +117 -0
  83. package/src/async/batch-operations.ts +53 -0
  84. package/src/async/index.ts +2 -0
  85. package/src/core/evaluator-base.ts +118 -0
  86. package/src/core/generate.ts +22 -0
  87. package/src/core/index.ts +2 -0
  88. package/src/date/date-recurrence.ts +244 -0
  89. package/src/date/date.ts +111 -0
  90. package/src/date/index.ts +2 -0
  91. package/src/file/child-reference.ts +76 -0
  92. package/src/file/file-operations.ts +197 -0
  93. package/src/file/file.ts +570 -0
  94. package/src/file/frontmatter.ts +80 -0
  95. package/src/file/index.ts +6 -0
  96. package/src/file/link-parser.ts +18 -0
  97. package/src/file/templater.ts +75 -0
  98. package/src/index.ts +14 -0
  99. package/src/settings/index.ts +2 -0
  100. package/src/settings/settings-store.ts +88 -0
  101. package/src/settings/settings-ui-builder.ts +507 -0
  102. package/src/string/index.ts +1 -0
  103. package/src/string/string.ts +26 -0
  104. package/src/testing/index.ts +23 -0
  105. package/src/testing/mocks/obsidian.ts +331 -0
  106. package/src/testing/mocks/utils.ts +113 -0
  107. package/src/testing/setup.ts +19 -0
  108. package/dist/async-utils.d.ts.map +0 -1
  109. package/dist/async-utils.js.map +0 -1
  110. package/dist/batch-operations.d.ts.map +0 -1
  111. package/dist/batch-operations.js.map +0 -1
  112. package/dist/child-reference-utils.d.ts.map +0 -1
  113. package/dist/child-reference-utils.js.map +0 -1
  114. package/dist/date-recurrence-utils.d.ts.map +0 -1
  115. package/dist/date-recurrence-utils.js.map +0 -1
  116. package/dist/date-utils.d.ts.map +0 -1
  117. package/dist/date-utils.js.map +0 -1
  118. package/dist/evaluator-base.d.ts.map +0 -1
  119. package/dist/evaluator-base.js.map +0 -1
  120. package/dist/file-operations.d.ts.map +0 -1
  121. package/dist/file-operations.js.map +0 -1
  122. package/dist/file-utils.d.ts +0 -6
  123. package/dist/file-utils.d.ts.map +0 -1
  124. package/dist/file-utils.js +0 -25
  125. package/dist/file-utils.js.map +0 -1
  126. package/dist/frontmatter-utils.d.ts.map +0 -1
  127. package/dist/frontmatter-utils.js.map +0 -1
  128. package/dist/generate.d.ts.map +0 -1
  129. package/dist/generate.js.map +0 -1
  130. package/dist/link-parser.d.ts.map +0 -1
  131. package/dist/link-parser.js.map +0 -1
  132. package/dist/settings-store.d.ts.map +0 -1
  133. package/dist/settings-store.js.map +0 -1
  134. package/dist/settings-ui-builder.d.ts.map +0 -1
  135. package/dist/settings-ui-builder.js.map +0 -1
  136. package/dist/string-utils.d.ts.map +0 -1
  137. package/dist/string-utils.js.map +0 -1
  138. package/dist/templater-utils.d.ts.map +0 -1
  139. package/dist/templater-utils.js.map +0 -1
  140. /package/dist/{batch-operations.d.ts → async/batch-operations.d.ts} +0 -0
  141. /package/dist/{batch-operations.js → async/batch-operations.js} +0 -0
  142. /package/dist/{evaluator-base.d.ts → core/evaluator-base.d.ts} +0 -0
  143. /package/dist/{evaluator-base.js → core/evaluator-base.js} +0 -0
  144. /package/dist/{generate.d.ts → core/generate.d.ts} +0 -0
  145. /package/dist/{generate.js → core/generate.js} +0 -0
  146. /package/dist/{file-operations.d.ts → file/file-operations.d.ts} +0 -0
  147. /package/dist/{link-parser.d.ts → file/link-parser.d.ts} +0 -0
  148. /package/dist/{link-parser.js → file/link-parser.js} +0 -0
  149. /package/dist/{settings-store.d.ts → settings/settings-store.d.ts} +0 -0
  150. /package/dist/{settings-store.js → settings/settings-store.js} +0 -0
  151. /package/dist/{settings-ui-builder.d.ts → settings/settings-ui-builder.d.ts} +0 -0
  152. /package/dist/{settings-ui-builder.js → settings/settings-ui-builder.js} +0 -0
@@ -0,0 +1,26 @@
1
+ export const capitalize = (str: string): string => {
2
+ if (!str) return str;
3
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
4
+ };
5
+
6
+ export const generateDuplicatedTitle = (originalTitle: string): string => {
7
+ // Check if title already has a counter pattern like " (2)", " - Copy", etc.
8
+ const counterMatch = originalTitle.match(/^(.*?)(?:\s*\((\d+)\)|\s*-?\s*Copy(?:\s*(\d+))?)$/);
9
+
10
+ if (counterMatch) {
11
+ const baseName = counterMatch[1];
12
+ const existingCounter = counterMatch[2] || counterMatch[3];
13
+ const nextCounter = existingCounter ? parseInt(existingCounter, 10) + 1 : 2;
14
+ return `${baseName} (${nextCounter})`;
15
+ } else {
16
+ return `${originalTitle} (2)`;
17
+ }
18
+ };
19
+
20
+ export const pluralize = (count: number): string => {
21
+ return count === 1 ? "" : "s";
22
+ };
23
+
24
+ export const getWeekDirection = (weeks: number): "next" | "previous" => {
25
+ return weeks > 0 ? "next" : "previous";
26
+ };
@@ -0,0 +1,23 @@
1
+ export * from "./mocks/obsidian";
2
+ // Re-export commonly used combinations
3
+ export {
4
+ createMockApp,
5
+ createMockFile,
6
+ createMockFileCache,
7
+ Modal,
8
+ Notice,
9
+ Plugin,
10
+ PluginSettingTab,
11
+ Setting,
12
+ TFile,
13
+ } from "./mocks/obsidian";
14
+ export * from "./mocks/utils";
15
+ export {
16
+ mockFileOperations,
17
+ mockLinkParser,
18
+ resetAllMocks,
19
+ setupDefaultMockImplementations,
20
+ setupMockImplementation,
21
+ setupMockReturnValue,
22
+ verifyMockCalls,
23
+ } from "./mocks/utils";
@@ -0,0 +1,331 @@
1
+ import { vi } from "vitest";
2
+
3
+ // Base Plugin class mock
4
+ export class Plugin {
5
+ app: any;
6
+ manifest: any;
7
+ settings: any;
8
+
9
+ constructor(app: any, manifest: any) {
10
+ this.app = app;
11
+ this.manifest = manifest;
12
+ }
13
+
14
+ // Core plugin methods
15
+ addSettingTab = vi.fn();
16
+ registerEvent = vi.fn();
17
+ loadData = vi.fn().mockResolvedValue({});
18
+ saveData = vi.fn().mockResolvedValue(undefined);
19
+ onload = vi.fn();
20
+ onunload = vi.fn();
21
+
22
+ // UI methods
23
+ addRibbonIcon = vi.fn();
24
+ addStatusBarItem = vi.fn();
25
+ addCommand = vi.fn();
26
+ removeCommand = vi.fn();
27
+
28
+ // Event methods
29
+ registerDomEvent = vi.fn();
30
+ registerCodeMirror = vi.fn();
31
+ registerEditorExtension = vi.fn();
32
+ registerMarkdownPostProcessor = vi.fn();
33
+ registerMarkdownCodeBlockProcessor = vi.fn();
34
+ registerObsidianProtocolHandler = vi.fn();
35
+ registerEditorSuggest = vi.fn();
36
+ registerHoverLinkSource = vi.fn();
37
+
38
+ // Interval methods
39
+ registerInterval = vi.fn();
40
+
41
+ // View and extension methods
42
+ registerView = vi.fn();
43
+ registerExtensions = vi.fn();
44
+
45
+ // Lifecycle methods
46
+ onUserEnable = vi.fn();
47
+ load = vi.fn();
48
+ unload = vi.fn();
49
+
50
+ // Other methods
51
+ addChild = vi.fn();
52
+ removeChild = vi.fn();
53
+ register = vi.fn();
54
+ }
55
+
56
+ // PluginSettingTab mock
57
+ export class PluginSettingTab {
58
+ app: any;
59
+ plugin: any;
60
+ containerEl: HTMLElement;
61
+
62
+ constructor(app: any, plugin: any) {
63
+ this.app = app;
64
+ this.plugin = plugin;
65
+ this.containerEl = document.createElement("div");
66
+ }
67
+
68
+ display = vi.fn();
69
+ }
70
+
71
+ // ItemView mock
72
+ export class ItemView {
73
+ app: any;
74
+ leaf: any;
75
+ containerEl: HTMLElement;
76
+
77
+ constructor(leaf: any) {
78
+ this.leaf = leaf;
79
+ this.app = leaf?.app;
80
+ this.containerEl = document.createElement("div");
81
+ }
82
+
83
+ // Don't override onOpen/onClose - let subclasses implement them
84
+ // These methods are implemented by MountableView mixin
85
+
86
+ // Don't provide default implementations for these methods
87
+ // Let subclasses implement them
88
+ getViewType(): string {
89
+ return "mock-view";
90
+ }
91
+
92
+ getDisplayText(): string {
93
+ return "Mock View";
94
+ }
95
+
96
+ getIcon(): string {
97
+ return "mock-icon";
98
+ }
99
+
100
+ getState = vi.fn().mockReturnValue({});
101
+ setState = vi.fn().mockResolvedValue(undefined);
102
+ }
103
+
104
+ // Setting component mock
105
+ export class Setting {
106
+ settingEl: HTMLElement;
107
+ nameEl: HTMLElement;
108
+ descEl: HTMLElement;
109
+ controlEl: HTMLElement;
110
+
111
+ constructor(_containerEl: HTMLElement) {
112
+ this.settingEl = document.createElement("div");
113
+ this.nameEl = document.createElement("div");
114
+ this.descEl = document.createElement("div");
115
+ this.controlEl = document.createElement("div");
116
+ }
117
+
118
+ setName = vi.fn().mockReturnThis();
119
+ setDesc = vi.fn().mockReturnThis();
120
+ addText = vi.fn().mockReturnThis();
121
+ addTextArea = vi.fn().mockReturnThis();
122
+ }
123
+
124
+ // TFolder mock
125
+ export class TFolder {
126
+ path: string;
127
+ name: string;
128
+ children: any[];
129
+ vault: any;
130
+ parent: TFolder | null;
131
+
132
+ constructor(path: string) {
133
+ this.path = path;
134
+ this.name = path.split("/").pop() || "";
135
+ this.children = [];
136
+ this.vault = {};
137
+ this.parent = null;
138
+ }
139
+
140
+ isRoot(): boolean {
141
+ return this.path === "" || this.path === "/";
142
+ }
143
+ }
144
+
145
+ // TFile mock with full interface
146
+ export class TFile {
147
+ path: string;
148
+ name: string;
149
+ basename: string;
150
+ extension: string;
151
+ stat: any;
152
+ vault: any;
153
+ parent: TFolder | null;
154
+
155
+ constructor(path: string, parentPath?: string) {
156
+ this.path = path;
157
+ this.name = path.split("/").pop() || "";
158
+ this.basename = this.name.replace(/\.[^/.]+$/, ""); // Remove extension
159
+ this.extension = path.split(".").pop() || "md";
160
+ this.stat = {};
161
+ this.vault = {};
162
+
163
+ // Set parent based on path or explicit parentPath
164
+ if (parentPath !== undefined) {
165
+ this.parent = parentPath ? new TFolder(parentPath) : null;
166
+ } else {
167
+ // Derive parent from path
168
+ const lastSlash = path.lastIndexOf("/");
169
+ if (lastSlash > 0) {
170
+ this.parent = new TFolder(path.substring(0, lastSlash));
171
+ } else {
172
+ this.parent = null;
173
+ }
174
+ }
175
+ }
176
+ }
177
+
178
+ // Modal mock
179
+ export class Modal {
180
+ app: any;
181
+ containerEl: HTMLElement;
182
+ titleEl: HTMLElement;
183
+ contentEl: HTMLElement;
184
+
185
+ constructor(app: any) {
186
+ this.app = app;
187
+ this.containerEl = document.createElement("div");
188
+ this.titleEl = document.createElement("div");
189
+ this.contentEl = document.createElement("div");
190
+ }
191
+
192
+ open = vi.fn();
193
+ close = vi.fn();
194
+ onOpen = vi.fn();
195
+ onClose = vi.fn();
196
+ }
197
+
198
+ // Notice mock
199
+ export class Notice {
200
+ constructor(message: string) {
201
+ console.log(`Notice: ${message}`);
202
+ }
203
+ }
204
+
205
+ // MarkdownRenderer mock
206
+ export const MarkdownRenderer = {
207
+ render: vi.fn().mockResolvedValue(undefined),
208
+ };
209
+
210
+ // Debounce function mock
211
+ export function debounce<T extends (...args: any[]) => any>(
212
+ func: T,
213
+ wait: number,
214
+ immediate?: boolean
215
+ ): T {
216
+ let timeout: ReturnType<typeof setTimeout> | null = null;
217
+
218
+ return ((...args: Parameters<T>) => {
219
+ const later = () => {
220
+ timeout = null;
221
+ if (!immediate) func(...args);
222
+ };
223
+
224
+ const callNow = immediate && !timeout;
225
+
226
+ if (timeout !== null) {
227
+ clearTimeout(timeout);
228
+ }
229
+
230
+ timeout = setTimeout(later, wait);
231
+
232
+ if (callNow) func(...args);
233
+ }) as T;
234
+ }
235
+
236
+ // normalizePath mock - simple path normalization for tests
237
+ export function normalizePath(path: string): string {
238
+ // Basic normalization: replace backslashes with forward slashes
239
+ // and remove duplicate slashes
240
+ return path.replace(/\\/g, "/").replace(/\/+/g, "/");
241
+ }
242
+
243
+ // App mock
244
+ export const App = vi.fn();
245
+
246
+ // Mock interfaces for TypeScript
247
+ export interface MockApp {
248
+ fileManager: {
249
+ processFrontMatter: ReturnType<typeof vi.fn>;
250
+ };
251
+ metadataCache: {
252
+ getFileCache: ReturnType<typeof vi.fn>;
253
+ };
254
+ vault: {
255
+ getAbstractFileByPath: ReturnType<typeof vi.fn>;
256
+ on: ReturnType<typeof vi.fn>;
257
+ read: ReturnType<typeof vi.fn>;
258
+ modify: ReturnType<typeof vi.fn>;
259
+ create: ReturnType<typeof vi.fn>;
260
+ delete: ReturnType<typeof vi.fn>;
261
+ rename: ReturnType<typeof vi.fn>;
262
+ getFiles: ReturnType<typeof vi.fn>;
263
+ getMarkdownFiles: ReturnType<typeof vi.fn>;
264
+ getFolderByPath: ReturnType<typeof vi.fn>;
265
+ };
266
+ workspace: {
267
+ getActiveFile: ReturnType<typeof vi.fn>;
268
+ on: ReturnType<typeof vi.fn>;
269
+ };
270
+ }
271
+
272
+ // Helper function to create a fully mocked app
273
+ export function createMockApp(): MockApp {
274
+ return {
275
+ fileManager: {
276
+ processFrontMatter: vi.fn(),
277
+ },
278
+ metadataCache: {
279
+ getFileCache: vi.fn(),
280
+ },
281
+ vault: {
282
+ getAbstractFileByPath: vi.fn(),
283
+ on: vi.fn(),
284
+ read: vi.fn(),
285
+ modify: vi.fn(),
286
+ create: vi.fn(),
287
+ delete: vi.fn(),
288
+ rename: vi.fn(),
289
+ getFiles: vi.fn().mockReturnValue([]),
290
+ getMarkdownFiles: vi.fn().mockReturnValue([]),
291
+ getFolderByPath: vi.fn(),
292
+ },
293
+ workspace: {
294
+ getActiveFile: vi.fn(),
295
+ on: vi.fn(),
296
+ },
297
+ };
298
+ }
299
+
300
+ // Helper to create mock TFile instances
301
+ export function createMockFile(
302
+ path: string,
303
+ options?: {
304
+ basename?: string;
305
+ parentPath?: string;
306
+ extension?: string;
307
+ }
308
+ ): TFile {
309
+ const file = new TFile(path, options?.parentPath);
310
+ if (options?.basename) {
311
+ file.basename = options.basename;
312
+ }
313
+ if (options?.extension) {
314
+ file.extension = options.extension;
315
+ }
316
+ return file;
317
+ }
318
+
319
+ // Helper to create mock file cache
320
+ export function createMockFileCache(frontmatter?: Record<string, any>) {
321
+ return {
322
+ frontmatter: frontmatter || {},
323
+ frontmatterPosition: frontmatter ? { start: { line: 0 }, end: { line: 3 } } : null,
324
+ sections: [],
325
+ headings: [],
326
+ links: [],
327
+ embeds: [],
328
+ tags: [],
329
+ listItems: [],
330
+ };
331
+ }
@@ -0,0 +1,113 @@
1
+ import { expect, vi } from "vitest";
2
+
3
+ // File operations mocks
4
+ export const mockFileOperations = {
5
+ arraysEqual: vi.fn(),
6
+ normalizeArray: vi.fn(),
7
+ createFileLink: vi.fn(),
8
+ };
9
+
10
+ // Link parser mocks
11
+ export const mockLinkParser = {
12
+ extractFilePathFromLink: vi.fn(),
13
+ };
14
+
15
+ // Default mock implementations that match the actual behavior
16
+ export function setupDefaultMockImplementations() {
17
+ // Set up file operations mocks
18
+ mockFileOperations.normalizeArray.mockImplementation((arr) =>
19
+ Array.isArray(arr) ? arr : arr ? [arr] : []
20
+ );
21
+
22
+ mockFileOperations.arraysEqual.mockImplementation(
23
+ (a, b) => JSON.stringify(a) === JSON.stringify(b)
24
+ );
25
+
26
+ mockFileOperations.createFileLink.mockImplementation((file) => {
27
+ if (!file) return "[[Unknown File]]";
28
+
29
+ const basename =
30
+ file.basename ||
31
+ file.path
32
+ ?.split("/")
33
+ .pop()
34
+ ?.replace(/\.[^/.]+$/, "") ||
35
+ "";
36
+ const parentPath = file.parent?.path;
37
+
38
+ if (!parentPath || parentPath === "/" || parentPath === "") {
39
+ return `[[${basename}]]`;
40
+ }
41
+
42
+ return `[[${parentPath}/${basename}|${basename}]]`;
43
+ });
44
+
45
+ // Set up link parser mocks
46
+ mockLinkParser.extractFilePathFromLink.mockImplementation((link) => {
47
+ if (!link || typeof link !== "string") return null;
48
+
49
+ // Handle text that contains a link
50
+ const linkMatch = link.match(/\[\[([^\]]+)\]\]/);
51
+ if (linkMatch) {
52
+ const content = linkMatch[1];
53
+ // Remove display name if present
54
+ const filePart = content.split("|")[0].trim();
55
+ if (!filePart) return null;
56
+
57
+ // Add .md extension if not present
58
+ return filePart.endsWith(".md") ? filePart : `${filePart}.md`;
59
+ }
60
+
61
+ return null;
62
+ });
63
+ }
64
+
65
+ // Reset all mocks
66
+ export function resetAllMocks() {
67
+ Object.values(mockFileOperations).forEach((mock) => {
68
+ mock.mockReset();
69
+ });
70
+ Object.values(mockLinkParser).forEach((mock) => {
71
+ mock.mockReset();
72
+ });
73
+ }
74
+
75
+ // Helper to setup mocks with specific implementations
76
+ export function setupMockImplementation(
77
+ mockName: keyof typeof mockFileOperations | keyof typeof mockLinkParser,
78
+ implementation: (...args: any[]) => any
79
+ ) {
80
+ if (mockName in mockFileOperations) {
81
+ (mockFileOperations as any)[mockName].mockImplementation(implementation);
82
+ } else if (mockName in mockLinkParser) {
83
+ (mockLinkParser as any)[mockName].mockImplementation(implementation);
84
+ }
85
+ }
86
+
87
+ // Helper to setup mock return values
88
+ export function setupMockReturnValue(
89
+ mockName: keyof typeof mockFileOperations | keyof typeof mockLinkParser,
90
+ value: any
91
+ ) {
92
+ if (mockName in mockFileOperations) {
93
+ (mockFileOperations as any)[mockName].mockReturnValue(value);
94
+ } else if (mockName in mockLinkParser) {
95
+ (mockLinkParser as any)[mockName].mockReturnValue(value);
96
+ }
97
+ }
98
+
99
+ // Helper to verify mock calls
100
+ export function verifyMockCalls(
101
+ mockName: keyof typeof mockFileOperations | keyof typeof mockLinkParser,
102
+ expectedCalls: any[][]
103
+ ) {
104
+ const mock =
105
+ mockName in mockFileOperations
106
+ ? (mockFileOperations as any)[mockName]
107
+ : (mockLinkParser as any)[mockName];
108
+
109
+ expect(mock).toHaveBeenCalledTimes(expectedCalls.length);
110
+ expectedCalls.forEach((args, index) => {
111
+ expect(mock).toHaveBeenNthCalledWith(index + 1, ...args);
112
+ });
113
+ }
@@ -0,0 +1,19 @@
1
+ import { vi } from "vitest";
2
+ import { mockFileOperations, mockLinkParser } from "./mocks/utils";
3
+
4
+ // Global test setup that can be imported once per test file
5
+ export function setupTestEnvironment() {
6
+ // Mock the utils modules
7
+ vi.mock("@obsidian-plugins/utils/file-operations", () => mockFileOperations);
8
+ vi.mock("@obsidian-plugins/utils/link-parser", () => mockLinkParser);
9
+
10
+ // Mock any plugin-specific components
11
+ vi.mock("../src/components/settings-tab", () => ({
12
+ TreePropertiesManagerSettingTab: class MockSettingTab {},
13
+ }));
14
+
15
+ // Return cleanup function
16
+ return () => {
17
+ vi.clearAllMocks();
18
+ };
19
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-utils.d.ts","sourceRoot":"","sources":["../src/async-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,OAAO,CAAC,CAAC,CAAC,CAcnE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,EAAE,OAAO,EACvE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,GACtC,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAYtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG;IAC7D,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,KAAK,EAAE,MAAM,IAAI,CAAC;CAClB,CAmBA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-utils.js","sourceRoot":"","sources":["../src/async-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,SAAS,CAAI,EAAoB;IAChD,IAAI,OAAO,GAAsB,IAAI,CAAC;IAEtC,OAAO,GAAG,EAAE;QACX,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,IAAI,CAAC;gBACJ,OAAO,GAAG,EAAE,EAAE,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,kDAAkD;gBAClD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC;QACF,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc,CAC7B,EAAwC;IAExC,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B,CAAC;IAElD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAEjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACxB,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,mBAAmB,CAAI,EAAoB;IAI1D,IAAI,OAAO,GAAsB,IAAI,CAAC;IAEtC,OAAO;QACN,OAAO,EAAE,GAAG,EAAE;YACb,IAAI,CAAC,OAAO,EAAE,CAAC;gBACd,IAAI,CAAC;oBACJ,OAAO,GAAG,EAAE,EAAE,CAAC;gBAChB,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,kDAAkD;oBAClD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC;YACF,CAAC;YACD,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACX,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Creates a function that ensures an async operation runs only once,\n * returning the same promise for concurrent calls.\n *\n * Useful for initialization patterns where you want to ensure\n * expensive async operations (like indexing, API calls, etc.)\n * only happen once even if called multiple times.\n *\n * @param fn The async function to memoize\n * @returns A function that returns the same promise on subsequent calls\n *\n * @example\n * ```typescript\n * const initializeOnce = onceAsync(async () => {\n * await heavyInitialization();\n * console.log(\"Initialized!\");\n * });\n *\n * // All these calls will share the same promise\n * await initializeOnce();\n * await initializeOnce(); // Won't run again\n * await initializeOnce(); // Won't run again\n * ```\n */\nexport function onceAsync<T>(fn: () => Promise<T>): () => Promise<T> {\n\tlet promise: Promise<T> | null = null;\n\n\treturn () => {\n\t\tif (!promise) {\n\t\t\ttry {\n\t\t\t\tpromise = fn();\n\t\t\t} catch (error) {\n\t\t\t\t// Convert synchronous errors to rejected promises\n\t\t\t\tpromise = Promise.reject(error);\n\t\t\t}\n\t\t}\n\t\treturn promise;\n\t};\n}\n\n/**\n * Creates a function that ensures an async operation runs only once per key,\n * useful for caching expensive operations with different parameters.\n *\n * @param fn The async function to memoize\n * @returns A function that memoizes results by key\n *\n * @example\n * ```typescript\n * const fetchUserOnce = onceAsyncKeyed(async (userId: string) => {\n * return await api.getUser(userId);\n * });\n *\n * // Each unique userId will only be fetched once\n * await fetchUserOnce(\"user1\");\n * await fetchUserOnce(\"user1\"); // Returns cached promise\n * await fetchUserOnce(\"user2\"); // New fetch for different key\n * ```\n */\nexport function onceAsyncKeyed<TArgs extends readonly unknown[], TReturn>(\n\tfn: (...args: TArgs) => Promise<TReturn>\n): (...args: TArgs) => Promise<TReturn> {\n\tconst cache = new Map<string, Promise<TReturn>>();\n\n\treturn (...args: TArgs) => {\n\t\tconst key = JSON.stringify(args);\n\n\t\tif (!cache.has(key)) {\n\t\t\tcache.set(key, fn(...args));\n\t\t}\n\n\t\treturn cache.get(key)!;\n\t};\n}\n\n/**\n * Creates a resettable version of onceAsync that can be cleared and re-run.\n *\n * @param fn The async function to memoize\n * @returns Object with execute and reset methods\n *\n * @example\n * ```typescript\n * const { execute: initialize, reset } = onceAsyncResettable(async () => {\n * await heavyInitialization();\n * });\n *\n * await initialize(); // Runs\n * await initialize(); // Cached\n *\n * reset(); // Clear cache\n * await initialize(); // Runs again\n * ```\n */\nexport function onceAsyncResettable<T>(fn: () => Promise<T>): {\n\texecute: () => Promise<T>;\n\treset: () => void;\n} {\n\tlet promise: Promise<T> | null = null;\n\n\treturn {\n\t\texecute: () => {\n\t\t\tif (!promise) {\n\t\t\t\ttry {\n\t\t\t\t\tpromise = fn();\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Convert synchronous errors to rejected promises\n\t\t\t\t\tpromise = Promise.reject(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn promise;\n\t\t},\n\t\treset: () => {\n\t\t\tpromise = null;\n\t\t},\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"batch-operations.d.ts","sourceRoot":"","sources":["../src/batch-operations.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,EAAE,EACV,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EACnC,UAAU,GAAE,OAAc,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAmB/B;AAED,wBAAgB,wBAAwB,CACvC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAChB,IAAI,CAUN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"batch-operations.js","sourceRoot":"","sources":["../src/batch-operations.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAYlC,MAAM,UAAgB,iBAAiB;yDACtC,KAAU,EACV,cAAsB,EACtB,OAAmC,EACnC,aAAsB,IAAI;QAE1B,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAI,UAAU,GAAG,CAAC,CAAC;QAEnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC;gBACJ,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;gBACpB,YAAY,EAAE,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,KAAK,CAAC,GAAG,cAAc,0BAA0B,EAAE,KAAK,CAAC,CAAC;gBAClE,UAAU,EAAE,CAAC;YACd,CAAC;QACF,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YAChB,wBAAwB,CAAC,cAAc,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;IACrC,CAAC;CAAA;AAED,MAAM,UAAU,wBAAwB,CACvC,SAAiB,EACjB,YAAoB,EACpB,UAAkB;IAElB,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACtB,IAAI,MAAM,CACT,GAAG,SAAS,KAAK,YAAY,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,yBAAyB,CAC3F,CAAC;IACH,CAAC;SAAM,CAAC;QACP,IAAI,MAAM,CACT,GAAG,SAAS,KAAK,YAAY,eAAe,UAAU,qCAAqC,CAC3F,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Notice } from \"obsidian\";\n\nexport interface BatchOperationOptions {\n\tcloseAfter?: boolean;\n\tcallOnComplete?: boolean;\n}\n\nexport interface BatchOperationResult {\n\tsuccessCount: number;\n\terrorCount: number;\n}\n\nexport async function runBatchOperation<T>(\n\titems: T[],\n\toperationLabel: string,\n\thandler: (item: T) => Promise<void>,\n\tshowResult: boolean = true\n): Promise<BatchOperationResult> {\n\tlet successCount = 0;\n\tlet errorCount = 0;\n\n\tfor (const item of items) {\n\t\ttry {\n\t\t\tawait handler(item);\n\t\t\tsuccessCount++;\n\t\t} catch (error) {\n\t\t\tconsole.error(`${operationLabel}: error processing item:`, error);\n\t\t\terrorCount++;\n\t\t}\n\t}\n\n\tif (showResult) {\n\t\tshowBatchOperationResult(operationLabel, successCount, errorCount);\n\t}\n\n\treturn { successCount, errorCount };\n}\n\nexport function showBatchOperationResult(\n\toperation: string,\n\tsuccessCount: number,\n\terrorCount: number\n): void {\n\tif (errorCount === 0) {\n\t\tnew Notice(\n\t\t\t`${operation}: ${successCount} item${successCount === 1 ? \"\" : \"s\"} processed successfully`\n\t\t);\n\t} else {\n\t\tnew Notice(\n\t\t\t`${operation}: ${successCount} succeeded, ${errorCount} failed. Check console for details.`\n\t\t);\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-reference-utils.d.ts","sourceRoot":"","sources":["../src/child-reference-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,WAAW,YAAY;IAC5B,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;CAClD;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM7D;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMlE;AAED,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,YAAY,EACnB,oBAAoB,CAAC,EAAE,MAAM,GAC3B,MAAM,CAqCR;AAED,wBAAgB,wBAAwB,CACvC,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,EAAE,YAAY,EACnB,oBAAoB,CAAC,EAAE,MAAM,GAC3B,MAAM,EAAE,CAIV"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-reference-utils.js","sourceRoot":"","sources":["../src/child-reference-utils.ts"],"names":[],"mappings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,KAAK,CAAC;oBACzB,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,GAAG,QAAQ,KAAK,CAAC;YACrB,MAAM,IAAI,GAAG,KAAK,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;YACxD,IAAI,IAAI,YAAY,KAAK,EAAE,CAAC;gBAC3B,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,qDAAqD;IACrD,IAAI,wBAAwB,CAAC,QAAQ,CAAC,IAAI,oBAAoB,EAAE,CAAC;QAChE,MAAM,YAAY,GAAG,GAAG,oBAAoB,IAAI,QAAQ,EAAE,CAAC;QAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,IAAI,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,mFAAmF;IACnF,MAAM,IAAI,GAAG,KAAK,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACnD,IAAI,IAAI,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,wBAAwB,CACvC,SAAmB,EACnB,KAAmB,EACnB,oBAA6B;IAE7B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACjC,OAAO,uBAAuB,CAAC,QAAQ,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { TFile } from \"obsidian\";\nimport { createFileLink } from \"./file-operations\";\nimport { extractFilePathFromLink } from \"./link-parser\";\n\nexport interface VaultAdapter {\n\tgetAbstractFileByPath(path: string): TFile | null;\n}\n\nexport function extractDirectoryPath(filePath: string): string {\n\tconst lastSlashIndex = filePath.lastIndexOf(\"/\");\n\tif (lastSlashIndex === -1) {\n\t\treturn \"\";\n\t}\n\treturn filePath.substring(0, lastSlashIndex);\n}\n\nexport function isRelativeChildReference(childRef: string): boolean {\n\tconst filePath = extractFilePathFromLink(childRef);\n\tif (!filePath) {\n\t\treturn !childRef.includes(\"/\");\n\t}\n\treturn !filePath.includes(\"/\");\n}\n\nexport function normalizeChildReference(\n\tchildRef: string,\n\tvault: VaultAdapter,\n\tcurrentFileDirectory?: string\n): string {\n\tconst filePath = extractFilePathFromLink(childRef);\n\n\t// Handle plain text references (not wrapped in [[]])\n\tif (!filePath) {\n\t\t// If it's not a link format, check if it should be converted to a link\n\t\tif (!childRef.includes(\"/\") && currentFileDirectory !== undefined) {\n\t\t\t// This is a plain text reference that might need to be converted to a link\n\t\t\tconst potentialPath = currentFileDirectory\n\t\t\t\t? `${currentFileDirectory}/${childRef.endsWith(\".md\") ? childRef : `${childRef}.md`}`\n\t\t\t\t: childRef.endsWith(\".md\")\n\t\t\t\t\t? childRef\n\t\t\t\t\t: `${childRef}.md`;\n\t\t\tconst file = vault.getAbstractFileByPath(potentialPath);\n\t\t\tif (file instanceof TFile) {\n\t\t\t\treturn createFileLink(file);\n\t\t\t}\n\t\t}\n\t\treturn childRef;\n\t}\n\n\t// Handle relative references by making them absolute\n\tif (isRelativeChildReference(childRef) && currentFileDirectory) {\n\t\tconst absolutePath = `${currentFileDirectory}/${filePath}`;\n\t\tconst file = vault.getAbstractFileByPath(absolutePath);\n\t\tif (file instanceof TFile) {\n\t\t\treturn createFileLink(file);\n\t\t}\n\t}\n\n\t// For absolute references or when no directory context, try to find the file as-is\n\tconst file = vault.getAbstractFileByPath(filePath);\n\tif (file instanceof TFile) {\n\t\treturn createFileLink(file);\n\t}\n\n\treturn childRef;\n}\n\nexport function normalizeChildReferences(\n\tchildRefs: string[],\n\tvault: VaultAdapter,\n\tcurrentFileDirectory?: string\n): string[] {\n\treturn childRefs.map((childRef) => {\n\t\treturn normalizeChildReference(childRef, vault, currentFileDirectory);\n\t});\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-recurrence-utils.d.ts","sourceRoot":"","sources":["../src/date-recurrence-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEpG,MAAM,MAAM,OAAO,GAChB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,UAAU,GACV,QAAQ,GACR,UAAU,CAAC;AAEd,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAQrD,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,WAAW,EAAE,QAAQ,EACrB,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,OAAO,EAAE,GAClB,QAAQ,CAuBV;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAQ7E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,QAAQ,CAgB7F;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,QAAQ,CAI9F;AAED,wBAAiB,yBAAyB,CACzC,SAAS,EAAE,QAAQ,EACnB,MAAM,EAAE;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,EACtD,UAAU,EAAE,QAAQ,EACpB,QAAQ,EAAE,QAAQ,GAChB,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE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ourcesContent":["import type { DateTime } from \"luxon\";\n\nexport type RecurrenceType = \"daily\" | \"weekly\" | \"bi-weekly\" | \"monthly\" | \"bi-monthly\" | \"yearly\";\n\nexport type Weekday =\n\t| \"sunday\"\n\t| \"monday\"\n\t| \"tuesday\"\n\t| \"wednesday\"\n\t| \"thursday\"\n\t| \"friday\"\n\t| \"saturday\";\n\nexport const WEEKDAY_TO_NUMBER: Record<Weekday, number> = {\n\tsunday: 0,\n\tmonday: 1,\n\ttuesday: 2,\n\twednesday: 3,\n\tthursday: 4,\n\tfriday: 5,\n\tsaturday: 6,\n};\n\n/**\n * Calculates the next occurrence date based on recurrence type and optional weekdays\n */\nexport function getNextOccurrence(\n\tcurrentDate: DateTime,\n\trecurrenceType: RecurrenceType,\n\tweekdays?: Weekday[]\n): DateTime {\n\tswitch (recurrenceType) {\n\t\tcase \"daily\":\n\t\t\treturn currentDate.plus({ days: 1 });\n\t\tcase \"weekly\":\n\t\t\tif (weekdays && weekdays.length > 0) {\n\t\t\t\treturn getNextWeekdayOccurrence(currentDate, weekdays);\n\t\t\t}\n\t\t\treturn currentDate.plus({ weeks: 1 });\n\t\tcase \"bi-weekly\":\n\t\t\tif (weekdays && weekdays.length > 0) {\n\t\t\t\treturn getNextBiWeeklyOccurrence(currentDate, weekdays);\n\t\t\t}\n\t\t\treturn currentDate.plus({ weeks: 2 });\n\t\tcase \"monthly\":\n\t\t\treturn currentDate.plus({ months: 1 });\n\t\tcase \"bi-monthly\":\n\t\t\treturn currentDate.plus({ months: 2 });\n\t\tcase \"yearly\":\n\t\t\treturn currentDate.plus({ years: 1 });\n\t\tdefault:\n\t\t\treturn currentDate.plus({ days: 1 });\n\t}\n}\n\n/**\n * Checks if a given date matches any of the specified weekdays\n */\nexport function isDateOnWeekdays(date: DateTime, weekdays: Weekday[]): boolean {\n\tconst dateWeekday = date.weekday;\n\tconst luxonWeekdays = weekdays.map((day) => {\n\t\tconst dayNumber = WEEKDAY_TO_NUMBER[day];\n\t\treturn dayNumber === 0 ? 7 : dayNumber; // Convert Sunday from 0 to 7 for Luxon\n\t});\n\n\treturn luxonWeekdays.includes(dateWeekday);\n}\n\n/**\n * Finds the next occurrence on specified weekdays\n */\nexport function getNextWeekdayOccurrence(currentDate: DateTime, weekdays: Weekday[]): DateTime {\n\tconst currentWeekday = currentDate.weekday;\n\tconst luxonWeekdays = weekdays.map((day) => {\n\t\tconst dayNumber = WEEKDAY_TO_NUMBER[day];\n\t\treturn dayNumber === 0 ? 7 : dayNumber; // Convert Sunday from 0 to 7 for Luxon\n\t});\n\n\t// Find next weekday in the current week (after today)\n\tconst nextWeekday = luxonWeekdays.find((day) => day > currentWeekday);\n\tif (nextWeekday) {\n\t\treturn currentDate.set({ weekday: nextWeekday as 1 | 2 | 3 | 4 | 5 | 6 | 7 });\n\t}\n\n\t// No more weekdays this week, go to first weekday of next week\n\tconst firstWeekday = Math.min(...luxonWeekdays);\n\treturn currentDate.plus({ weeks: 1 }).set({ weekday: firstWeekday as 1 | 2 | 3 | 4 | 5 | 6 | 7 });\n}\n\n/**\n * Finds the next bi-weekly occurrence on specified weekdays\n */\nexport function getNextBiWeeklyOccurrence(currentDate: DateTime, weekdays: Weekday[]): DateTime {\n\tconst nextWeekly = getNextWeekdayOccurrence(currentDate, weekdays);\n\t// Add one more week to make it bi-weekly\n\treturn nextWeekly.plus({ weeks: 1 });\n}\n\nexport function* iterateOccurrencesInRange(\n\tstartDate: DateTime,\n\trrules: { type: RecurrenceType; weekdays?: Weekday[] },\n\trangeStart: DateTime,\n\trangeEnd: DateTime\n): Generator<DateTime, void, unknown> {\n\t// Normalize to start of day for comparison\n\tconst normalizedStart = startDate.startOf(\"day\");\n\tconst normalizedRangeStart = rangeStart.startOf(\"day\");\n\tconst normalizedRangeEnd = rangeEnd.startOf(\"day\");\n\n\t// Start from the later of startDate or rangeStart\n\tlet currentDate =\n\t\tnormalizedStart >= normalizedRangeStart ? normalizedStart : normalizedRangeStart;\n\n\t// For weekly/bi-weekly with weekdays, we need to track which week we're in\n\tif (\n\t\t(rrules.type === \"weekly\" || rrules.type === \"bi-weekly\") &&\n\t\trrules.weekdays &&\n\t\trrules.weekdays.length > 0\n\t) {\n\t\t// Calculate week offset from start date\n\t\tconst weeksFromStart = Math.floor(currentDate.diff(normalizedStart, \"weeks\").weeks);\n\n\t\t// For bi-weekly, we only want even weeks (0, 2, 4...) from the start date\n\t\tconst weekInterval = rrules.type === \"bi-weekly\" ? 2 : 1;\n\n\t\t// Adjust to the correct week if we're in an off-week\n\t\tconst weekOffset = weeksFromStart % weekInterval;\n\t\tif (weekOffset !== 0) {\n\t\t\tcurrentDate = currentDate.plus({ weeks: weekInterval - weekOffset });\n\t\t}\n\n\t\t// Now iterate through weeks, checking each day\n\t\twhile (currentDate <= normalizedRangeEnd) {\n\t\t\t// Check all 7 days of the current week\n\t\t\tfor (let dayOffset = 0; dayOffset < 7; dayOffset++) {\n\t\t\t\tconst checkDate = currentDate.plus({ days: dayOffset });\n\n\t\t\t\t// Only yield if within range and matches a target weekday\n\t\t\t\tif (\n\t\t\t\t\tcheckDate >= normalizedRangeStart &&\n\t\t\t\t\tcheckDate <= normalizedRangeEnd &&\n\t\t\t\t\tisDateOnWeekdays(checkDate, rrules.weekdays)\n\t\t\t\t) {\n\t\t\t\t\tyield checkDate;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Move to next occurrence week (1 week for weekly, 2 weeks for bi-weekly)\n\t\t\tcurrentDate = currentDate.plus({ weeks: weekInterval });\n\t\t}\n\t} else {\n\t\t// For other recurrence types (daily, monthly, yearly, or weekly without weekdays)\n\t\twhile (currentDate <= normalizedRangeEnd) {\n\t\t\tif (currentDate >= normalizedRangeStart) {\n\t\t\t\tyield currentDate;\n\t\t\t}\n\n\t\t\tconst nextDate = getNextOccurrence(currentDate, rrules.type, rrules.weekdays);\n\n\t\t\tif (nextDate <= normalizedRangeEnd) {\n\t\t\t\tcurrentDate = nextDate;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Calculates a DateTime for a specific date with optional time\n */\nexport function calculateInstanceDateTime(instanceDate: DateTime, timeString?: string): DateTime {\n\tif (!timeString) {\n\t\treturn instanceDate.startOf(\"day\");\n\t}\n\n\tconst [hours, minutes] = timeString.split(\":\").map(Number);\n\treturn instanceDate.set({ hour: hours, minute: minutes, second: 0, millisecond: 0 });\n}\n\nexport function calculateRecurringInstanceDateTime(\n\tnextInstanceDateTime: DateTime,\n\tnodeRecuringEventDateTime: DateTime,\n\trecurrenceType: RecurrenceType,\n\tallDay?: boolean\n): DateTime {\n\t// Convert the original event time to the target timezone once to preserve local time\n\tconst originalInTargetZone = nodeRecuringEventDateTime.setZone(nextInstanceDateTime.zone);\n\n\tswitch (recurrenceType) {\n\t\tcase \"daily\":\n\t\tcase \"weekly\":\n\t\tcase \"bi-weekly\": {\n\t\t\tif (allDay) {\n\t\t\t\treturn nextInstanceDateTime.startOf(\"day\");\n\t\t\t}\n\n\t\t\treturn nextInstanceDateTime.set({\n\t\t\t\thour: originalInTargetZone.hour,\n\t\t\t\tminute: originalInTargetZone.minute,\n\t\t\t\tsecond: 0,\n\t\t\t\tmillisecond: 0,\n\t\t\t});\n\t\t}\n\n\t\tcase \"monthly\":\n\t\tcase \"bi-monthly\": {\n\t\t\tif (allDay) {\n\t\t\t\treturn nextInstanceDateTime.set({ day: originalInTargetZone.day }).startOf(\"day\");\n\t\t\t}\n\n\t\t\treturn nextInstanceDateTime.set({\n\t\t\t\tday: originalInTargetZone.day,\n\t\t\t\thour: originalInTargetZone.hour,\n\t\t\t\tminute: originalInTargetZone.minute,\n\t\t\t\tsecond: 0,\n\t\t\t\tmillisecond: 0,\n\t\t\t});\n\t\t}\n\n\t\tcase \"yearly\": {\n\t\t\tif (allDay) {\n\t\t\t\treturn nextInstanceDateTime\n\t\t\t\t\t.set({\n\t\t\t\t\t\tmonth: originalInTargetZone.month,\n\t\t\t\t\t\tday: originalInTargetZone.day,\n\t\t\t\t\t})\n\t\t\t\t\t.startOf(\"day\");\n\t\t\t}\n\n\t\t\treturn nextInstanceDateTime.set({\n\t\t\t\tmonth: originalInTargetZone.month,\n\t\t\t\tday: originalInTargetZone.day,\n\t\t\t\thour: originalInTargetZone.hour,\n\t\t\t\tminute: originalInTargetZone.minute,\n\t\t\t\tsecond: 0,\n\t\t\t\tmillisecond: 0,\n\t\t\t});\n\t\t}\n\n\t\tdefault:\n\t\t\treturn nextInstanceDateTime.startOf(\"day\");\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../src/date-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,eAAO,MAAM,sBAAsB,GAAI,YAAY,MAAM,KAAG,MAgB3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,YAAY,MAAM,KAAG,MAavD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,KAAG,MAAM,GAAG,IAMnE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAIhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,QAAQ,GAAG,SAgBjE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,GAAG,IAAI,KAAG,QAAQ,GAAG,SA8BrE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-utils.js","sourceRoot":"","sources":["../src/date-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,UAAkB,EAAU,EAAE;IACpE,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAE3B,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,IAA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,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,IAAI,EAAE,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAE1B,sCAAsC;IACtC,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,IAAI,EAAE,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAE1B,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC","sourcesContent":["import { DateTime } from \"luxon\";\n\nexport const formatDateTimeForInput = (dateString: string): string => {\n\tif (!dateString) return \"\";\n\n\ttry {\n\t\tconst date = new Date(dateString);\n\t\t// Format for datetime-local input (YYYY-MM-DDTHH:mm)\n\t\tconst year = date.getFullYear();\n\t\tconst month = String(date.getMonth() + 1).padStart(2, \"0\");\n\t\tconst day = String(date.getDate()).padStart(2, \"0\");\n\t\tconst hours = String(date.getHours()).padStart(2, \"0\");\n\t\tconst minutes = String(date.getMinutes()).padStart(2, \"0\");\n\n\t\treturn `${year}-${month}-${day}T${hours}:${minutes}`;\n\t} catch {\n\t\treturn \"\";\n\t}\n};\n\nexport const formatDateForInput = (dateString: string): string => {\n\tif (!dateString) return \"\";\n\n\ttry {\n\t\tconst date = new Date(dateString);\n\t\tconst year = date.getFullYear();\n\t\tconst month = String(date.getMonth() + 1).padStart(2, \"0\");\n\t\tconst day = String(date.getDate()).padStart(2, \"0\");\n\n\t\treturn `${year}-${month}-${day}`;\n\t} catch {\n\t\treturn \"\";\n\t}\n};\n\n/**\n * Converts input value to ISO string, handling edge cases where\n * browser datetime-local inputs behave differently across platforms.\n * Returns null for invalid dates to prevent silent failures.\n */\nexport const inputValueToISOString = (inputValue: string): string | null => {\n\ttry {\n\t\treturn new Date(inputValue).toISOString();\n\t} catch {\n\t\treturn null;\n\t}\n};\n\nexport const formatDuration = (minutes: number): string => {\n\tconst hours = Math.floor(minutes / 60);\n\tconst mins = minutes % 60;\n\treturn `${String(hours).padStart(2, \"0\")}:${String(mins).padStart(2, \"0\")}:00`;\n};\n\n/**\n * Parse time string from datetime value - returns DateTime object\n * Rejects plain HH:mm format, requires full datetime\n */\nexport const parseTimeString = (value: string | null): DateTime | undefined => {\n\tif (value === null) return undefined;\n\n\tconst v = value.trim();\n\n\t// Reject plain HH:mm format - require full datetime\n\tif (/^\\d{2}:\\d{2}$/.test(v)) {\n\t\treturn undefined; // Reject plain time format\n\t}\n\n\t// Try ISO format first (most common) - EXACT same logic as recurring events\n\tlet dt = DateTime.fromISO(v, { setZone: true }); // ISO: with/without seconds, Z/offset, T\n\tif (!dt.isValid) dt = DateTime.fromSQL(v, { setZone: true }); // \"YYYY-MM-DD HH:mm[:ss]\" etc.\n\tif (!dt.isValid) dt = DateTime.fromFormat(v, \"yyyy-MM-dd HH:mm\", { setZone: true });\n\n\treturn dt.isValid ? dt : undefined;\n};\n\n/**\n * Parse and validate datetime strings for event parsing\n * Supports multiple formats including date-only and datetime formats\n */\nexport const parseDateTimeString = (value: string | null): DateTime | undefined => {\n\tif (value === null) return undefined;\n\n\tconst v = value.trim();\n\tif (!v) return undefined;\n\n\t// Try multiple datetime formats in order of preference\n\tlet dt: DateTime;\n\n\t// 1. Try ISO format first (most common)\n\tdt = DateTime.fromISO(v, { setZone: true });\n\tif (dt.isValid) return dt;\n\n\t// 2. Try SQL format (YYYY-MM-DD HH:mm:ss)\n\tdt = DateTime.fromSQL(v, { setZone: true });\n\tif (dt.isValid) return dt;\n\n\t// 3. Try common format with space (YYYY-MM-DD HH:mm)\n\tdt = DateTime.fromFormat(v, \"yyyy-MM-dd HH:mm\", { setZone: true });\n\tif (dt.isValid) return dt;\n\n\t// 4. Try date-only format (YYYY-MM-DD) - treat as start of day\n\tdt = DateTime.fromFormat(v, \"yyyy-MM-dd\", { setZone: true });\n\tif (dt.isValid) return dt;\n\n\t// 5. Try ISO date format (YYYY-MM-DD)\n\tdt = DateTime.fromISO(v, { setZone: true });\n\tif (dt.isValid) return dt;\n\n\treturn undefined;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"evaluator-base.d.ts","sourceRoot":"","sources":["../src/evaluator-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,MAAM,CAAC;AAE1D,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,8BAAsB,aAAa,CAAC,KAAK,SAAS,QAAQ,EAAE,SAAS;IACpE,SAAS,CAAC,aAAa,EAAE,KAAK,CAC7B,KAAK,GAAG;QAAE,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAA;KAAE,CACjE,CAAM;IACP,OAAO,CAAC,oBAAoB,CAA6B;gBAE7C,aAAa,EAAE,eAAe,CAAC,SAAS,CAAC;IAUrD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,KAAK,EAAE;IAE7D;;OAEG;IACH,OAAO,CAAC,YAAY;IA6BpB;;OAEG;IACH,SAAS,CAAC,YAAY,CACrB,IAAI,EAAE,KAAK,GAAG;QAAE,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAA;KAAE,EACvE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,GAAG,SAAS;IAStB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO;IAIxD;;OAEG;IACH,OAAO,IAAI,IAAI;IAQf;;OAEG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;OAEG;IACH,WAAW,IAAI,KAAK,CAAC;QAAE,UAAU,EAAE,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CAAC,UAAU,CAAC;YAC9C,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC,CAAC;IACL,CAAC;CACD","sourcesContent":["import type { BehaviorSubject, Subscription } from \"rxjs\";\n\nexport interface BaseRule {\n\tid: string;\n\texpression: string;\n\tenabled: boolean;\n}\n\n/**\n * Generic base class for evaluating JavaScript expressions against frontmatter objects.\n * Provides reactive compilation of rules via RxJS subscription and safe evaluation.\n */\nexport abstract class BaseEvaluator<TRule extends BaseRule, TSettings> {\n\tprotected compiledRules: Array<\n\t\tTRule & { fn: (frontmatter: Record<string, unknown>) => boolean }\n\t> = [];\n\tprivate settingsSubscription: Subscription | null = null;\n\n\tconstructor(settingsStore: BehaviorSubject<TSettings>) {\n\t\tconst initialRules = this.extractRules(settingsStore.value);\n\t\tthis.compileRules(initialRules);\n\n\t\tthis.settingsSubscription = settingsStore.subscribe((settings) => {\n\t\t\tconst newRules = this.extractRules(settings);\n\t\t\tthis.compileRules(newRules);\n\t\t});\n\t}\n\n\t/**\n\t * Extract rules from settings object. Must be implemented by subclasses.\n\t */\n\tprotected abstract extractRules(settings: TSettings): TRule[];\n\n\t/**\n\t * Compile rules into executable functions with error handling.\n\t */\n\tprivate compileRules(rules: TRule[]): void {\n\t\tthis.compiledRules = [];\n\n\t\tfor (const rule of rules) {\n\t\t\tif (!rule.enabled || !rule.expression.trim()) continue;\n\n\t\t\ttry {\n\t\t\t\tconst cleanExpression = rule.expression.trim();\n\n\t\t\t\t// Create a function that takes 'fm' (frontmatter) as parameter\n\t\t\t\t// and evaluates the expression in that context\n\t\t\t\tconst fn = new Function(\"fm\", `return (${cleanExpression});`) as (\n\t\t\t\t\tfrontmatter: Record<string, unknown>\n\t\t\t\t) => boolean;\n\n\t\t\t\t// Test the function with a dummy object to catch syntax errors early\n\t\t\t\tfn({});\n\n\t\t\t\tthis.compiledRules.push({\n\t\t\t\t\t...rule,\n\t\t\t\t\texpression: cleanExpression,\n\t\t\t\t\tfn,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tconsole.warn(`Invalid rule expression \"${rule.expression}\":`, error);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Evaluate a single rule against frontmatter. Returns the result or undefined if error.\n\t */\n\tprotected evaluateRule(\n\t\trule: TRule & { fn: (frontmatter: Record<string, unknown>) => boolean },\n\t\tfrontmatter: Record<string, unknown>\n\t): boolean | undefined {\n\t\ttry {\n\t\t\treturn rule.fn(frontmatter);\n\t\t} catch (error) {\n\t\t\tconsole.warn(`Error evaluating rule \"${rule.expression}\":`, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Convert evaluation result to boolean - only explicit true is considered truthy.\n\t */\n\tprotected isTruthy(result: boolean | undefined): boolean {\n\t\treturn result === true;\n\t}\n\n\t/**\n\t * Clean up subscriptions and compiled rules.\n\t */\n\tdestroy(): void {\n\t\tif (this.settingsSubscription) {\n\t\t\tthis.settingsSubscription.unsubscribe();\n\t\t\tthis.settingsSubscription = null;\n\t\t}\n\t\tthis.compiledRules = [];\n\t}\n\n\t/**\n\t * Get the number of active (compiled) rules.\n\t */\n\tgetActiveRuleCount(): number {\n\t\treturn this.compiledRules.length;\n\t}\n\n\t/**\n\t * Get information about all rules including their validity.\n\t */\n\tgetRuleInfo(): Array<{ expression: string; isValid: boolean; enabled: boolean }> {\n\t\tconst validExpressions = new Set(this.compiledRules.map((r) => r.expression));\n\n\t\treturn this.compiledRules.map((rule) => ({\n\t\t\texpression: rule.expression,\n\t\t\tisValid: validExpressions.has(rule.expression),\n\t\t\tenabled: rule.enabled,\n\t\t}));\n\t}\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-operations.d.ts","sourceRoot":"","sources":["../src/file-operations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAU,KAAK,EAAE,MAAM,UAAU,CAAC;AAGnD,eAAO,MAAM,QAAQ,GAAI,cAAc,MAAM,KAAG,MAE/C,CAAC;AAE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