@webstudio-is/react-sdk 0.7.0 → 0.7.2

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.
Files changed (187) hide show
  1. package/lib/arg-types/utils.d.ts +4 -18
  2. package/lib/arg-types/utils.d.ts.map +1 -1
  3. package/lib/arg-types/utils.js +23 -16
  4. package/lib/component-utils/image.d.ts +107 -0
  5. package/lib/component-utils/image.d.ts.map +1 -0
  6. package/lib/component-utils/image.js +198 -0
  7. package/lib/component-utils/image.test.d.ts +2 -0
  8. package/lib/component-utils/image.test.d.ts.map +1 -0
  9. package/lib/component-utils/image.test.js +132 -0
  10. package/lib/components/body.props.json +104 -1847
  11. package/lib/components/body.stories.d.ts +2 -2
  12. package/lib/components/body.stories.d.ts.map +1 -1
  13. package/lib/components/body.stories.js +0 -5
  14. package/lib/components/bold.d.ts +2 -2
  15. package/lib/components/bold.d.ts.map +1 -1
  16. package/lib/components/bold.props.json +104 -1847
  17. package/lib/components/bold.stories.d.ts +3 -3
  18. package/lib/components/bold.stories.d.ts.map +1 -1
  19. package/lib/components/bold.stories.js +0 -5
  20. package/lib/components/box.props.json +108 -1899
  21. package/lib/components/box.stories.d.ts +5 -5
  22. package/lib/components/box.stories.d.ts.map +1 -1
  23. package/lib/components/box.stories.js +0 -5
  24. package/lib/components/button.d.ts +2 -2
  25. package/lib/components/button.d.ts.map +1 -1
  26. package/lib/components/button.props.json +117 -2065
  27. package/lib/components/button.stories.d.ts +3 -3
  28. package/lib/components/button.stories.d.ts.map +1 -1
  29. package/lib/components/button.stories.js +0 -5
  30. package/lib/components/component-type.d.ts +1 -1
  31. package/lib/components/component-type.d.ts.map +1 -1
  32. package/lib/components/form.d.ts +2 -2
  33. package/lib/components/form.d.ts.map +1 -1
  34. package/lib/components/form.props.json +112 -1991
  35. package/lib/components/form.stories.d.ts +3 -3
  36. package/lib/components/form.stories.d.ts.map +1 -1
  37. package/lib/components/form.stories.js +0 -5
  38. package/lib/components/heading.props.json +107 -1893
  39. package/lib/components/heading.stories.d.ts +5 -5
  40. package/lib/components/heading.stories.d.ts.map +1 -1
  41. package/lib/components/heading.stories.js +0 -5
  42. package/lib/components/image-dev.stories.d.ts +36 -0
  43. package/lib/components/image-dev.stories.d.ts.map +1 -0
  44. package/lib/components/image-dev.stories.js +102 -0
  45. package/lib/components/image.d.ts +10 -2
  46. package/lib/components/image.d.ts.map +1 -1
  47. package/lib/components/image.js +19 -9
  48. package/lib/components/image.props.json +140 -2098
  49. package/lib/components/image.stories.d.ts +11 -3
  50. package/lib/components/image.stories.d.ts.map +1 -1
  51. package/lib/components/image.stories.js +0 -5
  52. package/lib/components/image.ws.d.ts.map +1 -1
  53. package/lib/components/image.ws.js +15 -0
  54. package/lib/components/index.d.ts +3 -0
  55. package/lib/components/index.d.ts.map +1 -1
  56. package/lib/components/index.js +7 -1
  57. package/lib/components/input.d.ts +2 -2
  58. package/lib/components/input.d.ts.map +1 -1
  59. package/lib/components/input.props.json +138 -2474
  60. package/lib/components/input.stories.d.ts +3 -3
  61. package/lib/components/input.stories.d.ts.map +1 -1
  62. package/lib/components/input.stories.js +0 -5
  63. package/lib/components/italic.d.ts +2 -2
  64. package/lib/components/italic.d.ts.map +1 -1
  65. package/lib/components/italic.props.json +104 -1847
  66. package/lib/components/italic.stories.d.ts +3 -3
  67. package/lib/components/italic.stories.d.ts.map +1 -1
  68. package/lib/components/italic.stories.js +0 -5
  69. package/lib/components/link.d.ts +2 -2
  70. package/lib/components/link.d.ts.map +1 -1
  71. package/lib/components/link.props.json +116 -2040
  72. package/lib/components/link.stories.d.ts +5 -5
  73. package/lib/components/link.stories.d.ts.map +1 -1
  74. package/lib/components/link.stories.js +0 -5
  75. package/lib/components/meta.d.ts +7469 -12
  76. package/lib/components/meta.d.ts.map +1 -1
  77. package/lib/components/meta.js +34 -25
  78. package/lib/components/paragraph.d.ts +2 -2
  79. package/lib/components/paragraph.d.ts.map +1 -1
  80. package/lib/components/paragraph.props.json +104 -1847
  81. package/lib/components/paragraph.stories.d.ts +3 -3
  82. package/lib/components/paragraph.stories.d.ts.map +1 -1
  83. package/lib/components/paragraph.stories.js +0 -5
  84. package/lib/components/span.d.ts +3 -0
  85. package/lib/components/span.d.ts.map +1 -0
  86. package/lib/components/span.js +8 -0
  87. package/lib/components/span.props.json +491 -0
  88. package/lib/components/span.stories.d.ts +6 -0
  89. package/lib/components/span.stories.d.ts.map +1 -0
  90. package/lib/components/span.stories.js +14 -0
  91. package/lib/components/span.ws.d.ts +5 -0
  92. package/lib/components/span.ws.d.ts.map +1 -0
  93. package/lib/components/span.ws.js +14 -0
  94. package/lib/components/subscript.d.ts +3 -0
  95. package/lib/components/subscript.d.ts.map +1 -0
  96. package/lib/components/subscript.js +8 -0
  97. package/lib/components/subscript.props.json +491 -0
  98. package/lib/components/subscript.stories.d.ts +6 -0
  99. package/lib/components/subscript.stories.d.ts.map +1 -0
  100. package/lib/components/subscript.stories.js +14 -0
  101. package/lib/components/subscript.ws.d.ts +5 -0
  102. package/lib/components/subscript.ws.d.ts.map +1 -0
  103. package/lib/components/subscript.ws.js +14 -0
  104. package/lib/components/superscript.d.ts +3 -0
  105. package/lib/components/superscript.d.ts.map +1 -0
  106. package/lib/components/superscript.js +8 -0
  107. package/lib/components/superscript.props.json +491 -0
  108. package/lib/components/superscript.stories.d.ts +6 -0
  109. package/lib/components/superscript.stories.d.ts.map +1 -0
  110. package/lib/components/superscript.stories.js +14 -0
  111. package/lib/components/superscript.ws.d.ts +5 -0
  112. package/lib/components/superscript.ws.d.ts.map +1 -0
  113. package/lib/components/superscript.ws.js +14 -0
  114. package/lib/components/text-block.d.ts +2 -2
  115. package/lib/components/text-block.d.ts.map +1 -1
  116. package/lib/components/text-block.props.json +104 -1847
  117. package/lib/components/text-block.stories.d.ts +3 -3
  118. package/lib/components/text-block.stories.d.ts.map +1 -1
  119. package/lib/components/text-block.stories.js +0 -5
  120. package/lib/css/breakpoints.d.ts +1 -1
  121. package/lib/css/breakpoints.d.ts.map +1 -1
  122. package/lib/css/categories.d.ts +2 -2
  123. package/lib/css/get-browser-style.d.ts +1 -1
  124. package/lib/css/get-browser-style.d.ts.map +1 -1
  125. package/lib/css/get-browser-style.js +10 -5
  126. package/lib/css/index.d.ts +0 -5
  127. package/lib/css/index.d.ts.map +1 -1
  128. package/lib/css/index.js +0 -5
  129. package/lib/db/instance.d.ts +1 -1
  130. package/lib/db/instance.d.ts.map +1 -1
  131. package/lib/db/instance.js +2 -2
  132. package/lib/index.d.ts +1 -2
  133. package/lib/index.d.ts.map +1 -1
  134. package/lib/index.js +2 -3
  135. package/lib/pubsub/create.d.ts +1 -0
  136. package/lib/pubsub/create.d.ts.map +1 -1
  137. package/lib/pubsub/create.js +8 -0
  138. package/lib/remix/handle-request.server.d.ts.map +1 -1
  139. package/lib/remix/handle-request.server.js +1 -2
  140. package/lib/remix/root.d.ts.map +1 -1
  141. package/lib/remix/root.js +2 -2
  142. package/lib/tree/create-elements-tree.d.ts +7 -11
  143. package/lib/tree/create-elements-tree.d.ts.map +1 -1
  144. package/lib/tree/create-elements-tree.js +5 -10
  145. package/lib/tree/root.d.ts +4 -6
  146. package/lib/tree/root.d.ts.map +1 -1
  147. package/lib/tree/root.js +1 -23
  148. package/lib/tree/session-storage-polyfill.d.ts +2 -0
  149. package/lib/tree/session-storage-polyfill.d.ts.map +1 -0
  150. package/lib/tree/session-storage-polyfill.js +39 -0
  151. package/lib/tree/wrapper-component.d.ts +4 -4
  152. package/lib/tree/wrapper-component.d.ts.map +1 -1
  153. package/lib/tree/wrapper-component.js +5 -5
  154. package/package.json +21 -13
  155. package/lib/css/keyword-values.d.ts +0 -302
  156. package/lib/css/keyword-values.d.ts.map +0 -1
  157. package/lib/css/keyword-values.js +0 -6619
  158. package/lib/css/properties.d.ts +0 -3199
  159. package/lib/css/properties.d.ts.map +0 -1
  160. package/lib/css/properties.js +0 -3202
  161. package/lib/css/schema.d.ts +0 -283
  162. package/lib/css/schema.d.ts.map +0 -1
  163. package/lib/css/schema.js +0 -48
  164. package/lib/css/types.d.ts +0 -6
  165. package/lib/css/types.d.ts.map +0 -1
  166. package/lib/css/types.js +0 -2
  167. package/lib/css/units.d.ts +0 -2
  168. package/lib/css/units.d.ts.map +0 -1
  169. package/lib/css/units.js +0 -35
  170. package/lib/remix/constants.d.ts +0 -2
  171. package/lib/remix/constants.d.ts.map +0 -1
  172. package/lib/remix/constants.js +0 -4
  173. package/lib/remix/insert-critical-css.d.ts +0 -2
  174. package/lib/remix/insert-critical-css.d.ts.map +0 -1
  175. package/lib/remix/insert-critical-css.js +0 -9
  176. package/lib/stitches/index.d.ts +0 -3
  177. package/lib/stitches/index.d.ts.map +0 -1
  178. package/lib/stitches/index.js +0 -18
  179. package/lib/stitches/stitches.d.ts +0 -8
  180. package/lib/stitches/stitches.d.ts.map +0 -1
  181. package/lib/stitches/stitches.js +0 -38
  182. package/lib/stitches/to-css.d.ts +0 -8
  183. package/lib/stitches/to-css.d.ts.map +0 -1
  184. package/lib/stitches/to-css.js +0 -52
  185. package/lib/stitches/to-css.test.d.ts +0 -2
  186. package/lib/stitches/to-css.test.d.ts.map +0 -1
  187. package/lib/stitches/to-css.test.js +0 -82
