@conloca/content-api 0.1.15 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) 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 +164 -0
  10. package/dist/asset-operations.d.ts.map +1 -0
  11. package/dist/asset-operations.js +784 -0
  12. package/dist/asset-operations.js.map +1 -0
  13. package/dist/asset-types.d.ts +72 -0
  14. package/dist/asset-types.d.ts.map +1 -0
  15. package/dist/asset-types.js +13 -0
  16. package/dist/asset-types.js.map +1 -0
  17. package/dist/asset-usage.d.ts +10 -0
  18. package/dist/asset-usage.d.ts.map +1 -0
  19. package/dist/asset-usage.js +49 -0
  20. package/dist/asset-usage.js.map +1 -0
  21. package/dist/base-content-index.d.ts +63 -0
  22. package/dist/base-content-index.d.ts.map +1 -0
  23. package/dist/base-content-index.js +200 -0
  24. package/dist/base-content-index.js.map +1 -0
  25. package/dist/cf-access.d.ts +31 -0
  26. package/dist/cf-access.d.ts.map +1 -0
  27. package/dist/cf-access.js +67 -0
  28. package/dist/cf-access.js.map +1 -0
  29. package/dist/component-registry.d.ts +50 -0
  30. package/dist/component-registry.d.ts.map +1 -0
  31. package/dist/component-registry.js +121 -0
  32. package/dist/component-registry.js.map +1 -0
  33. package/dist/component-registry.types.d.ts +11 -0
  34. package/dist/component-registry.types.d.ts.map +1 -0
  35. package/dist/component-registry.types.js +2 -0
  36. package/dist/component-registry.types.js.map +1 -0
  37. package/dist/component-vocabulary.d.ts +33 -0
  38. package/dist/component-vocabulary.d.ts.map +1 -0
  39. package/dist/component-vocabulary.js +105 -0
  40. package/dist/component-vocabulary.js.map +1 -0
  41. package/dist/content-api.interface.d.ts +64 -0
  42. package/dist/content-api.interface.d.ts.map +1 -0
  43. package/dist/content-api.interface.js +2 -0
  44. package/dist/content-api.interface.js.map +1 -0
  45. package/dist/content-filters.d.ts +31 -0
  46. package/dist/content-filters.d.ts.map +1 -0
  47. package/dist/content-filters.js +247 -0
  48. package/dist/content-filters.js.map +1 -0
  49. package/dist/content-index.d.ts +184 -0
  50. package/dist/content-index.d.ts.map +1 -0
  51. package/dist/content-index.js +546 -0
  52. package/dist/content-index.js.map +1 -0
  53. package/dist/content-operations.d.ts +157 -0
  54. package/dist/content-operations.d.ts.map +1 -0
  55. package/dist/content-operations.js +359 -0
  56. package/dist/content-operations.js.map +1 -0
  57. package/dist/content-path.d.ts +59 -0
  58. package/dist/content-path.d.ts.map +1 -0
  59. package/dist/content-path.js +88 -0
  60. package/dist/content-path.js.map +1 -0
  61. package/dist/content-reader.d.ts +10 -0
  62. package/dist/content-reader.d.ts.map +1 -0
  63. package/dist/content-reader.js +14 -0
  64. package/dist/content-reader.js.map +1 -0
  65. package/dist/content-utils.d.ts +175 -0
  66. package/dist/content-utils.d.ts.map +1 -0
  67. package/dist/content-utils.js +421 -0
  68. package/dist/content-utils.js.map +1 -0
  69. package/dist/content-watcher.d.ts +43 -0
  70. package/dist/content-watcher.d.ts.map +1 -0
  71. package/dist/content-watcher.js +86 -0
  72. package/dist/content-watcher.js.map +1 -0
  73. package/dist/data-index.d.ts +8 -0
  74. package/dist/data-index.d.ts.map +1 -0
  75. package/dist/data-index.js +8 -0
  76. package/dist/data-index.js.map +1 -0
  77. package/dist/data.d.ts +35 -0
  78. package/dist/data.d.ts.map +1 -0
  79. package/dist/data.js +104 -0
  80. package/dist/data.js.map +1 -0
  81. package/dist/editor-data-bindings.d.ts +10 -0
  82. package/dist/editor-data-bindings.d.ts.map +1 -0
  83. package/dist/editor-data-bindings.js +67 -0
  84. package/dist/editor-data-bindings.js.map +1 -0
  85. package/dist/etag-utils.d.ts +77 -0
  86. package/dist/etag-utils.d.ts.map +1 -0
  87. package/dist/etag-utils.js +161 -0
  88. package/dist/etag-utils.js.map +1 -0
  89. package/dist/filesystem-content-api.d.ts +162 -0
  90. package/dist/filesystem-content-api.d.ts.map +1 -0
  91. package/dist/filesystem-content-api.js +2307 -0
  92. package/dist/filesystem-content-api.js.map +1 -0
  93. package/dist/filesystem-reader-backend.d.ts +46 -0
  94. package/dist/filesystem-reader-backend.d.ts.map +1 -0
  95. package/dist/filesystem-reader-backend.js +119 -0
  96. package/dist/filesystem-reader-backend.js.map +1 -0
  97. package/dist/fragment-index.d.ts +8 -0
  98. package/dist/fragment-index.d.ts.map +1 -0
  99. package/dist/fragment-index.js +8 -0
  100. package/dist/fragment-index.js.map +1 -0
  101. package/dist/fragments.d.ts +16 -0
  102. package/dist/fragments.d.ts.map +1 -0
  103. package/dist/fragments.js +104 -0
  104. package/dist/fragments.js.map +1 -0
  105. package/dist/git-operations.d.ts +49 -0
  106. package/dist/git-operations.d.ts.map +1 -0
  107. package/dist/git-operations.js +256 -0
  108. package/dist/git-operations.js.map +1 -0
  109. package/dist/header-parser.d.ts +37 -0
  110. package/dist/header-parser.d.ts.map +1 -0
  111. package/dist/header-parser.js +233 -0
  112. package/dist/header-parser.js.map +1 -0
  113. package/dist/in-memory-content-api.d.ts +35 -0
  114. package/dist/in-memory-content-api.d.ts.map +1 -0
  115. package/dist/in-memory-content-api.js +609 -0
  116. package/dist/in-memory-content-api.js.map +1 -0
  117. package/dist/index.d.ts +26 -0
  118. package/dist/index.d.ts.map +1 -0
  119. package/dist/index.js +28 -0
  120. package/dist/index.js.map +1 -0
  121. package/dist/indexing.d.ts +5 -0
  122. package/dist/indexing.d.ts.map +1 -0
  123. package/dist/indexing.js +8 -0
  124. package/dist/indexing.js.map +1 -0
  125. package/dist/json-whitespace-view.d.ts +32 -0
  126. package/dist/json-whitespace-view.d.ts.map +1 -0
  127. package/dist/json-whitespace-view.js +153 -0
  128. package/dist/json-whitespace-view.js.map +1 -0
  129. package/dist/middleware.d.ts +20 -0
  130. package/dist/middleware.d.ts.map +1 -0
  131. package/dist/middleware.js +1082 -0
  132. package/dist/middleware.js.map +1 -0
  133. package/dist/node.d.ts +32 -0
  134. package/dist/node.d.ts.map +1 -0
  135. package/dist/node.js +27 -0
  136. package/dist/node.js.map +1 -0
  137. package/dist/page-references.d.ts +21 -0
  138. package/dist/page-references.d.ts.map +1 -0
  139. package/dist/page-references.js +50 -0
  140. package/dist/page-references.js.map +1 -0
  141. package/dist/read-date.d.ts +3 -0
  142. package/dist/read-date.d.ts.map +1 -0
  143. package/dist/read-date.js +9 -0
  144. package/dist/read-date.js.map +1 -0
  145. package/dist/reader-backend.d.ts +54 -0
  146. package/dist/reader-backend.d.ts.map +1 -0
  147. package/dist/reader-backend.js +2 -0
  148. package/dist/reader-backend.js.map +1 -0
  149. package/dist/reader.d.ts +15 -0
  150. package/dist/reader.d.ts.map +1 -0
  151. package/dist/reader.js +14 -0
  152. package/dist/reader.js.map +1 -0
  153. package/dist/schemas/index.d.ts +102 -0
  154. package/dist/schemas/index.d.ts.map +1 -0
  155. package/dist/schemas/index.js +88 -0
  156. package/dist/schemas/index.js.map +1 -0
  157. package/dist/site-index.d.ts +60 -0
  158. package/dist/site-index.d.ts.map +1 -0
  159. package/dist/site-index.js +291 -0
  160. package/dist/site-index.js.map +1 -0
  161. package/dist/site.d.ts +23 -0
  162. package/dist/site.d.ts.map +1 -0
  163. package/dist/site.js +180 -0
  164. package/dist/site.js.map +1 -0
  165. package/dist/types.d.ts +641 -0
  166. package/dist/types.d.ts.map +1 -0
  167. package/dist/types.js +45 -0
  168. package/dist/types.js.map +1 -0
  169. package/dist/url-safe-base64.d.ts +12 -0
  170. package/dist/url-safe-base64.d.ts.map +1 -0
  171. package/dist/url-safe-base64.js +41 -0
  172. package/dist/url-safe-base64.js.map +1 -0
  173. package/dist/url-validation.d.ts +28 -0
  174. package/dist/url-validation.d.ts.map +1 -0
  175. package/dist/url-validation.js +123 -0
  176. package/dist/url-validation.js.map +1 -0
  177. package/dist/utils/atomic-write.d.ts +6 -0
  178. package/dist/utils/atomic-write.d.ts.map +1 -0
  179. package/dist/utils/atomic-write.js +21 -0
  180. package/dist/utils/atomic-write.js.map +1 -0
  181. package/dist/utils.d.ts +46 -0
  182. package/dist/utils.d.ts.map +1 -0
  183. package/dist/utils.js +71 -0
  184. package/dist/utils.js.map +1 -0
  185. package/dist/vite-plugin.d.ts +12 -0
  186. package/dist/vite-plugin.d.ts.map +1 -0
  187. package/dist/vite-plugin.js +30 -0
  188. package/dist/vite-plugin.js.map +1 -0
  189. package/dist/vxjson-serialize.d.ts +13 -0
  190. package/dist/vxjson-serialize.d.ts.map +1 -0
  191. package/dist/vxjson-serialize.js +53 -0
  192. package/dist/vxjson-serialize.js.map +1 -0
  193. package/dist/vxjson.d.ts +113 -0
  194. package/dist/vxjson.d.ts.map +1 -0
  195. package/dist/vxjson.js +381 -0
  196. package/dist/vxjson.js.map +1 -0
  197. package/dist/xxhash.d.ts +10 -0
  198. package/dist/xxhash.d.ts.map +1 -0
  199. package/dist/xxhash.js +35 -0
  200. package/dist/xxhash.js.map +1 -0
  201. package/package.json +132 -34
  202. package/src/asset-constraints.ts +33 -0
  203. package/src/asset-metadata-store.ts +401 -0
  204. package/src/asset-operations.ts +914 -0
  205. package/src/asset-types.ts +74 -0
  206. package/src/asset-usage.ts +47 -0
  207. package/src/base-content-index.ts +227 -0
  208. package/src/cf-access.ts +85 -0
  209. package/src/component-registry.ts +145 -0
  210. package/src/component-registry.types.ts +12 -0
  211. package/src/component-vocabulary.ts +87 -0
  212. package/src/content-api.interface.ts +94 -0
  213. package/src/content-filters.ts +278 -0
  214. package/src/content-index.ts +642 -0
  215. package/src/content-operations.ts +497 -0
  216. package/src/content-path.ts +113 -0
  217. package/src/content-reader.ts +18 -0
  218. package/src/content-utils.ts +474 -0
  219. package/src/content-watcher.ts +122 -0
  220. package/src/data-index.ts +7 -0
  221. package/src/data.ts +134 -0
  222. package/src/editor-data-bindings.ts +66 -0
  223. package/src/etag-utils.ts +204 -0
  224. package/src/filesystem-content-api.ts +2685 -0
  225. package/src/filesystem-reader-backend.ts +135 -0
  226. package/src/fragment-index.ts +7 -0
  227. package/src/fragments.ts +113 -0
  228. package/src/git-operations.ts +340 -0
  229. package/src/header-parser.ts +272 -0
  230. package/src/in-memory-content-api.ts +760 -0
  231. package/src/index.ts +45 -0
  232. package/src/indexing.ts +8 -0
  233. package/src/json-whitespace-view.ts +155 -0
  234. package/src/middleware.ts +1341 -0
  235. package/src/node.ts +40 -0
  236. package/src/page-references.ts +76 -0
  237. package/src/read-date.ts +7 -0
  238. package/src/reader-backend.ts +54 -0
  239. package/src/reader.ts +15 -0
  240. package/src/schemas/index.ts +113 -0
  241. package/src/site-index.ts +330 -0
  242. package/src/site.ts +198 -0
  243. package/src/types.ts +759 -0
  244. package/src/url-safe-base64.ts +38 -0
  245. package/src/url-validation.ts +121 -0
  246. package/src/utils/atomic-write.ts +20 -0
  247. package/src/utils.ts +84 -0
  248. package/src/vite-plugin.ts +45 -0
  249. package/src/vxjson-serialize.ts +66 -0
  250. package/src/vxjson.ts +442 -0
  251. package/src/xxhash.ts +43 -0
  252. package/dist/component-registry.types-CBGONnYn.d.mts +0 -71
  253. package/dist/component-registry.types-CBGONnYn.d.mts.map +0 -1
  254. package/dist/content-operations-Dv67amz3.d.mts +0 -852
  255. package/dist/content-operations-Dv67amz3.d.mts.map +0 -1
  256. package/dist/data-Db1Iv9T0.mjs +0 -60
  257. package/dist/data-Db1Iv9T0.mjs.map +0 -1
  258. package/dist/filesystem-content-api-C1TM0GLo.d.mts +0 -119
  259. package/dist/filesystem-content-api-C1TM0GLo.d.mts.map +0 -1
  260. package/dist/filesystem-content-api-kxKY5IUw.mjs +0 -2678
  261. package/dist/filesystem-content-api-kxKY5IUw.mjs.map +0 -1
  262. package/dist/index.d.mts +0 -79
  263. package/dist/index.d.mts.map +0 -1
  264. package/dist/index.mjs +0 -47
  265. package/dist/index.mjs.map +0 -1
  266. package/dist/node.d.mts +0 -378
  267. package/dist/node.d.mts.map +0 -1
  268. package/dist/node.mjs +0 -2618
  269. package/dist/node.mjs.map +0 -1
  270. package/dist/reader.d.mts +0 -18
  271. package/dist/reader.d.mts.map +0 -1
  272. package/dist/reader.mjs +0 -22
  273. package/dist/reader.mjs.map +0 -1
  274. package/dist/schemas/index.d.mts +0 -90
  275. package/dist/schemas/index.d.mts.map +0 -1
  276. package/dist/schemas/index.mjs +0 -70
  277. package/dist/schemas/index.mjs.map +0 -1
  278. package/dist/site-vNtJ5jCh.mjs +0 -538
  279. package/dist/site-vNtJ5jCh.mjs.map +0 -1
  280. package/dist/types-DWt912tu.mjs +0 -33
  281. package/dist/types-DWt912tu.mjs.map +0 -1
