@makeswift/runtime 0.20.0-canary.0 → 0.20.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.
@@ -36,7 +36,7 @@ async function handler(...args) {
36
36
  const supportsPreviewMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => false).with(apiRoutePattern, () => true).exhaustive();
37
37
  const supportsDraftMode = (0, import_ts_pattern.match)(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
38
38
  const body = {
39
- version: "0.20.0-canary.0",
39
+ version: "0.20.0",
40
40
  previewMode: supportsPreviewMode,
41
41
  draftMode: supportsDraftMode,
42
42
  interactionMode: true,
@@ -25,38 +25,17 @@ var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_react = require("react");
26
26
  var import_react2 = require("react");
27
27
  var import_use_component = require("../hooks/use-component");
28
+ var import_suppress_ref_warning = require("../utils/suppress-ref-warning");
28
29
  var import_FallbackComponent = require("../../../components/shared/FallbackComponent");
29
30
  var import_controls = require("../controls");
30
- function hasTypeofSymbol(Component, symbol) {
31
- return Component && Component.type && Component.$$typeof?.toString() === `Symbol(${symbol})`;
32
- }
33
- function isMemoComponent(Component) {
34
- return hasTypeofSymbol(Component, "react.memo");
35
- }
36
- function unwrapIfMemo(Component) {
37
- return isMemoComponent(Component) ? Component.type : Component;
38
- }
39
- function isForwardRef(Component) {
40
- return hasTypeofSymbol(Component, "react.forward_ref");
41
- }
42
- function isClassComponent(Component) {
43
- return typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent;
44
- }
45
- function isLazyComponent(Component) {
46
- return hasTypeofSymbol(Component, "react.lazy");
47
- }
48
- function canAcceptRef(Component) {
49
- return isClassComponent(Component) || isForwardRef(Component) || // will try to pass a ref to all lazy components since we can't know if they accept refs without loading them
50
- isLazyComponent(Component);
51
- }
52
31
  const ElementData = (0, import_react2.memo)(
53
32
  (0, import_react2.forwardRef)(function ElementData2({ elementData }, ref) {
54
33
  const Component = (0, import_use_component.useComponent)(elementData.type);
55
- const forwardRef2 = canAcceptRef(unwrapIfMemo(Component));
34
+ (0, import_suppress_ref_warning.suppressRefWarning)(`\`ForwardRef(${ElementData2.name})\``);
56
35
  if (Component == null) {
57
36
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FallbackComponent.FallbackComponent, { ref, text: "Component not found" });
58
37
  }
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.PropsValue, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key }) }) });
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Suspense, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.PropsValue, { element: elementData, children: (props) => /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) }) });
60
39
  })
61
40
  );
