@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.es.js CHANGED
@@ -43,7 +43,7 @@ import { A as ActionTypes, o as apiResourceFulfilled, p as registerComponentEffe
43
43
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
44
44
  import { N as NumberControlType, C as CheckboxControlType } from "./number.es.js";
45
45
  import { C as ComboboxControlType } from "./combobox.es.js";
46
- import "ts-pattern";
46
+ import { match as match$1, P } from "ts-pattern";
47
47
  import { v4 } from "uuid";
48
48
  import "slate";
49
49
  import { useSyncExternalStore } from "use-sync-external-store/shim";
@@ -1159,7 +1159,7 @@ async function fonts(_req, res, { getFonts } = {}) {
1159
1159
  const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
1160
1160
  return res.json(fonts2);
1161
1161
  }
1162
- const version = "0.10.14";
1162
+ const version = "0.10.15";
1163
1163
  async function handler(req, res, { apiKey, siteVersions }) {
1164
1164
  if (req.query.secret !== apiKey) {
1165
1165
  return res.status(401).json({ message: "Unauthorized" });
@@ -3009,17 +3009,23 @@ function useIconRadioGroupValue(iconRadioGroupControlData, controlDefinition) {
3009
3009
  function useImageControlValue(data, definition) {
3010
3010
  var _a;
3011
3011
  const format = (_a = definition.config.format) != null ? _a : ImageControlValueFormat.URL;
3012
- const fileId = data != null ? data : null;
3012
+ const fileId = match$1(data).with(P.string, (id) => id).with({ type: "makeswift-file" }, ({ id }) => id).otherwise(() => null);
3013
3013
  const file = useFile(fileId);
3014
- if (format === ImageControlValueFormat.URL) {
3015
- return file == null ? void 0 : file.publicUrl;
3016
- }
3017
- if (file == null || file.dimensions == null)
3018
- return void 0;
3019
- return {
3020
- url: file.publicUrl,
3021
- dimensions: { width: file.dimensions.width, height: file.dimensions.height }
3022
- };
3014
+ return match$1([file, data, format]).with([{ __typename: "File" }, P.any, ImageControlValueFormat.URL], ([file2]) => file2.publicUrl).with([
3015
+ { __typename: "File", dimensions: P.not(P.nullish) },
3016
+ P.any,
3017
+ ImageControlValueFormat.WithDimensions
3018
+ ], ([file2]) => ({
3019
+ url: file2.publicUrl,
3020
+ dimensions: file2.dimensions
3021
+ })).with([P.any, { type: "external-file" }, ImageControlValueFormat.URL], ([, d]) => d.url).with([
3022
+ P.any,
3023
+ { type: "external-file", width: P.number, height: P.number },
3024
+ ImageControlValueFormat.WithDimensions
3025
+ ], ([, d]) => ({
3026
+ url: d.url,
3027
+ dimensions: { width: d.width, height: d.height }
3028
+ })).otherwise(() => void 0);
3023
3029
  }
3024
3030
  function useLinkControlValue(link, _definition) {
3025
3031
  var _a;