@valbuild/server 0.40.0 → 0.41.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.
package/README.md
ADDED
@@ -676,6 +676,24 @@ const patchSourceFile = (sourceFile, patch$1) => {
|
|
676
676
|
|
677
677
|
const readValFile = async (id, valConfigPath, runtime) => {
|
678
678
|
const context = runtime.newContext();
|
679
|
+
|
680
|
+
// avoid failures when console.log is called
|
681
|
+
const logHandle = context.newFunction("log", () => {
|
682
|
+
// do nothing
|
683
|
+
});
|
684
|
+
const consoleHandle = context.newObject();
|
685
|
+
context.setProp(consoleHandle, "log", logHandle);
|
686
|
+
context.setProp(context.global, "console", consoleHandle);
|
687
|
+
consoleHandle.dispose();
|
688
|
+
logHandle.dispose();
|
689
|
+
|
690
|
+
// avoid failures when process.env is called
|
691
|
+
const envHandle = context.newObject();
|
692
|
+
const processHandle = context.newObject();
|
693
|
+
context.setProp(processHandle, "env", envHandle);
|
694
|
+
context.setProp(context.global, "process", processHandle);
|
695
|
+
envHandle.dispose();
|
696
|
+
processHandle.dispose();
|
679
697
|
try {
|
680
698
|
const modulePath = `.${id}.val`;
|
681
699
|
const code = `import * as valModule from ${JSON.stringify(modulePath)};
|
@@ -716,6 +734,9 @@ globalThis.valModule = {
|
|
716
734
|
if (valModule.id !== id) {
|
717
735
|
fatalErrors.push(`Wrong val.content id! In the file of with: '${id}', found: '${valModule.id}'`);
|
718
736
|
}
|
737
|
+
if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
|
738
|
+
fatalErrors.push(`Invalid val.content id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
|
739
|
+
}
|
719
740
|
if (!(valModule !== null && valModule !== void 0 && valModule.schema)) {
|
720
741
|
fatalErrors.push(`Expected val id: '${id}' to have a schema`);
|
721
742
|
}
|
@@ -948,7 +969,7 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
|
|
948
969
|
}
|
949
970
|
if (modulePath === "@valbuild/react/stega") {
|
950
971
|
return {
|
951
|
-
value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export const fetchVal = () => { throw Error(`Cannot use 'fetchVal' in this type of file`) }; export const autoTagJSX = () => { /* ignore */ };"
|
972
|
+
value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export const fetchVal = () => { throw Error(`Cannot use 'fetchVal' in this type of file`) }; export const autoTagJSX = () => { /* ignore */ }; export const stegaClean = () => { throw Error(`Cannot use 'stegaClean' in this type of file`) }; "
|
952
973
|
};
|
953
974
|
}
|
954
975
|
if (modulePath.startsWith("next/navigation")) {
|
@@ -1056,7 +1077,7 @@ class Service {
|
|
1056
1077
|
}, sourceFileHandler, runtime) {
|
1057
1078
|
this.sourceFileHandler = sourceFileHandler;
|
1058
1079
|
this.runtime = runtime;
|
1059
|
-
this.valConfigPath = valConfigPath;
|
1080
|
+
this.valConfigPath = valConfigPath || "./val.config";
|
1060
1081
|
}
|
1061
1082
|
async get(moduleId, modulePath) {
|
1062
1083
|
const valModule = await readValFile(moduleId, this.valConfigPath, this.runtime);
|
@@ -676,6 +676,24 @@ const patchSourceFile = (sourceFile, patch$1) => {
|
|
676
676
|
|
677
677
|
const readValFile = async (id, valConfigPath, runtime) => {
|
678
678
|
const context = runtime.newContext();
|
679
|
+
|
680
|
+
// avoid failures when console.log is called
|
681
|
+
const logHandle = context.newFunction("log", () => {
|
682
|
+
// do nothing
|
683
|
+
});
|
684
|
+
const consoleHandle = context.newObject();
|
685
|
+
context.setProp(consoleHandle, "log", logHandle);
|
686
|
+
context.setProp(context.global, "console", consoleHandle);
|
687
|
+
consoleHandle.dispose();
|
688
|
+
logHandle.dispose();
|
689
|
+
|
690
|
+
// avoid failures when process.env is called
|
691
|
+
const envHandle = context.newObject();
|
692
|
+
const processHandle = context.newObject();
|
693
|
+
context.setProp(processHandle, "env", envHandle);
|
694
|
+
context.setProp(context.global, "process", processHandle);
|
695
|
+
envHandle.dispose();
|
696
|
+
processHandle.dispose();
|
679
697
|
try {
|
680
698
|
const modulePath = `.${id}.val`;
|
681
699
|
const code = `import * as valModule from ${JSON.stringify(modulePath)};
|
@@ -716,6 +734,9 @@ globalThis.valModule = {
|
|
716
734
|
if (valModule.id !== id) {
|
717
735
|
fatalErrors.push(`Wrong val.content id! In the file of with: '${id}', found: '${valModule.id}'`);
|
718
736
|
}
|
737
|
+
if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
|
738
|
+
fatalErrors.push(`Invalid val.content id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
|
739
|
+
}
|
719
740
|
if (!(valModule !== null && valModule !== void 0 && valModule.schema)) {
|
720
741
|
fatalErrors.push(`Expected val id: '${id}' to have a schema`);
|
721
742
|
}
|
@@ -948,7 +969,7 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
|
|
948
969
|
}
|
949
970
|
if (modulePath === "@valbuild/react/stega") {
|
950
971
|
return {
|
951
|
-
value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export const fetchVal = () => { throw Error(`Cannot use 'fetchVal' in this type of file`) }; export const autoTagJSX = () => { /* ignore */ };"
|
972
|
+
value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export const fetchVal = () => { throw Error(`Cannot use 'fetchVal' in this type of file`) }; export const autoTagJSX = () => { /* ignore */ }; export const stegaClean = () => { throw Error(`Cannot use 'stegaClean' in this type of file`) }; "
|
952
973
|
};
|
953
974
|
}
|
954
975
|
if (modulePath.startsWith("next/navigation")) {
|
@@ -1056,7 +1077,7 @@ class Service {
|
|
1056
1077
|
}, sourceFileHandler, runtime) {
|
1057
1078
|
this.sourceFileHandler = sourceFileHandler;
|
1058
1079
|
this.runtime = runtime;
|
1059
|
-
this.valConfigPath = valConfigPath;
|
1080
|
+
this.valConfigPath = valConfigPath || "./val.config";
|
1060
1081
|
}
|
1061
1082
|
async get(moduleId, modulePath) {
|
1062
1083
|
const valModule = await readValFile(moduleId, this.valConfigPath, this.runtime);
|
@@ -646,6 +646,24 @@ const patchSourceFile = (sourceFile, patch) => {
|
|
646
646
|
|
647
647
|
const readValFile = async (id, valConfigPath, runtime) => {
|
648
648
|
const context = runtime.newContext();
|
649
|
+
|
650
|
+
// avoid failures when console.log is called
|
651
|
+
const logHandle = context.newFunction("log", () => {
|
652
|
+
// do nothing
|
653
|
+
});
|
654
|
+
const consoleHandle = context.newObject();
|
655
|
+
context.setProp(consoleHandle, "log", logHandle);
|
656
|
+
context.setProp(context.global, "console", consoleHandle);
|
657
|
+
consoleHandle.dispose();
|
658
|
+
logHandle.dispose();
|
659
|
+
|
660
|
+
// avoid failures when process.env is called
|
661
|
+
const envHandle = context.newObject();
|
662
|
+
const processHandle = context.newObject();
|
663
|
+
context.setProp(processHandle, "env", envHandle);
|
664
|
+
context.setProp(context.global, "process", processHandle);
|
665
|
+
envHandle.dispose();
|
666
|
+
processHandle.dispose();
|
649
667
|
try {
|
650
668
|
const modulePath = `.${id}.val`;
|
651
669
|
const code = `import * as valModule from ${JSON.stringify(modulePath)};
|
@@ -686,6 +704,9 @@ globalThis.valModule = {
|
|
686
704
|
if (valModule.id !== id) {
|
687
705
|
fatalErrors.push(`Wrong val.content id! In the file of with: '${id}', found: '${valModule.id}'`);
|
688
706
|
}
|
707
|
+
if (encodeURIComponent(valModule.id).replace(/%2F/g, "/") !== valModule.id) {
|
708
|
+
fatalErrors.push(`Invalid val.content id! Must be a web-safe path without escape characters, found: '${valModule.id}', which was encoded as: '${encodeURIComponent(valModule.id).replace("%2F", "/")}'`);
|
709
|
+
}
|
689
710
|
if (!(valModule !== null && valModule !== void 0 && valModule.schema)) {
|
690
711
|
fatalErrors.push(`Expected val id: '${id}' to have a schema`);
|
691
712
|
}
|
@@ -918,7 +939,7 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
|
|
918
939
|
}
|
919
940
|
if (modulePath === "@valbuild/react/stega") {
|
920
941
|
return {
|
921
|
-
value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export const fetchVal = () => { throw Error(`Cannot use 'fetchVal' in this type of file`) }; export const autoTagJSX = () => { /* ignore */ };"
|
942
|
+
value: "export const useVal = () => { throw Error(`Cannot use 'useVal' in this type of file`) }; export const fetchVal = () => { throw Error(`Cannot use 'fetchVal' in this type of file`) }; export const autoTagJSX = () => { /* ignore */ }; export const stegaClean = () => { throw Error(`Cannot use 'stegaClean' in this type of file`) }; "
|
922
943
|
};
|
923
944
|
}
|
924
945
|
if (modulePath.startsWith("next/navigation")) {
|
@@ -1026,7 +1047,7 @@ class Service {
|
|
1026
1047
|
}, sourceFileHandler, runtime) {
|
1027
1048
|
this.sourceFileHandler = sourceFileHandler;
|
1028
1049
|
this.runtime = runtime;
|
1029
|
-
this.valConfigPath = valConfigPath;
|
1050
|
+
this.valConfigPath = valConfigPath || "./val.config";
|
1030
1051
|
}
|
1031
1052
|
async get(moduleId, modulePath) {
|
1032
1053
|
const valModule = await readValFile(moduleId, this.valConfigPath, this.runtime);
|
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.41.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.41.0",
|
28
|
+
"@valbuild/shared": "~0.41.0",
|
29
|
+
"@valbuild/ui": "~0.41.0",
|
30
30
|
"express": "^4.18.2",
|
31
31
|
"image-size": "^1.0.2",
|
32
32
|
"queue": "^6.0.2",
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"zod": "^3.20.6"
|
38
38
|
},
|
39
39
|
"engines": {
|
40
|
-
"node": ">=18.17.
|
40
|
+
"node": ">=18.17.0"
|
41
41
|
},
|
42
42
|
"files": [
|
43
43
|
"dist"
|