@makeswift/runtime 0.0.4 → 0.0.5

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.
@@ -3,7 +3,6 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
3
3
  var index = require("./index.cjs.js");
4
4
  var Page = require("./Page.cjs.js");
5
5
  require("react");
6
- require("react-is");
7
6
  require("use-sync-external-store/shim/with-selector");
8
7
  require("@apollo/client");
9
8
  require("./react-page.cjs.js");
@@ -1 +1 @@
1
- {"version":3,"file":"components.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,6 @@
1
1
  export { B as Box, c as Button, C as Carousel, d as Countdown, j as DEFAULT_BOX_ANIMATE_DELAY, k as DEFAULT_BOX_ANIMATE_DURATION, i as DEFAULT_BOX_ANIMATE_TYPE, m as DEFAULT_ITEM_ANIMATE_DELAY, n as DEFAULT_ITEM_ANIMATE_DURATION, l as DEFAULT_ITEM_ANIMATE_TYPE, o as DEFAULT_ITEM_STAGGER_DURATION, e as Divider, f as Embed, F as Form, I as Image, N as Navigation, g as Root, S as SocialLinks, T as Text, v as cssBorder, w as cssBorderRadius, x as cssBoxShadow, y as cssGridItem, s as cssMargin, p as cssMediaRules, t as cssPadding, z as cssTextStyle, q as cssWidth, r as registerBuiltinComponents, h as registerComponent, A as useBackgrounds, G as useBorder, H as useBoxShadow, J as useColor, K as useFile, L as useMediaQuery, M as usePage, O as useTable } from "./index.es.js";
2
2
  export { P as Page } from "./Page.es.js";
3
3
  import "react";
4
- import "react-is";
5
4
  import "use-sync-external-store/shim/with-selector";
6
5
  import "@apollo/client";
7
6
  import "./react-page.es.js";
@@ -1 +1 @@
1
- {"version":3,"file":"components.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"components.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.cjs.js CHANGED
@@ -34,8 +34,8 @@ var __publicField = (obj, key, value) => {
34
34
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
35
35
  return value;
36
36
  };
37
+ var _ea;
37
38
  var React = require("react");
38
- var reactIs = require("react-is");
39
39
  var withSelector = require("use-sync-external-store/shim/with-selector");
40
40
  var client = require("@apollo/client");
41
41
  var reactPage = require("./react-page.cjs.js");
@@ -1959,7 +1959,7 @@ function responsiveStyle(responsiveValues, join$1, strategy) {
1959
1959
  }
1960
1960
  function responsiveWidth(widthData, defaultValue = "100%") {
1961
1961
  return __spreadValues({
1962
- width: "100%"
1962
+ maxWidth: "100%"
1963
1963
  }, responsiveStyle([widthData], ([width = defaultValue]) => ({
1964
1964
  width: typeof width === "object" ? `${width.value}${width.unit}` : width
1965
1965
  })));
@@ -7846,9 +7846,267 @@ const FallbackComponent = React.forwardRef(function FallbackComponent2({
7846
7846
  })]
7847
7847
  });
7848
7848
  });
