@makeswift/runtime 0.10.14 → 0.10.15

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/dist/index.cjs.js CHANGED
@@ -43,7 +43,7 @@ var actions = require("./actions.cjs.js");
43
43
  var jsxRuntime = require("react/jsx-runtime");
44
44
  var number = require("./number.cjs.js");
45
45
  var combobox = require("./combobox.cjs.js");
46
- require("ts-pattern");
46
+ var tsPattern = require("ts-pattern");
47
47
  var uuid = require("uuid");
48
48
  require("slate");
49
49
  var shim = require("use-sync-external-store/shim");
@@ -1192,7 +1192,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1192
1192
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1193
1193
  return res.json(fonts2);
1194
1194
  }
1195
- const version = "0.10.14";
1195
+ const version = "0.10.15";
1196
1196
  async function handler(req, res, { apiKey, siteVersions }) {
1197
1197
  if (req.query.secret !== apiKey) {
1198
1198
  return res.status(401).json({ message: "Unauthorized" });
@@ -3068,17 +3068,23 @@ function useIconRadioGroupValue(iconRadioGroupControlData, controlDefinition) {
3068
3068
  function useImageControlValue(data, definition) {
3069
3069
  var _a;
3070
3070
  const format = (_a = definition.config.format) != null ? _a : reactPage.ImageControlValueFormat.URL;
3071
- const fileId = data != null ? data : null;
3071
+ const fileId = tsPattern.match(data).with(tsPattern.P.string, (id) => id).with({ type: "makeswift-file" }, ({ id }) => id).otherwise(() => null);
3072
3072
  const file = useFile(fileId);
3073
- if (format === reactPage.ImageControlValueFormat.URL) {
3074
- return file == null ? void 0 : file.publicUrl;
3075
- }
3076
- if (file == null || file.dimensions == null)
3077
- return void 0;
3078
- return {
3079
- url: file.publicUrl,
3080
- dimensions: { width: file.dimensions.width, height: file.dimensions.height }
3081
- };
3073
+ return tsPattern.match([file, data, format]).with([{ __typename: "File" }, tsPattern.P.any, reactPage.ImageControlValueFormat.URL], ([file2]) => file2.publicUrl).with([
3074
+ { __typename: "File", dimensions: tsPattern.P.not(tsPattern.P.nullish) },
3075
+ tsPattern.P.any,
3076
+ reactPage.ImageControlValueFormat.WithDimensions
3077
+ ], ([file2]) => ({
3078
+ url: file2.publicUrl,
3079
+ dimensions: file2.dimensions
3080
+ })).with([tsPattern.P.any, { type: "external-file" }, reactPage.ImageControlValueFormat.URL], ([, d]) => d.url).with([
3081
+ tsPattern.P.any,
3082
+ { type: "external-file", width: tsPattern.P.number, height: tsPattern.P.number },
3083
+ reactPage.ImageControlValueFormat.WithDimensions
3084
+ ], ([, d]) => ({
3085
+ url: d.url,
3086
+ dimensions: { width: d.width, height: d.height }
3087
+ })).otherwise(() => void 0);
3082
3088
  }
3083
3089
  function useLinkControlValue(link, _definition) {
3084
3090
  var _a;