@@ -1,6 +1,6 @@
1
- import React from "react";
1
+ /// <reference types="react" />
2
2
  import type { ComponentStory, ComponentMeta } from "@storybook/react";
3
- declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>>;
3
+ declare const _default: ComponentMeta<import("react").ForwardRefExoticComponent<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & import("react").RefAttributes<HTMLDivElement>>>;
4
4
  export default _default;
5
- export declare const TextBlock: ComponentStory<React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>>>;
5
+ export declare const TextBlock: ComponentStory<import("react").ForwardRefExoticComponent<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & import("react").RefAttributes<HTMLDivElement>>>;
6
6
  //# sourceMappingURL=text-block.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-block.stories.d.ts","sourceRoot":"","sources":["../../src/components/text-block.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;AAItE,wBAI8C;AAM9C,eAAO,MAAM,SAAS,gOAAoB,CAAC"}
1
+ {"version":3,"file":"text-block.stories.d.ts","sourceRoot":"","sources":["../../src/components/text-block.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;AAGtE,wBAG8C;AAM9C,eAAO,MAAM,SAAS,kRAAoB,CAAC"}
@@ -1,16 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.TextBlock = void 0;
7
4
  const jsx_runtime_1 = require("react/jsx-runtime");
8
5
  const text_block_1 = require("./text-block");
9
- const text_block_props_json_1 = __importDefault(require("./text-block.props.json"));
10
6
  exports.default = {
11
7
  title: "Components/TextBlock",
12
8
  component: text_block_1.TextBlock,
13
- argTypes: text_block_props_json_1.default,
14
9
  };
15
10
  const Template = (args) => ((0, jsx_runtime_1.jsx)(text_block_1.TextBlock, { ...args }));
16
11
  exports.TextBlock = Template.bind({});
@@ -1,4 +1,4 @@
1
- import { type Breakpoint } from "./schema";
1
+ import type { Breakpoint } from "@webstudio-is/css-data";
2
2
  export declare type BaseBreakpoint = Pick<Breakpoint, "label" | "minWidth">;
3
3
  export declare const initialBreakpoints: Array<BaseBreakpoint>;
4
4
  //# sourceMappingURL=breakpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../src/css/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,oBAAY,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AAEpE,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,cAAc,CAKpD,CAAC"}
1
+ {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../src/css/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AAEpE,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,cAAc,CAKpD,CAAC"}
@@ -56,8 +56,6 @@ export declare const categories: {
56
56
  };
57
57
  };
58
58
  export declare const propertyCategoryMap: {
59
- clip: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
60
- top: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
61
59
  accentColor: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
62
60
  alignContent: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
63
61
  alignItems: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
@@ -142,6 +140,7 @@ export declare const propertyCategoryMap: {
142
140
  captionSide: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
143
141
  caretColor: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
144
142
  clear: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
143
+ clip: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
145
144
  clipPath: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
146
145
  color: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
147
146
  colorAdjust: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
@@ -380,6 +379,7 @@ export declare const propertyCategoryMap: {
380
379
  textTransform: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
381
380
  textUnderlineOffset: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
382
381
  textUnderlinePosition: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
382
+ top: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
383
383
  touchAction: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
384
384
  transform: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
385
385
  transformBox: "position" | "layout" | "flexChild" | "gridChild" | "spacing" | "size" | "typography" | "backgrounds" | "borders" | "effects" | "other";
@@ -1,3 +1,3 @@
1
- import type { Style } from "./schema";
1
+ import type { Style } from "@webstudio-is/css-data";
2
2
  export declare const getBrowserStyle: (element?: Element) => Style;
3
3
  //# sourceMappingURL=get-browser-style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-browser-style.d.ts","sourceRoot":"","sources":["../../src/css/get-browser-style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAoB,MAAM,UAAU,CAAC;AA6BxD,eAAO,MAAM,eAAe,aAAc,OAAO,KAAG,KAYnD,CAAC"}
1
+ {"version":3,"file":"get-browser-style.d.ts","sourceRoot":"","sources":["../../src/css/get-browser-style.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,KAAK,EAGN,MAAM,wBAAwB,CAAC;AA4BhC,eAAO,MAAM,eAAe,aAAc,OAAO,KAAG,KAiBnD,CAAC"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBrowserStyle = void 0;
4
- const properties_1 = require("./properties");
5
- const units_1 = require("./units");
6
- const unitRegex = new RegExp(`${units_1.units.join("|")}`);
4
+ const detect_font_1 = require("detect-font");
5
+ const css_data_1 = require("@webstudio-is/css-data");
6
+ const unitRegex = new RegExp(`${css_data_1.units.join("|")}`);
7
7
  // @todo use a parser
8
8
  const parseValue = (property, value) => {
9
9
  const number = parseFloat(value);
@@ -17,7 +17,7 @@ const parseValue = (property, value) => {
17
17
  };
18
18
  }
19
19
  if (number === 0) {
20
- return properties_1.properties[property].initial;
20
+ return css_data_1.properties[property].initial;
21
21
  }
22
22
  return {
23
23
  type: "unit",
@@ -31,13 +31,18 @@ const getBrowserStyle = (element) => {
31
31
  return browserStyle;
32
32
  let knownProperty;
33
33
  const computedStyle = getComputedStyle(element);
34
- for (knownProperty in properties_1.properties) {
34
+ for (knownProperty in css_data_1.properties) {
35
35
  if (knownProperty in computedStyle === false)
36
36
  continue;
37
37
  // Typescript doesn't know we can access CSSStyleDeclaration properties by keys
38
38
  const computedValue = computedStyle[knownProperty];
39
39
  browserStyle[knownProperty] = parseValue(knownProperty, computedValue);
40
40
  }
41
+ // We need a single font-family that is actually rendered. Computed style will return a list of potential fonts.
42
+ browserStyle.fontFamily = {
43
+ type: "fontFamily",
44
+ value: [(0, detect_font_1.detectFont)(element)],
45
+ };
41
46
  return browserStyle;
42
47
  };
43
48
  exports.getBrowserStyle = getBrowserStyle;
@@ -1,9 +1,4 @@
1
- export * from "./properties";
2
- export * from "./units";
3
- export * from "./types";
4
- export * from "./schema";
5
1
  export * from "./get-browser-style";
6
2
  export * from "./categories";
7
- export * from "./keyword-values";
8
3
  export * from "./breakpoints";
9
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/css/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/css/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
package/lib/css/index.js CHANGED
@@ -14,11 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./properties"), exports);
18
- __exportStar(require("./units"), exports);
19
- __exportStar(require("./types"), exports);
20
- __exportStar(require("./schema"), exports);
21
17
  __exportStar(require("./get-browser-style"), exports);
22
18
  __exportStar(require("./categories"), exports);
23
- __exportStar(require("./keyword-values"), exports);
24
19
  __exportStar(require("./breakpoints"), exports);
@@ -1,6 +1,6 @@
1
+ import { CssRule } from "@webstudio-is/css-data";
1
2
  import { z } from "zod";
2
3
  import * as components from "../components";
3
- import { CssRule } from "../css";
4
4
  export declare type BaseInstance = {
5
5
  id: string;
6
6
  component: keyof typeof components;
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/db/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAIjC,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,UAAU,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,QAAQ,GAAG,YAAY,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,YAMnD,CAAC;AAEF,eAAO,MAAM,QAAQ,6CASG,CAAC"}
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/db/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAI5C,oBAAY,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,OAAO,UAAU,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,QAAQ,GAAG,YAAY,GAAG;IACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,YAMnD,CAAC;AAEF,eAAO,MAAM,QAAQ,6CASG,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Instance = exports.toBaseInstance = void 0;
4
+ const css_data_1 = require("@webstudio-is/css-data");
4
5
  const zod_1 = require("zod");
5
- const css_1 = require("../css");
6
6
  const toBaseInstance = (instance) => {
7
7
  return {
8
8
  id: instance.id,
@@ -15,7 +15,7 @@ exports.Instance = zod_1.z.lazy(() => zod_1.z.object({
15
15
  id: zod_1.z.string(),
16
16
  component: zod_1.z.string(),
17
17
  children: zod_1.z.array(zod_1.z.union([exports.Instance, zod_1.z.string()])),
18
- cssRules: zod_1.z.array(css_1.CssRule),
18
+ cssRules: zod_1.z.array(css_data_1.CssRule),
19
19
  })
20
20
  // @todo can't figure out how to make component to be z.enum(Object.keys(components))
21
21
  );
package/lib/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  export * from "./css";
2
2
  export * from "./tree";
3
- export * from "./stitches";
4
3
  export * as components from "./components";
5
- export * as componentsMeta from "./components/meta";
4
+ export * from "./components/meta";
6
5
  export * from "./user-props";
7
6
  export * from "./pubsub";
8
7
  export * from "./db";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC"}
package/lib/index.js CHANGED
@@ -26,12 +26,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.componentsMeta = exports.components = void 0;
29
+ exports.components = void 0;
30
30
  __exportStar(require("./css"), exports);
31
31
  __exportStar(require("./tree"), exports);
32
- __exportStar(require("./stitches"), exports);
33
32
  exports.components = __importStar(require("./components"));
34
- exports.componentsMeta = __importStar(require("./components/meta"));
33
+ __exportStar(require("./components/meta"), exports);
35
34
  __exportStar(require("./user-props"), exports);
36
35
  __exportStar(require("./pubsub"), exports);
37
36
  __exportStar(require("./db"), exports);
@@ -24,5 +24,6 @@ export declare const createPubsub: <PublishMap>() => {
24
24
  * To subscribe a message event on the current window.
25
25
  */
26
26
  useSubscribe<Type_2 extends keyof PublishMap>(type: Type_2, onAction: (payload: PublishMap[Type_2]) => void): void;
27
+ useSubscribeAll(onAction: <Type_3 extends keyof PublishMap>(type: Type_3, payload: PublishMap[Type_3]) => void): void;
27
28
  };
28
29
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/pubsub/create.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;IA0BrB;;OAEG;;;;;;;;IAMH;;OAEG;;;;;;;;IAeH;;OAEG;2GAGwC,IAAI;CAUlD,CAAC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/pubsub/create.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;IA0BrB;;OAEG;;;;;;;;IAMH;;OAEG;;;;;;;;IAeH;;OAEG;2GAGwC,IAAI;8GAcxC,IAAI;CAUd,CAAC"}
@@ -53,6 +53,14 @@ const createPubsub = () => {
53
53
  };
54
54
  }, [type, onAction]);
55
55
  },
56
+ useSubscribeAll(onAction) {
57
+ (0, react_1.useEffect)(() => {
58
+ emitter.on("*", onAction);
59
+ return () => {
60
+ emitter.off("*", onAction);
61
+ };
62
+ }, [onAction]);
63
+ },
56
64
  };
57
65
  };
58
66
  exports.createPubsub = createPubsub;
@@ -1 +1 @@
1
- {"version":3,"file":"handle-request.server.d.ts","sourceRoot":"","sources":["../../src/remix/handle-request.server.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,eAAO,MAAM,aAAa,YACf,OAAO,sBACI,MAAM,mBACT,OAAO,gBACV,YAAY,aAY3B,CAAC"}
1
+ {"version":3,"file":"handle-request.server.d.ts","sourceRoot":"","sources":["../../src/remix/handle-request.server.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,aAAa,YACf,OAAO,sBACI,MAAM,mBACT,OAAO,gBACV,YAAY,aAY3B,CAAC"}
@@ -4,11 +4,10 @@ exports.handleRequest = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const server_1 = require("react-dom/server");
6
6
  const react_1 = require("@remix-run/react");
7
- const insert_critical_css_1 = require("./insert-critical-css");
8
7
  const handleRequest = (request, responseStatusCode, responseHeaders, remixContext) => {
9
8
  const markup = (0, server_1.renderToString)((0, jsx_runtime_1.jsx)(react_1.RemixServer, { context: remixContext, url: request.url }));
10
9
  responseHeaders.set("Content-Type", "text/html");
11
- return new Response("<!DOCTYPE html>" + (0, insert_critical_css_1.insertCriticalCss)(markup), {
10
+ return new Response(`<!DOCTYPE html>${markup}`, {
12
11
  status: responseStatusCode,
13
12
  headers: responseHeaders,
14
13
  });
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/remix/root.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;GAEG;AACH,eAAO,MAAM,IAAI;YAGP,oBAAoB;iBAgB7B,CAAC"}
1
+ {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/remix/root.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;GAEG;AACH,eAAO,MAAM,IAAI;YAGP,oBAAoB;iBAiB7B,CAAC"}
package/lib/remix/root.js CHANGED
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Root = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("@remix-run/react");
6
- const constants_1 = require("./constants");
6
+ const remix_utils_1 = require("remix-utils");
7
7
  /**
8
8
  * We are using Outlet prop from index layout when user renders site from a subdomain.
9
9
  */
10
10
  const Root = ({ Outlet = react_1.Outlet, }) => {
11
- return ((0, jsx_runtime_1.jsxs)("html", { lang: "en", children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width,initial-scale=1" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)("link", { rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.Links, {}), typeof document === "undefined" ? constants_1.CRITICAL_CSS_MARKER : null] }), (0, jsx_runtime_1.jsx)(Outlet, {})] }));
11
+ return ((0, jsx_runtime_1.jsxs)("html", { lang: "en", children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width,initial-scale=1" }), (0, jsx_runtime_1.jsx)("link", { rel: "icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)("link", { rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon" }), (0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(remix_utils_1.DynamicLinks, {}), (0, jsx_runtime_1.jsx)(react_1.Links, {})] }), (0, jsx_runtime_1.jsx)(Outlet, {})] }));
12
12
  };
13
13
  exports.Root = Root;
@@ -1,23 +1,19 @@
1
+ import { type ComponentProps } from "react";
1
2
  import type { Instance } from "../db";
2
- import type { Breakpoint } from "../css";
3
- import { type WrapperComponentProps } from "./wrapper-component";
3
+ import { WrapperComponent } from "./wrapper-component";
4
4
  export declare type ChildrenUpdates = Array<string | {
5
- id: Instance["id"];
6
- text: string;
7
- } | {
8
- id: Instance["id"];
9
- text: string;
5
+ id: undefined | Instance["id"];
10
6
  component: Instance["component"];
11
- createInstance: true;
7
+ children: ChildrenUpdates;
12
8
  }>;
13
9
  export declare type OnChangeChildren = (change: {
14
10
  instanceId: Instance["id"];
15
11
  updates: ChildrenUpdates;
16
12
  }) => void;
17
- export declare const createElementsTree: ({ instance, breakpoints, Component, onChangeChildren, }: {
13
+ export declare const createElementsTree: ({ sandbox, instance, Component, onChangeChildren, }: {
14
+ sandbox?: boolean | undefined;
18
15
  instance: Instance;
19
- breakpoints: Array<Breakpoint>;
20
- Component: (props: WrapperComponentProps) => JSX.Element;
16
+ Component: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
21
17
  onChangeChildren?: OnChangeChildren | undefined;
22
18
  }) => JSX.Element;
23
19
  //# sourceMappingURL=create-elements-tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-elements-tree.d.ts","sourceRoot":"","sources":["../../src/tree/create-elements-tree.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGjE,oBAAY,eAAe,GAAG,KAAK,CAC/B,MAAM,GAEN;IAAE,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAEpC;IACE,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,cAAc,EAAE,IAAI,CAAC;CACtB,CACJ,CAAC;AAEF,oBAAY,gBAAgB,GAAG,CAAC,MAAM,EAAE;IACtC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,eAAe,CAAC;CAC1B,KAAK,IAAI,CAAC;AAEX,eAAO,MAAM,kBAAkB;cAMnB,QAAQ;iBACL,MAAM,UAAU,CAAC;uBACX,qBAAqB,KAAK,WAAW;;iBAsBzD,CAAC"}
1
+ {"version":3,"file":"create-elements-tree.d.ts","sourceRoot":"","sources":["../../src/tree/create-elements-tree.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,oBAAY,eAAe,GAAG,KAAK,CAC/B,MAAM,GACN;IACE,EAAE,EAAE,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,QAAQ,EAAE,eAAe,CAAC;CAC3B,CACJ,CAAC;AAEF,oBAAY,gBAAgB,GAAG,CAAC,MAAM,EAAE;IACtC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,eAAe,CAAC;CAC1B,KAAK,IAAI,CAAC;AAEX,eAAO,MAAM,kBAAkB;;cAOnB,QAAQ;uBACC,eAAe,uBAAuB,CAAC,KAAK,WAAW;;iBAqB3E,CAAC"}
@@ -3,27 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createElementsTree = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
- const stitches_1 = require("../stitches");
7
6
  const react_2 = require("@remix-run/react");
8
- const createElementsTree = ({ instance, breakpoints, Component, onChangeChildren, }) => {
7
+ const session_storage_polyfill_1 = require("./session-storage-polyfill");
8
+ const createElementsTree = ({ sandbox, instance, Component, onChangeChildren, }) => {
9
9
  const children = createInstanceChildrenElements({
10
10
  Component,
11
11
  children: instance.children,
12
- breakpoints,
13
12
  onChangeChildren,
14
13
  });
15
14
  const body = createInstanceElement({
16
15
  Component,
17
16
  instance,
18
17
  children: [
19
- (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [children, (0, jsx_runtime_1.jsx)(react_2.ScrollRestoration, {}), (0, jsx_runtime_1.jsx)(react_2.Scripts, {})] }, "children"),
18
+ (0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [children, sandbox && (0, jsx_runtime_1.jsx)(session_storage_polyfill_1.SessionStoragePolyfill, {}), (0, jsx_runtime_1.jsx)(react_2.ScrollRestoration, {}), (0, jsx_runtime_1.jsx)(react_2.Scripts, {})] }, "children"),
20
19
  ],
21
- breakpoints,
22
20
  });
23
21
  return body;
24
22
  };
25
23
  exports.createElementsTree = createElementsTree;
26
- const createInstanceChildrenElements = ({ children, breakpoints, Component, onChangeChildren, }) => {
24
+ const createInstanceChildrenElements = ({ children, Component, onChangeChildren, }) => {
27
25
  const elements = [];
28
26
  for (const child of children) {
29
27
  if (typeof child === "string") {
@@ -32,13 +30,11 @@ const createInstanceChildrenElements = ({ children, breakpoints, Component, onCh
32
30
  }
33
31
  const children = createInstanceChildrenElements({
34
32
  children: child.children,
35
- breakpoints,
36
33
  Component,
37
34
  onChangeChildren,
38
35
  });
39
36
  const element = createInstanceElement({
40
37
  instance: child,
41
- breakpoints,
42
38
  Component,
43
39
  onChangeChildren,
44
40
  children,
@@ -47,11 +43,10 @@ const createInstanceChildrenElements = ({ children, breakpoints, Component, onCh
47
43
  }
48
44
  return elements;
49
45
  };
50
- const createInstanceElement = ({ Component, instance, children = [], breakpoints, onChangeChildren, }) => {
46
+ const createInstanceElement = ({ Component, instance, children = [], onChangeChildren, }) => {
51
47
  const props = {
52
48
  instance,
53
49
  children,
54
- css: (0, stitches_1.toCss)(instance.cssRules, breakpoints),
55
50
  key: instance.id,
56
51
  onChangeChildren,
57
52
  };
@@ -1,19 +1,17 @@
1
1
  import type { Tree, InstanceProps } from "../db";
2
- import type { Breakpoint } from "../css";
3
- import { type WrapperComponentProps } from "./wrapper-component";
2
+ import { WrapperComponent } from "./wrapper-component";
4
3
  import type { Asset } from "@webstudio-is/asset-uploader";
4
+ import { type ComponentProps } from "react";
5
+ import type { Breakpoint } from "@webstudio-is/css-data";
5
6
  export declare type Data = {
6
7
  tree: Tree | null;
7
8
  breakpoints: Array<Breakpoint>;
8
9
  props: Array<InstanceProps>;
9
10
  assets: Array<Asset>;
10
11
  };
11
- export declare const useGlobalStyles: ({ assets }: {
12
- assets: Array<Asset>;
13
- }) => void;
14
12
  declare type RootProps = {
15
13
  data: Data;
16
- Component?: (props: WrapperComponentProps) => JSX.Element;
14
+ Component?: (props: ComponentProps<typeof WrapperComponent>) => JSX.Element;
17
15
  };
18
16
  export declare const InstanceRoot: ({ data, Component, }: RootProps) => JSX.Element | null;
19
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/tree/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,8BAA8B,CAAC;AAGrE,oBAAY,IAAI,GAAG;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe;YAA0B,MAAM,KAAK,CAAC;UAmBjE,CAAC;AAEF,aAAK,SAAS,GAAG;IACf,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,GAAG,CAAC,OAAO,CAAC;CAC3D,CAAC;AAEF,eAAO,MAAM,YAAY,yBAGtB,SAAS,KAAG,WAAW,GAAG,IAY5B,CAAC"}
1
+ {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/tree/root.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,IAAI,GAAG;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACtB,CAAC;AAEF,aAAK,SAAS,GAAG;IACf,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,OAAO,gBAAgB,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;CAC7E,CAAC;AAEF,eAAO,MAAM,YAAY,yBAGtB,SAAS,KAAG,WAAW,GAAG,IAS5B,CAAC"}
package/lib/tree/root.js CHANGED
@@ -1,38 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InstanceRoot = exports.useGlobalStyles = void 0;
3
+ exports.InstanceRoot = void 0;
4
4
  const user_props_1 = require("../user-props/");
5
- const stitches_1 = require("../stitches");
6
5
  const create_elements_tree_1 = require("./create-elements-tree");
7
6
  const wrapper_component_1 = require("./wrapper-component");
8
- const fonts_1 = require("@webstudio-is/fonts");
9
- const react_1 = require("react");
10
- const useGlobalStyles = ({ assets }) => {
11
- const ref = (0, react_1.useRef)();
12
- // This may look weird, but globalCss API doesn't allow us creating global styles with data,
13
- // so we have to manually ensure calling it only once
14
- if (ref.current === assets)
15
- return;
16
- const fontAssets = assets.filter((asset) => fonts_1.FONT_FORMATS.has(asset.format));
17
- (0, stitches_1.globalCss)({
18
- "@font-face": (0, fonts_1.getFontFaces)(fontAssets),
19
- html: {
20
- height: "100%",
21
- },
22
- })();
23
- ref.current = assets;
24
- };
25
- exports.useGlobalStyles = useGlobalStyles;
26
7
  const InstanceRoot = ({ data, Component, }) => {
27
8
  if (data.tree === null) {
28
9
  throw new Error("Tree is null");
29
10
  }
30
- (0, stitches_1.setBreakpoints)(data.breakpoints);
31
- (0, exports.useGlobalStyles)({ assets: data.assets });
32
11
  (0, user_props_1.useAllUserProps)(data.props);
33
12
  return (0, create_elements_tree_1.createElementsTree)({
34
13
  instance: data.tree.root,
35
- breakpoints: data.breakpoints,
36
14
  Component: Component ?? wrapper_component_1.WrapperComponent,
37
15
  });
38
16
  };
@@ -0,0 +1,2 @@
1
+ export declare const SessionStoragePolyfill: () => JSX.Element;
2
+ //# sourceMappingURL=session-storage-polyfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-storage-polyfill.d.ts","sourceRoot":"","sources":["../../src/tree/session-storage-polyfill.tsx"],"names":[],"mappings":"AA4CA,eAAO,MAAM,sBAAsB,mBAKlC,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SessionStoragePolyfill = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // This is a temporary work around for https://github.com/remix-run/remix/issues/3659
6
+ // The code is based on this discussion https://bugs.chromium.org/p/chromium/issues/detail?id=357625
7
+ const polyfill = function () {
8
+ try {
9
+ const key = "__session_storage_availability_test__";
10
+ sessionStorage.setItem(key, "test"); // test
11
+ sessionStorage.removeItem(key); // cleanup
12
+ }
13
+ catch (error) {
14
+ alert('It looks like you have disabled cookies in your browser. Webstudio designer may not work properly.\n\nTo enable cookies, go to "Setting" > "Privacy and security" > "Cookies and other site data", and make sure neither "Block all cookies" nor "Block third-party cookies" are selected.\n\nRead more at https://support.google.com/chrome/answer/95647');
15
+ const data = new Map();
16
+ Object.defineProperty(window, "sessionStorage", {
17
+ value: {
18
+ setItem: (key, val) => {
19
+ // eslint-disable-next-line no-console
20
+ console.warn(`Session storage is unavailable due to Error "${error.message}". A polyfill is used to set value of "${key}". The value will be lost when the page is reloaded.`);
21
+ data.set(key, String(val));
22
+ },
23
+ getItem: (key) => {
24
+ // eslint-disable-next-line no-console
25
+ console.warn(`Session storage is unavailable due to Error "${error.message}". A polyfill is used to get value of "${key}". The value will be undefined if the page was reloaded after it was set.`);
26
+ return data.get(key);
27
+ },
28
+ removeItem: (key) => {
29
+ data.delete(key);
30
+ },
31
+ clear: () => {
32
+ data.clear();
33
+ },
34
+ },
35
+ });
36
+ }
37
+ }.toString();
38
+ const SessionStoragePolyfill = () => ((0, jsx_runtime_1.jsx)("script", { dangerouslySetInnerHTML: { __html: `(${polyfill})()` }, suppressHydrationWarning: true }));
39
+ exports.SessionStoragePolyfill = SessionStoragePolyfill;
@@ -1,12 +1,12 @@
1
1
  import type { Instance } from "../db";
2
- import { type CSS } from "../stitches";
3
2
  import type { OnChangeChildren } from "./create-elements-tree";
4
3
  export declare const renderWrapperComponentChildren: (children: Array<JSX.Element | string> | undefined) => Array<JSX.Element | string | Array<JSX.Element | string>> | undefined;
5
- export declare type WrapperComponentProps = {
4
+ declare type WrapperComponentProps = {
6
5
  instance: Instance;
7
- css: CSS;
8
6
  children: Array<JSX.Element | string>;
9
7
  onChangeChildren?: OnChangeChildren;
10
8
  };
11
- export declare const WrapperComponent: ({ instance, css, onChangeChildren, children, ...rest }: WrapperComponentProps) => JSX.Element;
9
+ export declare const WrapperComponent: ({ instance, onChangeChildren, children, ...rest }: WrapperComponentProps) => JSX.Element;
10
+ export declare const idAttribute = "data-ws-id";
11
+ export {};
12
12
  //# sourceMappingURL=wrapper-component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrapper-component.d.ts","sourceRoot":"","sources":["../../src/tree/wrapper-component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,EAAE,KAAK,GAAG,EAAoB,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAY/D,eAAO,MAAM,8BAA8B,aAC/B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,SAAS,KAChD,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,GAAG,SAO9D,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IAClC,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,2DAM1B,qBAAqB,gBASvB,CAAC"}
1
+ {"version":3,"file":"wrapper-component.d.ts","sourceRoot":"","sources":["../../src/tree/wrapper-component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAY/D,eAAO,MAAM,8BAA8B,aAC/B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,SAAS,KAChD,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,WAAW,GAAG,MAAM,CAAC,CAAC,GAAG,SAO9D,CAAC;AAEF,aAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAK1B,qBAAqB,gBAOvB,CAAC;AAEF,eAAO,MAAM,WAAW,eAAe,CAAC"}
@@ -23,12 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.WrapperComponent = exports.renderWrapperComponentChildren = void 0;
26
+ exports.idAttribute = exports.WrapperComponent = exports.renderWrapperComponentChildren = void 0;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  const react_1 = require("react");
29
29
  const components = __importStar(require("../components"));
30
30
  const use_user_props_1 = require("../user-props/use-user-props");
31
- const stitches_1 = require("../stitches");
32
31
  const renderText = (text) => {
33
32
  const lines = text.split("\n");
34
33
  return lines.map((line, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [line, index < lines.length - 1 ? (0, jsx_runtime_1.jsx)("br", {}) : null] }, index)));
@@ -43,11 +42,12 @@ const renderWrapperComponentChildren = (children) => {
43
42
  });
44
43
  };
45
44
  exports.renderWrapperComponentChildren = renderWrapperComponentChildren;
46
- const WrapperComponent = ({ instance, css, onChangeChildren, // prevent it from passing to sdk component
45
+ const WrapperComponent = ({ instance, onChangeChildren, // prevent it from passing to sdk component
47
46
  children, ...rest }) => {
48
- const className = (0, react_1.useMemo)(() => (0, stitches_1.css)(css)(), [css]);
49
47
  const { Component } = components[instance.component];
50
48
  const userProps = (0, use_user_props_1.useUserProps)(instance.id);
51
- return ((0, jsx_runtime_1.jsx)(Component, { ...userProps, ...rest, id: instance.id, className: className, children: (0, exports.renderWrapperComponentChildren)(children) }));
49
+ const props = { ...userProps, ...rest, [exports.idAttribute]: instance.id };
50
+ return ((0, jsx_runtime_1.jsx)(Component, { ...props, children: (0, exports.renderWrapperComponentChildren)(children) }));
52
51
  };
53
52
  exports.WrapperComponent = WrapperComponent;
53
+ exports.idAttribute = "data-ws-id";