@webstudio-is/react-sdk 0.5.1 → 0.7.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.
Files changed (101) hide show
  1. package/lib/components/component-type.d.ts +1 -1
  2. package/lib/components/component-type.d.ts.map +1 -1
  3. package/lib/components/component-type.js +2 -2
  4. package/lib/components/image.d.ts +3 -0
  5. package/lib/components/image.d.ts.map +1 -0
  6. package/lib/components/image.js +42 -0
  7. package/lib/components/image.props.json +2533 -0
  8. package/lib/components/image.stories.d.ts +6 -0
  9. package/lib/components/image.stories.d.ts.map +1 -0
  10. package/lib/components/image.stories.js +17 -0
  11. package/lib/components/image.ws.d.ts +5 -0
  12. package/lib/components/image.ws.d.ts.map +1 -0
  13. package/lib/components/image.ws.js +14 -0
  14. package/lib/components/index.d.ts +1 -0
  15. package/lib/components/index.d.ts.map +1 -1
  16. package/lib/components/index.js +3 -1
  17. package/lib/components/index.test.js +1 -1
  18. package/lib/components/link.d.ts +1 -1
  19. package/lib/components/link.stories.d.ts +2 -2
  20. package/lib/components/meta.d.ts +1 -0
  21. package/lib/components/meta.d.ts.map +1 -1
  22. package/lib/components/meta.js +3 -1
  23. package/lib/css/breakpoints.d.ts +1 -1
  24. package/lib/css/breakpoints.d.ts.map +1 -1
  25. package/lib/css/categories.d.ts +4 -4
  26. package/lib/css/categories.js +1 -1
  27. package/lib/css/get-browser-style.d.ts +1 -1
  28. package/lib/css/get-browser-style.d.ts.map +1 -1
  29. package/lib/css/index.d.ts +1 -1
  30. package/lib/css/index.d.ts.map +1 -1
  31. package/lib/css/index.js +1 -1
  32. package/lib/css/keyword-values.d.ts.map +1 -1
  33. package/lib/css/keyword-values.js +396 -1149
  34. package/lib/css/properties.d.ts +6 -4
  35. package/lib/css/properties.d.ts.map +1 -1
  36. package/lib/css/properties.js +3196 -3194
  37. package/lib/css/schema.d.ts +142 -10
  38. package/lib/css/schema.d.ts.map +1 -1
  39. package/lib/css/schema.js +25 -15
  40. package/lib/css/types.d.ts +0 -9
  41. package/lib/css/types.d.ts.map +1 -1
  42. package/lib/css/units.js +1 -1
  43. package/lib/db/instance.d.ts +2 -2
  44. package/lib/db/instance.d.ts.map +1 -1
  45. package/lib/db/instance.js +4 -4
  46. package/lib/index.d.ts +1 -0
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js +1 -0
  49. package/lib/pubsub/create.d.ts +28 -0
  50. package/lib/pubsub/create.d.ts.map +1 -0
  51. package/lib/pubsub/create.js +58 -0
  52. package/lib/pubsub/index.d.ts +1 -2
  53. package/lib/pubsub/index.d.ts.map +1 -1
  54. package/lib/pubsub/index.js +1 -2
  55. package/lib/remix/constants.d.ts +2 -0
  56. package/lib/remix/constants.d.ts.map +1 -0
  57. package/lib/remix/constants.js +4 -0
  58. package/lib/remix/handle-request.server.d.ts +3 -0
  59. package/lib/remix/handle-request.server.d.ts.map +1 -0
  60. package/lib/remix/handle-request.server.js +16 -0
  61. package/lib/remix/index.d.ts +3 -0
  62. package/lib/remix/index.d.ts.map +1 -0
  63. package/lib/remix/index.js +18 -0
  64. package/lib/remix/insert-critical-css.d.ts +2 -0
  65. package/lib/remix/insert-critical-css.d.ts.map +1 -0
  66. package/lib/remix/insert-critical-css.js +9 -0
  67. package/lib/remix/root.d.ts +8 -0
  68. package/lib/remix/root.d.ts.map +1 -0
  69. package/lib/remix/root.js +13 -0
  70. package/lib/stitches/index.d.ts +1 -2
  71. package/lib/stitches/index.d.ts.map +1 -1
  72. package/lib/stitches/index.js +1 -2
  73. package/lib/stitches/stitches.d.ts +8 -0
  74. package/lib/stitches/stitches.d.ts.map +1 -0
  75. package/lib/stitches/{css.js → stitches.js} +12 -7
  76. package/lib/stitches/to-css.d.ts +1 -1
  77. package/lib/stitches/to-css.d.ts.map +1 -1
  78. package/lib/stitches/to-css.js +9 -0
  79. package/lib/stitches/to-css.test.js +20 -1
  80. package/lib/tree/root.d.ts +6 -2
  81. package/lib/tree/root.d.ts.map +1 -1
  82. package/lib/tree/root.js +22 -9
  83. package/lib/user-props/schema.d.ts +3 -2
  84. package/lib/user-props/schema.d.ts.map +1 -1
  85. package/lib/user-props/schema.js +3 -3
  86. package/lib/user-props/types.d.ts +1 -3
  87. package/lib/user-props/types.d.ts.map +1 -1
  88. package/lib/user-props/use-user-props.d.ts +1 -1
  89. package/lib/user-props/use-user-props.d.ts.map +1 -1
  90. package/package.json +13 -10
  91. package/lib/pubsub/publish.d.ts +0 -17
  92. package/lib/pubsub/publish.d.ts.map +0 -1
  93. package/lib/pubsub/publish.js +0 -27
  94. package/lib/pubsub/subscribe.d.ts +0 -8
  95. package/lib/pubsub/subscribe.d.ts.map +0 -1
  96. package/lib/pubsub/subscribe.js +0 -30
  97. package/lib/stitches/critical-css.d.ts +0 -4
  98. package/lib/stitches/critical-css.d.ts.map +0 -1
  99. package/lib/stitches/critical-css.js +0 -12
  100. package/lib/stitches/css.d.ts +0 -9
  101. package/lib/stitches/css.d.ts.map +0 -1
