@valbuild/shared 0.66.0 → 0.67.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.
@@ -2053,17 +2053,17 @@ export declare const Api: {
2053
2053
  message: z.ZodString;
2054
2054
  value: z.ZodOptional<z.ZodUnknown>;
2055
2055
  fatal: z.ZodOptional<z.ZodBoolean>;
2056
- fixes: z.ZodOptional<z.ZodArray<z.ZodType<"image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext", z.ZodTypeDef, "image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext">, "many">>;
2056
+ fixes: z.ZodOptional<z.ZodArray<z.ZodType<"image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata", z.ZodTypeDef, "image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata">, "many">>;
2057
2057
  }, "strip", z.ZodTypeAny, {
2058
2058
  message: string;
2059
2059
  value?: unknown;
2060
2060
  fatal?: boolean | undefined;
2061
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2061
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2062
2062
  }, {
2063
2063
  message: string;
2064
2064
  value?: unknown;
2065
2065
  fatal?: boolean | undefined;
2066
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2066
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2067
2067
  }>, "many">>>;
2068
2068
  }, "strip", z.ZodTypeAny, {
2069
2069
  patches?: {
@@ -2078,7 +2078,7 @@ export declare const Api: {
2078
2078
  message: string;
2079
2079
  value?: unknown;
2080
2080
  fatal?: boolean | undefined;
2081
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2081
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2082
2082
  }[]>> | undefined;
2083
2083
  }, {
2084
2084
  patches?: {
@@ -2093,7 +2093,7 @@ export declare const Api: {
2093
2093
  message: string;
2094
2094
  value?: unknown;
2095
2095
  fatal?: boolean | undefined;
2096
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2096
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2097
2097
  }[]> | undefined;
2098
2098
  }>>;
2099
2099
  errors: z.ZodRecord<z.ZodEffects<z.ZodString, ModuleFilePath, string>, z.ZodArray<z.ZodObject<{
@@ -2147,7 +2147,7 @@ export declare const Api: {
2147
2147
  message: string;
2148
2148
  value?: unknown;
2149
2149
  fatal?: boolean | undefined;
2150
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2150
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2151
2151
  }[]>> | undefined;
2152
2152
  }>>;
2153
2153
  }, {
@@ -2174,7 +2174,7 @@ export declare const Api: {
2174
2174
  message: string;
2175
2175
  value?: unknown;
2176
2176
  fatal?: boolean | undefined;
2177
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2177
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2178
2178
  }[]> | undefined;
2179
2179
  }>;
2180
2180
  }>;
@@ -2206,7 +2206,7 @@ export declare const Api: {
2206
2206
  message: string;
2207
2207
  value?: unknown;
2208
2208
  fatal?: boolean | undefined;
2209
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2209
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2210
2210
  }[]>> | undefined;
2211
2211
  }>>;
2212
2212
  };
@@ -2236,7 +2236,7 @@ export declare const Api: {
2236
2236
  message: string;
2237
2237
  value?: unknown;
2238
2238
  fatal?: boolean | undefined;
2239
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2239
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2240
2240
  }[]> | undefined;
2241
2241
  }>;
2242
2242
  };
@@ -2273,17 +2273,17 @@ export declare const Api: {
2273
2273
  message: z.ZodString;
2274
2274
  value: z.ZodOptional<z.ZodUnknown>;
2275
2275
  fatal: z.ZodOptional<z.ZodBoolean>;
2276
- fixes: z.ZodOptional<z.ZodArray<z.ZodType<"image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext", z.ZodTypeDef, "image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext">, "many">>;
2276
+ fixes: z.ZodOptional<z.ZodArray<z.ZodType<"image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata", z.ZodTypeDef, "image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata">, "many">>;
2277
2277
  }, "strip", z.ZodTypeAny, {
2278
2278
  message: string;
2279
2279
  value?: unknown;
2280
2280
  fatal?: boolean | undefined;
2281
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2281
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2282
2282
  }, {
2283
2283
  message: string;
2284
2284
  value?: unknown;
2285
2285
  fatal?: boolean | undefined;
2286
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2286
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2287
2287
  }>, "many">>>;