62
41
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, Suspense, forwardRef, memo } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useComponent } from '../hooks/use-component'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { PropsValue } from '../controls'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nfunction hasTypeofSymbol(Component: any, symbol: string) {\n return Component && Component.type && Component.$$typeof?.toString() === `Symbol(${symbol})`\n}\n\nfunction isMemoComponent(Component: any) {\n return hasTypeofSymbol(Component, 'react.memo')\n}\n\nfunction unwrapIfMemo(Component: any) {\n return isMemoComponent(Component) ? Component.type : Component\n}\n\nfunction isForwardRef(Component: any) {\n return hasTypeofSymbol(Component, 'react.forward_ref')\n}\n\nfunction isClassComponent(Component: any) {\n return (\n typeof Component === 'function' && Component.prototype && Component.prototype.isReactComponent\n )\n}\n\nfunction isLazyComponent(Component: any) {\n return hasTypeofSymbol(Component, 'react.lazy')\n}\n\nfunction canAcceptRef(Component: any) {\n return (\n isClassComponent(Component) ||\n isForwardRef(Component) ||\n // will try to pass a ref to all lazy components since we can't know if they accept refs without loading them\n isLazyComponent(Component)\n )\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData(\n { elementData }: ElementDataProps,\n ref: Ref<unknown>,\n ): JSX.Element {\n const Component = useComponent(elementData.type)\n const forwardRef = canAcceptRef(unwrapIfMemo(Component))\n\n if (Component == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n return (\n <Suspense>\n <PropsValue element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </PropsValue>\n </Suspense>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDa;AAQC;AA9Dd,IAAAA,gBAAgD;AAEhD,2BAA6B;AAC7B,+BAAkC;AAClC,sBAA2B;AAM3B,SAAS,gBAAgB,WAAgB,QAAgB;AACvD,SAAO,aAAa,UAAU,QAAQ,UAAU,UAAU,SAAS,MAAM,UAAU,MAAM;AAC3F;AAEA,SAAS,gBAAgB,WAAgB;AACvC,SAAO,gBAAgB,WAAW,YAAY;AAChD;AAEA,SAAS,aAAa,WAAgB;AACpC,SAAO,gBAAgB,SAAS,IAAI,UAAU,OAAO;AACvD;AAEA,SAAS,aAAa,WAAgB;AACpC,SAAO,gBAAgB,WAAW,mBAAmB;AACvD;AAEA,SAAS,iBAAiB,WAAgB;AACxC,SACE,OAAO,cAAc,cAAc,UAAU,aAAa,UAAU,UAAU;AAElF;AAEA,SAAS,gBAAgB,WAAgB;AACvC,SAAO,gBAAgB,WAAW,YAAY;AAChD;AAEA,SAAS,aAAa,WAAgB;AACpC,SACE,iBAAiB,SAAS,KAC1B,aAAa,SAAS;AAAA,EAEtB,gBAAgB,SAAS;AAE7B;AAEO,MAAM,kBAAc;AAAA,MACzB,0BAAW,SAASC,aAClB,EAAE,YAAY,GACd,KACa;AACb,UAAM,gBAAY,mCAAa,YAAY,IAAI;AAC/C,UAAMC,cAAa,aAAa,aAAa,SAAS,CAAC;AAEvD,QAAI,aAAa,MAAM;AACrB,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,WACE,4CAAC,0BACC,sDAAC,8BAAW,SAAS,aAClB,qBACCA,cACE,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["import_react","ElementData","forwardRef"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, Suspense, forwardRef, memo } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useComponent } from '../hooks/use-component'\nimport { suppressRefWarning } from '../utils/suppress-ref-warning'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { PropsValue } from '../controls'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData(\n { elementData }: ElementDataProps,\n ref: Ref<unknown>,\n ): JSX.Element {\n const Component = useComponent(elementData.type)\n\n suppressRefWarning(`\\`ForwardRef(${ElementData.name})\\``)\n\n if (Component == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n return (\n <Suspense>\n <PropsValue element={elementData}>\n {props => <Component {...props} key={elementData.key} ref={ref} />}\n </PropsValue>\n </Suspense>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBa;AAMO;AA3BpB,IAAAA,gBAAgD;AAEhD,2BAA6B;AAC7B,kCAAmC;AACnC,+BAAkC;AAClC,sBAA2B;AAMpB,MAAM,kBAAc;AAAA,MACzB,0BAAW,SAASC,aAClB,EAAE,YAAY,GACd,KACa;AACb,UAAM,gBAAY,mCAAa,YAAY,IAAI;AAE/C,wDAAmB,gBAAgBA,aAAY,IAAI,KAAK;AAExD,QAAI,aAAa,MAAM;AACrB,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,WACE,4CAAC,0BACC,sDAAC,8BAAW,SAAS,aAClB,qBAAS,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,GAClE,GACF;AAAA,EAEJ,CAAC;AACH;","names":["import_react","ElementData"]}
@@ -13,7 +13,7 @@ async function handler(...args) {
13
13
  const supportsPreviewMode = match(args).with(routeHandlerPattern, () => false).with(apiRoutePattern, () => true).exhaustive();
14
14
  const supportsDraftMode = match(args).with(routeHandlerPattern, () => true).with(apiRoutePattern, () => false).exhaustive();
15
15
  const body = {
16
- version: "0.20.0-canary.0",
16
+ version: "0.20.0",
17
17
  previewMode: supportsPreviewMode,
18
18
  draftMode: supportsDraftMode,
19
19
  interactionMode: true,
@@ -2,38 +2,17 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { createElement } from "react";
3
3
  import { Suspense, forwardRef, memo } from "react";
4
4
  import { useComponent } from "../hooks/use-component";
5
+ import { suppressRefWarning } from "../utils/suppress-ref-warning";
5
6
  import { FallbackComponent } from "../../../components/shared/FallbackComponent";
6
7
  import { PropsValue } from "../controls";
7
- function hasTypeofSymbol(Component, symbol) {
8
- return Component && Component.type && Component.$$typeof?.toString() === `Symbol(${symbol})`;
9
- }
10
- function isMemoComponent(Component) {
11
- return hasTypeofSymbol(Component, "react.memo");
12
- }
13
- function unwrapIfMemo(Component) {
14
- return isMemoComponent(Component) ? Component.type : Component;
15
- }
16
- function isForwardRef(Component) {
17
- return hasTypeofSymbol(Component, "react.forward_ref");
18
- }
19
- function isClassComponent(Component) {
20
- return typeof Component === "function" && Component.prototype && Component.prototype.isReactComponent;
21
- }
22
- function isLazyComponent(Component) {
23
- return hasTypeofSymbol(Component, "react.lazy");
24
- }
25
- function canAcceptRef(Component) {
26
- return isClassComponent(Component) || isForwardRef(Component) || // will try to pass a ref to all lazy components since we can't know if they accept refs without loading them
27
- isLazyComponent(Component);
28
- }
29
8
  const ElementData = memo(
30
9
  forwardRef(function ElementData2({ elementData }, ref) {
31
10
  const Component = useComponent(elementData.type);
32
- const forwardRef2 = canAcceptRef(unwrapIfMemo(Component));
11
+ suppressRefWarning(`\`ForwardRef(${ElementData2.name})\``);
33
12
  if (Component == null) {
34
13
  return /* @__PURE__ */ jsx(FallbackComponent, { ref, text: "Component not found" });
35
14
  }
36
- return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(PropsValue, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key }) }) });
15
+ return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(PropsValue, { element: elementData, children: (props) => /* @__PURE__ */ createElement(Component, { ...props, key: elementData.key, ref }) }) });
37
16
  })
