@conloca/content-api 0.1.16 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/dist/asset-constraints.d.ts +16 -0
  2. package/dist/asset-constraints.d.ts.map +1 -0
  3. package/dist/asset-constraints.js +29 -0
  4. package/dist/asset-constraints.js.map +1 -0
  5. package/dist/asset-metadata-store.d.ts +60 -0
  6. package/dist/asset-metadata-store.d.ts.map +1 -0
  7. package/dist/asset-metadata-store.js +335 -0
  8. package/dist/asset-metadata-store.js.map +1 -0
  9. package/dist/asset-operations.d.ts +21 -28
  10. package/dist/asset-operations.d.ts.map +1 -1
  11. package/dist/asset-operations.js +268 -305
  12. package/dist/asset-operations.js.map +1 -0
  13. package/dist/asset-types.d.ts +23 -7
  14. package/dist/asset-types.d.ts.map +1 -1
  15. package/dist/asset-types.js +8 -2
  16. package/dist/asset-types.js.map +1 -0
  17. package/dist/asset-usage.d.ts +11 -0
  18. package/dist/asset-usage.d.ts.map +1 -0
  19. package/dist/asset-usage.js +50 -0
  20. package/dist/asset-usage.js.map +1 -0
  21. package/dist/base-content-index.d.ts +8 -2
  22. package/dist/base-content-index.d.ts.map +1 -1
  23. package/dist/base-content-index.js +24 -3
  24. package/dist/base-content-index.js.map +1 -0
  25. package/dist/cf-access.js +1 -0
  26. package/dist/cf-access.js.map +1 -0
  27. package/dist/component-registry.d.ts +1 -1
  28. package/dist/component-registry.d.ts.map +1 -1
  29. package/dist/component-registry.js +2 -1
  30. package/dist/component-registry.js.map +1 -0
  31. package/dist/component-registry.types.js +1 -0
  32. package/dist/component-registry.types.js.map +1 -0
  33. package/dist/component-vocabulary.d.ts +33 -0
  34. package/dist/component-vocabulary.d.ts.map +1 -0
  35. package/dist/component-vocabulary.js +105 -0
  36. package/dist/component-vocabulary.js.map +1 -0
  37. package/dist/content-api.interface.d.ts +5 -5
  38. package/dist/content-api.interface.d.ts.map +1 -1
  39. package/dist/content-api.interface.js +1 -0
  40. package/dist/content-api.interface.js.map +1 -0
  41. package/dist/content-filters.d.ts +2 -2
  42. package/dist/content-filters.d.ts.map +1 -1
  43. package/dist/content-filters.js +9 -8
  44. package/dist/content-filters.js.map +1 -0
  45. package/dist/content-index.d.ts +74 -16
  46. package/dist/content-index.d.ts.map +1 -1
  47. package/dist/content-index.js +183 -55
  48. package/dist/content-index.js.map +1 -0
  49. package/dist/content-operations.d.ts +71 -7
  50. package/dist/content-operations.d.ts.map +1 -1
  51. package/dist/content-operations.js +166 -82
  52. package/dist/content-operations.js.map +1 -0
  53. package/dist/content-path.d.ts +64 -0
  54. package/dist/content-path.d.ts.map +1 -0
  55. package/dist/content-path.js +95 -0
  56. package/dist/content-path.js.map +1 -0
  57. package/dist/content-reader.d.ts +2 -2
  58. package/dist/content-reader.d.ts.map +1 -1
  59. package/dist/content-reader.js +2 -1
  60. package/dist/content-reader.js.map +1 -0
  61. package/dist/content-utils.d.ts +53 -10
  62. package/dist/content-utils.d.ts.map +1 -1
  63. package/dist/content-utils.js +103 -34
  64. package/dist/content-utils.js.map +1 -0
  65. package/dist/content-watcher.d.ts +3 -3
  66. package/dist/content-watcher.d.ts.map +1 -1
  67. package/dist/content-watcher.js +13 -10
  68. package/dist/content-watcher.js.map +1 -0
  69. package/dist/data-index.d.ts +1 -1
  70. package/dist/data-index.d.ts.map +1 -1
  71. package/dist/data-index.js +2 -1
  72. package/dist/data-index.js.map +1 -0
  73. package/dist/data.d.ts +5 -13
  74. package/dist/data.d.ts.map +1 -1
  75. package/dist/data.js +7 -6
  76. package/dist/data.js.map +1 -0
  77. package/dist/editor-data-bindings.d.ts +10 -0
  78. package/dist/editor-data-bindings.d.ts.map +1 -0
  79. package/dist/editor-data-bindings.js +67 -0
  80. package/dist/editor-data-bindings.js.map +1 -0
  81. package/dist/etag-utils.d.ts.map +1 -1
  82. package/dist/etag-utils.js +5 -4
  83. package/dist/etag-utils.js.map +1 -0
  84. package/dist/filesystem-content-api.d.ts +45 -18
  85. package/dist/filesystem-content-api.d.ts.map +1 -1
  86. package/dist/filesystem-content-api.js +455 -286
  87. package/dist/filesystem-content-api.js.map +1 -0
  88. package/dist/filesystem-reader-backend.d.ts +46 -0
  89. package/dist/filesystem-reader-backend.d.ts.map +1 -0
  90. package/dist/filesystem-reader-backend.js +119 -0
  91. package/dist/filesystem-reader-backend.js.map +1 -0
  92. package/dist/fragment-index.d.ts +8 -0
  93. package/dist/fragment-index.d.ts.map +1 -0
  94. package/dist/fragment-index.js +8 -0
  95. package/dist/fragment-index.js.map +1 -0
  96. package/dist/fragments.d.ts +16 -0
  97. package/dist/fragments.d.ts.map +1 -0
  98. package/dist/fragments.js +104 -0
  99. package/dist/fragments.js.map +1 -0
  100. package/dist/git-operations.d.ts.map +1 -1
  101. package/dist/git-operations.js +5 -1
  102. package/dist/git-operations.js.map +1 -0
  103. package/dist/header-parser.d.ts +4 -4
  104. package/dist/header-parser.d.ts.map +1 -1
  105. package/dist/header-parser.js +8 -61
  106. package/dist/header-parser.js.map +1 -0
  107. package/dist/in-memory-content-api.d.ts +7 -7
  108. package/dist/in-memory-content-api.d.ts.map +1 -1
  109. package/dist/in-memory-content-api.js +74 -56
  110. package/dist/in-memory-content-api.js.map +1 -0
  111. package/dist/index.d.ts +19 -12
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +21 -9
  114. package/dist/index.js.map +1 -0
  115. package/dist/indexing.d.ts +4 -4
  116. package/dist/indexing.d.ts.map +1 -1
  117. package/dist/indexing.js +6 -5
  118. package/dist/indexing.js.map +1 -0
  119. package/dist/json-whitespace-view.js +1 -0
  120. package/dist/json-whitespace-view.js.map +1 -0
  121. package/dist/middleware.d.ts +8 -6
  122. package/dist/middleware.d.ts.map +1 -1
  123. package/dist/middleware.js +178 -142
  124. package/dist/middleware.js.map +1 -0
  125. package/dist/node.d.ts +24 -17
  126. package/dist/node.d.ts.map +1 -1
  127. package/dist/node.js +17 -14
  128. package/dist/node.js.map +1 -0
  129. package/dist/page-references.d.ts +21 -0
  130. package/dist/page-references.d.ts.map +1 -0
  131. package/dist/page-references.js +50 -0
  132. package/dist/page-references.js.map +1 -0
  133. package/dist/read-date.d.ts +3 -0
  134. package/dist/read-date.d.ts.map +1 -0
  135. package/dist/read-date.js +9 -0
  136. package/dist/read-date.js.map +1 -0
  137. package/dist/reader-backend.d.ts +54 -0
  138. package/dist/reader-backend.d.ts.map +1 -0
  139. package/dist/reader-backend.js +2 -0
  140. package/dist/reader-backend.js.map +1 -0
  141. package/dist/reader.d.ts +8 -8
  142. package/dist/reader.d.ts.map +1 -1
  143. package/dist/reader.js +8 -7
  144. package/dist/reader.js.map +1 -0
  145. package/dist/schemas/index.d.ts +6 -6
  146. package/dist/schemas/index.d.ts.map +1 -1
  147. package/dist/schemas/index.js +9 -8
  148. package/dist/schemas/index.js.map +1 -0
  149. package/dist/site-index.d.ts +3 -3
  150. package/dist/site-index.d.ts.map +1 -1
  151. package/dist/site-index.js +9 -5
  152. package/dist/site-index.js.map +1 -0
  153. package/dist/site.d.ts +5 -3
  154. package/dist/site.d.ts.map +1 -1
  155. package/dist/site.js +14 -2
  156. package/dist/site.js.map +1 -0
  157. package/dist/types.d.ts +203 -15
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/types.js +9 -0
  160. package/dist/types.js.map +1 -0
  161. package/dist/url-safe-base64.js +1 -0
  162. package/dist/url-safe-base64.js.map +1 -0
  163. package/dist/url-validation.d.ts +14 -0
  164. package/dist/url-validation.d.ts.map +1 -1
  165. package/dist/url-validation.js +56 -14
  166. package/dist/url-validation.js.map +1 -0
  167. package/dist/utils/atomic-write.js +1 -0
  168. package/dist/utils/atomic-write.js.map +1 -0
  169. package/dist/utils.d.ts +1 -1
  170. package/dist/utils.js +2 -1
  171. package/dist/utils.js.map +1 -0
  172. package/dist/vite-plugin.d.ts +2 -2
  173. package/dist/vite-plugin.js +5 -4
  174. package/dist/vite-plugin.js.map +1 -0
  175. package/dist/vxjson-serialize.d.ts +5 -6
  176. package/dist/vxjson-serialize.d.ts.map +1 -1
  177. package/dist/vxjson-serialize.js +13 -10
  178. package/dist/vxjson-serialize.js.map +1 -0
  179. package/dist/vxjson.d.ts +4 -3
  180. package/dist/vxjson.d.ts.map +1 -1
  181. package/dist/vxjson.js +10 -20
  182. package/dist/vxjson.js.map +1 -0
  183. package/dist/xxhash.d.ts.map +1 -1
  184. package/dist/xxhash.js +6 -2
  185. package/dist/xxhash.js.map +1 -0
  186. package/package.json +92 -56
  187. package/src/asset-constraints.ts +33 -0
  188. package/src/asset-metadata-store.ts +401 -0
  189. package/src/asset-operations.ts +814 -0
  190. package/src/asset-types.ts +74 -0
  191. package/src/asset-usage.ts +48 -0
  192. package/src/base-content-index.ts +227 -0
  193. package/src/cf-access.ts +85 -0
  194. package/src/component-registry.ts +145 -0
  195. package/src/component-registry.types.ts +12 -0
  196. package/src/component-vocabulary.ts +87 -0
  197. package/src/content-api.interface.ts +94 -0
  198. package/src/content-filters.ts +278 -0
  199. package/src/content-index.ts +642 -0
  200. package/src/content-operations.ts +497 -0
  201. package/src/content-path.ts +121 -0
  202. package/src/content-reader.ts +18 -0
  203. package/src/content-utils.ts +474 -0
  204. package/src/content-watcher.ts +122 -0
  205. package/src/data-index.ts +7 -0
  206. package/src/data.ts +134 -0
  207. package/src/editor-data-bindings.ts +66 -0
  208. package/src/etag-utils.ts +204 -0
  209. package/src/filesystem-content-api.ts +2740 -0
  210. package/src/filesystem-reader-backend.ts +135 -0
  211. package/src/fragment-index.ts +7 -0
  212. package/src/fragments.ts +113 -0
  213. package/src/git-operations.ts +340 -0
  214. package/src/header-parser.ts +272 -0
  215. package/src/in-memory-content-api.ts +760 -0
  216. package/src/index.ts +45 -0
  217. package/src/indexing.ts +8 -0
  218. package/src/json-whitespace-view.ts +155 -0
  219. package/src/middleware.ts +1322 -0
  220. package/src/node.ts +40 -0
  221. package/src/page-references.ts +76 -0
  222. package/src/read-date.ts +7 -0
  223. package/src/reader-backend.ts +54 -0
  224. package/src/reader.ts +15 -0
  225. package/src/schemas/index.ts +113 -0
  226. package/src/site-index.ts +330 -0
  227. package/src/site.ts +198 -0
  228. package/src/types.ts +759 -0
  229. package/src/url-safe-base64.ts +38 -0
  230. package/src/url-validation.ts +121 -0
  231. package/src/utils/atomic-write.ts +20 -0
  232. package/src/utils.ts +84 -0
  233. package/src/vite-plugin.ts +45 -0
  234. package/src/vxjson-serialize.ts +66 -0
  235. package/src/vxjson.ts +442 -0
  236. package/src/xxhash.ts +43 -0
  237. package/dist/asset-manifest.d.ts +0 -23
  238. package/dist/asset-manifest.d.ts.map +0 -1
  239. package/dist/asset-manifest.js +0 -73
  240. package/dist/block-index.d.ts +0 -9
  241. package/dist/block-index.d.ts.map +0 -1
  242. package/dist/block-index.js +0 -11
  243. package/dist/blocks.d.ts +0 -16
  244. package/dist/blocks.d.ts.map +0 -1
  245. package/dist/blocks.js +0 -103
  246. package/dist/component-registry.types-C0ctF9nh.d.mts +0 -71
  247. package/dist/component-registry.types-C0ctF9nh.d.mts.map +0 -1
  248. package/dist/content-index-D092_vk1.mjs +0 -629
  249. package/dist/content-index-D092_vk1.mjs.map +0 -1
  250. package/dist/content-index-D6IVMmAB.d.mts +0 -127
  251. package/dist/content-index-D6IVMmAB.d.mts.map +0 -1
  252. package/dist/content-operations-DIbsxG5A.d.mts +0 -354
  253. package/dist/content-operations-DIbsxG5A.d.mts.map +0 -1
  254. package/dist/content-utils-fWNHTrPy.mjs +0 -280
  255. package/dist/content-utils-fWNHTrPy.mjs.map +0 -1
  256. package/dist/data-DquNIEnQ.mjs +0 -62
  257. package/dist/data-DquNIEnQ.mjs.map +0 -1
  258. package/dist/filesystem-content-api-B1KIQJfk.mjs +0 -2
  259. package/dist/filesystem-content-api-C0HIhqZi.mjs +0 -1620
  260. package/dist/filesystem-content-api-C0HIhqZi.mjs.map +0 -1
  261. package/dist/filesystem-content-api-DCdNi-co.d.mts +0 -134
  262. package/dist/filesystem-content-api-DCdNi-co.d.mts.map +0 -1
  263. package/dist/index-DxVTFK66.d.mts +0 -105
  264. package/dist/index-DxVTFK66.d.mts.map +0 -1
  265. package/dist/index.d.mts +0 -80
  266. package/dist/index.d.mts.map +0 -1
  267. package/dist/index.mjs +0 -78
  268. package/dist/index.mjs.map +0 -1
  269. package/dist/indexing.d.mts +0 -152
  270. package/dist/indexing.d.mts.map +0 -1
  271. package/dist/indexing.mjs +0 -255
  272. package/dist/indexing.mjs.map +0 -1
  273. package/dist/node.d.mts +0 -373
  274. package/dist/node.d.mts.map +0 -1
  275. package/dist/node.mjs +0 -2572
  276. package/dist/node.mjs.map +0 -1
  277. package/dist/reader.d.mts +0 -15
  278. package/dist/reader.d.mts.map +0 -1
  279. package/dist/reader.mjs +0 -22
  280. package/dist/reader.mjs.map +0 -1
  281. package/dist/schemas/index.d.mts +0 -2
  282. package/dist/schemas/index.mjs +0 -2
  283. package/dist/schemas-CFRD0FIQ.mjs +0 -84
  284. package/dist/schemas-CFRD0FIQ.mjs.map +0 -1
  285. package/dist/site-8oaj1Q60.mjs +0 -366
  286. package/dist/site-8oaj1Q60.mjs.map +0 -1
  287. package/dist/site-index-B_254bCc.d.mts +0 -136
  288. package/dist/site-index-B_254bCc.d.mts.map +0 -1
  289. package/dist/types-DOdldbfD.mjs +0 -34
  290. package/dist/types-DOdldbfD.mjs.map +0 -1
  291. package/dist/types-DjfhS272.d.mts +0 -456
  292. package/dist/types-DjfhS272.d.mts.map +0 -1
  293. package/dist/vxjson-qHrgLGip.mjs +0 -555
  294. package/dist/vxjson-qHrgLGip.mjs.map +0 -1
  295. package/dist/vxjson-serialize-geF6qvpn.mjs +0 -34
  296. package/dist/vxjson-serialize-geF6qvpn.mjs.map +0 -1
  297. package/dist/vxjson-serialize.d.mts +0 -17
  298. package/dist/vxjson-serialize.d.mts.map +0 -1
  299. package/dist/vxjson-serialize.mjs +0 -2
