@valbuild/server 0.52.0 → 0.54.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.
@@ -93,7 +93,7 @@ function validateObjectProperties(nodes) {
|
|
93
93
|
* validating its children.
|
94
94
|
*/
|
95
95
|
function shallowValidateExpression(value) {
|
96
|
-
return ts__default["default"].isStringLiteralLike(value) || ts__default["default"].isNumericLiteral(value) || value.kind === ts__default["default"].SyntaxKind.TrueKeyword || value.kind === ts__default["default"].SyntaxKind.FalseKeyword || value.kind === ts__default["default"].SyntaxKind.NullKeyword || ts__default["default"].isArrayLiteralExpression(value) || ts__default["default"].isObjectLiteralExpression(value) || isValFileMethodCall(value) ? undefined : new ValSyntaxError("Expression must be a literal or call
|
96
|
+
return ts__default["default"].isStringLiteralLike(value) || ts__default["default"].isNumericLiteral(value) || value.kind === ts__default["default"].SyntaxKind.TrueKeyword || value.kind === ts__default["default"].SyntaxKind.FalseKeyword || value.kind === ts__default["default"].SyntaxKind.NullKeyword || ts__default["default"].isArrayLiteralExpression(value) || ts__default["default"].isObjectLiteralExpression(value) || isValFileMethodCall(value) ? undefined : new ValSyntaxError("Expression must be a literal or call c.file", value);
|
97
97
|
}
|
98
98
|
|
99
99
|
/**
|
@@ -135,7 +135,7 @@ function evaluateExpression(value) {
|
|
135
135
|
}
|
136
136
|
}));
|
137
137
|
} else {
|
138
|
-
return fp.result.err(new ValSyntaxError("Expression must be a literal or call
|
138
|
+
return fp.result.err(new ValSyntaxError("Expression must be a literal or call c.file", value));
|
139
139
|
}
|
140
140
|
}
|
141
141
|
function findObjectPropertyAssignment(value, key) {
|
@@ -150,27 +150,27 @@ function findObjectPropertyAssignment(value, key) {
|
|
150
150
|
}));
|
151
151
|
}
|
152
152
|
function isValFileMethodCall(node) {
|
153
|
-
return ts__default["default"].isCallExpression(node) && ts__default["default"].isPropertyAccessExpression(node.expression) && ts__default["default"].isIdentifier(node.expression.expression) && node.expression.expression.text === "
|
153
|
+
return ts__default["default"].isCallExpression(node) && ts__default["default"].isPropertyAccessExpression(node.expression) && ts__default["default"].isIdentifier(node.expression.expression) && node.expression.expression.text === "c" && node.expression.name.text === "file";
|
154
154
|
}
|
155
155
|
function findValFileNodeArg(node) {
|
156
156
|
if (node.arguments.length === 0) {
|
157
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
157
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: missing ref argument`, node));
|
158
158
|
} else if (node.arguments.length > 2) {
|
159
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
159
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: too many arguments ${node.arguments.length}}`, node));
|
160
160
|
} else if (!ts__default["default"].isStringLiteral(node.arguments[0])) {
|
161
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
161
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: ref must be a string literal`, node));
|
162
162
|
}
|
163
163
|
const refNode = node.arguments[0];
|
164
164
|
return fp.result.ok(refNode);
|
165
165
|
}
|
166
166
|
function findValFileMetadataArg(node) {
|
167
167
|
if (node.arguments.length === 0) {
|
168
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
168
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: missing ref argument`, node));
|
169
169
|
} else if (node.arguments.length > 2) {
|
170
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
170
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: too many arguments ${node.arguments.length}}`, node));
|
171
171
|
} else if (node.arguments.length === 2) {
|
172
172
|
if (!ts__default["default"].isObjectLiteralExpression(node.arguments[1])) {
|
173
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
173
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: metadata must be a object literal`, node));
|
174
174
|
}
|
175
175
|
return fp.result.ok(node.arguments[1]);
|
176
176
|
}
|
@@ -209,17 +209,17 @@ function validateArguments(node, validators) {
|
|
209
209
|
return fp.result.allV([node.arguments.length === validators.length ? fp.result.voidOk : fp.result.err(new ValSyntaxError(`Expected ${validators.length} arguments`, node)), ...node.arguments.slice(0, validators.length).map((argument, index) => validators[index](argument))]);
|
210
210
|
}
|
211
211
|
function analyzeDefaultExport(node) {
|
212
|
-
const
|
213
|
-
if (!ts__default["default"].isCallExpression(
|
214
|
-
return fp.result.err(new ValSyntaxError("Expected default expression to be a call expression",
|
212
|
+
const cDefine = node.expression;
|
213
|
+
if (!ts__default["default"].isCallExpression(cDefine)) {
|
214
|
+
return fp.result.err(new ValSyntaxError("Expected default expression to be a call expression", cDefine));
|
215
215
|
}
|
216
|
-
if (!isPath(
|
217
|
-
return fp.result.err(new ValSyntaxError("Expected default expression to be calling
|
216
|
+
if (!isPath(cDefine.expression, ["c", "define"])) {
|
217
|
+
return fp.result.err(new ValSyntaxError("Expected default expression to be calling c.define", cDefine.expression));
|
218
218
|
}
|
219
|
-
return fp.pipe(validateArguments(
|
219
|
+
return fp.pipe(validateArguments(cDefine, [id => {
|
220
220
|
// TODO: validate ID value here?
|
221
221
|
if (!ts__default["default"].isStringLiteralLike(id)) {
|
222
|
-
return fp.result.err(new ValSyntaxError("Expected first argument to
|
222
|
+
return fp.result.err(new ValSyntaxError("Expected first argument to c.define to be a string literal", id));
|
223
223
|
}
|
224
224
|
return fp.result.voidOk;
|
225
225
|
}, () => {
|
@@ -227,7 +227,7 @@ function analyzeDefaultExport(node) {
|
|
227
227
|
}, () => {
|
228
228
|
return fp.result.voidOk;
|
229
229
|
}]), fp.result.map(() => {
|
230
|
-
const [, schema, source] =
|
230
|
+
const [, schema, source] = cDefine.arguments;
|
231
231
|
return {
|
232
232
|
schema,
|
233
233
|
source
|
@@ -268,20 +268,27 @@ function createValFileReference(value) {
|
|
268
268
|
if (value.metadata) {
|
269
269
|
args.push(toExpression(value.metadata));
|
270
270
|
}
|
271
|
-
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("
|
271
|
+
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("file")), undefined, args);
|
272
|
+
}
|
273
|
+
function createValRichTextImage(value) {
|
274
|
+
const args = [ts__default["default"].factory.createStringLiteral(value[core.FILE_REF_PROP])];
|
275
|
+
if (value.metadata) {
|
276
|
+
args.push(toExpression(value.metadata));
|
277
|
+
}
|
278
|
+
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), "rt"), ts__default["default"].factory.createIdentifier("image")), undefined, args);
|
272
279
|
}
|
273
280
|
function createValLink(value) {
|
274
281
|
const args = [ts__default["default"].factory.createStringLiteral(value.children[0]), toExpression({
|
275
282
|
href: value.href
|
276
283
|
})];
|
277
|
-
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("
|
284
|
+
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), "rt"), ts__default["default"].factory.createIdentifier("link")), undefined, args);
|
278
285
|
}
|
279
286
|
function createValRichTextTaggedStringTemplate(value) {
|
280
287
|
const {
|
281
288
|
templateStrings: [head, ...others],
|
282
289
|
exprs
|
283
290
|
} = value;
|
284
|
-
const tag = ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("
|
291
|
+
const tag = ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("richtext"));
|
285
292
|
if (exprs.length > 0) {
|
286
293
|
return ts__default["default"].factory.createTaggedTemplateExpression(tag, undefined, ts__default["default"].factory.createTemplateExpression(ts__default["default"].factory.createTemplateHead(head, head), others.map((s, i) => ts__default["default"].factory.createTemplateSpan(toExpression(exprs[i]), i < others.length - 1 ? ts__default["default"].factory.createTemplateMiddle(s, s) : ts__default["default"].factory.createTemplateTail(s, s)))));
|
287
294
|
}
|
@@ -301,6 +308,9 @@ function toExpression(value) {
|
|
301
308
|
return ts__default["default"].factory.createArrayLiteralExpression(value.map(toExpression));
|
302
309
|
} else if (typeof value === "object") {
|
303
310
|
if (isValFileValue(value)) {
|
311
|
+
if (isValRichTextImageValue(value)) {
|
312
|
+
return createValRichTextImage(value);
|
313
|
+
}
|
304
314
|
return createValFileReference(value);
|
305
315
|
} else if (isValLinkValue(value)) {
|
306
316
|
return createValLink(value);
|
@@ -443,16 +453,16 @@ function replaceInNode(document, node, key, value) {
|
|
443
453
|
} else if (isValFileMethodCall(node)) {
|
444
454
|
if (key === core.FILE_REF_PROP) {
|
445
455
|
if (typeof value !== "string") {
|
446
|
-
return fp.result.err(new patch.PatchError("Cannot replace
|
456
|
+
return fp.result.err(new patch.PatchError("Cannot replace c.file reference with non-string value"));
|
447
457
|
}
|
448
458
|
return fp.pipe(findValFileNodeArg(node), fp.result.map(refNode => replaceNodeValue(document, refNode, value)));
|
449
459
|
} else {
|
450
460
|
return fp.pipe(findValFileMetadataArg(node), fp.result.flatMap(metadataArgNode => {
|
451
461
|
if (!metadataArgNode) {
|
452
|
-
return fp.result.err(new patch.PatchError("Cannot replace in
|
462
|
+
return fp.result.err(new patch.PatchError("Cannot replace in c.file metadata when it does not exist"));
|
453
463
|
}
|
454
464
|
if (key !== "metadata") {
|
455
|
-
return fp.result.err(new patch.PatchError(`Cannot replace
|
465
|
+
return fp.result.err(new patch.PatchError(`Cannot replace c.file metadata key ${key} when it does not exist`));
|
456
466
|
}
|
457
467
|
return replaceInNode(document,
|
458
468
|
// TODO: creating a fake object here might not be right - seems to work though
|
@@ -514,11 +524,11 @@ function removeFromNode(document, node, key) {
|
|
514
524
|
}), fp.result.map(assignment => [removeAt(document, node.properties, node.properties.indexOf(assignment))[0], assignment.initializer]));
|
515
525
|
} else if (isValFileMethodCall(node)) {
|
516
526
|
if (key === core.FILE_REF_PROP) {
|
517
|
-
return fp.result.err(new patch.PatchError("Cannot remove a ref from
|
527
|
+
return fp.result.err(new patch.PatchError("Cannot remove a ref from c.file"));
|
518
528
|
} else {
|
519
529
|
return fp.pipe(findValFileMetadataArg(node), fp.result.flatMap(metadataArgNode => {
|
520
530
|
if (!metadataArgNode) {
|
521
|
-
return fp.result.err(new patch.PatchError("Cannot remove from
|
531
|
+
return fp.result.err(new patch.PatchError("Cannot remove from c.file metadata when it does not exist"));
|
522
532
|
}
|
523
533
|
return removeFromNode(document, metadataArgNode, key);
|
524
534
|
}));
|
@@ -537,6 +547,13 @@ function isValFileValue(value) {
|
|
537
547
|
// value[VAL_EXTENSION] === "file" &&
|
538
548
|
core.FILE_REF_PROP in value && typeof value[core.FILE_REF_PROP] === "string");
|
539
549
|
}
|
550
|
+
function isValRichTextImageValue(value) {
|
551
|
+
return !!(typeof value === "object" && value &&
|
552
|
+
// TODO: replace the below with this:
|
553
|
+
// VAL_EXTENSION in value &&
|
554
|
+
// value[VAL_EXTENSION] === "file" &&
|
555
|
+
core.FILE_REF_PROP in value && typeof value[core.FILE_REF_PROP] === "string" && typeof value[core.FILE_REF_SUBTYPE_TAG] === "string" && value[core.FILE_REF_SUBTYPE_TAG] === core.RT_IMAGE_TAG);
|
556
|
+
}
|
540
557
|
function isValLinkValue(value) {
|
541
558
|
return !!(typeof value === "object" && value && core.VAL_EXTENSION in value && value[core.VAL_EXTENSION] === "link");
|
542
559
|
}
|
@@ -560,16 +577,16 @@ function addToNode(document, node, key, value) {
|
|
560
577
|
} else if (isValFileMethodCall(node)) {
|
561
578
|
if (key === core.FILE_REF_PROP) {
|
562
579
|
if (typeof value !== "string") {
|
563
|
-
return fp.result.err(new patch.PatchError(`Cannot add ${core.FILE_REF_PROP} key to
|
580
|
+
return fp.result.err(new patch.PatchError(`Cannot add ${core.FILE_REF_PROP} key to c.file with non-string value`));
|
564
581
|
}
|
565
582
|
return fp.pipe(findValFileNodeArg(node), fp.result.map(arg => replaceNodeValue(document, arg, value)));
|
566
583
|
} else {
|
567
584
|
return fp.pipe(findValFileMetadataArg(node), fp.result.flatMap(metadataArgNode => {
|
568
585
|
if (metadataArgNode) {
|
569
|
-
return fp.result.err(new patch.PatchError("Cannot add metadata to
|
586
|
+
return fp.result.err(new patch.PatchError("Cannot add metadata to c.file when it already exists"));
|
570
587
|
}
|
571
588
|
if (key !== "metadata") {
|
572
|
-
return fp.result.err(new patch.PatchError(`Cannot add ${key} key to
|
589
|
+
return fp.result.err(new patch.PatchError(`Cannot add ${key} key to c.file: only metadata is allowed`));
|
573
590
|
}
|
574
591
|
return fp.result.ok([insertAt(document, node.arguments, node.arguments.length, toExpression(value))]);
|
575
592
|
}));
|
@@ -733,9 +750,9 @@ globalThis.valModule = {
|
|
733
750
|
// if one of these are set it is a Val module, so must validate
|
734
751
|
(valModule === null || valModule === void 0 ? void 0 : valModule.id) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.schema) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.source) !== undefined) {
|
735
752
|
if (valModule.id !== id) {
|
736
|
-
fatalErrors.push(`Wrong
|
753
|
+
fatalErrors.push(`Wrong c.define id! Expected: '${id}', found: '${valModule.id}'`);
|
737
754
|
} else if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
|
738
|
-
fatalErrors.push(`Invalid
|
755
|
+
fatalErrors.push(`Invalid c.define id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
|
739
756
|
} else if ((valModule === null || valModule === void 0 ? void 0 : valModule.schema) === undefined) {
|
740
757
|
fatalErrors.push(`Expected val id: '${id}' to have a schema`);
|
741
758
|
} else if ((valModule === null || valModule === void 0 ? void 0 : valModule.source) === undefined) {
|
@@ -93,7 +93,7 @@ function validateObjectProperties(nodes) {
|
|
93
93
|
* validating its children.
|
94
94
|
*/
|
95
95
|
function shallowValidateExpression(value) {
|
96
|
-
return ts__default["default"].isStringLiteralLike(value) || ts__default["default"].isNumericLiteral(value) || value.kind === ts__default["default"].SyntaxKind.TrueKeyword || value.kind === ts__default["default"].SyntaxKind.FalseKeyword || value.kind === ts__default["default"].SyntaxKind.NullKeyword || ts__default["default"].isArrayLiteralExpression(value) || ts__default["default"].isObjectLiteralExpression(value) || isValFileMethodCall(value) ? undefined : new ValSyntaxError("Expression must be a literal or call
|
96
|
+
return ts__default["default"].isStringLiteralLike(value) || ts__default["default"].isNumericLiteral(value) || value.kind === ts__default["default"].SyntaxKind.TrueKeyword || value.kind === ts__default["default"].SyntaxKind.FalseKeyword || value.kind === ts__default["default"].SyntaxKind.NullKeyword || ts__default["default"].isArrayLiteralExpression(value) || ts__default["default"].isObjectLiteralExpression(value) || isValFileMethodCall(value) ? undefined : new ValSyntaxError("Expression must be a literal or call c.file", value);
|
97
97
|
}
|
98
98
|
|
99
99
|
/**
|
@@ -135,7 +135,7 @@ function evaluateExpression(value) {
|
|
135
135
|
}
|
136
136
|
}));
|
137
137
|
} else {
|
138
|
-
return fp.result.err(new ValSyntaxError("Expression must be a literal or call
|
138
|
+
return fp.result.err(new ValSyntaxError("Expression must be a literal or call c.file", value));
|
139
139
|
}
|
140
140
|
}
|
141
141
|
function findObjectPropertyAssignment(value, key) {
|
@@ -150,27 +150,27 @@ function findObjectPropertyAssignment(value, key) {
|
|
150
150
|
}));
|
151
151
|
}
|
152
152
|
function isValFileMethodCall(node) {
|
153
|
-
return ts__default["default"].isCallExpression(node) && ts__default["default"].isPropertyAccessExpression(node.expression) && ts__default["default"].isIdentifier(node.expression.expression) && node.expression.expression.text === "
|
153
|
+
return ts__default["default"].isCallExpression(node) && ts__default["default"].isPropertyAccessExpression(node.expression) && ts__default["default"].isIdentifier(node.expression.expression) && node.expression.expression.text === "c" && node.expression.name.text === "file";
|
154
154
|
}
|
155
155
|
function findValFileNodeArg(node) {
|
156
156
|
if (node.arguments.length === 0) {
|
157
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
157
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: missing ref argument`, node));
|
158
158
|
} else if (node.arguments.length > 2) {
|
159
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
159
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: too many arguments ${node.arguments.length}}`, node));
|
160
160
|
} else if (!ts__default["default"].isStringLiteral(node.arguments[0])) {
|
161
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
161
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: ref must be a string literal`, node));
|
162
162
|
}
|
163
163
|
const refNode = node.arguments[0];
|
164
164
|
return fp.result.ok(refNode);
|
165
165
|
}
|
166
166
|
function findValFileMetadataArg(node) {
|
167
167
|
if (node.arguments.length === 0) {
|
168
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
168
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: missing ref argument`, node));
|
169
169
|
} else if (node.arguments.length > 2) {
|
170
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
170
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: too many arguments ${node.arguments.length}}`, node));
|
171
171
|
} else if (node.arguments.length === 2) {
|
172
172
|
if (!ts__default["default"].isObjectLiteralExpression(node.arguments[1])) {
|
173
|
-
return fp.result.err(new ValSyntaxError(`Invalid
|
173
|
+
return fp.result.err(new ValSyntaxError(`Invalid c.file() call: metadata must be a object literal`, node));
|
174
174
|
}
|
175
175
|
return fp.result.ok(node.arguments[1]);
|
176
176
|
}
|
@@ -209,17 +209,17 @@ function validateArguments(node, validators) {
|
|
209
209
|
return fp.result.allV([node.arguments.length === validators.length ? fp.result.voidOk : fp.result.err(new ValSyntaxError(`Expected ${validators.length} arguments`, node)), ...node.arguments.slice(0, validators.length).map((argument, index) => validators[index](argument))]);
|
210
210
|
}
|
211
211
|
function analyzeDefaultExport(node) {
|
212
|
-
const
|
213
|
-
if (!ts__default["default"].isCallExpression(
|
214
|
-
return fp.result.err(new ValSyntaxError("Expected default expression to be a call expression",
|
212
|
+
const cDefine = node.expression;
|
213
|
+
if (!ts__default["default"].isCallExpression(cDefine)) {
|
214
|
+
return fp.result.err(new ValSyntaxError("Expected default expression to be a call expression", cDefine));
|
215
215
|
}
|
216
|
-
if (!isPath(
|
217
|
-
return fp.result.err(new ValSyntaxError("Expected default expression to be calling
|
216
|
+
if (!isPath(cDefine.expression, ["c", "define"])) {
|
217
|
+
return fp.result.err(new ValSyntaxError("Expected default expression to be calling c.define", cDefine.expression));
|
218
218
|
}
|
219
|
-
return fp.pipe(validateArguments(
|
219
|
+
return fp.pipe(validateArguments(cDefine, [id => {
|
220
220
|
// TODO: validate ID value here?
|
221
221
|
if (!ts__default["default"].isStringLiteralLike(id)) {
|
222
|
-
return fp.result.err(new ValSyntaxError("Expected first argument to
|
222
|
+
return fp.result.err(new ValSyntaxError("Expected first argument to c.define to be a string literal", id));
|
223
223
|
}
|
224
224
|
return fp.result.voidOk;
|
225
225
|
}, () => {
|
@@ -227,7 +227,7 @@ function analyzeDefaultExport(node) {
|
|
227
227
|
}, () => {
|
228
228
|
return fp.result.voidOk;
|
229
229
|
}]), fp.result.map(() => {
|
230
|
-
const [, schema, source] =
|
230
|
+
const [, schema, source] = cDefine.arguments;
|
231
231
|
return {
|
232
232
|
schema,
|
233
233
|
source
|
@@ -268,20 +268,27 @@ function createValFileReference(value) {
|
|
268
268
|
if (value.metadata) {
|
269
269
|
args.push(toExpression(value.metadata));
|
270
270
|
}
|
271
|
-
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("
|
271
|
+
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("file")), undefined, args);
|
272
|
+
}
|
273
|
+
function createValRichTextImage(value) {
|
274
|
+
const args = [ts__default["default"].factory.createStringLiteral(value[core.FILE_REF_PROP])];
|
275
|
+
if (value.metadata) {
|
276
|
+
args.push(toExpression(value.metadata));
|
277
|
+
}
|
278
|
+
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), "rt"), ts__default["default"].factory.createIdentifier("image")), undefined, args);
|
272
279
|
}
|
273
280
|
function createValLink(value) {
|
274
281
|
const args = [ts__default["default"].factory.createStringLiteral(value.children[0]), toExpression({
|
275
282
|
href: value.href
|
276
283
|
})];
|
277
|
-
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("
|
284
|
+
return ts__default["default"].factory.createCallExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), "rt"), ts__default["default"].factory.createIdentifier("link")), undefined, args);
|
278
285
|
}
|
279
286
|
function createValRichTextTaggedStringTemplate(value) {
|
280
287
|
const {
|
281
288
|
templateStrings: [head, ...others],
|
282
289
|
exprs
|
283
290
|
} = value;
|
284
|
-
const tag = ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("
|
291
|
+
const tag = ts__default["default"].factory.createPropertyAccessExpression(ts__default["default"].factory.createIdentifier("c"), ts__default["default"].factory.createIdentifier("richtext"));
|
285
292
|
if (exprs.length > 0) {
|
286
293
|
return ts__default["default"].factory.createTaggedTemplateExpression(tag, undefined, ts__default["default"].factory.createTemplateExpression(ts__default["default"].factory.createTemplateHead(head, head), others.map((s, i) => ts__default["default"].factory.createTemplateSpan(toExpression(exprs[i]), i < others.length - 1 ? ts__default["default"].factory.createTemplateMiddle(s, s) : ts__default["default"].factory.createTemplateTail(s, s)))));
|
287
294
|
}
|
@@ -301,6 +308,9 @@ function toExpression(value) {
|
|
301
308
|
return ts__default["default"].factory.createArrayLiteralExpression(value.map(toExpression));
|
302
309
|
} else if (typeof value === "object") {
|
303
310
|
if (isValFileValue(value)) {
|
311
|
+
if (isValRichTextImageValue(value)) {
|
312
|
+
return createValRichTextImage(value);
|
313
|
+
}
|
304
314
|
return createValFileReference(value);
|
305
315
|
} else if (isValLinkValue(value)) {
|
306
316
|
return createValLink(value);
|
@@ -443,16 +453,16 @@ function replaceInNode(document, node, key, value) {
|
|
443
453
|
} else if (isValFileMethodCall(node)) {
|
444
454
|
if (key === core.FILE_REF_PROP) {
|
445
455
|
if (typeof value !== "string") {
|
446
|
-
return fp.result.err(new patch.PatchError("Cannot replace
|
456
|
+
return fp.result.err(new patch.PatchError("Cannot replace c.file reference with non-string value"));
|
447
457
|
}
|
448
458
|
return fp.pipe(findValFileNodeArg(node), fp.result.map(refNode => replaceNodeValue(document, refNode, value)));
|
449
459
|
} else {
|
450
460
|
return fp.pipe(findValFileMetadataArg(node), fp.result.flatMap(metadataArgNode => {
|
451
461
|
if (!metadataArgNode) {
|
452
|
-
return fp.result.err(new patch.PatchError("Cannot replace in
|
462
|
+
return fp.result.err(new patch.PatchError("Cannot replace in c.file metadata when it does not exist"));
|
453
463
|
}
|
454
464
|
if (key !== "metadata") {
|
455
|
-
return fp.result.err(new patch.PatchError(`Cannot replace
|
465
|
+
return fp.result.err(new patch.PatchError(`Cannot replace c.file metadata key ${key} when it does not exist`));
|
456
466
|
}
|
457
467
|
return replaceInNode(document,
|
458
468
|
// TODO: creating a fake object here might not be right - seems to work though
|
@@ -514,11 +524,11 @@ function removeFromNode(document, node, key) {
|
|
514
524
|
}), fp.result.map(assignment => [removeAt(document, node.properties, node.properties.indexOf(assignment))[0], assignment.initializer]));
|
515
525
|
} else if (isValFileMethodCall(node)) {
|
516
526
|
if (key === core.FILE_REF_PROP) {
|
517
|
-
return fp.result.err(new patch.PatchError("Cannot remove a ref from
|
527
|
+
return fp.result.err(new patch.PatchError("Cannot remove a ref from c.file"));
|
518
528
|
} else {
|
519
529
|
return fp.pipe(findValFileMetadataArg(node), fp.result.flatMap(metadataArgNode => {
|
520
530
|
if (!metadataArgNode) {
|
521
|
-
return fp.result.err(new patch.PatchError("Cannot remove from
|
531
|
+
return fp.result.err(new patch.PatchError("Cannot remove from c.file metadata when it does not exist"));
|
522
532
|
}
|
523
533
|
return removeFromNode(document, metadataArgNode, key);
|
524
534
|
}));
|
@@ -537,6 +547,13 @@ function isValFileValue(value) {
|
|
537
547
|
// value[VAL_EXTENSION] === "file" &&
|
538
548
|
core.FILE_REF_PROP in value && typeof value[core.FILE_REF_PROP] === "string");
|
539
549
|
}
|
550
|
+
function isValRichTextImageValue(value) {
|
551
|
+
return !!(typeof value === "object" && value &&
|
552
|
+
// TODO: replace the below with this:
|
553
|
+
// VAL_EXTENSION in value &&
|
554
|
+
// value[VAL_EXTENSION] === "file" &&
|
555
|
+
core.FILE_REF_PROP in value && typeof value[core.FILE_REF_PROP] === "string" && typeof value[core.FILE_REF_SUBTYPE_TAG] === "string" && value[core.FILE_REF_SUBTYPE_TAG] === core.RT_IMAGE_TAG);
|
556
|
+
}
|
540
557
|
function isValLinkValue(value) {
|
541
558
|
return !!(typeof value === "object" && value && core.VAL_EXTENSION in value && value[core.VAL_EXTENSION] === "link");
|
542
559
|
}
|
@@ -560,16 +577,16 @@ function addToNode(document, node, key, value) {
|
|
560
577
|
} else if (isValFileMethodCall(node)) {
|
561
578
|
if (key === core.FILE_REF_PROP) {
|
562
579
|
if (typeof value !== "string") {
|
563
|
-
return fp.result.err(new patch.PatchError(`Cannot add ${core.FILE_REF_PROP} key to
|
580
|
+
return fp.result.err(new patch.PatchError(`Cannot add ${core.FILE_REF_PROP} key to c.file with non-string value`));
|
564
581
|
}
|
565
582
|
return fp.pipe(findValFileNodeArg(node), fp.result.map(arg => replaceNodeValue(document, arg, value)));
|
566
583
|
} else {
|
567
584
|
return fp.pipe(findValFileMetadataArg(node), fp.result.flatMap(metadataArgNode => {
|
568
585
|
if (metadataArgNode) {
|
569
|
-
return fp.result.err(new patch.PatchError("Cannot add metadata to
|
586
|
+
return fp.result.err(new patch.PatchError("Cannot add metadata to c.file when it already exists"));
|
570
587
|
}
|
571
588
|
if (key !== "metadata") {
|
572
|
-
return fp.result.err(new patch.PatchError(`Cannot add ${key} key to
|
589
|
+
return fp.result.err(new patch.PatchError(`Cannot add ${key} key to c.file: only metadata is allowed`));
|
573
590
|
}
|
574
591
|
return fp.result.ok([insertAt(document, node.arguments, node.arguments.length, toExpression(value))]);
|
575
592
|
}));
|
@@ -733,9 +750,9 @@ globalThis.valModule = {
|
|
733
750
|
// if one of these are set it is a Val module, so must validate
|
734
751
|
(valModule === null || valModule === void 0 ? void 0 : valModule.id) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.schema) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.source) !== undefined) {
|
735
752
|
if (valModule.id !== id) {
|
736
|
-
fatalErrors.push(`Wrong
|
753
|
+
fatalErrors.push(`Wrong c.define id! Expected: '${id}', found: '${valModule.id}'`);
|
737
754
|
} else if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
|
738
|
-
fatalErrors.push(`Invalid
|
755
|
+
fatalErrors.push(`Invalid c.define id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
|
739
756
|
} else if ((valModule === null || valModule === void 0 ? void 0 : valModule.schema) === undefined) {
|
740
757
|
fatalErrors.push(`Expected val id: '${id}' to have a schema`);
|
741
758
|
} else if ((valModule === null || valModule === void 0 ? void 0 : valModule.source) === undefined) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { newQuickJSWASMModule } from 'quickjs-emscripten';
|
2
2
|
import ts from 'typescript';
|
3
3
|
import { result, pipe } from '@valbuild/core/fp';
|
4
|
-
import { FILE_REF_PROP, VAL_EXTENSION, derefPatch, Internal, Schema } from '@valbuild/core';
|
4
|
+
import { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG, RT_IMAGE_TAG, VAL_EXTENSION, derefPatch, Internal, Schema } from '@valbuild/core';
|
5
5
|
import { deepEqual, isNotRoot, PatchError, parseAndValidateArrayIndex, applyPatch, parsePatch, sourceToPatchPath } from '@valbuild/core/patch';
|
6
6
|
import * as path from 'path';
|
7
7
|
import path__default from 'path';
|
@@ -63,7 +63,7 @@ function validateObjectProperties(nodes) {
|
|
63
63
|
* validating its children.
|
64
64
|
*/
|
65
65
|
function shallowValidateExpression(value) {
|
66
|
-
return ts.isStringLiteralLike(value) || ts.isNumericLiteral(value) || value.kind === ts.SyntaxKind.TrueKeyword || value.kind === ts.SyntaxKind.FalseKeyword || value.kind === ts.SyntaxKind.NullKeyword || ts.isArrayLiteralExpression(value) || ts.isObjectLiteralExpression(value) || isValFileMethodCall(value) ? undefined : new ValSyntaxError("Expression must be a literal or call
|
66
|
+
return ts.isStringLiteralLike(value) || ts.isNumericLiteral(value) || value.kind === ts.SyntaxKind.TrueKeyword || value.kind === ts.SyntaxKind.FalseKeyword || value.kind === ts.SyntaxKind.NullKeyword || ts.isArrayLiteralExpression(value) || ts.isObjectLiteralExpression(value) || isValFileMethodCall(value) ? undefined : new ValSyntaxError("Expression must be a literal or call c.file", value);
|
67
67
|
}
|
68
68
|
|
69
69
|
/**
|
@@ -105,7 +105,7 @@ function evaluateExpression(value) {
|
|
105
105
|
}
|
106
106
|
}));
|
107
107
|
} else {
|
108
|
-
return result.err(new ValSyntaxError("Expression must be a literal or call
|
108
|
+
return result.err(new ValSyntaxError("Expression must be a literal or call c.file", value));
|
109
109
|
}
|
110
110
|
}
|
111
111
|
function findObjectPropertyAssignment(value, key) {
|
@@ -120,27 +120,27 @@ function findObjectPropertyAssignment(value, key) {
|
|
120
120
|
}));
|
121
121
|
}
|
122
122
|
function isValFileMethodCall(node) {
|
123
|
-
return ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && node.expression.expression.text === "
|
123
|
+
return ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && node.expression.expression.text === "c" && node.expression.name.text === "file";
|
124
124
|
}
|
125
125
|
function findValFileNodeArg(node) {
|
126
126
|
if (node.arguments.length === 0) {
|
127
|
-
return result.err(new ValSyntaxError(`Invalid
|
127
|
+
return result.err(new ValSyntaxError(`Invalid c.file() call: missing ref argument`, node));
|
128
128
|
} else if (node.arguments.length > 2) {
|
129
|
-
return result.err(new ValSyntaxError(`Invalid
|
129
|
+
return result.err(new ValSyntaxError(`Invalid c.file() call: too many arguments ${node.arguments.length}}`, node));
|
130
130
|
} else if (!ts.isStringLiteral(node.arguments[0])) {
|
131
|
-
return result.err(new ValSyntaxError(`Invalid
|
131
|
+
return result.err(new ValSyntaxError(`Invalid c.file() call: ref must be a string literal`, node));
|
132
132
|
}
|
133
133
|
const refNode = node.arguments[0];
|
134
134
|
return result.ok(refNode);
|
135
135
|
}
|
136
136
|
function findValFileMetadataArg(node) {
|
137
137
|
if (node.arguments.length === 0) {
|
138
|
-
return result.err(new ValSyntaxError(`Invalid
|
138
|
+
return result.err(new ValSyntaxError(`Invalid c.file() call: missing ref argument`, node));
|
139
139
|
} else if (node.arguments.length > 2) {
|
140
|
-
return result.err(new ValSyntaxError(`Invalid
|
140
|
+
return result.err(new ValSyntaxError(`Invalid c.file() call: too many arguments ${node.arguments.length}}`, node));
|
141
141
|
} else if (node.arguments.length === 2) {
|
142
142
|
if (!ts.isObjectLiteralExpression(node.arguments[1])) {
|
143
|
-
return result.err(new ValSyntaxError(`Invalid
|
143
|
+
return result.err(new ValSyntaxError(`Invalid c.file() call: metadata must be a object literal`, node));
|
144
144
|
}
|
145
145
|
return result.ok(node.arguments[1]);
|
146
146
|
}
|
@@ -179,17 +179,17 @@ function validateArguments(node, validators) {
|
|
179
179
|
return result.allV([node.arguments.length === validators.length ? result.voidOk : result.err(new ValSyntaxError(`Expected ${validators.length} arguments`, node)), ...node.arguments.slice(0, validators.length).map((argument, index) => validators[index](argument))]);
|
180
180
|
}
|
181
181
|
function analyzeDefaultExport(node) {
|
182
|
-
const
|
183
|
-
if (!ts.isCallExpression(
|
184
|
-
return result.err(new ValSyntaxError("Expected default expression to be a call expression",
|
182
|
+
const cDefine = node.expression;
|
183
|
+
if (!ts.isCallExpression(cDefine)) {
|
184
|
+
return result.err(new ValSyntaxError("Expected default expression to be a call expression", cDefine));
|
185
185
|
}
|
186
|
-
if (!isPath(
|
187
|
-
return result.err(new ValSyntaxError("Expected default expression to be calling
|
186
|
+
if (!isPath(cDefine.expression, ["c", "define"])) {
|
187
|
+
return result.err(new ValSyntaxError("Expected default expression to be calling c.define", cDefine.expression));
|
188
188
|
}
|
189
|
-
return pipe(validateArguments(
|
189
|
+
return pipe(validateArguments(cDefine, [id => {
|
190
190
|
// TODO: validate ID value here?
|
191
191
|
if (!ts.isStringLiteralLike(id)) {
|
192
|
-
return result.err(new ValSyntaxError("Expected first argument to
|
192
|
+
return result.err(new ValSyntaxError("Expected first argument to c.define to be a string literal", id));
|
193
193
|
}
|
194
194
|
return result.voidOk;
|
195
195
|
}, () => {
|
@@ -197,7 +197,7 @@ function analyzeDefaultExport(node) {
|
|
197
197
|
}, () => {
|
198
198
|
return result.voidOk;
|
199
199
|
}]), result.map(() => {
|
200
|
-
const [, schema, source] =
|
200
|
+
const [, schema, source] = cDefine.arguments;
|
201
201
|
return {
|
202
202
|
schema,
|
203
203
|
source
|
@@ -238,20 +238,27 @@ function createValFileReference(value) {
|
|
238
238
|
if (value.metadata) {
|
239
239
|
args.push(toExpression(value.metadata));
|
240
240
|
}
|
241
|
-
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("
|
241
|
+
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("c"), ts.factory.createIdentifier("file")), undefined, args);
|
242
|
+
}
|
243
|
+
function createValRichTextImage(value) {
|
244
|
+
const args = [ts.factory.createStringLiteral(value[FILE_REF_PROP])];
|
245
|
+
if (value.metadata) {
|
246
|
+
args.push(toExpression(value.metadata));
|
247
|
+
}
|
248
|
+
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("c"), "rt"), ts.factory.createIdentifier("image")), undefined, args);
|
242
249
|
}
|
243
250
|
function createValLink(value) {
|
244
251
|
const args = [ts.factory.createStringLiteral(value.children[0]), toExpression({
|
245
252
|
href: value.href
|
246
253
|
})];
|
247
|
-
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("
|
254
|
+
return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("c"), "rt"), ts.factory.createIdentifier("link")), undefined, args);
|
248
255
|
}
|
249
256
|
function createValRichTextTaggedStringTemplate(value) {
|
250
257
|
const {
|
251
258
|
templateStrings: [head, ...others],
|
252
259
|
exprs
|
253
260
|
} = value;
|
254
|
-
const tag = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("
|
261
|
+
const tag = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("c"), ts.factory.createIdentifier("richtext"));
|
255
262
|
if (exprs.length > 0) {
|
256
263
|
return ts.factory.createTaggedTemplateExpression(tag, undefined, ts.factory.createTemplateExpression(ts.factory.createTemplateHead(head, head), others.map((s, i) => ts.factory.createTemplateSpan(toExpression(exprs[i]), i < others.length - 1 ? ts.factory.createTemplateMiddle(s, s) : ts.factory.createTemplateTail(s, s)))));
|
257
264
|
}
|
@@ -271,6 +278,9 @@ function toExpression(value) {
|
|
271
278
|
return ts.factory.createArrayLiteralExpression(value.map(toExpression));
|
272
279
|
} else if (typeof value === "object") {
|
273
280
|
if (isValFileValue(value)) {
|
281
|
+
if (isValRichTextImageValue(value)) {
|
282
|
+
return createValRichTextImage(value);
|
283
|
+
}
|
274
284
|
return createValFileReference(value);
|
275
285
|
} else if (isValLinkValue(value)) {
|
276
286
|
return createValLink(value);
|
@@ -413,16 +423,16 @@ function replaceInNode(document, node, key, value) {
|
|
413
423
|
} else if (isValFileMethodCall(node)) {
|
414
424
|
if (key === FILE_REF_PROP) {
|
415
425
|
if (typeof value !== "string") {
|
416
|
-
return result.err(new PatchError("Cannot replace
|
426
|
+
return result.err(new PatchError("Cannot replace c.file reference with non-string value"));
|
417
427
|
}
|
418
428
|
return pipe(findValFileNodeArg(node), result.map(refNode => replaceNodeValue(document, refNode, value)));
|
419
429
|
} else {
|
420
430
|
return pipe(findValFileMetadataArg(node), result.flatMap(metadataArgNode => {
|
421
431
|
if (!metadataArgNode) {
|
422
|
-
return result.err(new PatchError("Cannot replace in
|
432
|
+
return result.err(new PatchError("Cannot replace in c.file metadata when it does not exist"));
|
423
433
|
}
|
424
434
|
if (key !== "metadata") {
|
425
|
-
return result.err(new PatchError(`Cannot replace
|
435
|
+
return result.err(new PatchError(`Cannot replace c.file metadata key ${key} when it does not exist`));
|
426
436
|
}
|
427
437
|
return replaceInNode(document,
|
428
438
|
// TODO: creating a fake object here might not be right - seems to work though
|
@@ -484,11 +494,11 @@ function removeFromNode(document, node, key) {
|
|
484
494
|
}), result.map(assignment => [removeAt(document, node.properties, node.properties.indexOf(assignment))[0], assignment.initializer]));
|
485
495
|
} else if (isValFileMethodCall(node)) {
|
486
496
|
if (key === FILE_REF_PROP) {
|
487
|
-
return result.err(new PatchError("Cannot remove a ref from
|
497
|
+
return result.err(new PatchError("Cannot remove a ref from c.file"));
|
488
498
|
} else {
|
489
499
|
return pipe(findValFileMetadataArg(node), result.flatMap(metadataArgNode => {
|
490
500
|
if (!metadataArgNode) {
|
491
|
-
return result.err(new PatchError("Cannot remove from
|
501
|
+
return result.err(new PatchError("Cannot remove from c.file metadata when it does not exist"));
|
492
502
|
}
|
493
503
|
return removeFromNode(document, metadataArgNode, key);
|
494
504
|
}));
|
@@ -507,6 +517,13 @@ function isValFileValue(value) {
|
|
507
517
|
// value[VAL_EXTENSION] === "file" &&
|
508
518
|
FILE_REF_PROP in value && typeof value[FILE_REF_PROP] === "string");
|
509
519
|
}
|
520
|
+
function isValRichTextImageValue(value) {
|
521
|
+
return !!(typeof value === "object" && value &&
|
522
|
+
// TODO: replace the below with this:
|
523
|
+
// VAL_EXTENSION in value &&
|
524
|
+
// value[VAL_EXTENSION] === "file" &&
|
525
|
+
FILE_REF_PROP in value && typeof value[FILE_REF_PROP] === "string" && typeof value[FILE_REF_SUBTYPE_TAG] === "string" && value[FILE_REF_SUBTYPE_TAG] === RT_IMAGE_TAG);
|
526
|
+
}
|
510
527
|
function isValLinkValue(value) {
|
511
528
|
return !!(typeof value === "object" && value && VAL_EXTENSION in value && value[VAL_EXTENSION] === "link");
|
512
529
|
}
|
@@ -530,16 +547,16 @@ function addToNode(document, node, key, value) {
|
|
530
547
|
} else if (isValFileMethodCall(node)) {
|
531
548
|
if (key === FILE_REF_PROP) {
|
532
549
|
if (typeof value !== "string") {
|
533
|
-
return result.err(new PatchError(`Cannot add ${FILE_REF_PROP} key to
|
550
|
+
return result.err(new PatchError(`Cannot add ${FILE_REF_PROP} key to c.file with non-string value`));
|
534
551
|
}
|
535
552
|
return pipe(findValFileNodeArg(node), result.map(arg => replaceNodeValue(document, arg, value)));
|
536
553
|
} else {
|
537
554
|
return pipe(findValFileMetadataArg(node), result.flatMap(metadataArgNode => {
|
538
555
|
if (metadataArgNode) {
|
539
|
-
return result.err(new PatchError("Cannot add metadata to
|
556
|
+
return result.err(new PatchError("Cannot add metadata to c.file when it already exists"));
|
540
557
|
}
|
541
558
|
if (key !== "metadata") {
|
542
|
-
return result.err(new PatchError(`Cannot add ${key} key to
|
559
|
+
return result.err(new PatchError(`Cannot add ${key} key to c.file: only metadata is allowed`));
|
543
560
|
}
|
544
561
|
return result.ok([insertAt(document, node.arguments, node.arguments.length, toExpression(value))]);
|
545
562
|
}));
|
@@ -703,9 +720,9 @@ globalThis.valModule = {
|
|
703
720
|
// if one of these are set it is a Val module, so must validate
|
704
721
|
(valModule === null || valModule === void 0 ? void 0 : valModule.id) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.schema) !== undefined || (valModule === null || valModule === void 0 ? void 0 : valModule.source) !== undefined) {
|
705
722
|
if (valModule.id !== id) {
|
706
|
-
fatalErrors.push(`Wrong
|
723
|
+
fatalErrors.push(`Wrong c.define id! Expected: '${id}', found: '${valModule.id}'`);
|
707
724
|
} else if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
|
708
|
-
fatalErrors.push(`Invalid
|
725
|
+
fatalErrors.push(`Invalid c.define id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
|
709
726
|
} else if ((valModule === null || valModule === void 0 ? void 0 : valModule.schema) === undefined) {
|
710
727
|
fatalErrors.push(`Expected val id: '${id}' to have a schema`);
|
711
728
|
} else if ((valModule === null || valModule === void 0 ? void 0 : valModule.source) === undefined) {
|
package/package.json
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
"./package.json": "./package.json"
|
13
13
|
},
|
14
14
|
"types": "dist/valbuild-server.cjs.d.ts",
|
15
|
-
"version": "0.
|
15
|
+
"version": "0.54.0",
|
16
16
|
"scripts": {
|
17
17
|
"typecheck": "tsc --noEmit",
|
18
18
|
"test": "jest",
|
@@ -24,9 +24,9 @@
|
|
24
24
|
"concurrently": "^7.6.0"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@valbuild/core": "~0.
|
28
|
-
"@valbuild/shared": "~0.
|
29
|
-
"@valbuild/ui": "~0.
|
27
|
+
"@valbuild/core": "~0.54.0",
|
28
|
+
"@valbuild/shared": "~0.54.0",
|
29
|
+
"@valbuild/ui": "~0.54.0",
|
30
30
|
"express": "^4.18.2",
|
31
31
|
"image-size": "^1.0.2",
|
32
32
|
"queue": "^6.0.2",
|