@real1ty-obsidian-plugins/utils 2.30.0 → 2.32.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.
- package/dist/async/async.d.ts +69 -0
- package/dist/async/async.d.ts.map +1 -0
- package/dist/async/async.js +108 -0
- package/dist/async/async.js.map +1 -0
- package/dist/async/batch-operations.d.ts +21 -0
- package/dist/async/batch-operations.d.ts.map +1 -0
- package/dist/async/batch-operations.js +60 -0
- package/dist/async/batch-operations.js.map +1 -0
- package/dist/async/change-notifier.d.ts +13 -0
- package/dist/async/change-notifier.d.ts.map +1 -0
- package/dist/async/change-notifier.js +26 -0
- package/dist/async/change-notifier.js.map +1 -0
- package/dist/async/debounced-notifier.d.ts +26 -0
- package/dist/async/debounced-notifier.d.ts.map +1 -0
- package/dist/async/debounced-notifier.js +50 -0
- package/dist/async/debounced-notifier.js.map +1 -0
- package/dist/async/index.d.ts +5 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/index.js +5 -0
- package/dist/async/index.js.map +1 -0
- package/dist/components/frontmatter-propagation-modal.d.ts +17 -0
- package/dist/components/frontmatter-propagation-modal.d.ts.map +1 -0
- package/dist/components/frontmatter-propagation-modal.js +85 -0
- package/dist/components/frontmatter-propagation-modal.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input-managers/base.d.ts +30 -0
- package/dist/components/input-managers/base.d.ts.map +1 -0
- package/dist/components/input-managers/base.js +115 -0
- package/dist/components/input-managers/base.js.map +1 -0
- package/dist/components/input-managers/expression.d.ts +12 -0
- package/dist/components/input-managers/expression.d.ts.map +1 -0
- package/dist/components/input-managers/expression.js +56 -0
- package/dist/components/input-managers/expression.js.map +1 -0
- package/dist/components/input-managers/index.d.ts +4 -0
- package/dist/components/input-managers/index.d.ts.map +1 -0
- package/dist/components/input-managers/index.js +4 -0
- package/dist/components/input-managers/index.js.map +1 -0
- package/dist/components/input-managers/search.d.ts +6 -0
- package/dist/components/input-managers/search.d.ts.map +1 -0
- package/dist/components/input-managers/search.js +16 -0
- package/dist/components/input-managers/search.js.map +1 -0
- package/dist/components/registered-events-component.d.ts +30 -0
- package/dist/components/registered-events-component.d.ts.map +1 -0
- package/dist/components/registered-events-component.js +43 -0
- package/dist/components/registered-events-component.js.map +1 -0
- package/dist/components/whats-new-modal.d.ts +315 -0
- package/dist/components/whats-new-modal.d.ts.map +1 -0
- package/dist/components/whats-new-modal.js +426 -0
- package/dist/components/whats-new-modal.js.map +1 -0
- package/dist/core/color-utils.d.ts +17 -0
- package/dist/core/color-utils.d.ts.map +1 -0
- package/dist/core/color-utils.js +29 -0
- package/dist/core/color-utils.js.map +1 -0
- package/dist/core/css-utils.d.ts +39 -0
- package/dist/core/css-utils.d.ts.map +1 -0
- package/dist/core/css-utils.js +60 -0
- package/dist/core/css-utils.js.map +1 -0
- package/dist/core/evaluator/base.d.ts +22 -0
- package/dist/core/evaluator/base.d.ts.map +1 -0
- package/dist/core/evaluator/base.js +67 -0
- package/dist/core/evaluator/base.js.map +1 -0
- package/dist/core/evaluator/color.d.ts +19 -0
- package/dist/core/evaluator/color.d.ts.map +1 -0
- package/dist/core/evaluator/color.js +25 -0
- package/dist/core/evaluator/color.js.map +1 -0
- package/dist/core/evaluator/excluded.d.ts +32 -0
- package/dist/core/evaluator/excluded.d.ts.map +1 -0
- package/dist/core/evaluator/excluded.js +41 -0
- package/dist/core/evaluator/excluded.js.map +1 -0
- package/dist/core/evaluator/filter.d.ts +15 -0
- package/dist/core/evaluator/filter.d.ts.map +1 -0
- package/dist/core/evaluator/filter.js +27 -0
- package/dist/core/evaluator/filter.js.map +1 -0
- package/dist/core/evaluator/included.d.ts +36 -0
- package/dist/core/evaluator/included.d.ts.map +1 -0
- package/dist/core/evaluator/included.js +51 -0
- package/dist/core/evaluator/included.js.map +1 -0
- package/dist/core/evaluator/index.d.ts +6 -0
- package/dist/core/evaluator/index.d.ts.map +1 -0
- package/dist/core/evaluator/index.js +6 -0
- package/dist/core/evaluator/index.js.map +1 -0
- package/dist/core/expression-utils.d.ts +17 -0
- package/dist/core/expression-utils.d.ts.map +1 -0
- package/dist/core/expression-utils.js +40 -0
- package/dist/core/expression-utils.js.map +1 -0
- package/dist/core/frontmatter-value.d.ts +157 -0
- package/dist/core/frontmatter-value.d.ts.map +1 -0
- package/dist/core/frontmatter-value.js +417 -0
- package/dist/core/frontmatter-value.js.map +1 -0
- package/dist/core/generate.d.ts +7 -0
- package/dist/core/generate.d.ts.map +1 -0
- package/dist/core/generate.js +13 -0
- package/dist/core/generate.js.map +1 -0
- package/dist/core/history.d.ts +12 -0
- package/dist/core/history.d.ts.map +1 -0
- package/dist/core/history.js +39 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/indexer.d.ts +109 -0
- package/dist/core/indexer.d.ts.map +1 -0
- package/dist/core/indexer.js +185 -0
- package/dist/core/indexer.js.map +1 -0
- package/dist/core/property-renderer.d.ts +9 -0
- package/dist/core/property-renderer.d.ts.map +1 -0
- package/dist/core/property-renderer.js +42 -0
- package/dist/core/property-renderer.js.map +1 -0
- package/dist/core/validation.d.ts +13 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +27 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/date/date-recurrence.d.ts +30 -0
- package/dist/date/date-recurrence.d.ts.map +1 -0
- package/dist/date/date-recurrence.js +188 -0
- package/dist/date/date-recurrence.js.map +1 -0
- package/dist/date/date.d.ts +21 -0
- package/dist/date/date.d.ts.map +1 -0
- package/dist/date/date.js +105 -0
- package/dist/date/date.js.map +1 -0
- package/dist/date/index.d.ts +3 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/date/index.js +3 -0
- package/dist/date/index.js.map +1 -0
- package/dist/file/child-reference.d.ts +9 -0
- package/dist/file/child-reference.d.ts.map +1 -0
- package/dist/file/child-reference.js +57 -0
- package/dist/file/child-reference.js.map +1 -0
- package/dist/file/file-operations.d.ts +31 -0
- package/dist/file/file-operations.d.ts.map +1 -0
- package/dist/file/file-operations.js +160 -0
- package/dist/file/file-operations.js.map +1 -0
- package/dist/file/file-utils.d.ts +33 -0
- package/dist/file/file-utils.d.ts.map +1 -0
- package/dist/file/file-utils.js +76 -0
- package/dist/file/file-utils.js.map +1 -0
- package/dist/file/file.d.ts +332 -0
- package/dist/file/file.d.ts.map +1 -0
- package/dist/file/file.js +559 -0
- package/dist/file/file.js.map +1 -0
- package/dist/file/frontmatter-diff.d.ts +38 -0
- package/dist/file/frontmatter-diff.d.ts.map +1 -0
- package/dist/file/frontmatter-diff.js +162 -0
- package/dist/file/frontmatter-diff.js.map +1 -0
- package/dist/file/frontmatter-propagation.d.ts +4 -0
- package/dist/file/frontmatter-propagation.d.ts.map +1 -0
- package/dist/file/frontmatter-propagation.js +28 -0
- package/dist/file/frontmatter-propagation.js.map +1 -0
- package/dist/file/frontmatter-serialization.d.ts +21 -0
- package/dist/file/frontmatter-serialization.d.ts.map +1 -0
- package/dist/file/frontmatter-serialization.js +57 -0
- package/dist/file/frontmatter-serialization.js.map +1 -0
- package/dist/file/frontmatter.d.ts +15 -0
- package/dist/file/frontmatter.d.ts.map +1 -0
- package/dist/file/frontmatter.js +68 -0
- package/dist/file/frontmatter.js.map +1 -0
- package/dist/file/index.d.ts +13 -0
- package/dist/file/index.d.ts.map +1 -0
- package/dist/file/index.js +13 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/link-parser.d.ts +63 -0
- package/dist/file/link-parser.d.ts.map +1 -0
- package/dist/file/link-parser.js +137 -0
- package/dist/file/link-parser.js.map +1 -0
- package/dist/file/property-utils.d.ts +55 -0
- package/dist/file/property-utils.d.ts.map +1 -0
- package/dist/file/property-utils.js +90 -0
- package/dist/file/property-utils.js.map +1 -0
- package/dist/file/templater-service.d.ts +16 -0
- package/dist/file/templater-service.d.ts.map +1 -0
- package/dist/file/templater-service.js +37 -0
- package/dist/file/templater-service.js.map +1 -0
- package/dist/file/templater.d.ts +28 -0
- package/dist/file/templater.d.ts.map +1 -0
- package/dist/file/templater.js +126 -0
- package/dist/file/templater.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs/index.d.ts +2 -0
- package/dist/inputs/index.d.ts.map +1 -0
- package/dist/inputs/index.js +2 -0
- package/dist/inputs/index.js.map +1 -0
- package/dist/inputs/input-filter-manager.d.ts +72 -0
- package/dist/inputs/input-filter-manager.d.ts.map +1 -0
- package/dist/inputs/input-filter-manager.js +140 -0
- package/dist/inputs/input-filter-manager.js.map +1 -0
- package/dist/settings/index.d.ts +3 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +3 -0
- package/dist/settings/index.js.map +1 -0
- package/dist/settings/settings-store.d.ts +20 -0
- package/dist/settings/settings-store.d.ts.map +1 -0
- package/dist/settings/settings-store.js +82 -0
- package/dist/settings/settings-store.js.map +1 -0
- package/dist/settings/settings-ui-builder.d.ts +74 -0
- package/dist/settings/settings-ui-builder.d.ts.map +1 -0
- package/dist/settings/settings-ui-builder.js +436 -0
- package/dist/settings/settings-ui-builder.js.map +1 -0
- package/dist/string/changelog-parser.d.ts +17 -0
- package/dist/string/changelog-parser.d.ts.map +1 -0
- package/dist/string/changelog-parser.js +77 -0
- package/dist/string/changelog-parser.js.map +1 -0
- package/dist/string/filename-utils.d.ts +46 -0
- package/dist/string/filename-utils.d.ts.map +1 -0
- package/dist/string/filename-utils.js +65 -0
- package/dist/string/filename-utils.js.map +1 -0
- package/dist/string/index.d.ts +4 -0
- package/dist/string/index.d.ts.map +1 -0
- package/dist/string/index.js +4 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/string.d.ts +5 -0
- package/dist/string/string.d.ts.map +1 -0
- package/dist/string/string.js +25 -0
- package/dist/string/string.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +6 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mocks/obsidian.d.ts +150 -0
- package/dist/testing/mocks/obsidian.d.ts.map +1 -0
- package/dist/testing/mocks/obsidian.js +226 -0
- package/dist/testing/mocks/obsidian.js.map +1 -0
- package/dist/testing/mocks/utils.d.ts +14 -0
- package/dist/testing/mocks/utils.d.ts.map +1 -0
- package/dist/testing/mocks/utils.js +85 -0
- package/dist/testing/mocks/utils.js.map +1 -0
- package/dist/testing/setup.d.ts +2 -0
- package/dist/testing/setup.d.ts.map +1 -0
- package/dist/testing/setup.js +18 -0
- package/dist/testing/setup.js.map +1 -0
- package/package.json +1 -1
- package/src/components/whats-new-modal.ts +306 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-diff.d.ts","sourceRoot":"","sources":["../../src/file/frontmatter-diff.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,MAAM,WAAW,iBAAiB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;CAC7C;AAED,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC3B,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,GACnC,eAAe,CAwDjB;AAkCD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,eAAe,CA8C/E;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAkBxE"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two frontmatter objects and returns a detailed diff.
|
|
3
|
+
* Excludes specified properties from comparison (e.g., Prisma-managed properties).
|
|
4
|
+
*
|
|
5
|
+
* @param oldFrontmatter - The original frontmatter
|
|
6
|
+
* @param newFrontmatter - The updated frontmatter
|
|
7
|
+
* @param excludeProps - Set of property keys to exclude from comparison
|
|
8
|
+
* @returns Detailed diff with categorized changes
|
|
9
|
+
*/
|
|
10
|
+
export function compareFrontmatter(oldFrontmatter, newFrontmatter, excludeProps = new Set()) {
|
|
11
|
+
const changes = [];
|
|
12
|
+
const added = [];
|
|
13
|
+
const modified = [];
|
|
14
|
+
const deleted = [];
|
|
15
|
+
const allKeys = new Set([...Object.keys(oldFrontmatter), ...Object.keys(newFrontmatter)]);
|
|
16
|
+
for (const key of allKeys) {
|
|
17
|
+
if (excludeProps.has(key)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const oldValue = oldFrontmatter[key];
|
|
21
|
+
const newValue = newFrontmatter[key];
|
|
22
|
+
if (!(key in oldFrontmatter) && key in newFrontmatter) {
|
|
23
|
+
const change = {
|
|
24
|
+
key,
|
|
25
|
+
oldValue: undefined,
|
|
26
|
+
newValue,
|
|
27
|
+
changeType: "added",
|
|
28
|
+
};
|
|
29
|
+
changes.push(change);
|
|
30
|
+
added.push(change);
|
|
31
|
+
}
|
|
32
|
+
else if (key in oldFrontmatter && !(key in newFrontmatter)) {
|
|
33
|
+
const change = {
|
|
34
|
+
key,
|
|
35
|
+
oldValue,
|
|
36
|
+
newValue: undefined,
|
|
37
|
+
changeType: "deleted",
|
|
38
|
+
};
|
|
39
|
+
changes.push(change);
|
|
40
|
+
deleted.push(change);
|
|
41
|
+
}
|
|
42
|
+
else if (!deepEqual(oldValue, newValue)) {
|
|
43
|
+
const change = {
|
|
44
|
+
key,
|
|
45
|
+
oldValue,
|
|
46
|
+
newValue,
|
|
47
|
+
changeType: "modified",
|
|
48
|
+
};
|
|
49
|
+
changes.push(change);
|
|
50
|
+
modified.push(change);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
hasChanges: changes.length > 0,
|
|
55
|
+
changes,
|
|
56
|
+
added,
|
|
57
|
+
modified,
|
|
58
|
+
deleted,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Deep equality check for frontmatter values.
|
|
63
|
+
* Handles primitives, arrays, and objects.
|
|
64
|
+
*/
|
|
65
|
+
function deepEqual(a, b) {
|
|
66
|
+
if (a === b)
|
|
67
|
+
return true;
|
|
68
|
+
if (a === null || b === null || a === undefined || b === undefined) {
|
|
69
|
+
return a === b;
|
|
70
|
+
}
|
|
71
|
+
if (typeof a !== typeof b)
|
|
72
|
+
return false;
|
|
73
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
74
|
+
if (a.length !== b.length)
|
|
75
|
+
return false;
|
|
76
|
+
return a.every((val, idx) => deepEqual(val, b[idx]));
|
|
77
|
+
}
|
|
78
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
79
|
+
const keysA = Object.keys(a);
|
|
80
|
+
const keysB = Object.keys(b);
|
|
81
|
+
if (keysA.length !== keysB.length)
|
|
82
|
+
return false;
|
|
83
|
+
return keysA.every((key) => deepEqual(a[key], b[key]));
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Merges multiple frontmatter diffs into a single accumulated diff.
|
|
89
|
+
* Later diffs override earlier ones for the same key.
|
|
90
|
+
*
|
|
91
|
+
* @param diffs - Array of diffs to merge (in chronological order)
|
|
92
|
+
* @returns A single merged diff containing all accumulated changes
|
|
93
|
+
*/
|
|
94
|
+
export function mergeFrontmatterDiffs(diffs) {
|
|
95
|
+
if (diffs.length === 0) {
|
|
96
|
+
return {
|
|
97
|
+
hasChanges: false,
|
|
98
|
+
changes: [],
|
|
99
|
+
added: [],
|
|
100
|
+
modified: [],
|
|
101
|
+
deleted: [],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (diffs.length === 1) {
|
|
105
|
+
return diffs[0];
|
|
106
|
+
}
|
|
107
|
+
const changesByKey = new Map();
|
|
108
|
+
for (const diff of diffs) {
|
|
109
|
+
for (const change of diff.changes) {
|
|
110
|
+
const existing = changesByKey.get(change.key);
|
|
111
|
+
if (!existing) {
|
|
112
|
+
changesByKey.set(change.key, Object.assign({}, change));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
existing.newValue = change.newValue;
|
|
116
|
+
existing.changeType = change.changeType;
|
|
117
|
+
if (existing.oldValue === change.newValue) {
|
|
118
|
+
changesByKey.delete(change.key);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const allChanges = Array.from(changesByKey.values());
|
|
124
|
+
const added = allChanges.filter((c) => c.changeType === "added");
|
|
125
|
+
const modified = allChanges.filter((c) => c.changeType === "modified");
|
|
126
|
+
const deleted = allChanges.filter((c) => c.changeType === "deleted");
|
|
127
|
+
return {
|
|
128
|
+
hasChanges: allChanges.length > 0,
|
|
129
|
+
changes: allChanges,
|
|
130
|
+
added,
|
|
131
|
+
modified,
|
|
132
|
+
deleted,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Formats a frontmatter change for display in a modal.
|
|
137
|
+
* Returns a human-readable string describing the change.
|
|
138
|
+
*/
|
|
139
|
+
export function formatChangeForDisplay(change) {
|
|
140
|
+
const formatValue = (value) => {
|
|
141
|
+
if (value === undefined)
|
|
142
|
+
return "(not set)";
|
|
143
|
+
if (value === null)
|
|
144
|
+
return "null";
|
|
145
|
+
if (typeof value === "string")
|
|
146
|
+
return `"${value}"`;
|
|
147
|
+
if (typeof value === "object")
|
|
148
|
+
return JSON.stringify(value);
|
|
149
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
150
|
+
return String(value);
|
|
151
|
+
return JSON.stringify(value);
|
|
152
|
+
};
|
|
153
|
+
switch (change.changeType) {
|
|
154
|
+
case "added":
|
|
155
|
+
return `+ ${change.key}: ${formatValue(change.newValue)}`;
|
|
156
|
+
case "deleted":
|
|
157
|
+
return `- ${change.key}: ${formatValue(change.oldValue)}`;
|
|
158
|
+
case "modified":
|
|
159
|
+
return `~ ${change.key}: ${formatValue(change.oldValue)} → ${formatValue(change.newValue)}`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=frontmatter-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-diff.js","sourceRoot":"","sources":["../../src/file/frontmatter-diff.ts"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CACjC,cAA2B,EAC3B,cAA2B,EAC3B,eAA4B,IAAI,GAAG,EAAE;IAErC,MAAM,OAAO,GAAwB,EAAE,CAAC;IACxC,MAAM,KAAK,GAAwB,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAwB,EAAE,CAAC;IACzC,MAAM,OAAO,GAAwB,EAAE,CAAC;IAExC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAE1F,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,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C9F,CAAC;AACF,CAAC","sourcesContent":["export type Frontmatter = Record<string, unknown>;\n\nexport interface FrontmatterChange {\n\tkey: string;\n\toldValue: unknown;\n\tnewValue: unknown;\n\tchangeType: \"added\" | \"modified\" | \"deleted\";\n}\n\nexport interface FrontmatterDiff {\n\thasChanges: boolean;\n\tchanges: FrontmatterChange[];\n\tadded: FrontmatterChange[];\n\tmodified: FrontmatterChange[];\n\tdeleted: FrontmatterChange[];\n}\n\n/**\n * Compares two frontmatter objects and returns a detailed diff.\n * Excludes specified properties from comparison (e.g., Prisma-managed properties).\n *\n * @param oldFrontmatter - The original frontmatter\n * @param newFrontmatter - The updated frontmatter\n * @param excludeProps - Set of property keys to exclude from comparison\n * @returns Detailed diff with categorized changes\n */\nexport function compareFrontmatter(\n\toldFrontmatter: Frontmatter,\n\tnewFrontmatter: Frontmatter,\n\texcludeProps: Set<string> = new Set()\n): FrontmatterDiff {\n\tconst changes: FrontmatterChange[] = [];\n\tconst added: FrontmatterChange[] = [];\n\tconst modified: FrontmatterChange[] = [];\n\tconst deleted: FrontmatterChange[] = [];\n\n\tconst allKeys = new Set([...Object.keys(oldFrontmatter), ...Object.keys(newFrontmatter)]);\n\n\tfor (const key of allKeys) {\n\t\tif (excludeProps.has(key)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst oldValue = oldFrontmatter[key];\n\t\tconst newValue = newFrontmatter[key];\n\n\t\tif (!(key in oldFrontmatter) && key in newFrontmatter) {\n\t\t\tconst change: FrontmatterChange = {\n\t\t\t\tkey,\n\t\t\t\toldValue: undefined,\n\t\t\t\tnewValue,\n\t\t\t\tchangeType: \"added\",\n\t\t\t};\n\n\t\t\tchanges.push(change);\n\t\t\tadded.push(change);\n\t\t} else if (key in oldFrontmatter && !(key in newFrontmatter)) {\n\t\t\tconst change: FrontmatterChange = {\n\t\t\t\tkey,\n\t\t\t\toldValue,\n\t\t\t\tnewValue: undefined,\n\t\t\t\tchangeType: \"deleted\",\n\t\t\t};\n\n\t\t\tchanges.push(change);\n\t\t\tdeleted.push(change);\n\t\t} else if (!deepEqual(oldValue, newValue)) {\n\t\t\tconst change: FrontmatterChange = {\n\t\t\t\tkey,\n\t\t\t\toldValue,\n\t\t\t\tnewValue,\n\t\t\t\tchangeType: \"modified\",\n\t\t\t};\n\n\t\t\tchanges.push(change);\n\t\t\tmodified.push(change);\n\t\t}\n\t}\n\n\treturn {\n\t\thasChanges: changes.length > 0,\n\t\tchanges,\n\t\tadded,\n\t\tmodified,\n\t\tdeleted,\n\t};\n}\n\n/**\n * Deep equality check for frontmatter values.\n * Handles primitives, arrays, and objects.\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n\tif (a === b) return true;\n\n\tif (a === null || b === null || a === undefined || b === undefined) {\n\t\treturn a === b;\n\t}\n\n\tif (typeof a !== typeof b) return false;\n\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\tif (a.length !== b.length) return false;\n\t\treturn a.every((val, idx) => deepEqual(val, b[idx]));\n\t}\n\n\tif (typeof a === \"object\" && typeof b === \"object\") {\n\t\tconst keysA = Object.keys(a as Record<string, unknown>);\n\t\tconst keysB = Object.keys(b as Record<string, unknown>);\n\n\t\tif (keysA.length !== keysB.length) return false;\n\n\t\treturn keysA.every((key) =>\n\t\t\tdeepEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key])\n\t\t);\n\t}\n\n\treturn false;\n}\n\n/**\n * Merges multiple frontmatter diffs into a single accumulated diff.\n * Later diffs override earlier ones for the same key.\n *\n * @param diffs - Array of diffs to merge (in chronological order)\n * @returns A single merged diff containing all accumulated changes\n */\nexport function mergeFrontmatterDiffs(diffs: FrontmatterDiff[]): FrontmatterDiff {\n\tif (diffs.length === 0) {\n\t\treturn {\n\t\t\thasChanges: false,\n\t\t\tchanges: [],\n\t\t\tadded: [],\n\t\t\tmodified: [],\n\t\t\tdeleted: [],\n\t\t};\n\t}\n\n\tif (diffs.length === 1) {\n\t\treturn diffs[0];\n\t}\n\n\tconst changesByKey = new Map<string, FrontmatterChange>();\n\n\tfor (const diff of diffs) {\n\t\tfor (const change of diff.changes) {\n\t\t\tconst existing = changesByKey.get(change.key);\n\n\t\t\tif (!existing) {\n\t\t\t\tchangesByKey.set(change.key, { ...change });\n\t\t\t} else {\n\t\t\t\texisting.newValue = change.newValue;\n\t\t\t\texisting.changeType = change.changeType;\n\n\t\t\t\tif (existing.oldValue === change.newValue) {\n\t\t\t\t\tchangesByKey.delete(change.key);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst allChanges = Array.from(changesByKey.values());\n\tconst added = allChanges.filter((c) => c.changeType === \"added\");\n\tconst modified = allChanges.filter((c) => c.changeType === \"modified\");\n\tconst deleted = allChanges.filter((c) => c.changeType === \"deleted\");\n\n\treturn {\n\t\thasChanges: allChanges.length > 0,\n\t\tchanges: allChanges,\n\t\tadded,\n\t\tmodified,\n\t\tdeleted,\n\t};\n}\n\n/**\n * Formats a frontmatter change for display in a modal.\n * Returns a human-readable string describing the change.\n */\nexport function formatChangeForDisplay(change: FrontmatterChange): string {\n\tconst formatValue = (value: unknown): string => {\n\t\tif (value === undefined) return \"(not set)\";\n\t\tif (value === null) return \"null\";\n\t\tif (typeof value === \"string\") return `\"${value}\"`;\n\t\tif (typeof value === \"object\") return JSON.stringify(value);\n\t\tif (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n\t\treturn JSON.stringify(value);\n\t};\n\n\tswitch (change.changeType) {\n\t\tcase \"added\":\n\t\t\treturn `+ ${change.key}: ${formatValue(change.newValue)}`;\n\t\tcase \"deleted\":\n\t\t\treturn `- ${change.key}: ${formatValue(change.oldValue)}`;\n\t\tcase \"modified\":\n\t\t\treturn `~ ${change.key}: ${formatValue(change.oldValue)} → ${formatValue(change.newValue)}`;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { App } from "obsidian";
|
|
2
|
+
import type { Frontmatter, FrontmatterDiff } from "./frontmatter-diff";
|
|
3
|
+
export declare function applyFrontmatterChanges(app: App, targetPath: string, sourceFrontmatter: Frontmatter, diff: FrontmatterDiff): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=frontmatter-propagation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-propagation.d.ts","sourceRoot":"","sources":["../../src/file/frontmatter-propagation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEvE,wBAAsB,uBAAuB,CAC5C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,WAAW,EAC9B,IAAI,EAAE,eAAe,GACnB,OAAO,CAAC,IAAI,CAAC,CAwBf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { TFile } from "obsidian";
|
|
3
|
+
export function applyFrontmatterChanges(app, targetPath, sourceFrontmatter, diff) {
|
|
4
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5
|
+
try {
|
|
6
|
+
const file = app.vault.getAbstractFileByPath(targetPath);
|
|
7
|
+
if (!(file instanceof TFile)) {
|
|
8
|
+
console.warn(`Target file not found: ${targetPath}`);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
yield app.fileManager.processFrontMatter(file, (fm) => {
|
|
12
|
+
for (const change of diff.added) {
|
|
13
|
+
fm[change.key] = sourceFrontmatter[change.key];
|
|
14
|
+
}
|
|
15
|
+
for (const change of diff.modified) {
|
|
16
|
+
fm[change.key] = sourceFrontmatter[change.key];
|
|
17
|
+
}
|
|
18
|
+
for (const change of diff.deleted) {
|
|
19
|
+
delete fm[change.key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error(`Error applying frontmatter changes to ${targetPath}:`, error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=frontmatter-propagation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-propagation.js","sourceRoot":"","sources":["../../src/file/frontmatter-propagation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,MAAM,UAAgB,uBAAuB,CAC5C,GAAQ,EACR,UAAkB,EAClB,iBAA8B,EAC9B,IAAqB;;QAErB,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YACzD,IAAI,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;gBACrD,OAAO;YACR,CAAC;YAED,MAAM,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE;gBACrD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACjC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChD,CAAC;gBAED,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACpC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChD,CAAC;gBAED,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACnC,OAAO,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACvB,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,yCAAyC,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9E,CAAC;IACF,CAAC;CAAA","sourcesContent":["import type { App } from \"obsidian\";\nimport { TFile } from \"obsidian\";\nimport type { Frontmatter, FrontmatterDiff } from \"./frontmatter-diff\";\n\nexport async function applyFrontmatterChanges(\n\tapp: App,\n\ttargetPath: string,\n\tsourceFrontmatter: Frontmatter,\n\tdiff: FrontmatterDiff\n): Promise<void> {\n\ttry {\n\t\tconst file = app.vault.getAbstractFileByPath(targetPath);\n\t\tif (!(file instanceof TFile)) {\n\t\t\tconsole.warn(`Target file not found: ${targetPath}`);\n\t\t\treturn;\n\t\t}\n\n\t\tawait app.fileManager.processFrontMatter(file, (fm) => {\n\t\t\tfor (const change of diff.added) {\n\t\t\t\tfm[change.key] = sourceFrontmatter[change.key];\n\t\t\t}\n\n\t\t\tfor (const change of diff.modified) {\n\t\t\t\tfm[change.key] = sourceFrontmatter[change.key];\n\t\t\t}\n\n\t\t\tfor (const change of diff.deleted) {\n\t\t\t\tdelete fm[change.key];\n\t\t\t}\n\t\t});\n\t} catch (error) {\n\t\tconsole.error(`Error applying frontmatter changes to ${targetPath}:`, error);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates file content with YAML frontmatter and body content.
|
|
3
|
+
* This is the atomic file creation format that prevents race conditions.
|
|
4
|
+
*
|
|
5
|
+
* @param frontmatter - Frontmatter as JSON object
|
|
6
|
+
* @param content - Body content (markdown text after frontmatter)
|
|
7
|
+
* @returns Complete file content with YAML frontmatter
|
|
8
|
+
*/
|
|
9
|
+
export declare function createFileContentWithFrontmatter(frontmatter: Record<string, unknown>, content?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Parses file content to extract frontmatter and body separately.
|
|
12
|
+
* Returns both the frontmatter object and the body content.
|
|
13
|
+
*
|
|
14
|
+
* @param fileContent - Complete file content including frontmatter
|
|
15
|
+
* @returns Object with frontmatter and body
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseFileContent(fileContent: string): {
|
|
18
|
+
frontmatter: Record<string, unknown>;
|
|
19
|
+
body: string;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=frontmatter-serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-serialization.d.ts","sourceRoot":"","sources":["../../src/file/frontmatter-serialization.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC/C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,OAAO,SAAK,GACV,MAAM,CAgCR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACtD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;CACb,CAcA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { stringify as stringifyYAML } from "yaml";
|
|
2
|
+
/**
|
|
3
|
+
* Creates file content with YAML frontmatter and body content.
|
|
4
|
+
* This is the atomic file creation format that prevents race conditions.
|
|
5
|
+
*
|
|
6
|
+
* @param frontmatter - Frontmatter as JSON object
|
|
7
|
+
* @param content - Body content (markdown text after frontmatter)
|
|
8
|
+
* @returns Complete file content with YAML frontmatter
|
|
9
|
+
*/
|
|
10
|
+
export function createFileContentWithFrontmatter(frontmatter, content = "") {
|
|
11
|
+
if (!frontmatter || Object.keys(frontmatter).length === 0) {
|
|
12
|
+
// No frontmatter, just return content
|
|
13
|
+
return content;
|
|
14
|
+
}
|
|
15
|
+
// Use the yaml library to stringify frontmatter
|
|
16
|
+
// This handles all edge cases: special characters, multiline strings, arrays, nested objects, etc.
|
|
17
|
+
const yaml = stringifyYAML(frontmatter, {
|
|
18
|
+
// Use 2-space indentation (Obsidian standard)
|
|
19
|
+
indent: 2,
|
|
20
|
+
// Don't add document markers (--- at the end)
|
|
21
|
+
lineWidth: 0,
|
|
22
|
+
// Minimize unnecessary quotes
|
|
23
|
+
defaultStringType: "PLAIN",
|
|
24
|
+
// Handle null values explicitly
|
|
25
|
+
nullStr: "",
|
|
26
|
+
}).trim();
|
|
27
|
+
if (!yaml) {
|
|
28
|
+
// Empty frontmatter after stringification
|
|
29
|
+
return content;
|
|
30
|
+
}
|
|
31
|
+
// Ensure content doesn't start with extra newlines
|
|
32
|
+
const trimmedContent = content.replace(/^\n+/, "");
|
|
33
|
+
if (trimmedContent) {
|
|
34
|
+
return `---\n${yaml}\n---\n\n${trimmedContent}`;
|
|
35
|
+
}
|
|
36
|
+
return `---\n${yaml}\n---\n`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parses file content to extract frontmatter and body separately.
|
|
40
|
+
* Returns both the frontmatter object and the body content.
|
|
41
|
+
*
|
|
42
|
+
* @param fileContent - Complete file content including frontmatter
|
|
43
|
+
* @returns Object with frontmatter and body
|
|
44
|
+
*/
|
|
45
|
+
export function parseFileContent(fileContent) {
|
|
46
|
+
const frontmatterRegex = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;
|
|
47
|
+
const match = fileContent.match(frontmatterRegex);
|
|
48
|
+
if (!match) {
|
|
49
|
+
// No frontmatter found
|
|
50
|
+
return { frontmatter: {}, body: fileContent };
|
|
51
|
+
}
|
|
52
|
+
const [, , body] = match;
|
|
53
|
+
// For this use case, we just need to split the file
|
|
54
|
+
// The frontmatter will be properly parsed when we read it back with Obsidian's APIs
|
|
55
|
+
return { frontmatter: {}, body: body.trim() };
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=frontmatter-serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-serialization.js","sourceRoot":"","sources":["../../src/file/frontmatter-serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAC;AAElD;;;;;;;GAOG;AACH,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EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;AAC/C,CAAC","sourcesContent":["import { stringify as stringifyYAML } from \"yaml\";\n\n/**\n * Creates file content with YAML frontmatter and body content.\n * This is the atomic file creation format that prevents race conditions.\n *\n * @param frontmatter - Frontmatter as JSON object\n * @param content - Body content (markdown text after frontmatter)\n * @returns Complete file content with YAML frontmatter\n */\nexport function createFileContentWithFrontmatter(\n\tfrontmatter: Record<string, unknown>,\n\tcontent = \"\"\n): string {\n\tif (!frontmatter || Object.keys(frontmatter).length === 0) {\n\t\t// No frontmatter, just return content\n\t\treturn content;\n\t}\n\n\t// Use the yaml library to stringify frontmatter\n\t// This handles all edge cases: special characters, multiline strings, arrays, nested objects, etc.\n\tconst yaml = stringifyYAML(frontmatter, {\n\t\t// Use 2-space indentation (Obsidian standard)\n\t\tindent: 2,\n\t\t// Don't add document markers (--- at the end)\n\t\tlineWidth: 0,\n\t\t// Minimize unnecessary quotes\n\t\tdefaultStringType: \"PLAIN\",\n\t\t// Handle null values explicitly\n\t\tnullStr: \"\",\n\t}).trim();\n\n\tif (!yaml) {\n\t\t// Empty frontmatter after stringification\n\t\treturn content;\n\t}\n\n\t// Ensure content doesn't start with extra newlines\n\tconst trimmedContent = content.replace(/^\\n+/, \"\");\n\n\tif (trimmedContent) {\n\t\treturn `---\\n${yaml}\\n---\\n\\n${trimmedContent}`;\n\t}\n\n\treturn `---\\n${yaml}\\n---\\n`;\n}\n\n/**\n * Parses file content to extract frontmatter and body separately.\n * Returns both the frontmatter object and the body content.\n *\n * @param fileContent - Complete file content including frontmatter\n * @returns Object with frontmatter and body\n */\nexport function parseFileContent(fileContent: string): {\n\tfrontmatter: Record<string, unknown>;\n\tbody: string;\n} {\n\tconst frontmatterRegex = /^---\\n([\\s\\S]*?)\\n---\\n?([\\s\\S]*)$/;\n\tconst match = fileContent.match(frontmatterRegex);\n\n\tif (!match) {\n\t\t// No frontmatter found\n\t\treturn { frontmatter: {}, body: fileContent };\n\t}\n\n\tconst [, , body] = match;\n\n\t// For this use case, we just need to split the file\n\t// The frontmatter will be properly parsed when we read it back with Obsidian's APIs\n\treturn { frontmatter: {}, body: body.trim() };\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes a frontmatter value to a string representation for display in input fields.
|
|
3
|
+
* Converts arrays, objects, booleans, and numbers to their string representations.
|
|
4
|
+
*/
|
|
5
|
+
export declare function serializeFrontmatterValue(value: unknown): string;
|
|
6
|
+
/**
|
|
7
|
+
* Parses a string value back to its original frontmatter type.
|
|
8
|
+
* Detects and converts to: arrays, objects, booleans, numbers, or keeps as string.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseFrontmatterValue(stringValue: string): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a record of string values back to their original frontmatter types.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseFrontmatterRecord(record: Record<string, string>): Record<string, unknown>;
|
|
15
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/file/frontmatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAsClE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQ9F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes a frontmatter value to a string representation for display in input fields.
|
|
3
|
+
* Converts arrays, objects, booleans, and numbers to their string representations.
|
|
4
|
+
*/
|
|
5
|
+
export function serializeFrontmatterValue(value) {
|
|
6
|
+
if (value === null || value === undefined) {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === "string") {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
13
|
+
return String(value);
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(value) || typeof value === "object") {
|
|
16
|
+
return JSON.stringify(value);
|
|
17
|
+
}
|
|
18
|
+
return String(value);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parses a string value back to its original frontmatter type.
|
|
22
|
+
* Detects and converts to: arrays, objects, booleans, numbers, or keeps as string.
|
|
23
|
+
*/
|
|
24
|
+
export function parseFrontmatterValue(stringValue) {
|
|
25
|
+
// Empty string
|
|
26
|
+
if (stringValue === "") {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
// Try to parse as JSON (arrays, objects, null)
|
|
30
|
+
if ((stringValue.startsWith("[") && stringValue.endsWith("]")) ||
|
|
31
|
+
(stringValue.startsWith("{") && stringValue.endsWith("}")) ||
|
|
32
|
+
stringValue === "null") {
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(stringValue);
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
// If JSON parse fails, return as string
|
|
38
|
+
return stringValue;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Parse booleans
|
|
42
|
+
if (stringValue === "true") {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (stringValue === "false") {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Parse numbers (including integers and floats)
|
|
49
|
+
if (/^-?\d+(\.\d+)?$/.test(stringValue)) {
|
|
50
|
+
const num = Number(stringValue);
|
|
51
|
+
if (!Number.isNaN(num)) {
|
|
52
|
+
return num;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Return as string if no other type matches
|
|
56
|
+
return stringValue;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Converts a record of string values back to their original frontmatter types.
|
|
60
|
+
*/
|
|
61
|
+
export function parseFrontmatterRecord(record) {
|
|
62
|
+
const parsed = {};
|
|
63
|
+
for (const [key, value] of Object.entries(record)) {
|
|
64
|
+
parsed[key] = parseFrontmatterValue(value);
|
|
65
|
+
}
|
|
66
|
+
return parsed;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/file/frontmatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACvD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IACxD,eAAe;IACf,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,+CAA+C;IAC/C,IACC,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1D,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1D,WAAW,KAAK,MAAM,EACrB,CAAC;QACF,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAChC,CAAC;QAAC,WAAM,CAAC;YACR,wCAAwC;YACxC,OAAO,WAAW,CAAC;QACpB,CAAC;IACF,CAAC;IAED,iBAAiB;IACjB,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,IAAI,WAAW,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,gDAAgD;IAChD,IAAI,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,GAAG,CAAC;QACZ,CAAC;IACF,CAAC;IAED,4CAA4C;IAC5C,OAAO,WAAW,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAA8B;IACpE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * Serializes a frontmatter value to a string representation for display in input fields.\n * Converts arrays, objects, booleans, and numbers to their string representations.\n */\nexport function serializeFrontmatterValue(value: unknown): string {\n\tif (value === null || value === undefined) {\n\t\treturn \"\";\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn value;\n\t}\n\n\tif (typeof value === \"number\" || typeof value === \"boolean\") {\n\t\treturn String(value);\n\t}\n\n\tif (Array.isArray(value) || typeof value === \"object\") {\n\t\treturn JSON.stringify(value);\n\t}\n\n\treturn String(value);\n}\n\n/**\n * Parses a string value back to its original frontmatter type.\n * Detects and converts to: arrays, objects, booleans, numbers, or keeps as string.\n */\nexport function parseFrontmatterValue(stringValue: string): unknown {\n\t// Empty string\n\tif (stringValue === \"\") {\n\t\treturn \"\";\n\t}\n\n\t// Try to parse as JSON (arrays, objects, null)\n\tif (\n\t\t(stringValue.startsWith(\"[\") && stringValue.endsWith(\"]\")) ||\n\t\t(stringValue.startsWith(\"{\") && stringValue.endsWith(\"}\")) ||\n\t\tstringValue === \"null\"\n\t) {\n\t\ttry {\n\t\t\treturn JSON.parse(stringValue);\n\t\t} catch {\n\t\t\t// If JSON parse fails, return as string\n\t\t\treturn stringValue;\n\t\t}\n\t}\n\n\t// Parse booleans\n\tif (stringValue === \"true\") {\n\t\treturn true;\n\t}\n\tif (stringValue === \"false\") {\n\t\treturn false;\n\t}\n\n\t// Parse numbers (including integers and floats)\n\tif (/^-?\\d+(\\.\\d+)?$/.test(stringValue)) {\n\t\tconst num = Number(stringValue);\n\t\tif (!Number.isNaN(num)) {\n\t\t\treturn num;\n\t\t}\n\t}\n\n\t// Return as string if no other type matches\n\treturn stringValue;\n}\n\n/**\n * Converts a record of string values back to their original frontmatter types.\n */\nexport function parseFrontmatterRecord(record: Record<string, string>): Record<string, unknown> {\n\tconst parsed: Record<string, unknown> = {};\n\n\tfor (const [key, value] of Object.entries(record)) {\n\t\tparsed[key] = parseFrontmatterValue(value);\n\t}\n\n\treturn parsed;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./child-reference";
|
|
2
|
+
export * from "./file";
|
|
3
|
+
export * from "./file-operations";
|
|
4
|
+
export * from "./file-utils";
|
|
5
|
+
export * from "./frontmatter";
|
|
6
|
+
export * from "./frontmatter-diff";
|
|
7
|
+
export * from "./frontmatter-propagation";
|
|
8
|
+
export * from "./frontmatter-serialization";
|
|
9
|
+
export * from "./link-parser";
|
|
10
|
+
export * from "./property-utils";
|
|
11
|
+
export * from "./templater";
|
|
12
|
+
export * from "./templater-service";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./child-reference";
|
|
2
|
+
export * from "./file";
|
|
3
|
+
export * from "./file-operations";
|
|
4
|
+
export * from "./file-utils";
|
|
5
|
+
export * from "./frontmatter";
|
|
6
|
+
export * from "./frontmatter-diff";
|
|
7
|
+
export * from "./frontmatter-propagation";
|
|
8
|
+
export * from "./frontmatter-serialization";
|
|
9
|
+
export * from "./link-parser";
|
|
10
|
+
export * from "./property-utils";
|
|
11
|
+
export * from "./templater";
|
|
12
|
+
export * from "./templater-service";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/file/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./child-reference\";\nexport * from \"./file\";\nexport * from \"./file-operations\";\nexport * from \"./file-utils\";\nexport * from \"./frontmatter\";\nexport * from \"./frontmatter-diff\";\nexport * from \"./frontmatter-propagation\";\nexport * from \"./frontmatter-serialization\";\nexport * from \"./link-parser\";\nexport * from \"./property-utils\";\nexport * from \"./templater\";\nexport * from \"./templater-service\";\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles different link formats and edge cases:
|
|
3
|
+
* [[FileName]] -> FileName.md
|
|
4
|
+
* [[Folder/FileName]] -> Folder/FileName.md
|
|
5
|
+
* [[Folder/FileName|DisplayName]] -> Folder/FileName.md
|
|
6
|
+
* Normalizes paths and handles malformed links gracefully.
|
|
7
|
+
*/
|
|
8
|
+
export declare const extractFilePathFromLink: (link: string) => string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Parses an Obsidian wiki link to extract the file path.
|
|
11
|
+
* Handles formats like:
|
|
12
|
+
* - [[path/to/file]]
|
|
13
|
+
* - [[path/to/file|Display Name]]
|
|
14
|
+
*
|
|
15
|
+
* @param link - The wiki link string
|
|
16
|
+
* @returns The file path without the [[ ]] brackets, or null if invalid
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseWikiLink(link: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Parses a property value that can be a single link or an array of links.
|
|
21
|
+
* Extracts file paths from all valid wiki links.
|
|
22
|
+
*
|
|
23
|
+
* @param value - The property value (string, string[], or undefined)
|
|
24
|
+
* @returns Array of file paths, empty if no valid links found
|
|
25
|
+
*/
|
|
26
|
+
export declare function parsePropertyLinks(value: string | string[] | undefined): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Formats a file path as an Obsidian wiki link with display name.
|
|
29
|
+
* Example: "Projects/MyProject" -> "[[Projects/MyProject|MyProject]]"
|
|
30
|
+
*
|
|
31
|
+
* @param filePath - The file path to format
|
|
32
|
+
* @returns The formatted wiki link with display name alias
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatWikiLink(filePath: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Represents a parsed Obsidian link with its components
|
|
37
|
+
*/
|
|
38
|
+
export interface ObsidianLink {
|
|
39
|
+
raw: string;
|
|
40
|
+
path: string;
|
|
41
|
+
alias: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a value is an Obsidian internal link in the format [[...]]
|
|
45
|
+
*/
|
|
46
|
+
export declare function isObsidianLink(value: unknown): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Parses an Obsidian internal link and extracts its components
|
|
49
|
+
*
|
|
50
|
+
* Supports both formats:
|
|
51
|
+
* - Simple: [[Page Name]]
|
|
52
|
+
* - With alias: [[Path/To/Page|Display Name]]
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseObsidianLink(linkString: string): ObsidianLink | null;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the display alias from an Obsidian link
|
|
57
|
+
*/
|
|
58
|
+
export declare function getObsidianLinkAlias(linkString: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the file path from an Obsidian link
|
|
61
|
+
*/
|
|
62
|
+
export declare function getObsidianLinkPath(linkString: string): string;
|
|
63
|
+
//# sourceMappingURL=link-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link-parser.d.ts","sourceRoot":"","sources":["../../src/file/link-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAU/D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAezD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CAQjF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAqBvD;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAItD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CA4BzE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAG9D"}
|