7849
- function useStyleControlDataClass(style$1, controlDefinition) {
7849
+ function murmur2(str) {
7850
+ var h = 0;
7851
+ var k, i = 0, len = str.length;
7852
+ for (; len >= 4; ++i, len -= 4) {
7853
+ k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
7854
+ k = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
7855
+ k ^= k >>> 24;
7856
+ h = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
7857
+ }
7858
+ switch (len) {
7859
+ case 3:
7860
+ h ^= (str.charCodeAt(i + 2) & 255) << 16;
7861
+ case 2:
7862
+ h ^= (str.charCodeAt(i + 1) & 255) << 8;
7863
+ case 1:
7864
+ h ^= str.charCodeAt(i) & 255;
7865
+ h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
7866
+ }
7867
+ h ^= h >>> 13;
7868
+ h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
7869
+ return ((h ^ h >>> 15) >>> 0).toString(36);
7870
+ }
7871
+ var unitlessKeys = {
7872
+ animationIterationCount: 1,
7873
+ borderImageOutset: 1,
7874
+ borderImageSlice: 1,
7875
+ borderImageWidth: 1,
7876
+ boxFlex: 1,
7877
+ boxFlexGroup: 1,
7878
+ boxOrdinalGroup: 1,
7879
+ columnCount: 1,
7880
+ columns: 1,
7881
+ flex: 1,
7882
+ flexGrow: 1,
7883
+ flexPositive: 1,
7884
+ flexShrink: 1,
7885
+ flexNegative: 1,
7886
+ flexOrder: 1,
7887
+ gridRow: 1,
7888
+ gridRowEnd: 1,
7889
+ gridRowSpan: 1,
7890
+ gridRowStart: 1,
7891
+ gridColumn: 1,
7892
+ gridColumnEnd: 1,
7893
+ gridColumnSpan: 1,
7894
+ gridColumnStart: 1,
7895
+ msGridRow: 1,
7896
+ msGridRowSpan: 1,
7897
+ msGridColumn: 1,
7898
+ msGridColumnSpan: 1,
7899
+ fontWeight: 1,
7900
+ lineHeight: 1,
7901
+ opacity: 1,
7902
+ order: 1,
7903
+ orphans: 1,
7904
+ tabSize: 1,
7905
+ widows: 1,
7906
+ zIndex: 1,
7907
+ zoom: 1,
7908
+ WebkitLineClamp: 1,
7909
+ fillOpacity: 1,
7910
+ floodOpacity: 1,
7911
+ stopOpacity: 1,
7912
+ strokeDasharray: 1,
7913
+ strokeDashoffset: 1,
7914
+ strokeMiterlimit: 1,
7915
+ strokeOpacity: 1,
7916
+ strokeWidth: 1
7917
+ };
7918
+ function memoize(fn) {
7919
+ var cache = /* @__PURE__ */ Object.create(null);
7920
+ return function(arg) {
7921
+ if (cache[arg] === void 0)
7922
+ cache[arg] = fn(arg);
7923
+ return cache[arg];
7924
+ };
7925
+ }
7926
+ var hyphenateRegex = /[A-Z]|^ms/g;
7927
+ var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
7928
+ var isCustomProperty = function isCustomProperty2(property) {
7929
+ return property.charCodeAt(1) === 45;
7930
+ };
7931
+ var isProcessableValue = function isProcessableValue2(value) {
7932
+ return value != null && typeof value !== "boolean";
7933
+ };
7934
+ var processStyleName = /* @__PURE__ */ memoize(function(styleName) {
7935
+ return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase();
7936
+ });
7937
+ var processStyleValue = function processStyleValue2(key, value) {
7938
+ switch (key) {
7939
+ case "animation":
7940
+ case "animationName": {
7941
+ if (typeof value === "string") {
7942
+ return value.replace(animationRegex, function(match, p1, p2) {
7943
+ cursor = {
7944
+ name: p1,
7945
+ styles: p2,
7946
+ next: cursor
7947
+ };
7948
+ return p1;
7949
+ });
7950
+ }
7951
+ }
7952
+ }
7953
+ if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) {
7954
+ return value + "px";
7955
+ }
7956
+ return value;
7957
+ };
7958
+ function handleInterpolation(mergedProps, registered, interpolation) {
7959
+ if (interpolation == null) {
7960
+ return "";
7961
+ }
7962
+ if (interpolation.__emotion_styles !== void 0) {
7963
+ return interpolation;
7964
+ }
7965
+ switch (typeof interpolation) {
7966
+ case "boolean": {
7967
+ return "";
7968
+ }
7969
+ case "object": {
7970
+ if (interpolation.anim === 1) {
7971
+ cursor = {
7972
+ name: interpolation.name,
7973
+ styles: interpolation.styles,
7974
+ next: cursor
7975
+ };
7976
+ return interpolation.name;
7977
+ }
7978
+ if (interpolation.styles !== void 0) {
7979
+ var next = interpolation.next;
7980
+ if (next !== void 0) {
7981
+ while (next !== void 0) {
7982
+ cursor = {
7983
+ name: next.name,
7984
+ styles: next.styles,
7985
+ next: cursor
7986
+ };
7987
+ next = next.next;
7988
+ }
7989
+ }
7990
+ var styles = interpolation.styles + ";";
7991
+ return styles;
7992
+ }
7993
+ return createStringFromObject(mergedProps, registered, interpolation);
7994
+ }
7995
+ case "function": {
7996
+ if (mergedProps !== void 0) {
7997
+ var previousCursor = cursor;
7998
+ var result = interpolation(mergedProps);
7999
+ cursor = previousCursor;
8000
+ return handleInterpolation(mergedProps, registered, result);
8001
+ }
8002
+ break;
8003
+ }
8004
+ }
8005
+ if (registered == null) {
8006
+ return interpolation;
8007
+ }
8008
+ var cached = registered[interpolation];
8009
+ return cached !== void 0 ? cached : interpolation;
8010
+ }
8011
+ function createStringFromObject(mergedProps, registered, obj) {
8012
+ var string = "";
8013
+ if (Array.isArray(obj)) {
8014
+ for (var i = 0; i < obj.length; i++) {
8015
+ string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
8016
+ }
8017
+ } else {
8018
+ for (var _key in obj) {
8019
+ var value = obj[_key];
8020
+ if (typeof value !== "object") {
8021
+ if (registered != null && registered[value] !== void 0) {
8022
+ string += _key + "{" + registered[value] + "}";
8023
+ } else if (isProcessableValue(value)) {
8024
+ string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
8025
+ }
8026
+ } else {
8027
+ if (_key === "NO_COMPONENT_SELECTOR" && false) {
8028
+ throw new Error("Component selectors can only be used in conjunction with @emotion/babel-plugin.");
8029
+ }
8030
+ if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
8031
+ for (var _i = 0; _i < value.length; _i++) {
8032
+ if (isProcessableValue(value[_i])) {
8033
+ string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
8034
+ }
8035
+ }
8036
+ } else {
8037
+ var interpolated = handleInterpolation(mergedProps, registered, value);
8038
+ switch (_key) {
8039
+ case "animation":
8040
+ case "animationName": {
8041
+ string += processStyleName(_key) + ":" + interpolated + ";";
8042
+ break;
8043
+ }
8044
+ default: {
8045
+ string += _key + "{" + interpolated + "}";
8046
+ }
8047
+ }
8048
+ }
8049
+ }
8050
+ }
8051
+ }
8052
+ return string;
8053
+ }
8054
+ var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
8055
+ var cursor;
8056
+ var serializeStyles = function serializeStyles2(args, registered, mergedProps) {
8057
+ if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) {
8058
+ return args[0];
8059
+ }
8060
+ var stringMode = true;
8061
+ var styles = "";
8062
+ cursor = void 0;
8063
+ var strings = args[0];
8064
+ if (strings == null || strings.raw === void 0) {
8065
+ stringMode = false;
8066
+ styles += handleInterpolation(mergedProps, registered, strings);
8067
+ } else {
8068
+ styles += strings[0];
8069
+ }
8070
+ for (var i = 1; i < args.length; i++) {
8071
+ styles += handleInterpolation(mergedProps, registered, args[i]);
8072
+ if (stringMode) {
8073
+ styles += strings[i];
8074
+ }
8075
+ }
8076
+ labelPattern.lastIndex = 0;
8077
+ var identifierName = "";
8078
+ var match;
8079
+ while ((match = labelPattern.exec(styles)) !== null) {
8080
+ identifierName += "-" + match[1];
8081
+ }
8082
+ var name = murmur2(styles) + identifierName;
8083
+ return {
8084
+ name,
8085
+ styles,
8086
+ next: cursor
8087
+ };
8088
+ };
8089
+ var isBrowser = true;
8090
+ var registerStyles = function registerStyles2(cache, serialized, isStringTag) {
8091
+ var className = cache.key + "-" + serialized.name;
8092
+ if ((isStringTag === false || isBrowser === false) && cache.registered[className] === void 0) {
8093
+ cache.registered[className] = serialized.styles;
8094
+ }
8095
+ };
8096
+ var insertStyles = function insertStyles2(cache, serialized, isStringTag) {
8097
+ registerStyles(cache, serialized, isStringTag);
8098
+ var className = cache.key + "-" + serialized.name;
8099
+ if (cache.inserted[serialized.name] === void 0) {
8100
+ var current = serialized;
8101
+ do {
8102
+ cache.insert(serialized === current ? "." + className : "", current, cache.sheet, true);
8103
+ current = current.next;
8104
+ } while (current !== void 0);
8105
+ }
8106
+ };
8107
+ function useStyleControlCssObject(style$1, controlDefinition) {
7850
8108
  const { properties } = controlDefinition.config;
7851
- return css.css(__spreadValues(__spreadValues({}, properties.includes(style.StyleControlProperty.Width) && {
8109
+ return __spreadValues(__spreadValues({}, properties.includes(style.StyleControlProperty.Width) && {
7852
8110
  maxWidth: "100%"
7853
8111
  }), responsiveStyle([
7854
8112
  style$1 == null ? void 0 : style$1.width,
@@ -7881,7 +8139,7 @@ function useStyleControlDataClass(style$1, controlDefinition) {
7881
8139
  borderBottomRightRadius: (_p = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomRightRadius)) != null ? _p : 0,
7882
8140
  borderBottomLeftRadius: (_q = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomLeftRadius)) != null ? _q : 0
7883
8141
  });
7884
- })));
8142
+ }));
7885
8143
  function widthToString(widthProperty) {
7886
8144
  if (widthProperty == null)
7887
8145
  return null;
@@ -7911,8 +8169,14 @@ function useStyleControlDataClass(style$1, controlDefinition) {
7911
8169
  return `${borderRadius.value}${borderRadius.unit}`;
7912
8170
  }
7913
8171
  }