2288
2288
  }, "strip", z.ZodTypeAny, {
2289
2289
  patches?: {
@@ -2298,7 +2298,7 @@ export declare const Api: {
2298
2298
  message: string;
2299
2299
  value?: unknown;
2300
2300
  fatal?: boolean | undefined;
2301
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2301
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2302
2302
  }[]>> | undefined;
2303
2303
  }, {
2304
2304
  patches?: {
@@ -2313,7 +2313,7 @@ export declare const Api: {
2313
2313
  message: string;
2314
2314
  value?: unknown;
2315
2315
  fatal?: boolean | undefined;
2316
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2316
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2317
2317
  }[]> | undefined;
2318
2318
  }>>;
2319
2319
  newPatchIds: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, PatchId, string>, "many">>;
@@ -2332,7 +2332,7 @@ export declare const Api: {
2332
2332
  message: string;
2333
2333
  value?: unknown;
2334
2334
  fatal?: boolean | undefined;
2335
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2335
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2336
2336
  }[]>> | undefined;
2337
2337
  }>>;
2338
2338
  newPatchIds?: PatchId[] | undefined;
@@ -2351,7 +2351,7 @@ export declare const Api: {
2351
2351
  message: string;
2352
2352
  value?: unknown;
2353
2353
  fatal?: boolean | undefined;
2354
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2354
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2355
2355
  }[]> | undefined;
2356
2356
  }>;
2357
2357
  newPatchIds?: string[] | undefined;
@@ -2373,7 +2373,7 @@ export declare const Api: {
2373
2373
  message: string;
2374
2374
  value?: unknown;
2375
2375
  fatal?: boolean | undefined;
2376
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2376
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2377
2377
  }[]>> | undefined;
2378
2378
  }>>;
2379
2379
  newPatchIds?: PatchId[] | undefined;
@@ -2395,7 +2395,7 @@ export declare const Api: {
2395
2395
  message: string;
2396
2396
  value?: unknown;
2397
2397
  fatal?: boolean | undefined;
2398
- fixes?: ("image:add-metadata" | "image:replace-metadata" | "file:add-metadata" | "file:check-metadata" | "fix:deprecated-richtext")[] | undefined;
2398
+ fixes?: ("image:change-extension" | "image:add-metadata" | "image:check-metadata" | "file:change-extension" | "file:add-metadata" | "file:check-metadata")[] | undefined;
2399
2399
  }[]> | undefined;
2400
2400
  }>;
2401
2401
  newPatchIds?: string[] | undefined;
@@ -1,6 +1,6 @@
1
- import { RichTextSource, AllRichTextOptions } from "@valbuild/core";
1
+ import { RichTextSource, AllRichTextOptions, ConfigDirectory } from "@valbuild/core";
2
2
  import { RemirrorJSON } from "./remirrorTypes.js";