@@ -0,0 +1,8 @@
1
+ import { globalCss as globalCssImport, type CSS, css as createCss } from "@stitches/core";
2
+ import type { Breakpoint } from "../css";
3
+ export { type CSS };
4
+ export declare const css: typeof createCss;
5
+ export declare const globalCss: typeof globalCssImport;
6
+ export declare const flushCss: () => any;
7
+ export declare const setBreakpoints: (breakpoints: Array<Breakpoint>) => void;
8
+ //# sourceMappingURL=stitches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stitches.d.ts","sourceRoot":"","sources":["../../src/stitches/stitches.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,IAAI,eAAe,EAC5B,KAAK,GAAG,EACR,GAAG,IAAI,SAAS,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQzC,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC;AASpB,eAAO,MAAM,GAAG,EAAE,OAAO,SAExB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,OAAO,eAE9B,CAAC;AAEF,eAAO,MAAM,QAAQ,WAKpB,CAAC;AAEF,eAAO,MAAM,cAAc,gBAAiB,MAAM,UAAU,CAAC,SAO5D,CAAC"}
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setBreakpoints = exports.getCssText = exports.globalCss = exports.css = exports.getCachedConfig = void 0;
3
+ exports.setBreakpoints = exports.flushCss = exports.globalCss = exports.css = void 0;
4
4
  const core_1 = require("@stitches/core");
5
- Object.defineProperty(exports, "globalCss", { enumerable: true, get: function () { return core_1.globalCss; } });
6
5
  let media = {};
7
6
  // @todo needs fixing
8
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -13,15 +12,21 @@ const getCachedConfig = () => {
13
12
  }
14
13
  return stitches;
15
14
  };
16
- exports.getCachedConfig = getCachedConfig;
17
15
  const css = (...args) => {
18
- return (0, exports.getCachedConfig)().css(...args);
16
+ return getCachedConfig().css(...args);
19
17
  };
20
18
  exports.css = css;
