@contentstorage/core 0.3.23 → 0.3.24

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.
@@ -36,36 +36,23 @@ pathString, fallbackValue) {
36
36
  console.warn(msg);
37
37
  return fallbackValue;
38
38
  }
39
- // Direct lookup since activeContent is expected to be flat and pathString is a key.
40
- // We use Object.prototype.hasOwnProperty.call for safer property checking.
41
- if (Object.prototype.hasOwnProperty.call(activeContent, pathString)) {
42
- // Since pathString is `keyof CustomContentStructure`, activeContent[pathString] is type-safe.
43
- // However, CustomContentStructure is initially `[key: string]: any` in the library,
44
- // so we might need a cast here if strict typing is desired for `value`.
45
- // But the consumer's augmentation makes CustomContentStructure specific.
46
- const keys = pathString.split('.');
47
- let current = activeContent;
48
- for (const key of keys) {
49
- if (current && typeof current === 'object' && key in current) {
50
- current = current[key];
51
- }
52
- else {
53
- const msg = `[Contentstorage] getText: Path "${String(pathString)}" not found in loaded content.`;
54
- console.warn(msg);
55
- return fallbackValue;
56
- }
57
- }
58
- if (typeof current === 'string') {
59
- return current;
39
+ const keys = pathString.split('.');
40
+ let current = activeContent;
41
+ for (const key of keys) {
42
+ if (current && typeof current === 'object' && key in current) {
43
+ current = current[key];
60
44
  }
61
45
  else {
62
- const msg = `[Contentstorage] getText: Value at path "${String(pathString)}" is not a string (actual type: ${typeof current}).`;
46
+ const msg = `[Contentstorage] getText: Path "${String(pathString)}" not found in loaded content.`;
63
47
  console.warn(msg);
64
48
  return fallbackValue;
65
49
  }
66
50
  }
51
+ if (typeof current === 'string') {
52
+ return current;
53
+ }
67
54
  else {
68
- const msg = `[Contentstorage] getText: Key "${String(pathString)}" not found in loaded content'.`;
55
+ const msg = `[Contentstorage] getText: Value at path "${String(pathString)}" is not a string (actual type: ${typeof current}).`;
69
56
  console.warn(msg);
70
57
  return fallbackValue;
71
58
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@contentstorage/core",
3
3
  "author": "Kaido Hussar <kaidohus@gmail.com>",
4
4
  "homepage": "https://contentstorage.app",
5
- "version": "0.3.23",
5
+ "version": "0.3.24",
6
6
  "type": "module",
7
7
  "description": "Fetch content from contentstorage and generate TypeScript types",
8
8
  "module": "dist/index.js",