@@ -1,629 +0,0 @@
1
- import { d as mapLocales, f as mapSiteNames, o as isContentPublished, u as localesOf } from "./content-utils-fWNHTrPy.mjs";
2
- //#region src/base-content-index.ts
3
- /**
4
- * Base class for content indexes (blocks, data)
5
- * Maintains collection->name->locale lookups with V8-optimized structures
6
- */
7
- var BaseContentIndex = class {
8
- index = /* @__PURE__ */ new Map();
9
- contentCache = /* @__PURE__ */ new Map();
10
- nameIndex = /* @__PURE__ */ new Map();
11
- collections = /* @__PURE__ */ new Set();
12
- /**
13
- * Add or update content in the index
14
- * Merges manifest locales and updates content cache if provided
15
- */
16
- addContent(identity, localeVersion, content) {
17
- const existing = this.index.get(identity.id);
18
- const locale = localeVersion.locale;
19
- if (existing) {
20
- const existingLocale = existing.locales[locale];
21
- if (!existingLocale || existingLocale.etag !== localeVersion.etag) existing.locales[locale] = localeVersion;
22
- } else {
23
- const newManifest = {
24
- id: identity.id,
25
- type: identity.type,
26
- kind: identity.kind,
27
- site: identity.site,
28
- collection: identity.collection,
29
- locales: { [locale]: localeVersion }
30
- };
31
- this.index.set(identity.id, newManifest);
32
- this.collections.add(identity.collection);
33
- }
34
- if (content !== void 0) {
35
- const existingCache = this.contentCache.get(identity.id);
36
- if (existingCache) existingCache[locale] = content;
37
- else this.contentCache.set(identity.id, { [locale]: content });
38
- }
39
- const manifestToIndex = existing || this.index.get(identity.id);
40
- if (localeVersion.name) {
41
- if (!this.nameIndex.has(identity.collection)) this.nameIndex.set(identity.collection, /* @__PURE__ */ new Map());
42
- this.nameIndex.get(identity.collection).set(localeVersion.name, manifestToIndex);
43
- }
44
- }
45
- /**
46
- * Remove a specific locale from an entry
47
- */
48
- removeLocale(id, locale) {
49
- const manifest = this.index.get(id);
50
- if (!manifest || !manifest.locales[locale]) return;
51
- manifest.locales[locale] = void 0;
52
- const contentCache = this.contentCache.get(id);
53
- if (contentCache) delete contentCache[locale];
54
- if (Object.values(manifest.locales).filter((v) => v !== void 0).length === 0) this.removeEntry(id);
55
- }
56
- /**
57
- * Remove an entry from the index
58
- */
59
- removeEntry(id) {
60
- const manifest = this.index.get(id);
61
- if (!manifest) return;
62
- for (const localeVersion of localesOf(manifest)) if (localeVersion.name) {
63
- const collectionMap = this.nameIndex.get(manifest.collection);
64
- if (collectionMap) collectionMap.delete(localeVersion.name);
65
- break;
66
- }
67
- this.index.delete(id);
68
- this.contentCache.delete(id);
69
- }
70
- /**
71
- * Get cached content for a specific locale
72
- */
73
- getCachedContent(id, locale) {
74
- return this.contentCache.get(id)?.[locale] || null;
75
- }
76
- /**
77
- * Get content manifest
78
- */
79
- getManifest(id) {
80
- return this.index.get(id) || null;
81
- }
82
- /**
83
- * Find entry by name
84
- */
85
- getByName(collection, name, locale) {
86
- const collectionMap = this.nameIndex.get(collection);
87
- if (!collectionMap) return null;
88
- const manifest = collectionMap.get(name);
89
- if (!manifest) return null;
90
- if (locale && !manifest.locales[locale]) return null;
91
- return manifest;
92
- }
93
- /**
94
- * Generator for all manifests
95
- */
96
- *getAllManifests() {
97
- for (const manifest of this.index.values()) yield manifest;
98
- }
99
- /**
100
- * Generator for manifests by locale
101
- */
102
- *getManifestsByLocale(locale) {
103
- for (const manifest of this.index.values()) if (manifest.locales[locale]) yield manifest;
104
- }
105
- /**
106
- * Generator for manifests by collection
107
- */
108
- *getManifestsByCollection(collection) {
109
- for (const manifest of this.index.values()) if (manifest.collection === collection) yield manifest;
110
- }
111
- /**
112
- * Get the count of indexed content entries (unique IDs)
113
- */
114
- get entryCount() {
115
- return this.index.size;
116
- }
117
- /**
118
- * Clear all indexes
119
- */
120
- clear() {
121
- this.index.clear();
122
- this.contentCache.clear();
123
- this.nameIndex.clear();
124
- this.collections.clear();
125
- }
126
- };
127
- //#endregion
128
- //#region src/block-index.ts
129
- /**
130
- * V8-optimized index for blocks
131
- * Maintains collection->name->locale lookups
132
- */
133
- var BlockIndex = class extends BaseContentIndex {
134
- constructor(locales) {
135
- super();
136
- }
137
- };
138
- //#endregion
139
- //#region src/data-index.ts
140
- /**
141
- * V8-optimized index for data collections
142
- * Maintains collection->name->locale lookups
143
- */
144
- var DataIndex = class extends BaseContentIndex {};
145
- //#endregion
146
- //#region src/site-index.ts
147
- /**
148
- * V8-optimized index for a single site
149
- * Maintains pathname lookups and collections for one site only
150
- */
151
- var SiteIndex = class {
152
- locales;
153
- index = /* @__PURE__ */ new Map();
154
- contentCache = /* @__PURE__ */ new Map();
155
- pathnameIndex;
156
- previousPathnameIndex;
157
- collections = /* @__PURE__ */ new Set();
158
- constructor(siteName, locales) {
159
- this.locales = locales;
160
- this.pathnameIndex = mapLocales(locales, () => /* @__PURE__ */ new Map());
161
- this.previousPathnameIndex = mapLocales(locales, () => /* @__PURE__ */ new Map());
162
- }
163
- /**
164
- * Add or update content in the index
165
- * Merges manifest locales and updates content cache if provided
166
- */
167
- addContent(identity, localeVersion, content) {
168
- const existing = this.index.get(identity.id);
169
- const locale = localeVersion.locale;
170
- if (existing) {
171
- const existingLocale = existing.locales[locale];
172
- let oldPathname;
173
- for (const [pathname, indexedManifest] of this.pathnameIndex[locale].entries()) if (indexedManifest === existing && pathname !== localeVersion.pathname) {
174
- oldPathname = pathname;
175
- break;
176
- }
177
- if (!oldPathname && existingLocale?.pathname && existingLocale.pathname !== localeVersion.pathname) oldPathname = existingLocale.pathname;
178
- const hadExistingLocale = !!existingLocale;
179
- let deletedOldPathname = false;
180
- let addedNewPathname = false;
181
- const addedPreviousPathnames = [];
182
- if (!existingLocale || existingLocale.etag !== localeVersion.etag || existingLocale.modified !== localeVersion.modified || oldPathname && oldPathname !== localeVersion.pathname) try {
183
- existing.locales[locale] = localeVersion;
184
- if (localeVersion.pathname) {
185
- if (oldPathname && oldPathname !== localeVersion.pathname) {
186
- this.pathnameIndex[locale].delete(oldPathname);
187
- deletedOldPathname = true;
188
- if (isContentPublished(localeVersion)) {
189
- this.previousPathnameIndex[locale].set(oldPathname, existing);
190
- addedPreviousPathnames.push(oldPathname);
191
- }
192
- }
193
- this.pathnameIndex[locale].set(localeVersion.pathname, existing);
194
- addedNewPathname = true;
195
- }
196
- if (localeVersion.previousPathnames) {
197
- for (const prevPath of Object.keys(localeVersion.previousPathnames)) if (!this.previousPathnameIndex[locale].has(prevPath)) {
198
- this.previousPathnameIndex[locale].set(prevPath, existing);
199
- addedPreviousPathnames.push(prevPath);
200
- }
201
- }
202
- } catch (error) {
203
- if (hadExistingLocale) existing.locales[locale] = existingLocale;
204
- else existing.locales[locale] = void 0;
205
- if (deletedOldPathname && oldPathname) this.pathnameIndex[locale].set(oldPathname, existing);
206
- if (addedNewPathname && localeVersion.pathname) this.pathnameIndex[locale].delete(localeVersion.pathname);
207
- for (const prevPath of addedPreviousPathnames) this.previousPathnameIndex[locale].delete(prevPath);
208
- throw error;
209
- }
210
- } else {
211
- const newManifest = {
212
- id: identity.id,
213
- type: identity.type,
214
- kind: identity.kind,
215
- site: identity.site,
216
- collection: identity.collection,
217
- locales: { [locale]: localeVersion }
218
- };
219
- this.index.set(identity.id, newManifest);
220
- this.collections.add(identity.collection);
221
- if (localeVersion.pathname) this.pathnameIndex[locale].set(localeVersion.pathname, newManifest);
222
- if (localeVersion.previousPathnames) for (const prevPath of Object.keys(localeVersion.previousPathnames)) this.previousPathnameIndex[locale].set(prevPath, newManifest);
223
- }
224
- if (content !== void 0) {
225
- const existingCache = this.contentCache.get(identity.id);
226
- if (existingCache) existingCache[locale] = content;
227
- else this.contentCache.set(identity.id, { [locale]: content });
228
- }
229
- }
230
- /**
231
- * Remove a specific locale from an entry
232
- */
233
- removeLocale(id, locale) {
234
- const manifest = this.index.get(id);
235
- if (!manifest || !manifest.locales[locale]) return;
236
- const localeVersion = manifest.locales[locale];
237
- if (localeVersion.pathname) this.pathnameIndex[locale].delete(localeVersion.pathname);
238
- if (localeVersion.previousPathnames) for (const prevPath of Object.keys(localeVersion.previousPathnames)) this.previousPathnameIndex[locale].delete(prevPath);
239
- manifest.locales[locale] = void 0;
240
- const contentCache = this.contentCache.get(id);
241
- if (contentCache) delete contentCache[locale];
242
- if (Object.keys(manifest.locales).length === 0) this.removeEntry(id);
243
- }
244
- /**
245
- * Remove an entry from the index
246
- */
247
- removeEntry(id) {
248
- const manifest = this.index.get(id);
249
- if (!manifest) return;
250
- for (const localeVersion of localesOf(manifest)) {
251
- const { locale } = localeVersion;
252
- if (localeVersion.pathname) this.pathnameIndex[locale].delete(localeVersion.pathname);
253
- if (localeVersion.previousPathnames) for (const prevPath of Object.keys(localeVersion.previousPathnames)) this.previousPathnameIndex[locale].delete(prevPath);
254
- }
255
- this.index.delete(id);
256
- this.contentCache.delete(id);
257
- }
258
- /**
259
- * Get cached content for a specific locale
260
- */
261
- getCachedContent(id, locale) {
262
- return this.contentCache.get(id)?.[locale] || null;
263
- }
264
- /**
265
- * Get content manifest
266
- */
267
- getManifest(id) {
268
- return this.index.get(id) || null;
269
- }
270
- /**
271
- * Find content by pathname
272
- */
273
- getByPathname(pathname, locale) {
274
- if (locale) return this.pathnameIndex[locale]?.get(pathname) || null;
275
- for (const locale of this.locales) {
276
- const manifest = this.pathnameIndex[locale].get(pathname);
277
- if (manifest) return manifest;
278
- }
279
- return null;
280
- }
281
- /**
282
- * Find content by previous pathname (for redirects)
283
- */
284
- getByPreviousPathname(pathname, locale) {
285
- if (locale) return this.previousPathnameIndex[locale]?.get(pathname) || null;
286
- for (const locale of this.locales) {
287
- const manifest = this.previousPathnameIndex[locale].get(pathname);
288
- if (manifest) return manifest;
289
- }
290
- return null;
291
- }
292
- /**
293
- * Generator for all manifests
294
- */
295
- *getAllManifests() {
296
- for (const manifest of this.index.values()) yield manifest;
297
- }
298
- /**
299
- * Generator for manifests by locale
300
- */
301
- *getManifestsByLocale(locale) {
302
- for (const manifest of this.index.values()) if (manifest.locales[locale]) yield manifest;
303
- }
304
- /**
305
- * Get the count of indexed content entries (unique IDs)
306
- */
307
- get entryCount() {
308
- return this.index.size;
309
- }
310
- /**
311
- * Clear all indexes
312
- */
313
- clear() {
314
- this.index.clear();
315
- this.contentCache.clear();
316
- for (const locale of this.locales) {
317
- this.pathnameIndex[locale].clear();
318
- this.previousPathnameIndex[locale].clear();
319
- }
320
- this.collections.clear();
321
- }
322
- };
323
- //#endregion
324
- //#region src/content-index.ts
325
- /**
326
- * ContentIndex coordinates between per-site indexes and the block index
327
- * This provides efficient filtering by routing to the appropriate specialized index
328
- */
329
- const globalCache = globalThis.__CONLOCA_CONTENT_INDEX_CACHE__ || {};
330
- if (!globalThis.__CONLOCA_CONTENT_INDEX_CACHE__) globalThis.__CONLOCA_CONTENT_INDEX_CACHE__ = globalCache;
331
- var ContentIndex = class ContentIndex {
332
- sitesConfig;
333
- static get cache() {
334
- return globalCache;
335
- }
336
- siteIndexes;
337
- blockIndex;
338
- dataIndex;
339
- constructor(sitesConfig) {
340
- this.sitesConfig = sitesConfig;
341
- this.blockIndex = new BlockIndex(sitesConfig.globalLocales);
342
- this.dataIndex = new DataIndex();
343
- this.siteIndexes = mapSiteNames(sitesConfig, (siteName) => {
344
- const siteConfig = sitesConfig.sites[siteName];
345
- return new SiteIndex(siteName, siteConfig.locales);
346
- });
347
- }
348
- /**
349
- * Get cached index or create a new one
350
- */
351
- static async getCachedOrCreate(contentRoot, sitesConfig) {
352
- if (!ContentIndex.cache[contentRoot]) ContentIndex.cache[contentRoot] = new ContentIndex(sitesConfig);
353
- return ContentIndex.cache[contentRoot];
354
- }
355
- /**
356
- * Clear all cached indexes
357
- */
358
- static clearCache() {
359
- for (const key of Object.keys(globalCache)) delete globalCache[key];
360
- }
361
- /**
362
- * Create a new index without caching - for testing
363
- */
364
- static createUncached(sitesConfig) {
365
- return new ContentIndex(sitesConfig);
366
- }
367
- /**
368
- * Add or update content in the appropriate index
369
- * Updates a single locale's manifest and content cache if provided
370
- */
371
- addContent(identity, localeVersion, content) {
372
- if ((identity.kind === "block" || identity.kind === "data") && identity.site) throw new Error(`${identity.kind} cannot have a site property`);
373
- if (identity.kind === "page" && !identity.site) throw new Error("Pages must have a site property");
374
- if (identity.kind === "block") this.blockIndex.addContent(identity, localeVersion, content);
375
- else if (identity.kind === "data") this.dataIndex.addContent(identity, localeVersion, content);
376
- else {
377
- const siteIndex = this.siteIndexes[identity.site];
378
- if (siteIndex) siteIndex.addContent(identity, localeVersion, content);
379
- }
380
- }
381
- /**
382
- * Remove a specific locale from content
383
- */
384
- removeLocale(id, locale) {
385
- const manifest = this.getManifest(id);
386
- if (!manifest) return;
387
- if (manifest.kind === "block") this.blockIndex.removeLocale(id, locale);
388
- else if (manifest.kind === "data") this.dataIndex.removeLocale(id, locale);
389
- else {
390
- const siteIndex = this.siteIndexes[manifest.site];
391
- if (siteIndex) siteIndex.removeLocale(id, locale);
392
- }
393
- }
394
- /**
395
- * Get cached content
396
- */
397
- getCachedContent(id, locale) {
398
- const manifest = this.getManifest(id);
399
- if (!manifest) return null;
400
- if (manifest.kind === "block") return this.blockIndex.getCachedContent(id, locale);
401
- if (manifest.kind === "data") return this.dataIndex.getCachedContent(id, locale);
402
- const siteIndex = this.siteIndexes[manifest.site];
403
- return siteIndex ? siteIndex.getCachedContent(id, locale) : null;
404
- }
405
- /**
406
- * Remove an entry from all indexes
407
- */
408
- removeEntry(id) {
409
- this.blockIndex.removeEntry(id);
410
- this.dataIndex.removeEntry(id);
411
- for (const site in this.siteIndexes) {
412
- const siteIndex = this.siteIndexes[site];
413
- if (siteIndex) siteIndex.removeEntry(id);
414
- }
415
- }
416
- /**
417
- * Get content manifest for a content ID
418
- */
419
- getManifest(id) {
420
- let manifest = this.blockIndex.getManifest(id);
421
- if (manifest) return manifest;
422
- manifest = this.dataIndex.getManifest(id);
423
- if (manifest) return manifest;
424
- for (const site in this.siteIndexes) {
425
- const siteIndex = this.siteIndexes[site];
426
- if (siteIndex) {
427
- manifest = siteIndex.getManifest(id);
428
- if (manifest) return manifest;
429
- }
430
- }
431
- return null;
432
- }
433
- /**
434
- * Get a specific locale manifest
435
- */
436
- getLocaleVersion(id, locale) {
437
- const manifest = this.getManifest(id);
438
- if (!manifest) return null;
439
- return manifest.locales[locale] || null;
440
- }
441
- /**
442
- * Get site index
443
- */
444
- getSiteIndex(site) {
445
- return this.siteIndexes[site] || null;
446
- }
447
- /**
448
- * Get block index
449
- */
450
- getBlockIndex() {
451
- return this.blockIndex;
452
- }
453
- /**
454
- * Find content by pathname (delegates to site indexes)
455
- */
456
- getByPathname(site, pathname, locale) {
457
- const siteIndex = this.siteIndexes[site];
458
- return siteIndex ? siteIndex.getByPathname(pathname, locale) : null;
459
- }
460
- /**
461
- * Find content by previous pathname (for redirects)
462
- */
463
- getByPreviousPathname(site, pathname, locale) {
464
- const siteIndex = this.siteIndexes[site];
465
- return siteIndex ? siteIndex.getByPreviousPathname(pathname, locale) : null;
466
- }
467
- /**
468
- * Find block by name
469
- */
470
- getBlockByName(collection, name, locale) {
471
- return this.blockIndex.getByName(collection, name, locale);
472
- }
473
- /**
474
- * Get data index
475
- */
476
- getDataIndex() {
477
- return this.dataIndex;
478
- }
479
- /**
480
- * Find data entry by name
481
- */
482
- getDataByName(collection, name, locale) {
483
- return this.dataIndex.getByName(collection, name, locale);
484
- }
485
- /**
486
- * Get all collections for data
487
- */
488
- getDataCollections() {
489
- return this.dataIndex.collections;
490
- }
491
- /**
492
- * List all content (for iteration)
493
- */
494
- *listAllContent() {
495
- yield* this.blockIndex.getAllManifests();
496
- yield* this.dataIndex.getAllManifests();
497
- for (const site in this.siteIndexes) {
498
- const siteIndex = this.siteIndexes[site];
499
- if (siteIndex) yield* siteIndex.getAllManifests();
500
- }
501
- }
502
- /**
503
- * Generator for all sites
504
- */
505
- *allSites() {
506
- for (const site in this.siteIndexes) if (this.siteIndexes[site]) yield site;
507
- }
508
- /**
509
- * Get all collections for a site
510
- */
511
- getCollectionsForSite(site) {
512
- const siteIndex = this.siteIndexes[site];
513
- return siteIndex ? siteIndex.collections : /* @__PURE__ */ new Set();
514
- }
515
- /**
516
- * Get all collections for blocks
517
- */
518
- getBlockCollections() {
519
- return this.blockIndex.collections;
520
- }
521
- /**
522
- * Get default locale for a site
523
- */
524
- getDefaultLocale(site) {
525
- if (!site) return this.sitesConfig.globalLocales[0];
526
- return this.sitesConfig.sites[site]?.defaultLocale || this.sitesConfig.globalLocales[0];
527
- }
528
- /**
529
- * Find content missing a specific locale
530
- */
531
- *findUntranslatedContent(targetLocale, options) {
532
- for (const manifest of this.blockIndex.getAllManifests()) if (!manifest.locales[targetLocale]) {
533
- if (!options?.includeUnpublished) {
534
- let hasPublishedLocale = false;
535
- for (const locale of localesOf(manifest)) if (!locale.unpublishAt || new Date(locale.unpublishAt) > /* @__PURE__ */ new Date()) {
536
- hasPublishedLocale = true;
537
- break;
538
- }
539
- if (!hasPublishedLocale) continue;
540
- }
541
- yield manifest;
542
- }
543
- for (const siteName in this.siteIndexes) {
544
- const siteIndex = this.siteIndexes[siteName];
545
- if (!siteIndex || options?.excludeSites?.includes(siteName)) continue;
546
- for (const manifest of siteIndex.getAllManifests()) if (!manifest.locales[targetLocale]) {
547
- if (!options?.includeUnpublished) {
548
- let hasPublishedLocale = false;
549
- for (const locale of localesOf(manifest)) if (!locale.unpublishAt || new Date(locale.unpublishAt) > /* @__PURE__ */ new Date()) {
550
- hasPublishedLocale = true;
551
- break;
552
- }
553
- if (!hasPublishedLocale) continue;
554
- }
555
- yield manifest;
556
- }
557
- }
558
- }
559
- /**
560
- * Generators for efficient filtering
561
- */
562
- *getManifestsForKind(kind) {
563
- if (kind === "block") yield* this.blockIndex.getAllManifests();
564
- else if (kind === "data") yield* this.dataIndex.getAllManifests();
565
- else for (const site in this.siteIndexes) {
566
- const siteIndex = this.siteIndexes[site];
567
- if (siteIndex) yield* siteIndex.getAllManifests();
568
- }
569
- }
570
- *getManifestsForSite(site) {
571
- const siteIndex = this.siteIndexes[site];
572
- if (siteIndex) yield* siteIndex.getAllManifests();
573
- }
574
- *getManifestsForSiteLocale(site, locale) {
575
- const siteIndex = this.siteIndexes[site];
576
- if (siteIndex) yield* siteIndex.getManifestsByLocale(locale);
577
- }
578
- *getManifestsForSiteCollection(site, collection) {
579
- const siteIndex = this.siteIndexes[site];
580
- if (siteIndex) {
581
- for (const manifest of siteIndex.getAllManifests()) if (manifest.collection === collection) yield manifest;
582
- }
583
- }
584
- *getManifestsForLocale(locale) {
585
- yield* this.blockIndex.getManifestsByLocale(locale);
586
- yield* this.dataIndex.getManifestsByLocale(locale);
587
- for (const site in this.siteIndexes) {
588
- const siteIndex = this.siteIndexes[site];
589
- if (siteIndex) yield* siteIndex.getManifestsByLocale(locale);
590
- }
591
- }
592
- *getManifestsForCollection(collection) {
593
- yield* this.blockIndex.getManifestsByCollection(collection);
594
- yield* this.dataIndex.getManifestsByCollection(collection);
595
- for (const site in this.siteIndexes) {
596
- const siteIndex = this.siteIndexes[site];
597
- if (siteIndex) {
598
- for (const manifest of siteIndex.getAllManifests()) if (manifest.collection === collection) yield manifest;
599
- }
600
- }
601
- }
602
- /**
603
- * Get the count of indexed content entries
604
- */
605
- get entryCount() {
606
- let count = this.blockIndex.entryCount;
607
- count += this.dataIndex.entryCount;
608
- for (const site in this.siteIndexes) {
609
- const siteIndex = this.siteIndexes[site];
610
- if (siteIndex) count += siteIndex.entryCount;
611
- }
612
- return count;
613
- }
614
- /**
615
- * Clear all indexes
616
- */
617
- clear() {
618
- this.blockIndex.clear();
619
- this.dataIndex.clear();
620
- for (const site in this.siteIndexes) {
621
- const siteIndex = this.siteIndexes[site];
622
- if (siteIndex) siteIndex.clear();
623
- }
624
- }
625
- };
626
- //#endregion
627
- export { ContentIndex as t };
628
-
629
- //# sourceMappingURL=content-index-D092_vk1.mjs.map