38
17
  );
39
18
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, Suspense, forwardRef, memo } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useComponent } from '../hooks/use-component'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { PropsValue } from '../controls'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nfunction hasTypeofSymbol(Component: any, symbol: string) {\n return Component && Component.type && Component.$$typeof?.toString() === `Symbol(${symbol})`\n}\n\nfunction isMemoComponent(Component: any) {\n return hasTypeofSymbol(Component, 'react.memo')\n}\n\nfunction unwrapIfMemo(Component: any) {\n return isMemoComponent(Component) ? Component.type : Component\n}\n\nfunction isForwardRef(Component: any) {\n return hasTypeofSymbol(Component, 'react.forward_ref')\n}\n\nfunction isClassComponent(Component: any) {\n return (\n typeof Component === 'function' && Component.prototype && Component.prototype.isReactComponent\n )\n}\n\nfunction isLazyComponent(Component: any) {\n return hasTypeofSymbol(Component, 'react.lazy')\n}\n\nfunction canAcceptRef(Component: any) {\n return (\n isClassComponent(Component) ||\n isForwardRef(Component) ||\n // will try to pass a ref to all lazy components since we can't know if they accept refs without loading them\n isLazyComponent(Component)\n )\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData(\n { elementData }: ElementDataProps,\n ref: Ref<unknown>,\n ): JSX.Element {\n const Component = useComponent(elementData.type)\n const forwardRef = canAcceptRef(unwrapIfMemo(Component))\n\n if (Component == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n return (\n <Suspense>\n <PropsValue element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </PropsValue>\n </Suspense>\n )\n }),\n)\n"],"mappings":"AAsDa;AAQC;AA9Dd,SAAc,UAAU,YAAY,YAAY;AAEhD,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAM3B,SAAS,gBAAgB,WAAgB,QAAgB;AACvD,SAAO,aAAa,UAAU,QAAQ,UAAU,UAAU,SAAS,MAAM,UAAU,MAAM;AAC3F;AAEA,SAAS,gBAAgB,WAAgB;AACvC,SAAO,gBAAgB,WAAW,YAAY;AAChD;AAEA,SAAS,aAAa,WAAgB;AACpC,SAAO,gBAAgB,SAAS,IAAI,UAAU,OAAO;AACvD;AAEA,SAAS,aAAa,WAAgB;AACpC,SAAO,gBAAgB,WAAW,mBAAmB;AACvD;AAEA,SAAS,iBAAiB,WAAgB;AACxC,SACE,OAAO,cAAc,cAAc,UAAU,aAAa,UAAU,UAAU;AAElF;AAEA,SAAS,gBAAgB,WAAgB;AACvC,SAAO,gBAAgB,WAAW,YAAY;AAChD;AAEA,SAAS,aAAa,WAAgB;AACpC,SACE,iBAAiB,SAAS,KAC1B,aAAa,SAAS;AAAA,EAEtB,gBAAgB,SAAS;AAE7B;AAEO,MAAM,cAAc;AAAA,EACzB,WAAW,SAASA,aAClB,EAAE,YAAY,GACd,KACa;AACb,UAAM,YAAY,aAAa,YAAY,IAAI;AAC/C,UAAMC,cAAa,aAAa,aAAa,SAAS,CAAC;AAEvD,QAAI,aAAa,MAAM;AACrB,aAAO,oBAAC,qBAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,WACE,oBAAC,YACC,8BAAC,cAAW,SAAS,aAClB,qBACCA,cACE,8BAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,8BAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["ElementData","forwardRef"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, Suspense, forwardRef, memo } from 'react'\nimport { ElementData as ReactPageElementData } from '../../../state/react-page'\nimport { useComponent } from '../hooks/use-component'\nimport { suppressRefWarning } from '../utils/suppress-ref-warning'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { PropsValue } from '../controls'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData(\n { elementData }: ElementDataProps,\n ref: Ref<unknown>,\n ): JSX.Element {\n const Component = useComponent(elementData.type)\n\n suppressRefWarning(`\\`ForwardRef(${ElementData.name})\\``)\n\n if (Component == null) {\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n return (\n <Suspense>\n <PropsValue element={elementData}>\n {props => <Component {...props} key={elementData.key} ref={ref} />}\n </PropsValue>\n </Suspense>\n )\n }),\n)\n"],"mappings":"AAqBa;AAMO;AA3BpB,SAAc,UAAU,YAAY,YAAY;AAEhD,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAMpB,MAAM,cAAc;AAAA,EACzB,WAAW,SAASA,aAClB,EAAE,YAAY,GACd,KACa;AACb,UAAM,YAAY,aAAa,YAAY,IAAI;AAE/C,uBAAmB,gBAAgBA,aAAY,IAAI,KAAK;AAExD,QAAI,aAAa,MAAM;AACrB,aAAO,oBAAC,qBAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,WACE,oBAAC,YACC,8BAAC,cAAW,SAAS,aAClB,qBAAS,8BAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,GAClE,GACF;AAAA,EAEJ,CAAC;AACH;","names":["ElementData"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ElementData.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAK/E,KAAK,gBAAgB,GAAG;IACtB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAAA;AAqCD,eAAO,MAAM,WAAW,2IA0BvB,CAAA"}
1
+ {"version":3,"file":"ElementData.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAM/E,KAAK,gBAAgB,GAAG;IACtB,WAAW,EAAE,oBAAoB,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,WAAW,2IAqBvB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.20.0-canary.0",
3
+ "version": "0.20.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist",
@@ -149,9 +149,9 @@
149
149
  "use-sync-external-store": "^1.0.0-rc.0",
150
150
  "uuid": "^9.0.0",
151
151
  "zod": "^3.21.4",
152
- "@makeswift/controls": "0.1.0-canary.0",
153
- "@makeswift/next-plugin": "0.3.0",
154
- "@makeswift/prop-controllers": "0.3.1-canary.0"
152
+ "@makeswift/controls": "0.1.0",
153
+ "@makeswift/prop-controllers": "0.3.1",
154
+ "@makeswift/next-plugin": "0.3.0"
155
155
  },
156
156
  "devDependencies": {
157
157
  "@emotion/jest": "^11.11.0",