package/dist/types.js ADDED
@@ -0,0 +1,45 @@
1
+ // Common error codes
2
+ export const ErrorCodes = {
3
+ // Content errors
4
+ CONTENT_NOT_FOUND: 'CONTENT_NOT_FOUND',
5
+ LOCALE_NOT_FOUND: 'LOCALE_NOT_FOUND',
6
+ COLLECTION_NOT_FOUND: 'COLLECTION_NOT_FOUND',
7
+ SITE_NOT_FOUND: 'SITE_NOT_FOUND',
8
+ // Write errors
9
+ STALE_WRITE: 'STALE_WRITE',
10
+ ALREADY_EXISTS: 'ALREADY_EXISTS',
11
+ PATHNAME_TAKEN: 'PATHNAME_TAKEN',
12
+ INVALID_PATHNAME: 'INVALID_PATHNAME',
13
+ NAME_TAKEN: 'NAME_TAKEN',
14
+ METADATA_TOO_LARGE: 'METADATA_TOO_LARGE',
15
+ WRITE_ERROR: 'WRITE_ERROR',
16
+ // Validation errors
17
+ MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',
18
+ INVALID_LOCALE: 'INVALID_LOCALE',
19
+ INVALID_CONTENT_TYPE: 'INVALID_CONTENT_TYPE',
20
+ INVALID_REQUEST: 'INVALID_REQUEST',
21
+ MDX_COMPILE_FAILED: 'MDX_COMPILE_FAILED',
22
+ // Request errors
23
+ /** A write another website sent through the developer's browser. */
24
+ FORBIDDEN: 'FORBIDDEN',
25
+ // System errors
26
+ INTERNAL_ERROR: 'INTERNAL_ERROR',
27
+ FETCH_ERROR: 'FETCH_ERROR',
28
+ // Git errors
29
+ GIT_NOT_REPO: 'GIT_NOT_REPO',
30
+ GIT_COMMIT_FAILED: 'GIT_COMMIT_FAILED',
31
+ GIT_PUSH_FAILED: 'GIT_PUSH_FAILED',
32
+ GIT_PULL_FAILED: 'GIT_PULL_FAILED',
33
+ GIT_STATUS_FAILED: 'GIT_STATUS_FAILED',
34
+ // Asset errors
35
+ ASSET_NOT_FOUND: 'ASSET_NOT_FOUND',
36
+ ASSET_INVALID_FORMAT: 'ASSET_INVALID_FORMAT',
37
+ ASSET_TOO_LARGE: 'ASSET_TOO_LARGE',
38
+ ASSET_UPLOAD_FAILED: 'ASSET_UPLOAD_FAILED',
39
+ // Preview errors
40
+ /** The target site is not serving the preview endpoint, so a generated
41
+ * preview URL would 404 there. This describes the target deployment, not a
42
+ * failure of the request — callers must not render it as an error. */
43
+ PREVIEW_NOT_DEPLOYED: 'PREVIEW_NOT_DEPLOYED',
44
+ };
45
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAwFA,qBAAqB;AACrB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,iBAAiB;IACjB,iBAAiB,EAAE,mBAAmB;IACtC,gBAAgB,EAAE,kBAAkB;IACpC,oBAAoB,EAAE,sBAAsB;IAC5C,cAAc,EAAE,gBAAgB;IAEhC,eAAe;IACf,WAAW,EAAE,aAAa;IAC1B,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,UAAU,EAAE,YAAY;IACxB,kBAAkB,EAAE,oBAAoB;IACxC,WAAW,EAAE,aAAa;IAE1B,oBAAoB;IACpB,sBAAsB,EAAE,wBAAwB;IAChD,cAAc,EAAE,gBAAgB;IAChC,oBAAoB,EAAE,sBAAsB;IAC5C,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB;IAExC,iBAAiB;IACjB,oEAAoE;IACpE,SAAS,EAAE,WAAW;IAEtB,gBAAgB;IAChB,cAAc,EAAE,gBAAgB;IAChC,WAAW,EAAE,aAAa;IAE1B,aAAa;IACb,YAAY,EAAE,cAAc;IAC5B,iBAAiB,EAAE,mBAAmB;IACtC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,mBAAmB;IAEtC,eAAe;IACf,eAAe,EAAE,iBAAiB;IAClC,oBAAoB,EAAE,sBAAsB;IAC5C,eAAe,EAAE,iBAAiB;IAClC,mBAAmB,EAAE,qBAAqB;IAE1C,iBAAiB;IACjB;;2EAEuE;IACvE,oBAAoB,EAAE,sBAAsB;CACpC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Convert bytes to URL-safe base64
3
+ * Replaces + with -, / with _, and removes = padding
4
+ */
5
+ export declare function toUrlSafeBase64(bytes: Uint8Array): string;
6
+ /**
7
+ * Convert BigInt to URL-safe base64
8
+ * @param value - The BigInt value to convert
9
+ * @returns URL-safe base64 string representation
10
+ */
11
+ export declare function bigintToUrlSafeBase64(value: bigint): string;
12
+ //# sourceMappingURL=url-safe-base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-safe-base64.d.ts","sourceRoot":"","sources":["../src/url-safe-base64.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAoBzD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM3D"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Convert bytes to URL-safe base64
3
+ * Replaces + with -, / with _, and removes = padding
4
+ */
5
+ export function toUrlSafeBase64(bytes) {
6
+ const b64 = Buffer.from(bytes).toString('base64');
7
+ const buf = Buffer.from(b64, 'ascii');
8
+ let write = 0;
9
+ for (let read = 0; read < buf.length; read++) {
10
+ const c = buf[read];
11
+ if (c === 0x2b) {
12
+ // '+'
13
+ buf[write++] = 0x2d; // '-'
14
+ }
15
+ else if (c === 0x2f) {
16
+ // '/'
17
+ buf[write++] = 0x5f; // '_'
18
+ }
19
+ else if (c === 0x3d) {
20
+ // '='
21
+ // skip padding
22
+ }
23
+ else {
24
+ buf[write++] = c;
25
+ }
26
+ }
27
+ return buf.subarray(0, write).toString('ascii');
28
+ }
29
+ /**
30
+ * Convert BigInt to URL-safe base64
31
+ * @param value - The BigInt value to convert
32
+ * @returns URL-safe base64 string representation
33
+ */
34
+ export function bigintToUrlSafeBase64(value) {
35
+ // Convert BigInt to 8-byte buffer
36
+ const hashBuffer = new Uint8Array(8);
37
+ const dataView = new DataView(hashBuffer.buffer);
38
+ dataView.setBigUint64(0, value, false); // big-endian
39
+ return toUrlSafeBase64(hashBuffer);
40
+ }
41
+ //# sourceMappingURL=url-safe-base64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-safe-base64.js","sourceRoot":"","sources":["../src/url-safe-base64.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;QAC7C,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACf,MAAM;YACN,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM;QAC7B,CAAC;aAAM,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACtB,MAAM;YACN,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM;QAC7B,CAAC;aAAM,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACtB,MAAM;YACN,eAAe;QACjB,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,kCAAkC;IAClC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACjD,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,aAAa;IACrD,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * URL validation for SSRF prevention in server-side fetch operations.
3
+ * Blocks private/reserved IP addresses and non-http(s) schemes.
4
+ */
5
+ /**
6
+ * Check if a hostname names a private/reserved destination: a blocked name,
7
+ * or an address in a loopback/link-local/private range. A trailing root-label
8
+ * dot and the IPv6 brackets `URL.hostname` keeps are stripped internally, and
9
+ * an IPv4-mapped IPv6 literal is canonicalized to the address it embeds so the
10
+ * mapped spelling cannot smuggle a private destination past the range tables.
11
+ *
12
+ * Exported so other media import guards can reuse these range tables
13
+ * instead of copying them.
14
+ *
15
+ * @param hostname The hostname to check (bare or bracketed IPv6)
16
+ * @returns true if the hostname points to a private/reserved destination
17
+ */
18
+ export declare function isPrivateFetchHost(hostname: string): boolean;
19
+ /**
20
+ * Validate that a URL is safe to fetch server-side.
21
+ * Blocks private/reserved IP addresses and non-http(s) schemes.
22
+ *
23
+ * @param url The URL string to validate
24
+ * @returns The parsed URL object if valid
25
+ * @throws Error if the URL is invalid, uses a blocked scheme, or points to a private IP
26
+ */
27
+ export declare function validateFetchUrl(url: string): URL;
28
+ //# sourceMappingURL=url-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-validation.d.ts","sourceRoot":"","sources":["../src/url-validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+DH;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAkB5D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAajD"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * URL validation for SSRF prevention in server-side fetch operations.
3
+ * Blocks private/reserved IP addresses and non-http(s) schemes.
4
+ */
5
+ const BLOCKED_HOSTNAMES = new Set(['localhost']);
6
+ /** Check if an IPv4 address string points to a private/reserved range */
7
+ function isPrivateIPv4(hostname) {
8
+ const parts = hostname.split('.');
9
+ if (parts.length !== 4)
10
+ return false;
11
+ const octets = parts.map((p) => Number.parseInt(p, 10));
12
+ if (octets.some((o) => Number.isNaN(o) || o < 0 || o > 255))
13
+ return false;
14
+ const [first, second] = octets;
15
+ // 0.x.x.x — unspecified
16
+ if (first === 0)
17
+ return true;
18
+ // 10.x.x.x — Class A private
19
+ if (first === 10)
20
+ return true;
21
+ // 127.x.x.x — loopback
22
+ if (first === 127)
23
+ return true;
24
+ // 169.254.x.x — link-local (cloud metadata endpoint)
25
+ if (first === 169 && second === 254)
26
+ return true;
27
+ // 172.16.0.0 – 172.31.255.255 — Class B private
28
+ if (first === 172 && second >= 16 && second <= 31)
29
+ return true;
30
+ // 192.168.x.x — Class C private
31
+ if (first === 192 && second === 168)
32
+ return true;
33
+ return false;
34
+ }
35
+ /** Check if an IPv6 address string points to a private/reserved range */
36
+ function isPrivateIPv6(hostname) {
37
+ const lower = hostname.toLowerCase();
38
+ // ::1 — loopback
39
+ if (lower === '::1')
40
+ return true;
41
+ // :: — unspecified
42
+ if (lower === '::')
43
+ return true;
44
+ // fe80: — link-local
45
+ if (lower.startsWith('fe80:') || lower.startsWith('fe80%'))
46
+ return true;
47
+ // fc00::/7 — unique local address (ULA). Anchored to the address form, as a
48
+ // bare `fc`/`fd` prefix also matches public domains such as `fdic.gov`.
49
+ if (/^f[cd][0-9a-f]{2}[:%]/.test(lower))
50
+ return true;
51
+ return false;
52
+ }
53
+ /**
54
+ * The dotted-quad address embedded in an IPv4-mapped IPv6 host, or `null`.
55
+ * Both spellings of the tail are read: dotted (`::ffff:127.0.0.1`) and hex
56
+ * (`::ffff:7f00:1`), the latter being what URL parsing canonicalizes to.
57
+ */
58
+ function ipv4MappedEmbedded(host) {
59
+ if (!host.startsWith('::ffff:'))
60
+ return null;
61
+ const tail = host.slice('::ffff:'.length);
62
+ if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(tail))
63
+ return tail;
64
+ const hex = tail.match(/^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);
65
+ if (!hex)
66
+ return null;
67
+ const high = Number.parseInt(hex[1], 16);
68
+ const low = Number.parseInt(hex[2], 16);
69
+ return `${(high >> 8) & 0xff}.${high & 0xff}.${(low >> 8) & 0xff}.${low & 0xff}`;
70
+ }
71
+ /**
72
+ * Check if a hostname names a private/reserved destination: a blocked name,
73
+ * or an address in a loopback/link-local/private range. A trailing root-label
74
+ * dot and the IPv6 brackets `URL.hostname` keeps are stripped internally, and
75
+ * an IPv4-mapped IPv6 literal is canonicalized to the address it embeds so the
76
+ * mapped spelling cannot smuggle a private destination past the range tables.
77
+ *
78
+ * Exported so other media import guards can reuse these range tables
79
+ * instead of copying them.
80
+ *
81
+ * @param hostname The hostname to check (bare or bracketed IPv6)
82
+ * @returns true if the hostname points to a private/reserved destination
83
+ */
84
+ export function isPrivateFetchHost(hostname) {
85
+ // A trailing root-label dot is valid syntax for the same host — `localhost.`
86
+ // resolves identically — so drop it before any table sees the name. Stripped
87
+ // ahead of the brackets, whose closing match is anchored to the end.
88
+ const rooted = hostname.replace(/\.+$/, '');
89
+ // URL.hostname keeps the brackets on an IPv6 literal; strip them here so
90
+ // consumers don't have to (no-op for bare input)
91
+ const bare = rooted.replace(/^\[|\]$/g, '').toLowerCase();
92
+ // Check blocked hostnames
93
+ if (BLOCKED_HOSTNAMES.has(bare))
94
+ return true;
95
+ // An IPv4-mapped IPv6 literal reaches the address it embeds, so range-check
96
+ // that address rather than the mapped spelling
97
+ const address = ipv4MappedEmbedded(bare) ?? bare;
98
+ // Check IPv4 private ranges
99
+ if (isPrivateIPv4(address))
100
+ return true;
101
+ // Check IPv6 private ranges
102
+ return isPrivateIPv6(address);
103
+ }
104
+ /**
105
+ * Validate that a URL is safe to fetch server-side.
106
+ * Blocks private/reserved IP addresses and non-http(s) schemes.
107
+ *
108
+ * @param url The URL string to validate
109
+ * @returns The parsed URL object if valid
110
+ * @throws Error if the URL is invalid, uses a blocked scheme, or points to a private IP
111
+ */
112
+ export function validateFetchUrl(url) {
113
+ const parsed = new URL(url); // throws on invalid URLs
114
+ // Check scheme
115
+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
116
+ throw new Error('URL scheme must be http or https');
117
+ }
118
+ if (isPrivateFetchHost(parsed.hostname)) {
119
+ throw new Error('URL points to a private/reserved IP address');
120
+ }
121
+ return parsed;
122
+ }
123
+ //# sourceMappingURL=url-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-validation.js","sourceRoot":"","sources":["../src/url-validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH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;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,6EAA6E;IAC7E,6EAA6E;IAC7E,qEAAqE;IACrE,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5C,yEAAyE;IACzE,iDAAiD;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAE1D,0BAA0B;IAC1B,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,4EAA4E;IAC5E,+CAA+C;IAC/C,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACjD,4BAA4B;IAC5B,IAAI,aAAa,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,4BAA4B;IAC5B,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,yBAAyB;IAEtD,eAAe;IACf,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Write file atomically via temp file + rename to prevent corruption on crash.
3
+ * Callers are responsible for ensuring the parent directory exists.
4
+ */
5
+ export declare function atomicWriteFile(filePath: string, content: string): Promise<void>;
6
+ //# sourceMappingURL=atomic-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomic-write.d.ts","sourceRoot":"","sources":["../../src/utils/atomic-write.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAatF"}
@@ -0,0 +1,21 @@
1
+ import { rename, unlink, writeFile } from 'node:fs/promises';
2
+ /**
3
+ * Write file atomically via temp file + rename to prevent corruption on crash.
4
+ * Callers are responsible for ensuring the parent directory exists.
5
+ */
6
+ export async function atomicWriteFile(filePath, content) {
7
+ const hrtime = process.hrtime.bigint();
8
+ const tempFile = `${filePath}.tmp.${process.pid}.${hrtime}`;
9
+ try {
10
+ await writeFile(tempFile, content);
11
+ await rename(tempFile, filePath);
12
+ }
13
+ catch (error) {
14
+ try {
15
+ await unlink(tempFile);
16
+ }
17
+ catch { }
18
+ throw error;
19
+ }
20
+ }
21
+ //# sourceMappingURL=atomic-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomic-write.js","sourceRoot":"","sources":["../../src/utils/atomic-write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,OAAe;IACrE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACvC,MAAM,QAAQ,GAAG,GAAG,QAAQ,QAAQ,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnC,MAAM,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Utilities for working with the `<name>.<locale>.<ext>` suffix pattern.
3
+ */
4
+ export declare const ContentUtils: {
5
+ /**
6
+ * Extract locale from filename
7
+ * @example
8
+ * - about.en.vxjson → 'en'
9
+ * - about.nl.vxjson → 'nl'
10
+ * - hero-main.mdx → 'en' (default)
11
+ * - hero-main.nl.mdx → 'nl'
12
+ */
13
+ extractLocale(filename: string): string;
14
+ /**
15
+ * Get base path without locale and extension
16
+ * @example
17
+ * - about.en.vxjson → 'about'
18
+ * - about.nl.vxjson → 'about'
19
+ * - hero-main.mdx → 'hero-main'
20
+ */
21
+ extractBasePath(filename: string): string;
22
+ /**
23
+ * Build filename from base path and locale
24
+ * @example
25
+ * - ('about', 'en') → 'about.en.vxjson'
26
+ * - ('about', 'nl') → 'about.nl.vxjson'
27
+ */
28
+ buildFilename(basePath: string, locale: string, extension?: string): string;
29
+ /**
30
+ * Group files by base path for i18n
31
+ */
32
+ groupByContent(filenames: string[]): Map<string, Record<string, string>>;
33
+ /**
34
+ * Check if a file is a content file (vxjson or mdx)
35
+ */
36
+ isContentFile(filename: string): boolean;
37
+ /**
38
+ * Parse filename to get all components
39
+ */
40
+ parseFilename(filename: string): {
41
+ basePath: string;
42
+ locale: string;
43
+ extension: string;
44
+ };
45
+ };
46
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB;;;;;;;OAOG;IACH,aAAa,WAAW,MAAM,GAAG,MAAM;IAKvC;;;;;;OAMG;IACH,eAAe,WAAW,MAAM,GAAG,MAAM;IAIzC;;;;;OAKG;IACH,aAAa,WAAW,MAAM,UAAU,MAAM,uBAAyB,MAAM;IAO7E;;OAEG;IACH,cAAc,YAAY,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAkBxE;;OAEG;IACH,aAAa,WAAW,MAAM,GAAG,OAAO;IAIxC;;OAEG;IACH,aAAa,WAAW,MAAM,GAAG;QAC/B,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB;CAOF,CAAC"}
package/dist/utils.js ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Utilities for working with the `<name>.<locale>.<ext>` suffix pattern.
3
+ */
4
+ export const ContentUtils = {
5
+ /**
6
+ * Extract locale from filename
7
+ * @example
8
+ * - about.en.vxjson → 'en'
9
+ * - about.nl.vxjson → 'nl'
10
+ * - hero-main.mdx → 'en' (default)
11
+ * - hero-main.nl.mdx → 'nl'
12
+ */
13
+ extractLocale(filename) {
14
+ const match = filename.match(/\.([a-z]{2})\.(vxjson|mdx)$/);
15
+ return match?.[1] || 'en';
16
+ },
17
+ /**
18
+ * Get base path without locale and extension
19
+ * @example
20
+ * - about.en.vxjson → 'about'
21
+ * - about.nl.vxjson → 'about'
22
+ * - hero-main.mdx → 'hero-main'
23
+ */
24
+ extractBasePath(filename) {
25
+ return filename.replace(/\.([a-z]{2})?\.(vxjson|mdx)$/, '').replace(/\.(vxjson|mdx)$/, '');
26
+ },
27
+ /**
28
+ * Build filename from base path and locale
29
+ * @example
30
+ * - ('about', 'en') → 'about.en.vxjson'
31
+ * - ('about', 'nl') → 'about.nl.vxjson'
32
+ */
33
+ buildFilename(basePath, locale, extension = 'vxjson') {
34
+ if (locale === 'en' && extension === 'vxjson') {
35
+ return `${basePath}.${extension}`;
36
+ }
37
+ return `${basePath}.${locale}.${extension}`;
38
+ },
39
+ /**
40
+ * Group files by base path for i18n
41
+ */
42
+ groupByContent(filenames) {
43
+ const groups = new Map();
44
+ for (const filename of filenames) {
45
+ const base = this.extractBasePath(filename);
46
+ const locale = this.extractLocale(filename);
47
+ if (!groups.has(base)) {
48
+ groups.set(base, {});
49
+ }
50
+ const localeFiles = groups.get(base);
51
+ localeFiles[locale] = filename;
52
+ }
53
+ return groups;
54
+ },
55
+ /**
56
+ * Check if a file is a content file (vxjson or mdx)
57
+ */
58
+ isContentFile(filename) {
59
+ return /\.(vxjson|mdx)$/.test(filename);
60
+ },
61
+ /**
62
+ * Parse filename to get all components
63
+ */
64
+ parseFilename(filename) {
65
+ const extension = filename.match(/\.(vxjson|mdx)$/)?.[1] || '';
66
+ const locale = this.extractLocale(filename);
67
+ const basePath = this.extractBasePath(filename);
68
+ return { basePath, locale, extension };
69
+ },
70
+ };
71
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B;;;;;;;OAOG;IACH,aAAa,CAAC,QAAgB;QAC5B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC5D,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACH,eAAe,CAAC,QAAgB;QAC9B,OAAO,QAAQ,CAAC,OAAO,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAAgB,EAAE,MAAc,EAAE,SAAS,GAAG,QAAQ;QAClE,IAAI,MAAM,KAAK,IAAI,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC9C,OAAO,GAAG,QAAQ,IAAI,SAAS,EAAE,CAA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: string;
5
+ basePath?: string;
6
+ }
7
+ /**
8
+ * Vite plugin wrapper for content middleware, mounting the content API routes
9
+ * on the dev server so editing works without a separate backend.
10
+ */
11
+ export declare function conlocaContent(options: ConlocaContentOptions): Plugin;
12
+ //# sourceMappingURL=vite-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAKlD,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CA4BrE"}
@@ -0,0 +1,30 @@
1
+ import { getRequestListener } from '@hono/node-server';
2
+ import { createContentAPI, createContentWatchHandlers } from './content-watcher.js';
3
+ import { createContentAPIRouter } from './middleware.js';
4
+ /**
5
+ * Vite plugin wrapper for content middleware, mounting the content API routes
6
+ * on the dev server so editing works without a separate backend.
7
+ */
8
+ export function conlocaContent(options) {
9
+ let contentApi;
10
+ const basePath = options.basePath || '/__conloca/api/content';
11
+ return {
12
+ name: 'vite-plugin-conloca-content',
13
+ async configureServer(server) {
14
+ // Initialize content API
15
+ contentApi = await createContentAPI(options);
16
+ // Set up content file watcher
17
+ server.watcher.add(options.contentRoot);
18
+ // Create Hono app with routes
19
+ const app = createContentAPIRouter(contentApi);
20
+ // Add to Vite as middleware using @hono/node-server
21
+ server.middlewares.use(basePath, getRequestListener(app.fetch));
22
+ // Set up HMR for content changes using extracted handlers
23
+ const handlers = createContentWatchHandlers(contentApi, options, server.ws);
24
+ server.watcher.on('change', handlers.onChange);
25
+ server.watcher.on('add', handlers.onAdd);
26
+ server.watcher.on('unlink', handlers.onUnlink);
27
+ },
28
+ };
29
+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Q,CAAC,CAAC;QACjD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { VXJSONFile } from './types.js';
2
+ /**
3
+ * The canonical VXJSON serializer: metadata alphabetical, content last so
4
+ * the indexer reads all metadata from the first 4KB, 4KB position enforced.
5
+ *
6
+ * Lives apart from vxjson.ts on purpose: that module's ETag half imports
7
+ * node crypto and WASM-backed xxhash at module level. This file imports only
8
+ * sort-keys and types, so code that must stay free of node/WASM imports can
9
+ * consume it via the dedicated `@conloca/content-api/vxjson-serialize`
10
+ * subpath.
11
+ */
12
+ export declare function serializeVxjson(data: VXJSONFile): string;
13
+ //# sourceMappingURL=vxjson-serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vxjson-serialize.d.ts","sourceRoot":"","sources":["../src/vxjson-serialize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAoDxD"}
@@ -0,0 +1,53 @@
1
+ import sortKeys from 'sort-keys';
2
+ /**
3
+ * The canonical VXJSON serializer: metadata alphabetical, content last so
4
+ * the indexer reads all metadata from the first 4KB, 4KB position enforced.
5
+ *
6
+ * Lives apart from vxjson.ts on purpose: that module's ETag half imports
7
+ * node crypto and WASM-backed xxhash at module level. This file imports only
8
+ * sort-keys and types, so code that must stay free of node/WASM imports can
9
+ * consume it via the dedicated `@conloca/content-api/vxjson-serialize`
10
+ * subpath.
11
+ */
12
+ export function serializeVxjson(data) {
13
+ // Extract content to add it last
14
+ const { content, ...metadataFields } = data;
15
+ // Ensure content field exists (required for VXJSON format)
16
+ if (content === undefined || content === null) {
17
+ throw new Error('VXJSON format requires a "content" field');
18
+ }
19
+ // Sort all metadata fields alphabetically and serialize with tab indentation.
20
+ // The replacer drops empty-string FIELDS, so clearing a value removes the key
21
+ // rather than storing '' — deliberate, and covered by vxjson-empty-strings.
22
+ // Array ELEMENTS are exempt: a replacer returning undefined drops an object
23
+ // key but emits null inside an array, so ['a','','b'] used to reach disk as
24
+ // ['a',null,'b'] and crash whatever walked the list later.
25
+ const sortedMetadata = sortKeys(metadataFields, { deep: true });
26
+ const metadataJson = JSON.stringify(sortedMetadata, function (_key, value) {
27
+ if (value === '' && !Array.isArray(this)) {
28
+ return undefined;
29
+ }
30
+ return value;
31
+ }, '\t');
32
+ // Serialize content wrapped in an object to get proper indentation
33
+ const wrappedContent = JSON.stringify({ c: sortKeys(content, { deep: true }) }, null, '\t');
34
+ // Extract just the content part, removing the wrapper
35
+ // This transforms: '{\n "c": {\n "puckData": ...\n }\n}'
36
+ // Into: '{\n "puckData": ...\n }'
37
+ const contentJson = wrappedContent.slice(wrappedContent.indexOf(': ') + 2, -2);
38
+ // Remove the closing } and newline from metadata
39
+ const metadataWithoutClosing = metadataJson.slice(0, -2); // Remove \n}
40
+ const contentFieldPrefix = ',\n\t"content": ';
41
+ const contentKeyPosition = metadataWithoutClosing.length + 1 + '\n\t'.length; // Position of "content":
42
+ // VXJSON constraint: "content": must appear within first 4KB
43
+ const maxContentKeyPosition = 4096 - '"content":'.length; // 4086
44
+ if (contentKeyPosition > maxContentKeyPosition) {
45
+ throw new Error('VXJSON format violation: metadata too large. ' +
46
+ `"content" field would start at position ${contentKeyPosition}, ` +
47
+ `but must start within ${maxContentKeyPosition} bytes. ` +
48
+ `Reduce metadata size by ${contentKeyPosition - maxContentKeyPosition} bytes.`);
49
+ }
50
+ // Build final JSON string efficiently
51
+ return `${metadataWithoutClosing}${contentFieldPrefix}${contentJson}\n}`;
52
+ }
53
+ //# sourceMappingURL=vxjson-serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vxjson-serialize.js","sourceRoot":"","sources":["../src/vxjson-serialize.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAGjC;;;;;;;;;GASG;AACH,MAAM,UAAU,e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