@makeswift/runtime 0.28.8-canary.7 → 0.28.8-canary.8

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.
@@ -27,7 +27,7 @@ class MakeswiftGraphQLApiClient {
27
27
  graphqlClient;
28
28
  constructor({ endpoint }) {
29
29
  this.graphqlClient = new import_client.GraphQLClient(endpoint, {
30
- "makeswift-runtime-version": "0.28.8-canary.7"
30
+ "makeswift-runtime-version": "0.28.8-canary.8"
31
31
  });
32
32
  }
33
33
  async createTableRecord(tableId, columns) {
@@ -147,7 +147,7 @@ class MakeswiftRestAPIClient {
147
147
  const requestHeaders = new Headers({
148
148
  "x-api-key": this.apiKey,
149
149
  "makeswift-site-api-key": this.apiKey,
150
- "makeswift-runtime-version": "0.28.8-canary.7"
150
+ "makeswift-runtime-version": "0.28.8-canary.8"
151
151
  });
152
152
  if (siteVersion?.token) {
153
153
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
28
28
  return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
29
29
  }
30
30
  return import_request_response.ApiResponse.json({
31
- version: "0.28.8-canary.7",
31
+ version: "0.28.8-canary.8",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -689,7 +689,7 @@ Received "${apiKey}" instead.`
689
689
  headers: {
690
690
  "x-api-key": this.apiKey,
691
691
  "makeswift-site-api-key": this.apiKey,
692
- "makeswift-runtime-version": "0.28.8-canary.7",
692
+ "makeswift-runtime-version": "0.28.8-canary.8",
693
693
  "content-type": "application/json"
694
694
  },
695
695
  body: JSON.stringify({ token }),
@@ -94,6 +94,7 @@ const Embed = (0, import_react.forwardRef)(function Embed2({ id, width, margin,
94
94
  });
95
95
  }, [container, html]);
96
96
  const className = (0, import_use_style.useStyle)({ minHeight: 15 });
97
+ const dangerouslySetInnerHTML = (0, import_react.useMemo)(() => ({ __html: html }), [html]);
97
98
  if (shouldRender === false)
98
99
  return null;
99
100
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -102,7 +103,7 @@ const Embed = (0, import_react.forwardRef)(function Embed2({ id, width, margin,
102
103
  ref: setContainer,
103
104
  id,
104
105
  className: (0, import_css.cx)(className, width, margin),
105
- dangerouslySetInnerHTML: { __html: html }
106
+ dangerouslySetInnerHTML
106
107
  }
107
108
  );
108
109
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n )\n})\n\nexport default Embed\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgHI;AA5GJ,mBAA0E;AAE1E,uCAA0C;AAC1C,uBAAyB;AACzB,iBAAmB;AASnB,MAAM,cAAc;AAAA;AAA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AAI,CAAC,OAAO,aAAa,KAAK;AAAG,oBAAQ;AAAA,QAC3C,CAAC;AAAA,MACH;AAAA,IACF;AAEA,0BAAsB,EAAE,MAAM,WAAS;AAErC,cAAQ,MAAM,KAAK;AAAA,IACrB,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,QAAM,gBAAY,2BAAS,EAAE,WAAW,GAAG,CAAC;AAE5C,MAAI,iBAAiB;AAAO,WAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,eAAW,eAAG,WAAW,OAAO,MAAM;AAAA,MACtC,yBAAyB,EAAE,QAAQ,KAAK;AAAA;AAAA,EAC1C;AAEJ,CAAC;AAED,IAAO,gBAAQ;","names":["Embed"]}
1
+ {"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, useMemo, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n // React 19+ resets `innerHTML` whenever the `dangerouslySetInnerHTML`\n // object's identity changes, even if `__html` is the same string. Memoize\n // the object so unrelated re-renders don't wipe out DOM produced by the\n // executed scripts above. See https://github.com/facebook/react/issues/31660\n // and https://github.com/react/react/issues/31600\n const dangerouslySetInnerHTML = useMemo(() => ({ __html: html }), [html])\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={dangerouslySetInnerHTML}\n />\n )\n})\n\nexport default Embed\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuHI;AAnHJ,mBAAmF;AAEnF,uCAA0C;AAC1C,uBAAyB;AACzB,iBAAmB;AASnB,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBpB,MAAM,aAAa;AAEnB,MAAM,YAAQ,yBAAW,SAASA,OAChC,EAAE,IAAI,OAAO,QAAQ,OAAO,YAAY,GACxC,KACA;AACA,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAgC,IAAI;AACtE,QAAM,CAAC,cAAc,eAAe,QAAI,uBAAS,KAAK;AAEtD,kEAA0B,MAAM;AAC9B,oBAAgB,IAAI;AAAA,EACtB,GAAG,CAAC,CAAC;AAEL,wCAAkE,KAAK,MAAM,WAAW;AAAA,IACtF;AAAA,EACF,CAAC;AAED,8BAAU,MAAM;AAGd,QAAI,CAAC;AAAW;AAEhB,UAAM,SAAS,UAAU,cAAc,iBAAiB,WAAW,WAAW,cAAc;AAAA,MAC1F,WAAW,MAAe;AACxB,eAAO,KAAK,QAAQ,YAAY,MAAM,aAClC,WAAW,gBACX,WAAW;AAAA,MACjB;AAAA,IACF,CAAC;AAED,UAAM,QAAmB,CAAC;AAE1B,WAAO,OAAO,SAAS;AAAG,YAAM,KAAK,OAAO,WAAsB;AAOlE,mBAAe,wBAAwB;AACrC,eAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,cAAM,IAAI,QAAc,aAAW;AACjC,gBAAM,OAAO,MAAM,CAAC;AACpB,gBAAM,SAAS,KAAK,cAAc,cAAc,UAAU;AAE1D,iBAAO,cAAc,KAAK;AAC1B,gBAAM,KAAK,KAAK,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,MAAM,MAAM;AACvD,mBAAO,aAAa,MAAM,KAAK;AAAA,UACjC,CAAC;AAED,iBAAO,SAAS,MAAM,QAAQ;AAC9B,iBAAO,UAAU,MAAM,QAAQ;AAE/B,eAAK,YAAY,aAAa,QAAQ,IAAI;AAC1C,eAAK,YAAY,YAAY,IAAI;AAEjC,cAAI,CAAC,OAAO,aAAa,KAAK;AAAG,oBAAQ;AAAA,QAC3C,CAAC;AAAA,MACH;AAAA,IACF;AAEA,0BAAsB,EAAE,MAAM,WAAS;AAErC,cAAQ,MAAM,KAAK;AAAA,IACrB,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,QAAM,gBAAY,2BAAS,EAAE,WAAW,GAAG,CAAC;AAO5C,QAAM,8BAA0B,sBAAQ,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAC;AAExE,MAAI,iBAAiB;AAAO,WAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,eAAW,eAAG,WAAW,OAAO,MAAM;AAAA,MACtC;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,IAAO,gBAAQ;","names":["Embed"]}
@@ -9,7 +9,7 @@ class MakeswiftGraphQLApiClient {
9
9
  graphqlClient;
10
10
  constructor({ endpoint }) {
11
11
  this.graphqlClient = new GraphQLClient(endpoint, {
12
- "makeswift-runtime-version": "0.28.8-canary.7"
12
+ "makeswift-runtime-version": "0.28.8-canary.8"
13
13
  });
14
14
  }
15
15
  async createTableRecord(tableId, columns) {
@@ -113,7 +113,7 @@ class MakeswiftRestAPIClient {
113
113
  const requestHeaders = new Headers({
114
114
  "x-api-key": this.apiKey,
115
115
  "makeswift-site-api-key": this.apiKey,
116
- "makeswift-runtime-version": "0.28.8-canary.7"
116
+ "makeswift-runtime-version": "0.28.8-canary.8"
117
117
  });
118
118
  if (siteVersion?.token) {
119
119
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
8
8
  return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
9
9
  }
10
10
  return ApiResponse.json({
11
- version: "0.28.8-canary.7",
11
+ version: "0.28.8-canary.8",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,
@@ -669,7 +669,7 @@ Received "${apiKey}" instead.`
669
669
  headers: {
670
670
  "x-api-key": this.apiKey,
671
671
  "makeswift-site-api-key": this.apiKey,
672
- "makeswift-runtime-version": "0.28.8-canary.7",
672
+ "makeswift-runtime-version": "0.28.8-canary.8",
673
673
  "content-type": "application/json"
674
674
  },
675
675
  body: JSON.stringify({ token }),
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { useState, useEffect, forwardRef, useImperativeHandle } from "react";
3
+ import { useState, useEffect, useMemo, forwardRef, useImperativeHandle } from "react";
4
4
  import { useIsomorphicLayoutEffect } from "../../hooks/useIsomorphicLayoutEffect";
5
5
  import { useStyle } from "../../../runtimes/react/use-style";
6
6
  import { cx } from "@emotion/css";
@@ -71,6 +71,7 @@ const Embed = forwardRef(function Embed2({ id, width, margin, html = defaultHtml
71
71
  });
72
72
  }, [container, html]);
73
73
  const className = useStyle({ minHeight: 15 });
74
+ const dangerouslySetInnerHTML = useMemo(() => ({ __html: html }), [html]);
74
75
  if (shouldRender === false)
75
76
  return null;
76
77
  return /* @__PURE__ */ jsx(
@@ -79,7 +80,7 @@ const Embed = forwardRef(function Embed2({ id, width, margin, html = defaultHtml
79
80
  ref: setContainer,
80
81
  id,
81
82
  className: cx(className, width, margin),
82
- dangerouslySetInnerHTML: { __html: html }
83
+ dangerouslySetInnerHTML
83
84
  }
84
85
  );
85
86
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n )\n})\n\nexport default Embed\n"],"mappings":";AAgHI;AA5GJ,SAAS,UAAU,WAAW,YAAiB,2BAA2B;AAE1E,SAAS,iCAAiC;AAC1C,SAAS,gBAAgB;AACzB,SAAS,UAAU;AASnB,MAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBpB,MAAM,aAAa;AAEnB,MAAM,QAAQ,WAAW,SAASA,OAChC,EAAE,IAAI,OAAO,QAAQ,OAAO,YAAY,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S,EAAE,WAAW,GAAG,CAAC;AAE5C,MAAI,iBAAiB;AAAO,WAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,WAAW,GAAG,WAAW,OAAO,MAAM;AAAA,MACtC,yBAAyB,EAAE,QAAQ,KAAK;AAAA;AAAA,EAC1C;AAEJ,CAAC;AAED,IAAO,gBAAQ;","names":["Embed"]}
1
+ {"version":3,"sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"sourcesContent":["'use client'\n\n/* eslint-env browser */\n\nimport { useState, useEffect, useMemo, forwardRef, Ref, useImperativeHandle } from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect'\nimport { useStyle } from '../../../runtimes/react/use-style'\nimport { cx } from '@emotion/css'\n\ntype Props = {\n id?: string\n html?: string\n width?: string\n margin?: string\n}\n\nconst defaultHtml = `<div style=\"padding: 24px; background-color: rgba(161, 168, 194, 0.18); overflow: hidden;\">\n<svg width=\"316\" height=\"168\" viewBox=\"0 0 316 168\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect width=\"70\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"78\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"116\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"20\" width=\"120\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"128\" y=\"20\" width=\"30\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"166\" y=\"20\" width=\"78\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect y=\"60\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"80\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"100\" width=\"110\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"206\" y=\"100\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"238\" y=\"100\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"40\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"88\" y=\"120\" width=\"50\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"146\" y=\"120\" width=\"24\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"178\" y=\"120\" width=\"90\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.25\"/>\n<rect x=\"276\" y=\"120\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect x=\"20\" y=\"140\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n<rect y=\"160\" width=\"40\" height=\"8\" rx=\"2\" fill=\"#A1A8C2\" fill-opacity=\"0.5\"/>\n</svg>\n</div>`\nconst SCRIPT_TAG = 'script'\n\nconst Embed = forwardRef(function Embed(\n { id, width, margin, html = defaultHtml }: Props,\n ref: Ref<HTMLDivElement | null>,\n) {\n const [container, setContainer] = useState<HTMLDivElement | null>(null)\n const [shouldRender, setShouldRender] = useState(false)\n\n useIsomorphicLayoutEffect(() => {\n setShouldRender(true)\n }, [])\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(ref, () => container, [\n container,\n ])\n\n useEffect(() => {\n // TODO: When we SSR the editor, we can remove the editor check\n // and not run this effect on the first render.\n if (!container) return\n\n const walker = container.ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode(node: Element) {\n return node.tagName.toLowerCase() === SCRIPT_TAG\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_REJECT\n },\n })\n\n const nodes: Element[] = []\n\n while (walker.nextNode()) nodes.push(walker.currentNode as Element)\n\n // By default scripts appended dynamically will execute asyncrhonously. Here we ensure that\n // scripts are loaded synchronously since that's what a user usually expects with scripts in\n // embedded in HTML which usually comes from the server.\n //\n // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#notes\n async function executeScriptsInOrder() {\n for (let i = 0; i < nodes.length; i++) {\n await new Promise<void>(resolve => {\n const node = nodes[i]\n const script = node.ownerDocument.createElement(SCRIPT_TAG)\n\n script.textContent = node.textContent\n Array.from(node.attributes).forEach(({ name, value }) => {\n script.setAttribute(name, value)\n })\n\n script.onload = () => resolve()\n script.onerror = () => resolve()\n\n node.parentNode?.insertBefore(script, node)\n node.parentNode?.removeChild(node)\n\n if (!script.hasAttribute('src')) resolve()\n })\n }\n }\n\n executeScriptsInOrder().catch(error => {\n // Ignore errors from user-provided code\n console.error(error)\n })\n }, [container, html])\n\n const className = useStyle({ minHeight: 15 })\n\n // React 19+ resets `innerHTML` whenever the `dangerouslySetInnerHTML`\n // object's identity changes, even if `__html` is the same string. Memoize\n // the object so unrelated re-renders don't wipe out DOM produced by the\n // executed scripts above. See https://github.com/facebook/react/issues/31660\n // and https://github.com/react/react/issues/31600\n const dangerouslySetInnerHTML = useMemo(() => ({ __html: html }), [html])\n\n if (shouldRender === false) return null\n\n return (\n <div\n ref={setContainer}\n id={id}\n className={cx(className, width, margin)}\n dangerouslySetInnerHTML={dangerouslySetInn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,aAAa,MAAM,KAAK;AAAA,UACjC,CAAC;AAED,iBAAO,SAAS,MAAM,QAAQ;AAC9B,iBAAO,UAAU,MAAM,QAAQ;AAE/B,eAAK,YAAY,aAAa,QAAQ,IAAI;AAC1C,eAAK,YAAY,YAAY,IAAI;AAEjC,cAAI,CAAC,OAAO,aAAa,KAAK;AAAG,oBAAQ;AAAA,QAC3C,CAAC;AAAA,MACH;AAAA,IACF;AAEA,0BAAsB,EAAE,MAAM,WAAS;AAErC,cAAQ,MAAM,KAAK;AAAA,IACrB,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,IAAI,CAAC;AAEpB,QAAM,YAAY,SAAS,EAAE,WAAW,GAAG,CAAC;AAO5C,QAAM,0BAA0B,QAAQ,OAAO,EAAE,QAAQ,KAAK,IAAI,CAAC,IAAI,CAAC;AAExE,MAAI,iBAAiB;AAAO,WAAO;AAEnC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL;AAAA,MACA,WAAW,GAAG,WAAW,OAAO,MAAM;AAAA,MACtC;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,IAAO,gBAAQ;","names":["Embed"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncDOMSelection.tsx"],"sourcesContent":["import { ReactEditor } from 'slate-react'\nimport { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: boolean) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAiB,SAAS,kBAAkB;AAC5C,SAAS,iCAAiC;AAOnC,SAAS,oBAAoB,QAAgB,WAAoB;AACtE,4BAA0B,MAAM;AAC9B,QAAI,CAAC,aAAa,OAAO,aAAa,QAAQ,YAAY,UAAU,MAAM;AAAG;AAC7E,QAAI;AACF,YAAM,OAAO,YAAY,yBAAyB,MAAM;AACxD,YAAM,eAAe,KAAK,aAAa;AACvC,YAAM,cAA4B,YAAY,WAAW,QAAQ,OAAO,SAAS;AAEjF,UAAI,aAAa;AACf,YAAI,WAAW,WAAW,OAAO,SAAU,GAAG;AAC5C,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF,OAAO;AACL,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF;AAAA,MACF,OAAO;AACL,sBAAc,gBAAgB;AAAA,MAChC;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AAAA,IACjB;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text/EditableText/useSyncWithBuilder.tsx"],"sourcesContent":["import { useState, useEffect, useCallback } from 'react'\nimport { Editor, Range } from 'slate'\nimport { type RichTextDTO, richTextDTOtoDAO, richTextDTOtoSelection } from '@makeswift/controls'\n\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\nimport deepEqual from '../../../../../utils/deepEqual'\n\nconst COMMIT_DEBOUNCE_DELAY = 500\n\n/**\n * Compare new prop value with current editor and update editor\n * if the values are not equal.\n */\nexport function useSyncWithBuilder(editor: Editor, text?: RichTextDTO) {\n const [shouldCommit, setShouldCommit] = useState(true)\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (shouldCommit && text && isInBuilder) {\n const nextValue = richTextDTOtoDAO(text)\n const nextSelection = richTextDTOtoSelection(text)\n const sameSelection =\n editor.selection == null || nextSelection == null\n ? editor.selection == nextSelection\n : Range.equals(editor.selection, nextSelection)\n\n if (!deepEqual(editor.children, nextValue) || !sameSelection) {\n editor.children = nextValue\n editor.selection = nextSelection\n editor.onChange()\n }\n }\n }, [editor, isInBuilder, shouldCommit, text])\n\n useEffect(() => {\n if (shouldCommit) return\n\n const timeoutId = window.setTimeout(() => {\n setShouldCommit(true)\n }, COMMIT_DEBOUNCE_DELAY)\n\n return () => {\n window.clearTimeout(timeoutId)\n }\n }, [shouldCommit])\n\n return useCallback(() => setShouldCommit(false), [])\n}\n"],"mappings":"AAAA,SAAS,UAAU,WAAW,mBAAmB;AACjD,SAAiB,aAAa;AAC9B,SAA2B,kBAAkB,8BAA8B;AAE3E,SAAS,sBAAsB;AAC/B,OAAO,eAAe;AAEtB,MAAM,wBAAwB;AAMvB,SAAS,mBAAmB,QAAgB,MAAoB;AACrE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,IAAI;AACrD,QAAM,cAAc,eAAe;AAEnC,YAAU,MAAM;AACd,QAAI,gBAAgB,QAAQ,aAAa;AACvC,YAAM,YAAY,iBAAiB,IAAI;AACvC,YAAM,gBAAgB,uBAAuB,IAAI;AACjD,YAAM,gBACJ,OAAO,aAAa,QAAQ,iBAAiB,OACzC,OAAO,aAAa,gBACpB,MAAM,OAAO,OAAO,WAAW,aAAa;AAElD,UAAI,CAAC,UAAU,OAAO,UAAU,SAAS,KAAK,CAAC,eAAe;AAC5D,eAAO,WAAW;AAClB,eAAO,YAAY;AACnB,eAAO,SAAS;AAAA,MAClB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,aAAa,cAAc,IAAI,CAAC;AAE5C,YAAU,MAAM;AACd,QAAI;AAAc;AAElB,UAAM,YAAY,OAAO,WAAW,MAAM;AACxC,sBAAgB,IAAI;AAAA,IACtB,GAAG,qBAAqB;AAExB,WAAO,MAAM;AACX,aAAO,aAAa,SAAS;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,SAAO,YAAY,MAAM,gBAAgB,KAAK,GAAG,CAAC,CAAC;AACrD;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/usePresetValue.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { Descendant } from 'slate'\nimport { Slate, getBaseBreakpoint } from '@makeswift/controls'\n\nimport { DefaultBreakpointID } from '../../../../../state/modules/breakpoints'\nimport { useBreakpoints } from '../../../hooks/use-breakpoints'\nimport { RichTextV2Definition, RichText } from '../../../../../controls'\n\nexport function usePresetValue(definition: RichTextV2Definition): Descendant[] {\n const breakpoints = useBreakpoints()\n return useMemo(\n () => [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: definition.config.defaultValue ?? '',\n ...(definition.config.mode === RichText.Mode.Inline\n ? {}\n : {\n typography: {\n style: [\n {\n deviceId: getBaseBreakpoint(breakpoints).id,\n value: {\n fontWeight: 400,\n fontSize: { value: 18, unit: 'px' },\n lineHeight: 1.5,\n },\n },\n ...(breakpoints.some(({ id }) => id === DefaultBreakpointID.Mobile)\n ? [\n {\n deviceId: DefaultBreakpointID.Mobile,\n value: { fontSize: { value: 16, unit: 'px' } },\n },\n ]\n : []),\n ],\n },\n }),\n },\n ],\n },\n ],\n [definition.config.mode, definition.config.defaultValue, breakpoints],\n )\n}\n\nexport const defaultValue = [\n {\n type: Slate.BlockType.Default,\n children: [\n {\n text: '',\n },\n ],\n },\n]\n"],"mappings":"AAAA,SAAS,eAAe;AAExB,SAAS,OAAO,yBAAyB;AAEzC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAA+B,gBAAgB;AAExC,SAAS,eAAe,YAAgD;AAC7E,QAAM,cAAc,eAAe;AACnC,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,QACE,MAAM,MAAM,UAAU;AAAA,QACtB,UAAU;AAAA,UACR;AAAA,YACE,MAAM,WAAW,OAAO,gBAAgB;AAAA,YACxC,GAAI,WAAW,OAAO,SAAS,SAAS,KAAK,SACzC,CAAC,IACD;AAAA,cACE,YAAY;AAAA,gBACV,OAAO;AAAA,kBACL;AAAA,oBACE,UAAU,kBAAkB,WAAW,EAAE;AAAA,oBACzC,OAAO;AAAA,sBACL,YAAY;AAAA,sBACZ,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK;AAAA,sBAClC,YAAY;AAAA,oBACd;AAAA,kBACF;AAAA,kBACA,GAAI,YAAY,KAAK,CAAC,EAAE,GAAG,MAAM,OAAO,oBAAoB,MAAM,IAC9D;AAAA,oBACE;AAAA,sBACE,UAAU,oBAAoB;AAAA,sBAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,MAAM,KAAK,EAAE;AAAA,oBAC/C;AAAA,kBACF,IACA,CAAC;AAAA,gBACP;AAAA,cACF;AAAA,YACF;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,OAAO,MAAM,WAAW,OAAO,cAAc,WAAW;AAAA,EACtE;AACF;AAEO,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM,MAAM,UAAU;AAAA,IACtB,UAAU;AAAA,MACR;AAAA,QACE,MAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useRemoteChanges.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { Editor } from 'slate'\n\nimport { RichText, RichTextDataV2 } from '../../../../../controls/rich-text-v2'\nimport { LocalChange } from '../../../../../slate'\nimport { useIsInBuilder } from '../../../hooks/use-is-in-builder'\n\n// From the component point of view we can't know if the change came from an action or a undo/redo\n// So we diff the time and force updates on actions that occured over a second ago.\nfunction isChangeWithinPreviousSec(change?: LocalChange) {\n return performance.now() - (change?.time ?? 0) < 1000\n}\n\nexport function useSyncRemoteChanges(editor: Editor, data?: RichTextDataV2) {\n const isInBuilder = useIsInBuilder()\n\n useEffect(() => {\n if (\n !isChangeWithinPreviousSec(editor.localChanges.get(data?.key ?? '')) &&\n data &&\n isInBuilder\n ) {\n editor.children = RichText.dataToNodes(data)\n editor.selection = editor?.localChanges.get(data.key)?.selection ?? null\n editor.onChange()\n }\n }, [editor, data])\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAG1B,SAAS,gBAAgC;AAEzC,SAAS,sBAAsB;AAI/B,SAAS,0BAA0B,QAAsB;AACvD,SAAO,YAAY,IAAI,KAAK,QAAQ,QAAQ,KAAK;AACnD;AAEO,SAAS,qBAAqB,QAAgB,MAAuB;AAC1E,QAAM,cAAc,eAAe;AAEnC,YAAU,MAAM;AACd,QACE,CAAC,0BAA0B,OAAO,aAAa,IAAI,MAAM,OAAO,EAAE,CAAC,KACnE,QACA,aACA;AACA,aAAO,WAAW,SAAS,YAAY,IAAI;AAC3C,aAAO,YAAY,QAAQ,aAAa,IAAI,KAAK,GAAG,GAAG,aAAa;AACpE,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,QAAQ,IAAI,CAAC;AACnB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../../../../src/runtimes/react/controls/rich-text-v2/EditableTextV2/useSyncDOMSelection.tsx"],"sourcesContent":["import { Editor, Range as SlateRange } from 'slate'\nimport { useIsomorphicLayoutEffect } from '../../../../../components/hooks/useIsomorphicLayoutEffect'\nimport { MutableRefObject } from 'react'\nimport { ReactEditor } from 'slate-react'\n\n/**\n * Clicking outside of the host blurs our `<Editable />`.\n * `<Editable />` only updates the DOM's selection to match slate when it is focused.\n * In the case of a panel being clicked this hook updates the DOM selection to match slate.\n */\nexport function useSyncDOMSelection(editor: Editor, isEnabled: MutableRefObject<boolean>) {\n useIsomorphicLayoutEffect(() => {\n if (!isEnabled.current || editor.selection == null || ReactEditor.isFocused(editor)) return\n try {\n const root = ReactEditor.findDocumentOrShadowRoot(editor) as Document\n const domSelection = root.getSelection()\n const newDomRange: Range | null = ReactEditor.toDOMRange(editor, editor.selection)\n\n if (newDomRange) {\n if (SlateRange.isBackward(editor.selection!)) {\n domSelection?.setBaseAndExtent(\n newDomRange.endContainer,\n newDomRange.endOffset,\n newDomRange.startContainer,\n newDomRange.startOffset,\n )\n } else {\n domSelection?.setBaseAndExtent(\n newDomRange.startContainer,\n newDomRange.startOffset,\n newDomRange.endContainer,\n newDomRange.endOffset,\n )\n }\n } else {\n domSelection?.removeAllRanges()\n }\n } catch (e) {\n console.error(e)\n }\n })\n}\n"],"mappings":"AAAA,SAAiB,SAAS,kBAAkB;AAC5C,SAAS,iCAAiC;AAE1C,SAAS,mBAAmB;AAOrB,SAAS,oBAAoB,QAAgB,WAAsC;AACxF,4BAA0B,MAAM;AAC9B,QAAI,CAAC,UAAU,WAAW,OAAO,aAAa,QAAQ,YAAY,UAAU,MAAM;AAAG;AACrF,QAAI;AACF,YAAM,OAAO,YAAY,yBAAyB,MAAM;AACxD,YAAM,eAAe,KAAK,aAAa;AACvC,YAAM,cAA4B,YAAY,WAAW,QAAQ,OAAO,SAAS;AAEjF,UAAI,aAAa;AACf,YAAI,WAAW,WAAW,OAAO,SAAU,GAAG;AAC5C,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF,OAAO;AACL,wBAAc;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,YACZ,YAAY;AAAA,UACd;AAAA,QACF;AAAA,MACF,OAAO;AACL,sBAAc,gBAAgB;AAAA,MAChC;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AAAA,IACjB;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"names":[],"mappings":"AAUA,KAAK,KAAK,GAAG;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AA2BD,QAAA,MAAM,KAAK,kGA6ET,CAAA;AAEF,eAAe,KAAK,CAAA"}
1
+ {"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../../../../src/components/builtin/Embed/Embed.tsx"],"names":[],"mappings":"AAUA,KAAK,KAAK,GAAG;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AA2BD,QAAA,MAAM,KAAK,kGAoFT,CAAA;AAEF,eAAe,KAAK,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.28.8-canary.7",
3
+ "version": "0.28.8-canary.8",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "url": "makeswift/makeswift",