21
- const getCssText = () => {
22
- return (0, exports.getCachedConfig)().getCssText();
19
+ const globalCss = (...args) => {
20
+ return getCachedConfig().globalCss(...args);
23
21
  };
24
- exports.getCssText = getCssText;
22
+ exports.globalCss = globalCss;
23
+ const flushCss = () => {
24
+ const config = getCachedConfig();
25
+ const css = config.getCssText();
26
+ config.reset();
27
+ return css;
28
+ };
29
+ exports.flushCss = flushCss;
25
30
  const setBreakpoints = (breakpoints) => {
26
31
  const nextMedia = {};
27
32
  for (const breakpoint of breakpoints) {
@@ -1,4 +1,4 @@
1
- import type { CSS } from "./css";
1
+ import type { CSS } from "./stitches";
2
2
  import type { StyleValue, CssRule, Breakpoint } from "../css";
3
3
  export declare const toValue: (value: StyleValue) => string;
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"to-css.d.ts","sourceRoot":"","sources":["../../src/stitches/to-css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EAAiB,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE7E,eAAO,MAAM,OAAO,UAAW,UAAU,KAAG,MAK3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,aACN,MAAM,OAAO,CAAC,eACX,MAAM,UAAU,CAAC,KAC7B,GAgCF,CAAC"}
1
+ {"version":3,"file":"to-css.d.ts","sourceRoot":"","sources":["../../src/stitches/to-css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAiB,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAG7E,eAAO,MAAM,OAAO,UAAW,UAAU,KAAG,MAa3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,aACN,MAAM,OAAO,CAAC,eACX,MAAM,UAAU,CAAC,KAC7B,GAgCF,CAAC"}
@@ -1,10 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toCss = exports.toValue = void 0;
4
+ const fonts_1 = require("@webstudio-is/fonts");
4
5
  const toValue = (value) => {
5
6
  if (value.type === "unit") {
6
7
  return value.value + (value.unit === "number" ? "" : value.unit);
7
8
  }
9
+ if (value.type === "fontFamily") {
10
+ const family = value.value[0];
11
+ const fallbacks = fonts_1.SYSTEM_FONTS.get(family);
12
+ if (Array.isArray(fallbacks)) {
13
+ return [...value.value, ...fallbacks].join(", ");
14
+ }
15
+ return [...value.value, fonts_1.DEFAULT_FONT_FALLBACK].join(", ");
16
+ }
8
17
  return value.value;
9
18
  };
10
19
  exports.toValue = toValue;
@@ -8,7 +8,7 @@ const breakpoints = css_1.initialBreakpoints.map((breakpoint, index) => ({
8
8
  projectId: "projectId",
9
9
  }));
10
10
  describe("Convert WS CSS rules to stitches", () => {
11
- test("basic", () => {
11
+ test("keyword", () => {
12
12
  const cssRules = [
13
13
  {
14
14
  style: {
@@ -27,6 +27,25 @@ describe("Convert WS CSS rules to stitches", () => {
27
27
  },
28
28
  });
29
29
  });
30
+ test("fontFamily", () => {
31
+ const cssRules = [
32
+ {
33
+ style: {
34
+ fontFamily: {
35
+ type: "fontFamily",
36
+ value: ["Courier New"],
37
+ },
38
+ },
39
+ breakpoint: "0",
40
+ },
41
+ ];
42
+ const stitchesCss = (0, to_css_1.toCss)(cssRules, breakpoints);
43
+ expect(stitchesCss).toEqual({
44
+ "@0": {
45
+ fontFamily: "Courier New, monospace",
46
+ },
47
+ });
48
+ });
30
49
  test("sort order based on maxWidth in breakpoints", () => {
31
50
  const cssRules = [
32
51
  {
@@ -1,16 +1,20 @@
1
1
  import type { Tree, InstanceProps } from "../db";
2
2
  import type { Breakpoint } from "../css";
3
3
  import { type WrapperComponentProps } from "./wrapper-component";
4
+ import type { Asset } from "@webstudio-is/asset-uploader";
4
5
  export declare type Data = {
5
6
  tree: Tree | null;
6
7
  breakpoints: Array<Breakpoint>;
7
8
  props: Array<InstanceProps>;
9
+ assets: Array<Asset>;
8
10
  };
9
- export declare const globalStyles: () => string;
11
+ export declare const useGlobalStyles: ({ assets }: {
12
+ assets: Array<Asset>;
13
+ }) => void;
10
14
  declare type RootProps = {
11
15
  data: Data;
12
16
  Component?: (props: WrapperComponentProps) => JSX.Element;
13
17
  };
14
- export declare const Root: ({ data, Component }: RootProps) => JSX.Element | null;
18
+ export declare const InstanceRoot: ({ data, Component, }: RootProps) => JSX.Element | null;
15
19
  export {};
16
20
  //# sourceMappingURL=root.d.ts.map
@@ -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;AAE7B,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;CAC7B,CAAC;AAEF,eAAO,MAAM,YAAY,cAIvB,CAAC;AAEH,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,IAAI,wBAAyB,SAAS,KAAG,WAAW,GAAG,IAYnE,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;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"}
package/lib/tree/root.js CHANGED
@@ -1,21 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Root = exports.globalStyles = void 0;
3
+ exports.InstanceRoot = exports.useGlobalStyles = void 0;
4
4
  const user_props_1 = require("../user-props/");
5
5
  const stitches_1 = require("../stitches");
6
6
  const create_elements_tree_1 = require("./create-elements-tree");
7
7
  const wrapper_component_1 = require("./wrapper-component");
8
- exports.globalStyles = (0, stitches_1.globalCss)({
9
- html: {
10
- height: "100%",
11
- },
12
- });
13
- const Root = ({ data, 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
+ const InstanceRoot = ({ data, Component, }) => {
14
27
  if (data.tree === null) {
15
28
  throw new Error("Tree is null");
16
29
  }
17
30
  (0, stitches_1.setBreakpoints)(data.breakpoints);
18
- (0, exports.globalStyles)();
31
+ (0, exports.useGlobalStyles)({ assets: data.assets });
19
32
  (0, user_props_1.useAllUserProps)(data.props);
20
33
  return (0, create_elements_tree_1.createElementsTree)({
21
34
  instance: data.tree.root,
@@ -23,4 +36,4 @@ const Root = ({ data, Component }) => {
23
36
  Component: Component ?? wrapper_component_1.WrapperComponent,
24
37
  });
25
38
  };
26
- exports.Root = Root;
39
+ exports.InstanceRoot = InstanceRoot;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export declare const UserPropSchema: z.ZodObject<{
2
+ export declare const UserProp: z.ZodObject<{
3
3
  id: z.ZodString;
4
4
  prop: z.ZodString;
5
5
  value: z.ZodUnion<[z.ZodString, z.ZodBoolean]>;
@@ -15,7 +15,8 @@ export declare const UserPropSchema: z.ZodObject<{
15
15
  id: string;
16
16
  prop: string;
17
17
  }>;
18
- export declare const UserPropsSchema: z.ZodArray<z.ZodObject<{
18
+ export declare type UserProp = z.infer<typeof UserProp>;
19
+ export declare const UserProps: z.ZodArray<z.ZodObject<{
19
20
  id: z.ZodString;
20
21
  prop: z.ZodString;
21
22
  value: z.ZodUnion<[z.ZodString, z.ZodBoolean]>;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/user-props/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAKzB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;WAA0B,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/user-props/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;EAKnB,CAAC;AAEH,oBAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;WAAoB,CAAC"}
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserPropsSchema = exports.UserPropSchema = void 0;
3
+ exports.UserProps = exports.UserProp = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.UserPropSchema = zod_1.z.object({
5
+ exports.UserProp = zod_1.z.object({
6
6
  id: zod_1.z.string(),
7
7
  prop: zod_1.z.string(),
8
8
  value: zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]),
9
9
  required: zod_1.z.optional(zod_1.z.boolean()),
10
10
  });
11
- exports.UserPropsSchema = zod_1.z.array(exports.UserPropSchema);
11
+ exports.UserProps = zod_1.z.array(exports.UserProp);
@@ -1,7 +1,5 @@
1
- import { z } from "zod";
2
1
  import type { InstanceProps, Instance } from "../db";
3
- import { UserPropSchema } from "./schema";
4
- export declare type UserProp = z.infer<typeof UserPropSchema>;
2
+ import { UserProp } from "./schema";
5
3
  export declare type UserPropsUpdates = {
6
4
  treeId: InstanceProps["treeId"];
7
5
  propsId: InstanceProps["id"];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/user-props/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,oBAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/user-props/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC1B,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type Instance } from "../db";
2
- import { type UserProp } from "./types";
2
+ import { type UserProp } from "./schema";
3
3
  declare type UserProps = {
4
4
  [prop: UserProp["prop"]]: UserProp["value"];
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-user-props.d.ts","sourceRoot":"","sources":["../../src/user-props/use-user-props.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,aAAK,SAAS,GAAG;IAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,YAAY,eAAgB,QAAQ,CAAC,IAAI,CAAC,cAuBtD,CAAC"}
1
+ {"version":3,"file":"use-user-props.d.ts","sourceRoot":"","sources":["../../src/user-props/use-user-props.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,aAAK,SAAS,GAAG;IAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,YAAY,eAAgB,QAAQ,CAAC,IAAI,CAAC,cAuBtD,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
7
7
  "scripts": {
8
8
  "dev": "tsup src/index.ts --format esm,cjs --watch --out-dir=lib",
9
- "build": "yarn build:mdn-data && yarn build:args && yarn build:lib",
10
- "build:mdn-data": "node --experimental-loader esbuild-node-loader ./bin/mdn-data.ts ./src/css",
11
- "build:args": "node --experimental-loader esbuild-node-loader ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'",
9
+ "build": "yarn build:lib",
10
+ "build:mdn-data": "tsx ./bin/mdn-data.ts ./src/css",
11
+ "build:args": "tsx ./bin/generate-arg-types.ts './src/components/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx'",
12
12
  "typecheck": "tsc --noEmit",
13
- "build:lib": "rm -fr lib && tsc",
13
+ "build:lib": "rm -fr lib tsconfig.tsbuildinfo && tsc",
14
14
  "test": "jest",
15
15
  "lint": "eslint ./src --ext .ts,.tsx --max-warnings 0",
16
16
  "checks": "yarn typecheck && yarn lint && yarn test",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@babel/core": "^7.17.12",
23
+ "@esbuild-kit/esm-loader": "^2.4.2",
23
24
  "@remix-run/react": "^1.2.3",
24
25
  "@remix-run/server-runtime": "^1.2.3",
25
26
  "@storybook/addon-actions": "^6.5.6",
@@ -33,20 +34,20 @@
33
34
  "@types/css-tree": "^1.0.7",
34
35
  "@types/fs-extra": "^9.0.13",
35
36
  "@types/node": "^17.0.21",
37
+ "@webstudio-is/jest-config": "*",
38
+ "@webstudio-is/prisma-client": "*",
36
39
  "babel-loader": "^8.2.5",
37
40
  "camelcase": "^6.3.0",
38
41
  "css-tree": "^2.1.0",
39
42
  "esbuild": "^0.14.25",
40
43
  "esbuild-node-externals": "^1.4.1",
41
- "esbuild-node-loader": "^0.8.0",
42
- "@webstudio-is/jest-config": "*",
43
44
  "mdn-data": "2.0.23",
44
45
  "react": "^17.0.2",
45
46
  "react-docgen-typescript": "^2.2.2",
46
47
  "react-dom": "^17.0.2",
47
- "@webstudio-is/prisma-client": "*",
48
48
  "tsup": "^6.1.3",
49
- "typescript": "^4.6.2"
49
+ "tsx": "^3.9.0",
50
+ "typescript": "4.7.4"
50
51
  },
51
52
  "peerDependencies": {
52
53
  "@remix-run/react": "^1.2.3",
@@ -57,11 +58,13 @@
57
58
  },
58
59
  "dependencies": {
59
60
  "@stitches/core": "^1.2.7",
61
+ "@webstudio-is/asset-uploader": "^*",
60
62
  "@webstudio-is/icons": "*",
63
+ "@webstudio-is/jest-config": "*",
64
+ "@webstudio-is/fonts": "*",
61
65
  "immer": "^9.0.12",
62
66
  "mitt": "^3.0.0",
63
67
  "react-nano-state": "^0.4.0",
64
- "@webstudio-is/jest-config": "*",
65
68
  "zod": "^3.17.3"
66
69
  },
67
70
  "main": "lib/index.js",
@@ -1,17 +0,0 @@
1
- import { MutableRefObject } from "react";
2
- declare type Action<Type, Payload> = {
3
- type: Type;
4
- payload?: Payload;
5
- };
6
- export declare type Publish = <Type, Payload = undefined>(action: Action<Type, Payload>) => void;
7
- declare type UsePublish = [Publish, MutableRefObject<HTMLIFrameElement | null>];
8
- /**
9
- * To publish a postMessage event on the iframe and parent window from the parent window.
10
- */
11
- export declare const usePublish: () => UsePublish;
12
- /**
13
- * To publish a postMessage event on the current window and parent window from the iframe.
14
- */
15
- export declare const publish: <Type extends string, Payload = undefined>(action: Action<Type, Payload>) => void;
16
- export {};
17
- //# sourceMappingURL=publish.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/pubsub/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9D,aAAK,MAAM,CAAC,IAAI,EAAE,OAAO,IAAI;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oBAAY,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAC9C,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,KAC1B,IAAI,CAAC;AAEV,aAAK,UAAU,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,UAAU,kBAYtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,mFAKnB,CAAC"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.publish = exports.usePublish = void 0;
4
- const react_1 = require("react");
5
- /**
6
- * To publish a postMessage event on the iframe and parent window from the parent window.
7
- */
8
- const usePublish = () => {
9
- const iframeRef = (0, react_1.useRef)(null);
10
- const publishCallback = (0, react_1.useCallback)((action) => {
11
- const element = iframeRef.current;
12
- if (element?.contentWindow == null)
13
- return;
14
- element.contentWindow.postMessage(action, "*");
15
- window.postMessage(action, "*");
16
- }, [iframeRef]);
17
- return [publishCallback, iframeRef];
18
- };
19
- exports.usePublish = usePublish;
20
- /**
21
- * To publish a postMessage event on the current window and parent window from the iframe.
22
- */
23
- const publish = (action) => {
24
- window.parent.postMessage(action, "*");
25
- window.postMessage(action, "*");
26
- };
27
- exports.publish = publish;
@@ -1,8 +0,0 @@
1
- declare type Events = Record<string, any>;
2
- export declare const emitter: import("mitt").Emitter<Events>;
3
- /**
4
- * To subscribe a message event on the current window.
5
- */
6
- export declare const useSubscribe: <Type extends string, Payload = undefined>(type: Type, onAction: (payload: Payload) => void) => void;
7
- export {};
8
- //# sourceMappingURL=subscribe.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/pubsub/subscribe.ts"],"names":[],"mappings":"AAQA,aAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAElC,eAAO,MAAM,OAAO,gCAAiB,CAAC;AAgBtC;;GAEG;AACH,eAAO,MAAM,YAAY,yFAES,IAAI,SAQrC,CAAC"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useSubscribe = exports.emitter = void 0;
7
- const mitt_1 = __importDefault(require("mitt"));
8
- const react_1 = require("react");
9
- exports.emitter = (0, mitt_1.default)();
10
- if (typeof window === "object") {
11
- window.addEventListener("message", (event) => {
12
- // @todo this has no type safety built in, could be anything from any source.
13
- // we could potentially maintain a list of valid event types, but see prior contra points.
14
- if (typeof event.data?.type === "string") {
15
- exports.emitter.emit(event.data.type, event.data.payload);
16
- }
17
- }, false);
18
- }
19
- /**
20
- * To subscribe a message event on the current window.
21
- */
22
- const useSubscribe = (type, onAction) => {
23
- (0, react_1.useEffect)(() => {
24
- exports.emitter.on(type, onAction);
25
- return () => {
26
- exports.emitter.off(type, onAction);
27
- };
28
- }, [type, onAction]);
29
- };
30
- exports.useSubscribe = useSubscribe;
@@ -1,4 +0,0 @@
1
- import { getCssText as getCssTextDefault } from "./css";
2
- export declare const CriticalCss: () => JSX.Element | null;
3
- export declare const insertCriticalCss: (markup: string, getCssText?: typeof getCssTextDefault) => string;
4
- //# sourceMappingURL=critical-css.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"critical-css.d.ts","sourceRoot":"","sources":["../../src/stitches/critical-css.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIxD,eAAO,MAAM,WAAW,QAAO,WAAW,GAAG,IACsB,CAAC;AAEpE,eAAO,MAAM,iBAAiB,WACpB,MAAM,eACF,wBAAwB,KACnC,MAEF,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.insertCriticalCss = exports.CriticalCss = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const css_1 = require("./css");
6
- const criticalCssMarker = "__critical-css__";
7
- const CriticalCss = () => typeof document === "undefined" ? (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: criticalCssMarker }) : null;
8
- exports.CriticalCss = CriticalCss;
9
- const insertCriticalCss = (markup, getCssText = css_1.getCssText) => {
10
- return markup.replace(criticalCssMarker, `<style>${getCssText()}</style>`);
11
- };
12
- exports.insertCriticalCss = insertCriticalCss;
@@ -1,9 +0,0 @@
1
- import { globalCss, type CSS, css as createCss } from "@stitches/core";
2
- import type { Breakpoint } from "../css";
3
- export declare const getCachedConfig: () => any;
4
- export declare const css: typeof createCss;
5
- export { globalCss };
6
- export { type CSS };
7
- export declare const getCssText: () => string;
8
- export declare const setBreakpoints: (breakpoints: Array<Breakpoint>) => void;
9
- //# sourceMappingURL=css.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/stitches/css.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,KAAK,GAAG,EACR,GAAG,IAAI,SAAS,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQzC,eAAO,MAAM,eAAe,WAK3B,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,OAAO,SAExB,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,KAAK,GAAG,EAAE,CAAC;AAEpB,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAC;AAEF,eAAO,MAAM,cAAc,gBAAiB,MAAM,UAAU,CAAC,SAO5D,CAAC"}