@real1ty-obsidian-plugins/utils 2.30.0 → 2.31.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 +89 -0
- package/dist/components/whats-new-modal.d.ts.map +1 -0
- package/dist/components/whats-new-modal.js +196 -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 +74 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/evaluator/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/evaluator/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./base\";\nexport * from \"./color\";\nexport * from \"./excluded\";\nexport * from \"./filter\";\nexport * from \"./included\";\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a property name for use as a JavaScript function parameter
|
|
3
|
+
* by replacing spaces and special characters with underscores.
|
|
4
|
+
* Adds a prefix to avoid conflicts with JavaScript reserved words.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sanitizePropertyName(name: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Builds a mapping of original property names to sanitized versions
|
|
9
|
+
* suitable for use as JavaScript function parameters.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildPropertyMapping(properties: string[]): Map<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Replaces property names in an expression with their sanitized versions.
|
|
14
|
+
* Sorts by length descending to replace longer property names first and avoid partial matches.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sanitizeExpression(expression: string, propertyMapping: Map<string, string>): string;
|
|
17
|
+
//# sourceMappingURL=expression-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-utils.d.ts","sourceRoot":"","sources":["../../src/core/expression-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ9E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,MAAM,CAqBR"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a property name for use as a JavaScript function parameter
|
|
3
|
+
* by replacing spaces and special characters with underscores.
|
|
4
|
+
* Adds a prefix to avoid conflicts with JavaScript reserved words.
|
|
5
|
+
*/
|
|
6
|
+
export function sanitizePropertyName(name) {
|
|
7
|
+
const sanitized = name.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
8
|
+
return `prop_${sanitized}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds a mapping of original property names to sanitized versions
|
|
12
|
+
* suitable for use as JavaScript function parameters.
|
|
13
|
+
*/
|
|
14
|
+
export function buildPropertyMapping(properties) {
|
|
15
|
+
const mapping = new Map();
|
|
16
|
+
for (const prop of properties) {
|
|
17
|
+
mapping.set(prop, sanitizePropertyName(prop));
|
|
18
|
+
}
|
|
19
|
+
return mapping;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Replaces property names in an expression with their sanitized versions.
|
|
23
|
+
* Sorts by length descending to replace longer property names first and avoid partial matches.
|
|
24
|
+
*/
|
|
25
|
+
export function sanitizeExpression(expression, propertyMapping) {
|
|
26
|
+
let sanitized = expression;
|
|
27
|
+
// Sort by length descending to replace longer property names first
|
|
28
|
+
const sortedEntries = Array.from(propertyMapping.entries()).sort(([a], [b]) => b.length - a.length);
|
|
29
|
+
for (const [original, sanitizedName] of sortedEntries) {
|
|
30
|
+
if (original !== sanitizedName) {
|
|
31
|
+
const escaped = original.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
32
|
+
// Use a regex that matches the property name not preceded or followed by word characters
|
|
33
|
+
// This allows matching properties with special characters like "My-Property"
|
|
34
|
+
const regex = new RegExp(`(?<!\\w)${escaped}(?!\\w)`, "g");
|
|
35
|
+
sanitized = sanitized.replace(regex, sanitizedName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return sanitized;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=expression-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-utils.js","sourceRoot":"","sources":["../../src/core/expression-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO,QAAQ,SAAS,EAAE,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAoB;IACxD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE1C,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CACjC,UAAkB,EAClB,eAAoC;IAEpC,IAAI,SAAS,GAAG,UAAU,CAAC;IAE3B,mEAAmE;IACnE,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAC/D,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CACjC,CAAC;IAEF,KAAK,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,aAAa,EAAE,CAAC;QACvD,IAAI,QAAQ,KAAK,aAAa,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;YAEhE,yFAAyF;YACzF,6EAA6E;YAC7E,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,WAAW,OAAO,SAAS,EAAE,GAAG,CAAC,CAAC;YAE3D,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Sanitizes a property name for use as a JavaScript function parameter\n * by replacing spaces and special characters with underscores.\n * Adds a prefix to avoid conflicts with JavaScript reserved words.\n */\nexport function sanitizePropertyName(name: string): string {\n\tconst sanitized = name.replace(/[^a-zA-Z0-9_]/g, \"_\");\n\treturn `prop_${sanitized}`;\n}\n\n/**\n * Builds a mapping of original property names to sanitized versions\n * suitable for use as JavaScript function parameters.\n */\nexport function buildPropertyMapping(properties: string[]): Map<string, string> {\n\tconst mapping = new Map<string, string>();\n\n\tfor (const prop of properties) {\n\t\tmapping.set(prop, sanitizePropertyName(prop));\n\t}\n\n\treturn mapping;\n}\n\n/**\n * Replaces property names in an expression with their sanitized versions.\n * Sorts by length descending to replace longer property names first and avoid partial matches.\n */\nexport function sanitizeExpression(\n\texpression: string,\n\tpropertyMapping: Map<string, string>\n): string {\n\tlet sanitized = expression;\n\n\t// Sort by length descending to replace longer property names first\n\tconst sortedEntries = Array.from(propertyMapping.entries()).sort(\n\t\t([a], [b]) => b.length - a.length\n\t);\n\n\tfor (const [original, sanitizedName] of sortedEntries) {\n\t\tif (original !== sanitizedName) {\n\t\t\tconst escaped = original.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n\t\t\t// Use a regex that matches the property name not preceded or followed by word characters\n\t\t\t// This allows matching properties with special characters like \"My-Property\"\n\t\t\tconst regex = new RegExp(`(?<!\\\\w)${escaped}(?!\\\\w)`, \"g\");\n\n\t\t\tsanitized = sanitized.replace(regex, sanitizedName);\n\t\t}\n\t}\n\n\treturn sanitized;\n}\n"]}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export declare function isEmptyValue(value: unknown): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a frontmatter value to a string for editing in input fields.
|
|
4
|
+
* Arrays are joined with ", " for easier editing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function serializeValue(value: unknown): string;
|
|
7
|
+
/**
|
|
8
|
+
* Parses a string value from an input field into the appropriate type.
|
|
9
|
+
* Handles: booleans, numbers, JSON objects/arrays, comma-separated arrays, and strings.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseValue(rawValue: string): unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a frontmatter value for display in read-only contexts.
|
|
14
|
+
* Converts booleans to "Yes"/"No", numbers to strings, and objects to JSON.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatValue(value: unknown): string;
|
|
17
|
+
/**
|
|
18
|
+
* Parses wiki link syntax from a string value.
|
|
19
|
+
* Supports both [[path]] and [[path|alias]] formats.
|
|
20
|
+
* Returns null if the string is not a wiki link.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseWikiLinkWithDisplay(value: string): {
|
|
23
|
+
linkPath: string;
|
|
24
|
+
displayText: string;
|
|
25
|
+
} | null;
|
|
26
|
+
export interface NormalizePropertyOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Whether to log warnings for unexpected types.
|
|
29
|
+
* Default: false (silent mode)
|
|
30
|
+
*/
|
|
31
|
+
logWarnings?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Normalizes frontmatter property values to an array of strings.
|
|
35
|
+
* Handles various YAML formats and ensures consistent output.
|
|
36
|
+
*
|
|
37
|
+
* @param value - The raw frontmatter property value (can be any type)
|
|
38
|
+
* @param propertyName - Optional property name for logging purposes
|
|
39
|
+
* @param options - Optional configuration for normalization behavior
|
|
40
|
+
* @returns Array of strings, or empty array if value is invalid/unexpected
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Single string value
|
|
44
|
+
* normalizeProperty("[[link]]") // ["[[link]]"]
|
|
45
|
+
*
|
|
46
|
+
* // Array of strings
|
|
47
|
+
* normalizeProperty(["[[link1]]", "[[link2]]"]) // ["[[link1]]", "[[link2]]"]
|
|
48
|
+
*
|
|
49
|
+
* // Mixed array (filters out non-strings silently)
|
|
50
|
+
* normalizeProperty(["[[link]]", 42, null]) // ["[[link]]"]
|
|
51
|
+
*
|
|
52
|
+
* // Mixed array with warnings enabled
|
|
53
|
+
* normalizeProperty(["[[link]]", 42], "myProp", { logWarnings: true })
|
|
54
|
+
* // Logs: Property "myProp" contains non-string value (number), filtering it out: 42
|
|
55
|
+
* // Returns: ["[[link]]"]
|
|
56
|
+
*
|
|
57
|
+
* // Invalid types
|
|
58
|
+
* normalizeProperty(null) // []
|
|
59
|
+
* normalizeProperty(undefined) // []
|
|
60
|
+
* normalizeProperty(42) // []
|
|
61
|
+
* normalizeProperty({}) // []
|
|
62
|
+
*/
|
|
63
|
+
export declare function normalizeProperty(value: unknown, propertyName?: string, options?: NormalizePropertyOptions): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Batch normalize multiple property values from frontmatter.
|
|
66
|
+
* Useful for processing multiple properties at once.
|
|
67
|
+
*
|
|
68
|
+
* @param frontmatter - The frontmatter object
|
|
69
|
+
* @param propertyNames - Array of property names to normalize
|
|
70
|
+
* @param options - Optional configuration for normalization behavior
|
|
71
|
+
* @returns Map of property names to normalized string arrays
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const frontmatter = {
|
|
75
|
+
* parent: "[[Parent]]",
|
|
76
|
+
* children: ["[[Child1]]", "[[Child2]]"],
|
|
77
|
+
* related: null
|
|
78
|
+
* };
|
|
79
|
+
*
|
|
80
|
+
* const normalized = normalizeProperties(frontmatter, ["parent", "children", "related"]);
|
|
81
|
+
* // Map {
|
|
82
|
+
* // "parent" => ["[[Parent]]"],
|
|
83
|
+
* // "children" => ["[[Child1]]", "[[Child2]]"],
|
|
84
|
+
* // "related" => []
|
|
85
|
+
* // }
|
|
86
|
+
*/
|
|
87
|
+
export declare function normalizeProperties(frontmatter: Record<string, unknown>, propertyNames: string[], options?: NormalizePropertyOptions): Map<string, string[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Truncates a string to a maximum length, adding ellipsis if needed.
|
|
90
|
+
*/
|
|
91
|
+
export declare function truncateString(text: string, maxLength: number): string;
|
|
92
|
+
/**
|
|
93
|
+
* Removes wiki link syntax from a string for cleaner display.
|
|
94
|
+
* Converts [[Link|Alias]] to just "Link" or [[Link]] to "Link".
|
|
95
|
+
*/
|
|
96
|
+
export declare function removeWikiLinks(text: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Formats an array as a compact comma-separated string with smart truncation.
|
|
99
|
+
* Shows "item1, item2, +3" if the full list would exceed maxLength.
|
|
100
|
+
*/
|
|
101
|
+
export declare function formatArrayCompact(items: string[], maxLength: number): string;
|
|
102
|
+
export interface DisplaySettings {
|
|
103
|
+
hideUnderscoreProperties?: boolean;
|
|
104
|
+
hideEmptyProperties?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Filters frontmatter properties based on display settings.
|
|
108
|
+
* Returns an array of [key, value] pairs that should be displayed.
|
|
109
|
+
*/
|
|
110
|
+
export declare function filterPropertiesForDisplay<TSettings extends DisplaySettings>(frontmatter: Record<string, unknown>, settings: TSettings): Array<[string, unknown]>;
|
|
111
|
+
/**
|
|
112
|
+
* Filters a specific list of property names from frontmatter.
|
|
113
|
+
* Useful when you want to display only specific properties (like in tooltips).
|
|
114
|
+
*/
|
|
115
|
+
export declare function filterSpecificProperties<TSettings extends DisplaySettings>(frontmatter: Record<string, unknown>, propertyNames: string[], settings: TSettings): Array<{
|
|
116
|
+
key: string;
|
|
117
|
+
value: unknown;
|
|
118
|
+
}>;
|
|
119
|
+
export interface WikiLinkSegment {
|
|
120
|
+
type: "text" | "link";
|
|
121
|
+
content: string;
|
|
122
|
+
linkPath?: string;
|
|
123
|
+
displayText?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parses a string containing inline wiki links into segments.
|
|
127
|
+
* Useful for rendering strings with clickable wiki links mixed with regular text.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* parseInlineWikiLinks("Visit [[Page1]] and [[Page2|Second Page]]")
|
|
131
|
+
* // Returns:
|
|
132
|
+
* // [
|
|
133
|
+
* // { type: "text", content: "Visit " },
|
|
134
|
+
* // { type: "link", content: "[[Page1]]", linkPath: "Page1", displayText: "Page1" },
|
|
135
|
+
* // { type: "text", content: " and " },
|
|
136
|
+
* // { type: "link", content: "[[Page2|Second Page]]", linkPath: "Page2", displayText: "Second Page" }
|
|
137
|
+
* // ]
|
|
138
|
+
*/
|
|
139
|
+
export declare function parseInlineWikiLinks(text: string): WikiLinkSegment[];
|
|
140
|
+
/**
|
|
141
|
+
* Formats a frontmatter value for compact display inside graph nodes.
|
|
142
|
+
* Truncates long values and handles arrays gracefully.
|
|
143
|
+
*
|
|
144
|
+
* @param value - The frontmatter value to format
|
|
145
|
+
* @param maxLength - Maximum length before truncation (default: 20)
|
|
146
|
+
* @returns Formatted string suitable for node display
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* formatValueForNode("completed") // "completed"
|
|
150
|
+
* formatValueForNode("A very long string that exceeds the limit") // "A very long string..."
|
|
151
|
+
* formatValueForNode(["tag1", "tag2", "tag3"]) // "tag1, tag2, tag3"
|
|
152
|
+
* formatValueForNode(["tag1", "tag2", "tag3", "tag4", "tag5"], 15) // "tag1, tag2, +3"
|
|
153
|
+
* formatValueForNode(true) // "Yes"
|
|
154
|
+
* formatValueForNode(42) // "42"
|
|
155
|
+
*/
|
|
156
|
+
export declare function formatValueForNode(value: unknown, maxLength?: number): string;
|
|
157
|
+
//# sourceMappingURL=frontmatter-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter-value.d.ts","sourceRoot":"","sources":["../../src/core/frontmatter-value.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAcpD;AAMD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAcrD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA8CpD;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAclD;AAMD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,MAAM,GACX;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAelD;AAMD,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,OAAO,EACd,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,wBAAwB,GAChC,MAAM,EAAE,CA4DV;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,aAAa,EAAE,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,wBAAwB,GAChC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CASvB;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAkC7E;AAMD,MAAM,WAAW,eAAe;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,SAAS,eAAe,EAC3E,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,QAAQ,EAAE,SAAS,GACjB,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAgB1B;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,SAAS,eAAe,EACzE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,aAAa,EAAE,MAAM,EAAE,EACvB,QAAQ,EAAE,SAAS,GACjB,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAyBxC;AAMD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CA+CpE;AAMD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,SAAK,GAAG,MAAM,CAkCzE"}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Value Checking
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export function isEmptyValue(value) {
|
|
5
|
+
if (value === null || value === undefined) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (typeof value === "string" && value.trim() === "") {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Value Serialization & Parsing (for editing in input fields)
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Serializes a frontmatter value to a string for editing in input fields.
|
|
21
|
+
* Arrays are joined with ", " for easier editing.
|
|
22
|
+
*/
|
|
23
|
+
export function serializeValue(value) {
|
|
24
|
+
if (value === null || value === undefined) {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
return value.map((item) => serializeValue(item)).join(", ");
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === "object") {
|
|
31
|
+
return JSON.stringify(value);
|
|
32
|
+
}
|
|
33
|
+
return String(value);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parses a string value from an input field into the appropriate type.
|
|
37
|
+
* Handles: booleans, numbers, JSON objects/arrays, comma-separated arrays, and strings.
|
|
38
|
+
*/
|
|
39
|
+
export function parseValue(rawValue) {
|
|
40
|
+
const trimmed = rawValue.trim();
|
|
41
|
+
if (trimmed === "") {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
// Parse boolean
|
|
45
|
+
if (trimmed.toLowerCase() === "true") {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (trimmed.toLowerCase() === "false") {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// Parse number
|
|
52
|
+
if (/^-?\d+(\.\d+)?$/.test(trimmed)) {
|
|
53
|
+
const num = Number(trimmed);
|
|
54
|
+
if (!Number.isNaN(num)) {
|
|
55
|
+
return num;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Parse JSON object or array (check BEFORE comma-separated arrays)
|
|
59
|
+
if ((trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
|
60
|
+
(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(trimmed);
|
|
63
|
+
}
|
|
64
|
+
catch (_a) {
|
|
65
|
+
// If parsing fails, continue to other checks
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Parse comma-separated array
|
|
69
|
+
if (trimmed.includes(",")) {
|
|
70
|
+
const items = trimmed.split(",").map((item) => item.trim());
|
|
71
|
+
if (items.every((item) => item.length > 0)) {
|
|
72
|
+
return items;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Default: return as string
|
|
76
|
+
return trimmed;
|
|
77
|
+
}
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Value Formatting (for display in read-only contexts)
|
|
80
|
+
// ============================================================================
|
|
81
|
+
/**
|
|
82
|
+
* Formats a frontmatter value for display in read-only contexts.
|
|
83
|
+
* Converts booleans to "Yes"/"No", numbers to strings, and objects to JSON.
|
|
84
|
+
*/
|
|
85
|
+
export function formatValue(value) {
|
|
86
|
+
if (typeof value === "boolean") {
|
|
87
|
+
return value ? "Yes" : "No";
|
|
88
|
+
}
|
|
89
|
+
if (typeof value === "number") {
|
|
90
|
+
return value.toString();
|
|
91
|
+
}
|
|
92
|
+
if (typeof value === "object" && value !== null) {
|
|
93
|
+
return JSON.stringify(value, null, 2);
|
|
94
|
+
}
|
|
95
|
+
return String(value);
|
|
96
|
+
}
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// Wiki Link Parsing
|
|
99
|
+
// ============================================================================
|
|
100
|
+
/**
|
|
101
|
+
* Parses wiki link syntax from a string value.
|
|
102
|
+
* Supports both [[path]] and [[path|alias]] formats.
|
|
103
|
+
* Returns null if the string is not a wiki link.
|
|
104
|
+
*/
|
|
105
|
+
export function parseWikiLinkWithDisplay(value) {
|
|
106
|
+
const wikiLinkMatch = value.match(/^\[\[([^\]]*)\]\]$/);
|
|
107
|
+
if (!wikiLinkMatch) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const innerContent = wikiLinkMatch[1];
|
|
111
|
+
const pipeIndex = innerContent.indexOf("|");
|
|
112
|
+
const linkPath = pipeIndex !== -1 ? innerContent.substring(0, pipeIndex).trim() : innerContent.trim();
|
|
113
|
+
const displayText = pipeIndex !== -1 ? innerContent.substring(pipeIndex + 1).trim() : linkPath;
|
|
114
|
+
return { linkPath, displayText };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Normalizes frontmatter property values to an array of strings.
|
|
118
|
+
* Handles various YAML formats and ensures consistent output.
|
|
119
|
+
*
|
|
120
|
+
* @param value - The raw frontmatter property value (can be any type)
|
|
121
|
+
* @param propertyName - Optional property name for logging purposes
|
|
122
|
+
* @param options - Optional configuration for normalization behavior
|
|
123
|
+
* @returns Array of strings, or empty array if value is invalid/unexpected
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // Single string value
|
|
127
|
+
* normalizeProperty("[[link]]") // ["[[link]]"]
|
|
128
|
+
*
|
|
129
|
+
* // Array of strings
|
|
130
|
+
* normalizeProperty(["[[link1]]", "[[link2]]"]) // ["[[link1]]", "[[link2]]"]
|
|
131
|
+
*
|
|
132
|
+
* // Mixed array (filters out non-strings silently)
|
|
133
|
+
* normalizeProperty(["[[link]]", 42, null]) // ["[[link]]"]
|
|
134
|
+
*
|
|
135
|
+
* // Mixed array with warnings enabled
|
|
136
|
+
* normalizeProperty(["[[link]]", 42], "myProp", { logWarnings: true })
|
|
137
|
+
* // Logs: Property "myProp" contains non-string value (number), filtering it out: 42
|
|
138
|
+
* // Returns: ["[[link]]"]
|
|
139
|
+
*
|
|
140
|
+
* // Invalid types
|
|
141
|
+
* normalizeProperty(null) // []
|
|
142
|
+
* normalizeProperty(undefined) // []
|
|
143
|
+
* normalizeProperty(42) // []
|
|
144
|
+
* normalizeProperty({}) // []
|
|
145
|
+
*/
|
|
146
|
+
export function normalizeProperty(value, propertyName, options) {
|
|
147
|
+
const { logWarnings = false } = options !== null && options !== void 0 ? options : {};
|
|
148
|
+
// Handle undefined and null
|
|
149
|
+
if (value === undefined || value === null) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
// Handle string values - convert to single-item array
|
|
153
|
+
if (typeof value === "string") {
|
|
154
|
+
// Empty strings should return empty array
|
|
155
|
+
if (value.trim() === "") {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
return [value];
|
|
159
|
+
}
|
|
160
|
+
// Handle array values
|
|
161
|
+
if (Array.isArray(value)) {
|
|
162
|
+
// Empty arrays
|
|
163
|
+
if (value.length === 0) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
// Filter to only string values
|
|
167
|
+
const stringValues = value.filter((item) => {
|
|
168
|
+
if (typeof item === "string") {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
// null and undefined are expected in YAML arrays, don't warn
|
|
172
|
+
if (item === null || item === undefined) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
// Log warning for truly unexpected types (numbers, booleans, objects, etc.)
|
|
176
|
+
if (logWarnings && propertyName) {
|
|
177
|
+
console.warn(`Property "${propertyName}" contains non-string value (${typeof item}), filtering it out:`, item);
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
});
|
|
181
|
+
// Filter out empty strings
|
|
182
|
+
const nonEmptyStrings = stringValues.filter((s) => s.trim() !== "");
|
|
183
|
+
return nonEmptyStrings;
|
|
184
|
+
}
|
|
185
|
+
// Handle unexpected types (numbers, booleans, objects, etc.)
|
|
186
|
+
if (logWarnings && propertyName) {
|
|
187
|
+
console.warn(`Property "${propertyName}" has unexpected type (${typeof value}), returning empty array. Value:`, value);
|
|
188
|
+
}
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Batch normalize multiple property values from frontmatter.
|
|
193
|
+
* Useful for processing multiple properties at once.
|
|
194
|
+
*
|
|
195
|
+
* @param frontmatter - The frontmatter object
|
|
196
|
+
* @param propertyNames - Array of property names to normalize
|
|
197
|
+
* @param options - Optional configuration for normalization behavior
|
|
198
|
+
* @returns Map of property names to normalized string arrays
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* const frontmatter = {
|
|
202
|
+
* parent: "[[Parent]]",
|
|
203
|
+
* children: ["[[Child1]]", "[[Child2]]"],
|
|
204
|
+
* related: null
|
|
205
|
+
* };
|
|
206
|
+
*
|
|
207
|
+
* const normalized = normalizeProperties(frontmatter, ["parent", "children", "related"]);
|
|
208
|
+
* // Map {
|
|
209
|
+
* // "parent" => ["[[Parent]]"],
|
|
210
|
+
* // "children" => ["[[Child1]]", "[[Child2]]"],
|
|
211
|
+
* // "related" => []
|
|
212
|
+
* // }
|
|
213
|
+
*/
|
|
214
|
+
export function normalizeProperties(frontmatter, propertyNames, options) {
|
|
215
|
+
const result = new Map();
|
|
216
|
+
for (const propName of propertyNames) {
|
|
217
|
+
const value = frontmatter[propName];
|
|
218
|
+
result.set(propName, normalizeProperty(value, propName, options));
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
// ============================================================================
|
|
223
|
+
// String Utilities
|
|
224
|
+
// ============================================================================
|
|
225
|
+
/**
|
|
226
|
+
* Truncates a string to a maximum length, adding ellipsis if needed.
|
|
227
|
+
*/
|
|
228
|
+
export function truncateString(text, maxLength) {
|
|
229
|
+
return text.length > maxLength ? `${text.substring(0, maxLength)}...` : text;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Removes wiki link syntax from a string for cleaner display.
|
|
233
|
+
* Converts [[Link|Alias]] to just "Link" or [[Link]] to "Link".
|
|
234
|
+
*/
|
|
235
|
+
export function removeWikiLinks(text) {
|
|
236
|
+
return text.replace(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g, "$1");
|
|
237
|
+
}
|
|
238
|
+
// ============================================================================
|
|
239
|
+
// Array Formatting Utilities
|
|
240
|
+
// ============================================================================
|
|
241
|
+
/**
|
|
242
|
+
* Formats an array as a compact comma-separated string with smart truncation.
|
|
243
|
+
* Shows "item1, item2, +3" if the full list would exceed maxLength.
|
|
244
|
+
*/
|
|
245
|
+
export function formatArrayCompact(items, maxLength) {
|
|
246
|
+
if (items.length === 0) {
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
// Single item - just truncate it
|
|
250
|
+
if (items.length === 1) {
|
|
251
|
+
return truncateString(items[0], maxLength);
|
|
252
|
+
}
|
|
253
|
+
const joined = items.join(", ");
|
|
254
|
+
// Fits within limit - return as is
|
|
255
|
+
if (joined.length <= maxLength) {
|
|
256
|
+
return joined;
|
|
257
|
+
}
|
|
258
|
+
// Too long - show first few items + count
|
|
259
|
+
let result = "";
|
|
260
|
+
let count = 0;
|
|
261
|
+
for (const item of items) {
|
|
262
|
+
const testResult = result ? `${result}, ${item}` : item;
|
|
263
|
+
if (testResult.length > maxLength - 5) {
|
|
264
|
+
const remaining = items.length - count;
|
|
265
|
+
return `${result}${remaining > 0 ? `, +${remaining}` : ""}`;
|
|
266
|
+
}
|
|
267
|
+
result = testResult;
|
|
268
|
+
count++;
|
|
269
|
+
}
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Filters frontmatter properties based on display settings.
|
|
274
|
+
* Returns an array of [key, value] pairs that should be displayed.
|
|
275
|
+
*/
|
|
276
|
+
export function filterPropertiesForDisplay(frontmatter, settings) {
|
|
277
|
+
const entries = Object.entries(frontmatter);
|
|
278
|
+
return entries.filter(([key, value]) => {
|
|
279
|
+
// Hide underscore properties if configured
|
|
280
|
+
if (settings.hideUnderscoreProperties && key.startsWith("_")) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
// Hide empty properties if configured
|
|
284
|
+
if (settings.hideEmptyProperties && isEmptyValue(value)) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
return true;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Filters a specific list of property names from frontmatter.
|
|
292
|
+
* Useful when you want to display only specific properties (like in tooltips).
|
|
293
|
+
*/
|
|
294
|
+
export function filterSpecificProperties(frontmatter, propertyNames, settings) {
|
|
295
|
+
const result = [];
|
|
296
|
+
for (const propName of propertyNames) {
|
|
297
|
+
// Skip if property doesn't exist in frontmatter
|
|
298
|
+
if (!(propName in frontmatter)) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const value = frontmatter[propName];
|
|
302
|
+
// Hide underscore properties if configured
|
|
303
|
+
if (settings.hideUnderscoreProperties && propName.startsWith("_")) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
// Hide empty properties if configured
|
|
307
|
+
if (settings.hideEmptyProperties && isEmptyValue(value)) {
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
result.push({ key: propName, value });
|
|
311
|
+
}
|
|
312
|
+
return result;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Parses a string containing inline wiki links into segments.
|
|
316
|
+
* Useful for rendering strings with clickable wiki links mixed with regular text.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* parseInlineWikiLinks("Visit [[Page1]] and [[Page2|Second Page]]")
|
|
320
|
+
* // Returns:
|
|
321
|
+
* // [
|
|
322
|
+
* // { type: "text", content: "Visit " },
|
|
323
|
+
* // { type: "link", content: "[[Page1]]", linkPath: "Page1", displayText: "Page1" },
|
|
324
|
+
* // { type: "text", content: " and " },
|
|
325
|
+
* // { type: "link", content: "[[Page2|Second Page]]", linkPath: "Page2", displayText: "Second Page" }
|
|
326
|
+
* // ]
|
|
327
|
+
*/
|
|
328
|
+
export function parseInlineWikiLinks(text) {
|
|
329
|
+
var _a;
|
|
330
|
+
const segments = [];
|
|
331
|
+
const wikiLinkRegex = /\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g;
|
|
332
|
+
let lastIndex = 0;
|
|
333
|
+
const matches = text.matchAll(wikiLinkRegex);
|
|
334
|
+
for (const match of matches) {
|
|
335
|
+
// Add text before the link
|
|
336
|
+
if (match.index !== undefined && match.index > lastIndex) {
|
|
337
|
+
segments.push({
|
|
338
|
+
type: "text",
|
|
339
|
+
content: text.substring(lastIndex, match.index),
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// Add the link segment
|
|
343
|
+
const linkPath = match[1];
|
|
344
|
+
const displayText = match[2] || linkPath;
|
|
345
|
+
segments.push({
|
|
346
|
+
type: "link",
|
|
347
|
+
content: match[0],
|
|
348
|
+
linkPath,
|
|
349
|
+
displayText,
|
|
350
|
+
});
|
|
351
|
+
lastIndex = ((_a = match.index) !== null && _a !== void 0 ? _a : 0) + match[0].length;
|
|
352
|
+
}
|
|
353
|
+
// Add remaining text
|
|
354
|
+
if (lastIndex < text.length) {
|
|
355
|
+
segments.push({
|
|
356
|
+
type: "text",
|
|
357
|
+
content: text.substring(lastIndex),
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
// If no links found, return the entire text as a single segment
|
|
361
|
+
if (segments.length === 0) {
|
|
362
|
+
segments.push({
|
|
363
|
+
type: "text",
|
|
364
|
+
content: text,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
return segments;
|
|
368
|
+
}
|
|
369
|
+
// ============================================================================
|
|
370
|
+
// Node Display Formatting
|
|
371
|
+
// ============================================================================
|
|
372
|
+
/**
|
|
373
|
+
* Formats a frontmatter value for compact display inside graph nodes.
|
|
374
|
+
* Truncates long values and handles arrays gracefully.
|
|
375
|
+
*
|
|
376
|
+
* @param value - The frontmatter value to format
|
|
377
|
+
* @param maxLength - Maximum length before truncation (default: 20)
|
|
378
|
+
* @returns Formatted string suitable for node display
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* formatValueForNode("completed") // "completed"
|
|
382
|
+
* formatValueForNode("A very long string that exceeds the limit") // "A very long string..."
|
|
383
|
+
* formatValueForNode(["tag1", "tag2", "tag3"]) // "tag1, tag2, tag3"
|
|
384
|
+
* formatValueForNode(["tag1", "tag2", "tag3", "tag4", "tag5"], 15) // "tag1, tag2, +3"
|
|
385
|
+
* formatValueForNode(true) // "Yes"
|
|
386
|
+
* formatValueForNode(42) // "42"
|
|
387
|
+
*/
|
|
388
|
+
export function formatValueForNode(value, maxLength = 20) {
|
|
389
|
+
if (isEmptyValue(value)) {
|
|
390
|
+
return "";
|
|
391
|
+
}
|
|
392
|
+
// Booleans: reuse formatValue logic
|
|
393
|
+
if (typeof value === "boolean") {
|
|
394
|
+
return value ? "Yes" : "No";
|
|
395
|
+
}
|
|
396
|
+
// Numbers: reuse formatValue logic
|
|
397
|
+
if (typeof value === "number") {
|
|
398
|
+
return value.toString();
|
|
399
|
+
}
|
|
400
|
+
// Arrays: extract strings and format compactly
|
|
401
|
+
if (Array.isArray(value)) {
|
|
402
|
+
const stringValues = value.filter((item) => typeof item === "string");
|
|
403
|
+
return formatArrayCompact(stringValues, maxLength);
|
|
404
|
+
}
|
|
405
|
+
// Strings: clean wiki links and truncate
|
|
406
|
+
if (typeof value === "string") {
|
|
407
|
+
const cleaned = removeWikiLinks(value);
|
|
408
|
+
return truncateString(cleaned, maxLength);
|
|
409
|
+
}
|
|
410
|
+
// Objects: stringify and truncate
|
|
411
|
+
if (typeof value === "object" && value !== null) {
|
|
412
|
+
const jsonStr = JSON.stringify(value);
|
|
413
|
+
return truncateString(jsonStr, maxLength);
|
|
414
|
+
}
|
|
415
|
+
return String(value);
|
|
416
|
+
}
|
|
417
|
+
//# sourceMappingURL=frontmatter-value.js.map
|