@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.
- package/dist/components.cjs.js +0 -1
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +0 -1
- package/dist/components.es.js.map +1 -1
- package/dist/index.cjs.js +292 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +296 -17
- package/dist/index.es.js.map +1 -1
- package/dist/next.cjs.js +0 -1
- package/dist/next.cjs.js.map +1 -1
- package/dist/next.es.js +0 -1
- package/dist/next.es.js.map +1 -1
- package/dist/react.cjs.js +0 -1
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.es.js +0 -1
- package/dist/react.es.js.map +1 -1
- package/dist/types/runtimes/react/controls/style.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/package.json +1 -3
package/dist/index.es.js
CHANGED
|
@@ -33,16 +33,16 @@ var __publicField = (obj, key, value) => {
|
|
|
33
33
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
34
|
return value;
|
|
35
35
|
};
|
|
36
|
+
var _ea;
|
|
36
37
|
import * as React from "react";
|
|
37
38
|
import { forwardRef, createContext, useContext, useMemo, useState, useLayoutEffect, useCallback, useEffect, useRef, useImperativeHandle, Children, createElement, Fragment as Fragment$1, Component, memo } from "react";
|
|
38
|
-
import { isForwardRef } from "react-is";
|
|
39
39
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
40
40
|
import { gql, useQuery as useQuery$1, useMutation as useMutation$1, ApolloClient, InMemoryCache } from "@apollo/client";
|
|
41
41
|
import { a as createDocumentReference, g as getComponentPropControllerDescriptors, b as getIsInBuilder, d as configureStore, e as getElementId, f as getReactComponent, h as getDocument, i as isElementReference, c as createDocument } from "./react-page.es.js";
|
|
42
42
|
import { f as registerComponentHandleEffect, g as mountComponentEffect, h as registerComponentEffect, j as registerReactComponentEffect, k as registerDocumentEffect } from "./actions.es.js";
|
|
43
43
|
import styled, { css, keyframes, createGlobalStyle } from "styled-components";
|
|
44
44
|
import { useReducedMotion, useAnimation, motion } from "framer-motion";
|
|
45
|
-
import { cx, css as css$1 } from "@emotion/css";
|
|
45
|
+
import { cx, css as css$1, cache } from "@emotion/css";
|
|
46
46
|
import { getDataFromTree } from "@apollo/client/react/ssr";
|
|
47
47
|
import { KeyUtils, Value } from "slate";
|
|
48
48
|
import uuid from "uuid/v4";
|
|
@@ -293,14 +293,14 @@ function createApolloClient({
|
|
|
293
293
|
uri,
|
|
294
294
|
cacheData
|
|
295
295
|
}) {
|
|
296
|
-
const
|
|
296
|
+
const cache2 = new InMemoryCache({
|
|
297
297
|
typePolicies
|
|
298
298
|
});
|
|
299
299
|
if (cacheData)
|
|
300
|
-
|
|
300
|
+
cache2.restore(cacheData);
|
|
301
301
|
return new ApolloClient({
|
|
302
302
|
uri,
|
|
303
|
-
cache
|
|
303
|
+
cache: cache2
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
306
|
class MakeswiftClient {
|
|
@@ -1925,7 +1925,7 @@ function responsiveStyle(responsiveValues, join$1, strategy) {
|
|
|
1925
1925
|
}
|
|
1926
1926
|
function responsiveWidth(widthData, defaultValue = "100%") {
|
|
1927
1927
|
return __spreadValues({
|
|
1928
|
-
|
|
1928
|
+
maxWidth: "100%"
|
|
1929
1929
|
}, responsiveStyle([widthData], ([width = defaultValue]) => ({
|
|
1930
1930
|
width: typeof width === "object" ? `${width.value}${width.unit}` : width
|
|
1931
1931
|
})));
|
|
@@ -7812,9 +7812,267 @@ const FallbackComponent = forwardRef(function FallbackComponent2({
|
|
|
7812
7812
|
})]
|
|
7813
7813
|
});
|
|
7814
7814
|
});
|
|
7815
|
-
function
|
|
7815
|
+
function murmur2(str) {
|
|
7816
|
+
var h = 0;
|
|
7817
|
+
var k, i = 0, len = str.length;
|
|
7818
|
+
for (; len >= 4; ++i, len -= 4) {
|
|
7819
|
+
k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
|
|
7820
|
+
k = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
|
|
7821
|
+
k ^= k >>> 24;
|
|
7822
|
+
h = (k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
|
7823
|
+
}
|
|
7824
|
+
switch (len) {
|
|
7825
|
+
case 3:
|
|
7826
|
+
h ^= (str.charCodeAt(i + 2) & 255) << 16;
|
|
7827
|
+
case 2:
|
|
7828
|
+
h ^= (str.charCodeAt(i + 1) & 255) << 8;
|
|
7829
|
+
case 1:
|
|
7830
|
+
h ^= str.charCodeAt(i) & 255;
|
|
7831
|
+
h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
|
7832
|
+
}
|
|
7833
|
+
h ^= h >>> 13;
|
|
7834
|
+
h = (h & 65535) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
|
7835
|
+
return ((h ^ h >>> 15) >>> 0).toString(36);
|
|
7836
|
+
}
|
|
7837
|
+
var unitlessKeys = {
|
|
7838
|
+
animationIterationCount: 1,
|
|
7839
|
+
borderImageOutset: 1,
|
|
7840
|
+
borderImageSlice: 1,
|
|
7841
|
+
borderImageWidth: 1,
|
|
7842
|
+
boxFlex: 1,
|
|
7843
|
+
boxFlexGroup: 1,
|
|
7844
|
+
boxOrdinalGroup: 1,
|
|
7845
|
+
columnCount: 1,
|
|
7846
|
+
columns: 1,
|
|
7847
|
+
flex: 1,
|
|
7848
|
+
flexGrow: 1,
|
|
7849
|
+
flexPositive: 1,
|
|
7850
|
+
flexShrink: 1,
|
|
7851
|
+
flexNegative: 1,
|
|
7852
|
+
flexOrder: 1,
|
|
7853
|
+
gridRow: 1,
|
|
7854
|
+
gridRowEnd: 1,
|
|
7855
|
+
gridRowSpan: 1,
|
|
7856
|
+
gridRowStart: 1,
|
|
7857
|
+
gridColumn: 1,
|
|
7858
|
+
gridColumnEnd: 1,
|
|
7859
|
+
gridColumnSpan: 1,
|
|
7860
|
+
gridColumnStart: 1,
|
|
7861
|
+
msGridRow: 1,
|
|
7862
|
+
msGridRowSpan: 1,
|
|
7863
|
+
msGridColumn: 1,
|
|
7864
|
+
msGridColumnSpan: 1,
|
|
7865
|
+
fontWeight: 1,
|
|
7866
|
+
lineHeight: 1,
|
|
7867
|
+
opacity: 1,
|
|
7868
|
+
order: 1,
|
|
7869
|
+
orphans: 1,
|
|
7870
|
+
tabSize: 1,
|
|
7871
|
+
widows: 1,
|
|
7872
|
+
zIndex: 1,
|
|
7873
|
+
zoom: 1,
|
|
7874
|
+
WebkitLineClamp: 1,
|
|
7875
|
+
fillOpacity: 1,
|
|
7876
|
+
floodOpacity: 1,
|
|
7877
|
+
stopOpacity: 1,
|
|
7878
|
+
strokeDasharray: 1,
|
|
7879
|
+
strokeDashoffset: 1,
|
|
7880
|
+
strokeMiterlimit: 1,
|
|
7881
|
+
strokeOpacity: 1,
|
|
7882
|
+
strokeWidth: 1
|
|
7883
|
+
};
|
|
7884
|
+
function memoize(fn) {
|
|
7885
|
+
var cache2 = /* @__PURE__ */ Object.create(null);
|
|
7886
|
+
return function(arg) {
|
|
7887
|
+
if (cache2[arg] === void 0)
|
|
7888
|
+
cache2[arg] = fn(arg);
|
|
7889
|
+
return cache2[arg];
|
|
7890
|
+
};
|
|
7891
|
+
}
|
|
7892
|
+
var hyphenateRegex = /[A-Z]|^ms/g;
|
|
7893
|
+
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
|
|
7894
|
+
var isCustomProperty = function isCustomProperty2(property) {
|
|
7895
|
+
return property.charCodeAt(1) === 45;
|
|
7896
|
+
};
|
|
7897
|
+
var isProcessableValue = function isProcessableValue2(value) {
|
|
7898
|
+
return value != null && typeof value !== "boolean";
|
|
7899
|
+
};
|
|
7900
|
+
var processStyleName = /* @__PURE__ */ memoize(function(styleName) {
|
|
7901
|
+
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase();
|
|
7902
|
+
});
|
|
7903
|
+
var processStyleValue = function processStyleValue2(key, value) {
|
|
7904
|
+
switch (key) {
|
|
7905
|
+
case "animation":
|
|
7906
|
+
case "animationName": {
|
|
7907
|
+
if (typeof value === "string") {
|
|
7908
|
+
return value.replace(animationRegex, function(match, p1, p2) {
|
|
7909
|
+
cursor = {
|
|
7910
|
+
name: p1,
|
|
7911
|
+
styles: p2,
|
|
7912
|
+
next: cursor
|
|
7913
|
+
};
|
|
7914
|
+
return p1;
|
|
7915
|
+
});
|
|
7916
|
+
}
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) {
|
|
7920
|
+
return value + "px";
|
|
7921
|
+
}
|
|
7922
|
+
return value;
|
|
7923
|
+
};
|
|
7924
|
+
function handleInterpolation(mergedProps, registered, interpolation) {
|
|
7925
|
+
if (interpolation == null) {
|
|
7926
|
+
return "";
|
|
7927
|
+
}
|
|
7928
|
+
if (interpolation.__emotion_styles !== void 0) {
|
|
7929
|
+
return interpolation;
|
|
7930
|
+
}
|
|
7931
|
+
switch (typeof interpolation) {
|
|
7932
|
+
case "boolean": {
|
|
7933
|
+
return "";
|
|
7934
|
+
}
|
|
7935
|
+
case "object": {
|
|
7936
|
+
if (interpolation.anim === 1) {
|
|
7937
|
+
cursor = {
|
|
7938
|
+
name: interpolation.name,
|
|
7939
|
+
styles: interpolation.styles,
|
|
7940
|
+
next: cursor
|
|
7941
|
+
};
|
|
7942
|
+
return interpolation.name;
|
|
7943
|
+
}
|
|
7944
|
+
if (interpolation.styles !== void 0) {
|
|
7945
|
+
var next = interpolation.next;
|
|
7946
|
+
if (next !== void 0) {
|
|
7947
|
+
while (next !== void 0) {
|
|
7948
|
+
cursor = {
|
|
7949
|
+
name: next.name,
|
|
7950
|
+
styles: next.styles,
|
|
7951
|
+
next: cursor
|
|
7952
|
+
};
|
|
7953
|
+
next = next.next;
|
|
7954
|
+
}
|
|
7955
|
+
}
|
|
7956
|
+
var styles = interpolation.styles + ";";
|
|
7957
|
+
return styles;
|
|
7958
|
+
}
|
|
7959
|
+
return createStringFromObject(mergedProps, registered, interpolation);
|
|
7960
|
+
}
|
|
7961
|
+
case "function": {
|
|
7962
|
+
if (mergedProps !== void 0) {
|
|
7963
|
+
var previousCursor = cursor;
|
|
7964
|
+
var result = interpolation(mergedProps);
|
|
7965
|
+
cursor = previousCursor;
|
|
7966
|
+
return handleInterpolation(mergedProps, registered, result);
|
|
7967
|
+
}
|
|
7968
|
+
break;
|
|
7969
|
+
}
|
|
7970
|
+
}
|
|
7971
|
+
if (registered == null) {
|
|
7972
|
+
return interpolation;
|
|
7973
|
+
}
|
|
7974
|
+
var cached = registered[interpolation];
|
|
7975
|
+
return cached !== void 0 ? cached : interpolation;
|
|
7976
|
+
}
|
|
7977
|
+
function createStringFromObject(mergedProps, registered, obj) {
|
|
7978
|
+
var string = "";
|
|
7979
|
+
if (Array.isArray(obj)) {
|
|
7980
|
+
for (var i = 0; i < obj.length; i++) {
|
|
7981
|
+
string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
|
|
7982
|
+
}
|
|
7983
|
+
} else {
|
|
7984
|
+
for (var _key in obj) {
|
|
7985
|
+
var value = obj[_key];
|
|
7986
|
+
if (typeof value !== "object") {
|
|
7987
|
+
if (registered != null && registered[value] !== void 0) {
|
|
7988
|
+
string += _key + "{" + registered[value] + "}";
|
|
7989
|
+
} else if (isProcessableValue(value)) {
|
|
7990
|
+
string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
|
|
7991
|
+
}
|
|
7992
|
+
} else {
|
|
7993
|
+
if (_key === "NO_COMPONENT_SELECTOR" && false) {
|
|
7994
|
+
throw new Error("Component selectors can only be used in conjunction with @emotion/babel-plugin.");
|
|
7995
|
+
}
|
|
7996
|
+
if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) {
|
|
7997
|
+
for (var _i = 0; _i < value.length; _i++) {
|
|
7998
|
+
if (isProcessableValue(value[_i])) {
|
|
7999
|
+
string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
|
|
8000
|
+
}
|
|
8001
|
+
}
|
|
8002
|
+
} else {
|
|
8003
|
+
var interpolated = handleInterpolation(mergedProps, registered, value);
|
|
8004
|
+
switch (_key) {
|
|
8005
|
+
case "animation":
|
|
8006
|
+
case "animationName": {
|
|
8007
|
+
string += processStyleName(_key) + ":" + interpolated + ";";
|
|
8008
|
+
break;
|
|
8009
|
+
}
|
|
8010
|
+
default: {
|
|
8011
|
+
string += _key + "{" + interpolated + "}";
|
|
8012
|
+
}
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
8015
|
+
}
|
|
8016
|
+
}
|
|
8017
|
+
}
|
|
8018
|
+
return string;
|
|
8019
|
+
}
|
|
8020
|
+
var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
|
|
8021
|
+
var cursor;
|
|
8022
|
+
var serializeStyles = function serializeStyles2(args, registered, mergedProps) {
|
|
8023
|
+
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) {
|
|
8024
|
+
return args[0];
|
|
8025
|
+
}
|
|
8026
|
+
var stringMode = true;
|
|
8027
|
+
var styles = "";
|
|
8028
|
+
cursor = void 0;
|
|
8029
|
+
var strings = args[0];
|
|
8030
|
+
if (strings == null || strings.raw === void 0) {
|
|
8031
|
+
stringMode = false;
|
|
8032
|
+
styles += handleInterpolation(mergedProps, registered, strings);
|
|
8033
|
+
} else {
|
|
8034
|
+
styles += strings[0];
|
|
8035
|
+
}
|
|
8036
|
+
for (var i = 1; i < args.length; i++) {
|
|
8037
|
+
styles += handleInterpolation(mergedProps, registered, args[i]);
|
|
8038
|
+
if (stringMode) {
|
|
8039
|
+
styles += strings[i];
|
|
8040
|
+
}
|
|
8041
|
+
}
|
|
8042
|
+
labelPattern.lastIndex = 0;
|
|
8043
|
+
var identifierName = "";
|
|
8044
|
+
var match;
|
|
8045
|
+
while ((match = labelPattern.exec(styles)) !== null) {
|
|
8046
|
+
identifierName += "-" + match[1];
|
|
8047
|
+
}
|
|
8048
|
+
var name = murmur2(styles) + identifierName;
|
|
8049
|
+
return {
|
|
8050
|
+
name,
|
|
8051
|
+
styles,
|
|
8052
|
+
next: cursor
|
|
8053
|
+
};
|
|
8054
|
+
};
|
|
8055
|
+
var isBrowser = true;
|
|
8056
|
+
var registerStyles = function registerStyles2(cache2, serialized, isStringTag) {
|
|
8057
|
+
var className = cache2.key + "-" + serialized.name;
|
|
8058
|
+
if ((isStringTag === false || isBrowser === false) && cache2.registered[className] === void 0) {
|
|
8059
|
+
cache2.registered[className] = serialized.styles;
|
|
8060
|
+
}
|
|
8061
|
+
};
|
|
8062
|
+
var insertStyles = function insertStyles2(cache2, serialized, isStringTag) {
|
|
8063
|
+
registerStyles(cache2, serialized, isStringTag);
|
|
8064
|
+
var className = cache2.key + "-" + serialized.name;
|
|
8065
|
+
if (cache2.inserted[serialized.name] === void 0) {
|
|
8066
|
+
var current = serialized;
|
|
8067
|
+
do {
|
|
8068
|
+
cache2.insert(serialized === current ? "." + className : "", current, cache2.sheet, true);
|
|
8069
|
+
current = current.next;
|
|
8070
|
+
} while (current !== void 0);
|
|
8071
|
+
}
|
|
8072
|
+
};
|
|
8073
|
+
function useStyleControlCssObject(style, controlDefinition) {
|
|
7816
8074
|
const { properties } = controlDefinition.config;
|
|
7817
|
-
return
|
|
8075
|
+
return __spreadValues(__spreadValues({}, properties.includes(StyleControlProperty.Width) && {
|
|
7818
8076
|
maxWidth: "100%"
|
|
7819
8077
|
}), responsiveStyle([
|
|
7820
8078
|
style == null ? void 0 : style.width,
|
|
@@ -7847,7 +8105,7 @@ function useStyleControlDataClass(style, controlDefinition) {
|
|
|
7847
8105
|
borderBottomRightRadius: (_p = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomRightRadius)) != null ? _p : 0,
|
|
7848
8106
|
borderBottomLeftRadius: (_q = borderRadiusToString(borderRadius == null ? void 0 : borderRadius.borderBottomLeftRadius)) != null ? _q : 0
|
|
7849
8107
|
});
|
|
7850
|
-
}))
|
|
8108
|
+
}));
|
|
7851
8109
|
function widthToString(widthProperty) {
|
|
7852
8110
|
if (widthProperty == null)
|
|
7853
8111
|
return null;
|
|
@@ -7877,8 +8135,14 @@ function useStyleControlDataClass(style, controlDefinition) {
|
|
|
7877
8135
|
return `${borderRadius.value}${borderRadius.unit}`;
|
|
7878
8136
|
}
|
|
7879
8137
|
}
|
|
8138
|
+
const useInsertionEffect = (_ea = React.useInsertionEffect) != null ? _ea : React.useLayoutEffect;
|
|
7880
8139
|
function useFormattedStyle(styleControlData, controlDefinition) {
|
|
7881
|
-
|
|
8140
|
+
const style = useStyleControlCssObject(styleControlData, controlDefinition);
|
|
8141
|
+
const serialized = serializeStyles([style], cache.registered);
|
|
8142
|
+
useInsertionEffect(() => {
|
|
8143
|
+
insertStyles(cache, serialized, false);
|
|
8144
|
+
});
|
|
8145
|
+
return `${cache.key}-${serialized.name}`;
|
|
7882
8146
|
}
|
|
7883
8147
|
function useDeviceMode() {
|
|
7884
8148
|
return "desktop";
|
|
@@ -8092,25 +8356,40 @@ function useDispatch() {
|
|
|
8092
8356
|
const store = useContext(Context);
|
|
8093
8357
|
return store.dispatch;
|
|
8094
8358
|
}
|
|
8359
|
+
function useSuppressRefWarning(ownerName) {
|
|
8360
|
+
const originalErrorRef = useRef(console.error);
|
|
8361
|
+
const patchedRef = useRef(false);
|
|
8362
|
+
if (patchedRef.current === false) {
|
|
8363
|
+
console.error = (...args) => {
|
|
8364
|
+
const [msg, ...substitutions] = args;
|
|
8365
|
+
const text = substitutions.reduce((text2, substitution) => text2.replace("%s", substitution), msg);
|
|
8366
|
+
if (!text.includes("Function components cannot be given refs.") || !text.includes(`Check the render method of \`${ownerName}\`.`)) {
|
|
8367
|
+
originalErrorRef.current(...args);
|
|
8368
|
+
}
|
|
8369
|
+
};
|
|
8370
|
+
patchedRef.current = true;
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8095
8373
|
const ElementData = memo(forwardRef(function ElementData2({
|
|
8096
8374
|
elementData
|
|
8097
8375
|
}, ref) {
|
|
8098
8376
|
const Component2 = useComponent(elementData.type);
|
|
8099
8377
|
const props = useProps(elementData);
|
|
8100
|
-
const
|
|
8378
|
+
const [handle, setHandle] = useState(null);
|
|
8379
|
+
const [foundDomNode, setFoundDomNode] = useState(null);
|
|
8380
|
+
useImperativeHandle(ref, () => handle != null ? handle : foundDomNode, [handle, foundDomNode]);
|
|
8381
|
+
useSuppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
|
|
8101
8382
|
if (Component2 == null) {
|
|
8102
8383
|
return /* @__PURE__ */ jsx(FallbackComponent, {
|
|
8103
8384
|
ref,
|
|
8104
8385
|
text: "Component not found"
|
|
8105
8386
|
});
|
|
8106
8387
|
}
|
|
8107
|
-
return
|
|
8108
|
-
|
|
8109
|
-
ref
|
|
8110
|
-
})) : /* @__PURE__ */ jsx(FindDomNode, {
|
|
8111
|
-
ref,
|
|
8388
|
+
return /* @__PURE__ */ jsx(FindDomNode, {
|
|
8389
|
+
ref: setFoundDomNode,
|
|
8112
8390
|
children: /* @__PURE__ */ createElement(Component2, __spreadProps(__spreadValues({}, props), {
|
|
8113
|
-
key: elementData.key
|
|
8391
|
+
key: elementData.key,
|
|
8392
|
+
ref: setHandle
|
|
8114
8393
|
}))
|
|
8115
8394
|
});
|
|
8116
8395
|
}));
|