3
- export declare function remirrorToRichTextSource(node: RemirrorJSON): {
3
+ export declare function remirrorToRichTextSource(node: RemirrorJSON, configDirectory: ConfigDirectory): {
4
4
  blocks: RichTextSource<AllRichTextOptions>;
5
5
  files: Record<string, {
6
6
  value: string;
@@ -117,7 +117,7 @@ function _createForOfIteratorHelper(r, e) {
117
117
  };
118
118
  }
119
119
 
120
- function remirrorToRichTextSource(node) {
120
+ function remirrorToRichTextSource(node, configDirectory) {
121
121
  var files = {};
122
122
  var blocks = [];
123
123
  var i = 0;
@@ -126,7 +126,7 @@ function remirrorToRichTextSource(node) {
126
126
  try {
127
127
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
128
128
  var child = _step.value;
129
- var block = convertBlock([(i++).toString()], child, files);
129
+ var block = convertBlock([(i++).toString()], child, files, configDirectory);
130
130
  blocks.push(block);
131
131
  }
132
132
  } catch (err) {
@@ -139,7 +139,7 @@ function remirrorToRichTextSource(node) {
139
139
  files: files
140
140
  };
141
141
  }
142
- function convertBlock(path, node, files) {
142
+ function convertBlock(path, node, files, configDirectory) {
143
143
  if (node.type === "heading") {
144
144
  var _node$attrs, _node$content;
145
145
  var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
@@ -149,21 +149,21 @@ function convertBlock(path, node, files) {
149
149
  return {
150
150
  tag: "h".concat(depth),
151
151
  children: ((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child, i) {
152
- return convertHeadingChild(path.concat("children", i.toString()), child, files);
152
+ return convertHeadingChild(path.concat("children", i.toString()), child, files, configDirectory);
153
153
  })) || []
154
154
  };
155
155
  } else if (node.type === "paragraph") {
156
- return convertParagraph(path, node, files);
156
+ return convertParagraph(path, node, files, configDirectory);
157
157
  } else if (node.type === "bulletList") {
158
- return convertBulletList(path, node, files);
158
+ return convertBulletList(path, node, files, configDirectory);
159
159
  } else if (node.type === "orderedList") {
160
- return convertOrderedList(path, node, files);
160
+ return convertOrderedList(path, node, files, configDirectory);
161
161
  } else {
162
162
  var exhaustiveCheck = node;
163
163
  throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
164
164
  }
165
165
  }
166
- function convertHeadingChild(path, node, files) {
166
+ function convertHeadingChild(path, node, files, configDirectory) {
167
167
  if (node.type === "text") {
168
168
  return convertTextNode(node);
169
169
  } else if (node.type === "hardBreak") {
@@ -171,13 +171,13 @@ function convertHeadingChild(path, node, files) {
171
171
  tag: "br"
172
172
  };
173
173
  } else if (node.type === "image") {
174
- return convertImageNode(path, node, files);
174
+ return convertImageNode(path, node, files, configDirectory);
175
175
  } else {
176
176
  var exhaustiveCheck = node;
177
177
  throw new Error("Unexpected heading child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
178
178
  }
179
179
  }
180
- function convertParagraph(path, child, files) {
180
+ function convertParagraph(path, child, files, configDirectory) {
181
181
  var _child$content;
182
182
  return {
183
183
  tag: "p",
@@ -189,7 +189,7 @@ function convertParagraph(path, child, files) {
189
189
  tag: "br"
190
190
  };
191
191
  } else if (child.type === "image") {
192
- return convertImageNode(path.concat("children", i.toString()), child, files);
192
+ return convertImageNode(path.concat("children", i.toString()), child, files, configDirectory);
193
193
  }
194
194
  var exhaustiveCheck = child;
195
195
  throw new Error("Unexpected paragraph child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
@@ -248,17 +248,17 @@ function convertTextNode(node) {
248
248
  throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
249
249
  }
250
250
  }
251
- function convertListItem(path, child, files) {
251
+ function convertListItem(path, child, files, configDirectory) {
252
252
  var _child$content2;
253
253
  return {
254
254
  tag: "li",
255
255
  children: ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.map(function (child, i) {
256
256
  if (child.type === "paragraph") {
257
- return convertParagraph(path.concat("children", i.toString()), child, files);
257
+ return convertParagraph(path.concat("children", i.toString()), child, files, configDirectory);
258
258
  } else if (child.type === "bulletList") {
259
- return convertBulletList(path.concat("children", i.toString()), child, files);
259
+ return convertBulletList(path.concat("children", i.toString()), child, files, configDirectory);
260
260
  } else if (child.type === "orderedList") {
261
- return convertOrderedList(path.concat("children", i.toString()), child, files);
261
+ return convertOrderedList(path.concat("children", i.toString()), child, files, configDirectory);
262
262
  } else {
263
263
  var exhaustiveCheck = child;
264
264
  throw new Error("Unexpected list child type: ".concat(exhaustiveCheck));
@@ -266,13 +266,13 @@ function convertListItem(path, child, files) {
266
266
  })) || []
267
267
  };
268
268
  }
269
- function convertBulletList(path, node, files) {
269
+ function convertBulletList(path, node, files, configDirectory) {
270
270
  var _node$content2;
271
271
  return {
272
272
  tag: "ul",
273
273
  children: ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.map(function (child, i) {
274
274
  if (child.type === "listItem") {
275
- return convertListItem(path.concat("children", i.toString()), child, files);
275
+ return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
276
276
  } else {
277
277
  var exhaustiveCheck = child.type;
278
278
  throw new Error("Unexpected bullet list child type: ".concat(exhaustiveCheck));
@@ -280,13 +280,13 @@ function convertBulletList(path, node, files) {
280
280
  })) || []
281
281
  };
282
282
  }
283
- function convertOrderedList(path, node, files) {
283
+ function convertOrderedList(path, node, files, configDirectory) {
284
284
  var _node$content3;
285
285
  return {
286
286
  tag: "ol",
287
287
  children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.map(function (child, i) {
288
288
  if (child.type === "listItem") {
289
- return convertListItem(path.concat("children", i.toString()), child, files);
289
+ return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
290
290
  } else {
291
291
  var exhaustiveCheck = child.type;
292
292
  throw new Error("Unexpected ordered list child type: ".concat(exhaustiveCheck));
@@ -295,7 +295,7 @@ function convertOrderedList(path, node, files) {
295
295
  };
296
296
  }
297
297
  var textEncoder = new TextEncoder();
298
- function convertImageNode(path, node, files) {
298
+ function convertImageNode(path, node, files, configDirectory) {
299
299
  if (node.attrs && node.attrs.src.startsWith("data:")) {
300
300
  var sha256 = core.Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
301
301
  var mimeType = core.Internal.getMimeType(node.attrs.src);
@@ -307,7 +307,8 @@ function convertImageNode(path, node, files) {
307
307
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
308
308
  mimeType: mimeType
309
309
  }, sha256);
310
- var filePath = "/public/val/".concat(fileName);
310
+ var dir = configDirectory !== null && configDirectory !== void 0 && configDirectory.endsWith("/") ? configDirectory : "".concat(configDirectory, "/");
311
+ var filePath = "".concat(dir).concat(fileName);
311
312
  var existingFilesEntry = files[filePath];
312
313
  var thisPath = path
313
314
  // file is added as src (see below):
@@ -322,7 +323,7 @@ function convertImageNode(path, node, files) {
322
323
  }
323
324
  return {
324
325
  tag: "img",
325
- src: _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
326
+ src: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
326
327
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
327
328
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
328
329
  mimeType: mimeType
@@ -347,7 +348,7 @@ function convertImageNode(path, node, files) {
347
348
  }
348
349
  var tag = {
349
350
  tag: "img",
350
- src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), "metadata", {
351
+ src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
351
352
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
352
353
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
353
354
  mimeType: noParamsUrl && core.Internal.filenameToMimeType(noParamsUrl) || ""
@@ -1783,7 +1784,7 @@ var ValConfig = zod.z.object({
1783
1784
  gitCommit: zod.z.string().optional(),
1784
1785
  gitBranch: zod.z.string().optional()
1785
1786
  });
1786
- var ValidationFixZ = zod.z.union([zod.z.literal("image:add-metadata"), zod.z.literal("image:replace-metadata"), zod.z.literal("file:add-metadata"), zod.z.literal("file:check-metadata"), zod.z.literal("fix:deprecated-richtext")]);
1787
+ var ValidationFixZ = zod.z.union([zod.z.literal("image:change-extension"), zod.z.literal("image:add-metadata"), zod.z.literal("image:check-metadata"), zod.z.literal("file:change-extension"), zod.z.literal("file:add-metadata"), zod.z.literal("file:check-metadata")]);
1787
1788
  var ValidationError = zod.z.object({
1788
1789
  message: zod.z.string(),
1789
1790
  value: zod.z.unknown().optional(),
@@ -117,7 +117,7 @@ function _createForOfIteratorHelper(r, e) {
117
117
  };
118
118
  }
119
119
 
120
- function remirrorToRichTextSource(node) {
120
+ function remirrorToRichTextSource(node, configDirectory) {
121
121
  var files = {};
122
122
  var blocks = [];
123
123
  var i = 0;
@@ -126,7 +126,7 @@ function remirrorToRichTextSource(node) {
126
126
  try {
127
127
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
128
128
  var child = _step.value;
129
- var block = convertBlock([(i++).toString()], child, files);
129
+ var block = convertBlock([(i++).toString()], child, files, configDirectory);
130
130
  blocks.push(block);
131
131
  }
132
132
  } catch (err) {
@@ -139,7 +139,7 @@ function remirrorToRichTextSource(node) {
139
139
  files: files
140
140
  };
141
141
  }
142
- function convertBlock(path, node, files) {
142
+ function convertBlock(path, node, files, configDirectory) {
143
143
  if (node.type === "heading") {
144
144
  var _node$attrs, _node$content;
145
145
  var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
@@ -149,21 +149,21 @@ function convertBlock(path, node, files) {
149
149
  return {
150
150
  tag: "h".concat(depth),
151
151
  children: ((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child, i) {
152
- return convertHeadingChild(path.concat("children", i.toString()), child, files);
152
+ return convertHeadingChild(path.concat("children", i.toString()), child, files, configDirectory);
153
153
  })) || []
154
154
  };
155
155
  } else if (node.type === "paragraph") {
156
- return convertParagraph(path, node, files);
156
+ return convertParagraph(path, node, files, configDirectory);
157
157
  } else if (node.type === "bulletList") {
158
- return convertBulletList(path, node, files);
158
+ return convertBulletList(path, node, files, configDirectory);
159
159
  } else if (node.type === "orderedList") {
160
- return convertOrderedList(path, node, files);
160
+ return convertOrderedList(path, node, files, configDirectory);
161
161
  } else {
162
162
  var exhaustiveCheck = node;
163
163
  throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
164
164
  }
165
165
  }
166
- function convertHeadingChild(path, node, files) {
166
+ function convertHeadingChild(path, node, files, configDirectory) {
167
167
  if (node.type === "text") {
168
168
  return convertTextNode(node);
169
169
  } else if (node.type === "hardBreak") {
@@ -171,13 +171,13 @@ function convertHeadingChild(path, node, files) {
171
171
  tag: "br"
172
172
  };
173
173
  } else if (node.type === "image") {
174
- return convertImageNode(path, node, files);
174
+ return convertImageNode(path, node, files, configDirectory);
175
175
  } else {
176
176
  var exhaustiveCheck = node;
177
177
  throw new Error("Unexpected heading child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
178
178
  }
179
179
  }
180
- function convertParagraph(path, child, files) {
180
+ function convertParagraph(path, child, files, configDirectory) {
181
181
  var _child$content;
182
182
  return {
183
183
  tag: "p",
@@ -189,7 +189,7 @@ function convertParagraph(path, child, files) {
189
189
  tag: "br"
190
190
  };
191
191
  } else if (child.type === "image") {
192
- return convertImageNode(path.concat("children", i.toString()), child, files);
192
+ return convertImageNode(path.concat("children", i.toString()), child, files, configDirectory);
193
193
  }
194
194
  var exhaustiveCheck = child;
195
195
  throw new Error("Unexpected paragraph child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
@@ -248,17 +248,17 @@ function convertTextNode(node) {
248
248
  throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
249
249
  }
250
250
  }
251
- function convertListItem(path, child, files) {
251
+ function convertListItem(path, child, files, configDirectory) {
252
252
  var _child$content2;
253
253
  return {
254
254
  tag: "li",
255
255
  children: ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.map(function (child, i) {
256
256
  if (child.type === "paragraph") {
257
- return convertParagraph(path.concat("children", i.toString()), child, files);
257
+ return convertParagraph(path.concat("children", i.toString()), child, files, configDirectory);
258
258
  } else if (child.type === "bulletList") {
259
- return convertBulletList(path.concat("children", i.toString()), child, files);
259
+ return convertBulletList(path.concat("children", i.toString()), child, files, configDirectory);
260
260
  } else if (child.type === "orderedList") {
261
- return convertOrderedList(path.concat("children", i.toString()), child, files);
261
+ return convertOrderedList(path.concat("children", i.toString()), child, files, configDirectory);
262
262
  } else {
263
263
  var exhaustiveCheck = child;
264
264
  throw new Error("Unexpected list child type: ".concat(exhaustiveCheck));
@@ -266,13 +266,13 @@ function convertListItem(path, child, files) {
266
266
  })) || []
267
267
  };
268
268
  }
269
- function convertBulletList(path, node, files) {
269
+ function convertBulletList(path, node, files, configDirectory) {
270
270
  var _node$content2;
271
271
  return {
272
272
  tag: "ul",
273
273
  children: ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.map(function (child, i) {
274
274
  if (child.type === "listItem") {
275
- return convertListItem(path.concat("children", i.toString()), child, files);
275
+ return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
276
276
  } else {
277
277
  var exhaustiveCheck = child.type;
278
278
  throw new Error("Unexpected bullet list child type: ".concat(exhaustiveCheck));
@@ -280,13 +280,13 @@ function convertBulletList(path, node, files) {
280
280
  })) || []
281
281
  };
282
282
  }
283
- function convertOrderedList(path, node, files) {
283
+ function convertOrderedList(path, node, files, configDirectory) {
284
284
  var _node$content3;
285
285
  return {
286
286
  tag: "ol",
287
287
  children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.map(function (child, i) {
288
288
  if (child.type === "listItem") {
289
- return convertListItem(path.concat("children", i.toString()), child, files);
289
+ return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
290
290
  } else {
291
291
  var exhaustiveCheck = child.type;
292
292
  throw new Error("Unexpected ordered list child type: ".concat(exhaustiveCheck));
@@ -295,7 +295,7 @@ function convertOrderedList(path, node, files) {
295
295
  };
296
296
  }
297
297
  var textEncoder = new TextEncoder();
298
- function convertImageNode(path, node, files) {
298
+ function convertImageNode(path, node, files, configDirectory) {
299
299
  if (node.attrs && node.attrs.src.startsWith("data:")) {
300
300
  var sha256 = core.Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
301
301
  var mimeType = core.Internal.getMimeType(node.attrs.src);
@@ -307,7 +307,8 @@ function convertImageNode(path, node, files) {
307
307
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
308
308
  mimeType: mimeType
309
309
  }, sha256);
310
- var filePath = "/public/val/".concat(fileName);
310
+ var dir = configDirectory !== null && configDirectory !== void 0 && configDirectory.endsWith("/") ? configDirectory : "".concat(configDirectory, "/");
311
+ var filePath = "".concat(dir).concat(fileName);
311
312
  var existingFilesEntry = files[filePath];
312
313
  var thisPath = path
313
314
  // file is added as src (see below):
@@ -322,7 +323,7 @@ function convertImageNode(path, node, files) {
322
323
  }
323
324
  return {
324
325
  tag: "img",
325
- src: _defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), "metadata", {
326
+ src: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, filePath), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
326
327
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
327
328
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
328
329
  mimeType: mimeType
@@ -347,7 +348,7 @@ function convertImageNode(path, node, files) {
347
348
  }
348
349
  var tag = {
349
350
  tag: "img",
350
- src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), "metadata", {
351
+ src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, core.VAL_EXTENSION, "file"), core.FILE_REF_PROP, noParamsUrl), core.FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
351
352
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
352
353
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
353
354
  mimeType: noParamsUrl && core.Internal.filenameToMimeType(noParamsUrl) || ""
@@ -1783,7 +1784,7 @@ var ValConfig = zod.z.object({
1783
1784
  gitCommit: zod.z.string().optional(),
1784
1785
  gitBranch: zod.z.string().optional()
1785
1786
  });
1786
- var ValidationFixZ = zod.z.union([zod.z.literal("image:add-metadata"), zod.z.literal("image:replace-metadata"), zod.z.literal("file:add-metadata"), zod.z.literal("file:check-metadata"), zod.z.literal("fix:deprecated-richtext")]);
1787
+ var ValidationFixZ = zod.z.union([zod.z.literal("image:change-extension"), zod.z.literal("image:add-metadata"), zod.z.literal("image:check-metadata"), zod.z.literal("file:change-extension"), zod.z.literal("file:add-metadata"), zod.z.literal("file:check-metadata")]);
1787
1788
  var ValidationError = zod.z.object({
1788
1789
  message: zod.z.string(),
1789
1790
  value: zod.z.unknown().optional(),
@@ -1,4 +1,4 @@
1
- import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
1
+ import { Internal, VAL_EXTENSION, FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from '@valbuild/core';
2
2
  import { z } from 'zod';
3
3
  import { result } from '@valbuild/core/fp';
4
4
  import { fromZodError } from 'zod-validation-error';
@@ -113,7 +113,7 @@ function _createForOfIteratorHelper(r, e) {
113
113
  };
114
114
  }
115
115
 
116
- function remirrorToRichTextSource(node) {
116
+ function remirrorToRichTextSource(node, configDirectory) {
117
117
  var files = {};
118
118
  var blocks = [];
119
119
  var i = 0;
@@ -122,7 +122,7 @@ function remirrorToRichTextSource(node) {
122
122
  try {
123
123
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
124
124
  var child = _step.value;
125
- var block = convertBlock([(i++).toString()], child, files);
125
+ var block = convertBlock([(i++).toString()], child, files, configDirectory);
126
126
  blocks.push(block);
127
127
  }
128
128
  } catch (err) {
@@ -135,7 +135,7 @@ function remirrorToRichTextSource(node) {
135
135
  files: files
136
136
  };
137
137
  }
138
- function convertBlock(path, node, files) {
138
+ function convertBlock(path, node, files, configDirectory) {
139
139
  if (node.type === "heading") {
140
140
  var _node$attrs, _node$content;
141
141
  var depth = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) || 1;
@@ -145,21 +145,21 @@ function convertBlock(path, node, files) {
145
145
  return {
146
146
  tag: "h".concat(depth),
147
147
  children: ((_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.map(function (child, i) {
148
- return convertHeadingChild(path.concat("children", i.toString()), child, files);
148
+ return convertHeadingChild(path.concat("children", i.toString()), child, files, configDirectory);
149
149
  })) || []
150
150
  };
151
151
  } else if (node.type === "paragraph") {
152
- return convertParagraph(path, node, files);
152
+ return convertParagraph(path, node, files, configDirectory);
153
153
  } else if (node.type === "bulletList") {
154
- return convertBulletList(path, node, files);
154
+ return convertBulletList(path, node, files, configDirectory);
155
155
  } else if (node.type === "orderedList") {
156
- return convertOrderedList(path, node, files);
156
+ return convertOrderedList(path, node, files, configDirectory);
157
157
  } else {
158
158
  var exhaustiveCheck = node;
159
159
  throw new Error("Unhandled node type: ".concat("type" in exhaustiveCheck ? "exhaustiveCheck.type" : "unknown"));
160
160
  }
161
161
  }
162
- function convertHeadingChild(path, node, files) {
162
+ function convertHeadingChild(path, node, files, configDirectory) {
163
163
  if (node.type === "text") {
164
164
  return convertTextNode(node);
165
165
  } else if (node.type === "hardBreak") {
@@ -167,13 +167,13 @@ function convertHeadingChild(path, node, files) {
167
167
  tag: "br"
168
168
  };
169
169
  } else if (node.type === "image") {
170
- return convertImageNode(path, node, files);
170
+ return convertImageNode(path, node, files, configDirectory);
171
171
  } else {
172
172
  var exhaustiveCheck = node;
173
173
  throw new Error("Unexpected heading child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
174
174
  }
175
175
  }
176
- function convertParagraph(path, child, files) {
176
+ function convertParagraph(path, child, files, configDirectory) {
177
177
  var _child$content;
178
178
  return {
179
179
  tag: "p",
@@ -185,7 +185,7 @@ function convertParagraph(path, child, files) {
185
185
  tag: "br"
186
186
  };
187
187
  } else if (child.type === "image") {
188
- return convertImageNode(path.concat("children", i.toString()), child, files);
188
+ return convertImageNode(path.concat("children", i.toString()), child, files, configDirectory);
189
189
  }
190
190
  var exhaustiveCheck = child;
191
191
  throw new Error("Unexpected paragraph child type: ".concat(JSON.stringify(exhaustiveCheck, null, 2)));
@@ -244,17 +244,17 @@ function convertTextNode(node) {
244
244
  throw new Error("Unexpected node type: ".concat(exhaustiveCheck));
245
245
  }
246
246
  }
247
- function convertListItem(path, child, files) {
247
+ function convertListItem(path, child, files, configDirectory) {
248
248
  var _child$content2;
249
249
  return {
250
250
  tag: "li",
251
251
  children: ((_child$content2 = child.content) === null || _child$content2 === void 0 ? void 0 : _child$content2.map(function (child, i) {
252
252
  if (child.type === "paragraph") {
253
- return convertParagraph(path.concat("children", i.toString()), child, files);
253
+ return convertParagraph(path.concat("children", i.toString()), child, files, configDirectory);
254
254
  } else if (child.type === "bulletList") {
255
- return convertBulletList(path.concat("children", i.toString()), child, files);
255
+ return convertBulletList(path.concat("children", i.toString()), child, files, configDirectory);
256
256
  } else if (child.type === "orderedList") {
257
- return convertOrderedList(path.concat("children", i.toString()), child, files);
257
+ return convertOrderedList(path.concat("children", i.toString()), child, files, configDirectory);
258
258
  } else {
259
259
  var exhaustiveCheck = child;
260
260
  throw new Error("Unexpected list child type: ".concat(exhaustiveCheck));
@@ -262,13 +262,13 @@ function convertListItem(path, child, files) {
262
262
  })) || []
263
263
  };
264
264
  }
265
- function convertBulletList(path, node, files) {
265
+ function convertBulletList(path, node, files, configDirectory) {
266
266
  var _node$content2;
267
267
  return {
268
268
  tag: "ul",
269
269
  children: ((_node$content2 = node.content) === null || _node$content2 === void 0 ? void 0 : _node$content2.map(function (child, i) {
270
270
  if (child.type === "listItem") {
271
- return convertListItem(path.concat("children", i.toString()), child, files);
271
+ return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
272
272
  } else {
273
273
  var exhaustiveCheck = child.type;
274
274
  throw new Error("Unexpected bullet list child type: ".concat(exhaustiveCheck));
@@ -276,13 +276,13 @@ function convertBulletList(path, node, files) {
276
276
  })) || []
277
277
  };
278
278
  }
279
- function convertOrderedList(path, node, files) {
279
+ function convertOrderedList(path, node, files, configDirectory) {
280
280
  var _node$content3;
281
281
  return {
282
282
  tag: "ol",
283
283
  children: ((_node$content3 = node.content) === null || _node$content3 === void 0 ? void 0 : _node$content3.map(function (child, i) {
284
284
  if (child.type === "listItem") {
285
- return convertListItem(path.concat("children", i.toString()), child, files);
285
+ return convertListItem(path.concat("children", i.toString()), child, files, configDirectory);
286
286
  } else {
287
287
  var exhaustiveCheck = child.type;
288
288
  throw new Error("Unexpected ordered list child type: ".concat(exhaustiveCheck));
@@ -291,7 +291,7 @@ function convertOrderedList(path, node, files) {
291
291
  };
292
292
  }
293
293
  var textEncoder = new TextEncoder();
294
- function convertImageNode(path, node, files) {
294
+ function convertImageNode(path, node, files, configDirectory) {
295
295
  if (node.attrs && node.attrs.src.startsWith("data:")) {
296
296
  var sha256 = Internal.getSHA256Hash(textEncoder.encode(node.attrs.src));
297
297
  var mimeType = Internal.getMimeType(node.attrs.src);
@@ -303,7 +303,8 @@ function convertImageNode(path, node, files) {
303
303
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
304
304
  mimeType: mimeType
305
305
  }, sha256);
306
- var filePath = "/public/val/".concat(fileName);
306
+ var dir = configDirectory !== null && configDirectory !== void 0 && configDirectory.endsWith("/") ? configDirectory : "".concat(configDirectory, "/");
307
+ var filePath = "".concat(dir).concat(fileName);
307
308
  var existingFilesEntry = files[filePath];
308
309
  var thisPath = path
309
310
  // file is added as src (see below):
@@ -318,7 +319,7 @@ function convertImageNode(path, node, files) {
318
319
  }
319
320
  return {
320
321
  tag: "img",
321
- src: _defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, filePath), "metadata", {
322
+ src: _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, filePath), FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
322
323
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
323
324
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
324
325
  mimeType: mimeType
@@ -343,7 +344,7 @@ function convertImageNode(path, node, files) {
343
344
  }
344
345
  var tag = {
345
346
  tag: "img",
346
- src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, noParamsUrl), "metadata", {
347
+ src: _objectSpread2(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, VAL_EXTENSION, "file"), FILE_REF_PROP, noParamsUrl), FILE_REF_SUBTYPE_TAG, "image"), "metadata", {
347
348
  width: typeof node.attrs.width === "number" ? node.attrs.width : 0,
348
349
  height: typeof node.attrs.height === "number" ? node.attrs.height : 0,
349
350
  mimeType: noParamsUrl && Internal.filenameToMimeType(noParamsUrl) || ""
@@ -1779,7 +1780,7 @@ var ValConfig = z.object({
1779
1780
  gitCommit: z.string().optional(),
1780
1781
  gitBranch: z.string().optional()
1781
1782
  });
1782
- var ValidationFixZ = z.union([z.literal("image:add-metadata"), z.literal("image:replace-metadata"), z.literal("file:add-metadata"), z.literal("file:check-metadata"), z.literal("fix:deprecated-richtext")]);
1783
+ var ValidationFixZ = z.union([z.literal("image:change-extension"), z.literal("image:add-metadata"), z.literal("image:check-metadata"), z.literal("file:change-extension"), z.literal("file:add-metadata"), z.literal("file:check-metadata")]);
1783
1784
  var ValidationError = z.object({
1784
1785
  message: z.string(),
1785
1786
  value: z.unknown().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.66.0",
3
+ "version": "0.67.1",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "scripts": {
@@ -29,8 +29,7 @@
29
29
  "exports": true
30
30
  },
31
31
  "dependencies": {
32
- "@valbuild/core": "~0.66.0",
33
- "marked": "^9.0.3",
32
+ "@valbuild/core": "~0.67.1",
34
33
  "zod": "^3.22.4",
35
34
  "zod-validation-error": "^3.3.0"
36
35
  },