@valbuild/server 0.44.0 → 0.46.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.
@@ -77,13 +77,11 @@ type ValServerOverrides = Partial<{
77
77
  */
78
78
  valContentUrl: string;
79
79
  /**
80
- * The full name of this Val project.
81
- *
82
- * Typically this is set using the VAL_NAME env var.
80
+ * The cloud name of this Val project.
83
81
  *
84
82
  * @example "myorg/my-project"
85
83
  */
86
- valName: string;
84
+ valCloud: string;
87
85
  /**
88
86
  * After Val is enabled, redirect to this url.
89
87
  *
@@ -976,7 +976,7 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
976
976
  }
977
977
  if (modulePath === "@valbuild/react/stega") {
978
978
  return {
979
- 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`) }; "
979
+ 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`) }; export const stegaDecodeString = () => { throw Error(`Cannot use 'stegaDecodeString' in this type of file`) }; "
980
980
  };
981
981
  }
982
982
  if (modulePath.startsWith("next/navigation")) {
@@ -1004,6 +1004,11 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
1004
1004
  value: "export const ValNextProvider = new Proxy({}, { get() { return () => { throw new Error(`Cannot import 'ValNextProvider' in this file`) } } } )"
1005
1005
  };
1006
1006
  }
1007
+ if (modulePath.includes("/ValImage")) {
1008
+ return {
1009
+ value: "export const ValImage = new Proxy({}, { get() { return () => { throw new Error(`Cannot import 'ValImage' in this file`) } } } )"
1010
+ };
1011
+ }
1007
1012
  return {
1008
1013
  value: moduleLoader.getModule(modulePath)
1009
1014
  };
@@ -1054,6 +1059,11 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
1054
1059
  value: requestedName
1055
1060
  };
1056
1061
  }
1062
+ if (requestedName.includes("/ValImage")) {
1063
+ return {
1064
+ value: requestedName
1065
+ };
1066
+ }
1057
1067
  const modulePath = moduleLoader.resolveModulePath(baseModuleName, requestedName);
1058
1068
  return {
1059
1069
  value: modulePath
@@ -1262,7 +1272,7 @@ class LocalValServer {
1262
1272
  return {
1263
1273
  cookies: {
1264
1274
  [internal.VAL_ENABLE_COOKIE_NAME]: {
1265
- value: null
1275
+ value: "false"
1266
1276
  }
1267
1277
  },
1268
1278
  status: 302,
@@ -2007,9 +2017,9 @@ async function initHandlerOptions(route, opts) {
2007
2017
  if (!maybeGitBranch) {
2008
2018
  throw new Error("VAL_GIT_BRANCH env var must be set in proxy mode");
2009
2019
  }
2010
- const maybeValName = opts.valName || process.env.VAL_NAME;
2020
+ const maybeValName = opts.valCloud || process.env.VAL_CLOUD_NAME || process.env.VAL_NAME; // VAL_NAME is deprecated
2011
2021
  if (!maybeValName) {
2012
- throw new Error("VAL_NAME env var must be set in proxy mode");
2022
+ throw new Error("VAL_CLOUD_NAME env var must be set in proxy mode");
2013
2023
  }
2014
2024
  return {
2015
2025
  mode: "proxy",
@@ -2266,12 +2276,25 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
2266
2276
  const filename = path__namespace["default"].join(config.projectRoot, maybeRef);
2267
2277
  const buffer = fs__default["default"].readFileSync(filename);
2268
2278
  const imageSize = sizeOf__default["default"](buffer);
2279
+ const mimeType = imageSize.type ? internal.imageTypeToMimeType(imageSize.type) : internal.filenameToMimeType(filename);
2280
+ if (!mimeType) {
2281
+ throw Error("Cannot determine mimetype of image");
2282
+ }
2283
+ const {
2284
+ width,
2285
+ height
2286
+ } = imageSize;
2287
+ if (!width || !height) {
2288
+ throw Error("Cannot determine image size");
2289
+ }
2269
2290
  const sha256 = core.Internal.getSHA256Hash(textEncoder.encode(
2270
2291
  // TODO: we should probably store the mimetype in the metadata and reuse it here
2271
- `data:${imageSize.type ? internal.imageTypeToMimeType(imageSize.type) : internal.filenameToMimeType(filename)};base64,${buffer.toString("base64")}`));
2292
+ `data:${mimeType};base64,${buffer.toString("base64")}`));
2272
2293
  return {
2273
- ...imageSize,
2274
- sha256
2294
+ width,
2295
+ height,
2296
+ sha256,
2297
+ mimeType
2275
2298
  };
2276
2299
  }
2277
2300
  const remainingErrors = [];
@@ -2306,7 +2329,8 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
2306
2329
  value: {
2307
2330
  width: imageMetadata.width,
2308
2331
  height: imageMetadata.height,
2309
- sha256: imageMetadata.sha256
2332
+ sha256: imageMetadata.sha256,
2333
+ mimeType: imageMetadata.mimeType
2310
2334
  }
2311
2335
  });
2312
2336
  } else {
@@ -976,7 +976,7 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
976
976
  }
977
977
  if (modulePath === "@valbuild/react/stega") {
978
978
  return {
979
- 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`) }; "
979
+ 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`) }; export const stegaDecodeString = () => { throw Error(`Cannot use 'stegaDecodeString' in this type of file`) }; "
980
980
  };
981
981
  }
982
982
  if (modulePath.startsWith("next/navigation")) {
@@ -1004,6 +1004,11 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
1004
1004
  value: "export const ValNextProvider = new Proxy({}, { get() { return () => { throw new Error(`Cannot import 'ValNextProvider' in this file`) } } } )"
1005
1005
  };
1006
1006
  }
1007
+ if (modulePath.includes("/ValImage")) {
1008
+ return {
1009
+ value: "export const ValImage = new Proxy({}, { get() { return () => { throw new Error(`Cannot import 'ValImage' in this file`) } } } )"
1010
+ };
1011
+ }
1007
1012
  return {
1008
1013
  value: moduleLoader.getModule(modulePath)
1009
1014
  };
@@ -1054,6 +1059,11 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
1054
1059
  value: requestedName
1055
1060
  };
1056
1061
  }
1062
+ if (requestedName.includes("/ValImage")) {
1063
+ return {
1064
+ value: requestedName
1065
+ };
1066
+ }
1057
1067
  const modulePath = moduleLoader.resolveModulePath(baseModuleName, requestedName);
1058
1068
  return {
1059
1069
  value: modulePath
@@ -1262,7 +1272,7 @@ class LocalValServer {
1262
1272
  return {
1263
1273
  cookies: {
1264
1274
  [internal.VAL_ENABLE_COOKIE_NAME]: {
1265
- value: null
1275
+ value: "false"
1266
1276
  }
1267
1277
  },
1268
1278
  status: 302,
@@ -2007,9 +2017,9 @@ async function initHandlerOptions(route, opts) {
2007
2017
  if (!maybeGitBranch) {
2008
2018
  throw new Error("VAL_GIT_BRANCH env var must be set in proxy mode");
2009
2019
  }
2010
- const maybeValName = opts.valName || process.env.VAL_NAME;
2020
+ const maybeValName = opts.valCloud || process.env.VAL_CLOUD_NAME || process.env.VAL_NAME; // VAL_NAME is deprecated
2011
2021
  if (!maybeValName) {
2012
- throw new Error("VAL_NAME env var must be set in proxy mode");
2022
+ throw new Error("VAL_CLOUD_NAME env var must be set in proxy mode");
2013
2023
  }
2014
2024
  return {
2015
2025
  mode: "proxy",
@@ -2266,12 +2276,25 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
2266
2276
  const filename = path__namespace["default"].join(config.projectRoot, maybeRef);
2267
2277
  const buffer = fs__default["default"].readFileSync(filename);
2268
2278
  const imageSize = sizeOf__default["default"](buffer);
2279
+ const mimeType = imageSize.type ? internal.imageTypeToMimeType(imageSize.type) : internal.filenameToMimeType(filename);
2280
+ if (!mimeType) {
2281
+ throw Error("Cannot determine mimetype of image");
2282
+ }
2283
+ const {
2284
+ width,
2285
+ height
2286
+ } = imageSize;
2287
+ if (!width || !height) {
2288
+ throw Error("Cannot determine image size");
2289
+ }
2269
2290
  const sha256 = core.Internal.getSHA256Hash(textEncoder.encode(
2270
2291
  // TODO: we should probably store the mimetype in the metadata and reuse it here
2271
- `data:${imageSize.type ? internal.imageTypeToMimeType(imageSize.type) : internal.filenameToMimeType(filename)};base64,${buffer.toString("base64")}`));
2292
+ `data:${mimeType};base64,${buffer.toString("base64")}`));
2272
2293
  return {
2273
- ...imageSize,
2274
- sha256
2294
+ width,
2295
+ height,
2296
+ sha256,
2297
+ mimeType
2275
2298
  };
2276
2299
  }
2277
2300
  const remainingErrors = [];
@@ -2306,7 +2329,8 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
2306
2329
  value: {
2307
2330
  width: imageMetadata.width,
2308
2331
  height: imageMetadata.height,
2309
- sha256: imageMetadata.sha256
2332
+ sha256: imageMetadata.sha256,
2333
+ mimeType: imageMetadata.mimeType
2310
2334
  }
2311
2335
  });
2312
2336
  } else {
@@ -946,7 +946,7 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
946
946
  }
947
947
  if (modulePath === "@valbuild/react/stega") {
948
948
  return {
949
- 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`) }; "
949
+ 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`) }; export const stegaDecodeString = () => { throw Error(`Cannot use 'stegaDecodeString' in this type of file`) }; "
950
950
  };
951
951
  }
952
952
  if (modulePath.startsWith("next/navigation")) {
@@ -974,6 +974,11 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
974
974
  value: "export const ValNextProvider = new Proxy({}, { get() { return () => { throw new Error(`Cannot import 'ValNextProvider' in this file`) } } } )"
975
975
  };
976
976
  }
977
+ if (modulePath.includes("/ValImage")) {
978
+ return {
979
+ value: "export const ValImage = new Proxy({}, { get() { return () => { throw new Error(`Cannot import 'ValImage' in this file`) } } } )"
980
+ };
981
+ }
977
982
  return {
978
983
  value: moduleLoader.getModule(modulePath)
979
984
  };
@@ -1024,6 +1029,11 @@ async function newValQuickJSRuntime(quickJSModule, moduleLoader, {
1024
1029
  value: requestedName
1025
1030
  };
1026
1031
  }
1032
+ if (requestedName.includes("/ValImage")) {
1033
+ return {
1034
+ value: requestedName
1035
+ };
1036
+ }
1027
1037
  const modulePath = moduleLoader.resolveModulePath(baseModuleName, requestedName);
1028
1038
  return {
1029
1039
  value: modulePath
@@ -1232,7 +1242,7 @@ class LocalValServer {
1232
1242
  return {
1233
1243
  cookies: {
1234
1244
  [VAL_ENABLE_COOKIE_NAME]: {
1235
- value: null
1245
+ value: "false"
1236
1246
  }
1237
1247
  },
1238
1248
  status: 302,
@@ -1977,9 +1987,9 @@ async function initHandlerOptions(route, opts) {
1977
1987
  if (!maybeGitBranch) {
1978
1988
  throw new Error("VAL_GIT_BRANCH env var must be set in proxy mode");
1979
1989
  }
1980
- const maybeValName = opts.valName || process.env.VAL_NAME;
1990
+ const maybeValName = opts.valCloud || process.env.VAL_CLOUD_NAME || process.env.VAL_NAME; // VAL_NAME is deprecated
1981
1991
  if (!maybeValName) {
1982
- throw new Error("VAL_NAME env var must be set in proxy mode");
1992
+ throw new Error("VAL_CLOUD_NAME env var must be set in proxy mode");
1983
1993
  }
1984
1994
  return {
1985
1995
  mode: "proxy",
@@ -2236,12 +2246,25 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
2236
2246
  const filename = path__default.join(config.projectRoot, maybeRef);
2237
2247
  const buffer = fs.readFileSync(filename);
2238
2248
  const imageSize = sizeOf(buffer);
2249
+ const mimeType = imageSize.type ? imageTypeToMimeType(imageSize.type) : filenameToMimeType(filename);
2250
+ if (!mimeType) {
2251
+ throw Error("Cannot determine mimetype of image");
2252
+ }
2253
+ const {
2254
+ width,
2255
+ height
2256
+ } = imageSize;
2257
+ if (!width || !height) {
2258
+ throw Error("Cannot determine image size");
2259
+ }
2239
2260
  const sha256 = Internal.getSHA256Hash(textEncoder.encode(
2240
2261
  // TODO: we should probably store the mimetype in the metadata and reuse it here
2241
- `data:${imageSize.type ? imageTypeToMimeType(imageSize.type) : filenameToMimeType(filename)};base64,${buffer.toString("base64")}`));
2262
+ `data:${mimeType};base64,${buffer.toString("base64")}`));
2242
2263
  return {
2243
- ...imageSize,
2244
- sha256
2264
+ width,
2265
+ height,
2266
+ sha256,
2267
+ mimeType
2245
2268
  };
2246
2269
  }
2247
2270
  const remainingErrors = [];
@@ -2276,7 +2299,8 @@ async function createFixPatch(config, apply, sourcePath, validationError) {
2276
2299
  value: {
2277
2300
  width: imageMetadata.width,
2278
2301
  height: imageMetadata.height,
2279
- sha256: imageMetadata.sha256
2302
+ sha256: imageMetadata.sha256,
2303
+ mimeType: imageMetadata.mimeType
2280
2304
  }
2281
2305
  });
2282
2306
  } else {
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.44.0",
15
+ "version": "0.46.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.44.0",
28
- "@valbuild/shared": "~0.44.0",
29
- "@valbuild/ui": "~0.44.0",
27
+ "@valbuild/core": "~0.46.0",
28
+ "@valbuild/shared": "~0.46.0",
29
+ "@valbuild/ui": "~0.46.0",
30
30
  "express": "^4.18.2",
31
31
  "image-size": "^1.0.2",
32
32
  "queue": "^6.0.2",