8172
+ const useInsertionEffect = (_ea = React__namespace.useInsertionEffect) != null ? _ea : React__namespace.useLayoutEffect;
7914
8173
  function useFormattedStyle(styleControlData, controlDefinition) {
7915
- return useStyleControlDataClass(styleControlData, controlDefinition);
8174
+ const style2 = useStyleControlCssObject(styleControlData, controlDefinition);
8175
+ const serialized = serializeStyles([style2], css.cache.registered);
8176
+ useInsertionEffect(() => {
8177
+ insertStyles(css.cache, serialized, false);
8178
+ });
8179
+ return `${css.cache.key}-${serialized.name}`;
7916
8180
  }
7917
8181
  function useDeviceMode() {
7918
8182
  return "desktop";
@@ -8128,25 +8392,40 @@ function useDispatch() {
8128
8392
  const store = React.useContext(Context);
8129
8393
  return store.dispatch;
8130
8394
  }
8395
+ function useSuppressRefWarning(ownerName) {
8396
+ const originalErrorRef = React.useRef(console.error);
8397
+ const patchedRef = React.useRef(false);
8398
+ if (patchedRef.current === false) {
8399
+ console.error = (...args) => {
8400
+ const [msg, ...substitutions] = args;
8401
+ const text = substitutions.reduce((text2, substitution) => text2.replace("%s", substitution), msg);
8402
+ if (!text.includes("Function components cannot be given refs.") || !text.includes(`Check the render method of \`${ownerName}\`.`)) {
8403
+ originalErrorRef.current(...args);
8404
+ }
8405
+ };
8406
+ patchedRef.current = true;
8407
+ }
8408
+ }
8131
8409
  const ElementData = React.memo(React.forwardRef(function ElementData2({
8132
8410
  elementData
8133
8411
  }, ref) {
8134
8412
  const Component = useComponent(elementData.type);
8135
8413
  const props = useProps(elementData);
8136
- const forwardsRef = React.useMemo(() => reactIs.isForwardRef(Component), [Component]);
8414
+ const [handle, setHandle] = React.useState(null);
8415
+ const [foundDomNode, setFoundDomNode] = React.useState(null);
8416
+ React.useImperativeHandle(ref, () => handle != null ? handle : foundDomNode, [handle, foundDomNode]);
8417
+ useSuppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
8137
8418
  if (Component == null) {
8138
8419
  return /* @__PURE__ */ jsxRuntime.jsx(FallbackComponent, {
8139
8420
  ref,
8140
8421
  text: "Component not found"
8141
8422
  });
8142
8423
  }
8143
- return forwardsRef ? /* @__PURE__ */ React.createElement(Component, __spreadProps(__spreadValues({}, props), {
8144
- key: elementData.key,
8145
- ref
8146
- })) : /* @__PURE__ */ jsxRuntime.jsx(FindDomNode, {
8147
- ref,
8424
+ return /* @__PURE__ */ jsxRuntime.jsx(FindDomNode, {
8425
+ ref: setFoundDomNode,
8148
8426
  children: /* @__PURE__ */ React.createElement(Component, __spreadProps(__spreadValues({}, props), {
8149
- key: elementData.key
8427
+ key: elementData.key,
8428
+ ref: setHandle
8150
8429
  }))
8151
8430
  });
8152
8431
  }));